Author: Fangrui Song
Date: 2022-09-08T13:39:30-07:00
New Revision: 49c289879c7aa9737429f7342c7149a8ba958667

URL: 
https://github.com/llvm/llvm-project/commit/49c289879c7aa9737429f7342c7149a8ba958667
DIFF: 
https://github.com/llvm/llvm-project/commit/49c289879c7aa9737429f7342c7149a8ba958667.diff

LOG: [AST/Interp] Fix latent unitialized use of memory bug in D64146

Exposed by D132727: clang/test/AST/Interp/arrays.cpp fails with --config=msan

Added: 
    

Modified: 
    clang/lib/AST/Interp/Descriptor.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index 5c1a8a9cf3066..2098ae778a87a 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -259,9 +259,7 @@ SourceLocation Descriptor::getLocation() const {
 }
 
 InitMap::InitMap(unsigned N) : UninitFields(N) {
-  for (unsigned I = 0; I < N / PER_FIELD; ++I) {
-    data()[I] = 0;
-  }
+  std::fill_n(data(), (N + PER_FIELD - 1) / PER_FIELD, 0);
 }
 
 InitMap::T *InitMap::data() {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to