Some changes to ASTLocation's methods
-Change hasStmt() to isStmt()
-Add isDecl()
-Add getSourceRange()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74862 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp
index 4b95d9d..3cd657b 100644
--- a/lib/Index/ASTLocation.cpp
+++ b/lib/Index/ASTLocation.cpp
@@ -66,6 +66,10 @@
return D == FindImmediateParent(D, Node);
}
+SourceRange ASTLocation::getSourceRange() const {
+ return isDecl() ? getDecl()->getSourceRange() : getStmt()->getSourceRange();
+}
+
void ASTLocation::print(llvm::raw_ostream &OS) {
assert(isValid() && "ASTLocation is not valid");
@@ -81,8 +85,7 @@
OS << "] <";
- SourceRange Range = hasStmt() ? getStmt()->getSourceRange()
- : getDecl()->getSourceRange();
+ SourceRange Range = getSourceRange();
SourceManager &SourceMgr = getDecl()->getASTContext().getSourceManager();
Range.getBegin().print(OS, SourceMgr);
OS << ", ";