[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-30 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a subscriber: tstellar.
mstorsjo added a comment.

@tstellar, FYI there are still issues being reported with this commit (which 
was made before the branch). One fix is committed and a backport request was 
made in https://llvm.org/PR51261, but there’s still a couple other outstanding 
issues here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-07-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/test/Analysis/return-ptr-range.cpp:1
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange 
-verify %s
+// RUN1: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange 
-verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange 
-analyzer-output text -verify=notes %s

Szelethus wrote:
> steakhal wrote:
> > Is `RUN1` intentional? If so, what does it do?
> We could just delete it. I guess that was the intent, to make this RUN line 
> non-functional.
I wanted to make two runs, one for warnings only and one for notes only. But 
could not find out how to disable the warning messages and show only notes. 
Because the same warnings appear anyway it should be enough to use only one run 
with text output and remove the custom prefix.



Comment at: clang/test/Analysis/return-ptr-range.cpp:19-20
+ptr = arr1 + x; // notes-note{{Value assigned to 'ptr'}}
+if (x != 20) // notes-note{{Assuming 'x' is equal to 20}}
+ // notes-note@-1{{Taking false branch}}
+  return arr1; // no-warning

Szelethus wrote:
> steakhal wrote:
> > This is probably more of a taste.
> > I would prefer fewer indentations.
> > The same applies everywhere.
> I disagree, and prefer it as it is written now.
The current style will be used, the comments are better grouped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

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


[PATCH] D107051: [clang][analyzer] Improve bug report in alpha.security.ReturnPtrRange

2021-07-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 362981.
balazske added a comment.

Changed way of generating notes.
Re-structured the tests.
Other small changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107051

Files:
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/test/Analysis/return-ptr-range.cpp

Index: clang/test/Analysis/return-ptr-range.cpp
===
--- clang/test/Analysis/return-ptr-range.cpp
+++ clang/test/Analysis/return-ptr-range.cpp
@@ -1,29 +1,39 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.security.ReturnPtrRange -verify %s
-
-int arr[10];
-int *ptr;
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.ReturnPtrRange -analyzer-output text -verify %s
 
 int conjure_index();
 
-int *test_element_index_lifetime() {
-  do {
+namespace test_element_index_lifetime {
+
+int arr[10]; // expected-note{{Original object declared here}} expected-note{{Original object declared here}}
+int *ptr;
+
+int *test_global_ptr() {
+  do { // expected-note{{Loop condition is false.  Exiting loop}}
 int x = conjure_index();
-ptr = arr + x;
-if (x != 20)
+ptr = arr + x; // expected-note{{Value assigned to 'ptr'}}
+if (x != 20) // expected-note{{Assuming 'x' is equal to 20}}
+ // expected-note@-1{{Taking false branch}}
   return arr; // no-warning
   } while (0);
-  return ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  return ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow) [alpha.security.ReturnPtrRange]}}
+  // expected-note@-1{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  // expected-note@-2{{Original object 'arr' is an array of 10 'int' objects}}
 }
 
-int *test_element_index_lifetime_with_local_ptr() {
+int *test_local_ptr() {
   int *local_ptr;
-  do {
+  do { // expected-note{{Loop condition is false.  Exiting loop}}
 int x = conjure_index();
-local_ptr = arr + x;
-if (x != 20)
+local_ptr = arr + x; // expected-note{{Value assigned to 'local_ptr'}}
+if (x != 20) // expected-note{{Assuming 'x' is equal to 20}}
+ // expected-note@-1{{Taking false branch}}
   return arr; // no-warning
   } while (0);
-  return local_ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  return local_ptr; // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow) [alpha.security.ReturnPtrRange]}}
+// expected-note@-1{{Returned pointer value points outside the original object (potential buffer overflow)}}
+// expected-note@-2{{Original object 'arr' is an array of 10 'int' objects}}
+}
+
 }
 
 template 
@@ -55,17 +65,52 @@
 
 template 
 class BadIterable {
-  int buffer[N];
+  int buffer[N]; // expected-note{{Original object declared here}}
   int *start, *finish;
 
 public:
-  BadIterable() : start(buffer), finish(buffer + N) {}
+  BadIterable() : start(buffer), finish(buffer + N) {} // expected-note{{Value assigned to 'iter.finish'}}
 
   int* begin() { return start; }
-  int* end() { return finish + 1; } // expected-warning{{Returned pointer value points outside the original object (potential buffer overflow)}}
+  int* end() { return finish + 1; } // expected-warning{{Returned pointer value points outside the original object}}
+// expected-note@-1{{Returned pointer value points outside the original object}}
+// expected-note@-2{{Original object 'buffer' is an array of 20 'int' objects, returned pointer points at index 21}}
 };
 
 void use_bad_iterable_object() {
-  BadIterable<20> iter;
-  iter.end();
+  BadIterable<20> iter; // expected-note{{Calling default constructor for 'BadIterable<20>'}}
+// expected-note@-1{{Returning from default constructor for 'BadIterable<20>'}}
+  iter.end(); // expected-note{{Calling 'BadIterable::end'}}
+}
+
+int *test_idx_sym(int I) {
+  static int arr[10]; // expected-note{{Original object declared here}} expected-note{{'arr' initialized here}}
+
+  if (I != 11) // expected-note{{Assuming 'I' is equal to 11}}
+   // expected-note@-1{{Taking false branch}}
+return arr;
+  return arr + I; // expected-warning{{Returned pointer value points outside the original object}}
+  // expected-note@-1{{Returned pointer value points outside the original object}}
+  // expected-note@-2{{Original object 'arr' is an array of 10 'int' objects, returned pointer points at index 11}}
+}
+
+namespace test_array_of_struct {
+
+struct Data {
+  int A;
+  char *B;
+};

[PATCH] D107137: clangd: Provide hover info for include directives

2021-07-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

It's quite useful to be able to hover over an #include and see the full
path to the header file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107137

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2750,6 +2750,15 @@
 
 // In test::Bar
 int foo = 3)",
+  },
+  {
+  [](HoverInfo &HI)
+  {
+  HI.TargetFile = Location();
+  HI.TargetFile->uri
+  = URIForFile::canonicalize("/usr/include/stdio.h", "/");
+  },
+  "/usr/include/stdio.h",
   }};
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -74,6 +74,12 @@
 const syntax::Token *findNearbyIdentifier(const SpelledWord &Word,
   const syntax::TokenBuffer &TB);
 
+// Treat #included files as symbols, to enable go-to-definition and hover
+// on them.
+llvm::Optional locateFileReferent(const Position &Pos,
+ ParsedAST &AST,
+ llvm::StringRef MainFilePath);
+
 /// Get all document links
 std::vector getDocumentLinks(ParsedAST &AST);
 
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -227,24 +227,6 @@
   return L;
 }
 
-// Treat #included files as symbols, to enable go-to-definition on them.
-llvm::Optional locateFileReferent(const Position &Pos,
- ParsedAST &AST,
- llvm::StringRef MainFilePath) {
-  for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
-if (!Inc.Resolved.empty() && Inc.HashLine == Pos.line) {
-  LocatedSymbol File;
-  File.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
-  File.PreferredDeclaration = {
-  URIForFile::canonicalize(Inc.Resolved, MainFilePath), Range{}};
-  File.Definition = File.PreferredDeclaration;
-  // We're not going to find any further symbols on #include lines.
-  return File;
-}
-  }
-  return llvm::None;
-}
-
 // Macros are simple: there's no declaration/definition distinction.
 // As a consequence, there's no need to look them up in the index either.
 llvm::Optional
@@ -552,6 +534,23 @@
 
 } // namespace
 
+llvm::Optional locateFileReferent(const Position &Pos,
+ ParsedAST &AST,
+ llvm::StringRef MainFilePath) {
+  for (auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
+if (!Inc.Resolved.empty() && Inc.HashLine == Pos.line) {
+  LocatedSymbol File;
+  File.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
+  File.PreferredDeclaration = {
+  URIForFile::canonicalize(Inc.Resolved, MainFilePath), Range{}};
+  File.Definition = File.PreferredDeclaration;
+  // We're not going to find any further symbols on #include lines.
+  return File;
+}
+  }
+  return llvm::None;
+}
+
 std::vector
 locateSymbolTextually(const SpelledWord &Word, ParsedAST &AST,
   const SymbolIndex *Index, const std::string &MainFilePath,
@@ -1987,4 +1986,4 @@
 }
 
 } // namespace clangd
-} // namespace clang
\ No newline at end of file
+} // namespace clang
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -58,7 +58,8 @@
   std::string Documentation;
   /// Source code containing the definition of the symbol.
   std::string Definition;
-
+  /// For #include directives, the pointed-to file.
+  llvm::Optional TargetFile;
   /// Access specifier for declarations inside class/struct/unions, empty for
   /// others.
   std::string AccessSpecifier;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -14,6 +14,7 @@
 #include "ParsedAST.h"
 #include "Selection.h"

[PATCH] D107054: [Clang][CUDA] Add descriptors, mappings, and features for missing CUDA and PTX versions

2021-07-30 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen updated this revision to Diff 362986.
steffenlarsen added a comment.

Made sure the PTX73 and PTX74 macros are popped correctly.


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

https://reviews.llvm.org/D107054

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  llvm/lib/Target/NVPTX/NVPTX.td
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td

Index: llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
===
--- llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
+++ llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
@@ -147,6 +147,9 @@
 def hasPTX65 : Predicate<"Subtarget->getPTXVersion() >= 65">;
 def hasPTX70 : Predicate<"Subtarget->getPTXVersion() >= 70">;
 def hasPTX71 : Predicate<"Subtarget->getPTXVersion() >= 71">;
+def hasPTX72 : Predicate<"Subtarget->getPTXVersion() >= 72">;
+def hasPTX73 : Predicate<"Subtarget->getPTXVersion() >= 73">;
+def hasPTX74 : Predicate<"Subtarget->getPTXVersion() >= 74">;
 
 def hasSM30 : Predicate<"Subtarget->getSmVersion() >= 30">;
 def hasSM70 : Predicate<"Subtarget->getSmVersion() >= 70">;
Index: llvm/lib/Target/NVPTX/NVPTX.td
===
--- llvm/lib/Target/NVPTX/NVPTX.td
+++ llvm/lib/Target/NVPTX/NVPTX.td
@@ -89,6 +89,10 @@
  "Use PTX version 7.1">;
 def PTX72 : SubtargetFeature<"ptx72", "PTXVersion", "72",
  "Use PTX version 7.2">;
+def PTX73 : SubtargetFeature<"ptx73", "PTXVersion", "73",
+ "Use PTX version 7.3">;
+def PTX74 : SubtargetFeature<"ptx74", "PTXVersion", "74",
+ "Use PTX version 7.4">;
 
 //===--===//
 // NVPTX supported processors.
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -77,6 +77,12 @@
 return CudaVersion::CUDA_110;
   if (raw_version < 11020)
 return CudaVersion::CUDA_111;
+  if (raw_version < 11030)
+return CudaVersion::CUDA_112;
+  if (raw_version < 11040)
+return CudaVersion::CUDA_113;
+  if (raw_version < 11050)
+return CudaVersion::CUDA_114;
   return CudaVersion::LATEST;
 }
 
@@ -131,7 +137,9 @@
   SmallVector Candidates;
 
   // In decreasing order so we prefer newer versions to older versions.
-  std::initializer_list Versions = {"8.0", "7.5", "7.0"};
+  std::initializer_list Versions = {
+  "11.4", "11.3", "11.2", "11.1", "10.2", "10.1", "10.0",
+  "9.2",  "9.1",  "9.0",  "8.0",  "7.5",  "7.0"};
   auto &FS = D.getVFS();
 
   if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
@@ -720,6 +728,8 @@
   case CudaVersion::CUDA_##CUDA_VER:   \
 PtxFeature = "+ptx" #PTX_VER;  \
 break;
+CASE_CUDA_VERSION(114, 74);
+CASE_CUDA_VERSION(113, 73);
 CASE_CUDA_VERSION(112, 72);
 CASE_CUDA_VERSION(111, 71);
 CASE_CUDA_VERSION(110, 70);
Index: clang/lib/Basic/Targets/NVPTX.cpp
===
--- clang/lib/Basic/Targets/NVPTX.cpp
+++ clang/lib/Basic/Targets/NVPTX.cpp
@@ -45,6 +45,8 @@
 if (!Feature.startswith("+ptx"))
   continue;
 PTXVersion = llvm::StringSwitch(Feature)
+ .Case("+ptx74", 74)
+ .Case("+ptx73", 73)
  .Case("+ptx72", 72)
  .Case("+ptx71", 71)
  .Case("+ptx70", 70)
Index: clang/lib/Basic/Cuda.cpp
===
--- clang/lib/Basic/Cuda.cpp
+++ clang/lib/Basic/Cuda.cpp
@@ -36,6 +36,10 @@
 return "11.1";
   case CudaVersion::CUDA_112:
 return "11.2";
+  case CudaVersion::CUDA_113:
+return "11.3";
+  case CudaVersion::CUDA_114:
+return "11.4";
   }
   llvm_unreachable("invalid enum");
 }
@@ -54,6 +58,8 @@
   .Case("11.0", CudaVersion::CUDA_110)
   .Case("11.1", CudaVersion::CUDA_111)
   .Case("11.2", CudaVersion::CUDA_112)
+  .Case("11.3", CudaVersion::CUDA_113)
+  .Case("11.4", CudaVersion::CUDA_114)
   .Default(CudaVersion::UNKNOWN);
 }
 
@@ -227,6 +233,10 @@
 return CudaVersion::CUDA_111;
   case 112:
 return CudaVersion::CUDA_112;
+  case 113:
+return CudaVersion::CUDA_113;
+  case 114:
+return CudaVersion::CUDA_114;
   default:
 return CudaVersion::UNKNOWN;
   }
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -31,7 +31,9 @@
   CUDA_110,
   CUDA_111,
   CUDA_112,
-  LATEST = CUDA_112,
+  CUDA_113,
+  CUDA_114,
+  

[clang] 577220e - [OpenCL] Add std flag aliases clc++1.0 and CLC++1.0

2021-07-30 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-07-30T09:19:26+01:00
New Revision: 577220e89866608e0706e3a2b9f8f48215e4e811

URL: 
https://github.com/llvm/llvm-project/commit/577220e89866608e0706e3a2b9f8f48215e4e811
DIFF: 
https://github.com/llvm/llvm-project/commit/577220e89866608e0706e3a2b9f8f48215e4e811.diff

LOG: [OpenCL] Add std flag aliases clc++1.0 and CLC++1.0

Renamed language standard from openclcpp to openclcpp10.
Added new std values i.e. '-cl-std=clc++1.0' and
'-cl-std=CLC++1.0'.

Patch by Topotuna (Justas Janickas)!

Differential Revision: https://reviews.llvm.org/D106266

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Basic/LangStandards.def
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/autocomplete.c
clang/test/Driver/unknown-std.cl
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 63056e09ac574..838669794ea87 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3297,8 +3297,9 @@ or in `the official release
 
`_.
 
 To enable the C++ for OpenCL mode, pass one of following command line options 
when
-compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, ``-std=clc++`` or
-``-std=CLC++``.
+compiling ``.cl`` file ``-cl-std=clc++``, ``-cl-std=CLC++``, 
``-cl-std=clc++1.0``,
+``-cl-std=CLC++1.0``, ``-std=clc++``, ``-std=CLC++``, ``-std=clc++1.0`` or
+``-std=CLC++1.0``.
 
.. code-block:: c++
 

diff  --git a/clang/include/clang/Basic/LangStandards.def 
b/clang/include/clang/Basic/LangStandards.def
index 2cfeb68e56d62..160dc3f2405a7 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -180,17 +180,19 @@ LANGSTANDARD(opencl20, "cl2.0",
 LANGSTANDARD(opencl30, "cl3.0",
  OpenCL, "OpenCL 3.0",
  LineComment | C99 | Digraphs | HexFloat | OpenCL)
-LANGSTANDARD(openclcpp, "clc++",
- OpenCL, "C++ for OpenCL",
+LANGSTANDARD(openclcpp10, "clc++1.0",
+ OpenCL, "C++ for OpenCL 1.0",
  LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 
|
  Digraphs | HexFloat | OpenCL)
+LANGSTANDARD_ALIAS(openclcpp10, "clc++")
 
 LANGSTANDARD_ALIAS_DEPR(opencl10, "CL")
 LANGSTANDARD_ALIAS_DEPR(opencl11, "CL1.1")
 LANGSTANDARD_ALIAS_DEPR(opencl12, "CL1.2")
 LANGSTANDARD_ALIAS_DEPR(opencl20, "CL2.0")
 LANGSTANDARD_ALIAS_DEPR(opencl30, "CL3.0")
-LANGSTANDARD_ALIAS_DEPR(openclcpp, "CLC++")
+LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++")
+LANGSTANDARD_ALIAS_DEPR(openclcpp10, "CLC++1.0")
 
 // CUDA
 LANGSTANDARD(cuda, "cuda", CUDA, "NVIDIA CUDA(tm)",

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7e2397c4192f5..819beaffbf9f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -843,7 +843,8 @@ def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group,
   HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">,
   MarshallingInfoFlag>;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">,
+  
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], 
"cl-fp32-correctly-rounded-divide-sqrt">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 63436b7aebe1a..ae5c5d43318be 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3091,7 +3091,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
   LangStd = LangStandard::lang_opencl12;
   break;
 case Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case Language::CUDA:
   LangStd = LangStandard::lang_cuda;
@@ -3164,7 +3164,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
 Opts.OpenCLVersion = 200;
   else if (LangStd == LangStandard::lang_opencl30)
 Opts.OpenCLVersion = 300;
-  else if (LangStd == LangStandard::lang_openclcpp)
+  else if (LangStd == LangStandard::lang_openclcpp10)
 Opts.OpenCLCPlusPlusVersion = 100;
 
   // OpenCL has some addition

[PATCH] D106266: [C++4OpenCL] Add run line standard aliases clc++1.0 and CLC++1.0

2021-07-30 Thread Anastasia Stulova 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 rG577220e89866: [OpenCL] Add std flag aliases clc++1.0 and 
CLC++1.0 (authored by Anastasia).

Changed prior to commit:
  https://reviews.llvm.org/D106266?vs=360059&id=362988#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106266

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangStandards.def
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/unknown-std.cl
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -478,7 +478,7 @@
   LangStd = LangStandard::lang_opencl10;
   break;
 case clang::Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case clang::Language::CUDA:
   LangStd = LangStandard::lang_cuda;
Index: clang/test/Driver/unknown-std.cl
===
--- clang/test/Driver/unknown-std.cl
+++ clang/test/Driver/unknown-std.cl
@@ -11,7 +11,7 @@
 // CHECK-NEXT: note: use 'cl1.2' for 'OpenCL 1.2' standard
 // CHECK-NEXT: note: use 'cl2.0' for 'OpenCL 2.0' standard
 // CHECK-NEXT: note: use 'cl3.0' for 'OpenCL 3.0' standard
-// CHECK-NEXT: note: use 'clc++' for 'C++ for OpenCL' standard
+// CHECK-NEXT: note: use 'clc++1.0' or 'clc++' for 'C++ for OpenCL 1.0' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -49,6 +49,8 @@
 // CLSTDALL-NEXT: CL3.0
 // CLSTDALL-NEXT: clc++
 // CLSTDALL-NEXT: CLC++
+// CLSTDALL-NEXT: clc++1.0
+// CLSTDALL-NEXT: CLC++1.0
 // RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
 // FNOSANICOVER: func
 // RUN: %clang --autocomplete=-fno-sanitize-coverage= | FileCheck %s -check-prefix=FNOSANICOVERALL
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3091,7 +3091,7 @@
   LangStd = LangStandard::lang_opencl12;
   break;
 case Language::OpenCLCXX:
-  LangStd = LangStandard::lang_openclcpp;
+  LangStd = LangStandard::lang_openclcpp10;
   break;
 case Language::CUDA:
   LangStd = LangStandard::lang_cuda;
@@ -3164,7 +3164,7 @@
 Opts.OpenCLVersion = 200;
   else if (LangStd == LangStandard::lang_opencl30)
 Opts.OpenCLVersion = 300;
-  else if (LangStd == LangStandard::lang_openclcpp)
+  else if (LangStd == LangStandard::lang_openclcpp10)
 Opts.OpenCLCPlusPlusVersion = 100;
 
   // OpenCL has some additional defaults.
@@ -3314,7 +3314,7 @@
   case LangStandard::lang_opencl12:
   case LangStandard::lang_opencl20:
   case LangStandard::lang_opencl30:
-  case LangStandard::lang_openclcpp:
+  case LangStandard::lang_openclcpp10:
 StdOpt = OPT_cl_std_EQ;
 break;
   default:
@@ -3608,7 +3608,8 @@
 .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
 .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
 .Cases("cl3.0", "CL3.0", LangStandard::lang_opencl30)
-.Cases("clc++", "CLC++", LangStandard::lang_openclcpp)
+.Cases("clc++", "CLC++", LangStandard::lang_openclcpp10)
+.Cases("clc++1.0", "CLC++1.0", LangStandard::lang_openclcpp10)
 .Default(LangStandard::lang_unspecified);
 
 if (OpenCLLangStd == LangStandard::lang_unspecified) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -843,7 +843,8 @@
   HelpText<"OpenCL only. Allow use of less precise no signed zeros computations in the generated binary.">,
   MarshallingInfoFlag>;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">,
+  Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++,clc++1.0,CLC++1.0">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divid

[PATCH] D107054: [Clang][CUDA] Add descriptors, mappings, and features for missing CUDA and PTX versions

2021-07-30 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen marked an inline comment as done.
steffenlarsen added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:821
 #pragma pop_macro("PTX71")
 #pragma pop_macro("PTX72")

tra wrote:
> You need to pop new macros here.
My bad! It has been corrected.


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

https://reviews.llvm.org/D107054

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


[PATCH] D107138: [PowerPC] Implement cmplxl builtins

2021-07-30 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
Conanap requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch implements the builtins for cmplxl by utilising
__builtin_complex. This builtin is implemented to match XL
functionality.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107138

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex-32bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex.ll
@@ -0,0 +1,41 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-AIX64
+
+@lda = external local_unnamed_addr global ppc_fp128, align 16
+@ldb = external local_unnamed_addr global ppc_fp128, align 16
+
+define { ppc_fp128, ppc_fp128 } @test_long_double_complex() {
+; CHECK-LABEL: test_long_double_complex:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:addis 3, 2, .LC0@toc@ha
+; CHECK-NEXT:addis 4, 2, .LC1@toc@ha
+; CHECK-NEXT:ld 3, .LC0@toc@l(3)
+; CHECK-NEXT:ld 4, .LC1@toc@l(4)
+; CHECK-NEXT:lfd 1, 0(3)
+; CHECK-NEXT:lfd 2, 8(3)
+; CHECK-NEXT:lfd 3, 0(4)
+; CHECK-NEXT:lfd 4, 8(4)
+; CHECK-NEXT:blr
+;
+; CHECK-AIX64-LABEL: test_long_double_complex:
+; CHECK-AIX64:   # %bb.0: # %entry
+; CHECK-AIX64-NEXT:ld 3, L..C0(2) # @lda
+; CHECK-AIX64-NEXT:ld 4, L..C1(2) # @ldb
+; CHECK-AIX64-NEXT:lfd 1, 0(3)
+; CHECK-AIX64-NEXT:lfd 2, 8(3)
+; CHECK-AIX64-NEXT:lfd 3, 0(4)
+; CHECK-AIX64-NEXT:lfd 4, 8(4)
+; CHECK-AIX64-NEXT:blr
+entry:
+  %0 = load ppc_fp128, ppc_fp128* @lda, align 16
+  %1 = load ppc_fp128, ppc_fp128* @ldb, align 16
+  %.fca.0.insert = insertvalue { ppc_fp128, ppc_fp128 } undef, ppc_fp128 %0, 0
+  %.fca.1.insert = insertvalue { ppc_fp128, ppc_fp128 } %.fca.0.insert, ppc_fp128 %1, 1
+  ret { ppc_fp128, ppc_fp128 } %.fca.1.insert
+}
+
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex-32bit-only.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex-32bit-only.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
+; RUN:   -mcpu=pwr8 < %s | FileCheck %s
+
+@lda = external local_unnamed_addr global double, align 16
+@ldb = external local_unnamed_addr global double, align 16
+
+define { double, double } @test_long_double_complex() {
+; CHECK-LABEL: test_long_double_complex:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lwz 3, L..C0(2) # @lda
+; CHECK-NEXT:lwz 4, L..C1(2) # @ldb
+; CHECK-NEXT:lfd 1, 0(3)
+; CHECK-NEXT:lfd 2, 0(4)
+; CHECK-NEXT:blr
+entry:
+  %0 = load double, double* @lda, align 16
+  %1 = load double, double* @ldb, align 16
+  %.fca.0.insert = insertvalue { double, double } undef, double %0, 0
+  %.fca.1.insert = insertvalue { double, double } %.fca.0.insert, double %1, 1
+  ret { double, double } %.fca.1.insert
+}
Index: clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
+// RUN: %clang_cc1 -O2 -triple powerpc64le-unknown-unknown \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
+// RUN: %clang_cc1 -O2 -triple powerpc-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-AIX
+// RUN: %clang_cc1 -O2 -triple powerpc64-unknown-aix \
+// RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s \
+// RUN:   --check-prefix=CHECK-AIX
+
+extern long double lda, ldb;
+
+long double _Complex test_cmplxl() {
+  // CHECK-LABEL: test_cmplxl
+  // CHECK: %0 = load ppc_fp128, ppc_fp128* @lda
+  // CHECK-NEXT: %1 = load ppc_fp128, ppc_fp128* @ldb
+  // CHECK-NEXT: %.fca.0.insert = insertvalue { ppc_fp128, ppc_fp128 } undef, ppc_fp128 %0, 0
+  // CHECK-NEXT: %.fca.1.insert = insertvalue { ppc_fp128, ppc_fp128 } %.fca.0.insert, ppc_fp128 %1, 1
+  // CHECK-NEXT: ret { ppc_fp128, ppc_fp128 } %.fca

[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-07-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The bug type is passed to `constructNoteTag` only to identify what message will 
be displayed. The bug types that are related to the current function (a message 
should be here if the bug is happening) are passed in. It should be enough to 
look at comment before `constructNoteTag` to check this (and to the bug type -> 
message map).

  C.addTransition(StateFailed, constructNoteTag(C, StreamSym,
{&BT_StreamEof,
 &BT_IndeterminatePosition}));

This indicates that if later an EOF error happens (function called in EOF 
state) this is the place to display a message "stream becomes EOF here". And if 
later an error "stream position indeterminate" happens the note should be here 
too, but with other message. So we can not have a single string as last 
parameter instead of the bug types. It is possible to add multiple note tags 
but I do not like it because this makes more `ExplodedNode`s. Or it is possible 
to figure out the needed message in the NoteTag function from the program state 
but this may be relatively difficult task and more code than the current 
solution.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:387-391
+  /// Create a NoteTag to display a note if a later bug report is generated.
+  /// The `BT` should contain all bug types that could be caused by the
+  /// operation at this location.
+  /// If later on the path a problematic event (reported bug) happens with the
+  /// same type, the last place is found with a note tag with that bug type.

balazske wrote:
> Szelethus wrote:
> > How about:
> > 
> > Create a `NoteTag` describing an stream operation (whether stream opening 
> > succeeds or fails, stream reaches EOF, etc).
> > As not all operations are interesting for all types of stream bugs (the 
> > stream being at an indeterminate file position is irrelevant to whether it 
> > leaks or not), callers can specify in `BT` for which `BugType`s should this 
> > note be displayed for.
> > Only the `NoteTag` closest to the error location will be added to the bug 
> > report.
> The `NoteTag` is added at a place where a possible future bug is introduced. 
> The bug type indicates which bug is the one that can happen after this event. 
> If this bug is really detected the last NoteTag for this type (ignore other 
> NoteTags with non-matching bug type) contains the relevant information.
This is the planned comment at `constructNoteTag`:
  /// Create a NoteTag to display a note if a later bug report is generated.
  /// This should be added added at a place where a possible future bug is
  /// introduced. The bug type indicates which bug is the one that can happen
  /// after this event. If this bug is really detected the last NoteTag for
  /// its type (ignore other NoteTags with non-matching bug type) contains the
  /// relevant information (location and text message).



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


[PATCH] D106939: [RISCV] If the maskedoff is vundefined(), use ta, ma for vsetvli.

2021-07-30 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

In D106939#2915134 , @HsiangKai wrote:

> In D106939#2912807 , @frasercrmck 
> wrote:
>
>> LGTM but there are test failures. Is that just a whole load of `mu->ma` 
>> changes that have been omitted for a smaller diff?
>
> Updated test cases are put in https://reviews.llvm.org/D107022.

Should I combine these two into one patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106939

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-30 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 362997.
pdhaliwal added a comment.

It required some work to fix the failing lit test case. And many thanks to
@estewart for helping in that.

The current status is that we are now following the nvptx openmp strategy for
openmp math headers very closely. In this version of patch, there are bunch
of HIP cmath overloads which are disabled for AMDGPU openmp similar to nvptx.
This fixed the lit failure, but a large number of tests started failing in OvO.,
Reason being that there were some overloads which were used in the suite but 
were disabled earlier. In order to fix them, we had added definitions in the
openmp_wrappers/cmath for the missing overloads. With these changes,  OvO 
compiles 100% of the
mathematical_function test suite successfully. There are still 6/177 tests in
the suite which are producing wrong result.

Now my suggestion is to land this patch as it is and fix the remaining 6 tests
in a later patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+  

[PATCH] D107139: [RISCV] Rename vector inline constraint from 'v' to 'vr' and 'vm' in IR.

2021-07-30 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, khchen, kito-cheng, frasercrmck, 
rogfer01.
Herald added subscribers: StephenFan, vkmr, evandro, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
HsiangKai requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107139

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/rvv/inline-asm.ll

Index: llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
===
--- llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
+++ llvm/test/CodeGen/RISCV/rvv/inline-asm.ll
@@ -10,7 +10,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -22,7 +22,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -34,7 +34,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -46,7 +46,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -58,7 +58,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -70,7 +70,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -82,7 +82,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vmand.mm $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vmand.mm $0, $1, $2", "=@2vm,@2vm,@2vm"( %in,  %in2)
   ret  %0
 }
 
@@ -94,7 +94,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -106,7 +106,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -118,7 +118,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -130,7 +130,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -142,7 +142,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -154,7 +154,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -166,7 +166,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -178,7 +178,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -190,7 +190,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -202,7 +202,7 @@
 ; CHECK-NEXT:#NO_APP
 ; CHECK-NEXT:ret
 entry:
-  %0 = tail call  asm "vadd.vv $0, $1, $2", "=v,v,v"( %in,  %in2)
+  %0 = tail call  asm "vadd.vv $0, $1, $2", "=@2vr,@2vr,@2vr"( %in,  %in2)
   ret  %0
 }
 
@@ -214,7 +214,7

[PATCH] D107141: [Inline-asm] Add semacheck for unsupported constraint

2021-07-30 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: jyu2, epastor, ABataev, kbsmith1, LuoYuanke.
pengfei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang will crash if we tie a structure with a small size type. This
patch adds check for this case to show the error in user-friendly way.

Note, both GCC and ICC support a more loose constraint that Clang.
https://godbolt.org/z/5ex9x3dvv

I don't find any document about GCC and ICC's behavior and the generated
code doesn't make much sense to me. Besides, if we change "=rm" to "=r"
or "=m", GCC and ICC will report error differently. Which gives me an
impression that the use of constraint is undefined behavior.

So I'd like to simply report error in Clang at present.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107141

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/Sema/asm.c


Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -313,3 +313,23 @@
   asm ("jne %l0":::);
   asm goto ("jne %l0"lab);
 }
+
+// FIXME: GCC and ICC support this case. We may need to follow them.
+typedef struct test19_foo {
+  int a;
+  char b;
+} test19_foo;
+
+typedef struct test19_bar {
+  int a;
+  int b;
+  int c;
+} test19_bar;
+
+void test19()
+{
+  test19_foo a;
+  test19_bar b;
+  asm ("" : "=rm" (a): "0" (1)); // expected-error {{unsupported inline asm: 
input with type 'int' matching output with type 'test19_foo' (aka 'struct 
test19_foo')}}
+  asm ("" : "=rm" (b): "0" (1)); // expected-error {{unsupported inline asm: 
input with type 'int' matching output with type 'test19_bar' (aka 'struct 
test19_bar')}}
+}
Index: clang/lib/Sema/SemaStmtAsm.cpp
===
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -666,7 +666,8 @@
 // output was a register, just extend the shorter one to the size of the
 // larger one.
 if (!SmallerValueMentioned && InputDomain != AD_Other &&
-OutputConstraintInfos[TiedTo].allowsRegister())
+OutputConstraintInfos[TiedTo].allowsRegister() &&
+(OutputDomain != AD_Other || OutSize <= InSize))
   continue;
 
 // Either both of the operands were mentioned or the smaller one was
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2467,7 +2467,8 @@
 // that is usually cheaper, but LLVM IR should really get an anyext 
someday.
 if (Info.hasTiedOperand()) {
   unsigned Output = Info.getTiedOperand();
-  QualType OutputType = S.getOutputExpr(Output)->getType();
+  const Expr *OutputExpr = S.getOutputExpr(Output);
+  QualType OutputType = OutputExpr->getType();
   QualType InputTy = InputExpr->getType();
 
   if (getContext().getTypeSize(OutputType) >
@@ -2480,10 +2481,14 @@
   Arg = Builder.CreateZExt(Arg, OutputTy);
 else if (isa(OutputTy))
   Arg = Builder.CreateZExt(Arg, IntPtrTy);
-else {
-  assert(OutputTy->isFloatingPointTy() && "Unexpected output type");
+else if (OutputTy->isFloatingPointTy())
   Arg = Builder.CreateFPExt(Arg, OutputTy);
-}
+else
+  // FIXME: GCC and ICC can handle structure type that have more than 1
+  // element. We may need to match the same behavior.
+  CGM.getDiags().Report(S.getAsmLoc(), diag::err_asm_invalid_type)
+  << OutputExpr->getType() << 1 /*Output*/
+  << OutputExpr->getSourceRange();
   }
   // Deal with the tied operands' constraint code in adjustInlineAsmType.
   ReplaceConstraint = OutputConstraints[Output];


Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -313,3 +313,23 @@
   asm ("jne %l0":::);
   asm goto ("jne %l0"lab);
 }
+
+// FIXME: GCC and ICC support this case. We may need to follow them.
+typedef struct test19_foo {
+  int a;
+  char b;
+} test19_foo;
+
+typedef struct test19_bar {
+  int a;
+  int b;
+  int c;
+} test19_bar;
+
+void test19()
+{
+  test19_foo a;
+  test19_bar b;
+  asm ("" : "=rm" (a): "0" (1)); // expected-error {{unsupported inline asm: input with type 'int' matching output with type 'test19_foo' (aka 'struct test19_foo')}}
+  asm ("" : "=rm" (b): "0" (1)); // expected-error {{unsupported inline asm: input with type 'int' matching output with type 'test19_bar' (aka 'struct test19_bar')}}
+}
Index: clang/lib/Sema/SemaStmtAsm.cpp
===
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -666,7 +666,8 @@
 // output was a register, just extend the shorter one to the size

[clang] 8eaa05d - [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-30 Thread Dmitry Polukhin via cfe-commits

Author: Ivan Murashko
Date: 2021-07-30T12:40:38+03:00
New Revision: 8eaa05d06161db69e68ff2a5f4c8e3545a4e8080

URL: 
https://github.com/llvm/llvm-project/commit/8eaa05d06161db69e68ff2a5f4c8e3545a4e8080
DIFF: 
https://github.com/llvm/llvm-project/commit/8eaa05d06161db69e68ff2a5f4c8e3545a4e8080.diff

LOG: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

There is a SIGSEGV at `DeduceTemplateArgumentsByTypeMatch`. The bug 
[#51171](https://bugs.llvm.org/show_bug.cgi?id=51171) was filled. The 
reproducer can be found at the bug description.

LIT test for the issue was added:
```
./bin/llvm-lit -v ../clang/test/SemaCXX/pr51171-crash.cpp
```

The debug stack trace is below:
```
 #0 0x055afcb9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x055afd70 PrintStackTraceSignalHandler(void*) 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x055add2d llvm::sys::RunSignalHandlers() 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Signals.cpp:97:20
 #3 0x055af701 SignalHandler(int) 
/home/ivanmurashko/local/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x77bc2b20 __restore_rt sigaction.c:0:0
 #5 0x766a337f raise (/lib64/libc.so.6+0x3737f)
 #6 0x7668ddb5 abort (/lib64/libc.so.6+0x21db5)
 #7 0x7668dc89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #8 0x7669ba76 .annobin___GI___assert_fail.end assert.c:0:0
 #9 0x0594b210 clang::QualType::getCommonPtr() const 
/home/ivanmurashko/local/llvm-project/clang/include/clang/AST/Type.h:684:5
#10 0x05a12ca6 clang::QualType::getCanonicalType() const 
/home/ivanmurashko/local/llvm-project/clang/include/clang/AST/Type.h:6467:36
#11 0x05a137a6 clang::ASTContext::getCanonicalType(clang::QualType) 
const 
/home/ivanmurashko/local/llvm-project/clang/include/clang/AST/ASTContext.h:2433:58
#12 0x09204584 DeduceTemplateArgumentsByTypeMatch(clang::Sema&, 
clang::TemplateParameterList*, clang::QualType, clang::QualType, 
clang::sema::TemplateDeductionInfo&, 
llvm::SmallVectorImpl&, unsigned int, bool, 
bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:1355:54
#13 0x0920df0d 
clang::Sema::DeduceTemplateArguments(clang::FunctionTemplateDecl*, 
clang::TemplateArgumentListInfo*, clang::QualType, clang::FunctionDecl*&, 
clang::sema::TemplateDeductionInfo&, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4354:47
#14 0x09012b09 (anonymous 
namespace)::AddressOfFunctionResolver::AddMatchingTemplateFunction(clang::FunctionTemplateDecl*,
 clang::DeclAccessPair const&) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12026:38
#15 0x09013030 (anonymous 
namespace)::AddressOfFunctionResolver::FindAllFunctionsThatMatchTargetTypeExactly()
 /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12119:9
#16 0x09012679 (anonymous 
namespace)::AddressOfFunctionResolver::AddressOfFunctionResolver(clang::Sema&, 
clang::Expr*, clang::QualType const&, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:11931:5
#17 0x09013c91 
clang::Sema::ResolveAddressOfOverloadedFunction(clang::Expr*, clang::QualType, 
bool, clang::DeclAccessPair&, bool*) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:12286:42
#18 0x08fed85d IsStandardConversion(clang::Sema&, clang::Expr*, 
clang::QualType, bool, clang::StandardConversionSequence&, bool, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:1712:49
#19 0x08fec8ea TryImplicitConversion(clang::Sema&, clang::Expr*, 
clang::QualType, bool, clang::Sema::AllowedExplicit, bool, bool, bool, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:1433:27
#20 0x08ff90ba TryCopyInitialization(clang::Sema&, clang::Expr*, 
clang::QualType, bool, bool, bool, bool) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:5273:71
#21 0x090024fb clang::Sema::AddBuiltinCandidate(clang::QualType*, 
llvm::ArrayRef, clang::OverloadCandidateSet&, bool, unsigned int) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:7755:32
#22 0x0900513f (anonymous 
namespace)::BuiltinOperatorOverloadBuilder::addGenericBinaryArithmeticOverloads()
 /home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:8633:30
#23 0x09007624 
clang::Sema::AddBuiltinOperatorCandidates(clang::OverloadedOperatorKind, 
clang::SourceLocation, llvm::ArrayRef, 
clang::OverloadCandidateSet&) 
/home/ivanmurashko/local/llvm-project/clang/lib/Sema/SemaOverload.cpp:9205:51
#24 0x09018734 
clang::Sema::LookupOverloadedBinOp(clang::OverloadCandidateSet&, 
clang::OverloadedOperatorKind, clang::UnresolvedSetImpl const&, 
llvm::ArrayRef, bool) 
/home/ivanmurashko/local/ll

[PATCH] D106583: [clang] SIGSEGV at DeduceTemplateArgumentsByTypeMatch

2021-07-30 Thread Dmitry Polukhin 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 rG8eaa05d06161: [clang] SIGSEGV at 
DeduceTemplateArgumentsByTypeMatch (authored by ivanmurashko, committed by 
DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106583

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/pr51171-crash.cpp


Index: clang/test/SemaCXX/pr51171-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr51171-crash.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+// Ensure that we don't crash if errors are suppressed by an error limit.
+// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit 1 %s
+
+template 
+struct tv_val {
+};
+
+template 
+auto &val(const tv_val &val) { return val.val(); } // expected-note 
{{possible target for call}}
+
+struct Class {
+  template 
+  struct Entry {
+tv_val val;
+  };
+};
+
+enum Types : int {
+  Class = 1, // expected-note 2 {{struct 'Class' is hidden}}
+};
+
+struct Record {
+  Class *val_;// expected-error {{must use 'struct' tag}}
+  void setClass(Class *); // expected-error {{must use 'struct' tag}}
+};
+
+void Record::setClass(Class *val) { // expected-error {{variable has 
incomplete type 'void'}} \
+   // expected-error {{reference to overloaded 
function}} \
+   // expected-error {{expected ';' after top 
level declarator}}
+  val_ = val;
+}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@
 HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
 unsigned TDF =
 TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
 // Deduce template arguments from the function type.


Index: clang/test/SemaCXX/pr51171-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr51171-crash.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
+
+// Ensure that we don't crash if errors are suppressed by an error limit.
+// RUN: not %clang_cc1 -fsyntax-only -std=c++17 -ferror-limit 1 %s
+
+template 
+struct tv_val {
+};
+
+template 
+auto &val(const tv_val &val) { return val.val(); } // expected-note {{possible target for call}}
+
+struct Class {
+  template 
+  struct Entry {
+tv_val val;
+  };
+};
+
+enum Types : int {
+  Class = 1, // expected-note 2 {{struct 'Class' is hidden}}
+};
+
+struct Record {
+  Class *val_;// expected-error {{must use 'struct' tag}}
+  void setClass(Class *); // expected-error {{must use 'struct' tag}}
+};
+
+void Record::setClass(Class *val) { // expected-error {{variable has incomplete type 'void'}} \
+   // expected-error {{reference to overloaded function}} \
+   // expected-error {{expected ';' after top level declarator}}
+  val_ = val;
+}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4346,7 +4346,7 @@
 HasDeducedReturnType = true;
   }
 
-  if (!ArgFunctionType.isNull()) {
+  if (!ArgFunctionType.isNull() && !FunctionType.isNull()) {
 unsigned TDF =
 TDF_TopLevelParameterTypeList | TDF_AllowCompatibleFunctionType;
 // Deduce template arguments from the function type.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107145: clangd: Add new semantic token modifier "virtual"

2021-07-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is needed for clients that want to highlight virtual functions
differently.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107145

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -642,8 +642,8 @@
 )cpp",
   R"cpp(
   class $Class_decl_abstract[[Abstract]] {
-virtual void $Method_decl_abstract[[pure]]() = 0;
-virtual void $Method_decl[[impl]]();
+virtual void $Method_decl_abstract_virtual[[pure]]() = 0;
+virtual void $Method_decl_virtual[[impl]]();
   };
   )cpp",
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -66,6 +66,7 @@
   Readonly,
   Static,
   Abstract,
+  Virtual,
   DependentName,
   DefaultLibrary,
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -240,6 +240,12 @@
   return false;
 }
 
+bool isVirtual(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isVirtual();
+  return false;
+}
+
 bool isDependent(const Decl *D) {
   if (isa(D))
 return true;
@@ -712,6 +718,8 @@
 Tok.addModifier(HighlightingModifier::Static);
   if (isAbstract(Decl))
 Tok.addModifier(HighlightingModifier::Abstract);
+  if (isVirtual(Decl))
+Tok.addModifier(HighlightingModifier::Virtual);
   if (isDependent(Decl))
 Tok.addModifier(HighlightingModifier::DependentName);
   if (isDefaultLibrary(Decl))
@@ -898,6 +906,8 @@
 return "deduced"; // nonstandard
   case HighlightingModifier::Abstract:
 return "abstract";
+  case HighlightingModifier::Virtual:
+return "virtual";
   case HighlightingModifier::DependentName:
 return "dependentName"; // nonstandard
   case HighlightingModifier::DefaultLibrary:


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -642,8 +642,8 @@
 )cpp",
   R"cpp(
   class $Class_decl_abstract[[Abstract]] {
-virtual void $Method_decl_abstract[[pure]]() = 0;
-virtual void $Method_decl[[impl]]();
+virtual void $Method_decl_abstract_virtual[[pure]]() = 0;
+virtual void $Method_decl_virtual[[impl]]();
   };
   )cpp",
   R"cpp(
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -66,6 +66,7 @@
   Readonly,
   Static,
   Abstract,
+  Virtual,
   DependentName,
   DefaultLibrary,
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -240,6 +240,12 @@
   return false;
 }
 
+bool isVirtual(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isVirtual();
+  return false;
+}
+
 bool isDependent(const Decl *D) {
   if (isa(D))
 return true;
@@ -712,6 +718,8 @@
 Tok.addModifier(HighlightingModifier::Static);
   if (isAbstract(Decl))
 Tok.addModifier(HighlightingModifier::Abstract);
+  if (isVirtual(Decl))
+Tok.addModifier(HighlightingModifier::Virtual);
   if (isDependent(Decl))
 Tok.addModifier(HighlightingModifier::DependentName);
   if (isDefaultLibrary(Decl))
@@ -898,6 +906,8 @@
 return "deduced"; // nonstandard
   case HighlightingModifier::Abstract:
 return "abstract";
+  case HighlightingModifier::Virtual:
+return "virtual";
   case HighlightingModifier::DependentName:
 return "dependentName"; // nonstandard
   case HighlightingModifier::DefaultLibrary:

[PATCH] D107145: clangd: Add new semantic token modifier "virtual"

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

The modifier seems reasonable to me.
The most important cases are callsites (where `virtual`) isn't written. Can you 
extend a test to cover some such case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107145

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-30 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

Passed PSDB


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D107145: clangd: Add new semantic token modifier "virtual"

2021-07-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 363031.
ckandeler added a comment.

Extended test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107145

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -642,9 +642,14 @@
 )cpp",
   R"cpp(
   class $Class_decl_abstract[[Abstract]] {
-virtual void $Method_decl_abstract[[pure]]() = 0;
-virtual void $Method_decl[[impl]]();
+  public:
+virtual void $Method_decl_abstract_virtual[[pure]]() = 0;
+virtual void $Method_decl_virtual[[impl]]();
   };
+  void $Function_decl[[foo]]($Class_abstract[[Abstract]]* 
$Parameter_decl[[A]]) {
+  $Parameter[[A]]->$Method_abstract_virtual[[pure]]();
+  $Parameter[[A]]->$Method_virtual[[impl]]();
+  }
   )cpp",
   R"cpp(
   <:[deprecated]:> int $Variable_decl_deprecated[[x]];
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -66,6 +66,7 @@
   Readonly,
   Static,
   Abstract,
+  Virtual,
   DependentName,
   DefaultLibrary,
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -240,6 +240,12 @@
   return false;
 }
 
+bool isVirtual(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isVirtual();
+  return false;
+}
+
 bool isDependent(const Decl *D) {
   if (isa(D))
 return true;
@@ -712,6 +718,8 @@
 Tok.addModifier(HighlightingModifier::Static);
   if (isAbstract(Decl))
 Tok.addModifier(HighlightingModifier::Abstract);
+  if (isVirtual(Decl))
+Tok.addModifier(HighlightingModifier::Virtual);
   if (isDependent(Decl))
 Tok.addModifier(HighlightingModifier::DependentName);
   if (isDefaultLibrary(Decl))
@@ -898,6 +906,8 @@
 return "deduced"; // nonstandard
   case HighlightingModifier::Abstract:
 return "abstract";
+  case HighlightingModifier::Virtual:
+return "virtual";
   case HighlightingModifier::DependentName:
 return "dependentName"; // nonstandard
   case HighlightingModifier::DefaultLibrary:


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -642,9 +642,14 @@
 )cpp",
   R"cpp(
   class $Class_decl_abstract[[Abstract]] {
-virtual void $Method_decl_abstract[[pure]]() = 0;
-virtual void $Method_decl[[impl]]();
+  public:
+virtual void $Method_decl_abstract_virtual[[pure]]() = 0;
+virtual void $Method_decl_virtual[[impl]]();
   };
+  void $Function_decl[[foo]]($Class_abstract[[Abstract]]* $Parameter_decl[[A]]) {
+  $Parameter[[A]]->$Method_abstract_virtual[[pure]]();
+  $Parameter[[A]]->$Method_virtual[[impl]]();
+  }
   )cpp",
   R"cpp(
   <:[deprecated]:> int $Variable_decl_deprecated[[x]];
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -66,6 +66,7 @@
   Readonly,
   Static,
   Abstract,
+  Virtual,
   DependentName,
   DefaultLibrary,
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -240,6 +240,12 @@
   return false;
 }
 
+bool isVirtual(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isVirtual();
+  return false;
+}
+
 bool isDependent(const Decl *D) {
   if (isa(D))
 return true;
@@ -712,6 +718,8 @@
 Tok.addModifier(HighlightingModifier::Static);
   if (isAbstract(Decl))
 Tok.addModifier(HighlightingModifier::Abstract);
+  if (isVirtual(Decl))
+Tok.addModifier(HighlightingModifier::Virtual);
   if (isDependent(Decl))
 Tok.addModifier(HighlightingModifier::DependentName);
   if (isDe

[PATCH] D107026: [Clang] Add support for attribute 'escape'

2021-07-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> The attribute will first be used by the Swift compiler in a new implicit 
> bridging diagnostic, but may have other non-Swift use-cases for diagnostics.

This means there's no use of this attribute within Clang which suggests to me 
that this attribute belongs in the Swift compiler until there's a reason to 
upstream it. Or are you planning on using this attribute within Clang in the 
Very Near Future?




Comment at: clang/include/clang/Basic/Attr.td:1957
+}
+
 def AssumeAligned : InheritableAttr {

You should define these attributes as being mutually exclusive; e.g.,
```
def : MutualExclusions<[Escape, NoEscape]>;
```



Comment at: clang/include/clang/Basic/AttrDocs.td:260
+``escape`` placed on a function parameter of a pointer type is used to indicate
+that the pointer can escape the function. This means that a reference to the 
object
+the pointer points to that is derived from the parameter value may survive

guitard0g wrote:
> NoQ wrote:
> > Are you sure you want "can escape" instead of "will escape"? In the former 
> > case it's impossible to implement the warning without false positives 
> > ("well, it says it may escape, but I know for sure that if I pass these 
> > other arguments then it won't escape"). In the latter case, of course, a 
> > lot of places where the value escapes conditionally won't be able to wear 
> > the attribute. Do I understand correctly that you want to proceed with the 
> > more aggressive diagnostic?
> Hmm that's an interesting question. Initially my thought was that any 
> possibility of escaping should eliminate the option of passing in a temporary 
> pointer, which I think is reasonable in Swift's implicit bridging use-case. 
> In terms of the API contract, I was thinking that any API author who 
> annotates their function parameter with 'escaping' is effectively saying you 
> shouldn't pass in a pointer that you're not comfortable escaping. I think it 
> may be a little restrictive to say that the pointer will always escape for 
> certain, but I do think that anybody using a function that takes an escaping 
> parameter should treat this as if it were always escaping (if that makes 
> sense). I suppose my question then would be, do you think it's better to say 
> "will escape" if that's what the client calling into an API should expect 
> (even though the pointer might not always escape in the implementation)? 
> ``escape`` placed on a function parameter of a pointer type is used to 
> indicate that the pointer can escape the function.

FWIW, this reads a bit strangely to me because that's already the case without 
the attribute. Anything that's not marked *can* escape. I think "will escape" 
more clearly identifies to the person reading the function signature that the 
parameter should be treated as though it will escape. If it does not escape, 
that's not necessarily an issue because that shouldn't change how the user 
treats the argument (for example, it may not escape today but it may start to 
escape in the future).

One thing the docs are missing is an explanation of what benefit you get from 
using this annotation. Does this improve optimizations? Enable better checking 
somewhere? That sort of thing (with examples) would be good to add.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:1568
 
-  D->addAttr(::new (S.Context) NoEscapeAttr(S.Context, AL));
+  switch (AL.getKind()) {
+  default:

This should be handled directly from Attr.td, I'll put some comments in there.



Comment at: clang/test/SemaObjCXX/escape.mm:1-2
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=c++1z %s
+

I don't see any use of blocks, so I don't think you need `-fblocks`. I think 
you can also remove the C++11 RUN line as it doesn't really add any test 
coverage.



Comment at: clang/test/SemaObjCXX/escape.mm:24
+// expected-note {{conflicting attribute is here}}
+void invalidFunc5(__attribute__((noescape)) __attribute__((escape)) int *); // 
expected-error {{'escape' and 'noescape' attributes are not compatible}} \
+// expected-note {{conflicting attribute is here}}

Can you also add test coverage for the more likely case of inheriting mutually 
exclusive attributes? e.g.,
```
void foo() __attribute__((escape));
void foo() __attribute__((noescape));

void bar() __attribute__((noescape));
void bar() __attribute__((escape));
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107026

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


[PATCH] D107151: [OpenCL] Reduce duplicate defs by using multiclasses; NFC

2021-07-30 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
svenvh added a project: clang.
Herald added subscribers: ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Builtin definitions with pointer arguments were duplicated to provide
overloads differing in the pointer argument's address space.

Reduce this duplication by capturing the definitions in multiclasses.
This still results in the same number of builtins in the generated
tables, but the description is more concise now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107151

Files:
  clang/lib/Sema/OpenCLBuiltins.td

Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -543,9 +543,10 @@
   def : Builtin;
 }
 
-// --- Version dependent ---
-let MaxVersion = CL20 in {
-  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+// The following math builtins take pointer arguments.  Which overloads are
+// available depends on whether the generic address space feature is enabled.
+multiclass MathWithPointer addrspaces> {
+  foreach AS = addrspaces in {
 foreach name = ["fract", "modf", "sincos"] in {
   def : Builtin]>;
 }
@@ -561,19 +562,12 @@
 }
   }
 }
+
+let MaxVersion = CL20 in {
+  defm : MathWithPointer<[GlobalAS, LocalAS, PrivateAS]>;
+}
 let MinVersion = CL20 in {
-  foreach name = ["fract", "modf", "sincos"] in {
-def : Builtin]>;
-  }
-  foreach name = ["frexp", "lgamma_r"] in {
-foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
-  def : Builtin]>;
-}  }
-  foreach name = ["remquo"] in {
-foreach Type = [GenTypeFloatVecAndScalar, GenTypeDoubleVecAndScalar, GenTypeHalfVecAndScalar] in {
-  def : Builtin]>;
-}
-  }
+  defm : MathWithPointer<[GenericAS]>;
 }
 
 // --- Table 9 ---
