alvinhochun created this revision. alvinhochun added reviewers: rnk, ajpaverd, mstorsjo, aaron.ballman. Herald added a project: All. alvinhochun requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Control Flow Guard is only supported on Windows target, therefore there is no point to make it an accepted attribute for other targets. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D132661 Files: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Attr.td Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ 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<TargetHasCFGuard> { // 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">]; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ 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 ---------------
Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ 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<TargetHasCFGuard> { // 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">]; Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ 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 ---------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits