[PATCH] D80228: [clang-format] [PR33890] Add support for Microsoft C++/CLI non standard for each looping extension

2020-05-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcc918e90c048: [clang-format] [PR33890] Add support for 
Microsoft C++/CLI non standard for… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80228

Files:
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/FormatTokenLexer.h
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -994,6 +994,9 @@
"#define Q_FOREACH (x, y)\n"
"#define BOOST_FOREACH (x, y)\n"
"#define UNKNOWN_FOREACH (x, y)\n");
+
+  // handle microsoft non standard extension
+  verifyFormat("for each (char c in x->MyStringProperty)");
 }
 
 TEST_F(FormatTest, FormatsWhileLoop) {
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -55,6 +55,7 @@
   bool tryMergeCSharpDoubleQuestion();
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
+  bool tryMergeForEach();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,8 @@
 return;
   if (tryMergeLessLess())
 return;
+  if (tryMergeForEach())
+return;
 
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
@@ -359,6 +361,28 @@
   return true;
 }
 
+bool FormatTokenLexer::tryMergeForEach() {
+  if (Tokens.size() < 2)
+return false;
+  auto &For = *(Tokens.end() - 2);
+  auto &Each = *(Tokens.end() - 1);
+  if (!For->is(tok::kw_for))
+return false;
+  if (!Each->is(tok::identifier))
+return false;
+  if (Each->TokenText != "each")
+return false;
+
+  For->setType(TT_ForEachMacro);
+  For->Tok.setKind(tok::kw_for);
+
+  For->TokenText = StringRef(For->TokenText.begin(),
+ Each->TokenText.end() - For->TokenText.begin());
+  For->ColumnWidth += Each->ColumnWidth;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -994,6 +994,9 @@
"#define Q_FOREACH (x, y)\n"
"#define BOOST_FOREACH (x, y)\n"
"#define UNKNOWN_FOREACH (x, y)\n");
+
+  // handle microsoft non standard extension
+  verifyFormat("for each (char c in x->MyStringProperty)");
 }
 
 TEST_F(FormatTest, FormatsWhileLoop) {
Index: clang/lib/Format/FormatTokenLexer.h
===
--- clang/lib/Format/FormatTokenLexer.h
+++ clang/lib/Format/FormatTokenLexer.h
@@ -55,6 +55,7 @@
   bool tryMergeCSharpDoubleQuestion();
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
+  bool tryMergeForEach();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,8 @@
 return;
   if (tryMergeLessLess())
 return;
+  if (tryMergeForEach())
+return;
 
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
@@ -359,6 +361,28 @@
   return true;
 }
 
+bool FormatTokenLexer::tryMergeForEach() {
+  if (Tokens.size() < 2)
+return false;
+  auto &For = *(Tokens.end() - 2);
+  auto &Each = *(Tokens.end() - 1);
+  if (!For->is(tok::kw_for))
+return false;
+  if (!Each->is(tok::identifier))
+return false;
+  if (Each->TokenText != "each")
+return false;
+
+  For->setType(TT_ForEachMacro);
+  For->Tok.setKind(tok::kw_for);
+
+  For->TokenText = StringRef(For->TokenText.begin(),
+ Each->TokenText.end() - For->TokenText.begin());
+  For->ColumnWidth += Each->ColumnWidth;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79325: [clang-format] [PR42164] Add Option to Break before While

2020-05-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG807ab2cd0db3: [clang-format] [PR42164] Add Option to Break 
before While (authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D79325?vs=264235&id=265153#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79325

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1706,6 +1706,22 @@
 format("try{foo();}catch(...){baz();}", Style));
 }
 
+TEST_F(FormatTest, BeforeWhile) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BraceBreakingStyle::BS_Custom;
+
+  verifyFormat("do {\n"
+   "  foo();\n"
+   "} while (1);",
+   Style);
+  Style.BraceWrapping.BeforeWhile = true;
+  verifyFormat("do {\n"
+   "  foo();\n"
+   "}\n"
+   "while (1);",
+   Style);
+}
+
 //===--===//
 // Tests for classes, namespaces, etc.
 //===--===//
@@ -13543,6 +13559,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyRecord);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2175,7 +2175,7 @@
   if (FormatTok->Tok.is(tok::l_brace)) {
 CompoundStatementIndenter Indenter(this, Style, Line->Level);
 parseBlock(/*MustBeDeclaration=*/false);
-if (Style.BraceWrapping.IndentBraces)
+if (Style.BraceWrapping.BeforeWhile)
   addUnwrappedLine();
   } else {
 addUnwrappedLine();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -604,6 +604,7 @@
 IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
 IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
 IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
+IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
 IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
 IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
 IO.mapOptional("SplitEmptyRecord", Wrapping.SplitEmptyRecord);
@@ -687,12 +688,24 @@
   if (Style.BreakBeforeBraces == FormatStyle::BS_Custom)
 return Style;
   FormatStyle Expanded = Style;
-  Expanded.BraceWrapping = {false, false, FormatStyle::BWACS_Never,
-false, false, false,
-false, false, false,
-false, false, false,
-false, false, true,
-true,  true};
+  Expanded.BraceWrapping = {/*AfterCaseLabel=*/false,
+/*AfterClass=*/false,
+/*AfterControlStatement=*/FormatStyle::BWACS_Never,
+/*AfterEnum=*/false,
+/*AfterFunction=*/false,
+/*AfterNamespace=*/false,
+/*AfterObjCDeclaration=*/false,
+/*AfterStruct=*/false,
+/*AfterUnion=*/false,
+/*AfterExternBlock=*/false,
+/*BeforeCatch=*/false,
+/*BeforeElse=*/false,
+/*BeforeLambdaBody=*/false,
+/*BeforeWhile=*/false,
+/*IndentBraces=*/false,
+/*SplitEmptyFunction=*/true,
+/*SplitEmptyRecord=*/true,
+/*SplitEmptyNamespace=*/true};
   switch (Style.BreakBeforeBraces) {
   case FormatStyle::BS_Linux:
 Expanded.BraceWrapping.AfterClass = true;
@@ -743,12 +756,25 @@
 Expanded.BraceWrapping.BeforeLambdaBody = true;
 break;
   case FormatStyle::BS_GNU:
-Expanded.BraceWrapping = {true,  true, FormatStyle::BWACS_Always,
-  true,  true, true,
-   

[PATCH] D80176: [clang-format][PR45816] Add AlignConsecutiveBitFields

2020-05-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb99bf0e08be4: [clang-format][PR45816] Add 
AlignConsecutiveBitFields (authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D80176?vs=265048&id=265152#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80176

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12022,6 +12022,48 @@
Alignment));
 }
 
+TEST_F(FormatTest, AlignConsecutiveBitFields) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveBitFields = true;
+  verifyFormat("int const a : 5;\n"
+   "int oneTwoThree : 23;",
+   Alignment);
+
+  // Initializers are allowed starting with c++2a
+  verifyFormat("int const a : 5 = 1;\n"
+   "int oneTwoThree : 23 = 0;",
+   Alignment);
+
+  Alignment.AlignConsecutiveDeclarations = true;
+  verifyFormat("int const a   : 5;\n"
+   "int   oneTwoThree : 23;",
+   Alignment);
+
+  verifyFormat("int const a   : 5;  // comment\n"
+   "int   oneTwoThree : 23; // comment",
+   Alignment);
+
+  verifyFormat("int const a   : 5 = 1;\n"
+   "int   oneTwoThree : 23 = 0;",
+   Alignment);
+
+  Alignment.AlignConsecutiveAssignments = true;
+  verifyFormat("int const a   : 5  = 1;\n"
+   "int   oneTwoThree : 23 = 0;",
+   Alignment);
+  verifyFormat("int const a   : 5  = {1};\n"
+   "int   oneTwoThree : 23 = 0;",
+   Alignment);
+
+  // Known limitations: ':' is only recognized as a bitfield colon when
+  // followed by a number.
+  /*
+  verifyFormat("int oneTwoThree : SOME_CONSTANT;\n"
+   "int a   : 5;",
+   Alignment);
+  */
+}
+
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = true;
@@ -13436,6 +13478,7 @@
   Style.Language = FormatStyle::LK_Cpp;
   CHECK_PARSE_BOOL(AlignTrailingComments);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
+  CHECK_PARSE_BOOL(AlignConsecutiveBitFields);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AlignConsecutiveMacros);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
Index: clang/lib/Format/WhitespaceManager.h
===
--- clang/lib/Format/WhitespaceManager.h
+++ clang/lib/Format/WhitespaceManager.h
@@ -184,6 +184,9 @@
   /// Align consecutive assignments over all \c Changes.
   void alignConsecutiveAssignments();
 
+  /// Align consecutive bitfields over all \c Changes.
+  void alignConsecutiveBitFields();
+
   /// Align consecutive declarations over all \c Changes.
   void alignConsecutiveDeclarations();
 
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -95,6 +95,7 @@
   calculateLineBreakInformation();
   alignConsecutiveMacros();
   alignConsecutiveDeclarations();
+  alignConsecutiveBitFields();
   alignConsecutiveAssignments();
   alignChainedConditionals();
   alignTrailingComments();
@@ -617,6 +618,26 @@
   Changes, /*StartAt=*/0);
 }
 
+void WhitespaceManager::alignConsecutiveBitFields() {
+  if (!Style.AlignConsecutiveBitFields)
+return;
+
+  AlignTokens(
+  Style,
+  [&](Change const &C) {
+// Do not align on ':' that is first on a line.
+if (C.NewlinesBefore > 0)
+  return false;
+
+// Do not align on ':' that is last on a line.
+if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)
+  return false;
+
+return C.Tok->is(TT_BitFieldColon);
+  },
+  Changes, /*StartAt=*/0);
+}
+
 void WhitespaceManager::alignConsecutiveDeclarations() {
   if (!Style.AlignConsecutiveDeclarations)
 return;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -403,6 +403,8 @@
 IO.mapOptional("AlignConsecutiveMacros", Style.AlignConsecutiveMacros);
 IO.mapOptional("AlignConsecutiveAssignments",
Style.AlignConsecutiveAssignments);
+IO.mapOptional("AlignConsecutiveBitFields",
+   Style.AlignConsecutiveBitFields);

[PATCH] D80237: [hip] Ensure pointer in struct argument has proper `addrspacecast`.

2020-05-19 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 265148.
hliao added a comment.

Revise following comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80237

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu

Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -1,37 +1,52 @@
-// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s --check-prefixes=COMMON,OPT
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - | FileCheck -check-prefix=HOST %s
 
 #include "Inputs/cuda.h"
 
 // Coerced struct from `struct S` without all generic pointers lowered into
 // global ones.
-// CHECK: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
-// CHECK: %struct.T.coerce = type { [2 x float addrspace(1)*] }
+// COMMON: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
+// COMMON: %struct.T.coerce = type { [2 x float addrspace(1)*] }
 
 // On the host-side compilation, generic pointer won't be coerced.
 // HOST-NOT: %struct.S.coerce
 // HOST-NOT: %struct.T.coerce
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
 // HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel1Pi(i32 addrspace(1)*{{.*}} %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: inttoptr
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* nonnull align 4 dereferenceable(4) %x.coerce)
 // HOST: define void @_Z22__device_stub__kernel2Ri(i32* nonnull align 4 dereferenceable(4) %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel2Ri(i32 addrspace(1)*{{.*}} nonnull align 4 dereferenceable(4) %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __global__ void kernel2(int &x) {
   x++;
 }
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
 // HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
+// CHECK-LABEL: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)*{{.*}} %x, i32 addrspace(1)*{{.*}} %y)
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
 }
 
-// CHECK: define void @_Z4funcPi(i32* %x)
+// COMMON-LABEL: define void @_Z4funcPi(i32*{{.*}} %x)
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __device__ void func(int *x) {
   x[0]++;
 }
@@ -42,16 +57,26 @@
 };
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
-// CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
 // HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* %s.coerce1)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
+// CHECK-COUNT-2: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __global__ void kernel4(struct S s) {
   s.x[0]++;
   s.y[0] += 1.f;
 }
 
 // If a pointer to struct is passed, only the pointer itself is coerced into the global one.
-// CHECK: define amdgpu_kernel void @_Z7kernel5P1S(%struct.S addrspace(1)* %s.coerce)
 // HOST: define void @_Z22__device_stub__kernel5P1S(%struct.S* %s)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel5P1S(%struct.S addrspace(1)*{{.*}} %s.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __global__ void kernel5(struct S *s) {
   s->x[0]++;
   s->y[0] += 1.f;
@@ -61,16 +86,26 @@
   float *x[2];
 };
 // `

[clang] 807ab2c - [clang-format] [PR42164] Add Option to Break before While

2020-05-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-20T07:48:45+01:00
New Revision: 807ab2cd0db398c420ca5b8a7fc260aaea5051a1

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

LOG: [clang-format] [PR42164] Add Option to Break before While

Summary:
Its currently not possible to recreate the GNU style using the 
`BreakBeforeBraces: Custom` style due to a lack of missing `BeforeWhile` in the 
`BraceWrappingFlags`

The following request was raised to add `BeforeWhile` in a `do..while` context 
like `BeforeElse` and `BeforeCatch` to give greater control over the 
positioning of the `while`

https://bugs.llvm.org/show_bug.cgi?id=42164

Reviewers: krasimir, mitchell-stellar, sammccall

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index c4d6c1d50d13..e5a5fd154849 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1025,6 +1025,21 @@ the configuration (without a prefix: ``Auto``).
 bar();
   });
 
+  * ``bool BeforeWhile`` Wrap before ``while``.
+
+.. code-block:: c++
+
+  true:
+  do {
+foo();
+  }
+  while (1);
+
+  false:
+  do {
+foo();
+  } while (1);
+
   * ``bool IndentBraces`` Indent the wrapped braces themselves.
 
   * ``bool SplitEmptyFunction`` If ``false``, empty function body can be put 
on a single line.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 06b01420ca4e..48c1c9ea019d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -312,6 +312,27 @@ clang-format
 bool a : 1;
 bool bb : 1;
 
+- Option ``BraceWrapping.BeforeWhile`` has been added to allow wrapping
+  before the ```while`` in a do..while loop. By default the value is 
(``false``)
+
+  In previous releases ``IndentBraces`` implied ``BraceWrapping.BeforeWhile``.
+  If using a Custom BraceWrapping style you may need to now set 
+  ``BraceWrapping.BeforeWhile`` to (``true``) to be explicit.
+
+  .. code-block:: c++
+
+  true:
+  do {
+foo();
+  }
+  while(1);
+
+  false:
+  do {
+foo();
+  } while(1);
+
+
 libclang
 
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7083a46b5b14..05a9cd2d418d 100755
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1076,6 +1076,20 @@ struct FormatStyle {
 ///   });
 /// \endcode
 bool BeforeLambdaBody;
+/// Wrap before ``while``.
+/// \code
+///   true:
+///   do {
+/// foo();
+///   }
+///   while (1);
+///
+///   false:
+///   do {
+/// foo();
+///   } while (1);
+/// \endcode
+bool BeforeWhile;
 /// Indent the wrapped braces themselves.
 bool IndentBraces;
 /// If ``false``, empty function body can be put on a single line.

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 418ace7376ff..79e9f35de707 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -604,6 +604,7 @@ template <> struct 
MappingTraits {
 IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
 IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
 IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
+IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
 IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
 IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
 IO.mapOptional("SplitEmptyRecord", Wrapping.SplitEmptyRecord);
@@ -687,12 +688,24 @@ static FormatStyle expandPresets(const FormatStyle 
&Style) {
   if (Style.BreakBeforeBraces == FormatStyle::BS_Custom)
 return Style;
   FormatStyle Expanded = Style;
-  Expanded.BraceWrapping = {false, false, FormatStyle::BWACS_Never,
-false, false, false,
-false, false, false,
-false, false, false,
-false, false, true,
-true,  true};
+  Expanded.BraceWrapping = {/*AfterCaseLabel=*/false,
+/*AfterClass=*/false,
+/*AfterControlStatement=*/FormatStyle::BWACS_Never,
+/*AfterEnum=*/false,
+/*AfterFu

[clang] cc918e9 - [clang-format] [PR33890] Add support for Microsoft C++/CLI non standard for each looping extension

2020-05-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-20T07:44:36+01:00
New Revision: cc918e90c048c6c9a59ed08e7b2a2f92b4ac8140

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

LOG: [clang-format] [PR33890] Add support for Microsoft C++/CLI non standard 
for each looping extension

Summary:
https://bugs.llvm.org/show_bug.cgi?id=33890

This revision allow the microsoft `for each( in ...` nonstandard C++ 
extension which can be used in C++/CLI to be handled as a ForEach macro.

This prevents the breaking between the for and each onto a new line

Reviewed By: JakeMerdichAMD

Subscribers: cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/FormatTokenLexer.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 249d3ac39c3e..b6cbebdcbe7f 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,8 @@ void FormatTokenLexer::tryMergePreviousTokens() {
 return;
   if (tryMergeLessLess())
 return;
+  if (tryMergeForEach())
+return;
 
   if (Style.isCSharp()) {
 if (tryMergeCSharpKeywordVariables())
@@ -359,6 +361,28 @@ bool FormatTokenLexer::tryTransformCSharpForEach() {
   return true;
 }
 
+bool FormatTokenLexer::tryMergeForEach() {
+  if (Tokens.size() < 2)
+return false;
+  auto &For = *(Tokens.end() - 2);
+  auto &Each = *(Tokens.end() - 1);
+  if (!For->is(tok::kw_for))
+return false;
+  if (!Each->is(tok::identifier))
+return false;
+  if (Each->TokenText != "each")
+return false;
+
+  For->setType(TT_ForEachMacro);
+  For->Tok.setKind(tok::kw_for);
+
+  For->TokenText = StringRef(For->TokenText.begin(),
+ Each->TokenText.end() - For->TokenText.begin());
+  For->ColumnWidth += Each->ColumnWidth;
+  Tokens.erase(Tokens.end() - 1);
+  return true;
+}
+
 bool FormatTokenLexer::tryMergeLessLess() {
   // Merge X,less,less,Y into X,lessless,Y unless X or Y is less.
   if (Tokens.size() < 3)

diff  --git a/clang/lib/Format/FormatTokenLexer.h 
b/clang/lib/Format/FormatTokenLexer.h
index 192e26a10d4a..be11020270a3 100644
--- a/clang/lib/Format/FormatTokenLexer.h
+++ b/clang/lib/Format/FormatTokenLexer.h
@@ -55,6 +55,7 @@ class FormatTokenLexer {
   bool tryMergeCSharpDoubleQuestion();
   bool tryMergeCSharpNullConditional();
   bool tryTransformCSharpForEach();
+  bool tryMergeForEach();
 
   bool tryMergeTokens(ArrayRef Kinds, TokenType NewType);
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 9f1b88bf6a6f..dada02e5841c 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -994,6 +994,9 @@ TEST_F(FormatTest, ForEachLoops) {
"#define Q_FOREACH (x, y)\n"
"#define BOOST_FOREACH (x, y)\n"
"#define UNKNOWN_FOREACH (x, y)\n");
+
+  // handle microsoft non standard extension
+  verifyFormat("for each (char c in x->MyStringProperty)");
 }
 
 TEST_F(FormatTest, FormatsWhileLoop) {



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


[clang] b99bf0e - [clang-format][PR45816] Add AlignConsecutiveBitFields

2020-05-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-20T07:42:58+01:00
New Revision: b99bf0e08be4faa4527709541dfdc29240e0c75c

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

LOG: [clang-format][PR45816] Add AlignConsecutiveBitFields

Summary:
The following revision follows D80115 since @MyDeveloperDay and I apparently 
both had the same idea at the same time, for 
https://bugs.llvm.org/show_bug.cgi?id=45816 and my efforts on tooling support 
for AMDVLK, respectively.

This option aligns adjacent bitfield separators across lines, in a manner 
similar to AlignConsecutiveAssignments and friends.

Example:
```
struct RawFloat {
  uint32_t sign : 1;
  uint32_t exponent : 8;
  uint32_t mantissa : 23;
};
```
would become
```
struct RawFloat {
  uint32_t sign : 1;
  uint32_t exponent : 8;
  uint32_t mantissa : 23;
};
```

This also handles c++2a style bitfield-initializers with 
AlignConsecutiveAssignments.
```
struct RawFloat {
  uint32_t sign : 1  = 0;
  uint32_t exponent : 8  = 127;
  uint32_t mantissa : 23 = 0;
}; // defaults to 1.0f
```

Things this change does not do:
 - Align multiple comma-chained bitfield variables. None of the other
   AlignConsecutive* options seem to implement that either.
 - Detect bitfields that have a width specified with something other
   than a numeric literal (ie, `int a : SOME_MACRO;`). That'd be fairly
   difficult to parse and is rare.

Patch By:  JakeMerdichAMD

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/WhitespaceManager.cpp
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index e367c3620e16..c4d6c1d50d13 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -204,6 +204,18 @@ the configuration (without a prefix: ``Auto``).
 int b= 23;
 int ccc  = 23;
 
+**AlignConsecutiveBitFields** (``bool``)
+  If ``true``, aligns consecutive bitfield members.
+
+  This will align the bitfield separators of consecutive lines. This
+  will result in formattings like
+
+  .. code-block:: c++
+
+int  : 1;
+int b: 12;
+int ccc  : 8;
+
 **AlignConsecutiveDeclarations** (``bool``)
   If ``true``, aligns consecutive declarations.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8dd22887a195..06b01420ca4e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -297,6 +297,21 @@ clang-format
   bar();
 });
 
+- Option ``AlignConsecutiveBitFields`` has been added to align bit field
+  declarations across multiple adjacent lines
+
+  .. code-block:: c++
+
+  true:
+bool aaa  : 1;
+bool a: 1;
+bool bb   : 1;
+
+  false:
+bool aaa : 1;
+bool a : 1;
+bool bb : 1;
+
 libclang
 
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
old mode 100644
new mode 100755
index 9bc08a775647..7083a46b5b14
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -108,6 +108,17 @@ struct FormatStyle {
   /// \endcode
   bool AlignConsecutiveAssignments;
 
+  /// If ``true``, aligns consecutive bitfield members.
+  ///
+  /// This will align the bitfield separators of consecutive lines. This
+  /// will result in formattings like
+  /// \code
+  ///   int  : 1;
+  ///   int b: 12;
+  ///   int ccc  : 8;
+  /// \endcode
+  bool AlignConsecutiveBitFields;
+
   /// If ``true``, aligns consecutive declarations.
   ///
   /// This will align the declaration names of consecutive lines. This
@@ -2011,8 +2022,8 @@ struct FormatStyle {
 /// \endcode
 SBPO_ControlStatements,
 /// Same as ``SBPO_ControlStatements`` except this option doesn't apply to
-/// ForEach macros. This is useful in projects where ForEach macros are 
-/// treated as function calls instead of control statements. 
+/// ForEach macros. This is useful in projects where ForEach macros are
+/// treated as function calls instead of control statements.
 /// \code
 ///void f() {
 ///  Q_FOREACH(...) {
@@ -2218,6 +2229,7 @@ struct FormatStyle {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
+   AlignConsecutiveBitFi

[PATCH] D79465: [clang-format] Fix line lengths w/ comments in align

2020-05-19 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe71c537a487c: [clang-format] Fix line lengths w/ comments in 
align (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79465

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12010,6 +12010,16 @@
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -445,8 +445,16 @@
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = Changes[i].TokenLength;
-for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12010,6 +12010,16 @@
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -445,8 +445,16 @@
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = Changes[i].TokenLength;
-for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e71c537 - [clang-format] Fix line lengths w/ comments in align

2020-05-19 Thread via cfe-commits

Author: mydeveloperday
Date: 2020-05-20T07:22:01+01:00
New Revision: e71c537a487cacaa00265e1acb765235943d5172

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

LOG: [clang-format] Fix line lengths w/ comments in align

Summary:
https://bugs.llvm.org/show_bug.cgi?id=43845

When a '//comment' trails a consecutive alignment, it adds a whitespace
replacement within the comment token. This wasn't handled correctly in
the alignment code, which treats it as a whole token and thus double
counts it.

This can wrongly trigger the "line too long, it'll wrap" alignment-break
condition with specific lengths, causing the alignment to break for
seemingly no reason.

Patch By:  JakeMerdichAMD

Reviewed By: MyDeveloperDay

Subscribers: kostyakozko, cfe-commits

Tags: #clang, #clang-format

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 000141a7a1b0..fd1d74933925 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -445,8 +445,16 @@ static unsigned AlignTokens(const FormatStyle &Style, F 
&&Matches,
 
 unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
 int LineLengthAfter = Changes[i].TokenLength;
-for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j)
-  LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
+for (unsigned j = i + 1; j != e && Changes[j].NewlinesBefore == 0; ++j) {
+  LineLengthAfter += Changes[j].Spaces;
+  // Changes are generally 1:1 with the tokens, but a change could also be
+  // inside of a token, in which case it's counted more than once: once for
+  // the whitespace surrounding the token (!IsInsideToken) and once for
+  // each whitespace change within it (IsInsideToken).
+  // Therefore, changes inside of a token should only count the space.
+  if (!Changes[j].IsInsideToken)
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
 
 // If we are restricted by the maximum column width, end the sequence.

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index a0b1dc7331e1..5eefe99214b2 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12010,6 +12010,16 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) {
"  x = 1;\n"
"y = 1;\n",
Alignment);
+
+  Alignment.ReflowComments = true;
+  Alignment.ColumnLimit = 50;
+  EXPECT_EQ("int x   = 0;\n"
+"int yy  = 1; /// specificlennospace\n"
+"int zzz = 2;\n",
+format("int x   = 0;\n"
+   "int yy  = 1; ///specificlennospace\n"
+   "int zzz = 2;\n",
+   Alignment));
 }
 
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {



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


[PATCH] D69987: [RISCV] Assemble/Disassemble v-ext instructions.

2020-05-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai added a comment.

Is this patch ready to land? Are there any comments or suggestions I missed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69987



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-05-19 Thread Michael Schellenberger Costa via Phabricator via cfe-commits
miscco added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2314
+  nextToken();
+  if (FormatTok->Tok.is(tok::less)) {
+while (!FormatTok->Tok.is(tok::greater)) {

miscco wrote:
> I guess you could use `parseBracedList(/*ContinueOnSemicolons=*/false, 
> /*IsEnum=*/false,/*ClosingBraceKind=*/tok::greater);` here?
To be more specific, I am concerned what happens if you have multiple template 
arguments where a linebreak should occur. Is this still happening here?


```
template 
concept someVeryLongConceptName = someVeryLongConstraintName1;
```



Comment at: clang/unittests/Format/FormatTest.cpp:16319
+  verifyFormat("template \n"
+   "concept bool EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"

I think `concept bool` should just be `concept` occurs below 


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

https://reviews.llvm.org/D79773



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D79675#2045563 , @fghanim wrote:

> In D79675#2045405 , @jdoerfert wrote:
>
> > > Could you please list the other patches that are being held back by this 
> > > one? I'd be interested to have a look at them. :)
> >
> > We need the target type support for D80222 
> > , D79739  
> > can go in but we need to modify it afterwards.
>
>
> So this whole thing was about moving Def.s out of `CGOMPRuntime`? Given how 
> low priority making the-soon-to-be-deprecated `CGOMPRuntime` use the new 
> Def.s is, and that I actually use these stuff as part of 
> the-soon-to-be-the-way-to-CG-OMP `OMPBuilder`, wouldn't it have been better 
> to postpone both patches until we are done with this one then add anything I 
> didn't have already as part of D79739  ? It 
> would have certainly saved everyone a lot of time, and made more sense given 
> that the earlier patch came out 2 days after mine, and the other patch today? 
> :)




1. Soon is relative.
2. In the meantime people work on clang and add runtime functions into the 
CGOMPRuntime but not into OMPKinds.def. We are playing catch up all the time, 
thus wasting time.
3. I said it before, please split them up in small pieces. It does really not 
help if we combine unrelated things in a single patch. It doesn't make it 
faster and it is not less work at the end of the day.

> In any case, I addressed everything based on your earlier comments. Thanks 
> for reviewing my patches. Let me know if you think other changes are needed 
> here, otherwise could you please commit this for me, I still don't have 
> commit access.

Thanks. Comments added.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:62
+
+  /// Set Insert point to Instruction /p IPII
+  void setInsertPoint(Instruction *IPII) { Builder.SetInsertPoint(IPII); }

Nit: \p not /p (Or does both work?)



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:86
+  llvm::omp::types::Int8PtrPtr = Int8Ptr->getPointerTo();
+  llvm::omp::types::Int8PtrPtrPtr = Int8PtrPtr->getPointerTo();
+

I think the macro way to specify pointer is easier to use.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:109
+  llvm::omp::types::SizeTy = (SizeTy) ? SizeTy : Int32;
+}
+

I guess we don't need anymore.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:104
+  initializeSizeTy(SizeTy);
+}
 

Probably won't need these either.



Comment at: llvm/lib/Transforms/IPO/OpenMPOpt.cpp:61
 initializeRuntimeFunctions();
-OMPBuilder.initialize();
+OMPBuilder.initialize(Type::getInt32Ty(M.getContext()));
   }

Is size_t always 32 bit? I think you can use the datalayout from the module via 
`getIntPtrType`.



Comment at: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:65
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
 

Same as above, also below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

No, go ahead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79903



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


[PATCH] D79617: Add cet.h for writing CET-enabled assembly code

2020-05-19 Thread Xiang Zhang via Phabricator via cfe-commits
xiangzhangllvm added a comment.

Hello rsmith, 
first, very sorry for have committed this patch before your reply, I waited 10 
days, I thought you have agreed it. 
I think the  linux-ABI can be the specification of this head file. The context 
of this cet.h is according to the linux ABI about CET.
We explained in which case we should use this cet.h file. (line 2-4)
tks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79617



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


[PATCH] D79617: Add cet.h for writing CET-enabled assembly code

2020-05-19 Thread H.J Lu via Phabricator via cfe-commits
hjl.tools added a comment.

In D79617#2045552 , @rsmith wrote:

> I would like a specification for this header to be added somewhere. We 
> shouldn't be implementing random things with no specification. (Suppose 
> someone claims that our `` is wrong in some way. How would we know 
> whether they're right?)
>
> Ideally, I'd also like this header to be installed somewhere where we look 
> for assembler-with-cpp preprocessing but not for regular compilation; it 
> doesn't make sense to me to pollute the header namespace for all C and C++ 
> compilations with a header that is not meaningful in C and C++. But knowing 
> whether that change is correct depends on having, you know, a specification.


 from GCC is as close as you can get for a reference 
implementation/specification.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79617



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-19 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

In D79675#2045405 , @jdoerfert wrote:

> > Could you please list the other patches that are being held back by this 
> > one? I'd be interested to have a look at them. :)
>
> We need the target type support for D80222 , 
> D79739  can go in but we need to modify it 
> afterwards.


So this whole thing was about moving Def.s out of `CGOMPRuntime`? Given how low 
priority making the-soon-to-be-deprecated `CGOMPRuntime` use the new Def.s is, 
and that I actually use these stuff as part of the-soon-to-be-the-way-to-CG-OMP 
`OMPBuilder`, wouldn't it have been better to postpone both patches until we 
are done with this one then add anything I didn't have already as part of 
D79739  ? It would have certainly saved 
everyone a lot of time, and made more sense given that the earlier patch came 
out 2 days after mine, and the other patch today? :)

In any case, I addressed everything based on your earlier comments. Thanks for 
reviewing my patches. Let me know if you think other changes are needed here, 
otherwise could you please commit this for me, I still don't have commit access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D80263: [HeaderSearch] Fix processing #import-ed headers multiple times with modules enabled.

2020-05-19 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, bruno, Bigcheese.
Herald added subscribers: ributzka, dexonsmith, jkorous.
Herald added a project: clang.

HeaderSearch was marking requested HeaderFileInfo as Resolved only based on
the presence of ExternalSource. As the result, using any module was enough
to set ExternalSource and headers unknown to this module would have
HeaderFileInfo with empty fields, including `isImport = 0`, `NumIncludes = 0`.
Such HeaderFileInfo was preserved without changes regardless of how the
header was used in other modules and caused incorrect result in
`HeaderSearch::ShouldEnterIncludeFile`.

Fix by marking HeaderFileInfo as Resolved only if ExternalSource knows
about this header.

rdar://problem/62126911


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80263

Files:
  clang/lib/Lex/HeaderSearch.cpp
  
clang/test/Modules/Inputs/import-once/ImportOnce.framework/Headers/ImportOnce.h
  
clang/test/Modules/Inputs/import-once/ImportOnce.framework/Modules/module.modulemap
  
clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Headers/IndirectImporter.h
  
clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Modules/module.modulemap
  clang/test/Modules/Inputs/import-once/Unrelated.framework/Headers/Unrelated.h
  
clang/test/Modules/Inputs/import-once/Unrelated.framework/Modules/module.modulemap
  clang/test/Modules/import-once.m

Index: clang/test/Modules/import-once.m
===
--- /dev/null
+++ clang/test/Modules/import-once.m
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-name=ImportOnce -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/import-once %s
+
+// Test #import-ed headers are processed only once, even without header guards.
+// Dependency graph is
+//
+// Unrelated   ImportOnce
+//   ^  ^^
+//\/ |
+//   IndirectImporter|
+// ^ |
+//  \|
+//   import-once.m
+#import 
+#import 
Index: clang/test/Modules/Inputs/import-once/Unrelated.framework/Modules/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-once/Unrelated.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module Unrelated {
+umbrella header "Unrelated.h"
+export *
+}
Index: clang/test/Modules/Inputs/import-once/Unrelated.framework/Headers/Unrelated.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-once/Unrelated.framework/Headers/Unrelated.h
@@ -0,0 +1 @@
+void foo(void);
Index: clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Modules/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module IndirectImporter {
+umbrella header "IndirectImporter.h"
+export *
+}
Index: clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Headers/IndirectImporter.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-once/IndirectImporter.framework/Headers/IndirectImporter.h
@@ -0,0 +1,2 @@
+#import 
+#import 
Index: clang/test/Modules/Inputs/import-once/ImportOnce.framework/Modules/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-once/ImportOnce.framework/Modules/module.modulemap
@@ -0,0 +1,4 @@
+framework module ImportOnce {
+  umbrella header "ImportOnce.h"
+  export *
+}
Index: clang/test/Modules/Inputs/import-once/ImportOnce.framework/Headers/ImportOnce.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/import-once/ImportOnce.framework/Headers/ImportOnce.h
@@ -0,0 +1,5 @@
+// No header guards on purpose.
+
+enum SomeSimpleEnum {
+SomeSimpleEnumCase,
+};
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1167,12 +1167,12 @@
   HeaderFileInfo *HFI = &FileInfo[FE->getUID()];
   // FIXME: Use a generation count to check whether this is really up to date.
   if (ExternalSource && !HFI->Resolved) {
-HFI->Resolved = true;
 auto ExternalHFI = ExternalSource->GetHeaderFileInfo(FE);
-
-HFI = &FileInfo[FE->getUID()];
-if (ExternalHFI.External)
-  mergeHeaderFileInfo(*HFI, ExternalHFI);
+if (ExternalHFI.IsValid) {
+  HFI->Resolved = true;
+  if (ExternalHFI.External)
+mergeHeaderFileInfo(*HFI, ExternalHFI);
+}
   }
 
   HFI->IsValid = true;
@@ -1199,12 +1199,12 @@
 if (!WantExternal && (!HFI->IsValid || H

[PATCH] D79617: Add cet.h for writing CET-enabled assembly code

2020-05-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I would like a specification for this header to be added somewhere. We 
shouldn't be implementing random things with no specification. (Suppose someone 
claims that our `` is wrong in some way. How would we know whether 
they're right?)

Ideally, I'd also like this header to be installed somewhere where we look for 
assembler-with-cpp preprocessing but not for regular compilation; it doesn't 
make sense to me to pollute the header namespace for all C and C++ compilations 
with a header that is not meaningful in C and C++. But knowing whether that 
change is correct depends on having, you know, a specification.

I don't think we should be porting this to Clang 10. It seems clear that this 
is a new feature, not a bug fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79617



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


[PATCH] D80171: [analyzer] LoopUnrolling: fix crash when a parameter is a loop counter

2020-05-19 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 265095.
AbbasSabra added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80171

Files:
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/Analysis/loop-unrolling.cpp


Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -499,3 +499,15 @@
 clang_analyzer_numTimesReached(); // expected-warning {{6}}
   }
 }
+
+void parm_by_value_as_loop_counter(int i) {
+  for (i = 0; i < 10; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{10}}
+  }
+}
+
+void parm_by_ref_as_loop_counter(int &i) {
+  for (i = 0; i < 10; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -164,6 +164,11 @@
   if (VD->hasGlobalStorage())
 return true;
 
+  const bool isParm = VD->getKind() == Decl::ParmVar;
+  // Reference parameters are assumed as escaped variables.
+  if (isParm && VD->getType()->isReferenceType())
+return true;
+
   while (!N->pred_empty()) {
 // FIXME: getStmtForDiagnostics() does nasty things in order to provide
 // a valid statement for body farms, do we need this behavior here?
@@ -193,6 +198,11 @@
 
 N = N->getFirstPred();
   }
+
+  // Parameter declaration will not be found.
+  if (isParm)
+return false;
+
   llvm_unreachable("Reached root without finding the declaration of VD");
 }
 


Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -499,3 +499,15 @@
 clang_analyzer_numTimesReached(); // expected-warning {{6}}
   }
 }
+
+void parm_by_value_as_loop_counter(int i) {
+  for (i = 0; i < 10; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{10}}
+  }
+}
+
+void parm_by_ref_as_loop_counter(int &i) {
+  for (i = 0; i < 10; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
+  }
+}
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -164,6 +164,11 @@
   if (VD->hasGlobalStorage())
 return true;
 
+  const bool isParm = VD->getKind() == Decl::ParmVar;
+  // Reference parameters are assumed as escaped variables.
+  if (isParm && VD->getType()->isReferenceType())
+return true;
+
   while (!N->pred_empty()) {
 // FIXME: getStmtForDiagnostics() does nasty things in order to provide
 // a valid statement for body farms, do we need this behavior here?
@@ -193,6 +198,11 @@
 
 N = N->getFirstPred();
   }
+
+  // Parameter declaration will not be found.
+  if (isParm)
+return false;
+
   llvm_unreachable("Reached root without finding the declaration of VD");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79743: [clang][asm goto][slh] Warn if asm goto + SLH

2020-05-19 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 accepted this revision.
jyu2 added a comment.
This revision is now accepted and ready to land.

LGTM.  Please changed format for td file.




Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:247
+
+  def warn_slh_does_not_support_asm_goto : Warning<
+"Speculative load hardening does not protect functions with asm goto">, 
InGroup>;

Just need run clang-format:
def warn_slh_does_not_support_asm_goto
  : Warning<"Speculative load hardening does not protect functions with "
"asm goto">,
InGroup>;



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79743



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


[PATCH] D78101: [analyzer][StackAddressEscape] Tie warnings to the diagnostic checkers rather then core.StackAddrEscapeBase

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a6ee4fefec0: [analyzer][StackAddressEscape] Tie warnings to 
the diagnostic checkers rather… (authored by Szelethus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78101

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
  clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  clang/test/Analysis/incorrect-checker-names.cpp
  clang/test/Analysis/incorrect-checker-names.mm

Index: clang/test/Analysis/incorrect-checker-names.mm
===
--- clang/test/Analysis/incorrect-checker-names.mm
+++ clang/test/Analysis/incorrect-checker-names.mm
@@ -1,5 +1,6 @@
-// RUN: %clang_analyze_cc1 -fblocks -verify %s -Wno-objc-root-class \
+// RUN: %clang_analyze_cc1 -fblocks -fobjc-arc -verify %s -Wno-objc-root-class \
 // RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.core.StackAddressAsyncEscape \
 // RUN:   -analyzer-checker=nullability \
 // RUN:   -analyzer-checker=osx
 
@@ -126,3 +127,32 @@
   // FIXME: This shouldn't be tied to a modeling checker.
   write_into_out_param_on_success(&obj); // expected-warning{{Potential leak of an object stored into 'obj' [osx.cocoa.RetainCountBase]}}
 }
+
+typedef struct dispatch_queue_s *dispatch_queue_t;
+typedef void (^dispatch_block_t)(void);
+void dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
+typedef long dispatch_once_t;
+void dispatch_once(dispatch_once_t *predicate, dispatch_block_t block);
+typedef long dispatch_time_t;
+void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);
+void dispatch_barrier_sync(dispatch_queue_t queue, dispatch_block_t block);
+
+extern dispatch_queue_t queue;
+extern dispatch_once_t *predicate;
+extern dispatch_time_t when;
+
+dispatch_block_t get_leaking_block() {
+  int leaked_x = 791;
+  int *p = &leaked_x;
+  return ^void(void) {
+*p = 1;
+  };
+  // expected-warning@-3 {{Address of stack memory associated with local variable 'leaked_x' \
+is captured by a returned block [core.StackAddressEscape]}}
+}
+
+void test_returned_from_func_block_async() {
+  dispatch_async(queue, get_leaking_block());
+  // expected-warning@-1 {{Address of stack memory associated with local variable 'leaked_x' \
+is captured by an asynchronously-executed block [alpha.core.StackAddressAsyncEscape]}}
+}
Index: clang/test/Analysis/incorrect-checker-names.cpp
===
--- clang/test/Analysis/incorrect-checker-names.cpp
+++ clang/test/Analysis/incorrect-checker-names.cpp
@@ -5,9 +5,16 @@
 int* stack_addr_escape_base() {
   int x = 0;
   // FIXME: This shouldn't be tied to a modeling checker.
-  return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned to caller [core.StackAddrEscapeBase]}}
+  return &x; // expected-warning{{Address of stack memory associated with local variable 'x' returned to caller [core.StackAddressEscape]}}
   // expected-note-re@-1^Address of stack memory associated with local variable 'x' returned to caller$
   // Just a regular compiler warning.
   // expected-warning@-3{{address of stack memory associated with local variable 'x' returned}}
 }
 
+char const *p;
+
+void f0() {
+  char const str[] = "This will change";
+  p = str;
+} // expected-warning{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller.  This will be a dangling reference [core.StackAddressEscape]}}
+// expected-note@-1{{Address of stack memory associated with local variable 'str' is still referred to by the global variable 'p' upon returning to the caller.  This will be a dangling reference}}
Index: clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -43,6 +43,7 @@
   };
 
   DefaultBool ChecksEnabled[CK_NumCheckKinds];
+  CheckerNameRef CheckNames[CK_NumCheckKinds];
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPreStmt(const ReturnStmt *RS, CheckerContext &C) const;
@@ -156,7 +157,8 @@
 return;
   if (!BT_returnstack)
 BT_returnstack = std::make_unique(
-this, "Return of address to stack-allocated memory");
+CheckNames[CK_StackAddrEscapeChecker],
+"Return of address to stack-allocated memory");
   // Generate a report for this bug.
   SmallString<128> buf;
   llvm::raw_svector_ostream os(buf);
@@ -195,7 +197,8 @@
   continue;
 if (!BT_capturedstackasync)
   BT_capturedstackasync = std::make_unique(
-  this, "Address of stack-allocated memory is captured");

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5369
 if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
-  DebugInfo->completeUnusedClass(cast(*D));
+  DebugInfo->completeUnusedClass(*CRD);
 }

The difference between using `DebugInfo` vs `getModuleDebugInfo` in this method 
is *killing* me.  Same with `return` vs `break`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D80171: [analyzer] LoopUnrolling: fix crash when a parameter is a loop counter

2020-05-19 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra requested review of this revision.
AbbasSabra added a comment.

What you both said makes sense.  Now, reference parameters are escaped and 
value parameters are treated as the local variables.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80171



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 265093.
nickdesaulniers added a comment.

- add C++ `using` and `class` support


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp

Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+
+// CHECK: !4 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo", file: !5, line: 5, baseType: !6)
+// CHECK: !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// CHECK: !7 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar", file: !5, line: 6, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: "_ZTS3bar")
+
+// NODBG-NOT: !4 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo", file: !5, line: 5, baseType: !6)
+// NODBG-NOT: !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// NODBG-NOT: !7 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "bar", file: !5, line: 6, size: 8, flags: DIFlagTypePassByValue, elements: !2, identifier: "_ZTS3bar")
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,30 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar", file: !4, line: 7, baseType: !5, size: 32, elements: !6)
+// CHECK: !5 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+// CHECK: !7 = !DIEnumerator(name: "BAR", value: 0, isUnsigned: true)
+// CHECK: !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int", file: !4, line: 5, baseType: !10)
+// CHECK: !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// CHECK: !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !4, line: 6, elements: !12)
+// CHECK: !13 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "baz", file: !4, line: 8, elements: !12)
+
+// Check that debug info is not emitted for the typedef, struct, enum, and
+// union when -fno-eliminate-unused-debug-types and -g are not set.
+
+// NODBG-NOT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar", file: !4, line: 7, baseType: !5, size: 32, elements: !6)
+// NODBG-NOT: !5 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+// NODBG-NOT: !7 = !DIEnumerator(name: "BAR", value: 0, isUnsigned: true)
+// NODBG-NOT: !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int", file: !4, line: 5, baseType: !10)
+// NODBG-NOT: !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// NODBG-NOT: !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !4, line: 6, elements: !12)
+// NODBG-NOT: !13 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "baz", file: !4, line: 8, elements: !12)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -765,6 +765,7 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
   Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
   Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
+  Opts.DebugUnusedTypes = Args.hasArg(OPT_eliminate_unused_debug_types_fno);
   Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
   Opts.ForceDwarfFrameSection = Args.hasArg(OPT_fforce_dwarf_frame);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- cla

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

`CXXRecordDecl` is a funny case, the AST looks like:

  |-CXXRecordDecl 0x5c661a8  col:7 class foo 
definition
  | |-DefinitionData pass_in_registers empty aggregate standard_layout 
trivially_copyable pod trivial literal has_constexpr_non_copy_
  | `-CXXRecordDecl 0x5c662d0  col:7 implicit class foo
  ...

There's probably a bunch more C++ cases I'm not thinking of.  Reading through 
gcc's test suite for `-fno-eliminate-unused-debug-types`, this feature doesn't 
have tests for anything with templates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[clang] 3a6ee4f - [analyzer][StackAddressEscape] Tie warnings to the diagnostic checkers rather then core.StackAddrEscapeBase

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-20T02:26:40+02:00
New Revision: 3a6ee4fefec0bc97a0340ddc33e7a8ffd4590ad5

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

LOG: [analyzer][StackAddressEscape] Tie warnings to the diagnostic checkers 
rather then core.StackAddrEscapeBase

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
clang/test/Analysis/incorrect-checker-names.cpp
clang/test/Analysis/incorrect-checker-names.mm

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
index 237053df7e44..49ab25eca2dd 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugType.h
@@ -78,13 +78,16 @@ class BuiltinBug : public BugType {
  const char *description)
   : BugType(checker, name, categories::LogicError), desc(description) {}
 
+  BuiltinBug(class CheckerNameRef checker, const char *name)
+  : BugType(checker, name, categories::LogicError), desc(name) {}
+
   BuiltinBug(const CheckerBase *checker, const char *name)
   : BugType(checker, name, categories::LogicError), desc(name) {}
 
   StringRef getDescription() const { return desc; }
 };
 
-} // end ento namespace
+} // namespace ento
 
 } // end clang namespace
 #endif

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index 21fc65a8e4f1..b5c9356322fc 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -43,6 +43,7 @@ class StackAddrEscapeChecker
   };
 
   DefaultBool ChecksEnabled[CK_NumCheckKinds];
+  CheckerNameRef CheckNames[CK_NumCheckKinds];
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPreStmt(const ReturnStmt *RS, CheckerContext &C) const;
@@ -156,7 +157,8 @@ void StackAddrEscapeChecker::EmitStackError(CheckerContext 
&C,
 return;
   if (!BT_returnstack)
 BT_returnstack = std::make_unique(
-this, "Return of address to stack-allocated memory");
+CheckNames[CK_StackAddrEscapeChecker],
+"Return of address to stack-allocated memory");
   // Generate a report for this bug.
   SmallString<128> buf;
   llvm::raw_svector_ostream os(buf);
@@ -195,7 +197,8 @@ void 
StackAddrEscapeChecker::checkAsyncExecutedBlockCaptures(
   continue;
 if (!BT_capturedstackasync)
   BT_capturedstackasync = std::make_unique(
-  this, "Address of stack-allocated memory is captured");
+  CheckNames[CK_StackAddrAsyncEscapeChecker],
+  "Address of stack-allocated memory is captured");
 SmallString<128> Buf;
 llvm::raw_svector_ostream Out(Buf);
 SourceRange Range = genName(Out, Region, C.getASTContext());
@@ -218,7 +221,8 @@ void StackAddrEscapeChecker::checkReturnedBlockCaptures(
   continue;
 if (!BT_capturedstackret)
   BT_capturedstackret = std::make_unique(
-  this, "Address of stack-allocated memory is captured");
+  CheckNames[CK_StackAddrEscapeChecker],
+  "Address of stack-allocated memory is captured");
 SmallString<128> Buf;
 llvm::raw_svector_ostream Out(Buf);
 SourceRange Range = genName(Out, Region, C.getASTContext());
@@ -277,7 +281,7 @@ void StackAddrEscapeChecker::checkPreStmt(const ReturnStmt 
*RS,
 
   // The CK_CopyAndAutoreleaseBlockObject cast causes the block to be copied
   // so the stack address is not escaping here.
-  if (auto *ICE = dyn_cast(RetE)) {
+  if (const auto *ICE = dyn_cast(RetE)) {
 if (isa(R) &&
 ICE->getCastKind() == CK_CopyAndAutoreleaseBlockObject) {
   return;
@@ -333,7 +337,8 @@ void StackAddrEscapeChecker::checkEndFunction(const 
ReturnStmt *RS,
 
   if (!BT_stackleak)
 BT_stackleak = std::make_unique(
-this, "Stack address stored into global variable",
+CheckNames[CK_StackAddrEscapeChecker],
+"Stack address stored into global variable",
 "Stack address was saved into a global variable. "
 "This is dangerous because the address will become "
 "invalid after returning from the function");
@@ -371,14 +376,13 @@ bool ento::shouldRegisterStackAddrEscapeBase(const 
CheckerManager &mgr) {
 
 #define REGISTER_CHECKER(name) 
\
   void ento::register##name(CheckerManager &Mgr) { 
\
-StackAddrEscapeChecker *Chk =  
\
-Mgr.getC

[PATCH] D75432: [analyzer][NFC][MallocChecker] Convert many parameters into CallEvent

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39dd7265: [analyzer][NFC][MallocChecker] Convert many 
parameters into CallEvent (authored by Szelethus).
Herald added a subscriber: ASDenysPetrov.

Changed prior to commit:
  https://reviews.llvm.org/D75432?vs=247534&id=265091#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75432

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -47,7 +47,10 @@
 #include "AllocationState.h"
 #include "InterCheckerAPI.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Lexer.h"
@@ -63,10 +66,12 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -268,7 +273,7 @@
 /// placement operators and other standard overloads.
 static bool isStandardNewDelete(const FunctionDecl *FD);
 static bool isStandardNewDelete(const CallEvent &Call) {
-  if (!Call.getDecl())
+  if (!Call.getDecl() || !isa(Call.getDecl()))
 return false;
   return isStandardNewDelete(cast(Call.getDecl()));
 }
@@ -283,9 +288,8 @@
 : public Checker,
  check::EndFunction, check::PreCall, check::PostCall,
- check::PostStmt, check::NewAllocator,
- check::PostStmt, check::PostObjCMessage,
- check::Location, eval::Assume> {
+ check::NewAllocator, check::PostStmt,
+ check::PostObjCMessage, check::Location, eval::Assume> {
 public:
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -314,8 +318,6 @@
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
-  void checkPostStmt(const CXXNewExpr *NE, CheckerContext &C) const;
-  void checkPreStmt(const CXXDeleteExpr *DE, CheckerContext &C) const;
   void checkNewAllocator(const CXXAllocatorCall &Call, CheckerContext &C) const;
   void checkPostObjCMessage(const ObjCMethodCall &Call, CheckerContext &C) const;
   void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const;
@@ -351,7 +353,7 @@
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
 
 #define CHECK_FN(NAME) \
-  void NAME(CheckerContext &C, const CallExpr *CE, ProgramStateRef State) const;
+  void NAME(const CallEvent &Call, CheckerContext &C) const;
 
   CHECK_FN(checkFree)
   CHECK_FN(checkIfNameIndex)
@@ -369,12 +371,11 @@
   CHECK_FN(checkReallocN)
   CHECK_FN(checkOwnershipAttr)
 
-  void checkRealloc(CheckerContext &C, const CallExpr *CE,
-ProgramStateRef State, bool ShouldFreeOnFail) const;
+  void checkRealloc(const CallEvent &Call, CheckerContext &C,
+bool ShouldFreeOnFail) const;
 
-  using CheckFn =
-  std::function;
+  using CheckFn = std::function;
 
   const CallDescriptionMap FreeingMemFnMap{
   {{"free", 1}, &MallocChecker::checkFree},
@@ -412,13 +413,13 @@
 
   CallDescriptionMap ReallocatingMemFnMap{
   {{"realloc", 2},
-   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, _4, false)},
+   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, false)},
   {{"reallocf", 2},
-   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, _4, true)},
+   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, true)},
   {{"g_realloc", 2},
-   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, _4, false)},
+   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, false)},
   {{"g_try_realloc", 2},
-   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, _4, false)},
+   std::bind(&MallocChecker::checkRealloc, _1, _2, _3, false)},
   {{"g_realloc_n", 3}, &MallocChecker::checkReallocN},
   {{"g_try_realloc_n", 3}, &MallocChecker::checkReallocN},
   };
