mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-21 15:02:51 +00:00
Improve the attribute language option interface somewhat; NFCi.
The name field is optional if the custom code is supplied, so this updates the documentation for LangOpt and introduces a tablegen warning if both custom code and a language option name are supplied.
This commit is contained in:
parent
b8b8f04c0d
commit
eda58ac04c
@ -312,6 +312,7 @@ class SubjectList<list<AttrSubject> subjects, SubjectDiag diag = WarnDiag,
|
||||
}
|
||||
|
||||
class LangOpt<string name, code customCode = [{}]> {
|
||||
// The language option to test; ignored when custom code is supplied.
|
||||
string Name = name;
|
||||
|
||||
// A custom predicate, written as an expression evaluated in a context with
|
||||
@ -323,15 +324,15 @@ def Borland : LangOpt<"Borland">;
|
||||
def CUDA : LangOpt<"CUDA">;
|
||||
def HIP : LangOpt<"HIP">;
|
||||
def SYCL : LangOpt<"SYCLIsDevice">;
|
||||
def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
|
||||
def COnly : LangOpt<"", "!LangOpts.CPlusPlus">;
|
||||
def CPlusPlus : LangOpt<"CPlusPlus">;
|
||||
def OpenCL : LangOpt<"OpenCL">;
|
||||
def RenderScript : LangOpt<"RenderScript">;
|
||||
def ObjC : LangOpt<"ObjC">;
|
||||
def BlocksSupported : LangOpt<"Blocks">;
|
||||
def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
|
||||
def ObjCNonFragileRuntime : LangOpt<"ObjCNonFragileRuntime",
|
||||
"LangOpts.ObjCRuntime.allowsClassStubs()">;
|
||||
def ObjCNonFragileRuntime
|
||||
: LangOpt<"", "LangOpts.ObjCRuntime.allowsClassStubs()">;
|
||||
|
||||
// Language option for CMSE extensions
|
||||
def Cmse : LangOpt<"Cmse">;
|
||||
|
@ -1980,6 +1980,11 @@ static std::string GenerateTestExpression(ArrayRef<Record *> LangOpts) {
|
||||
Test += "(";
|
||||
Test += Code;
|
||||
Test += ")";
|
||||
if (!E->getValueAsString("Name").empty()) {
|
||||
PrintWarning(
|
||||
E->getLoc(),
|
||||
"non-empty 'Name' field ignored because 'CustomCode' was supplied");
|
||||
}
|
||||
} else {
|
||||
Test += "LangOpts.";
|
||||
Test += E->getValueAsString("Name");
|
||||
|
Loading…
Reference in New Issue
Block a user