[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-03-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked 6 inline comments as not done.
lebedev.ri added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

gribozavr wrote:
> lebedev.ri wrote:
> > lebedev.ri wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > lebedev.ri wrote:
> > > > > > ABataev wrote:
> > > > > > > Well, I think it would be good to filter out `OMPC_flush` somehow 
> > > > > > > because there is no such clause actually, it is a pseudo clause 
> > > > > > > for better handling of the `flush` directive.
> > > > > > > 
> > > > > > Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
> > > > > > I don't see those clauses in spec.
> > > > > > 
> > > > > > Perhaps `OMPC_flush` should be made more like those other two?
> > > > > > (i.e. handled outside of `OPENMP_CLAUSE` macro)
> > > > > `OMPC_threadprivate` is also a special kind of pseudo-clause.
> > > > > `OMPC_flush` is in the enum, because it has the corresponding class. 
> > > > > You can try to exclude it from the enum, but it may require some 
> > > > > additional work.
> > > > > `OMPC_uniform` is a normal clause, but it has the corresponding 
> > > > > class. This clause can be used on `declare simd` directive, which is 
> > > > > represented as an attribute.
> > > > I mean, `OOMPC_uniform` has no(!) corresponding class. Mistyped
> > > As one would expect, simply adding 
> > > ```
> > >   case OMPC_flush: // Pseudo clause, does not exist (keep before 
> > > including .def)
> > > llvm_unreachable("unexpected OpenMP clause kind");
> > > ```
> > > results in a
> > > ```
> > > [58/1118 5.6/sec] Building CXX object 
> > > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o
> > > FAILED: tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o 
> > > /usr/bin/g++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
> > > -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> > > -Itools/clang/lib/AST -I/build/clang/lib/AST -I/build/clang/include 
> > > -Itools/clang/include -I/usr/include/libxml2 -Iinclude 
> > > -I/build/llvm/include -pipe -O2 -g0 -UNDEBUG -fPIC 
> > > -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra 
> > > -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> > > -Wno-missing-field-initializers -pedantic -Wno-long-long 
> > > -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
> > > -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment 
> > > -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
> > > -Woverloaded-virtual -fno-strict-aliasing -pipe -O2 -g0 -UNDEBUG -fPIC   
> > > -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT 
> > > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -MF 
> > > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o.d -o 
> > > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -c 
> > > /build/clang/lib/AST/ASTTypeTraits.cpp
> > > /build/clang/include/clang/Basic/OpenMPKinds.def: In static member 
> > > function ‘static clang::ast_type_traits::ASTNodeKind 
> > > clang::ast_type_traits::ASTNodeKind::getFromNode(const 
> > > clang::OMPClause&)’:
> > > /build/clang/lib/AST/ASTTypeTraits.cpp:116:5: error: duplicate case value
> > >  case OMPC_##Name: return ASTNodeKind(NKI_##Class);
> > >  ^~~~
> > > /build/clang/include/clang/Basic/OpenMPKinds.def:261:1: note: in 
> > > expansion of macro ‘OPENMP_CLAUSE’
> > >  OPENMP_CLAUSE(flush, OMPFlushClause)
> > >  ^
> > > /build/clang/lib/AST/ASTTypeTraits.cpp:113:3: note: previously used here
> > >case OMPC_flush: // Pseudo clause, does not exist (keep before 
> > > including .def)
> > >^~~~
> > > ```
> > > So one will need to pull `OMPC_flush` out of 
> > > `clang/Basic/OpenMPKinds.def`.
> > D57280, will rebase this.
> > Well, I think it would be good to filter out `OMPC_flush` somehow because 
> > there is no such clause actually, it is a pseudo clause for better handling 
> > of the `flush` directive.
> 
> Sorry to be late for this discussion, but I don't think this conclusion 
> follows.  ASTMatchers are supposed to match the AST as it is.  Even if 
> `OMPC_flush` is synthetic, it exists in the AST, and users might want to 
> match it.  I think users would find anything else (trying to filter out AST 
> nodes that are not in the source code) to be surprising. For example, there's 
> a matcher `materializeTemporaryExpr` even though this AST node is a Clang 
> invention and is not a part of the C++ spec.
> 
> Matching only constructs that appear in the source code is not feasible with 
> ASTMatchers, because they are based on Clang's AST that exposes tons of 
> semantic information, and its design is dictated by the structure of the 
> semantic information.  See "RFC: Tree-based refactorings with 

[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-03-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

> The test coverage i have will be in the clang-tidy check.

Please add unit tests to `clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp`. 
 You can pull matchers from D57113  into the 
shared matchers library (instead of keeping them private to the check), and add 
unit tests.




Comment at: include/clang/AST/ASTTypeTraits.h:83
+  /// Return the AST node kind of this ASTNodeKind.
+  OpenMPClauseKind getOMPClauseKind() const;
+  /// \}

"asOMPClauseKind()"?



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

lebedev.ri wrote:
> lebedev.ri wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > lebedev.ri wrote:
> > > > > ABataev wrote:
> > > > > > Well, I think it would be good to filter out `OMPC_flush` somehow 
> > > > > > because there is no such clause actually, it is a pseudo clause for 
> > > > > > better handling of the `flush` directive.
> > > > > > 
> > > > > Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
> > > > > I don't see those clauses in spec.
> > > > > 
> > > > > Perhaps `OMPC_flush` should be made more like those other two?
> > > > > (i.e. handled outside of `OPENMP_CLAUSE` macro)
> > > > `OMPC_threadprivate` is also a special kind of pseudo-clause.
> > > > `OMPC_flush` is in the enum, because it has the corresponding class. 
> > > > You can try to exclude it from the enum, but it may require some 
> > > > additional work.
> > > > `OMPC_uniform` is a normal clause, but it has the corresponding class. 
> > > > This clause can be used on `declare simd` directive, which is 
> > > > represented as an attribute.
> > > I mean, `OOMPC_uniform` has no(!) corresponding class. Mistyped
> > As one would expect, simply adding 
> > ```
> >   case OMPC_flush: // Pseudo clause, does not exist (keep before including 
> > .def)
> > llvm_unreachable("unexpected OpenMP clause kind");
> > ```
> > results in a
> > ```
> > [58/1118 5.6/sec] Building CXX object 
> > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o
> > FAILED: tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o 
> > /usr/bin/g++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
> > -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> > -Itools/clang/lib/AST -I/build/clang/lib/AST -I/build/clang/include 
> > -Itools/clang/include -I/usr/include/libxml2 -Iinclude 
> > -I/build/llvm/include -pipe -O2 -g0 -UNDEBUG -fPIC 
> > -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra 
> > -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> > -Wno-missing-field-initializers -pedantic -Wno-long-long 
> > -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
> > -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment 
> > -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
> > -Woverloaded-virtual -fno-strict-aliasing -pipe -O2 -g0 -UNDEBUG -fPIC   
> > -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT 
> > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -MF 
> > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o.d -o 
> > tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -c 
> > /build/clang/lib/AST/ASTTypeTraits.cpp
> > /build/clang/include/clang/Basic/OpenMPKinds.def: In static member function 
> > ‘static clang::ast_type_traits::ASTNodeKind 
> > clang::ast_type_traits::ASTNodeKind::getFromNode(const clang::OMPClause&)’:
> > /build/clang/lib/AST/ASTTypeTraits.cpp:116:5: error: duplicate case value
> >  case OMPC_##Name: return ASTNodeKind(NKI_##Class);
> >  ^~~~
> > /build/clang/include/clang/Basic/OpenMPKinds.def:261:1: note: in expansion 
> > of macro ‘OPENMP_CLAUSE’
> >  OPENMP_CLAUSE(flush, OMPFlushClause)
> >  ^
> > /build/clang/lib/AST/ASTTypeTraits.cpp:113:3: note: previously used here
> >case OMPC_flush: // Pseudo clause, does not exist (keep before including 
> > .def)
> >^~~~
> > ```
> > So one will need to pull `OMPC_flush` out of `clang/Basic/OpenMPKinds.def`.
> D57280, will rebase this.
> Well, I think it would be good to filter out `OMPC_flush` somehow because 
> there is no such clause actually, it is a pseudo clause for better handling 
> of the `flush` directive.

Sorry to be late for this discussion, but I don't think this conclusion 
follows.  ASTMatchers are supposed to match the AST as it is.  Even if 
`OMPC_flush` is synthetic, it exists in the AST, and users might want to match 
it.  I think users would find anything else (trying to filter out AST nodes 
that are not in the source code) to be surprising. For example, there's a 
matcher `materializeTemporaryExpr` even though this AST node is a Clang 
invention and is not a part of the C++ spec.

Matching only 

[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

ping @klimek @hokein thanks.
The fun of of the code that is so well separated that no one
touches it for years and thus can't review patches for it :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Maybe ping @klimek then? :)

In D57112#1400046 , @alexfh wrote:

> In D57112#1399516 , @lebedev.ri 
> wrote:
>
> > Ping @hokein / @alexfh (as per git blame).
> >  Not sure who is best suited to review this.
>
>
> I only made a couple of random fixes to these files, so I don't feel 
> particularly competent to review them. Though overall the changes in this 
> patch seem reasonable to me. No concerns from me ;)


Makes sense, thanks for looking!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D57112#1399516 , @lebedev.ri wrote:

> Ping @hokein / @alexfh (as per git blame).
>  Not sure who is best suited to review this.


I only made a couple of random fixes to these files, so I don't feel 
particularly competent to review them. Though overall the changes in this patch 
seem reasonable to me. No concerns from me ;)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: alexfh.
lebedev.ri added a comment.
Herald added a subscriber: jdoerfert.

Ping @hokein / @alexfh (as per git blame).
Not sure who is best suited to review this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-04 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.
Herald added a project: clang.

Ping. I'm not quite sure who is the best suited to review this..


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 183902.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

- Rebased
- Go back to storing the actual AST class type as string in 
`ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[]`.
- Add `OpenMPClauseKind ASTNodeKind::getOMPClauseKind()` to address the 
regression of D57113  due to the previous ^ 
change. This is better anyway, since it avoids string comparisons, and is a 
simple switch over an enum.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112

Files:
  include/clang/AST/ASTTypeTraits.h
  lib/AST/ASTTypeTraits.cpp

Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -37,6 +37,9 @@
   { NKI_None, "Type" },
 #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
 #include "clang/AST/TypeNodes.def"
+  { NKI_None, "OMPClause" },
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) { NKI_OMPClause, #DERIVED },
+#include "clang/Basic/OpenMPKinds.def"
 };
 
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
@@ -58,6 +61,19 @@
 
 StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; }
 