@@ -783,10 +777,8 @@
 // OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions
 // OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s5.1.6 and s6.1.6 - Vector Data Load and Store Functions
 // --- Table 15 ---
-// Variants for OpenCL versions below 2.0, using pointers to the global, local
-// and private address spaces.
-let MaxVersion = CL20 in {
-  foreach AS = [GlobalAS, LocalAS, PrivateAS] in {
+multiclass VloadVstore addrspaces, bit defStores> {
+  foreach AS = addrspaces in {
 foreach VSize = [2, 3, 4, 8, 16] in {
   foreach name = ["vload" # VSize] in {
 def : Builtin, Size, PointerType, AS>]>;
@@ -801,116 +793,45 @@
 def : Builtin, Size, PointerType, AS>]>;
 def : Builtin, Size, PointerType, AS>]>;
   }
-  foreach name = ["vstore" # VSize] in {
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-def : Builtin, Size, PointerType]>;
-  }
   foreach name = ["vloada_half" # VSize] in {
 def : Builtin, Size, PointerType, AS>]>;
   }
-  foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
-foreach name = ["vstorea_half" # VSize # rnd] in {
-  def : Builtin, Size, PointerType]>;
-  def : Builtin, Size, PointerType]>;
+  if defStores then {
+foreach name = ["vstore" # VSize] in {
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+  def : Builtin, Size, PointerType]>;
+}
+foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in {
+  foreach name = ["vstorea_half" # VSize # rnd] in {
+def : Builtin, Size, PointerType]>;
+def : Builtin, Size, PointerType]>;
+  }
 }
   }
 }
   }
 }
