[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-08-18 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
fodinabor added reviewers: bkramer, djasper, klimek.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
fodinabor requested review of this revision.

Currently newer clang-format options cannot be included in .clang-format files, 
if not all users can be forced to use an updated version.
This patch tries to solve this by adding an option to clang-format, enabling to 
ignore unknown (newer) options.

As this is my first LLVM patch, I'm expecting to get some things wrong and are 
happy to receive any feedback!
E.g.: I haven't found how to update the clang-format help page yet. Is it auto 
generated?
Also if you have any suggestions on whom to ask wrt review, please add them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86137

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLTraits.cpp

Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -195,6 +195,8 @@
   MapHNode *MN = dyn_cast_or_null(CurrentNode);
   if (!MN)
 return;
+  if (IgnoreUnkown)
+return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
   setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
@@ -428,6 +430,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setIgnoreUnknown(bool Value) { IgnoreUnkown = Value; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
@@ -735,6 +739,8 @@
 void Output::setError(const Twine &message) {
 }
 
+void Output::setIgnoreUnknown(bool Value) {}
+
 bool Output::canElideEmptySequence() {
   // Normally, with an optional key/value where the value is an empty sequence,
   // the whole key/value can be not written.  But, that produces wrong yaml
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setIgnoreUnknown(bool) = 0;
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1504,6 +1505,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setIgnoreUnknown(bool) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1517,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   boolScalarMatchFound = false;
+  bool IgnoreUnkown = false;
 };
 
 ///
@@ -1561,6 +1565,7 @@
   void scalarTag(std::string &) override;
   NodeKind getNodeKind() override;
   void setError(const Twine &message) override;
+  void setIgnoreUnknown(bool) override;
   bool canElideEmptySequence() override;
 
   // These are only used by operator<<. They could be private
Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,6 +104,11 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
+static cl::opt
+IgnoreUnkownOptions("ignore-unknown-options",
+cl::desc("If set, unknown format options are ignored."),
+cl::init(false), cl::cat(ClangFormatCategory));
+
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -378,7 +383,8 @@
   }
 
   llvm::Expected FormatStyle =
-  getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer());
+  getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
+   nullptr, IgnoreUnkownOptions.getValue());
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1288,7 +1288,8 @@
   return true;
 }
 
-std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
+std::error_code parseConfiguration(StringRef Text, FormatStyle *Style,
+   bool IgnoreUnknownOptions) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
@@ -1302,6 +1303,7 @@
   // Mapping also uses the context to get the language to find the correct
   // base style.
   Input.setContext(Style);
+  Input.setIgnoreUnknown(IgnoreUn

[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-07-18 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor accepted this revision.
fodinabor added a comment.
This revision is now accepted and ready to land.

LGTM as well :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105221

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-12 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 291405.
fodinabor added a comment.

Address review comments, copy the help text into docs and add some basic unit 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/docs/ClangFormat.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/ObjectYAML/YAMLTest.cpp

Index: llvm/unittests/ObjectYAML/YAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/YAMLTest.cpp
+++ llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -35,3 +35,24 @@
   YOut << BH;
   EXPECT_NE(OS.str().find("''"), StringRef::npos);
 }
+
+TEST(ObjectYAML, UnkownOption) {
+  std::string InputYAML = "Binary: \n"
+  "InvalidKey: InvalidValue";
+  BinaryHolder BH;
+  llvm::yaml::Input Input(InputYAML);
+  // test 1: default in trying to parse invalid key is an error case
+  Input >> BH;
+  EXPECT_EQ(Input.error().value(), 22);
+
+  // test 2: only warn about invalid key if actively set.
+  llvm::yaml::Input Input2(InputYAML);
+  BinaryHolder BH2;
+  Input2.setAllowUnknownKeys(true);
+  Input2 >> BH2;
+
+  BinaryHolder BH_GT;
+  BH_GT.Binary = yaml::BinaryRef("");
+  EXPECT_EQ(BH2.Binary, BH_GT.Binary);
+  EXPECT_EQ(Input2.error().value(), 0);
+}
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,12 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  HNode *ReportNode = NN.second.get();
+  if (!AllowUnknownKeys) {
+setError(ReportNode, Twine("unknown key '") + NN.first() + "'");
+break;
+  } else
+reportWarning(ReportNode, Twine("unknown key '") + NN.first() + "'");
 }
   }
 }
@@ -370,6 +378,11 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +441,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std::

[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-15 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

All comments should be adressed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-15 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 291826.
fodinabor marked 9 inline comments as done.
fodinabor added a comment.

Unit test cleanups.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/docs/ClangFormat.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/ObjectYAML/YAMLTest.cpp

Index: llvm/unittests/ObjectYAML/YAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/YAMLTest.cpp
+++ llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -35,3 +35,21 @@
   YOut << BH;
   EXPECT_NE(OS.str().find("''"), StringRef::npos);
 }