+OpenMPClauseKind ASTNodeKind::getOMPClauseKind() const {
+  assert(isBaseOf(NKI_OMPClause, KindId, nullptr) && KindId != NKI_OMPClause &&
+ "Should be an OpenMP clause node");
+  switch (KindId) {
+  default:
+llvm_unreachable("Unknown clause kind!");
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED)\
+  case NKI_##DERIVED:  \
+return OMPC_##TextualSpelling;
+#include "clang/Basic/OpenMPKinds.def"
+  }
+}
+
 ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1,
 ASTNodeKind Kind2) {
   if (Kind1.isBaseOf(Kind2)) return Kind2;
@@ -103,6 +119,20 @@
 #include "clang/AST/TypeNodes.def"
   }
   llvm_unreachable("invalid type kind");
+ }
+
+ASTNodeKind ASTNodeKind::getFromNode(const OMPClause ) {
+  switch (C.getClauseKind()) {
+#define OPENMP_CLAUSE(Name, Class) \
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"
+case OMPC_flush:
+case OMPC_threadprivate:
+case OMPC_uniform:
+case OMPC_unknown:
+  llvm_unreachable("unexpected OpenMP clause kind");
+  }
+  llvm_unreachable("invalid stmt kind");
 }
 
 void DynTypedNode::print(llvm::raw_ostream ,
@@ -151,6 +181,8 @@
 return D->getSourceRange();
   if (const Stmt *S = get())
 return S->getSourceRange();
+  if (const auto *C = get())
+return SourceRange(C->getBeginLoc(), C->getEndLoc());
   return SourceRange();
 }
 
