kuhnel created this revision.
Herald added subscribers: carlosgalvezp, usaxena95, kadircet, arphaman,
javed.absar.
kuhnel added subscribers: sammccall, adamcz, kbobyrev.
kuhnel published this revision for review.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
This is a cleanup of all llvm-qualified-auto findings.
This patch was created by automatically applying the fixes from
clang-tidy.
Repository:
rG LLVM Github Monorepo
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
@@ -214,7 +214,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";
@@ -230,7 +230,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";
@@ -265,7 +265,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";
@@ -422,7 +422,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";
@@ -431,7 +431,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";
@@ -447,11 +447,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";
@@ -483,7 +483,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
@@ -587,7 +587,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();
};
@@ -653,14 +653,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;
@@ -893,14 +893,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) {
+ const 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 (const 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();
+ const 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;
+ const 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 (const 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 = "";
+ const 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 = "";
+ const 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 *const 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 (const 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 (const 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 (const 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 (const 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 (const 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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits