diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-02-09 23:30:07 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-02-09 23:30:07 +0000 |
commit | 441e8fdf94e628ce7fcfba6915fedb9c096b3850 (patch) | |
tree | 5e1b7dbcba18baae4a755b91ca01b412684f181b /clang/lib/Basic/SourceManager.cpp | |
parent | 1e871bcd188e5ec369903d8928bbf1725f149992 (diff) | |
download | bcm5719-llvm-441e8fdf94e628ce7fcfba6915fedb9c096b3850.tar.gz bcm5719-llvm-441e8fdf94e628ce7fcfba6915fedb9c096b3850.zip |
[NFC] Extract method to SourceManager for traversing the macro "stack"
The code for going up the macro arg expansion is duplicated in many
places (and we need it for the analyzer as well, so I did not want to
duplicate it two more times).
This patch is an NFC, so the semantics should remain the same.
Differential Revision: https://reviews.llvm.org/D42458
llvm-svn: 324780
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 0a51985614c..3bf70b66693 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -955,6 +955,12 @@ SourceManager::getImmediateExpansionRange(SourceLocation Loc) const { return Expansion.getExpansionLocRange(); } +SourceLocation SourceManager::getTopMacroCallerLoc(SourceLocation Loc) const { + while (isMacroArgExpansion(Loc)) + Loc = getImmediateSpellingLoc(Loc); + return Loc; +} + /// getExpansionRange - Given a SourceLocation object, return the range of /// tokens covered by the expansion in the ultimate file. std::pair<SourceLocation,SourceLocation> |