[PATCH] Qualify all types used in AST matcher macros.

Alexander Kornienko alexfh at google.com
Wed Jun 17 05:34:48 PDT 2015


================
Comment at: include/clang/ASTMatchers/ASTMatchersMacros.h:23-26
@@ -22,4 +22,6 @@
 //
-//  To define a matcher in user code, always put it into the clang::ast_matchers
-//  namespace and refer to the internal types via the 'internal::':
+//  To define a matcher in user code, always put it into an unnamed namespace
+//  inside the clang::ast_matchers namespace and refer to the internal types via
+//  the 'internal::'. This would help to prevent ODR violations in case a
+//  matcher with the same name is defined in multiple translation units:
 //
----------------
djasper wrote:
> I don't know whether we need to recommend using an unnamed namespace. I would think that certain projects also have a repository of their own reusable matchers.
> 
> Do the custom matchers even have to be inside ::clang::ast_matchers?
No, they can be in any namespace now. I just wanted to emphasize that putting all user-defined matchers to clang::ast_matchers is not a good idea. I'll suggest to use user's own namespace for the matchers.

http://reviews.llvm.org/D10501

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list