+
+TEST(ObjectYAML, UnknownOption) {
+  StringRef InputYAML = "InvalidKey: InvalidValue\n"
+"Binary: \n";
+  BinaryHolder BH;
+  yaml::Input Input(InputYAML);
+  // test 1: default in trying to parse invalid key is an error case.
+  Input >> BH;
+  EXPECT_EQ(Input.error().value(), 22);
+
+  // test 2: only warn about invalid key if actively set.
+  yaml::Input Input2(InputYAML);
+  BinaryHolder BH2;
+  Input2.setAllowUnknownKeys(true);
+  Input2 >> BH2;
+  EXPECT_EQ(BH2.Binary, yaml::BinaryRef(""));
+  EXPECT_EQ(Input2.error().value(), 0);
+}
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,12 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  HNode *ReportNode = NN.second.get();
+  if (!AllowUnknownKeys) {
+setError(ReportNode, Twine("unknown key '") + NN.first() + "'");
+break;
+  } else
+reportWarning(ReportNode, Twine("unknown key '") + NN.first() + "'");
 }
   }
 }
@@ -370,6 +378,11 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +441,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   bool   

[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-18 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 292781.
fodinabor marked an inline comment as done.
fodinabor added a comment.

Fix the nit :)
Anyone with access may commit this now (ideally ofc someone with a final 
opinion on the clang-format part).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/docs/ClangFormat.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/ObjectYAML/YAMLTest.cpp

Index: llvm/unittests/ObjectYAML/YAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/YAMLTest.cpp
+++ llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -35,3 +35,21 @@
   YOut << BH;
   EXPECT_NE(OS.str().find("''"), StringRef::npos);
 }
+
+TEST(ObjectYAML, UnknownOption) {
+  StringRef InputYAML = "InvalidKey: InvalidValue\n"
+"Binary: \n";
+  BinaryHolder BH;
+  yaml::Input Input(InputYAML);
+  // test 1: default in trying to parse invalid key is an error case.
+  Input >> BH;
+  EXPECT_EQ(Input.error().value(), 22);
+
+  // test 2: only warn about invalid key if actively set.
+  yaml::Input Input2(InputYAML);
+  BinaryHolder BH2;
+  Input2.setAllowUnknownKeys(true);
+  Input2 >> BH2;
+  EXPECT_EQ(BH2.Binary, yaml::BinaryRef(""));
+  EXPECT_EQ(Input2.error().value(), 0);
+}
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,12 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  HNode *ReportNode = NN.second.get();
+  if (!AllowUnknownKeys) {
+setError(ReportNode, Twine("unknown key '") + NN.first() + "'");
+break;
+  } else
+reportWarning(ReportNode, Twine("unknown key '") + NN.first() + "'");
 }
   }
 }
@@ -370,6 +378,11 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +441,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,

[PATCH] D86137: Add -Wno-error=unknown flag to clang-format.

2020-09-18 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Okay, I requested commit access.
So the patch is fine with you from a clang-format perspective?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D86137: Add -Wno-error=unknown flag to clang-format.

2020-09-19 Thread Joachim Meyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf64903fd8176: Add -Wno-error=unknown flag to clang-format. 
(authored by fodinabor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/docs/ClangFormat.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/ObjectYAML/YAMLTest.cpp

Index: llvm/unittests/ObjectYAML/YAMLTest.cpp
===
--- llvm/unittests/ObjectYAML/YAMLTest.cpp
+++ llvm/unittests/ObjectYAML/YAMLTest.cpp
@@ -35,3 +35,21 @@
   YOut << BH;
   EXPECT_NE(OS.str().find("''"), StringRef::npos);
 }
+
+TEST(ObjectYAML, UnknownOption) {
+  StringRef InputYAML = "InvalidKey: InvalidValue\n"
+"Binary: \n";
+  BinaryHolder BH;
+  yaml::Input Input(InputYAML);
+  // test 1: default in trying to parse invalid key is an error case.
+  Input >> BH;
+  EXPECT_EQ(Input.error().value(), 22);
+
+  // test 2: only warn about invalid key if actively set.
+  yaml::Input Input2(InputYAML);
+  BinaryHolder BH2;
+  Input2.setAllowUnknownKeys(true);
+  Input2 >> BH2;
+  EXPECT_EQ(BH2.Binary, yaml::BinaryRef(""));
+  EXPECT_EQ(Input2.error().value(), 0);
+}
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,12 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  HNode *ReportNode = NN.second.get();
+  if (!AllowUnknownKeys) {
+setError(ReportNode, Twine("unknown key '") + NN.first() + "'");
+break;
+  } else
+reportWarning(ReportNode, Twine("unknown key '") + NN.first() + "'");
 }
   }
 }
@@ -370,6 +378,11 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  Strm->printError(hnode->_node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +441,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std

[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-05 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-05 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

I see the possible issue with the possible version mismatches and that is why 
I'd make people opt-in for this option, to still being able to format their 
files (e.g. if using out-dated built-in versions like in Visual Studio - I know 
you can specify your own binary) but the real formatting can be done with a 
pre-commit script or similar, where the new options are actually supported.

Regarding not touching the LLVM support library: I'd love to find a way, but as 
clang-format uses the `>>` operator to read the YAML and this operator 
automatically emits the errors, I don't see any other obvious way.. (maybe 
there's a LLVM trick to suppress those errors that I haven't seen, yet :))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-07 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a subscriber: grimar.
fodinabor added a comment.