Index: include/clang/AST/ASTTypeTraits.h
===
--- include/clang/AST/ASTTypeTraits.h
+++ include/clang/AST/ASTTypeTraits.h
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
@@ -58,6 +59,7 @@
   static ASTNodeKind getFromNode(const Decl );
   static ASTNodeKind getFromNode(const Stmt );
   static ASTNodeKind getFromNode(const Type );
+  static ASTNodeKind getFromNode(const OMPClause );
   /// \}
 
   /// Returns \c true if \c this and \c Other represent the same kind.
@@ -76,6 +78,11 @@
   /// String representation of the kind.
   StringRef asStringRef() const;
 
+  /// \{
+  /// Return the AST node kind of this ASTNodeKind.
+  OpenMPClauseKind getOMPClauseKind() const;
+  /// \}
+
   /// Strict weak ordering for ASTNodeKind.
   bool operator<(const ASTNodeKind ) const {
 return KindId < Other.KindId;
@@ -136,6 +143,9 @@
 NKI_Type,
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.def"
+NKI_OMPClause,
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) NKI_##DERIVED,
+#include "clang/Basic/OpenMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -183,12 +193,15 @@
 KIND_TO_KIND_ID(Decl)
 KIND_TO_KIND_ID(Stmt)
 KIND_TO_KIND_ID(Type)