-// Variants for OpenCL versions above 2.0, using pointers to the generic
-// address space.
-let MinVersion = CL20 in {
-  foreach VSize = [2, 3, 4, 8, 16] in {
-foreach name = ["vload" # VSize] in {
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-  def : Builtin, Size, PointerType, GenericAS>]>;
-

[PATCH] D106862: [clang][modules] Avoid creating partial FullSourceLoc for explicit modules imports

2021-07-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 363033.
jansvoboda11 edited the summary of this revision.
jansvoboda11 added a comment.

Remove assertion altogether.


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

https://reviews.llvm.org/D106862

Files:
  clang/include/clang/Basic/SourceLocation.h
  clang/test/Modules/Inputs/explicit-build-diags/a.h
  clang/test/Modules/Inputs/explicit-build-diags/module.modulemap
  clang/test/Modules/explicit-build-diags.cpp


Index: clang/test/Modules/explicit-build-diags.cpp
===
--- /dev/null
+++ clang/test/Modules/explicit-build-diags.cpp
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -fmodules -x c++ 
%S/Inputs/explicit-build-diags/module.modulemap -fmodule-name=a -emit-module -o 
%t/a.pcm
+// RUN: %clang_cc1 -fmodules -Wdeprecated-declarations 
-fdiagnostics-show-note-include-stack -serialize-diagnostic-file %t/tu.dia \
+// RUN:   -I %S/Inputs/explicit-build-diags -fmodule-file=%t/a.pcm 
-fsyntax-only %s
+
+#include "a.h"
+
+void foo() { a(); }
Index: clang/test/Modules/Inputs/explicit-build-diags/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/explicit-build-diags/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" }
Index: clang/test/Modules/Inputs/explicit-build-diags/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/explicit-build-diags/a.h
@@ -0,0 +1 @@
+void a() __attribute__((deprecated));
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -363,6 +363,10 @@
 /// A SourceLocation and its associated SourceManager.
 ///
 /// This is useful for argument passing to functions that expect both objects.
+///
+/// This class does not guarantee the presence of either the SourceManager or
+/// a valid SourceLocation. Clients should use `isValid()` and `hasManager()`
+/// before calling the member functions.
 class FullSourceLoc : public SourceLocation {
   const SourceManager *SrcMgr = nullptr;
 
@@ -373,13 +377,10 @@
   explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
   : SourceLocation(Loc), SrcMgr(&SM) {}
 
-  bool hasManager() const {
-  bool hasSrcMgr =  SrcMgr != nullptr;
-  assert(hasSrcMgr == isValid() && "FullSourceLoc has location but no 
manager");
-  return hasSrcMgr;
-  }
+  /// Checks whether the SourceManager is present.
+  bool hasManager() const { return SrcMgr != nullptr; }
 
-  /// \pre This FullSourceLoc has an associated SourceManager.
+  /// \pre hasManager()
   const SourceManager &getManager() const {
 assert(SrcMgr && "SourceManager is NULL.");
 return *SrcMgr;


Index: clang/test/Modules/explicit-build-diags.cpp
===
--- /dev/null
+++ clang/test/Modules/explicit-build-diags.cpp
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -fmodules -x c++ %S/Inputs/explicit-build-diags/module.modulemap -fmodule-name=a -emit-module -o %t/a.pcm
+// RUN: %clang_cc1 -fmodules -Wdeprecated-declarations -fdiagnostics-show-note-include-stack -serialize-diagnostic-file %t/tu.dia \
+// RUN:   -I %S/Inputs/explicit-build-diags -fmodule-file=%t/a.pcm -fsyntax-only %s
+
+#include "a.h"
+
+void foo() { a(); }
Index: clang/test/Modules/Inputs/explicit-build-diags/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/explicit-build-diags/module.modulemap
@@ -0,0 +1 @@
+module a { header "a.h" }
Index: clang/test/Modules/Inputs/explicit-build-diags/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/explicit-build-diags/a.h
@@ -0,0 +1 @@
+void a() __attribute__((deprecated));
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -363,6 +363,10 @@
 /// A SourceLocation and its associated SourceManager.
 ///
 /// This is useful for argument passing to functions that expect both objects.
+///
+/// This class does not guarantee the presence of either the SourceManager or
+/// a valid SourceLocation. Clients should use `isValid()` and `hasManager()`
+/// before calling the member functions.
 class FullSourceLoc : public SourceLocation {
   const SourceManager *SrcMgr = nullptr;
 
@@ -373,13 +377,10 @@
   explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
   : SourceLocation(Loc), SrcMgr(&SM) {}
 
-  bool hasManager() const {
-  bool hasSrcMgr =  SrcMgr != nullptr;
-  assert(hasSrcMgr == isValid() && "FullSourceLoc has locatio

[PATCH] D106862: [clang][modules] Avoid creating partial FullSourceLoc for explicit modules imports

2021-07-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 requested review of this revision.
jansvoboda11 added a comment.

I investigated this a bit more.

What previously lead me to believe that `SourceLoc::ID` is being modified from 
the outside was the way it's declared right after some `friend`s:

  class SourceLocation {
friend class ASTReader;
friend class ASTWriter;
friend class SourceManager;
friend struct llvm::FoldingSetTrait;
  
  public:
using UIntTy = uint32_t;
using IntTy = int32_t;
  
  private:
UIntTy ID = 0;

I looked up the actual writes to `ID` and they only occur in the 
`SourceLocation` factory functions, for example:

  SourceLocation getLocWithOffset(IntTy Offset) const {
assert(((getOffset()+Offset) & MacroIDBit) == 0 && "offset overflow");
SourceLocation L;
L.ID = ID+Offset;
return L;
  }

Theoretically there's nothing preventing the friends from modifying the field 
as well, but that's not being abused at this moment.

This means that if the `FullSourceLoc(SourceLocation, SourceManager &)` 
constructor was to be called with an invalid `SourceLocation`, it would stay 
invalid for the whole lifetime of `FullSourceLoc`.

---

So if we really expect  
`FullSourceLoc` to always uphold this invariant: `(SrcMgr != nullptr) == 
isValid()`, we should be able to replace this assertion:

  bool hasManager() const {
  bool hasSrcMgr =  SrcMgr != nullptr;
  assert(hasSrcMgr == isValid() && "FullSourceLoc has location but no 
manager");
  return hasSrcMgr;
  }

with this one:

  explicit FullSourceLoc(SourceLocation Loc, const SourceManager &SM)
  : SourceLocation(Loc), SrcMgr(&SM) {
assert(isValid() && "FullSourceLoc has manager but no location");
  }

That way, we can catch any future misuse of `FullSourceLoc` much earlier.

---

But: I think the intention for `FullSourceLoc` has never been to uphold that 
invariant:

- `FullSourceLoc` is being constructed without clients ensuring the validity of 
the `SourceLoc`.
  - Moving the assertion into the constructor and running tests confirmed 
`FullSourceLoc` is indeed being constructed with invalid `SourceLocation` (and 
valid `SourceManager`).
- The clients also never check `isValid()` before calling `hasManager()` to 
avoid the assertion in `hasManager()`, which is odd.
  - I think the assertion in `hasManager` has never been hit before simply by 
pure luck.

---

Considering that `FullSourceLoc` has been around since 2007 and the assertion 
was just added in 2017, I think the correct thing to do here is to remove the 
assertion and properly document that `FullSourceLoc` does not uphold any 
invariants.


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

https://reviews.llvm.org/D106862

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


[PATCH] D107130: [clangd] Enable relative configs in check mode

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/tool/Check.cpp:275
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(File));
   Checker C(File, Opts);

Only if FakeFile.empty() - we shouldn't take the arbitrary temp path into 
account


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107130

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


[PATCH] D106934: [clangd] Do not inlay hints pertaining to code in other files

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:320
+// file that was included after the preamble), do not show in that case.
+if (AST.getSourceManager().getFileID(FileRange->getBegin()) != MainFileID)
+  return;

nit: getSourceManager().isWrittenInMainFile(FileRange->getBegin())


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106934

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


[PATCH] D107040: [clangd] Make use of diagnostic tags for some clang diags

2021-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 363038.
kadircet added a comment.

- Fix base


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107040

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -65,6 +65,11 @@
   return Field(&Diag::Notes, UnorderedElementsAre(NoteMatcher1, NoteMatcher2));
 }
 
+::testing::Matcher
+WithTag(::testing::Matcher TagMatcher) {
+  return Field(&Diag::Tags, Contains(TagMatcher));
+}
+
 MATCHER_P2(Diag, Range, Message,
"Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
   return arg.Range == Range && arg.Message == Message;
@@ -665,6 +670,7 @@
 
   clangd::Diag D;
   D.ID = clang::diag::err_undeclared_var_use;
+  D.Tags = {DiagnosticTag::Unnecessary};
   D.Name = "undeclared_var_use";
   D.Source = clangd::Diag::Clang;
   D.Message = "something terrible happened";
@@ -710,6 +716,7 @@
 
 ../foo/baz/header.h:10:11:
 note: declared somewhere in the header file)";
+  MainLSP.tags = {DiagnosticTag::Unnecessary};
 
   clangd::Diagnostic NoteInMainLSP;
   NoteInMainLSP.range = NoteInMain.Range;
@@ -1419,6 +1426,24 @@
 testing::Contains(Diag(Code.range(), "no newline at end of file")));
   }
 }
+
+TEST(Diagnostics, Tags) {
+  TestTU TU;
+  TU.ExtraArgs = {"-Wunused", "-Wdeprecated"};
+  Annotations Test(R"cpp(
+  void bar() __attribute__((deprecated));
+  void foo() {
+int $unused[[x]];
+$deprecated[[bar]]();
+  })cpp");
+  TU.Code = Test.code().str();
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unused"), "unused variable 'x'"),
+WithTag(DiagnosticTag::Unnecessary)),
+  AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
+WithTag(DiagnosticTag::Deprecated;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -811,6 +811,19 @@
 };
 llvm::json::Value toJSON(const DiagnosticRelatedInformation &);
 
+enum DiagnosticTag {
+  /// Unused or unnecessary code.
+  ///
+  /// Clients are allowed to render diagnostics with this tag faded out instead
+  /// of having an error squiggle.
+  Unnecessary = 1,
+  /// Deprecated or obsolete code.
+  ///
+  /// Clients are allowed to rendered diagnostics with this tag strike through.
+  Deprecated = 2,
+};
+llvm::json::Value toJSON(DiagnosticTag Tag);
+
 struct CodeAction;
 struct Diagnostic {
   /// The range at which the message applies.
@@ -830,6 +843,9 @@
   /// The diagnostic's message.
   std::string message;
 
+  /// Additional metadata about the diagnostic.
+  std::vector tags;
+
   /// An array of related diagnostic information, e.g. when symbol-names within
   /// a scope collide all definitions can be marked via this property.
   llvm::Optional> relatedInformation;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -602,6 +602,8 @@
 Diag["relatedInformation"] = *D.relatedInformation;
   if (!D.data.empty())
 Diag["data"] = llvm::json::Object(D.data);
+  if (!D.tags.empty())
+Diag["tags"] = D.tags;
   // FIXME: workaround for older gcc/clang
   return std::move(Diag);
 }
@@ -1450,5 +1452,6 @@
   return OS;
 }
 
+llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast(Tag); }
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -106,6 +106,7 @@
   std::vector Notes;
   /// *Alternative* fixes for this diagnostic, one should be chosen.
   std::vector Fixes;
+  std::vector Tags;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diag &D);
 
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Ca

[PATCH] D107130: [clangd] Enable relative configs in check mode

2021-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 363040.
kadircet marked an inline comment as done.
kadircet added a comment.

- Don't use local configs for temp files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107130

Files:
  clang-tools-extra/clangd/test/check-fail.test
  clang-tools-extra/clangd/test/check-lines.test
  clang-tools-extra/clangd/test/check.test
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,10 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(
+  FakeFile.empty()
+  ? File
+  : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace 
%s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck 
-strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck 
-strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | 
FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | 
FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- clang-tools-extra/clangd/test/check-fail.test
+++ clang-tools-extra/clangd/test/check-fail.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-fail.test
 // CHECK: internal (cc1) args are: -cc1


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,10 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(
+  FakeFile.empty()
+  ? File
+  : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- clang-tools-extra/clangd/test/check

[PATCH] D107040: [clangd] Make use of diagnostic tags for some clang diags

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:330
+
+std::vector getDiagnosticTags(unsigned DiagID) {
+  static const llvm::DenseSet DeprecatedDiags = {

I think it might be nicer if this took a clangd::Diag& and added the tags to 
it, then we could naturally group the clang-tidy list along with the main clang 
diag list (I don't think having them separately serves anyone well)



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:331
+std::vector getDiagnosticTags(unsigned DiagID) {
+  static const llvm::DenseSet DeprecatedDiags = {
+  diag::warn_access_decl_deprecated,

nit: static const auto& DeprecatedDiags = *new llvm::DenseSet{...

This suppresses destruction



Comment at: clang-tools-extra/clangd/Diagnostics.h:109
   std::vector Fixes;
+  std::vector Tags;
 };

Maybe SmallVector or even Optional since this is 0-1 integers in practice?



Comment at: clang-tools-extra/clangd/Protocol.cpp:1455
 
+llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast(Tag); }
 } // namespace clangd

keep ordering consistent with the header? so before Diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107040

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


[PATCH] D106934: [clangd] Do not inlay hints pertaining to code in other files

2021-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:320
+// file that was included after the preamble), do not show in that case.
+if (AST.getSourceManager().getFileID(FileRange->getBegin()) != MainFileID)
+  return;

sammccall wrote:
> nit: getSourceManager().isWrittenInMainFile(FileRange->getBegin())
double nit: `isInsideMainFile(Loc, SM)`, I presume we would like to keep hints 
in preamble section as well (even though it is unlikely that we'll have any)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106934

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


[clang-tools-extra] c3682a2 - [clangd] Enable relative configs in check mode

2021-07-30 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-07-30T14:23:48+02:00
New Revision: c3682a22c227652558764c67a2529399c59e58e6

URL: 
https://github.com/llvm/llvm-project/commit/c3682a22c227652558764c67a2529399c59e58e6
DIFF: 
https://github.com/llvm/llvm-project/commit/c3682a22c227652558764c67a2529399c59e58e6.diff

LOG: [clangd] Enable relative configs in check mode

See https://github.com/clangd/clangd/issues/649#issuecomment-885903316.
Also disables config support in lit tests to make sure tests are not affected by
clangd config files lying around.

Differential Revision: https://reviews.llvm.org/D107130

Added: 


Modified: 
clang-tools-extra/clangd/test/check-fail.test
clang-tools-extra/clangd/test/check-lines.test
clang-tools-extra/clangd/test/check.test
clang-tools-extra/clangd/tool/Check.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/test/check-fail.test 
b/clang-tools-extra/clangd/test/check-fail.test
index dd50b59b2c790..5a370b4653b1c 100644
--- a/clang-tools-extra/clangd/test/check-fail.test
+++ b/clang-tools-extra/clangd/test/check-fail.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-fail.test
 // CHECK: internal (cc1) args are: -cc1

diff  --git a/clang-tools-extra/clangd/test/check-lines.test 
b/clang-tools-extra/clangd/test/check-lines.test
index bfd30dd6104ff..4e8509869d8f9 100644
--- a/clang-tools-extra/clangd/test/check-lines.test
+++ b/clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck 
-strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck 
-strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | 
FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | 
FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1

diff  --git a/clang-tools-extra/clangd/test/check.test 
b/clang-tools-extra/clangd/test/check.test
index d83562c4dcf00..280e01ef0a044 100644
--- a/clang-tools-extra/clangd/test/check.test
+++ b/clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace 
%s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1

diff  --git a/clang-tools-extra/clangd/tool/Check.cpp 
b/clang-tools-extra/clangd/tool/Check.cpp
index 88eb945d20d43..6672b7d968de8 100644
--- a/clang-tools-extra/clangd/tool/Check.cpp
+++ b/clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,10 @@ bool check(llvm::StringRef File,
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(
+  FakeFile.empty()
+  ? File
+  : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())



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


[PATCH] D107130: [clangd] Enable relative configs in check mode

2021-07-30 Thread Kadir Cetinkaya 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 rGc3682a22c227: [clangd] Enable relative configs in check mode 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107130

Files:
  clang-tools-extra/clangd/test/check-fail.test
  clang-tools-extra/clangd/test/check-lines.test
  clang-tools-extra/clangd/test/check.test
  clang-tools-extra/clangd/tool/Check.cpp


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,10 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(
+  FakeFile.empty()
+  ? File
+  : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace 
%s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck 
-strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck 
-strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | 
FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | 
FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===
--- clang-tools-extra/clangd/test/check-fail.test
+++ clang-tools-extra/clangd/test/check-fail.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp 2>&1 | FileCheck 
-strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-fail.test
 // CHECK: internal (cc1) args are: -cc1


Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -272,7 +272,10 @@
 
   auto ContextProvider = ClangdServer::createConfiguredContextProvider(
   Opts.ConfigProvider, nullptr);
-  WithContext Ctx(ContextProvider(""));
+  WithContext Ctx(ContextProvider(
+  FakeFile.empty()
+  ? File
+  : /*Don't turn on local configs for an arbitrary temp path.*/ ""));
   Checker C(File, Opts);
   if (!C.buildCommand(TFS) || !C.buildInvocation(TFS, Contents) ||
   !C.buildAST())
Index: clang-tools-extra/clangd/test/check.test
===
--- clang-tools-extra/clangd/test/check.test
+++ clang-tools-extra/clangd/test/check.test
@@ -1,5 +1,5 @@
 // RUN: cp %s %t.cpp
-// RUN: clangd -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+// RUN: clangd -enable-config=0 -log=verbose -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-lines.test
===
--- clang-tools-extra/clangd/test/check-lines.test
+++ clang-tools-extra/clangd/test/check-lines.test
@@ -1,6 +1,6 @@
 // RUN: cp %s %t.cpp
-// RUN: not clangd -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
-// RUN: not clangd -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=6-14 2>&1 | FileCheck -strict-whitespace %s
+// RUN: not clangd -enable-config=0 -check=%t.cpp -check-lines=14 2>&1 | FileCheck -strict-whitespace %s
 
 // CHECK: Testing on source file {{.*}}check-lines.test
 // CHECK: internal (cc1) args are: -cc1
Index: clang-tools-extra/clangd/test/check-fail.test
===

[PATCH] D107154: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-30 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov created this revision.
azabaznov added reviewers: Anastasia, svenvh.
Herald added subscribers: ldrumm, dexonsmith, yaxunl.
azabaznov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version 
while
parsing and then later on check for language options to construct actual pipe. 
This feature
requires support of __opencl_c_generic_address_space, so diagnostics for that 
is provided as well.

This is the same patch as in D106748  but 
with a tiny fix in checking of diagnostic messages.
Also added tests when program scope global variables are not supported.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107154

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_builtin.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error-re{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}} expected-error{{'write_only' attribute only applies to parameters and typedefs}}
+extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_program_scope_global_variables))
+// expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
+#else
+// FIXME: '__private' here makes no sense since program scope variables feature is not supported, should diagnose as '__global' probably
+// expected-error-re@-5{{type '__private write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
+#endif
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'__private reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang

[PATCH] D107137: clangd: Provide hover info for include directives

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this is great! I think we need to hold the line a bit on keeping 
different hovers uniform though.




Comment at: clang-tools-extra/clangd/Hover.cpp:914
+  HoverInfo HI;
+  HI.TargetFile = File->Definition;
+  return HI;

A HoverInfo with no name and no kind is a bit of a problem.

For the markdown rendering you're bailing out with a special case, which works 
but makes the layout inconsistent with other hovers. It's also harder to reason 
about the code when many kinds of symbols take different codepaths, which is 
one of the reasons we'd unified it.
We also have other clients of the C++ API that rely on name and preferably kind 
being present.

What about making `Name` the basename e.g. `foo.h` for `#include 
"project/foo.h"`

For Kind, there's no perfect Kind (using Module seems too confusing) and we 
can't easily extend the enum since we don't own it (we should fix this 
sometime...). Maybe just a FIXME there.

For the full path, it would be more consistent to store this in Definition if 
we can.
Only problem is Definition is a code block syntax-highlighted as C++. Quoting 
it will cause problems on windows (ugly escaped backslashes).
So I'd suggest adding `const char* DefinitionLanguage = "cpp"` to HoverInfo, 
and overriding it here. (And passing it through to codeBlock in present()).



Comment at: clang-tools-extra/clangd/XRefs.cpp:537
 
+llvm::Optional locateFileReferent(const Position &Pos,
+ ParsedAST &AST,

This function is pretty simple and we don't use most of the result for hover.
Rather than making it public (and testing it!) and depending from hover->xrefs, 
can we just copy the needed bits into hover.cpp?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107137

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


[PATCH] D107154: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-30 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 363044.
azabaznov added a comment.

Fix doubling run lines, misprint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107154

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_builtin.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error-re{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}} expected-error{{'write_only' attribute only applies to parameters and typedefs}}
+extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_program_scope_global_variables))
+// expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
+#else
+// FIXME: '__private' here makes no sense since program scope variables feature is not supported, should diagnose as '__global' probably
+// expected-error-re@-5{{type '__private write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
+#endif
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'__private reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
-// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
-// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-3 {{expected ')'}} expected-note@-3 {{to match this '('}}
+#if __OPENCL_C_VERSION__ > 120
+/

[PATCH] D106669: [clangd] Unify compiler invocation creation

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Compiler.h:64
 
+/// Clears \p CI from options that are not supported by clangd, like codegen or
+/// plugins.

Comment is good, but call this disableUnsupportedOptions?
(We're in namespace clangd already)



Comment at: clang-tools-extra/clangd/Compiler.h:64
 
+/// Clears \p CI from options that are not supported by clangd, like codegen or
+/// plugins.

sammccall wrote:
> Comment is good, but call this disableUnsupportedOptions?
> (We're in namespace clangd already)
This should also probably have a comment about being paired with 
CommandMangler, as that provides similar functionality that just happens to be 
best expressed on the command instead (e.g. stripping --save-temps) 



Comment at: clang-tools-extra/clangd/test/indexer.test:3
+# RUN: touch %t.cpp
+# RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | 
FileCheck %s
+# CHECK-NOT: error: no expected directives found: consider use of 
'expected-no-diagnostics'

Add a comment (or rename test file) saying what functionality this is trying to 
test? it's not obvious


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106669

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


[PATCH] D107138: [PowerPC] Implement cmplxl builtins

2021-07-30 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Basic/BuiltinsPPC.def:146
 BUILTIN(__builtin_ppc_stfiw, "viC*d", "")
+BUILTIN(__builtin_ppc_cmplxl, "XLdLdLd", "")
 

Please remove this. The preprocessor will replace this and the builtin call 
will never make it to the front end.



Comment at: clang/lib/Basic/Targets/PPC.cpp:238
   Builder.defineMacro("__fsqrts", "__builtin_ppc_fsqrts");
+  Builder.defineMacro("__builtin_ppc_cmplxl", "__builtin_complex");
+  Builder.defineMacro("__cmplxl", "__builtin_complex");

I don't see a compelling reason to have this. Users that want this 
functionality in new code (that doesn't already use `__cmplxl`) can simply use 
`__builtin_complex`.



Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-complex.c:45
+  // CHECK-AIX-NEXT: ret { double, double } %.fca.1.insert
+  return __cmplxl(lda, ldb);
+}

We really only need this test case and we should be able to just add it to one 
of the existing XL-compat clang test cases.



Comment at: 
llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex-32bit-only.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \

I don't think we need the back end tests. No new IR is produced in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107138

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


[PATCH] D107155: [clang][deps] Substitute clang-scan-deps executable in lit tests

2021-07-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman, lxfind.
jansvoboda11 added a project: clang.
jansvoboda11 requested review of this revision.

The lit tests for `clang-scan-deps` invoke the tool without going through the 
substitution system. While the test runner correctly picks up the 
`clang-scan-deps` binary from the build directory, it doesn't print its 
absolute path. When copying the invocations when reproducing test failures, 
this can result in `command not found: clang-scan-deps` errors or worse yet: 
pick up the system `clang-scan-deps`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107155

Files:
  clang/test/ClangScanDeps/has_include_if_elif.cpp
  clang/test/ClangScanDeps/header_stat_before_open.m
  clang/test/ClangScanDeps/headerwithdirname.cpp
  clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
  clang/test/ClangScanDeps/lit.local.cfg
  clang/test/ClangScanDeps/modules-fmodule-name-no-module-built.m
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m
  clang/test/ClangScanDeps/modules-pch.c
  clang/test/ClangScanDeps/modules.cpp
  clang/test/ClangScanDeps/no-werror.cpp
  clang/test/ClangScanDeps/preserved-args.c
  clang/test/ClangScanDeps/regular_cdb.cpp
  clang/test/ClangScanDeps/relative_directory.cpp
  clang/test/ClangScanDeps/static-analyzer.c
  clang/test/ClangScanDeps/strip_diag_serialize.cpp
  clang/test/ClangScanDeps/subframework_header_dir_symlink.m
  clang/test/ClangScanDeps/symlink.cpp
  clang/test/ClangScanDeps/target-filename.cpp
  clang/test/ClangScanDeps/vfsoverlay.cpp

Index: clang/test/ClangScanDeps/vfsoverlay.cpp
===
--- clang/test/ClangScanDeps/vfsoverlay.cpp
+++ clang/test/ClangScanDeps/vfsoverlay.cpp
@@ -8,7 +8,7 @@
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/vfsoverlay_cdb.json > %t.cdb
 //
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | \
+// RUN: %clang-scan-deps -compilation-database %t.cdb -j 1 | \
 // RUN:   FileCheck %s
 
 #include "not_real.h"
Index: clang/test/ClangScanDeps/target-filename.cpp
===
--- clang/test/ClangScanDeps/target-filename.cpp
+++ clang/test/ClangScanDeps/target-filename.cpp
@@ -5,7 +5,7 @@
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/target-filename-cdb.json > %t.cdb
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
+// RUN: %clang-scan-deps -compilation-database %t.cdb -j 1 | FileCheck %s
 
 // CHECK: target-filename_input.o:
 // CHECK-NEXT: target-filename_input.cpp
Index: clang/test/ClangScanDeps/symlink.cpp
===
--- clang/test/ClangScanDeps/symlink.cpp
+++ clang/test/ClangScanDeps/symlink.cpp
@@ -8,8 +8,8 @@
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
 // RUN: ln -s %t.dir/Inputs/header.h %t.dir/Inputs/symlink.h
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/symlink_cdb.json > %t.cdb
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=0 | FileCheck %s
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=1 | FileCheck %s
+// RUN: %clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=0 | FileCheck %s
+// RUN: %clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=1 | FileCheck %s
 
 #include "symlink.h"
 #include "header.h"
Index: clang/test/ClangScanDeps/subframework_header_dir_symlink.m
===
--- clang/test/ClangScanDeps/subframework_header_dir_symlink.m
+++ clang/test/ClangScanDeps/subframework_header_dir_symlink.m
@@ -8,9 +8,9 @@
 // RUN: cp -R %S/Inputs/frameworks %t.dir/Inputs/frameworks
 // RUN: ln -s %t.dir/Inputs/frameworks %t.dir/Inputs/frameworks_symlink
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/subframework_header_dir_symlink_cdb.json > %t.cdb
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=0 | \
+// RUN: %clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=0 | \
 // RUN:   FileCheck %s
-// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=1 | \
+// RUN: %clang-scan-deps -compilation-database %t.cdb -j 1 -reuse-filemanager=1 | \
 // RUN:   FileCheck %s
 
 #ifndef EMPTY
Index: clang/test/ClangScanDeps/strip_diag_serialize.cpp
===
--- clang/test/ClangScanDeps/strip_diag_serialize.cpp
+++ clang/test/ClangScanDeps/strip_diag_serialize.cpp
@@ -5,7 +5,7 @@
 // RUN: cp %s %t.dir/strip_diag_serialize_input_clangcl.cpp
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/strip_diag_serialize.json > %t.cdb
 //
-// RUN: clang-sc

[PATCH] D107002: [PowerPC] Implement XL compatibility builtin __addex

2021-07-30 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added a comment.
This revision now requires changes to proceed.

Requesting changes until my comment is answered/addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107002

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


[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified

2021-07-30 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

Other than the naming nit, this LGTM.




Comment at: clang/include/clang/Sema/Sema.h:6103
+  // these vectors on gcc (an error is emitted).
+  bool IsAltivecCompatGCC(SourceRange R, QualType VecTy, QualType SrcTy);
+

I think a more appropriate name here would be something like
`CheckAltivecInitFromScalar()`
Since this checks whether initialization of an Altivec vector type from a 
scalar is allowed. The fact that it is not allowed only if we have the GCC 
source compat option specified isn't really the important aspect to the caller 
- the caller only cares if it is OK to allow an initialization of an Altivec 
vector from a scalar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106410

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


[PATCH] D106778: [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

2021-07-30 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

@airlied, can you please fix that to something like here 
https://godbolt.org/z/3Kbso8ca3? What currently we do have with your patch is 
that generic address space overload is always selected, but more strict 
overloading always exist in OpenCL C 3.0 (https://godbolt.org/z/vbMrdMxs1).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106778

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


[PATCH] D107040: [clangd] Make use of diagnostic tags for some clang diags

2021-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 363053.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107040

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -65,6 +65,11 @@
   return Field(&Diag::Notes, UnorderedElementsAre(NoteMatcher1, NoteMatcher2));
 }
 
+::testing::Matcher
+WithTag(::testing::Matcher TagMatcher) {
+  return Field(&Diag::Tags, Contains(TagMatcher));
+}
+
 MATCHER_P2(Diag, Range, Message,
"Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
   return arg.Range == Range && arg.Message == Message;
@@ -665,6 +670,7 @@
 
   clangd::Diag D;
   D.ID = clang::diag::err_undeclared_var_use;
+  D.Tags = {DiagnosticTag::Unnecessary};
   D.Name = "undeclared_var_use";
   D.Source = clangd::Diag::Clang;
   D.Message = "something terrible happened";
@@ -710,6 +716,7 @@
 
 ../foo/baz/header.h:10:11:
 note: declared somewhere in the header file)";
+  MainLSP.tags = {DiagnosticTag::Unnecessary};
 
   clangd::Diagnostic NoteInMainLSP;
   NoteInMainLSP.range = NoteInMain.Range;
@@ -1419,6 +1426,24 @@
 testing::Contains(Diag(Code.range(), "no newline at end of file")));
   }
 }
+
+TEST(Diagnostics, Tags) {
+  TestTU TU;
+  TU.ExtraArgs = {"-Wunused", "-Wdeprecated"};
+  Annotations Test(R"cpp(
+  void bar() __attribute__((deprecated));
+  void foo() {
+int $unused[[x]];
+$deprecated[[bar]]();
+  })cpp");
+  TU.Code = Test.code().str();
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unused"), "unused variable 'x'"),
+WithTag(DiagnosticTag::Unnecessary)),
+  AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
+WithTag(DiagnosticTag::Deprecated;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -28,6 +28,7 @@
 #include "support/MemoryTree.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -811,6 +812,19 @@
 };
 llvm::json::Value toJSON(const DiagnosticRelatedInformation &);
 
+enum DiagnosticTag {
+  /// Unused or unnecessary code.
+  ///
+  /// Clients are allowed to render diagnostics with this tag faded out instead
+  /// of having an error squiggle.
+  Unnecessary = 1,
+  /// Deprecated or obsolete code.
+  ///
+  /// Clients are allowed to rendered diagnostics with this tag strike through.
+  Deprecated = 2,
+};
+llvm::json::Value toJSON(DiagnosticTag Tag);
+
 struct CodeAction;
 struct Diagnostic {
   /// The range at which the message applies.
@@ -830,6 +844,9 @@
   /// The diagnostic's message.
   std::string message;
 
+  /// Additional metadata about the diagnostic.
+  llvm::SmallVector tags;
+
   /// An array of related diagnostic information, e.g. when symbol-names within
   /// a scope collide all definitions can be marked via this property.
   llvm::Optional> relatedInformation;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -584,6 +584,8 @@
   };
 }
 
+llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast(Tag); }
+
 llvm::json::Value toJSON(const Diagnostic &D) {
   llvm::json::Object Diag{
   {"range", D.range},
@@ -602,6 +604,8 @@
 Diag["relatedInformation"] = *D.relatedInformation;
   if (!D.data.empty())
 Diag["data"] = llvm::json::Object(D.data);
+  if (!D.tags.empty())
+Diag["tags"] = llvm::json::Array{D.tags};
   // FIXME: workaround for older gcc/clang
   return std::move(Diag);
 }
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/SourceMgr.h"
@@ -106,6 +107,7 @@
   std::vector Notes;
   /// *Alternative* fix

[clang-tools-extra] 5734652 - [clangd] Make use of diagnostic tags for some clang diags

2021-07-30 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-07-30T15:11:46+02:00
New Revision: 57346526c83e1fcf03baf80362fc2a9e6624f5fd

URL: 
https://github.com/llvm/llvm-project/commit/57346526c83e1fcf03baf80362fc2a9e6624f5fd
DIFF: 
https://github.com/llvm/llvm-project/commit/57346526c83e1fcf03baf80362fc2a9e6624f5fd.diff

LOG: [clangd] Make use of diagnostic tags for some clang diags

It is not great to list diag ids by hand, but I don't see any other
solution unless diagnostics are annotated with these explicitly, which is a
bigger change in clang and I am not sure if would be worth it.

Diagnostics handled by this patch is by no means exhaustive, there might be
other checks that don't mention "unused"/"deprecated" in their names. But it
feels like this should be enough to catch common diagnostics and can be extended
over time.

Differential Revision: https://reviews.llvm.org/D107040

Added: 


Modified: 
clang-tools-extra/clangd/Diagnostics.cpp
clang-tools-extra/clangd/Diagnostics.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Diagnostics.cpp 
b/clang-tools-extra/clangd/Diagnostics.cpp
index 089802db4f691..c4f174993e2d6 100644
--- a/clang-tools-extra/clangd/Diagnostics.cpp
+++ b/clang-tools-extra/clangd/Diagnostics.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Capacity.h"
@@ -35,6 +36,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -324,6 +326,60 @@ std::string noteMessage(const Diag &Main, const DiagBase 
&Note,
   OS.flush();
   return capitalize(std::move(Result));
 }
+
+void setTags(clangd::Diag &D) {
+  static const auto *DeprecatedDiags = new llvm::DenseSet{
+  diag::warn_access_decl_deprecated,
+  diag::warn_atl_uuid_deprecated,
+  diag::warn_deprecated,
+  diag::warn_deprecated_altivec_src_compat,
+  diag::warn_deprecated_comma_subscript,
+  diag::warn_deprecated_compound_assign_volatile,
+  diag::warn_deprecated_copy,
+  diag::warn_deprecated_copy_with_dtor,
+  diag::warn_deprecated_copy_with_user_provided_copy,
+  diag::warn_deprecated_copy_with_user_provided_dtor,
+  diag::warn_deprecated_def,
+  diag::warn_deprecated_increment_decrement_volatile,
+  diag::warn_deprecated_message,
+  diag::warn_deprecated_redundant_constexpr_static_def,
+  diag::warn_deprecated_register,
+  diag::warn_deprecated_simple_assign_volatile,
+  diag::warn_deprecated_string_literal_conversion,
+  diag::warn_deprecated_this_capture,
+  diag::warn_deprecated_volatile_param,
+  diag::warn_deprecated_volatile_return,
+  diag::warn_deprecated_volatile_structured_binding,
+  diag::warn_opencl_attr_deprecated_ignored,
+  diag::warn_property_method_deprecated,
+  diag::warn_vector_mode_deprecated,
+  };
+  static const auto *UnusedDiags = new llvm::DenseSet{
+  diag::warn_opencl_attr_deprecated_ignored,
+  diag::warn_pragma_attribute_unused,
+  diag::warn_unused_but_set_parameter,
+  diag::warn_unused_but_set_variable,
+  diag::warn_unused_comparison,
+  diag::warn_unused_const_variable,
+  diag::warn_unused_exception_param,
+  diag::warn_unused_function,
+  diag::warn_unused_label,
+  diag::warn_unused_lambda_capture,
+  diag::warn_unused_local_typedef,
+  diag::warn_unused_member_function,
+  diag::warn_unused_parameter,
+  diag::warn_unused_private_field,
+  diag::warn_unused_property_backing_ivar,
+  diag::warn_unused_template,
+  diag::warn_unused_variable,
+  };
+  if (DeprecatedDiags->contains(D.ID)) {
+D.Tags.push_back(DiagnosticTag::Deprecated);
+  } else if (UnusedDiags->contains(D.ID)) {
+D.Tags.push_back(DiagnosticTag::Unnecessary);
+  }
+  // FIXME: Set tags for tidy-based diagnostics too.
+}
 } // namespace
 
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const DiagBase &D) {
@@ -461,6 +517,7 @@ void toLSPDiags(
   Main.relatedInformation->push_back(std::move(RelInfo));
 }
   }
+  Main.tags = D.Tags;
   OutFn(std::move(Main), D.Fixes);
 
   // If we didn't emit the notes as relatedLocations, emit separate diagnostics
@@ -504,6 +561,7 @@ std::vector StoreDiags::take(const 
clang::tidy::ClangTidyContext *Tidy) {
 
   // Fill in name/source now that we have all the context needed to map them.
   for (auto &Diag : Output) {
+setTags(Diag);
 if (const char *ClangDiag = getDiagnosticCode(Diag.ID)) {
   // Warnings controlled by -Wfoo are better recognized by that name.
   StringRef Warning = DiagnosticIDs::getWarningOptionForDiag(D

[PATCH] D107040: [clangd] Make use of diagnostic tags for some clang diags

2021-07-30 Thread Kadir Cetinkaya 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 rG57346526c83e: [clangd] Make use of diagnostic tags for some 
clang diags (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107040

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -65,6 +65,11 @@
   return Field(&Diag::Notes, UnorderedElementsAre(NoteMatcher1, NoteMatcher2));
 }
 
+::testing::Matcher
+WithTag(::testing::Matcher TagMatcher) {
+  return Field(&Diag::Tags, Contains(TagMatcher));
+}
+
 MATCHER_P2(Diag, Range, Message,
"Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
   return arg.Range == Range && arg.Message == Message;
@@ -665,6 +670,7 @@
 
   clangd::Diag D;
   D.ID = clang::diag::err_undeclared_var_use;
+  D.Tags = {DiagnosticTag::Unnecessary};
   D.Name = "undeclared_var_use";
   D.Source = clangd::Diag::Clang;
   D.Message = "something terrible happened";
@@ -710,6 +716,7 @@
 
 ../foo/baz/header.h:10:11:
 note: declared somewhere in the header file)";
+  MainLSP.tags = {DiagnosticTag::Unnecessary};
 
   clangd::Diagnostic NoteInMainLSP;
   NoteInMainLSP.range = NoteInMain.Range;
@@ -1419,6 +1426,24 @@
 testing::Contains(Diag(Code.range(), "no newline at end of file")));
   }
 }
+
+TEST(Diagnostics, Tags) {
+  TestTU TU;
+  TU.ExtraArgs = {"-Wunused", "-Wdeprecated"};
+  Annotations Test(R"cpp(
+  void bar() __attribute__((deprecated));
+  void foo() {
+int $unused[[x]];
+$deprecated[[bar]]();
+  })cpp");
+  TU.Code = Test.code().str();
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unused"), "unused variable 'x'"),
+WithTag(DiagnosticTag::Unnecessary)),
+  AllOf(Diag(Test.range("deprecated"), "'bar' is deprecated"),
+WithTag(DiagnosticTag::Deprecated;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -28,6 +28,7 @@
 #include "support/MemoryTree.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -811,6 +812,19 @@
 };
 llvm::json::Value toJSON(const DiagnosticRelatedInformation &);
 
+enum DiagnosticTag {
+  /// Unused or unnecessary code.
+  ///
+  /// Clients are allowed to render diagnostics with this tag faded out instead
+  /// of having an error squiggle.
+  Unnecessary = 1,
+  /// Deprecated or obsolete code.
+  ///
+  /// Clients are allowed to rendered diagnostics with this tag strike through.
+  Deprecated = 2,
+};
+llvm::json::Value toJSON(DiagnosticTag Tag);
+
 struct CodeAction;
 struct Diagnostic {
   /// The range at which the message applies.
@@ -830,6 +844,9 @@
   /// The diagnostic's message.
   std::string message;
 
+  /// Additional metadata about the diagnostic.
+  llvm::SmallVector tags;
+
   /// An array of related diagnostic information, e.g. when symbol-names within
   /// a scope collide all definitions can be marked via this property.
   llvm::Optional> relatedInformation;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -584,6 +584,8 @@
   };
 }
 
+llvm::json::Value toJSON(DiagnosticTag Tag) { return static_cast(Tag); }
+
 llvm::json::Value toJSON(const Diagnostic &D) {
   llvm::json::Object Diag{
   {"range", D.range},
@@ -602,6 +604,8 @@
 Diag["relatedInformation"] = *D.relatedInformation;
   if (!D.data.empty())
 Diag["data"] = llvm::json::Object(D.data);
+  if (!D.tags.empty())
+Diag["tags"] = llvm::json::Array{D.tags};
   // FIXME: workaround for older gcc/clang
   return std::move(Diag);
 }
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -19,6 +19,7 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Support/JS

[PATCH] D106550: [PowerPC] Allow MMA builtins to accpet restrict qualified pointers

2021-07-30 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai requested changes to this revision.
nemanjai added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Sema/SemaChecking.cpp:7306
 (!ExpectedType->isVoidPointerType() &&
-   ArgType.getCanonicalType() != ExpectedType))
+ (!ArgType.isRestrictQualified() &&
+  ArgType.getCanonicalType() != ExpectedType)))

Parentheses here seem superfluous. Also, am I reading this correctly? Does this 
mean that if the argument type is `__restrict` anything, we are accepting it? 
That is not the intent here. We don't want to accept just ANY restrict 
qualified type. We want to accept either: `ExpectedType` or `ExpectedType 
__restrict`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106550

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


[PATCH] D105981: [AMDGPU][OpenMP] Support linking of math libraries

2021-07-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

I think this is good enough for now, assuming the majority of OvO is running 
locally. More cleanups to do after landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105981

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


[PATCH] D107154: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks

We might need to fix the target triple in 
`clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl` to avoid surprises with testing 
but it has better coverage if we don't though...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107154

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


[PATCH] D106669: [clangd] Unify compiler invocation creation

2021-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 363055.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106669

Files:
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/test/indexer.test

Index: clang-tools-extra/clangd/test/indexer.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/indexer.test
@@ -0,0 +1,9 @@
+# RUN: rm -rf %t.cpp
+# RUN: touch %t.cpp
+#
+# Make sure compile flags are adjusted for clangd. `--save-temps` creates a
+# `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should
+# strip those.
+# RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | FileCheck %s
+# CHECK-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics'
+# RUN: not ls %t.ii
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -10,6 +10,8 @@
 //
 //===--===//
 
+#include "CompileCommands.h"
+#include "Compiler.h"
 #include "index/IndexAction.h"
 #include "index/Merge.h"
 #include "index/Ref.h"
@@ -23,6 +25,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -82,6 +85,15 @@
 /*IncludeGraphCallback=*/nullptr);
   }
 
