[clang] [clang][Interp] Add inline descriptor to global variables (PR #72892)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 10:31:36 PST 2024


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/72892 at github.com>


================
@@ -332,6 +332,22 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
   return false;
 }
 
+bool CheckGlobalInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
+  if (Ptr.isInitialized())
+    return true;
+
+  const VarDecl *VD = cast<VarDecl>(Ptr.getDeclDesc()->asValueDecl());
+  if ((S.getLangOpts().CPlusPlus && !VD->hasConstantInitialization() &&
----------------
tbaederr wrote:

Yes, but in C we don't create global variables for `x`, so we don't try to load one either and don't reach this code.

https://github.com/llvm/llvm-project/pull/72892


More information about the cfe-commits mailing list