[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 09:39:26 PDT 2023


Manna created this revision.
Manna added a reviewer: tahonermann.
Herald added subscribers: kosarev, tpr.
Herald added a reviewer: aaron.ballman.
Herald added a reviewer: ributzka.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.
Herald added a reviewer: dang.

Reported by Coverity:
AUTO_CAUSES_COPY
Unnecessary object copies can affect performance.

1. Inside "ExtractAPIVisitor.h" file, in clang::​extractapi::​impl::​ExtractAPIVisitorBase<<unnamed>::​BatchExtractAPIVisitor>::​VisitFunctionDecl(clang::​FunctionDecl const *): Using the auto keyword without an & causes the copy of an object of type DynTypedNode.

2. Inside "NeonEmitter.cpp" file, in <unnamed>::​Intrinsic::​Intrinsic(llvm::​Record *, llvm::​StringRef, llvm::​StringRef, <unnamed>::​TypeSpec, <unnamed>::​TypeSpec, <unnamed>::​ClassKind, llvm::​ListInit *, <unnamed>::​NeonEmitter &, llvm::​StringRef, llvm::​StringRef, bool, bool): Using the auto keyword without an & causes the copy of an object of type Type.

3. Inside "MicrosoftCXXABI.cpp" file, in <unnamed>::​MSRTTIBuilder::​getClassHierarchyDescriptor(): Using the auto keyword without an & causes the copy of an object of type MSRTTIClass.

4. Inside "Registry.cpp" file, in clang::​ast_matchers::​dynamic::​Registry::​getAcceptedCompletionTypes(llvm::​ArrayRef<std::​pair<clang::​ast_matchers::​dynamic::​internal::​MatcherDescriptor const *, unsigned int>>): Using the auto keyword without an & causes he copy of an object of type ASTNodeKind.

5. Inside "Tokens.cpp" file, in clang::​syntax::​TokenBuffer::​macroExpansions(clang::​FileID): Using the auto keyword without an & causes he copy of an object of type Mapping.

6. Inside "CGGPUBuiltin.cpp" file, in clang::​CodeGen::​CodeGenFunction::​EmitAMDGPUDevicePrintfCallExpr(clang::​CallExpr const *): Using the auto keyword without an & causes the copy of an object of type CallArg.

7. Inside "SemaDeclAttr.cpp" file, in threadSafetyCheckIsSmartPointer(clang::​Sema &, clang::​RecordType const *): Using the auto keyword without an & causes the copy of an object of type CXXBaseSpecifier.

8. Inside "ComputeDependence.cpp" file, in clang::​computeDependence(clang::​DesignatedInitExpr *): Using the auto keyword without an & causes the copy of an object of type Designator.

9. Inside "Format.cpp" file, In clang::​format::​affectsRange(llvm::​ArrayRef<clang::​tooling::​Range>, unsigned int, unsigned int): Using the auto keyword without an & causes the copy of an object of type Range.

10. Inside "SemaLookup.cpp" file, In clang::​TypoCorrectionConsumer::​addNamespaces(llvm::​MapVector<clang::​NamespaceDecl *, bool, llvm::​DenseMap<clang::​NamespaceDecl *, unsigned int, llvm::​DenseMapInfo<clang::​NamespaceDecl *, void>, llvm::​detail::​DenseMapPair<clang::​NamespaceDecl *, unsigned int>>, std::​vector<std::​pair<clang::​NamespaceDecl *, bool>, std::​allocator<std::​pair<clang::​NamespaceDecl *, bool>>>> const &): Using the auto keyword without an & causes  the copy of an object of type pair.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149074

Files:
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/utils/TableGen/NeonEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149074.516437.patch
Type: text/x-patch
Size: 5358 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230424/ee0d1f11/attachment.bin>


More information about the cfe-commits mailing list