diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -1045,7 +1045,7 @@ /// ExpressionEvaluationContextRecord object. bool isConstantEvaluatedOverride; - bool isConstantEvaluated() { + bool isConstantEvaluated() const { return ExprEvalContexts.back().isConstantEvaluated() || isConstantEvaluatedOverride; } @@ -1486,7 +1486,7 @@ /// 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 @@ 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 @@ /// 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 @@ /// 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 @@ 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 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -793,7 +793,7 @@ /// 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 @@ // Helper functions. //===----------------------------------------------------------------------===// -DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) { +DeclContext *Sema::getFunctionLevelDeclContext(bool AllowLambda) const { DeclContext *DC = CurContext; while (true) { @@ -1461,7 +1461,7 @@ /// 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(DC); } @@ -1473,7 +1473,7 @@ return dyn_cast(DC); } -NamedDecl *Sema::getCurFunctionOrMethodDecl() { +NamedDecl *Sema::getCurFunctionOrMethodDecl() const { DeclContext *DC = getFunctionLevelDeclContext(); if (isa(DC) || isa(DC)) return cast(DC); diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1593,7 +1593,7 @@ } bool Sema::isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S, - bool AllowInlineNamespace) { + bool AllowInlineNamespace) const { return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace); }