[PATCH] D19647: [find-all-symbols] Save absolute file path instead of relative file path in SymbolInfo.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 29 02:53:33 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268019: [find-all-symbols] Save absolute file path instead of relative file path in… (authored by hokein).
Changed prior to commit:
http://reviews.llvm.org/D19647?vs=55398&id=55556#toc
Repository:
rL LLVM
http://reviews.llvm.org/D19647
Files:
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
Index: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
===================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
@@ -16,6 +16,7 @@
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Tooling/Tooling.h"
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
using namespace clang::ast_matchers;
@@ -47,19 +48,37 @@
SetContext(ND, Symbol);
Symbol->Name = ND->getNameAsString();
- SourceLocation Loc = Result.SourceManager->getExpansionLoc(ND->getLocation());
+
+ const SourceManager *SM = Result.SourceManager;
+ SourceLocation Loc = SM->getExpansionLoc(ND->getLocation());
if (!Loc.isValid()) {
llvm::errs() << "Declaration " << ND->getNameAsString() << "("
<< ND->getDeclKindName()
<< ") has invalid declaration location.";
return false;
}
- std::string FilePath = Result.SourceManager->getFilename(Loc).str();
+
+ Symbol->LineNumber = SM->getExpansionLineNumber(Loc);
+
+ llvm::StringRef FilePath = SM->getFilename(Loc);
if (FilePath.empty())
return false;
- Symbol->FilePath = FilePath;
- Symbol->LineNumber = Result.SourceManager->getExpansionLineNumber(Loc);
+ llvm::SmallString<128> AbsolutePath;
+ if (llvm::sys::path::is_absolute(FilePath)) {
+ AbsolutePath = FilePath;
+ } else {
+ auto WorkingDir = SM->getFileManager()
+ .getVirtualFileSystem()
+ ->getCurrentWorkingDirectory();
+ if (!WorkingDir)
+ return false;
+ AbsolutePath = *WorkingDir;
+ llvm::sys::path::append(AbsolutePath, FilePath);
+ }
+
+ llvm::sys::path::remove_dots(AbsolutePath, true);
+ Symbol->FilePath = AbsolutePath.str();
return true;
}
} // namespace
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19647.55556.patch
Type: text/x-patch
Size: 1914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160429/a9ec70fc/attachment.bin>
More information about the cfe-commits
mailing list