[PATCH] D61643: [PragmaHandler] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361335: [PragmaHandler] Expose `#pragma` location (authored 
by jdenny, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61643?vs=198489=200608#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61643

Files:
  docs/ClangPlugins.rst
  examples/AnnotateFunctions/AnnotateFunctions.cpp
  include/clang/Lex/Pragma.h
  include/clang/Lex/Preprocessor.h
  lib/Frontend/PrintPreprocessedOutput.cpp
  lib/Lex/PPDirectives.cpp
  lib/Lex/Pragma.cpp
  lib/Parse/ParsePragma.cpp

Index: docs/ClangPlugins.rst
===
--- docs/ClangPlugins.rst
+++ docs/ClangPlugins.rst
@@ -55,7 +55,7 @@
   class ExamplePragmaHandler : public PragmaHandler {
   public:
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
   Token ) {
   // Handle the pragma
 }
Index: include/clang/Lex/Preprocessor.h
===
--- include/clang/Lex/Preprocessor.h
+++ include/clang/Lex/Preprocessor.h
@@ -2291,8 +2291,7 @@
   void HandleElifDirective(Token , const Token );
 
   // Pragmas.
-  void HandlePragmaDirective(SourceLocation IntroducerLoc,
- PragmaIntroducerKind Introducer);
+  void HandlePragmaDirective(PragmaIntroducer Introducer);
 
 public:
   void HandlePragmaOnce(Token );
Index: include/clang/Lex/Pragma.h
===
--- include/clang/Lex/Pragma.h
+++ include/clang/Lex/Pragma.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_LEX_PRAGMA_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -46,6 +47,12 @@
 PIK___pragma
   };
 
+  /// Describes how and where the pragma was introduced.
+  struct PragmaIntroducer {
+PragmaIntroducerKind Kind;
+SourceLocation Loc;
+  };
+
 /// PragmaHandler - Instances of this interface defined to handle the various
 /// pragmas that the language front-end uses.  Each handler optionally has a
 /// name (e.g. "pack") and the HandlePragma method is invoked when a pragma with
@@ -64,7 +71,7 @@
   virtual ~PragmaHandler();
 
   StringRef getName() const { return Name; }
-  virtual void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  virtual void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) = 0;
 
   /// getIfNamespace - If this is a namespace, return it.  This is equivalent to
@@ -78,7 +85,7 @@
 public:
   explicit EmptyPragmaHandler(StringRef Name = StringRef());
 
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 };
 
@@ -111,7 +118,7 @@
 
   bool IsEmpty() const { return Handlers.empty(); }
 
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 
   PragmaNamespace *getIfNamespace() override { return this; }
Index: examples/AnnotateFunctions/AnnotateFunctions.cpp
===
--- examples/AnnotateFunctions/AnnotateFunctions.cpp
+++ examples/AnnotateFunctions/AnnotateFunctions.cpp
@@ -58,7 +58,7 @@
 public:
   PragmaAnnotateHandler() : PragmaHandler("enable_annotate") { }
 
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override {
 
 Token Tok;
Index: lib/Parse/ParsePragma.cpp
===
--- lib/Parse/ParsePragma.cpp
+++ lib/Parse/ParsePragma.cpp
@@ -26,71 +26,72 @@
 
 struct PragmaAlignHandler : public PragmaHandler {
   explicit PragmaAlignHandler() : PragmaHandler("align") {}
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 };
 
 struct PragmaGCCVisibilityHandler : public PragmaHandler {
   explicit PragmaGCCVisibilityHandler() : PragmaHandler("visibility") {}
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 Token ) override;
 };
 
 struct PragmaOptionsHandler : public PragmaHandler {
   explicit PragmaOptionsHandler() : PragmaHandler("options") {}
-  void HandlePragma(Preprocessor , PragmaIntroducerKind Introducer,
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
 

[PATCH] D61643: [PragmaHandler] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D61643#1510815 , @Meinersbur wrote:

> +1
>
> Such a solution also came up in https://bugs.llvm.org/show_bug.cgi?id=41514#c1


Cool.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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


[PATCH] D61643: [PragmaHandler] Expose `#pragma` location

2019-05-21 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

+1

Such a solution also came up in https://bugs.llvm.org/show_bug.cgi?id=41514#c1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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