[PATCH] D71397: [clang] Improve LLVM-style RTTI support in ExternalASTSource/ExternalSemaSource

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 12 16:03:16 PST 2019


rjmccall added inline comments.


================
Comment at: clang/include/clang/AST/ExternalASTSource.h:69
 
-  /// Whether this AST source also provides information for
-  /// semantic analysis.
-  bool SemaSource = false;
+  // LLVM-style RTTI.
+  static char ID;
----------------
aprantl wrote:
> /// LLVM-style RTTI.
It would be better if this had a dedicated type instead of using `char` and then `void*` as the parameter, just to prevent simple bugs where somebody passes in the wrong pointer.  Maybe you could have a non-copyable `ClassID` type and a `ClassRef` type with the sole constructor `ClassRef(const ClassID &)`?

The virtual method name is trying too hard to be succinct, and it doesn't matter because it's rarely used; I would recommend borrowing the name `isKindOf` from Objective-C.


Repository:
  rC Clang

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

https://reviews.llvm.org/D71397





More information about the cfe-commits mailing list