[PATCH] D149461: [NFC] ][CLANG] Fix static code analyzer concerns

Tom Honermann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 5 13:48:36 PDT 2023


tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

These changes look good to me and I agree with not making a change for the `KnownHeaders` case.



================
Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:1131-1132
     // Deallocate the memory for each globalized VLA object
-    for (auto AddrSizePair :
+    for (const auto &AddrSizePair :
          llvm::reverse(I->getSecond().EscapedVariableLengthDeclsAddrs)) {
       CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
----------------
`EscapedVariableLengthDeclsAddrs` is a `llvm::SmallVector`; this looks like a good change.


================
Comment at: clang/lib/Serialization/ASTReader.cpp:4428
   // Mark selectors as out of date.
-  for (auto Sel : SelectorGeneration)
+  for (const auto &Sel : SelectorGeneration)
     SelectorOutOfDate[Sel.first] = true;
----------------
Manna wrote:
> Here Object of type is `DenseMapPair`.  `SelectorGeneration`  returns `llvm::DenseMap<Selector, Unsigned>' in `ASTReader.h' file.
Yes, looks like a good change.


================
Comment at: clang/lib/Serialization/ASTReader.cpp:7696
   if (isa<TranslationUnitDecl>(DC)) {
-    for (auto Lexical : TULexicalDecls)
+    for (const auto &Lexical : TULexicalDecls)
       Visit(Lexical.first, Lexical.second);
----------------
Manna wrote:
> This returns `std::vector<std::pair<ModuleFile*, LexicalContents>` in 'ASTReader.h` file
Yes, this looks like a good change.


================
Comment at: clang/lib/Serialization/ASTWriter.cpp:1887
       // enough information in the module map.
-      for (auto U : M->MissingHeaders) {
+      for (const auto &U : M->MissingHeaders) {
         // Check that we were given enough information to build a module
----------------
Manna wrote:
> This returns ` SmallVector<UnresolvedHeaderDirective, 1>` in `Module.h' file
> 
> 
> 
Yes, looks like a good change.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149461/new/

https://reviews.llvm.org/D149461



More information about the cfe-commits mailing list