+KIND_TO_KIND_ID(OMPClause)
 #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl)
 #include "clang/AST/DeclNodes.inc"
 #define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.def"
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) KIND_TO_KIND_ID(DERIVED)
+#include "clang/Basic/OpenMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {
@@ -459,6 +472,11 @@
 T, typename std::enable_if::value>::type>
 : public DynCastPtrConverter {};
 
+template 
+struct 

[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:40-43
+  { NKI_None, "OMPClause" },
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED)
\
+  {NKI_OMPClause, #TextualSpelling},
+#include "clang/Basic/OpenMPKinds.def"

Humm, though i guess this will need to be changed back for when the matchers 
evolve
from the check into the ASTMatchers, for better clang-query expirience.

Would it be ok to add the opposite direction functionality
as compared to `static ASTNodeKind getFromNode(const OMPClause );`?
I.e. roughly `OMPClauseKind getOMPClauseKindFromASTNodeKind() const;`  ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 183692.
lebedev.ri added a comment.

Store OpenMP clause spelling in the `ASTNodeKind::KindInfo 
ASTNodeKind::AllKindInfo[]`, not the stringified clang AST class name.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112

Files:
  include/clang/AST/ASTTypeTraits.h
  lib/AST/ASTTypeTraits.cpp

Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -37,6 +37,10 @@
   { NKI_None, "Type" },
 #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
 #include "clang/AST/TypeNodes.def"
+  { NKI_None, "OMPClause" },
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED)\
+  {NKI_OMPClause, #TextualSpelling},
+#include "clang/Basic/OpenMPKinds.def"
 };
 
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
@@ -103,6 +107,20 @@
 #include "clang/AST/TypeNodes.def"
   }
   llvm_unreachable("invalid type kind");
+ }
+
+ASTNodeKind ASTNodeKind::getFromNode(const OMPClause ) {
+  switch (C.getClauseKind()) {
+#define OPENMP_CLAUSE(Name, Class) \
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"
+case OMPC_flush:
+case OMPC_threadprivate:
+case OMPC_uniform:
+case OMPC_unknown:
+  llvm_unreachable("unexpected OpenMP clause kind");
+  }
+  llvm_unreachable("invalid stmt kind");
 }
 
 void DynTypedNode::print(llvm::raw_ostream ,
@@ -151,6 +169,8 @@
 return D->getSourceRange();
   if (const Stmt *S = get())
 return S->getSourceRange();
+  if (const auto *C = get())
+return SourceRange(C->getBeginLoc(), C->getEndLoc());
   return SourceRange();
 }
 
Index: include/clang/AST/ASTTypeTraits.h
===
--- include/clang/AST/ASTTypeTraits.h
+++ include/clang/AST/ASTTypeTraits.h
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
@@ -58,6 +59,7 @@
   static ASTNodeKind getFromNode(const Decl );
   static ASTNodeKind getFromNode(const Stmt );
   static ASTNodeKind getFromNode(const Type );
+  static ASTNodeKind getFromNode(const OMPClause );
   /// \}
 
   /// Returns \c true if \c this and \c Other represent the same kind.
@@ -136,6 +138,9 @@
 NKI_Type,
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.def"
+NKI_OMPClause,
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) NKI_##DERIVED,
+#include "clang/Basic/OpenMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -183,12 +188,15 @@
 KIND_TO_KIND_ID(Decl)
 KIND_TO_KIND_ID(Stmt)
 KIND_TO_KIND_ID(Type)
+KIND_TO_KIND_ID(OMPClause)
 #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl)
 #include "clang/AST/DeclNodes.inc"
 #define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.def"
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) KIND_TO_KIND_ID(DERIVED)
+#include "clang/Basic/OpenMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {
@@ -459,6 +467,11 @@
 T, typename std::enable_if::value>::type>
 : public DynCastPtrConverter {};
 
+template 
+struct DynTypedNode::BaseConverter<
+T, typename std::enable_if::value>::type>
+: public DynCastPtrConverter {};
+
 template <>
 struct DynTypedNode::BaseConverter<
 NestedNameSpecifier, void> : public PtrConverter {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 183690.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

Rebased ontop of D57280 , use `const auto*`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112

Files:
  include/clang/AST/ASTTypeTraits.h
  lib/AST/ASTTypeTraits.cpp

Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -37,6 +37,9 @@
   { NKI_None, "Type" },
 #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
 #include "clang/AST/TypeNodes.def"
+  { NKI_None, "OMPClause" },
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) { NKI_OMPClause, #DERIVED },
+#include "clang/Basic/OpenMPKinds.def"
 };
 
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
@@ -103,6 +106,20 @@
 #include "clang/AST/TypeNodes.def"
   }
   llvm_unreachable("invalid type kind");
+ }
+
+ASTNodeKind ASTNodeKind::getFromNode(const OMPClause ) {
+  switch (C.getClauseKind()) {
+#define OPENMP_CLAUSE(Name, Class) \
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"
+case OMPC_flush:
+case OMPC_threadprivate:
+case OMPC_uniform:
+case OMPC_unknown:
+  llvm_unreachable("unexpected OpenMP clause kind");
+  }
+  llvm_unreachable("invalid stmt kind");
 }
 
 void DynTypedNode::print(llvm::raw_ostream ,
@@ -151,6 +168,8 @@
 return D->getSourceRange();
   if (const Stmt *S = get())
 return S->getSourceRange();
+  if (const auto *C = get())
+return SourceRange(C->getBeginLoc(), C->getEndLoc());
   return SourceRange();
 }
 
Index: include/clang/AST/ASTTypeTraits.h
===
--- include/clang/AST/ASTTypeTraits.h
+++ include/clang/AST/ASTTypeTraits.h
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
@@ -58,6 +59,7 @@
   static ASTNodeKind getFromNode(const Decl );
   static ASTNodeKind getFromNode(const Stmt );
   static ASTNodeKind getFromNode(const Type );
+  static ASTNodeKind getFromNode(const OMPClause );
   /// \}
 
   /// Returns \c true if \c this and \c Other represent the same kind.
@@ -136,6 +138,9 @@
 NKI_Type,
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.def"
+NKI_OMPClause,
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) NKI_##DERIVED,
+#include "clang/Basic/OpenMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -183,12 +188,15 @@
 KIND_TO_KIND_ID(Decl)
 KIND_TO_KIND_ID(Stmt)
 KIND_TO_KIND_ID(Type)
+KIND_TO_KIND_ID(OMPClause)
 #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl)
 #include "clang/AST/DeclNodes.inc"
 #define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.def"
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) KIND_TO_KIND_ID(DERIVED)
+#include "clang/Basic/OpenMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {
@@ -459,6 +467,11 @@
 T, typename std::enable_if::value>::type>
 : public DynCastPtrConverter {};
 
