aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/SourceManager.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-15 21:26:50 +0000
committerChris Lattner <sabre@nondot.org>2009-02-15 21:26:50 +0000
commit6678133b8ce642f93e5141f056fa643112041ad0 (patch)
tree3a9f46dfb9270efc2f17fb986dd9cf0e23f560b2 /lib/Basic/SourceManager.cpp
parent736166b38235cf6d0ffb67638960d95fb2afcbd6 (diff)
add a new SourceManager::getInstantiationRange helper method.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64606 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r--lib/Basic/SourceManager.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 71bda5b255..88980efcda 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -606,6 +606,24 @@ SourceManager::getImmediateInstantiationRange(SourceLocation Loc) const {
return II.getInstantiationLocRange();
}
+/// getInstantiationRange - Given a SourceLocation object, return the
+/// range of tokens covered by the instantiation in the ultimate file.
+std::pair<SourceLocation,SourceLocation>
+SourceManager::getInstantiationRange(SourceLocation Loc) const {
+ if (Loc.isFileID()) return std::make_pair(Loc, Loc);
+
+ std::pair<SourceLocation,SourceLocation> Res =
+ getImmediateInstantiationRange(Loc);
+
+ // Fully resolve the start and end locations to their ultimate instantiation
+ // points.
+ while (!Res.first.isFileID())
+ Res.first = getImmediateInstantiationRange(Res.first).first;
+ while (!Res.second.isFileID())
+ Res.second = getImmediateInstantiationRange(Res.second).second;
+ return Res;
+}
+
//===----------------------------------------------------------------------===//