-
Notifications
You must be signed in to change notification settings - Fork 15k
[clang][ExprConst] Move getLangOpts() to interp::State subclasses #159280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) ChangesInstead of having Full diff: https://github.com/llvm/llvm-project/pull/159280.diff 4 Files Affected:
diff --git a/clang/lib/AST/ByteCode/InterpState.h b/clang/lib/AST/ByteCode/InterpState.h
index 1814d273ec1c6..a13244bf383ae 100644
--- a/clang/lib/AST/ByteCode/InterpState.h
+++ b/clang/lib/AST/ByteCode/InterpState.h
@@ -68,6 +68,9 @@ class InterpState final : public State, public SourceMapper {
return Parent.getEvalStatus();
}
ASTContext &getASTContext() const override { return Ctx.getASTContext(); }
+ const LangOptions &getLangOpts() const {
+ return Ctx.getASTContext().getLangOpts();
+ }
// Forward status checks and updates to the walker.
bool keepEvaluatingAfterFailure() const override {
diff --git a/clang/lib/AST/ByteCode/State.cpp b/clang/lib/AST/ByteCode/State.cpp
index dc3d0da7a4a46..323231fbf8236 100644
--- a/clang/lib/AST/ByteCode/State.cpp
+++ b/clang/lib/AST/ByteCode/State.cpp
@@ -112,10 +112,6 @@ OptionalDiagnostic State::diag(SourceLocation Loc, diag::kind DiagId,
return OptionalDiagnostic();
}
-const LangOptions &State::getLangOpts() const {
- return getASTContext().getLangOpts();
-}
-
void State::addCallStack(unsigned Limit) {
// Determine which calls to skip, if any.
unsigned ActiveCalls = getCallStackDepth() - 1;
diff --git a/clang/lib/AST/ByteCode/State.h b/clang/lib/AST/ByteCode/State.h
index a834eed142de0..0695c61c07a05 100644
--- a/clang/lib/AST/ByteCode/State.h
+++ b/clang/lib/AST/ByteCode/State.h
@@ -151,8 +151,6 @@ class State {
/// Directly reports a diagnostic message.
DiagnosticBuilder report(SourceLocation Loc, diag::kind DiagId);
- const LangOptions &getLangOpts() const;
-
/// Whether or not we're in a context where the front end requires a
/// constant value.
bool InConstantContext = false;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 12e4e25bd29c4..81748c42c319b 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -945,6 +945,7 @@ namespace {
}
ASTContext &getASTContext() const override { return Ctx; }
+ const LangOptions &getLangOpts() const { return Ctx.getLangOpts(); }
void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {
|
| } | ||
|
|
||
| ASTContext &getASTContext() const override { return Ctx; } | ||
| const LangOptions &getLangOpts() const { return Ctx.getLangOpts(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ grep "Info.getLangOpts()" ../clang/lib/AST/ExprConstant.cpp | wc -l
61Yep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum, okay i missed that EvalInfo inherits from interp::State - that's fun
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/154/builds/21604 Here is the relevant piece of the build log for the reference |
Instead of having
State::getLangOpts(), which does a virtual call togetASTContext()to callgetLangOpts()on that, just movegetLangOpts()to the subclasses so we can do that without the virtual call. We never callgetLangOpts()inState.cpp, so it's not needed in the base class.