[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 13 11:46:52 PDT 2023


rjmccall added inline comments.


================
Comment at: clang/include/clang/Basic/Builtins.h:65
 enum ID {
+#define INTERESTING_IDENTIER(ID, TYPE, ATTRS) ID,
   NotBuiltin  = 0,      // This is not a builtin function.
----------------
You shouldn't muddle this into `Builtin::ID`.


================
Comment at: clang/include/clang/Basic/IdentifierTable.h:79
+static constexpr int FirstInterestingIdentifierID = 1;
+static constexpr int FirstBuiltinID = 3;
 
----------------
```
// The "layout" of ObjCOrBuiltinID is:
//   - The first value (0) represents "not a special identifier".
//   - The next (NUM_OBJC_KEYWORDS - 1) values represent ObjCKeywordKinds (not
//      including objc_not_keyword).
//   - The next (NUM_INTERESTING_IDENTIFIERS - 1) values represent InterestingIdentifierKinds
//      (not including not_interesting).
//   - The rest of the values represent builtin IDs (not including not_builtin).
static constexpr int FirstObjCKeywordID = 1;
static constexpr int LastObjCKeywordID = FirstObjCKeywordID + tok::NUM_OBJC_KEYWORDS - 2;
static constexpr int FirstInterestingIdentifierID = LastObjCKeywordID + 1;
static constexpr int LastInterestingIdentifierID = LastObjCKeywordID + tok::NUM_INTERESTING_IDENTIFIERS - 2;
static constexpr int FirstBuiltinID = LastInterestingIdentifierID + 1;
```


================
Comment at: clang/include/clang/Basic/IdentifierTable.h:295
   tok::ObjCKeywordKind getObjCKeywordID() const {
     if (ObjCOrBuiltinID < tok::NUM_OBJC_KEYWORDS)
       return tok::ObjCKeywordKind(ObjCOrBuiltinID);
----------------
```
  static_assert(FirstObjCKeywordID == 1, "hard-coding this assumption to simplify code");
  if (ObjCOrBuiltinID <= LastObjCKeywordID)
    return tok::ObjCKeywordKind(ObjCOrBuiltinID);
  else
    return tok::objc_not_keyword;
```


================
Comment at: clang/include/clang/Basic/IdentifierTable.h:306
   unsigned getBuiltinID() const {
-    if (ObjCOrBuiltinID >= tok::NUM_OBJC_KEYWORDS)
-      return ObjCOrBuiltinID - tok::NUM_OBJC_KEYWORDS;
+    if (ObjCOrBuiltinID >=
+        (tok::NUM_OBJC_KEYWORDS + tok::NUM_INTERESTING_IDENTIFIERS))
----------------
```
if (ObjCOrBuiltinID >= FirstBuiltinID)
  return 1 + (ObjCOrBuiltinID - FirstBuiltinID);
else
  return 0;
```


================
Comment at: clang/include/clang/Basic/IdentifierTable.h:314
   void setBuiltinID(unsigned ID) {
-    ObjCOrBuiltinID = ID + tok::NUM_OBJC_KEYWORDS;
-    assert(ObjCOrBuiltinID - unsigned(tok::NUM_OBJC_KEYWORDS) == ID
-           && "ID too large for field!");
+    ObjCOrBuiltinID =
+        ID + tok::NUM_OBJC_KEYWORDS + tok::NUM_INTERESTING_IDENTIFIERS;
----------------
```
  assert(ID != NotBuiltin);
  ObjCOrBuiltinID = FirstBuiltinID + (ID - 1);
  assert(getBuiltinID() == ID && "ID too large for field!");
```


================
Comment at: clang/include/clang/Basic/IdentifierTable.h:323
+  unsigned getInterestingIdentifierID() {
+    unsigned LowerID = tok::NUM_INTERESTING_IDENTIFIERS + tok::NUM_OBJC_KEYWORDS;
+    unsigned UpperID = tok::NUM_INTERESTING_IDENTIFIERS + tok::NUM_OBJC_KEYWORDS +
----------------
```
tok::InterestingIdentifierKind getInterestingIdentifierID() const {
  if (ObjCOrBuiltinID >= FirstInterestingIdentifierID && ObjCOrBuiltinID <= LastInterestingIdentifierID)
    return tok::InterestingIdentifierKind(1 + (ObjCOrBuiltinID - FirstInterestingIdentifierID));
  else
    return tok::not_interesting;
}
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146148/new/

https://reviews.llvm.org/D146148



More information about the cfe-commits mailing list