[all-commits] [llvm/llvm-project] 15f3cd: [clang] Implement ElaboratedType sugaring for type...

Matheus Izvekov via All-commits all-commits at lists.llvm.org
Wed Jul 27 02:11:37 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 15f3cd6bfc670ba6106184a903eb04be059e5977
      https://github.com/llvm/llvm-project/commit/15f3cd6bfc670ba6106184a903eb04be059e5977
  Author: Matheus Izvekov <mizvekov at gmail.com>
  Date:   2022-07-27 (Wed, 27 Jul 2022)

  Changed paths:
    M clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
    M clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
    M clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
    M clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
    M clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
    M clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
    M clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
    M clang-tools-extra/clangd/FindTarget.cpp
    M clang-tools-extra/clangd/unittests/ASTTests.cpp
    M clang-tools-extra/clangd/unittests/DumpASTTests.cpp
    M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
    M clang-tools-extra/clangd/unittests/HoverTests.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp
    M clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp
    M clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
    M clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
    M clang/bindings/python/tests/cindex/test_type.py
    M clang/include/clang/AST/ASTContext.h
    M clang/include/clang/AST/Type.h
    M clang/include/clang/AST/TypeLoc.h
    M clang/lib/ARCMigrate/ObjCMT.cpp
    M clang/lib/AST/ASTContext.cpp
    M clang/lib/AST/ASTDiagnostic.cpp
    M clang/lib/AST/DeclCXX.cpp
    M clang/lib/AST/ExprCXX.cpp
    M clang/lib/AST/FormatString.cpp
    M clang/lib/AST/PrintfFormatString.cpp
    M clang/lib/AST/QualTypeNames.cpp
    M clang/lib/AST/ScanfFormatString.cpp
    M clang/lib/AST/Type.cpp
    M clang/lib/AST/TypeLoc.cpp
    M clang/lib/Analysis/RetainSummaryManager.cpp
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CGExprScalar.cpp
    M clang/lib/CodeGen/CodeGenFunction.cpp
    M clang/lib/CodeGen/CodeGenModule.cpp
    M clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
    M clang/lib/Sema/SemaChecking.cpp
    M clang/lib/Sema/SemaCodeComplete.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/lib/Sema/SemaExprObjC.cpp
    M clang/lib/Sema/SemaTemplate.cpp
    M clang/lib/Sema/SemaType.cpp
    M clang/lib/Sema/TreeTransform.h
    M clang/lib/Sema/TypeLocBuilder.cpp
    M clang/lib/Sema/TypeLocBuilder.h
    M clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
    M clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
    M clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
    M clang/test/AST/ast-dump-APValue-anon-union.cpp
    M clang/test/AST/ast-dump-APValue-struct.cpp
    M clang/test/AST/ast-dump-APValue-union.cpp
    M clang/test/AST/ast-dump-decl.cpp
    M clang/test/AST/ast-dump-expr-json.cpp
    M clang/test/AST/ast-dump-expr.cpp
    M clang/test/AST/ast-dump-funcs.cpp
    M clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
    M clang/test/AST/ast-dump-overloaded-operators.cpp
    M clang/test/AST/ast-dump-records-json.cpp
    M clang/test/AST/ast-dump-recovery.cpp
    M clang/test/AST/ast-dump-stmt-json.cpp
    M clang/test/AST/ast-dump-stmt.cpp
    M clang/test/AST/ast-dump-template-decls-json.cpp
    M clang/test/AST/ast-dump-temporaries-json.cpp
    M clang/test/AST/ast-dump-using-template.cpp
    M clang/test/AST/ast-dump-using.cpp
    M clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
    M clang/test/AST/coroutine-locals-cleanup.cpp
    M clang/test/AST/float16.cpp
    M clang/test/AST/sourceranges.cpp
    M clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
    M clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
    M clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
    M clang/test/Analysis/analyzer-display-progress.cpp
    M clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
    M clang/test/Analysis/blocks.mm
    M clang/test/Analysis/bug_hash_test.cpp
    M clang/test/Analysis/cast-value-notes.cpp
    M clang/test/Analysis/cast-value-state-dump.cpp
    M clang/test/Analysis/cfg-rich-constructors.cpp
    M clang/test/Analysis/cfg-rich-constructors.mm
    M clang/test/Analysis/cfg.cpp
    M clang/test/Analysis/copy-elision.cpp
    M clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
    M clang/test/Analysis/dump_egraph.cpp
    M clang/test/Analysis/exploded-graph-rewriter/dynamic_types.cpp
    M clang/test/Analysis/initializers-cfg-output.cpp
    M clang/test/Analysis/inlining/Inputs/expected-plists/path-notes.cpp.plist
    M clang/test/Analysis/lambdas.cpp
    M clang/test/Analysis/lifetime-cfg-output.cpp
    M clang/test/Analysis/malloc-sizeof.cpp
    M clang/test/Analysis/memory-model.cpp
    M clang/test/Analysis/missing-bind-temporary.cpp
    M clang/test/Analysis/more-dtors-cfg-output.cpp
    M clang/test/Analysis/ptr-arith.cpp
    M clang/test/Analysis/scopes-cfg-output.cpp
    M clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
    M clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4.cpp
    M clang/test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2.cpp
    M clang/test/CXX/class.access/p4.cpp
    M clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
    M clang/test/CXX/class/class.compare/class.eq/p2.cpp
    M clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
    M clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
    M clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
    M clang/test/CXX/class/class.mem/p2.cpp
    M clang/test/CXX/conv/conv.fctptr/p1.cpp
    M clang/test/CXX/conv/conv.mem/p4.cpp
    M clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
    M clang/test/CXX/dcl.decl/dcl.decomp/p4.cpp
    M clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
    M clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
    M clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp
    M clang/test/CXX/drs/dr0xx.cpp
    M clang/test/CXX/drs/dr13xx.cpp
    M clang/test/CXX/drs/dr16xx.cpp
    M clang/test/CXX/drs/dr17xx.cpp
    M clang/test/CXX/drs/dr1xx.cpp
    M clang/test/CXX/drs/dr2xx.cpp
    M clang/test/CXX/drs/dr3xx.cpp
    M clang/test/CXX/drs/dr4xx.cpp
    M clang/test/CXX/drs/dr5xx.cpp
    M clang/test/CXX/drs/dr9xx.cpp
    M clang/test/CXX/except/except.spec/p1.cpp
    M clang/test/CXX/expr/expr.const/p2-0x.cpp
    M clang/test/CXX/expr/expr.const/p5-0x.cpp
    M clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
    M clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp
    M clang/test/CXX/over/over.match/over.match.funcs/over.match.copy/p1.cpp
    M clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp
    M clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p9-2a.cpp
    M clang/test/CXX/special/class.copy/p23-cxx11.cpp
    M clang/test/CXX/special/class.copy/p3-cxx11.cpp
    M clang/test/CXX/special/class.inhctor/p4.cpp
    M clang/test/CXX/special/class.temporary/p1.cpp
    M clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
    M clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp
    M clang/test/CodeGen/builtin-bpf-btf-type-id.c
    M clang/test/CodeGen/builtins-bpf-preserve-field-info-3.c
    M clang/test/CodeGenCXX/microsoft-abi-vtables-multiple-nonvirtual-inheritance-return-adjustment.cpp
    M clang/test/CodeGenCXX/microsoft-abi-vtables-return-thunks.cpp
    M clang/test/CodeGenCXX/microsoft-abi-vtables-virtual-inheritance.cpp
    M clang/test/CodeGenCXX/predefined-expr.cpp
    M clang/test/CodeGenCXX/vtable-layout.cpp
    M clang/test/FixIt/fixit.cpp
    M clang/test/Index/annotate-context-sensitive.cpp
    M clang/test/Index/comment-cplus-decls.cpp
    M clang/test/Index/keep-going.cpp
    M clang/test/Index/load-stmts.cpp
    M clang/test/Index/opencl-types.cl
    M clang/test/Index/paren-type.c
    M clang/test/Index/print-type-size.cpp
    M clang/test/Index/print-type.c
    M clang/test/Index/print-type.cpp
    M clang/test/Layout/aix-bitfield-alignment.cpp
    M clang/test/Layout/aix-power-alignment-typedef.cpp
    M clang/test/Layout/dump-canonical.cpp
    M clang/test/Layout/ms-x86-basic-layout.cpp
    M clang/test/Layout/ms-x86-misalignedarray.cpp
    M clang/test/Misc/diag-line-wrapping.cpp
    M clang/test/Misc/diag-template-diffing.cpp
    M clang/test/Modules/namespaces.cpp
    M clang/test/Modules/odr_hash-gnu.cpp
    M clang/test/Modules/odr_hash.cpp
    M clang/test/OpenMP/declare_mapper_ast_print.cpp
    M clang/test/OpenMP/declare_reduction_ast_print.cpp
    M clang/test/OpenMP/deferred-diags.cpp
    M clang/test/PCH/cxx_exprs.cpp
    M clang/test/Parser/cxx1z-decomposition.cpp
    M clang/test/SemaCXX/MicrosoftCompatibility.cpp
    M clang/test/SemaCXX/abstract.cpp
    M clang/test/SemaCXX/access-base-class.cpp
    M clang/test/SemaCXX/accessible-base.cpp
    M clang/test/SemaCXX/aggregate-initialization.cpp
    M clang/test/SemaCXX/ambig-user-defined-conversions.cpp
    M clang/test/SemaCXX/atomic-type.cpp
    M clang/test/SemaCXX/attr-noreturn.cpp
    M clang/test/SemaCXX/builtins.cpp
    M clang/test/SemaCXX/calling-conv-compat.cpp
    M clang/test/SemaCXX/class-base-member-init.cpp
    M clang/test/SemaCXX/class.cpp
    M clang/test/SemaCXX/co_await-ast.cpp
    M clang/test/SemaCXX/compound-literal.cpp
    M clang/test/SemaCXX/constant-expression-cxx11.cpp
    M clang/test/SemaCXX/constant-expression-cxx2a.cpp
    M clang/test/SemaCXX/constant-expression.cpp
    M clang/test/SemaCXX/constexpr-default-init-value-crash.cpp
    M clang/test/SemaCXX/constructor-initializer.cpp
    M clang/test/SemaCXX/conversion-function.cpp
    M clang/test/SemaCXX/copy-initialization.cpp
    M clang/test/SemaCXX/cstyle-cast.cpp
    M clang/test/SemaCXX/cxx0x-class.cpp
    M clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
    M clang/test/SemaCXX/cxx0x-initializer-constructor.cpp
    M clang/test/SemaCXX/cxx0x-initializer-references.cpp
    M clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
    M clang/test/SemaCXX/cxx0x-nontrivial-union.cpp
    M clang/test/SemaCXX/cxx11-inheriting-ctors.cpp
    M clang/test/SemaCXX/cxx17-compat.cpp
    M clang/test/SemaCXX/cxx1y-contextual-conversion-tweaks.cpp
    M clang/test/SemaCXX/cxx2a-destroying-delete.cpp
    M clang/test/SemaCXX/cxx98-compat-flags.cpp
    M clang/test/SemaCXX/cxx98-compat-pedantic.cpp
    M clang/test/SemaCXX/decl-init-ref.cpp
    M clang/test/SemaCXX/default-assignment-operator.cpp
    M clang/test/SemaCXX/derived-to-base-ambig.cpp
    M clang/test/SemaCXX/destructor.cpp
    M clang/test/SemaCXX/dynamic-cast.cpp
    M clang/test/SemaCXX/elaborated-type-specifier.cpp
    M clang/test/SemaCXX/enum-scoped.cpp
    M clang/test/SemaCXX/enum.cpp
    M clang/test/SemaCXX/exceptions.cpp
    M clang/test/SemaCXX/for-range-examples.cpp
    M clang/test/SemaCXX/function-extern-c.cpp
    M clang/test/SemaCXX/functional-cast.cpp
    M clang/test/SemaCXX/ignored-reference-qualifiers-disabled.cpp
    M clang/test/SemaCXX/matrix-type-operators.cpp
    M clang/test/SemaCXX/member-expr.cpp
    M clang/test/SemaCXX/member-init.cpp
    M clang/test/SemaCXX/microsoft-cxx0x.cpp
    M clang/test/SemaCXX/microsoft-dtor-lookup.cpp
    M clang/test/SemaCXX/new-array-size-conv.cpp
    M clang/test/SemaCXX/new-delete.cpp
    M clang/test/SemaCXX/out-of-line-def-mismatch.cpp
    M clang/test/SemaCXX/overload-0x.cpp
    M clang/test/SemaCXX/overload-call.cpp
    M clang/test/SemaCXX/overload-member-call.cpp
    M clang/test/SemaCXX/overloaded-operator.cpp
    M clang/test/SemaCXX/pseudo-destructors.cpp
    M clang/test/SemaCXX/recovery-expr-type.cpp
    M clang/test/SemaCXX/references.cpp
    M clang/test/SemaCXX/static-cast.cpp
    M clang/test/SemaCXX/switch.cpp
    M clang/test/SemaCXX/type-traits.cpp
    M clang/test/SemaCXX/undefined-internal.cpp
    M clang/test/SemaCXX/underlying_type.cpp
    M clang/test/SemaCXX/vector.cpp
    M clang/test/SemaCXX/virtual-override.cpp
    M clang/test/SemaCXX/warn-bad-memaccess.cpp
    M clang/test/SemaCXX/warn-enum-compare.cpp
    M clang/test/SemaCXX/warn-new-overaligned-3.cpp
    M clang/test/SemaCXX/warn-new-overaligned.cpp
    M clang/test/SemaCXX/warn-reinterpret-base-class.cpp
    M clang/test/SemaCXX/warn-reorder-ctor-initialization.cpp
    M clang/test/SemaCXX/warn-thread-safety-parsing.cpp
    M clang/test/SemaHLSL/prohibit_pointer.hlsl
    M clang/test/SemaObjCXX/arc-templates.mm
    M clang/test/SemaObjCXX/blocks.mm
    M clang/test/SemaSYCL/float128.cpp
    M clang/test/SemaSYCL/int128.cpp
    M clang/test/SemaTemplate/anonymous-union.cpp
    M clang/test/SemaTemplate/attributes.cpp
    M clang/test/SemaTemplate/deduction-guide.cpp
    M clang/test/SemaTemplate/default-expr-arguments-3.cpp
    M clang/test/SemaTemplate/dependent-names.cpp
    M clang/test/SemaTemplate/instantiate-self.cpp
    M clang/test/SemaTemplate/member-access-ambig.cpp
    M clang/test/SemaTemplate/member-access-expr.cpp
    M clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
    M clang/test/SemaTemplate/pr52909.cpp
    M clang/test/SemaTemplate/pr52970.cpp
    M clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
    M clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
    M clang/test/SemaTemplate/virtual-member-functions.cpp
    M clang/unittests/AST/ASTImporterTest.cpp
    M clang/unittests/AST/ASTTraverserTest.cpp
    M clang/unittests/AST/TypePrinterTest.cpp
    M clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
    M clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
    M clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
    M clang/unittests/Introspection/IntrospectionTest.cpp
    M clang/unittests/Sema/CodeCompleteTest.cpp
    M clang/unittests/StaticAnalyzer/SValTest.cpp
    M clang/unittests/StaticAnalyzer/TestReturnValueUnderConstruction.cpp
    M clang/unittests/Tooling/QualTypeNamesTest.cpp
    M clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp
    M clang/unittests/Tooling/StencilTest.cpp
    M lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
    M lldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py

  Log Message:
  -----------
  [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.

---

Troubleshooting list to deal with any breakage seen with this patch:

1) The most likely effect one would see by this patch is a change in how
   a type is printed. The type printer will, by design and default,
   print types as written. There are customization options there, but
   not that many, and they mainly apply to how to print a type that we
   somehow failed to track how it was written. This patch fixes a
   problem where we failed to distinguish between a type
   that was written without any elaborated-type qualifiers,
   such as a 'struct'/'class' tags and name spacifiers such as 'std::',
   and one that has been stripped of any 'metadata' that identifies such,
   the so called canonical types.
   Example:
   ```
   namespace foo {
     struct A {};
     A a;
   };
   ```
   If one were to print the type of `foo::a`, prior to this patch, this
   would result in `foo::A`. This is how the type printer would have,
   by default, printed the canonical type of A as well.
   As soon as you add any name qualifiers to A, the type printer would
   suddenly start accurately printing the type as written. This patch
   will make it print it accurately even when written without
   qualifiers, so we will just print `A` for the initial example, as
   the user did not really write that `foo::` namespace qualifier.

