[clang] eda58ac - Improve the attribute language option interface somewhat; NFCi.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 14 12:59:30 PDT 2020
Author: Aaron Ballman
Date: 2020-03-14T15:59:14-04:00
New Revision: eda58ac04cfa95298583223ba6779916e4721550
URL: https://github.com/llvm/llvm-project/commit/eda58ac04cfa95298583223ba6779916e4721550
DIFF: https://github.com/llvm/llvm-project/commit/eda58ac04cfa95298583223ba6779916e4721550.diff
LOG: 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.
Added:
Modified:
clang/include/clang/Basic/Attr.td
clang/utils/TableGen/ClangAttrEmitter.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 484691f419c3..c2504ba620e8 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -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">;
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 20fb9bc14439..529145efa3d0 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -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");
More information about the cfe-commits
mailing list