@@ -437,8 +438,10 @@
 
   /// Process C++ operator new()'s allocation, which is the part of C++
   /// new-expression that goes before the construct

[PATCH] D80171: [analyzer] LoopUnrolling: fix crash when a parameter is a loop counter

2020-05-19 Thread Abbas Sabra via Phabricator via cfe-commits
AbbasSabra updated this revision to Diff 265090.
AbbasSabra added a comment.

Fix code review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80171

Files:
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/Analysis/loop-unrolling.cpp


Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -500,8 +500,14 @@
   }
 }
 
-void arg_as_loop_counter(int i) {
+void parm_by_value_as_loop_counter(int i) {
   for (i = 0; i < 10; ++i) {
-(void)i;
+clang_analyzer_numTimesReached(); // expected-warning {{10}}
+  }
+}
+
+void parm_by_ref_as_loop_counter(int &i) {
+  for (i = 0; i < 10; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
   }
 }
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -160,8 +160,13 @@
 }
 
 static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
-  // Global variables and parameters assumed as escaped variables.
-  if (VD->hasGlobalStorage() || VD->getKind() == Decl::ParmVar)
+  // Global variables assumed as escaped variables.
+  if (VD->hasGlobalStorage())
+return true;
+
+  const bool isParm = VD->getKind() == Decl::ParmVar;
+  // Reference parameters are assumed as escaped variables.
+  if (isParm && VD->getType()->isReferenceType())
 return true;
 
   while (!N->pred_empty()) {
@@ -193,6 +198,11 @@
 
 N = N->getFirstPred();
   }
+
+  // Parameter declaration will not be found.
+  if (isParm)
+return false;
+
   llvm_unreachable("Reached root without finding the declaration of VD");
 }
 


Index: clang/test/Analysis/loop-unrolling.cpp
===
--- clang/test/Analysis/loop-unrolling.cpp
+++ clang/test/Analysis/loop-unrolling.cpp
@@ -500,8 +500,14 @@
   }
 }
 
