diff --git a/clang-tools-extra/clangd/ClangdServer.cpp b/clang-tools-extra/clangd/ClangdServer.cpp --- a/clang-tools-extra/clangd/ClangdServer.cpp +++ b/clang-tools-extra/clangd/ClangdServer.cpp @@ -497,7 +497,7 @@ // prepareRename is latency-sensitive: we don't query the index, as we // only need main-file references auto Results = - clangd::rename({Pos, NewName.getValueOr("__clangd_rename_dummy"), + clangd::rename({Pos, NewName.getValueOr("__clangd_rename_placeholder"), InpAST->AST, File, /*FS=*/nullptr, /*Index=*/nullptr, RenameOpts}); if (!Results) { diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -96,9 +96,9 @@ if (auto PathCC = llvm::sys::findProgramByName(Name)) return resolve(std::move(*PathCC)); // Fallback: a nonexistent 'clang' binary next to clangd. - static int Dummy; + static int StaticForMainAddr; std::string ClangdExecutable = - llvm::sys::fs::getMainExecutable("clangd", (void *)&Dummy); + llvm::sys::fs::getMainExecutable("clangd", (void *)&StaticForMainAddr); SmallString<128> ClangPath; ClangPath = llvm::sys::path::parent_path(ClangdExecutable); llvm::sys::path::append(ClangPath, "clang"); @@ -120,8 +120,9 @@ } std::string detectStandardResourceDir() { - static int Dummy; // Just an address in this process. - return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy); + static int StaticForMainAddr; // Just an address in this process. + return CompilerInvocation::GetResourcesPath("clangd", + (void *)&StaticForMainAddr); } // The path passed to argv[0] is important: diff --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp --- a/clang-tools-extra/clangd/FindSymbols.cpp +++ b/clang-tools-extra/clangd/FindSymbols.cpp @@ -376,10 +376,10 @@ /// Builds the document outline for the generated AST. std::vector build() { - SymBuilder DummyRoot; + SymBuilder Root; for (auto &TopLevel : AST.getLocalTopLevelDecls()) - traverseDecl(TopLevel, DummyRoot); - return std::move(std::move(DummyRoot).build().children); + traverseDecl(TopLevel, Root); + return std::move(std::move(Root).build().children); } private: diff --git a/clang-tools-extra/clangd/Format.cpp b/clang-tools-extra/clangd/Format.cpp --- a/clang-tools-extra/clangd/Format.cpp +++ b/clang-tools-extra/clangd/Format.cpp @@ -23,7 +23,7 @@ /// as it isn't sure where the errors are and so can't correct. /// When editing, it's reasonable to assume code before the cursor is complete. void closeBrackets(std::string &Code, const format::FormatStyle &Style) { - SourceManagerForFile FileSM("dummy.cpp", Code); + SourceManagerForFile FileSM("mock_file.cpp", Code); auto &SM = FileSM.get(); FileID FID = SM.getMainFileID(); Lexer Lex(FID, SM.getBufferOrFake(FID), SM, diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -294,7 +294,7 @@ HighlightingToken &addToken(SourceLocation Loc, HighlightingKind Kind) { Loc = getHighlightableSpellingToken(Loc, SourceMgr); if (Loc.isInvalid()) - return Dummy; + return InvalidHighlightingToken; const auto *Tok = TB.spelledTokenAt(Loc); assert(Tok); return addToken( @@ -395,7 +395,8 @@ const SourceManager &SourceMgr; const LangOptions &LangOpts; std::vector Tokens; - HighlightingToken Dummy; // returned from addToken(InvalidLoc) + // returned from addToken(InvalidLoc) + HighlightingToken InvalidHighlightingToken; }; llvm::Optional scopeModifier(const NamedDecl *D) { diff --git a/clang-tools-extra/clangd/SourceCode.cpp b/clang-tools-extra/clangd/SourceCode.cpp --- a/clang-tools-extra/clangd/SourceCode.cpp +++ b/clang-tools-extra/clangd/SourceCode.cpp @@ -599,7 +599,7 @@ Action) { // FIXME: InMemoryFileAdapter crashes unless the buffer is null terminated! std::string NullTerminatedCode = Code.str(); - SourceManagerForFile FileSM("dummy.cpp", NullTerminatedCode); + SourceManagerForFile FileSM("mock_file_name.cpp", NullTerminatedCode); auto &SM = FileSM.get(); for (const auto &Tok : syntax::tokenize(SM.getMainFileID(), SM, LangOpts)) Action(Tok, SM); diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -162,10 +162,10 @@ SymbolLocation getPreferredLocation(const Location &ASTLoc, const SymbolLocation &IdxLoc, std::string &Scratch) { - // Also use a dummy symbol for the index location so that other fields (e.g. + // Also use a mock symbol for the index location so that other fields (e.g. // definition) are not factored into the preference. Symbol ASTSym, IdxSym; - ASTSym.ID = IdxSym.ID = SymbolID("dummy_id"); + ASTSym.ID = IdxSym.ID = SymbolID("mock_symbol_id"); ASTSym.CanonicalDeclaration = toIndexLocation(ASTLoc, Scratch); IdxSym.CanonicalDeclaration = IdxLoc; auto Merged = mergeSymbol(ASTSym, IdxSym); diff --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt --- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt +++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt @@ -9,7 +9,7 @@ # This fuzzer runs on oss-fuzz, so keep it around even if it looks unreferenced. add_llvm_fuzzer(clangd-fuzzer clangd-fuzzer.cpp - DUMMY_MAIN DummyClangdMain.cpp + DUMMY_MAIN FuzzerClangdMain.cpp ) clang_target_link_libraries(clangd-fuzzer diff --git a/clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp b/clang-tools-extra/clangd/fuzzer/FuzzerClangdMain.cpp rename from clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp rename to clang-tools-extra/clangd/fuzzer/FuzzerClangdMain.cpp --- a/clang-tools-extra/clangd/fuzzer/DummyClangdMain.cpp +++ b/clang-tools-extra/clangd/fuzzer/FuzzerClangdMain.cpp @@ -1,4 +1,4 @@ -//===---- DummyClangdMain.cpp - Entry point to sanity check the fuzzer ----===// +//===--- FuzzerClangdMain.cpp - Entry point to sanity check the fuzzer ----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt b/clang-tools-extra/clangd/index/remote/CMakeLists.txt --- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt +++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt @@ -39,6 +39,6 @@ add_subdirectory(marshalling) add_subdirectory(server) else() - # Provides a dummy implementation of clangdRemoteIndex. + # Provides a no-op implementation of clangdRemoteIndex. add_subdirectory(unimplemented) endif() diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp --- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp @@ -376,7 +376,7 @@ if (llvm::isa(E) || llvm::isa(E)) return false; - // Extracting Exprs like a = 1 gives dummy = a = 1 which isn't useful. + // Extracting Exprs like a = 1 gives placeholder = a = 1 which isn't useful. // FIXME: we could still hoist the assignment, and leave the variable there? ParsedBinaryOperator BinOp; if (BinOp.parse(*N) && BinaryOperator::isAssignmentOp(BinOp.Kind)) @@ -387,7 +387,7 @@ if (!Parent) return false; // We don't want to extract expressions used as statements, that would leave - // a `dummy;` around that has no effect. + // a `placeholder;` around that has no effect. // Unfortunately because the AST doesn't have ExprStmt, we have to check in // this roundabout way. if (childExprIsStmt(Parent->ASTNode.get(), @@ -422,7 +422,7 @@ llvm::isa(SelectedExpr)) if (const SelectionTree::Node *Call = getCallExpr(N)) TargetNode = Call; - // Extracting Exprs like a = 1 gives dummy = a = 1 which isn't useful. + // Extracting Exprs like a = 1 gives placeholder = a = 1 which isn't useful. if (const BinaryOperator *BinOpExpr = dyn_cast_or_null(SelectedExpr)) { if (BinOpExpr->getOpcode() == BinaryOperatorKind::BO_Assign) @@ -433,13 +433,13 @@ return TargetNode; } -/// Extracts an expression to the variable dummy +/// Extracts an expression to the variable placeholder /// Before: /// int x = 5 + 4 * 3; /// ^^^^^ /// After: -/// auto dummy = 5 + 4; -/// int x = dummy * 3; +/// auto placeholder = 5 + 4; +/// int x = placeholder * 3; class ExtractVariable : public Tweak { public: const char *id() const override final; @@ -476,7 +476,7 @@ Expected ExtractVariable::apply(const Selection &Inputs) { tooling::Replacements Result; // FIXME: get variable name from user or suggest based on type - std::string VarName = "dummy"; + std::string VarName = "placeholder"; SourceRange Range = Target->getExtractionChars(); // insert new variable declaration if (auto Err = Result.add(Target->insertDeclaration(VarName, Range))) diff --git a/clang-tools-extra/clangd/support/Trace.cpp b/clang-tools-extra/clangd/support/Trace.cpp --- a/clang-tools-extra/clangd/support/Trace.cpp +++ b/clang-tools-extra/clangd/support/Trace.cpp @@ -112,14 +112,14 @@ "s", llvm::json::Object{{"id", FlowID}, {"name", "Context crosses threads"}, - {"cat", "dummy"}}, + {"cat", "mock_cat"}}, (*Parent)->TID, (*Parent)->StartTime); Tracer->jsonEvent( "f", llvm::json::Object{{"id", FlowID}, {"bp", "e"}, {"name", "Context crosses threads"}, - {"cat", "dummy"}}, + {"cat", "mock_cat"}}, TID); } } diff --git a/clang-tools-extra/clangd/unittests/ClangdTests.cpp b/clang-tools-extra/clangd/unittests/ClangdTests.cpp --- a/clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ b/clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -407,9 +407,9 @@ // Put crtbegin.o into LibDir/64 to trick clang into thinking there's a gcc // installation there. - SmallString<64> DummyLibFile; - llvm::sys::path::append(DummyLibFile, LibDir, "64", "crtbegin.o"); - FS.Files[DummyLibFile] = ""; + SmallString<64> MockLibFile; + llvm::sys::path::append(MockLibFile, LibDir, "64", "crtbegin.o"); + FS.Files[MockLibFile] = ""; SmallString<64> IncludeDir("/randomusr/include/c++"); llvm::sys::path::append(IncludeDir, Version); diff --git a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp --- a/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp +++ b/clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp @@ -463,7 +463,9 @@ return true; } -auto hasFlag(llvm::StringRef Flag) { return hasFlag(Flag, "dummy.cc"); } +auto hasFlag(llvm::StringRef Flag) { + return hasFlag(Flag, "mock_file_name.cc"); +} TEST_F(DirectoryBasedGlobalCompilationDatabaseCacheTest, Cacheable) { MockFS FS; @@ -507,15 +509,15 @@ // compile_commands.json takes precedence over compile_flags.txt. FS.Files["foo/compile_commands.json"] = llvm::formatv(R"json([{ - "file": "{0}/foo/dummy.cc", - "command": "clang -DBAZ dummy.cc", + "file": "{0}/foo/mock_file.cc", + "command": "clang -DBAZ mock_file.cc", "directory": "{0}/foo", }])json", llvm::sys::path::convert_to_slash(testRoot())); EXPECT_EQ(FooBar, lookupCDB(GDB, testPath("foo/test.cc"), Stale)) << "cache still valid"; auto Baz = lookupCDB(GDB, testPath("foo/test.cc"), Fresh); - EXPECT_THAT(Baz, hasFlag("-DBAZ", testPath("foo/dummy.cc"))) + EXPECT_THAT(Baz, hasFlag("-DBAZ", testPath("foo/mock_file.cc"))) << "compile_commands overrides compile_flags"; // Removing compile_commands.json reveals compile_flags.txt again. diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp --- a/clang-tools-extra/clangd/unittests/RenameTests.cpp +++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -844,7 +844,7 @@ const char *Code; const char* ErrorMessage; // null if no error bool IsHeaderFile; - llvm::StringRef NewName = "DummyName"; + llvm::StringRef NewName = "MockName"; }; const bool HeaderFile = true; Case Cases[] = { diff --git a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp --- a/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ b/clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -71,7 +71,7 @@ return true; } -// Dummy ContextProvider to verify the provider is invoked & contexts are used. +// Simple ContextProvider to verify the provider is invoked & contexts are used. static Key BoundPath; Context bindPath(PathRef F) { return Context::current().derive(BoundPath, F.str()); diff --git a/clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp b/clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp --- a/clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp +++ b/clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp @@ -131,7 +131,7 @@ int a = 5 * (4 + (3 [[- 1)]]); })cpp", R"cpp(void varDecl() { - auto dummy = (3 - 1); int a = 5 * (4 + dummy); + auto placeholder = (3 - 1); int a = 5 * (4 + placeholder); })cpp"}, // FIXME: extraction from switch case /*{R"cpp(void f(int a) { @@ -146,11 +146,11 @@ } })cpp", R"cpp(void f(int a) { - auto dummy = 1 + 2; if(1) + auto placeholder = 1 + 2; if(1) while(a < 1) switch (1) { case 1: - a = dummy; + a = placeholder; break; default: break; @@ -164,11 +164,11 @@ /*FIXME: It should be extracted like this. R"cpp(#define PLUS(x) x++ void f(int a) { - auto dummy = 1+a; int y = PLUS(dummy); + auto placeholder = 1+a; int y = PLUS(placeholder); })cpp"},*/ R"cpp(#define PLUS(x) x++ void f(int a) { - auto dummy = PLUS(1+a); int y = dummy; + auto placeholder = PLUS(1+a); int y = placeholder; })cpp"}, // ensure InsertionPoint isn't inside a macro {R"cpp(#define LOOP(x) while (1) {a = x;} @@ -178,8 +178,8 @@ })cpp", R"cpp(#define LOOP(x) while (1) {a = x;} void f(int a) { - auto dummy = 3; if(1) - LOOP(5 + dummy) + auto placeholder = 3; if(1) + LOOP(5 + placeholder) })cpp"}, {R"cpp(#define LOOP(x) do {x;} while(1); void f(int a) { @@ -188,15 +188,15 @@ })cpp", R"cpp(#define LOOP(x) do {x;} while(1); void f(int a) { - auto dummy = 3; if(1) - LOOP(5 + dummy) + auto placeholder = 3; if(1) + LOOP(5 + placeholder) })cpp"}, // attribute testing {R"cpp(void f(int a) { [ [gsl::suppress("type")] ] for (;;) a = [[1]] + 1; })cpp", R"cpp(void f(int a) { - auto dummy = 1; [ [gsl::suppress("type")] ] for (;;) a = dummy + 1; + auto placeholder = 1; [ [gsl::suppress("type")] ] for (;;) a = placeholder + 1; })cpp"}, // MemberExpr {R"cpp(class T { @@ -206,7 +206,7 @@ };)cpp", R"cpp(class T { T f() { - auto dummy = T().f(); return dummy.f(); + auto placeholder = T().f(); return placeholder.f(); } };)cpp"}, // Function DeclRefExpr @@ -214,7 +214,7 @@ return [[f]](); })cpp", R"cpp(int f() { - auto dummy = f(); return dummy; + auto placeholder = f(); return placeholder; })cpp"}, // FIXME: Wrong result for \[\[clang::uninitialized\]\] int b = [[1]]; // since the attr is inside the DeclStmt and the bounds of @@ -225,33 +225,33 @@ int x = 1 + [[2 + 3 + 4]] + 5; })cpp", R"cpp(void f() { - auto dummy = 2 + 3 + 4; int x = 1 + dummy + 5; + auto placeholder = 2 + 3 + 4; int x = 1 + placeholder + 5; })cpp"}, {R"cpp(void f() { int x = [[1 + 2 + 3]] + 4 + 5; })cpp", R"cpp(void f() { - auto dummy = 1 + 2 + 3; int x = dummy + 4 + 5; + auto placeholder = 1 + 2 + 3; int x = placeholder + 4 + 5; })cpp"}, {R"cpp(void f() { int x = 1 + 2 + [[3 + 4 + 5]]; })cpp", R"cpp(void f() { - auto dummy = 3 + 4 + 5; int x = 1 + 2 + dummy; + auto placeholder = 3 + 4 + 5; int x = 1 + 2 + placeholder; })cpp"}, // Non-associative operations have no special support {R"cpp(void f() { int x = 1 - [[2 - 3 - 4]] - 5; })cpp", R"cpp(void f() { - auto dummy = 1 - 2 - 3 - 4; int x = dummy - 5; + auto placeholder = 1 - 2 - 3 - 4; int x = placeholder - 5; })cpp"}, // A mix of associative operators isn't associative. {R"cpp(void f() { int x = 0 + 1 * [[2 + 3]] * 4 + 5; })cpp", R"cpp(void f() { - auto dummy = 1 * 2 + 3 * 4; int x = 0 + dummy + 5; + auto placeholder = 1 * 2 + 3 * 4; int x = 0 + placeholder + 5; })cpp"}, // Overloaded operators are supported, we assume associativity // as if they were built-in. @@ -269,7 +269,7 @@ S operator+(S, S); void f() { - auto dummy = S(2) + S(3) + S(4); S x = S(1) + dummy + S(5); + auto placeholder = S(2) + S(3) + S(4); S x = S(1) + placeholder + S(5); })cpp"}, // Don't try to analyze across macro boundaries // FIXME: it'd be nice to do this someday (in a safe way) @@ -279,7 +279,7 @@ })cpp", R"cpp(#define ECHO(X) X void f() { - auto dummy = 1 + ECHO(2 + 3) + 4; int x = dummy + 5; + auto placeholder = 1 + ECHO(2 + 3) + 4; int x = placeholder + 5; })cpp"}, {R"cpp(#define ECHO(X) X void f() { @@ -287,7 +287,7 @@ })cpp", R"cpp(#define ECHO(X) X void f() { - auto dummy = 1 + ECHO(2) + ECHO(3) + 4; int x = dummy + 5; + auto placeholder = 1 + ECHO(2) + ECHO(3) + 4; int x = placeholder + 5; })cpp"}, }; for (const auto &IO : InputOutputs) {