[PATCH] D86048: [AST][RecoveryExpr] Popagate the error-bit from a VarDecl's initializer to DeclRefExpr.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 28 02:00:16 PDT 2020


hokein added inline comments.


================
Comment at: clang/test/Sema/invalid-member.cpp:29
+};
+static_assert(sizeof(T) == 1, "No valid members");
----------------
The current fix (by invalidating the member decl) is probably suboptimal.

The crash is caused by the fact that we escape the dependent-type guard in HandleSizeOf -- the `recordType` T is not type-dependent, because the implementation `TagDecl::isDependentType` just checks `isDependentContext()`.

This is incorrect after recovery-expr is introduced -- in this example, `ABC<N> abc` is type-dependent because the template argument DeclRefExpr is value-dependent,
so the recordType T should be type-dependent.

I think right fix is to make the recordType `T` type-dependent, but there are a few tricky things in clang making it harder:
 - The TagType is cached and uniqued, and the dependence-bits are set in the constructor; 
 - The TagType can be created before we see the RecordDecl body;

To set the type-dependent, we need to see class body, by that time, the TagType is created, and cached, I'm not sure it is reasonable to rewrite the dependence-bits when we complete a class definition. Any suggestions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86048



More information about the cfe-commits mailing list