[clang] Allow the no_stack_protector attribute on local variables (PR #173311)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 18 20:43:00 PST 2026


================
@@ -5736,6 +5736,17 @@ option.
     }];
 }
 
+def StackProtectorIgnoreDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``stack_protector_ignore`` attribute skips analysis of the given local
+variable when determining if a function should use a stack protector.
+
+If ``-fstack-protector-all`` is specified then the given function will still
+use a stack protector, even if some/all variables have this attribute.
----------------
cooperp wrote:

I've added `CodeGenModule::StackProtectorAttribute(const Decl *D)` so that i could get the attribute kind (if any) for a given decl.  That is then used from `SetLLVMFunctionAttributesForDefinition()` as it is today.

I also use it from `EmitAutoVarAlloca()` such that when the `stack_protector_ignore` attribute is on a variable, you can get a warning such as:

    'stack_protector_ignore' attribute ignored due to '-fstack-protector-all' option

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


More information about the cfe-commits mailing list