Skip to content

Commit e969bd7

Browse files
authored
[clang][ExprConst] Move getLangOpts() to interp::State subclasses (#159280)
Instead of having `State::getLangOpts()`, which does a virtual call to `getASTContext()` to call `getLangOpts()` on that, just move `getLangOpts()` to the subclasses so we can do that without the virtual call. We never call `getLangOpts()` in `State.cpp`, so it's not needed in the base class.
1 parent fe8e703 commit e969bd7

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

clang/lib/AST/ByteCode/InterpState.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class InterpState final : public State, public SourceMapper {
6868
return Parent.getEvalStatus();
6969
}
7070
ASTContext &getASTContext() const override { return Ctx.getASTContext(); }
71+
const LangOptions &getLangOpts() const {
72+
return Ctx.getASTContext().getLangOpts();
73+
}
7174

7275
// Forward status checks and updates to the walker.
7376
bool keepEvaluatingAfterFailure() const override {

clang/lib/AST/ByteCode/State.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ OptionalDiagnostic State::diag(SourceLocation Loc, diag::kind DiagId,
112112
return OptionalDiagnostic();
113113
}
114114

115-
const LangOptions &State::getLangOpts() const {
116-
return getASTContext().getLangOpts();
117-
}
118-
119115
void State::addCallStack(unsigned Limit) {
120116
// Determine which calls to skip, if any.
121117
unsigned ActiveCalls = getCallStackDepth() - 1;

clang/lib/AST/ByteCode/State.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ class State {
151151
/// Directly reports a diagnostic message.
152152
DiagnosticBuilder report(SourceLocation Loc, diag::kind DiagId);
153153

154-
const LangOptions &getLangOpts() const;
155-
156154
/// Whether or not we're in a context where the front end requires a
157155
/// constant value.
158156
bool InConstantContext = false;

clang/lib/AST/ExprConstant.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ namespace {
945945
}
946946

947947
ASTContext &getASTContext() const override { return Ctx; }
948+
const LangOptions &getLangOpts() const { return Ctx.getLangOpts(); }
948949

949950
void setEvaluatingDecl(APValue::LValueBase Base, APValue &Value,
950951
EvaluatingDeclKind EDK = EvaluatingDeclKind::Ctor) {

0 commit comments

Comments
 (0)