-void arg_as_loop_counter(int i) {
+void parm_by_value_as_loop_counter(int i) {
   for (i = 0; i < 10; ++i) {
-(void)i;
+clang_analyzer_numTimesReached(); // expected-warning {{10}}
+  }
+}
+
+void parm_by_ref_as_loop_counter(int &i) {
+  for (i = 0; i < 10; ++i) {
+clang_analyzer_numTimesReached(); // expected-warning {{4}}
   }
 }
Index: clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
===
--- clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
+++ clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
@@ -160,8 +160,13 @@
 }
 
 static bool isPossiblyEscaped(const VarDecl *VD, ExplodedNode *N) {
-  // Global variables and parameters assumed as escaped variables.
-  if (VD->hasGlobalStorage() || VD->getKind() == Decl::ParmVar)
+  // Global variables assumed as escaped variables.
+  if (VD->hasGlobalStorage())
+return true;
+
+  const bool isParm = VD->getKind() == Decl::ParmVar;
+  // Reference parameters are assumed as escaped variables.
+  if (isParm && VD->getType()->isReferenceType())
 return true;
 
   while (!N->pred_empty()) {
@@ -193,6 +198,11 @@
 
 N = N->getFirstPred();
   }
+
+  // Parameter declaration will not be found.
+  if (isParm)
+return false;
+
   llvm_unreachable("Reached root without finding the declaration of VD");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-05-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/include/clang/Frontend/CompilerInvocation.h:156
   /// \param [out] Res - The resulting invocation.
+  /// \param [in] CommandLineArgs - Array of argument strings, this should not
+  /// contain "-cc1".

Is this really a should not, or is it must not?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3604-3610
+#define OPTION_WITH_MARSHALLING(PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, 
\
+ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR,
\
+VALUES, KEYPATH, IS_POSITIVE, DEFAULT_VALUE)   
\
+  if (Option::KIND##Class == Option::FlagClass)
\
+Res.KEYPATH = Args.hasArg(OPT_##ID) && IS_POSITIVE;
+#include "clang/Driver/Options.inc"
+#undef OPTION_WITH_MARSHALLING

This should probably go in a separate function as it will grow. I would 
recommend something like `ParseSimpleArgs` and call it right before 
`ParseAnalyzerArgs `.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3607
+VALUES, KEYPATH, IS_POSITIVE, DEFAULT_VALUE)   
\
+  if (Option::KIND##Class == Option::FlagClass)
\
+Res.KEYPATH = Args.hasArg(OPT_##ID) && IS_POSITIVE;

How would this handle other option classes? I think it would be good to include 
a few different types of options in the first patch.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3845
+  IS_POSITIVE != DEFAULT_VALUE && this->KEYPATH != DEFAULT_VALUE)  
\
+Args.push_back(StringAllocator(Twine(PREFIX_TYPE[0]) + NAME));
+#include "clang/Driver/Options.inc"

It's a little sad that we need to allocation every string just because of the 
`-`. We definitely need to be able to allocate strings for options with data, 
but it would be good if we could just have the strings with `-` prefixed in the 
option table if that's reasonable to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796



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


[clang] 392222d - [analyzer][NFC][MallocChecker] Convert many parameters into CallEvent

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kristóf Umann
Date: 2020-05-20T02:03:31+02:00
New Revision: 39dd72657244f13d7f99cc6a497cc78eba2e

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

LOG: [analyzer][NFC][MallocChecker] Convert many parameters into CallEvent

Exactly what it says on the tin! This is clearly not the end of the road in this
direction, the parameters could be merged far more with the use of CallEvent or
a better value type in the CallDescriptionMap, but this was shockingly difficult
enough on its own. I expect that simplifying the file further will be far easier
moving forward.

The end goal is to research how we could create a more mature checker
interaction infrastructure for more complicated C++ modeling, and I'm pretty
sure that being able successfully split up our giants is the first step in this
direction.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index edcee6e2d052..f5f4dd0eaea5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -47,7 +47,10 @@
 #include "AllocationState.h"
 #include "InterCheckerAPI.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Lex/Lexer.h"
@@ -63,10 +66,12 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -268,7 +273,7 @@ REGISTER_MAP_WITH_PROGRAMSTATE(ReallocPairs, SymbolRef, 
ReallocPair)
 /// placement operators and other standard overloads.
 static bool isStandardNewDelete(const FunctionDecl *FD);
 static bool isStandardNewDelete(const CallEvent &Call) {
-  if (!Call.getDecl())
+  if (!Call.getDecl() || !isa(Call.getDecl()))
 return false;
   return isStandardNewDelete(cast(Call.getDecl()));
 }
@@ -283,9 +288,8 @@ class MallocChecker
 : public Checker,
  check::EndFunction, check::PreCall, check::PostCall,
- check::PostStmt, check::NewAllocator,
- check::PostStmt, check::PostObjCMessage,
- check::Location, eval::Assume> {
+ check::NewAllocator, check::PostStmt,
+ check::PostObjCMessage, check::Location, eval::Assume> {
 public:
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -314,8 +318,6 @@ class MallocChecker
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
-  void checkPostStmt(const CXXNewExpr *NE, CheckerContext &C) const;
-  void checkPreStmt(const CXXDeleteExpr *DE, CheckerContext &C) const;
   void checkNewAllocator(const CXXAllocatorCall &Call, CheckerContext &C) 
const;
   void checkPostObjCMessage(const ObjCMethodCall &Call, CheckerContext &C) 
const;
   void checkPostStmt(const BlockExpr *BE, CheckerContext &C) const;
@@ -351,7 +353,7 @@ class MallocChecker
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
 
 #define CHECK_FN(NAME) 
\
-  void NAME(CheckerContext &C, const CallExpr *CE, ProgramStateRef State) 
const;
+  void NAME(const CallEvent &Call, CheckerContext &C) const;
 
   CHECK_FN(checkFree)
   CHECK_FN(checkIfNameIndex)
@@ -369,12 +371,11 @@ class MallocChecker
   CHECK_FN(checkReallocN)
   CHECK_FN(checkOwnershipAttr)
 
-  void checkRealloc(CheckerContext &C, const CallExpr *CE,
-ProgramStateRef State, bool ShouldFreeOnFail) const;
+  void checkRealloc(const CallEvent &Call, CheckerContext &C,
+bool ShouldFreeOnFail) const;
 
-  using CheckFn =
-  std::function;
+  using CheckFn = std::function;
 
   const CallDescriptionMap FreeingMemFnMap{
   {{"free", 1}, &MallocChecker::checkFree},
@@ -412,13 +413,13 @@ class MallocChecker
 
   CallDescriptionMap ReallocatingMemFnMap{
   {{"realloc", 2},
-   std::bind(&MallocChecker::checkRealloc, _1, 

[PATCH] D76510: [analyzer] Change the default output type to PD_TEXT_MINIMAL in the frontend, error if an output loc is missing for PathDiagConsumers that need it

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe1a3a7e8c8b: [analyzer] Change the default output type to 
PD_TEXT_MINIMAL in the frontend… (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D76510?vs=251673&id=265087#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76510

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/test/Analysis/output_types.cpp

Index: clang/test/Analysis/output_types.cpp
===
--- /dev/null
+++ clang/test/Analysis/output_types.cpp
@@ -0,0 +1,49 @@
+// RUN: not %clang_analyze_cc1 %s \
+// RUN:   -analyzer-output=plist \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-PLIST
+
+// CHECK-PLIST: error: analyzer output type 'plist' requires an output file to
+// CHECK-PLIST-SAME: be specified with -o 
+
+
+// RUN: not %clang_analyze_cc1 %s \
+// RUN:   -analyzer-output=plist-multi-file \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-PLIST-MULTI
+
+// CHECK-PLIST-MULTI: error: analyzer output type 'plist-multi-file' requires
+// CHECK-PLIST-MULTI-SAME: an output file to be specified with
+// CHECK-PLIST-MULTI-SAME: -o 
+
+
+// RUN: not %clang_analyze_cc1 %s \
+// RUN:   -analyzer-output=plist-html \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-PLIST-HTML
+
+// CHECK-PLIST-HTML: error: analyzer output type 'plist-html' requires an output
+// CHECK-PLIST-HTML-SAME: directory to be specified with
+// CHECK-PLIST-HTML-SAME: -o 
+
+
+// RUN: not %clang_analyze_cc1 %s \
+// RUN:   -analyzer-output=sarif \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-SARIF
+
+// CHECK-SARIF: error: analyzer output type 'sarif' requires an output file to
+// CHECK-SARIF-SAME: be specified with -o 
+
+
+// RUN: not %clang_analyze_cc1 %s \
+// RUN:   -analyzer-output=html \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-HTML
+
+// CHECK-HTML: error: analyzer output type 'html' requires an output directory
+// CHECK-HTML-SAME: to be specified with -o 
+
+
+// RUN: not %clang_analyze_cc1 %s \
+// RUN:   -analyzer-output=html-single-file \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-HTML-SINGLE
+
+// CHECK-HTML-SINGLE: error: analyzer output type 'html-single-file' requires
+// CHECK-HTML-SINGLE-SAME: an output directory to be specified with
+// CHECK-HTML-SINGLE-SAME: -o 
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -23,6 +23,7 @@
 #include "clang/Analysis/PathDiagnostic.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Rewrite/Core/Rewriter.h"
Index: clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/Version.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
@@ -52,9 +53,11 @@
 const std::string &Output, const Preprocessor &PP,
 const cross_tu::CrossTranslationUnitContext &CTU) {
 
-  // TODO: Emit an error here.
-  if (Output.empty())
+  if (Output.empty()) {
+PP.getDiagnostics().Report(diag::err_analyzer_missing_output_loc)
+  << "sarif" << "file";
 return;
+  }
 
   C.push_back(new SarifDiagnostics(AnalyzerOpts, Output, PP.getLangOpts()));
   createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, Output, PP, CTU);
Index: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Version.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/TokenConcatenation.h"
@@ -571,10 +572,10 @@
 //===--===

[clang] fe1a3a7 - [analyzer] Change the default output type to PD_TEXT_MINIMAL in the frontend, error if an output loc is missing for PathDiagConsumers that need it

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-20T01:36:06+02:00
New Revision: fe1a3a7e8c8be33968b9a768666489823dabab10

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

LOG: [analyzer] Change the default output type to PD_TEXT_MINIMAL in the 
frontend, error if an output loc is missing for PathDiagConsumers that need it

The title and the included test file sums everything up -- the only thing I'm
mildly afraid of is whether anyone actually depends on the weird behavior of
HTMLDiagnostics pretending to be TextDiagnostics if an output directory is not
supplied. If it is, I guess we would need to resort to tiptoeing around the
compatibility flag.

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

Added: 
clang/test/Analysis/output_types.cpp

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index d010a7dfb2de..fdca8532ab53 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -358,6 +358,9 @@ def err_analyzer_checker_option_invalid_input : Error<
   "invalid input for checker option '%0', that expects %1">;
 def err_analyzer_checker_incompatible_analyzer_option : Error<
   "checker cannot be enabled with analyzer option '%0' == %1">;
+def err_analyzer_missing_output_loc : Error<
+  "analyzer output type '%0' requires an output %1 to be specified with "
+  "-o ">;
 
 def err_drv_invalid_hvx_length : Error<
   "-mhvx-length is not supported without a -mhvx/-mhvx= flag">;

diff  --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h 
b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index d2df24a6e21b..373caa30bbc9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -206,7 +206,7 @@ class AnalyzerOptions : public 
RefCountedBase {
   ConfigTable Config;
   AnalysisStores AnalysisStoreOpt = RegionStoreModel;
   AnalysisConstraints AnalysisConstraintsOpt = RangeConstraintsModel;
-  AnalysisDiagClients AnalysisDiagOpt = PD_HTML;
+  AnalysisDiagClients AnalysisDiagOpt = PD_TEXT_MINIMAL;
   AnalysisPurgeMode AnalysisPurgeOpt = PurgeStmt;
 
   std::string AnalyzeSpecificFunction;

diff  --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index 184fdcfb3d4b..8ce3aa2e081e 100644
--- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -21,6 +21,7 @@
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/Token.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Rewrite/Core/HTMLRewrite.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
@@ -137,18 +138,14 @@ void ento::createHTMLDiagnosticConsumer(
 const std::string &OutputDir, const Preprocessor &PP,
 const cross_tu::CrossTranslationUnitContext &CTU) {
 
-  // FIXME: HTML is currently our default output type, but if the output
-  // directory isn't specified, it acts like if it was in the minimal text
-  // output mode. This doesn't make much sense, we should have the minimal text
-  // as our default. In the case of backward compatibility concerns, this could
-  // be preserved with -analyzer-config-compatibility-mode=true.
-  createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, OutputDir, PP, CTU);
-
-  // TODO: Emit an error here.
-  if (OutputDir.empty())
+  if (OutputDir.empty()) {
+PP.getDiagnostics().Report(diag::err_analyzer_missing_output_loc)
+  << "html" << "directory";
 return;
+  }
 
   C.push_back(new HTMLDiagnostics(AnalyzerOpts, OutputDir, PP, true));
+  createTextMinimalPathDiagnosticConsumer(AnalyzerOpts, C, OutputDir, PP, CTU);
 }
 
 void ento::createHTMLSingleFileDiagnosticConsumer(
@@ -156,9 +153,11 @@ void ento::createHTMLSingleFileDiagnosticConsumer(
 const std::string &OutputDir, const Preprocessor &PP,
 const cross_tu::CrossTranslationUnitContext &CTU) {
 
-  // TODO: Emit an error here.
-  if (OutputDir.empty())
+  if (OutputDir.empty()) {
+PP.getDiagnostics().Report(diag::err_analyzer_missing_output_loc)
+  << "html-single-file" << "directory";
 return;
+  }
 
   C.push_back(new HTMLDiagnostics(AnalyzerOpts, OutputDir, PP, false));
   createTextMinimalPathDiagnosticConsu

[PATCH] D76510: [analyzer] Change the default output type to PD_TEXT_MINIMAL in the frontend, error if an output loc is missing for PathDiagConsumers that need it

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I'm committing this now as-is, if something breaks, I'll revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76510



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

> Could you please list the other patches that are being held back by this one? 
> I'd be interested to have a look at them. :)

We need the target type support for D80222 , 
D79739  can go in but we need to modify it 
afterwards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Basic/HIP.cpp:16
+const llvm::SmallVector
+getAllPossibleTargetIdFeatures(llvm::StringRef Device) {
+  llvm::SmallVector Ret;

Nit: there's an unfortunate clash with already [[ 
https://github.com/llvm/llvm-project/blob/6a3469f58d0c230e86043f6975f048968334dfa4/clang/include/clang/Driver/CC1Options.td#L23
 | target-feature ]] in clang & LLVM.

Would something like `GPUProperties` be a reasonable name?



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:121-123
+  auto Pos = SubArchName.find_first_of("+-");
+  if (Pos != SubArchName.npos)
+SubArchName = SubArchName.substr(0, Pos);

Parsing should probably be extracted into a separate function to avoid 
replicating it all over the place.

I'd also propose use a different syntax for the properties.
* use explicit character to separate individual elements. This way splitting 
the properties becomes independent of what those properties are. If you decide 
to make properties with values or change their meaning some other way, it would 
not affect how you compose them.
* use `name=value` or `name[+-]` for individual properties. This makes it easy 
to parse individual properties and normalize their names. This makes property 
map creation independent of the property values.

Right now `[+-]` serves as both a separator and as the value, which would 
present problems if you ever need more flexible parametrization of properties. 
What if a property must be a number or a string. Granted, you can always encode 
them as a set of bools, but that's rather unpractical. 

E.g. something like this would work a bit better: 
`gfx111:foo+:bar=33:buz=string`.



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

https://reviews.llvm.org/D60620



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


[PATCH] D79743: [clang][asm goto][slh] Warn if asm goto + SLH

2020-05-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid added a comment.

In D79743#2044676 , @jyu2 wrote:

> This looks good to me.  Could you also add a test to use this new DiagGroup 
> (-Wno-slh-asm-goto)?
>
> Thanks.
>
> Jennifer


Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79743



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


[PATCH] D79743: [clang][asm goto][slh] Warn if asm goto + SLH

2020-05-19 Thread Zola Bridges via Phabricator via cfe-commits
zbrid updated this revision to Diff 265081.
zbrid added a comment.

Add test; Update command for existing test

Also rename file to match warning flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79743

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/test/Parser/slh-asm-goto-no-warn.cpp
  clang/test/Parser/slh-asm-goto.cpp


Index: clang/test/Parser/slh-asm-goto.cpp
===
--- /dev/null
+++ clang/test/Parser/slh-asm-goto.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-warning {{Speculative load 
hardening does not protect functions with asm goto}}
+}
Index: clang/test/Parser/slh-asm-goto-no-warn.cpp
===
--- /dev/null
+++ clang/test/Parser/slh-asm-goto-no-warn.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -Wno-slh-asm-goto -mspeculative-load-hardening 
-fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-no-diagnostics
+}
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -729,6 +729,9 @@
   if (parseGNUAsmQualifierListOpt(GAQ))
 return StmtError();
 
+  if (GAQ.isGoto() && getLangOpts().SpeculativeLoadHardening)
+Diag(Loc, diag::warn_slh_does_not_support_asm_goto);
+
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
 
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,9 @@
   def warn_stack_clash_protection_inline_asm : Warning<
 "Unable to protect inline asm that clobbers stack pointer against stack 
clash">,
 InGroup>;
+
+  def warn_slh_does_not_support_asm_goto : Warning<
+"Speculative load hardening does not protect functions with asm goto">, 
InGroup>;
 }
 
 // Sema && Serialization


Index: clang/test/Parser/slh-asm-goto.cpp
===
--- /dev/null
+++ clang/test/Parser/slh-asm-goto.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-warning {{Speculative load hardening does not protect functions with asm goto}}
+}
Index: clang/test/Parser/slh-asm-goto-no-warn.cpp
===
--- /dev/null
+++ clang/test/Parser/slh-asm-goto-no-warn.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -Wno-slh-asm-goto -mspeculative-load-hardening -fsyntax-only -verify %s
+
+void f() {
+  __asm goto("movl %ecx, %edx"); // expected-no-diagnostics
+}
Index: clang/lib/Parse/ParseStmtAsm.cpp
===
--- clang/lib/Parse/ParseStmtAsm.cpp
+++ clang/lib/Parse/ParseStmtAsm.cpp
@@ -729,6 +729,9 @@
   if (parseGNUAsmQualifierListOpt(GAQ))
 return StmtError();
 
+  if (GAQ.isGoto() && getLangOpts().SpeculativeLoadHardening)
+Diag(Loc, diag::warn_slh_does_not_support_asm_goto);
+
   BalancedDelimiterTracker T(*this, tok::l_paren);
   T.consumeOpen();
 
Index: clang/include/clang/Basic/DiagnosticCommonKinds.td
===
--- clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -243,6 +243,9 @@
   def warn_stack_clash_protection_inline_asm : Warning<
 "Unable to protect inline asm that clobbers stack pointer against stack clash">,
 InGroup>;
+
+  def warn_slh_does_not_support_asm_goto : Warning<
+"Speculative load hardening does not protect functions with asm goto">, InGroup>;
 }
 
 // Sema && Serialization
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79998: Add AST_SIGNATURE record to unhashed control block of pcm files (Patch series 2/3)

2020-05-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

In D79998#2038430 , @dang wrote:

> Should I add the test here or in the clang-scan-deps patch?


It's best to have a test in every non-nfc patch. You should be able to test 
this with llvm-bcanalyzer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79998



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 265077.
nickdesaulniers added a comment.

- add support for structs, unions, and enums


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c

Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,30 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar", file: !4, line: 7, baseType: !5, size: 32, elements: !6)
+// CHECK: !5 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+// CHECK: !7 = !DIEnumerator(name: "BAR", value: 0, isUnsigned: true)
+// CHECK: !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int", file: !4, line: 5, baseType: !10)
+// CHECK: !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// CHECK: !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !4, line: 6, elements: !12)
+// CHECK: !13 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "baz", file: !4, line: 8, elements: !12)
+
+// Check that debug info is not emitted for the typedef, struct, enum, and
+// union when -fno-eliminate-unused-debug-types and -g are not set.
+
+// NODBG-NOT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar", file: !4, line: 7, baseType: !5, size: 32, elements: !6)
+// NODBG-NOT: !5 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+// NODBG-NOT: !7 = !DIEnumerator(name: "BAR", value: 0, isUnsigned: true)
+// NODBG-NOT: !9 = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int", file: !4, line: 5, baseType: !10)
+// NODBG-NOT: !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// NODBG-NOT: !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !4, line: 6, elements: !12)
+// NODBG-NOT: !13 = distinct !DICompositeType(tag: DW_TAG_union_type, name: "baz", file: !4, line: 8, elements: !12)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -765,6 +765,7 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
   Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
   Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
+  Opts.DebugUnusedTypes = Args.hasArg(OPT_eliminate_unused_debug_types_fno);
   Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
   Opts.ForceDwarfFrameSection = Args.hasArg(OPT_fforce_dwarf_frame);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5190,6 +5190,8 @@
 
   // Forward -f (flag) options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
+  Args.AddLastArg(CmdArgs, options::OPT_eliminate_unused_debug_types_f);
+  Args.AddLastArg(CmdArgs, options::OPT_eliminate_unused_debug_types_fno);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -,6 +,30 @@
 EmitOMPRequiresDecl(cast(D));
 break;
 
+  case Decl::Typedef:
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  if (getCodeGenOpts().DebugUnusedTypes) {
+QualType QT = getContext().getTypedefType(cast(D));
+DI->EmitExplicitCastType(QT);
+  }
+break;
+
+  case Decl::Record:
+if (CGDebugInfo *DI = getModuleDebugInfo())
+  if (getCodeGenOpts().DebugUnusedTypes) {
+QualType QT = getContext().getRecordType(cast(D));
+DI->EmitExplicitCastType(QT);
+  }
+break;
+
+  case Decl::Enum:
+i

[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D79967#2045196 , @vsk wrote:

> @yaxunl thanks, this patch lgtm.
>
> @dblaikie I've kicked off a thread on cfe-dev about the topics you brought up 
> ("Design discussion re: DW_TAG_call_site support in clang") and cc'd you.


Thanks on both counts!


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

https://reviews.llvm.org/D79967



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

For C++, I'd imagine:

  class foo {};
  using my_foo = foo;
  template 
  struct baz {
bar my_bar;
  };

but it seems that `g++` doesn't emit debug info the for the templated struct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-19 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 265071.
fghanim marked 2 inline comments as done.
fghanim added a comment.

Addressing reviewer Comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -62,7 +62,7 @@
 
 TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
 
   IRBuilder<> Builder(BB);
 
@@ -102,7 +102,7 @@
 TEST_F(OpenMPIRBuilderTest, CreateCancel) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
 
   BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
   new UnreachableInst(Ctx, CBB);
@@ -157,7 +157,7 @@
 TEST_F(OpenMPIRBuilderTest, CreateCancelIfCond) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
 
   BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
   new UnreachableInst(Ctx, CBB);
@@ -218,7 +218,7 @@
 TEST_F(OpenMPIRBuilderTest, CreateCancelBarrier) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
 
   BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
   new UnreachableInst(Ctx, CBB);
@@ -272,7 +272,7 @@
 
 TEST_F(OpenMPIRBuilderTest, DbgLoc) {
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
   F->setName("func");
 
   IRBuilder<> Builder(BB);
@@ -308,7 +308,7 @@
 TEST_F(OpenMPIRBuilderTest, ParallelSimple) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
   F->setName("func");
   IRBuilder<> Builder(BB);
 
@@ -405,7 +405,7 @@
 TEST_F(OpenMPIRBuilderTest, ParallelIfCond) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
   F->setName("func");
   IRBuilder<> Builder(BB);
 
@@ -516,7 +516,7 @@
 TEST_F(OpenMPIRBuilderTest, ParallelCancelBarrier) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
   F->setName("func");
   IRBuilder<> Builder(BB);
 
@@ -625,7 +625,7 @@
 TEST_F(OpenMPIRBuilderTest, MasterDirective) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
   F->setName("func");
   IRBuilder<> Builder(BB);
 
@@ -704,7 +704,7 @@
 TEST_F(OpenMPIRBuilderTest, CriticalDirective) {
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.initialize();
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
   F->setName("func");
   IRBuilder<> Builder(BB);
 
@@ -779,4 +779,41 @@
   EXPECT_EQ(CriticalEndCI->getArgOperand(2)->getType(), CriticalNamePtrTy);
 }
 
+TEST_F(OpenMPIRBuilderTest, CopyinBlocks) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize(Type::getInt32Ty(M->getContext()));
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+  IntegerType* Int32 = Type::getInt32Ty(M->getContext());
+  AllocaInst* MasterAddress = Builder.CreateAlloca(Int32->getPointerTo());
+	AllocaInst* PrivAddress = Builder.CreateAlloca(Int32->getPointerTo());
+
+  BasicBlock *EntryBB = BB;
+
+  OMPBuilder.CreateCopyinClauseBlocks(Builder.saveIP(), MasterAddress, PrivAddress, Int32, /*BranchtoEnd*/true);
+
+  BranchInst* EntryBr = dyn_cast_or_null(EntryBB->getTerminator());
+
+  EXPECT_NE(EntryBr, nullptr);
+  EXPECT_TRUE(EntryBr->isConditional());
+
+  BasicBlock* NotMasterBB = EntryBr->getSuccessor(0);
+  BasicBlock* CopyinEnd = EntryBr->getSuccessor(1);
+  CmpInst* CMP = dyn_cast_or_null(EntryBr->getCondition())

[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-19 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked 21 inline comments as done.
fghanim added a comment.

In D79675#2044809 , @jdoerfert wrote:

> What's the status? Can we split the target specific types stuff if this may 
> take a while, other patches depend on that :)


Could you please list the other patches that are being held back by this one? 
I'd be interested to have a look at them. :)




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > fghanim wrote:
> > > > jdoerfert wrote:
> > > > > fghanim wrote:
> > > > > > jdoerfert wrote:
> > > > > > > I think this was correct before:
> > > > > > > ```
> > > > > > >   KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 
> > > > > > > global_tid, kmp_critical_name *, uint32_t hint);
> > > > > > > ```
> > > > > > Nop, it's supposed to be whatever `IntPtrTy` is in the frontend 
> > > > > > (i.e. 32 for 32bit, 64 for 64bit).
> > > > > > 
> > > > > > `IntPtrTy` is actually a union with `sizety` in `CodeGenModule`
> > > > > I'm confused. I copied the declaration above from the runtime. It 
> > > > > doesn't contain an `IntPtrTy` or similar. I agree that `IntPtrTy` is 
> > > > > machine dependent and we need your initializers. What I tried to say 
> > > > > is that at least one declaration in the runtime has 
> > > > > `__kmpc_critical_with_hint` with an int32 as last argument. That 
> > > > > said, the runtime is not shy of incompatible declarations for 
> > > > > functions.
> > > > I cannot speak for what's in the runtime. However, in clang, this 
> > > > currently is defined to use `IntPtrTy`. If you go check, I have a todo 
> > > > in the current implementation for critical to come back and fix it.
> > > That is just an existing bug in Clang. The runtime is consistent with the 
> > > type and arguably it is the runtime we must match, not the other way 
> > > around ;)
> > Apparently, this used to be `uintptr_t` in the runtime and was changed by 
> > D51235 . It doesn't say why the change was made.
> > 
> > Clang uses this in multiple places, which makes me think it may have been 
> > intentional. So I suggest we go by the standard. Where can I find what does 
> > the OMP standard say about how the signature of the runtime calls should 
> > look like? This way I'll fix this one accordingly, and later we may go and 
> > make sure that all the rest match up with the standard - where possible.
> This is not a standard function. It is a runtime function. I suspect it is a 
> int32_t because enums default to `int` which is 32 bit on all interesting 
> platforms. Should probably be a `int` but I would need to read up to confirm. 
> Long story short, and as I said before, it is a bug in clang. The code here 
> was correct.
> 
> FWIW, we will soon replace clang's runtime function generation with these 
> macros. That will happen in the next days I hope.
Oh, my bad. I thought OMP runtime functions are designed a specific way based 
on the OMP standard. If that's not the case, then it doesn't matter. I'll drop 
this change as well. There is a handful of hints anyway.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:122
+  }
+}
+

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > fghanim wrote:
> > > > jdoerfert wrote:
> > > > > (I doubt we need the `initVoidPtr` function but if we do, the 
> > > > > condition looks wrong)
> > > > Forgot to refractor when I changed names.
> > > > 
> > > > Regarding `void*` , I am not sure how it is defined in fortran. That's 
> > > > why I made it possible to initialize it separately.
> > > I see. Let's cross that bridge once we get to it.
> > Modified it a bit and removed usage from initialization. If fortran people 
> > don't end using it, then we can remove it.
> Let's not add stuff that might be used.
I just looked this up. Apparently, Fortran doesn't seem to have the concept of 
void pointer natively. However, They have something called `Assumed types` , 
which was added for interoperability with C, which *probably* means it will 
follow whatever C does to handle void pointers.

I'll remove it now, and if they choose, people can add it later.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:106
+  initializeVoidPtrTy(VoidPtrTy);
+}
+

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > I guess we can directly call the initialize functions, right?
> > > With an assert that SizeTy is set we can make sure users do it ;)
> > Sure, then again, I am just followin

[PATCH] D77845: [analyzer][CallAndMessage][NFC] Change old callbacks to rely on CallEvent

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d0d2fefc0a1: analyzer][CallAndMessage][NFC] Change old 
callbacks to rely on CallEvent (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D77845?vs=256461&id=265074#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77845

Files:
  clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -11,9 +11,10 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
@@ -21,6 +22,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -29,11 +31,8 @@
 namespace {
 
 class CallAndMessageChecker
-  : public Checker< check::PreStmt,
-check::PreStmt,
-check::PreObjCMessage,
-check::ObjCMessageNil,
-check::PreCall > {
+: public Checker {
   mutable std::unique_ptr BT_call_null;
   mutable std::unique_ptr BT_call_undef;
   mutable std::unique_ptr BT_cxx_call_null;
@@ -48,11 +47,10 @@
   mutable std::unique_ptr BT_call_few_args;
 
 public:
-  DefaultBool Check_CallAndMessageUnInitRefArg;
-  CheckerNameRef CheckName_CallAndMessageUnInitRefArg;
+  enum CheckKind { CK_CallAndMessageUnInitRefArg, CK_NumCheckKinds };
+
+  DefaultBool ChecksEnabled[CK_NumCheckKinds];
 
-  void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
-  void checkPreStmt(const CXXDeleteExpr *DE, CheckerContext &C) const;
   void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const;
 
   /// Fill in the return value that results from messaging nil based on the
@@ -144,7 +142,7 @@
 CheckerContext &C, const SVal &V, SourceRange ArgRange, const Expr *ArgEx,
 std::unique_ptr &BT, const ParmVarDecl *ParamDecl, const char *BD,
 int ArgumentNumber) const {
-  if (!Check_CallAndMessageUnInitRefArg)
+  if (!ChecksEnabled[CK_CallAndMessageUnInitRefArg])
 return false;
 
   // No parameter declaration available, i.e. variadic function argument.
@@ -311,63 +309,36 @@
   return false;
 }
 
-void CallAndMessageChecker::checkPreStmt(const CallExpr *CE,
- CheckerContext &C) const{
-
-  const Expr *Callee = CE->getCallee()->IgnoreParens();
+void CallAndMessageChecker::checkPreCall(const CallEvent &Call,
+ CheckerContext &C) const {
   ProgramStateRef State = C.getState();
-  const LocationContext *LCtx = C.getLocationContext();
-  SVal L = State->getSVal(Callee, LCtx);
-
-  if (L.isUndef()) {
-if (!BT_call_undef)
-  BT_call_undef.reset(new BuiltinBug(
-  this, "Called function pointer is an uninitialized pointer value"));
-emitBadCall(BT_call_undef.get(), C, Callee);
-return;
-  }
-
-  ProgramStateRef StNonNull, StNull;
-  std::tie(StNonNull, StNull) = State->assume(L.castAs());
-
-  if (StNull && !StNonNull) {
-if (!BT_call_null)
-  BT_call_null.reset(new BuiltinBug(
-  this, "Called function pointer is null (null dereference)"));
-emitBadCall(BT_call_null.get(), C, Callee);
-return;
-  }
-
-  C.addTransition(StNonNull);
-}
+  if (const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr())) {
+const Expr *Callee = CE->getCallee()->IgnoreParens();
+const LocationContext *LCtx = C.getLocationContext();
+SVal L = State->getSVal(Callee, LCtx);
+
+if (L.isUndef()) {
+  if (!BT_call_undef)
+BT_call_undef.reset(new BuiltinBug(
+this, "Called function pointer is an uninitialized pointer value"));
+  emitBadCall(BT_call_undef.get(), C, Callee);
+  return;
+}
 
-void CallAndMessageChecker::checkPreStmt(const CXXDeleteExpr *DE,
- CheckerContext &C) const {
+ProgramStateRef StNonNull, StNull;
+std::tie(StNonNull, StNull) =
+State->assume(L.castAs());
 
-  SVal Arg = C.getSVal(DE->getArgument());
-  if (Arg.isUndef()) {
-StringRef Desc;
-ExplodedNode *N = C.generateErrorNode();
-if (!N)
+if (StNull && !StNonNull) {
+  

[PATCH] D75431: [analyzer][NFC] Merge checkNewAllocator's paramaters into CXXAllocatorCall

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf2be30def37d: [analyzer][NFC] Merge checkNewAllocator's 
paramaters into CXXAllocatorCall (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D75431?vs=254816&id=265075#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75431

Files:
  clang/include/clang/StaticAnalyzer/Core/Checker.h
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -21,6 +21,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/SaveAndRestore.h"
 
@@ -325,17 +326,14 @@
 CallEventRef<> UpdatedCall = Call.cloneWithState(CEEState);
 
 ExplodedNodeSet DstPostCall;
-if (const CXXNewExpr *CNE = dyn_cast_or_null(CE)) {
+if (llvm::isa_and_nonnull(CE)) {
   ExplodedNodeSet DstPostPostCallCallback;
   getCheckerManager().runCheckersForPostCall(DstPostPostCallCallback,
  CEENode, *UpdatedCall, *this,
  /*wasInlined=*/true);
-  for (auto I : DstPostPostCallCallback) {
+  for (ExplodedNode *I : DstPostPostCallCallback) {
 getCheckerManager().runCheckersForNewAllocator(
-CNE,
-*getObjectUnderConstruction(I->getState(), CNE,
-calleeCtx->getParent()),
-DstPostCall, I, *this,
+cast(*UpdatedCall), DstPostCall, I, *this,
 /*wasInlined=*/true);
   }
 } else {
@@ -591,7 +589,7 @@
   // If there were other constructors called for object-type arguments
   // of this call, clean them up.
   ExplodedNodeSet dstArgumentCleanup;
-  for (auto I : dstCallEvaluated)
+  for (ExplodedNode *I : dstCallEvaluated)
 finishArgumentConstruction(dstArgumentCleanup, I, Call);
 
   ExplodedNodeSet dstPostCall;
@@ -605,7 +603,7 @@
 
   // Run pointerEscape callback with the newly conjured symbols.
   SmallVector, 8> Escaped;
-  for (auto I : dstPostCall) {
+  for (ExplodedNode *I : dstPostCall) {
 NodeBuilder B(I, Dst, *currBldrCtx);
 ProgramStateRef State = I->getState();
 Escaped.clear();
@@ -743,7 +741,7 @@
 const ConstructionContext *CC = CCE ? CCE->getConstructionContext()
 : nullptr;
 
-if (CC && isa(CC) &&
+if (llvm::isa_and_nonnull(CC) &&
 !Opts.MayInlineCXXAllocator)
   return CIP_DisallowedOnce;
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -577,9 +577,10 @@
   // paths when no-return temporary destructors are used for assertions.
   const AnalysisDeclContext *ADC = LCtx->getAnalysisDeclContext();
   if (!ADC->getCFGBuildOptions().AddTemporaryDtors) {
-if (TargetRegion && isa(TargetRegion) &&
+if (llvm::isa_and_nonnull(TargetRegion) &&
 cast(Call->getDecl())
-->getParent()->isAnyDestructorNoReturn()) {
+->getParent()
+->isAnyDestructorNoReturn()) {
 
   // If we've inlined the constructor, then DstEvaluated would be empty.
   // In this case we still want a sink, which could be implemented
@@ -603,7 +604,7 @@
   }
 
   ExplodedNodeSet DstPostArgumentCleanup;
-  for (auto I : DstEvaluated)
+  for (ExplodedNode *I : DstEvaluated)
 finishArgumentConstruction(DstPostArgumentCleanup, I, *Call);
 
   // If there were other constructors called for object-type arguments
@@ -712,7 +713,7 @@
 
   ExplodedNodeSet DstPostCall;
   StmtNodeBuilder CallBldr(DstPreCall, DstPostCall, *currBldrCtx);
-  for (auto I : DstPreCall) {
+  for (ExplodedNode *I : DstPreCall) {
 // FIXME: Provide evalCall for checkers?
 defaultEvalCall(CallBldr, I, *Call);
   }
@@ -722,7 +723,7 @@
   // CXXNewExpr gets processed.
   ExplodedNodeSet DstPostValue;
   StmtNodeBuilder ValueBldr(DstPostCall, DstPostValue, *currBldrCtx);
-  for (auto I : DstPostCall) {
+  for (ExplodedNode *I : DstPostCall) {
 // FIXME: Because CNE serves as the "call site" for the all

[PATCH] D55892: [OpenMP] 'close' map-type-modifier code generation

2020-05-19 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir closed this revision.
saghir added a comment.
Herald added subscribers: sstefan1, yaxunl.

Support for  'close' map-type-modifier code generation in clang has been added 
by patch D65341 . This revision can be closed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55892



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


[PATCH] D80214: [clang-format] Set of unit test to begin to validate that we don't change defaults

2020-05-19 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

+1 for this idea. It'd eventually be neat to also take all samples from the 
style guide of each project and test them, if there aren't licensing concerns.

LGTM with an appropriate merge fix/CI passing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80214



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


[PATCH] D79465: [clang-format] Fix line lengths w/ comments in align

2020-05-19 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

Hey @MyDeveloperDay, can I get your assistance committing this when you have 
the chance?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79465



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:4965
+  DBuilder.retainType(Ty);
+}

Looks like I can just reuse CGDebugInfo::EmitExplicitCastType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[clang] f2be30d - [analyzer][NFC] Merge checkNewAllocator's paramaters into CXXAllocatorCall

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-20T00:56:10+02:00
New Revision: f2be30def37d248a7666cfac3c922ca9db308c2a

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

LOG: [analyzer][NFC] Merge checkNewAllocator's paramaters into CXXAllocatorCall

Party based on this thread:
http://lists.llvm.org/pipermail/cfe-dev/2020-February/064754.html.

This patch merges two of CXXAllocatorCall's parameters, so that we are able to
supply a CallEvent object to check::NewAllocatorCall (see the description of
D75430 to see why this would be great).

One of the things mentioned by @NoQ was the following:

  I think at this point we might actually do a good job sorting out this
  check::NewAllocator issue because we have a "separate" "Environment" to hold
  the other SVal, which is "objects under construction"! - so we should probably
  simply teach CXXAllocatorCall to extract the value from the
  objects-under-construction trait of the program state and we're good.

I had MallocChecker in my crosshair for now, so I admittedly threw together
something as a proof of concept. Now that I know that this effort is worth
pursuing though, I'll happily look for a solution better then demonstrated in
this patch.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/Checker.h
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h 
b/clang/include/clang/StaticAnalyzer/Core/Checker.h
index 0c7acdbc3a97..fdba49664615 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Checker.h
+++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h
@@ -285,9 +285,9 @@ class BranchCondition {
 
 class NewAllocator {
   template 
-  static void _checkNewAllocator(void *checker, const CXXNewExpr *NE,
- SVal Target, CheckerContext &C) {
-((const CHECKER *)checker)->checkNewAllocator(NE, Target, C);
+  static void _checkNewAllocator(void *checker, const CXXAllocatorCall &Call,
+ CheckerContext &C) {
+((const CHECKER *)checker)->checkNewAllocator(Call, C);
   }
 
 public:

diff  --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index f34f5c239290..820ccfceecf6 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -37,6 +37,7 @@ class TranslationUnitDecl;
 namespace ento {
 
 class AnalysisManager;
+class CXXAllocatorCall;
 class BugReporter;
 class CallEvent;
 class CheckerBase;
@@ -361,11 +362,9 @@ class CheckerManager {
  ExprEngine &Eng);
 
   /// Run checkers between C++ operator new and constructor calls.
-  void runCheckersForNewAllocator(const CXXNewExpr *NE, SVal Target,
-  ExplodedNodeSet &Dst,
-  ExplodedNode *Pred,
-  ExprEngine &Eng,
-  bool wasInlined = false);
+  void runCheckersForNewAllocator(const CXXAllocatorCall &Call,
+  ExplodedNodeSet &Dst, ExplodedNode *Pred,
+  ExprEngine &Eng, bool wasInlined = false);
 
   /// Run checkers for live symbols.
   ///
@@ -506,7 +505,7 @@ class CheckerManager {
   CheckerFn;
 
   using CheckNewAllocatorFunc =
-  CheckerFn;
+  CheckerFn;
 
   using CheckDeadSymbolsFunc =
   CheckerFn;

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
index 871875b45b1b..8b84b79651bd 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -39,6 +39,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -1010,6 +1011,12 @@ class CXXAllocatorCall : public AnyFunctionCall {
 return getOriginExpr()->getOperatorNew();
   }
 
+  SVal getObjectUnderConstruction() const {
+return ExprEngine::getObjectUnderConstruction(getState(), getOriginExpr(),

[clang] 3d0d2fe - analyzer][CallAndMessage][NFC] Change old callbacks to rely on CallEvent

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-20T00:37:59+02:00
New Revision: 3d0d2fefc0a18f13e45a17be04a3da8d2b1299f8

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

LOG: analyzer][CallAndMessage][NFC] Change old callbacks to rely on CallEvent

The following series of patches has something similar in mind with D77474, with
the same goal to finally end incorrect checker names for good. Despite
CallAndMessage not suffering from this particular issue, it is a dependency for
many other checkers, which is problematic, because we don't really want
dependencies to also emit diagnostics (reasoning for this is also more detailed
in D77474).

CallAndMessage also has another problem, namely that it is responsible for a lot
of reports. You'll soon learn that this isn't really easy to solve for
compatibility reasons, but that is the topic of followup patches.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index 82bc200ba4ce..00fbe2c8dcb7 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -11,9 +11,10 @@
 //
 
//===--===//
 
-#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ParentMap.h"
 #include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
@@ -21,6 +22,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -29,11 +31,8 @@ using namespace ento;
 namespace {
 
 class CallAndMessageChecker
-  : public Checker< check::PreStmt,
-check::PreStmt,
-check::PreObjCMessage,
-check::ObjCMessageNil,
-check::PreCall > {
+: public Checker {
   mutable std::unique_ptr BT_call_null;
   mutable std::unique_ptr BT_call_undef;
   mutable std::unique_ptr BT_cxx_call_null;
@@ -48,11 +47,10 @@ class CallAndMessageChecker
   mutable std::unique_ptr BT_call_few_args;
 
 public:
-  DefaultBool Check_CallAndMessageUnInitRefArg;
-  CheckerNameRef CheckName_CallAndMessageUnInitRefArg;
+  enum CheckKind { CK_CallAndMessageUnInitRefArg, CK_NumCheckKinds };
+
+  DefaultBool ChecksEnabled[CK_NumCheckKinds];
 
-  void checkPreStmt(const CallExpr *CE, CheckerContext &C) const;
-  void checkPreStmt(const CXXDeleteExpr *DE, CheckerContext &C) const;
   void checkPreObjCMessage(const ObjCMethodCall &msg, CheckerContext &C) const;
 
   /// Fill in the return value that results from messaging nil based on the
@@ -144,7 +142,7 @@ bool CallAndMessageChecker::uninitRefOrPointer(
 CheckerContext &C, const SVal &V, SourceRange ArgRange, const Expr *ArgEx,
 std::unique_ptr &BT, const ParmVarDecl *ParamDecl, const char *BD,
 int ArgumentNumber) const {
-  if (!Check_CallAndMessageUnInitRefArg)
+  if (!ChecksEnabled[CK_CallAndMessageUnInitRefArg])
 return false;
 
   // No parameter declaration available, i.e. variadic function argument.
@@ -311,63 +309,36 @@ bool 
CallAndMessageChecker::PreVisitProcessArg(CheckerContext &C,
   return false;
 }
 
-void CallAndMessageChecker::checkPreStmt(const CallExpr *CE,
- CheckerContext &C) const{
-
-  const Expr *Callee = CE->getCallee()->IgnoreParens();
+void CallAndMessageChecker::checkPreCall(const CallEvent &Call,
+ CheckerContext &C) const {
   ProgramStateRef State = C.getState();
-  const LocationContext *LCtx = C.getLocationContext();
-  SVal L = State->getSVal(Callee, LCtx);
-
-  if (L.isUndef()) {
-if (!BT_call_undef)
-  BT_call_undef.reset(new BuiltinBug(
-  this, "Called function pointer is an uninitialized pointer value"));
-emitBadCall(BT_call_undef.get(), C, Callee);
-return;
-  }
-
-  ProgramStateRef StNonNull, StNull;
-  std::tie(StNonNull, StNull) = 
State->assume(L.castAs());
-
-  if (StNull && !StNonNull) {
-if (!BT_call_null)
-  BT_call_null.reset(new BuiltinBug(
-  this, "Called function pointer is null (null dereference)"));
-emitBadCall(BT_call_null.get(), C, Callee);
-return;
-  }
-
-  C.ad

[PATCH] D80176: [clang-format][PR45816] Add AlignConsecutiveBitFields

2020-05-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80176



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


[PATCH] D78124: [analyzer][ObjCGenerics] Don't emit diagnostics under the name core.DynamicTypePropagation

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66224d309d08: [analyzer][ObjCGenerics] Don't emit 
diagnostics under the name core. (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D78124?vs=257375&id=265067#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78124

Files:
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/test/Analysis/Inputs/expected-plists/generics.m.plist

Index: clang/test/Analysis/Inputs/expected-plists/generics.m.plist
===
--- clang/test/Analysis/Inputs/expected-plists/generics.m.plist
+++ clang/test/Analysis/Inputs/expected-plists/generics.m.plist
@@ -138,9 +138,9 @@
descriptionConversion from value of type 'NSMutableArray *' to incompatible type 'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_context33d4584e2bf66b029ab9d152cc9cd8f7
+   issue_hash_content_of_line_in_context9be4ccbeebeb5f814eb9ff5cef4907d3
   issue_context_kindfunction
   issue_contextincompatibleTypesErased
   issue_hash_function_offset2
@@ -295,9 +295,9 @@
descriptionConversion from value of type 'NSMutableArray *' to incompatible type 'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_context6edc910aaa9dc1f2d823abc8cb75360f
+   issue_hash_content_of_line_in_context567cd90c936f23ea70aca98b9d3af2b7
   issue_context_kindfunction
   issue_contextincompatibleTypesErased
   issue_hash_function_offset5
@@ -421,9 +421,9 @@
descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_context73c71c858082f5d7a2258f707927da3c
+   issue_hash_content_of_line_in_contexta6e6f9c2db7532f45c07d2c13bcf496b
   issue_context_kindfunction
   issue_contextincompatibleTypesErased
   issue_hash_function_offset8
@@ -689,9 +689,9 @@
descriptionConversion from value of type 'NSArray *' to incompatible type 'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_context82c378fdcfcc5c0318d2f3ca46420ec1
+   issue_hash_content_of_line_in_context73523166e7c9e436da86a96fbd7b3d90
   issue_context_kindfunction
   issue_contextcrossProceduralErasedTypes
   issue_hash_function_offset1
@@ -846,9 +846,9 @@
descriptionConversion from value of type 'NSMutableArray *' to incompatible type 'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_context234e3c299ee75a4dd4563e0ea88b9ed9
+   issue_hash_content_of_line_in_context649d50ef4cf1287ed225396d39995361
   issue_context_kindfunction
   issue_contextincompatibleTypesErasedReverseConversion
   issue_hash_function_offset4
@@ -970,9 +970,9 @@
descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_contexte875afc5479fec33a693ce2b550a9573
+   issue_hash_content_of_line_in_contextd5cc413c71cae912d5ba469f8fa05ac3
   issue_context_kindfunction
   issue_contextincompatibleTypesErasedReverseConversion
   issue_hash_function_offset6
@@ -1129,9 +1129,9 @@
descriptionConversion from value of type 'NSMutableArray *' to incompatible type 'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_contextd7fa9fa89fe860ed8f5d22631233a5fa
+   issue_hash_content_of_line_in_context36d360e268b9ebc2d70e160a15b9a186
   issue_context_kindfunction
   issue_contextidErasedIncompatibleTypesReverseConversion
   issue_hash_function_offset4
@@ -1252,9 +1252,9 @@
descriptionConversion from value of type 'NSNumber *' to incompatible type 'NSString *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   issue_hash_content_of_line_in_context7de91182a5d6e40a85fa3b91cf3fd089
+   issue_hash_content_of_line_in_contexta7326f4dedbc94e8fa1ee02d851e7810
   issue_context_kindfunction
   issue_contextidErasedIncompatibl

[PATCH] D78123: [analyzer][NSOrCFError] Don't emit diagnostics under the name osx.NSOrCFErrorDerefChecker

2020-05-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb47d1baa535a: [analyzer][NSOrCFError] Don't emit 
diagnostics under the name osx. (authored by Szelethus).

Changed prior to commit:
  https://reviews.llvm.org/D78123?vs=257373&id=265066#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78123

Files:
  clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
  clang/test/Analysis/incorrect-checker-names.mm


Index: clang/test/Analysis/incorrect-checker-names.mm
===
--- clang/test/Analysis/incorrect-checker-names.mm
+++ clang/test/Analysis/incorrect-checker-names.mm
@@ -106,9 +106,19 @@
 
 void foo(CFErrorRef* error) { // expected-warning{{Function accepting 
CFErrorRef* should have a non-void return value to indicate whether or not an 
error occurred [osx.coreFoundation.CFError]}}
   // FIXME: This shouldn't be tied to a modeling checker.
-  *error = 0;  // expected-warning {{Potential null dereference.  According to 
coding standards documented in CoreFoundation/CFError.h the parameter may be 
null [osx.NSOrCFErrorDerefChecker]}}
+  *error = 0; // expected-warning {{Potential null dereference.  According to 
coding standards documented in CoreFoundation/CFError.h the parameter may be 
null [osx.coreFoundation.CFError]}}
 }
 
+@interface A
+- (void)myMethodWhichMayFail:(NSError **)error;
+@end
+
+@implementation A
+- (void)myMethodWhichMayFail:(NSError **)error {  // 
expected-warning {{Method accepting NSError** should have a non-void return 
value to indicate whether or not an error occurred [osx.cocoa.NSError]}}
+  *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // 
expected-warning {{Potential null dereference.  According to coding standards 
in 'Creating and Returning NSError Objects' the parameter may be null 
[osx.cocoa.NSError]}}
+}
+@end
+
 bool write_into_out_param_on_success(OS_RETURNS_RETAINED OSObject **obj);
 
 void use_out_param_leak() {
Index: clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
@@ -144,14 +144,14 @@
 
 class NSErrorDerefBug : public BugType {
 public:
-  NSErrorDerefBug(const CheckerBase *Checker)
+  NSErrorDerefBug(const CheckerNameRef Checker)
   : BugType(Checker, "NSError** null dereference",
 "Coding conventions (Apple)") {}
 };
 
 class CFErrorDerefBug : public BugType {
 public:
-  CFErrorDerefBug(const CheckerBase *Checker)
+  CFErrorDerefBug(const CheckerNameRef Checker)
   : BugType(Checker, "CFErrorRef* null dereference",
 "Coding conventions (Apple)") {}
 };
@@ -166,9 +166,9 @@
   mutable std::unique_ptr NSBT;
   mutable std::unique_ptr CFBT;
 public:
-  bool ShouldCheckNSError, ShouldCheckCFError;
-  NSOrCFErrorDerefChecker() : NSErrorII(nullptr), CFErrorII(nullptr),
-  ShouldCheckNSError(0), ShouldCheckCFError(0) { }
+  DefaultBool ShouldCheckNSError, ShouldCheckCFError;
+  CheckerNameRef NSErrorName, CFErrorName;
+  NSOrCFErrorDerefChecker() : NSErrorII(nullptr), CFErrorII(nullptr) {}
 
   void checkLocation(SVal loc, bool isLoad, const Stmt *S,
  CheckerContext &C) const;
@@ -276,12 +276,12 @@
   BugType *bug = nullptr;
   if (isNSError) {
 if (!NSBT)
-  NSBT.reset(new NSErrorDerefBug(this));
+  NSBT.reset(new NSErrorDerefBug(NSErrorName));
 bug = NSBT.get();
   }
   else {
 if (!CFBT)
-  CFBT.reset(new CFErrorDerefBug(this));
+  CFBT.reset(new CFErrorDerefBug(CFErrorName));
 bug = CFBT.get();
   }
   BR.emitReport(
@@ -331,6 +331,7 @@
   mgr.registerChecker();
   NSOrCFErrorDerefChecker *checker = mgr.getChecker();
   checker->ShouldCheckNSError = true;
+  checker->NSErrorName = mgr.getCurrentCheckerName();
 }
 
 bool ento::shouldRegisterNSErrorChecker(const CheckerManager &mgr) {
@@ -341,6 +342,7 @@
   mgr.registerChecker();
   NSOrCFErrorDerefChecker *checker = mgr.getChecker();
   checker->ShouldCheckCFError = true;
+  checker->CFErrorName = mgr.getCurrentCheckerName();
 }
 
 bool ento::shouldRegisterCFErrorChecker(const CheckerManager &mgr) {


Index: clang/test/Analysis/incorrect-checker-names.mm
===
--- clang/test/Analysis/incorrect-checker-names.mm
+++ clang/test/Analysis/incorrect-checker-names.mm
@@ -106,9 +106,19 @@
 
 void foo(CFErrorRef* error) { // expected-warning{{Function accepting CFErrorRef* should have a non-void return value to indicate whether or not an error occurred [osx.coreFoundation.CFError]}}
   // FIXME: This shouldn't be tied to a modeling checker.
-  *error = 0;  // expected-warning {{Potential null dereference.  According to coding standards documente

[PATCH] D80176: [clang-format][PR45816] Add AlignConsecutiveBitFields

2020-05-19 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

Can I get your assistance committing this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80176



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

ah, right. I need to additionally handle structs, unions, enums.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D80166: [CGCall] Annotate reference parameters with "align" attribute.

2020-05-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/lib/CodeGen/CGCall.cpp:2258
 Attrs.addDereferenceableAttr(info.first.getQuantity());
-Attrs.addAttribute(llvm::Attribute::getWithAlignment(
-getLLVMContext(), info.second.getAsAlign()));
+Attrs.addAlignmentAttr(info.second.getAsAlign());
   }

efriedma wrote:
> rjmccall wrote:
> > Both of these are wrong for classes with virtual bases.
> I'm pretty sure classes with virtual bases aren't used with 
> SwiftIndirectResult, so not really relevant.
Ah... true, and even if they were, it would presumably be a complete object 
that was returned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80166



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D60620#1464633 , @tra wrote:

> It looks like you are solving two problems here.
>  a) you want to create multiple device passes for the same GPU, but with 
> different options.
>  b) you may want to pass different compiler options to different device 
> compilations.
>  The patch effectively hard-codes {gpu, options} tuple into 
> --offloading-target-id variant.
>  Is that correct?
>
> This looks essentially the same as your previous patch D59863 
> .
>
> We have a limited way to deal with (b), but there's currently no way to deal 
> with (a).
>
> For (a), I think, the real problem is that until now we've assumed that 
> there's only one device-side compilation per target GPU arch. If we need 
> multiple device-side compilations, we need a way to name them.  Using 
> `offloading-target-id` as  a super-set of `--cuda-gpu-arch` is OK with me. 
> However, I'm on the fence about the option serving a double-duty of setting 
> magic compiler flags. On one hand, that's what driver does, so it may be OK. 
> On the other hand, it's unnecessarily strict. I.e. if we provide ability to 
> create multiple compilation passes for the same GPU arch, why limit that to 
> only changing those hard-coded options? A general approach would allow a way 
> to create more than one device-side compilation and provide arbitrary 
> compiler options only to *that* compilation. Thiw will also help solving 
> number of issues we have right now when some host-side compilation options 
> break device-side compilation and we have to work around that by filtering 
> out some of them in the driver.


This patch is trying to solve the issue about GPU arch explosion due to 
combination of GPU configurations. A GPU may have several configurations which 
require different ISA's. From the compiler point of view, the GPU plus 
configuration behaves like different GPU archs. Previously we have been using 
different gfx names for the same GPU with different configurations. However, 
that does not scale. Therefore in this patch we extend GPU arch to `target id`, 
which is something like gpu+feature1-feature2.

The features allowed in target id are not arbitrary target features. They 
corresponding a limited number of GPU configurations that HIP runtime 
understands. Basically HIP runtime looks at the target id of the device objects 
in a fat binary and knows which one is best for the current GPU configuration. 
On the other hand, this is not some feature that can be easily implemented by 
users, since it needs knowledge about GPU configurations and corresponding 
compiler options for such configurations. Therefore, this is some feature 
better implemented within HIP compiler/runtime.

For embedding multiple device binaries for the same GPU but compiled with 
different options in one fat binary, since HIP runtime does not know which one 
to load, I don't think it is useful. On the other hand, users can always 
implement their own mechanisms for using device binaries compiled with 
different options with their own logic about how to choose them, therefore this 
is better left to the users.


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

https://reviews.llvm.org/D60620



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


[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-19 Thread Vedant Kumar via Phabricator via cfe-commits
vsk accepted this revision.
vsk added a comment.
This revision is now accepted and ready to land.

@yaxunl thanks, this patch lgtm.

@dblaikie I've kicked off a thread on cfe-dev about the topics you brought up 
("Design discussion re: DW_TAG_call_site support in clang") and cc'd you.


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

https://reviews.llvm.org/D79967



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


[clang] 66224d3 - [analyzer][ObjCGenerics] Don't emit diagnostics under the name core.DynamicTypePropagation

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-20T00:19:20+02:00
New Revision: 66224d309d08c048b3bea257ceafe4873ce166c6

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

LOG: [analyzer][ObjCGenerics] Don't emit diagnostics under the name 
core.DynamicTypePropagation

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
clang/test/Analysis/Inputs/expected-plists/generics.m.plist

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
index 1502c0f9d656..14ba5d769969 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -55,6 +55,7 @@ class DynamicTypePropagation:
 check::PostStmt,
 check::PreObjCMessage,
 check::PostObjCMessage > {
+
   const ObjCObjectType *getObjectTypeForAllocAndNew(const ObjCMessageExpr 
*MsgE,
 CheckerContext &C) const;
 
@@ -69,8 +70,8 @@ class DynamicTypePropagation:
   mutable std::unique_ptr ObjCGenericsBugType;
   void initBugType() const {
 if (!ObjCGenericsBugType)
-  ObjCGenericsBugType.reset(
-  new BugType(this, "Generics", categories::CoreFoundationObjectiveC));
+  ObjCGenericsBugType.reset(new BugType(
+  GenericCheckName, "Generics", categories::CoreFoundationObjectiveC));
   }
 
   class GenericsBugVisitor : public BugReporterVisitor {
@@ -108,6 +109,7 @@ class DynamicTypePropagation:
 
   /// This value is set to true, when the Generics checker is turned on.
   DefaultBool CheckGenerics;
+  CheckerNameRef GenericCheckName;
 };
 
 bool isObjCClassType(QualType Type) {
@@ -1101,6 +1103,7 @@ PathDiagnosticPieceRef 
DynamicTypePropagation::GenericsBugVisitor::VisitNode(
 void ento::registerObjCGenericsChecker(CheckerManager &mgr) {
   DynamicTypePropagation *checker = mgr.getChecker();
   checker->CheckGenerics = true;
+  checker->GenericCheckName = mgr.getCurrentCheckerName();
 }
 
 bool ento::shouldRegisterObjCGenericsChecker(const CheckerManager &mgr) {

diff  --git a/clang/test/Analysis/Inputs/expected-plists/generics.m.plist 
b/clang/test/Analysis/Inputs/expected-plists/generics.m.plist
index ad01828a350e..bbe77595818d 100644
--- a/clang/test/Analysis/Inputs/expected-plists/generics.m.plist
+++ b/clang/test/Analysis/Inputs/expected-plists/generics.m.plist
@@ -138,9 +138,9 @@
descriptionConversion from value of type 
'NSMutableArray *' to incompatible type 
'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   
issue_hash_content_of_line_in_context33d4584e2bf66b029ab9d152cc9cd8f7
+   
issue_hash_content_of_line_in_context9be4ccbeebeb5f814eb9ff5cef4907d3
   issue_context_kindfunction
   issue_contextincompatibleTypesErased
   issue_hash_function_offset2
@@ -295,9 +295,9 @@
descriptionConversion from value of type 
'NSMutableArray *' to incompatible type 
'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   
issue_hash_content_of_line_in_context6edc910aaa9dc1f2d823abc8cb75360f
+   
issue_hash_content_of_line_in_context567cd90c936f23ea70aca98b9d3af2b7
   issue_context_kindfunction
   issue_contextincompatibleTypesErased
   issue_hash_function_offset5
@@ -421,9 +421,9 @@
descriptionConversion from value of type 'NSNumber 
*' to incompatible type 'NSString *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   
issue_hash_content_of_line_in_context73c71c858082f5d7a2258f707927da3c
+   
issue_hash_content_of_line_in_contexta6e6f9c2db7532f45c07d2c13bcf496b
   issue_context_kindfunction
   issue_contextincompatibleTypesErased
   issue_hash_function_offset8
@@ -689,9 +689,9 @@
descriptionConversion from value of type 
'NSArray *' to incompatible type 
'NSArray *'
categoryCore Foundation/Objective-C
typeGenerics
-   check_namecore.DynamicTypePropagation
+   check_nameosx.cocoa.ObjCGenerics

-   
issue_hash_content_of_line_in_context82c378fdcfcc5c0318d2f3ca46420ec1
+   
issue_hash_content_of_line_in_context73523166e7c9e436da86a96fbd7b3d90
   issue_context_kindfunction
   issue_contextcrossProceduralErasedTypes
   issue_hash_function_offset1
@@ -846,9 +846,9 @@
descriptionConversion from value of type 
'NSMutableArray *' to incompatible type 
'NSArr

[clang] b47d1ba - [analyzer][NSOrCFError] Don't emit diagnostics under the name osx.NSOrCFErrorDerefChecker

2020-05-19 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-05-20T00:05:49+02:00
New Revision: b47d1baa535abe061e6a89341e91c8b885b5b80e

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

LOG: [analyzer][NSOrCFError] Don't emit diagnostics under the name 
osx.NSOrCFErrorDerefChecker

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
clang/test/Analysis/incorrect-checker-names.mm

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
index 5f68788fafcd..90c5583d8969 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
@@ -144,14 +144,14 @@ namespace {
 
 class NSErrorDerefBug : public BugType {
 public:
-  NSErrorDerefBug(const CheckerBase *Checker)
+  NSErrorDerefBug(const CheckerNameRef Checker)
   : BugType(Checker, "NSError** null dereference",
 "Coding conventions (Apple)") {}
 };
 
 class CFErrorDerefBug : public BugType {
 public:
-  CFErrorDerefBug(const CheckerBase *Checker)
+  CFErrorDerefBug(const CheckerNameRef Checker)
   : BugType(Checker, "CFErrorRef* null dereference",
 "Coding conventions (Apple)") {}
 };
@@ -166,9 +166,9 @@ class NSOrCFErrorDerefChecker
   mutable std::unique_ptr NSBT;
   mutable std::unique_ptr CFBT;
 public:
-  bool ShouldCheckNSError, ShouldCheckCFError;
-  NSOrCFErrorDerefChecker() : NSErrorII(nullptr), CFErrorII(nullptr),
-  ShouldCheckNSError(0), ShouldCheckCFError(0) { }
+  DefaultBool ShouldCheckNSError, ShouldCheckCFError;
+  CheckerNameRef NSErrorName, CFErrorName;
+  NSOrCFErrorDerefChecker() : NSErrorII(nullptr), CFErrorII(nullptr) {}
 
   void checkLocation(SVal loc, bool isLoad, const Stmt *S,
  CheckerContext &C) const;
@@ -276,12 +276,12 @@ void 
NSOrCFErrorDerefChecker::checkEvent(ImplicitNullDerefEvent event) const {
   BugType *bug = nullptr;
   if (isNSError) {
 if (!NSBT)
-  NSBT.reset(new NSErrorDerefBug(this));
+  NSBT.reset(new NSErrorDerefBug(NSErrorName));
 bug = NSBT.get();
   }
   else {
 if (!CFBT)
-  CFBT.reset(new CFErrorDerefBug(this));
+  CFBT.reset(new CFErrorDerefBug(CFErrorName));
 bug = CFBT.get();
   }
   BR.emitReport(
@@ -331,6 +331,7 @@ void ento::registerNSErrorChecker(CheckerManager &mgr) {
   mgr.registerChecker();
   NSOrCFErrorDerefChecker *checker = mgr.getChecker();
   checker->ShouldCheckNSError = true;
+  checker->NSErrorName = mgr.getCurrentCheckerName();
 }
 
 bool ento::shouldRegisterNSErrorChecker(const CheckerManager &mgr) {
@@ -341,6 +342,7 @@ void ento::registerCFErrorChecker(CheckerManager &mgr) {
   mgr.registerChecker();
   NSOrCFErrorDerefChecker *checker = mgr.getChecker();
   checker->ShouldCheckCFError = true;
+  checker->CFErrorName = mgr.getCurrentCheckerName();
 }
 
 bool ento::shouldRegisterCFErrorChecker(const CheckerManager &mgr) {

diff  --git a/clang/test/Analysis/incorrect-checker-names.mm 
b/clang/test/Analysis/incorrect-checker-names.mm
index f14eea9d9c63..11b6a21a14a9 100644
--- a/clang/test/Analysis/incorrect-checker-names.mm
+++ b/clang/test/Analysis/incorrect-checker-names.mm
@@ -106,9 +106,19 @@ + (id)errorWithDomain:(NSString *)domain 
code:(NSInteger)code userInfo:(NSDictio
 
 void foo(CFErrorRef* error) { // expected-warning{{Function accepting 
CFErrorRef* should have a non-void return value to indicate whether or not an 
error occurred [osx.coreFoundation.CFError]}}
   // FIXME: This shouldn't be tied to a modeling checker.
-  *error = 0;  // expected-warning {{Potential null dereference.  According to 
coding standards documented in CoreFoundation/CFError.h the parameter may be 
null [osx.NSOrCFErrorDerefChecker]}}
+  *error = 0; // expected-warning {{Potential null dereference.  According to 
coding standards documented in CoreFoundation/CFError.h the parameter may be 
null [osx.coreFoundation.CFError]}}
 }
 
+@interface A
+- (void)myMethodWhichMayFail:(NSError **)error;
+@end
+
+@implementation A
+- (void)myMethodWhichMayFail:(NSError **)error {  // 
expected-warning {{Method accepting NSError** should have a non-void return 
value to indicate whether or not an error occurred [osx.cocoa.NSError]}}
+  *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // 
expected-warning {{Potential null dereference.  According to coding standards 
in 'Creating and Returning NSError Objects' the parameter may be null 
[osx.cocoa.NSError]}}
+}
+@end
+
 bool write_into_out_param_on_success(OS_RETURNS_RETAINED OSObject **obj);
 
 void use_out_param_leak() {



___
cfe-commit

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Looks like this only implements support for typedefs, but the flag in GCC does 
more than that (as the flag name indicates - it's about unused types in 
general) - could you test this across some non-trivial code and see if it 
matches GCC's behavior (or, where it doesn't, that there's a good reason for 
that divergence)

Here's a few cases I tested by hand:

  typedef int t1; // yes
  struct t2 { }; // yes
  template
  struct t3 { T t; };
  void f1(
  decltype(t3::t), // yes (t3)
  t3); // no (t3)
  struct t4; // no
  struct t5; // yes because \/
  typedef t5* t6; // yes
  struct t7; // no
  void f2(t7*);

https://godbolt.org/z/SgHxJv




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5559
+  case Decl::Typedef:
+if (getCodeGenOpts().DebugUnusedTypes)
+  if (CGDebugInfo *DI = getModuleDebugInfo())

Probably test this within the implementation of CGDebugInfo? & rename the 
EmitTypedef function to something that clarifies that it's for an otherwise 
unused type?

But that function might need to be generalized further, rather than only having 
it for typedefs. (see general comment above)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[PATCH] D80251: [X86] Update some av512 shift intrinsics to use "unsigned int" parameter instead of int to match Intel documentaiton

2020-05-19 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.

There are 65 that take a scalar shift amount. Intel documentation shows 60 of 
them taking unsigned int. There are 5 versions of srli_epi16 that use int, the 
512-bit maskz and 128/256 mask/maskz.

Fixes PR45931


https://reviews.llvm.org/D80251

Files:
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/test/CodeGen/avx512bw-builtins.c
  clang/test/CodeGen/avx512f-builtins.c
  clang/test/CodeGen/avx512vl-builtins.c
  clang/test/CodeGen/avx512vlbw-builtins.c

Index: clang/test/CodeGen/avx512vlbw-builtins.c
===
--- clang/test/CodeGen/avx512vlbw-builtins.c
+++ clang/test/CodeGen/avx512vlbw-builtins.c
@@ -2199,7 +2199,7 @@
   return _mm_mask_slli_epi16(__W, __U, __A, 5); 
 }
 
-__m128i test_mm_mask_slli_epi16_2(__m128i __W, __mmask8 __U, __m128i __A, int __B) {
+__m128i test_mm_mask_slli_epi16_2(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm_mask_slli_epi16_2
   // CHECK: @llvm.x86.sse2.pslli.w
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
@@ -2213,7 +2213,7 @@
   return _mm_maskz_slli_epi16(__U, __A, 5); 
 }
 
-__m128i test_mm_maskz_slli_epi16_2(__mmask8 __U, __m128i __A, int __B) {
+__m128i test_mm_maskz_slli_epi16_2(__mmask8 __U, __m128i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm_maskz_slli_epi16_2
   // CHECK: @llvm.x86.sse2.pslli.w
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
@@ -2227,7 +2227,7 @@
   return _mm256_mask_slli_epi16(__W, __U, __A, 5); 
 }
 
-__m256i test_mm256_mask_slli_epi16_2(__m256i __W, __mmask16 __U, __m256i __A, int __B) {
+__m256i test_mm256_mask_slli_epi16_2(__m256i __W, __mmask16 __U, __m256i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm256_mask_slli_epi16_2
   // CHECK: @llvm.x86.avx2.pslli.w
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
@@ -2241,7 +2241,7 @@
   return _mm256_maskz_slli_epi16(__U, __A, 5); 
 }
 
-__m256i test_mm256_maskz_slli_epi16_2(__mmask16 __U, __m256i __A, int __B) {
+__m256i test_mm256_maskz_slli_epi16_2(__mmask16 __U, __m256i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm256_maskz_slli_epi16_2
   // CHECK: @llvm.x86.avx2.pslli.w
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
@@ -2447,7 +2447,7 @@
   return _mm_mask_srai_epi16(__W, __U, __A, 5); 
 }
 
-__m128i test_mm_mask_srai_epi16_2(__m128i __W, __mmask8 __U, __m128i __A, int __B) {
+__m128i test_mm_mask_srai_epi16_2(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm_mask_srai_epi16_2
   // CHECK: @llvm.x86.sse2.psrai.w
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
@@ -2461,7 +2461,7 @@
   return _mm_maskz_srai_epi16(__U, __A, 5); 
 }
 
-__m128i test_mm_maskz_srai_epi16_2(__mmask8 __U, __m128i __A, int __B) {
+__m128i test_mm_maskz_srai_epi16_2(__mmask8 __U, __m128i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm_maskz_srai_epi16_2
   // CHECK: @llvm.x86.sse2.psrai.w
   // CHECK: select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
@@ -2475,7 +2475,7 @@
   return _mm256_mask_srai_epi16(__W, __U, __A, 5); 
 }
 
-__m256i test_mm256_mask_srai_epi16_2(__m256i __W, __mmask16 __U, __m256i __A, int __B) {
+__m256i test_mm256_mask_srai_epi16_2(__m256i __W, __mmask16 __U, __m256i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm256_mask_srai_epi16_2
   // CHECK: @llvm.x86.avx2.psrai.w
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
@@ -2489,7 +2489,7 @@
   return _mm256_maskz_srai_epi16(__U, __A, 5); 
 }
 
-__m256i test_mm256_maskz_srai_epi16_2(__mmask16 __U, __m256i __A, int __B) {
+__m256i test_mm256_maskz_srai_epi16_2(__mmask16 __U, __m256i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm256_maskz_srai_epi16_2
   // CHECK: @llvm.x86.avx2.psrai.w
   // CHECK: select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
Index: clang/test/CodeGen/avx512vl-builtins.c
===
--- clang/test/CodeGen/avx512vl-builtins.c
+++ clang/test/CodeGen/avx512vl-builtins.c
@@ -6236,7 +6236,7 @@
   return _mm_mask_srli_epi32(__W, __U, __A, 5); 
 }
 
-__m128i test_mm_mask_srli_epi32_2(__m128i __W, __mmask8 __U, __m128i __A, int __B) {
+__m128i test_mm_mask_srli_epi32_2(__m128i __W, __mmask8 __U, __m128i __A, unsigned int __B) {
   // CHECK-LABEL: @test_mm_mask_srli_epi32_2
   // CHECK: @llvm.x86.sse2.psrli.d
   // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
@@ -6250,7 +6250,7 @@
   return _mm_maskz_srli_epi32(__U, __A, 5); 
 }
 
-__m128i test_mm_maskz_srli_epi32_2(__mmask8 __U, __m128i __A, int __B) {
+__m128i test_mm_maskz_srli_epi32_2(__mmask8 __U, __m128i __A, unsigned int __B) {
   // CHECK-LAB

[PATCH] D80153: [AST] Mangle LambdaContextDecl for top level decl

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 265046.
zequanwu added a comment.

Update test cases.


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

https://reviews.llvm.org/D80153

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx17.cpp


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -19,3 +19,11 @@
 
 // CHECK-DAG: "?$S4@@3US@@B"
 const auto [x2, y2] = f();
+
+// CHECK-DAG: "?i1@@3V@0@B"
+inline const auto i1 = [](auto x) { return 0; };
+// CHECK-DAG: "?i2@@3V@0@B"
+inline const auto i2 = [](auto x) { return 1; };
+// CHECK-DAG: "??$?RH@@i1@@QBE?A?@@H@Z"
+// CHECK-DAG: "??$?RH@@i2@@QBE?A?@@H@Z"
+int g() {return i1(1) + i2(1); }
Index: clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
@@ -337,10 +337,10 @@
   }();
   using FPtrTy = void(void);
   static void default_args(FPtrTy x = [] {}, FPtrTy y = [] {}, int z = [] { 
return 1; }() + [] { return 2; }()) {}
-  // CHECK-DAG: 
@"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
-  // CHECK-DAG: 
@"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
-  // CHECK-DAG: 
@"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
-  // CHECK-DAG: 
@"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: 
@"??R@z@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: 
@"??R@z@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: 
@"??R@y@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: 
@"??R@x@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
 };
 A a;
 
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,11 @@
 
   mangleSourceName(Name);
 
-  // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // If the context is a variable or a class member, it is encoded
+  // in a qualified name.
   if (LambdaManglingNumber && LambdaContextDecl) {
 if ((isa(LambdaContextDecl) ||
- isa(LambdaContextDecl)) &&
-LambdaContextDecl->getDeclContext()->isRecord()) {
+ isa(LambdaContextDecl))) {
   mangleUnqualifiedName(cast(LambdaContextDecl));
 }
   }


Index: clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
@@ -19,3 +19,11 @@
 
 // CHECK-DAG: "?$S4@@3US@@B"
 const auto [x2, y2] = f();
+
+// CHECK-DAG: "?i1@@3V@0@B"
+inline const auto i1 = [](auto x) { return 0; };
+// CHECK-DAG: "?i2@@3V@0@B"
+inline const auto i2 = [](auto x) { return 1; };
+// CHECK-DAG: "??$?RH@@i1@@QBE?A?@@H@Z"
+// CHECK-DAG: "??$?RH@@i2@@QBE?A?@@H@Z"
+int g() {return i1(1) + i2(1); }
Index: clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
===
--- clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
+++ clang/test/CodeGenCXX/mangle-ms-cxx11.cpp
@@ -337,10 +337,10 @@
   }();
   using FPtrTy = void(void);
   static void default_args(FPtrTy x = [] {}, FPtrTy y = [] {}, int z = [] { return 1; }() + [] { return 2; }()) {}
-  // CHECK-DAG: @"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
-  // CHECK-DAG: @"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
-  // CHECK-DAG: @"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
-  // CHECK-DAG: @"??R@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: @"??R@z@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: @"??R@z@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: @"??R@y@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
+  // CHECK-DAG: @"??R@x@?0??default_args@A@PR31197@@SAXP6AXXZ0H@Z@QBE@XZ"(
 };
 A a;
 
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,11 @@
 
   mangleSourceName(Name);
 
-  // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // If the context is a variable or a class member, it is encoded
+  // in a qualified name.
   if (LambdaManglingNumber && LambdaContextDecl) {
 if ((isa(LambdaContextDecl) ||
- isa(LambdaContextDecl)) &&
-  

[PATCH] D80153: [AST] Mangle LambdaContextDecl for top level decl

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 265031.
zequanwu added a comment.

Remove check for context of `LambdaContextDecl`.
Update test cases.


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

https://reviews.llvm.org/D80153

Files:
  clang/lib/AST/MicrosoftMangle.cpp


Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,11 @@
 
   mangleSourceName(Name);
 
-  // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // If the context is a variable or a class member, it is encoded
+  // in a qualified name.
   if (LambdaManglingNumber && LambdaContextDecl) {
 if ((isa(LambdaContextDecl) ||
- isa(LambdaContextDecl)) &&
-LambdaContextDecl->getDeclContext()->isRecord()) {
+ isa(LambdaContextDecl))) {
   mangleUnqualifiedName(cast(LambdaContextDecl));
 }
   }


Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -947,12 +947,11 @@
 
   mangleSourceName(Name);
 
-  // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // If the context is a variable or a class member, it is encoded
+  // in a qualified name.
   if (LambdaManglingNumber && LambdaContextDecl) {
 if ((isa(LambdaContextDecl) ||
- isa(LambdaContextDecl)) &&
-LambdaContextDecl->getDeclContext()->isRecord()) {
+ isa(LambdaContextDecl))) {
   mangleUnqualifiedName(cast(LambdaContextDecl));
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80176: [clang-format][PR45816] Add AlignConsecutiveBitFields

2020-05-19 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD updated this revision to Diff 265048.
JakeMerdichAMD added a comment.

Reformat with a newer clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80176

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11955,6 +11955,48 @@
Alignment);
 }
 
+TEST_F(FormatTest, AlignConsecutiveBitFields) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AlignConsecutiveBitFields = true;
+  verifyFormat("int const a : 5;\n"
+   "int oneTwoThree : 23;",
+   Alignment);
+
+  // Initializers are allowed starting with c++2a
+  verifyFormat("int const a : 5 = 1;\n"
+   "int oneTwoThree : 23 = 0;",
+   Alignment);
+
+  Alignment.AlignConsecutiveDeclarations = true;
+  verifyFormat("int const a   : 5;\n"
+   "int   oneTwoThree : 23;",
+   Alignment);
+
+  verifyFormat("int const a   : 5;  // comment\n"
+   "int   oneTwoThree : 23; // comment",
+   Alignment);
+
+  verifyFormat("int const a   : 5 = 1;\n"
+   "int   oneTwoThree : 23 = 0;",
+   Alignment);
+
+  Alignment.AlignConsecutiveAssignments = true;
+  verifyFormat("int const a   : 5  = 1;\n"
+   "int   oneTwoThree : 23 = 0;",
+   Alignment);
+  verifyFormat("int const a   : 5  = {1};\n"
+   "int   oneTwoThree : 23 = 0;",
+   Alignment);
+
+  // Known limitations: ':' is only recognized as a bitfield colon when
+  // followed by a number.
+  /*
+  verifyFormat("int oneTwoThree : SOME_CONSTANT;\n"
+   "int a   : 5;",
+   Alignment);
+  */
+}
+
 TEST_F(FormatTest, AlignConsecutiveDeclarations) {
   FormatStyle Alignment = getLLVMStyle();
   Alignment.AlignConsecutiveMacros = true;
@@ -13369,6 +13411,7 @@
   Style.Language = FormatStyle::LK_Cpp;
   CHECK_PARSE_BOOL(AlignTrailingComments);
   CHECK_PARSE_BOOL(AlignConsecutiveAssignments);
+  CHECK_PARSE_BOOL(AlignConsecutiveBitFields);
   CHECK_PARSE_BOOL(AlignConsecutiveDeclarations);
   CHECK_PARSE_BOOL(AlignConsecutiveMacros);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
Index: clang/lib/Format/WhitespaceManager.h
===
--- clang/lib/Format/WhitespaceManager.h
+++ clang/lib/Format/WhitespaceManager.h
@@ -184,6 +184,9 @@
   /// Align consecutive assignments over all \c Changes.
   void alignConsecutiveAssignments();
 
+  /// Align consecutive bitfields over all \c Changes.
+  void alignConsecutiveBitFields();
+
   /// Align consecutive declarations over all \c Changes.
   void alignConsecutiveDeclarations();
 
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -95,6 +95,7 @@
   calculateLineBreakInformation();
   alignConsecutiveMacros();
   alignConsecutiveDeclarations();
+  alignConsecutiveBitFields();
   alignConsecutiveAssignments();
   alignChainedConditionals();
   alignTrailingComments();
@@ -609,6 +610,26 @@
   Changes, /*StartAt=*/0);
 }
 
+void WhitespaceManager::alignConsecutiveBitFields() {
+  if (!Style.AlignConsecutiveBitFields)
+return;
+
+  AlignTokens(
+  Style,
+  [&](Change const &C) {
+// Do not align on ':' that is first on a line.
+if (C.NewlinesBefore > 0)
+  return false;
+
+// Do not align on ':' that is last on a line.
+if (&C != &Changes.back() && (&C + 1)->NewlinesBefore > 0)
+  return false;
+
+return C.Tok->is(TT_BitFieldColon);
+  },
+  Changes, /*StartAt=*/0);
+}
+
 void WhitespaceManager::alignConsecutiveDeclarations() {
   if (!Style.AlignConsecutiveDeclarations)
 return;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -403,6 +403,8 @@
 IO.mapOptional("AlignConsecutiveMacros", Style.AlignConsecutiveMacros);
 IO.mapOptional("AlignConsecutiveAssignments",
Style.AlignConsecutiveAssignments);
+IO.mapOptional("AlignConsecutiveBitFields",
+   Style.AlignConsecutiveBitFields);
 IO.mapOptional("AlignConsecutiveDeclarations",
Style.AlignConsecutiveDeclarations);
 IO.mapOptional("AlignEscapedNewlines", Style.Alig

[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:72
+   binaryOperator(hasOperatorName("=="),
+  hasEitherOperand(ignoringParenImpCasts(StringNpos)),
+  hasEitherOperand(ignoringParenImpCasts(StringFind))),

ymandel wrote:
> Would `hasOperands` replace these two separate calls to `hasEitherOperand`? 
> Same below lines 79-80 (I think it's a new matcher, fwiw).
Just added, I added it to remove calls of multiple hasEitherOperand calls for 
the reason of preventing the matchers matching the same operand. I just got a 
little lost in my previous comment



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:98
+const LangOptions &LangOpts) const {
+  return LangOpts.CPlusPlus;
+}

nit: as abseil requires c++11, should this check also require c++11 support


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80023



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


[PATCH] D80020: [PowerPC] Add support for -mcpu=pwr10 in both clang and llvm

2020-05-19 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.cpp:339
 
   if (!(ArchDefs & ArchDefinePwr9) && (ArchDefs & ArchDefinePpcgr) &&
   llvm::find(FeaturesVec, "+float128") != FeaturesVec.end()) {

I think we also need to check for `ArchDefinePwr10` and `ArchDefineFuture` 
based on the comment  "// We have __float128 on PPC but not power 9 and above."

`!(ArchDefs & ArchDefinePwr9)` -> `!(ArchDefs & (ArchDefinePwr9 | 
ArchDefinePwr10 | ArchDefineFuture))`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80020



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


[clang] 47650dc - Revert "[clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option is not passed in the compiler invocation"

2020-05-19 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-05-19T23:20:54+02:00
New Revision: 47650dcbeee215f48277ed8bea5f0e43cbf125fc

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

LOG: Revert "[clang-misexpect] Fixed typo which causes that 
--pgo-warn-misexpect option is not passed in the compiler invocation"

This reverts commit 6d2b75e0887ee87e247756c4d51733616bb2f356.

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 5496df79dbfb..94ba0dd8e598 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3680,7 +3680,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 }
   }
 
-  if (!Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
+  if (Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
 Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect");
 
   LangOpts.FunctionAlignment =



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


[PATCH] D60620: [HIP] Support target id by --offload-arch

2020-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 265025.
yaxunl retitled this revision from "[HIP] Support -offloading-target-id" to 
"[HIP] Support target id by --offload-arch".
yaxunl edited the summary of this revision.
yaxunl added a comment.

rebased the patch and revised by passing target id by `--offload-arch`.


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

https://reviews.llvm.org/D60620

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/HIP.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/HIP.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-invalid-target-id.hip
  clang/test/Driver/hip-target-id.hip

Index: clang/test/Driver/hip-target-id.hip
===
--- /dev/null
+++ clang/test/Driver/hip-target-id.hip
@@ -0,0 +1,56 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offload-arch=gfx908+xnack+sramecc \
+// RUN:   --offload-arch=gfx908+xnack-sramecc \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %s 2>&1 | FileCheck %s
+
+// CHECK: [[CLANG:".*clang.*"]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-target-cpu" "gfx908"
+
+// CHECK: [[OPT:".*opt"]] {{".*-gfx908-linked.*bc"}} "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "-mcpu=gfx908"
+// CHECK-SAME: "-o" [[OPT_906_BC:".*-gfx908-optimized.*bc"]]
+
+// CHECK: [[LLC: ".*llc"]] [[OPT_906_BC]]
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-mcpu=gfx908"
+// CHECK-SAME: "-o" {{".*-gfx908-.*o"}}
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-target-cpu" "gfx908" "-mxnack" "-msram-ecc"
+
+// CHECK: [[OPT]] {{".*-gfx908\+xnack\+sramecc.*bc"}} "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "-mcpu=gfx908"
+// CHECK-SAME: "-o" [[OPT_906XE_BC:".*-gfx908\+xnack\+sramecc.*bc"]]
+
+// CHECK: [[LLC]] [[OPT_906XE_BC]]
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-mcpu=gfx908"
+// CHECK-SAME: "-o" {{".*-gfx908\+xnack\+sramecc.*o"}}
+
+// CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
+// CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-emit-llvm-bc"
+// CHECK-SAME: {{.*}} "-target-cpu" "gfx908" "-mxnack" "-mno-sram-ecc"
+
+// CHECK: [[OPT]] {{".*-gfx908\+xnack.*bc"}} "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: "-mcpu=gfx908"
+// CHECK-SAME: "-o" [[OPT_906XN_BC:".*-gfx908\+xnack.*bc"]]
+
+// CHECK: [[LLC]] [[OPT_906XN_BC]]
+// CHECK-SAME: "-mtriple=amdgcn-amd-amdhsa"
+// CHECK-SAME: {{.*}} "-mcpu=gfx908"
+// CHECK-SAME: "-o" {{".*-gfx908\+xnack.*o"}}
+
+
+// CHECK: {{".*clang-offload-bundler"}}
+// CHECK-SAME: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa-gfx908,hip-amdgcn-amd-amdhsa-gfx908+xnack+sramecc,hip-amdgcn-amd-amdhsa-gfx908+xnack-sramecc"
Index: clang/test/Driver/hip-invalid-target-id.hip
===
--- /dev/null
+++ clang/test/Driver/hip-invalid-target-id.hip
@@ -0,0 +1,48 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offload-arch=gfx908xnack \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=NOPLUS %s
+
+// NOPLUS: error: Unsupported CUDA gpu architecture
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offload-arch=gfx908+sramecc+xnack \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=ORDER %s
+
+// ORDER: error: Invalid HIP offloading target id: gfx908+sramecc+xnack
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offload-arch=gfx908+unknown \
+// RUN:   --offload-arch=gfx908+sramecc+unknown \
+// RUN:   --offload-arch=gfx900+xnack \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=UNK %s
+
+// UNK: error: Invalid HIP offloading target id: gfx908+unknown
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offload-arch=gfx908+sramecc+unknown \
+// RUN:   --offload-arch=gfx900+xnack \
+// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=MIXED %s
+
+// MIXED: error: Invalid HIP offloading target id: gfx908+sramecc+unknown
+
+// RUN: %clang -### -target x86_64-linux-gnu \
+// RUN:   -x hip --offload-arch=gfx908 \
+// RUN:   --offloa

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-05-19 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: echristo, dblaikie.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes pr/11710.
Signed-off-by: Nick Desaulniers 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80242

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c

Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,11 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int", file: !5, line: 5, baseType: !6)
+// CHECK-NEXT: !5 = !DIFile(filename: "clang/test/CodeGen/debug-info-unused-types.c", directory: "/android0/llvm-project")
+// CHECK-NEXT: !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int", file: !5, line: 5, baseType: !6)
+// NODBG-NOT: !5 = !DIFile(filename: "clang/test/CodeGen/debug-info-unused-types.c", directory: "/android0/llvm-project")
+// NODBG-NOT: !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -765,6 +765,7 @@
   Opts.DebugTypeExtRefs = Args.hasArg(OPT_dwarf_ext_refs);
   Opts.DebugExplicitImport = Args.hasArg(OPT_dwarf_explicit_import);
   Opts.DebugFwdTemplateParams = Args.hasArg(OPT_debug_forward_template_params);
+  Opts.DebugUnusedTypes = Args.hasArg(OPT_eliminate_unused_debug_types_fno);
   Opts.EmbedSource = Args.hasArg(OPT_gembed_source);
   Opts.ForceDwarfFrameSection = Args.hasArg(OPT_fforce_dwarf_frame);
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5190,6 +5190,8 @@
 
   // Forward -f (flag) options which we can pass directly.
   Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
+  Args.AddLastArg(CmdArgs, options::OPT_eliminate_unused_debug_types_f);
+  Args.AddLastArg(CmdArgs, options::OPT_eliminate_unused_debug_types_fno);
   Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
   Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -,6 +,12 @@
 EmitOMPRequiresDecl(cast(D));
 break;
 
+  case Decl::Typedef:
+if (getCodeGenOpts().DebugUnusedTypes)
+  if (CGDebugInfo *DI = getModuleDebugInfo())
+DI->EmitTypedef(*cast(D));
+break;
+
   default:
 // Make sure we handled everything we should, every other kind is a
 // non-top-level decl.  FIXME: Would be nice to have an isTopLevelDeclKind
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -496,6 +496,9 @@
   /// Emit an @import declaration.
   void EmitImportDecl(const ImportDecl &ID);
 
+  /// Eagerly emit Typedef.
+  void EmitTypedef(const TypedefDecl &TD);
+
   /// Emit C++ namespace alias.
   llvm::DIImportedEntity *EmitNamespaceAlias(const NamespaceAliasDecl &NA);
 
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4956,3 +4956,10 @@
 
   return llvm::DINode::FlagAllCallsDescribed;
 }
+
+void CGDebugInfo::EmitTypedef(const TypedefDecl &TD) {
+  QualType QT = CGM.getContext().getTypedefType(&TD);
+  llvm::DIFile *Unit = getOrCreateFile(TD.getLocation());
+  llvm::DIType *Ty = getOrCreateType(QT, Unit);
+  DBuilder.retainType(Ty);
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3343,7 +3343,10 @@
 defm fcheck_new : BooleanFFlag<"check-new">, Group;
 defm ca

[PATCH] D64128: [CodeGen] Generate llvm.ptrmask instead of inttoptr(and(ptrtoint, C)) if possible.

2020-05-19 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

In D64128#1578916 , @fhahn wrote:

> In D64128#1576391 , @rjmccall wrote:
>
> > I wouldn't favor adding something really obscure that was only useful for 
> > clang, but I think builtins to set and clear mask bits while promising to 
> > preserve object-reference identity would be more generally useful for 
> > libraries.  For example, there might be somewhere in libc++ that could take 
> > advantage of this.
>
>
> Yep, I think for this to be generally useful we would also need an intrinsic 
> to set bits as well. I'll commit the LLVM patches and improvements to 
> ValueTracking in the next few days for ptrmask and will put up a patch for 
> builtins once I know more about how libcxx could use them.


Thanks for all the comments! I checked with a few contributors to libcxx and 
there seem to be no very obvious places where this would help a lot. IUUC for 
now the patch is not really worth pursuing further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64128



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


[PATCH] D80237: [hip] Ensure pointer in struct argument has proper `addrspacecast`.

2020-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1339
+  }
+  for (uint64_t i = 0, e = SrcATy->getNumElements(); i < e; ++i) {
+Address EltPtr = CGF.Builder.CreateConstArrayGEP(Dest, i);

Is there a limit on array size? We may end up here with potentially unbounded 
number of spacecasts. Perhaps we need a loop which may later be unrolled, if 
feasible.



Comment at: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu:17
 // HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel1Pi(i32 
addrspace(1)*{{.*}} %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*

Nit: relying on parameter name `%x.coerce` may be rather fragile. Considering 
that we don't care about the name itself, it may be better to just trim the 
match after `%x` or even after`%`.



Comment at: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu:62-63
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce 
%s.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*

Nit: You could use `CHECK-COUNT-2` : 
https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-count-directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80237



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


[PATCH] D80240: [OPENMP50]Initial codegen for 'affinity' clauses.

2020-05-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1, guansong, yaxunl.
Herald added projects: clang, LLVM.

Added initial codegen for 'affinity' clauses on task directives.
Emits next code:

  kmp_task_affinity_info_t affs[];
  
  void *td = __kmpc_task_alloc(..);
  
  affs[].base = &data_i;
  affs[].size = sizeof(data_i);
  __kmpc_omp_reg_task_with_affinity(&loc, , td, , affs);

The result returned by the call of `__kmpc_omp_reg_task_with_affinity`
function is ignored currently sincethe  runtime currently ignores args
and returns 0 uncoditionally.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80240

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/task_affinity_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -311,6 +311,8 @@
 __OMP_RTL(__kmpc_push_proc_bind, false, Void, IdentPtr, Int32, /* Int */ Int32)
 __OMP_RTL(__kmpc_serialized_parallel, false, Void, IdentPtr, Int32)
 __OMP_RTL(__kmpc_end_serialized_parallel, false, Void, IdentPtr, Int32)
+__OMP_RTL(__kmpc_omp_reg_task_with_affinity, false, Int32, IdentPtr, Int32,
+  Int8Ptr, Int32, Int8Ptr)
 
 __OMP_RTL(omp_get_thread_num, false, Int32, )
 __OMP_RTL(omp_get_num_threads, false, Int32, )
Index: clang/test/OpenMP/task_affinity_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/task_affinity_codegen.cpp
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fopenmp-version=50 -x c++ -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -fopenmp-version=50 -x c++ -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-LABEL: @main
+int main() {
+  float *p;
+  int a = 10;
+  // kmp_task_affinity_info_t affs[1];
+  // CHECK: [[AFFS_ADDR:%.+]] = alloca [1 x %struct.kmp_task_affinity_info_t],
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID:%.+]], i32 1, i64 40, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: [[AFFINE_LST_ADDR:%.+]] = getelementptr inbounds [1 x %struct.kmp_task_affinity_info_t], [1 x %struct.kmp_task_affinity_info_t]* [[AFFS_ADDR]], i64 0, i64 0
+  // CHECK: [[P:%.+]] = load float*, float** [[P_ADDR:%.+]],
+  // CHECK: [[A_VAL:%.+]] = load i32, i32* [[A_ADDR:%.+]],
+  // CHECK: [[A_SZ:%.+]] = sext i32 [[A_VAL]] to i64
+  // CHECK: [[BYTES:%.+]] = mul nuw i64 4, [[A_SZ]]
+  // CHECK: [[SZ:%.+]] = mul nuw i64 [[BYTES]], 10
+  // CHECK: [[A_VAL:%.+]] = load i32, i32* [[A_ADDR]],
+  // CHECK: [[A_SZ1:%.+]] = sext i32 [[A_VAL]] to i64
+  // CHECK: [[SIZE:%.+]] = mul nuw i64 [[SZ]], [[A_SZ]]
+  // CHECK: [[AFFS_0_ADDR:%.+]] = getelementptr %struct.kmp_task_affinity_info_t, %struct.kmp_task_affinity_info_t* [[AFFINE_LST_ADDR]], i64 0
+
+  // affs[0].base = p;
+  // CHECK: [[AFFS_0_BASE_ADDR:%.+]] = getelementptr inbounds %struct.kmp_task_affinity_info_t, %struct.kmp_task_affinity_info_t* [[AFFS_0_ADDR]], i32 0, i32 0
+  // CHECK: [[P_INTPTR:%.+]] = ptrtoint float* [[P]] to i64
+  // CHECK: store i64 [[P_INTPTR]], i64* [[AFFS_0_BASE_ADDR]],
+
+  // affs[0].size = sizeof(*p) * a * 10 * a;
+  // CHECK: [[AFFS_0_SIZE_ADDR:%.+]] = getelementptr inbounds %struct.kmp_task_affinity_info_t, %struct.kmp_task_affinity_info_t* [[AFFS_0_ADDR]], i32 0, i32 1
+  // CHECK: store i64 [[SIZE]], i64* [[AFFS_0_SIZE_ADDR]],
+  // CHECK: [[BC:%.+]] = bitcast %struct.kmp_task_affinity_info_t* [[AFFINE_LST_ADDR]] to i8*
+  // CHECK: call i32 @__kmpc_omp_reg_task_with_affinity(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* [[TD]], i32 1, i8* [[BC]])
+#pragma omp task affinity(([a][10][a])p)
+  ;
+  // CHECK: [[TD:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* @{{.+}}, i32 [[GTID]], i32 1, i64 40, i64 1, i32 (i32, i8*)* bitcast (i32 (i32, %{{.+}}*)* @{{.+}} to i32 (i32, i8*)*))
+  // CHECK: [[A_VAL:%.+]] = load i32, i32* [[A_ADDR]],
+  // CHECK: [[SUB:%.+]] = sub nsw i32 [[A_VAL]], 0
+  // CHECK: [[CONV:%.+

Re: [clang] 6d2b75e - [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option is not passed in the compiler invocation

2020-05-19 Thread Roman Lebedev via cfe-commits
This seems to be missing a test

On Wed, May 20, 2020 at 12:12 AM Dávid Bolvanský via cfe-commits
 wrote:
>
>
> Author: Dávid Bolvanský
> Date: 2020-05-19T23:12:08+02:00
> New Revision: 6d2b75e0887ee87e247756c4d51733616bb2f356
>
> URL: 
> https://github.com/llvm/llvm-project/commit/6d2b75e0887ee87e247756c4d51733616bb2f356
> DIFF: 
> https://github.com/llvm/llvm-project/commit/6d2b75e0887ee87e247756c4d51733616bb2f356.diff
>
> LOG: [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect 
> option is not passed in the compiler invocation
>
> Added:
>
>
> Modified:
> clang/lib/Frontend/CompilerInvocation.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
> b/clang/lib/Frontend/CompilerInvocation.cpp
> index 94ba0dd8e598..5496df79dbfb 100644
> --- a/clang/lib/Frontend/CompilerInvocation.cpp
> +++ b/clang/lib/Frontend/CompilerInvocation.cpp
> @@ -3680,7 +3680,7 @@ bool 
> CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
>  }
>}
>
> -  if (Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
> +  if (!Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
>  Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect");
>
>LangOpts.FunctionAlignment =
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] 6d2b75e - [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option is not passed in the compiler invocation

2020-05-19 Thread Nico Weber via cfe-commits
This breaks check-clang: http://45.33.8.238/linux/18098/step_7.txt

Please take a look, and revert if it takes a while to fix.

On Tue, May 19, 2020 at 5:12 PM Dávid Bolvanský via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Dávid Bolvanský
> Date: 2020-05-19T23:12:08+02:00
> New Revision: 6d2b75e0887ee87e247756c4d51733616bb2f356
>
> URL:
> https://github.com/llvm/llvm-project/commit/6d2b75e0887ee87e247756c4d51733616bb2f356
> DIFF:
> https://github.com/llvm/llvm-project/commit/6d2b75e0887ee87e247756c4d51733616bb2f356.diff
>
> LOG: [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect
> option is not passed in the compiler invocation
>
> Added:
>
>
> Modified:
> clang/lib/Frontend/CompilerInvocation.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp
> b/clang/lib/Frontend/CompilerInvocation.cpp
> index 94ba0dd8e598..5496df79dbfb 100644
> --- a/clang/lib/Frontend/CompilerInvocation.cpp
> +++ b/clang/lib/Frontend/CompilerInvocation.cpp
> @@ -3680,7 +3680,7 @@ bool
> CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
>  }
>}
>
> -  if (Diags.isIgnored(diag::warn_profile_data_misexpect,
> SourceLocation()))
> +  if (!Diags.isIgnored(diag::warn_profile_data_misexpect,
> SourceLocation()))
>  Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect");
>
>LangOpts.FunctionAlignment =
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6d2b75e - [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option is not passed in the compiler invocation

2020-05-19 Thread Dávid Bolvanský via cfe-commits

Author: Dávid Bolvanský
Date: 2020-05-19T23:12:08+02:00
New Revision: 6d2b75e0887ee87e247756c4d51733616bb2f356

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

LOG: [clang-misexpect] Fixed typo which causes that --pgo-warn-misexpect option 
is not passed in the compiler invocation

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 94ba0dd8e598..5496df79dbfb 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3680,7 +3680,7 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
 }
   }
 
-  if (Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
+  if (!Diags.isIgnored(diag::warn_profile_data_misexpect, SourceLocation()))
 Res.FrontendOpts.LLVMArgs.push_back("-pgo-warn-misexpect");
 
   LangOpts.FunctionAlignment =



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


[PATCH] D80225: [Driver] Recognize -fuse-ld={bfd, gold, lld} but don't prepend "ld." or "ld64." for other values

2020-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 265026.
MaskRay added a comment.

Fix fuse-ld-windows.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80225

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/ld.lld-link2
  clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/lld-link2
  clang/test/Driver/Inputs/fuse_ld_windows/foo.exe
  clang/test/Driver/Inputs/fuse_ld_windows/ld.foo.exe
  clang/test/Driver/fuse-ld-windows.c
  clang/test/Driver/fuse-ld.c


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -15,6 +15,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+// RUN: %clang %s -### -fuse-ld=ld.bfd \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+
 // CHECK-FREEBSD-BFD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.bfd
 
 // RUN: %clang %s -### -fuse-ld=gold \
@@ -22,6 +28,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// RUN: %clang %s -### -fuse-ld=ld.gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+
 // CHECK-FREEBSD-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 // RUN: %clang %s -### -fuse-ld=plib \
Index: clang/test/Driver/fuse-ld-windows.c
===
--- clang/test/Driver/fuse-ld-windows.c
+++ clang/test/Driver/fuse-ld-windows.c
@@ -13,13 +13,13 @@
 // With the full path, the extension can be omitted, too,
 // because Windows allows that.
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
-// RUN: -fuse-ld=%S/Inputs/fuse_ld_windows/ld.foo 2>&1 \
+// RUN: -fuse-ld=%S/Inputs/fuse_ld_windows/foo 2>&1 \
 // RUN:   | FileCheck %s
 
 // Check that the full path with the extension works too.
 // RUN: %clang %s -### -o %t.o -target i386-unknown-linux \
-// RUN: -fuse-ld=%S/Inputs/fuse_ld_windows/ld.foo.exe 2>&1 \
+// RUN: -fuse-ld=%S/Inputs/fuse_ld_windows/foo.exe 2>&1 \
 // RUN:   | FileCheck %s
 
 // CHECK-NOT: invalid linker name
-// CHECK: /Inputs/fuse_ld_windows{{/|}}ld.foo
+// CHECK: /Inputs/fuse_ld_windows{{/|}}foo
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -534,21 +534,24 @@
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
   StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
 
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath(getDefaultLinker());
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
 if (llvm::sys::fs::can_execute(UseLinker))
   return std::string(UseLinker);
-  } else if (UseLinker.empty() || UseLinker == "ld") {
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-return GetProgramPath(getDefaultLinker());
   } else {
 llvm::SmallString<8> LinkerName;
-if (Triple.isOSDarwin())
-  LinkerName.append("ld64.");
-else
+// Recognize common abbreviations by appending an OS specific prefix.
+if (Triple.isOSDarwin()) {
+  if (UseLinker == "lld")
+LinkerName.append("ld64.");
+} else if (UseLinker == "bfd" || UseLinker == "gold" || UseLinker == "lld")
   LinkerName.append("ld.");
+
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -15,6 +15,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+// RUN: %clang %s -### -fuse-ld=ld.bfd \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+
 // CHECK-FREEBSD-BFD: Inputs/basic_freebsd_tree/usr/bin{{/

[PATCH] D80239: [libTooling] In Transformer, allow atomic changes to span multiple files.

2020-05-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added subscribers: jfb, mgrang.
Herald added a project: clang.

Currently, all changes returned by a single application of a rule must fit in
one atomic change and therefore must apply to one file. However, there are
patterns in which a single rule will want to modify multiple files; for example,
a header and implementation to change a declaration and its definition. This
patch relaxes Transformer, libTooling's interpreter of RewriteRules, to support
multiple changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80239

Files:
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -817,4 +817,46 @@
"Matcher must be.*node matcher");
 }
 #endif
+
+// Edits are able to span multiple files; in this case, a header and an
+// implementation file.
+TEST_F(TransformerTest, MultipleFiles) {
+  std::string Header = R"cc(void RemoveThisFunction();)cc";
+  std::string Source = R"cc(#include "input.h"
+void RemoveThisFunction();)cc";
+  Transformer T(
+  makeRule(functionDecl(hasName("RemoveThisFunction")), changeTo(cat(""))),
+  consumer());
+  T.registerMatchers(&MatchFinder);
+  auto Factory = newFrontendActionFactory(&MatchFinder);
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  Factory->create(), Source, std::vector(), "input.cc",
+  "clang-tool", std::make_shared(),
+  {{"input.h", Header}}));
+
+  std::sort(Changes.begin(), Changes.end(),
+[](const AtomicChange &L, const AtomicChange &R) {
+  return L.getFilePath() < R.getFilePath();
+});
+
+  ASSERT_EQ(Changes[0].getFilePath(), "./input.h");
+  EXPECT_THAT(Changes[0].getInsertedHeaders(), IsEmpty());
+  EXPECT_THAT(Changes[0].getRemovedHeaders(), IsEmpty());
+  llvm::Expected UpdatedCode =
+  clang::tooling::applyAllReplacements(Header,
+   Changes[0].getReplacements());
+  ASSERT_TRUE(static_cast(UpdatedCode))
+  << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
+  EXPECT_EQ(format(*UpdatedCode), format(R"cc(;)cc"));
+
+  ASSERT_EQ(Changes[1].getFilePath(), "input.cc");
+  EXPECT_THAT(Changes[1].getInsertedHeaders(), IsEmpty());
+  EXPECT_THAT(Changes[1].getRemovedHeaders(), IsEmpty());
+  UpdatedCode = clang::tooling::applyAllReplacements(
+  Source, Changes[1].getReplacements());
+  ASSERT_TRUE(static_cast(UpdatedCode))
+  << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
+  EXPECT_EQ(format(*UpdatedCode), format(R"cc(#include "input.h"
+;)cc"));
+}
 } // namespace
Index: clang/lib/Tooling/Transformer/Transformer.cpp
===
--- clang/lib/Tooling/Transformer/Transformer.cpp
+++ clang/lib/Tooling/Transformer/Transformer.cpp
@@ -12,6 +12,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "llvm/Support/Error.h"
+#include 
 #include 
 #include 
 
@@ -45,28 +46,36 @@
 return;
   }
 
-  // Record the results in the AtomicChange, anchored at the location of the
-  // first change.
-  AtomicChange AC(*Result.SourceManager,
-  (*Transformations)[0].Range.getBegin());
+  // Group the transformations, by file, into AtomicChanges, each anchored by
+  // the location of the first change in that file.
+  std::map ChangesByFileID;
   for (const auto &T : *Transformations) {
+auto ID = Result.SourceManager->getFileID(T.Range.getBegin());
+auto Iter = ChangesByFileID
+.emplace(ID, AtomicChange(*Result.SourceManager,
+  T.Range.getBegin()))
+.first;
+auto &AC = Iter->second;
 if (auto Err = AC.replace(*Result.SourceManager, T.Range, T.Replacement)) {
   Consumer(std::move(Err));
   return;
 }
   }
 
-  for (const auto &I : Case.AddedIncludes) {
-auto &Header = I.first;
-switch (I.second) {
-case transformer::IncludeFormat::Quoted:
-  AC.addHeader(Header);
-  break;
-case transformer::IncludeFormat::Angled:
-  AC.addHeader((llvm::Twine("<") + Header + ">").str());
-  break;
+  for (auto &IDChangePair : ChangesByFileID) {
+auto &AC = IDChangePair.second;
+for (const auto &I : Case.AddedIncludes) {
+  auto &Header = I.first;
+  switch (I.second) {
+  case transformer::IncludeFormat::Quoted:
+AC.addHeader(Header);
+break;
+  case transformer::IncludeFormat::Angled:
+AC.addHeader((llvm::Twine("<") + Header + ">").str());
+break;
+  }
 }
-  }
 
-  Consumer(std::move(AC));
+Con

[PATCH] D80237: [hip] Ensure pointer in struct argument has proper `addrspacecast`.

2020-05-19 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: arsenm, tra, rjmccall, yaxunl.
Herald added subscribers: cfe-commits, kerbowa, nhaehnle, wdng, jvesely.
Herald added a project: clang.

- In last https://reviews.llvm.org/D69826, generic pointers in struct/array 
types are also replaced with global pointers. But, as no additional 
`addrspacecast` is inserted, they are promoted with a `ptrtoint`/`inttoptr` 
pair in SROA/GVN. That breaks the address space inferring as well as other 
optimizations. For such case, we need to recursively dive into these aggregate 
types and insert `addrspacecast` when necessary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80237

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu

Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -1,37 +1,52 @@
-// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck --check-prefixes=COMMON,CHECK %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip %s -disable-O0-optnone -o - | opt -S -O2 | FileCheck %s --check-prefixes=COMMON,OPT
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -x hip %s -o - | FileCheck -check-prefix=HOST %s
 
 #include "Inputs/cuda.h"
 
 // Coerced struct from `struct S` without all generic pointers lowered into
 // global ones.
-// CHECK: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
-// CHECK: %struct.T.coerce = type { [2 x float addrspace(1)*] }
+// COMMON: %struct.S.coerce = type { i32 addrspace(1)*, float addrspace(1)* }
+// COMMON: %struct.T.coerce = type { [2 x float addrspace(1)*] }
 
 // On the host-side compilation, generic pointer won't be coerced.
 // HOST-NOT: %struct.S.coerce
 // HOST-NOT: %struct.T.coerce
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
 // HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel1Pi(i32 addrspace(1)*{{.*}} %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: inttoptr
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* dereferenceable(4) %x.coerce)
 // HOST: define void @_Z22__device_stub__kernel2Ri(i32* dereferenceable(4) %x)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel2Ri(i32 addrspace(1)*{{.*}} dereferenceable(4) %x.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __global__ void kernel2(int &x) {
   x++;
 }
 
-// CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
 // HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
+// CHECK-LABEL: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)*{{.*}} %x, i32 addrspace(1)*{{.*}} %y)
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
 }
 
-// CHECK: define void @_Z4funcPi(i32* %x)
+// COMMON-LABEL: define void @_Z4funcPi(i32*{{.*}} %x)
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __device__ void func(int *x) {
   x[0]++;
 }
@@ -42,16 +57,27 @@
 };
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
-// CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
 // HOST: define void @_Z22__device_stub__kernel41S(i32* %s.coerce0, float* %s.coerce1)
+// COMMON-LABEL: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// CHECK-NOT: = addrspacecast [[TYPE:.*]] addrspace(1)* %{{.*}} to [[TYPE]]*
+// OPT-NOT: alloca
+// OPT-NOT: ptrtoint
+// OPT-NOT: inttoptr
 __global__ void kernel4(struct S s) {
   s.x[0]++;
   s.y[0] += 1.f;
 }
 
 // If a pointer to struct is passed, only the pointer itself is coerced into the global one.
-// CHECK: define amdgpu_kernel void @_Z7kernel5P1S(%struct.S addrspace(1)* %s.coerce)
 // HOST: define void @_Z

[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-19 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Looks good, just some nits!




Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:48
+  Options.get("StringLikeClasses", DefaultStringLikeClasses));
+  const std::string AbseilStringsMatchHeader(
+  Options.get("AbseilStringsMatchHeader", 
DefaultAbseilStringsMatchHeader));

nit: just use assignment?  `Options.get()` returns a string, so `=` seems a 
clearer way to initialize.



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:72
+   binaryOperator(hasOperatorName("=="),
+  hasEitherOperand(ignoringParenImpCasts(StringNpos)),
+  hasEitherOperand(ignoringParenImpCasts(StringFind))),

Would `hasOperands` replace these two separate calls to `hasEitherOperand`? 
Same below lines 79-80 (I think it's a new matcher, fwiw).



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst:6
+
+Finds s.find(...) == string::npos comparisons (for various string-like types)
+and suggests replacing with absl::StrContains.

nit: use double back ticks (like below)



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst:7
+Finds s.find(...) == string::npos comparisons (for various string-like types)
+and suggests replacing with absl::StrContains.
+

Same for `absl::StrContains`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-str-contains.rst:28
+
+  string s = "...";
+  if (!absl::StrContains(s, "Hello World")) { /* do something */ }

nit: `std::string`



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-str-contains.cpp:2
+// RUN: %check_clang_tidy %s abseil-string-find-str-contains %t -- \
+// RUN:   -config="{CheckOptions: []}"
+

I'm not sure what's standard practice, but consider whether its worth adding 
another test file that tests the check options. It wouldn't have to be 
comprehensive like this one, just some basic tests that the options are being 
honored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80023



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


[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2020-05-19 Thread Jean-Michaël Celerier via Phabricator via cfe-commits
jcelerier added a comment.

Also hit by this issue - a lot more people are certainly going to have it as 
this has started landing in Linux distros.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324



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


[PATCH] D75323: Support relative dest paths in headermap files

2020-05-19 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

The issue with this change is that it claims to add functionality that exists 
already. I.e., the test is passing without the change. The confusing part might 
be that even if `DirectoryLookup::LookupFile` doesn't find a file for relative 
destination immediately, it updates `MappedName` which is used by 
`HeaderSearch::LookupFile`. And I haven't tested it but looks like the change 
violates that header search paths are tested in order. So when we have `-I A -I 
B.hmap -I C` instead of processing A, B.hmap, C in that order, we can end up 
with A, B.hmap, A, B.hmap, C.

Unfortunately, https://crbug.com/1056174 doesn't describe a reproducible 
problem but only a proposed solution. If you provide more details about 
distributed compilation pitfalls, which paths are relative and which are 
absolute, we'll be able to help you with header maps.


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

https://reviews.llvm.org/D75323



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


[PATCH] D78155: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in wrapper headers

2020-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78155



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


[clang] 74ef6a1 - Fix X86_64 complex-returns for regcall.

2020-05-19 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-05-19T13:21:15-07:00
New Revision: 74ef6a11478abe5f0f3f817640508f0cf5d8de0c

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

LOG: Fix X86_64 complex-returns for regcall.

D35259 introduced a case where complex types of non-long-double would
result in FI.getReturnInfo() to not be initialized properly.  This
resulted in a crash under some very specific circumstances when
dereferencing the LLVMContext.

This patch makes sure that these types have the intended getReturnInfo
initialization.

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGenCXX/regcall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index e1fe1330695c..2f564f3e860b 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -3745,14 +3745,15 @@ void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) 
const {
   } else {
 FI.getReturnInfo() = getIndirectReturnResult(FI.getReturnType());
   }
-} else if (IsRegCall && FI.getReturnType()->getAs()) {
+} else if (IsRegCall && FI.getReturnType()->getAs() &&
+   getContext().getCanonicalType(FI.getReturnType()
+ ->getAs()
+ ->getElementType()) ==
+   getContext().LongDoubleTy)
   // Complex Long Double Type is passed in Memory when Regcall
   // calling convention is used.
-  const ComplexType *CT = FI.getReturnType()->getAs();
-  if (getContext().getCanonicalType(CT->getElementType()) ==
-  getContext().LongDoubleTy)
-FI.getReturnInfo() = getIndirectReturnResult(FI.getReturnType());
-} else
+  FI.getReturnInfo() = getIndirectReturnResult(FI.getReturnType());
+else
   FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
   }
 

diff  --git a/clang/test/CodeGenCXX/regcall.cpp 
b/clang/test/CodeGenCXX/regcall.cpp
index 9eca868fc31d..5bc9d462877b 100644
--- a/clang/test/CodeGenCXX/regcall.cpp
+++ b/clang/test/CodeGenCXX/regcall.cpp
@@ -31,7 +31,7 @@ class test_class {
   int a;
 public:
 #ifndef WIN_TEST
-  __regcall 
+  __regcall
 #endif
 test_class(){++x;}
   // CHECK-LIN-DAG: define linkonce_odr x86_regcallcc void @_ZN10test_classC1Ev
@@ -41,7 +41,7 @@ class test_class {
   // CHECK-WIN32-DAG: define linkonce_odr dso_local x86_thiscallcc 
%class.test_class* @"??0test_class@@QAE@XZ"
 
 #ifndef WIN_TEST
-  __regcall 
+  __regcall
 #endif
   ~test_class(){--x;}
   // CHECK-LIN-DAG: define linkonce_odr x86_regcallcc void @_ZN10test_classD2Ev
@@ -49,7 +49,7 @@ class test_class {
   // Windows ignores calling convention on constructor/destructors.
   // CHECK-WIN64-DAG: define linkonce_odr dso_local void 
@"??1test_class@@QEAA@XZ"
   // CHECK-WIN32-DAG: define linkonce_odr dso_local x86_thiscallcc void 
@"??1test_class@@QAE@XZ"
-  
+
   test_class& __regcall operator+=(const test_class&){
 return *this;
   }
@@ -60,7 +60,7 @@ class test_class {
   // CHECK-LIN-DAG: define linkonce_odr x86_regcallcc void 
@_ZN10test_class20__regcall3__do_thingEv
   // CHECK-WIN64-DAG: define linkonce_odr dso_local x86_regcallcc void 
@"?do_thing@test_class@@QEAwXXZ"
   // CHECK-WIN32-DAG: define linkonce_odr dso_local x86_regcallcc void 
@"?do_thing@test_class@@QAwXXZ"
-  
+
   template
   void __regcall tempFunc(T i){}
   // CHECK-LIN-DAG: define linkonce_odr x86_regcallcc void 
@_ZN10test_class20__regcall3__tempFuncIiEEvT_
@@ -103,3 +103,18 @@ long double _Complex __regcall foo(long double _Complex f) 
{
 // CHECK-LIN32-DAG: define x86_regcallcc void @_Z15__regcall3__fooCe({ 
x86_fp80, x86_fp80 }* inreg noalias sret align 4 %agg.result, { x86_fp80, 
x86_fp80 }* byval({ x86_fp80, x86_fp80 }) align 4 %f)
 // CHECK-WIN64-DAG: define dso_local x86_regcallcc { double, double } 
@"?foo@@YwU?$_Complex@O@__clang@@U12@@Z"(double %f.0, double %f.1)
 // CHECK-WIN32-DAG: define dso_local x86_regcallcc { double, double } 
@"?foo@@YwU?$_Complex@O@__clang@@U12@@Z"(double %f.0, double %f.1)
+
+// The following caused us to dereference uninitialized memory. The long name
+// seems necessary, as does the return types.
+float _Complex __regcall callee(float _Complex f);
+// CHECK-LIN64-DAG: declare x86_regcallcc <2 x float> 
@_Z18__regcall3__calleeCf(<2 x float>)
+// CHECK-LIN32-DAG: declare x86_regcallcc { float, float } 
@_Z18__regcall3__calleeCf(float, float)
+// CHECK-WIN64-DAG: declare dso_local x86_regcallcc { float, float } 
@"?callee@@YwU?$_Complex@M@__clang@@U12@@Z"(float, float)
+// CHECK-WIN32-DAG: declare dso_local x86_regcallcc { float, float } 
@"?callee@@YwU?$_Complex@M@__clang@@U12@@Z"(float, float)
+
+__regcall int
+some_really_long_name_that_manages_to_hi

[clang] 350dada - Give helpers internal linkage. NFC.

2020-05-19 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-05-19T22:16:37+02:00
New Revision: 350dadaa8ab3db34ff41d7291f43442c57719de3

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

LOG: Give helpers internal linkage. NFC.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
llvm/lib/IR/Instructions.cpp
llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/Utils/AssumeBundleBuilder.cpp
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/test/lib/IR/TestMatchers.cpp
mlir/test/lib/Transforms/TestLinalgTransforms.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index b8d52f096e1c..aefcad374596 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -568,21 +568,6 @@ StdLibraryFunctionsChecker::findFunctionSummary(const 
CallEvent &Call,
   return findFunctionSummary(FD, C);
 }
 
-llvm::Optional
-lookupGlobalCFunction(StringRef Name, const ASTContext &ACtx) {
-  IdentifierInfo &II = ACtx.Idents.get(Name);
-  auto LookupRes = ACtx.getTranslationUnitDecl()->lookup(&II);
-  if (LookupRes.size() == 0)
-return None;
-
-  assert(LookupRes.size() == 1 && "In C, identifiers should be unique");
-  Decl *D = LookupRes.front()->getCanonicalDecl();
-  auto *FD = dyn_cast(D);
-  if (!FD)
-return None;
-  return FD->getCanonicalDecl();
-}
-
 void StdLibraryFunctionsChecker::initFunctionSummaries(
 CheckerContext &C) const {
   if (!FunctionSummaryMap.empty())

diff  --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp 
b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index cd15cd872d9d..1ea7c26dc76b 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -1202,7 +1202,7 @@ template <> struct DenseMapInfo {
 };
 } // end namespace llvm
 
-const ObjCMethodDecl *
+static const ObjCMethodDecl *
 lookupRuntimeDefinition(const ObjCInterfaceDecl *Interface,
 Selector LookupSelector, bool InstanceMethod) {
   // Repeatedly calling lookupPrivateMethod() is expensive, especially

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 7ddf25b99a6a..957db32d6085 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -1246,12 +1246,12 @@ static Value *getAISize(LLVMContext &Context, Value 
*Amt) {
   return Amt;
 }
 
-Align computeAllocaDefaultAlign(Type *Ty, BasicBlock *BB) {
+static Align computeAllocaDefaultAlign(Type *Ty, BasicBlock *BB) {
   const DataLayout &DL = BB->getModule()->getDataLayout();
   return DL.getPrefTypeAlign(Ty);
 }
 
-Align computeAllocaDefaultAlign(Type *Ty, Instruction *I) {
+static Align computeAllocaDefaultAlign(Type *Ty, Instruction *I) {
   return computeAllocaDefaultAlign(Ty, I->getParent());
 }
 
@@ -1333,12 +1333,12 @@ void LoadInst::AssertOK() {
  "Alignment required for atomic load");
 }
 
-Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) {
+static Align computeLoadStoreDefaultAlign(Type *Ty, BasicBlock *BB) {
   const DataLayout &DL = BB->getModule()->getDataLayout();
   return DL.getABITypeAlign(Ty);
 }
 
-Align computeLoadStoreDefaultAlign(Type *Ty, Instruction *I) {
+static Align computeLoadStoreDefaultAlign(Type *Ty, Instruction *I) {
   return computeLoadStoreDefaultAlign(Ty, I->getParent());
 }
 

diff  --git a/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp 
b/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
index f908f883fb24..49056d783028 100644
--- a/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
@@ -960,9 +960,9 @@ void ARMExpandPseudo::ExpandMOV32BitImm(MachineBasicBlock 
&MBB,
 // S0-S31 + FPSCR + 8 more bytes (VPR + pad, or just pad)
 static const int CMSE_FP_SAVE_SIZE = 136;
 
-void determineGPRegsToClear(const MachineInstr &MI,
-const std::initializer_list &Regs,
-SmallVectorImpl &ClearRegs) {
+static void determineGPRegsToClear(const MachineInstr &MI,
+   const std::initializer_list &Regs,
+   SmallVectorImpl &ClearRegs) {
   SmallVector OpRegs;
   for (const MachineOperand &Op : MI.operands()) {
 if (!Op.isReg() || !Op.isUse())

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 655147076a40..08f455b8bf2c 100644

[PATCH] D80213: [analyzer] Move StdCLibraryFunctionArgs to alpha.

2020-05-19 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe42e5e4d0fc0: [analyzer] Move 
apiModeling.StdCLibraryFunctionArgs to alpha. (authored by dergachev.a).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D80213?vs=264896&id=265008#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80213

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/test/Analysis/analyzer-enabled-checkers.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -2,7 +2,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
@@ -12,7 +12,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
Index: clang/test/Analysis/analyzer-enabled-checkers.c
===
--- clang/test/Analysis/analyzer-enabled-checkers.c
+++ clang/test/Analysis/analyzer-enabled-checkers.c
@@ -9,7 +9,6 @@
 // CHECK-NEXT: core.NonNullParamChecker
 // CHECK-NEXT: core.CallAndMessage
 // CHECK-NEXT: apiModeling.StdCLibraryFunctions
-// CHECK-NEXT: apiModeling.StdCLibraryFunctionArgs
 // CHECK-NEXT: apiModeling.TrustNonnull
 // CHECK-NEXT: apiModeling.llvm.CastValue
 // CHECK-NEXT: apiModeling.llvm.ReturnValue
Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -102,6 +102,8 @@
 // any diagnostics. These checkers are always turned on; this package is
 // intended for API modeling that is not controlled by the target triple.
 def APIModeling : Package<"apiModeling">, Hidden;
+def APIModelingAlpha : Package<"apiModeling">, ParentPackage, Hidden;
+
 def GoogleAPIModeling : Package<"google">, ParentPackage, Hidden;
 def LLVMAPIModeling : Package<"llvm">, ParentPackage, Hidden;
 
@@ -304,6 +306,15 @@
   ]>,
   Documentation;
 
+def TrustNonnullChecker : Checker<"TrustNonnull">,
+  HelpText<"Trust that returns from framework methods annotated with _Nonnull "
+   "are not null">,
+  Documentation;
+
+} // end "apiModeling"
+
+let ParentPackage = APIModelingAlpha in {
+
 def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">,
   HelpText<"Check constraints of arguments of C standard library functions, "
"such as whether the parameter of isalpha is in the range [0, 255] "
@@ -311,12 +322,7 @@
   Dependencies<[StdCLibraryFunctionsChecker]>,
   Documentation;
 
-def TrustNonnullChecker : Checker<"TrustNonnull">,
-  HelpText<"Trust that returns from framework methods annotated with _Nonnull "
-   "are not null">,
-  Documentation;
-
-} // end "apiModeling"
+} // end "alpha.apiModeling"
 
 
//===--===//
 // Evaluate "builtin" functions.


Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/t

[PATCH] D80174: [WebAssembly] Implement i64x2.mul and remove i8x16.mul

2020-05-19 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3181273be73a: [WebAssembly] Implement i64x2.mul and remove 
i8x16.mul (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80174

Files:
  clang/lib/Headers/wasm_simd128.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-arith.ll
  llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -328,9 +328,6 @@
 # CHECK: i8x16.sub_saturate_u # encoding: [0xfd,0x73]
 i8x16.sub_saturate_u
 
-# CHECK: i8x16.mul # encoding: [0xfd,0x75]
-i8x16.mul
-
 # CHECK: i8x16.min_s # encoding: [0xfd,0x76]
 i8x16.min_s
 
@@ -508,6 +505,9 @@
 # CHECK: i64x2.sub # encoding: [0xfd,0xd1,0x01]
 i64x2.sub
 
+# CHECK: i64x2.mul # encoding: [0xfd,0xd5,0x01]
+i64x2.mul
+
 # CHECK: f32x4.abs # encoding: [0xfd,0xe0,0x01]
 f32x4.abs
 
Index: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
+++ llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
@@ -308,7 +308,8 @@
 }
 
 ; CHECK-LABEL: ctpop_v2i64:
-; CHECK: i64.popcnt
+; Note: expansion does not use i64.popcnt
+; CHECK: v128.and
 declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>)
 define <2 x i64> @ctpop_v2i64(<2 x i64> %x) {
   %v = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %x)
Index: llvm/test/CodeGen/WebAssembly/simd-arith.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-arith.ll
+++ llvm/test/CodeGen/WebAssembly/simd-arith.ll
@@ -37,11 +37,12 @@
   ret <16 x i8> %a
 }
 
+; i8x16.mul is not in spec
 ; CHECK-LABEL: mul_v16i8:
 ; NO-SIMD128-NOT: i8x16
-; SIMD128-NEXT: .functype mul_v16i8 (v128, v128) -> (v128){{$}}
-; SIMD128-NEXT: i8x16.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
-; SIMD128-NEXT: return $pop[[R]]{{$}}
+; SIMD128-NOT: i8x16.mul
+; SIMD128: i8x16.extract_lane_u
+; SIMD128: i32.mul
 define <16 x i8> @mul_v16i8(<16 x i8> %x, <16 x i8> %y) {
   %a = mul <16 x i8> %x, %y
   ret <16 x i8> %a
@@ -956,12 +957,11 @@
   ret <2 x i64> %a
 }
 
-; v2i64.mul is not in spec
 ; CHECK-LABEL: mul_v2i64:
 ; NO-SIMD128-NOT: i64x2
-; SIMD128-NOT: i64x2.mul
-; SIMD128: i64x2.extract_lane
-; SIMD128: i64.mul
+; SIMD128-NEXT: .functype mul_v2i64 (v128, v128) -> (v128){{$}}
+; SIMD128: i64x2.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
 define <2 x i64> @mul_v2i64(<2 x i64> %x, <2 x i64> %y) {
   %a = mul <2 x i64> %x, %y
   ret <2 x i64> %a
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -673,6 +673,12 @@
 // Integer binary arithmetic
 //===--===//
 
+multiclass SIMDBinaryIntNoI8x16 baseInst> {
+  defm "" : SIMDBinary;
+  defm "" : SIMDBinary;
+  defm "" : SIMDBinary;
+}
+
 multiclass SIMDBinaryIntSmall baseInst> {
   defm "" : SIMDBinary;
   defm "" : SIMDBinary;
@@ -704,7 +710,7 @@
 
 // Integer multiplication: mul
 let isCommutable = 1 in
-defm MUL : SIMDBinaryIntNoI64x2;
+defm MUL : SIMDBinaryIntNoI8x16;
 
 // Integer min_s / min_u / max_s / max_u
 let isCommutable = 1 in {
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -153,9 +153,8 @@
  MVT::v2f64})
 setOperationAction(Op, T, Custom);
 
-// There is no i64x2.mul instruction
-// TODO: Actually, there is now. Implement it.
-setOperationAction(ISD::MUL, MVT::v2i64, Expand);
+// There is no i8x16.mul instruction
+setOperationAction(ISD::MUL, MVT::v16i8, Expand);
 
 // There are no vector select instructions
 for (auto Op : {ISD::VSELECT, ISD::SELECT_CC, ISD::SELECT})
Index: clang/lib/Headers/wasm_simd128.h
===
--- clang/lib/Headers/wasm_simd128.h
+++ clang/lib/Headers/wasm_simd128.h
@@ -637,11 +637,6 @@
  (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_mul(v128_t __a,
-   v128_t __b) {
-  return (v128_t)((__u8x16)__a * (__u8x16)__b);
-}
-
 static __inline_

[PATCH] D80153: [AST] Mangle LambdaContextDecl for top level decl

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done.
zequanwu added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:950-952
   // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // member (static or nonstatic) or is a top level decl, it is encoded
+  // in a qualified name.

zequanwu wrote:
> rnk wrote:
> > Will this fix work if the inline variable is in a namespace, or inline 
> > function?
> > 
> > This code seems like maybe it should live in `getEffectiveDeclContext`. Are 
> > you sure the fix won't be there?
> Because whenever we got a `LambdaExpr` and it is inside `VarDecl`, we want to 
> add `@[varaible]` after `@`. So, the demangled result will have 
> `[variable]::`. 
> 
> I think we should remove the check for record and translation unit.
Otherwise, the fix won't work if inline variable is inside namespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80153



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


[PATCH] D80153: [AST] Mangle LambdaContextDecl for top level decl

2020-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu marked an inline comment as done.
zequanwu added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:950-952
   // If the context of a closure type is an initializer for a class
-  // member (static or nonstatic), it is encoded in a qualified name.
+  // member (static or nonstatic) or is a top level decl, it is encoded
+  // in a qualified name.

rnk wrote:
> Will this fix work if the inline variable is in a namespace, or inline 
> function?
> 
> This code seems like maybe it should live in `getEffectiveDeclContext`. Are 
> you sure the fix won't be there?
Because whenever we got a `LambdaExpr` and it is inside `VarDecl`, we want to 
add `@[varaible]` after `@`. So, the demangled result will have 
`[variable]::`. 

I think we should remove the check for record and translation unit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80153



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.
Herald added a subscriber: sstefan1.

What's the status? Can we split the target specific types stuff if this may 
take a while, other patches depend on that :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[PATCH] D80020: [PowerPC] Add support for -mcpu=pwr10 in both clang and llvm

2020-05-19 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp added a comment.

Most of my comments are related to the fact that we are now inserting P10 
 between P9  and 
Future and so a few things need to change for the Future code to sit on top of 
P10  now.




Comment at: clang/test/Preprocessor/init-ppc64.c:652
 // PPCFUTURE:#define _ARCH_PPCSQ 1
 // PPCFUTURE:#define _ARCH_PWR4 1
 // PPCFUTURE:#define _ARCH_PWR5 1

Since we are adding P10 between P9 and Future we should add another line here:
```
PPCFUTURE:#define _ARCH_PWR10 1
```



Comment at: llvm/lib/Target/PowerPC/PPC.td:340
+  list P10SpecificFeatures =
+[FeaturePrefixInstrs, FeaturePCRelativeMemops];
+  list P10InheritableFeatures =

I think these can be moved up to `P10AdditionalFeatures`. That way everything 
on P10 is now inheritable by future and we don't have to specify anything for 
`FutureSpecificFeatures`.



Comment at: llvm/lib/Target/PowerPC/PPC.td:351
   list FutureSpecificFeatures =
 [FeaturePrefixInstrs, FeaturePCRelativeMemops];
   list FutureInheritableFeatures =

These features are now no longer `FutureSpecificFeatures` I would think that 
they would now be part of Power10 and should be inherited by future CPU. 



Comment at: llvm/test/CodeGen/PowerPC/check-cpu.ll:11
 
 ; Test mcpu=future that should be recognized on PowerPC.
 

nit:
We should probably update this comment too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80020



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


[PATCH] D80174: [WebAssembly] Implement i64x2.mul and remove i8x16.mul

2020-05-19 Thread Thomas Lively via Phabricator via cfe-commits
tlively marked 2 inline comments as done.
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td:690
   defm "" : SIMDBinary;
 }
 

aheejin wrote:
> Can we delete this now then?
No, it is still used down in MIN_S and friends.



Comment at: llvm/test/CodeGen/WebAssembly/simd-unsupported.ll:312
+; Note: expansion does not use i64.popcnt
+; CHECK: v128.and
 declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>)

aheejin wrote:
> What caused this change?
The default legalization uses a bunch of SIMD operations rather than 
scalarizing. One of the SIMD operations it uses is multiplication, so now that 
multiplication is legal, popcnt is no longer scalarized.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80174



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


[PATCH] D78155: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in wrapper headers

2020-05-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.
Herald added a subscriber: sstefan1.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78155



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


[clang] e42e5e4 - [analyzer] Move apiModeling.StdCLibraryFunctionArgs to alpha.

2020-05-19 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-05-19T23:05:49+03:00
New Revision: e42e5e4d0fc08fed673b453268606bc9fdf0a7d2

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

LOG: [analyzer] Move apiModeling.StdCLibraryFunctionArgs to alpha.

It was enabled by default accidentally; still missing some important
features. Also it needs a better package because it doesn't boil down to
API modeling.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/test/Analysis/analyzer-enabled-checkers.c
clang/test/Analysis/std-c-library-functions-arg-constraints.c
clang/test/Analysis/std-c-library-functions-arg-constraints.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index cc6952b55810..d06c64ad118b 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -102,6 +102,8 @@ def LLVMAlpha : Package<"llvm">, ParentPackage;
 // any diagnostics. These checkers are always turned on; this package is
 // intended for API modeling that is not controlled by the target triple.
 def APIModeling : Package<"apiModeling">, Hidden;
+def APIModelingAlpha : Package<"apiModeling">, ParentPackage, Hidden;
+
 def GoogleAPIModeling : Package<"google">, ParentPackage, Hidden;
 def LLVMAPIModeling : Package<"llvm">, ParentPackage, Hidden;
 
@@ -304,6 +306,15 @@ def StdCLibraryFunctionsChecker : 
Checker<"StdCLibraryFunctions">,
   ]>,
   Documentation;
 
+def TrustNonnullChecker : Checker<"TrustNonnull">,
+  HelpText<"Trust that returns from framework methods annotated with _Nonnull "
+   "are not null">,
+  Documentation;
+
+} // end "apiModeling"
+
+let ParentPackage = APIModelingAlpha in {
+
 def StdCLibraryFunctionArgsChecker : Checker<"StdCLibraryFunctionArgs">,
   HelpText<"Check constraints of arguments of C standard library functions, "
"such as whether the parameter of isalpha is in the range [0, 255] "
@@ -311,12 +322,7 @@ def StdCLibraryFunctionArgsChecker : 
Checker<"StdCLibraryFunctionArgs">,
   Dependencies<[StdCLibraryFunctionsChecker]>,
   Documentation;
 
-def TrustNonnullChecker : Checker<"TrustNonnull">,
-  HelpText<"Trust that returns from framework methods annotated with _Nonnull "
-   "are not null">,
-  Documentation;
-
-} // end "apiModeling"
+} // end "alpha.apiModeling"
 
 
//===--===//
 // Evaluate "builtin" functions.

diff  --git a/clang/test/Analysis/analyzer-enabled-checkers.c 
b/clang/test/Analysis/analyzer-enabled-checkers.c
index 0e44b1147f04..ad195b086d87 100644
--- a/clang/test/Analysis/analyzer-enabled-checkers.c
+++ b/clang/test/Analysis/analyzer-enabled-checkers.c
@@ -9,7 +9,6 @@
 // CHECK-NEXT: core.NonNullParamChecker
 // CHECK-NEXT: core.CallAndMessage
 // CHECK-NEXT: apiModeling.StdCLibraryFunctions
-// CHECK-NEXT: apiModeling.StdCLibraryFunctionArgs
 // CHECK-NEXT: apiModeling.TrustNonnull
 // CHECK-NEXT: apiModeling.llvm.CastValue
 // CHECK-NEXT: apiModeling.llvm.ReturnValue

diff  --git a/clang/test/Analysis/std-c-library-functions-arg-constraints.c 
b/clang/test/Analysis/std-c-library-functions-arg-constraints.c
index 62962a398689..00960e42fb55 100644
--- a/clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ b/clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -2,7 +2,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
@@ -12,7 +12,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
-// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=alpha.apiModeling.StdCLibraryFunctionArgs \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \

diff  --git a/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp 
b/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
index fed815f67a57..ebc841a07fb7 100644
--- a/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ b/clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -1,7 +1,7 @@
 // RUN: %

[clang] 3181273 - [WebAssembly] Implement i64x2.mul and remove i8x16.mul

2020-05-19 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2020-05-19T12:50:44-07:00
New Revision: 3181273be73ac798c3d5b9081dd53d87a31c91b3

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

LOG: [WebAssembly] Implement i64x2.mul and remove i8x16.mul

Summary:
This reflects changes in the spec proposal made since basic arithmetic
was first implemented.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/Headers/wasm_simd128.h
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-arith.ll
llvm/test/CodeGen/WebAssembly/simd-unsupported.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/lib/Headers/wasm_simd128.h 
b/clang/lib/Headers/wasm_simd128.h
index d79b83b21c0e..580aa1e85c1b 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -637,11 +637,6 @@ wasm_u8x16_sub_saturate(v128_t __a, v128_t __b) {
  (__i8x16)__b);
 }
 
-static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_mul(v128_t __a,
-   v128_t __b) {
-  return (v128_t)((__u8x16)__a * (__u8x16)__b);
-}
-
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
v128_t __b) {
   return (v128_t)__builtin_wasm_min_s_i8x16((__i8x16)__a, (__i8x16)__b);

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
index 2ad2ae6413d5..bf4a0da31062 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -153,9 +153,8 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
  MVT::v2f64})
 setOperationAction(Op, T, Custom);
 
-// There is no i64x2.mul instruction
-// TODO: Actually, there is now. Implement it.
-setOperationAction(ISD::MUL, MVT::v2i64, Expand);
+// There is no i8x16.mul instruction
+setOperationAction(ISD::MUL, MVT::v16i8, Expand);
 
 // There are no vector select instructions
 for (auto Op : {ISD::VSELECT, ISD::SELECT_CC, ISD::SELECT})

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index 4236d9095c97..7faae22424fb 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -673,6 +673,12 @@ def : Pat<(v2i64 (shifts[0] (v2i64 V128:$vec), I32:$x)),
 // Integer binary arithmetic
 
//===--===//
 
+multiclass SIMDBinaryIntNoI8x16 baseInst> {
+  defm "" : SIMDBinary;
+  defm "" : SIMDBinary;
+  defm "" : SIMDBinary;
+}
+
 multiclass SIMDBinaryIntSmall baseInst> {
   defm "" : SIMDBinary;
   defm "" : SIMDBinary;
@@ -704,7 +710,7 @@ defm SUB_SAT_U :
 
 // Integer multiplication: mul
 let isCommutable = 1 in
-defm MUL : SIMDBinaryIntNoI64x2;
+defm MUL : SIMDBinaryIntNoI8x16;
 
 // Integer min_s / min_u / max_s / max_u
 let isCommutable = 1 in {

diff  --git a/llvm/test/CodeGen/WebAssembly/simd-arith.ll 
b/llvm/test/CodeGen/WebAssembly/simd-arith.ll
index d616828c51e3..c56566991a8c 100644
--- a/llvm/test/CodeGen/WebAssembly/simd-arith.ll
+++ b/llvm/test/CodeGen/WebAssembly/simd-arith.ll
@@ -37,11 +37,12 @@ define <16 x i8> @sub_v16i8(<16 x i8> %x, <16 x i8> %y) {
   ret <16 x i8> %a
 }
 
+; i8x16.mul is not in spec
 ; CHECK-LABEL: mul_v16i8:
 ; NO-SIMD128-NOT: i8x16
-; SIMD128-NEXT: .functype mul_v16i8 (v128, v128) -> (v128){{$}}
-; SIMD128-NEXT: i8x16.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
-; SIMD128-NEXT: return $pop[[R]]{{$}}
+; SIMD128-NOT: i8x16.mul
+; SIMD128: i8x16.extract_lane_u
+; SIMD128: i32.mul
 define <16 x i8> @mul_v16i8(<16 x i8> %x, <16 x i8> %y) {
   %a = mul <16 x i8> %x, %y
   ret <16 x i8> %a
@@ -956,12 +957,11 @@ define <2 x i64> @sub_v2i64(<2 x i64> %x, <2 x i64> %y) {
   ret <2 x i64> %a
 }
 
-; v2i64.mul is not in spec
 ; CHECK-LABEL: mul_v2i64:
 ; NO-SIMD128-NOT: i64x2
-; SIMD128-NOT: i64x2.mul
-; SIMD128: i64x2.extract_lane
-; SIMD128: i64.mul
+; SIMD128-NEXT: .functype mul_v2i64 (v128, v128) -> (v128){{$}}
+; SIMD128: i64x2.mul $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
 define <2 x i64> @mul_v2i64(<2 x i64> %x, <2 x i64> %y) {
   %a = mul <2 x i64> %x, %y
   ret <2 x i64> %a

diff  --git a/llvm/test/CodeGen/WebAssembly/simd-unsupported.ll 
b/llvm/test/CodeGen/WebAssembly/simd-unsupp

[PATCH] D80225: [Driver] Recognize -fuse-ld={bfd, gold, lld} but don't prepend "ld." or "ld64." for other values

2020-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 264995.
MaskRay added a comment.

Fix fuse-ld-windows.c (I don't have Windows (REQUIRES: system-windows), so I 
failed to catch the issue earlier)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80225

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/ld.lld-link2
  clang/test/Driver/Inputs/Windows/ARM/8.1/usr/bin/lld-link2
  clang/test/Driver/Inputs/fuse_ld_windows/foo.exe
  clang/test/Driver/Inputs/fuse_ld_windows/ld.foo.exe
  clang/test/Driver/fuse-ld-windows.c
  clang/test/Driver/fuse-ld.c


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -15,6 +15,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+// RUN: %clang %s -### -fuse-ld=ld.bfd \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+
 // CHECK-FREEBSD-BFD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.bfd
 
 // RUN: %clang %s -### -fuse-ld=gold \
@@ -22,6 +28,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// RUN: %clang %s -### -fuse-ld=ld.gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+
 // CHECK-FREEBSD-GOLD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.gold
 
 // RUN: %clang %s -### -fuse-ld=plib \
Index: clang/test/Driver/fuse-ld-windows.c
===
--- clang/test/Driver/fuse-ld-windows.c
+++ clang/test/Driver/fuse-ld-windows.c
@@ -22,4 +22,4 @@
 // RUN:   | FileCheck %s
 
 // CHECK-NOT: invalid linker name
-// CHECK: /Inputs/fuse_ld_windows{{/|}}ld.foo
+// CHECK: /Inputs/fuse_ld_windows{{/|}}foo
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -534,21 +534,24 @@
   const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
   StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
 
+  // If we're passed -fuse-ld= with no argument, or with the argument ld,
+  // then use whatever the default system linker is.
+  if (UseLinker.empty() || UseLinker == "ld")
+return GetProgramPath(getDefaultLinker());
   if (llvm::sys::path::is_absolute(UseLinker)) {
 // If we're passed what looks like an absolute path, don't attempt to
 // second-guess that.
 if (llvm::sys::fs::can_execute(UseLinker))
   return std::string(UseLinker);
-  } else if (UseLinker.empty() || UseLinker == "ld") {
-// If we're passed -fuse-ld= with no argument, or with the argument ld,
-// then use whatever the default system linker is.
-return GetProgramPath(getDefaultLinker());
   } else {
 llvm::SmallString<8> LinkerName;
-if (Triple.isOSDarwin())
-  LinkerName.append("ld64.");
-else
+// Recognize common abbreviations by appending an OS specific prefix.
+if (Triple.isOSDarwin()) {
+  if (UseLinker == "lld")
+LinkerName.append("ld64.");
+} else if (UseLinker == "bfd" || UseLinker == "gold" || UseLinker == "lld")
   LinkerName.append("ld.");
+
 LinkerName.append(UseLinker);
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -15,6 +15,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+// RUN: %clang %s -### -fuse-ld=ld.bfd \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-BFD
+
 // CHECK-FREEBSD-BFD: Inputs/basic_freebsd_tree/usr/bin{{/|\\+}}ld.bfd
 
 // RUN: %clang %s -### -fuse-ld=gold \
@@ -22,6 +28,12 @@
 // RUN: -target x86_64-unknown-freebsd \
 // RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-GOLD
+// RUN: %clang %s -### -fuse-ld=ld.gold \
+// RUN: --sysroot=%S/Inputs/basic_freebsd_tree \
+// RUN: -target x86_64-unknown-freebsd \
+// RUN: -B%S/Inputs/basic_freebsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck

[PATCH] D78760: Check a class doesn't have a dependent type before iterating over its base classes

2020-05-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 264992.
ahatanak retitled this revision from "Check a class has a definition before 
iterating over its base classes" to "Check a class doesn't have a dependent 
type before iterating over its base classes".
ahatanak edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78760

Files:
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/class.cpp


Index: clang/test/SemaCXX/class.cpp
===
--- clang/test/SemaCXX/class.cpp
+++ clang/test/SemaCXX/class.cpp
@@ -211,3 +211,30 @@
 struct PR9989 { 
   static int const PR9989_Member = sizeof PR9989_Member; 
 };
+
+namespace dependent_base_type {
+struct B1 {};
+
+template 
+struct S0 {
+  void m0() {
+struct B0; // expected-note {{member is declared here}}
+
+struct D : B0, B1 { // expected-error {{implicit instantiation}} 
expected-note {{in instantiation of}}
+};
+  }
+};
+
+void test() {
+  S0().m0(); // expected-note {{in instantiation of}}
+}
+
+// clang used to crash compiling this code.
+struct A {};
+template 
+struct X {
+  struct B : A {};
+  struct C : A, B {};
+};
+
+} // namespace dependent_base_type
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2611,6 +2611,9 @@
   if (auto Rec = Type->getAs()) {
 auto Decl = Rec->getAsCXXRecordDecl();
 
+if (Decl->isDependentType())
+  return;
+
 // Iterate over its bases.
 for (const auto &BaseSpec : Decl->bases()) {
   QualType Base = Context.getCanonicalType(BaseSpec.getType())
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -173,6 +173,8 @@
   SmallVector WorkList = {StartRD};
   while (!WorkList.empty()) {
 const CXXRecordDecl *RD = WorkList.pop_back_val();
+if (RD->isDependentType())
+  continue;
 for (const CXXBaseSpecifier &BaseSpec : RD->bases()) {
   if (const CXXRecordDecl *B = BaseSpec.getType()->getAsCXXRecordDecl()) {
 if (!SeenBaseTypes.insert(B).second)


Index: clang/test/SemaCXX/class.cpp
===
--- clang/test/SemaCXX/class.cpp
+++ clang/test/SemaCXX/class.cpp
@@ -211,3 +211,30 @@
 struct PR9989 { 
   static int const PR9989_Member = sizeof PR9989_Member; 
 };
+
+namespace dependent_base_type {
+struct B1 {};
+
+template 
+struct S0 {
+  void m0() {
+struct B0; // expected-note {{member is declared here}}
+
+struct D : B0, B1 { // expected-error {{implicit instantiation}} expected-note {{in instantiation of}}
+};
+  }
+};
+
+void test() {
+  S0().m0(); // expected-note {{in instantiation of}}
+}
+
+// clang used to crash compiling this code.
+struct A {};
+template 
+struct X {
+  struct B : A {};
+  struct C : A, B {};
+};
+
+} // namespace dependent_base_type
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2611,6 +2611,9 @@
   if (auto Rec = Type->getAs()) {
 auto Decl = Rec->getAsCXXRecordDecl();
 
+if (Decl->isDependentType())
+  return;
+
 // Iterate over its bases.
 for (const auto &BaseSpec : Decl->bases()) {
   QualType Base = Context.getCanonicalType(BaseSpec.getType())
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -173,6 +173,8 @@
   SmallVector WorkList = {StartRD};
   while (!WorkList.empty()) {
 const CXXRecordDecl *RD = WorkList.pop_back_val();
+if (RD->isDependentType())
+  continue;
 for (const CXXBaseSpecifier &BaseSpec : RD->bases()) {
   if (const CXXRecordDecl *B = BaseSpec.getType()->getAsCXXRecordDecl()) {
 if (!SeenBaseTypes.insert(B).second)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80023: [clang-tidy] Add abseil-string-find-str-contains checker.

2020-05-19 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp:101-102
+
+void StringFindStrContainsCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "StringLikeClasses",

I don't know if you have rebased recently, but `TransformerClangTidyCheck` now 
has a `storeOptions` method that needs calling from derived classes that 
override `storeOptions`. For now can you add a call to that in here 
`TransformerClangTidyCheck::storeOptions(Opts);` I Agree that we need to rework 
how options are handled but for now, make it work correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80023



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


[PATCH] D50078: clang-format: support aligned nested conditionals formatting

2020-05-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

https://bugs.llvm.org/show_bug.cgi?id=33896 shows an interesting use case (when 
using UseTab: Always)

  std::string CLogView::GetItemText(int item) const {
return item == 1 ? "one" :
   item == 2 ? "two" :
   item == 3 ? "three" :
   item == 4 ? "four" :
 "high";
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50078



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


  1   2   3   >