From e4775e165981eae6747d7cf9610880ed83b92726 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 9 Mar 2012 19:35:29 +0000 Subject: [PATCH] [AST/etc] Mark {getSourceRange(),getStartLoc(),getEndLoc()} as LLVM_READONLY. - The theory here is that we have these functions sprinkled in all over the place. This should allow the optimizer to at least realize it can still do load CSE across these calls. - I blindly marked all instances as such, even though the optimizer can infer this attribute in some instances (some of the inline ones) as that was easier and also, when given the choice between thinking and not thinking, I prefer the latter. You might think this is mere frivolity, but actually this is good for a .7 - 1.1% speedup on 403.gcc/combine.c, JSC/Interpreter.cpp, OGF/NSBezierPath-OAExtensions.m. llvm-svn: 152426 --- clang/include/clang/AST/Decl.h | 37 +++---- clang/include/clang/AST/DeclBase.h | 15 ++- clang/include/clang/AST/DeclCXX.h | 25 ++--- clang/include/clang/AST/DeclFriend.h | 3 +- clang/include/clang/AST/DeclObjC.h | 19 ++-- clang/include/clang/AST/DeclTemplate.h | 13 +-- clang/include/clang/AST/DeclarationName.h | 7 +- clang/include/clang/AST/Expr.h | 97 ++++++++++--------- clang/include/clang/AST/ExprCXX.h | 73 +++++++------- clang/include/clang/AST/ExprObjC.h | 31 +++--- clang/include/clang/AST/NestedNameSpecifier.h | 5 +- clang/include/clang/AST/Stmt.h | 52 +++++----- clang/include/clang/AST/StmtCXX.h | 9 +- clang/include/clang/AST/StmtObjC.h | 15 +-- clang/include/clang/AST/TemplateBase.h | 9 +- clang/include/clang/AST/TypeLoc.h | 7 +- clang/include/clang/Index/ASTLocation.h | 3 +- clang/include/clang/Lex/PreprocessingRecord.h | 3 +- clang/include/clang/Parse/Parser.h | 5 +- clang/include/clang/Sema/DeclSpec.h | 19 ++-- .../Core/PathSensitive/ObjCMessage.h | 3 +- 21 files changed, 238 insertions(+), 212 deletions(-) diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 724b56895967..05be052675c0 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -22,6 +22,7 @@ #include "clang/Basic/Linkage.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" +#include "llvm/Support/Compiler.h" namespace clang { class CXXTemporary; @@ -379,7 +380,7 @@ public: bool isGnuLocal() const { return LocStart != getLocation(); } void setLocStart(SourceLocation L) { LocStart = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LocStart, getLocation()); } @@ -500,11 +501,11 @@ public: return getOriginalNamespace(); } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LocStart, RBraceLoc); } - SourceLocation getLocStart() const { return LocStart; } + SourceLocation getLocStart() const LLVM_READONLY { return LocStart; } SourceLocation getRBraceLoc() const { return RBraceLoc; } void setLocStart(SourceLocation L) { LocStart = L; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } @@ -632,8 +633,8 @@ public: /// range taking into account any outer template declarations. SourceLocation getOuterLocStart() const; - virtual SourceRange getSourceRange() const; - SourceLocation getLocStart() const { + virtual SourceRange getSourceRange() const LLVM_READONLY; + SourceLocation getLocStart() const LLVM_READONLY { return getOuterLocStart(); } @@ -850,7 +851,7 @@ public: static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; StorageClass getStorageClass() const { return (StorageClass) VarDeclBits.SClass; @@ -1264,7 +1265,7 @@ public: static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; void setObjCMethodScopeInfo(unsigned parameterIndex) { ParmVarDeclBits.IsObjCMethodParam = true; @@ -1622,7 +1623,7 @@ public: void setRangeEnd(SourceLocation E) { EndRangeLoc = E; } - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; /// \brief Returns true if the function has a body (definition). The /// function body might be in any of the (re-)declarations of this @@ -2198,7 +2199,7 @@ public: return cast(getDeclContext()); } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2234,7 +2235,7 @@ public: void setInitExpr(Expr *E) { Init = (Stmt*) E; } void setInitVal(const llvm::APSInt &V) { Val = V; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2315,9 +2316,9 @@ public: const Type *getTypeForDecl() const { return TypeForDecl; } void setTypeForDecl(const Type *TD) { TypeForDecl = TD; } - SourceLocation getLocStart() const { return LocStart; } + SourceLocation getLocStart() const LLVM_READONLY { return LocStart; } void setLocStart(SourceLocation L) { LocStart = L; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { if (LocStart.isValid()) return SourceRange(LocStart, getLocation()); else @@ -2401,7 +2402,7 @@ public: IdentifierInfo *Id, TypeSourceInfo *TInfo); static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2422,7 +2423,7 @@ public: IdentifierInfo *Id, TypeSourceInfo *TInfo); static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -2545,7 +2546,7 @@ public: /// getOuterLocStart - Return SourceLocation representing start of source /// range taking into account any outer template declarations. SourceLocation getOuterLocStart() const; - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; virtual TagDecl* getCanonicalDecl(); const TagDecl* getCanonicalDecl() const { @@ -3023,7 +3024,7 @@ public: SourceLocation getAsmLoc() const { return getLocation(); } SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getAsmLoc(), getRParenLoc()); } @@ -3174,7 +3175,7 @@ public: const Capture *end, bool capturesCXXThis); - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -3249,7 +3250,7 @@ public: /// identifiers aren't available. ArrayRef getIdentifierLocs() const; - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const ImportDecl *D) { return true; } diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index 4ed4b1aea986..351f77cef104 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -17,8 +17,9 @@ #include "clang/AST/Attr.h" #include "clang/AST/Type.h" #include "clang/Basic/Specifiers.h" -#include "llvm/Support/PrettyStackTrace.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/PrettyStackTrace.h" namespace clang { class DeclContext; @@ -337,11 +338,15 @@ protected: public: /// \brief Source range that this declaration covers. - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), getLocation()); } - SourceLocation getLocStart() const { return getSourceRange().getBegin(); } - SourceLocation getLocEnd() const { return getSourceRange().getEnd(); } + SourceLocation getLocStart() const LLVM_READONLY { + return getSourceRange().getBegin(); + } + SourceLocation getLocEnd() const LLVM_READONLY { + return getSourceRange().getEnd(); + } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } @@ -375,7 +380,7 @@ public: bool isInAnonymousNamespace() const; - ASTContext &getASTContext() const; + ASTContext &getASTContext() const LLVM_READONLY; void setAccess(AccessSpecifier AS) { Access = AS; diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index 838912d49eaf..a77c70c85983 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -23,6 +23,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/Support/Compiler.h" namespace clang { @@ -130,7 +131,7 @@ public: /// setColonLoc - Sets the location of the colon. void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getAccessSpecifierLoc(), getColonLoc()); } @@ -208,9 +209,9 @@ public: /// getSourceRange - Retrieves the source range that contains the /// entire base specifier. - SourceRange getSourceRange() const { return Range; } - SourceLocation getLocStart() const { return Range.getBegin(); } - SourceLocation getLocEnd() const { return Range.getEnd(); } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } + SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } + SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } /// isVirtual - Determines whether the base class is a virtual base /// class (or not). @@ -1851,7 +1852,7 @@ public: SourceLocation getSourceLocation() const; /// \brief Determine the source range covering the entire initializer. - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; /// isWritten - Returns true if this initializer is explicitly written /// in the source code. @@ -2334,7 +2335,7 @@ public: void setExternLoc(SourceLocation L) { ExternLoc = L; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } - SourceLocation getLocEnd() const { + SourceLocation getLocEnd() const LLVM_READONLY { if (hasBraces()) return getRBraceLoc(); // No braces: get the end location of the (only) declaration in context @@ -2342,7 +2343,7 @@ public: return decls_empty() ? getLocation() : decls_begin()->getLocEnd(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(ExternLoc, getLocEnd()); } @@ -2446,7 +2447,7 @@ public: DeclContext *CommonAncestor); static UsingDirectiveDecl *CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(UsingLoc, getLocation()); } @@ -2538,7 +2539,7 @@ public: static NamespaceAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(NamespaceLoc, IdentLoc); } @@ -2733,7 +2734,7 @@ public: static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(UsingLocation, getNameInfo().getEndLoc()); } @@ -2804,7 +2805,7 @@ public: static UnresolvedUsingValueDecl * CreateDeserialized(ASTContext &C, unsigned ID); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(UsingLocation, getNameInfo().getEndLoc()); } @@ -2906,7 +2907,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), getRParenLoc()); } diff --git a/clang/include/clang/AST/DeclFriend.h b/clang/include/clang/AST/DeclFriend.h index d8fd646dcd8f..ba1eb8d729f3 100644 --- a/clang/include/clang/AST/DeclFriend.h +++ b/clang/include/clang/AST/DeclFriend.h @@ -16,6 +16,7 @@ #define LLVM_CLANG_AST_DECLFRIEND_H #include "clang/AST/DeclCXX.h" +#include "llvm/Support/Compiler.h" namespace clang { @@ -100,7 +101,7 @@ public: } /// Retrieves the source range for the friend declaration. - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { /* FIXME: consider the case of templates wrt start of range. */ if (NamedDecl *ND = getFriendDecl()) return SourceRange(getFriendLoc(), ND->getLocEnd()); diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index cf46fa42264f..6aad5d0823a3 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/include/clang/AST/DeclObjC.h @@ -17,6 +17,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/SelectorLocationsKind.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Compiler.h" namespace clang { class Expr; @@ -281,10 +282,10 @@ public: void setAsRedeclaration(const ObjCMethodDecl *PrevMethod); // Location information, modeled after the Stmt API. - SourceLocation getLocStart() const { return getLocation(); } - SourceLocation getLocEnd() const { return EndLoc; } + SourceLocation getLocStart() const LLVM_READONLY { return getLocation(); } + SourceLocation getLocEnd() const LLVM_READONLY { return EndLoc; } void setEndLoc(SourceLocation Loc) { EndLoc = Loc; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLocation(), EndLoc); } @@ -507,7 +508,7 @@ public: AtEnd = atEnd; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtStart, getAtEndRange().getEnd()); } @@ -637,7 +638,7 @@ public: static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); @@ -1217,7 +1218,7 @@ public: /// \brief Starts the definition of this Objective-C protocol. void startDefinition(); - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { if (isThisDeclarationADefinition()) return ObjCContainerDecl::getSourceRange(); @@ -1868,7 +1869,7 @@ public: return PropertyIvarDecl; } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, getLocation()); } @@ -1936,9 +1937,9 @@ public: static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); - virtual SourceRange getSourceRange() const; + virtual SourceRange getSourceRange() const LLVM_READONLY; - SourceLocation getLocStart() const { return AtLoc; } + SourceLocation getLocStart() const LLVM_READONLY { return AtLoc; } void setAtLoc(SourceLocation Loc) { AtLoc = Loc; } ObjCPropertyDecl *getPropertyDecl() const { diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 511f9c7edf47..fc3083aa7919 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -18,6 +18,7 @@ #include "clang/AST/Redeclarable.h" #include "clang/AST/TemplateBase.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/Support/Compiler.h" #include namespace clang { @@ -105,7 +106,7 @@ public: SourceLocation getLAngleLoc() const { return LAngleLoc; } SourceLocation getRAngleLoc() const { return RAngleLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(TemplateLoc, RAngleLoc); } }; @@ -239,7 +240,7 @@ public: return K >= firstTemplate && K <= lastTemplate; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(TemplateParams->getTemplateLoc(), TemplatedDecl->getSourceRange().getEnd()); } @@ -917,7 +918,7 @@ public: /// \brief Returns whether this is a parameter pack. bool isParameterPack() const; - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } @@ -995,7 +996,7 @@ public: using TemplateParmPosition::setPosition; using TemplateParmPosition::getIndex; - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; /// \brief Determine whether this template parameter has a default /// argument. @@ -1181,7 +1182,7 @@ public: DefaultArgumentWasInherited = false; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { SourceLocation End = getLocation(); if (hasDefaultArgument() && !defaultArgumentWasInherited()) End = getDefaultArgument().getSourceRange().getEnd(); @@ -1437,7 +1438,7 @@ public: return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; void Profile(llvm::FoldingSetNodeID &ID) const { Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext()); diff --git a/clang/include/clang/AST/DeclarationName.h b/clang/include/clang/AST/DeclarationName.h index eb7d39b0ba1a..6349d9c001fd 100644 --- a/clang/include/clang/AST/DeclarationName.h +++ b/clang/include/clang/AST/DeclarationName.h @@ -17,6 +17,7 @@ #include "clang/AST/Type.h" #include "clang/AST/CanonicalType.h" #include "clang/Basic/PartialDiagnostic.h" +#include "llvm/Support/Compiler.h" namespace llvm { template struct DenseMapInfo; @@ -510,15 +511,15 @@ public: /// getEndLoc - Retrieve the location of the last token. SourceLocation getEndLoc() const; /// getSourceRange - The range of the declaration name. - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { SourceLocation BeginLoc = getBeginLoc(); SourceLocation EndLoc = getEndLoc(); return SourceRange(BeginLoc, EndLoc.isValid() ? EndLoc : BeginLoc); } - SourceLocation getLocStart() const { + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } - SourceLocation getLocEnd() const { + SourceLocation getLocEnd() const LLVM_READONLY { SourceLocation EndLoc = getEndLoc(); return EndLoc.isValid() ? EndLoc : getLocStart(); } diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 494aef5ae86a..59f84853dea3 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -27,6 +27,7 @@ #include "llvm/ADT/APFloat.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/Support/Compiler.h" #include namespace clang { @@ -716,7 +717,7 @@ public: /// \brief Retrieve the location of this expression. SourceLocation getLocation() const { return Loc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { if (SourceExpr) return SourceExpr->getSourceRange(); return Loc; } @@ -867,9 +868,9 @@ public: SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - SourceRange getSourceRange() const; - SourceLocation getLocStart() const; - SourceLocation getLocEnd() const; + SourceRange getSourceRange() const LLVM_READONLY; + SourceLocation getLocStart() const LLVM_READONLY; + SourceLocation getLocEnd() const LLVM_READONLY; /// \brief Determine whether this declaration reference was preceded by a /// C++ nested-name-specifier, e.g., \c N::foo. @@ -1067,7 +1068,7 @@ public: static std::string ComputeName(IdentType IT, const Decl *CurrentDecl); - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } static bool classof(const Stmt *T) { return T->getStmtClass() == PredefinedExprClass; @@ -1157,7 +1158,7 @@ public: /// \brief Returns a new empty integer literal. static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty); - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } /// \brief Retrieve the location of the literal. SourceLocation getLocation() const { return Loc; } @@ -1203,7 +1204,7 @@ public: return static_cast(CharacterLiteralBits.Kind); } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } unsigned getValue() const { return Value; } @@ -1264,7 +1265,7 @@ public: SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } static bool classof(const Stmt *T) { return T->getStmtClass() == FloatingLiteralClass; @@ -1296,7 +1297,7 @@ public: Expr *getSubExpr() { return cast(Val); } void setSubExpr(Expr *E) { Val = E; } - SourceRange getSourceRange() const { return Val->getSourceRange(); } + SourceRange getSourceRange() const LLVM_READONLY { return Val->getSourceRange(); } static bool classof(const Stmt *T) { return T->getStmtClass() == ImaginaryLiteralClass; } @@ -1454,7 +1455,7 @@ public: tokloc_iterator tokloc_begin() const { return TokLocs; } tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]); } static bool classof(const Stmt *T) { @@ -1488,7 +1489,7 @@ public: Expr *getSubExpr() { return cast(Val); } void setSubExpr(Expr *E) { Val = E; } - SourceRange getSourceRange() const { return SourceRange(L, R); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(L, R); } /// \brief Get the location of the left parentheses '('. SourceLocation getLParen() const { return L; } @@ -1601,7 +1602,7 @@ public: /// the given unary opcode. static OverloadedOperatorKind getOverloadedOperator(Opcode Opc); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { if (isPostfix()) return SourceRange(Val->getLocStart(), Loc); else @@ -1723,7 +1724,7 @@ public: /// the square brackets. For a field or identifier node, the source range /// contains the location of the period (if there is one) and the /// identifier. - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } }; private: @@ -1805,7 +1806,7 @@ public: return NumExprs; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(OperatorLoc, RParenLoc); } @@ -1911,7 +1912,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(OpLoc, RParenLoc); } @@ -1986,7 +1987,7 @@ public: return cast(getRHS()->getType()->isIntegerType() ? getRHS():getLHS()); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLHS()->getLocStart(), RBracketLoc); } @@ -2126,9 +2127,9 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const; - SourceLocation getLocStart() const; - SourceLocation getLocEnd() const; + SourceRange getSourceRange() const LLVM_READONLY; + SourceLocation getLocStart() const LLVM_READONLY; + SourceLocation getLocEnd() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() >= firstCallExprConstant && @@ -2395,9 +2396,9 @@ public: SourceLocation getMemberLoc() const { return MemberLoc; } void setMemberLoc(SourceLocation L) { MemberLoc = L; } - SourceRange getSourceRange() const; - SourceLocation getLocStart() const; - SourceLocation getLocEnd() const; + SourceRange getSourceRange() const LLVM_READONLY; + SourceLocation getLocStart() const LLVM_READONLY; + SourceLocation getLocEnd() const LLVM_READONLY; SourceLocation getExprLoc() const { return MemberLoc; } @@ -2475,7 +2476,7 @@ public: TInfoAndScope.setPointer(tinfo); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { // FIXME: Init should never be null. if (!Init) return SourceRange(); @@ -2629,13 +2630,13 @@ public: static ImplicitCastExpr *CreateEmpty(ASTContext &Context, unsigned PathSize); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return getSubExpr()->getSourceRange(); } - SourceLocation getLocStart() const { + SourceLocation getLocStart() const LLVM_READONLY { return getSubExpr()->getLocStart(); } - SourceLocation getLocEnd() const { + SourceLocation getLocEnd() const LLVM_READONLY { return getSubExpr()->getLocEnd(); } @@ -2732,7 +2733,7 @@ public: SourceLocation getRParenLoc() const { return RPLoc; } void setRParenLoc(SourceLocation L) { RPLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd()); } static bool classof(const Stmt *T) { @@ -2804,7 +2805,7 @@ public: Expr *getRHS() const { return cast(SubExprs[RHS]); } void setRHS(Expr *E) { SubExprs[RHS] = E; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd()); } @@ -3035,7 +3036,7 @@ public: Expr *getLHS() const { return cast(SubExprs[LHS]); } Expr *getRHS() const { return cast(SubExprs[RHS]); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd()); } static bool classof(const Stmt *T) { @@ -3117,7 +3118,7 @@ public: return cast(SubExprs[RHS]); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getCommon()->getLocStart(), getFalseExpr()->getLocEnd()); } static bool classof(const Stmt *T) { @@ -3169,7 +3170,7 @@ public: SourceLocation getLabelLoc() const { return LabelLoc; } void setLabelLoc(SourceLocation L) { LabelLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AmpAmpLoc, LabelLoc); } @@ -3211,7 +3212,7 @@ public: const CompoundStmt *getSubStmt() const { return cast(SubStmt); } void setSubStmt(CompoundStmt *S) { SubStmt = S; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LParenLoc, RParenLoc); } @@ -3261,7 +3262,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -3356,7 +3357,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -3393,7 +3394,7 @@ public: SourceLocation getTokenLocation() const { return TokenLoc; } void setTokenLocation(SourceLocation L) { TokenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(TokenLoc); } static bool classof(const Stmt *T) { @@ -3439,7 +3440,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -3619,7 +3620,7 @@ public: InitListExprBits.InitializesStdInitializerList = ISIL; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == InitListExprClass; @@ -3855,7 +3856,7 @@ public: SourceLocation getEndLocation() const { return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getStartLocation(), getEndLocation()); } }; @@ -3957,7 +3958,7 @@ public: SourceRange getDesignatorsSourceRange() const; - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == DesignatedInitExprClass; @@ -3994,7 +3995,7 @@ public: } static bool classof(const ImplicitValueInitExpr *) { return true; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); } @@ -4032,7 +4033,7 @@ public: SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LParenLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -4147,7 +4148,7 @@ public: const Expr *getResultExpr() const { return getAssocExpr(getResultIndex()); } Expr *getResultExpr() { return getAssocExpr(getResultIndex()); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(GenericLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -4213,7 +4214,7 @@ public: /// aggregate Constant of ConstantInt(s). void getEncodedElementAccess(SmallVectorImpl &Elts) const; - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getBase()->getLocStart(), AccessorLoc); } @@ -4256,7 +4257,7 @@ public: const Stmt *getBody() const; Stmt *getBody(); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getCaretLocation(), getBody()->getLocEnd()); } @@ -4295,7 +4296,7 @@ public: SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } bool isByRef() const { return IsByRef; } void setByRef(bool BR) { IsByRef = BR; } @@ -4346,7 +4347,7 @@ public: /// getRParenLoc - Return the location of final right parenthesis. SourceLocation getRParenLoc() const { return RParenLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BuiltinLoc, RParenLoc); } @@ -4478,7 +4479,7 @@ public: SourceLocation getExprLoc() const { return getSyntacticForm()->getExprLoc(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return getSyntacticForm()->getSourceRange(); } @@ -4580,7 +4581,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BuiltinLoc, RParenLoc); } static bool classof(const Stmt *T) { diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index a9699f1ce853..4b7bfde8182d 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -20,6 +20,7 @@ #include "clang/Basic/ExpressionTraits.h" #include "clang/Basic/Lambda.h" #include "clang/Basic/TypeTraits.h" +#include "llvm/Support/Compiler.h" namespace clang { @@ -73,7 +74,7 @@ public: /// bracket. SourceLocation getOperatorLoc() const { return getRParenLoc(); } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == CXXOperatorCallExprClass; @@ -183,7 +184,7 @@ public: /// \brief Retrieve the location of the closing parenthesis. SourceLocation getRParenLoc() const { return RParenLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParenLoc); } static bool classof(const Stmt *T) { @@ -402,7 +403,7 @@ public: bool getValue() const { return Value; } void setValue(bool V) { Value = V; } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } @@ -428,7 +429,7 @@ public: explicit CXXNullPtrLiteralExpr(EmptyShell Empty) : Expr(CXXNullPtrLiteralExprClass, Empty) { } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } @@ -507,7 +508,7 @@ public: Operand = E; } - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } void setSourceRange(SourceRange R) { Range = R; } static bool classof(const Stmt *T) { @@ -582,7 +583,7 @@ public: Operand = E; } - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } void setSourceRange(SourceRange R) { Range = R; } static bool classof(const Stmt *T) { @@ -628,7 +629,7 @@ public: SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } bool isImplicit() const { return Implicit; } void setImplicit(bool I) { Implicit = I; } @@ -678,7 +679,7 @@ public: /// this variable. bool isThrownVariableInScope() const { return IsThrownVariableInScope; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { if (getSubExpr() == 0) return SourceRange(ThrowLoc, ThrowLoc); return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); @@ -766,7 +767,7 @@ public: /// used. SourceLocation getUsedLocation() const { return Loc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { // Default argument expressions have no representation in the // source, so they have an empty source range. return SourceRange(); @@ -844,7 +845,7 @@ public: Expr *getSubExpr() { return cast(SubExpr); } void setSubExpr(Expr *E) { SubExpr = E; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SubExpr->getSourceRange(); } @@ -980,7 +981,7 @@ public: Args[Arg] = ArgExpr; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; SourceRange getParenRange() const { return ParenRange; } static bool classof(const Stmt *T) { @@ -1032,7 +1033,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(TyBeginLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -1071,7 +1072,7 @@ public: TypeSourceInfo *getTypeSourceInfo() const { return Type; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == CXXTemporaryObjectExprClass; @@ -1370,7 +1371,7 @@ public: } static bool classof(const LambdaExpr *) { return true; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(IntroducerRange.getBegin(), ClosingBrace); } @@ -1411,7 +1412,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == CXXScalarValueInitExprClass; @@ -1590,7 +1591,7 @@ public: SourceRange getDirectInitRange() const { return DirectInitRange; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getStartLoc(), getEndLoc()); } @@ -1661,7 +1662,7 @@ public: /// return an invalid type. QualType getDestroyedType() const; - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, Argument->getLocEnd()); } @@ -1853,7 +1854,7 @@ public: DestroyedType = PseudoDestructorTypeStorage(Info); } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == CXXPseudoDestructorExprClass; @@ -1898,7 +1899,7 @@ public: : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), QueriedType() { } - SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen);} UnaryTypeTrait getTrait() const { return static_cast(UTT); } @@ -1961,7 +1962,7 @@ public: : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), LhsType(), RhsType() { } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen); } @@ -2069,7 +2070,7 @@ public: return getTypeSourceInfos() + getNumArgs(); } - SourceRange getSourceRange() const { return SourceRange(Loc, RParenLoc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParenLoc); } static bool classof(const Stmt *T) { return T->getStmtClass() == TypeTraitExprClass; @@ -2129,7 +2130,7 @@ public: virtual ~ArrayTypeTraitExpr() { } - virtual SourceRange getSourceRange() const { + virtual SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen); } @@ -2188,7 +2189,7 @@ public: : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false), QueriedExpression() { } - SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen);} ExpressionTrait getTrait() const { return static_cast(ET); } @@ -2493,7 +2494,7 @@ public: /// that was looked in to find these results. CXXRecordDecl *getNamingClass() const { return NamingClass; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { SourceRange Range(getNameInfo().getSourceRange()); if (getQualifierLoc()) Range.setBegin(getQualifierLoc().getBeginLoc()); @@ -2648,7 +2649,7 @@ public: return getExplicitTemplateArgs().NumTemplateArgs; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); if (hasExplicitTemplateArgs()) Range.setEnd(getRAngleLoc()); @@ -2723,7 +2724,7 @@ public: /// when modifying an existing AST to preserve its invariants. void setSubExpr(Expr *E) { SubExpr = E; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SubExpr->getSourceRange(); } @@ -2841,7 +2842,7 @@ public: *(arg_begin() + I) = E; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == CXXUnresolvedConstructExprClass; @@ -3076,7 +3077,7 @@ public: return getExplicitTemplateArgs().NumTemplateArgs; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { SourceRange Range; if (!isImplicitAccess()) Range.setBegin(Base->getSourceRange().getBegin()); @@ -3214,7 +3215,7 @@ public: // expression refers to. SourceLocation getMemberLoc() const { return getNameLoc(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { SourceRange Range = getMemberNameInfo().getSourceRange(); if (!isImplicitAccess()) Range.setBegin(Base->getSourceRange().getBegin()); @@ -3266,7 +3267,7 @@ public: Expr *getOperand() const { return static_cast(Operand); } - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } bool getValue() const { return Value; } @@ -3343,7 +3344,7 @@ public: return llvm::Optional(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Pattern->getLocStart(), EllipsisLoc); } @@ -3449,7 +3450,7 @@ public: return Length; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(OperatorLoc, RParenLoc); } @@ -3492,7 +3493,7 @@ public: Param(param), Replacement(replacement), NameLoc(loc) {} SourceLocation getNameLoc() const { return NameLoc; } - SourceRange getSourceRange() const { return NameLoc; } + SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; } Expr *getReplacement() const { return cast(Replacement); } @@ -3556,7 +3557,7 @@ public: /// template arguments. TemplateArgument getArgumentPack() const; - SourceRange getSourceRange() const { return NameLoc; } + SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; } static bool classof(const Stmt *T) { return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass; @@ -3616,7 +3617,9 @@ public: return getValueKind() == VK_LValue; } - SourceRange getSourceRange() const { return Temporary->getSourceRange(); } + SourceRange getSourceRange() const LLVM_READONLY { + return Temporary->getSourceRange(); + } static bool classof(const Stmt *T) { return T->getStmtClass() == MaterializeTemporaryExprClass; diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h index 1e4c7f84aeb5..302262a497ca 100644 --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -18,6 +18,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/SelectorLocationsKind.h" #include "clang/Basic/IdentifierTable.h" +#include "llvm/Support/Compiler.h" namespace clang { class IdentifierInfo; @@ -43,7 +44,7 @@ public: SourceLocation getAtLoc() const { return AtLoc; } void setAtLoc(SourceLocation L) { AtLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, String->getLocEnd()); } @@ -72,7 +73,7 @@ public: bool getValue() const { return Value; } void setValue(bool V) { Value = V; } - SourceRange getSourceRange() const { return SourceRange(Loc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); } SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } @@ -111,7 +112,7 @@ public: SourceLocation getAtLoc() const { return AtLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, Number->getSourceRange().getEnd()); } @@ -148,7 +149,7 @@ public: static ObjCArrayLiteral *CreateEmpty(ASTContext &C, unsigned NumElements); - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCArrayLiteralClass; @@ -311,7 +312,7 @@ public: ObjCMethodDecl *getDictWithObjectsMethod() const { return DictWithObjectsMethod; } - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCDictionaryLiteralClass; @@ -362,7 +363,7 @@ public: EncodedType = EncType; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, RParenLoc); } @@ -396,7 +397,7 @@ public: void setAtLoc(SourceLocation L) { AtLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, RParenLoc); } @@ -436,7 +437,7 @@ public: void setAtLoc(SourceLocation L) { AtLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, RParenLoc); } @@ -486,7 +487,7 @@ public: SourceLocation getLocation() const { return Loc; } void setLocation(SourceLocation L) { Loc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return isFreeIvar() ? SourceRange(Loc) : SourceRange(getBase()->getLocStart(), Loc); } @@ -666,7 +667,7 @@ public: bool isSuperReceiver() const { return Receiver.is(); } bool isClassReceiver() const { return Receiver.is(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange((isObjectReceiver() ? getBase()->getLocStart() : getReceiverLocation()), IdLoc); @@ -753,7 +754,7 @@ public: SourceLocation getRBracket() const { return RBracket; } void setRBracket(SourceLocation RB) { RBracket = RB; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(SubExprs[BASE]->getLocStart(), RBracket); } @@ -1290,7 +1291,7 @@ public: LBracLoc = R.getBegin(); RBracLoc = R.getEnd(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LBracLoc, RBracLoc); } @@ -1353,7 +1354,7 @@ public: SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getBase()->getLocStart(), IsaMemberLoc); } @@ -1426,7 +1427,7 @@ public: child_range children() { return child_range(&Operand, &Operand+1); } // Source locations are determined by the subexpression. - SourceRange getSourceRange() const { return Operand->getSourceRange(); } + SourceRange getSourceRange() const LLVM_READONLY { return Operand->getSourceRange(); } SourceLocation getExprLoc() const { return getSubExpr()->getExprLoc(); } static bool classof(const Stmt *s) { @@ -1474,7 +1475,7 @@ public: /// \brief The location of the bridge keyword. SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LParenLoc, getSubExpr()->getLocEnd()); } diff --git a/clang/include/clang/AST/NestedNameSpecifier.h b/clang/include/clang/AST/NestedNameSpecifier.h index 228edc301d3a..b5bd824c6504 100644 --- a/clang/include/clang/AST/NestedNameSpecifier.h +++ b/clang/include/clang/AST/NestedNameSpecifier.h @@ -17,6 +17,7 @@ #include "clang/Basic/Diagnostic.h" #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/Support/Compiler.h" namespace clang { @@ -248,7 +249,7 @@ public: /// For example, if this instance refers to a nested-name-specifier /// \c ::std::vector::, the returned source range would cover /// from the initial '::' to the last '::'. - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; /// \brief Retrieve the source range covering just the last part of /// this nested-name-specifier, not including the prefix. @@ -430,7 +431,7 @@ public: void Adopt(NestedNameSpecifierLoc Other); /// \brief Retrieve the source range covered by this nested-name-specifier. - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange(); } diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index d6743443774b..2e2fd84ba6e4 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -20,8 +20,9 @@ #include "clang/AST/StmtIterator.h" #include "clang/AST/DeclGroup.h" #include "clang/AST/ASTContext.h" -#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/raw_ostream.h" #include namespace llvm { @@ -346,10 +347,9 @@ public: /// SourceLocation tokens are not useful in isolation - they are low level /// value objects created/interpreted by SourceManager. We assume AST /// clients will have a pointer to the respective SourceManager. - SourceRange getSourceRange() const; - - SourceLocation getLocStart() const; - SourceLocation getLocEnd() const; + SourceRange getSourceRange() const LLVM_READONLY; + SourceLocation getLocStart() const LLVM_READONLY; + SourceLocation getLocEnd() const LLVM_READONLY; // global temp stats (until we have a per-module visitor) static void addStmtClass(const StmtClass s); @@ -475,7 +475,7 @@ public: SourceLocation getEndLoc() const { return EndLoc; } void setEndLoc(SourceLocation L) { EndLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(StartLoc, EndLoc); } @@ -524,7 +524,7 @@ public: bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; } - SourceRange getSourceRange() const { return SourceRange(SemiLoc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(SemiLoc); } static bool classof(const Stmt *T) { return T->getStmtClass() == NullStmtClass; @@ -604,7 +604,7 @@ public: return const_reverse_body_iterator(body_begin()); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(LBracLoc, RBracLoc); } @@ -649,7 +649,7 @@ public: return const_cast(this)->getSubStmt(); } - SourceRange getSourceRange() const { return SourceRange(); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); } static bool classof(const Stmt *T) { return T->getStmtClass() == CaseStmtClass || @@ -704,7 +704,7 @@ public: void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast(Val); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { // Handle deeply nested case statements with iteration instead of recursion. const CaseStmt *CS = this; while (const CaseStmt *CS2 = dyn_cast(CS->getSubStmt())) @@ -744,7 +744,7 @@ public: SourceLocation getColonLoc() const { return ColonLoc; } void setColonLoc(SourceLocation L) { ColonLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(DefaultLoc, SubStmt->getLocEnd()); } static bool classof(const Stmt *T) { @@ -781,7 +781,7 @@ public: void setIdentLoc(SourceLocation L) { IdentLoc = L; } void setSubStmt(Stmt *SS) { SubStmt = SS; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(IdentLoc, SubStmt->getLocEnd()); } child_range children() { return child_range(&SubStmt, &SubStmt+1); } @@ -842,7 +842,7 @@ public: SourceLocation getElseLoc() const { return ElseLoc; } void setElseLoc(SourceLocation L) { ElseLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { if (SubExprs[ELSE]) return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd()); else @@ -941,7 +941,7 @@ public: return (bool) AllEnumCasesCovered; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd()); } // Iterators @@ -996,7 +996,7 @@ public: SourceLocation getWhileLoc() const { return WhileLoc; } void setWhileLoc(SourceLocation L) { WhileLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd()); } static bool classof(const Stmt *T) { @@ -1045,7 +1045,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(DoLoc, RParenLoc); } static bool classof(const Stmt *T) { @@ -1117,7 +1117,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation L) { RParenLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); } static bool classof(const Stmt *T) { @@ -1152,7 +1152,7 @@ public: SourceLocation getLabelLoc() const { return LabelLoc; } void setLabelLoc(SourceLocation L) { LabelLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(GotoLoc, LabelLoc); } static bool classof(const Stmt *T) { @@ -1196,7 +1196,7 @@ public: return const_cast(this)->getConstantTarget(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(GotoLoc, Target->getLocEnd()); } @@ -1223,7 +1223,7 @@ public: SourceLocation getContinueLoc() const { return ContinueLoc; } void setContinueLoc(SourceLocation L) { ContinueLoc = L; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(ContinueLoc); } @@ -1249,7 +1249,7 @@ public: SourceLocation getBreakLoc() const { return BreakLoc; } void setBreakLoc(SourceLocation L) { BreakLoc = L; } - SourceRange getSourceRange() const { return SourceRange(BreakLoc); } + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(BreakLoc); } static bool classof(const Stmt *T) { return T->getStmtClass() == BreakStmtClass; @@ -1301,7 +1301,7 @@ public: const VarDecl *getNRVOCandidate() const { return NRVOCandidate; } void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == ReturnStmtClass; @@ -1511,7 +1511,7 @@ public: StringLiteral *getClobber(unsigned i) { return Clobbers[i]; } const StringLiteral *getClobber(unsigned i) const { return Clobbers[i]; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AsmLoc, RParenLoc); } @@ -1582,7 +1582,7 @@ public: SourceLocation ExceptLoc, Expr *FilterExpr, Stmt *Block); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getExceptLoc(), getEndLoc()); } @@ -1625,7 +1625,7 @@ public: SourceLocation FinallyLoc, Stmt *Block); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getFinallyLoc(), getEndLoc()); } @@ -1669,7 +1669,7 @@ public: Stmt *TryBlock, Stmt *Handler); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getTryLoc(), getEndLoc()); } diff --git a/clang/include/clang/AST/StmtCXX.h b/clang/include/clang/AST/StmtCXX.h index 8c7231408090..a948722cc1d5 100644 --- a/clang/include/clang/AST/StmtCXX.h +++ b/clang/include/clang/AST/StmtCXX.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_AST_STMTCXX_H #include "clang/AST/Stmt.h" +#include "llvm/Support/Compiler.h" namespace clang { @@ -37,7 +38,7 @@ public: CXXCatchStmt(EmptyShell Empty) : Stmt(CXXCatchStmtClass), ExceptionDecl(0), HandlerBlock(0) {} - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(CatchLoc, HandlerBlock->getLocEnd()); } @@ -83,7 +84,7 @@ public: static CXXTryStmt *Create(ASTContext &C, EmptyShell Empty, unsigned numHandlers); - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getTryLoc(), getEndLoc()); } @@ -189,7 +190,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); } static bool classof(const Stmt *T) { @@ -274,7 +275,7 @@ public: return reinterpret_cast(SubStmt); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(KeywordLoc, SubStmt->getLocEnd()); } diff --git a/clang/include/clang/AST/StmtObjC.h b/clang/include/clang/AST/StmtObjC.h index d996fc5cada3..a32104123b15 100644 --- a/clang/include/clang/AST/StmtObjC.h +++ b/clang/include/clang/AST/StmtObjC.h @@ -15,6 +15,7 @@ #define LLVM_CLANG_AST_STMTOBJC_H #include "clang/AST/Stmt.h" +#include "llvm/Support/Compiler.h" namespace clang { @@ -55,7 +56,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); } static bool classof(const Stmt *T) { @@ -103,7 +104,7 @@ public: SourceLocation getRParenLoc() const { return RParenLoc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtCatchLoc, Body->getLocEnd()); } @@ -133,7 +134,7 @@ public: Stmt *getFinallyBody() { return AtFinallyStmt; } void setFinallyBody(Stmt *S) { AtFinallyStmt = S; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); } @@ -240,7 +241,7 @@ public: getStmts()[1 + NumCatchStmts] = S; } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; static bool classof(const Stmt *T) { return T->getStmtClass() == ObjCAtTryStmtClass; @@ -294,7 +295,7 @@ public: } void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); } @@ -327,7 +328,7 @@ public: SourceLocation getThrowLoc() { return AtThrowLoc; } void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { if (Throw) return SourceRange(AtThrowLoc, Throw->getLocEnd()); else @@ -360,7 +361,7 @@ public: Stmt *getSubStmt() { return SubStmt; } void setSubStmt(Stmt *S) { SubStmt = S; } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(AtLoc, SubStmt->getLocEnd()); } diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h index f56b8df30738..06e4181e713c 100644 --- a/clang/include/clang/AST/TemplateBase.h +++ b/clang/include/clang/AST/TemplateBase.h @@ -15,11 +15,12 @@ #ifndef LLVM_CLANG_AST_TEMPLATEBASE_H #define LLVM_CLANG_AST_TEMPLATEBASE_H -#include "llvm/ADT/APSInt.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/ErrorHandling.h" #include "clang/AST/Type.h" #include "clang/AST/TemplateName.h" +#include "llvm/ADT/APSInt.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/ErrorHandling.h" namespace llvm { class FoldingSetNodeID; @@ -457,7 +458,7 @@ public: } /// \brief - Fetches the full source range of the argument. - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; const TemplateArgument &getArgument() const { return Argument; diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index c0a77d48b3f6..1c750965ae37 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -18,6 +18,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/TemplateBase.h" #include "clang/Basic/Specifiers.h" +#include "llvm/Support/Compiler.h" namespace clang { class ASTContext; @@ -93,11 +94,11 @@ public: SourceLocation getEndLoc() const; /// \brief Get the full source range. - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(getBeginLoc(), getEndLoc()); } - SourceLocation getLocStart() const { return getBeginLoc(); } - SourceLocation getLocEnd() const { return getEndLoc(); } + SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); } + SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); } /// \brief Get the local source range. SourceRange getLocalSourceRange() const { diff --git a/clang/include/clang/Index/ASTLocation.h b/clang/include/clang/Index/ASTLocation.h index 5fc2be2dbea8..45097cc5c3d9 100644 --- a/clang/include/clang/Index/ASTLocation.h +++ b/clang/include/clang/Index/ASTLocation.h @@ -16,6 +16,7 @@ #include "clang/AST/TypeLoc.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/Support/Compiler.h" namespace clang { class Decl; @@ -146,7 +147,7 @@ public: return const_cast(this)->getReferencedDecl(); } - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; void print(raw_ostream &OS) const; }; diff --git a/clang/include/clang/Lex/PreprocessingRecord.h b/clang/include/clang/Lex/PreprocessingRecord.h index 587c2a72984a..c8c894e4b75e 100644 --- a/clang/include/clang/Lex/PreprocessingRecord.h +++ b/clang/include/clang/Lex/PreprocessingRecord.h @@ -21,6 +21,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/Compiler.h" #include namespace clang { @@ -87,7 +88,7 @@ namespace clang { /// \brief Retrieve the source range that covers this entire preprocessed /// entity. - SourceRange getSourceRange() const { return Range; } + SourceRange getSourceRange() const LLVM_READONLY { return Range; } /// \brief Returns true if there was a problem loading the preprocessed /// entity. diff --git a/clang/include/clang/Parse/Parser.h b/clang/include/clang/Parse/Parser.h index abc3717cefd3..e3b6fe2cf4f9 100644 --- a/clang/include/clang/Parse/Parser.h +++ b/clang/include/clang/Parse/Parser.h @@ -20,9 +20,10 @@ #include "clang/Lex/CodeCompletionHandler.h" #include "clang/Sema/Sema.h" #include "clang/Sema/DeclSpec.h" -#include "llvm/Support/PrettyStackTrace.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" +#include "llvm/Support/PrettyStackTrace.h" #include namespace clang { @@ -1115,7 +1116,7 @@ private: /// \brief Whether the last template parameter list was empty. bool LastParameterListWasEmpty; - SourceRange getSourceRange() const; + SourceRange getSourceRange() const LLVM_READONLY; }; /// \brief Contains a late templated function. diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 4f8417a8eadc..e86b4852d667 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -29,6 +29,7 @@ #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/Specifiers.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" namespace clang { @@ -446,9 +447,9 @@ public: CXXScopeSpec &getTypeSpecScope() { return TypeScope; } const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; } - const SourceRange &getSourceRange() const { return Range; } - SourceLocation getLocStart() const { return Range.getBegin(); } - SourceLocation getLocEnd() const { return Range.getEnd(); } + const SourceRange &getSourceRange() const LLVM_READONLY { return Range; } + SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } + SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; } SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; } @@ -966,11 +967,11 @@ public: void setTemplateId(TemplateIdAnnotation *TemplateId); /// \brief Return the source range that covers this unqualified-id. - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(StartLocation, EndLocation); } - SourceLocation getLocStart() const { return StartLocation; } - SourceLocation getLocEnd() const { return EndLocation; } + SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; } + SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; } }; /// CachedTokens - A set of tokens that has been cached for later @@ -1529,9 +1530,9 @@ public: } /// getSourceRange - Get the source range that spans this declarator. - const SourceRange &getSourceRange() const { return Range; } - SourceLocation getLocStart() const { return Range.getBegin(); } - SourceLocation getLocEnd() const { return Range.getEnd(); } + const SourceRange &getSourceRange() const LLVM_READONLY { return Range; } + SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); } + SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); } void SetSourceRange(SourceRange R) { Range = R; } /// SetRangeBegin - Set the start of the source range to Loc, unless it's diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h index 21f80cdc4a7c..33934af10cc6 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h @@ -22,6 +22,7 @@ #include "clang/Basic/SourceManager.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Support/Compiler.h" namespace clang { namespace ento { @@ -110,7 +111,7 @@ public: return Msg->getSuperLoc(); } - SourceRange getSourceRange() const { + SourceRange getSourceRange() const LLVM_READONLY { if (PE) return PE->getSourceRange(); return Msg->getSourceRange();