Author: Timm Bäder Date: 2023-01-19T12:16:03+01:00 New Revision: 2aa23ff263a012afaf0dbb05d96a7301fc6cbb57
URL: https://github.com/llvm/llvm-project/commit/2aa23ff263a012afaf0dbb05d96a7301fc6cbb57 DIFF: https://github.com/llvm/llvm-project/commit/2aa23ff263a012afaf0dbb05d96a7301fc6cbb57.diff LOG: [clang][Interp][NFCI] Pull IsConstantContext into State This way we can check for this flag in the new interpreter as well. Added: Modified: clang/lib/AST/ExprConstant.cpp clang/lib/AST/Interp/InterpState.h clang/lib/AST/Interp/State.h Removed: ################################################################################ diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index e3f34579372a..7105c7dfa753 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -925,10 +925,6 @@ namespace { /// fold (not just why it's not strictly a constant expression)? bool HasFoldFailureDiagnostic; - /// Whether or not we're in a context where the front end requires a - /// constant value. - bool InConstantContext; - /// Whether we're checking that an expression is a potential constant /// expression. If so, do not fail on constructs that could become constant /// later on (such as a use of an undefined global). @@ -984,8 +980,7 @@ namespace { BottomFrame(*this, SourceLocation(), nullptr, nullptr, CallRef()), EvaluatingDecl((const ValueDecl *)nullptr), EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false), - HasFoldFailureDiagnostic(false), InConstantContext(false), - EvalMode(Mode) {} + HasFoldFailureDiagnostic(false), EvalMode(Mode) {} ~EvalInfo() { discardCleanups(); diff --git a/clang/lib/AST/Interp/InterpState.h b/clang/lib/AST/Interp/InterpState.h index 72f6dd09dc2e..033080637385 100644 --- a/clang/lib/AST/Interp/InterpState.h +++ b/clang/lib/AST/Interp/InterpState.h @@ -65,6 +65,7 @@ class InterpState final : public State, public SourceMapper { bool noteUndefinedBehavior() override { return Parent.noteUndefinedBehavior(); } + bool inConstantContext() const { return Parent.InConstantContext; } bool hasActiveDiagnostic() override { return Parent.hasActiveDiagnostic(); } void setActiveDiagnostic(bool Flag) override { Parent.setActiveDiagnostic(Flag); diff --git a/clang/lib/AST/Interp/State.h b/clang/lib/AST/Interp/State.h index d9a645a3eb3e..131fbcf3cffc 100644 --- a/clang/lib/AST/Interp/State.h +++ b/clang/lib/AST/Interp/State.h @@ -71,6 +71,7 @@ class State { virtual unsigned getCallStackDepth() = 0; public: + State() : InConstantContext(false) {} // Diagnose that the evaluation could not be folded (FF => FoldFailure) OptionalDiagnostic FFDiag(SourceLocation Loc, @@ -118,6 +119,10 @@ class State { const LangOptions &getLangOpts() const; + /// Whether or not we're in a context where the front end requires a + /// constant value. + bool InConstantContext; + private: void addCallStack(unsigned Limit); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits