diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp --- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp +++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp @@ -567,14 +567,12 @@ if (Loc.getTypeLocClass() == TypeLoc::Elaborated) { NestedNameSpecifierLoc NestedNameSpecifier = Loc.castAs().getQualifierLoc(); - // This happens for friend declaration of a base class with injected class - // name. - if (!NestedNameSpecifier.getNestedNameSpecifier()) - return; - const Type *SpecifierType = - NestedNameSpecifier.getNestedNameSpecifier()->getAsType(); - if (SpecifierType && SpecifierType->isRecordType()) - return; + // FIXME: avoid changing injected class names. + if (auto *NNS = NestedNameSpecifier.getNestedNameSpecifier()) { + const Type *SpecifierType = NNS->getAsType(); + if (SpecifierType && SpecifierType->isRecordType()) + return; + } } fixTypeLoc(Result, startLocationForType(Loc), endLocationForType(Loc), Loc); } else if (const auto *VarRef = diff --git a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp --- a/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp +++ b/clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp @@ -215,7 +215,8 @@ // Uses of most types: just look at what the typeLoc refers to. MatchFinder->addMatcher( typeLoc(isExpansionInMainFile(), - loc(qualType(hasDeclaration(Types.bind("use"))))), + loc(qualType(allOf(unless(elaboratedType()), + hasDeclaration(Types.bind("use")))))), this); // Uses of typedefs: these are often transparent to hasDeclaration, so we need // to handle them explicitly. diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -87,9 +87,9 @@ const auto ConstantExpr = ignoringParenImpCasts( anyOf(integerLiteral(), unaryOperator(hasUnaryOperand(IntegerExpr)), binaryOperator(hasLHS(IntegerExpr), hasRHS(IntegerExpr)))); - const auto IntegerCallExpr = ignoringParenImpCasts( - callExpr(anyOf(hasType(isInteger()), hasType(enumType())), - unless(isInTemplateInstantiation()))); + const auto IntegerCallExpr = ignoringParenImpCasts(callExpr( + anyOf(hasType(isInteger()), hasType(hasCanonicalType(enumType()))), + unless(isInTemplateInstantiation()))); const auto SizeOfExpr = sizeOfExpr(hasArgumentOfType( hasUnqualifiedDesugaredType(type().bind("sizeof-arg-type")))); const auto SizeOfZero = @@ -147,8 +147,8 @@ const auto StructAddrOfExpr = unaryOperator( hasOperatorName("&"), hasUnaryOperand(ignoringParenImpCasts( hasType(hasCanonicalType(recordType()))))); - const auto PointerToStructType = - hasUnqualifiedDesugaredType(pointerType(pointee(recordType()))); + const auto PointerToStructType = hasUnqualifiedDesugaredType( + pointerType(pointee(hasCanonicalType(recordType())))); const auto PointerToStructExpr = ignoringParenImpCasts(expr( hasType(hasCanonicalType(PointerToStructType)), unless(cxxThisExpr()))); diff --git a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp @@ -67,10 +67,11 @@ auto FindConstructExpr = cxxConstructExpr( hasDeclaration(FindConstructor), argumentCountIs(1), - hasArgument( - 0, cxxNewExpr(isArray(), hasType(pointerType(pointee( - equalsBoundNode(PointerTypeN))))) - .bind(NewExprN))) + hasArgument(0, + cxxNewExpr(isArray(), + hasType(hasCanonicalType(pointerType( + pointee(equalsBoundNode(PointerTypeN)))))) + .bind(NewExprN))) .bind(ConstructExprN); Finder->addMatcher(FindConstructExpr, this); } @@ -101,7 +102,7 @@ SourceRange TemplateArgumentRange = TSTypeLoc.getArgLoc(0) .getTypeSourceInfo() ->getTypeLoc() - .getLocalSourceRange(); + .getSourceRange(); D << TemplateArgumentRange; if (isInSingleDeclStmt(VarOrField)) { diff --git a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp --- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -130,7 +130,12 @@ // case of overloaded functions, so detection of redundant casts is trickier // in this case. Don't emit "redundant cast" warnings for function // pointer/reference types. - if (SourceTypeAsWritten == DestTypeAsWritten) { + QualType Src = SourceTypeAsWritten, Dst = DestTypeAsWritten; + if (const auto *ElTy = dyn_cast(Src)) + Src = ElTy->getNamedType(); + if (const auto *ElTy = dyn_cast(Dst)) + Dst = ElTy->getNamedType(); + if (Src == Dst) { diag(CastExpr->getBeginLoc(), "redundant cast to the same type") << FixItHint::CreateRemoval(ReplaceRange); return; diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -36,7 +36,8 @@ // otherwise the matcher does not work correctly, because it // will not explicitly ignore enum conditions. unless(ignoringImpCasts( - declRefExpr(hasType(enumType())).bind("enum-condition")))))) + declRefExpr(hasType(hasCanonicalType(enumType()))) + .bind("enum-condition")))))) .bind("switch"), this); diff --git a/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp b/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp --- a/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp @@ -21,12 +21,13 @@ pointee(anyOf(isConstQualified(), ignoringParens(functionType())))))); Finder->addMatcher( - valueDecl( - hasType(isConstQualified()), - hasType(typedefType(hasDeclaration(anyOf( - typedefDecl(NonConstAndNonFunctionPointerType).bind("typedef"), - typeAliasDecl(NonConstAndNonFunctionPointerType) - .bind("typeAlias")))))) + valueDecl(hasType(qualType( + isConstQualified(), + elaboratedType(namesType(typedefType(hasDeclaration( + anyOf(typedefDecl(NonConstAndNonFunctionPointerType) + .bind("typedef"), + typeAliasDecl(NonConstAndNonFunctionPointerType) + .bind("typeAlias"))))))))) .bind("decl"), this); } diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -400,7 +400,7 @@ return true; if (const auto *Cast = Parents[0].get()) { if ((Cast->getCastKind() == CK_NoOp && - Cast->getType() == E->getType().withConst()) || + Context->hasSameType(Cast->getType(), E->getType().withConst())) || (Cast->getCastKind() == CK_LValueToRValue && !Cast->getType().isNull() && Cast->getType()->isFundamentalType())) return false; diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -48,7 +48,8 @@ static TypeMatcher notTemplateSpecConstRefType() { return lValueReferenceType( - pointee(unless(templateSpecializationType()), isConstQualified())); + pointee(unless(elaboratedType(namesType(templateSpecializationType()))), + isConstQualified())); } static TypeMatcher nonConstValueType() { diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -153,22 +153,24 @@ // ((Base*)this)->operator=((Base)Other); // // So we are looking for a member call that fulfills: - if (match(traverse(TK_AsIs, - compoundStmt(has(ignoringParenImpCasts(cxxMemberCallExpr( - // - The object is an implicit cast of 'this' to a - // pointer to - // a base class. - onImplicitObjectArgument(implicitCastExpr( - hasImplicitDestinationType( - pointsTo(type(equalsNode(Base)))), - hasSourceExpression(cxxThisExpr()))), - // - The called method is the operator=. - callee(cxxMethodDecl(isCopyAssignmentOperator())), - // - The argument is (an implicit cast to a Base of) - // the argument taken by "Operator". - argumentCountIs(1), - hasArgument(0, declRefExpr(to(varDecl( - equalsNode(Param)))))))))), + if (match(traverse( + TK_AsIs, + compoundStmt(has(ignoringParenImpCasts(cxxMemberCallExpr( + // - The object is an implicit cast of 'this' to a + // pointer to + // a base class. + onImplicitObjectArgument(implicitCastExpr( + hasImplicitDestinationType(hasCanonicalType(pointsTo( + type(equalsNode(Base->getCanonicalTypeInternal() + .getTypePtr()))))), + hasSourceExpression(cxxThisExpr()))), + // - The called method is the operator=. + callee(cxxMethodDecl(isCopyAssignmentOperator())), + // - The argument is (an implicit cast to a Base of) + // the argument taken by "Operator". + argumentCountIs(1), + hasArgument( + 0, declRefExpr(to(varDecl(equalsNode(Param)))))))))), *Compound, *Context) .empty()) return false; diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp --- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp @@ -97,7 +97,9 @@ if (TL.getQualifierLoc() && !TraverseNestedNameSpecifierLoc(TL.getQualifierLoc())) return false; - return TraverseTypeLoc(TL.getNamedTypeLoc(), true); + const auto *T = TL.getTypePtr(); + return TraverseTypeLoc(TL.getNamedTypeLoc(), + T->getKeyword() != ETK_None || T->getQualifier()); } bool VisitDeclRefExpr(DeclRefExpr *S) { diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -950,7 +950,10 @@ // ElaboratedTypeLoc will reports information for its inner type loc. // Otherwise we loose information about inner types loc's qualifier. TypeLoc Inner = L.getNamedTypeLoc().getUnqualifiedLoc(); - TypeLocsToSkip.insert(Inner.getBeginLoc()); + if (L.getBeginLoc() == Inner.getBeginLoc()) + return RecursiveASTVisitor::TraverseTypeLoc(Inner); + else + TypeLocsToSkip.insert(Inner.getBeginLoc()); return RecursiveASTVisitor::TraverseElaboratedTypeLoc(L); } diff --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp b/clang-tools-extra/clangd/unittests/ASTTests.cpp --- a/clang-tools-extra/clangd/unittests/ASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp @@ -72,7 +72,7 @@ template class Foo {}; ^auto v = Foo(); )cpp", - "Foo", + "Foo", }, { R"cpp( // auto on initializer list. @@ -93,7 +93,7 @@ return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // decltype in trailing return type @@ -102,7 +102,7 @@ return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // auto in function return type @@ -111,7 +111,7 @@ return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // auto& in function return type @@ -121,7 +121,7 @@ return x; } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // auto* in function return type @@ -131,7 +131,7 @@ return x; } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // const auto& in function return type @@ -141,7 +141,7 @@ return x; } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // decltype(auto) in function return (value) @@ -150,7 +150,7 @@ return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // decltype(auto) in function return (ref) @@ -160,7 +160,7 @@ return (x); } )cpp", - "struct Foo &", + "Foo &", }, { R"cpp( // decltype(auto) in function return (const ref) @@ -170,7 +170,7 @@ return (x); } )cpp", - "const struct Foo &", + "const Foo &", }, { R"cpp( // auto on alias diff --git a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp --- a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp @@ -121,7 +121,8 @@ expression: DeclRef - operator+ expression: MaterializeTemporary - lvalue expression: CXXTemporaryObject - Foo - type: Record - Foo + type: Elaborated + type: Record - Foo expression: IntegerLiteral - 42 )"}, {R"cpp( diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -1612,13 +1612,14 @@ { R"cpp( void foo() { - class {} $0^x; - int (*$1^fptr)(int $2^a, int) = nullptr; + $0^class {} $1^x; + int (*$2^fptr)(int $3^a, int) = nullptr; } )cpp", - "0: targets = {x}, decl\n" - "1: targets = {fptr}, decl\n" - "2: targets = {a}, decl\n"}, + "0: targets = {}\n" + "1: targets = {x}, decl\n" + "2: targets = {fptr}, decl\n" + "3: targets = {a}, decl\n"}, // Namespace aliases should be handled properly. { R"cpp( diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -427,7 +427,7 @@ [](HoverInfo &HI) { HI.Name = "auto"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct S"; + HI.Definition = "S"; }}, // undeduced auto {R"cpp( @@ -550,7 +550,7 @@ HI.NamespaceScope = ""; HI.Definition = "Color x = RED"; HI.Kind = index::SymbolKind::Variable; - HI.Type = "enum Color"; + HI.Type = "Color"; HI.Value = "RED (0xffffff85)"; // Symbolic on an expression. }}, {R"cpp( @@ -795,7 +795,7 @@ HI.Kind = index::SymbolKind::Variable; HI.NamespaceScope = ""; HI.Definition = "X x"; - HI.Type = "struct X"; + HI.Type = "X"; }}, {// Don't crash on null types. R"cpp(auto [^[[x]]] = 1; /*error-ok*/)cpp", @@ -1944,7 +1944,7 @@ [](HoverInfo &HI) { HI.Name = "auto"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "auto function return with trailing type"; }}, { @@ -1957,7 +1957,7 @@ [](HoverInfo &HI) { HI.Name = "decltype"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "trailing return type"; }}, { @@ -1970,7 +1970,7 @@ [](HoverInfo &HI) { HI.Name = "auto"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "auto in function return"; }}, { @@ -1984,7 +1984,7 @@ [](HoverInfo &HI) { HI.Name = "auto"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "auto& in function return"; }}, { @@ -1998,7 +1998,7 @@ [](HoverInfo &HI) { HI.Name = "auto"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "auto* in function return"; }}, { @@ -2012,7 +2012,7 @@ [](HoverInfo &HI) { HI.Name = "auto"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "const auto& in function return"; }}, { @@ -2025,7 +2025,7 @@ [](HoverInfo &HI) { HI.Name = "decltype"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "decltype(auto) in function return"; }}, { @@ -2115,7 +2115,7 @@ [](HoverInfo &HI) { HI.Name = "decltype"; HI.Kind = index::SymbolKind::TypeAlias; - HI.Definition = "struct Bar"; + HI.Definition = "Bar"; HI.Documentation = "decltype of function with trailing return type."; }}, diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp @@ -144,7 +144,6 @@ class X12 : public CopyableAlias { X12(const X12 &other) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor - // CHECK-FIXES: X12(const X12 &other) {} }; template @@ -166,7 +165,7 @@ class X15 : public CopyableAlias2 { X15(const X15 &other) {} // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling a base constructor - // CHECK-FIXES: X15(const X15 &other) {} + // CHECK-FIXES: X15(const X15 &other) : Copyable5(other) {} }; class X16 : public NonCopyable { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp @@ -72,6 +72,8 @@ template void f_tmpl() { std::shared_ptr P1{new T[10]}; + // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: shared pointer to non-array is initialized with array [bugprone-shared-ptr-array-mismatch] + // CHECK-FIXES: std::shared_ptr P1{new T[10]}; } void f5() { diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp @@ -28,6 +28,6 @@ void test() { S a, b; std::memcmp(&a, &b, sizeof(S)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'inner_padding::S' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace inner_padding diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp @@ -16,7 +16,7 @@ void f(C &c1, C &c2) { if (!std::memcmp(&c1, &c2, sizeof(C))) { - // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: comparing object representation of non-standard-layout type 'sei_cert_example_oop57_cpp::C'; consider using a comparison operator instead + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: comparing object representation of non-standard-layout type 'C'; consider using a comparison operator instead } } } // namespace sei_cert_example_oop57_cpp @@ -30,7 +30,7 @@ void test() { S a, b; std::memcmp(&a, &b, sizeof(S)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'inner_padding_64bit_only::S' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace inner_padding_64bit_only @@ -47,17 +47,17 @@ void testDerived() { Derived a, b; std::memcmp(&a, &b, sizeof(Base)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'Derived' which does not have a unique object representation; consider comparing the members of the object manually std::memcmp(&a, &b, sizeof(Derived)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'Derived' which does not have a unique object representation; consider comparing the members of the object manually } void testDerived2() { Derived2 a, b; std::memcmp(&a, &b, sizeof(Base)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived2' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'Derived2' which does not have a unique object representation; consider comparing the members of the object manually std::memcmp(&a, &b, sizeof(Derived2)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived2' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'Derived2' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace padding_in_base @@ -97,7 +97,7 @@ void test() { C a, b; std::memcmp(&a, &b, sizeof(C)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of non-standard-layout type 'non_standard_layout::C'; consider using a comparison operator instead + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of non-standard-layout type 'C'; consider using a comparison operator instead } } // namespace non_standard_layout @@ -131,7 +131,7 @@ void test() { S a, b; std::memcmp(&a, &b, sizeof(S)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'empty_struct::S' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace empty_struct @@ -144,7 +144,7 @@ void test() { S a, b; std::memcmp(&a, &b, sizeof(S)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'empty_field::S' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace empty_field @@ -173,7 +173,7 @@ void test() { S a, b; std::memcmp(&a, &b, sizeof(S)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'no_unique_address_attribute::multiple_empties_same_type::S' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace multiple_empties_same_type @@ -203,7 +203,7 @@ void test() { S a, b; std::memcmp(&a, &b, sizeof(S)); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'alignment::S' which does not have a unique object representation; consider comparing the members of the object manually + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'S' which does not have a unique object representation; consider comparing the members of the object manually } } // namespace alignment diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp @@ -76,7 +76,7 @@ }; const Strukt p6() {} - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Strukt' i // CHECK-FIXES: Strukt p6() {} // No warning is emitted here, because this is only the declaration. The @@ -90,7 +90,7 @@ // CHECK-FIXES: static int p8() {} static const Strukt p9() {} - // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Clazz::Strukt' i + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const Strukt' i // CHECK-FIXES: static Strukt p9() {} int n0() const { return 0; } diff --git a/clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp b/clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp --- a/clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp +++ b/clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp @@ -2229,7 +2229,7 @@ "namespace e {\n" "class D : public a::Base {\n" " private:\n" - " friend class Base;\n" + " friend class a::Base;\n" " void priv() {}\n" " a::Base b;\n" "};\n" diff --git a/clang/bindings/python/tests/cindex/test_type.py b/clang/bindings/python/tests/cindex/test_type.py --- a/clang/bindings/python/tests/cindex/test_type.py +++ b/clang/bindings/python/tests/cindex/test_type.py @@ -58,7 +58,7 @@ self.assertIsNotNone(fields[1].translation_unit) self.assertEqual(fields[1].spelling, 'b') self.assertFalse(fields[1].type.is_const_qualified()) - self.assertEqual(fields[1].type.kind, TypeKind.TYPEDEF) + self.assertEqual(fields[1].type.kind, TypeKind.ELABORATED) self.assertEqual(fields[1].type.get_canonical().kind, TypeKind.INT) self.assertEqual(fields[1].type.get_declaration().spelling, 'I') self.assertEqual(fields[1].type.get_typedef_name(), 'I') diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2811,14 +2811,20 @@ bool typesAreBlockPointerCompatible(QualType, QualType); bool isObjCIdType(QualType T) const { + if (const auto *ET = dyn_cast(T)) + T = ET->getNamedType(); return T == getObjCIdType(); } bool isObjCClassType(QualType T) const { + if (const auto *ET = dyn_cast(T)) + T = ET->getNamedType(); return T == getObjCClassType(); } bool isObjCSelType(QualType T) const { + if (const auto *ET = dyn_cast(T)) + T = ET->getNamedType(); return T == getObjCSelType(); } diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -5569,9 +5569,6 @@ ElaboratedTypeBits.HasOwnedTagDecl = true; *getTrailingObjects() = OwnedTagDecl; } - assert(!(Keyword == ETK_None && NNS == nullptr) && - "ElaboratedType cannot have elaborated type keyword " - "and name qualifier both null."); } public: diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -430,7 +430,7 @@ unsigned size = sizeof(LocalData); unsigned extraAlign = asDerived()->getExtraLocalDataAlignment(); size = llvm::alignTo(size, extraAlign); - return reinterpret_cast(Base::Data) + size; + return reinterpret_cast(Base::Data) + size; } void *getNonLocalData() const { @@ -2263,22 +2263,31 @@ ElaboratedLocInfo> { public: SourceLocation getElaboratedKeywordLoc() const { - return this->getLocalData()->ElaboratedKWLoc; + return !isEmpty() ? getLocalData()->ElaboratedKWLoc : SourceLocation(); } void setElaboratedKeywordLoc(SourceLocation Loc) { - this->getLocalData()->ElaboratedKWLoc = Loc; + if (isEmpty()) { + assert(Loc.isInvalid()); + return; + } + getLocalData()->ElaboratedKWLoc = Loc; } NestedNameSpecifierLoc getQualifierLoc() const { - return NestedNameSpecifierLoc(getTypePtr()->getQualifier(), - getLocalData()->QualifierData); + return !isEmpty() ? NestedNameSpecifierLoc(getTypePtr()->getQualifier(), + getLocalData()->QualifierData) + : NestedNameSpecifierLoc(); } void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc) { - assert(QualifierLoc.getNestedNameSpecifier() - == getTypePtr()->getQualifier() && + assert(QualifierLoc.getNestedNameSpecifier() == + getTypePtr()->getQualifier() && "Inconsistent nested-name-specifier pointer"); + if (isEmpty()) { + assert(!QualifierLoc.hasQualifier()); + return; + } getLocalData()->QualifierData = QualifierLoc.getOpaqueData(); } @@ -2295,12 +2304,24 @@ void initializeLocal(ASTContext &Context, SourceLocation Loc); - TypeLoc getNamedTypeLoc() const { - return getInnerTypeLoc(); + TypeLoc getNamedTypeLoc() const { return getInnerTypeLoc(); } + + QualType getInnerType() const { return getTypePtr()->getNamedType(); } + + bool isEmpty() const { + return getTypePtr()->getKeyword() == ElaboratedTypeKeyword::ETK_None && + !getTypePtr()->getQualifier(); } - QualType getInnerType() const { - return getTypePtr()->getNamedType(); + unsigned getLocalDataAlignment() const { + // FIXME: We want to return 1 here in the empty case, but + // there are bugs in how alignment is handled in TypeLocs + // that prevent this from working. + return ConcreteTypeLoc::getLocalDataAlignment(); + } + + unsigned getLocalDataSize() const { + return !isEmpty() ? ConcreteTypeLoc::getLocalDataSize() : 0; } void copy(ElaboratedTypeLoc Loc) { diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -505,7 +505,7 @@ if (LParenAdded) PropertyString += ')'; QualType RT = Getter->getReturnType(); - if (!isa(RT)) { + if (!RT->getAs()) { // strip off any ARC lifetime qualifier. QualType CanResultTy = Context.getCanonicalType(RT); if (CanResultTy.getQualifiers().hasObjCLifetime()) { @@ -1053,7 +1053,7 @@ // Also, typedef-of-pointer-to-incomplete-struct is something that we assume // is not an innter pointer type. QualType OrigT = T; - while (const TypedefType *TD = dyn_cast(T.getTypePtr())) + while (const auto *TD = T->getAs()) T = TD->getDecl()->getUnderlyingType(); if (OrigT == T || !T->isPointerType()) return true; @@ -1356,9 +1356,6 @@ if (!Ty->isPointerType()) return false; - while (const TypedefType *TD = dyn_cast(Ty.getTypePtr())) - Ty = TD->getDecl()->getUnderlyingType(); - // Is the type void*? const PointerType* PT = Ty->castAs(); if (PT->getPointeeType().getUnqualifiedType()->isVoidType()) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -7816,7 +7816,7 @@ /// 'l' or 'L' , but not always. For typedefs, we need to use /// 'i' or 'I' instead if encoding a struct field, or a pointer! void ASTContext::getLegacyIntegralTypeEncoding (QualType &PointeeTy) const { - if (isa(PointeeTy.getTypePtr())) { + if (PointeeTy->getAs()) { if (const auto *BT = PointeeTy->getAs()) { if (BT->getKind() == BuiltinType::ULong && getIntWidth(PointeeTy) == 32) PointeeTy = UnsignedIntTy; @@ -8104,7 +8104,7 @@ // pointee gets emitted _before_ the '^'. The read-only qualifier of // the pointer itself gets ignored, _unless_ we are looking at a typedef! // Also, do not emit the 'r' for anything but the outermost type! - if (isa(T.getTypePtr())) { + if (T->getAs()) { if (Options.IsOutermostType() && T.isConstQualified()) { isReadOnly = true; S += 'r'; diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1684,9 +1684,24 @@ : FromType.getAsString(Policy); std::string ToTypeStr = ToType.isNull() ? "(no argument)" : ToType.getAsString(Policy); - // Switch to canonical typename if it is better. + // Print without ElaboratedType sugar if it is better. // TODO: merge this with other aka printing above. if (FromTypeStr == ToTypeStr) { + const auto *FromElTy = dyn_cast(FromType), + *ToElTy = dyn_cast(ToType); + if (FromElTy || ToElTy) { + std::string FromNamedTypeStr = + FromElTy ? FromElTy->getNamedType().getAsString(Policy) + : FromTypeStr; + std::string ToNamedTypeStr = + ToElTy ? ToElTy->getNamedType().getAsString(Policy) : ToTypeStr; + if (FromNamedTypeStr != ToNamedTypeStr) { + FromTypeStr = FromNamedTypeStr; + ToTypeStr = ToNamedTypeStr; + goto PrintTypes; + } + } + // Switch to canonical typename if it is better. std::string FromCanTypeStr = FromType.getCanonicalType().getAsString(Policy); std::string ToCanTypeStr = ToType.getCanonicalType().getAsString(Policy); @@ -1696,6 +1711,7 @@ } } + PrintTypes: if (PrintTree) OS << '['; OS << (FromDefault ? "(default) " : ""); Bold(); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2566,7 +2566,7 @@ return getMemberLocation(); if (const auto *TSInfo = Initializee.get()) - return TSInfo->getTypeLoc().getLocalSourceRange().getBegin(); + return TSInfo->getTypeLoc().getBeginLoc(); return {}; } diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -314,7 +314,7 @@ // CXXPseudoDestructorExpr PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) : Type(Info) { - Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); + Location = Info->getTypeLoc().getBeginLoc(); } CXXPseudoDestructorExpr::CXXPseudoDestructorExpr( @@ -341,7 +341,7 @@ SourceLocation CXXPseudoDestructorExpr::getEndLoc() const { SourceLocation End = DestroyedType.getLocation(); if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo()) - End = TInfo->getTypeLoc().getLocalSourceRange().getEnd(); + End = TInfo->getTypeLoc().getSourceRange().getEnd(); return End; } diff --git a/clang/lib/AST/FormatString.cpp b/clang/lib/AST/FormatString.cpp --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -981,10 +981,9 @@ bool FormatSpecifier::namedTypeToLengthModifier(QualType QT, LengthModifier &LM) { - assert(isa(QT) && "Expected a TypedefType"); - const TypedefNameDecl *Typedef = cast(QT)->getDecl(); - - for (;;) { + for (/**/; const auto *TT = QT->getAs(); + QT = TT->getDecl()->getUnderlyingType()) { + const TypedefNameDecl *Typedef = TT->getDecl(); const IdentifierInfo *Identifier = Typedef->getIdentifier(); if (Identifier->getName() == "size_t") { LM.setKind(LengthModifier::AsSizeT); @@ -1003,12 +1002,6 @@ LM.setKind(LengthModifier::AsPtrDiff); return true; } - - QualType T = Typedef->getUnderlyingType(); - if (!isa(T)) - break; - - Typedef = cast(T)->getDecl(); } return false; } diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp --- a/clang/lib/AST/PrintfFormatString.cpp +++ b/clang/lib/AST/PrintfFormatString.cpp @@ -844,7 +844,7 @@ } // Handle size_t, ptrdiff_t, etc. that have dedicated length modifiers in C99. - if (isa(QT) && (LangOpt.C99 || LangOpt.CPlusPlus11)) + if (LangOpt.C99 || LangOpt.CPlusPlus11) namedTypeToLengthModifier(QT, LM); // If fixing the length modifier was enough, we might be done. @@ -874,7 +874,7 @@ // Set conversion specifier and disable any flags which do not apply to it. // Let typedefs to char fall through to int, as %c is silly for uint8_t. - if (!isa(QT) && QT->isCharType()) { + if (!QT->getAs() && QT->isCharType()) { CS.setKind(ConversionSpecifier::cArg); LM.setKind(LengthModifier::None); Precision.setHowSpecified(OptionalAmount::NotSpecified); @@ -885,12 +885,10 @@ // Test for Floating type first as LongDouble can pass isUnsignedIntegerType else if (QT->isRealFloatingType()) { CS.setKind(ConversionSpecifier::fArg); - } - else if (QT->isSignedIntegerType()) { + } else if (QT->isSignedIntegerType()) { CS.setKind(ConversionSpecifier::dArg); HasAlternativeForm = false; - } - else if (QT->isUnsignedIntegerType()) { + } else if (QT->isUnsignedIntegerType()) { CS.setKind(ConversionSpecifier::uArg); HasAlternativeForm = false; HasPlusPrefix = false; diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -422,13 +422,6 @@ return QT; } - // We don't consider the alias introduced by `using a::X` as a new type. - // The qualified name is still a::X. - if (isa(QT.getTypePtr())) { - return getFullyQualifiedType(QT.getSingleStepDesugaredType(Ctx), Ctx, - WithGlobalNsPrefix); - } - // Remove the part of the type related to the type being a template // parameter (we won't report it as part of the 'type name' and it // is actually make the code below to be more complex (to handle @@ -455,6 +448,14 @@ assert(!QT.hasLocalQualifiers()); Keyword = ETypeInput->getKeyword(); } + + // We don't consider the alias introduced by `using a::X` as a new type. + // The qualified name is still a::X. + if (const auto *UT = QT->getAs()) { + return getFullyQualifiedType(UT->getUnderlyingType(), Ctx, + WithGlobalNsPrefix); + } + // Create a nested name specifier if needed. Prefix = createNestedNameSpecifierForScopeOf(Ctx, QT.getTypePtr(), true /*FullyQualified*/, diff --git a/clang/lib/AST/ScanfFormatString.cpp b/clang/lib/AST/ScanfFormatString.cpp --- a/clang/lib/AST/ScanfFormatString.cpp +++ b/clang/lib/AST/ScanfFormatString.cpp @@ -500,7 +500,7 @@ } // Handle size_t, ptrdiff_t, etc. that have dedicated length modifiers in C99. - if (isa(PT) && (LangOpt.C99 || LangOpt.CPlusPlus11)) + if (LangOpt.C99 || LangOpt.CPlusPlus11) namedTypeToLengthModifier(PT, LM); // If fixing the length modifier was enough, we are done. diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -4320,20 +4320,13 @@ } bool Type::isObjCNSObjectType() const { - const Type *cur = this; - while (true) { - if (const auto *typedefType = dyn_cast(cur)) - return typedefType->getDecl()->hasAttr(); - - // Single-step desugar until we run out of sugar. - QualType next = cur->getLocallyUnqualifiedSingleStepDesugaredType(); - if (next.getTypePtr() == cur) return false; - cur = next.getTypePtr(); - } + if (const auto *typedefType = getAs()) + return typedefType->getDecl()->hasAttr(); + return false; } bool Type::isObjCIndependentClassType() const { - if (const auto *typedefType = dyn_cast(this)) + if (const auto *typedefType = getAs()) return typedefType->getDecl()->hasAttr(); return false; } diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/lib/AST/TypeLoc.cpp @@ -194,8 +194,14 @@ while (true) { switch (Cur.getTypeLocClass()) { case Elaborated: - LeftMost = Cur; - break; + if (Cur.getLocalSourceRange().getBegin().isValid()) { + LeftMost = Cur; + break; + } + Cur = Cur.getNextTypeLoc(); + if (Cur.isNull()) + break; + continue; case FunctionProto: if (Cur.castAs().getTypePtr() ->hasTrailingReturn()) { @@ -530,6 +536,8 @@ void ElaboratedTypeLoc::initializeLocal(ASTContext &Context, SourceLocation Loc) { + if (isEmpty()) + return; setElaboratedKeywordLoc(Loc); NestedNameSpecifierLocBuilder Builder; Builder.MakeTrivial(Context, getTypePtr()->getQualifier(), Loc); diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp --- a/clang/lib/Analysis/RetainSummaryManager.cpp +++ b/clang/lib/Analysis/RetainSummaryManager.cpp @@ -892,7 +892,7 @@ /// has a typedef with a given name @c Name. static bool hasTypedefNamed(QualType QT, StringRef Name) { - while (auto *T = dyn_cast(QT)) { + while (auto *T = QT->getAs()) { const auto &Context = T->getDecl()->getASTContext(); if (T->getDecl()->getIdentifier() == &Context.Idents.get(Name)) return true; diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2860,7 +2860,7 @@ // Set `align` attribute if any. const auto *AVAttr = PVD->getAttr(); if (!AVAttr) - if (const auto *TOTy = dyn_cast(OTy)) + if (const auto *TOTy = OTy->getAs()) AVAttr = TOTy->getDecl()->getAttr(); if (AVAttr && !SanOpts.has(SanitizerKind::Alignment)) { // If alignment-assumption sanitizer is enabled, we do *not* add diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -255,7 +255,7 @@ if (VD->getType()->isReferenceType()) { if (const auto *TTy = - dyn_cast(VD->getType().getNonReferenceType())) + VD->getType().getNonReferenceType()->getAs()) AVAttr = TTy->getDecl()->getAttr(); } else { // Assumptions for function parameters are emitted at the start of the @@ -271,8 +271,7 @@ } if (!AVAttr) - if (const auto *TTy = - dyn_cast(E->getType())) + if (const auto *TTy = E->getType()->getAs()) AVAttr = TTy->getDecl()->getAttr(); if (!AVAttr) diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2214,7 +2214,6 @@ case Type::ConstantMatrix: case Type::Record: case Type::Enum: - case Type::Elaborated: case Type::Using: case Type::TemplateSpecialization: case Type::ObjCTypeParam: @@ -2224,6 +2223,10 @@ case Type::BitInt: llvm_unreachable("type class is never variably-modified!"); + case Type::Elaborated: + type = cast(ty)->getNamedType(); + break; + case Type::Adjusted: type = cast(ty)->getAdjustedType(); break; diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1743,7 +1743,7 @@ // Get image and pipe access qualifier: if (ty->isImageType() || ty->isPipeType()) { const Decl *PDecl = parm; - if (auto *TD = dyn_cast(ty)) + if (const auto *TD = ty->getAs()) PDecl = TD->getDecl(); const OpenCLAccessAttr *A = PDecl->getAttr(); if (A && A->isWriteOnly()) diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -853,7 +853,7 @@ if (D->isBitField()) IvarT = GetGroupRecordTypeForObjCIvarBitfield(D); - if (!isa(IvarT) && IvarT->isRecordType()) { + if (!IvarT->getAs() && IvarT->isRecordType()) { RecordDecl *RD = IvarT->castAs()->getDecl(); RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { @@ -3629,7 +3629,7 @@ /// It handles elaborated types, as well as enum types in the process. bool RewriteModernObjC::RewriteObjCFieldDeclType(QualType &Type, std::string &Result) { - if (isa(Type)) { + if (Type->getAs()) { Result += "\t"; return false; } @@ -3724,7 +3724,7 @@ void RewriteModernObjC::RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDecl, std::string &Result) { QualType Type = fieldDecl->getType(); - if (isa(Type)) + if (Type->getAs()) return; if (Type->isArrayType()) Type = Context->getBaseElementType(Type); @@ -7496,7 +7496,7 @@ if (D->isBitField()) IvarT = GetGroupRecordTypeForObjCIvarBitfield(D); - if (!isa(IvarT) && IvarT->isRecordType()) { + if (!IvarT->getAs() && IvarT->isRecordType()) { RecordDecl *RD = IvarT->castAs()->getDecl(); RD = RD->getDefinition(); if (RD && !RD->getDeclName().getAsIdentifierInfo()) { diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -10196,7 +10196,7 @@ // We extract the name from the typedef because we don't want to show // the underlying type in the diagnostic. StringRef Name; - if (const TypedefType *TypedefTy = dyn_cast(ExprTy)) + if (const auto *TypedefTy = ExprTy->getAs()) Name = TypedefTy->getDecl()->getName(); else Name = CastTyName; @@ -15800,7 +15800,7 @@ while (TInfo) { TypeLoc TL = TInfo->getTypeLoc(); // Look through typedefs. - if (TypedefTypeLoc TTL = TL.getAs()) { + if (TypedefTypeLoc TTL = TL.getAsAdjusted()) { const TypedefNameDecl *TDL = TTL.getTypedefNameDecl(); TInfo = TDL->getTypeSourceInfo(); continue; diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -2782,7 +2782,7 @@ while (true) { // Look through typedefs. if (!SuppressBlock) { - if (TypedefTypeLoc TypedefTL = TL.getAs()) { + if (TypedefTypeLoc TypedefTL = TL.getAsAdjusted()) { if (TypeSourceInfo *InnerTSInfo = TypedefTL.getTypedefNameDecl()->getTypeSourceInfo()) { TL = InnerTSInfo->getTypeLoc().getUnqualifiedLoc(); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -275,6 +275,45 @@ return S.CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); } +/// Build a ParsedType for a simple-type-specifier with a nested-name-specifier. +static ParsedType buildNamedType(Sema &S, const CXXScopeSpec *SS, QualType T, + SourceLocation NameLoc, + bool WantNontrivialTypeSourceInfo = true) { + switch (T->getTypeClass()) { + case Type::DeducedTemplateSpecialization: + case Type::Enum: + case Type::InjectedClassName: + case Type::Record: + case Type::Typedef: + case Type::UnresolvedUsing: + case Type::Using: + break; + // These can never be qualified so an ElaboratedType node + // would carry no additional meaning. + case Type::ObjCInterface: + case Type::ObjCTypeParam: + case Type::TemplateTypeParm: + return ParsedType::make(T); + default: + llvm_unreachable("Unexpected Type Class"); + } + + if (!SS || SS->isEmpty()) + return ParsedType::make( + S.Context.getElaboratedType(ETK_None, nullptr, T, nullptr)); + + QualType ElTy = S.getElaboratedType(ETK_None, *SS, T); + if (!WantNontrivialTypeSourceInfo) + return ParsedType::make(ElTy); + + TypeLocBuilder Builder; + Builder.pushTypeSpec(T).setNameLoc(NameLoc); + ElaboratedTypeLoc ElabTL = Builder.push(ElTy); + ElabTL.setElaboratedKeywordLoc(SourceLocation()); + ElabTL.setQualifierLoc(SS->getWithLocInContext(S.Context)); + return S.CreateParsedType(ElTy, Builder.getTypeSourceInfo(S.Context, ElTy)); +} + /// If the identifier refers to a type name within this scope, /// return the declaration of that type. /// @@ -500,8 +539,7 @@ } else if (auto *UD = dyn_cast(IIDecl)) { (void)DiagnoseUseOfDecl(UD, NameLoc); // Recover with 'int' - T = Context.IntTy; - FoundUsingShadow = nullptr; + return ParsedType::make(Context.IntTy); } else if (AllowDeducedTemplate) { if (auto *TD = getAsTypeTemplateDecl(IIDecl)) { assert(!FoundUsingShadow || FoundUsingShadow->getTargetDecl() == TD); @@ -523,27 +561,7 @@ if (FoundUsingShadow) T = Context.getUsingType(FoundUsingShadow, T); - // NOTE: avoid constructing an ElaboratedType(Loc) if this is a - // constructor or destructor name (in such a case, the scope specifier - // will be attached to the enclosing Expr or Decl node). - if (SS && SS->isNotEmpty() && !IsCtorOrDtorName && - !isa(IIDecl)) { - if (WantNontrivialTypeSourceInfo) { - // Construct a type with type-source information. - TypeLocBuilder Builder; - Builder.pushTypeSpec(T).setNameLoc(NameLoc); - - T = getElaboratedType(ETK_None, *SS, T); - ElaboratedTypeLoc ElabTL = Builder.push(T); - ElabTL.setElaboratedKeywordLoc(SourceLocation()); - ElabTL.setQualifierLoc(SS->getWithLocInContext(Context)); - return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); - } else { - T = getElaboratedType(ETK_None, *SS, T); - } - } - - return ParsedType::make(T); + return buildNamedType(*this, SS, T, NameLoc, WantNontrivialTypeSourceInfo); } // Builds a fake NNS for the given decl context. @@ -1147,17 +1165,7 @@ QualType T = Context.getTypeDeclType(Type); if (const auto *USD = dyn_cast(Found)) T = Context.getUsingType(USD, T); - - if (SS.isEmpty()) // No elaborated type, trivial location info - return ParsedType::make(T); - - TypeLocBuilder Builder; - Builder.pushTypeSpec(T).setNameLoc(NameLoc); - T = getElaboratedType(ETK_None, SS, T); - ElaboratedTypeLoc ElabTL = Builder.push(T); - ElabTL.setElaboratedKeywordLoc(SourceLocation()); - ElabTL.setQualifierLoc(SS.getWithLocInContext(Context)); - return CreateParsedType(T, Builder.getTypeSourceInfo(Context, T)); + return buildNamedType(*this, &SS, T, NameLoc); }; NamedDecl *FirstDecl = (*Result.begin())->getUnderlyingDecl(); 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 @@ -4362,17 +4362,13 @@ } if (BaseType.isNull()) { - BaseType = Context.getTypeDeclType(TyD); + BaseType = getElaboratedType(ETK_None, SS, Context.getTypeDeclType(TyD)); MarkAnyDeclReferenced(TyD->getLocation(), TyD, /*OdrUse=*/false); - if (SS.isSet()) { - BaseType = Context.getElaboratedType(ETK_None, SS.getScopeRep(), - BaseType); - TInfo = Context.CreateTypeSourceInfo(BaseType); - ElaboratedTypeLoc TL = TInfo->getTypeLoc().castAs(); - TL.getNamedTypeLoc().castAs().setNameLoc(IdLoc); - TL.setElaboratedKeywordLoc(SourceLocation()); - TL.setQualifierLoc(SS.getWithLocInContext(Context)); - } + TInfo = Context.CreateTypeSourceInfo(BaseType); + ElaboratedTypeLoc TL = TInfo->getTypeLoc().castAs(); + TL.getNamedTypeLoc().castAs().setNameLoc(IdLoc); + TL.setElaboratedKeywordLoc(SourceLocation()); + TL.setQualifierLoc(SS.getWithLocInContext(Context)); } } @@ -4468,10 +4464,10 @@ MemInitResult Sema::BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl) { - SourceLocation NameLoc = TInfo->getTypeLoc().getLocalSourceRange().getBegin(); + SourceLocation NameLoc = TInfo->getTypeLoc().getSourceRange().getBegin(); if (!LangOpts.CPlusPlus11) return Diag(NameLoc, diag::err_delegating_ctor) - << TInfo->getTypeLoc().getLocalSourceRange(); + << TInfo->getTypeLoc().getSourceRange(); Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor); bool InitList = true; @@ -4532,12 +4528,11 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc) { - SourceLocation BaseLoc - = BaseTInfo->getTypeLoc().getLocalSourceRange().getBegin(); + SourceLocation BaseLoc = BaseTInfo->getTypeLoc().getBeginLoc(); if (!BaseType->isDependentType() && !BaseType->isRecordType()) return Diag(BaseLoc, diag::err_base_init_does_not_name_class) - << BaseType << BaseTInfo->getTypeLoc().getLocalSourceRange(); + << BaseType << BaseTInfo->getTypeLoc().getSourceRange(); // C++ [class.base.init]p2: // [...] Unless the mem-initializer-id names a nonstatic data @@ -4595,8 +4590,8 @@ Dependent = true; else return Diag(BaseLoc, diag::err_not_direct_base_or_virtual) - << BaseType << Context.getTypeDeclType(ClassDecl) - << BaseTInfo->getTypeLoc().getLocalSourceRange(); + << BaseType << Context.getTypeDeclType(ClassDecl) + << BaseTInfo->getTypeLoc().getSourceRange(); } } @@ -11044,7 +11039,7 @@ bool AcceptableReturnType = false; bool MightInstantiateToSpecialization = false; if (auto RetTST = - TSI->getTypeLoc().getAs()) { + TSI->getTypeLoc().getAsAdjusted()) { TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName(); bool TemplateMatches = Context.hasSameTemplateName(SpecifiedName, GuidedTemplate); @@ -16650,7 +16645,7 @@ assert(TSInfo && "NULL TypeSourceInfo for friend type declaration"); QualType T = TSInfo->getType(); - SourceRange TypeRange = TSInfo->getTypeLoc().getLocalSourceRange(); + SourceRange TypeRange = TSInfo->getTypeLoc().getSourceRange(); // C++03 [class.friend]p2: // An elaborated-type-specifier shall be used in a friend declaration diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4504,7 +4504,6 @@ case Type::ConstantMatrix: case Type::Record: case Type::Enum: - case Type::Elaborated: case Type::TemplateSpecialization: case Type::ObjCObject: case Type::ObjCInterface: @@ -4513,6 +4512,9 @@ case Type::Pipe: case Type::BitInt: llvm_unreachable("type class is never variably-modified!"); + case Type::Elaborated: + T = cast(Ty)->getNamedType(); + break; case Type::Adjusted: T = cast(Ty)->getOriginalType(); break; diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -241,7 +241,7 @@ if (IsAcceptableResult(Type)) { QualType T = Context.getTypeDeclType(Type); MarkAnyDeclReferenced(Type->getLocation(), Type, /*OdrUse=*/false); - return CreateParsedType(T, + return CreateParsedType(Context.getElaboratedType(ETK_None, nullptr, T), Context.getTrivialTypeSourceInfo(T, NameLoc)); } } @@ -7713,8 +7713,8 @@ // designated by the pseudo-destructor-name shall be the same type. if (DestructedTypeInfo) { QualType DestructedType = DestructedTypeInfo->getType(); - SourceLocation DestructedTypeStart - = DestructedTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(); + SourceLocation DestructedTypeStart = + DestructedTypeInfo->getTypeLoc().getBeginLoc(); if (!DestructedType->isDependentType() && !ObjectType->isDependentType()) { if (!Context.hasSameUnqualifiedType(DestructedType, ObjectType)) { // Detect dot pseudo destructor calls on pointer objects, e.g.: @@ -7739,7 +7739,7 @@ } else { Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch) << ObjectType << DestructedType << Base->getSourceRange() - << DestructedTypeInfo->getTypeLoc().getLocalSourceRange(); + << DestructedTypeInfo->getTypeLoc().getSourceRange(); // Recover by setting the destructed type to the object type. DestructedType = ObjectType; @@ -7755,8 +7755,8 @@ // type. } else { Diag(DestructedTypeStart, diag::err_arc_pseudo_dtor_inconstant_quals) - << ObjectType << DestructedType << Base->getSourceRange() - << DestructedTypeInfo->getTypeLoc().getLocalSourceRange(); + << ObjectType << DestructedType << Base->getSourceRange() + << DestructedTypeInfo->getTypeLoc().getSourceRange(); } // Recover by setting the destructed type to the object type. @@ -7780,10 +7780,10 @@ if (!ScopeType->isDependentType() && !ObjectType->isDependentType() && !Context.hasSameUnqualifiedType(ScopeType, ObjectType)) { - Diag(ScopeTypeInfo->getTypeLoc().getLocalSourceRange().getBegin(), + Diag(ScopeTypeInfo->getTypeLoc().getSourceRange().getBegin(), diag::err_pseudo_dtor_type_mismatch) - << ObjectType << ScopeType << Base->getSourceRange() - << ScopeTypeInfo->getTypeLoc().getLocalSourceRange(); + << ObjectType << ScopeType << Base->getSourceRange() + << ScopeTypeInfo->getTypeLoc().getSourceRange(); ScopeType = QualType(); ScopeTypeInfo = nullptr; diff --git a/clang/lib/Sema/SemaExprObjC.cpp b/clang/lib/Sema/SemaExprObjC.cpp --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -3860,7 +3860,7 @@ static ObjCBridgeRelatedAttr *ObjCBridgeRelatedAttrFromType(QualType T, TypedefNameDecl *&TDNDecl) { - while (const TypedefType *TD = dyn_cast(T.getTypePtr())) { + while (const auto *TD = T->getAs()) { TDNDecl = TD->getDecl(); if (ObjCBridgeRelatedAttr *ObjCBAttr = getObjCBridgeAttr(TD)) @@ -4007,7 +4007,7 @@ bool &HadTheAttribute, bool warn) { QualType T = castExpr->getType(); HadTheAttribute = false; - while (const TypedefType *TD = dyn_cast(T.getTypePtr())) { + while (const auto *TD = T->getAs()) { TypedefNameDecl *TDNDecl = TD->getDecl(); if (TB *ObjCBAttr = getObjCBridgeAttr(TD)) { if (IdentifierInfo *Parm = ObjCBAttr->getBridgedType()) { @@ -4070,7 +4070,7 @@ bool &HadTheAttribute, bool warn) { QualType T = castType; HadTheAttribute = false; - while (const TypedefType *TD = dyn_cast(T.getTypePtr())) { + while (const auto *TD = T->getAs()) { TypedefNameDecl *TDNDecl = TD->getDecl(); if (TB *ObjCBAttr = getObjCBridgeAttr(TD)) { if (IdentifierInfo *Parm = ObjCBAttr->getBridgedType()) { diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4033,14 +4033,14 @@ return CreateParsedType(T, TLB.getTypeSourceInfo(Context, T)); } - QualType Result = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs); - if (Result.isNull()) + QualType SpecTy = CheckTemplateIdType(Template, TemplateIILoc, TemplateArgs); + if (SpecTy.isNull()) return true; // Build type-source information. TypeLocBuilder TLB; - TemplateSpecializationTypeLoc SpecTL - = TLB.push(Result); + TemplateSpecializationTypeLoc SpecTL = + TLB.push(SpecTy); SpecTL.setTemplateKeywordLoc(TemplateKWLoc); SpecTL.setTemplateNameLoc(TemplateIILoc); SpecTL.setLAngleLoc(LAngleLoc); @@ -4048,18 +4048,14 @@ for (unsigned i = 0, e = SpecTL.getNumArgs(); i != e; ++i) SpecTL.setArgLocInfo(i, TemplateArgs[i].getLocInfo()); - // NOTE: avoid constructing an ElaboratedTypeLoc if this is a - // constructor or destructor name (in such a case, the scope specifier - // will be attached to the enclosing Decl or Expr node). - if (SS.isNotEmpty() && !IsCtorOrDtorName) { - // Create an elaborated-type-specifier containing the nested-name-specifier. - Result = Context.getElaboratedType(ETK_None, SS.getScopeRep(), Result); - ElaboratedTypeLoc ElabTL = TLB.push(Result); - ElabTL.setElaboratedKeywordLoc(SourceLocation()); + // Create an elaborated-type-specifier containing the nested-name-specifier. + QualType ElTy = getElaboratedType( + ETK_None, !IsCtorOrDtorName ? SS : CXXScopeSpec(), SpecTy); + ElaboratedTypeLoc ElabTL = TLB.push(ElTy); + ElabTL.setElaboratedKeywordLoc(SourceLocation()); + if (!ElabTL.isEmpty()) ElabTL.setQualifierLoc(SS.getWithLocInContext(Context)); - } - - return CreateParsedType(Result, TLB.getTypeSourceInfo(Context, Result)); + return CreateParsedType(ElTy, TLB.getTypeSourceInfo(Context, ElTy)); } TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK, diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -5538,7 +5538,7 @@ // in ClsType; hence we wrap ClsType into an ElaboratedType. // NOTE: in particular, no wrap occurs if ClsType already is an // Elaborated, DependentName, or DependentTemplateSpecialization. - if (NNSPrefix && isa(NNS->getAsType())) + if (isa(NNS->getAsType())) ClsType = Context.getElaboratedType(ETK_None, NNSPrefix, ClsType); break; } @@ -6090,19 +6090,19 @@ } } void VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) { - ElaboratedTypeKeyword Keyword - = TypeWithKeyword::getKeywordForTypeSpec(DS.getTypeSpecType()); if (DS.getTypeSpecType() == TST_typename) { TypeSourceInfo *TInfo = nullptr; Sema::GetTypeFromParser(DS.getRepAsType(), &TInfo); - if (TInfo) { - TL.copy(TInfo->getTypeLoc().castAs()); - return; - } + if (TInfo) + if (auto ETL = TInfo->getTypeLoc().getAs()) { + TL.copy(ETL); + return; + } } - TL.setElaboratedKeywordLoc(Keyword != ETK_None - ? DS.getTypeSpecTypeLoc() - : SourceLocation()); + const ElaboratedType *T = TL.getTypePtr(); + TL.setElaboratedKeywordLoc(T->getKeyword() != ETK_None + ? DS.getTypeSpecTypeLoc() + : SourceLocation()); const CXXScopeSpec& SS = DS.getTypeSpecScope(); TL.setQualifierLoc(SS.getWithLocInContext(Context)); Visit(TL.getNextTypeLoc().getUnqualifiedLoc()); @@ -9099,15 +9099,8 @@ TagDecl *OwnedTagDecl) { if (T.isNull()) return T; - NestedNameSpecifier *NNS; - if (SS.isValid()) - NNS = SS.getScopeRep(); - else { - if (Keyword == ETK_None) - return T; - NNS = nullptr; - } - return Context.getElaboratedType(Keyword, NNS, T, OwnedTagDecl); + return Context.getElaboratedType( + Keyword, SS.isValid() ? SS.getScopeRep() : nullptr, T, OwnedTagDecl); } QualType Sema::BuildTypeofExprType(Expr *E) { diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1069,15 +1069,11 @@ // Otherwise, make an elaborated type wrapping a non-dependent // specialization. QualType T = - getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); - if (T.isNull()) return QualType(); - - if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr) - return T; - - return SemaRef.Context.getElaboratedType(Keyword, - QualifierLoc.getNestedNameSpecifier(), - T); + getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); + if (T.isNull()) + return QualType(); + return SemaRef.Context.getElaboratedType( + Keyword, QualifierLoc.getNestedNameSpecifier(), T); } /// Build a new typename type that refers to an identifier. @@ -4196,7 +4192,7 @@ } // If the nested-name-specifier is an invalid type def, don't emit an // error because a previous error should have already been emitted. - TypedefTypeLoc TTL = TL.getAs(); + TypedefTypeLoc TTL = TL.getAsAdjusted(); if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) { SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag) << TL.getType() << SS.getRange(); diff --git a/clang/lib/Sema/TypeLocBuilder.h b/clang/lib/Sema/TypeLocBuilder.h --- a/clang/lib/Sema/TypeLocBuilder.h +++ b/clang/lib/Sema/TypeLocBuilder.h @@ -40,12 +40,13 @@ /// The inline buffer. enum { BufferMaxAlignment = alignof(void *) }; alignas(BufferMaxAlignment) char InlineBuffer[InlineCapacity]; - unsigned NumBytesAtAlign4, NumBytesAtAlign8; + unsigned NumBytesAtAlign4; + bool AtAlign8; public: TypeLocBuilder() : Buffer(InlineBuffer), Capacity(InlineCapacity), Index(InlineCapacity), - NumBytesAtAlign4(0), NumBytesAtAlign8(0) {} + NumBytesAtAlign4(0), AtAlign8(false) {} ~TypeLocBuilder() { if (Buffer != InlineBuffer) @@ -77,7 +78,8 @@ LastTy = QualType(); #endif Index = Capacity; - NumBytesAtAlign4 = NumBytesAtAlign8 = 0; + NumBytesAtAlign4 = 0; + AtAlign8 = false; } /// Tell the TypeLocBuilder that the type it is storing has been diff --git a/clang/lib/Sema/TypeLocBuilder.cpp b/clang/lib/Sema/TypeLocBuilder.cpp --- a/clang/lib/Sema/TypeLocBuilder.cpp +++ b/clang/lib/Sema/TypeLocBuilder.cpp @@ -85,7 +85,7 @@ // FIXME: 4 and 8 are sufficient at the moment, but it's pretty ugly to // hardcode them. if (LocalAlignment == 4) { - if (NumBytesAtAlign8 == 0) { + if (!AtAlign8) { NumBytesAtAlign4 += LocalSize; } else { unsigned Padding = NumBytesAtAlign4 % 8; @@ -114,7 +114,7 @@ NumBytesAtAlign4 += LocalSize; } } else if (LocalAlignment == 8) { - if (NumBytesAtAlign8 == 0) { + if (!AtAlign8) { // We have not seen any 8-byte aligned element yet. We insert a padding // only if the new Index is not 8-byte-aligned. if ((Index - LocalSize) % 8 != 0) { @@ -149,14 +149,15 @@ // Forget about any padding. NumBytesAtAlign4 = 0; - NumBytesAtAlign8 += LocalSize; + AtAlign8 = true; } else { assert(LocalSize == 0); } Index -= LocalSize; - assert(Capacity - Index == TypeLoc::getFullDataSizeForType(T) && + unsigned FDSz = TypeLoc::getFullDataSizeForType(T); + assert(Capacity - Index == FDSz && "incorrect data size provided to CreateTypeSourceInfo!"); return getTemporaryTypeLoc(T); diff --git a/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp @@ -109,17 +109,20 @@ // Look through the typedefs. while (const Type *T = Ty.getTypePtr()) { - if (const auto *TT = dyn_cast(T)) { + if (const auto *AT = dyn_cast(T)) { + if (AT->getAttrKind() == attr::TypeNonNull) + return true; + Ty = AT->getModifiedType(); + } else if (const auto *ET = dyn_cast(T)) { + const auto *TT = dyn_cast(ET->getNamedType()); + if (!TT) + return false; Ty = TT->getDecl()->getUnderlyingType(); // It is sufficient for any intermediate typedef // to be classified const. HasConst = HasConst || Ty.isConstQualified(); if (isNonnullType(Ty) && HasConst) return true; - } else if (const auto *AT = dyn_cast(T)) { - if (AT->getAttrKind() == attr::TypeNonNull) - return true; - Ty = AT->getModifiedType(); } else { return false; } @@ -136,7 +139,7 @@ if (auto *T = dyn_cast(Ty)) { return T->getInterfaceDecl() && T->getInterfaceDecl()->getIdentifier() == NSStringII; - } else if (auto *T = dyn_cast(Ty)) { + } else if (auto *T = Ty->getAs()) { IdentifierInfo* II = T->getDecl()->getIdentifier(); return II == CFStringRefII || II == CFBooleanRefII || II == CFNullRefII; } diff --git a/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp @@ -196,12 +196,10 @@ AnalysisManager &AM, BugReporter &BR) const { // Currently this matches CoreFoundation opaque pointer typedefs. - auto CSuspiciousNumberObjectExprM = - expr(ignoringParenImpCasts( - expr(hasType( - typedefType(hasDeclaration(anyOf( - typedefDecl(hasName("CFNumberRef")), - typedefDecl(hasName("CFBooleanRef"))))))) + auto CSuspiciousNumberObjectExprM = expr(ignoringParenImpCasts( + expr(hasType(elaboratedType(namesType(typedefType( + hasDeclaration(anyOf(typedefDecl(hasName("CFNumberRef")), + typedefDecl(hasName("CFBooleanRef"))))))))) .bind("c_object"))); // Currently this matches XNU kernel number-object pointers. @@ -240,8 +238,9 @@ // The .bind here is in order to compose the error message more accurately. auto ObjCSuspiciousScalarBooleanTypeM = - qualType(typedefType(hasDeclaration( - typedefDecl(hasName("BOOL"))))).bind("objc_bool_type"); + qualType(elaboratedType(namesType( + typedefType(hasDeclaration(typedefDecl(hasName("BOOL"))))))) + .bind("objc_bool_type"); // The .bind here is in order to compose the error message more accurately. auto SuspiciousScalarBooleanTypeM = @@ -253,9 +252,9 @@ // for storing pointers. auto SuspiciousScalarNumberTypeM = qualType(hasCanonicalType(isInteger()), - unless(typedefType(hasDeclaration( - typedefDecl(matchesName("^::u?intptr_t$")))))) - .bind("int_type"); + unless(elaboratedType(namesType(typedefType(hasDeclaration( + typedefDecl(matchesName("^::u?intptr_t$")))))))) + .bind("int_type"); auto SuspiciousScalarTypeM = qualType(anyOf(SuspiciousScalarBooleanTypeM, diff --git a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp --- a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp +++ b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp @@ -161,7 +161,7 @@ optionally( isDerivedFrom(cxxRecordDecl(hasName("clang::TypeLoc")) .bind("typeLocBase"))))), - returns(asString(TypeString))) + returns(hasCanonicalType(asString(TypeString)))) .bind("classMethod")), *ASTClass, *Result.Context); diff --git a/clang/test/AST/ast-dump-APValue-anon-union.cpp b/clang/test/AST/ast-dump-APValue-anon-union.cpp --- a/clang/test/AST/ast-dump-APValue-anon-union.cpp +++ b/clang/test/AST/ast-dump-APValue-anon-union.cpp @@ -30,23 +30,23 @@ void Test() { constexpr S0 s0{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} s0 'const S0' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s0 'const S0':'const S0' constexpr listinit // CHECK-NEXT: | |-value: Struct // CHECK-NEXT: | | `-field: Union .i Int 42 constexpr U0 u0a{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0a 'const U0' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0a 'const U0':'const U0' constexpr listinit // CHECK-NEXT: | |-value: Union None constexpr U0 u0b{3.1415f}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0b 'const U0' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0b 'const U0':'const U0' constexpr listinit // CHECK-NEXT: | |-value: Union . Union .f Float 3.141500e+00 constexpr U1 u1a{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u1a 'const U1' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u1a 'const U1':'const U1' constexpr listinit // CHECK-NEXT: | |-value: Union . Union .f Float 0.000000e+00 constexpr U1 u1b{3.1415f}; - // CHECK: `-VarDecl {{.*}} col:{{.*}} u1b 'const U1' constexpr listinit + // CHECK: `-VarDecl {{.*}} col:{{.*}} u1b 'const U1':'const U1' constexpr listinit // CHECK-NEXT: |-value: Union . Union .f Float 3.141500e+00 } diff --git a/clang/test/AST/ast-dump-APValue-struct.cpp b/clang/test/AST/ast-dump-APValue-struct.cpp --- a/clang/test/AST/ast-dump-APValue-struct.cpp +++ b/clang/test/AST/ast-dump-APValue-struct.cpp @@ -60,12 +60,12 @@ void Test() { constexpr S0 s0{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} s0 'const S0' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s0 'const S0':'const S0' constexpr listinit // CHECK-NEXT: | |-value: Struct // CHECK-NEXT: | | `-fields: Int 0, Union .j Int 0 constexpr S1 s1{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} s1 'const S1' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s1 'const S1':'const S1' constexpr listinit // CHECK-NEXT: | |-value: Struct // CHECK-NEXT: | | |-field: Int 0 // CHECK-NEXT: | | `-field: Union .s @@ -73,12 +73,12 @@ // CHECK-NEXT: | | `-field: Int 0 constexpr S2 s2{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} s2 'const S2' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s2 'const S2':'const S2' constexpr listinit // CHECK-NEXT: | |-value: Struct // CHECK-NEXT: | | `-fields: Int 0, Union .u Union .j Int 0 constexpr S3 s3{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} s3 'const S3' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s3 'const S3':'const S3' constexpr listinit // CHECK-NEXT: | |-value: Struct // CHECK-NEXT: | | |-field: Int 0 // CHECK-NEXT: | | `-field: Union .u @@ -87,7 +87,7 @@ // CHECK-NEXT: | | `-field: Int 0 constexpr S4 s4{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} s4 'const S4' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} s4 'const S4':'const S4' constexpr listinit // CHECK-NEXT: | |-value: Struct // CHECK-NEXT: | | |-base: Struct // CHECK-NEXT: | | | `-fields: Int 0, Union .j Int 0 @@ -96,7 +96,7 @@ // CHECK-NEXT: | | `-fields: Int 4, Int 5, Int 6 constexpr S5 s5{}; - // CHECK: `-VarDecl {{.*}} col:{{.*}} s5 'const S5' constexpr listinit + // CHECK: `-VarDecl {{.*}} col:{{.*}} s5 'const S5':'const S5' constexpr listinit // CHECK-NEXT: |-value: Struct // CHECK-NEXT: | |-base: Struct // CHECK-NEXT: | | |-base: Struct diff --git a/clang/test/AST/ast-dump-APValue-union.cpp b/clang/test/AST/ast-dump-APValue-union.cpp --- a/clang/test/AST/ast-dump-APValue-union.cpp +++ b/clang/test/AST/ast-dump-APValue-union.cpp @@ -39,25 +39,25 @@ void Test() { constexpr U0 u0{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0 'const U0' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u0 'const U0':'const U0' constexpr listinit // CHECK-NEXT: | |-value: Union .i Int 42 constexpr U1 u1{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u1 'const U1' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u1 'const U1':'const U1' constexpr listinit // CHECK-NEXT: | |-value: Union .uinner Union .f Float 3.141500e+00 constexpr U2 u2{}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u2 'const U2' constexpr listinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u2 'const U2':'const U2' constexpr listinit // CHECK-NEXT: | |-value: Union .uinner // CHECK-NEXT: | | `-Union .arr // CHECK-NEXT: | | `-Array size=2 // CHECK-NEXT: | | `-elements: Int 1, Int 2 constexpr U3 u3a = {.f = 3.1415}; - // CHECK: | `-VarDecl {{.*}} col:{{.*}} u3a 'const U3' constexpr cinit + // CHECK: | `-VarDecl {{.*}} col:{{.*}} u3a 'const U3':'const U3' constexpr cinit // CHECK-NEXT: | |-value: Union .f Float 3.141500e+00 constexpr U3 u3b = {.uinner = {}}; - // CHECK: `-VarDecl {{.*}} col:{{.*}} u3b 'const U3' constexpr cinit + // CHECK: `-VarDecl {{.*}} col:{{.*}} u3b 'const U3':'const U3' constexpr cinit // CHECK-NEXT: |-value: Union .uinner Union .d Float 3.141500e+00 } diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -30,7 +30,7 @@ return TestVarDeclNRVO; } } -// CHECK: VarDecl{{.*}} TestVarDeclNRVO 'testVarDeclNRVO::A' nrvo +// CHECK: VarDecl{{.*}} TestVarDeclNRVO 'A':'testVarDeclNRVO::A' nrvo void testParmVarDeclInit(int TestParmVarDeclInit = 0); // CHECK: ParmVarDecl{{.*}} TestParmVarDeclInit 'int' @@ -107,8 +107,8 @@ // CHECK-NEXT: CopyAssignment simple non_trivial has_const_param // CHECK-NEXT: MoveAssignment exists simple non_trivial // CHECK-NEXT: Destructor simple irrelevant trivial -// CHECK-NEXT: virtual private 'testCXXRecordDecl::A' -// CHECK-NEXT: public 'testCXXRecordDecl::B' +// CHECK-NEXT: virtual private 'A':'testCXXRecordDecl::A' +// CHECK-NEXT: public 'B':'testCXXRecordDecl::B' // CHECK-NEXT: CXXRecordDecl{{.*}} class TestCXXRecordDecl // CHECK-NEXT: FieldDecl @@ -228,7 +228,7 @@ // CHECK-NEXT: | | `-CXXRecord 0x{{.+}} 'A' // CHECK-NEXT: | |-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::A':'testFunctionTemplateDecl::A' // CHECK-NEXT: | `-CompoundStmt 0x{{.+}} - // CHECK-NEXT: |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testFunctionTemplateDecl::B)' + // CHECK-NEXT: |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (B)' // CHECK-NEXT: |-FunctionDecl 0x{{.+}} col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::C)' // CHECK-NEXT: | |-TemplateArgument type 'testFunctionTemplateDecl::C' // CHECK-NEXT: | | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::C' @@ -241,11 +241,11 @@ // CHECK-NEXT: |-ParmVarDecl 0x{{.+}} col:51 'testFunctionTemplateDecl::D':'testFunctionTemplateDecl::D' // CHECK-NEXT: `-CompoundStmt 0x{{.+}} - // CHECK: FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)' + // CHECK: FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, col:41> col:19 TestFunctionTemplate 'void (B)' // CHECK-NEXT: |-TemplateArgument type 'testFunctionTemplateDecl::B' // CHECK-NEXT: | `-RecordType 0{{.+}} 'testFunctionTemplateDecl::B' // CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'B' - // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:41 'testFunctionTemplateDecl::B' + // CHECK-NEXT: `-ParmVarDecl 0x{{.+}} col:41 'B':'testFunctionTemplateDecl::B' namespace testClassTemplateDecl { diff --git a/clang/test/AST/ast-dump-expr-json.cpp b/clang/test/AST/ast-dump-expr-json.cpp --- a/clang/test/AST/ast-dump-expr-json.cpp +++ b/clang/test/AST/ast-dump-expr-json.cpp @@ -325,6 +325,7 @@ // CHECK-NEXT: "isUsed": true, // CHECK-NEXT: "name": "obj1", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: }, @@ -461,6 +462,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -469,6 +471,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "obj1", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -730,6 +733,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -738,6 +742,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "obj1", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2534,6 +2539,7 @@ // CHECK-NEXT: "isUsed": true, // CHECK-NEXT: "name": "a", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: }, @@ -2666,6 +2672,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -2674,6 +2681,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "a", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2984,6 +2992,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -2992,6 +3001,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "a", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -3159,6 +3169,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -3167,6 +3178,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "a", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -3235,6 +3247,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -3243,6 +3256,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "a", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -3486,6 +3500,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -3494,6 +3509,7 @@ // CHECK-NEXT: "kind": "ParmVarDecl", // CHECK-NEXT: "name": "a", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -3521,6 +3537,7 @@ // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "typeArg": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: }, @@ -3545,9 +3562,11 @@ // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "typeArg": { +// CHECK-NEXT: "desugaredQualType": "const volatile S", // CHECK-NEXT: "qualType": "const volatile S" // CHECK-NEXT: }, // CHECK-NEXT: "adjustedTypeArg": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: } // CHECK-NEXT: } @@ -7911,7 +7930,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (*)(NS::X)" +// CHECK-NEXT: "qualType": "void (*)(X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "FunctionToPointerDecay", @@ -7932,7 +7951,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "referencedDecl": { @@ -7940,7 +7959,7 @@ // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "f", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -7962,7 +7981,8 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "ctorType": { @@ -8348,7 +8368,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (*)(NS::X)" +// CHECK-NEXT: "qualType": "void (*)(X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "FunctionToPointerDecay", @@ -8369,7 +8389,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "referencedDecl": { @@ -8377,7 +8397,7 @@ // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "f", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -8399,7 +8419,8 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "ctorType": { @@ -8670,7 +8691,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (*)(NS::X)" +// CHECK-NEXT: "qualType": "void (*)(X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "FunctionToPointerDecay", @@ -8691,7 +8712,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "referencedDecl": { @@ -8699,7 +8720,7 @@ // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "f", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "foundReferencedDecl": { @@ -8726,7 +8747,8 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "ctorType": { @@ -9040,7 +9062,8 @@ // CHECK-NEXT: "isUsed": true, // CHECK-NEXT: "name": "x", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "init": "call", // CHECK-NEXT: "inner": [ @@ -9060,7 +9083,8 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "ctorType": { @@ -9110,7 +9134,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (*)(NS::X)" +// CHECK-NEXT: "qualType": "void (*)(X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "FunctionToPointerDecay", @@ -9131,7 +9155,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "referencedDecl": { @@ -9139,7 +9163,7 @@ // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "f", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (NS::X)" +// CHECK-NEXT: "qualType": "void (X)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -9161,7 +9185,8 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "ctorType": { @@ -9207,7 +9232,8 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", // CHECK-NEXT: "referencedDecl": { @@ -9215,7 +9241,8 @@ // CHECK-NEXT: "kind": "VarDecl", // CHECK-NEXT: "name": "x", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "NS::X" +// CHECK-NEXT: "desugaredQualType": "NS::X", +// CHECK-NEXT: "qualType": "X" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/clang/test/AST/ast-dump-expr.cpp b/clang/test/AST/ast-dump-expr.cpp --- a/clang/test/AST/ast-dump-expr.cpp +++ b/clang/test/AST/ast-dump-expr.cpp @@ -59,7 +59,7 @@ void PointerToMember(S obj1, S *obj2, int S::* data, void (S::*call)(int)) { obj1.*data; // CHECK: BinaryOperator 0x{{[^ ]*}} 'int' lvalue '.*' - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S':'S' // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int S::*' lvalue ParmVar 0x{{[^ ]*}} 'data' 'int S::*' @@ -74,7 +74,7 @@ // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} 'void' // CHECK-NEXT: ParenExpr 0x{{[^ ]*}} '' // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} '' '.*' - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'obj1' 'S':'S' // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'void (S::*)(int)' lvalue ParmVar 0x{{[^ ]*}} 'call' 'void (S::*)(int)' // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 @@ -91,20 +91,18 @@ } void Casting(const S *s) { - // FIXME: The cast expressions contain "struct S" instead of "S". - const_cast(s); - // CHECK: CXXConstCastExpr 0x{{[^ ]*}} 'S *' const_cast + // CHECK: CXXConstCastExpr 0x{{[^ ]*}} 'S *' const_cast // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} 'const S *' part_of_explicit_cast // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' static_cast(s); - // CHECK: CXXStaticCastExpr 0x{{[^ ]*}} 'const T *' static_cast + // CHECK: CXXStaticCastExpr 0x{{[^ ]*}} 'const T *' static_cast // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} 'const S *' part_of_explicit_cast // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' dynamic_cast(s); - // CHECK: CXXDynamicCastExpr 0x{{[^ ]*}} 'const T *' dynamic_cast + // CHECK: CXXDynamicCastExpr 0x{{[^ ]*}} 'const T *' dynamic_cast // CHECK-NEXT: ImplicitCastExpr 0x{{[^ ]*}} 'const S *' part_of_explicit_cast // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'const S *' lvalue ParmVar 0x{{[^ ]*}} 's' 'const S *' @@ -180,7 +178,7 @@ a.func(0); // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} 'void' // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} '' .func 0x{{[^ ]*}} - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S':'S' // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 0 p->func(0); @@ -201,7 +199,7 @@ a.template foo(); // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} 'float':'float' // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} '' .foo 0x{{[^ ]*}} - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S':'S' p->~S(); // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} 'void' @@ -212,14 +210,14 @@ a.~S(); // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} 'void' // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} '' .~S 0x{{[^ ]*}} - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S':'S' // FIXME: there seems to be no way to distinguish the construct below from // the construct above. a.~decltype(a)(); // CHECK: CXXMemberCallExpr 0x{{[^ ]*}} 'void' // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} '' .~S 0x{{[^ ]*}} - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S':'S' // FIXME: similarly, there is no way to distinguish the construct below from // the p->~S() case. @@ -238,7 +236,7 @@ typeid(a); // CHECK: CXXTypeidExpr 0x{{[^ ]*}} 'const std::type_info' lvalue - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'S':'S' lvalue ParmVar 0x{{[^ ]*}} 'a' 'S':'S' // FIXME: no type information is printed for the argument. typeid(S); diff --git a/clang/test/AST/ast-dump-funcs.cpp b/clang/test/AST/ast-dump-funcs.cpp --- a/clang/test/AST/ast-dump-funcs.cpp +++ b/clang/test/AST/ast-dump-funcs.cpp @@ -32,7 +32,7 @@ // CHECK-NEXT: CXXCtorInitializer Field 0x{{[^ ]*}} 'j' 'int' // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 0 // CHECK-NEXT: CXXCtorInitializer Field 0x{{[^ ]*}} 'r' 'R' - // CHECK-NEXT: CXXConstructExpr 0x{{[^ ]*}} 'R' 'void () noexcept' + // CHECK-NEXT: CXXConstructExpr 0x{{[^ ]*}} 'R':'R' 'void () noexcept' // CHECK-NEXT: CompoundStmt 0x{{[^ ]*}} void a(); diff --git a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp --- a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp +++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp @@ -114,7 +114,7 @@ // CHECK-NEXT: | | |-DeclStmt [[ADDR_44:0x[a-z0-9]*]] // CHECK-NEXT: | | | `-VarDecl [[ADDR_45:0x[a-z0-9]*]] col:10 referenced t 'double' // CHECK-NEXT: | | |-DeclStmt [[ADDR_46:0x[a-z0-9]*]] -// CHECK-NEXT: | | | `-VarDecl [[ADDR_47:0x[a-z0-9]*]] col:8 q 'S' callinit +// CHECK-NEXT: | | | `-VarDecl [[ADDR_47:0x[a-z0-9]*]] col:8 q 'S':'S' callinit // CHECK-NEXT: | | | `-ParenListExpr [[ADDR_48:0x[a-z0-9]*]] 'NULL TYPE' // CHECK-NEXT: | | | |-IntegerLiteral [[ADDR_49:0x[a-z0-9]*]] 'int' 1 // CHECK-NEXT: | | | `-UnaryOperator [[ADDR_50:0x[a-z0-9]*]] 'double *' prefix '&' cannot overflow @@ -149,7 +149,7 @@ // CHECK-NEXT: | | |-DeclStmt [[ADDR_72:0x[a-z0-9]*]] // CHECK-NEXT: | | | `-VarDecl [[ADDR_73:0x[a-z0-9]*]] col:5 referenced t 'T' // CHECK-NEXT: | | |-DeclStmt [[ADDR_74:0x[a-z0-9]*]] -// CHECK-NEXT: | | | `-VarDecl [[ADDR_75:0x[a-z0-9]*]] col:8 q 'S' callinit +// CHECK-NEXT: | | | `-VarDecl [[ADDR_75:0x[a-z0-9]*]] col:8 q 'S':'S' callinit // CHECK-NEXT: | | | `-ParenListExpr [[ADDR_76:0x[a-z0-9]*]] 'NULL TYPE' // CHECK-NEXT: | | | |-IntegerLiteral [[ADDR_77:0x[a-z0-9]*]] 'int' 0 // CHECK-NEXT: | | | `-UnaryOperator [[ADDR_78:0x[a-z0-9]*]] '' prefix '&' cannot overflow @@ -185,7 +185,7 @@ // CHECK-NEXT: | |-DeclStmt [[ADDR_101:0x[a-z0-9]*]] // CHECK-NEXT: | | `-VarDecl [[ADDR_102:0x[a-z0-9]*]] col:10 referenced t 'double' // CHECK-NEXT: | |-DeclStmt [[ADDR_103:0x[a-z0-9]*]] -// CHECK-NEXT: | | `-VarDecl [[ADDR_104:0x[a-z0-9]*]] col:8 q 'S' callinit +// CHECK-NEXT: | | `-VarDecl [[ADDR_104:0x[a-z0-9]*]] col:8 q 'S':'S' callinit // CHECK-NEXT: | | `-ParenListExpr [[ADDR_105:0x[a-z0-9]*]] 'NULL TYPE' // CHECK-NEXT: | | |-FloatingLiteral [[ADDR_106:0x[a-z0-9]*]] 'double' 2.000000e+00 // CHECK-NEXT: | | `-UnaryOperator [[ADDR_107:0x[a-z0-9]*]] 'double *' prefix '&' cannot overflow diff --git a/clang/test/AST/ast-dump-overloaded-operators.cpp b/clang/test/AST/ast-dump-overloaded-operators.cpp --- a/clang/test/AST/ast-dump-overloaded-operators.cpp +++ b/clang/test/AST/ast-dump-overloaded-operators.cpp @@ -31,14 +31,14 @@ // CHECK-NEXT: |-CXXOperatorCallExpr {{.*}} 'void' '+' // CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'void (*)(E, E)' // CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'void (E, E)' lvalue Function {{.*}} 'operator+' 'void (E, E)' -// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'E' -// CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' -// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'E' -// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' +// CHECK-NEXT: | |-ImplicitCastExpr {{.*}} 'E':'E' +// CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'E':'E' lvalue Var {{.*}} 'e' 'E':'E' +// CHECK-NEXT: | `-ImplicitCastExpr {{.*}} 'E':'E' +// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'E':'E' lvalue Var {{.*}} 'e' 'E':'E' // CHECK-NEXT: `-CXXOperatorCallExpr {{.*}} 'void' ',' // CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'void (*)(E, E)' // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'void (E, E)' lvalue Function {{.*}} 'operator,' 'void (E, E)' -// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'E' -// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' -// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'E' -// CHECK-NEXT: `-DeclRefExpr {{.*}} 'E' lvalue Var {{.*}} 'e' 'E' +// CHECK-NEXT: |-ImplicitCastExpr {{.*}} 'E':'E' +// CHECK-NEXT: | `-DeclRefExpr {{.*}} 'E':'E' lvalue Var {{.*}} 'e' 'E':'E' +// CHECK-NEXT: `-ImplicitCastExpr {{.*}} 'E':'E' +// CHECK-NEXT: `-DeclRefExpr {{.*}} 'E':'E' lvalue Var {{.*}} 'e' 'E':'E' diff --git a/clang/test/AST/ast-dump-records-json.cpp b/clang/test/AST/ast-dump-records-json.cpp --- a/clang/test/AST/ast-dump-records-json.cpp +++ b/clang/test/AST/ast-dump-records-json.cpp @@ -3266,6 +3266,7 @@ // CHECK-NEXT: { // CHECK-NEXT: "access": "public", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base1", // CHECK-NEXT: "qualType": "Base1" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "none" @@ -3377,6 +3378,7 @@ // CHECK-NEXT: { // CHECK-NEXT: "access": "private", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base1", // CHECK-NEXT: "qualType": "Base1" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "private" @@ -3477,6 +3479,7 @@ // CHECK-NEXT: "access": "public", // CHECK-NEXT: "isVirtual": true, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base1", // CHECK-NEXT: "qualType": "Base1" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "none" @@ -3715,6 +3718,7 @@ // CHECK-NEXT: { // CHECK-NEXT: "access": "public", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base1", // CHECK-NEXT: "qualType": "Base1" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "none" @@ -3723,6 +3727,7 @@ // CHECK-NEXT: "access": "public", // CHECK-NEXT: "isVirtual": true, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base2", // CHECK-NEXT: "qualType": "Base2" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "none" @@ -3730,6 +3735,7 @@ // CHECK-NEXT: { // CHECK-NEXT: "access": "protected", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base3", // CHECK-NEXT: "qualType": "Base3" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "protected" @@ -3969,6 +3975,7 @@ // CHECK-NEXT: "access": "protected", // CHECK-NEXT: "isVirtual": true, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Base1", // CHECK-NEXT: "qualType": "Base1" // CHECK-NEXT: }, // CHECK-NEXT: "writtenAccess": "protected" diff --git a/clang/test/AST/ast-dump-recovery.cpp b/clang/test/AST/ast-dump-recovery.cpp --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -145,7 +145,7 @@ // CHECK-NEXT: | `-DeclRefExpr {{.*}} 'f' // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1 f.func(1); - // CHECK: RecoveryExpr {{.*}} 'Foo2::ForwardClass' + // CHECK: RecoveryExpr {{.*}} 'ForwardClass':'Foo2::ForwardClass' // CHECK-NEXT: `-MemberExpr {{.*}} '' .createFwd // CHECK-NEXT: `-DeclRefExpr {{.*}} 'f' f.createFwd(); @@ -202,27 +202,27 @@ // CHECK-NEXT: `-InitListExpr Bar b2 = {1}; // CHECK: `-VarDecl {{.*}} b3 'Bar' - // CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar' contains-errors + // CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar':'Bar' contains-errors // CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int' Bar b3 = Bar(x); // CHECK: `-VarDecl {{.*}} b4 'Bar' - // CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar' contains-errors + // CHECK-NEXT: `-RecoveryExpr {{.*}} 'Bar':'Bar' contains-errors // CHECK-NEXT: `-InitListExpr {{.*}} 'void' // CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int' Bar b4 = Bar{x}; // CHECK: `-VarDecl {{.*}} b5 'Bar' - // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar' contains-errors 'Bar' + // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar':'Bar' contains-errors 'Bar' // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid' Bar b5 = Bar(invalid()); // CHECK: `-VarDecl {{.*}} b6 'Bar' - // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar' contains-errors 'Bar' + // CHECK-NEXT: `-CXXUnresolvedConstructExpr {{.*}} 'Bar':'Bar' contains-errors 'Bar' // CHECK-NEXT: `-InitListExpr {{.*}} contains-errors // CHECK-NEXT: `-RecoveryExpr {{.*}} contains-errors // CHECK-NEXT: `-UnresolvedLookupExpr {{.*}} 'invalid' Bar b6 = Bar{invalid()}; - // CHECK: RecoveryExpr {{.*}} 'Bar' contains-errors + // CHECK: RecoveryExpr {{.*}} 'Bar':'Bar' contains-errors // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1 Bar(1); @@ -326,7 +326,7 @@ // CHECK-NEXT: | `-RecoveryExpr {{.*}} '' // CHECK-NEXT: | `-UnresolvedLookupExpr {{.*}} '' // CHECK-NEXT: |-CXXCtorInitializer Field {{.*}} 's' 'S' - // CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S' contains-errors + // CHECK-NEXT: | `-RecoveryExpr {{.*}} 'S':'S' contains-errors // CHECK-NEXT: | |-IntegerLiteral {{.*}} 1 // CHECK-NEXT: | `-IntegerLiteral {{.*}} 2 }; diff --git a/clang/test/AST/ast-dump-stmt-json.cpp b/clang/test/AST/ast-dump-stmt-json.cpp --- a/clang/test/AST/ast-dump-stmt-json.cpp +++ b/clang/test/AST/ast-dump-stmt-json.cpp @@ -2257,6 +2257,7 @@ // CHECK-NEXT: "isReferenced": true, // CHECK-NEXT: "name": "obj", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2322,6 +2323,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -2330,6 +2332,7 @@ // CHECK-NEXT: "kind": "VarDecl", // CHECK-NEXT: "name": "obj", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2418,6 +2421,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -2426,6 +2430,7 @@ // CHECK-NEXT: "kind": "VarDecl", // CHECK-NEXT: "name": "obj", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2580,6 +2585,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -2588,6 +2594,7 @@ // CHECK-NEXT: "kind": "VarDecl", // CHECK-NEXT: "name": "obj", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "DependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "DependentScopeMemberExprWrapper" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2764,6 +2771,7 @@ // CHECK-NEXT: "isReferenced": true, // CHECK-NEXT: "name": "obj", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "OtherDependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "OtherDependentScopeMemberExprWrapper" // CHECK-NEXT: } // CHECK-NEXT: } @@ -2851,6 +2859,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "OtherDependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "OtherDependentScopeMemberExprWrapper" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -2859,6 +2868,7 @@ // CHECK-NEXT: "kind": "VarDecl", // CHECK-NEXT: "name": "obj", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "OtherDependentScopeMemberExprWrapper", // CHECK-NEXT: "qualType": "OtherDependentScopeMemberExprWrapper" // CHECK-NEXT: } // CHECK-NEXT: } @@ -3019,6 +3029,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "U", // CHECK-NEXT: "qualType": "U" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", @@ -3047,6 +3058,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "U", // CHECK-NEXT: "qualType": "U" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", @@ -5140,6 +5152,7 @@ // CHECK-NEXT: "isUsed": true, // CHECK-NEXT: "name": "C", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Container", // CHECK-NEXT: "qualType": "Container" // CHECK-NEXT: }, // CHECK-NEXT: "init": "call", @@ -5160,6 +5173,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Container", // CHECK-NEXT: "qualType": "Container" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", @@ -5253,6 +5267,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Container", // CHECK-NEXT: "qualType": "Container" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -5261,6 +5276,7 @@ // CHECK-NEXT: "kind": "VarDecl", // CHECK-NEXT: "name": "C", // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Container", // CHECK-NEXT: "qualType": "Container" // CHECK-NEXT: } // CHECK-NEXT: } @@ -5394,6 +5410,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Container", // CHECK-NEXT: "qualType": "Container" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -5541,6 +5558,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Container", // CHECK-NEXT: "qualType": "Container" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", diff --git a/clang/test/AST/ast-dump-stmt.cpp b/clang/test/AST/ast-dump-stmt.cpp --- a/clang/test/AST/ast-dump-stmt.cpp +++ b/clang/test/AST/ast-dump-stmt.cpp @@ -99,8 +99,8 @@ U us[3] = {1}; // CHECK: VarDecl {{.+}} col:5 us 'U[3]' cinit // CHECK-NEXT: `-InitListExpr {{.+}} 'U[3]' -// CHECK-NEXT: |-array_filler: InitListExpr {{.+}} 'U' field Field {{.+}} 'i' 'int' -// CHECK-NEXT: `-InitListExpr {{.+}} 'U' field Field {{.+}} 'i' 'int' +// CHECK-NEXT: |-array_filler: InitListExpr {{.+}} 'U':'U' field Field {{.+}} 'i' 'int' +// CHECK-NEXT: `-InitListExpr {{.+}} 'U':'U' field Field {{.+}} 'i' 'int' // CHECK-NEXT: `-IntegerLiteral {{.+}} 'int' 1 } @@ -229,19 +229,19 @@ // CHECK-NEXT: <<>> // CHECK-NEXT: DeclStmt // CHECK-NEXT: VarDecl 0x{{[^ ]*}} col:16 implicit used __range1 'Container &' cinit - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'Container' lvalue Var 0x{{[^ ]*}} 'C' 'Container' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'Container':'Container' lvalue Var 0x{{[^ ]*}} 'C' 'Container':'Container' // CHECK-NEXT: DeclStmt // CHECK-NEXT: VarDecl 0x{{[^ ]*}} col:14 implicit used __begin1 'int *':'int *' cinit // CHECK-NEXT: CXXMemberCallExpr 0x{{[^ ]*}} 'int *' // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} '' .begin 0x{{[^ ]*}} // CHECK-NEXT: ImplicitCastExpr - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'Container' lvalue Var 0x{{[^ ]*}} '__range1' 'Container &' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'Container':'Container' lvalue Var 0x{{[^ ]*}} '__range1' 'Container &' // CHECK-NEXT: DeclStmt // CHECK-NEXT: VarDecl 0x{{[^ ]*}} col:14 implicit used __end1 'int *':'int *' cinit // CHECK-NEXT: CXXMemberCallExpr 0x{{[^ ]*}} 'int *' // CHECK-NEXT: MemberExpr 0x{{[^ ]*}} '' .end 0x{{[^ ]*}} // CHECK-NEXT: ImplicitCastExpr - // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'Container' lvalue Var 0x{{[^ ]*}} '__range1' 'Container &' + // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'Container':'Container' lvalue Var 0x{{[^ ]*}} '__range1' 'Container &' // CHECK-NEXT: BinaryOperator 0x{{[^ ]*}} 'bool' '!=' // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int *':'int *' lvalue Var 0x{{[^ ]*}} '__begin1' 'int *':'int *' diff --git a/clang/test/AST/ast-dump-template-decls-json.cpp b/clang/test/AST/ast-dump-template-decls-json.cpp --- a/clang/test/AST/ast-dump-template-decls-json.cpp +++ b/clang/test/AST/ast-dump-template-decls-json.cpp @@ -826,6 +826,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "Uy", // CHECK-NEXT: "qualType": "Uy" // CHECK-NEXT: } // CHECK-NEXT: } diff --git a/clang/test/AST/ast-dump-temporaries-json.cpp b/clang/test/AST/ast-dump-temporaries-json.cpp --- a/clang/test/AST/ast-dump-temporaries-json.cpp +++ b/clang/test/AST/ast-dump-temporaries-json.cpp @@ -36,6 +36,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "const S", // CHECK-NEXT: "qualType": "const S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -57,6 +58,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "const S", // CHECK-NEXT: "qualType": "const S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "lvalue", @@ -87,6 +89,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "const S", // CHECK-NEXT: "qualType": "const S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", @@ -108,6 +111,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", @@ -137,6 +141,7 @@ // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "type": { +// CHECK-NEXT: "desugaredQualType": "S", // CHECK-NEXT: "qualType": "S" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", diff --git a/clang/test/AST/ast-dump-using-template.cpp b/clang/test/AST/ast-dump-using-template.cpp --- a/clang/test/AST/ast-dump-using-template.cpp +++ b/clang/test/AST/ast-dump-using-template.cpp @@ -16,20 +16,23 @@ template using A = S; // CHECK: TypeAliasDecl -// CHECK-NEXT: `-TemplateSpecializationType {{.*}} 'S' dependent using S +// CHECK-NEXT: `-ElaboratedType {{.*}} 'S' sugar dependent +// CHECK-NEXT: `-TemplateSpecializationType {{.*}} 'S' dependent using S // TemplateName in TemplateArgument. template