[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
This commit is contained in:
Daniel Dunbar 2012-03-09 19:35:29 +00:00
parent 14eb175836
commit e4775e1659
21 changed files with 238 additions and 212 deletions

View File

@ -22,6 +22,7 @@
#include "clang/Basic/Linkage.h" #include "clang/Basic/Linkage.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
class CXXTemporary; class CXXTemporary;
@ -379,7 +380,7 @@ public:
bool isGnuLocal() const { return LocStart != getLocation(); } bool isGnuLocal() const { return LocStart != getLocation(); }
void setLocStart(SourceLocation L) { LocStart = L; } void setLocStart(SourceLocation L) { LocStart = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LocStart, getLocation()); return SourceRange(LocStart, getLocation());
} }
@ -500,11 +501,11 @@ public:
return getOriginalNamespace(); return getOriginalNamespace();
} }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LocStart, RBraceLoc); return SourceRange(LocStart, RBraceLoc);
} }
SourceLocation getLocStart() const { return LocStart; } SourceLocation getLocStart() const LLVM_READONLY { return LocStart; }
SourceLocation getRBraceLoc() const { return RBraceLoc; } SourceLocation getRBraceLoc() const { return RBraceLoc; }
void setLocStart(SourceLocation L) { LocStart = L; } void setLocStart(SourceLocation L) { LocStart = L; }
void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
@ -632,8 +633,8 @@ public:
/// range taking into account any outer template declarations. /// range taking into account any outer template declarations.
SourceLocation getOuterLocStart() const; SourceLocation getOuterLocStart() const;
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const { SourceLocation getLocStart() const LLVM_READONLY {
return getOuterLocStart(); return getOuterLocStart();
} }
@ -850,7 +851,7 @@ public:
static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID); static VarDecl *CreateDeserialized(ASTContext &C, unsigned ID);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const LLVM_READONLY;
StorageClass getStorageClass() const { StorageClass getStorageClass() const {
return (StorageClass) VarDeclBits.SClass; return (StorageClass) VarDeclBits.SClass;
@ -1264,7 +1265,7 @@ public:
static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID); static ParmVarDecl *CreateDeserialized(ASTContext &C, unsigned ID);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const LLVM_READONLY;
void setObjCMethodScopeInfo(unsigned parameterIndex) { void setObjCMethodScopeInfo(unsigned parameterIndex) {
ParmVarDeclBits.IsObjCMethodParam = true; ParmVarDeclBits.IsObjCMethodParam = true;
@ -1622,7 +1623,7 @@ public:
void setRangeEnd(SourceLocation E) { EndRangeLoc = E; } 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 /// \brief Returns true if the function has a body (definition). The
/// function body might be in any of the (re-)declarations of this /// function body might be in any of the (re-)declarations of this
@ -2198,7 +2199,7 @@ public:
return cast<RecordDecl>(getDeclContext()); return cast<RecordDecl>(getDeclContext());
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -2234,7 +2235,7 @@ public:
void setInitExpr(Expr *E) { Init = (Stmt*) E; } void setInitExpr(Expr *E) { Init = (Stmt*) E; }
void setInitVal(const llvm::APSInt &V) { Val = V; } void setInitVal(const llvm::APSInt &V) { Val = V; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -2315,9 +2316,9 @@ public:
const Type *getTypeForDecl() const { return TypeForDecl; } const Type *getTypeForDecl() const { return TypeForDecl; }
void setTypeForDecl(const Type *TD) { TypeForDecl = TD; } 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; } void setLocStart(SourceLocation L) { LocStart = L; }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
if (LocStart.isValid()) if (LocStart.isValid())
return SourceRange(LocStart, getLocation()); return SourceRange(LocStart, getLocation());
else else
@ -2401,7 +2402,7 @@ public:
IdentifierInfo *Id, TypeSourceInfo *TInfo); IdentifierInfo *Id, TypeSourceInfo *TInfo);
static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID); static TypedefDecl *CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -2422,7 +2423,7 @@ public:
IdentifierInfo *Id, TypeSourceInfo *TInfo); IdentifierInfo *Id, TypeSourceInfo *TInfo);
static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); static TypeAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -2545,7 +2546,7 @@ public:
/// getOuterLocStart - Return SourceLocation representing start of source /// getOuterLocStart - Return SourceLocation representing start of source
/// range taking into account any outer template declarations. /// range taking into account any outer template declarations.
SourceLocation getOuterLocStart() const; SourceLocation getOuterLocStart() const;
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const LLVM_READONLY;
virtual TagDecl* getCanonicalDecl(); virtual TagDecl* getCanonicalDecl();
const TagDecl* getCanonicalDecl() const { const TagDecl* getCanonicalDecl() const {
@ -3023,7 +3024,7 @@ public:
SourceLocation getAsmLoc() const { return getLocation(); } SourceLocation getAsmLoc() const { return getLocation(); }
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getAsmLoc(), getRParenLoc()); return SourceRange(getAsmLoc(), getRParenLoc());
} }
@ -3174,7 +3175,7 @@ public:
const Capture *end, const Capture *end,
bool capturesCXXThis); bool capturesCXXThis);
virtual SourceRange getSourceRange() const; virtual SourceRange getSourceRange() const LLVM_READONLY;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -3249,7 +3250,7 @@ public:
/// identifiers aren't available. /// identifiers aren't available.
ArrayRef<SourceLocation> getIdentifierLocs() const; ArrayRef<SourceLocation> 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 Decl *D) { return classofKind(D->getKind()); }
static bool classof(const ImportDecl *D) { return true; } static bool classof(const ImportDecl *D) { return true; }

View File

@ -17,8 +17,9 @@
#include "clang/AST/Attr.h" #include "clang/AST/Attr.h"
#include "clang/AST/Type.h" #include "clang/AST/Type.h"
#include "clang/Basic/Specifiers.h" #include "clang/Basic/Specifiers.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/PointerUnion.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/PrettyStackTrace.h"
namespace clang { namespace clang {
class DeclContext; class DeclContext;
@ -337,11 +338,15 @@ protected:
public: public:
/// \brief Source range that this declaration covers. /// \brief Source range that this declaration covers.
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getLocation(), getLocation()); return SourceRange(getLocation(), getLocation());
} }
SourceLocation getLocStart() const { return getSourceRange().getBegin(); } SourceLocation getLocStart() const LLVM_READONLY {
SourceLocation getLocEnd() const { return getSourceRange().getEnd(); } return getSourceRange().getBegin();
}
SourceLocation getLocEnd() const LLVM_READONLY {
return getSourceRange().getEnd();
}
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -375,7 +380,7 @@ public:
bool isInAnonymousNamespace() const; bool isInAnonymousNamespace() const;
ASTContext &getASTContext() const; ASTContext &getASTContext() const LLVM_READONLY;
void setAccess(AccessSpecifier AS) { void setAccess(AccessSpecifier AS) {
Access = AS; Access = AS;

View File

@ -23,6 +23,7 @@
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -130,7 +131,7 @@ public:
/// setColonLoc - Sets the location of the colon. /// setColonLoc - Sets the location of the colon.
void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; } void setColonLoc(SourceLocation CLoc) { ColonLoc = CLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getAccessSpecifierLoc(), getColonLoc()); return SourceRange(getAccessSpecifierLoc(), getColonLoc());
} }
@ -208,9 +209,9 @@ public:
/// getSourceRange - Retrieves the source range that contains the /// getSourceRange - Retrieves the source range that contains the
/// entire base specifier. /// entire base specifier.
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
SourceLocation getLocStart() const { return Range.getBegin(); } SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const { return Range.getEnd(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
/// isVirtual - Determines whether the base class is a virtual base /// isVirtual - Determines whether the base class is a virtual base
/// class (or not). /// class (or not).
@ -1851,7 +1852,7 @@ public:
SourceLocation getSourceLocation() const; SourceLocation getSourceLocation() const;
/// \brief Determine the source range covering the entire initializer. /// \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 /// isWritten - Returns true if this initializer is explicitly written
/// in the source code. /// in the source code.
@ -2334,7 +2335,7 @@ public:
void setExternLoc(SourceLocation L) { ExternLoc = L; } void setExternLoc(SourceLocation L) { ExternLoc = L; }
void setRBraceLoc(SourceLocation L) { RBraceLoc = L; } void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
SourceLocation getLocEnd() const { SourceLocation getLocEnd() const LLVM_READONLY {
if (hasBraces()) if (hasBraces())
return getRBraceLoc(); return getRBraceLoc();
// No braces: get the end location of the (only) declaration in context // No braces: get the end location of the (only) declaration in context
@ -2342,7 +2343,7 @@ public:
return decls_empty() ? getLocation() : decls_begin()->getLocEnd(); return decls_empty() ? getLocation() : decls_begin()->getLocEnd();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(ExternLoc, getLocEnd()); return SourceRange(ExternLoc, getLocEnd());
} }
@ -2446,7 +2447,7 @@ public:
DeclContext *CommonAncestor); DeclContext *CommonAncestor);
static UsingDirectiveDecl *CreateDeserialized(ASTContext &C, unsigned ID); static UsingDirectiveDecl *CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(UsingLoc, getLocation()); return SourceRange(UsingLoc, getLocation());
} }
@ -2538,7 +2539,7 @@ public:
static NamespaceAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID); static NamespaceAliasDecl *CreateDeserialized(ASTContext &C, unsigned ID);
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(NamespaceLoc, IdentLoc); return SourceRange(NamespaceLoc, IdentLoc);
} }
@ -2733,7 +2734,7 @@ public:
static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID); static UsingDecl *CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(UsingLocation, getNameInfo().getEndLoc()); return SourceRange(UsingLocation, getNameInfo().getEndLoc());
} }
@ -2804,7 +2805,7 @@ public:
static UnresolvedUsingValueDecl * static UnresolvedUsingValueDecl *
CreateDeserialized(ASTContext &C, unsigned ID); CreateDeserialized(ASTContext &C, unsigned ID);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(UsingLocation, getNameInfo().getEndLoc()); return SourceRange(UsingLocation, getNameInfo().getEndLoc());
} }
@ -2906,7 +2907,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getLocation(), getRParenLoc()); return SourceRange(getLocation(), getRParenLoc());
} }

