[clang-tools-extra] r269173 - [find-all-symbols] Save relative file path for each symbol.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed May 11 04:50:08 PDT 2016
Author: hokein
Date: Wed May 11 06:50:08 2016
New Revision: 269173
URL: http://llvm.org/viewvc/llvm-project?rev=269173&view=rev
Log:
[find-all-symbols] Save relative file path for each symbol.
Summary:
The HeaderSearch::suggestPathToFileForDiagnostics used in include-fixer
doesn't work well with absolute file path, it assumes a relative file
path based on header searching path.
So saving relative file path to make include-fixer get the most
appropriate header path.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D20158
Modified:
clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp?rev=269173&r1=269172&r2=269173&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/FindAllSymbols.cpp Wed May 11 06:50:08 2016
@@ -17,7 +17,6 @@
#include "clang/Tooling/Tooling.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"
using namespace clang::ast_matchers;
@@ -76,21 +75,7 @@ llvm::Optional<SymbolInfo> CreateSymbolI
if (FilePath.empty())
return llvm::None;
- llvm::SmallString<128> AbsolutePath;
- if (llvm::sys::path::is_absolute(FilePath)) {
- AbsolutePath = FilePath;
- } else {
- auto WorkingDir = SM.getFileManager()
- .getVirtualFileSystem()
- ->getCurrentWorkingDirectory();
- if (!WorkingDir)
- return llvm::None;
- AbsolutePath = *WorkingDir;
- llvm::sys::path::append(AbsolutePath, FilePath);
- }
-
- llvm::sys::path::remove_dots(AbsolutePath, true);
- return SymbolInfo(ND->getNameAsString(), Type, AbsolutePath.str(),
+ return SymbolInfo(ND->getNameAsString(), Type, FilePath.str(),
GetContexts(ND), SM.getExpansionLineNumber(Loc));
}
Modified: clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h?rev=269173&r1=269172&r2=269173&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h (original)
+++ clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h Wed May 11 06:50:08 2016
@@ -55,7 +55,7 @@ public:
/// \brief Get symbol type.
SymbolKind getSymbolKind() const;
- /// \brief Get the file path where symbol comes from
+ /// \brief Get a relative file path where symbol comes from.
llvm::StringRef getFilePath() const;
/// \brief Get symbol contexts.
@@ -77,7 +77,8 @@ private:
/// \brief Symbol type.
SymbolKind Type;
- /// \brief The file path where the symbol comes from.
+ /// \brief The file path where the symbol comes from. It's a relative file
+ /// path based on the build directory.
std::string FilePath;
/// \brief Contains information about symbol contexts. Context information is
More information about the cfe-commits
mailing list