Thank you so far for the feedback!
maybe you can give further guidance on the comments on the comments :)

As of the git history it seems that @grimar did some work on YAML error 
handling..




Comment at: clang/tools/clang-format/ClangFormat.cpp:108
+static cl::opt
+IgnoreUnkownOptions("ignore-unknown-options",
+cl::desc("If set, unknown format options are 
ignored."),

MyDeveloperDay wrote:
> feels like a mouthful is there nothing shorter we could use?  -Wignore (or 
> something)
hmm... `-Wunknown`
but the `-W` does not really make it clear that the default "errors" should now 
be treated as warnings instead. From compiler conventions, I'd expect the `-W` 
to enable a warning ... 

and something like `-Wno-error=unknown` is not really shorter...



Comment at: llvm/include/llvm/Support/YAMLTraits.h:1520
   boolScalarMatchFound = false;
+  bool IgnoreUnkown = false;
 };

MyDeveloperDay wrote:
> is this clang-formatted?
the patch is... the original alignment of the members is not. (also see the 
`CurrentNode`'s formatting).
not sure what to do in this case, as the whole file seems rather unformatted?



Comment at: llvm/lib/Support/YAMLTraits.cpp:199
+  if (IgnoreUnkown)
+return;
   for (const auto &NN : MN->Mapping) {

MyDeveloperDay wrote:
> do we want to flat out ignore or just report but not fatally. (just a 
> thought) silent failures are hard to diagnose
true.. don't know what's the best option?

keep it as a printed out error and just don't return an error code on exit? 
This option would make it a clang-format only change, but feels really dirty.

Otherwise I'd have to dig my way through to `llvm::yaml::Stream::printError` 
(or maybe rather add a `printWarning`) to conditionally change the message type 
for the ignore case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-08 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 290460.
fodinabor marked 9 inline comments as done.
fodinabor added a comment.

Incorporating review comments:

- renaming option to -Wno-error=unknown and adding warning in description
- emit warnings instead of fully ignoring the issues

Documentation and unit tests will follow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  .clang-format
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp

Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,13 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  auto ReportNode = NN.second.get();
+  auto ReportMessage = Twine("unknown key '") + NN.first() + "'";
+  if (!AllowUnknownKeys) {
+setError(ReportNode, ReportMessage);
+break;
+  } else
+reportWarning(ReportNode, ReportMessage);
 }
   }
 }
@@ -370,6 +379,15 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  reportWarning(hnode->_node, message);
+}
+
+void Input::reportWarning(Node *node, const Twine &message) {
+  Strm->printError(node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +446,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   boolScalarMatchFound = false;
+  bool AllowUnknownKeys = false;
 };
 
 ///
Index: llvm/include/llvm/Support/YAMLParser.h
===
--- llvm/include/llvm/Support/YAMLParser.h
+++ llvm/include/llvm/Support/YAMLParser.h
@@ -40,6 +40,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/SMLoc.h"
+#include "llvm/Support/SourceMgr.h"
 #include 
 #include 
 #include 
@@ -51,7 +52,6 @@
 namespace llvm {
 
 class MemoryBufferRef;
-class SourceMgr;
 class raw_ostream;
 class Twine;
 
@@ -100,7 +100,8 @@
 return !failed();
   }
 
-  void printError(N

[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-08 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 290461.
fodinabor added a comment.

Remove test entry form .clang-format :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  llvm/include/llvm/Support/YAMLParser.h
  llvm/include/llvm/Support/YAMLTraits.h
  llvm/lib/Support/YAMLParser.cpp
  llvm/lib/Support/YAMLTraits.cpp

Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -48,6 +48,10 @@
   Ctxt = Context;
 }
 
+void IO::setAllowUnknownKeys(bool Allow) {
+  llvm_unreachable("Only supported for Input");
+}
+
 //===--===//
 //  Input
 //===--===//
@@ -197,8 +201,13 @@
 return;
   for (const auto &NN : MN->Mapping) {
 if (!is_contained(MN->ValidKeys, NN.first())) {
-  setError(NN.second.get(), Twine("unknown key '") + NN.first() + "'");
-  break;
+  auto ReportNode = NN.second.get();
+  auto ReportMessage = Twine("unknown key '") + NN.first() + "'";
+  if (!AllowUnknownKeys) {
+setError(ReportNode, ReportMessage);
+break;
+  } else
+reportWarning(ReportNode, ReportMessage);
 }
   }
 }
@@ -370,6 +379,15 @@
   EC = make_error_code(errc::invalid_argument);
 }
 
