[PATCH] D148812: [NFC][clang] Fix static analyzer concerns
Soumi Manna via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 20 11:04:41 PDT 2023
Manna added inline comments.
================
Comment at: clang/lib/AST/ASTContext.cpp:8206
- for (auto B : CXXRD->bases())
+ for (const auto &B : CXXRD->bases())
if (hasTemplateSpecializationInEncodedString(B.getType().getTypePtr(),
----------------
CXXBaseSpecifier is less in size, but most of cases we are using reference semantics.
================
Comment at: clang/lib/AST/ComputeDependence.cpp:763
D |= toExprDependence(Q->getDependence());
- for (auto A : E->template_arguments())
+ for (const auto &A : E->template_arguments())
D |= toExprDependence(A.getArgument().getDependence());
----------------
TemplateArgumentLoc has a TemplateArgument (pass by value usually), but it also has a TemplateArgumentLocInfo, which is a pair of pointers + source locations.
================
Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:1011
std::vector<ASTNodeKind> NodeKinds;
- for (auto Arg : Args) {
+ for (const auto &Arg : Args) {
if (!Arg.Value.isNodeKind())
----------------
This returns ParserValue which passes as a reference.
================
Comment at: clang/lib/CodeGen/CGVTables.cpp:1278
- for (auto B : RD->vbases())
+ for (const auto &B : RD->vbases())
if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
----------------
CXXBaseSpecifier is less in size, but most of cases we are using reference semantics.
================
Comment at: clang/lib/Lex/Pragma.cpp:1110
Module *M = nullptr;
- for (auto IIAndLoc : ModuleName) {
+ for (const auto &IIAndLoc : ModuleName) {
M = MM.lookupModuleQualified(IIAndLoc.first->getName(), M);
----------------
This returns a std::pair<IdentifierInfo *, SourceLocation> which is not particularly expensive to copy
================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3974
llvm::SmallPtrSet<QualType, 4> UninitializedBaseClasses;
- for (auto I : RD->bases())
+ for (const auto &I : RD->bases())
UninitializedBaseClasses.insert(I.getType().getCanonicalType());
----------------
CXXBaseSpecifier is less in size, but most of cases we are using reference semantics.
================
Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:4262
// will be using.
- for (auto I : Attrs) {
+ for (const auto &I : Attrs) {
const Record &Attr = *I.second;
----------------
Passes as a reference
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148812/new/
https://reviews.llvm.org/D148812
More information about the cfe-commits
mailing list