[clang-tools-extra] r306598 - [clangd] Cleanup ClangdUnit.cpp, update docs; NFC
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 28 13:57:28 PDT 2017
Author: omtcyfz
Date: Wed Jun 28 13:57:28 2017
New Revision: 306598
URL: http://llvm.org/viewvc/llvm-project?rev=306598&view=rev
Log:
[clangd] Cleanup ClangdUnit.cpp, update docs; NFC
* Enforce 80 characters limit where appropriate
* Use slightly more descriptive names for searched locations
* Update docs to reflect D34269, which adds "Go To Declaration" functionality
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/docs/clangd.rst
clang-tools-extra/trunk/test/CMakeLists.txt
Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=306598&r1=306597&r2=306598&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Jun 28 13:57:28 2017
@@ -36,7 +36,8 @@ ClangdUnit::ClangdUnit(PathRef FileName,
// Inject the resource dir.
// FIXME: Don't overwrite it if it's already there.
- Commands.front().CommandLine.push_back("-resource-dir=" + std::string(ResourceDir));
+ Commands.front().CommandLine.push_back("-resource-dir=" +
+ std::string(ResourceDir));
IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
CompilerInstance::createDiagnostics(new DiagnosticOptions);
@@ -277,14 +278,14 @@ class DeclarationLocationsFinder : publi
public:
DeclarationLocationsFinder(raw_ostream &OS,
const SourceLocation &SearchedLocation, ASTUnit &Unit) :
- SearchedLocation(SearchedLocation), Unit(Unit) {
- }
+ SearchedLocation(SearchedLocation), Unit(Unit) {}
std::vector<Location> takeLocations() {
// Don't keep the same location multiple times.
// This can happen when nodes in the AST are visited twice.
std::sort(DeclarationLocations.begin(), DeclarationLocations.end());
- auto last = std::unique(DeclarationLocations.begin(), DeclarationLocations.end());
+ auto last =
+ std::unique(DeclarationLocations.begin(), DeclarationLocations.end());
DeclarationLocations.erase(last, DeclarationLocations.end());
return std::move(DeclarationLocations);
}
@@ -312,13 +313,13 @@ private:
SourceLocation LocStart = ValSourceRange.getBegin();
SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(),
0, SourceMgr, LangOpts);
- Position P1;
- P1.line = SourceMgr.getSpellingLineNumber(LocStart) - 1;
- P1.character = SourceMgr.getSpellingColumnNumber(LocStart) - 1;
- Position P2;
- P2.line = SourceMgr.getSpellingLineNumber(LocEnd) - 1;
- P2.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
- Range R = { P1, P2 };
+ Position Begin;
+ Begin.line = SourceMgr.getSpellingLineNumber(LocStart) - 1;
+ Begin.character = SourceMgr.getSpellingColumnNumber(LocStart) - 1;
+ Position End;
+ End.line = SourceMgr.getSpellingLineNumber(LocEnd) - 1;
+ End.character = SourceMgr.getSpellingColumnNumber(LocEnd) - 1;
+ Range R = {Begin, End};
Location L;
L.uri = URI::fromFile(
SourceMgr.getFilename(SourceMgr.getSpellingLoc(LocStart)));
@@ -326,8 +327,7 @@ private:
DeclarationLocations.push_back(L);
}
- void finish() override
- {
+ void finish() override {
// Also handle possible macro at the searched location.
Token Result;
if (!Lexer::getRawToken(SearchedLocation, Result, Unit.getSourceManager(),
@@ -366,8 +366,8 @@ std::vector<Location> ClangdUnit::findDe
SourceLocation SourceLocationBeg = getBeginningOfIdentifier(Pos, FE);
- auto DeclLocationsFinder = std::make_shared<DeclarationLocationsFinder>(llvm::errs(),
- SourceLocationBeg, *Unit);
+ auto DeclLocationsFinder = std::make_shared<DeclarationLocationsFinder>(
+ llvm::errs(), SourceLocationBeg, *Unit);
index::IndexingOptions IndexOpts;
IndexOpts.SystemSymbolFilter =
index::IndexingOptions::SystemSymbolFilterKind::All;
Modified: clang-tools-extra/trunk/docs/clangd.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clangd.rst?rev=306598&r1=306597&r2=306598&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clangd.rst (original)
+++ clang-tools-extra/trunk/docs/clangd.rst Wed Jun 28 13:57:28 2017
@@ -54,7 +54,7 @@ features might be eventually developed o
+-------------------------------------+------------+----------+
| Fix-its | Yes | Yes |
+-------------------------------------+------------+----------+
-| Go to Definition | Yes | No |
+| Go to Definition | Yes | Yes |
+-------------------------------------+------------+----------+
| Source hover | Yes | No |
+-------------------------------------+------------+----------+
@@ -103,4 +103,4 @@ look at the `LLVM Developer Policy
to the `Language Server Protocol
<https://github.com/Microsoft/language-server-protocol>`_ itself would also be
very useful, so that :program:`Clangd` can eventually implement them in a
-conforming way.
\ No newline at end of file
+conforming way.
Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=306598&r1=306597&r2=306598&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Wed Jun 28 13:57:28 2017
@@ -70,5 +70,5 @@ add_lit_testsuite(check-clang-tools "Run
DEPENDS ${CLANG_TOOLS_TEST_DEPS}
ARGS ${CLANG_TOOLS_TEST_EXTRA_ARGS}
)
-set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
+set_target_properties(check-clang-tools PROPERTIES FOLDER "Clang extra tools' tests")
More information about the cfe-commits
mailing list