+  bool runInvocation(std::shared_ptr Invocation,
+ FileManager *Files,
+ std::shared_ptr PCHContainerOps,
+ DiagnosticConsumer *DiagConsumer) override {
+disableUnsupportedOptions(*Invocation);
+return tooling::FrontendActionFactory::runInvocation(
+std::move(Invocation), Files, std::move(PCHContainerOps), DiagConsumer);
+  }
+
   // Awkward: we write the result in the destructor, because the executor
   // takes ownership so it's the easiest way to get our data back out.
   ~IndexActionFactory() {
@@ -135,7 +147,8 @@
   clang::clangd::IndexFileIn Data;
   auto Err = Executor->get()->execute(
   std::make_unique(Data),
-  clang::tooling::getStripPluginsAdjuster());
+  clang::tooling::ArgumentsAdjuster(
+  clang::clangd::CommandMangler::detect()));
   if (Err) {
 clang::clangd::elog("{0}", std::move(Err));
   }
Index: clang-tools-extra/clangd/Compiler.h
===
--- clang-tools-extra/clangd/Compiler.h
+++ clang-tools-extra/clangd/Compiler.h
@@ -61,6 +61,12 @@
   FeatureModuleSet *FeatureModules = nullptr;
 };
 
+/// Clears \p CI from options that are not supported by clangd, like codegen or
+/// plugins. This should be combined with CommandMangler::adjust, which provides
+/// similar functionality for options that needs to be stripped from compile
+/// flags.
+void disableUnsupportedOptions(CompilerInvocation &CI);
+
 /// Builds compiler invocation that could be used to build AST or preamble.
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -9,6 +9,7 @@
 #include "Compiler.h"
 #include "support/Logger.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "llvm/ADT/StringRef.h"
@@ -41,6 +42,44 @@
   IgnoreDiagnostics::log(DiagLevel, Info);
 }
 
+void disableUnsupportedOptions(CompilerInvocation &CI) {
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI.getDiagnosticOpts().VerifyDiagnostics = false;
+  CI.getDiagnosticOpts().ShowColors = false;
+
+  // Disable any dependency outputting, we don't want to generate files or write
+  // to stdout/stderr.
+  CI.getDependencyOutputOpts().ShowIncludesDest = ShowIncludesDestination::None;
+  CI.getDependencyOutputOpts().OutputFile.clear();
+  CI.getDependencyOutputOpts().HeaderIncludeOutputFile.clear();
+  CI.getDependencyOutputOpts().DOTOutputFile.clear();
+  CI.getDependencyOutputOpts().ModuleDependencyOutputDir.clear();
+
+  // Disable any pch generation/usage operations. Since serialized preamble
+  // format is unstable, using an incompatible one might result 

[clang-tools-extra] 41e2422 - [clangd] Unify compiler invocation creation

2021-07-30 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-07-30T15:22:51+02:00
New Revision: 41e24222861fb5394ab4c7e892a7d7f2914b533e

URL: 
https://github.com/llvm/llvm-project/commit/41e24222861fb5394ab4c7e892a7d7f2914b533e
DIFF: 
https://github.com/llvm/llvm-project/commit/41e24222861fb5394ab4c7e892a7d7f2914b533e.diff

LOG: [clangd] Unify compiler invocation creation

Background-indexing is fine, because it uses GlobalCompilationDatabase
to fetch the compile commands (hence uses CommandMangler), and creates
invocation through buildCompilerInvocation.

Depends on D106639.

Differential Revision: https://reviews.llvm.org/D106669

Added: 
clang-tools-extra/clangd/test/indexer.test

Modified: 
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/Compiler.h
clang-tools-extra/clangd/indexer/IndexerMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.h 
b/clang-tools-extra/clangd/CompileCommands.h
index 50c1a3571ec42..c6b338297385f 100644
--- a/clang-tools-extra/clangd/CompileCommands.h
+++ b/clang-tools-extra/clangd/CompileCommands.h
@@ -26,10 +26,6 @@ namespace clangd {
 //  - forcing the use of clangd's builtin headers rather than clang's
 //  - resolving argv0 as cc1 expects
 //  - injecting -isysroot flags on mac as the system clang does
-// FIXME: This is currently not used in all code paths that create invocations.
-// Make use of these adjusters and buildCompilerInvocation in clangd-indexer as
-// well. It should be possible to hook it up by overriding RunInvocation in
-// FrontendActionFactory.
 struct CommandMangler {
   // Absolute path to clang.
   llvm::Optional ClangPath;

diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index f2fb4489f105a..44a1b1a77db56 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -9,6 +9,7 @@
 #include "Compiler.h"
 #include "support/Logger.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "llvm/ADT/StringRef.h"
@@ -41,6 +42,44 @@ void 
IgnoreDiagnostics::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
   IgnoreDiagnostics::log(DiagLevel, Info);
 }
 
+void disableUnsupportedOptions(CompilerInvocation &CI) {
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI.getDiagnosticOpts().VerifyDiagnostics = false;
+  CI.getDiagnosticOpts().ShowColors = false;
+
+  // Disable any dependency outputting, we don't want to generate files or 
write
+  // to stdout/stderr.
+  CI.getDependencyOutputOpts().ShowIncludesDest = 
ShowIncludesDestination::None;
+  CI.getDependencyOutputOpts().OutputFile.clear();
+  CI.getDependencyOutputOpts().HeaderIncludeOutputFile.clear();
+  CI.getDependencyOutputOpts().DOTOutputFile.clear();
+  CI.getDependencyOutputOpts().ModuleDependencyOutputDir.clear();
+
+  // Disable any pch generation/usage operations. Since serialized preamble
+  // format is unstable, using an incompatible one might result in unexpected
+  // behaviours, including crashes.
+  CI.getPreprocessorOpts().ImplicitPCHInclude.clear();
+  CI.getPreprocessorOpts().PrecompiledPreambleBytes = {0, false};
+  CI.getPreprocessorOpts().PCHThroughHeader.clear();
+  CI.getPreprocessorOpts().PCHWithHdrStop = false;
+  CI.getPreprocessorOpts().PCHWithHdrStopCreate = false;
+  // Don't crash on `#pragma clang __debug parser_crash`
+  CI.getPreprocessorOpts().DisablePragmaDebugCrash = true;
+
+  // Always default to raw container format as clangd doesn't registry any 
other
+  // and clang dies when faced with unknown formats.
+  CI.getHeaderSearchOpts().ModuleFormat =
+  PCHContainerOperations().getRawReader().getFormat().str();
+
+  CI.getFrontendOpts().Plugins.clear();
+  CI.getFrontendOpts().AddPluginActions.clear();
+  CI.getFrontendOpts().PluginArgs.clear();
+  CI.getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
+  CI.getFrontendOpts().ActionName.clear();
+}
+
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer 
&D,
 std::vector *CC1Args) {
@@ -60,43 +99,8 @@ buildCompilerInvocation(const ParseInputs &Inputs, 
clang::DiagnosticConsumer &D,
   CI->getFrontendOpts().DisableFree = false;
   CI->getLangOpts()->CommentOpts.ParseAllComments = true;
   CI->getLangOpts()->RetainCommentsFromSystemHeaders = true;
-  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
-  // our compiler invocation set-up doesn't seem to work with it (leading
-  // assertions in VerifyDiagnosticConsumer).
-  CI->getDiagnosticOpts().VerifyDiagnostics = false;
-  CI-

[PATCH] D106669: [clangd] Unify compiler invocation creation

2021-07-30 Thread Kadir Cetinkaya 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 rG41e24222861f: [clangd] Unify compiler invocation creation 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106669

Files:
  clang-tools-extra/clangd/CompileCommands.h
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/test/indexer.test

Index: clang-tools-extra/clangd/test/indexer.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/indexer.test
@@ -0,0 +1,9 @@
+# RUN: rm -rf %t.cpp
+# RUN: touch %t.cpp
+#
+# Make sure compile flags are adjusted for clangd. `--save-temps` creates a
+# `.ii` file and `-verify` triggers extra diagnostics generation. Clangd should
+# strip those.
+# RUN: clangd-indexer %t.cpp -- -Xclang -verify --save-temps -- 2>&1 | FileCheck %s
+# CHECK-NOT: error: no expected directives found: consider use of 'expected-no-diagnostics'
+# RUN: not ls %t.ii
Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -10,6 +10,8 @@
 //
 //===--===//
 
+#include "CompileCommands.h"
+#include "Compiler.h"
 #include "index/IndexAction.h"
 #include "index/Merge.h"
 #include "index/Ref.h"
@@ -23,6 +25,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Signals.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -82,6 +85,15 @@
 /*IncludeGraphCallback=*/nullptr);
   }
 
+  bool runInvocation(std::shared_ptr Invocation,
+ FileManager *Files,
+ std::shared_ptr PCHContainerOps,
+ DiagnosticConsumer *DiagConsumer) override {
+disableUnsupportedOptions(*Invocation);
+return tooling::FrontendActionFactory::runInvocation(
+std::move(Invocation), Files, std::move(PCHContainerOps), DiagConsumer);
+  }
+
   // Awkward: we write the result in the destructor, because the executor
   // takes ownership so it's the easiest way to get our data back out.
   ~IndexActionFactory() {
@@ -135,7 +147,8 @@
   clang::clangd::IndexFileIn Data;
   auto Err = Executor->get()->execute(
   std::make_unique(Data),
-  clang::tooling::getStripPluginsAdjuster());
+  clang::tooling::ArgumentsAdjuster(
+  clang::clangd::CommandMangler::detect()));
   if (Err) {
 clang::clangd::elog("{0}", std::move(Err));
   }
Index: clang-tools-extra/clangd/Compiler.h
===
--- clang-tools-extra/clangd/Compiler.h
+++ clang-tools-extra/clangd/Compiler.h
@@ -61,6 +61,12 @@
   FeatureModuleSet *FeatureModules = nullptr;
 };
 
+/// Clears \p CI from options that are not supported by clangd, like codegen or
+/// plugins. This should be combined with CommandMangler::adjust, which provides
+/// similar functionality for options that needs to be stripped from compile
+/// flags.
+void disableUnsupportedOptions(CompilerInvocation &CI);
+
 /// Builds compiler invocation that could be used to build AST or preamble.
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D,
Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -9,6 +9,7 @@
 #include "Compiler.h"
 #include "support/Logger.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Serialization/PCHContainerOperations.h"
 #include "llvm/ADT/StringRef.h"
@@ -41,6 +42,44 @@
   IgnoreDiagnostics::log(DiagLevel, Info);
 }
 
+void disableUnsupportedOptions(CompilerInvocation &CI) {
+  // Disable "clang -verify" diagnostics, they are rarely useful in clangd, and
+  // our compiler invocation set-up doesn't seem to work with it (leading
+  // assertions in VerifyDiagnosticConsumer).
+  CI.getDiagnosticOpts().VerifyDiagnostics = false;
+  CI.getDiagnosticOpts().ShowColors = false;
+
+  // Disable any dependency outputting, we don't want to generate files or write
+  // to stdout/stderr.
+  CI.getDependencyOutputOpts().ShowIncludesDest = ShowIncludesDestination::None;
+  CI.getDependencyOutputOpts().OutputFile.clear();
+  CI.getDependencyOutputOpts().HeaderIncludeOutputFile.clear();
+  CI.getDependencyOutputOpts().DOTOutputFile.clear();
+  CI.getDependencyOutputOpts().ModuleDependencyOutputDir.clear();
+
+  // Disable any pch generation/usage operatio

[PATCH] D107154: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-30 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> We might need to fix the target triple in 
> clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl to avoid surprises with testing 
> but it has better coverage if we don't though...

Yeah, I am not sure now though. It's awful because testing is not deterministic 
as we have different default targets here, but on the other hand it helps to 
catch errors like this. Maybe it makes sense to change the existing target to 
spir and also add a random target here, such as nvptx for example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107154

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


[clang-tools-extra] 8070bf8 - [clangd] Record remote index usage

2021-07-30 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-07-30T15:24:22+02:00
New Revision: 8070bf8c6e6afbf0b8a20322d935cb530b4b796a

URL: 
https://github.com/llvm/llvm-project/commit/8070bf8c6e6afbf0b8a20322d935cb530b4b796a
DIFF: 
https://github.com/llvm/llvm-project/commit/8070bf8c6e6afbf0b8a20322d935cb530b4b796a.diff

LOG: [clangd] Record remote index usage

This is a gauage metric that sets particular remote-index instances as
used. It should enable accumulation of multiple streams to see number of clangd
processes making use of remote index, broken down by remote index address.

Differential Revision: https://reviews.llvm.org/D106796

Added: 


Modified: 
clang-tools-extra/clangd/tool/ClangdMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp 
b/clang-tools-extra/clangd/tool/ClangdMain.cpp
index c40f98f5a4ee..234fee0c4447 100644
--- a/clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -561,10 +561,13 @@ const char TestScheme::TestDir[] = "/clangd-test";
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
   AsyncTaskRunner *Tasks) {
+  static const trace::Metric RemoteIndexUsed("used_remote_index",
+ trace::Metric::Value, "address");
   switch (External.Kind) {
   case Config::ExternalIndexSpec::None:
 break;
   case Config::ExternalIndexSpec::Server:
+RemoteIndexUsed.record(1, External.Location);
 log("Associating {0} with remote index at {1}.", External.MountPoint,
 External.Location);
 return remote::getClient(External.Location, External.MountPoint);



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


[PATCH] D106796: [clangd] Record remote index usage

2021-07-30 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8070bf8c6e6a: [clangd] Record remote index usage (authored 
by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106796

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -561,10 +561,13 @@
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
   AsyncTaskRunner *Tasks) {
+  static const trace::Metric RemoteIndexUsed("used_remote_index",
+ trace::Metric::Value, "address");
   switch (External.Kind) {
   case Config::ExternalIndexSpec::None:
 break;
   case Config::ExternalIndexSpec::Server:
+RemoteIndexUsed.record(1, External.Location);
 log("Associating {0} with remote index at {1}.", External.MountPoint,
 External.Location);
 return remote::getClient(External.Location, External.MountPoint);


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -561,10 +561,13 @@
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
   AsyncTaskRunner *Tasks) {
+  static const trace::Metric RemoteIndexUsed("used_remote_index",
+ trace::Metric::Value, "address");
   switch (External.Kind) {
   case Config::ExternalIndexSpec::None:
 break;
   case Config::ExternalIndexSpec::Server:
+RemoteIndexUsed.record(1, External.Location);
 log("Associating {0} with remote index at {1}.", External.MountPoint,
 External.Location);
 return remote::getClient(External.Location, External.MountPoint);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-07-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/test/Analysis/copy-elision.cpp:9-10
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-std=c++17 \
+// RUN:-analyzer-config elide-constructors=false -DNO_ELIDE_FLAG   
   \
+// RUN:-analyzer-config eagerly-assume=false -verify %s
 

steakhal wrote:
> martong wrote:
> > Should we use `-verify=no-elide` here as well? Since we set the 
> > `DNO_ELIDE_FLAG`?
> According to  the comment a few lines below:
> > Copy elision always occurs in C++17, otherwise it's under an on-by-default 
> > flag.
> 
> So I think even though one passes the `elide-constructors=false` analyzer 
> config, we follow the language semantics, which requires us to elide those 
> copies, thus no copy should happen.
If copy elision always occur then `DNO_ELIDE_FLAG` has no effect, and as such 
it is misleading to have it in this RUN line.


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

https://reviews.llvm.org/D107078

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Looking at this once again, I'm pretty sure that reverting this is much safer 
than trying to fix forward. Unless there's a really trivial fix to the 
outstanding issues, I'll revert this later today.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Missing sema test for rejecting the builtins on targets that don't support this




Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:201
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f32, "ff*1fi", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_2f16, "hh*1hi", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmin_f64, "dd*1di", "t", 
"gfx90a-insts")

"_2f16" looks weird to me. The instruction names call it "pk"



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:16114
+Intrinsic::ID IID;
+llvm::Type *ArgTy = llvm::Type::getDoubleTy(getLLVMContext());
+switch (BuiltinID) {

Initializing this here is strange, sink down to the double case



Comment at: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl:112
+kernel void test_flat_global_max(__global double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fmax_f64(addr, x, memory_order_relaxed);
+}

If you're going to bother testing the ISA, is it worth testing rtn and no rtn 
versions?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D105981: [AMDGPU][OpenMP] Support linking of math libraries

2021-07-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105981

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


[PATCH] D106934: [clangd] Do not inlay hints pertaining to code in other files

2021-07-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:320
+// file that was included after the preamble), do not show in that case.
+if (AST.getSourceManager().getFileID(FileRange->getBegin()) != MainFileID)
+  return;

kadircet wrote:
> sammccall wrote:
> > nit: getSourceManager().isWrittenInMainFile(FileRange->getBegin())
> double nit: `isInsideMainFile(Loc, SM)`, I presume we would like to keep 
> hints in preamble section as well (even though it is unlikely that we'll have 
> any)
Yeah I did think about that too :-) I don't think we have any that can trigger 
there, and isInsideMainFile is more expensive.
I'm fine with either version though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106934

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


[PATCH] D107002: [PowerPC] Implement XL compatibility builtin __addex

2021-07-30 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: llvm/lib/Target/PowerPC/P9InstrResources.td:1434
+  ADDEX,
+  ADDEX8
 )> { let Unsupported = 1; }

nemanjai wrote:
> You have added the 64-bit version of this, but it seems this is only 
> available for 64-bit operands in 64-bit mode. Under which conditions do we 
> need the plain `ADDEX`?
Correct, the builtin `__addex()` is only available for 64bit. 
Unless I am reading the ISA wrong, the instruction `addex` is valid for both 
32bit and 64bit:
```
ForCY=0,OVis set to 1 if there is a carry out of bit 0 of the sum in 64-bit 
mode or there is a carry out of bit 32 of the sum in 32-bit mode, and set to 0 
otherwise. OV32 is set to 1 if there is a carry out of bit 32 bit of the sum.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107002

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:201
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f32, "ff*1fi", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_2f16, "hh*1hi", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmin_f64, "dd*1di", "t", 
"gfx90a-insts")

arsenm wrote:
> "_2f16" looks weird to me. The instruction names call it "pk"
This is to have a consistent postfix naming convention, since the stem part 
here are the same. the postfix is for the argument type of the builtin function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[clang] 9830f90 - [AMDGPU][OpenMP] Support linking of math libraries

2021-07-30 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-07-30T13:53:44Z
New Revision: 9830f902e4d087ecb1706912b730c046f20600ee

URL: 
https://github.com/llvm/llvm-project/commit/9830f902e4d087ecb1706912b730c046f20600ee
DIFF: 
https://github.com/llvm/llvm-project/commit/9830f902e4d087ecb1706912b730c046f20600ee.diff

LOG: [AMDGPU][OpenMP] Support linking of math libraries

Math libraries are linked only when -lm is specified. This is because
host system could be missing rocm-device-libs.

Reviewed By: JonChesterfield, yaxunl

Differential Revision: https://reviews.llvm.org/D105981

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index d63c5e12c4af4..4a7413112b55d 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -893,3 +893,38 @@ bool AMDGPUToolChain::shouldSkipArgument(const 
llvm::opt::Arg *A) const {
 return true;
   return false;
 }
+
+llvm::SmallVector
+ROCMToolChain::getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
+   const std::string &GPUArch) const {
+  auto Kind = llvm::AMDGPU::parseArchAMDGCN(GPUArch);
+  const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
+
+  std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
+  if (LibDeviceFile.empty()) {
+getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GPUArch;
+return {};
+  }
+
+  // If --hip-device-lib is not set, add the default bitcode libraries.
+  // TODO: There are way too many flags that change this. Do we need to check
+  // them all?
+  bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
+options::OPT_fno_gpu_flush_denormals_to_zero,
+getDefaultDenormsAreZeroForTarget(Kind));
+  bool FiniteOnly = DriverArgs.hasFlag(
+  options::OPT_ffinite_math_only, options::OPT_fno_finite_math_only, 
false);
+  bool UnsafeMathOpt =
+  DriverArgs.hasFlag(options::OPT_funsafe_math_optimizations,
+ options::OPT_fno_unsafe_math_optimizations, false);
+  bool FastRelaxedMath = DriverArgs.hasFlag(options::OPT_ffast_math,
+options::OPT_fno_fast_math, false);
+  bool CorrectSqrt = DriverArgs.hasFlag(
+  options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
+  options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt);
+  bool Wave64 = isWave64(DriverArgs, Kind);
+
+  return RocmInstallation.getCommonBitcodeLibs(
+  DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
+  FastRelaxedMath, CorrectSqrt);
+}
\ No newline at end of file

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index 50ed3b3ded9a3..a4bcf315ca765 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -136,6 +136,11 @@ class LLVM_LIBRARY_VISIBILITY ROCMToolChain : public 
AMDGPUToolChain {
   addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const override;
+
+  // Returns a list of device library names shared by 
diff erent languages
+  llvm::SmallVector
+  getCommonDeviceLibNames(const llvm::opt::ArgList &DriverArgs,
+  const std::string &GPUArch) const;
 };
 
 } // end namespace toolchains

diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index fe1d19c2dd676..7b335f33aa824 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -9,12 +9,14 @@
 #include "AMDGPUOpenMP.h"
 #include "AMDGPU.h"
 #include "CommonArgs.h"
+#include "ToolChains/ROCm.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatAdapters.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -232,6 +234,27 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
 
   addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
  getTriple());
+
+  if (!DriverArgs.hasArg(options::OPT_l))
+return;
+
+  auto Lm = DriverArgs.getAllArgValues(options::OPT_l);
+  bool HasLibm = false;
+  for (auto &Lib : Lm) {
+if (Lib == "m") {
+  HasLibm = true;
+  break;
+}
+  }
+
+  if 

[PATCH] D105981: [AMDGPU][OpenMP] Support linking of math libraries

2021-07-30 Thread Pushpinder Singh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9830f902e4d0: [AMDGPU][OpenMP] Support linking of math 
libraries (authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105981

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c

Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -74,3 +74,6 @@
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -emit-llvm -S -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-EMIT-LLVM-IR
 // CHECK-EMIT-LLVM-IR: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
+
+// RUN: env LIBRARY_PATH=%S/Inputs/hip_dev_lib %clang -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -lm --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIB-DEVICE
+// CHECK-LIB-DEVICE: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}"-mlink-builtin-bitcode"{{.*}}ocml.bc" "-mlink-builtin-bitcode"{{.*}}ockl.bc" "-mlink-builtin-bitcode"{{.*}}oclc_daz_opt_on.bc" "-mlink-builtin-bitcode"{{.*}}oclc_unsafe_math_off.bc" "-mlink-builtin-bitcode"{{.*}}oclc_finite_only_off.bc" "-mlink-builtin-bitcode"{{.*}}oclc_correctly_rounded_sqrt_on.bc" "-mlink-builtin-bitcode"{{.*}}oclc_wavefrontsize64_on.bc" "-mlink-builtin-bitcode"{{.*}}oclc_isa_version_803.bc"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -395,35 +395,8 @@
 }
 StringRef GpuArch = getGPUArch(DriverArgs);
 assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
-(void)GpuArch;
-auto Kind = llvm::AMDGPU::parseArchAMDGCN(GpuArch);
-const StringRef CanonArch = llvm::AMDGPU::getArchNameAMDGCN(Kind);
-
-std::string LibDeviceFile = RocmInstallation.getLibDeviceFile(CanonArch);
-if (LibDeviceFile.empty()) {
-  getDriver().Diag(diag::err_drv_no_rocm_device_lib) << 1 << GpuArch;
-  return {};
-}
 
 // If --hip-device-lib is not set, add the default bitcode libraries.
-// TODO: There are way too many flags that change this. Do we need to check
-// them all?
-bool DAZ = DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
-  options::OPT_fno_gpu_flush_denormals_to_zero,
-  getDefaultDenormsAreZeroForTarget(Kind));
-bool FiniteOnly =
-DriverArgs.hasFlag(options::OPT_ffinite_math_only,
-   options::OPT_fno_finite_math_only, false);
-bool UnsafeMathOpt =
-DriverArgs.hasFlag(options::OPT_funsafe_math_optimizations,
-   options::OPT_fno_unsafe_math_optimizations, false);
-bool FastRelaxedMath = DriverArgs.hasFlag(
-options::OPT_ffast_math, options::OPT_fno_fast_math, false);
-bool CorrectSqrt = DriverArgs.hasFlag(
-options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
-options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt);
-bool Wave64 = isWave64(DriverArgs, Kind);
-
 if (DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
options::OPT_fno_gpu_sanitize, false)) {
   auto AsanRTL = RocmInstallation.getAsanRTLPath();
@@ -442,10 +415,8 @@
 // Add the HIP specific bitcode library.
 BCLibs.push_back(RocmInstallation.getHIPPath().str());
 
-// Add the generic set of libraries.
-BCLibs.append(RocmInstallation.getCommonBitcodeLibs(
-DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
-FastRelaxedMath, CorrectSqrt));
+// Add common device libraries like ocml etc.
+BCLibs.append(getCommonDeviceLibNames(DriverArgs, GpuArch.str()));
 
 // Add instrument lib.
 auto InstLib =
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -9,12 +9,14 @@
 #include "AMDGPUOpenMP.h"
 #include "AMDGPU.h"
 #include "CommonArgs.h"
+#include "ToolChains/ROCm.h"
 #include "clang/Basic/DiagnosticDriver.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Dri

[PATCH] D106864: [clang][cli] Expose -fno-cxx-modules in cc1

2021-07-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 363071.
jansvoboda11 added a comment.

Add negative test, check error messages.


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

https://reviews.llvm.org/D106864

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Modules/cxx20-disable.cpp


Index: clang/test/Modules/cxx20-disable.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-disable.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -x objective-c++ -std=c++20  -I %t %s 
-verify=enabled
+// RUN: %clang_cc1 -x objective-c++ -std=c++20 -fno-cxx-modules -I %t %s 
-verify=disabled
+
+// enabled-no-diagnostics
+
+// The spelling of these errors is misleading.
+// The important thing is Clang rejected C++20 modules syntax.
+export module Foo; // disabled-error{{expected template}}
+   // disabled-error@-1{{unknown type name 'module'}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3150,8 +3150,6 @@
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
 
-  Opts.CPlusPlusModules = Opts.CPlusPlus20;
-
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();
   if (LangStd == LangStandard::lang_opencl10)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -467,7 +467,6 @@
 defvar hip = LangOpts<"HIP">;
 defvar gnu_mode = LangOpts<"GNUMode">;
 defvar asm_preprocessor = LangOpts<"AsmPreprocessor">;
-defvar cpp_modules = LangOpts<"CPlusPlusModules">;
 
 defvar std = !strconcat("LangStandard::getLangStandardForKind(", 
lang_std.KeyPath, ")");
 
@@ -1329,8 +1328,11 @@
 defm async_exceptions: BoolFOption<"async-exceptions",
   LangOpts<"EHAsynch">, DefaultFalse,
   PosFlag, 
NegFlag>;
-def fcxx_modules : Flag <["-"], "fcxx-modules">, Group,
-  Flags<[NoXarchOption]>;
+defm cxx_modules : BoolFOption<"cxx-modules",
+  LangOpts<"CPlusPlusModules">, Default,
+  NegFlag, PosFlag,
+  BothFlags<[NoXarchOption], " modules for C++">>,
+  ShouldParseIf;
 def fdebug_pass_arguments : Flag<["-"], "fdebug-pass-arguments">, 
Group;
 def fdebug_pass_structure : Flag<["-"], "fdebug-pass-structure">, 
Group;
 def fdepfile_entry : Joined<["-"], "fdepfile-entry=">,
@@ -2146,7 +2148,7 @@
   Flags<[CC1Option]>, HelpText<"Enable support for the C++ Modules TS">,
   MarshallingInfoFlag>;
 defm modules : BoolFOption<"modules",
-  LangOpts<"Modules">, Default,
+  LangOpts<"Modules">, Default,
   PosFlag,
   NegFlag, BothFlags<[NoXarchOption, CoreOption]>>;
 def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, 
Alias;
@@ -2205,8 +2207,6 @@
   Flags<[CoreOption, NoXarchOption]>;
 def fno_common : Flag<["-"], "fno-common">, Group, Flags<[CC1Option]>,
 HelpText<"Compile common globals like normal definitions">;
-def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group,
-  Flags<[NoXarchOption]>;
 defm digraphs : BoolFOption<"digraphs",
   LangOpts<"Digraphs">, Default,
   PosFlag', 
'<%', '%>', '%:', '%:%:' (default)">,
@@ -5283,7 +5283,7 @@
   HelpText<"Enforce name visibility rules across submodules of the same "
"top-level module.">,
   MarshallingInfoFlag>,
-  ImpliedByAnyOf<[fmodules_ts.KeyPath, cpp_modules.KeyPath]>;
+  ImpliedByAnyOf<[fmodules_ts.KeyPath, fcxx_modules.KeyPath]>;
 def fmodules_codegen :
   Flag<["-"], "fmodules-codegen">,
   HelpText<"Generate code for uses of this module that assumes an explicit "


Index: clang/test/Modules/cxx20-disable.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-disable.cpp
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: %clang_cc1 -x objective-c++ -std=c++20  -I %t %s -verify=enabled
+// RUN: %clang_cc1 -x objective-c++ -std=c++20 -fno-cxx-modules -I %t %s -verify=disabled
+
+// enabled-no-diagnostics
+
+// The spelling of these errors is misleading.
+// The important thing is Clang rejected C++20 modules syntax.
+export module Foo; // disabled-error{{expected template}}
+   // disabled-error@-1{{unknown type name 'module'}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3150,8 +3150,6 @@
   Opts.HexFloats = Std.hasHexFloats();
   Opts.ImplicitInt = Std.hasImplicitInt();
 
-  Opts.CPlusPlusModules = Opts.CPlusPlus20;
-
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();
   if (LangStd == LangStandard::lang_opencl10)
Index: clang/include/clang/Driver/Options.td
==

[PATCH] D106864: [clang][cli] Expose -fno-cxx-modules in cc1

2021-07-30 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/Modules/cxx20-disable.cpp:2
+// RUN: rm -rf %t && mkdir %t
+// RUN: not %clang_cc1 -x objective-c++ -std=c++20 -fno-cxx-modules -I %t %s
+

arphaman wrote:
> jansvoboda11 wrote:
> > I'm not sure how to best test this. Checking the error messages is not that 
> > useful, since they don't make the intent here any clearer:
> > 
> > ```
> > /llvm-project/clang/test/Modules/cxx20-disable.cpp:4:8: error: 
> > expected template
> > export module Foo;
> >^
> > /llvm-project/clang/test/Modules/cxx20-disable.cpp:4:8: error: 
> > unknown type name 'module'
> > 2 errors generated.
> > ```
> You could still check the errors with -verify but add a comment that 
> expressed the intent of why these errors are verified. Also it might make 
> sense to add an inverse test case that doesn't use the `-fno-cxx-modules` 
> flag, where this will just work.
Addressed in the latest revision.


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

https://reviews.llvm.org/D106864

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


[clang] 0a175ad - [clang][patch][FPEnv] Fix syntax errors in pragma float_control test

2021-07-30 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-30T09:59:45-04:00
New Revision: 0a175ad445f095caf59f7175fbc035464919b7a3

URL: 
https://github.com/llvm/llvm-project/commit/0a175ad445f095caf59f7175fbc035464919b7a3
DIFF: 
https://github.com/llvm/llvm-project/commit/0a175ad445f095caf59f7175fbc035464919b7a3.diff

LOG: [clang][patch][FPEnv] Fix syntax errors in pragma float_control test

In a post-commit message to https://reviews.llvm.org/D102343
@MaskRay pointed out syntax errors in one of the test cases. This
patch fixes those problems, I had forgotten the colon after the CHECK- strings.

Added: 


Modified: 
clang/test/CodeGen/fp-floatcontrol-stack.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp 
b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
index 35908dbc579fd..3de3af0cbad05 100644
--- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -6,10 +6,10 @@
 #define FUN(n) \
   (float z) { return n * z + n; }
 
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
 float fun_default FUN(1)
 //CHECK-LABEL: define {{.*}} @_Z11fun_defaultf{{.*}}
 #if DEFAULT
@@ -32,10 +32,10 @@ float fun_default FUN(1)
 // Rule: precise must be enabled
 #pragma float_control(except, on)
 #endif
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone strictfp 
mustprogress
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
 float exc_on FUN(2)
 //CHECK-LABEL: define {{.*}} @_Z6exc_onf{{.*}}
 #if DEFAULT
@@ -54,10 +54,10 @@ float fun_default FUN(1)
 #endif
 
 #pragma float_control(pop)
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind 
optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: mustprogress noinline nounwind optnone 
strictfp{{$$}}
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind 
optnone{{$$}}
 float exc_pop FUN(5)
 //CHECK-LABEL: define {{.*}} @_Z7exc_popf{{.*}}
 #if DEFAULT
@@ -223,10 +223,10 @@ float fun_default FUN(1)
 #pragma float_control(except, on)
 #endif
 float y();
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone mustprogress
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone strictfp 
mustprogress
-// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone mustprogress
+// CHECK-DDEFAULT: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone strictfp{{$$}}
+// CHECK-FAST: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: mustprogress noinline nounwind optnone{{$$}}
 class ON {
   // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
@@ -246,14 +246,14 @@ class ON {
 };
 ON on;
 #pragma float_control(except, off)
-// CHECK-DDEFAULT Function Attrs: noinline nounwind optnone
-// CHECK-DEBSTRICT Function Attrs: noinline nounwind optnone
-// CHECK-FAST: Function Attrs: noinline nounwind optnone
-// CHECK-NOHONOR Function Attrs: noinline nounwind optnone
+// CHECK-DDEFAULT: Function Attrs: noinline nounwind optnone{{$$}}
+// CHECK-DEBSTRICT: Function Attrs: noinline nounwind optnone{{$$}}
+// CHECK-FAST: Function Attrs: noinline nounwind optnone{{$$}}
+// CHECK-NOHONOR: Function Attrs: noinline 

[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-30 Thread Sean Fertile via Phabricator via cfe-commits
sfertile added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1781
-  // pragma align(packed).
-  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
-FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);

stevewan wrote:
> Just noting that the comment says `MaxFieldAlignment - The maximum allowed 
> field alignment. This is set by #pragma pack`, but `__attribute__(packed)` 
> also seems to set it to some large value that is at least as large as the 
> FieldAlign. Maybe edit the comment accordingly for now, and a future 
> follow-on patch if necessary.
Sorry Steven, not sure what you are asking for. 

attribute packed will set 'FieldPacked` to true, in which case we ignore the 
max field alignment  (and why the new comment says, or 1 if packed). IIUC the 
MaXFieldAlign is set by only by pragma pack and pragma align in the Itanium 
recored layout builder, and the place where it is set based on attribute packed 
is int he Microsoft record layout builder and doesn't affect us here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106900

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


[PATCH] D107125: [Diagnostic] Split 'qualifier on reference type has no effect' out into a new flag

2021-07-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for this! The changes LGTM as far as they go, but I'd appreciate some 
test coverage that shows the new diagnostic can be disabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107125

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-30 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added inline comments.



Comment at: clang/lib/Headers/openmp_wrappers/cmath:113
+__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
+//__DEVICE__ long long int llrint(float __x) { return ::llrintf(__x); }
+//__DEVICE__ long long int llround(float __x) { return ::llroundf(__x); }

let's not add in commented out code



Comment at: clang/test/Headers/Inputs/include/cstdlib:24
 
+// amdgcn already provides definition of fabs
 float fabs(float __x) { return __builtin_fabs(__x); }

drop comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D107163: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode

2021-07-30 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Definition of __cpp_threadsafe_static_init macro is controlled by
language option Opts.ThreadsafeStatics. This patch sets language
option to false by default in OpenCL mode, resulting in macro
__cpp_threadsafe_static_init being undefined. Default value can be
overriden using command line option -fthreadsafe-statics.

Change is supposed to address portability because not all OpenCL
vendors support thread safe implementation of static initialization.

Fixes llvm.org/PR48012


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107163

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/threadsafe-statics.clcpp


Index: clang/test/Driver/threadsafe-statics.clcpp
===
--- /dev/null
+++ clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6147,7 +6147,8 @@
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.


Index: clang/test/Driver/threadsafe-statics.clcpp
===
--- /dev/null
+++ clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 | FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6147,7 +6147,8 @@
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107137: clangd: Provide hover info for include directives

2021-07-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 363083.
ckandeler added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107137

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2750,6 +2750,15 @@
 
 // In test::Bar
 int foo = 3)",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Name = "stdio.h";
+HI.Definition = "/usr/include/stdio.h", "/";
+  },
+  R"(stdio.h
+
+/usr/include/stdio.h)",
   }};
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -58,7 +58,7 @@
   std::string Documentation;
   /// Source code containing the definition of the symbol.
   std::string Definition;
