[clang] 6603c68 - [clang][sema][NFC] Make a few functions const
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 14 05:48:25 PDT 2023
Author: Timm Bäder
Date: 2023-03-14T13:48:11+01:00
New Revision: 6603c68302c16e52be6d6262033def4348a9f864
URL: https://github.com/llvm/llvm-project/commit/6603c68302c16e52be6d6262033def4348a9f864
DIFF: https://github.com/llvm/llvm-project/commit/6603c68302c16e52be6d6262033def4348a9f864.diff
LOG: [clang][sema][NFC] Make a few functions const
Differential Revision: https://reviews.llvm.org/D145947
Added:
Modified:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a492721f77bfa..2c3ffe0533a71 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1045,7 +1045,7 @@ class Sema final {
/// ExpressionEvaluationContextRecord object.
bool isConstantEvaluatedOverride;
- bool isConstantEvaluated() {
+ bool isConstantEvaluated() const {
return ExprEvalContexts.back().isConstantEvaluated() ||
isConstantEvaluatedOverride;
}
@@ -1486,7 +1486,7 @@ class Sema final {
/// Determine if VD, which must be a variable or function, is an external
/// symbol that nonetheless can't be referenced from outside this translation
/// unit because its type has no linkage and it's not extern "C".
- bool isExternalWithNoLinkageType(ValueDecl *VD);
+ bool isExternalWithNoLinkageType(ValueDecl *VD) const;
/// Obtain a sorted list of functions that are undefined but ODR-used.
void getUndefinedButUsed(
@@ -3548,13 +3548,13 @@ class Sema final {
void ActOnExitFunctionContext();
/// If \p AllowLambda is true, treat lambda as function.
- DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false);
+ DeclContext *getFunctionLevelDeclContext(bool AllowLambda = false) const;
/// Returns a pointer to the innermost enclosing function, or nullptr if the
/// current context is not inside a function. If \p AllowLambda is true,
/// this can return the call operator of an enclosing lambda, otherwise
/// lambdas are skipped when looking for an enclosing function.
- FunctionDecl *getCurFunctionDecl(bool AllowLambda = false);
+ FunctionDecl *getCurFunctionDecl(bool AllowLambda = false) const;
/// getCurMethodDecl - If inside of a method body, this returns a pointer to
/// the method decl for the method being parsed. If we're currently
@@ -3564,7 +3564,7 @@ class Sema final {
/// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
/// or C function we're in, otherwise return null. If we're currently
/// in a 'block', this returns the containing context.
- NamedDecl *getCurFunctionOrMethodDecl();
+ NamedDecl *getCurFunctionOrMethodDecl() const;
/// Add this decl to the scope shadowed decl chains.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
@@ -3577,7 +3577,7 @@ class Sema final {
/// enclosing namespace set of the context, rather than contained
/// directly within it.
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S = nullptr,
- bool AllowInlineNamespace = false);
+ bool AllowInlineNamespace = false) const;
/// Finds the scope corresponding to the given decl context, if it
/// happens to be an enclosing scope. Otherwise return NULL.
@@ -4349,7 +4349,7 @@ class Sema final {
ForExternalRedeclaration
};
- RedeclarationKind forRedeclarationInCurContext() {
+ RedeclarationKind forRedeclarationInCurContext() const {
// A declaration with an owning module for linkage can never link against
// anything that is not visible. We don't need to check linkage here; if
// the context has internal linkage, redeclaration lookup won't find things
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 72575470a78bc..89ac016f60e97 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -793,7 +793,7 @@ static bool isFunctionOrVarDeclExternC(NamedDecl *ND) {
/// Determine whether ND is an external-linkage function or variable whose
/// type has no linkage.
-bool Sema::isExternalWithNoLinkageType(ValueDecl *VD) {
+bool Sema::isExternalWithNoLinkageType(ValueDecl *VD) const {
// Note: it's not quite enough to check whether VD has UniqueExternalLinkage,
// because we also want to catch the case where its type has VisibleNoLinkage,
// which does not affect the linkage of VD.
@@ -1441,7 +1441,7 @@ void Sema::ActOnEndOfTranslationUnit() {
// Helper functions.
//===----------------------------------------------------------------------===//
-DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) {
+DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) const {
DeclContext *DC = CurContext;
while (true) {
@@ -1461,7 +1461,7 @@ DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) {
/// getCurFunctionDecl - If inside of a function body, this returns a pointer
/// to the function decl for the function being parsed. If we're currently
/// in a 'block', this returns the containing context.
-FunctionDecl *Sema::getCurFunctionDecl(bool AllowLambda) {
+FunctionDecl *Sema::getCurFunctionDecl(bool AllowLambda) const {
DeclContext *DC = getFunctionLevelDeclContext(AllowLambda);
return dyn_cast<FunctionDecl>(DC);
}
@@ -1473,7 +1473,7 @@ ObjCMethodDecl *Sema::getCurMethodDecl() {
return dyn_cast<ObjCMethodDecl>(DC);
}
-NamedDecl *Sema::getCurFunctionOrMethodDecl() {
+NamedDecl *Sema::getCurFunctionOrMethodDecl() const {
DeclContext *DC = getFunctionLevelDeclContext();
if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
return cast<NamedDecl>(DC);
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 0abf67f0d62d2..381673b88b436 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1593,7 +1593,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
}
bool Sema::isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S,
- bool AllowInlineNamespace) {
+ bool AllowInlineNamespace) const {
return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
}
More information about the cfe-commits
mailing list