diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -13926,11 +13926,9 @@ // Build the parameter declarations. SmallVector ParamDecls; for (unsigned I = 0, N = FPT->getNumParams(); I != N; ++I) { - TypeSourceInfo *TInfo = - Context.getTrivialTypeSourceInfo(FPT->getParamType(I), UsingLoc); ParmVarDecl *PD = ParmVarDecl::Create( Context, DerivedCtor, UsingLoc, UsingLoc, /*IdentifierInfo=*/nullptr, - FPT->getParamType(I), TInfo, SC_None, /*DefArg=*/nullptr); + FPT->getParamType(I), nullptr, SC_None, /*DefArg=*/nullptr); PD->setScopeInfo(0, I); PD->setImplicit(); // Ensure attributes are propagated onto parameters (this matters for diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp --- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp @@ -2129,6 +2129,20 @@ notMatches(Code, typeAliasTemplateDecl(hasName("typeAliasDecl")))); } +TEST_P(ASTMatchersTest, TypeLocTest_DoesNotBindToSyntheticParams) { + if (!GetParam().isCXX11OrLater()) { + return; + } + EXPECT_TRUE( + notMatches(R"cpp( + struct Base { Base(int); }; + struct Derived : Base { using Base::Base; }; + Derived d(42); // force constructor to exist + )cpp", + typeLoc(loc(asString("int")), + hasAncestor(cxxRecordDecl(hasAnyName("Derived")))))); +} + TEST_P(ASTMatchersTest, QualifiedTypeLocTest_BindsToConstIntVarDecl) { EXPECT_TRUE(matches("const int x = 0;", qualifiedTypeLoc(loc(asString("const int")))));