summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-03-08 07:59:04 +0000
committerJohn McCall <rjmccall@apple.com>2011-03-08 07:59:04 +0000
commit462c055d85ffcea5bec6dfc4f547fe38aedea848 (patch)
treed18804c0ddfab9fc731e80be2a034b0fe37d6dc9 /clang/lib/Sema/Sema.cpp
parentafc8098c9e9da8f315b2d79f04fbc12a765e0dcb (diff)
downloadbcm5719-llvm-462c055d85ffcea5bec6dfc4f547fe38aedea848.tar.gz
bcm5719-llvm-462c055d85ffcea5bec6dfc4f547fe38aedea848.zip
Fix my earlier commit to work with escaped newlines and leave breadcrumbs
in case we want to make a world where we can check intermediate instantiations for this kind of breadcrumb. llvm-svn: 127221
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 4bfb388081d..0846845e26d 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -592,6 +592,27 @@ Sema::Diag(SourceLocation Loc, const PartialDiagnostic& PD) {
return Builder;
}
+/// \brief Looks through the macro-instantiation chain for the given
+/// location, looking for a macro instantiation with the given name.
+/// If one is found, returns true and sets the location to that
+/// instantiation loc.
+bool Sema::findMacroSpelling(SourceLocation &locref, llvm::StringRef name) {
+ SourceLocation loc = locref;
+ if (!loc.isMacroID()) return false;
+
+ // There's no good way right now to look at the intermediate
+ // instantiations, so just jump to the instantiation location.
+ loc = getSourceManager().getInstantiationLoc(loc);
+
+ // If that's written with the name, stop here.
+ llvm::SmallVector<char, 16> buffer;
+ if (getPreprocessor().getSpelling(loc, buffer) == name) {
+ locref = loc;
+ return true;
+ }
+ return false;
+}
+
/// \brief Determines the active Scope associated with the given declaration
/// context.
///
OpenPOWER on IntegriCloud