[PATCH] D84222: [AST][RecoveryExpr] Error-dependent expression should not be treat as a nullptr pointer constant.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 23:49:41 PDT 2020


hokein added inline comments.


================
Comment at: clang/test/AST/ast-dump-recovery.c:51
+  // CHECK-NEXT:     `-DeclRefExpr {{.*}} 'some_func'
+  ptr = some_func(); // should not crash
+}
----------------
For references, the crash stacktrace is like below, the cause is that we run into the [codepath](https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaExpr.cpp#L9373-L9384).

```
can't implicitly cast lvalue to rvalue with this cast kind: NullToPointer
UNREACHABLE executed at llvm-project/clang/lib/Sema/Sema.cpp:545!
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./bin/clang -cc1 -fsyntax-only -ast-dump -frecovery-ast /tmp/t.c 
1.      /tmp/t.c:78:20: current parser token ';'
2.      /tmp/t.c:71:16: parsing function body 'NoCrash'
#13 0x0000000003e75e59 clang::Sema::ImpCastExprToType(clang::Expr*, clang::QualType, clang::CastKind, clang::ExprValueKind, llvm::SmallVector<clang::CXXBaseSpecifier*, 4u> const*, clang::Sema::CheckedConversionKind) llvm-project/clang/lib/Sema/Sema.cpp:582:16
#14 0x0000000004132c06 clang::Sema::CheckSingleAssignmentConstraints(clang::QualType, clang::ActionResult<clang::Expr*, true>&, bool, bool, bool) llvm-project/clang/lib/Sema/SemaExpr.cpp:9374:13
#15 0x00000000041420f6 clang::Sema::CheckAssignmentOperands(clang::Expr*, clang::ActionResult<clang::Expr*, true>&, clang::SourceLocation, clang::QualType) llvm-project/clang/lib/Sema/SemaExpr.cpp:12759:9
#16 0x000000000411e348 clang::Sema::CreateBuiltinBinOp(clang::SourceLocation, clang::BinaryOperatorKind, clang::Expr*, clang::Expr*) llvm-project/clang/lib/Sema/SemaExpr.cpp:0:16
#17 0x00000000041060ba clang::Sema::ActOnBinOp(clang::Scope*, clang::SourceLocation, clang::tok::TokenKind, clang::Expr*, clang::Expr*) llvm-project/clang/lib/Sema/SemaExpr.cpp:14170:1
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84222





More information about the cfe-commits mailing list