View File

@ -16,6 +16,7 @@
#define LLVM_CLANG_AST_DECLFRIEND_H #define LLVM_CLANG_AST_DECLFRIEND_H
#include "clang/AST/DeclCXX.h" #include "clang/AST/DeclCXX.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -100,7 +101,7 @@ public:
} }
/// Retrieves the source range for the friend declaration. /// 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. */ /* FIXME: consider the case of templates wrt start of range. */
if (NamedDecl *ND = getFriendDecl()) if (NamedDecl *ND = getFriendDecl())
return SourceRange(getFriendLoc(), ND->getLocEnd()); return SourceRange(getFriendLoc(), ND->getLocEnd());

View File

@ -17,6 +17,7 @@
#include "clang/AST/Decl.h" #include "clang/AST/Decl.h"
#include "clang/AST/SelectorLocationsKind.h" #include "clang/AST/SelectorLocationsKind.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
class Expr; class Expr;
@ -281,10 +282,10 @@ public:
void setAsRedeclaration(const ObjCMethodDecl *PrevMethod); void setAsRedeclaration(const ObjCMethodDecl *PrevMethod);
// Location information, modeled after the Stmt API. // Location information, modeled after the Stmt API.
SourceLocation getLocStart() const { return getLocation(); } SourceLocation getLocStart() const LLVM_READONLY { return getLocation(); }
SourceLocation getLocEnd() const { return EndLoc; } SourceLocation getLocEnd() const LLVM_READONLY { return EndLoc; }
void setEndLoc(SourceLocation Loc) { EndLoc = Loc; } void setEndLoc(SourceLocation Loc) { EndLoc = Loc; }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getLocation(), EndLoc); return SourceRange(getLocation(), EndLoc);
} }
@ -507,7 +508,7 @@ public:
AtEnd = atEnd; AtEnd = atEnd;
} }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtStart, getAtEndRange().getEnd()); return SourceRange(AtStart, getAtEndRange().getEnd());
} }
@ -637,7 +638,7 @@ public:
static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID); static ObjCInterfaceDecl *CreateDeserialized(ASTContext &C, unsigned ID);
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
if (isThisDeclarationADefinition()) if (isThisDeclarationADefinition())
return ObjCContainerDecl::getSourceRange(); return ObjCContainerDecl::getSourceRange();
@ -1217,7 +1218,7 @@ public:
/// \brief Starts the definition of this Objective-C protocol. /// \brief Starts the definition of this Objective-C protocol.
void startDefinition(); void startDefinition();
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
if (isThisDeclarationADefinition()) if (isThisDeclarationADefinition())
return ObjCContainerDecl::getSourceRange(); return ObjCContainerDecl::getSourceRange();
@ -1868,7 +1869,7 @@ public:
return PropertyIvarDecl; return PropertyIvarDecl;
} }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, getLocation()); return SourceRange(AtLoc, getLocation());
} }
@ -1936,9 +1937,9 @@ public:
static ObjCPropertyImplDecl *CreateDeserialized(ASTContext &C, unsigned ID); 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; } void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
ObjCPropertyDecl *getPropertyDecl() const { ObjCPropertyDecl *getPropertyDecl() const {

View File

@ -18,6 +18,7 @@
#include "clang/AST/Redeclarable.h" #include "clang/AST/Redeclarable.h"
#include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateBase.h"
#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/PointerUnion.h"
#include "llvm/Support/Compiler.h"
#include <limits> #include <limits>
namespace clang { namespace clang {
@ -105,7 +106,7 @@ public:
SourceLocation getLAngleLoc() const { return LAngleLoc; } SourceLocation getLAngleLoc() const { return LAngleLoc; }
SourceLocation getRAngleLoc() const { return RAngleLoc; } SourceLocation getRAngleLoc() const { return RAngleLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(TemplateLoc, RAngleLoc); return SourceRange(TemplateLoc, RAngleLoc);
} }
}; };
@ -239,7 +240,7 @@ public:
return K >= firstTemplate && K <= lastTemplate; return K >= firstTemplate && K <= lastTemplate;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(TemplateParams->getTemplateLoc(), return SourceRange(TemplateParams->getTemplateLoc(),
TemplatedDecl->getSourceRange().getEnd()); TemplatedDecl->getSourceRange().getEnd());
} }
@ -917,7 +918,7 @@ public:
/// \brief Returns whether this is a parameter pack. /// \brief Returns whether this is a parameter pack.
bool isParameterPack() const; bool isParameterPack() const;
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
// Implement isa/cast/dyncast/etc. // Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@ -995,7 +996,7 @@ public:
using TemplateParmPosition::setPosition; using TemplateParmPosition::setPosition;
using TemplateParmPosition::getIndex; using TemplateParmPosition::getIndex;
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
/// \brief Determine whether this template parameter has a default /// \brief Determine whether this template parameter has a default
/// argument. /// argument.
@ -1181,7 +1182,7 @@ public:
DefaultArgumentWasInherited = false; DefaultArgumentWasInherited = false;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
SourceLocation End = getLocation(); SourceLocation End = getLocation();
if (hasDefaultArgument() && !defaultArgumentWasInherited()) if (hasDefaultArgument() && !defaultArgumentWasInherited())
End = getDefaultArgument().getSourceRange().getEnd(); End = getDefaultArgument().getSourceRange().getEnd();
@ -1437,7 +1438,7 @@ public:
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
void Profile(llvm::FoldingSetNodeID &ID) const { void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext()); Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext());

View File

