[PATCH] D112765: [AST] injected-class-name is not a redecl, even in template specializations

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 29 06:37:20 PDT 2021


hokein added a comment.

I think we also want to update the ast dumper bit: https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ASTDumper.cpp#L94-L100



================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:1841-1842
+                                   /*DelayTypeCreation=*/IsInjectedClassName);
+  if (IsInjectedClassName)
+    SemaRef.Context.getTypeDeclType(Record, cast<CXXRecordDecl>(Owner));
 
----------------
aaron.ballman wrote:
> Why is this call needed? (It seems strange to me that we call it and ignore the return value.)
my understanding is
  - `getTypeDeclType` is more than a getter, it also has a side-effort -- if the type of the passed `Record` is empty, it creates a type, and propagates the type to `Record->TypeForDecl`;
  - from the above line, we delay the type creation when `IsInjectedClassName` is true;
  - so we need to create a type for the `Record` by invoking `getTypeDeclType`;

might be worth a comment.



================
Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:1910
 
+  if (IsInjectedClassName)
+    assert(Record->isInjectedClassName() && "Broken injected-class-name");
----------------
it is unclear to me what's the intention of the assertion.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112765/new/

https://reviews.llvm.org/D112765



More information about the cfe-commits mailing list