kuhnel updated this revision to Diff 393890. kuhnel added a comment. reverted the `const` as advised in Sam's comment
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113898/new/ https://reviews.llvm.org/D113898 Files: clang-tools-extra/clangd/AST.cpp clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/ExpectedTypes.cpp clang-tools-extra/clangd/FindSymbols.cpp clang-tools-extra/clangd/HeaderSourceSwitch.cpp clang-tools-extra/clangd/Hover.cpp clang-tools-extra/clangd/TUScheduler.cpp clang-tools-extra/clangd/index/IndexAction.cpp clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/index/dex/Iterator.cpp clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp clang-tools-extra/clangd/unittests/ClangdTests.cpp clang-tools-extra/clangd/unittests/FileIndexTests.cpp clang-tools-extra/clangd/unittests/HoverTests.cpp clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp clang-tools-extra/clangd/unittests/tweaks/DefineInlineTests.cpp
Index: clang-tools-extra/clangd/unittests/tweaks/DefineInlineTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/tweaks/DefineInlineTests.cpp +++ clang-tools-extra/clangd/unittests/tweaks/DefineInlineTests.cpp @@ -192,7 +192,7 @@ } TEST_F(DefineInlineTest, TransformNestedNamespaces) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { void bar(); namespace b { @@ -220,7 +220,7 @@ b::c::aux(); a::b::c::aux(); })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { void bar(); namespace b { @@ -252,7 +252,7 @@ } TEST_F(DefineInlineTest, TransformUsings) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { namespace b { namespace c { void aux(); } } } void foo(); @@ -263,7 +263,7 @@ using c::aux; namespace d = c; })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { namespace b { namespace c { void aux(); } } } void foo(){ @@ -278,7 +278,7 @@ } TEST_F(DefineInlineTest, TransformDecls) { - auto Test = R"cpp( + const auto *Test = R"cpp( void foo(); void f^oo() { class Foo { @@ -293,7 +293,7 @@ enum class EnClass { Zero, One }; EnClass y = EnClass::Zero; })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( void foo(){ class Foo { public: @@ -312,7 +312,7 @@ } TEST_F(DefineInlineTest, TransformTemplDecls) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { template <typename T> class Bar { public: @@ -329,7 +329,7 @@ bar<Bar<int>>.bar(); aux<Bar<int>>(); })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { template <typename T> class Bar { public: @@ -350,7 +350,7 @@ } TEST_F(DefineInlineTest, TransformMembers) { - auto Test = R"cpp( + const auto *Test = R"cpp( class Foo { void foo(); }; @@ -358,7 +358,7 @@ void Foo::f^oo() { return; })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( class Foo { void foo(){ return; @@ -395,7 +395,7 @@ } TEST_F(DefineInlineTest, TransformDependentTypes) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { template <typename T> class Bar {}; } @@ -409,7 +409,7 @@ Bar<T> B; Bar<Bar<T>> q; })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { template <typename T> class Bar {}; } @@ -511,7 +511,7 @@ } TEST_F(DefineInlineTest, TransformTypeLocs) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { template <typename T> class Bar { public: @@ -528,7 +528,7 @@ Foo foo; a::Bar<Bar<int>>::Baz<Bar<int>> q; })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { template <typename T> class Bar { public: @@ -549,7 +549,7 @@ } TEST_F(DefineInlineTest, TransformDeclRefs) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { template <typename T> class Bar { public: @@ -575,7 +575,7 @@ bar(); a::test(); })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { template <typename T> class Bar { public: @@ -605,12 +605,12 @@ } TEST_F(DefineInlineTest, StaticMembers) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace ns { class X { static void foo(); void bar(); }; } void ns::X::b^ar() { foo(); })cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace ns { class X { static void foo(); void bar(){ foo(); } }; } @@ -654,7 +654,7 @@ } TEST_F(DefineInlineTest, TransformTemplParamNames) { - auto Test = R"cpp( + const auto *Test = R"cpp( struct Foo { struct Bar { template <class, class X, @@ -668,7 +668,7 @@ template<typename> class V, template<typename> class W, int X, int Y> void Foo::Bar::f^oo(U, W<U>, int Q) {})cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( struct Foo { struct Bar { template <class T, class U, @@ -683,13 +683,13 @@ } TEST_F(DefineInlineTest, TransformInlineNamespaces) { - auto Test = R"cpp( + const auto *Test = R"cpp( namespace a { inline namespace b { namespace { struct Foo{}; } } } void foo(); using namespace a; void ^foo() {Foo foo;})cpp"; - auto Expected = R"cpp( + const auto *Expected = R"cpp( namespace a { inline namespace b { namespace { struct Foo{}; } } } void foo(){a::Foo foo;} Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp +++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp @@ -132,7 +132,7 @@ private: void reportDiagnostics(PathRef File, llvm::ArrayRef<Diag> Diags, PublishFn Publish) { - auto D = Context::current().get(DiagsCallbackKey); + const auto *D = Context::current().get(DiagsCallbackKey); if (!D) return; Publish([&]() { @@ -671,11 +671,11 @@ FS.Files[Header] = "void foo()"; FS.Timestamps[Header] = time_t(0); - auto WithPreamble = R"cpp( + const auto *WithPreamble = R"cpp( #include "foo.h" int main() {} )cpp"; - auto WithEmptyPreamble = R"cpp(int main() {})cpp"; + const auto *WithEmptyPreamble = R"cpp(int main() {})cpp"; S.update(Foo, getInputs(Foo, WithPreamble), WantDiagnostics::Auto); S.runWithPreamble( "getNonEmptyPreamble", Foo, TUScheduler::Stale, @@ -748,7 +748,7 @@ // the same time. All reads should get the same non-null preamble. TUScheduler S(CDB, optsForTest()); auto Foo = testPath("foo.cpp"); - auto NonEmptyPreamble = R"cpp( + const auto *NonEmptyPreamble = R"cpp( #define FOO 1 #define BAR 2 @@ -844,7 +844,7 @@ auto HeaderA = testPath("a/foo.h"); auto HeaderB = testPath("b/foo.h"); - auto SourceContents = R"cpp( + const auto *SourceContents = R"cpp( #include "foo.h" int c = b; )cpp"; Index: clang-tools-extra/clangd/unittests/HoverTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/HoverTests.cpp +++ clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -2547,7 +2547,7 @@ TestTU TU = TestTU::withCode(T.code()); auto AST = TU.build(); - for (auto Comment : {"doc1", "doc2", "doc3"}) { + for (const auto *Comment : {"doc1", "doc2", "doc3"}) { for (const auto &P : T.points(Comment)) { auto H = getHover(AST, P, format::getLLVMStyle(), nullptr); ASSERT_TRUE(H); Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FileIndexTests.cpp +++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp @@ -249,7 +249,7 @@ } TEST(FileIndexTest, TemplateParamsInLabel) { - auto Source = R"cpp( + const auto *Source = R"cpp( template <class Ty> class vector { }; Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/ClangdTests.cpp +++ clang-tools-extra/clangd/unittests/ClangdTests.cpp @@ -212,7 +212,7 @@ parseSourceAndDumpAST("foo.cpp", "#include \"foo.h\"", {{"foo.h", ""}}, /*ExpectErrors=*/false); - const auto SourceContents = R"cpp( + const auto *const SourceContents = R"cpp( #include "foo.h" int b = a; )cpp"; @@ -228,7 +228,7 @@ MockCompilationDatabase CDB; ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer); - const auto SourceContents = R"cpp( + const auto *const SourceContents = R"cpp( #include "foo.h" int b = a; )cpp"; @@ -263,7 +263,7 @@ MockCompilationDatabase CDB; ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer); - const auto SourceContents = R"cpp( + const auto *const SourceContents = R"cpp( #include "foo.h" int b = a; )cpp"; @@ -420,7 +420,7 @@ FS.Files[StringPath] = "class mock_string {};"; auto FooCpp = testPath("foo.cpp"); - const auto SourceContents = R"cpp( + const auto *const SourceContents = R"cpp( #include <string> mock_string x; )cpp"; @@ -429,7 +429,7 @@ runAddDocument(Server, FooCpp, SourceContents); EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags()); - const auto SourceContentsWithError = R"cpp( + const auto *const SourceContentsWithError = R"cpp( #include <string> std::string x; )cpp"; @@ -445,11 +445,11 @@ ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer); auto FooCpp = testPath("foo.cpp"); - const auto SourceContents1 = R"cpp( + const auto *const SourceContents1 = R"cpp( template <class T> struct foo { T x; }; )cpp"; - const auto SourceContents2 = R"cpp( + const auto *const SourceContents2 = R"cpp( template <class T> struct bar { T x; }; )cpp"; @@ -481,7 +481,7 @@ ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer); auto FooCpp = testPath("foo.cpp"); - const auto SourceContents = R"cpp( + const auto *const SourceContents = R"cpp( #ifdef WITH_ERROR this #endif @@ -585,7 +585,7 @@ ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer); Path FooCpp = testPath("foo.cpp"); - const auto SourceContents = R"cpp( + const auto *const SourceContents = R"cpp( struct Something { int method(); }; @@ -651,14 +651,14 @@ // BlockingRequestInterval-request will be a blocking one. const unsigned BlockingRequestInterval = 40; - const auto SourceContentsWithoutErrors = R"cpp( + const auto *const SourceContentsWithoutErrors = R"cpp( int a; int b; int c; int d; )cpp"; - const auto SourceContentsWithErrors = R"cpp( + const auto *const SourceContentsWithErrors = R"cpp( int a = x; int b; int c; @@ -891,14 +891,14 @@ std::promise<void> StartSecondReparse; }; - const auto SourceContentsWithoutErrors = R"cpp( + const auto *const SourceContentsWithoutErrors = R"cpp( int a; int b; int c; int d; )cpp"; - const auto SourceContentsWithErrors = R"cpp( + const auto *const SourceContentsWithErrors = R"cpp( int a = x; int b; int c; Index: clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp +++ clang-tools-extra/clangd/refactor/tweaks/ExpandMacro.cpp @@ -52,7 +52,7 @@ llvm::ArrayRef<syntax::Token> Spelled, unsigned CursorOffset) { // Find the token that strats after the offset, then look at a previous one. - auto It = llvm::partition_point(Spelled, [&](const syntax::Token &T) { + auto *It = llvm::partition_point(Spelled, [&](const syntax::Token &T) { assert(T.location().isFileID()); return SM.getFileOffset(T.location()) <= CursorOffset; }); Index: clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp +++ clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp @@ -34,7 +34,7 @@ const char *id() const override final; bool prepare(const Selection &Inputs) override { - for (auto N = Inputs.ASTSelection.commonAncestor(); N && !Node; + for (auto *N = Inputs.ASTSelection.commonAncestor(); N && !Node; N = N->Parent) if (dumpable(N->ASTNode)) Node = N->ASTNode; Index: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -342,13 +342,13 @@ // Because canonical declaration points to template decl instead of // specialization. const FunctionDecl *findTarget(const FunctionDecl *FD) { - auto CanonDecl = FD->getCanonicalDecl(); + auto *CanonDecl = FD->getCanonicalDecl(); if (!FD->isFunctionTemplateSpecialization() || CanonDecl == FD) return CanonDecl; // For specializations CanonicalDecl is the TemplatedDecl, which is not the // target we want to inline into. Instead we traverse previous decls to find // the first forward decl for this specialization. - auto PrevDecl = FD; + auto *PrevDecl = FD; while (PrevDecl->getPreviousDecl() != CanonDecl) { PrevDecl = PrevDecl->getPreviousDecl(); assert(PrevDecl && "Found specialization without template decl"); Index: clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp +++ clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp @@ -38,7 +38,7 @@ Expected<Tweak::Effect> AnnotateHighlightings::apply(const Selection &Inputs) { const Decl *CommonDecl = nullptr; - for (auto N = Inputs.ASTSelection.commonAncestor(); N && !CommonDecl; + for (auto *N = Inputs.ASTSelection.commonAncestor(); N && !CommonDecl; N = N->Parent) CommonDecl = N->ASTNode.get<Decl>(); Index: clang-tools-extra/clangd/index/dex/Iterator.cpp =================================================================== --- clang-tools-extra/clangd/index/dex/Iterator.cpp +++ clang-tools-extra/clangd/index/dex/Iterator.cpp @@ -77,7 +77,7 @@ private: llvm::raw_ostream &dump(llvm::raw_ostream &OS) const override { OS << "(& "; - auto Separator = ""; + auto *Separator = ""; for (const auto &Child : Children) { OS << Separator << *Child; Separator = " "; @@ -206,7 +206,7 @@ private: llvm::raw_ostream &dump(llvm::raw_ostream &OS) const override { OS << "(| "; - auto Separator = ""; + auto *Separator = ""; for (const auto &Child : Children) { OS << Separator << *Child; Separator = " "; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp =================================================================== --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -43,7 +43,7 @@ /// If \p ND is a template specialization, returns the described template. /// Otherwise, returns \p ND. const NamedDecl &getTemplateOrThis(const NamedDecl &ND) { - if (auto T = ND.getDescribedTemplate()) + if (auto *T = ND.getDescribedTemplate()) return *T; return ND; } Index: clang-tools-extra/clangd/index/IndexAction.cpp =================================================================== --- clang-tools-extra/clangd/index/IndexAction.cpp +++ clang-tools-extra/clangd/index/IndexAction.cpp @@ -61,7 +61,7 @@ return; const auto FileID = SM.getFileID(Loc); - const auto File = SM.getFileEntryForID(FileID); + const auto *File = SM.getFileEntryForID(FileID); auto URI = toURI(File); if (!URI) return; Index: clang-tools-extra/clangd/TUScheduler.cpp =================================================================== --- clang-tools-extra/clangd/TUScheduler.cpp +++ clang-tools-extra/clangd/TUScheduler.cpp @@ -1717,7 +1717,7 @@ // nth_element needs a mutable array, take the chance to bound the data size. History = History.take_back(15); llvm::SmallVector<clock::duration, 15> Recent(History.begin(), History.end()); - auto Median = Recent.begin() + Recent.size() / 2; + auto *Median = Recent.begin() + Recent.size() / 2; std::nth_element(Recent.begin(), Median, Recent.end()); clock::duration Target = Index: clang-tools-extra/clangd/Hover.cpp =================================================================== --- clang-tools-extra/clangd/Hover.cpp +++ clang-tools-extra/clangd/Hover.cpp @@ -83,7 +83,7 @@ Policy.SuppressScope = true; return declaredType(D).getAsString(Policy); } - if (auto RD = dyn_cast<RecordDecl>(D)) + if (auto *RD = dyn_cast<RecordDecl>(D)) return ("(anonymous " + RD->getKindName() + ")").str(); return std::string(""); }; Index: clang-tools-extra/clangd/HeaderSourceSwitch.cpp =================================================================== --- clang-tools-extra/clangd/HeaderSourceSwitch.cpp +++ clang-tools-extra/clangd/HeaderSourceSwitch.cpp @@ -25,13 +25,13 @@ llvm::StringRef PathExt = llvm::sys::path::extension(OriginalFile); // Lookup in a list of known extensions. - auto SourceIter = + auto *SourceIter = llvm::find_if(SourceExtensions, [&PathExt](PathRef SourceExt) { return SourceExt.equals_insensitive(PathExt); }); bool IsSource = SourceIter != std::end(SourceExtensions); - auto HeaderIter = + auto *HeaderIter = llvm::find_if(HeaderExtensions, [&PathExt](PathRef HeaderExt) { return HeaderExt.equals_insensitive(PathExt); }); Index: clang-tools-extra/clangd/FindSymbols.cpp =================================================================== --- clang-tools-extra/clangd/FindSymbols.cpp +++ clang-tools-extra/clangd/FindSymbols.cpp @@ -483,7 +483,7 @@ if (!llvm::isa<NamedDecl>(D)) return VisitKind::No; - if (auto Func = llvm::dyn_cast<FunctionDecl>(D)) { + if (auto *Func = llvm::dyn_cast<FunctionDecl>(D)) { // Some functions are implicit template instantiations, those should be // ignored. if (auto *Info = Func->getTemplateSpecializationInfo()) { Index: clang-tools-extra/clangd/ExpectedTypes.cpp =================================================================== --- clang-tools-extra/clangd/ExpectedTypes.cpp +++ clang-tools-extra/clangd/ExpectedTypes.cpp @@ -53,7 +53,7 @@ auto T = VD->getType(); if (T.isNull()) return llvm::None; - if (auto FuncT = T->getAs<FunctionType>()) { + if (auto *FuncT = T->getAs<FunctionType>()) { // Functions are a special case. They are completed as 'foo()' and we want // to match their return type rather than the function type itself. // FIXME(ibiryukov): in some cases, we might want to avoid completing `()` Index: clang-tools-extra/clangd/CodeComplete.cpp =================================================================== --- clang-tools-extra/clangd/CodeComplete.cpp +++ clang-tools-extra/clangd/CodeComplete.cpp @@ -437,7 +437,7 @@ template <std::string BundledEntry::*Member> const std::string *onlyValue() const { auto B = Bundled.begin(), E = Bundled.end(); - for (auto I = B + 1; I != E; ++I) + for (auto *I = B + 1; I != E; ++I) if (I->*Member != B->*Member) return nullptr; return &(B->*Member); @@ -445,7 +445,7 @@ template <bool BundledEntry::*Member> const bool *onlyValue() const { auto B = Bundled.begin(), E = Bundled.end(); - for (auto I = B + 1; I != E; ++I) + for (auto *I = B + 1; I != E; ++I) if (I->*Member != B->*Member) return nullptr; return &(B->*Member); Index: clang-tools-extra/clangd/AST.cpp =================================================================== --- clang-tools-extra/clangd/AST.cpp +++ clang-tools-extra/clangd/AST.cpp @@ -438,7 +438,7 @@ const AutoType *AT = D->getReturnType()->getContainedAutoType(); if (AT && !AT->getDeducedType().isNull()) { DeducedType = AT->getDeducedType(); - } else if (auto DT = dyn_cast<DecltypeType>(D->getReturnType())) { + } else if (auto *DT = dyn_cast<DecltypeType>(D->getReturnType())) { // auto in a trailing return type just points to a DecltypeType and // getContainedAutoType does not unwrap it. if (!DT->getUnderlyingType().isNull())
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits