On Thu, Oct 18, 2012 at 6:34 AM, Mahesha HS <mahesha.l...@gmail.com> wrote:
> Sorry, in my previous mail,  I had missed to attach changes to
> "clang/include/clang/Basic/TokenKinds.def" in the patch 2. Please
> refer to the patch (2) attached in *this* mail, instead of the one
> sent in the previous mail. Patch 1 is fine.

+//--------------------------------
+// OpenMP directives
+//--------------------------------
+// \#pragam omp parallel ...
+TOK(pragma_omp_parallel)
+// \#pragam omp for ...
+TOK(pragma_omp_for)

Please use ANNOTATION(pragma_omp_parallel) etc. instead.

+/// PragmaOmpHandler - "\#pragma omp ...".
+template<class T, tok::TokenKind TKind>
+struct PragmaOmpHandler : public PragmaHandler {
+  PragmaOmpHandler() : PragmaHandler(T::Name) {}
+  virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+                            Token &OmpTok) {
+    PP.HandlePragmaOmp(OmpTok, TKind);
+  }
+};

Something like following would make your patch substantially shorter:

struct PragmaOmpHandler : public PragmaHandler {
  tok::TokenKind TKind;
  PragmaOmpHandler(tok::TokenKind Kind, StringRef Name)
    : PragmaHandler(Name), TKind(Kind) {}
  virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
                            Token &OmpTok) {
    PP.HandlePragmaOmp(OmpTok, TKind);
  }
};


Please add a test that the pragmas round-trip correctly through clang -E.

-Eli
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to