@ -17,6 +17,7 @@
#include "clang/AST/Type.h" #include "clang/AST/Type.h"
#include "clang/AST/CanonicalType.h" #include "clang/AST/CanonicalType.h"
#include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/PartialDiagnostic.h"
#include "llvm/Support/Compiler.h"
namespace llvm { namespace llvm {
template <typename T> struct DenseMapInfo; template <typename T> struct DenseMapInfo;
@ -510,15 +511,15 @@ public:
/// getEndLoc - Retrieve the location of the last token. /// getEndLoc - Retrieve the location of the last token.
SourceLocation getEndLoc() const; SourceLocation getEndLoc() const;
/// getSourceRange - The range of the declaration name. /// getSourceRange - The range of the declaration name.
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
SourceLocation BeginLoc = getBeginLoc(); SourceLocation BeginLoc = getBeginLoc();
SourceLocation EndLoc = getEndLoc(); SourceLocation EndLoc = getEndLoc();
return SourceRange(BeginLoc, EndLoc.isValid() ? EndLoc : BeginLoc); return SourceRange(BeginLoc, EndLoc.isValid() ? EndLoc : BeginLoc);
} }
SourceLocation getLocStart() const { SourceLocation getLocStart() const LLVM_READONLY {
return getBeginLoc(); return getBeginLoc();
} }
SourceLocation getLocEnd() const { SourceLocation getLocEnd() const LLVM_READONLY {
SourceLocation EndLoc = getEndLoc(); SourceLocation EndLoc = getEndLoc();
return EndLoc.isValid() ? EndLoc : getLocStart(); return EndLoc.isValid() ? EndLoc : getLocStart();
} }

View File