-
+  const char *DefinitionLanguage = "cpp";
   /// Access specifier for declarations inside class/struct/unions, empty for
   /// others.
   std::string AccessSpecifier;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -905,6 +905,22 @@
   if (TokensTouchingCursor.empty())
 return llvm::None;
 
+  // Show full header file path if cursor is on include directive.
+  if (const auto MainFilePath
+  = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM)) {
+for (const auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
+  if (Inc.Resolved.empty() || Inc.HashLine != Pos.line)
+continue;
+  HoverInfo HI;
+  HI.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
+  // FIXME: We don't have a fitting value for Kind.
+  HI.Definition = URIForFile::canonicalize(Inc.Resolved, *MainFilePath)
+  .file().str();
+  HI.DefinitionLanguage = "";
+  return HI;
+}
+  }
+
   // To be used as a backup for highlighting the selected token, we use back as
   // it aligns better with biases elsewhere (editors tend to send the position
   // for the left of the hovered token).
@@ -981,6 +997,7 @@
 
 markup::Document HoverInfo::present() const {
   markup::Document Output;
+
   // Header contains a text of the form:
   // variable `var`
   //
@@ -1081,7 +1098,8 @@
: Definition;
 // Note that we don't print anything for global namespace, to not annoy
 // non-c++ projects or projects that are not making use of namespaces.
-Output.addCodeBlock(ScopeComment + DefinitionWithAccess);
+Output.addCodeBlock(ScopeComment + DefinitionWithAccess,
+DefinitionLanguage);
   }
 
   return Output;


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2750,6 +2750,15 @@
 
 // In test::Bar
 int foo = 3)",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Name = "stdio.h";
+HI.Definition = "/usr/include/stdio.h", "/";
+  },
+  R"(stdio.h
+
+/usr/include/stdio.h)",
   }};
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -58,7 +58,7 @@
   std::string Documentation;
   /// Source code containing the definition of the symbol.
   std::string Definition;
-
+  const char *DefinitionLanguage = "cpp";
   /// Access specifier for declarations inside class/struct/unions, empty for
   /// others.
   std::string AccessSpecifier;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -905,6 +905,22 @@
   if (TokensTouchingCursor.empty())
 return llvm::None;
 
