Author: ibiryukov Date: Thu Jan 3 05:28:05 2019 New Revision: 350303 URL: http://llvm.org/viewvc/llvm-project?rev=350303&view=rev Log: [clangd] clang-format everything. NFC
Modified: clang-tools-extra/trunk/clangd/AST.cpp clang-tools-extra/trunk/clangd/AST.h clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp clang-tools-extra/trunk/clangd/ClangdServer.cpp clang-tools-extra/trunk/clangd/CodeComplete.cpp clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp clang-tools-extra/trunk/clangd/Diagnostics.cpp clang-tools-extra/trunk/clangd/FSProvider.cpp clang-tools-extra/trunk/clangd/FileDistance.h clang-tools-extra/trunk/clangd/FindSymbols.cpp clang-tools-extra/trunk/clangd/Protocol.cpp clang-tools-extra/trunk/clangd/TUScheduler.cpp clang-tools-extra/trunk/clangd/TUScheduler.h clang-tools-extra/trunk/clangd/Trace.cpp clang-tools-extra/trunk/clangd/URI.cpp clang-tools-extra/trunk/clangd/XRefs.cpp clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp clang-tools-extra/trunk/unittests/clangd/DexTests.cpp clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Modified: clang-tools-extra/trunk/clangd/AST.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/AST.cpp (original) +++ clang-tools-extra/trunk/clangd/AST.cpp Thu Jan 3 05:28:05 2019 @@ -44,7 +44,7 @@ bool isSpelledInSourceCode(const Decl *D bool isImplementationDetail(const Decl *D) { return !isSpelledInSourceCode(D); } -SourceLocation findNameLoc(const clang::Decl* D) { +SourceLocation findNameLoc(const clang::Decl *D) { const auto &SM = D->getASTContext().getSourceManager(); if (!isSpelledInSourceCode(D)) // Use the expansion location as spelling location is not interesting. Modified: clang-tools-extra/trunk/clangd/AST.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.h?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/AST.h (original) +++ clang-tools-extra/trunk/clangd/AST.h Thu Jan 3 05:28:05 2019 @@ -14,9 +14,9 @@ #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_AST_H_ +#include "index/Index.h" #include "clang/AST/Decl.h" #include "clang/Basic/SourceLocation.h" -#include "index/Index.h" namespace clang { class SourceManager; Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Jan 3 05:28:05 2019 @@ -163,9 +163,9 @@ private: Server(Other.Server), TraceArgs(Other.TraceArgs) { Other.Server = nullptr; } - ReplyOnce& operator=(ReplyOnce&&) = delete; + ReplyOnce &operator=(ReplyOnce &&) = delete; ReplyOnce(const ReplyOnce &) = delete; - ReplyOnce& operator=(const ReplyOnce&) = delete; + ReplyOnce &operator=(const ReplyOnce &) = delete; ~ReplyOnce() { if (Server && !Replied) { @@ -614,23 +614,23 @@ void ClangdLSPServer::onCodeAction(const void ClangdLSPServer::onCompletion(const TextDocumentPositionParams &Params, Callback<CompletionList> Reply) { - Server->codeComplete(Params.textDocument.uri.file(), Params.position, CCOpts, - Bind( - [this](decltype(Reply) Reply, - Expected<CodeCompleteResult> List) { - if (!List) - return Reply(List.takeError()); - CompletionList LSPList; - LSPList.isIncomplete = List->HasMore; - for (const auto &R : List->Completions) { - CompletionItem C = R.render(CCOpts); - C.kind = adjustKindToCapability( - C.kind, SupportedCompletionItemKinds); - LSPList.items.push_back(std::move(C)); - } - return Reply(std::move(LSPList)); - }, - std::move(Reply))); + Server->codeComplete( + Params.textDocument.uri.file(), Params.position, CCOpts, + Bind( + [this](decltype(Reply) Reply, Expected<CodeCompleteResult> List) { + if (!List) + return Reply(List.takeError()); + CompletionList LSPList; + LSPList.isIncomplete = List->HasMore; + for (const auto &R : List->Completions) { + CompletionItem C = R.render(CCOpts); + C.kind = + adjustKindToCapability(C.kind, SupportedCompletionItemKinds); + LSPList.items.push_back(std::move(C)); + } + return Reply(std::move(LSPList)); + }, + std::move(Reply))); } void ClangdLSPServer::onSignatureHelp(const TextDocumentPositionParams &Params, Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original) +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Jan 3 05:28:05 2019 @@ -159,9 +159,7 @@ void ClangdServer::addDocument(PathRef F WantDiags); } -void ClangdServer::removeDocument(PathRef File) { - WorkScheduler.remove(File); -} +void ClangdServer::removeDocument(PathRef File) { WorkScheduler.remove(File); } void ClangdServer::codeComplete(PathRef File, Position Pos, const clangd::CodeCompleteOptions &Opts, Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Thu Jan 3 05:28:05 2019 @@ -879,38 +879,37 @@ public: IndexRequest.IDs.size(), FetchedDocs.size()); } - llvm::sort( - ScoredSignatures, - [](const ScoredSignature &L, const ScoredSignature &R) { - // Ordering follows: - // - Less number of parameters is better. - // - Function is better than FunctionType which is better than - // Function Template. - // - High score is better. - // - Shorter signature is better. - // - Alphebatically smaller is better. - if (L.Quality.NumberOfParameters != R.Quality.NumberOfParameters) - return L.Quality.NumberOfParameters < R.Quality.NumberOfParameters; - if (L.Quality.NumberOfOptionalParameters != - R.Quality.NumberOfOptionalParameters) - return L.Quality.NumberOfOptionalParameters < - R.Quality.NumberOfOptionalParameters; - if (L.Quality.Kind != R.Quality.Kind) { - using OC = CodeCompleteConsumer::OverloadCandidate; - switch (L.Quality.Kind) { - case OC::CK_Function: - return true; - case OC::CK_FunctionType: - return R.Quality.Kind != OC::CK_Function; - case OC::CK_FunctionTemplate: - return false; - } - llvm_unreachable("Unknown overload candidate type."); - } - if (L.Signature.label.size() != R.Signature.label.size()) - return L.Signature.label.size() < R.Signature.label.size(); - return L.Signature.label < R.Signature.label; - }); + llvm::sort(ScoredSignatures, [](const ScoredSignature &L, + const ScoredSignature &R) { + // Ordering follows: + // - Less number of parameters is better. + // - Function is better than FunctionType which is better than + // Function Template. + // - High score is better. + // - Shorter signature is better. + // - Alphebatically smaller is better. + if (L.Quality.NumberOfParameters != R.Quality.NumberOfParameters) + return L.Quality.NumberOfParameters < R.Quality.NumberOfParameters; + if (L.Quality.NumberOfOptionalParameters != + R.Quality.NumberOfOptionalParameters) + return L.Quality.NumberOfOptionalParameters < + R.Quality.NumberOfOptionalParameters; + if (L.Quality.Kind != R.Quality.Kind) { + using OC = CodeCompleteConsumer::OverloadCandidate; + switch (L.Quality.Kind) { + case OC::CK_Function: + return true; + case OC::CK_FunctionType: + return R.Quality.Kind != OC::CK_Function; + case OC::CK_FunctionTemplate: + return false; + } + llvm_unreachable("Unknown overload candidate type."); + } + if (L.Signature.label.size() != R.Signature.label.size()) + return L.Signature.label.size() < R.Signature.label.size(); + return L.Signature.label < R.Signature.label; + }); for (auto &SS : ScoredSignatures) { auto IndexDocIt = @@ -1224,15 +1223,15 @@ SmallVector<StringRef, 1> getRankedInclu // - TopN determines the results with the best score. class CodeCompleteFlow { PathRef FileName; - IncludeStructure Includes; // Complete once the compiler runs. + IncludeStructure Includes; // Complete once the compiler runs. SpeculativeFuzzyFind *SpecFuzzyFind; // Can be nullptr. const CodeCompleteOptions &Opts; // Sema takes ownership of Recorder. Recorder is valid until Sema cleanup. CompletionRecorder *Recorder = nullptr; int NSema = 0, NIndex = 0, NBoth = 0; // Counters for logging. - bool Incomplete = false; // Would more be available with a higher limit? - Optional<FuzzyMatcher> Filter; // Initialized once Sema runs. + bool Incomplete = false; // Would more be available with a higher limit? + Optional<FuzzyMatcher> Filter; // Initialized once Sema runs. std::vector<std::string> QueryScopes; // Initialized once Sema runs. // Initialized once QueryScopes is initialized, if there are scopes. Optional<ScopeDistance> ScopeProximity; Modified: clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp (original) +++ clang-tools-extra/trunk/clangd/CodeCompletionStrings.cpp Thu Jan 3 05:28:05 2019 @@ -69,7 +69,8 @@ std::string getDeclComment(const ASTCont // Sanity check that the comment does not come from the PCH. We choose to not // write them into PCH, because they are racy and slow to load. assert(!Ctx.getSourceManager().isLoadedSourceLocation(RC->getBeginLoc())); - std::string Doc = RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics()); + std::string Doc = + RC->getFormattedText(Ctx.getSourceManager(), Ctx.getDiagnostics()); return looksLikeDocComment(Doc) ? Doc : ""; } @@ -96,12 +97,12 @@ void getSignature(const CodeCompletionSt // treat them carefully. For Objective-C methods, all typed-text chunks // will end in ':' (unless there are no arguments, in which case we // can safely treat them as C++). - if (!StringRef(Chunk.Text).endswith(":")) { // Treat as C++. + if (!StringRef(Chunk.Text).endswith(":")) { // Treat as C++. if (RequiredQualifiers) *RequiredQualifiers = std::move(*Signature); Signature->clear(); Snippet->clear(); - } else { // Objective-C method with args. + } else { // Objective-C method with args. // If this is the first TypedText to the Objective-C method, discard any // text that we've previously seen (such as previous parameter selector, // which will be marked as Informative text). @@ -111,7 +112,7 @@ void getSignature(const CodeCompletionSt if (!HadObjCArguments) { HadObjCArguments = true; Signature->clear(); - } else { // Subsequent argument, considered part of snippet/signature. + } else { // Subsequent argument, considered part of snippet/signature. *Signature += Chunk.Text; *Snippet += Chunk.Text; } Modified: clang-tools-extra/trunk/clangd/Diagnostics.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Diagnostics.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Diagnostics.cpp (original) +++ clang-tools-extra/trunk/clangd/Diagnostics.cpp Thu Jan 3 05:28:05 2019 @@ -240,9 +240,9 @@ CodeAction toCodeAction(const Fix &F, co return Action; } -void toLSPDiags( - const Diag &D, const URIForFile &File, const ClangdDiagnosticOptions &Opts, - function_ref<void(clangd::Diagnostic, ArrayRef<Fix>)> OutFn) { +void toLSPDiags(const Diag &D, const URIForFile &File, + const ClangdDiagnosticOptions &Opts, + function_ref<void(clangd::Diagnostic, ArrayRef<Fix>)> OutFn) { auto FillBasicFields = [](const DiagBase &D) -> clangd::Diagnostic { clangd::Diagnostic Res; Res.range = D.Range; Modified: clang-tools-extra/trunk/clangd/FSProvider.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FSProvider.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/FSProvider.cpp (original) +++ clang-tools-extra/trunk/clangd/FSProvider.cpp Thu Jan 3 05:28:05 2019 @@ -41,8 +41,7 @@ public: StringRef FileName = llvm::sys::path::filename(Path); if (FileName.startswith("preamble-") && FileName.endswith(".pch")) return File; - return std::unique_ptr<VolatileFile>( - new VolatileFile(std::move(*File))); + return std::unique_ptr<VolatileFile>(new VolatileFile(std::move(*File))); } private: Modified: clang-tools-extra/trunk/clangd/FileDistance.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FileDistance.h?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/FileDistance.h (original) +++ clang-tools-extra/trunk/clangd/FileDistance.h Thu Jan 3 05:28:05 2019 @@ -54,9 +54,9 @@ namespace clang { namespace clangd { struct FileDistanceOptions { - unsigned UpCost = 2; // |foo/bar.h -> foo| - unsigned DownCost = 1; // |foo -> foo/bar.h| - unsigned IncludeCost = 2; // |foo.cc -> included_header.h| + unsigned UpCost = 2; // |foo/bar.h -> foo| + unsigned DownCost = 1; // |foo -> foo/bar.h| + unsigned IncludeCost = 2; // |foo.cc -> included_header.h| bool AllowDownTraversalFromRoot = true; // | / -> /a | }; Modified: clang-tools-extra/trunk/clangd/FindSymbols.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindSymbols.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/FindSymbols.cpp (original) +++ clang-tools-extra/trunk/clangd/FindSymbols.cpp Thu Jan 3 05:28:05 2019 @@ -190,7 +190,7 @@ llvm::Optional<DocumentSymbol> declToSym // sourceLocToPosition won't switch files, so we call getSpellingLoc on top of // that to make sure it does not switch files. // FIXME: sourceLocToPosition should not switch files! - SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc())); + SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc())); SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc())); if (NameLoc.isInvalid() || BeginLoc.isInvalid() || EndLoc.isInvalid()) return llvm::None; Modified: clang-tools-extra/trunk/clangd/Protocol.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Protocol.cpp (original) +++ clang-tools-extra/trunk/clangd/Protocol.cpp Thu Jan 3 05:28:05 2019 @@ -386,21 +386,21 @@ bool fromJSON(const json::Value &Params, raw_ostream &operator<<(raw_ostream &OS, const Diagnostic &D) { OS << D.range << " ["; switch (D.severity) { - case 1: - OS << "error"; - break; - case 2: - OS << "warning"; - break; - case 3: - OS << "note"; - break; - case 4: - OS << "remark"; - break; - default: - OS << "diagnostic"; - break; + case 1: + OS << "error"; + break; + case 2: + OS << "warning"; + break; + case 3: + OS << "note"; + break; + case 4: + OS << "remark"; + break; + default: + OS << "diagnostic"; + break; } return OS << '(' << D.severity << "): " << D.message << "]"; } @@ -718,7 +718,8 @@ json::Value toJSON(const DocumentHighlig llvm::json::Value toJSON(const FileStatus &FStatus) { return json::Object{ - {"uri", FStatus.uri}, {"state", FStatus.state}, + {"uri", FStatus.uri}, + {"state", FStatus.state}, }; } Modified: clang-tools-extra/trunk/clangd/TUScheduler.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/TUScheduler.cpp (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.cpp Thu Jan 3 05:28:05 2019 @@ -18,8 +18,8 @@ // preamble. However, unlike AST, the same preamble can be read concurrently, so // we run each of async preamble reads on its own thread. // -// To limit the concurrent load that clangd produces we maintain a semaphore that -// keeps more than a fixed number of threads from running concurrently. +// To limit the concurrent load that clangd produces we maintain a semaphore +// that keeps more than a fixed number of threads from running concurrently. // // Rationale for cancelling updates. // LSP clients can send updates to clangd on each keystroke. Some files take @@ -334,8 +334,9 @@ ASTWorker::ASTWorker(PathRef FileName, T bool StorePreamblesInMemory, ParsingCallbacks &Callbacks) : IdleASTs(LRUCache), RunSync(RunSync), UpdateDebounce(UpdateDebounce), FileName(FileName), StorePreambleInMemory(StorePreamblesInMemory), - Callbacks(Callbacks), PCHs(std::move(PCHs)), - Status{TUAction(TUAction::Idle, ""), TUStatus::BuildDetails()}, + Callbacks(Callbacks), + PCHs(std::move(PCHs)), Status{TUAction(TUAction::Idle, ""), + TUStatus::BuildDetails()}, Barrier(Barrier), Done(false) {} ASTWorker::~ASTWorker() { @@ -537,9 +538,7 @@ void ASTWorker::getCurrentPreamble( RequestsCV.notify_all(); } -void ASTWorker::waitForFirstPreamble() const { - PreambleWasBuilt.wait(); -} +void ASTWorker::waitForFirstPreamble() const { PreambleWasBuilt.wait(); } std::size_t ASTWorker::getUsedBytes() const { // Note that we don't report the size of ASTs currently used for processing Modified: clang-tools-extra/trunk/clangd/TUScheduler.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/TUScheduler.h?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/TUScheduler.h (original) +++ clang-tools-extra/trunk/clangd/TUScheduler.h Thu Jan 3 05:28:05 2019 @@ -226,12 +226,13 @@ private: /// propagated. template <typename T> std::future<T> runAsync(llvm::unique_function<T()> Action) { - return std::async(std::launch::async, - [](llvm::unique_function<T()> &&Action, Context Ctx) { - WithContext WithCtx(std::move(Ctx)); - return Action(); - }, - std::move(Action), Context::current().clone()); + return std::async( + std::launch::async, + [](llvm::unique_function<T()> &&Action, Context Ctx) { + WithContext WithCtx(std::move(Ctx)); + return Action(); + }, + std::move(Action), Context::current().clone()); } } // namespace clangd Modified: clang-tools-extra/trunk/clangd/Trace.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Trace.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/Trace.cpp (original) +++ clang-tools-extra/trunk/clangd/Trace.cpp Thu Jan 3 05:28:05 2019 @@ -124,9 +124,7 @@ private: } // May be called by any thread. - void markEnded() { - EndTime = Tracer->timestamp(); - } + void markEnded() { EndTime = Tracer->timestamp(); } private: static int64_t nextID() { Modified: clang-tools-extra/trunk/clangd/URI.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/URI.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/URI.cpp (original) +++ clang-tools-extra/trunk/clangd/URI.cpp Thu Jan 3 05:28:05 2019 @@ -229,7 +229,7 @@ Expected<std::string> URI::resolvePath(S if (!sys::path::is_absolute(AbsPath)) llvm_unreachable(("Not a valid absolute path: " + AbsPath).str().c_str()); for (auto &Entry : URISchemeRegistry::entries()) { - auto S = Entry.instantiate(); + auto S = Entry.instantiate(); auto U = S->uriFromAbsolutePath(AbsPath); // For some paths, conversion to different URI schemes is impossible. These // should be just skipped. Modified: clang-tools-extra/trunk/clangd/XRefs.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/XRefs.cpp (original) +++ clang-tools-extra/trunk/clangd/XRefs.cpp Thu Jan 3 05:28:05 2019 @@ -46,8 +46,7 @@ void logIfOverflow(const SymbolLocation // TUPath is used to resolve the path of URI. // FIXME: figure out a good home for it, and share the implementation with // FindSymbols. -Optional<Location> toLSPLocation(const SymbolLocation &Loc, - StringRef TUPath) { +Optional<Location> toLSPLocation(const SymbolLocation &Loc, StringRef TUPath) { if (!Loc) return None; auto Uri = URI::parse(Loc.FileURI); @@ -336,8 +335,7 @@ std::vector<Location> findDefinitions(Pa for (auto It : CandidatesIndex) QueryRequest.IDs.insert(It.first); std::string TUPath; - const FileEntry *FE = - SM.getFileEntryForID(SM.getMainFileID()); + const FileEntry *FE = SM.getFileEntryForID(SM.getMainFileID()); if (auto Path = getCanonicalPath(FE, SM)) TUPath = *Path; // Query the index and populate the empty slot. Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Thu Jan 3 05:28:05 2019 @@ -477,8 +477,8 @@ int hello; Locations = runFindDefinitions(Server, FooCpp, FooSource.point()); EXPECT_TRUE(bool(Locations)); - EXPECT_THAT(*Locations, ElementsAre(FileRange(FooCpp, - FooSource.range("two")))); + EXPECT_THAT(*Locations, + ElementsAre(FileRange(FooCpp, FooSource.range("two")))); } TEST_F(ClangdVFSTest, MemoryUsage) { Modified: clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp Thu Jan 3 05:28:05 2019 @@ -255,20 +255,19 @@ main.cpp:2:3: error: something terrible // Transform dianostics and check the results. std::vector<std::pair<clangd::Diagnostic, std::vector<clangd::Fix>>> LSPDiags; - toLSPDiags( - D, + toLSPDiags(D, #ifdef _WIN32 - URIForFile::canonicalize("c:\\path\\to\\foo\\bar\\main.cpp", - /*TUPath=*/""), + URIForFile::canonicalize("c:\\path\\to\\foo\\bar\\main.cpp", + /*TUPath=*/""), #else URIForFile::canonicalize("/path/to/foo/bar/main.cpp", /*TUPath=*/""), #endif - ClangdDiagnosticOptions(), - [&](clangd::Diagnostic LSPDiag, ArrayRef<clangd::Fix> Fixes) { - LSPDiags.push_back( - {std::move(LSPDiag), - std::vector<clangd::Fix>(Fixes.begin(), Fixes.end())}); - }); + ClangdDiagnosticOptions(), + [&](clangd::Diagnostic LSPDiag, ArrayRef<clangd::Fix> Fixes) { + LSPDiags.push_back( + {std::move(LSPDiag), + std::vector<clangd::Fix>(Fixes.begin(), Fixes.end())}); + }); EXPECT_THAT( LSPDiags, Modified: clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp Thu Jan 3 05:28:05 2019 @@ -516,7 +516,8 @@ TEST(CompletionTest, ScopedWithFilter) { TEST(CompletionTest, ReferencesAffectRanking) { auto Results = completions("int main() { abs^ }", {ns("absl"), func("absb")}); - EXPECT_THAT(Results.Completions, HasSubsequence(Named("absb"), Named("absl"))); + EXPECT_THAT(Results.Completions, + HasSubsequence(Named("absb"), Named("absl"))); Results = completions("int main() { abs^ }", {withReferences(10000, ns("absl")), func("absb")}); EXPECT_THAT(Results.Completions, @@ -1662,7 +1663,8 @@ TEST(CompletionTest, CompletionTokenRang auto Results = completions(Server, TestCode.code(), TestCode.point()); EXPECT_EQ(Results.Completions.size(), 1u); - EXPECT_THAT(Results.Completions.front().CompletionTokenRange, TestCode.range()); + EXPECT_THAT(Results.Completions.front().CompletionTokenRange, + TestCode.range()); } } @@ -2095,11 +2097,10 @@ TEST(SignatureHelpTest, ConstructorIniti A a_elem; }; )cpp"); - EXPECT_THAT(Results.signatures, UnorderedElementsAre( - Sig("A(int)", {"int"}), - Sig("A(A &&)", {"A &&"}), - Sig("A(const A &)", {"const A &"}) - )); + EXPECT_THAT(Results.signatures, + UnorderedElementsAre(Sig("A(int)", {"int"}), + Sig("A(A &&)", {"A &&"}), + Sig("A(const A &)", {"const A &"}))); } { const auto Results = signatures(R"cpp( @@ -2115,11 +2116,10 @@ TEST(SignatureHelpTest, ConstructorIniti C c_elem; }; )cpp"); - EXPECT_THAT(Results.signatures, UnorderedElementsAre( - Sig("A(int)", {"int"}), - Sig("A(A &&)", {"A &&"}), - Sig("A(const A &)", {"const A &"}) - )); + EXPECT_THAT(Results.signatures, + UnorderedElementsAre(Sig("A(int)", {"int"}), + Sig("A(A &&)", {"A &&"}), + Sig("A(const A &)", {"const A &"}))); } } @@ -2134,10 +2134,9 @@ TEST(CompletionTest, IncludedCompletionK IgnoreDiagnostics DiagConsumer; ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest()); auto Results = completions(Server, - R"cpp( + R"cpp( #include "^" - )cpp" - ); + )cpp"); EXPECT_THAT(Results.Completions, AllOf(Has("sub/", CompletionItemKind::Folder), Has("bar.h\"", CompletionItemKind::File))); @@ -2147,8 +2146,7 @@ TEST(CompletionTest, NoCrashAtNonAlphaIn auto Results = completions( R"cpp( #include "./^" - )cpp" - ); + )cpp"); EXPECT_TRUE(Results.Completions.empty()); } @@ -2221,9 +2219,8 @@ TEST(CompletionTest, ObjectiveCMethodNoA @end Foo *foo = [Foo new]; int y = [foo v^] )objc", - /*IndexSymbols=*/{}, - /*Opts=*/{}, - "Foo.m"); + /*IndexSymbols=*/{}, + /*Opts=*/{}, "Foo.m"); auto C = Results.Completions; EXPECT_THAT(C, ElementsAre(Named("value"))); @@ -2240,9 +2237,8 @@ TEST(CompletionTest, ObjectiveCMethodOne @end Foo *foo = [Foo new]; int y = [foo v^] )objc", - /*IndexSymbols=*/{}, - /*Opts=*/{}, - "Foo.m"); + /*IndexSymbols=*/{}, + /*Opts=*/{}, "Foo.m"); auto C = Results.Completions; EXPECT_THAT(C, ElementsAre(Named("valueForCharacter:"))); @@ -2259,17 +2255,16 @@ TEST(CompletionTest, ObjectiveCMethodTwo @end id val = [Foo foo^] )objc", - /*IndexSymbols=*/{}, - /*Opts=*/{}, - "Foo.m"); + /*IndexSymbols=*/{}, + /*Opts=*/{}, "Foo.m"); auto C = Results.Completions; EXPECT_THAT(C, ElementsAre(Named("fooWithValue:"))); EXPECT_THAT(C, ElementsAre(Kind(CompletionItemKind::Method))); EXPECT_THAT(C, ElementsAre(ReturnType("id"))); EXPECT_THAT(C, ElementsAre(Signature("(int) fooey:(unsigned int)"))); - EXPECT_THAT(C, - ElementsAre(SnippetSuffix("${1:(int)} fooey:${2:(unsigned int)}"))); + EXPECT_THAT( + C, ElementsAre(SnippetSuffix("${1:(int)} fooey:${2:(unsigned int)}"))); } TEST(CompletionTest, ObjectiveCMethodTwoArgumentsFromMiddle) { @@ -2279,9 +2274,8 @@ TEST(CompletionTest, ObjectiveCMethodTwo @end id val = [Foo fooWithValue:10 f^] )objc", - /*IndexSymbols=*/{}, - /*Opts=*/{}, - "Foo.m"); + /*IndexSymbols=*/{}, + /*Opts=*/{}, "Foo.m"); auto C = Results.Completions; EXPECT_THAT(C, ElementsAre(Named("fooey:"))); Modified: clang-tools-extra/trunk/unittests/clangd/DexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/DexTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/DexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/DexTests.cpp Thu Jan 3 05:28:05 2019 @@ -659,7 +659,7 @@ TEST(DexTest, ProximityPathsBoosting) { TEST(DexTests, Refs) { DenseMap<SymbolID, std::vector<Ref>> Refs; auto AddRef = [&](const Symbol &Sym, const char *Filename, RefKind Kind) { - auto& SymbolRefs = Refs[Sym.ID]; + auto &SymbolRefs = Refs[Sym.ID]; SymbolRefs.emplace_back(); SymbolRefs.back().Kind = Kind; SymbolRefs.back().Location.FileURI = Filename; Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp Thu Jan 3 05:28:05 2019 @@ -343,7 +343,7 @@ TEST(FileIndexTest, ReferencesInMainFile )cpp"); auto MainFile = testPath("foo.cpp"); auto HeaderFile = testPath("foo.h"); - std::vector<const char*> Cmd = {"clang", "-xc++", MainFile.c_str()}; + std::vector<const char *> Cmd = {"clang", "-xc++", MainFile.c_str()}; // Preparse ParseInputs. ParseInputs PI; PI.CompileCommand.Directory = testRoot(); @@ -355,10 +355,9 @@ TEST(FileIndexTest, ReferencesInMainFile // Prepare preamble. auto CI = buildCompilerInvocation(PI); auto PreambleData = buildPreamble( - MainFile, - *buildCompilerInvocation(PI), /*OldPreamble=*/nullptr, - tooling::CompileCommand(), PI, - std::make_shared<PCHContainerOperations>(), /*StoreInMemory=*/true, + MainFile, *buildCompilerInvocation(PI), /*OldPreamble=*/nullptr, + tooling::CompileCommand(), PI, std::make_shared<PCHContainerOperations>(), + /*StoreInMemory=*/true, [&](ASTContext &Ctx, std::shared_ptr<Preprocessor> PP) {}); // Build AST for main file with preamble. auto AST = @@ -369,8 +368,7 @@ TEST(FileIndexTest, ReferencesInMainFile FileIndex Index; Index.updateMain(MainFile, *AST); - auto Foo = - findSymbol(TestTU::withHeaderCode(Header).headerSymbols(), "Foo"); + auto Foo = findSymbol(TestTU::withHeaderCode(Header).headerSymbols(), "Foo"); RefsRequest Request; Request.IDs.insert(Foo.ID); Modified: clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp Thu Jan 3 05:28:05 2019 @@ -303,7 +303,7 @@ TEST(MergeIndexTest, Refs) { FileURI("unittest:///test2.cc")))))); } -MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { +MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { return (arg.IncludeHeader == IncludeHeader) && (arg.References == References); } Modified: clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/JSONTransportTests.cpp Thu Jan 3 05:28:05 2019 @@ -19,9 +19,8 @@ namespace { // No fmemopen on windows or on versions of MacOS X earlier than 10.13, so we // can't easily run this test. -#if !(defined(WIN32) || \ - (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ - __MAC_OS_X_VERSION_MIN_REQUIRED < 101300)) +#if !(defined(WIN32) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ + __MAC_OS_X_VERSION_MIN_REQUIRED < 101300)) // Fixture takes care of managing the input/output buffers for the transport. class JSONTransportTest : public ::testing::Test { Modified: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Thu Jan 3 05:28:05 2019 @@ -371,7 +371,7 @@ TEST(QualityTests, IsInstanceMember) { Rel.merge(BarSym); EXPECT_TRUE(Rel.IsInstanceMember); - Rel.IsInstanceMember =false; + Rel.IsInstanceMember = false; const Symbol &TplSym = findSymbol(Symbols, "Foo::tpl"); Rel.merge(TplSym); EXPECT_TRUE(Rel.IsInstanceMember); Modified: clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/SerializationTests.cpp Thu Jan 3 05:28:05 2019 @@ -99,9 +99,9 @@ TEST(SerializationTest, YAMLConversions) auto ParsedYAML = readIndexFile(YAML); ASSERT_TRUE(bool(ParsedYAML)) << ParsedYAML.takeError(); ASSERT_TRUE(bool(ParsedYAML->Symbols)); - EXPECT_THAT(*ParsedYAML->Symbols, - UnorderedElementsAre(ID("057557CEBF6E6B2D"), - ID("057557CEBF6E6B2E"))); + EXPECT_THAT( + *ParsedYAML->Symbols, + UnorderedElementsAre(ID("057557CEBF6E6B2D"), ID("057557CEBF6E6B2E"))); auto Sym1 = *ParsedYAML->Symbols->find( cantFail(SymbolID::fromStr("057557CEBF6E6B2D"))); @@ -131,9 +131,8 @@ TEST(SerializationTest, YAMLConversions) ASSERT_TRUE(bool(ParsedYAML->Refs)); EXPECT_THAT( *ParsedYAML->Refs, - UnorderedElementsAre( - Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2D")), - testing::SizeIs(1)))); + UnorderedElementsAre(Pair(cantFail(SymbolID::fromStr("057557CEBF6E6B2D")), + testing::SizeIs(1)))); auto Ref1 = ParsedYAML->Refs->begin()->second.front(); EXPECT_EQ(Ref1.Kind, RefKind::Reference); EXPECT_EQ(StringRef(Ref1.Location.FileURI), "file:///path/foo.cc"); Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Thu Jan 3 05:28:05 2019 @@ -61,7 +61,7 @@ MATCHER_P(IncludeHeader, P, "") { return (arg.IncludeHeaders.size() == 1) && (arg.IncludeHeaders.begin()->IncludeHeader == P); } -MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { +MATCHER_P2(IncludeHeaderWithRef, IncludeHeader, References, "") { return (arg.IncludeHeader == IncludeHeader) && (arg.References == References); } MATCHER_P(DeclRange, Pos, "") { @@ -123,7 +123,7 @@ protected: std::string HeaderName = "f.h"; std::string FileName = "f.cpp"; TestTU File; - Optional<ParsedAST> AST; // Initialized after build. + Optional<ParsedAST> AST; // Initialized after build. }; TEST_F(ShouldCollectSymbolTest, ShouldCollectSymbol) { @@ -248,8 +248,7 @@ public: Args.push_back(TestFileName); tooling::ToolInvocation Invocation( - Args, - Factory->create(), Files.get(), + Args, Factory->create(), Files.get(), std::make_shared<PCHContainerOperations>()); InMemoryFileSystem->addFile(TestHeaderName, 0, @@ -422,18 +421,16 @@ o]](); int Y; )cpp"); runSymbolCollector(Header.code(), Main.code()); - EXPECT_THAT( - Symbols, - UnorderedElementsAre( - AllOf(QName("X"), DeclRange(Header.range("xdecl")), - DefRange(Main.range("xdef"))), - AllOf(QName("Cls"), DeclRange(Header.range("clsdecl")), - DefRange(Main.range("clsdef"))), - AllOf(QName("print"), DeclRange(Header.range("printdecl")), - DefRange(Main.range("printdef"))), - AllOf(QName("Z"), DeclRange(Header.range("zdecl"))), - AllOf(QName("foo"), DeclRange(Header.range("foodecl"))) - )); + EXPECT_THAT(Symbols, + UnorderedElementsAre( + AllOf(QName("X"), DeclRange(Header.range("xdecl")), + DefRange(Main.range("xdef"))), + AllOf(QName("Cls"), DeclRange(Header.range("clsdecl")), + DefRange(Main.range("clsdef"))), + AllOf(QName("print"), DeclRange(Header.range("printdecl")), + DefRange(Main.range("printdef"))), + AllOf(QName("Z"), DeclRange(Header.range("zdecl"))), + AllOf(QName("foo"), DeclRange(Header.range("foodecl"))))); } TEST_F(SymbolCollectorTest, Refs) { @@ -537,8 +534,8 @@ TEST_F(SymbolCollectorTest, SymbolRelati TestHeaderURI = URI::create(testPath(TestHeaderName)).toString(); CollectorOpts.FallbackDir = testRoot(); runSymbolCollector("class Foo {};", /*Main=*/""); - EXPECT_THAT(Symbols, - UnorderedElementsAre(AllOf(QName("Foo"), DeclURI(TestHeaderURI)))); + EXPECT_THAT(Symbols, UnorderedElementsAre( + AllOf(QName("Foo"), DeclURI(TestHeaderURI)))); } TEST_F(SymbolCollectorTest, UnittestURIScheme) { @@ -605,13 +602,12 @@ TEST_F(SymbolCollectorTest, SymbolFormed )"); runSymbolCollector(Header.code(), /*Main=*/""); - EXPECT_THAT( - Symbols, - UnorderedElementsAre( - AllOf(QName("abc_Test"), DeclRange(Header.range("expansion")), - DeclURI(TestHeaderURI)), - AllOf(QName("Test"), DeclRange(Header.range("spelling")), - DeclURI(TestHeaderURI)))); + EXPECT_THAT(Symbols, + UnorderedElementsAre( + AllOf(QName("abc_Test"), DeclRange(Header.range("expansion")), + DeclURI(TestHeaderURI)), + AllOf(QName("Test"), DeclRange(Header.range("spelling")), + DeclURI(TestHeaderURI)))); } TEST_F(SymbolCollectorTest, SymbolFormedByCLI) { Modified: clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/SymbolInfoTests.cpp Thu Jan 3 05:28:05 2019 @@ -37,26 +37,24 @@ auto CreateExpectedSymbolDetails = [](co TEST(SymbolInfoTests, All) { std::pair<const char *, std::vector<SymbolDetails>> TestInputExpectedOutput[] = { - { - R"cpp( // Simple function reference - declaration + { + R"cpp( // Simple function reference - declaration void foo(); int bar() { fo^o(); } )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")} - }, - { - R"cpp( // Simple function reference - definition + {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}}, + { + R"cpp( // Simple function reference - definition void foo() {} int bar() { fo^o(); } )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")} - }, - { - R"cpp( // Function in namespace reference + {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}}, + { + R"cpp( // Function in namespace reference namespace bar { void foo(); int baz() { @@ -64,10 +62,9 @@ TEST(SymbolInfoTests, All) { } } )cpp", - {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")} - }, - { - R"cpp( // Function in different namespace reference + {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}}, + { + R"cpp( // Function in different namespace reference namespace bar { void foo(); } @@ -77,10 +74,9 @@ TEST(SymbolInfoTests, All) { } } )cpp", - {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")} - }, - { - R"cpp( // Function in global namespace reference + {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#")}}, + { + R"cpp( // Function in global namespace reference void foo(); namespace Nbar { namespace Nbaz { @@ -90,10 +86,9 @@ TEST(SymbolInfoTests, All) { } } )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")} - }, - { - R"cpp( // Function in anonymous namespace reference + {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#")}}, + { + R"cpp( // Function in anonymous namespace reference namespace { void foo(); } @@ -103,10 +98,10 @@ TEST(SymbolInfoTests, All) { } } )cpp", - {CreateExpectedSymbolDetails("foo", "(anonymous)", "c:TestTU.cpp@aN@F@foo#")} - }, - { - R"cpp( // Function reference - ADL + {CreateExpectedSymbolDetails("foo", "(anonymous)", + "c:TestTU.cpp@aN@F@foo#")}}, + { + R"cpp( // Function reference - ADL namespace bar { struct BarType {}; void foo(const BarType&); @@ -118,49 +113,47 @@ TEST(SymbolInfoTests, All) { } } )cpp", - {CreateExpectedSymbolDetails("foo", "bar::", "c:@N@bar@F@foo#&1$@N@bar@S@BarType#")} - }, - { - R"cpp( // Global value reference + {CreateExpectedSymbolDetails( + "foo", "bar::", "c:@N@bar@F@foo#&1$@N@bar@S@BarType#")}}, + { + R"cpp( // Global value reference int value; void foo(int) { } void bar() { foo(val^ue); } )cpp", - {CreateExpectedSymbolDetails("value", "", "c:@value")} - }, - { - R"cpp( // Local value reference + {CreateExpectedSymbolDetails("value", "", "c:@value")}}, + { + R"cpp( // Local value reference void foo() { int aaa; int bbb = aa^a; } )cpp", - {CreateExpectedSymbolDetails("aaa", "foo", "c:TestTU.cpp@49@F@foo#@aaa")} - }, - { - R"cpp( // Function param + {CreateExpectedSymbolDetails("aaa", "foo", + "c:TestTU.cpp@49@F@foo#@aaa")}}, + { + R"cpp( // Function param void bar(int aaa) { int bbb = a^aa; } )cpp", - {CreateExpectedSymbolDetails("aaa", "bar", "c:TestTU.cpp@38@F@bar#I#@aaa")} - }, - { - R"cpp( // Lambda capture + {CreateExpectedSymbolDetails("aaa", "bar", + "c:TestTU.cpp@38@F@bar#I#@aaa")}}, + { + R"cpp( // Lambda capture int ii; auto lam = [ii]() { return i^i; }; )cpp", - {CreateExpectedSymbolDetails("ii", "", "c:@ii")} - }, - { - R"cpp( // Macro reference + {CreateExpectedSymbolDetails("ii", "", "c:@ii")}}, + { + R"cpp( // Macro reference #define MACRO 5\nint i = MAC^RO; )cpp", - {CreateExpectedSymbolDetails("MACRO", "", "c:TestTU.cpp@55@macro@MACRO")} - }, - { - R"cpp( // Multiple symbols returned - using overloaded function name + {CreateExpectedSymbolDetails("MACRO", "", + "c:TestTU.cpp@55@macro@MACRO")}}, + { + R"cpp( // Multiple symbols returned - using overloaded function name void foo() {} void foo(bool) {} void foo(int) {} @@ -168,14 +161,11 @@ TEST(SymbolInfoTests, All) { using ::fo^o; } )cpp", - { - CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"), - CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"), - CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#") - } - }, - { - R"cpp( // Multiple symbols returned - implicit conversion + {CreateExpectedSymbolDetails("foo", "", "c:@F@foo#"), + CreateExpectedSymbolDetails("foo", "", "c:@F@foo#b#"), + CreateExpectedSymbolDetails("foo", "", "c:@F@foo#I#")}}, + { + R"cpp( // Multiple symbols returned - implicit conversion struct foo {}; struct bar { bar(const foo&) {} @@ -186,53 +176,49 @@ TEST(SymbolInfoTests, All) { func_baz1(f^f); } )cpp", - { - CreateExpectedSymbolDetails("ff", "func_baz2", "c:TestTU.cpp@218@F@func_baz2#@ff"), - CreateExpectedSymbolDetails("bar", "bar::", "c:@S@bar@F@bar#&1$@S@foo#"), - } - }, - { - R"cpp( // Type reference - declaration + { + CreateExpectedSymbolDetails( + "ff", "func_baz2", "c:TestTU.cpp@218@F@func_baz2#@ff"), + CreateExpectedSymbolDetails( + "bar", "bar::", "c:@S@bar@F@bar#&1$@S@foo#"), + }}, + { + R"cpp( // Type reference - declaration struct foo; void bar(fo^o*); )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@S@foo")} - }, - { - R"cpp( // Type reference - definition + {CreateExpectedSymbolDetails("foo", "", "c:@S@foo")}}, + { + R"cpp( // Type reference - definition struct foo {}; void bar(fo^o*); )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@S@foo")} - }, - { - R"cpp( // Type Reference - template argumen + {CreateExpectedSymbolDetails("foo", "", "c:@S@foo")}}, + { + R"cpp( // Type Reference - template argumen struct foo {}; template<class T> struct bar {}; void baz() { bar<fo^o> b; } )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@S@foo")} - }, - { - R"cpp( // Template parameter reference - type param + {CreateExpectedSymbolDetails("foo", "", "c:@S@foo")}}, + { + R"cpp( // Template parameter reference - type param template<class TT> struct bar { T^T t; }; )cpp", - { /* not implemented */ } - }, - { - R"cpp( // Template parameter reference - type param + {/* not implemented */}}, + { + R"cpp( // Template parameter reference - type param template<int NN> struct bar { int a = N^N; }; )cpp", - { /* not implemented */ } - }, - { - R"cpp( // Class member reference - objec + {/* not implemented */}}, + { + R"cpp( // Class member reference - objec struct foo { int aa; }; @@ -241,10 +227,9 @@ TEST(SymbolInfoTests, All) { f.a^a; } )cpp", - {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@FI@aa")} - }, - { - R"cpp( // Class member reference - pointer + {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@FI@aa")}}, + { + R"cpp( // Class member reference - pointer struct foo { int aa; }; @@ -252,10 +237,9 @@ TEST(SymbolInfoTests, All) { &foo::a^a; } )cpp", - {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@FI@aa")} - }, - { - R"cpp( // Class method reference - objec + {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@FI@aa")}}, + { + R"cpp( // Class method reference - objec struct foo { void aa() {} }; @@ -264,10 +248,9 @@ TEST(SymbolInfoTests, All) { f.a^a(); } )cpp", - {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@F@aa#")} - }, - { - R"cpp( // Class method reference - pointer + {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@F@aa#")}}, + { + R"cpp( // Class method reference - pointer struct foo { void aa() {} }; @@ -275,72 +258,64 @@ TEST(SymbolInfoTests, All) { &foo::a^a; } )cpp", - {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@F@aa#")} - }, - { - R"cpp( // Typedef + {CreateExpectedSymbolDetails("aa", "foo::", "c:@S@foo@F@aa#")}}, + { + R"cpp( // Typedef typedef int foo; void bar() { fo^o a; } )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:TestTU.cpp@T@foo")} - }, - { - R"cpp( // Type alias + {CreateExpectedSymbolDetails("foo", "", "c:TestTU.cpp@T@foo")}}, + { + R"cpp( // Type alias using foo = int; void bar() { fo^o a; } )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@foo")} - }, - { - R"cpp( // Namespace reference + {CreateExpectedSymbolDetails("foo", "", "c:@foo")}}, + { + R"cpp( // Namespace reference namespace foo {} using namespace fo^o; )cpp", - {CreateExpectedSymbolDetails("foo", "", "c:@N@foo")} - }, - { - R"cpp( // Enum value reference + {CreateExpectedSymbolDetails("foo", "", "c:@N@foo")}}, + { + R"cpp( // Enum value reference enum foo { bar, baz }; void f() { foo fff = ba^r; } )cpp", - {CreateExpectedSymbolDetails("bar", "foo", "c:@E@foo@bar")} - }, - { - R"cpp( // Enum class value reference + {CreateExpectedSymbolDetails("bar", "foo", "c:@E@foo@bar")}}, + { + R"cpp( // Enum class value reference enum class foo { bar, baz }; void f() { foo fff = foo::ba^r; } )cpp", - {CreateExpectedSymbolDetails("bar", "foo::", "c:@E@foo@bar")} - }, - { - R"cpp( // Type inferrence with auto keyword + {CreateExpectedSymbolDetails("bar", "foo::", "c:@E@foo@bar")}}, + { + R"cpp( // Type inferrence with auto keyword struct foo {}; foo getfoo() { return foo{}; } void f() { au^to a = getfoo(); } )cpp", - {/* not implemented */} - }, - { - R"cpp( // decltype + {/* not implemented */}}, + { + R"cpp( // decltype struct foo {}; void f() { foo f; declt^ype(f); } )cpp", - {/* not implemented */} - }, - }; + {/* not implemented */}}, + }; for (const auto &T : TestInputExpectedOutput) { Annotations TestInput(T.first); Modified: clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp Thu Jan 3 05:28:05 2019 @@ -148,6 +148,5 @@ RefSlab getRefs(const SymbolIndex &Index return std::move(Slab).build(); } - } // namespace clangd } // namespace clang Modified: clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp Thu Jan 3 05:28:05 2019 @@ -12,8 +12,8 @@ #include "Matchers.h" #include "TUScheduler.h" #include "TestFS.h" -#include "gmock/gmock.h" #include "llvm/ADT/ScopeExit.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" #include <algorithm> #include <utility> @@ -389,22 +389,20 @@ TEST_F(TUSchedulerTests, ManyUpdates) { } { WithContextValue WithNonce(NonceKey, ++Nonce); - S.runWithAST("CheckAST", File, - [File, Inputs, Nonce, &Mut, - &TotalASTReads](Expected<InputsAndAST> AST) { - EXPECT_THAT(Context::current().get(NonceKey), - Pointee(Nonce)); - - ASSERT_TRUE((bool)AST); - EXPECT_EQ(AST->Inputs.FS, Inputs.FS); - EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents); - - std::lock_guard<std::mutex> Lock(Mut); - ++TotalASTReads; - EXPECT_EQ( - File, - *TUScheduler::getFileBeingProcessedInContext()); - }); + S.runWithAST( + "CheckAST", File, + [File, Inputs, Nonce, &Mut, + &TotalASTReads](Expected<InputsAndAST> AST) { + EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce)); + + ASSERT_TRUE((bool)AST); + EXPECT_EQ(AST->Inputs.FS, Inputs.FS); + EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents); + + std::lock_guard<std::mutex> Lock(Mut); + ++TotalASTReads; + EXPECT_EQ(File, *TUScheduler::getFileBeingProcessedInContext()); + }); } { @@ -505,14 +503,14 @@ TEST_F(TUSchedulerTests, EmptyPreamble) )cpp"; auto WithEmptyPreamble = R"cpp(int main() {})cpp"; S.update(Foo, getInputs(Foo, WithPreamble), WantDiagnostics::Auto); - S.runWithPreamble("getNonEmptyPreamble", Foo, TUScheduler::Stale, - [&](Expected<InputsAndPreamble> Preamble) { - // We expect to get a non-empty preamble. - EXPECT_GT(cantFail(std::move(Preamble)) - .Preamble->Preamble.getBounds() - .Size, - 0u); - }); + S.runWithPreamble( + "getNonEmptyPreamble", Foo, TUScheduler::Stale, + [&](Expected<InputsAndPreamble> Preamble) { + // We expect to get a non-empty preamble. + EXPECT_GT( + cantFail(std::move(Preamble)).Preamble->Preamble.getBounds().Size, + 0u); + }); // Wait for the preamble is being built. ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10))); @@ -520,14 +518,14 @@ TEST_F(TUSchedulerTests, EmptyPreamble) S.update(Foo, getInputs(Foo, WithEmptyPreamble), WantDiagnostics::Auto); // Wait for the preamble is being built. ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10))); - S.runWithPreamble("getEmptyPreamble", Foo, TUScheduler::Stale, - [&](Expected<InputsAndPreamble> Preamble) { - // We expect to get an empty preamble. - EXPECT_EQ(cantFail(std::move(Preamble)) - .Preamble->Preamble.getBounds() - .Size, - 0u); - }); + S.runWithPreamble( + "getEmptyPreamble", Foo, TUScheduler::Stale, + [&](Expected<InputsAndPreamble> Preamble) { + // We expect to get an empty preamble. + EXPECT_EQ( + cantFail(std::move(Preamble)).Preamble->Preamble.getBounds().Size, + 0u); + }); } TEST_F(TUSchedulerTests, RunWaitsForPreamble) { Modified: clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp?rev=350303&r1=350302&r2=350303&view=diff ============================================================================== --- clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp (original) +++ clang-tools-extra/trunk/unittests/clangd/XRefsTests.cpp Thu Jan 3 05:28:05 2019 @@ -156,7 +156,8 @@ TEST(GoToDefinition, WithIndex) { )cpp"); EXPECT_THAT(runFindDefinitionsWithIndex(Test), testing::ElementsAreArray({ - RangeIs(Test.range()), RangeIs(SymbolHeader.range("forward")), + RangeIs(Test.range()), + RangeIs(SymbolHeader.range("forward")), })); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits