================
@@ -15338,6 +15339,73 @@ void Sema::CheckThreadLocalForLargeAlignment(VarDecl 
*VD) {
   }
 }
 
+/// Process a variable definition whose mangled name may be listed in
+/// '-mloadtime-comment-vars=': attach an implicit attribute to supported
+/// string variables so CodeGen preserves them as loadtime identifying
+/// strings, and warn when a named variable cannot be preserved.
+static void checkLoadTimeCommentVar(Sema &S, VarDecl *VD) {
+  // Only variables defined at file, namespace, or class scope participate;
+  // anything else (e.g. a function-local static) is silently ignored. A
+  // template has no object-file symbol of its own, only its instantiations
+  // do, so template patterns are ignored as well.
+  if (!VD->isFileVarDecl() && !VD->isStaticDataMember())
+    return;
+  if (VD->isTemplated())
+    return;
+  if (VD->isThisDeclarationADefinition(S.Context) != VarDecl::Definition)
+    return;
+
+  // Only character pointers/arrays with an initializer are supported; a
+  // matched variable of any other form (int, struct, no initializer, ...) is
+  // silently ignored.
+  QualType Ty = VD->getType();
+  const PointerType *PT = Ty->getAs<PointerType>();
----------------
tonykuttai wrote:

Done. Now uses `Ty->getAsCanonical<PointerType>()`, and the element-type check 
is `hasSameUnqualifiedType(Pointee, Context.CharTy)` and only plain char 
matches. Tests added

https://github.com/llvm/llvm-project/pull/187986
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to