[PATCH] D19871: Add an AST matcher for CastExpr kind

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue May 3 11:18:14 PDT 2016


aaron.ballman added inline comments.

================
Comment at: lib/ASTMatchers/Dynamic/Marshallers.h:102
@@ +101,3 @@
+  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
+    return llvm::StringSwitch<clang::CastKind>(AttrKind)
+      .Case("CK_Dependent", CK_Dependent)
----------------
This might be an awful idea, but let's explore it.

What if we moved the CastKind enumerator names into a .def (or .inc) file and use macros to generate the enumeration as well as this monster switch statement? We do this in other places where it makes sense to do so, such as in Expr.h:
```
  enum AtomicOp {
#define BUILTIN(ID, TYPE, ATTRS)
#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
#include "clang/Basic/Builtins.def"
    // Avoid trailing comma
    BI_First = 0
  };
```


http://reviews.llvm.org/D19871





More information about the cfe-commits mailing list