diff options
author | Chris Lattner <sabre@nondot.org> | 2009-02-15 21:26:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-02-15 21:26:50 +0000 |
commit | f52c0b261cb09bda8d39821f264578b7c5f181bf (patch) | |
tree | ebdd0c240f4eb116611c8457ab57adc020af255f /clang/lib/Basic/SourceManager.cpp | |
parent | 641f1eab779ee5b52bc9be19652a8e1d65508b3d (diff) | |
download | bcm5719-llvm-f52c0b261cb09bda8d39821f264578b7c5f181bf.tar.gz bcm5719-llvm-f52c0b261cb09bda8d39821f264578b7c5f181bf.zip |
add a new SourceManager::getInstantiationRange helper method.
llvm-svn: 64606
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 71bda5b255f..88980efcdaa 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/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; +} + //===----------------------------------------------------------------------===// |