summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/USRGeneration.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2017-02-02 16:13:10 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2017-02-02 16:13:10 +0000
commit5b7a09aca40ead4dd0ca607ae21736219c272846 (patch)
treef70f137e7fe618a5076597e7dc5bec03334cd794 /clang/lib/Index/USRGeneration.cpp
parentf3e421d6e99eca984cec7ee1c6acfd2d7b23d391 (diff)
downloadbcm5719-llvm-5b7a09aca40ead4dd0ca607ae21736219c272846.tar.gz
bcm5719-llvm-5b7a09aca40ead4dd0ca607ae21736219c272846.zip
[index] Provide a more general index::generateUSRForMacro() that doesn't depend on having a PreprocessingRecord.
llvm-svn: 293904
Diffstat (limited to 'clang/lib/Index/USRGeneration.cpp')
-rw-r--r--clang/lib/Index/USRGeneration.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index 58f61c3c65b..f9ed3c47995 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -911,21 +911,30 @@ bool clang::index::generateUSRForDecl(const Decl *D,
bool clang::index::generateUSRForMacro(const MacroDefinitionRecord *MD,
const SourceManager &SM,
SmallVectorImpl<char> &Buf) {
+ if (!MD)
+ return true;
+ return generateUSRForMacro(MD->getName()->getName(), MD->getLocation(),
+ SM, Buf);
+
+}
+
+bool clang::index::generateUSRForMacro(StringRef MacroName, SourceLocation Loc,
+ const SourceManager &SM,
+ SmallVectorImpl<char> &Buf) {
// Don't generate USRs for things with invalid locations.
- if (!MD || MD->getLocation().isInvalid())
+ if (MacroName.empty() || Loc.isInvalid())
return true;
llvm::raw_svector_ostream Out(Buf);
// Assume that system headers are sane. Don't put source location
// information into the USR if the macro comes from a system header.
- SourceLocation Loc = MD->getLocation();
bool ShouldGenerateLocation = !SM.isInSystemHeader(Loc);
Out << getUSRSpacePrefix();
if (ShouldGenerateLocation)
printLoc(Out, Loc, SM, /*IncludeOffset=*/true);
Out << "@macro@";
- Out << MD->getName()->getName();
+ Out << MacroName;
return false;
}
OpenPOWER on IntegriCloud