2) This patch could expose a bug in some AST matcher. Matching types
   is harder to get right when there is sugar involved. For example,
   if you want to match a type against being a pointer to some type A,
   then you have to account for getting a type that is sugar for a
   pointer to A, or being a pointer to sugar to A, or both! Usually
   you would get the second part wrong, and this would work for a
   very simple test where you don't use any name qualifiers, but
   you would discover is broken when you do. The usual fix is to
   either use the matcher which strips sugar, which is annoying
   to use as for example if you match an N level pointer, you have
   to put N+1 such matchers in there, beginning to end and between
   all those levels. But in a lot of cases, if the property you want
   to match is present in the canonical type, it's easier and faster
   to just match on that... This goes with what is said in 1), if
   you want to match against the name of a type, and you want
   the name string to be something stable, perhaps matching on
   the name of the canonical type is the better choice.

3) This patch could expose a bug in how you get the source range of some
   TypeLoc. For some reason, a lot of code is using getLocalSourceRange(),
   which only looks at the given TypeLoc node. This patch introduces a new,
   and more common TypeLoc node which contains no source locations on itself.
   This is not an inovation here, and some other, more rare TypeLoc nodes could
   also have this property, but if you use getLocalSourceRange on them, it's not
   going to return any valid locations, because it doesn't have any. The right fix
   here is to always use getSourceRange() or getBeginLoc/getEndLoc which will dive
   into the inner TypeLoc to get the source range if it doesn't find it on the
   top level one. You can use getLocalSourceRange if you are really into
   micro-optimizations and you have some outside knowledge that the TypeLocs you are
   dealing with will always include some source location.

4) Exposed a bug somewhere in the use of the normal clang type class API, where you
   have some type, you want to see if that type is some particular kind, you try a
   `dyn_cast` such as `dyn_cast<TypedefType>` and that fails because now you have an
   ElaboratedType which has a TypeDefType inside of it, which is what you wanted to match.
   Again, like 2), this would usually have been tested poorly with some simple tests with
   no qualifications, and would have been broken had there been any other kind of type sugar,
   be it an ElaboratedType or a TemplateSpecializationType or a SubstTemplateParmType.
   The usual fix here is to use `getAs` instead of `dyn_cast`, which will look deeper
   into the type. Or use `getAsAdjusted` when dealing with TypeLocs.
   For some reason the API is inconsistent there and on TypeLocs getAs behaves like a dyn_cast.

5) It could be a bug in this patch perhaps.

Let me know if you need any help!

Signed-off-by: Matheus Izvekov <mizvekov at gmail.com>

Differential Revision: https://reviews.llvm.org/D112374




More information about the All-commits mailing list