This makes sure we can preserve invalid-ness for consumers of this
node, it prevents crashes. It also aligns better with rest of the places that
store invalid expressions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nice, recoveryexpr is a better fit here. These changes tend to cause occasional new error-handling crashes on under-tested paths, but I guess it's a good time in the release cycle for that!
You might want a clangd or ast-dump test showing that we now preserve the internal structure of (some) invalid default initializes.
clang/include/clang/Sema/Sema.h | ||
---|---|---|
3026 | nit: Nullable ExprResult* since there are only two states? | |
clang/lib/Parse/ParseCXXInlineMethods.cpp | ||
398 | If this fixes the recursive copy-constructor case you mentioned, can you add a test? (Else does it do anything? Or just cleanup) | |
400–401 | DefArgResult is never anything here. I'd probably find /*DefaultArg=*/nullptr more obvious | |
clang/lib/Parse/ParseDecl.cpp | ||
7562 | Ditto |
- Use Expr* instead of ExprResult
- Add dump test to demonstrate new RecoveryExpr
clang/include/clang/Sema/Sema.h | ||
---|---|---|
3026 | i guess you meant Expr* ? | |
clang/lib/Parse/ParseCXXInlineMethods.cpp | ||
398 | no it doesn't. unfortunately that requires change in a separate code path to mark any method decls with invalid parmvardecls as invalid, which i'll try to put together. as that's the behavior for regular functiondecls, i don't see why it should be different for methods (if so we should probably change the behavior for functions instead). | |
400–401 | maybe i am missing something, but "invalid" doesn't mean "unusable". |
Still LG once you're happy
clang/include/clang/Sema/Sema.h | ||
---|---|---|
3026 | Yes, sorry! | |
clang/lib/Parse/ParseCXXInlineMethods.cpp | ||
400–401 | ActionResult can be pointer-and-valid, null-and-valid, or null-and-invalid. So invalid does indeed mean unusable ("usable" means pointer-and-valid). Its documentation strongly suggests an ActionResult can be pointer-and-invalid, but good luck constructing one :-) | |
clang/test/AST/ast-dump-default-arg-recovery.cpp | ||
7 | Can you also check the contents (there should be a declrefexpr at least)? Preserving this internal structure is important for clangd, the recoveryexpr alone doesn't help much. |
nit: Nullable ExprResult* since there are only two states?
Extra get() in some callers, but less mysterious