diff options
author | Haojian Wu <hokein.wu@gmail.com> | 2023-07-10 18:22:12 +0200 |
---|---|---|
committer | Haojian Wu <hokein.wu@gmail.com> | 2023-07-11 09:14:27 +0200 |
commit | 9ca395b5ade105aee63db20534d49a1c58ac76c7 (patch) | |
tree | c18acf23455af7a2bf48e52f96c76729d1205d73 /clang/lib/AST/ComputeDependence.cpp | |
parent | ffcf214b5d27453119575d4e075cac483d659024 (diff) | |
download | llvm-9ca395b5ade105aee63db20534d49a1c58ac76c7.zip llvm-9ca395b5ade105aee63db20534d49a1c58ac76c7.tar.gz llvm-9ca395b5ade105aee63db20534d49a1c58ac76c7.tar.bz2 |
[clang][AST] Propagate the contains-errors bit to DeclRefExpr from VarDecl's initializer.
Similar to the https://reviews.llvm.org/D86048 (it only sets the bit for C++
code), we propagate the contains-errors bit for C-code path.
Fixes https://github.com/llvm/llvm-project/issues/50236
Fixes https://github.com/llvm/llvm-project/issues/50243
Fixes https://github.com/llvm/llvm-project/issues/48636
Fixes https://github.com/llvm/llvm-project/issues/50320
Differential Revision: https://reviews.llvm.org/D154861
Diffstat (limited to 'clang/lib/AST/ComputeDependence.cpp')
-rw-r--r-- | clang/lib/AST/ComputeDependence.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp index 632f38f..09df540 100644 --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -489,7 +489,7 @@ ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext &Ctx) { // more bullets here that we handle by treating the declaration as having a // dependent type if they involve a placeholder type that can't be deduced.] if (Type->isDependentType()) - return Deps | ExprDependence::TypeValueInstantiation; + Deps |= ExprDependence::TypeValueInstantiation; else if (Type->isInstantiationDependentType()) Deps |= ExprDependence::Instantiation; @@ -525,13 +525,13 @@ ExprDependence clang::computeDependence(DeclRefExpr *E, const ASTContext &Ctx) { // - it names a potentially-constant variable that is initialized with an // expression that is value-dependent if (const auto *Var = dyn_cast<VarDecl>(Decl)) { - if (Var->mightBeUsableInConstantExpressions(Ctx)) { - if (const Expr *Init = Var->getAnyInitializer()) { - if (Init->isValueDependent()) - Deps |= ExprDependence::ValueInstantiation; - if (Init->containsErrors()) - Deps |= ExprDependence::Error; - } + if (const Expr *Init = Var->getAnyInitializer()) { + if (Init->containsErrors()) + Deps |= ExprDependence::Error; + + if (Var->mightBeUsableInConstantExpressions(Ctx) && + Init->isValueDependent()) + Deps |= ExprDependence::ValueInstantiation; } // - it names a static data member that is a dependent member of the |