diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -132,7 +132,8 @@ ``[[clang::guard(nocf)]]``, which is equivalent to ``__declspec(guard(nocf))`` when using the MSVC environment. This is to support enabling Windows Control Flow Guard checks with the ability to disable them for specific functions when - using the MinGW environment. + using the MinGW environment. This attribute is only available for Windows + targets. Windows Support --------------- diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -399,6 +399,9 @@ def TargetX86 : TargetArch<["x86"]>; def TargetAnyX86 : TargetArch<["x86", "x86_64"]>; def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>; +def TargetHasCFGuard : TargetSpec { + let CustomCode = [{ Target.getTriple().isOSWindows() }]; +} def TargetHasDLLImportExport : TargetSpec { let CustomCode = [{ Target.getTriple().hasDLLImportExport() }]; } @@ -3494,7 +3497,7 @@ let Documentation = [MSAllocatorDocs]; } -def CFGuard : InheritableAttr { +def CFGuard : InheritableAttr, TargetSpecificAttr { // Currently only the __declspec(guard(nocf)) modifier is supported. In future // we might also want to support __declspec(guard(suppress)). let Spellings = [Declspec<"guard">, Clang<"guard">];