[PATCH] D149074: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY
Soumi Manna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 24 14:53:43 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38ecb9767c14: [NFC][clang] Fix Coverity bugs with AUTO_CAUSES_COPY (authored by Manna).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149074/new/
https://reviews.llvm.org/D149074
Files:
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/CodeGen/CGGPUBuiltin.cpp
clang/lib/CodeGen/MicrosoftCXXABI.cpp
clang/lib/Format/Format.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/utils/TableGen/NeonEmitter.cpp
Index: clang/utils/TableGen/NeonEmitter.cpp
===================================================================
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -389,7 +389,7 @@
Mods = getNextModifiers(Proto, Pos);
}
- for (auto Type : Types) {
+ for (const auto &Type : Types) {
// If this builtin takes an immediate argument, we need to #define it rather
// than use a standard declaration, so that SemaChecking can range check
// the immediate passed by the user.
Index: clang/lib/Sema/SemaDeclAttr.cpp
===================================================================
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -447,7 +447,7 @@
if (!CXXRecord)
return false;
- for (auto BaseSpecifier : CXXRecord->bases()) {
+ for (const auto &BaseSpecifier : CXXRecord->bases()) {
if (!foundStarOperator)
foundStarOperator = IsOverloadedOperatorPresent(
BaseSpecifier.getType()->getAsRecordDecl(), OO_Star);
Index: clang/lib/Format/Format.cpp
===================================================================
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2806,7 +2806,7 @@
// Determines whether 'Ranges' intersects with ('Start', 'End').
static bool affectsRange(ArrayRef<tooling::Range> Ranges, unsigned Start,
unsigned End) {
- for (auto Range : Ranges) {
+ for (const auto &Range : Ranges) {
if (Range.getOffset() < End &&
Range.getOffset() + Range.getLength() > Start) {
return true;
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -3757,7 +3757,7 @@
Classes.front().initialize(/*Parent=*/nullptr, /*Specifier=*/nullptr);
detectAmbiguousBases(Classes);
int Flags = 0;
- for (auto Class : Classes) {
+ for (const MSRTTIClass &Class : Classes) {
if (Class.RD->getNumBases() > 1)
Flags |= HasBranchingHierarchy;
// Note: cl.exe does not calculate "HasAmbiguousBases" correctly. We
Index: clang/lib/CodeGen/CGGPUBuiltin.cpp
===================================================================
--- clang/lib/CodeGen/CGGPUBuiltin.cpp
+++ clang/lib/CodeGen/CGGPUBuiltin.cpp
@@ -189,7 +189,7 @@
/* ParamsToSkip = */ 0);
SmallVector<llvm::Value *, 8> Args;
- for (auto A : CallArgs) {
+ for (const auto &A : CallArgs) {
// We don't know how to emit non-scalar varargs.
if (!A.getRValue(*this).isScalar()) {
CGM.ErrorUnsupported(E, "non-scalar arg to printf");
Index: clang/lib/AST/ComputeDependence.cpp
===================================================================
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -663,7 +663,7 @@
ExprDependence clang::computeDependence(DesignatedInitExpr *E) {
auto Deps = E->getInit()->getDependence();
- for (auto D : E->designators()) {
+ for (const auto &D : E->designators()) {
auto DesignatorDeps = ExprDependence::None;
if (D.isArrayDesignator())
DesignatorDeps |= E->getArrayIndex(D)->getDependence();
Index: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
===================================================================
--- clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
+++ clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
@@ -179,7 +179,7 @@
return true;
// Skip methods in records.
- for (auto P : Context.getParents(*Method)) {
+ for (const auto &P : Context.getParents(*Method)) {
if (P.template get<CXXRecordDecl>())
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149074.516544.patch
Type: text/x-patch
Size: 3725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230424/0d18ba24/attachment-0001.bin>
More information about the cfe-commits
mailing list