+void Input::reportWarning(HNode *hnode, const Twine &message) {
+  assert(hnode && "HNode must not be NULL");
+  reportWarning(hnode->_node, message);
+}
+
+void Input::reportWarning(Node *node, const Twine &message) {
+  Strm->printError(node, message, SourceMgr::DK_Warning);
+}
+
 std::unique_ptr Input::createHNodes(Node *N) {
   SmallString<128> StringStorage;
   if (ScalarNode *SN = dyn_cast(N)) {
@@ -428,6 +446,8 @@
   setError(CurrentNode, Message);
 }
 
+void Input::setAllowUnknownKeys(bool Allow) { AllowUnknownKeys = Allow; }
+
 bool Input::canElideEmptySequence() {
   return false;
 }
Index: llvm/lib/Support/YAMLParser.cpp
===
--- llvm/lib/Support/YAMLParser.cpp
+++ llvm/lib/Support/YAMLParser.cpp
@@ -1775,12 +1775,9 @@
 
 bool Stream::failed() { return scanner->failed(); }
 
-void Stream::printError(Node *N, const Twine &Msg) {
+void Stream::printError(Node *N, const Twine &Msg, SourceMgr::DiagKind Kind) {
   SMRange Range = N ? N->getSourceRange() : SMRange();
-  scanner->printError( Range.Start
- , SourceMgr::DK_Error
- , Msg
- , Range);
+  scanner->printError(Range.Start, Kind, Msg, Range);
 }
 
 document_iterator Stream::begin() {
Index: llvm/include/llvm/Support/YAMLTraits.h
===
--- llvm/include/llvm/Support/YAMLTraits.h
+++ llvm/include/llvm/Support/YAMLTraits.h
@@ -789,6 +789,7 @@
   virtual NodeKind getNodeKind() = 0;
 
   virtual void setError(const Twine &) = 0;
+  virtual void setAllowUnknownKeys(bool Allow);
 
   template 
   void enumCase(T &Val, const char* Str, const T ConstVal) {
@@ -1495,6 +1496,9 @@
   void setError(HNode *hnode, const Twine &message);
   void setError(Node *node, const Twine &message);
 
+  void reportWarning(HNode *hnode, const Twine &message);
+  void reportWarning(Node *hnode, const Twine &message);
+
 public:
   // These are only used by operator>>. They could be private
   // if those templated things could be made friends.
@@ -1504,6 +1508,8 @@
   /// Returns the current node that's being parsed by the YAML Parser.
   const Node *getCurrentNode() const;
 
+  void setAllowUnknownKeys(bool Allow) override;
+
 private:
   SourceMgr   SrcMgr; // must be before Strm
   std::unique_ptr Strm;
@@ -1514,6 +1520,7 @@
   std::vector   BitValuesUsed;
   HNode *CurrentNode = nullptr;
   boolScalarMatchFound = false;
+  bool AllowUnknownKeys = false;
 };
 
 ///
Index: llvm/include/llvm/Support/YAMLParser.h
===
--- llvm/include/llvm/Support/YAMLParser.h
+++ llvm/include/llvm/Support/YAMLParser.h
@@ -40,6 +40,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/SMLoc.h"
+#include "llvm/Support/SourceMgr.h"
 #include 
 #include 
 #include 
@@ -51,7 +52,6 @@
 namespace llvm {
 
 class MemoryBufferRef;
-class SourceMgr;
 class raw_ostream;
 class Twine;
 
@@ -100,7 +100,8 @@
 return !failed();
   }
 
-  void printError(Node *N, const Twine &Msg);
+  void printError(Node *N, const Twine &Msg,
+  SourceMgr::DiagKind Kind = SourceMgr::DK_Error);
 
 private:
   friend class Document;
Index: clang/tools/clang-format/ClangForma

[PATCH] D86137: Add -Wno-error=unknown flag to clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

I can reproduce the issue, but not sure what introduced this.

In D86137#2460135 , @njames93 wrote:

> Should the name be changed to `Wno-error-unknown`?

I don't think this should be the solution, as we aimed for the common syntax 
using the `-Wno-error=` style.
I just tried to prepare a patch, changing the way, this is handled, it works 
already in theory, but the formatting of the `--help` page is still slightly 
off (I guess `cl::values` descriptions are supposed to be single line), so I 
guess I have to investigate my formatting options here or move the more 
extensive description somewhere else... if I don't find an obvious solution, I 
guess we can discuss that after I created the patch..

  Clang-format options:
  
--Werror   - If set, changes formatting warnings to errors
--Wno-error=- If set don't error out on the specified 
warning type.
  =unknown -   If set, unknown format options are only 
warned about.
  This can be used to enable formatting, even if the
  configuration contains unknown (newer) options.
  Use with caution, as this might lead to dramatically
  differing format depending on an option being
  supported or not.
--assume-filename= - Override filename used to determine the 
language.
 When reading from stdin, clang-format assumes 
this
 filename to determine the language.
--cursor=- The position of the cursor when invoking
  ...

Btw. is there a way to add tests for command line options, so this won't happen 
unnoticed again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
fodinabor added reviewers: MyDeveloperDay, JakeMerdichAMD.
fodinabor requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As noted in https://reviews.llvm.org/D86137#2460135 parsing of
the clang-format parameter -Wno-error=unknown fails.
This currently is done by having `-Wno-error=unknown` as an option.
In this patch this is changed to make `-Wno-error=` parse an enum into a bit 
set.
This way the parsing is fixed and also we can possibly add new options easily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93459

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-

[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Quoting my questions from the other review, as it should be more appropriate to 
discuss this here:

The formatting of the `--help` page is still slightly off (I guess `cl::values` 
descriptions are supposed to be single line), so I guess I have to investigate 
my formatting options here or move the more extensive description somewhere 
else...

  Clang-format options:
  
--Werror   - If set, changes formatting warnings to errors
--Wno-error=- If set don't error out on the specified 
warning type.
  =unknown -   If set, unknown format options are only 
warned about.
  This can be used to enable formatting, even if the
  configuration contains unknown (newer) options.
  Use with caution, as this might lead to dramatically
  differing format depending on an option being
  supported or not.
--assume-filename= - Override filename used to determine the 
language.
 When reading from stdin, clang-format assumes 
this
 filename to determine the language.
--cursor=- The position of the cursor when invoking
  ...

Btw. is there a way to add tests for command-line options, so this won't happen 
unnoticed again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

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


[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 312518.
fodinabor added a comment.

Add lit test to ensure behaviour of the -Wno-error=unkown flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if 

[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 312596.
fodinabor added a comment.

Update ClangFormat.rst.
This is manually well formatted.. will try to make a new patch in the coming 
days to actually fix it in the support library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/docs/ClangFormat.rst
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -31,12 +31,13 @@
   Clang-format options:
 
 --Werror   - If set, changes formatting warnings to errors
---Wno-error=unknown- If set, unknown format options are only 
warned about.
- This can be used to enable formatting, even 
if the
- configuration contains unknown (newer) 
options.
- Use with caution, as this might lead to 
dramatically
- differing format depending on an option being
- supported or not.
+--Wno-error=- If set don't error out on the specified 
warning type.
+  =unknown -   If set, unknown format options are only 
warned about.
+   This can be used to enable formatting, even 
if the
+   configuration contains unknown (newer) 
options.
+   Use with caution, as this might lead to 
dramatically
+   differing format depending on an option 
being
+   supported or not.
 --assume-filename= - Override filename used to determine the 
language.
  When reading from 

[PATCH] D93459: Fix -Wno-error= parsing in clang-format.

2020-12-17 Thread Joachim Meyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc755e41c336c: Fix -Wno-error= parsing in clang-format. 
(authored by fodinabor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93459

Files:
  clang/docs/ClangFormat.rst
  clang/test/Format/error-config.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -104,18 +104,6 @@
  "SortIncludes style flag"),
 cl::cat(ClangFormatCategory));
 
-// using the full param name as Wno-error probably won't be a common use case 
in
-// clang-format
-static cl::opt AllowUnknownOptions(
-"Wno-error=unknown",
-cl::desc("If set, unknown format options are only warned about.\n"
- "This can be used to enable formatting, even if the\n"
- "configuration contains unknown (newer) options.\n"
- "Use with caution, as this might lead to dramatically\n"
- "differing format depending on an option being\n"
- "supported or not."),
-cl::init(false), cl::cat(ClangFormatCategory));
-
 static cl::opt
 Verbose("verbose", cl::desc("If set, shows the list of processed files"),
 cl::cat(ClangFormatCategory));
@@ -156,6 +144,23 @@
  cl::desc("If set, changes formatting warnings to errors"),
  cl::cat(ClangFormatCategory));
 
+namespace {
+enum class WNoError { Unknown };
+}
+
+static cl::bits WNoErrorList(
+"Wno-error",
+cl::desc("If set don't error out on the specified warning type."),
+cl::values(
+clEnumValN(WNoError::Unknown, "unknown",
+   "If set, unknown format options are only warned about.\n"
+   "This can be used to enable formatting, even if the\n"
+   "configuration contains unknown (newer) options.\n"
+   "Use with caution, as this might lead to dramatically\n"
+   "differing format depending on an option being\n"
+   "supported or not.")),
+cl::cat(ClangFormatCategory));
+
 static cl::opt
 ShowColors("fcolor-diagnostics",
cl::desc("If set, and on a color-capable terminal controls "
@@ -391,7 +396,7 @@
 
   llvm::Expected FormatStyle =
   getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer(),
-   nullptr, AllowUnknownOptions.getValue());
+   nullptr, WNoErrorList.isSet(WNoError::Unknown));
   if (!FormatStyle) {
 llvm::errs() << llvm::toString(FormatStyle.takeError()) << "\n";
 return true;
Index: clang/test/Format/error-config.cpp
===
--- /dev/null
+++ clang/test/Format/error-config.cpp
@@ -0,0 +1,11 @@
+// RUN: clang-format %s --Wno-error=unknown --style="{UnknownKey: true}" 2>&1 
| FileCheck %s -check-prefix=CHECK
+// RUN: not clang-format %s --style="{UnknownKey: true}" 2>&1 | FileCheck %s 
-check-prefix=CHECK-FAIL
+
+// CHECK: YAML:1:2: warning: unknown key 'UnknownKey'
+// CHECK-NEXT: {UnknownKey: true}
+// CHECK-NEXT: ^~
+// CHECK-FAIL: YAML:1:2: error: unknown key 'UnknownKey'
+// CHECK-FAIL-NEXT: {UnknownKey: true}
+// CHECK-FAIL-NEXT: ^~
+
+int i ;
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -31,12 +31,13 @@
   Clang-format options:
 
 --Werror   - If set, changes formatting warnings to errors
---Wno-error=unknown- If set, unknown format options are only 
warned about.
- This can be used to enable formatting, even 
if the
- configuration contains unknown (newer) 
options.
- Use with caution, as this might lead to 
dramatically
- differing format depending on an option being
- supported or not.
+--Wno-error=- If set don't error out on the specified 
warning type.
+  =unknown -   If set, unknown format options are only 
warned about.
+   This can be used to enable formatting, even 
if the
+   configuration contains unknown (newer) 
options.
+   Use with caution, as this might lead to 
dramatically
+   differing format depending on an option 
being
+   supported or not.
 --assume-filename= - Override filename used to determine the 
language.
  When reading fr

[PATCH] D90415: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.

2020-10-29 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
Herald added subscribers: cfe-commits, guansong, yaxunl.
Herald added a project: clang.
fodinabor requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

This is very similar to 7f1e6fcff942 
, just 
fixing a left-over.
With this it should be possible to use both, -x cuda and -fopenmp in the same 
invocation,
enabling to use both OpenMP, targeting CPU, and CUDA, targeting the GPU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90415

Files:
  clang/lib/Headers/__clang_cuda_complex_builtins.h


Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp end declare target
 #endif
 


Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp end declare target
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90415: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.

2020-10-29 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 301726.
fodinabor edited the summary of this revision.
fodinabor added a comment.

Add missing macro definitions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90415

Files:
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/lib/Headers/openmp_wrappers/complex.h


Index: clang/lib/Headers/openmp_wrappers/complex.h
===
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp end declare target
 #endif
 


Index: clang/lib/Headers/openmp_wrappers/complex.h
===
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp end declare target
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90415: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.

2020-10-29 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Thanks, will land it later.

For the bug see: https://bugs.llvm.org/show_bug.cgi?id=48014
Do I have to create a new phabricator review, too?
I'm currently building the release/11.x branch with the patch cherry-picked 
(which worked flawlessly).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90415

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


[PATCH] D90415: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.

2020-10-29 Thread Joachim Meyer via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeaee608448c8: [OpenMP] Use __OPENMP_NVPTX__ instead of 
_OPENMP in complex wrapper headers. (authored by fodinabor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90415

Files:
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/openmp_wrappers/complex
  clang/lib/Headers/openmp_wrappers/complex.h


Index: clang/lib/Headers/openmp_wrappers/complex.h
===
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp end declare target
 #endif
 


Index: clang/lib/Headers/openmp_wrappers/complex.h
===
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -18,7 +18,9 @@
 #include 
 
 #define __CUDA__
+#define __OPENMP_NVPTX__
 #include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
 #endif
 
 // Grab the host header too.
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
 // to work with CUDA and OpenMP target offloading [in C and C++ mode].)
 
 #pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp declare target
 #define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
 #else
@@ -26,7 +26,7 @@
 // To make the algorithms available for C and C++ in CUDA and OpenMP we select
 // different but equivalent function versions. TODO: For OpenMP we currently
 // select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
 #define _ISNANd std::isnan
 #define _ISNANf std::isnan
 #define _ISINFd std::isinf
@@ -276,7 +276,7 @@
 #undef _fmaxd
 #undef _fmaxf
 
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
 #pragma omp end declare target
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102936: [CUDA] Work around compatibility issue with libstdc++ 11.1.0

2021-05-21 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Sadly don't have stdibc++11 available locally as well.. so can't verify, but 
looks good to me except for the push and pop macros.




Comment at: clang/lib/Headers/cuda_wrappers/complex:77
+// https://bugs.llvm.org/show_bug.cgi?id=50383
+#pragma push_macro("__failed_assert")
+#if _GLIBCXX_RELEASE == 11 && __GLIBCXX__ == 20210427

Not sure I understand what the push of `__failed_assert` is for..? can't find 
any reference to `__failed_assert` anywhere... did you mean to write 
`__failed_assertion`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102936

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


[PATCH] D102936: [CUDA] Work around compatibility issue with libstdc++ 11.1.0

2021-05-21 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor accepted this revision.
fodinabor added a comment.

LGTM :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102936

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


[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-07-01 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

Looks pretty much like a revert of https://reviews.llvm.org/D90415 which was 
necessary to allow building with `-x cuda -fopenmp`.
Won't this break that again?

I fear there's no test covering that case and I either wasn't sure where to add 
such a test.. (also `-x hip -fopenmp`?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105221

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


[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-07-01 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor requested changes to this revision.
fodinabor added a comment.
This revision now requires changes to proceed.

citing from https://reviews.llvm.org/rG7f1e6fcff9427adfa8efa3bfeeeac801da788b87:

> Due to recent changes we cannot use OpenMP in CUDA files anymore (PR45533) as 
> the math handling of CUDA is different when _OPENMP is defined. We actually 
> want this different behavior only if we are offloading with OpenMP to NVIDIA, 
> thus generating NVPTX.

`_OPENMP` is defined even when only the CPU backend is targeted, when using 
`-fopenmp`. But then e.g. the OpenMP `__nv_isnand` variant is chosen for 
`_ISNANd` which is not defined if using CPU OpenMP and CUDA.

Applying this patch thus leads to this bunch of errors for `clang -x cuda 
-fopenmp /dev/null -o /dev/null --cuda-gpu-arch=sm_70`

  In file included from :1:
  In file included from 
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:98:7:
 error: no matching function for call to '__nv_isnand'
if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17:
 note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __nv_isnand(double __a);
 ^
  In file included from :1:
  In file included from 
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:98:31:
 error: no matching function for call to '__nv_isnand'
if (_ISNANd(__real__(z)) && _ISNANd(__imag__(z))) {
^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:66:17:
 note: expanded from macro '_ISNANd'
  #define _ISNANd __nv_isnand
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:226:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __nv_isnand(double __a);
 ^
  In file included from :1:
  In file included from 
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:100:9:
 error: no matching function for call to '__nv_isinfd'
  if (_ISINFd(__a) || _ISINFd(__b)) {
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17:
 note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __nv_isinfd(double __a);
 ^
  In file included from :1:
  In file included from 
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:100:25:
 error: no matching function for call to '__nv_isinfd'
  if (_ISINFd(__a) || _ISINFd(__b)) {
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17:
 note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __nv_isinfd(double __a);
 ^
  In file included from :1:
  In file included from 
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_runtime_wrapper.h:419:
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:101:24:
 error: no matching function for call to '__nv_isinfd'
__a = _COPYSIGNd(_ISINFd(__a) ? 1 : 0, __a);
 ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_complex_builtins.h:68:17:
 note: expanded from macro '_ISINFd'
  #define _ISINFd __nv_isinfd
  ^~~
  
/home/joachim/Projekte/install/lib/clang/13.0.0/include/__clang_cuda_libdevice_declares.h:224:16:
 note: candidate function not viable: call to __device__ function from __host__ 
function
  __DEVICE__ int __nv_isinfd(double __a);
 ^
  In file included from :1:
  In file included from 
/home/joachim/Pr

[PATCH] D105322: [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

2021-07-01 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor created this revision.
fodinabor added reviewers: jdoerfert, tra.
Herald added subscribers: guansong, yaxunl.
fodinabor requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This adds a very basic test in `cuda_with_openmp.cu` that just checks whether 
the CUDA & OpenMP integrated headers do compile, when a CUDA file is compiled 
with OpenMP (CPU) enabled.
Thus this basically adds the missing test for https://reviews.llvm.org/D90415.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105322

Files:
  clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_runtime.h
  clang/test/Headers/Inputs/include/crt/host_runtime.h
  clang/test/Headers/Inputs/include/crt/math_functions.hpp
  clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/cuda.h
  clang/test/Headers/Inputs/include/cuda_runtime.h
  clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
  clang/test/Headers/Inputs/include/device_atomic_functions.h
  clang/test/Headers/Inputs/include/device_atomic_functions.hpp
  clang/test/Headers/Inputs/include/device_double_functions.h
  clang/test/Headers/Inputs/include/driver_types.h
  clang/test/Headers/Inputs/include/host_config.h
  clang/test/Headers/Inputs/include/host_defines.h
  clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
  clang/test/Headers/Inputs/include/new
  clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
  clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
  clang/test/Headers/Inputs/include/string.h
  clang/test/Headers/Inputs/include/texture_indirect_functions.h
  clang/test/Headers/cuda_with_openmp.cu

Index: clang/test/Headers/cuda_with_openmp.cu
===
--- /dev/null
+++ clang/test/Headers/cuda_with_openmp.cu
@@ -0,0 +1,8 @@
+// Test using -x cuda -fopenmp does not clash integrated headers.
+// Reported in https://bugs.llvm.org/show_bug.cgi?id=48014
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -x cuda -fopenmp -c %s -o - --cuda-path=%S/../Driver/Inputs/CUDA/usr/local/cuda -nocudalib -isystem %S/Inputs/include -isystem %S/../../lib/Headers -fsyntax-only
+
Index: clang/test/Headers/Inputs/include/texture_indirect_functions.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/texture_indirect_functions.h
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/string.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/string.h
@@ -0,0 +1,2 @@
+#pragma once
+void* memcpy(void* dst, const void* src, size_t num);
\ No newline at end of file
Index: clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/new
===
--- clang/test/Headers/Inputs/include/new
+++ clang/test/Headers/Inputs/include/new
@@ -1,3 +1,4 @@
+#pragma once
 
 namespace std
 {
Index: clang/test/Headers/I

[PATCH] D105322: [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

2021-07-01 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor updated this revision to Diff 356043.
fodinabor added a comment.

Cleanup left over commented out code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105322

Files:
  clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_runtime.h
  clang/test/Headers/Inputs/include/crt/host_runtime.h
  clang/test/Headers/Inputs/include/crt/math_functions.hpp
  clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/cuda.h
  clang/test/Headers/Inputs/include/cuda_runtime.h
  clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
  clang/test/Headers/Inputs/include/device_atomic_functions.h
  clang/test/Headers/Inputs/include/device_atomic_functions.hpp
  clang/test/Headers/Inputs/include/device_double_functions.h
  clang/test/Headers/Inputs/include/driver_types.h
  clang/test/Headers/Inputs/include/host_config.h
  clang/test/Headers/Inputs/include/host_defines.h
  clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
  clang/test/Headers/Inputs/include/new
  clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
  clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
  clang/test/Headers/Inputs/include/string.h
  clang/test/Headers/Inputs/include/texture_indirect_functions.h
  clang/test/Headers/cuda_with_openmp.cu

Index: clang/test/Headers/cuda_with_openmp.cu
===
--- /dev/null
+++ clang/test/Headers/cuda_with_openmp.cu
@@ -0,0 +1,8 @@
+// Test using -x cuda -fopenmp does not clash integrated headers.
+// Reported in https://bugs.llvm.org/show_bug.cgi?id=48014
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -x cuda -fopenmp -c %s -o - --cuda-path=%S/../Driver/Inputs/CUDA/usr/local/cuda -nocudalib -isystem %S/Inputs/include -isystem %S/../../lib/Headers -fsyntax-only
+
Index: clang/test/Headers/Inputs/include/texture_indirect_functions.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/texture_indirect_functions.h
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/string.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/string.h
@@ -0,0 +1,3 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
+void* memcpy(void* dst, const void* src, size_t num);
Index: clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/new
===
--- clang/test/Headers/Inputs/include/new
+++ clang/test/Headers/Inputs/include/new
@@ -1,3 +1,4 @@
+#pragma once
 
 namespace std
 {
Index: clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inp

[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers

2021-07-02 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor added a comment.

I added a pretty simple regression that should make testing this -x cuda 
-fopenmp issue simpler: https://reviews.llvm.org/D105322
I guess a similar test for -x hip -fopenmp could be added, but it hasn't been 
an issue so far as HIP and OpenMP AMDGCN seem to use the same builtins?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105221

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


[PATCH] D105322: [NFC][OpenMP][CUDA] Add test for using `-x cuda -fopenmp`

2021-07-02 Thread Joachim Meyer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG75e941b05c78: [NFC][OpenMP][CUDA] Add test for using `-x 
cuda -fopenmp` (authored by fodinabor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105322

Files:
  clang/test/Headers/Inputs/include/crt/device_double_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_functions.hpp
  clang/test/Headers/Inputs/include/crt/device_runtime.h
  clang/test/Headers/Inputs/include/crt/host_runtime.h
  clang/test/Headers/Inputs/include/crt/math_functions.hpp
  clang/test/Headers/Inputs/include/crt/sm_70_rt.hpp
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/cuda.h
  clang/test/Headers/Inputs/include/cuda_runtime.h
  clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h
  clang/test/Headers/Inputs/include/device_atomic_functions.h
  clang/test/Headers/Inputs/include/device_atomic_functions.hpp
  clang/test/Headers/Inputs/include/device_double_functions.h
  clang/test/Headers/Inputs/include/driver_types.h
  clang/test/Headers/Inputs/include/host_config.h
  clang/test/Headers/Inputs/include/host_defines.h
  clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
  clang/test/Headers/Inputs/include/new
  clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
  clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
  clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
  clang/test/Headers/Inputs/include/string.h
  clang/test/Headers/Inputs/include/texture_indirect_functions.h
  clang/test/Headers/cuda_with_openmp.cu

Index: clang/test/Headers/cuda_with_openmp.cu
===
--- /dev/null
+++ clang/test/Headers/cuda_with_openmp.cu
@@ -0,0 +1,8 @@
+// Test using -x cuda -fopenmp does not clash integrated headers.
+// Reported in https://bugs.llvm.org/show_bug.cgi?id=48014
+///==///
+
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -x cuda -fopenmp -c %s -o - --cuda-path=%S/../Driver/Inputs/CUDA/usr/local/cuda -nocudalib -isystem %S/Inputs/include -isystem %S/../../lib/Headers -fsyntax-only
+
Index: clang/test/Headers/Inputs/include/texture_indirect_functions.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/texture_indirect_functions.h
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/string.h
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/string.h
@@ -0,0 +1,3 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
+void* memcpy(void* dst, const void* src, size_t num);
Index: clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_61_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_60_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_32_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_intrinsics.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/sm_20_atomic_functions.hpp
@@ -0,0 +1,2 @@
+// required for __clang_cuda_runtime_wrapper.h tests
+#pragma once
Index: clang/test/Headers/Inputs/include/new
===
--- clang/test/Headers/Inputs/include/new
+++ clang/test/Headers/Inputs/include/new
@@ -1,3 +1,4 @@
+#pragma once
 
 namespace std
 {
Index: clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/math_functions_dbl_ptx3.hpp
@@ -0,0 +1,2 @@
+// required for __cl

[PATCH] D109232: [CUDA][NFC] Fix a wrong assert message

2021-09-03 Thread Joachim Meyer via Phabricator via cfe-commits
fodinabor accepted this revision.
fodinabor added a comment.
This revision is now accepted and ready to land.

LGTM, guess this can be commited right away.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109232

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