+  // Show full header file path if cursor is on include directive.
+  if (const auto MainFilePath
+  = getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM)) {
+for (const auto &Inc : AST.getIncludeStructure().MainFileIncludes) {
+  if (Inc.Resolved.empty() || Inc.HashLine != Pos.line)
+continue;
+  HoverInfo HI;
+  HI.Name = std::string(llvm::sys::path::filename(Inc.Resolved));
+  // FIXME: We don't have a fitting value for Kind.
+  HI.Definition = URIForFile::canonicalize(Inc.Resolved, *MainFilePath)
+

[clang] 5ea6117 - [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified

2021-07-30 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2021-07-30T09:35:43-05:00
New Revision: 5ea6117a9e9eae49ad1295fa422266ef3832e419

URL: 
https://github.com/llvm/llvm-project/commit/5ea6117a9e9eae49ad1295fa422266ef3832e419
DIFF: 
https://github.com/llvm/llvm-project/commit/5ea6117a9e9eae49ad1295fa422266ef3832e419.diff

LOG: [PowerPC] Emit error for Altivec vector initializations when 
-faltivec-src-compat=gcc is specified

Under the -faltivec-src-compat=gcc option, AltiVec vector initialization should
be treated as if they were compiled with gcc - which is, to emit an error when
the vectors are initialized in the parenthesized or non-parenthesized manner.
This patch implements this behaviour.

Differential Revision: https://reviews.llvm.org/D106410

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/CodeGen/vector-bool-pixel-altivec-init-no-parentheses.c
clang/test/CodeGen/vector-bool-pixel-altivec-init.c

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 1a696b4938061..07b7e61821f78 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6100,6 +6100,13 @@ class Sema final {
   // AltiVecPixel and AltiVecBool when -faltivec-src-compat=xl is specified.
   bool ShouldSplatAltivecScalarInCast(const VectorType *VecTy);
 
+  // Checks if the -faltivec-src-compat=gcc option is specified.
+  // If so, AltiVecVector, AltiVecBool and AltiVecPixel types are
+  // treated the same way as they are when trying to initialize
+  // these vectors on gcc (an error is emitted).
+  bool CheckAltivecInitFromScalar(SourceRange R, QualType VecTy,
+  QualType SrcTy);
+
   /// ActOnCXXNamedCast - Parse
   /// {dynamic,static,reinterpret,const,addrspace}_cast's.
   ExprResult ActOnCXXNamedCast(SourceLocation OpLoc,

diff  --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index cac43075f860c..50edcc1c23020 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2637,6 +2637,19 @@ bool Sema::ShouldSplatAltivecScalarInCast(const 
VectorType *VecTy) {
   return false;
 }
 
+bool Sema::CheckAltivecInitFromScalar(SourceRange R, QualType VecTy,
+  QualType SrcTy) {
+  bool SrcCompatGCC = this->getLangOpts().getAltivecSrcCompat() ==
+  LangOptions::AltivecSrcCompatKind::GCC;
+  if (this->getLangOpts().AltiVec && SrcCompatGCC) {
+this->Diag(R.getBegin(),
+   diag::err_invalid_conversion_between_vector_and_integer)
+<< VecTy << SrcTy << R;
+return true;
+  }
+  return false;
+}
+
 void CastOperation::CheckCXXCStyleCast(bool FunctionalStyle,
bool ListInitialization) {
   assert(Self.getLangOpts().CPlusPlus);
@@ -2690,7 +2703,12 @@ void CastOperation::CheckCXXCStyleCast(bool 
FunctionalStyle,
   }
 
   // AltiVec vector initialization with a single literal.
-  if (const VectorType *vecTy = DestType->getAs())
+  if (const VectorType *vecTy = DestType->getAs()) {
+if (Self.CheckAltivecInitFromScalar(OpRange, DestType,
+SrcExpr.get()->getType())) {
+  SrcExpr = ExprError();
+  return;
+}
 if (Self.ShouldSplatAltivecScalarInCast(vecTy) &&
 (SrcExpr.get()->getType()->isIntegerType() ||
  SrcExpr.get()->getType()->isFloatingType())) {
@@ -2698,6 +2716,7 @@ void CastOperation::CheckCXXCStyleCast(bool 
FunctionalStyle,
   SrcExpr = Self.prepareVectorSplat(DestType, SrcExpr.get());
   return;
 }
+  }
 
   // C++ [expr.cast]p5: The conversions performed by
   //   - a const_cast,
@@ -2976,6 +2995,10 @@ void CastOperation::CheckCStyleCast() {
   }
 
   if (const VectorType *DestVecTy = DestType->getAs()) {
+if (Self.CheckAltivecInitFromScalar(OpRange, DestType, SrcType)) {
+  SrcExpr = ExprError();
+  return;
+}
 if (Self.ShouldSplatAltivecScalarInCast(DestVecTy) &&
 (SrcType->isIntegerType() || SrcType->isFloatingType())) {
   Kind = CK_VectorSplat;

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 5ce5d122c2194..d316687c4cd8e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7735,6 +7735,9 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation 
LParenLoc,
   // initializers must be one or must match the size of the vector.
   // If a single value is specified in the initializer then it will be
   // replicated to all the components of the vector
+  if (CheckAltivecInitFromScalar(E->getSourceRange(), Ty,
+ VTy->getElementType()))
+return ExprError();
   if (ShouldSplatAltivecScalarInCast(VTy)) {
 // The number of initializers must be one or must match the size of the
 // vector. If a single value is specified in the

[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified

2021-07-30 Thread Amy Kwan 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 rG5ea6117a9e9e: [PowerPC] Emit error for Altivec vector 
initializations when -faltivec-src… (authored by amyk).

Changed prior to commit:
  https://reviews.llvm.org/D106410?vs=360312&id=363086#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106410

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/vector-bool-pixel-altivec-init-no-parentheses.c
  clang/test/CodeGen/vector-bool-pixel-altivec-init.c

Index: clang/test/CodeGen/vector-bool-pixel-altivec-init.c
===
--- clang/test/CodeGen/vector-bool-pixel-altivec-init.c
+++ clang/test/CodeGen/vector-bool-pixel-altivec-init.c
@@ -10,6 +10,12 @@
 // RUN: %clang_cc1 -target-feature +altivec -target-feature +vsx \
 // RUN:   -faltivec-src-compat=xl -triple powerpc64le-unknown-unknown -S \
 // RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc-unknown-unknown -S \
+// RUN:   -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC
+// RUN: not %clang_cc1 -target-feature +altivec -target-feature +vsx \
+// RUN:   -faltivec-src-compat=gcc -triple powerpc64le-unknown-unknown -S \
+// RUN:   -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC
 // RUN: %clang -mcpu=pwr8 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \
 // RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MIXED
 // RUN: %clang -mcpu=pwr9 -faltivec-src-compat=mixed --target=powerpc-unknown-unknown \
@@ -18,6 +24,10 @@
 // RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
 // RUN: %clang -mcpu=pwr9 -faltivec-src-compat=xl --target=powerpc-unknown-unknown \
 // RUN:   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=XL
+// RUN: not %clang -mcpu=pwr8 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown \
+// RUN:   -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC
+// RUN: not %clang -mcpu=pwr9 -faltivec-src-compat=gcc --target=powerpc-unknown-unknown \
+// RUN:   -S -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=GCC
 
 // Vector bool type
 vector bool char vbi8_1;
@@ -41,6 +51,7 @@
   vbi8_1 = (vector bool char)('a');
   // MIXED: 
   // XL: 
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned char' (vector of 16 'unsigned char' values) and integer type 'unsigned char' of different size
   char c = 'c';
   vbi8_2 = (vector bool char)(c);
   // MIXED: [[INS:%.*]] = insertelement <16 x i8>
@@ -48,11 +59,13 @@
   // XL: [[INS_ELT:%.*]] = insertelement <16 x i8>
   // XL: [[SHUFF:%.*]] = shufflevector <16 x i8> [[INS_ELT]], <16 x i8> poison, <16 x i32> zeroinitializer
   // XL: store <16 x i8> [[SHUFF]]
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned char' (vector of 16 'unsigned char' values) and integer type 'unsigned char' of different size
 
   // vector bool short initialization
   vbi16_1 = (vector bool short)(5);
   // MIXED: 
   // XL: 
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned short' (vector of 8 'unsigned short' values) and integer type 'unsigned short' of different size
   short si16 = 55;
   vbi16_2 = (vector bool short)(si16);
   // MIXED: [[INS:%.*]] = insertelement <8 x i16>
@@ -60,11 +73,13 @@
   // XL: [[INS_ELT:%.*]] = insertelement <8 x i16>
   // XL: [[SHUFF:%.*]] = shufflevector <8 x i16> [[INS_ELT]], <8 x i16> poison, <8 x i32> zeroinitializer
   // XL: store <8 x i16> [[SHUFF]]
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned short' (vector of 8 'unsigned short' values) and integer type 'unsigned short' of different size
 
   // vector bool int initialization
   vbi32_1 = (vector bool int)(9);
   // MIXED: 
   // XL: 
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned int' (vector of 4 'unsigned int' values) and integer type 'unsigned int' of different size
   int si32 = 99;
   vbi32_2 = (vector bool int)(si32);
   // MIXED: [[INS:%.*]] = insertelement <4 x i32>
@@ -72,11 +87,13 @@
   // XL: [[INS_ELT:%.*]] = insertelement <4 x i32>
   // XL: [[SHUFF:%.*]] = shufflevector <4 x i32> [[INS_ELT]], <4 x i32> poison, <4 x i32> zeroinitializer
   // XL: store <4 x i32> [[SHUFF]]
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned int' (vector of 4 'unsigned int' values) and integer type 'unsigned int' of different size
 
   // vector bool long long initialization
   vbi64_1 = (vector bool long long)(13);
   // MIXED: 
   // XL: 
+  // GCC: error: invalid conversion between vector type '__vector __bool unsigned long long' (vector of 2 

[PATCH] D106431: [clang-tidy] Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add support for initialization check of scoped enum.

2021-07-30 Thread gehry via Phabricator via cfe-commits
Sockke marked 2 inline comments as done.
Sockke added a comment.

In D106431#2913101 , @aaron.ballman 
wrote:

> In D106431#2912589 , @Sockke wrote:
>
>> Thank you for your reply! I generally understand what you mean, but there 
>> are three cases, namely, no diagnosis, providing diagnosis, and providing 
>> diagnosis & FixIt.  Only by judging whether "diagnosis" is null may fail to 
>> achieve the goal.  I have revised it a little bit, do you think that's 
>> alright? @aaron.ballman
>
> By how the code looks, you made the exact changes I was hoping to see. Thank 
> you!

Cheers! Can it be merged? @aaron.ballman




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:156
+
+  ⁣Added support for initialization check of the scoped enum
+

whisperity wrote:
> Unterminated sequence. Also, where is this feature implemented?
Before that, isIntegerType() would not treat scoped enum as an integer, so 
scoped enum was ignored. But isEnumeralType() will not.


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

https://reviews.llvm.org/D106431

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


[PATCH] D106431: [clang-tidy] Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add support for initialization check of scoped enum.

2021-07-30 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D106431#2916542 , @Sockke wrote:

> Cheers! Can it be merged? @aaron.ballman

Yes, but I think the patch needs to be rebased first as the pre-merge checks CI 
system said "patch application failed". Do you have commit access? If not, 
could you please specify the username and e-mail you would like to have 
associated with the commit?


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

https://reviews.llvm.org/D106431

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


[PATCH] D107163: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode

2021-07-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6150
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))

I think this will work fine apart from if someone creates `.cpp` file but 
passes `-cl-std=clc++`. But it is not the conventional flow so I think we  
should not worry about it for now.



Comment at: clang/test/Driver/threadsafe-statics.clcpp:2
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+

Worth adding one more RUN line with `-fthreadsafe-statics` passed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107163

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


[PATCH] D106431: [clang-tidy] Fix cppcoreguidelines-init-variables by removing the enum FixIt, and add support for initialization check of scoped enum.

2021-07-30 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

In D106431#2916551 , @whisperity 
wrote:

> In D106431#2916542 , @Sockke wrote:
>
>> Cheers! Can it be merged? @aaron.ballman
>
> Yes, but I think the patch needs to be rebased first as the pre-merge checks 
> CI system said "patch application failed". Do you have commit access? If not, 
> could you please specify the username and e-mail (the values of Git config 
> variable `user.name` and `user.email`) you would like to have associated with 
> the commit?

Thanks a lot!

Name: liuke
Email: liuke.ge...@bytedance.com


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

https://reviews.llvm.org/D106431

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


[PATCH] D107163: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode

2021-07-30 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna marked an inline comment as done.
Topotuna added inline comments.



Comment at: clang/test/Driver/threadsafe-statics.clcpp:2
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+

Anastasia wrote:
> Worth adding one more RUN line with `-fthreadsafe-statics` passed.
Such RUN line is present on line 8. Should I move it up so that all RUN lines 
are close to one another?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107163

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


[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-30 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 363090.
pdhaliwal added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+// CHECK: call float @__ocml_sin_f32
+float l1 = sinf(x);
+// CHECK: call float @__ocml_cos_f32
+float l2 = cosf(x);
+// CHECK: call float @__ocml_fabs_f32
+float l3 = fabsf(x);
+  }
+}
Index: clang/test/Headers/Inputs/include/utility
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/utility
@@ -0,0 +1,2 @@
+#pragma once
+
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -27,3 +27,4 @@
 double abs(double __x) { return fabs(__x); }
 
 }
+
Index: clang/test/Headers/Inputs/include/algorithm
===
--- /dev/null
+++ clang/test/Headers/Inputs/incl

[clang] 12da97e - [OpenMP][AMDGCN] Initial math headers support

2021-07-30 Thread Pushpinder Singh via cfe-commits

Author: Pushpinder Singh
Date: 2021-07-30T14:52:41Z
New Revision: 12da97ea10a941f0123340831300d09a2121e173

URL: 
https://github.com/llvm/llvm-project/commit/12da97ea10a941f0123340831300d09a2121e173
DIFF: 
https://github.com/llvm/llvm-project/commit/12da97ea10a941f0123340831300d09a2121e173.diff

LOG: [OpenMP][AMDGCN] Initial math headers support

With this patch, OpenMP on AMDGCN will use the math functions
provided by ROCm ocml library. Linking device code to the ocml will be
done in the next patch.

Reviewed By: JonChesterfield, jdoerfert, scchan

Differential Revision: https://reviews.llvm.org/D104904

Added: 
clang/test/Headers/Inputs/include/algorithm
clang/test/Headers/Inputs/include/utility
clang/test/Headers/amdgcn_openmp_device_math.c

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Headers/__clang_hip_cmath.h
clang/lib/Headers/__clang_hip_math.h
clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
clang/lib/Headers/openmp_wrappers/cmath
clang/lib/Headers/openmp_wrappers/math.h
clang/test/Headers/Inputs/include/cstdlib
clang/test/Headers/openmp_device_math_isnan.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e13302528cbd1..278ae118563d6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1256,7 +1256,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const 
JobAction &JA,
   // If we are offloading to a target via OpenMP we need to include the
   // openmp_wrappers folder which contains alternative system headers.
   if (JA.isDeviceOffloading(Action::OFK_OpenMP) &&
-  getToolChain().getTriple().isNVPTX()){
+  (getToolChain().getTriple().isNVPTX() ||
+   getToolChain().getTriple().isAMDGCN())) {
 if (!Args.hasArg(options::OPT_nobuiltininc)) {
   // Add openmp_wrappers/* to our system include path.  This lets us wrap
   // standard library headers.

diff  --git a/clang/lib/Headers/__clang_hip_cmath.h 
b/clang/lib/Headers/__clang_hip_cmath.h
index 7342705434e6b..d488db0a94d9d 100644
--- a/clang/lib/Headers/__clang_hip_cmath.h
+++ b/clang/lib/Headers/__clang_hip_cmath.h
@@ -10,7 +10,7 @@
 #ifndef __CLANG_HIP_CMATH_H__
 #define __CLANG_HIP_CMATH_H__
 
-#if !defined(__HIP__)
+#if !defined(__HIP__) && !defined(__OPENMP_AMDGCN__)
 #error "This file is for HIP and OpenMP AMDGCN device compilation only."
 #endif
 
@@ -25,31 +25,43 @@
 #endif // !defined(__HIPCC_RTC__)
 
 #pragma push_macro("__DEVICE__")
+#pragma push_macro("__CONSTEXPR__")
+#ifdef __OPENMP_AMDGCN__
+#define __DEVICE__ static __attribute__((always_inline, nothrow))
+#define __CONSTEXPR__ constexpr
+#else
 #define __DEVICE__ static __device__ inline __attribute__((always_inline))
+#define __CONSTEXPR__
+#endif // __OPENMP_AMDGCN__
 
 // Start with functions that cannot be defined by DEF macros below.
 #if defined(__cplusplus)
-__DEVICE__ double abs(double __x) { return ::fabs(__x); }
-__DEVICE__ float abs(float __x) { return ::fabsf(__x); }
-__DEVICE__ long long abs(long long __n) { return ::llabs(__n); }
-__DEVICE__ long abs(long __n) { return ::labs(__n); }
-__DEVICE__ float fma(float __x, float __y, float __z) {
+#if defined __OPENMP_AMDGCN__
+__DEVICE__ __CONSTEXPR__ float fabs(float __x) { return ::fabsf(__x); }
+__DEVICE__ __CONSTEXPR__ float sin(float __x) { return ::sinf(__x); }
+__DEVICE__ __CONSTEXPR__ float cos(float __x) { return ::cosf(__x); }
+#endif
+__DEVICE__ __CONSTEXPR__ double abs(double __x) { return ::fabs(__x); }
+__DEVICE__ __CONSTEXPR__ float abs(float __x) { return ::fabsf(__x); }
+__DEVICE__ __CONSTEXPR__ long long abs(long long __n) { return ::llabs(__n); }
+__DEVICE__ __CONSTEXPR__ long abs(long __n) { return ::labs(__n); }
+__DEVICE__ __CONSTEXPR__ float fma(float __x, float __y, float __z) {
   return ::fmaf(__x, __y, __z);
 }
 #if !defined(__HIPCC_RTC__)
 // The value returned by fpclassify is platform dependent, therefore it is not
 // supported by hipRTC.
-__DEVICE__ int fpclassify(float __x) {
+__DEVICE__ __CONSTEXPR__ int fpclassify(float __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
 }
-__DEVICE__ int fpclassify(double __x) {
+__DEVICE__ __CONSTEXPR__ int fpclassify(double __x) {
   return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL,
   FP_ZERO, __x);
 }
 #endif // !defined(__HIPCC_RTC__)
 
-__DEVICE__ float frexp(float __arg, int *__exp) {
+__DEVICE__ __CONSTEXPR__ float frexp(float __arg, int *__exp) {
   return ::frexpf(__arg, __exp);
 }
 
@@ -71,93 +83,101 @@ __DEVICE__ float frexp(float __arg, int *__exp) {
 //of the variants inside the inner region and avoid the clash.
 #pragma omp begin declare variant match(implementation = {vendor(llvm)})
 
-__DEVICE__ int isin

[PATCH] D104904: [OpenMP][AMDGCN] Initial math headers support

2021-07-30 Thread Pushpinder Singh 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 rG12da97ea10a9: [OpenMP][AMDGCN] Initial math headers support 
(authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Headers/__clang_hip_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/test/Headers/Inputs/include/algorithm
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/utility
  clang/test/Headers/amdgcn_openmp_device_math.c
  clang/test/Headers/openmp_device_math_isnan.cpp

Index: clang/test/Headers/openmp_device_math_isnan.cpp
===
--- clang/test/Headers/openmp_device_math_isnan.cpp
+++ clang/test/Headers/openmp_device_math_isnan.cpp
@@ -21,14 +21,14 @@
 double math(float f, double d) {
   double r = 0;
   // INT_RETURN: call i32 @__nv_isnanf(float
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnanf(float
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f32(float
   // BOOL_RETURN: call i32 @__nv_isnanf(float
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnanf(float
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f32(float
   r += std::isnan(f);
   // INT_RETURN: call i32 @__nv_isnand(double
-  // AMD_INT_RETURN: call i32 @_{{.*}}isnand(double
+  // AMD_INT_RETURN: call i32 @__ocml_isnan_f64(double
   // BOOL_RETURN: call i32 @__nv_isnand(double
-  // AMD_BOOL_RETURN: call zeroext i1 @_{{.*}}isnand(double
+  // AMD_BOOL_RETURN: call i32 @__ocml_isnan_f64(double
   r += std::isnan(d);
   return r;
 }
Index: clang/test/Headers/amdgcn_openmp_device_math.c
===
--- /dev/null
+++ clang/test/Headers/amdgcn_openmp_device_math.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK
+
+#ifdef __cplusplus
+#include 
+#else
+#include 
+#endif
+
+void test_math_f64(double x) {
+// CHECK-LABEL: define {{.*}}test_math_f64
+#pragma omp target
+  {
+// CHECK: call double @__ocml_sin_f64
+double l1 = sin(x);
+// CHECK: call double @__ocml_cos_f64
+double l2 = cos(x);
+// CHECK: call double @__ocml_fabs_f64
+double l3 = fabs(x);
+  }
+}
+
+void test_math_f32(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32
+#pragma omp target
+  {
+// CHECK-C: call double @__ocml_sin_f64
+// CHECK-CPP: call float @__ocml_sin_f32
+float l1 = sin(x);
+// CHECK-C: call double @__ocml_cos_f64
+// CHECK-CPP: call float @__ocml_cos_f32
+float l2 = cos(x);
+// CHECK-C: call double @__ocml_fabs_f64
+// CHECK-CPP: call float @__ocml_fabs_f32
+float l3 = fabs(x);
+  }
+}
+void test_math_f32_suffix(float x) {
+// CHECK-LABEL: define {{.*}}test_math_f32_suffix
+#pragma omp target
+  {
+// CHECK: call float @__ocml_sin_f32
+float l1 = sinf(x);
+// CHECK: call float @__ocml_cos_f32
+float l2 = cosf(x);
+// CHECK: call float @__ocml_fabs_f32
+float l3 = fabsf(x);
+  }
+}
Index: clang/test/Headers/Inputs/include/utility
===
--- /dev/null
+++ clang/test/Headers/Inputs/include/utility
@@ -0,0 +1,2 @@
+#pragma once
+
Index: clang/test/Headers/Inputs/include/cstdlib
===
--- clang/test/Headers/Inputs/include/cstdlib
+++ clang/test/Headers/Inputs/include/cstdlib
@@ -27,3 +27,4 @@
 double abs(double __x) { return fabs(__x); }
 
 }
+
Index: clang/test/Headers/Inputs/inc

[PATCH] D106860: [clang][AArch64][SVE] Avoid going through memory for fixed/scalable predicate casts

2021-07-30 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 363093.
bsmith marked an inline comment as done.
bsmith added a comment.

- Update comment to reflect changes
- Add new test for lax casting via memory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106860

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c

Index: clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
@@ -49,20 +49,16 @@
 
 // CHECK-128-LABEL: @write_global_bool(
 // CHECK-128-NEXT:  entry:
-// CHECK-128-NEXT:[[SAVED_VALUE:%.*]] = alloca , align 16
-// CHECK-128-NEXT:store  [[V:%.*]], * [[SAVED_VALUE]], align 16, !tbaa [[TBAA9:![0-9]+]]
-// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast * [[SAVED_VALUE]] to <2 x i8>*
-// CHECK-128-NEXT:[[TMP0:%.*]] = load <2 x i8>, <2 x i8>* [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
-// CHECK-128-NEXT:store <2 x i8> [[TMP0]], <2 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
+// CHECK-128-NEXT:[[TMP0:%.*]] = bitcast  [[V:%.*]] to 
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = call <2 x i8> @llvm.experimental.vector.extract.v2i8.nxv2i8( [[TMP0]], i64 0)
+// CHECK-128-NEXT:store <2 x i8> [[CASTFIXEDSVE]], <2 x i8>* @global_bool, align 2, !tbaa [[TBAA6:![0-9]+]]
 // CHECK-128-NEXT:ret void
 //
 // CHECK-512-LABEL: @write_global_bool(
 // CHECK-512-NEXT:  entry:
-// CHECK-512-NEXT:[[SAVED_VALUE:%.*]] = alloca , align 16
-// CHECK-512-NEXT:store  [[V:%.*]], * [[SAVED_VALUE]], align 16, !tbaa [[TBAA9:![0-9]+]]
-// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast * [[SAVED_VALUE]] to <8 x i8>*
-// CHECK-512-NEXT:[[TMP0:%.*]] = load <8 x i8>, <8 x i8>* [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
-// CHECK-512-NEXT:store <8 x i8> [[TMP0]], <8 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
+// CHECK-512-NEXT:[[TMP0:%.*]] = bitcast  [[V:%.*]] to 
+// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = call <8 x i8> @llvm.experimental.vector.extract.v8i8.nxv2i8( [[TMP0]], i64 0)
+// CHECK-512-NEXT:store <8 x i8> [[CASTFIXEDSVE]], <8 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
 // CHECK-512-NEXT:ret void
 //
 void write_global_bool(svbool_t v) { global_bool = v; }
@@ -101,20 +97,16 @@
 
 // CHECK-128-LABEL: @read_global_bool(
 // CHECK-128-NEXT:  entry:
-// CHECK-128-NEXT:[[SAVED_VALUE:%.*]] = alloca <2 x i8>, align 16
 // CHECK-128-NEXT:[[TMP0:%.*]] = load <2 x i8>, <2 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
-// CHECK-128-NEXT:store <2 x i8> [[TMP0]], <2 x i8>* [[SAVED_VALUE]], align 16, !tbaa [[TBAA6]]
-// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast <2 x i8>* [[SAVED_VALUE]] to *
-// CHECK-128-NEXT:[[TMP1:%.*]] = load , * [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
+// CHECK-128-NEXT:[[CASTFIXEDSVE:%.*]] = call  @llvm.experimental.vector.insert.nxv2i8.v2i8( undef, <2 x i8> [[TMP0]], i64 0)
+// CHECK-128-NEXT:[[TMP1:%.*]] = bitcast  [[CASTFIXEDSVE]] to 
 // CHECK-128-NEXT:ret  [[TMP1]]
 //
 // CHECK-512-LABEL: @read_global_bool(
 // CHECK-512-NEXT:  entry:
-// CHECK-512-NEXT:[[SAVED_VALUE:%.*]] = alloca <8 x i8>, align 16
 // CHECK-512-NEXT:[[TMP0:%.*]] = load <8 x i8>, <8 x i8>* @global_bool, align 2, !tbaa [[TBAA6]]
-// CHECK-512-NEXT:store <8 x i8> [[TMP0]], <8 x i8>* [[SAVED_VALUE]], align 16, !tbaa [[TBAA6]]
-// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = bitcast <8 x i8>* [[SAVED_VALUE]] to *
-// CHECK-512-NEXT:[[TMP1:%.*]] = load , * [[CASTFIXEDSVE]], align 16, !tbaa [[TBAA6]]
+// CHECK-512-NEXT:[[CASTFIXEDSVE:%.*]] = call  @llvm.experimental.vector.insert.nxv2i8.v8i8( undef, <8 x i8> [[TMP0]], i64 0)
+// CHECK-512-NEXT:[[TMP1:%.*]] = bitcast  [[CASTFIXEDSVE]] to 
 // CHECK-512-NEXT:ret  [[TMP1]]
 //
 svbool_t read_global_bool() { return global_bool; }
Index: clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
===
--- clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
+++ clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
@@ -18,19 +18,15 @@
 // CHECK-NEXT:[[PRED_ADDR:%.*]] = alloca , align 2
 // CHECK-NEXT:[[VEC_ADDR:%.*]] = alloca , align 16
 // CHECK-NEXT:[[PG:%.*]] = alloca , align 2
-// CHECK-NEXT:[[SAVED_VALUE:%.*]] = alloca <8 x i8>, align 8
-// CHECK-NEXT:[[SAVED_VALUE1:%.*]] = alloca <8 x i8>, align 8
 // CHECK-NEXT:store  [[PRED:%.*]], * [[PRED_ADDR]], align 2
 // CHECK-NEXT:store  [[VEC:%.*]], * [[VEC_ADDR]], align 16
 // CHECK-NEXT:[[TMP

[clang] e6620a3 - Fix test that was never run.

2021-07-30 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2021-07-30T07:59:29-07:00
New Revision: e6620a351ecb87a75eca116399c5b359e3c63cc8

URL: 
https://github.com/llvm/llvm-project/commit/e6620a351ecb87a75eca116399c5b359e3c63cc8
DIFF: 
https://github.com/llvm/llvm-project/commit/e6620a351ecb87a75eca116399c5b359e3c63cc8.diff

LOG: Fix test that was never run.

Commit 83df122 (r368334) added 'REQUIRES: linux' to this test, but
because triples are not respected by REQUIRES, that meant it was
invariably Unsupported.  The correct keyword would be 'system-linux'
(checking the host rather than the target).

Because the test was always skipped, commit 0cfd9e5 (r375439) did not
notice that the test modification was incorrect.

This patch corrects the REQUIRES clause and fixes the incorrect
previous patch.

Found after implementing https://reviews.llvm.org/D107162

Added: 


Modified: 
clang/test/Driver/as-no-warnings.c

Removed: 




diff  --git a/clang/test/Driver/as-no-warnings.c 
b/clang/test/Driver/as-no-warnings.c
index 4338d117a6d0..a6671c631dba 100644
--- a/clang/test/Driver/as-no-warnings.c
+++ b/clang/test/Driver/as-no-warnings.c
@@ -2,20 +2,22 @@
 // RUN: %clang -### %s -c -o tmp.o -integrated-as -Wa,--no-warn 2>&1 | 
FileCheck %s
 
 /// -W is alias for --no-warn.
-// RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu 
-fno-integrated-as -Wa,-W 2>&1 | FileCheck -check-prefix=CHECK-NOIAS %s
+// RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu 
-fno-integrated-as -Wa,-W 2>&1 | FileCheck -check-prefix=CHECK-NOIASW %s
 // RUN: %clang -### %s -c -o tmp.o -integrated-as -Wa,-W 2>&1 | FileCheck %s
 
 // RUN: %clang %s -c -o %t.o -integrated-as -Wa,--no-warn 2>&1 | FileCheck 
-allow-empty --check-prefix=CHECK-AS-NOWARN %s
 // RUN: %clang %s -c -o %t.o -target i686-pc-linux-gnu -fno-integrated-as 
-Wa,--no-warn 2>&1 | FileCheck -allow-empty --check-prefix=CHECK-AS-NOWARN %s
+// RUN: %clang %s -c -o %t.o -target i686-pc-linux-gnu -fno-integrated-as 
-Wa,-W 2>&1 | FileCheck -allow-empty --check-prefix=CHECK-AS-NOWARN %s
 // RUN: not %clang %s -c -o %t.o -target i686-pc-linux-gnu -integrated-as 
-Wa,--fatal-warnings 2>&1 | FileCheck --check-prefix=CHECK-AS-FATAL %s
 // RUN: not %clang %s -c -o %t.o -target i686-pc-linux-gnu -fno-integrated-as 
-Wa,--fatal-warnings 2>&1 | FileCheck --check-prefix=CHECK-AS-FATAL %s
 
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
-// REQUIRES: linux
+// REQUIRES: system-linux
 
 // CHECK: "-cc1" {{.*}} "-massembler-no-warn"
 // CHECK-NOIAS: "--no-warn"
+// CHECK-NOIASW: "-W"
 // CHECK-AS-NOWARN-NOT: warning:
 // CHECK-AS-FATAL-NOT: warning:
 // CHECK-AS-FATAL: error



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


[PATCH] D107155: [clang][deps] Substitute clang-scan-deps executable in lit tests

2021-07-30 Thread Xun Li via Phabricator via cfe-commits
lxfind accepted this revision.
lxfind added a comment.
This revision is now accepted and ready to land.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107155

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


[clang] acc5850 - [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-30 Thread Anton Zabaznov via cfe-commits

Author: Anton Zabaznov
Date: 2021-07-30T18:10:25+03:00
New Revision: acc58504952f0e2ca48a44d868f684e3b135dd34

URL: 
https://github.com/llvm/llvm-project/commit/acc58504952f0e2ca48a44d868f684e3b135dd34
DIFF: 
https://github.com/llvm/llvm-project/commit/acc58504952f0e2ca48a44d868f684e3b135dd34.diff

LOG: [OpenCL] Add support of __opencl_c_pipes feature macro.

'pipe' keyword is introduced in OpenCL C 2.0: so do checks for OpenCL C version 
while
parsing and then later on check for language options to construct actual pipe. 
This feature
requires support of __opencl_c_generic_address_space, so diagnostics for that 
is provided as well.

This is the same patch as in D106748 but with a tiny fix in checking of 
diagnostic messages.
Also added tests when program scope global variables are not supported.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D107154

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/lib/Basic/OpenCLOptions.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/Sema.cpp
clang/test/CodeGenOpenCL/address-spaces-mangling.cl
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/pipe_builtin.cl
clang/test/CodeGenOpenCL/pipe_types.cl
clang/test/CodeGenOpenCL/pipe_types_mangling.cl
clang/test/Misc/opencl-c-3.0.incorrect_options.cl
clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
clang/test/SemaOpenCL/storageclass.cl

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 5c3d534c9b118..61a4dbdf856a8 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -224,7 +224,7 @@ LANGOPT(OpenCLVersion , 32, 0, "OpenCL C version")
 LANGOPT(OpenCLCPlusPlus   , 1, 0, "C++ for OpenCL")
 LANGOPT(OpenCLCPlusPlusVersion , 32, 0, "C++ for OpenCL version")
 LANGOPT(OpenCLGenericAddressSpace, 1, 0, "OpenCL generic keyword")
-LANGOPT(OpenCLPipe   , 1, 0, "OpenCL pipe keyword")
+LANGOPT(OpenCLPipes  , 1, 0, "OpenCL pipes language constructs and 
built-ins")
 LANGOPT(NativeHalfType, 1, 0, "Native half type support")
 LANGOPT(NativeHalfArgsAndReturns, 1, 0, "Native half args and returns")
 LANGOPT(HalfArgsAndReturns, 1, 0, "half args and returns")

diff  --git a/clang/lib/Basic/OpenCLOptions.cpp 
b/clang/lib/Basic/OpenCLOptions.cpp
index f4f474fade4db..b7408f39bdab4 100644
--- a/clang/lib/Basic/OpenCLOptions.cpp
+++ b/clang/lib/Basic/OpenCLOptions.cpp
@@ -112,7 +112,8 @@ bool OpenCLOptions::diagnoseUnsupportedFeatureDependencies(
   // supported.
   static const llvm::StringMap DependentFeaturesMap = {
   {"__opencl_c_read_write_images", "__opencl_c_images"},
-  {"__opencl_c_3d_image_writes", "__opencl_c_images"}};
+  {"__opencl_c_3d_image_writes", "__opencl_c_images"},
+  {"__opencl_c_pipes", "__opencl_c_generic_address_space"}};
 
   auto OpenCLFeaturesMap = TI.getSupportedOpenCLOpts();
 

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index b647a2fb8a679..5f8e04c2bd6c4 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -400,14 +400,18 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, 
LangOptions &Opts) {
 // OpenCL C v3.0 s6.7.5 - The generic address space requires support for
 // OpenCL C 2.0 or OpenCL C 3.0 with the __opencl_c_generic_address_space
 // feature
-// FIXME: OpenCLGenericAddressSpace is also defined in setLangDefaults()
+// OpenCL C v3.0 s6.2.1 - OpenCL pipes require support of OpenCL C 2.0
+// or later and __opencl_c_pipes feature
+// FIXME: These language options are also defined in setLangDefaults()
 // for OpenCL C 2.0 but with no access to target capabilities. Target
-// should be immutable once created and thus this language option needs
+// should be immutable once created and thus these language options need
 // to be defined only once.
-if (Opts.OpenCLVersion >= 300) {
+if (Opts.OpenCLVersion == 300) {
   const auto &OpenCLFeaturesMap = getSupportedOpenCLOpts();
   Opts.OpenCLGenericAddressSpace = hasFeatureEnabled(
   OpenCLFeaturesMap, "__opencl_c_generic_address_space");
+  Opts.OpenCLPipes =
+  hasFeatureEnabled(OpenCLFeaturesMap, "__opencl_c_pipes");
 }
   }
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index ae5c5d43318be..39335c4771fa3 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3173,7 +3173,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
 Opts.ZVector = 0;
 Opts.setDefaultFPContractMode(LangOptions::FP

[PATCH] D107154: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-30 Thread Anton Zabaznov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGacc58504952f: [OpenCL] Add support of __opencl_c_pipes 
feature macro. (authored by azabaznov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107154

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Basic/OpenCLOptions.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/CodeGenOpenCL/address-spaces-mangling.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/pipe_builtin.cl
  clang/test/CodeGenOpenCL/pipe_types.cl
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl
  clang/test/Misc/opencl-c-3.0.incorrect_options.cl
  clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/storageclass.cl

Index: clang/test/SemaOpenCL/storageclass.cl
===
--- clang/test/SemaOpenCL/storageclass.cl
+++ clang/test/SemaOpenCL/storageclass.cl
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
 static constant int G1 = 0;
Index: clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,+__opencl_c_program_scope_global_variables
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_pipes,+__opencl_c_generic_address_space,-__opencl_c_program_scope_global_variables
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error-re{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}} expected-error{{'write_only' attribute only applies to parameters and typedefs}}
+extern pipe write_only int get_pipe(); // expected-error {{'write_only' attribute only applies to parameters and typedefs}}
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 200) || (__OPENCL_C_VERSION__ == 300 && defined(__opencl_c_program_scope_global_variables))
+// expected-error-re@-2{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
+#else
+// FIXME: '__private' here makes no sense since program scope variables feature is not supported, should diagnose as '__global' probably
+// expected-error-re@-5{{type '__private write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
+#endif
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'__private reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
===
--- clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
+++ clang/test/SemaOpenCL/invalid-pipes-cl1.2.cl
@@ -1,9 +1,23 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_pipes,-__opencl_c_generic_address_space
 
 void foo(read_only pipe int p);
-// expected-warning@-1 {{type specifier missing, defaults to 'int'}}
-// expected-error@-2 {{access qualifier can only be used for pipe and image type}}
-// expected-error@-3 {{expected 

[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-07-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal updated this revision to Diff 363101.
steakhal added a comment.

Removed the deceiving `-DNO_ELIDE_FLAG` define from the c++17 run line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107078

Files:
  clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  clang/test/Analysis/loop-block-counts.c
  clang/test/Analysis/stack-addr-ps.cpp

Index: clang/test/Analysis/stack-addr-ps.cpp
===
--- clang/test/Analysis/stack-addr-ps.cpp
+++ clang/test/Analysis/stack-addr-ps.cpp
@@ -137,3 +137,28 @@
   }
 }
 
+void write_stack_address_to(char **q) {
+  char local;
+  *q = &local;
+  // expected-warning@-1 {{Address of stack memory associated with local \
+variable 'local' is still referred to by the stack variable 'p' upon \
+returning to the caller}}
+}
+
+void test_stack() {
+  char *p;
+  write_stack_address_to(&p);
+}
+
+struct C {
+  ~C() {} // non-trivial class
+};
+
+C make1() {
+  C c;
+  return c; // no-warning
+}
+
+void test_copy_elision() {
+  C c1 = make1();
+}
Index: clang/test/Analysis/loop-block-counts.c
===
--- clang/test/Analysis/loop-block-counts.c
+++ clang/test/Analysis/loop-block-counts.c
@@ -5,6 +5,9 @@
 void callee(void **p) {
   int x;
   *p = &x;
+  // expected-warning@-1 {{Address of stack memory associated with local \
+variable 'x' is still referred to by the stack variable 'arr' upon \
+returning to the caller}}
 }
 
 void loop() {
Index: clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ clang/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -71,12 +71,17 @@
   void *allocaPtr;
   int dontGetFilteredByNonPedanticMode = 0;
 
+  // expected-warning-re@+3 {{Address of stack memory allocated by call to \
+alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
+stack upon returning to the caller.  This will be a dangling reference}}
   UntypedAllocaTest() : allocaPtr(__builtin_alloca(sizeof(int))) {
 // All good!
   }
 };
 
 void fUntypedAllocaTest() {
+  // expected-note@+2 {{The temporary object gets destroyed at the end of the \
+full expression}}
   UntypedAllocaTest();
 }
 
@@ -86,9 +91,14 @@
 
   TypedAllocaTest1() // expected-warning{{1 uninitialized field}}
   : allocaPtr(static_cast(__builtin_alloca(sizeof(int {}
+  // expected-warning-re@-2 {{Address of stack memory allocated by call to \
+alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
+stack upon returning to the caller.  This will be a dangling reference}}
 };
 
 void fTypedAllocaTest1() {
+  // expected-note@+2 {{The temporary object gets destroyed at the end of the \
+full expression}}
   TypedAllocaTest1();
 }
 
@@ -96,6 +106,9 @@
   int *allocaPtr;
   int dontGetFilteredByNonPedanticMode = 0;
 
+  // expected-warning-re@+5 {{Address of stack memory allocated by call to \
+alloca() on line {{[0-9]+}} is still referred to by a temporary object on the \
+stack upon returning to the caller.  This will be a dangling reference}}
   TypedAllocaTest2()
   : allocaPtr(static_cast(__builtin_alloca(sizeof(int {
 *allocaPtr = 5;
@@ -104,6 +117,8 @@
 };
 
 void fTypedAllocaTest2() {
+  // expected-note@+2 {{The temporary object gets destroyed at the end of the \
+full expression}}
   TypedAllocaTest2();
 }
 
@@ -341,6 +356,9 @@
   void *&&vptrrref; // expected-note {{here}}
 
 public:
+  // expected-warning@+3 {{Address of stack memory associated with local \
+variable 'vptr' is still referred to by a temporary object on the stack \
+upon returning to the caller.  This will be a dangling reference}}
   VoidPointerRRefTest1(void *vptr, char) : vptrrref(static_cast(vptr)) { // expected-warning {{binding reference member 'vptrrref' to stack allocated parameter 'vptr'}}
 // All good!
   }
@@ -349,12 +367,17 @@
 void fVoidPointerRRefTest1() {
   void *vptr = malloc(sizeof(int));
   VoidPointerRRefTest1(vptr, char());
+  // expected-note@-1 {{The temporary object gets destroyed at the end of the \
+full expression}}
 }
 
 class VoidPointerRRefTest2 {
   void **&&vpptrrref; // expected-note {{here}}
 
 public:
+  // expected-warning@+3 {{Address of stack memory associated with local \
+variable 'vptr' is still referred to by a temporary object on the stack \
+upon returning to the caller.  This will be a dangling reference}}
   VoidPointerRRefTest2(void **vptr, char) : vpptrrref(static_cast(vptr)) { // expected-warning {{binding reference member 'vpptrrref' to stack allocated parameter 'vptr'}}
 // All good!
   }
@@ -363,12 +386,17 @@
 void fVoidPointerRRefTest2() {
   void *vptr = malloc(si

[PATCH] D107078: [analyzer] Catch leaking stack addresses via stack variables

2021-07-30 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added inline comments.



Comment at: clang/test/Analysis/copy-elision.cpp:9-10
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-std=c++17 \
+// RUN:-analyzer-config elide-constructors=false -DNO_ELIDE_FLAG   
   \
+// RUN:-analyzer-config eagerly-assume=false -verify %s
 

martong wrote:
> steakhal wrote:
> > martong wrote:
> > > Should we use `-verify=no-elide` here as well? Since we set the 
> > > `DNO_ELIDE_FLAG`?
> > According to  the comment a few lines below:
> > > Copy elision always occurs in C++17, otherwise it's under an 
> > > on-by-default flag.
> > 
> > So I think even though one passes the `elide-constructors=false` analyzer 
> > config, we follow the language semantics, which requires us to elide those 
> > copies, thus no copy should happen.
> If copy elision always occur then `DNO_ELIDE_FLAG` has no effect, and as such 
> it is misleading to have it in this RUN line.
You are right. Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107078

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


[PATCH] D107155: [clang][deps] Substitute clang-scan-deps executable in lit tests

2021-07-30 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Hmm, don't we have some other substitution feature that avoids the need to add 
the %? (like, I think LLVM's tests don't usually use the % for many tool names 
- but they still make for good copy/pastable command lines, if I'm not 
mistaken?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107155

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


[PATCH] D107145: clangd: Add new semantic token modifier "virtual"

2021-07-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 363106.
ckandeler added a comment.

Fixed lit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107145

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -642,9 +642,14 @@
 )cpp",
   R"cpp(
   class $Class_decl_abstract[[Abstract]] {
-virtual void $Method_decl_abstract[[pure]]() = 0;
-virtual void $Method_decl[[impl]]();
+  public:
+virtual void $Method_decl_abstract_virtual[[pure]]() = 0;
+virtual void $Method_decl_virtual[[impl]]();
   };
+  void $Function_decl[[foo]]($Class_abstract[[Abstract]]* $Parameter_decl[[A]]) {
+  $Parameter[[A]]->$Method_abstract_virtual[[pure]]();
+  $Parameter[[A]]->$Method_virtual[[impl]]();
+  }
   )cpp",
   R"cpp(
   <:[deprecated]:> int $Variable_decl_deprecated[[x]];
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  2049
+# CHECK-NEXT:  4097
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  2049
+# CHECK-NEXT:  4097
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  2049,
+# CHECK-NEXT:  4097,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  2049
+# CHECK-NEXT:  4097
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -88,6 +88,7 @@
 # CHECK-NEXT:"readonly",
 # CHECK-NEXT:"static",
 # CHECK-NEXT:"abstract",
+# CHECK-NEXT:"virtual",
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"functionScope",
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -66,6 +66,7 @@
   Readonly,
   Static,
   Abstract,
+  Virtual,
   DependentName,
   DefaultLibrary,
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -240,6 +240,12 @@
   return false;
 }
 
+bool isVirtual(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isVirtual();
+  return false;
+}
+
 bool isDependent(const Decl *D) {
   if (isa(D))
 return true;
@@ -712,6 +718,8 @@
 Tok.addModifier(HighlightingModifier::Static);
   if (isAbstract(Decl))
 Tok.addModifier(HighlightingModifier::Abstract);
+  if (isVirtual(Decl))
+Tok.addModifier(HighlightingModifier::Virtual);
   if (isDependent(Decl))
 Tok.addModifier(HighlightingModifier::DependentName);
   if (isDefaultLibrary(Decl))
@@ -898,6 +906,8 @@
 return "deduced"; // nonstandard
   case HighlightingModifier::Abstract:
 return "abstract";
+  case HighlightingModifier::Virtual:
+return "virtual";
   case HighlightingModifier::DependentName:
 return "dependentName"; // nonstandard
   case HighlightingModifier::DefaultLibrary:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c0fa174 - Add triples to try to fix a test

2021-07-30 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2021-07-30T08:35:42-07:00
New Revision: c0fa174d63ad68f290745aaa6600cede1ad0a25d

URL: 
https://github.com/llvm/llvm-project/commit/c0fa174d63ad68f290745aaa6600cede1ad0a25d
DIFF: 
https://github.com/llvm/llvm-project/commit/c0fa174d63ad68f290745aaa6600cede1ad0a25d.diff

LOG: Add triples to try to fix a test

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/105/builds/13139
which provides no details about why it failed.

Added: 


Modified: 
clang/test/Driver/as-no-warnings.c

Removed: 




diff  --git a/clang/test/Driver/as-no-warnings.c 
b/clang/test/Driver/as-no-warnings.c
index a6671c631dba..9c2b3f096872 100644
--- a/clang/test/Driver/as-no-warnings.c
+++ b/clang/test/Driver/as-no-warnings.c
@@ -1,11 +1,11 @@
 // RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu 
-fno-integrated-as -Wa,--no-warn 2>&1 | FileCheck -check-prefix=CHECK-NOIAS %s
-// RUN: %clang -### %s -c -o tmp.o -integrated-as -Wa,--no-warn 2>&1 | 
FileCheck %s
+// RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as 
-Wa,--no-warn 2>&1 | FileCheck %s
 
 /// -W is alias for --no-warn.
 // RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu 
-fno-integrated-as -Wa,-W 2>&1 | FileCheck -check-prefix=CHECK-NOIASW %s
-// RUN: %clang -### %s -c -o tmp.o -integrated-as -Wa,-W 2>&1 | FileCheck %s
+// RUN: %clang -### %s -c -o tmp.o -target i686-pc-linux-gnu -integrated-as 
-Wa,-W 2>&1 | FileCheck %s
 
-// RUN: %clang %s -c -o %t.o -integrated-as -Wa,--no-warn 2>&1 | FileCheck 
-allow-empty --check-prefix=CHECK-AS-NOWARN %s
+// RUN: %clang %s -c -o %t.o -target i686-pc-linux-gnu -integrated-as 
-Wa,--no-warn 2>&1 | FileCheck -allow-empty --check-prefix=CHECK-AS-NOWARN %s
 // RUN: %clang %s -c -o %t.o -target i686-pc-linux-gnu -fno-integrated-as 
-Wa,--no-warn 2>&1 | FileCheck -allow-empty --check-prefix=CHECK-AS-NOWARN %s
 // RUN: %clang %s -c -o %t.o -target i686-pc-linux-gnu -fno-integrated-as 
-Wa,-W 2>&1 | FileCheck -allow-empty --check-prefix=CHECK-AS-NOWARN %s
 // RUN: not %clang %s -c -o %t.o -target i686-pc-linux-gnu -integrated-as 
-Wa,--fatal-warnings 2>&1 | FileCheck --check-prefix=CHECK-AS-FATAL %s



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


[PATCH] D107049: [clang-repl] Re-implement clang-interpreter as a test case.

2021-07-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a reviewer: rnk.
v.g.vassilev added a subscriber: rnk.
v.g.vassilev added inline comments.



Comment at: clang/unittests/Interpreter/InterpreterTest.cpp:134
+  // Instead we expect std::terminate to be called upon thrown exception.
+  EXPECT_DEATH(Main(), "terminate called after throwing an instance of '.*'");
+  std::string CapturedStdOut = testing::internal::GetCapturedStdout();

@rnk, would that test here be fine for both win32 and win64. Sorry for asking 
but I do not have an easy access to a Windows machine.


Repository:
  rC Clang

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

https://reviews.llvm.org/D107049

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


[PATCH] D105907: [CallGraphSection] Add call graph section options and documentation

2021-07-30 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Looks like the RFC threads didn't have any discussion - I think that'll be 
necessary before moving forward with/committing any work here, for what it's 
worth. Perhaps some Apple folks would have some interest since they use ARM and 
sanitizers a lot & probably care about performance of those things together too?

Might be worth looking at the overall feature this is part of - efficient call 
stack retrieval/rebuilding, by the sounds of it/from what I understand of the 
original proposal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105907

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


[clang] aa35c49 - [AIX] Pass the -b option to linker on AIX (with fix to build break)

2021-07-30 Thread Anjan Kumar via cfe-commits

Author: Anjan Kumar
Date: 2021-07-30T15:50:52Z
New Revision: aa35c496cf53627147f45adb84fc70ba4f81a38f

URL: 
https://github.com/llvm/llvm-project/commit/aa35c496cf53627147f45adb84fc70ba4f81a38f
DIFF: 
https://github.com/llvm/llvm-project/commit/aa35c496cf53627147f45adb84fc70ba4f81a38f.diff

LOG: [AIX] Pass the -b option to linker on AIX (with fix to build break)

This patch will re-enable the patch posted under 
https://reviews.llvm.org/D106688 originally which was reverted due to 
buildbreak that was caused by mismatched diagnostic message arguments.

Reviewed By: Zarko Todorovski

Differential Revision: https://reviews.llvm.org/D107105

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/Xlinker-args.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 819beaffbf9f..64d612d7dbd1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -815,7 +815,9 @@ def autocomplete : Joined<["--"], "autocomplete=">;
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
+def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
+  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
+  Group;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d9a6599a2416..00bc92a1933b 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@ void tools::AddLinkerInputs(const ToolChain &TC, const 
InputInfoList &Inputs,
 // Otherwise, this is a linker input argument.
 const Arg &A = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple &T = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << A.getSpelling() << T.str();
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);
+}
 // Handle reserved library options.
 if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);

diff  --git a/clang/test/Driver/Xlinker-args.c 
b/clang/test/Driver/Xlinker-args.c
index cb045a1d40ac..0ae5cb386672 100644
--- a/clang/test/Driver/Xlinker-args.c
+++ b/clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \



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


[PATCH] D107105: [AIX] Pass the -b option to linker on AIX (with fix to build break)

2021-07-30 Thread Anjan Kumar 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 rGaa35c496cf53: [AIX] Pass the -b option to linker on AIX 
(with fix to build break) (authored by anjankgk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107105

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/Xlinker-args.c


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@
 // Otherwise, this is a linker input argument.
 const Arg &A = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple &T = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << A.getSpelling() << T.str();
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);
+}
 // Handle reserved library options.
 if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx))
   TC.AddCXXStdlibLibArgs(Args, CmdArgs);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -815,7 +815,9 @@
 def bind__at__load : Flag<["-"], "bind_at_load">;
 def bundle__loader : Separate<["-"], "bundle_loader">;
 def bundle : Flag<["-"], "bundle">;