@ -27,6 +27,7 @@
#include "llvm/ADT/APFloat.h" #include "llvm/ADT/APFloat.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include <cctype> #include <cctype>
namespace clang { namespace clang {
@ -716,7 +717,7 @@ public:
/// \brief Retrieve the location of this expression. /// \brief Retrieve the location of this expression.
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
if (SourceExpr) return SourceExpr->getSourceRange(); if (SourceExpr) return SourceExpr->getSourceRange();
return Loc; return Loc;
} }
@ -867,9 +868,9 @@ public:
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const; SourceLocation getLocEnd() const LLVM_READONLY;
/// \brief Determine whether this declaration reference was preceded by a /// \brief Determine whether this declaration reference was preceded by a
/// C++ nested-name-specifier, e.g., \c N::foo. /// C++ nested-name-specifier, e.g., \c N::foo.
@ -1067,7 +1068,7 @@ public:
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl); 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == PredefinedExprClass; return T->getStmtClass() == PredefinedExprClass;
@ -1157,7 +1158,7 @@ public:
/// \brief Returns a new empty integer literal. /// \brief Returns a new empty integer literal.
static IntegerLiteral *Create(ASTContext &C, EmptyShell Empty); 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. /// \brief Retrieve the location of the literal.
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
@ -1203,7 +1204,7 @@ public:
return static_cast<CharacterKind>(CharacterLiteralBits.Kind); return static_cast<CharacterKind>(CharacterLiteralBits.Kind);
} }
SourceRange getSourceRange() const { return SourceRange(Loc); } SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); }
unsigned getValue() const { return Value; } unsigned getValue() const { return Value; }
@ -1264,7 +1265,7 @@ public:
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == FloatingLiteralClass; return T->getStmtClass() == FloatingLiteralClass;
@ -1296,7 +1297,7 @@ public:
Expr *getSubExpr() { return cast<Expr>(Val); } Expr *getSubExpr() { return cast<Expr>(Val); }
void setSubExpr(Expr *E) { Val = E; } 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ImaginaryLiteralClass; return T->getStmtClass() == ImaginaryLiteralClass;
} }
@ -1454,7 +1455,7 @@ public:
tokloc_iterator tokloc_begin() const { return TokLocs; } tokloc_iterator tokloc_begin() const { return TokLocs; }
tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; } tokloc_iterator tokloc_end() const { return TokLocs+NumConcatenated; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]); return SourceRange(TokLocs[0], TokLocs[NumConcatenated-1]);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1488,7 +1489,7 @@ public:
Expr *getSubExpr() { return cast<Expr>(Val); } Expr *getSubExpr() { return cast<Expr>(Val); }
void setSubExpr(Expr *E) { Val = E; } 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 '('. /// \brief Get the location of the left parentheses '('.
SourceLocation getLParen() const { return L; } SourceLocation getLParen() const { return L; }
@ -1601,7 +1602,7 @@ public:
/// the given unary opcode. /// the given unary opcode.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc); static OverloadedOperatorKind getOverloadedOperator(Opcode Opc);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
if (isPostfix()) if (isPostfix())
return SourceRange(Val->getLocStart(), Loc); return SourceRange(Val->getLocStart(), Loc);
else else
@ -1723,7 +1724,7 @@ public:
/// the square brackets. For a field or identifier node, the source range /// the square brackets. For a field or identifier node, the source range
/// contains the location of the period (if there is one) and the /// contains the location of the period (if there is one) and the
/// identifier. /// identifier.
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
}; };
private: private:
@ -1805,7 +1806,7 @@ public:
return NumExprs; return NumExprs;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(OperatorLoc, RParenLoc); return SourceRange(OperatorLoc, RParenLoc);
} }
@ -1911,7 +1912,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(OpLoc, RParenLoc); return SourceRange(OpLoc, RParenLoc);
} }
@ -1986,7 +1987,7 @@ public:
return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS()); return cast<Expr>(getRHS()->getType()->isIntegerType() ? getRHS():getLHS());
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getLHS()->getLocStart(), RBracketLoc); return SourceRange(getLHS()->getLocStart(), RBracketLoc);
} }
@ -2126,9 +2127,9 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const; SourceLocation getLocEnd() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() >= firstCallExprConstant && return T->getStmtClass() >= firstCallExprConstant &&
@ -2395,9 +2396,9 @@ public:
SourceLocation getMemberLoc() const { return MemberLoc; } SourceLocation getMemberLoc() const { return MemberLoc; }
void setMemberLoc(SourceLocation L) { MemberLoc = L; } void setMemberLoc(SourceLocation L) { MemberLoc = L; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const; SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocEnd() const; SourceLocation getLocEnd() const LLVM_READONLY;
SourceLocation getExprLoc() const { return MemberLoc; } SourceLocation getExprLoc() const { return MemberLoc; }
@ -2475,7 +2476,7 @@ public:
TInfoAndScope.setPointer(tinfo); TInfoAndScope.setPointer(tinfo);
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
// FIXME: Init should never be null. // FIXME: Init should never be null.
if (!Init) if (!Init)
return SourceRange(); return SourceRange();
@ -2629,13 +2630,13 @@ public:
static ImplicitCastExpr *CreateEmpty(ASTContext &Context, unsigned PathSize); static ImplicitCastExpr *CreateEmpty(ASTContext &Context, unsigned PathSize);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return getSubExpr()->getSourceRange(); return getSubExpr()->getSourceRange();
} }
SourceLocation getLocStart() const { SourceLocation getLocStart() const LLVM_READONLY {
return getSubExpr()->getLocStart(); return getSubExpr()->getLocStart();
} }
SourceLocation getLocEnd() const { SourceLocation getLocEnd() const LLVM_READONLY {
return getSubExpr()->getLocEnd(); return getSubExpr()->getLocEnd();
} }
@ -2732,7 +2733,7 @@ public:
SourceLocation getRParenLoc() const { return RPLoc; } SourceLocation getRParenLoc() const { return RPLoc; }
void setRParenLoc(SourceLocation L) { RPLoc = L; } void setRParenLoc(SourceLocation L) { RPLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd()); return SourceRange(LPLoc, getSubExpr()->getSourceRange().getEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -2804,7 +2805,7 @@ public:
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); } Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
void setRHS(Expr *E) { SubExprs[RHS] = E; } void setRHS(Expr *E) { SubExprs[RHS] = E; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd()); return SourceRange(getLHS()->getLocStart(), getRHS()->getLocEnd());
} }
@ -3035,7 +3036,7 @@ public:
Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); } Expr *getLHS() const { return cast<Expr>(SubExprs[LHS]); }
Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); } Expr *getRHS() const { return cast<Expr>(SubExprs[RHS]); }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd()); return SourceRange(getCond()->getLocStart(), getRHS()->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3117,7 +3118,7 @@ public:
return cast<Expr>(SubExprs[RHS]); return cast<Expr>(SubExprs[RHS]);
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getCommon()->getLocStart(), getFalseExpr()->getLocEnd()); return SourceRange(getCommon()->getLocStart(), getFalseExpr()->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3169,7 +3170,7 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; } SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; } void setLabelLoc(SourceLocation L) { LabelLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AmpAmpLoc, LabelLoc); return SourceRange(AmpAmpLoc, LabelLoc);
} }
@ -3211,7 +3212,7 @@ public:
const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); } const CompoundStmt *getSubStmt() const { return cast<CompoundStmt>(SubStmt); }
void setSubStmt(CompoundStmt *S) { SubStmt = S; } void setSubStmt(CompoundStmt *S) { SubStmt = S; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LParenLoc, RParenLoc); return SourceRange(LParenLoc, RParenLoc);
} }
@ -3261,7 +3262,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(BuiltinLoc, RParenLoc); return SourceRange(BuiltinLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3356,7 +3357,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(BuiltinLoc, RParenLoc); return SourceRange(BuiltinLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3393,7 +3394,7 @@ public:
SourceLocation getTokenLocation() const { return TokenLoc; } SourceLocation getTokenLocation() const { return TokenLoc; }
void setTokenLocation(SourceLocation L) { TokenLoc = L; } void setTokenLocation(SourceLocation L) { TokenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(TokenLoc); return SourceRange(TokenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3439,7 +3440,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(BuiltinLoc, RParenLoc); return SourceRange(BuiltinLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -3619,7 +3620,7 @@ public:
InitListExprBits.InitializesStdInitializerList = ISIL; InitListExprBits.InitializesStdInitializerList = ISIL;
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == InitListExprClass; return T->getStmtClass() == InitListExprClass;
@ -3855,7 +3856,7 @@ public:
SourceLocation getEndLocation() const { SourceLocation getEndLocation() const {
return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc(); return Kind == FieldDesignator ? getFieldLoc() : getRBracketLoc();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getStartLocation(), getEndLocation()); return SourceRange(getStartLocation(), getEndLocation());
} }
}; };
@ -3957,7 +3958,7 @@ public:
SourceRange getDesignatorsSourceRange() const; SourceRange getDesignatorsSourceRange() const;
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == DesignatedInitExprClass; return T->getStmtClass() == DesignatedInitExprClass;
@ -3994,7 +3995,7 @@ public:
} }
static bool classof(const ImplicitValueInitExpr *) { return true; } static bool classof(const ImplicitValueInitExpr *) { return true; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(); return SourceRange();
} }
@ -4032,7 +4033,7 @@ public:
SourceLocation getLParenLoc() const { return LParenLoc; } SourceLocation getLParenLoc() const { return LParenLoc; }
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LParenLoc, RParenLoc); return SourceRange(LParenLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -4147,7 +4148,7 @@ public:
const Expr *getResultExpr() const { return getAssocExpr(getResultIndex()); } const Expr *getResultExpr() const { return getAssocExpr(getResultIndex()); }
Expr *getResultExpr() { return getAssocExpr(getResultIndex()); } Expr *getResultExpr() { return getAssocExpr(getResultIndex()); }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(GenericLoc, RParenLoc); return SourceRange(GenericLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -4213,7 +4214,7 @@ public:
/// aggregate Constant of ConstantInt(s). /// aggregate Constant of ConstantInt(s).
void getEncodedElementAccess(SmallVectorImpl<unsigned> &Elts) const; void getEncodedElementAccess(SmallVectorImpl<unsigned> &Elts) const;
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getBase()->getLocStart(), AccessorLoc); return SourceRange(getBase()->getLocStart(), AccessorLoc);
} }
@ -4256,7 +4257,7 @@ public:
const Stmt *getBody() const; const Stmt *getBody() const;
Stmt *getBody(); Stmt *getBody();
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getCaretLocation(), getBody()->getLocEnd()); return SourceRange(getCaretLocation(), getBody()->getLocEnd());
} }
@ -4295,7 +4296,7 @@ public:
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } 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; } bool isByRef() const { return IsByRef; }
void setByRef(bool BR) { IsByRef = BR; } void setByRef(bool BR) { IsByRef = BR; }
@ -4346,7 +4347,7 @@ public:
/// getRParenLoc - Return the location of final right parenthesis. /// getRParenLoc - Return the location of final right parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(BuiltinLoc, RParenLoc); return SourceRange(BuiltinLoc, RParenLoc);
} }
@ -4478,7 +4479,7 @@ public:
SourceLocation getExprLoc() const { SourceLocation getExprLoc() const {
return getSyntacticForm()->getExprLoc(); return getSyntacticForm()->getExprLoc();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return getSyntacticForm()->getSourceRange(); return getSyntacticForm()->getSourceRange();
} }
@ -4580,7 +4581,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(BuiltinLoc, RParenLoc); return SourceRange(BuiltinLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {

View File

@ -20,6 +20,7 @@
#include "clang/Basic/ExpressionTraits.h" #include "clang/Basic/ExpressionTraits.h"
#include "clang/Basic/Lambda.h" #include "clang/Basic/Lambda.h"
#include "clang/Basic/TypeTraits.h" #include "clang/Basic/TypeTraits.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -73,7 +74,7 @@ public:
/// bracket. /// bracket.
SourceLocation getOperatorLoc() const { return getRParenLoc(); } SourceLocation getOperatorLoc() const { return getRParenLoc(); }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXOperatorCallExprClass; return T->getStmtClass() == CXXOperatorCallExprClass;
@ -183,7 +184,7 @@ public:
/// \brief Retrieve the location of the closing parenthesis. /// \brief Retrieve the location of the closing parenthesis.
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(Loc, RParenLoc); return SourceRange(Loc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -402,7 +403,7 @@ public:
bool getValue() const { return Value; } bool getValue() const { return Value; }
void setValue(bool V) { Value = V; } 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; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -428,7 +429,7 @@ public:
explicit CXXNullPtrLiteralExpr(EmptyShell Empty) explicit CXXNullPtrLiteralExpr(EmptyShell Empty)
: Expr(CXXNullPtrLiteralExprClass, Empty) { } : Expr(CXXNullPtrLiteralExprClass, Empty) { }
SourceRange getSourceRange() const { return SourceRange(Loc); } SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc); }
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -507,7 +508,7 @@ public:
Operand = E; Operand = E;
} }
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
void setSourceRange(SourceRange R) { Range = R; } void setSourceRange(SourceRange R) { Range = R; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -582,7 +583,7 @@ public:
Operand = E; Operand = E;
} }
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
void setSourceRange(SourceRange R) { Range = R; } void setSourceRange(SourceRange R) { Range = R; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -628,7 +629,7 @@ public:
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } 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; } bool isImplicit() const { return Implicit; }
void setImplicit(bool I) { Implicit = I; } void setImplicit(bool I) { Implicit = I; }
@ -678,7 +679,7 @@ public:
/// this variable. /// this variable.
bool isThrownVariableInScope() const { return IsThrownVariableInScope; } bool isThrownVariableInScope() const { return IsThrownVariableInScope; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
if (getSubExpr() == 0) if (getSubExpr() == 0)
return SourceRange(ThrowLoc, ThrowLoc); return SourceRange(ThrowLoc, ThrowLoc);
return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd()); return SourceRange(ThrowLoc, getSubExpr()->getSourceRange().getEnd());
@ -766,7 +767,7 @@ public:
/// used. /// used.
SourceLocation getUsedLocation() const { return Loc; } SourceLocation getUsedLocation() const { return Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
// Default argument expressions have no representation in the // Default argument expressions have no representation in the
// source, so they have an empty source range. // source, so they have an empty source range.
return SourceRange(); return SourceRange();
@ -844,7 +845,7 @@ public:
Expr *getSubExpr() { return cast<Expr>(SubExpr); } Expr *getSubExpr() { return cast<Expr>(SubExpr); }
void setSubExpr(Expr *E) { SubExpr = E; } void setSubExpr(Expr *E) { SubExpr = E; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SubExpr->getSourceRange(); return SubExpr->getSourceRange();
} }
@ -980,7 +981,7 @@ public:
Args[Arg] = ArgExpr; Args[Arg] = ArgExpr;
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
SourceRange getParenRange() const { return ParenRange; } SourceRange getParenRange() const { return ParenRange; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1032,7 +1033,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(TyBeginLoc, RParenLoc); return SourceRange(TyBeginLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1071,7 +1072,7 @@ public:
TypeSourceInfo *getTypeSourceInfo() const { return Type; } TypeSourceInfo *getTypeSourceInfo() const { return Type; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXTemporaryObjectExprClass; return T->getStmtClass() == CXXTemporaryObjectExprClass;
@ -1370,7 +1371,7 @@ public:
} }
static bool classof(const LambdaExpr *) { return true; } static bool classof(const LambdaExpr *) { return true; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(IntroducerRange.getBegin(), ClosingBrace); return SourceRange(IntroducerRange.getBegin(), ClosingBrace);
} }
@ -1411,7 +1412,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXScalarValueInitExprClass; return T->getStmtClass() == CXXScalarValueInitExprClass;
@ -1590,7 +1591,7 @@ public:
SourceRange getDirectInitRange() const { return DirectInitRange; } SourceRange getDirectInitRange() const { return DirectInitRange; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getStartLoc(), getEndLoc()); return SourceRange(getStartLoc(), getEndLoc());
} }
@ -1661,7 +1662,7 @@ public:
/// return an invalid type. /// return an invalid type.
QualType getDestroyedType() const; QualType getDestroyedType() const;
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(Loc, Argument->getLocEnd()); return SourceRange(Loc, Argument->getLocEnd());
} }
@ -1853,7 +1854,7 @@ public:
DestroyedType = PseudoDestructorTypeStorage(Info); DestroyedType = PseudoDestructorTypeStorage(Info);
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXPseudoDestructorExprClass; return T->getStmtClass() == CXXPseudoDestructorExprClass;
@ -1898,7 +1899,7 @@ public:
: Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false), : Expr(UnaryTypeTraitExprClass, Empty), UTT(0), Value(false),
QueriedType() { } QueriedType() { }
SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen);}
UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); } UnaryTypeTrait getTrait() const { return static_cast<UnaryTypeTrait>(UTT); }
@ -1961,7 +1962,7 @@ public:
: Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false), : Expr(BinaryTypeTraitExprClass, Empty), BTT(0), Value(false),
LhsType(), RhsType() { } LhsType(), RhsType() { }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(Loc, RParen); return SourceRange(Loc, RParen);
} }
@ -2069,7 +2070,7 @@ public:
return getTypeSourceInfos() + getNumArgs(); 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == TypeTraitExprClass; return T->getStmtClass() == TypeTraitExprClass;
@ -2129,7 +2130,7 @@ public:
virtual ~ArrayTypeTraitExpr() { } virtual ~ArrayTypeTraitExpr() { }
virtual SourceRange getSourceRange() const { virtual SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(Loc, RParen); return SourceRange(Loc, RParen);
} }
@ -2188,7 +2189,7 @@ public:
: Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false), : Expr(ExpressionTraitExprClass, Empty), ET(0), Value(false),
QueriedExpression() { } QueriedExpression() { }
SourceRange getSourceRange() const { return SourceRange(Loc, RParen);} SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(Loc, RParen);}
ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); } ExpressionTrait getTrait() const { return static_cast<ExpressionTrait>(ET); }
@ -2493,7 +2494,7 @@ public:
/// that was looked in to find these results. /// that was looked in to find these results.
CXXRecordDecl *getNamingClass() const { return NamingClass; } CXXRecordDecl *getNamingClass() const { return NamingClass; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
SourceRange Range(getNameInfo().getSourceRange()); SourceRange Range(getNameInfo().getSourceRange());
if (getQualifierLoc()) if (getQualifierLoc())
Range.setBegin(getQualifierLoc().getBeginLoc()); Range.setBegin(getQualifierLoc().getBeginLoc());
@ -2648,7 +2649,7 @@ public:
return getExplicitTemplateArgs().NumTemplateArgs; return getExplicitTemplateArgs().NumTemplateArgs;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
SourceRange Range(QualifierLoc.getBeginLoc(), getLocation()); SourceRange Range(QualifierLoc.getBeginLoc(), getLocation());
if (hasExplicitTemplateArgs()) if (hasExplicitTemplateArgs())
Range.setEnd(getRAngleLoc()); Range.setEnd(getRAngleLoc());
@ -2723,7 +2724,7 @@ public:
/// when modifying an existing AST to preserve its invariants. /// when modifying an existing AST to preserve its invariants.
void setSubExpr(Expr *E) { SubExpr = E; } void setSubExpr(Expr *E) { SubExpr = E; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SubExpr->getSourceRange(); return SubExpr->getSourceRange();
} }
@ -2841,7 +2842,7 @@ public:
*(arg_begin() + I) = E; *(arg_begin() + I) = E;
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXUnresolvedConstructExprClass; return T->getStmtClass() == CXXUnresolvedConstructExprClass;
@ -3076,7 +3077,7 @@ public:
return getExplicitTemplateArgs().NumTemplateArgs; return getExplicitTemplateArgs().NumTemplateArgs;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
SourceRange Range; SourceRange Range;
if (!isImplicitAccess()) if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin()); Range.setBegin(Base->getSourceRange().getBegin());
@ -3214,7 +3215,7 @@ public:
// expression refers to. // expression refers to.
SourceLocation getMemberLoc() const { return getNameLoc(); } SourceLocation getMemberLoc() const { return getNameLoc(); }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
SourceRange Range = getMemberNameInfo().getSourceRange(); SourceRange Range = getMemberNameInfo().getSourceRange();
if (!isImplicitAccess()) if (!isImplicitAccess())
Range.setBegin(Base->getSourceRange().getBegin()); Range.setBegin(Base->getSourceRange().getBegin());
@ -3266,7 +3267,7 @@ public:
Expr *getOperand() const { return static_cast<Expr*>(Operand); } Expr *getOperand() const { return static_cast<Expr*>(Operand); }
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
bool getValue() const { return Value; } bool getValue() const { return Value; }
@ -3343,7 +3344,7 @@ public:
return llvm::Optional<unsigned>(); return llvm::Optional<unsigned>();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(Pattern->getLocStart(), EllipsisLoc); return SourceRange(Pattern->getLocStart(), EllipsisLoc);
} }
@ -3449,7 +3450,7 @@ public:
return Length; return Length;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(OperatorLoc, RParenLoc); return SourceRange(OperatorLoc, RParenLoc);
} }
@ -3492,7 +3493,7 @@ public:
Param(param), Replacement(replacement), NameLoc(loc) {} Param(param), Replacement(replacement), NameLoc(loc) {}
SourceLocation getNameLoc() const { return NameLoc; } SourceLocation getNameLoc() const { return NameLoc; }
SourceRange getSourceRange() const { return NameLoc; } SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; }
Expr *getReplacement() const { return cast<Expr>(Replacement); } Expr *getReplacement() const { return cast<Expr>(Replacement); }
@ -3556,7 +3557,7 @@ public:
/// template arguments. /// template arguments.
TemplateArgument getArgumentPack() const; TemplateArgument getArgumentPack() const;
SourceRange getSourceRange() const { return NameLoc; } SourceRange getSourceRange() const LLVM_READONLY { return NameLoc; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass; return T->getStmtClass() == SubstNonTypeTemplateParmPackExprClass;
@ -3616,7 +3617,9 @@ public:
return getValueKind() == VK_LValue; return getValueKind() == VK_LValue;
} }
SourceRange getSourceRange() const { return Temporary->getSourceRange(); } SourceRange getSourceRange() const LLVM_READONLY {
return Temporary->getSourceRange();
}
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == MaterializeTemporaryExprClass; return T->getStmtClass() == MaterializeTemporaryExprClass;

