[clang] 6a72ed2 - [clang] NFC: Fix range-based for loop warnings related to decl lookup
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 19 09:32:16 PDT 2021
Author: Jan Svoboda
Date: 2021-04-19T18:31:31+02:00
New Revision: 6a72ed239cc3f30c1149721f07de463b4b459b16
URL: https://github.com/llvm/llvm-project/commit/6a72ed239cc3f30c1149721f07de463b4b459b16
DIFF: https://github.com/llvm/llvm-project/commit/6a72ed239cc3f30c1149721f07de463b4b459b16.diff
LOG: [clang] NFC: Fix range-based for loop warnings related to decl lookup
Added:
Modified:
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/SemaCodeComplete.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 7e5d96fb8633e..5ecd88e7a14c9 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -2887,7 +2887,7 @@ static void configureBlocksRuntimeObject(CodeGenModule &CGM,
"expected Function or GlobalVariable");
const NamedDecl *ND = nullptr;
- for (const auto &Result : DC->lookup(&II))
+ for (const auto *Result : DC->lookup(&II))
if ((ND = dyn_cast<FunctionDecl>(Result)) ||
(ND = dyn_cast<VarDecl>(Result)))
break;
diff --git a/clang/lib/CodeGen/CGCUDANV.cpp b/clang/lib/CodeGen/CGCUDANV.cpp
index 27fe048f827d0..1cd718d2e22fc 100644
--- a/clang/lib/CodeGen/CGCUDANV.cpp
+++ b/clang/lib/CodeGen/CGCUDANV.cpp
@@ -337,7 +337,7 @@ void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction &CGF,
IdentifierInfo &cudaLaunchKernelII =
CGM.getContext().Idents.get(LaunchKernelName);
FunctionDecl *cudaLaunchKernelFD = nullptr;
- for (const auto &Result : DC->lookup(&cudaLaunchKernelII)) {
+ for (auto *Result : DC->lookup(&cudaLaunchKernelII)) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(Result))
cudaLaunchKernelFD = FD;
}
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp
index 6e6b73f550e35..a790841caa0b3 100644
--- a/clang/lib/CodeGen/CGObjCGNU.cpp
+++ b/clang/lib/CodeGen/CGObjCGNU.cpp
@@ -1232,7 +1232,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
const ObjCInterfaceDecl *OID = nullptr;
- for (const auto &Result : DC->lookup(&II))
+ for (const auto *Result : DC->lookup(&II))
if ((OID = dyn_cast<ObjCInterfaceDecl>(Result)))
break;
@@ -2319,7 +2319,7 @@ llvm::Value *CGObjCGNU::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
const VarDecl *VD = nullptr;
- for (const auto &Result : DC->lookup(&II))
+ for (const auto *Result : DC->lookup(&II))
if ((VD = dyn_cast<VarDecl>(Result)))
break;
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 76ea28c933134..3de67bb4bbc5c 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -6522,7 +6522,7 @@ static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM,
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
const VarDecl *VD = nullptr;
- for (const auto &Result : DC->lookup(&II))
+ for (const auto *Result : DC->lookup(&II))
if ((VD = dyn_cast<VarDecl>(Result)))
break;
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index f719f009ea999..45c150c57c6c3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3644,8 +3644,8 @@ GetRuntimeFunctionDecl(ASTContext &C, StringRef Name) {
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
IdentifierInfo &CII = C.Idents.get(Name);
- for (const auto &Result : DC->lookup(&CII))
- if (const auto FD = dyn_cast<FunctionDecl>(Result))
+ for (const auto *Result : DC->lookup(&CII))
+ if (const auto *FD = dyn_cast<FunctionDecl>(Result))
return FD;
if (!C.getLangOpts().CPlusPlus)
@@ -3659,15 +3659,15 @@ GetRuntimeFunctionDecl(ASTContext &C, StringRef Name) {
for (const auto &N : {"__cxxabiv1", "std"}) {
IdentifierInfo &NS = C.Idents.get(N);
- for (const auto &Result : DC->lookup(&NS)) {
- NamespaceDecl *ND = dyn_cast<NamespaceDecl>(Result);
- if (auto LSD = dyn_cast<LinkageSpecDecl>(Result))
- for (const auto &Result : LSD->lookup(&NS))
+ for (const auto *Result : DC->lookup(&NS)) {
+ const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(Result);
+ if (auto *LSD = dyn_cast<LinkageSpecDecl>(Result))
+ for (const auto *Result : LSD->lookup(&NS))
if ((ND = dyn_cast<NamespaceDecl>(Result)))
break;
if (ND)
- for (const auto &Result : ND->lookup(&CXXII))
+ for (const auto *Result : ND->lookup(&CXXII))
if (const auto *FD = dyn_cast<FunctionDecl>(Result))
return FD;
}
@@ -5038,7 +5038,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
const VarDecl *VD = nullptr;
- for (const auto &Result : DC->lookup(&II))
+ for (const auto *Result : DC->lookup(&II))
if ((VD = dyn_cast<VarDecl>(Result)))
break;
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index dc7a67e92827f..4330024e60ccb 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -5257,7 +5257,7 @@ QualType getApproximateType(const Expr *E) {
Base = Base->getPointeeType(); // could handle unique_ptr etc here?
RecordDecl *RD = Base.isNull() ? nullptr : getAsRecordDecl(Base);
if (RD && RD->isCompleteDefinition()) {
- for (const auto &Member : RD->lookup(CDSME->getMember()))
+ for (const auto *Member : RD->lookup(CDSME->getMember()))
if (const ValueDecl *VD = llvm::dyn_cast<ValueDecl>(Member))
return VD->getType().getNonReferenceType();
}
@@ -5891,7 +5891,7 @@ static QualType getDesignatedType(QualType BaseType, const Designation &Desig) {
assert(D.isFieldDesignator());
auto *RD = getAsRecordDecl(BaseType);
if (RD && RD->isCompleteDefinition()) {
- for (const auto &Member : RD->lookup(D.getField()))
+ for (const auto *Member : RD->lookup(D.getField()))
if (const FieldDecl *FD = llvm::dyn_cast<FieldDecl>(Member)) {
NextType = FD->getType();
break;
More information about the cfe-commits
mailing list