+template 
+struct DynTypedNode::BaseConverter<
+T, typename std::enable_if::value>::type>
+: public DynCastPtrConverter {};
+
 template <>
 struct DynTypedNode::BaseConverter<
 NestedNameSpecifier, void> : public PtrConverter {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked 5 inline comments as done.
lebedev.ri added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

lebedev.ri wrote:
> ABataev wrote:
> > ABataev wrote:
> > > lebedev.ri wrote:
> > > > ABataev wrote:
> > > > > Well, I think it would be good to filter out `OMPC_flush` somehow 
> > > > > because there is no such clause actually, it is a pseudo clause for 
> > > > > better handling of the `flush` directive.
> > > > > 
> > > > Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
> > > > I don't see those clauses in spec.
> > > > 
> > > > Perhaps `OMPC_flush` should be made more like those other two?
> > > > (i.e. handled outside of `OPENMP_CLAUSE` macro)
> > > `OMPC_threadprivate` is also a special kind of pseudo-clause.
> > > `OMPC_flush` is in the enum, because it has the corresponding class. You 
> > > can try to exclude it from the enum, but it may require some additional 
> > > work.
> > > `OMPC_uniform` is a normal clause, but it has the corresponding class. 
> > > This clause can be used on `declare simd` directive, which is represented 
> > > as an attribute.
> > I mean, `OOMPC_uniform` has no(!) corresponding class. Mistyped
> As one would expect, simply adding 
> ```
>   case OMPC_flush: // Pseudo clause, does not exist (keep before including 
> .def)
> llvm_unreachable("unexpected OpenMP clause kind");
> ```
> results in a
> ```
> [58/1118 5.6/sec] Building CXX object 
> tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o
> FAILED: tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o 
> /usr/bin/g++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -Itools/clang/lib/AST -I/build/clang/lib/AST -I/build/clang/include 
> -Itools/clang/include -I/usr/include/libxml2 -Iinclude -I/build/llvm/include 
> -pipe -O2 -g0 -UNDEBUG -fPIC -fvisibility-inlines-hidden -Werror=date-time 
> -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess 
> -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color 
> -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
> -fno-strict-aliasing -pipe -O2 -g0 -UNDEBUG -fPIC   -UNDEBUG  -fno-exceptions 
> -fno-rtti -MD -MT 
> tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -MF 
> tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o.d -o 
> tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -c 
> /build/clang/lib/AST/ASTTypeTraits.cpp
> /build/clang/include/clang/Basic/OpenMPKinds.def: In static member function 
> ‘static clang::ast_type_traits::ASTNodeKind 
> clang::ast_type_traits::ASTNodeKind::getFromNode(const clang::OMPClause&)’:
> /build/clang/lib/AST/ASTTypeTraits.cpp:116:5: error: duplicate case value
>  case OMPC_##Name: return ASTNodeKind(NKI_##Class);
>  ^~~~
> /build/clang/include/clang/Basic/OpenMPKinds.def:261:1: note: in expansion of 
> macro ‘OPENMP_CLAUSE’
>  OPENMP_CLAUSE(flush, OMPFlushClause)
>  ^
> /build/clang/lib/AST/ASTTypeTraits.cpp:113:3: note: previously used here
>case OMPC_flush: // Pseudo clause, does not exist (keep before including 
> .def)
>^~~~
> ```
> So one will need to pull `OMPC_flush` out of `clang/Basic/OpenMPKinds.def`.
D57280, will rebase this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked an inline comment as done and an inline comment as not done.
lebedev.ri added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

ABataev wrote:
> ABataev wrote:
> > lebedev.ri wrote:
> > > ABataev wrote:
> > > > Well, I think it would be good to filter out `OMPC_flush` somehow 
> > > > because there is no such clause actually, it is a pseudo clause for 
> > > > better handling of the `flush` directive.
> > > > 
> > > Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
> > > I don't see those clauses in spec.
> > > 
> > > Perhaps `OMPC_flush` should be made more like those other two?
> > > (i.e. handled outside of `OPENMP_CLAUSE` macro)
> > `OMPC_threadprivate` is also a special kind of pseudo-clause.
> > `OMPC_flush` is in the enum, because it has the corresponding class. You 
> > can try to exclude it from the enum, but it may require some additional 
> > work.
> > `OMPC_uniform` is a normal clause, but it has the corresponding class. This 
> > clause can be used on `declare simd` directive, which is represented as an 
> > attribute.
> I mean, `OOMPC_uniform` has no(!) corresponding class. Mistyped
As one would expect, simply adding 
```
  case OMPC_flush: // Pseudo clause, does not exist (keep before including .def)
llvm_unreachable("unexpected OpenMP clause kind");
```
results in a
```
[58/1118 5.6/sec] Building CXX object 
tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o
FAILED: tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o 
/usr/bin/g++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Itools/clang/lib/AST -I/build/clang/lib/AST -I/build/clang/include 
-Itools/clang/include -I/usr/include/libxml2 -Iinclude -I/build/llvm/include 
-pipe -O2 -g0 -UNDEBUG -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections 
-fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -pipe -O2 
-g0 -UNDEBUG -fPIC   -UNDEBUG  -fno-exceptions -fno-rtti -MD -MT 
tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -MF 
tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o.d -o 
tools/clang/lib/AST/CMakeFiles/clangAST.dir/ASTTypeTraits.cpp.o -c 
/build/clang/lib/AST/ASTTypeTraits.cpp
/build/clang/include/clang/Basic/OpenMPKinds.def: In static member function 
‘static clang::ast_type_traits::ASTNodeKind 
clang::ast_type_traits::ASTNodeKind::getFromNode(const clang::OMPClause&)’:
/build/clang/lib/AST/ASTTypeTraits.cpp:116:5: error: duplicate case value
 case OMPC_##Name: return ASTNodeKind(NKI_##Class);
 ^~~~
/build/clang/include/clang/Basic/OpenMPKinds.def:261:1: note: in expansion of 
macro ‘OPENMP_CLAUSE’
 OPENMP_CLAUSE(flush, OMPFlushClause)
 ^
/build/clang/lib/AST/ASTTypeTraits.cpp:113:3: note: previously used here
   case OMPC_flush: // Pseudo clause, does not exist (keep before including 
.def)
   ^~~~
```
So one will need to pull `OMPC_flush` out of `clang/Basic/OpenMPKinds.def`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

ABataev wrote:
> lebedev.ri wrote:
> > ABataev wrote:
> > > Well, I think it would be good to filter out `OMPC_flush` somehow because 
> > > there is no such clause actually, it is a pseudo clause for better 
> > > handling of the `flush` directive.
> > > 
> > Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
> > I don't see those clauses in spec.
> > 
> > Perhaps `OMPC_flush` should be made more like those other two?
> > (i.e. handled outside of `OPENMP_CLAUSE` macro)
> `OMPC_threadprivate` is also a special kind of pseudo-clause.
> `OMPC_flush` is in the enum, because it has the corresponding class. You can 
> try to exclude it from the enum, but it may require some additional work.
> `OMPC_uniform` is a normal clause, but it has the corresponding class. This 
> clause can be used on `declare simd` directive, which is represented as an 
> attribute.
I mean, `OOMPC_uniform` has no(!) corresponding class. Mistyped


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

lebedev.ri wrote:
> ABataev wrote:
> > Well, I think it would be good to filter out `OMPC_flush` somehow because 
> > there is no such clause actually, it is a pseudo clause for better handling 
> > of the `flush` directive.
> > 
> Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
> I don't see those clauses in spec.
> 
> Perhaps `OMPC_flush` should be made more like those other two?
> (i.e. handled outside of `OPENMP_CLAUSE` macro)
`OMPC_threadprivate` is also a special kind of pseudo-clause.
`OMPC_flush` is in the enum, because it has the corresponding class. You can 
try to exclude it from the enum, but it may require some additional work.
`OMPC_uniform` is a normal clause, but it has the corresponding class. This 
clause can be used on `declare simd` directive, which is represented as an 
attribute.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-25 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

@ABataev Thank you for taking a look!




Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

ABataev wrote:
> Well, I think it would be good to filter out `OMPC_flush` somehow because 
> there is no such clause actually, it is a pseudo clause for better handling 
> of the `flush` directive.
> 
Are `OMPC_threadprivate` and `OMPC_uniform` also in the same boat?
I don't see those clauses in spec.

Perhaps `OMPC_flush` should be made more like those other two?
(i.e. handled outside of `OPENMP_CLAUSE` macro)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-25 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/AST/ASTTypeTraits.cpp:114
+#define OPENMP_CLAUSE(Name, Class) 
\
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"

Well, I think it would be good to filter out `OMPC_flush` somehow because there 
is no such clause actually, it is a pseudo clause for better handling of the 
`flush` directive.




Comment at: lib/AST/ASTTypeTraits.cpp:170
 return S->getSourceRange();
+  if (const OMPClause *C = get())
+return SourceRange(C->getBeginLoc(), C->getEndLoc());

`const auto *`


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: sbenza, bkramer, pcc, klimek, hokein.
lebedev.ri added a project: OpenMP.
lebedev.ri added a child revision: D57113: [clang-tidy] openmp-use-default-none 
- a new module and a check.

`OMPClause` is the base class, it is not descendant from **any** other class,
therefore for it to work with e.g. `VariadicDynCastAllOfMatcher<>`, it needs to 
be handled here.

Now, i'm not quite sure what else should be here,
i have simply followed the preexisting, prevalent pattern in these source files.

The test coverage i have will be in the clang-tidy check.


Repository:
  rC Clang

https://reviews.llvm.org/D57112

Files:
  include/clang/AST/ASTTypeTraits.h
  lib/AST/ASTTypeTraits.cpp

Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -37,6 +37,9 @@
   { NKI_None, "Type" },
 #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
 #include "clang/AST/TypeNodes.def"
+  { NKI_None, "OMPClause" },
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) { NKI_OMPClause, #DERIVED },
+#include "clang/Basic/OpenMPKinds.def"
 };
 
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
@@ -103,6 +106,19 @@
 #include "clang/AST/TypeNodes.def"
   }
   llvm_unreachable("invalid type kind");