View File

@ -18,6 +18,7 @@
#include "clang/AST/Expr.h" #include "clang/AST/Expr.h"
#include "clang/AST/SelectorLocationsKind.h" #include "clang/AST/SelectorLocationsKind.h"
#include "clang/Basic/IdentifierTable.h" #include "clang/Basic/IdentifierTable.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
class IdentifierInfo; class IdentifierInfo;
@ -43,7 +44,7 @@ public:
SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getAtLoc() const { return AtLoc; }
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, String->getLocEnd()); return SourceRange(AtLoc, String->getLocEnd());
} }
@ -72,7 +73,7 @@ public:
bool getValue() const { return Value; } bool getValue() const { return Value; }
void setValue(bool V) { Value = V; } 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; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
@ -111,7 +112,7 @@ public:
SourceLocation getAtLoc() const { return AtLoc; } SourceLocation getAtLoc() const { return AtLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, Number->getSourceRange().getEnd()); return SourceRange(AtLoc, Number->getSourceRange().getEnd());
} }
@ -148,7 +149,7 @@ public:
static ObjCArrayLiteral *CreateEmpty(ASTContext &C, unsigned NumElements); 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCArrayLiteralClass; return T->getStmtClass() == ObjCArrayLiteralClass;
@ -311,7 +312,7 @@ public:
ObjCMethodDecl *getDictWithObjectsMethod() const ObjCMethodDecl *getDictWithObjectsMethod() const
{ return DictWithObjectsMethod; } { return DictWithObjectsMethod; }
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCDictionaryLiteralClass; return T->getStmtClass() == ObjCDictionaryLiteralClass;
@ -362,7 +363,7 @@ public:
EncodedType = EncType; EncodedType = EncType;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, RParenLoc); return SourceRange(AtLoc, RParenLoc);
} }
@ -396,7 +397,7 @@ public:
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, RParenLoc); return SourceRange(AtLoc, RParenLoc);
} }
@ -436,7 +437,7 @@ public:
void setAtLoc(SourceLocation L) { AtLoc = L; } void setAtLoc(SourceLocation L) { AtLoc = L; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, RParenLoc); return SourceRange(AtLoc, RParenLoc);
} }
@ -486,7 +487,7 @@ public:
SourceLocation getLocation() const { return Loc; } SourceLocation getLocation() const { return Loc; }
void setLocation(SourceLocation L) { Loc = L; } void setLocation(SourceLocation L) { Loc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return isFreeIvar() ? SourceRange(Loc) return isFreeIvar() ? SourceRange(Loc)
: SourceRange(getBase()->getLocStart(), Loc); : SourceRange(getBase()->getLocStart(), Loc);
} }
@ -666,7 +667,7 @@ public:
bool isSuperReceiver() const { return Receiver.is<const Type*>(); } bool isSuperReceiver() const { return Receiver.is<const Type*>(); }
bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); } bool isClassReceiver() const { return Receiver.is<ObjCInterfaceDecl*>(); }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange((isObjectReceiver() ? getBase()->getLocStart() return SourceRange((isObjectReceiver() ? getBase()->getLocStart()
: getReceiverLocation()), : getReceiverLocation()),
IdLoc); IdLoc);
@ -753,7 +754,7 @@ public:
SourceLocation getRBracket() const { return RBracket; } SourceLocation getRBracket() const { return RBracket; }
void setRBracket(SourceLocation RB) { RBracket = RB; } void setRBracket(SourceLocation RB) { RBracket = RB; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(SubExprs[BASE]->getLocStart(), RBracket); return SourceRange(SubExprs[BASE]->getLocStart(), RBracket);
} }
@ -1290,7 +1291,7 @@ public:
LBracLoc = R.getBegin(); LBracLoc = R.getBegin();
RBracLoc = R.getEnd(); RBracLoc = R.getEnd();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LBracLoc, RBracLoc); return SourceRange(LBracLoc, RBracLoc);
} }
@ -1353,7 +1354,7 @@ public:
SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; } SourceLocation getIsaMemberLoc() const { return IsaMemberLoc; }
void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; } void setIsaMemberLoc(SourceLocation L) { IsaMemberLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getBase()->getLocStart(), IsaMemberLoc); return SourceRange(getBase()->getLocStart(), IsaMemberLoc);
} }
@ -1426,7 +1427,7 @@ public:
child_range children() { return child_range(&Operand, &Operand+1); } child_range children() { return child_range(&Operand, &Operand+1); }
// Source locations are determined by the subexpression. // 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(); } SourceLocation getExprLoc() const { return getSubExpr()->getExprLoc(); }
static bool classof(const Stmt *s) { static bool classof(const Stmt *s) {
@ -1474,7 +1475,7 @@ public:
/// \brief The location of the bridge keyword. /// \brief The location of the bridge keyword.
SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; } SourceLocation getBridgeKeywordLoc() const { return BridgeKeywordLoc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LParenLoc, getSubExpr()->getLocEnd()); return SourceRange(LParenLoc, getSubExpr()->getLocEnd());
} }

