[PATCH] D135750: [clang][Interp] Track initialization state of local variables

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 17 09:31:42 PST 2022


shafik added inline comments.


================
Comment at: clang/lib/AST/Interp/Context.cpp:128
   InterpState State(Parent, *P, Stk, *this);
-  State.Current = new InterpFrame(State, Func, nullptr, {}, {});
+  State.Current = new InterpFrame(State, Func, nullptr, {});
   if (Interpret(State, Result))
----------------



================
Comment at: clang/lib/AST/Interp/Descriptor.h:74
+  };
+  static constexpr MetadataSize NoMetadata = MetadataSize{0};
+
----------------
erichkeane wrote:
> add a line: 
> `static constexpr MetadataSize InlineDescriptor = MetadataSize{sizeof(InlineDescriptor)};` 
> and you can use this instead of depending on 'sizeof' all over the place.
It feels weird to call this `NoMetadata` but we will pass this as an argument to a function with a parameter of `MetaDataSize`. So I am expecting a size but I am getting no meta data instead and it looks like a mistake. 

Maybe a better name would be `ZeroMetaDataSize`?


================
Comment at: clang/lib/AST/Interp/EvalEmitter.cpp:26
   // Create a dummy frame for the interpreter which does not have locals.
-  S.Current = new InterpFrame(S, nullptr, nullptr, CodePtr(), Pointer());
+  S.Current = new InterpFrame(S, nullptr, nullptr, CodePtr());
 }
----------------



================
Comment at: clang/lib/AST/Interp/Pointer.h:50
+///
+/// Pointee                      Offset
+/// │                              │
----------------
I feel like the comment block in `InterpBlock.h` is more informative.


================
Comment at: clang/lib/AST/Interp/Pointer.h:347
     assert(Offset != 0 && "Not a nested pointer");
-    return reinterpret_cast<InlineDescriptor *>(Pointee->data() + Offset) - 1;
+    return reinterpret_cast<InlineDescriptor *>(Pointee->rawData() + Offset) -
+           1;
----------------
Why the `-1` 


================
Comment at: clang/lib/AST/Interp/Program.h:116
+      const DeclTy &D, PrimType Type,
+      Descriptor::MetadataSize MDSize = Descriptor::MetadataSize{0},
+      bool IsConst = false, bool IsTemporary = false, bool IsMutable = false) {
----------------



================
Comment at: clang/lib/AST/Interp/Program.h:124
+      const DeclTy &D, const Type *Ty,
+      Descriptor::MetadataSize MDSize = Descriptor::MetadataSize{0},
+      // size_t MetadataSize = 0,
----------------



================
Comment at: clang/lib/AST/Interp/Program.h:125
+      Descriptor::MetadataSize MDSize = Descriptor::MetadataSize{0},
+      // size_t MetadataSize = 0,
+      bool IsConst = false, bool IsTemporary = false, bool IsMutable = false,
----------------
Delete commented out code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135750/new/

https://reviews.llvm.org/D135750



More information about the cfe-commits mailing list