[NFC][clangd] cleaning up llvm-qualified-auto

This is a cleanup of all llvm-qualified-auto findings.
This patch was created by automatically applying the fixes from
clang-tidy.

Differential Revision: https://reviews.llvm.org/D113898
This commit is contained in:
Christian Kühnel 2021-12-13 15:14:31 +00:00
parent d581c94d6b
commit c0e3c893aa
19 changed files with 60 additions and 60 deletions

View File

@ -456,7 +456,7 @@ public:
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())

View File

@ -453,7 +453,7 @@ private:
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);
@ -461,7 +461,7 @@ private:
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);

View File

@ -53,7 +53,7 @@ typeOfCompletion(const CodeCompletionResult &R) {
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 `()`

View File

@ -483,7 +483,7 @@ private:
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()) {

View File

@ -25,13 +25,13 @@ llvm::Optional<Path> getCorrespondingHeaderOrSource(
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);
});

View File

@ -86,7 +86,7 @@ std::string getLocalScope(const Decl *D) {
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("");
};

View File

@ -1714,7 +1714,7 @@ DebouncePolicy::compute(llvm::ArrayRef<clock::duration> History) const {
// 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 =

View File

@ -61,7 +61,7 @@ public:
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;

View File

@ -43,7 +43,7 @@ namespace {
/// 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;
}

View File

@ -77,7 +77,7 @@ public:
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 @@ public:
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 = " ";

View File

@ -38,7 +38,7 @@ REGISTER_TWEAK(AnnotateHighlightings)
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>();

View File

@ -342,13 +342,13 @@ renameParameters(const FunctionDecl *Dest, const FunctionDecl *Source,
// 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");

View File

@ -34,7 +34,7 @@ public:
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;

View File

@ -52,7 +52,7 @@ findTokenUnderCursor(const SourceManager &SM,
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;
});

View File

@ -212,7 +212,7 @@ TEST(ClangdServerTest, ParseWithHeader) {
parseSourceAndDumpAST("foo.cpp", "#include \"foo.h\"", {{"foo.h", ""}},
/*ExpectErrors=*/false);
const auto SourceContents = R"cpp(
const auto *SourceContents = R"cpp(
#include "foo.h"
int b = a;
)cpp";
@ -228,7 +228,7 @@ TEST(ClangdServerTest, Reparse) {
MockCompilationDatabase CDB;
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
const auto SourceContents = R"cpp(
const auto *SourceContents = R"cpp(
#include "foo.h"
int b = a;
)cpp";
@ -263,7 +263,7 @@ TEST(ClangdServerTest, ReparseOnHeaderChange) {
MockCompilationDatabase CDB;
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
const auto SourceContents = R"cpp(
const auto *SourceContents = R"cpp(
#include "foo.h"
int b = a;
)cpp";
@ -420,7 +420,7 @@ TEST(ClangdServerTest, SearchLibDir) {
FS.Files[StringPath] = "class mock_string {};";
auto FooCpp = testPath("foo.cpp");
const auto SourceContents = R"cpp(
const auto *SourceContents = R"cpp(
#include <string>
mock_string x;
)cpp";
@ -429,7 +429,7 @@ mock_string x;
runAddDocument(Server, FooCpp, SourceContents);
EXPECT_FALSE(DiagConsumer.hadErrorInLastDiags());
const auto SourceContentsWithError = R"cpp(
const auto *SourceContentsWithError = R"cpp(
#include <string>
std::string x;
)cpp";
@ -445,11 +445,11 @@ TEST(ClangdServerTest, ForceReparseCompileCommand) {
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
auto FooCpp = testPath("foo.cpp");
const auto SourceContents1 = R"cpp(
const auto *SourceContents1 = R"cpp(
template <class T>
struct foo { T x; };
)cpp";
const auto SourceContents2 = R"cpp(
const auto *SourceContents2 = R"cpp(
template <class T>
struct bar { T x; };
)cpp";
@ -481,7 +481,7 @@ TEST(ClangdServerTest, ForceReparseCompileCommandDefines) {
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
auto FooCpp = testPath("foo.cpp");
const auto SourceContents = R"cpp(
const auto *SourceContents = R"cpp(
#ifdef WITH_ERROR
this
#endif
@ -585,7 +585,7 @@ TEST(ClangdServerTest, FileStats) {
ClangdServer Server(CDB, FS, ClangdServer::optsForTest(), &DiagConsumer);
Path FooCpp = testPath("foo.cpp");
const auto SourceContents = R"cpp(
const auto *SourceContents = R"cpp(
struct Something {
int method();
};
@ -652,14 +652,14 @@ TEST(ClangdThreadingTest, StressTest) {
// BlockingRequestInterval-request will be a blocking one.
const unsigned BlockingRequestInterval = 40;
const auto SourceContentsWithoutErrors = R"cpp(
const auto *SourceContentsWithoutErrors = R"cpp(
int a;
int b;
int c;
int d;
)cpp";
const auto SourceContentsWithErrors = R"cpp(
const auto *SourceContentsWithErrors = R"cpp(
int a = x;
int b;
int c;
@ -892,14 +892,14 @@ TEST(ClangdThreadingTest, NoConcurrentDiagnostics) {
std::promise<void> StartSecondReparse;
};
const auto SourceContentsWithoutErrors = R"cpp(
const auto *SourceContentsWithoutErrors = R"cpp(
int a;
int b;
int c;
int d;
)cpp";
const auto SourceContentsWithErrors = R"cpp(
const auto *SourceContentsWithErrors = R"cpp(
int a = x;
int b;
int c;

View File

@ -249,7 +249,7 @@ TEST(FileIndexTest, HasSystemHeaderMappingsInPreamble) {
}
TEST(FileIndexTest, TemplateParamsInLabel) {
auto Source = R"cpp(
auto *Source = R"cpp(
template <class Ty>
class vector {
};

View File

@ -2695,7 +2695,7 @@ TEST(Hover, DocsFromMostSpecial) {
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);

View File

@ -132,7 +132,7 @@ protected:
private:
void reportDiagnostics(PathRef File, llvm::ArrayRef<Diag> Diags,
PublishFn Publish) {
auto D = Context::current().get(DiagsCallbackKey);
auto *D = Context::current().get(DiagsCallbackKey);
if (!D)
return;
Publish([&]() {
@ -671,11 +671,11 @@ TEST_F(TUSchedulerTests, EmptyPreamble) {
FS.Files[Header] = "void foo()";
FS.Timestamps[Header] = time_t(0);
auto WithPreamble = R"cpp(
auto *WithPreamble = R"cpp(
#include "foo.h"
int main() {}
)cpp";
auto WithEmptyPreamble = R"cpp(int main() {})cpp";
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 @@ TEST_F(TUSchedulerTests, RunWaitsForPreamble) {
// 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(
auto *NonEmptyPreamble = R"cpp(
#define FOO 1
#define BAR 2
@ -844,7 +844,7 @@ TEST_F(TUSchedulerTests, MissingHeader) {
auto HeaderA = testPath("a/foo.h");
auto HeaderB = testPath("b/foo.h");
auto SourceContents = R"cpp(
auto *SourceContents = R"cpp(
#include "foo.h"
int c = b;
)cpp";

View File

@ -192,7 +192,7 @@ TEST_F(DefineInlineTest, UsingShadowDecls) {
}
TEST_F(DefineInlineTest, TransformNestedNamespaces) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace a {
void bar();
namespace b {
@ -220,7 +220,7 @@ TEST_F(DefineInlineTest, TransformNestedNamespaces) {
b::c::aux();
a::b::c::aux();
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace a {
void bar();
namespace b {
@ -252,7 +252,7 @@ TEST_F(DefineInlineTest, TransformNestedNamespaces) {
}
TEST_F(DefineInlineTest, TransformUsings) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace a { namespace b { namespace c { void aux(); } } }
void foo();
@ -263,7 +263,7 @@ TEST_F(DefineInlineTest, TransformUsings) {
using c::aux;
namespace d = c;
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace a { namespace b { namespace c { void aux(); } } }
void foo(){
@ -278,7 +278,7 @@ TEST_F(DefineInlineTest, TransformUsings) {
}
TEST_F(DefineInlineTest, TransformDecls) {
auto Test = R"cpp(
auto *Test = R"cpp(
void foo();
void f^oo() {
class Foo {
@ -293,7 +293,7 @@ TEST_F(DefineInlineTest, TransformDecls) {
enum class EnClass { Zero, One };
EnClass y = EnClass::Zero;
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
void foo(){
class Foo {
public:
@ -312,7 +312,7 @@ TEST_F(DefineInlineTest, TransformDecls) {
}
TEST_F(DefineInlineTest, TransformTemplDecls) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace a {
template <typename T> class Bar {
public:
@ -329,7 +329,7 @@ TEST_F(DefineInlineTest, TransformTemplDecls) {
bar<Bar<int>>.bar();
aux<Bar<int>>();
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace a {
template <typename T> class Bar {
public:
@ -350,7 +350,7 @@ TEST_F(DefineInlineTest, TransformTemplDecls) {
}
TEST_F(DefineInlineTest, TransformMembers) {
auto Test = R"cpp(
auto *Test = R"cpp(
class Foo {
void foo();
};
@ -358,7 +358,7 @@ TEST_F(DefineInlineTest, TransformMembers) {
void Foo::f^oo() {
return;
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
class Foo {
void foo(){
return;
@ -395,7 +395,7 @@ TEST_F(DefineInlineTest, TransformMembers) {
}
TEST_F(DefineInlineTest, TransformDependentTypes) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace a {
template <typename T> class Bar {};
}
@ -409,7 +409,7 @@ TEST_F(DefineInlineTest, TransformDependentTypes) {
Bar<T> B;
Bar<Bar<T>> q;
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace a {
template <typename T> class Bar {};
}
@ -511,7 +511,7 @@ TEST_F(DefineInlineTest, TransformFunctionTempls) {
}
TEST_F(DefineInlineTest, TransformTypeLocs) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace a {
template <typename T> class Bar {
public:
@ -528,7 +528,7 @@ TEST_F(DefineInlineTest, TransformTypeLocs) {
Foo foo;
a::Bar<Bar<int>>::Baz<Bar<int>> q;
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace a {
template <typename T> class Bar {
public:
@ -549,7 +549,7 @@ TEST_F(DefineInlineTest, TransformTypeLocs) {
}
TEST_F(DefineInlineTest, TransformDeclRefs) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace a {
template <typename T> class Bar {
public:
@ -575,7 +575,7 @@ TEST_F(DefineInlineTest, TransformDeclRefs) {
bar();
a::test();
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace a {
template <typename T> class Bar {
public:
@ -605,12 +605,12 @@ TEST_F(DefineInlineTest, TransformDeclRefs) {
}
TEST_F(DefineInlineTest, StaticMembers) {
auto Test = R"cpp(
auto *Test = R"cpp(
namespace ns { class X { static void foo(); void bar(); }; }
void ns::X::b^ar() {
foo();
})cpp";
auto Expected = R"cpp(
auto *Expected = R"cpp(
namespace ns { class X { static void foo(); void bar(){
foo();
} }; }
@ -654,7 +654,7 @@ est);
}
TEST_F(DefineInlineTest, TransformTemplParamNames) {
auto Test = R"cpp(
auto *Test = R"cpp(
struct Foo {
struct Bar {
template <class, class X,
@ -668,7 +668,7 @@ TEST_F(DefineInlineTest, TransformTemplParamNames) {
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(
auto *Expected = R"cpp(
struct Foo {
struct Bar {
template <class T, class U,
@ -683,13 +683,13 @@ TEST_F(DefineInlineTest, TransformTemplParamNames) {
}
TEST_F(DefineInlineTest, TransformInlineNamespaces) {
auto Test = R"cpp(
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(
auto *Expected = R"cpp(
namespace a { inline namespace b { namespace { struct Foo{}; } } }
void foo(){a::Foo foo;}