View File

@ -17,6 +17,7 @@
#include "clang/Basic/Diagnostic.h" #include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -248,7 +249,7 @@ public:
/// For example, if this instance refers to a nested-name-specifier /// For example, if this instance refers to a nested-name-specifier
/// \c ::std::vector<int>::, the returned source range would cover /// \c ::std::vector<int>::, the returned source range would cover
/// from the initial '::' to the last '::'. /// 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 /// \brief Retrieve the source range covering just the last part of
/// this nested-name-specifier, not including the prefix. /// this nested-name-specifier, not including the prefix.
@ -430,7 +431,7 @@ public:
void Adopt(NestedNameSpecifierLoc Other); void Adopt(NestedNameSpecifierLoc Other);
/// \brief Retrieve the source range covered by this nested-name-specifier. /// \brief Retrieve the source range covered by this nested-name-specifier.
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange(); return NestedNameSpecifierLoc(Representation, Buffer).getSourceRange();
} }

View File

@ -20,8 +20,9 @@
#include "clang/AST/StmtIterator.h" #include "clang/AST/StmtIterator.h"
#include "clang/AST/DeclGroup.h" #include "clang/AST/DeclGroup.h"
#include "clang/AST/ASTContext.h" #include "clang/AST/ASTContext.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include <string> #include <string>
namespace llvm { namespace llvm {
@ -346,10 +347,9 @@ public:
/// SourceLocation tokens are not useful in isolation - they are low level /// SourceLocation tokens are not useful in isolation - they are low level
/// value objects created/interpreted by SourceManager. We assume AST /// value objects created/interpreted by SourceManager. We assume AST
/// clients will have a pointer to the respective SourceManager. /// clients will have a pointer to the respective SourceManager.
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
SourceLocation getLocStart() const LLVM_READONLY;
SourceLocation getLocStart() const; SourceLocation getLocEnd() const LLVM_READONLY;
SourceLocation getLocEnd() const;
// global temp stats (until we have a per-module visitor) // global temp stats (until we have a per-module visitor)
static void addStmtClass(const StmtClass s); static void addStmtClass(const StmtClass s);
@ -475,7 +475,7 @@ public:
SourceLocation getEndLoc() const { return EndLoc; } SourceLocation getEndLoc() const { return EndLoc; }
void setEndLoc(SourceLocation L) { EndLoc = L; } void setEndLoc(SourceLocation L) { EndLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(StartLoc, EndLoc); return SourceRange(StartLoc, EndLoc);
} }
@ -524,7 +524,7 @@ public:
bool hasLeadingEmptyMacro() const { return HasLeadingEmptyMacro; } 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == NullStmtClass; return T->getStmtClass() == NullStmtClass;
@ -604,7 +604,7 @@ public:
return const_reverse_body_iterator(body_begin()); return const_reverse_body_iterator(body_begin());
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(LBracLoc, RBracLoc); return SourceRange(LBracLoc, RBracLoc);
} }
@ -649,7 +649,7 @@ public:
return const_cast<SwitchCase*>(this)->getSubStmt(); return const_cast<SwitchCase*>(this)->getSubStmt();
} }
SourceRange getSourceRange() const { return SourceRange(); } SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == CaseStmtClass || return T->getStmtClass() == CaseStmtClass ||
@ -704,7 +704,7 @@ public:
void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); } void setRHS(Expr *Val) { SubExprs[RHS] = reinterpret_cast<Stmt*>(Val); }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
// Handle deeply nested case statements with iteration instead of recursion. // Handle deeply nested case statements with iteration instead of recursion.
const CaseStmt *CS = this; const CaseStmt *CS = this;
while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt())) while (const CaseStmt *CS2 = dyn_cast<CaseStmt>(CS->getSubStmt()))
@ -744,7 +744,7 @@ public:
SourceLocation getColonLoc() const { return ColonLoc; } SourceLocation getColonLoc() const { return ColonLoc; }
void setColonLoc(SourceLocation L) { ColonLoc = L; } void setColonLoc(SourceLocation L) { ColonLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(DefaultLoc, SubStmt->getLocEnd()); return SourceRange(DefaultLoc, SubStmt->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -781,7 +781,7 @@ public:
void setIdentLoc(SourceLocation L) { IdentLoc = L; } void setIdentLoc(SourceLocation L) { IdentLoc = L; }
void setSubStmt(Stmt *SS) { SubStmt = SS; } void setSubStmt(Stmt *SS) { SubStmt = SS; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(IdentLoc, SubStmt->getLocEnd()); return SourceRange(IdentLoc, SubStmt->getLocEnd());
} }
child_range children() { return child_range(&SubStmt, &SubStmt+1); } child_range children() { return child_range(&SubStmt, &SubStmt+1); }
@ -842,7 +842,7 @@ public:
SourceLocation getElseLoc() const { return ElseLoc; } SourceLocation getElseLoc() const { return ElseLoc; }
void setElseLoc(SourceLocation L) { ElseLoc = L; } void setElseLoc(SourceLocation L) { ElseLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
if (SubExprs[ELSE]) if (SubExprs[ELSE])
return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd()); return SourceRange(IfLoc, SubExprs[ELSE]->getLocEnd());
else else
@ -941,7 +941,7 @@ public:
return (bool) AllEnumCasesCovered; return (bool) AllEnumCasesCovered;
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd()); return SourceRange(SwitchLoc, SubExprs[BODY]->getLocEnd());
} }
// Iterators // Iterators
@ -996,7 +996,7 @@ public:
SourceLocation getWhileLoc() const { return WhileLoc; } SourceLocation getWhileLoc() const { return WhileLoc; }
void setWhileLoc(SourceLocation L) { WhileLoc = L; } void setWhileLoc(SourceLocation L) { WhileLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd()); return SourceRange(WhileLoc, SubExprs[BODY]->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1045,7 +1045,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(DoLoc, RParenLoc); return SourceRange(DoLoc, RParenLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1117,7 +1117,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; } void setRParenLoc(SourceLocation L) { RParenLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1152,7 +1152,7 @@ public:
SourceLocation getLabelLoc() const { return LabelLoc; } SourceLocation getLabelLoc() const { return LabelLoc; }
void setLabelLoc(SourceLocation L) { LabelLoc = L; } void setLabelLoc(SourceLocation L) { LabelLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(GotoLoc, LabelLoc); return SourceRange(GotoLoc, LabelLoc);
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -1196,7 +1196,7 @@ public:
return const_cast<IndirectGotoStmt*>(this)->getConstantTarget(); return const_cast<IndirectGotoStmt*>(this)->getConstantTarget();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(GotoLoc, Target->getLocEnd()); return SourceRange(GotoLoc, Target->getLocEnd());
} }
@ -1223,7 +1223,7 @@ public:
SourceLocation getContinueLoc() const { return ContinueLoc; } SourceLocation getContinueLoc() const { return ContinueLoc; }
void setContinueLoc(SourceLocation L) { ContinueLoc = L; } void setContinueLoc(SourceLocation L) { ContinueLoc = L; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(ContinueLoc); return SourceRange(ContinueLoc);
} }
@ -1249,7 +1249,7 @@ public:
SourceLocation getBreakLoc() const { return BreakLoc; } SourceLocation getBreakLoc() const { return BreakLoc; }
void setBreakLoc(SourceLocation L) { BreakLoc = L; } 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) { static bool classof(const Stmt *T) {
return T->getStmtClass() == BreakStmtClass; return T->getStmtClass() == BreakStmtClass;
@ -1301,7 +1301,7 @@ public:
const VarDecl *getNRVOCandidate() const { return NRVOCandidate; } const VarDecl *getNRVOCandidate() const { return NRVOCandidate; }
void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; } void setNRVOCandidate(const VarDecl *Var) { NRVOCandidate = Var; }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ReturnStmtClass; return T->getStmtClass() == ReturnStmtClass;
@ -1511,7 +1511,7 @@ public:
StringLiteral *getClobber(unsigned i) { return Clobbers[i]; } StringLiteral *getClobber(unsigned i) { return Clobbers[i]; }
const StringLiteral *getClobber(unsigned i) const { return Clobbers[i]; } const StringLiteral *getClobber(unsigned i) const { return Clobbers[i]; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AsmLoc, RParenLoc); return SourceRange(AsmLoc, RParenLoc);
} }
@ -1582,7 +1582,7 @@ public:
SourceLocation ExceptLoc, SourceLocation ExceptLoc,
Expr *FilterExpr, Expr *FilterExpr,
Stmt *Block); Stmt *Block);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getExceptLoc(), getEndLoc()); return SourceRange(getExceptLoc(), getEndLoc());
} }
@ -1625,7 +1625,7 @@ public:
SourceLocation FinallyLoc, SourceLocation FinallyLoc,
Stmt *Block); Stmt *Block);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getFinallyLoc(), getEndLoc()); return SourceRange(getFinallyLoc(), getEndLoc());
} }
@ -1669,7 +1669,7 @@ public:
Stmt *TryBlock, Stmt *TryBlock,
Stmt *Handler); Stmt *Handler);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getTryLoc(), getEndLoc()); return SourceRange(getTryLoc(), getEndLoc());
} }

View File

@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_STMTCXX_H #define LLVM_CLANG_AST_STMTCXX_H
#include "clang/AST/Stmt.h" #include "clang/AST/Stmt.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -37,7 +38,7 @@ public:
CXXCatchStmt(EmptyShell Empty) CXXCatchStmt(EmptyShell Empty)
: Stmt(CXXCatchStmtClass), ExceptionDecl(0), HandlerBlock(0) {} : Stmt(CXXCatchStmtClass), ExceptionDecl(0), HandlerBlock(0) {}
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(CatchLoc, HandlerBlock->getLocEnd()); return SourceRange(CatchLoc, HandlerBlock->getLocEnd());
} }
@ -83,7 +84,7 @@ public:
static CXXTryStmt *Create(ASTContext &C, EmptyShell Empty, static CXXTryStmt *Create(ASTContext &C, EmptyShell Empty,
unsigned numHandlers); unsigned numHandlers);
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getTryLoc(), getEndLoc()); return SourceRange(getTryLoc(), getEndLoc());
} }
@ -189,7 +190,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -274,7 +275,7 @@ public:
return reinterpret_cast<CompoundStmt *>(SubStmt); return reinterpret_cast<CompoundStmt *>(SubStmt);
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(KeywordLoc, SubStmt->getLocEnd()); return SourceRange(KeywordLoc, SubStmt->getLocEnd());
} }

View File

