[PATCH] D150504: [AST] Construct Capture objects before use
This revision was automatically updated to reflect the committed changes. Closed by commit rG8826cd57825d: [AST] Construct Capture objects before use (authored by vitalybuka). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150504/new/ https://reviews.llvm.org/D150504 Files: clang/include/clang/AST/Stmt.h clang/lib/AST/Stmt.cpp Index: clang/lib/AST/Stmt.cpp === --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -1345,6 +1345,11 @@ : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), CapDeclAndKind(nullptr, CR_Default) { getStoredStmts()[NumCaptures] = nullptr; + + // Construct default capture objects. + Capture *Buffer = getStoredCaptures(); + for (unsigned I = 0, N = NumCaptures; I != N; ++I) +new (Buffer++) Capture(); } CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S, Index: clang/include/clang/AST/Stmt.h === --- clang/include/clang/AST/Stmt.h +++ clang/include/clang/AST/Stmt.h @@ -3587,8 +3587,11 @@ llvm::PointerIntPair VarAndKind; SourceLocation Loc; +Capture() = default; + public: friend class ASTStmtReader; +friend class CapturedStmt; /// Create a new capture. /// Index: clang/lib/AST/Stmt.cpp === --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -1345,6 +1345,11 @@ : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), CapDeclAndKind(nullptr, CR_Default) { getStoredStmts()[NumCaptures] = nullptr; + + // Construct default capture objects. + Capture *Buffer = getStoredCaptures(); + for (unsigned I = 0, N = NumCaptures; I != N; ++I) +new (Buffer++) Capture(); } CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S, Index: clang/include/clang/AST/Stmt.h === --- clang/include/clang/AST/Stmt.h +++ clang/include/clang/AST/Stmt.h @@ -3587,8 +3587,11 @@ llvm::PointerIntPair VarAndKind; SourceLocation Loc; +Capture() = default; + public: friend class ASTStmtReader; +friend class CapturedStmt; /// Create a new capture. /// ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D150504: [AST] Construct Capture objects before use
vitalybuka added a comment. ping, any concerns regarding this patch? i want to make MSAN stricter on our bot by reducing -O level Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150504/new/ https://reviews.llvm.org/D150504 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D150504: [AST] Construct Capture objects before use
vitalybuka created this revision. Herald added a project: All. vitalybuka requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Msan reports https://reviews.llvm.org/P8308 So the reason is if PointerIntPair is not properly constructed, setPointer uses Info::updatePointer on uninitialized value. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D150504 Files: clang/include/clang/AST/Stmt.h clang/lib/AST/Stmt.cpp Index: clang/lib/AST/Stmt.cpp === --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -1345,6 +1345,11 @@ : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), CapDeclAndKind(nullptr, CR_Default) { getStoredStmts()[NumCaptures] = nullptr; + + // Construct default capture objects. + Capture *Buffer = getStoredCaptures(); + for (unsigned I = 0, N = NumCaptures; I != N; ++I) +new (Buffer++) Capture(); } CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S, Index: clang/include/clang/AST/Stmt.h === --- clang/include/clang/AST/Stmt.h +++ clang/include/clang/AST/Stmt.h @@ -3587,8 +3587,11 @@ llvm::PointerIntPair VarAndKind; SourceLocation Loc; +Capture() = default; + public: friend class ASTStmtReader; +friend class CapturedStmt; /// Create a new capture. /// Index: clang/lib/AST/Stmt.cpp === --- clang/lib/AST/Stmt.cpp +++ clang/lib/AST/Stmt.cpp @@ -1345,6 +1345,11 @@ : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures), CapDeclAndKind(nullptr, CR_Default) { getStoredStmts()[NumCaptures] = nullptr; + + // Construct default capture objects. + Capture *Buffer = getStoredCaptures(); + for (unsigned I = 0, N = NumCaptures; I != N; ++I) +new (Buffer++) Capture(); } CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S, Index: clang/include/clang/AST/Stmt.h === --- clang/include/clang/AST/Stmt.h +++ clang/include/clang/AST/Stmt.h @@ -3587,8 +3587,11 @@ llvm::PointerIntPair VarAndKind; SourceLocation Loc; +Capture() = default; + public: friend class ASTStmtReader; +friend class CapturedStmt; /// Create a new capture. /// ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits