diff options
Diffstat (limited to 'lib/Index/ASTLocation.cpp')
-rw-r--r-- | lib/Index/ASTLocation.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Index/ASTLocation.cpp b/lib/Index/ASTLocation.cpp index 4b95d9d554..3cd657b9b9 100644 --- a/lib/Index/ASTLocation.cpp +++ b/lib/Index/ASTLocation.cpp @@ -66,6 +66,10 @@ bool ASTLocation::isImmediateParent(Decl *D, Stmt *Node) { 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 @@ void ASTLocation::print(llvm::raw_ostream &OS) { OS << "] <"; - SourceRange Range = hasStmt() ? getStmt()->getSourceRange() - : getDecl()->getSourceRange(); + SourceRange Range = getSourceRange(); SourceManager &SourceMgr = getDecl()->getASTContext().getSourceManager(); Range.getBegin().print(OS, SourceMgr); OS << ", "; |