From bdc6974f92304f4ed542241b9b89ba58ba6b20aa Mon Sep 17 00:00:00 2001 From: Matheus Izvekov Date: Mon, 11 Oct 2021 18:15:36 +0200 Subject: [PATCH] [clang] Implement ElaboratedType sugaring for types written bare Without this patch, clang will not wrap in an ElaboratedType node types written without a keyword and nested name qualifier, which goes against the intent that we should produce an AST which retains enough details to recover how things are written. The lack of this sugar is incompatible with the intent of the type printer default policy, which is to print types as written, but to fall back and print them fully qualified when they are desugared. An ElaboratedTypeLoc without keyword / NNS uses no storage by itself, but still requires pointer alignment due to pre-existing bug in the TypeLoc buffer handling. Signed-off-by: Matheus Izvekov Differential Revision: https://reviews.llvm.org/D112374 --- .../ChangeNamespace.cpp | 14 +- .../find-all-symbols/FindAllSymbols.cpp | 3 +- .../bugprone/SizeofExpressionCheck.cpp | 10 +- .../bugprone/SmartPtrArrayMismatchCheck.cpp | 11 +- .../google/AvoidCStyleCastsCheck.cpp | 7 +- .../hicpp/MultiwayPathsCoveredCheck.cpp | 3 +- .../clang-tidy/misc/MisplacedConstCheck.cpp | 13 +- .../clang-tidy/modernize/LoopConvertCheck.cpp | 2 +- .../clang-tidy/modernize/PassByValueCheck.cpp | 3 +- .../modernize/UseEqualsDefaultCheck.cpp | 34 +- .../modernize/UseTrailingReturnTypeCheck.cpp | 4 +- clang-tools-extra/clangd/FindTarget.cpp | 5 +- .../clangd/unittests/ASTTests.cpp | 20 +- .../clangd/unittests/DumpASTTests.cpp | 3 +- .../clangd/unittests/FindTargetTests.cpp | 11 +- .../clangd/unittests/HoverTests.cpp | 22 +- .../bugprone/copy-constructor-init.cpp | 3 +- .../bugprone/shared-ptr-array-mismatch.cpp | 2 + .../suspicious-memory-comparison-32bits.cpp | 2 +- .../bugprone/suspicious-memory-comparison.cpp | 22 +- .../readability/const-return-type.cpp | 4 +- .../ChangeNamespaceTests.cpp | 2 +- .../bindings/python/tests/cindex/test_type.py | 2 +- clang/include/clang/AST/ASTContext.h | 6 + clang/include/clang/AST/Type.h | 3 - clang/include/clang/AST/TypeLoc.h | 43 +- clang/lib/ARCMigrate/ObjCMT.cpp | 7 +- clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/AST/ASTDiagnostic.cpp | 18 +- clang/lib/AST/DeclCXX.cpp | 2 +- clang/lib/AST/ExprCXX.cpp | 4 +- clang/lib/AST/FormatString.cpp | 13 +- clang/lib/AST/PrintfFormatString.cpp | 10 +- clang/lib/AST/QualTypeNames.cpp | 15 +- clang/lib/AST/ScanfFormatString.cpp | 2 +- clang/lib/AST/Type.cpp | 15 +- clang/lib/AST/TypeLoc.cpp | 12 +- clang/lib/Analysis/RetainSummaryManager.cpp | 2 +- clang/lib/CodeGen/CGCall.cpp | 2 +- clang/lib/CodeGen/CGExprScalar.cpp | 5 +- clang/lib/CodeGen/CodeGenFunction.cpp | 5 +- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- .../Frontend/Rewrite/RewriteModernObjC.cpp | 8 +- clang/lib/Sema/SemaChecking.cpp | 4 +- clang/lib/Sema/SemaCodeComplete.cpp | 2 +- clang/lib/Sema/SemaDecl.cpp | 76 +-- clang/lib/Sema/SemaDeclCXX.cpp | 33 +- clang/lib/Sema/SemaExpr.cpp | 4 +- clang/lib/Sema/SemaExprCXX.cpp | 18 +- clang/lib/Sema/SemaExprObjC.cpp | 6 +- clang/lib/Sema/SemaTemplate.cpp | 26 +- clang/lib/Sema/SemaType.cpp | 31 +- clang/lib/Sema/TreeTransform.h | 16 +- clang/lib/Sema/TypeLocBuilder.cpp | 9 +- clang/lib/Sema/TypeLocBuilder.h | 8 +- .../NonnullGlobalConstantsChecker.cpp | 15 +- .../NumberObjectConversionChecker.cpp | 21 +- .../Tooling/DumpTool/ASTSrcLocProcessor.cpp | 2 +- .../test/AST/ast-dump-APValue-anon-union.cpp | 10 +- clang/test/AST/ast-dump-APValue-struct.cpp | 12 +- clang/test/AST/ast-dump-APValue-union.cpp | 10 +- clang/test/AST/ast-dump-decl.cpp | 12 +- clang/test/AST/ast-dump-expr-json.cpp | 67 +- clang/test/AST/ast-dump-expr.cpp | 22 +- clang/test/AST/ast-dump-funcs.cpp | 2 +- ...penmp-begin-declare-variant_template_3.cpp | 6 +- .../AST/ast-dump-overloaded-operators.cpp | 16 +- clang/test/AST/ast-dump-records-json.cpp | 7 + clang/test/AST/ast-dump-recovery.cpp | 14 +- clang/test/AST/ast-dump-stmt-json.cpp | 18 + clang/test/AST/ast-dump-stmt.cpp | 10 +- .../test/AST/ast-dump-template-decls-json.cpp | 1 + clang/test/AST/ast-dump-temporaries-json.cpp | 5 + clang/test/AST/ast-dump-using-template.cpp | 15 +- clang/test/AST/ast-dump-using.cpp | 7 +- ...coroutine-locals-cleanup-exp-namespace.cpp | 8 +- clang/test/AST/coroutine-locals-cleanup.cpp | 8 +- clang/test/AST/float16.cpp | 8 +- clang/test/AST/sourceranges.cpp | 8 +- .../NewDelete-path-notes.cpp.plist | 2 +- .../expected-plists/cxx-for-range.cpp.plist | 2 +- .../method-call-path-notes.cpp.plist | 4 +- .../Analysis/analyzer-display-progress.cpp | 2 +- .../Analysis/auto-obj-dtors-cfg-output.cpp | 382 ++++++------ clang/test/Analysis/blocks.mm | 8 +- clang/test/Analysis/bug_hash_test.cpp | 2 +- clang/test/Analysis/cast-value-notes.cpp | 4 +- clang/test/Analysis/cast-value-state-dump.cpp | 4 +- clang/test/Analysis/cfg-rich-constructors.cpp | 574 +++++++++--------- clang/test/Analysis/cfg-rich-constructors.mm | 14 +- clang/test/Analysis/cfg.cpp | 44 +- clang/test/Analysis/copy-elision.cpp | 16 +- .../cxx-uninitialized-object-inheritance.cpp | 6 +- clang/test/Analysis/dump_egraph.cpp | 2 +- .../exploded-graph-rewriter/dynamic_types.cpp | 4 +- .../test/Analysis/initializers-cfg-output.cpp | 44 +- .../expected-plists/path-notes.cpp.plist | 12 +- clang/test/Analysis/lambdas.cpp | 4 +- clang/test/Analysis/lifetime-cfg-output.cpp | 94 +-- clang/test/Analysis/malloc-sizeof.cpp | 4 +- clang/test/Analysis/memory-model.cpp | 8 +- .../test/Analysis/missing-bind-temporary.cpp | 18 +- clang/test/Analysis/more-dtors-cfg-output.cpp | 50 +- clang/test/Analysis/scopes-cfg-output.cpp | 106 ++-- .../Analysis/temp-obj-dtors-cfg-output.cpp | 410 ++++++------- .../basic.lookup/basic.lookup.argdep/p4.cpp | 2 +- .../basic.lookup.qual/namespace.qual/p2.cpp | 4 +- clang/test/CXX/class.access/p4.cpp | 40 +- .../class.compare.default/p1.cpp | 4 +- .../CXX/class/class.compare/class.eq/p2.cpp | 2 +- .../class.compare/class.spaceship/p1.cpp | 2 +- .../class.compare/class.spaceship/p2.cpp | 2 +- .../class.init/class.copy.elision/p3.cpp | 24 +- clang/test/CXX/class/class.mem/p2.cpp | 2 +- clang/test/CXX/conv/conv.fctptr/p1.cpp | 2 +- clang/test/CXX/conv/conv.mem/p4.cpp | 2 +- .../dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp | 4 +- clang/test/CXX/dcl.decl/dcl.decomp/p4.cpp | 14 +- .../dcl.fct.def/dcl.fct.def.default/p2.cpp | 2 +- .../dcl.decl/dcl.init/dcl.init.list/p3.cpp | 6 +- .../dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp | 8 +- clang/test/CXX/drs/dr0xx.cpp | 6 +- clang/test/CXX/drs/dr13xx.cpp | 2 +- clang/test/CXX/drs/dr16xx.cpp | 2 +- clang/test/CXX/drs/dr17xx.cpp | 2 +- clang/test/CXX/drs/dr1xx.cpp | 4 +- clang/test/CXX/drs/dr2xx.cpp | 12 +- clang/test/CXX/drs/dr3xx.cpp | 4 +- clang/test/CXX/drs/dr4xx.cpp | 8 +- clang/test/CXX/drs/dr5xx.cpp | 2 +- clang/test/CXX/drs/dr9xx.cpp | 2 +- clang/test/CXX/except/except.spec/p1.cpp | 2 +- clang/test/CXX/expr/expr.const/p2-0x.cpp | 2 +- clang/test/CXX/expr/expr.const/p5-0x.cpp | 2 +- .../expr/expr.prim/expr.prim.lambda/p14.cpp | 4 +- .../over.match.class.deduct/p2.cpp | 2 +- .../over.match.funcs/over.match.copy/p1.cpp | 2 +- .../over.match.oper/p3-2a.cpp | 14 +- .../over.match.oper/p9-2a.cpp | 2 +- .../test/CXX/special/class.copy/p23-cxx11.cpp | 2 +- .../test/CXX/special/class.copy/p3-cxx11.cpp | 2 +- clang/test/CXX/special/class.inhctor/p4.cpp | 2 +- clang/test/CXX/special/class.temporary/p1.cpp | 2 +- .../stmt.stmt/stmt.iter/stmt.ranged/p1.cpp | 4 +- .../CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp | 4 +- clang/test/CodeGen/builtin-bpf-btf-type-id.c | 2 +- .../builtins-bpf-preserve-field-info-3.c | 2 +- ...nvirtual-inheritance-return-adjustment.cpp | 80 +-- .../microsoft-abi-vtables-return-thunks.cpp | 44 +- ...rosoft-abi-vtables-virtual-inheritance.cpp | 26 +- clang/test/CodeGenCXX/predefined-expr.cpp | 10 +- clang/test/CodeGenCXX/vtable-layout.cpp | 40 +- clang/test/FixIt/fixit.cpp | 4 +- .../test/Index/annotate-context-sensitive.cpp | 2 +- clang/test/Index/comment-cplus-decls.cpp | 4 +- clang/test/Index/keep-going.cpp | 4 +- clang/test/Index/load-stmts.cpp | 8 +- clang/test/Index/opencl-types.cl | 16 +- clang/test/Index/paren-type.c | 2 +- clang/test/Index/print-type-size.cpp | 12 +- clang/test/Index/print-type.c | 10 +- clang/test/Index/print-type.cpp | 32 +- clang/test/Layout/aix-bitfield-alignment.cpp | 2 +- .../Layout/aix-power-alignment-typedef.cpp | 8 +- clang/test/Layout/dump-canonical.cpp | 4 +- clang/test/Layout/ms-x86-basic-layout.cpp | 12 +- clang/test/Layout/ms-x86-misalignedarray.cpp | 4 +- clang/test/Misc/diag-line-wrapping.cpp | 4 +- clang/test/Misc/diag-template-diffing.cpp | 4 +- clang/test/Modules/namespaces.cpp | 4 +- clang/test/Modules/odr_hash-gnu.cpp | 2 +- clang/test/Modules/odr_hash.cpp | 46 +- .../test/OpenMP/declare_mapper_ast_print.cpp | 8 +- .../OpenMP/declare_reduction_ast_print.cpp | 2 +- clang/test/OpenMP/deferred-diags.cpp | 2 +- clang/test/PCH/cxx_exprs.cpp | 2 +- clang/test/Parser/cxx1z-decomposition.cpp | 2 +- clang/test/SemaCXX/MicrosoftCompatibility.cpp | 4 +- clang/test/SemaCXX/abstract.cpp | 8 +- clang/test/SemaCXX/access-base-class.cpp | 6 +- clang/test/SemaCXX/accessible-base.cpp | 6 +- .../test/SemaCXX/aggregate-initialization.cpp | 2 +- .../ambig-user-defined-conversions.cpp | 4 +- clang/test/SemaCXX/atomic-type.cpp | 2 +- clang/test/SemaCXX/attr-noreturn.cpp | 6 +- clang/test/SemaCXX/builtins.cpp | 2 +- clang/test/SemaCXX/calling-conv-compat.cpp | 44 +- clang/test/SemaCXX/class-base-member-init.cpp | 2 +- clang/test/SemaCXX/class.cpp | 2 +- clang/test/SemaCXX/co_await-ast.cpp | 48 +- clang/test/SemaCXX/compound-literal.cpp | 36 +- .../SemaCXX/constant-expression-cxx11.cpp | 32 +- .../SemaCXX/constant-expression-cxx2a.cpp | 12 +- clang/test/SemaCXX/constant-expression.cpp | 2 +- .../constexpr-default-init-value-crash.cpp | 2 +- .../test/SemaCXX/constructor-initializer.cpp | 12 +- clang/test/SemaCXX/conversion-function.cpp | 4 +- clang/test/SemaCXX/copy-initialization.cpp | 2 +- clang/test/SemaCXX/cstyle-cast.cpp | 4 +- clang/test/SemaCXX/cxx0x-class.cpp | 2 +- .../SemaCXX/cxx0x-initializer-aggregates.cpp | 2 +- .../SemaCXX/cxx0x-initializer-constructor.cpp | 6 +- .../SemaCXX/cxx0x-initializer-references.cpp | 8 +- .../cxx0x-initializer-stdinitializerlist.cpp | 2 +- clang/test/SemaCXX/cxx0x-nontrivial-union.cpp | 2 +- clang/test/SemaCXX/cxx11-inheriting-ctors.cpp | 2 +- clang/test/SemaCXX/cxx17-compat.cpp | 4 +- .../cxx1y-contextual-conversion-tweaks.cpp | 14 +- .../test/SemaCXX/cxx2a-destroying-delete.cpp | 6 +- clang/test/SemaCXX/cxx98-compat-flags.cpp | 8 +- clang/test/SemaCXX/cxx98-compat-pedantic.cpp | 8 +- clang/test/SemaCXX/decl-init-ref.cpp | 2 +- .../SemaCXX/default-assignment-operator.cpp | 4 +- clang/test/SemaCXX/derived-to-base-ambig.cpp | 4 +- clang/test/SemaCXX/destructor.cpp | 4 +- clang/test/SemaCXX/dynamic-cast.cpp | 4 +- .../SemaCXX/elaborated-type-specifier.cpp | 2 +- clang/test/SemaCXX/enum-scoped.cpp | 8 +- clang/test/SemaCXX/enum.cpp | 4 +- clang/test/SemaCXX/exceptions.cpp | 24 +- clang/test/SemaCXX/for-range-examples.cpp | 2 +- clang/test/SemaCXX/function-extern-c.cpp | 6 +- clang/test/SemaCXX/functional-cast.cpp | 4 +- .../ignored-reference-qualifiers-disabled.cpp | 2 +- clang/test/SemaCXX/matrix-type-operators.cpp | 44 +- clang/test/SemaCXX/member-expr.cpp | 20 +- clang/test/SemaCXX/member-init.cpp | 4 +- clang/test/SemaCXX/microsoft-cxx0x.cpp | 2 +- clang/test/SemaCXX/microsoft-dtor-lookup.cpp | 2 +- clang/test/SemaCXX/new-array-size-conv.cpp | 2 +- clang/test/SemaCXX/new-delete.cpp | 2 +- .../test/SemaCXX/out-of-line-def-mismatch.cpp | 6 +- clang/test/SemaCXX/overload-0x.cpp | 6 +- clang/test/SemaCXX/overload-call.cpp | 6 +- clang/test/SemaCXX/overload-member-call.cpp | 10 +- clang/test/SemaCXX/overloaded-operator.cpp | 4 +- clang/test/SemaCXX/pseudo-destructors.cpp | 6 +- clang/test/SemaCXX/recovery-expr-type.cpp | 4 +- clang/test/SemaCXX/references.cpp | 4 +- clang/test/SemaCXX/static-cast.cpp | 4 +- clang/test/SemaCXX/switch.cpp | 2 +- clang/test/SemaCXX/type-traits.cpp | 2 +- clang/test/SemaCXX/undefined-internal.cpp | 2 +- clang/test/SemaCXX/underlying_type.cpp | 4 +- clang/test/SemaCXX/vector.cpp | 4 +- clang/test/SemaCXX/virtual-override.cpp | 24 +- clang/test/SemaCXX/warn-bad-memaccess.cpp | 2 +- clang/test/SemaCXX/warn-enum-compare.cpp | 10 +- clang/test/SemaCXX/warn-new-overaligned-3.cpp | 4 +- clang/test/SemaCXX/warn-new-overaligned.cpp | 12 +- .../SemaCXX/warn-reinterpret-base-class.cpp | 10 +- .../warn-reorder-ctor-initialization.cpp | 2 +- .../SemaCXX/warn-thread-safety-parsing.cpp | 2 +- clang/test/SemaHLSL/prohibit_pointer.hlsl | 2 +- clang/test/SemaObjCXX/arc-templates.mm | 4 +- clang/test/SemaObjCXX/blocks.mm | 2 +- clang/test/SemaSYCL/float128.cpp | 4 +- clang/test/SemaSYCL/int128.cpp | 4 +- clang/test/SemaTemplate/anonymous-union.cpp | 2 +- clang/test/SemaTemplate/attributes.cpp | 8 +- clang/test/SemaTemplate/deduction-guide.cpp | 14 +- .../SemaTemplate/default-expr-arguments-3.cpp | 6 +- clang/test/SemaTemplate/dependent-names.cpp | 6 +- clang/test/SemaTemplate/instantiate-self.cpp | 2 +- .../test/SemaTemplate/member-access-ambig.cpp | 2 +- .../test/SemaTemplate/member-access-expr.cpp | 2 +- .../ms-lookup-template-base-classes.cpp | 4 +- clang/test/SemaTemplate/pr52909.cpp | 4 +- clang/test/SemaTemplate/pr52970.cpp | 4 +- .../SemaTemplate/temp_arg_nontype_cxx1z.cpp | 2 +- .../SemaTemplate/temp_arg_nontype_cxx20.cpp | 6 +- .../SemaTemplate/virtual-member-functions.cpp | 8 +- clang/unittests/AST/ASTImporterTest.cpp | 64 +- clang/unittests/AST/ASTTraverserTest.cpp | 6 +- clang/unittests/AST/TypePrinterTest.cpp | 2 +- .../ASTMatchers/ASTMatchersNarrowingTest.cpp | 28 +- .../ASTMatchers/ASTMatchersNodeTest.cpp | 27 +- .../ASTMatchers/ASTMatchersTraversalTest.cpp | 112 ++-- .../Introspection/IntrospectionTest.cpp | 196 ++++-- clang/unittests/Sema/CodeCompleteTest.cpp | 6 +- clang/unittests/StaticAnalyzer/SValTest.cpp | 5 +- .../TestReturnValueUnderConstruction.cpp | 3 +- clang/unittests/Tooling/QualTypeNamesTest.cpp | 14 +- .../RecursiveASTVisitorTestTypeLocVisitor.cpp | 2 +- clang/unittests/Tooling/StencilTest.cpp | 5 +- 285 files changed, 2349 insertions(+), 2140 deletions(-) diff --git a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp index 59acc29e8ee9..26d31c669bcc 100644 --- a/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp +++ b/clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp @@ -567,14 +567,12 @@ void ChangeNamespaceTool::run( 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 index 70d4d7cfdff3..e000eae999bd 100644 --- 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 @@ void FindAllSymbols::registerMatchers(MatchFinder *MatchFinder) { // 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 index 4c537afd3347..e88b1846ef60 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -87,9 +87,9 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { 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 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { 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 index a706f6ce36b6..4b89f8291311 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp @@ -67,10 +67,11 @@ void SmartPtrArrayMismatchCheck::registerMatchers(MatchFinder *Finder) { 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 @@ void SmartPtrArrayMismatchCheck::check(const MatchFinder::MatchResult &Result) { 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 index 82804a670959..f1514c868f85 100644 --- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp @@ -130,7 +130,12 @@ void AvoidCStyleCastsCheck::check(const MatchFinder::MatchResult &Result) { // 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 index 7feb0c73f4d1..8b99a1058079 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -36,7 +36,8 @@ void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) { // 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 index 7a028df588ff..62df0884689f 100644 --- a/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp @@ -21,12 +21,13 @@ void MisplacedConstCheck::registerMatchers(MatchFinder *Finder) { 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 index accc95d126f8..679256839e43 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -400,7 +400,7 @@ static bool canBeModified(ASTContext *Context, const Expr *E) { 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 index cbfe528eaa7b..024a06bf3aa7 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -48,7 +48,8 @@ AST_MATCHER(CXXRecordDecl, isMoveConstructible) { 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 index 0f10dd375a80..c3e3759af32f 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -153,22 +153,24 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context, // ((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 index 8d6322563f79..a3908514d615 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp @@ -97,7 +97,9 @@ public: 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 index 408591589051..020f83b1a8fb 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -950,7 +950,10 @@ public: // 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 index 69285d019117..4bb3e025b87a 100644 --- a/clang-tools-extra/clangd/unittests/ASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp @@ -72,7 +72,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { template class Foo {}; ^auto v = Foo(); )cpp", - "Foo", + "Foo", }, { R"cpp( // auto on initializer list. @@ -93,7 +93,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // decltype in trailing return type @@ -102,7 +102,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // auto in function return type @@ -111,7 +111,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // auto& in function return type @@ -121,7 +121,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return x; } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // auto* in function return type @@ -131,7 +131,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return x; } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // const auto& in function return type @@ -141,7 +141,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return x; } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // decltype(auto) in function return (value) @@ -150,7 +150,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return Foo(); } )cpp", - "struct Foo", + "Foo", }, { R"cpp( // decltype(auto) in function return (ref) @@ -160,7 +160,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { return (x); } )cpp", - "struct Foo &", + "Foo &", }, { R"cpp( // decltype(auto) in function return (const ref) @@ -170,7 +170,7 @@ TEST(GetDeducedType, KwAutoKwDecltypeExpansion) { 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 index e7b368fd2552..d1b8f21b82c6 100644 --- a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp +++ b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp @@ -121,7 +121,8 @@ declaration: Var - root 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 index 51eae572ed90..6656ed984723 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -1612,13 +1612,14 @@ TEST_F(FindExplicitReferencesTest, All) { { 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 index 949ddbae58b3..53e4f55c2e3a 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -427,7 +427,7 @@ class Foo final {})cpp"; [](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 @@ class Foo final {})cpp"; 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 @@ class Foo final {})cpp"; 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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 @@ TEST(Hover, All) { [](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 index 981d0b5af742..b42d3fcd2b62 100644 --- 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 X11 : public Copyable5 { 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 @@ FROMMACRO 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 index a232b854530c..70449e6bfc24 100644 --- 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 @@ std::shared_ptr f_ret() { 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 index 1b70f79518dc..ebf96eebfb10 100644 --- 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 @@ struct S { 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 index f4406b222eeb..cef9a1c595d7 100644 --- 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 @@ public: 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 @@ struct S { 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 @@ class Derived2 : public Derived {}; 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 @@ public: 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 @@ struct S {}; 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 @@ struct S { 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 @@ struct S { 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 @@ struct S { 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 index a8642746145b..4b59cafb9f66 100644 --- 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 @@ class Clazz { }; 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 @@ class Clazz { // 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 index a8fbf3b7fe25..4a6352cd5975 100644 --- a/clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp +++ b/clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp @@ -2229,7 +2229,7 @@ TEST_F(ChangeNamespaceTest, InjectedClassNameInFriendDecl) { "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 index 0ef98e9555be..efe9b0f50be8 100644 --- a/clang/bindings/python/tests/cindex/test_type.py +++ b/clang/bindings/python/tests/cindex/test_type.py @@ -58,7 +58,7 @@ class TestType(unittest.TestCase): 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 index 85eba45e4de6..80de0bab2d9a 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2811,14 +2811,20 @@ public: 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 index 61c153b1f675..1a8cf27dab4b 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -5569,9 +5569,6 @@ class ElaboratedType final 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 index 6d7612b06adc..c93dcf8d8f2e 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -430,7 +430,7 @@ protected: 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 @@ class ElaboratedTypeLoc : public ConcreteTypeLoc { 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 @@ public: 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 index 3dfa9a0218a7..26f751b77f86 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -505,7 +505,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter, 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 @@ static bool TypeIsInnerPointer(QualType T) { // 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 @@ static bool IsVoidStarType(QualType Ty) { 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 index cfd7bf604542..4a9c9b97210a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -7816,7 +7816,7 @@ ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD, /// '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 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S, // 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 index 28269ec219e4..bb8bbc53cf4c 100644 --- a/clang/lib/AST/ASTDiagnostic.cpp +++ b/clang/lib/AST/ASTDiagnostic.cpp @@ -1684,9 +1684,24 @@ class TemplateDiff { : 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 @@ class TemplateDiff { } } + PrintTypes: if (PrintTree) OS << '['; OS << (FromDefault ? "(default) " : ""); Bold(); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 6fc9a86bc3cf..d936ea0aa7c1 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -2566,7 +2566,7 @@ SourceLocation CXXCtorInitializer::getSourceLocation() const { 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 index 891105692980..6328fa4a7dd5 100644 --- a/clang/lib/AST/ExprCXX.cpp +++ b/clang/lib/AST/ExprCXX.cpp @@ -314,7 +314,7 @@ QualType CXXDeleteExpr::getDestroyedType() const { // CXXPseudoDestructorExpr PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info) : Type(Info) { - Location = Info->getTypeLoc().getLocalSourceRange().getBegin(); + Location = Info->getTypeLoc().getBeginLoc(); } CXXPseudoDestructorExpr::CXXPseudoDestructorExpr( @@ -341,7 +341,7 @@ QualType CXXPseudoDestructorExpr::getDestroyedType() const { 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 index c0879704de4d..1a1dddcbacfd 100644 --- a/clang/lib/AST/FormatString.cpp +++ b/clang/lib/AST/FormatString.cpp @@ -981,10 +981,9 @@ Optional FormatSpecifier::getCorrectedLengthModifier() const { 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 @@ bool FormatSpecifier::namedTypeToLengthModifier(QualType QT, 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 index c6c41abc7e9a..d972c120ebac 100644 --- a/clang/lib/AST/PrintfFormatString.cpp +++ b/clang/lib/AST/PrintfFormatString.cpp @@ -844,7 +844,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, } // 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 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, // 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 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt, // 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 index 26aaa96a1dc6..8c736a718160 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -422,13 +422,6 @@ QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, 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 @@ QualType getFullyQualifiedType(QualType QT, const ASTContext &Ctx, 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 index 8d763f28e57f..7679f02e04ab 100644 --- a/clang/lib/AST/ScanfFormatString.cpp +++ b/clang/lib/AST/ScanfFormatString.cpp @@ -500,7 +500,7 @@ bool ScanfSpecifier::fixType(QualType QT, QualType RawQT, } // 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 index 0f168a518707..136af191f3c0 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -4320,20 +4320,13 @@ bool Type::isObjCARCImplicitlyUnretainedType() const { } 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 index cf5e2f979230..eb22bf5a0546 100644 --- a/clang/lib/AST/TypeLoc.cpp +++ b/clang/lib/AST/TypeLoc.cpp @@ -194,8 +194,14 @@ SourceLocation TypeLoc::getBeginLoc() const { 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 UnaryTransformTypeLoc::initializeLocal(ASTContext &Context, 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 index 9098cf370d4f..5e9c73534aeb 100644 --- a/clang/lib/Analysis/RetainSummaryManager.cpp +++ b/clang/lib/Analysis/RetainSummaryManager.cpp @@ -892,7 +892,7 @@ RetainSummaryManager::getRetEffectFromAnnotations(QualType RetTy, /// 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 index 104a30dd6b25..fa64a50d20cc 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2860,7 +2860,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, // 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 index b150aaa376eb..4f5e439bca8e 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -255,7 +255,7 @@ public: 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 @@ public: } 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 index 17c1c91c7e8f..89712ec8c7a5 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2214,7 +2214,6 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { 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 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { 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 index cf954b7b9277..a6d58aeef11b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1743,7 +1743,7 @@ void CodeGenModule::GenKernelArgMetadata(llvm::Function *Fn, // 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 index 2967bb3faa32..1a444fca2d17 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -853,7 +853,7 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) { 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 @@ bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCContainerDecl *IDecl, /// 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::RewriteObjCFieldDecl(FieldDecl *fieldDecl, 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 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) { 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 index d3929361213a..3fe8864c1c9b 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -10196,7 +10196,7 @@ CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS, // 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 @@ static bool IsTailPaddedMemberArray(Sema &S, const llvm::APInt &Size, 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 index 8c9ed5389488..e782fdd2ca23 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -2782,7 +2782,7 @@ static void findTypeLocationForBlockDecl(const TypeSourceInfo *TSInfo, 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 index 927d81826425..982fbf2203f7 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -275,6 +275,45 @@ static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, 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 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, } 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 @@ ParsedType Sema::getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, 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 @@ Corrected: 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 index 221cbd14da97..5df34fd2028a 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -4362,17 +4362,13 @@ Sema::BuildMemInitializer(Decl *ConstructorD, } 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 @@ Sema::BuildMemberInitializer(ValueDecl *Member, Expr *Init, 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 @@ MemInitResult 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 @@ Sema::BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, 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 @@ void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R, 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 @@ FriendDecl *Sema::CheckFriendTypeDecl(SourceLocation LocStart, 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 index 742c4828b8dc..9bc54aad6108 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4504,7 +4504,6 @@ static void captureVariablyModifiedType(ASTContext &Context, QualType T, 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 @@ static void captureVariablyModifiedType(ASTContext &Context, QualType T, 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 index 11f33c7c6363..20c6969bcbd2 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -241,7 +241,7 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc, 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 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, // 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 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, } 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 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, // 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 @@ ExprResult Sema::BuildPseudoDestructorExpr(Expr *Base, 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 index a6c92d1a338d..21326b3a1ba1 100644 --- a/clang/lib/Sema/SemaExprObjC.cpp +++ b/clang/lib/Sema/SemaExprObjC.cpp @@ -3860,7 +3860,7 @@ static inline T *getObjCBridgeAttr(const TypedefType *TD) { 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 @@ static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, 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 @@ static bool CheckObjCBridgeCFCast(Sema &S, QualType castType, Expr *castExpr, 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 index 67cf8f0371c5..2b8f371ac8b9 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4033,14 +4033,14 @@ TypeResult Sema::ActOnTemplateIdType( 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 @@ TypeResult Sema::ActOnTemplateIdType( 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 index 3edce941c381..12d6773676ad 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -5538,7 +5538,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state, // 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 @@ namespace { } } 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 @@ QualType Sema::getElaboratedType(ElaboratedTypeKeyword Keyword, 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 index a8589191fc91..c52e12d3eb9b 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -1069,15 +1069,11 @@ public: // 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 @@ NestedNameSpecifierLoc TreeTransform::TransformNestedNameSpecifierLoc( } // 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.cpp b/clang/lib/Sema/TypeLocBuilder.cpp index 2dcbbd83c691..d2360224ac60 100644 --- a/clang/lib/Sema/TypeLocBuilder.cpp +++ b/clang/lib/Sema/TypeLocBuilder.cpp @@ -85,7 +85,7 @@ TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t LocalSize, unsigned LocalAli // 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 @@ TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t LocalSize, unsigned LocalAli 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 @@ TypeLoc TypeLocBuilder::pushImpl(QualType T, size_t LocalSize, unsigned LocalAli // 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/Sema/TypeLocBuilder.h b/clang/lib/Sema/TypeLocBuilder.h index 738f731c9fe2..9e7422ec9906 100644 --- a/clang/lib/Sema/TypeLocBuilder.h +++ b/clang/lib/Sema/TypeLocBuilder.h @@ -40,12 +40,13 @@ class TypeLocBuilder { /// 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 @@ public: 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/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp index c5437b16c688..9a15f4568fc5 100644 --- a/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp @@ -109,17 +109,20 @@ bool NonnullGlobalConstantsChecker::isGlobalConstString(SVal V) const { // 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 @@ bool NonnullGlobalConstantsChecker::isNonnullType(QualType Ty) const { 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 index 3e9fc696f8e6..f217520d8f4a 100644 --- a/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp @@ -196,12 +196,10 @@ void NumberObjectConversionChecker::checkASTCodeBody(const Decl *D, 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 @@ void NumberObjectConversionChecker::checkASTCodeBody(const Decl *D, // 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 @@ void NumberObjectConversionChecker::checkASTCodeBody(const Decl *D, // 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 index 2f97067f6171..42691d556d98 100644 --- a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp +++ b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp @@ -161,7 +161,7 @@ CaptureMethods(std::string TypeString, const clang::CXXRecordDecl *ASTClass, 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 index 1c9480c5a943..1ed87e665614 100644 --- a/clang/test/AST/ast-dump-APValue-anon-union.cpp +++ b/clang/test/AST/ast-dump-APValue-anon-union.cpp @@ -30,23 +30,23 @@ union U1 { 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 index 4730404abc28..04d1877c293d 100644 --- a/clang/test/AST/ast-dump-APValue-struct.cpp +++ b/clang/test/AST/ast-dump-APValue-struct.cpp @@ -60,12 +60,12 @@ struct S5 : S4 { 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 @@ void Test() { // 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 @@ void Test() { // 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 @@ void Test() { // 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 index c717b6ece738..b70b5ea484a6 100644 --- a/clang/test/AST/ast-dump-APValue-union.cpp +++ b/clang/test/AST/ast-dump-APValue-union.cpp @@ -39,25 +39,25 @@ union U3 { 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 index 691f67fb04dc..a854e45cd5b1 100644 --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -30,7 +30,7 @@ namespace testVarDeclNRVO { 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 @@ namespace testCXXRecordDecl { // 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 @@ namespace testFunctionTemplateDecl { // 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 @@ namespace testFunctionTemplateDecl { // 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 index e924cb4bddcf..62abd9aa42db 100644 --- a/clang/test/AST/ast-dump-expr-json.cpp +++ b/clang/test/AST/ast-dump-expr-json.cpp @@ -325,6 +325,7 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 @@ void TestNonADLCall3() { // 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 index 8b890860e2e3..a0324e602f67 100644 --- a/clang/test/AST/ast-dump-expr.cpp +++ b/clang/test/AST/ast-dump-expr.cpp @@ -59,7 +59,7 @@ void Throw() { 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 @@ void PointerToMember(S obj1, S *obj2, int S::* data, void (S::*call)(int)) { // 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 PointerToMember(S obj1, S *obj2, int S::* data, void (S::*call)(int)) { } 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 @@ void PostfixExpressions(S a, S *p, U *r) { 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 @@ void PostfixExpressions(S a, S *p, U *r) { 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 @@ void PostfixExpressions(S a, S *p, U *r) { 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 @@ void PostfixExpressions(S a, S *p, U *r) { 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 index 61fb5d4eb654..7d47893d4596 100644 --- a/clang/test/AST/ast-dump-funcs.cpp +++ b/clang/test/AST/ast-dump-funcs.cpp @@ -32,7 +32,7 @@ struct S { // 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 index 88c47b213cfb..37490b9fdb30 100644 --- 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 @@ int test() { // 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 @@ int test() { // 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 @@ int test() { // 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 index 639a0d9874eb..8fd1f82fe2c8 100644 --- a/clang/test/AST/ast-dump-overloaded-operators.cpp +++ b/clang/test/AST/ast-dump-overloaded-operators.cpp @@ -31,14 +31,14 @@ void test() { // 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 index a7eb8771d3f0..bc53d03176f6 100644 --- a/clang/test/AST/ast-dump-records-json.cpp +++ b/clang/test/AST/ast-dump-records-json.cpp @@ -3266,6 +3266,7 @@ struct Derived6 : virtual public Bases... { // 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 @@ struct Derived6 : virtual public Bases... { // 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 @@ struct Derived6 : virtual public Bases... { // 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 @@ struct Derived6 : virtual public Bases... { // 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 @@ struct Derived6 : virtual public Bases... { // 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 @@ struct Derived6 : virtual public Bases... { // 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 @@ struct Derived6 : virtual public Bases... { // 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 index f2aca6a78fb0..53043027ddb8 100644 --- a/clang/test/AST/ast-dump-recovery.cpp +++ b/clang/test/AST/ast-dump-recovery.cpp @@ -145,7 +145,7 @@ void test2(Foo2 f) { // 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 @@ void InvalidInitalizer(int x) { // 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 @@ void CtorInitializer() { // 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 index 62afa1bffdab..4c895a660755 100644 --- a/clang/test/AST/ast-dump-stmt-json.cpp +++ b/clang/test/AST/ast-dump-stmt-json.cpp @@ -2257,6 +2257,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 @@ void TestDependentGenericSelectionExpr(Ty T) { // 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 index 4f73d39d4af2..6a1b0d366eda 100644 --- a/clang/test/AST/ast-dump-stmt.cpp +++ b/clang/test/AST/ast-dump-stmt.cpp @@ -99,8 +99,8 @@ void TestUnionInitList() 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 @@ void TestIteration() { // 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 index 00a656cd0591..f51ef937d91d 100644 --- a/clang/test/AST/ast-dump-template-decls-json.cpp +++ b/clang/test/AST/ast-dump-template-decls-json.cpp @@ -826,6 +826,7 @@ void i(); // 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 index 0fd2762cee1a..a8b14de29fcf 100644 --- a/clang/test/AST/ast-dump-temporaries-json.cpp +++ b/clang/test/AST/ast-dump-temporaries-json.cpp @@ -36,6 +36,7 @@ void MaterializeTemp() { // 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 @@ void MaterializeTemp() { // 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 @@ void MaterializeTemp() { // 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 @@ void MaterializeTemp() { // 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 @@ void MaterializeTemp() { // 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 index fbce09d116ed..da18f0499f54 100644 --- a/clang/test/AST/ast-dump-using-template.cpp +++ b/clang/test/AST/ast-dump-using-template.cpp @@ -16,20 +16,23 @@ using ns::S; 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