[clang-tools-extra] r269403 - [include-fixer] Rename XrefsDB to SymbolIndex.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Fri May 13 02:27:55 PDT 2016
Author: d0k
Date: Fri May 13 04:27:54 2016
New Revision: 269403
URL: http://llvm.org/viewvc/llvm-project?rev=269403&view=rev
Log:
[include-fixer] Rename XrefsDB to SymbolIndex.
It's not really containing xrefs so the name didn't fit. No functional change.
Added:
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
clang-tools-extra/trunk/include-fixer/SymbolIndex.h
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/XrefsDB.h
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h
- copied, changed from r269402, clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
Removed:
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
clang-tools-extra/trunk/include-fixer/XrefsDB.h
clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
Modified:
clang-tools-extra/trunk/docs/include-fixer.rst
clang-tools-extra/trunk/include-fixer/CMakeLists.txt
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/include-fixer/IncludeFixer.h
clang-tools-extra/trunk/include-fixer/find-all-symbols/SymbolInfo.h
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
Modified: clang-tools-extra/trunk/docs/include-fixer.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/include-fixer.rst?rev=269403&r1=269402&r2=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/include-fixer.rst (original)
+++ clang-tools-extra/trunk/docs/include-fixer.rst Fri May 13 04:27:54 2016
@@ -18,7 +18,7 @@ generated with existing tools.
- Compilation database. Contains the compiler commands for any given file in a
project and can be generated by CMake, see `How To Setup Tooling For LLVM`_.
-- Xrefs database. Contains all symbol information in a project to match a given
+- Symbol index. Contains all symbol information in a project to match a given
identifier to a header file.
Ideally both databases (``compile_commands.json`` and
@@ -30,7 +30,7 @@ so only implementation files can be hand
.. _How To Setup Tooling For LLVM: http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
-Creating an Xrefs Database From a Compilation Database
+Creating a Symbol Index From a Compilation Database
------------------------------------------------------
The include fixer contains :program:`find-all-symbols`, a tool to create a
Modified: clang-tools-extra/trunk/include-fixer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/CMakeLists.txt?rev=269403&r1=269402&r2=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/include-fixer/CMakeLists.txt Fri May 13 04:27:54 2016
@@ -4,9 +4,9 @@ set(LLVM_LINK_COMPONENTS
add_clang_library(clangIncludeFixer
IncludeFixer.cpp
- InMemoryXrefsDB.cpp
- XrefsDBManager.cpp
- YamlXrefsDB.cpp
+ InMemorySymbolIndex.cpp
+ SymbolIndexManager.cpp
+ YamlSymbolIndex.cpp
LINK_LIBS
clangAST
Copied: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp (from r269402, clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp?p2=clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp&p1=clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.cpp Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- InMemoryXrefsDB.cpp -----------------------------------------------===//
+//===-- InMemorySymbolIndex.cpp--------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "InMemoryXrefsDB.h"
+#include "InMemorySymbolIndex.h"
using clang::find_all_symbols::SymbolInfo;
namespace clang {
namespace include_fixer {
-InMemoryXrefsDB::InMemoryXrefsDB(
+InMemorySymbolIndex::InMemorySymbolIndex(
const std::map<std::string, std::vector<std::string>> &LookupTable) {
for (const auto &Entry : LookupTable) {
llvm::StringRef Identifier(Entry.first);
@@ -35,7 +35,8 @@ InMemoryXrefsDB::InMemoryXrefsDB(
}
}
-std::vector<SymbolInfo> InMemoryXrefsDB::search(llvm::StringRef Identifier) {
+std::vector<SymbolInfo>
+InMemorySymbolIndex::search(llvm::StringRef Identifier) {
auto I = LookupTable.find(Identifier);
if (I != LookupTable.end())
return I->second;
Copied: clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h (from r269402, clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h?p2=clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h&p1=clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/InMemorySymbolIndex.h Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- InMemoryXrefsDB.h ---------------------------------------*- C++ -*-===//
+//===-- InMemorySymbolIndex.h -----------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYXREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYXREFSDB_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYSYMBOLINDEX_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYSYMBOLINDEX_H
-#include "XrefsDB.h"
+#include "SymbolIndex.h"
#include <map>
#include <string>
#include <vector>
@@ -19,9 +19,9 @@ namespace clang {
namespace include_fixer {
/// Xref database with fixed content.
-class InMemoryXrefsDB : public XrefsDB {
+class InMemorySymbolIndex : public SymbolIndex {
public:
- InMemoryXrefsDB(
+ InMemorySymbolIndex(
const std::map<std::string, std::vector<std::string>> &LookupTable);
std::vector<clang::find_all_symbols::SymbolInfo>
@@ -35,4 +35,4 @@ private:
} // namespace include_fixer
} // namespace clang
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYXREFSDB_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYSYMBOLINDEX_H
Removed: clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.cpp (removed)
@@ -1,46 +0,0 @@
-//===-- InMemoryXrefsDB.cpp -----------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "InMemoryXrefsDB.h"
-
-using clang::find_all_symbols::SymbolInfo;
-
-namespace clang {
-namespace include_fixer {
-
-InMemoryXrefsDB::InMemoryXrefsDB(
- const std::map<std::string, std::vector<std::string>> &LookupTable) {
- for (const auto &Entry : LookupTable) {
- llvm::StringRef Identifier(Entry.first);
- llvm::SmallVector<llvm::StringRef, 8> Names;
- Identifier.split(Names, "::");
- for (const auto &Header : Entry.second) {
- std::vector<SymbolInfo::Context> Contexts;
- for (auto IdentiferContext = Names.rbegin() + 1;
- IdentiferContext != Names.rend(); ++IdentiferContext) {
- Contexts.emplace_back(SymbolInfo::ContextType::Namespace,
- *IdentiferContext);
- }
-
- SymbolInfo Symbol(Names.back(), SymbolInfo::SymbolKind::Class, Header,
- Contexts, 1);
- this->LookupTable[Symbol.getName()].push_back(Symbol);
- }
- }
-}
-
-std::vector<SymbolInfo> InMemoryXrefsDB::search(llvm::StringRef Identifier) {
- auto I = LookupTable.find(Identifier);
- if (I != LookupTable.end())
- return I->second;
- return {};
-}
-
-} // namespace include_fixer
-} // namespace clang
Removed: clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/InMemoryXrefsDB.h (removed)
@@ -1,38 +0,0 @@
-//===-- InMemoryXrefsDB.h ---------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYXREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYXREFSDB_H
-
-#include "XrefsDB.h"
-#include <map>
-#include <string>
-#include <vector>
-
-namespace clang {
-namespace include_fixer {
-
-/// Xref database with fixed content.
-class InMemoryXrefsDB : public XrefsDB {
-public:
- InMemoryXrefsDB(
- const std::map<std::string, std::vector<std::string>> &LookupTable);
-
- std::vector<clang::find_all_symbols::SymbolInfo>
- search(llvm::StringRef Identifier) override;
-
-private:
- std::map<std::string, std::vector<clang::find_all_symbols::SymbolInfo>>
- LookupTable;
-};
-
-} // namespace include_fixer
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INMEMORYXREFSDB_H
Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=269403&r1=269402&r2=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Fri May 13 04:27:54 2016
@@ -58,8 +58,9 @@ private:
class Action : public clang::ASTFrontendAction,
public clang::ExternalSemaSource {
public:
- explicit Action(XrefsDBManager &XrefsDBMgr, bool MinimizeIncludePaths)
- : XrefsDBMgr(XrefsDBMgr), MinimizeIncludePaths(MinimizeIncludePaths) {}
+ explicit Action(SymbolIndexManager &SymbolIndexMgr, bool MinimizeIncludePaths)
+ : SymbolIndexMgr(SymbolIndexMgr),
+ MinimizeIncludePaths(MinimizeIncludePaths) {}
std::unique_ptr<clang::ASTConsumer>
CreateASTConsumer(clang::CompilerInstance &Compiler,
@@ -246,7 +247,7 @@ private:
DEBUG(llvm::dbgs() << " ...");
std::string error_text;
- auto SearchReply = XrefsDBMgr.search(Query);
+ auto SearchReply = SymbolIndexMgr.search(Query);
DEBUG(llvm::dbgs() << SearchReply.size() << " replies\n");
if (SearchReply.empty())
return clang::TypoCorrection();
@@ -262,7 +263,7 @@ private:
}
/// The client to use to find cross-references.
- XrefsDBManager &XrefsDBMgr;
+ SymbolIndexManager &SymbolIndexMgr;
// Remeber things we looked up to avoid querying things twice.
llvm::StringSet<> SeenQueries;
@@ -328,10 +329,10 @@ void PreprocessorHooks::InclusionDirecti
} // namespace
IncludeFixerActionFactory::IncludeFixerActionFactory(
- XrefsDBManager &XrefsDBMgr,
+ SymbolIndexManager &SymbolIndexMgr,
std::vector<clang::tooling::Replacement> &Replacements,
bool MinimizeIncludePaths)
- : XrefsDBMgr(XrefsDBMgr), Replacements(Replacements),
+ : SymbolIndexMgr(SymbolIndexMgr), Replacements(Replacements),
MinimizeIncludePaths(MinimizeIncludePaths) {}
IncludeFixerActionFactory::~IncludeFixerActionFactory() = default;
@@ -355,7 +356,7 @@ bool IncludeFixerActionFactory::runInvoc
// Run the parser, gather missing includes.
auto ScopedToolAction =
- llvm::make_unique<Action>(XrefsDBMgr, MinimizeIncludePaths);
+ llvm::make_unique<Action>(SymbolIndexMgr, MinimizeIncludePaths);
Compiler.ExecuteAction(*ScopedToolAction);
// Generate replacements.
Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.h?rev=269403&r1=269402&r2=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.h (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.h Fri May 13 04:27:54 2016
@@ -10,7 +10,7 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H
#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_INCLUDEFIXER_H
-#include "XrefsDBManager.h"
+#include "SymbolIndexManager.h"
#include "clang/Tooling/Core/Replacement.h"
#include "clang/Tooling/Tooling.h"
#include <memory>
@@ -27,11 +27,11 @@ namespace include_fixer {
class IncludeFixerActionFactory : public clang::tooling::ToolAction {
public:
- /// \param XrefsDBMgr A source for matching symbols to header files.
+ /// \param SymbolIndexMgr A source for matching symbols to header files.
/// \param Replacements Storage for the output of the fixer.
/// \param MinimizeIncludePaths whether inserted include paths are optimized.
IncludeFixerActionFactory(
- XrefsDBManager &XrefsDBMgr,
+ SymbolIndexManager &SymbolIndexMgr,
std::vector<clang::tooling::Replacement> &Replacements,
bool MinimizeIncludePaths = true);
~IncludeFixerActionFactory() override;
@@ -44,7 +44,7 @@ public:
private:
/// The client to use to find cross-references.
- XrefsDBManager &XrefsDBMgr;
+ SymbolIndexManager &SymbolIndexMgr;
/// Replacements are written here.
std::vector<clang::tooling::Replacement> &Replacements;
Copied: clang-tools-extra/trunk/include-fixer/SymbolIndex.h (from r269402, clang-tools-extra/trunk/include-fixer/XrefsDB.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndex.h?p2=clang-tools-extra/trunk/include-fixer/SymbolIndex.h&p1=clang-tools-extra/trunk/include-fixer/XrefsDB.h&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/XrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndex.h Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- XrefsDB.h - Interface for symbol-header matching --------*- C++ -*-===//
+//===-- SymbolIndex.h - Interface for symbol-header matching ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEX_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEX_H
#include "find-all-symbols/SymbolInfo.h"
#include "llvm/ADT/StringRef.h"
@@ -19,9 +19,9 @@ namespace include_fixer {
/// This class provides an interface for finding all `SymbolInfo`s corresponding
/// to a symbol name from a symbol database.
-class XrefsDB {
+class SymbolIndex {
public:
- virtual ~XrefsDB() = default;
+ virtual ~SymbolIndex() = default;
/// Search for all `SymbolInfo`s corresponding to an identifier.
/// \param Identifier The unqualified identifier being searched for.
@@ -35,4 +35,4 @@ public:
} // namespace include_fixer
} // namespace clang
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEX_H
Copied: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp (from r269402, clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp?p2=clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp&p1=clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.cpp Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- XrefsDBManager.cpp - Managing multiple XrefsDBs ---------*- C++ -*-===//
+//===-- SymbolIndexManager.cpp - Managing multiple SymbolIndices-*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "XrefsDBManager.h"
+#include "SymbolIndexManager.h"
#include "find-all-symbols/SymbolInfo.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
@@ -18,14 +18,14 @@ namespace clang {
namespace include_fixer {
std::vector<std::string>
-XrefsDBManager::search(llvm::StringRef Identifier) const {
+SymbolIndexManager::search(llvm::StringRef Identifier) const {
// The identifier may be fully qualified, so split it and get all the context
// names.
llvm::SmallVector<llvm::StringRef, 8> Names;
Identifier.split(Names, "::");
std::vector<clang::find_all_symbols::SymbolInfo> Symbols;
- for (const auto &DB : XrefsDBs) {
+ for (const auto &DB : SymbolIndices) {
auto Res = DB->search(Names.back().str());
Symbols.insert(Symbols.end(), Res.begin(), Res.end());
}
Copied: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h (from r269402, clang-tools-extra/trunk/include-fixer/XrefsDBManager.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?p2=clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h&p1=clang-tools-extra/trunk/include-fixer/XrefsDBManager.h&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/XrefsDBManager.h (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- XrefsDBManager.h - Managing multiple XrefsDBs -----------*- C++ -*-===//
+//===-- SymbolIndexManager.h - Managing multiple SymbolIndices --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDBMANAGER_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDBMANAGER_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H
-#include "XrefsDB.h"
+#include "SymbolIndex.h"
#include "llvm/ADT/StringRef.h"
namespace clang {
@@ -18,10 +18,10 @@ namespace include_fixer {
/// This class provides an interface for finding the header files corresponding
/// to an indentifier in the source code from multiple symbol databases.
-class XrefsDBManager {
+class SymbolIndexManager {
public:
- void addXrefsDB(std::unique_ptr<XrefsDB> DB) {
- XrefsDBs.push_back(std::move(DB));
+ void addSymbolIndex(std::unique_ptr<SymbolIndex> DB) {
+ SymbolIndices.push_back(std::move(DB));
}
/// Search for header files to be included for an identifier.
@@ -32,11 +32,11 @@ public:
// FIXME: Expose the type name so we can also insert using declarations (or
// fix the usage)
// FIXME: Move mapping from SymbolInfo to headers out of
- // XrefsDBManager::search and return SymbolInfos instead of header paths.
+ // SymbolIndexManager::search and return SymbolInfos instead of header paths.
std::vector<std::string> search(llvm::StringRef Identifier) const;
private:
- std::vector<std::unique_ptr<XrefsDB>> XrefsDBs;
+ std::vector<std::unique_ptr<SymbolIndex>> SymbolIndices;
};
} // namespace include_fixer
Removed: clang-tools-extra/trunk/include-fixer/XrefsDB.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/XrefsDB.h?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/XrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/XrefsDB.h (removed)
@@ -1,38 +0,0 @@
-//===-- XrefsDB.h - Interface for symbol-header matching --------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
-
-#include "find-all-symbols/SymbolInfo.h"
-#include "llvm/ADT/StringRef.h"
-#include <vector>
-
-namespace clang {
-namespace include_fixer {
-
-/// This class provides an interface for finding all `SymbolInfo`s corresponding
-/// to a symbol name from a symbol database.
-class XrefsDB {
-public:
- virtual ~XrefsDB() = default;
-
- /// Search for all `SymbolInfo`s corresponding to an identifier.
- /// \param Identifier The unqualified identifier being searched for.
- /// \returns A list of `SymbolInfo` candidates.
- // FIXME: Expose the type name so we can also insert using declarations (or
- // fix the usage)
- virtual std::vector<clang::find_all_symbols::SymbolInfo>
- search(llvm::StringRef Identifier) = 0;
-};
-
-} // namespace include_fixer
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
Removed: clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/XrefsDBManager.cpp (removed)
@@ -1,70 +0,0 @@
-//===-- XrefsDBManager.cpp - Managing multiple XrefsDBs ---------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "XrefsDBManager.h"
-#include "find-all-symbols/SymbolInfo.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Debug.h"
-
-#define DEBUG_TYPE "include-fixer"
-
-namespace clang {
-namespace include_fixer {
-
-std::vector<std::string>
-XrefsDBManager::search(llvm::StringRef Identifier) const {
- // The identifier may be fully qualified, so split it and get all the context
- // names.
- llvm::SmallVector<llvm::StringRef, 8> Names;
- Identifier.split(Names, "::");
-
- std::vector<clang::find_all_symbols::SymbolInfo> Symbols;
- for (const auto &DB : XrefsDBs) {
- auto Res = DB->search(Names.back().str());
- Symbols.insert(Symbols.end(), Res.begin(), Res.end());
- }
-
- DEBUG(llvm::dbgs() << "Searching " << Names.back() << "... got "
- << Symbols.size() << " results...\n");
-
- std::vector<std::string> Results;
- for (const auto &Symbol : Symbols) {
- // Match the identifier name without qualifier.
- if (Symbol.getName() == Names.back()) {
- bool IsMatched = true;
- auto SymbolContext = Symbol.getContexts().begin();
- // Match the remaining context names.
- for (auto IdentiferContext = Names.rbegin() + 1;
- IdentiferContext != Names.rend() &&
- SymbolContext != Symbol.getContexts().end();
- ++IdentiferContext, ++SymbolContext) {
- if (SymbolContext->second != *IdentiferContext) {
- IsMatched = false;
- break;
- }
- }
-
- if (IsMatched) {
- // FIXME: file path should never be in the form of <...> or "...", but
- // the unit test with fixed database use <...> file path, which might
- // need to be changed.
- // FIXME: if the file path is a system header name, we want to use angle
- // brackets.
- std::string FilePath = Symbol.getFilePath().str();
- Results.push_back((FilePath[0] == '"' || FilePath[0] == '<')
- ? FilePath
- : "\"" + FilePath + "\"");
- }
- }
- }
- return Results;
-}
-
-} // namespace include_fixer
-} // namespace clang
Removed: clang-tools-extra/trunk/include-fixer/XrefsDBManager.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/XrefsDBManager.h?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/XrefsDBManager.h (original)
+++ clang-tools-extra/trunk/include-fixer/XrefsDBManager.h (removed)
@@ -1,45 +0,0 @@
-//===-- XrefsDBManager.h - Managing multiple XrefsDBs -----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDBMANAGER_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDBMANAGER_H
-
-#include "XrefsDB.h"
-#include "llvm/ADT/StringRef.h"
-
-namespace clang {
-namespace include_fixer {
-
-/// This class provides an interface for finding the header files corresponding
-/// to an indentifier in the source code from multiple symbol databases.
-class XrefsDBManager {
-public:
- void addXrefsDB(std::unique_ptr<XrefsDB> DB) {
- XrefsDBs.push_back(std::move(DB));
- }
-
- /// Search for header files to be included for an identifier.
- /// \param Identifier The identifier being searched for. May or may not be
- /// fully qualified.
- /// \returns A list of inclusion candidates, in a format ready for being
- /// pasted after an #include token.
- // FIXME: Expose the type name so we can also insert using declarations (or
- // fix the usage)
- // FIXME: Move mapping from SymbolInfo to headers out of
- // XrefsDBManager::search and return SymbolInfos instead of header paths.
- std::vector<std::string> search(llvm::StringRef Identifier) const;
-
-private:
- std::vector<std::unique_ptr<XrefsDB>> XrefsDBs;
-};
-
-} // namespace include_fixer
-} // namespace clang
-
-#endif
Copied: clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp (from r269402, clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp?p2=clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp&p1=clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.cpp Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- YamlXrefsDB.cpp ---------------------------------------------------===//
+//===-- YamlSymbolIndex.cpp -----------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "YamlXrefsDB.h"
+#include "YamlSymbolIndex.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
@@ -21,20 +21,20 @@ using clang::find_all_symbols::SymbolInf
namespace clang {
namespace include_fixer {
-llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
-YamlXrefsDB::createFromFile(llvm::StringRef FilePath) {
+llvm::ErrorOr<std::unique_ptr<YamlSymbolIndex>>
+YamlSymbolIndex::createFromFile(llvm::StringRef FilePath) {
auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
if (!Buffer)
return Buffer.getError();
- return std::unique_ptr<YamlXrefsDB>(
- new YamlXrefsDB(clang::find_all_symbols::ReadSymbolInfosFromYAML(
+ return std::unique_ptr<YamlSymbolIndex>(
+ new YamlSymbolIndex(clang::find_all_symbols::ReadSymbolInfosFromYAML(
Buffer.get()->getBuffer())));
}
-llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
-YamlXrefsDB::createFromDirectory(llvm::StringRef Directory,
- llvm::StringRef Name) {
+llvm::ErrorOr<std::unique_ptr<YamlSymbolIndex>>
+YamlSymbolIndex::createFromDirectory(llvm::StringRef Directory,
+ llvm::StringRef Name) {
// Walk upwards from Directory, looking for files.
for (llvm::SmallString<128> PathStorage = Directory; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
@@ -47,7 +47,7 @@ YamlXrefsDB::createFromDirectory(llvm::S
return llvm::make_error_code(llvm::errc::no_such_file_or_directory);
}
-std::vector<SymbolInfo> YamlXrefsDB::search(llvm::StringRef Identifier) {
+std::vector<SymbolInfo> YamlSymbolIndex::search(llvm::StringRef Identifier) {
std::vector<SymbolInfo> Results;
for (const auto &Symbol : Symbols) {
if (Symbol.getName() == Identifier)
Copied: clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h (from r269402, clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h?p2=clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h&p1=clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h&r1=269402&r2=269403&rev=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/YamlSymbolIndex.h Fri May 13 04:27:54 2016
@@ -1,4 +1,4 @@
-//===-- YamlXrefsDB.h -------------------------------------------*- C++ -*-===//
+//===-- YamlSymbolIndex.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLSYMBOLINDEX_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLSYMBOLINDEX_H
-#include "XrefsDB.h"
+#include "SymbolIndex.h"
#include "find-all-symbols/SymbolInfo.h"
#include "llvm/Support/ErrorOr.h"
#include <map>
@@ -20,20 +20,21 @@ namespace clang {
namespace include_fixer {
/// Yaml format database.
-class YamlXrefsDB : public XrefsDB {
+class YamlSymbolIndex : public SymbolIndex {
public:
/// Create a new Yaml db from a file.
- static llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
+ static llvm::ErrorOr<std::unique_ptr<YamlSymbolIndex>>
createFromFile(llvm::StringRef FilePath);
/// Look for a file called \c Name in \c Directory and all parent directories.
- static llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
+ static llvm::ErrorOr<std::unique_ptr<YamlSymbolIndex>>
createFromDirectory(llvm::StringRef Directory, llvm::StringRef Name);
std::vector<clang::find_all_symbols::SymbolInfo>
search(llvm::StringRef Identifier) override;
private:
- explicit YamlXrefsDB(std::vector<clang::find_all_symbols::SymbolInfo> Symbols)
+ explicit YamlSymbolIndex(
+ std::vector<clang::find_all_symbols::SymbolInfo> Symbols)
: Symbols(std::move(Symbols)) {}
std::vector<clang::find_all_symbols::SymbolInfo> Symbols;
@@ -42,4 +43,4 @@ private:
} // namespace include_fixer
} // namespace clang
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLSYMBOLINDEX_H
Removed: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.cpp (removed)
@@ -1,60 +0,0 @@
-//===-- YamlXrefsDB.cpp ---------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "YamlXrefsDB.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Errc.h"
-#include "llvm/Support/FileSystem.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
-#include <string>
-#include <vector>
-
-using clang::find_all_symbols::SymbolInfo;
-
-namespace clang {
-namespace include_fixer {
-
-llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
-YamlXrefsDB::createFromFile(llvm::StringRef FilePath) {
- auto Buffer = llvm::MemoryBuffer::getFile(FilePath);
- if (!Buffer)
- return Buffer.getError();
-
- return std::unique_ptr<YamlXrefsDB>(
- new YamlXrefsDB(clang::find_all_symbols::ReadSymbolInfosFromYAML(
- Buffer.get()->getBuffer())));
-}
-
-llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
-YamlXrefsDB::createFromDirectory(llvm::StringRef Directory,
- llvm::StringRef Name) {
- // Walk upwards from Directory, looking for files.
- for (llvm::SmallString<128> PathStorage = Directory; !Directory.empty();
- Directory = llvm::sys::path::parent_path(Directory)) {
- assert(Directory.size() <= PathStorage.size());
- PathStorage.resize(Directory.size()); // Shrink to parent.
- llvm::sys::path::append(PathStorage, Name);
- if (auto DB = createFromFile(PathStorage))
- return DB;
- }
- return llvm::make_error_code(llvm::errc::no_such_file_or_directory);
-}
-
-std::vector<SymbolInfo> YamlXrefsDB::search(llvm::StringRef Identifier) {
- std::vector<SymbolInfo> Results;
- for (const auto &Symbol : Symbols) {
- if (Symbol.getName() == Identifier)
- Results.push_back(Symbol);
- }
- return Results;
-}
-
-} // namespace include_fixer
-} // namespace clang
Removed: clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h?rev=269402&view=auto
==============================================================================
--- clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h (original)
+++ clang-tools-extra/trunk/include-fixer/YamlXrefsDB.h (removed)
@@ -1,45 +0,0 @@
-//===-- YamlXrefsDB.h -------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
-
-#include "XrefsDB.h"
-#include "find-all-symbols/SymbolInfo.h"
-#include "llvm/Support/ErrorOr.h"
-#include <map>
-#include <vector>
-
-namespace clang {
-namespace include_fixer {
-
-/// Yaml format database.
-class YamlXrefsDB : public XrefsDB {
-public:
- /// Create a new Yaml db from a file.
- static llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
- createFromFile(llvm::StringRef FilePath);
- /// Look for a file called \c Name in \c Directory and all parent directories.
- static llvm::ErrorOr<std::unique_ptr<YamlXrefsDB>>
- createFromDirectory(llvm::StringRef Directory, llvm::StringRef Name);
-
- std::vector<clang::find_all_symbols::SymbolInfo>
- search(llvm::StringRef Identifier) override;
-
-private:
- explicit YamlXrefsDB(std::vector<clang::find_all_symbols::SymbolInfo> Symbols)
- : Symbols(std::move(Symbols)) {}
-
- std::vector<clang::find_all_symbols::SymbolInfo> Symbols;
-};
-
-} // namespace include_fixer
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLXREFSDB_H
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=269403&r1=269402&r2=269403&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 Fri May 13 04:27:54 2016
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOL_INFO_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOL_INFO_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
+#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
@@ -110,4 +110,4 @@ std::vector<SymbolInfo> ReadSymbolInfosF
} // namespace find_all_symbols
} // namespace clang
-#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOL_INFO_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_FIND_ALL_SYMBOLS_SYMBOLINFO_H
Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=269403&r1=269402&r2=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Fri May 13 04:27:54 2016
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "InMemoryXrefsDB.h"
+#include "InMemorySymbolIndex.h"
#include "IncludeFixer.h"
-#include "XrefsDBManager.h"
-#include "YamlXrefsDB.h"
+#include "SymbolIndexManager.h"
+#include "YamlSymbolIndex.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/Tooling/CommonOptionsParser.h"
@@ -53,13 +53,13 @@ int includeFixerMain(int argc, const cha
options.getSourcePathList());
// Set up data source.
- auto XrefsDBMgr = llvm::make_unique<include_fixer::XrefsDBManager>();
+ auto SymbolIndexMgr = llvm::make_unique<include_fixer::SymbolIndexManager>();
switch (DatabaseFormat) {
case fixed: {
// Parse input and fill the database with it.
// <symbol>=<header><, header...>
// Multiple symbols can be given, separated by semicolons.
- std::map<std::string, std::vector<std::string>> XrefsMap;
+ std::map<std::string, std::vector<std::string>> SymbolsMap;
SmallVector<StringRef, 4> SemicolonSplits;
StringRef(Input).split(SemicolonSplits, ";");
for (StringRef Pair : SemicolonSplits) {
@@ -69,23 +69,24 @@ int includeFixerMain(int argc, const cha
Split.second.split(CommaSplits, ",");
for (StringRef Header : CommaSplits)
Headers.push_back(Header.trim());
- XrefsMap[Split.first.trim()] = std::move(Headers);
+ SymbolsMap[Split.first.trim()] = std::move(Headers);
}
- XrefsDBMgr->addXrefsDB(
- llvm::make_unique<include_fixer::InMemoryXrefsDB>(std::move(XrefsMap)));
+ SymbolIndexMgr->addSymbolIndex(
+ llvm::make_unique<include_fixer::InMemorySymbolIndex>(
+ std::move(SymbolsMap)));
break;
}
case yaml: {
- llvm::ErrorOr<std::unique_ptr<include_fixer::YamlXrefsDB>> DB(nullptr);
+ llvm::ErrorOr<std::unique_ptr<include_fixer::YamlSymbolIndex>> DB(nullptr);
if (!Input.empty()) {
- DB = include_fixer::YamlXrefsDB::createFromFile(Input);
+ DB = include_fixer::YamlSymbolIndex::createFromFile(Input);
} else {
// If we don't have any input file, look in the directory of the first
// file and its parents.
SmallString<128> AbsolutePath(
tooling::getAbsolutePath(options.getSourcePathList().front()));
StringRef Directory = llvm::sys::path::parent_path(AbsolutePath);
- DB = include_fixer::YamlXrefsDB::createFromDirectory(
+ DB = include_fixer::YamlSymbolIndex::createFromDirectory(
Directory, "find_all_symbols_db.yaml");
}
@@ -95,15 +96,15 @@ int includeFixerMain(int argc, const cha
return 1;
}
- XrefsDBMgr->addXrefsDB(std::move(*DB));
+ SymbolIndexMgr->addSymbolIndex(std::move(*DB));
break;
}
}
// Now run our tool.
std::vector<tooling::Replacement> Replacements;
- include_fixer::IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements,
- MinimizeIncludePaths);
+ include_fixer::IncludeFixerActionFactory Factory(
+ *SymbolIndexMgr, Replacements, MinimizeIncludePaths);
tool.run(&Factory); // Always succeeds.
Modified: clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp?rev=269403&r1=269402&r2=269403&view=diff
==============================================================================
--- clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/include-fixer/IncludeFixerTest.cpp Fri May 13 04:27:54 2016
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "InMemoryXrefsDB.h"
+#include "InMemorySymbolIndex.h"
#include "IncludeFixer.h"
-#include "XrefsDBManager.h"
+#include "SymbolIndexManager.h"
#include "unittests/Tooling/RewriterTestContext.h"
#include "clang/Tooling/Tooling.h"
#include "gtest/gtest.h"
@@ -47,18 +47,19 @@ static bool runOnCode(tooling::ToolActio
static std::string runIncludeFixer(
StringRef Code,
const std::vector<std::string> &ExtraArgs = std::vector<std::string>()) {
- std::map<std::string, std::vector<std::string>> XrefsMap = {
+ std::map<std::string, std::vector<std::string>> SymbolsMap = {
{"std::string", {"<string>"}},
{"std::sting", {"\"sting\""}},
{"std::string::size_type", {"<string>"}},
{"a::b::foo", {"dir/otherdir/qux.h"}},
};
- auto XrefsDBMgr = llvm::make_unique<include_fixer::XrefsDBManager>();
- XrefsDBMgr->addXrefsDB(
- llvm::make_unique<include_fixer::InMemoryXrefsDB>(std::move(XrefsMap)));
+ auto SymbolIndexMgr = llvm::make_unique<include_fixer::SymbolIndexManager>();
+ SymbolIndexMgr->addSymbolIndex(
+ llvm::make_unique<include_fixer::InMemorySymbolIndex>(
+ std::move(SymbolsMap)));
std::vector<clang::tooling::Replacement> Replacements;
- IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements);
+ IncludeFixerActionFactory Factory(*SymbolIndexMgr, Replacements);
runOnCode(&Factory, Code, "input.cc", ExtraArgs);
clang::RewriterTestContext Context;
clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
@@ -84,7 +85,8 @@ TEST(IncludeFixer, Typo) {
runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
// string without "std::" can also be fixed since fixed db results go through
- // XrefsDBManager, and XrefsDBManager matches unqualified identifiers too.
+ // SymbolIndexManager, and SymbolIndexManager matches unqualified identifiers
+ // too.
EXPECT_EQ("#include <string>\nstring foo;\n",
runIncludeFixer("string foo;\n"));
}
More information about the cfe-commits
mailing list