[clang] 4e3d462 - Fix undefined behaviour when trying to deref nullptr.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 14:52:19 PDT 2020


Author: Alexey Bataev
Date: 2020-06-04T17:52:06-04:00
New Revision: 4e3d4622b1e7bd419815510e5f7cd0f96595b2a3

URL: https://github.com/llvm/llvm-project/commit/4e3d4622b1e7bd419815510e5f7cd0f96595b2a3
DIFF: https://github.com/llvm/llvm-project/commit/4e3d4622b1e7bd419815510e5f7cd0f96595b2a3.diff

LOG: Fix undefined behaviour when trying to deref nullptr.

Added: 
    

Modified: 
    clang/lib/CodeGen/CodeGenFunction.h

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 2b0ebad3088e..cfd9950066bb 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -684,18 +684,18 @@ class CodeGenFunction : public CodeGenTypeCache {
   /// Manages parent directive for scan directives.
   class ParentLoopDirectiveForScanRegion {
     CodeGenFunction &CGF;
-    const OMPExecutableDirective &ParentLoopDirectiveForScan;
+    const OMPExecutableDirective *ParentLoopDirectiveForScan;
 
   public:
     ParentLoopDirectiveForScanRegion(
         CodeGenFunction &CGF,
         const OMPExecutableDirective &ParentLoopDirectiveForScan)
         : CGF(CGF),
-          ParentLoopDirectiveForScan(*CGF.OMPParentLoopDirectiveForScan) {
+          ParentLoopDirectiveForScan(CGF.OMPParentLoopDirectiveForScan) {
       CGF.OMPParentLoopDirectiveForScan = &ParentLoopDirectiveForScan;
     }
     ~ParentLoopDirectiveForScanRegion() {
-      CGF.OMPParentLoopDirectiveForScan = &ParentLoopDirectiveForScan;
+      CGF.OMPParentLoopDirectiveForScan = ParentLoopDirectiveForScan;
     }
   };
 


        


More information about the cfe-commits mailing list