@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_STMTOBJC_H #define LLVM_CLANG_AST_STMTOBJC_H
#include "clang/AST/Stmt.h" #include "clang/AST/Stmt.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
@ -55,7 +56,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd()); return SourceRange(ForLoc, SubExprs[BODY]->getLocEnd());
} }
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
@ -103,7 +104,7 @@ public:
SourceLocation getRParenLoc() const { return RParenLoc; } SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; } void setRParenLoc(SourceLocation Loc) { RParenLoc = Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtCatchLoc, Body->getLocEnd()); return SourceRange(AtCatchLoc, Body->getLocEnd());
} }
@ -133,7 +134,7 @@ public:
Stmt *getFinallyBody() { return AtFinallyStmt; } Stmt *getFinallyBody() { return AtFinallyStmt; }
void setFinallyBody(Stmt *S) { AtFinallyStmt = S; } void setFinallyBody(Stmt *S) { AtFinallyStmt = S; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd()); return SourceRange(AtFinallyLoc, AtFinallyStmt->getLocEnd());
} }
@ -240,7 +241,7 @@ public:
getStmts()[1 + NumCatchStmts] = S; getStmts()[1 + NumCatchStmts] = S;
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
static bool classof(const Stmt *T) { static bool classof(const Stmt *T) {
return T->getStmtClass() == ObjCAtTryStmtClass; return T->getStmtClass() == ObjCAtTryStmtClass;
@ -294,7 +295,7 @@ public:
} }
void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; } void setSynchExpr(Stmt *S) { SubStmts[SYNC_EXPR] = S; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd()); return SourceRange(AtSynchronizedLoc, getSynchBody()->getLocEnd());
} }
@ -327,7 +328,7 @@ public:
SourceLocation getThrowLoc() { return AtThrowLoc; } SourceLocation getThrowLoc() { return AtThrowLoc; }
void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; } void setThrowLoc(SourceLocation Loc) { AtThrowLoc = Loc; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
if (Throw) if (Throw)
return SourceRange(AtThrowLoc, Throw->getLocEnd()); return SourceRange(AtThrowLoc, Throw->getLocEnd());
else else
@ -360,7 +361,7 @@ public:
Stmt *getSubStmt() { return SubStmt; } Stmt *getSubStmt() { return SubStmt; }
void setSubStmt(Stmt *S) { SubStmt = S; } void setSubStmt(Stmt *S) { SubStmt = S; }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(AtLoc, SubStmt->getLocEnd()); return SourceRange(AtLoc, SubStmt->getLocEnd());
} }

View File

@ -15,11 +15,12 @@
#ifndef LLVM_CLANG_AST_TEMPLATEBASE_H #ifndef LLVM_CLANG_AST_TEMPLATEBASE_H
#define 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/Type.h"
#include "clang/AST/TemplateName.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 { namespace llvm {
class FoldingSetNodeID; class FoldingSetNodeID;
@ -457,7 +458,7 @@ public:
} }
/// \brief - Fetches the full source range of the argument. /// \brief - Fetches the full source range of the argument.
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
const TemplateArgument &getArgument() const { const TemplateArgument &getArgument() const {
return Argument; return Argument;

View File

@ -18,6 +18,7 @@
#include "clang/AST/Decl.h" #include "clang/AST/Decl.h"
#include "clang/AST/TemplateBase.h" #include "clang/AST/TemplateBase.h"
#include "clang/Basic/Specifiers.h" #include "clang/Basic/Specifiers.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
class ASTContext; class ASTContext;
@ -93,11 +94,11 @@ public:
SourceLocation getEndLoc() const; SourceLocation getEndLoc() const;
/// \brief Get the full source range. /// \brief Get the full source range.
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(getBeginLoc(), getEndLoc()); return SourceRange(getBeginLoc(), getEndLoc());
} }
SourceLocation getLocStart() const { return getBeginLoc(); } SourceLocation getLocStart() const LLVM_READONLY { return getBeginLoc(); }
SourceLocation getLocEnd() const { return getEndLoc(); } SourceLocation getLocEnd() const LLVM_READONLY { return getEndLoc(); }
/// \brief Get the local source range. /// \brief Get the local source range.
SourceRange getLocalSourceRange() const { SourceRange getLocalSourceRange() const {

View File

@ -16,6 +16,7 @@
#include "clang/AST/TypeLoc.h" #include "clang/AST/TypeLoc.h"
#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
class Decl; class Decl;
@ -146,7 +147,7 @@ public:
return const_cast<ASTLocation*>(this)->getReferencedDecl(); return const_cast<ASTLocation*>(this)->getReferencedDecl();
} }
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
void print(raw_ostream &OS) const; void print(raw_ostream &OS) const;
}; };

View File

@ -21,6 +21,7 @@
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include "llvm/Support/Compiler.h"
#include <vector> #include <vector>
namespace clang { namespace clang {
@ -87,7 +88,7 @@ namespace clang {
/// \brief Retrieve the source range that covers this entire preprocessed /// \brief Retrieve the source range that covers this entire preprocessed
/// entity. /// entity.
SourceRange getSourceRange() const { return Range; } SourceRange getSourceRange() const LLVM_READONLY { return Range; }
/// \brief Returns true if there was a problem loading the preprocessed /// \brief Returns true if there was a problem loading the preprocessed
/// entity. /// entity.

View File

@ -20,9 +20,10 @@
#include "clang/Lex/CodeCompletionHandler.h" #include "clang/Lex/CodeCompletionHandler.h"
#include "clang/Sema/Sema.h" #include "clang/Sema/Sema.h"
#include "clang/Sema/DeclSpec.h" #include "clang/Sema/DeclSpec.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/PrettyStackTrace.h"
#include <stack> #include <stack>
namespace clang { namespace clang {
@ -1115,7 +1116,7 @@ private:
/// \brief Whether the last template parameter list was empty. /// \brief Whether the last template parameter list was empty.
bool LastParameterListWasEmpty; bool LastParameterListWasEmpty;
SourceRange getSourceRange() const; SourceRange getSourceRange() const LLVM_READONLY;
}; };
/// \brief Contains a late templated function. /// \brief Contains a late templated function.

View File

@ -29,6 +29,7 @@
#include "clang/Basic/OperatorKinds.h" #include "clang/Basic/OperatorKinds.h"
#include "clang/Basic/Specifiers.h" #include "clang/Basic/Specifiers.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ErrorHandling.h"
namespace clang { namespace clang {
@ -446,9 +447,9 @@ public:
CXXScopeSpec &getTypeSpecScope() { return TypeScope; } CXXScopeSpec &getTypeSpecScope() { return TypeScope; }
const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; } const CXXScopeSpec &getTypeSpecScope() const { return TypeScope; }
const SourceRange &getSourceRange() const { return Range; } const SourceRange &getSourceRange() const LLVM_READONLY { return Range; }
SourceLocation getLocStart() const { return Range.getBegin(); } SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const { return Range.getEnd(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; } SourceLocation getTypeSpecWidthLoc() const { return TSWLoc; }
SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; } SourceLocation getTypeSpecComplexLoc() const { return TSCLoc; }
@ -966,11 +967,11 @@ public:
void setTemplateId(TemplateIdAnnotation *TemplateId); void setTemplateId(TemplateIdAnnotation *TemplateId);
/// \brief Return the source range that covers this unqualified-id. /// \brief Return the source range that covers this unqualified-id.
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
return SourceRange(StartLocation, EndLocation); return SourceRange(StartLocation, EndLocation);
} }
SourceLocation getLocStart() const { return StartLocation; } SourceLocation getLocStart() const LLVM_READONLY { return StartLocation; }
SourceLocation getLocEnd() const { return EndLocation; } SourceLocation getLocEnd() const LLVM_READONLY { return EndLocation; }
}; };
/// CachedTokens - A set of tokens that has been cached for later /// 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. /// getSourceRange - Get the source range that spans this declarator.
const SourceRange &getSourceRange() const { return Range; } const SourceRange &getSourceRange() const LLVM_READONLY { return Range; }
SourceLocation getLocStart() const { return Range.getBegin(); } SourceLocation getLocStart() const LLVM_READONLY { return Range.getBegin(); }
SourceLocation getLocEnd() const { return Range.getEnd(); } SourceLocation getLocEnd() const LLVM_READONLY { return Range.getEnd(); }
void SetSourceRange(SourceRange R) { Range = R; } void SetSourceRange(SourceRange R) { Range = R; }
/// SetRangeBegin - Set the start of the source range to Loc, unless it's /// SetRangeBegin - Set the start of the source range to Loc, unless it's

View File

@ -22,6 +22,7 @@
#include "clang/Basic/SourceManager.h" #include "clang/Basic/SourceManager.h"
#include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Compiler.h"
namespace clang { namespace clang {
namespace ento { namespace ento {
@ -110,7 +111,7 @@ public:
return Msg->getSuperLoc(); return Msg->getSuperLoc();
} }
SourceRange getSourceRange() const { SourceRange getSourceRange() const LLVM_READONLY {
if (PE) if (PE)
return PE->getSourceRange(); return PE->getSourceRange();
return Msg->getSourceRange(); return Msg->getSourceRange();