-def b : JoinedOrSeparate<["-"], "b">, Flags<[Unsupported]>;
+def b : JoinedOrSeparate<["-"], "b">, Flags<[LinkerInput, RenderAsInput]>,
+  HelpText<"Pass -b  to the linker on AIX (only).">, MetaVarName<"">,
+  Group;
 def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group, 
Flags<[CC1Option]>,
   HelpText<"OpenCL only. This option disables all optimizations. By default 
optimizations are enabled.">;
 def cl_strict_aliasing : Flag<["-"], "cl-strict-aliasing">, 
Group, Flags<[CC1Option]>,


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -11,10 +11,20 @@
 // RUN:   -e _start -T a.lds -Xlinker one -Xlinker --no-demangle \
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
-//
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s
+
+// RUN: %clang -target powerpc-unknown-linux -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=NOT-AIX < %t %s
+
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" "-r" {{.*}} "-T" "a.lds"
+// AIX: "-b" "one" 
+// NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
 // Check that we forward '-Xlinker' and '-Wl,' on Windows.
 // RUN: %clang -target i686-pc-win32 -fuse-ld=link -### \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -257,6 +257,16 @@
 // Otherwise, this is a linker input argument.
 const Arg &A = II.getInputArg();
 
+if (A.getOption().matches(options::OPT_b)) {
+  const llvm::Triple &T = TC.getTriple();
+  if (!T.isOSAIX()) {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt_for_target)
+  << A.getSpelling() << T.str();
+  }
+  // Pass -b prefix for AIX linker.
+  A.claim();
+  A.render(Args, CmdArgs);

[PATCH] D106410: [PowerPC] Emit error for Altivec vector initializations when -faltivec-src-compat=gcc is specified

2021-07-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked an inline comment as done.
amyk added a comment.

Addressed Nemanja's comment on the commit. 
https://reviews.llvm.org/rG5ea6117a9e9eae49ad1295fa422266ef3832e419


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106410

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


[PATCH] D106739: [analyzer] Add option to SATest.py for extra checkers

2021-07-30 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

In D106739#2907647 , @ASDenysPetrov 
wrote:

> @RedDocMD Could you, please, explain the motivation and add at least one test 
> to verify it works.

Motivation: I need to run these projects with the SmartPtrChecker enabled 
(which is an alpha checker, hence not enabled by default).
Test: This is more of a helper script, not a core library, so I think we can be 
a little relaxed with the testing thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106739

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


[clang] 9ca905b - XFAIL a test on ppc64

2021-07-30 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2021-07-30T09:05:14-07:00
New Revision: 9ca905b52d53c46aceb4d28e44dfbf4a815d0c68

URL: 
https://github.com/llvm/llvm-project/commit/9ca905b52d53c46aceb4d28e44dfbf4a815d0c68
DIFF: 
https://github.com/llvm/llvm-project/commit/9ca905b52d53c46aceb4d28e44dfbf4a815d0c68.diff

LOG: XFAIL a test on ppc64

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/105/builds/13141
which provides no details about why it failed, but the only failure
reports are for ppc64 bots.

Added: 


Modified: 
clang/test/Driver/as-no-warnings.c

Removed: 




diff  --git a/clang/test/Driver/as-no-warnings.c 
b/clang/test/Driver/as-no-warnings.c
index 9c2b3f096872..77971389ee65 100644
--- a/clang/test/Driver/as-no-warnings.c
+++ b/clang/test/Driver/as-no-warnings.c
@@ -14,6 +14,7 @@
 // REQUIRES: clang-driver
 // REQUIRES: x86-registered-target
 // REQUIRES: system-linux
+// XFAIL: ppc64
 
 // CHECK: "-cc1" {{.*}} "-massembler-no-warn"
 // CHECK-NOIAS: "--no-warn"



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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-30 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:16114
+Intrinsic::ID IID;
+llvm::Type *ArgTy = llvm::Type::getDoubleTy(getLLVMContext());
+switch (BuiltinID) {

arsenm wrote:
> Initializing this here is strange, sink down to the double case
You mean push it down after line 16119?



Comment at: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl:112
+kernel void test_flat_global_max(__global double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fmax_f64(addr, x, memory_order_relaxed);
+}

arsenm wrote:
> If you're going to bother testing the ISA, is it worth testing rtn and no rtn 
> versions?
Sorry, what do you mean by rtn version?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-30 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

Passed PSDB


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

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


[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsAMDGPU.def:201
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_f32, "ff*1fi", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_2f16, "hh*1hi", "t", 
"gfx90a-insts")
+TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fmin_f64, "dd*1di", "t", 
"gfx90a-insts")

yaxunl wrote:
> arsenm wrote:
> > "_2f16" looks weird to me. The instruction names call it "pk"
> This is to have a consistent postfix naming convention, since the stem part 
> here are the same. the postfix is for the argument type of the builtin 
> function.
Just a plain 2 isn't consistent either. The llvm type naming convention would 
add a v prefix, but the builtins should probably follow the instructions



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:16114
+Intrinsic::ID IID;
+llvm::Type *ArgTy = llvm::Type::getDoubleTy(getLLVMContext());
+switch (BuiltinID) {

gandhi21299 wrote:
> arsenm wrote:
> > Initializing this here is strange, sink down to the double case
> You mean push it down after line 16119?
Yes



Comment at: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl:112
+kernel void test_flat_global_max(__global double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fmax_f64(addr, x, memory_order_relaxed);
+}

gandhi21299 wrote:
> arsenm wrote:
> > If you're going to bother testing the ISA, is it worth testing rtn and no 
> > rtn versions?
> Sorry, what do you mean by rtn version?
Most atomics can be optimized if they don't return the in memory value if the 
value is unused


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106909

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


  1   2   >