================
@@ -15460,6 +15461,108 @@ 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 processForLoadTimeCommentVar(Sema &S, VarDecl *VD) {
+ // Declarations that cannot be name-matched are silently skipped: an
+ // automatic variable has no symbol of its own, and neither does a template
+ // pattern (only its specializations do, and those are processed
+ // separately). Only definitions are considered.
+ if (VD->hasLocalStorage())
+ return;
+ if (VD->isTemplated())
+ return;
+ if (VD->isThisDeclarationADefinition(S.Context) != VarDecl::Definition)
+ return;
+
+ // Only plain `char` pointers/arrays with an initializer are supported; a
+ // matched variable of any other form (int, struct, wide or explicitly
+ // signed/unsigned character types, no initializer, ...) is silently
+ // ignored.
----------------
tonykuttai wrote:
Right. A name match on a variable of an unsupported type (an int, a struct, a
wchar_t or unsigned char string, ...) is now diagnosed. But for the second
case (a listed name that matches nothing in the TU) I've kept it silent. The
option is meant to be set once in the build system and applied to every
translation unit of a build, and most TUs define only a subset of the listed
names, or define them conditionally as you note. A per-TU "no variable named X"
warning would fire on nearly every compilation, so it would be noisy.
https://github.com/llvm/llvm-project/pull/187986
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits