diff --git a/include/clang/ASTMatchers/ASTMatchers.h b/include/clang/ASTMatchers/ASTMatchers.h
index ac3ff73..28c36e9 100644
--- a/include/clang/ASTMatchers/ASTMatchers.h
+++ b/include/clang/ASTMatchers/ASTMatchers.h
@@ -702,7 +727,7 @@ template<typename C1, typename C2, typename C3>
 internal::PolymorphicMatcherWithParam2<internal::AllOfMatcher, C1,
     internal::PolymorphicMatcherWithParam2<internal::AllOfMatcher, C2, C3> >
 allOf(const C1& P1, const C2& P2, const C3& P3) {
-  return AllOf(P1, AllOf(P2, P3));
+  return allOf(P1, allOf(P2, P3));
 }
 /// @}
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index a529459..0075fca 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -276,6 +276,15 @@ TEST(DeclarationMatcher, ClassIsDerived) {
                                        isDerivedFrom("Base2")))))));
 }
 
+TEST(AllOF, CorrectOverloads) {
+  const char program[] =
+      "struct T { }; int f(int, T*); void g(int x) { T t; f(x, &t); }";
+  EXPECT_TRUE(matches(program,
+      call(allOf(callee(function(hasName("f"))),
+                 hasArgument(0, declarationReference(to(variable()))),
+                 hasArgument(1, hasType(pointsTo(record(hasName("T")))))))));
+}
+
 TEST(DeclarationMatcher, MatchAnyOf) {
   DeclarationMatcher YOrZDerivedFromX =
       record(anyOf(hasName("Y"), allOf(isDerivedFrom("X"), hasName("Z"))));
