================
@@ -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 was looking to check for `-fstack-protector-all` in `CGDecl.cpp` where i've 
made the changes in this PR.  Then at that point emit a warning too if the new 
ignore attribute is present.

Unfortunately running in to an ordering issue. The stack protector flags are 
checked in `CodeGenModule::SetLLVMFunctionAttributesForDefinition()` but that 
is after i'm emitting the attribute in `CodeGenFunction::EmitAutoVarAlloca()`.

I could potentially factor out the stack protector logic in to a helper, eg:

    clang::LangOptions::StackProtectorMode 
CodeGenModule::StackProtectorMode(const Decl *D) const;

then call that helper from `SetLLVMFunctionAttributesForDefinition()` to handle 
the current logic of attaching attributes, but also call it from 
`EmitAutoVarAlloca()` to see if we should emit this new suggested warning.

Alternatively, if this is totally the wrong direction just let me know 
@AaronBallman. I don't know if this is the kind of thing that something like 
Sema should handle instead as i'm more familiar with codegen and IR than the 
rest of clang.

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

Reply via email to