[clang] 0cb2906 - [NFC][clang] Fix static analyzer concerns

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 24 05:38:04 PDT 2023


Author: Podchishchaeva, Mariya
Date: 2023-07-24T05:31:55-07:00
New Revision: 0cb2906cdfb3480382828890e9ac4c076c17f3fa

URL: https://github.com/llvm/llvm-project/commit/0cb2906cdfb3480382828890e9ac4c076c17f3fa
DIFF: https://github.com/llvm/llvm-project/commit/0cb2906cdfb3480382828890e9ac4c076c17f3fa.diff

LOG: [NFC][clang] Fix static analyzer concerns

HeaderIncludesCallback and HeaderIncludesJSONCallback classes may own
resources and free them in the destructor. However they don't have copy
user-written constructors/assignment operators, so an attempt to copy a
HeaderIncludesCallback object will use compiler-generated copy
constructor which will only do dummy copy and afterwards there will be
use-after-free issues.

Reviewed By: aaron.ballman, tahonermann

Differential Revision: https://reviews.llvm.org/D155842

Added: 
    

Modified: 
    clang/lib/Frontend/HeaderIncludeGen.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/HeaderIncludeGen.cpp b/clang/lib/Frontend/HeaderIncludeGen.cpp
index 9ada227d42d622..9c1bf490fcd65e 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -43,6 +43,9 @@ class HeaderIncludesCallback : public PPCallbacks {
       delete OutputFile;
   }
 
+  HeaderIncludesCallback(const HeaderIncludesCallback &) = delete;
+  HeaderIncludesCallback &operator=(const HeaderIncludesCallback &) = delete;
+
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,
                    SrcMgr::CharacteristicKind FileType,
                    FileID PrevFID) override;
@@ -90,6 +93,10 @@ class HeaderIncludesJSONCallback : public PPCallbacks {
       delete OutputFile;
   }
 
+  HeaderIncludesJSONCallback(const HeaderIncludesJSONCallback &) = delete;
+  HeaderIncludesJSONCallback &
+  operator=(const HeaderIncludesJSONCallback &) = delete;
+
   void EndOfMainFile() override;
 
   void FileChanged(SourceLocation Loc, FileChangeReason Reason,


        


More information about the cfe-commits mailing list