+ }
+
+ASTNodeKind ASTNodeKind::getFromNode(const OMPClause ) {
+  switch (C.getClauseKind()) {
+#define OPENMP_CLAUSE(Name, Class) \
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"
+case OMPC_threadprivate:
+case OMPC_uniform:
+case OMPC_unknown:
+  llvm_unreachable("unexpected OpenMP clause kind");
+  }
+  llvm_unreachable("invalid stmt kind");
 }
 
 void DynTypedNode::print(llvm::raw_ostream ,
@@ -151,6 +167,8 @@
 return D->getSourceRange();
   if (const Stmt *S = get())
 return S->getSourceRange();
+  if (const OMPClause *C = get())
+return SourceRange(C->getBeginLoc(), C->getEndLoc());
   return SourceRange();
 }
 
Index: include/clang/AST/ASTTypeTraits.h
===
--- include/clang/AST/ASTTypeTraits.h
+++ include/clang/AST/ASTTypeTraits.h
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
@@ -58,6 +59,7 @@
   static ASTNodeKind getFromNode(const Decl );
   static ASTNodeKind getFromNode(const Stmt );
   static ASTNodeKind getFromNode(const Type );
+  static ASTNodeKind getFromNode(const OMPClause );
   /// \}
 
   /// Returns \c true if \c this and \c Other represent the same kind.
@@ -136,6 +138,9 @@
 NKI_Type,
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.def"
+NKI_OMPClause,
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) NKI_##DERIVED,
+#include "clang/Basic/OpenMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -183,12 +188,15 @@
 KIND_TO_KIND_ID(Decl)
 KIND_TO_KIND_ID(Stmt)
 KIND_TO_KIND_ID(Type)
+KIND_TO_KIND_ID(OMPClause)
 #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl)
 #include "clang/AST/DeclNodes.inc"
 #define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.def"
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) KIND_TO_KIND_ID(DERIVED)
+#include "clang/Basic/OpenMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream <<(raw_ostream , ASTNodeKind K) {
@@ -459,6 +467,11 @@
 T, typename std::enable_if::value>::type>
 : public DynCastPtrConverter {};
 
+template 
+struct DynTypedNode::BaseConverter<
+T, typename std::enable_if::value>::type>
+: public DynCastPtrConverter {};
+
 template <>
 struct DynTypedNode::BaseConverter<
 NestedNameSpecifier, void> : public PtrConverter {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits