[PATCH] D106645: [clangd] Tweak constructor of dex AndIterator for performance.

2021-08-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.

As discussed offline, does not yield performance improvements. Putting on 
"Request Changes" so that I don't miss ongoing reviews (please let me know if 
that's OK with you).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106645

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


[PATCH] D106640: [clangd] Make dex iterator peek() and reachedEnd() nonvirtual

2021-08-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.

Ditto (previous performance improvement attempt).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106640

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


[PATCH] D107047: [clangd] Fix the crash in getQualification

2021-08-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107047

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


[PATCH] D107047: [clangd] Fix the crash in getQualification

2021-08-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0f2d4af031c: [clangd] Fix the crash in getQualification 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107047

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp


Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -259,6 +259,18 @@
   {"ns2::", "ns2::", ""},
   {"ns1::"},
   },
+  {
+  R"cpp(
+namespace ns {
+extern "C" {
+typedef int Foo;
+}
+}
+void insert(); // ns::Foo
+  )cpp",
+  {"ns::"},
+  {},
+  },
   };
   for (const auto &Case : Cases) {
 Annotations Test(Case.Test);
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -119,14 +119,17 @@
   (void)ReachedNS;
   NNS = NestedNameSpecifier::Create(Context, nullptr, false,
 TD->getTypeForDecl());
-} else {
+} else if (auto *NSD = llvm::dyn_cast(CurContext)) {
   ReachedNS = true;
-  auto *NSD = llvm::cast(CurContext);
   NNS = NestedNameSpecifier::Create(Context, nullptr, NSD);
-  // Anonymous and inline namespace names are not spelled while qualifying 
a
-  // name, so skip those.
+  // Anonymous and inline namespace names are not spelled while qualifying
+  // a name, so skip those.
   if (NSD->isAnonymousNamespace() || NSD->isInlineNamespace())
 continue;
+} else {
+  // Other types of contexts cannot be spelled in code, just skip over
+  // them.
+  continue;
 }
 // Stop if this namespace is already visible at DestContext.
 if (IsVisible(NNS))


Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -259,6 +259,18 @@
   {"ns2::", "ns2::", ""},
   {"ns1::"},
   },
+  {
+  R"cpp(
+namespace ns {
+extern "C" {
+typedef int Foo;
+}
+}
+void insert(); // ns::Foo
+  )cpp",
+  {"ns::"},
+  {},
+  },
   };
   for (const auto &Case : Cases) {
 Annotations Test(Case.Test);
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -119,14 +119,17 @@
   (void)ReachedNS;
   NNS = NestedNameSpecifier::Create(Context, nullptr, false,
 TD->getTypeForDecl());
-} else {
+} else if (auto *NSD = llvm::dyn_cast(CurContext)) {
   ReachedNS = true;
-  auto *NSD = llvm::cast(CurContext);
   NNS = NestedNameSpecifier::Create(Context, nullptr, NSD);
-  // Anonymous and inline namespace names are not spelled while qualifying a
-  // name, so skip those.
+  // Anonymous and inline namespace names are not spelled while qualifying
+  // a name, so skip those.
   if (NSD->isAnonymousNamespace() || NSD->isInlineNamespace())
 continue;
+} else {
+  // Other types of contexts cannot be spelled in code, just skip over
+  // them.
+  continue;
 }
 // Stop if this namespace is already visible at DestContext.
 if (IsVisible(NNS))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e0f2d4a - [clangd] Fix the crash in getQualification

2021-08-02 Thread Kirill Bobyrev via cfe-commits
Author: Kirill Bobyrev
Date: 2021-08-02T09:08:25+02:00
New Revision: e0f2d4af031c93b46f0920620ab6a798113b4b6e

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

LOG: [clangd] Fix the crash in getQualification

Happens when DestContext is LinkageSpecDecl and hense CurContext happens to be
both not TagDecl and NamespaceDecl.

Minimal reproducer: trigger define outline in

```
namespace ns {
extern "C" {
typedef int foo;
}
foo Fo^o(int id) { return id; }
}
```

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/unittests/ASTTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index 32bae42a07976..778b945c47ca9 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -119,14 +119,17 @@ getQualification(ASTContext &Context, const DeclContext 
*DestContext,
   (void)ReachedNS;
   NNS = NestedNameSpecifier::Create(Context, nullptr, false,
 TD->getTypeForDecl());
-} else {
+} else if (auto *NSD = llvm::dyn_cast(CurContext)) {
   ReachedNS = true;
-  auto *NSD = llvm::cast(CurContext);
   NNS = NestedNameSpecifier::Create(Context, nullptr, NSD);
-  // Anonymous and inline namespace names are not spelled while qualifying 
a
-  // name, so skip those.
+  // Anonymous and inline namespace names are not spelled while qualifying
+  // a name, so skip those.
   if (NSD->isAnonymousNamespace() || NSD->isInlineNamespace())
 continue;
+} else {
+  // Other types of contexts cannot be spelled in code, just skip over
+  // them.
+  continue;
 }
 // Stop if this namespace is already visible at DestContext.
 if (IsVisible(NNS))

diff  --git a/clang-tools-extra/clangd/unittests/ASTTests.cpp 
b/clang-tools-extra/clangd/unittests/ASTTests.cpp
index 7b662189eaaf3..67ce927bf765b 100644
--- a/clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -259,6 +259,18 @@ TEST(ClangdAST, GetQualification) {
   {"ns2::", "ns2::", ""},
   {"ns1::"},
   },
+  {
+  R"cpp(
+namespace ns {
+extern "C" {
+typedef int Foo;
+}
+}
+void insert(); // ns::Foo
+  )cpp",
+  {"ns::"},
+  {},
+  },
   };
   for (const auto &Case : Cases) {
 Annotations Test(Case.Test);



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


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

2021-08-02 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal updated this revision to Diff 363387.
pdhaliwal added a comment.

Fixed compilation error for nvptx headers. Tested on both cuda and non-cuda 
systems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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

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

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

2021-08-02 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

@ye-luo and @JonChesterfield can you please test the latest version of this 
patch? It should work now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-08-02 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D74436#2917395 , @mibintc wrote:

> In D74436#2917357 , @haowei wrote:
>
>> We are seeing float related unit tests failing in Fuchsia after this patch. 
>> What flags should we add to our build to match llvm's previous float point 
>> behavior?
>
> This option: ffp-contract=off

We're seeing float related tests fail in Chromium too (crbug.com/1235145). I 
haven't read the background llvm-dev thread about this, but is changing the 
default behavior here really intentional? Does it match what the standards 
require and what other compilers do?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

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


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

2021-08-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

>>> I don't find any document about GCC and ICC's behavior and the generated

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

Here is gcc document: 
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands

To me it is defined behavior.  Or I may missing some thing here.

constraint:
A string constant specifying constraints on the placement of the operand; See 
Constraints, for details.

Output constraints must begin with either ‘=’ (a variable overwriting an 
existing value) or ‘+’ (when reading and writing). When using ‘=’, do not 
assume the location contains the existing value on entry to the asm, except 
when the operand is tied to an input; see Input Operands.

After the prefix, there must be one or more additional constraints (see 
Constraints) that describe where the value resides. Common constraints include 
‘r’ for register and ‘m’ for memory. When you list more than one possible 
location (for example, "=rm"), the compiler chooses the most efficient one 
based on the current context. If you list as many alternates as the asm 
statement allows, you permit the optimizers to produce the best possible code. 
If you must use a specific register, but your Machine Constraints do not 
provide sufficient control to select the specific register you want, local 
register variables may provide a solution (see Local Register Variables).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107141

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


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

2021-08-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 363411.
jansvoboda11 added a comment.

Move substitution to `clang/test/lit.cfg.py`, revert `%` prefixes.


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

https://reviews.llvm.org/D107155

Files:
  clang/test/lit.cfg.py


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -64,7 +64,7 @@
 
 tools = [
 'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format', 
'clang-repl',
-'clang-tblgen', 'opt', 'llvm-ifs', 'yaml2obj',
+'clang-tblgen', 'clang-scan-deps', 'opt', 'llvm-ifs', 'yaml2obj',
 ToolSubst('%clang_extdef_map', command=FindTool(
 'clang-extdef-mapping'), unresolved='ignore'),
 ]


Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -64,7 +64,7 @@
 
 tools = [
 'apinotes-test', 'c-index-test', 'clang-diff', 'clang-format', 'clang-repl',
-'clang-tblgen', 'opt', 'llvm-ifs', 'yaml2obj',
+'clang-tblgen', 'clang-scan-deps', 'opt', 'llvm-ifs', 'yaml2obj',
 ToolSubst('%clang_extdef_map', command=FindTool(
 'clang-extdef-mapping'), unresolved='ignore'),
 ]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106792: [clang-tidy] Always open files using UTF-8 encoding

2021-08-02 Thread Andy Yankovsky via Phabricator via cfe-commits
werat updated this revision to Diff 363413.
werat added a comment.

Moved the comment to the first usage of `io.open`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106792

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py

Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -10,20 +10,25 @@
 
 import argparse
 import glob
+import io
 import os
 import re
 
-
 def replaceInFileRegex(fileName, sFrom, sTo):
   if sFrom == sTo:
 return
+
+  # The documentation files are encoded using UTF-8, however on Windows the
+  # default encoding might be different (e.g. CP-1252). To make sure UTF-8 is
+  # always used, use `io.open(filename, mode, encoding='utf8')` for reading and
+  # writing files here and elsewhere.
   txt = None
-  with open(fileName, "r") as f:
+  with io.open(fileName, 'r', encoding='utf8') as f:
 txt = f.read()
 
   txt = re.sub(sFrom, sTo, txt)
   print("Replacing '%s' -> '%s' in '%s'..." % (sFrom, sTo, fileName))
-  with open(fileName, "w") as f:
+  with io.open(fileName, 'w', encoding='utf8') as f:
 f.write(txt)
 
 
@@ -31,7 +36,7 @@
   if sFrom == sTo:
 return
   txt = None
-  with open(fileName, "r") as f:
+  with io.open(fileName, 'r', encoding='utf8') as f:
 txt = f.read()
 
   if sFrom not in txt:
@@ -39,7 +44,7 @@
 
   txt = txt.replace(sFrom, sTo)
   print("Replacing '%s' -> '%s' in '%s'..." % (sFrom, sTo, fileName))
-  with open(fileName, "w") as f:
+  with io.open(fileName, 'w', encoding='utf8') as f:
 f.write(txt)
 
 
@@ -70,7 +75,7 @@
 
 def deleteMatchingLines(fileName, pattern):
   lines = None
-  with open(fileName, "r") as f:
+  with io.open(fileName, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   not_matching_lines = [l for l in lines if not re.search(pattern, l)]
@@ -79,7 +84,7 @@
 
   print("Removing lines matching '%s' in '%s'..." % (pattern, fileName))
   print('  ' + '  '.join([l for l in lines if re.search(pattern, l)]))
-  with open(fileName, "w") as f:
+  with io.open(fileName, 'w', encoding='utf8') as f:
 f.writelines(not_matching_lines)
 
   return True
@@ -101,7 +106,7 @@
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   cpp_file = check_name_camel + '.cpp'
@@ -112,7 +117,7 @@
   return False
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with io.open(filename, 'wb', encoding='utf8') as f:
 cpp_found = False
 file_added = False
 for line in lines:
@@ -130,11 +135,11 @@
 def adapt_module(module_path, module, check_name, check_name_camel):
   modulecpp = next(filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp', os.listdir(module_path)))
   filename = os.path.join(module_path, modulecpp)
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with io.open(filename, 'wb', encoding='utf8') as f:
 header_added = False
 header_found = False
 check_added = False
@@ -169,7 +174,7 @@
 def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
   filename = os.path.normpath(os.path.join(clang_tidy_path,
'../docs/ReleaseNotes.rst'))
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   lineMatcher = re.compile('Renamed checks')
@@ -177,7 +182,7 @@
   checkMatcher = re.compile('- The \'(.*)')
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with io.open(filename, 'wb', encoding='utf8') as f:
 note_added = False
 header_found = False
 add_note_here = False
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -11,16 +11,21 @@
 from __future__ import print_function
 
 import argparse
+import io
 import os
 import re
 import sys
 
-
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
-  with open(filename, 'r') as f:
+
+  # The documentation files are encoded using UTF-8, however on Windows the
+  # default encoding might be different (e.g. CP-1252). To make sure UTF-8 is
+  # always used, use `io.open(fil

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

2021-08-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D107155#2916664 , @dblaikie wrote:

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

You're right, I wasn't aware of this (and usually see `%clang` everywhere).

In D107155#2917400 , @dexonsmith 
wrote:

> I think that'd be adding clang-scan-deps somehow to the `tools` variable in 
> clang/test/lit.cfg.py:
>  https://github.com/llvm/llvm-project/blob/main/clang/test/lit.cfg.py#L59
> (which will then call `add_tool_substitutions` at 
> https://github.com/llvm/llvm-project/blob/main/clang/test/lit.cfg.py#L111)

Nice, that seems like the best place for this.

I updated the patch to reflect both findings, thanks!


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

https://reviews.llvm.org/D107155

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


[PATCH] D99353: [driver] Make `clang` warn rather then error on `flang` options

2021-08-02 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

In D99353#2918629 , @protze.joachim 
wrote:

> Any chance that we get this into llvm/13?

Given that Release-13 branch has already been created 
(https://lists.llvm.org/pipermail/llvm-dev/2021-July/151956.html), this is very 
unlikely. IMHO, this should be approved by somebody from `cfe-dev` before we 
merge it. But from the conversation 
 that we 
started on the mailing list, I feel that there's little appetite for this 
change.

@protze.joachim , if this is still required for your workflow, could you either 
reply to the thread on `cfe-dev` or create a bugzilla ticket? Otherwise people 
might not realise that this is an issue for some Clang users. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99353

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


[PATCH] D106792: [clang-tidy] Always open files using UTF-8 encoding

2021-08-02 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev accepted this revision.
kbobyrev added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106792

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


[clang-tools-extra] 307b1fd - [clang-tidy] Always open files using UTF-8 encoding

2021-08-02 Thread Andy Yankovsky via cfe-commits
Author: Andy Yankovsky
Date: 2021-08-02T11:36:04+02:00
New Revision: 307b1fddd4d84b559b154ff7744ae68bf9c6f503

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

LOG: [clang-tidy] Always open files using UTF-8 encoding

The encoding used for opening files depends on the OS and might be different
from UTF-8 (e.g. on Windows it can be CP-1252). The documentation files use
UTF-8 and might be incompatible with other encodings. For example, right now
`clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst`
has non-ASCII quotes and running `add_new_check.py` fails on Windows, because
it tries to read the file with incompatible encoding.

Use `io.open` for compatibility with both Python 2 and Python 3.

Reviewed By: kbobyrev

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/clang-tidy/rename_check.py

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index 14fcfe8d49ff..9239ca5953cd 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -11,16 +11,21 @@
 from __future__ import print_function
 
 import argparse
+import io
 import os
 import re
 import sys
 
-
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
-  with open(filename, 'r') as f:
+
+  # The documentation files are encoded using UTF-8, however on Windows the
+  # default encoding might be 
diff erent (e.g. CP-1252). To make sure UTF-8 is
+  # always used, use `io.open(filename, mode, encoding='utf8')` for reading and
+  # writing files here and elsewhere.
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   cpp_file = check_name_camel + '.cpp'
@@ -31,7 +36,7 @@ def adapt_cmake(module_path, check_name_camel):
   return False
 
   print('Updating %s...' % filename)
-  with open(filename, 'w') as f:
+  with io.open(filename, 'w', encoding='utf8') as f:
 cpp_found = False
 file_added = False
 for line in lines:
@@ -51,7 +56,7 @@ def write_header(module_path, module, namespace, check_name, 
check_name_camel):
   check_name_dashes = module + '-' + check_name
   filename = os.path.join(module_path, check_name_camel) + '.h'
   print('Creating %s...' % filename)
-  with open(filename, 'w') as f:
+  with io.open(filename, 'w', encoding='utf8') as f:
 header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() + '_'
 + check_name_camel.upper() + '_H')
 f.write('//===--- ')
@@ -104,7 +109,7 @@ class %(check_name)s : public ClangTidyCheck {
 def write_implementation(module_path, module, namespace, check_name_camel):
   filename = os.path.join(module_path, check_name_camel) + '.cpp'
   print('Creating %s...' % filename)
-  with open(filename, 'w') as f:
+  with io.open(filename, 'w', encoding='utf8') as f:
 f.write('//===--- ')
 f.write(os.path.basename(filename))
 f.write(' - clang-tidy ')
@@ -158,11 +163,11 @@ def adapt_module(module_path, module, check_name, 
check_name_camel):
   lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
   os.listdir(module_path)))[0]
   filename = os.path.join(module_path, modulecpp)
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   print('Updating %s...' % filename)
-  with open(filename, 'w') as f:
+  with io.open(filename, 'w', encoding='utf8') as f:
 header_added = False
 header_found = False
 check_added = False
@@ -217,7 +222,7 @@ def add_release_notes(module_path, module, check_name):
   check_name_dashes = module + '-' + check_name
   filename = os.path.normpath(os.path.join(module_path,
'../../docs/ReleaseNotes.rst'))
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   lineMatcher = re.compile('New checks')
@@ -225,7 +230,7 @@ def add_release_notes(module_path, module, check_name):
   checkMatcher = re.compile('- New :doc:`(.*)')
 
   print('Updating %s...' % filename)
-  with open(filename, 'w') as f:
+  with io.open(filename, 'w', encoding='utf8') as f:
 note_added = False
 header_found = False
 add_note_here = False
@@ -271,7 +276,7 @@ def write_test(module_path, module, check_name, 
test_extension):
   filename = os.path.normpath(os.path.join(module_path, 
'../../test/clang-tidy/checkers',
check_name_dashes + '.'

[PATCH] D106792: [clang-tidy] Always open files using UTF-8 encoding

2021-08-02 Thread Andy Yankovsky via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG307b1fddd4d8: [clang-tidy] Always open files using UTF-8 
encoding (authored by werat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106792

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py

Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -10,20 +10,25 @@
 
 import argparse
 import glob
+import io
 import os
 import re
 
-
 def replaceInFileRegex(fileName, sFrom, sTo):
   if sFrom == sTo:
 return
+
+  # The documentation files are encoded using UTF-8, however on Windows the
+  # default encoding might be different (e.g. CP-1252). To make sure UTF-8 is
+  # always used, use `io.open(filename, mode, encoding='utf8')` for reading and
+  # writing files here and elsewhere.
   txt = None
-  with open(fileName, "r") as f:
+  with io.open(fileName, 'r', encoding='utf8') as f:
 txt = f.read()
 
   txt = re.sub(sFrom, sTo, txt)
   print("Replacing '%s' -> '%s' in '%s'..." % (sFrom, sTo, fileName))
-  with open(fileName, "w") as f:
+  with io.open(fileName, 'w', encoding='utf8') as f:
 f.write(txt)
 
 
@@ -31,7 +36,7 @@
   if sFrom == sTo:
 return
   txt = None
-  with open(fileName, "r") as f:
+  with io.open(fileName, 'r', encoding='utf8') as f:
 txt = f.read()
 
   if sFrom not in txt:
@@ -39,7 +44,7 @@
 
   txt = txt.replace(sFrom, sTo)
   print("Replacing '%s' -> '%s' in '%s'..." % (sFrom, sTo, fileName))
-  with open(fileName, "w") as f:
+  with io.open(fileName, 'w', encoding='utf8') as f:
 f.write(txt)
 
 
@@ -70,7 +75,7 @@
 
 def deleteMatchingLines(fileName, pattern):
   lines = None
-  with open(fileName, "r") as f:
+  with io.open(fileName, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   not_matching_lines = [l for l in lines if not re.search(pattern, l)]
@@ -79,7 +84,7 @@
 
   print("Removing lines matching '%s' in '%s'..." % (pattern, fileName))
   print('  ' + '  '.join([l for l in lines if re.search(pattern, l)]))
-  with open(fileName, "w") as f:
+  with io.open(fileName, 'w', encoding='utf8') as f:
 f.writelines(not_matching_lines)
 
   return True
@@ -101,7 +106,7 @@
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   cpp_file = check_name_camel + '.cpp'
@@ -112,7 +117,7 @@
   return False
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with io.open(filename, 'wb', encoding='utf8') as f:
 cpp_found = False
 file_added = False
 for line in lines:
@@ -130,11 +135,11 @@
 def adapt_module(module_path, module, check_name, check_name_camel):
   modulecpp = next(filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp', os.listdir(module_path)))
   filename = os.path.join(module_path, modulecpp)
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with io.open(filename, 'wb', encoding='utf8') as f:
 header_added = False
 header_found = False
 check_added = False
@@ -169,7 +174,7 @@
 def add_release_notes(clang_tidy_path, old_check_name, new_check_name):
   filename = os.path.normpath(os.path.join(clang_tidy_path,
'../docs/ReleaseNotes.rst'))
-  with open(filename, 'r') as f:
+  with io.open(filename, 'r', encoding='utf8') as f:
 lines = f.readlines()
 
   lineMatcher = re.compile('Renamed checks')
@@ -177,7 +182,7 @@
   checkMatcher = re.compile('- The \'(.*)')
 
   print('Updating %s...' % filename)
-  with open(filename, 'wb') as f:
+  with io.open(filename, 'wb', encoding='utf8') as f:
 note_added = False
 header_found = False
 add_note_here = False
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -11,16 +11,21 @@
 from __future__ import print_function
 
 import argparse
+import io
 import os
 import re
 import sys
 
-
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
 def adapt_cmake(module_path, check_name_camel):
   filename = os.path.join(module_path, 'CMakeLists.txt')
-  with open(filename, 'r') as f:
+
+  # The documentation files are encoded using UTF-8, however on Windows 

[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2021-08-02 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko updated this revision to Diff 363418.

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

https://reviews.llvm.org/D91950

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6240,6 +6240,59 @@
 format(Input, Style));
 }
 
+TEST_F(FormatTest, BreakBeforeInlineASMColon) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Never;
+  /* Test the behaviour with long lines */
+  Style.ColumnLimit = 40;
+  verifyFormat("asm volatile(\"lng\",\n"
+   " : : val);",
+   Style);
+  verifyFormat("asm volatile(\"lng\",\n"
+   " : val1 : val2);",
+   Style);
+  verifyFormat("asm(\"movq\\t%%rbx, %%rsi\\n\\t\"\n"
+   "\"cpuid\\n\\t\"\n"
+   "\"xchgq\\t%%rbx %%rsi\\n\\t\",\n"
+   ": \"=a\" : \"a\");",
+   Style);
+  Style.ColumnLimit = 80;
+  verifyFormat("asm volatile(\"string\", : : val);", Style);
+  verifyFormat("asm volatile(\"string\", : val1 : val2);", Style);
+
+  Style.BreakBeforeInlineASMColon = FormatStyle::BBIAS_Always;
+  verifyFormat("asm volatile(\"string\",\n"
+   " :\n"
+   " : val);",
+   Style);
+  verifyFormat("asm volatile(\"string\",\n"
+   " : val1\n"
+   " : val2);",
+   Style);
+  /* Test the behaviour with long lines */
+  Style.ColumnLimit = 40;
+  verifyFormat("asm(\"movq\\t%%rbx, %%rsi\\n\\t\"\n"
+   "\"cpuid\\n\\t\"\n"
+   "\"xchgq\\t%%rbx, %%rsi\\n\\t\"\n"
+   ": \"=a\"(*rEAX)\n"
+   ": \"a\"(value));",
+   Style);
+  verifyFormat("asm(\"movq\\t%%rbx, %%rsi\\n\\t\"\n"
+   "\"cpuid\\n\\t\"\n"
+   "\"xchgq\\t%%rbx, %%rsi\\n\\t\"\n"
+   ":\n"
+   ": \"a\"(value));",
+   Style);
+  verifyFormat("asm volatile(\"lng\",\n"
+   " :\n"
+   " : val);",
+   Style);
+  verifyFormat("asm volatile(\"lng\",\n"
+   " : val1\n"
+   " : val2);",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3602,6 +3602,9 @@
   const FormatToken &Left = *Right.Previous;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
+  if (Line.startsWith(tok::kw_asm) && Right.is(TT_InlineASMColon) &&
+  Style.BreakBeforeInlineASMColon == FormatStyle::BBIAS_Always)
+return true;
 
   if (Style.isCSharp()) {
 if (Right.is(TT_CSharpNamedArgumentColon) ||
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -243,6 +243,16 @@
   }
 };
 
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO,
+  FormatStyle::BreakBeforeInlineASMColonStyle &Value) {
+IO.enumCase(Value, "Never", FormatStyle::BBIAS_Never);
+IO.enumCase(Value, "OnlyMultiline", FormatStyle::BBIAS_OnlyMultiline);
+IO.enumCase(Value, "Always", FormatStyle::BBIAS_Always);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits {
   static void
@@ -612,6 +622,9 @@
 Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon)
   Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
 
+IO.mapOptional("BreakBeforeInlineASMColon",
+   Style.BreakBeforeInlineASMColon);
+
 IO.mapOptional("BreakBeforeTernaryOperators",
Style.BreakBeforeTernaryOperators);
 
@@ -1006,6 +1019,7 @@
   LLVMStyle.BinPackParameters = true;
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeConceptDeclarations = true;
+  LLVMStyle.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
   LLVMStyle.BreakBeforeTernaryOperators = true;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
   LLVMStyle.BraceWrapping = {/*AfterCaseLabel=*/false,
Index: clang/lib/Format/ContinuationIndenter.cpp
===

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

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

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107163

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


[PATCH] D106924: [Preprocessor] -E -P: Ensure newline after 8 skipped lines.

2021-08-02 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

Bisecting shows that this commit causes

  $ echo foo | clang -E -P -
  
  foo

to emit a leading newline now.

That breaks e.g. LibreOffice's `configure`, which uses `echo __clang_version__ 
| clang -E -P -` to obtain the value of that macro, and expects a single line 
of output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106924

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


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

2021-08-02 Thread Romanov Vlad via Phabricator via cfe-commits
romanovvlad added a comment.

In D104601#2917065 , @Meinersbur 
wrote:

> Patch uploaded here: D107183 

The patch resolves the issue. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D107261: [clang] [MinGW] Let the last of -mconsole/-mwindows have effect

2021-08-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, mati865, jeremyd2019.
mstorsjo requested review of this revision.
Herald added a project: clang.

Don't just check for the existence of one, but check which one was
specified last, if any.

This fixes https://llvm.org/PR51296.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107261

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/mingw.cpp


Index: clang/test/Driver/mingw.cpp
===
--- clang/test/Driver/mingw.cpp
+++ clang/test/Driver/mingw.cpp
@@ -61,3 +61,10 @@
 // RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck 
-check-prefix=CHECK_MINGW_UNICODE %s
 // CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
 // CHECK_MINGW_UNICODE: "-DUNICODE"
+
+// RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_NO_SUBSYS %s
+// RUN: %clang -target i686-windows-gnu -### %s -mwindows -mconsole 2>&1 | 
FileCheck -check-prefix=CHECK_SUBSYS_CONSOLE %s
+// RUN: %clang -target i686-windows-gnu -### %s -mconsole -mwindows 2>&1 | 
FileCheck -check-prefix=CHECK_SUBSYS_WINDOWS %s
+// CHECK_NO_SUBSYS-NOT: "--subsystem"
+// CHECK_SUBSYS_CONSOLE: "--subsystem" "console"
+// CHECK_SUBSYS_WINDOWS: "--subsystem" "windows"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -136,10 +136,13 @@
 llvm_unreachable("Unsupported target architecture.");
   }
 
-  if (Args.hasArg(options::OPT_mwindows)) {
+  Arg *SubsysArg =
+  Args.getLastArg(options::OPT_mwindows, options::OPT_mconsole);
+  if (SubsysArg && SubsysArg->getOption().matches(options::OPT_mwindows)) {
 CmdArgs.push_back("--subsystem");
 CmdArgs.push_back("windows");
-  } else if (Args.hasArg(options::OPT_mconsole)) {
+  } else if (SubsysArg &&
+ SubsysArg->getOption().matches(options::OPT_mconsole)) {
 CmdArgs.push_back("--subsystem");
 CmdArgs.push_back("console");
   }


Index: clang/test/Driver/mingw.cpp
===
--- clang/test/Driver/mingw.cpp
+++ clang/test/Driver/mingw.cpp
@@ -61,3 +61,10 @@
 // RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UNICODE %s
 // CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE"
 // CHECK_MINGW_UNICODE: "-DUNICODE"
+
+// RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_NO_SUBSYS %s
+// RUN: %clang -target i686-windows-gnu -### %s -mwindows -mconsole 2>&1 | FileCheck -check-prefix=CHECK_SUBSYS_CONSOLE %s
+// RUN: %clang -target i686-windows-gnu -### %s -mconsole -mwindows 2>&1 | FileCheck -check-prefix=CHECK_SUBSYS_WINDOWS %s
+// CHECK_NO_SUBSYS-NOT: "--subsystem"
+// CHECK_SUBSYS_CONSOLE: "--subsystem" "console"
+// CHECK_SUBSYS_WINDOWS: "--subsystem" "windows"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -136,10 +136,13 @@
 llvm_unreachable("Unsupported target architecture.");
   }
 
-  if (Args.hasArg(options::OPT_mwindows)) {
+  Arg *SubsysArg =
+  Args.getLastArg(options::OPT_mwindows, options::OPT_mconsole);
+  if (SubsysArg && SubsysArg->getOption().matches(options::OPT_mwindows)) {
 CmdArgs.push_back("--subsystem");
 CmdArgs.push_back("windows");
-  } else if (Args.hasArg(options::OPT_mconsole)) {
+  } else if (SubsysArg &&
+ SubsysArg->getOption().matches(options::OPT_mconsole)) {
 CmdArgs.push_back("--subsystem");
 CmdArgs.push_back("console");
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-02 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104854

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


[PATCH] D105881: [flang][driver] Switch to `BoolFOption` for boolean options

2021-08-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D105881#2906955 , @awarzynski 
wrote:

> OK, that's fair enough. But what about the output from `clang --help` and 
> `clang -cc1 --help`? Let's look at -feliminate-unused-debug-types 
> 
>  (the only instance of `OptOutFFLag`):
>
>   # Only -fno-eliminate-unusued-debug-types is printed
>   clang -cc1 --help | grep eliminate-unused
> -fno-eliminate-unused-debug-types
>   # Both -fno-eliminate-unusued-debug-types and 
> -feliminate-unusued-debug-types printed?
>   clang --help | grep eliminate-unused
> -feliminate-unused-debug-types
> -fno-eliminate-unused-debug-types
>
> To me this behavior is counter-intuitive. So are these `clang` options? 
> `clang -cc1` options? Both? What's the point of adding `CC1Option` if both 
> `clang` and `clang -cc1` accept them. The definition of `CC1Option` from 
> Options.td:
>
>   // CC1Option - This option should be accepted by clang -cc1.
>   def CC1Option : OptionFlag;
>
> OK, so currently `-fno-eliminate-unused-debug-types` is a `CC1Option` and 
> _should_ be accepted by `clang -cc1`. How about 
> `-feliminate-unused-debug-types`?
>
>   clang -cc1 -feliminate-unused-debug-types file.c
>   error: unknown argument: '-feliminate-unused-debug-types'
>
> Makes sense, but:
>
>   clang -c -feliminate-unused-debug-types file.c
>   clang-13: warning: argument unused during compilation: 
> '-feliminate-unused-debug-types' [-Wunused-command-line-argument]
>
> Shouldn't it be rejected by `clang` with an error as well? Shouldn't 
> `CC1Option` be used consistently for `-feliminate-unused-debug-types`  and 
> `-fno-eliminate-unused-debug-types`?
>
>>> In fact, only the contents of `clang -cc1 --help` are being tweaked by 
>>> using `OptInFFlag/OptOutFFlag`.
>>
>> That's incorrect, `OptInFFlag` and `OptOutFFlag` both set `HelpText` for the 
>> positive and negative driver flags.
>
> Yes, but in `clang --cc1 --help`, only the variant with `CC1Option` is being 
> printed and the other one is ignored. So why bother adding the other one?
>
> Btw, now I see that `-cc1` does reject `-feliminate-unused-debug-types`, so 
> it's not only about the contents of `clang -cc1 --help`. I was wrong, sorry 
> about that and thanks for pointing this out!

The `clang` driver always accepts both the positive and negative options, and 
it always only considers the argument that appeared last on the command-line 
(using `ArgList::getLastArg(Pos, Neg)`). This allows users to take a random 
`clang` driver command-line, append `-feliminate-unused-debug-types` and get 
the desired behavior, even though the original command-line might have 
contained `-fno-eliminate-unused-debug-types`.

For the pair of options you mentioned, the `clang` driver knows they are 
"opt-out" in `clang -cc1`. The behavior is enabled by default in `-cc1` and can 
be disabled/opted-out through the negative `-fno-eliminate-unused-debug-types`. 
The positive option is **not** accepted by `clang -cc1`, since explicitly 
enabling a behavior that's already enabled by default is redundant.

If driver sees `-fno-eliminate-unused-debug-types` as the last option, it will 
forward it to `clang -cc1`. If it sees `-feliminate-unused-debug-types`, it 
will ignore it.

Does this make sense?

If neither the positive nor negative options have `CC1Option`, they are 
driver-only options. If you add `CC1Option` to both, both are accepted by 
`clang -cc1`. But the most common scenario is that only one of the two options 
is marked with `CC1Option`.

The `HelpText` doesn't play a role in option being accepted or not in `clang` 
or `clang -cc1`.

> **Content of `--help`**
>
>>> In Flang, we rely on the fact that "no help text? don't include it in 
>>> `flang-new -fc1 --help`" instead. This behavior is implemented in 
>>> `clangDriver` and applies to all drivers that use it (so this is nothing 
>>> specific to Flang).
>>
>> I see. Is this intentional?
>>
>>> This way, we can always mark Flang options with the relevant flags (e.g. 
>>> `FC1Option`). In other words, we can claim them and make it clear that 
>>> other drivers can ignore them.
>>
>> I don't understand this. Can you elaborate? Are you relying on the 
>> absence/presence of a help text to mark flags with `FC1Option`? When does 
>> this happen? (In `Options.td`? The TableGen backend? The consumer of 
>> `Options.inc`?)
>
> See the implementation of printHelp 
> 
>  from OptTable.cpp. Basically: "No help text? Not printing". We rely on this 
> **not to print** options supported by Flang, but for which we have no help 
> text. We only used that for boolean options (so we have a help text for e.g. 
> `-ffoo`, but not for `-fno-foo`). This is a minor thing and I a

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

2021-08-02 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler updated this revision to Diff 363442.
ckandeler added a comment.

Addressed lint comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107137

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


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


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

[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2021-08-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:1022
   LLVMStyle.BreakBeforeConceptDeclarations = true;
+  LLVMStyle.BreakBeforeInlineASMColon = FormatStyle::BBIAS_OnlyMultiline;
   LLVMStyle.BreakBeforeTernaryOperators = true;

Are we happy that is the correct default? didn't it always break before?


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

https://reviews.llvm.org/D91950

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


[clang] 9988ab3 - [clang][NFC] Typo fixes. Test commit.

2021-08-02 Thread Justas Janickas via cfe-commits
Author: Justas Janickas
Date: 2021-08-02T13:25:08+01:00
New Revision: 9988ab3989a2e2e9cde3cc1ab4d7a44a87dee393

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

LOG: [clang][NFC] Typo fixes. Test commit.

Fixed spelling of word "whether"

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4c63781660fbe..d3736311d5662 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -16013,7 +16013,7 @@ static bool isLayoutCompatible(ASTContext &C, QualType 
T1, QualType T2) {
 ///
 /// \param MagicValue Type tag magic value.
 ///
-/// \param isConstantEvaluated wether the evalaution should be performed in
+/// \param isConstantEvaluated whether the evalaution should be performed in
 
 /// constant context.
 static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx,
@@ -16093,7 +16093,7 @@ static bool FindTypeTagExpr(const Expr *TypeExpr, const 
ASTContext &Ctx,
 ///
 /// \param TypeInfo Information about the corresponding C type.
 ///
-/// \param isConstantEvaluated wether the evalaution should be performed in
+/// \param isConstantEvaluated whether the evalaution should be performed in
 /// constant context.
 ///
 /// \returns true if the corresponding C type was found.



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


[PATCH] D107267: [clang-format] don't break between function and function name in JS

2021-08-02 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The commit
https://github.com/llvm/llvm-project/commit/58494c856a15f5b0e886c7baf5d505ac6c05dfe5
updated detection of function declaration names. It had the unfortunate
consequence that it started breaking between `function` and the function
name in some cases in JavaScript code.

This patch addresses this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107267

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -692,6 +692,13 @@
"  let x = 1;\n"
"  console.log(x);\n"
"}\n");
+  EXPECT_EQ("a = function(x) {}\n"
+"\n"
+"function f(x) {}",
+format("a = function(x) {}\n"
+   "\n"
+   "function f(x) {}",
+   getGoogleJSStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestJS, GeneratorFunctions) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -495,7 +495,10 @@
   if (((Current.is(TT_FunctionDeclarationName) &&
 // Don't break before a C# function when no break after return type
 (!Style.isCSharp() ||
- Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None)) ||
+ Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None) &&
+// Don't always break between a JavaScript `function` and the function
+// name.
+Style.Language != FormatStyle::LK_JavaScript) ||
(Current.is(tok::kw_operator) && !Previous.is(tok::coloncolon))) &&
   !Previous.is(tok::kw_template) && 
State.Stack.back().BreakBeforeParameter)
 return true;


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -692,6 +692,13 @@
"  let x = 1;\n"
"  console.log(x);\n"
"}\n");
+  EXPECT_EQ("a = function(x) {}\n"
+"\n"
+"function f(x) {}",
+format("a = function(x) {}\n"
+   "\n"
+   "function f(x) {}",
+   getGoogleJSStyleWithColumns(20)));
 }
 
 TEST_F(FormatTestJS, GeneratorFunctions) {
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -495,7 +495,10 @@
   if (((Current.is(TT_FunctionDeclarationName) &&
 // Don't break before a C# function when no break after return type
 (!Style.isCSharp() ||
- Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None)) ||
+ Style.AlwaysBreakAfterReturnType != FormatStyle::RTBS_None) &&
+// Don't always break between a JavaScript `function` and the function
+// name.
+Style.Language != FormatStyle::LK_JavaScript) ||
(Current.is(tok::kw_operator) && !Previous.is(tok::coloncolon))) &&
   !Previous.is(tok::kw_template) && State.Stack.back().BreakBeforeParameter)
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D107125#2917668 , @lunasorcery 
wrote:

> Sure thing - would the suite in /clang/test/SemaCXX/ be the right place to 
> put that?

Yeah, that'd be a great place for it. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107125

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


[PATCH] D107073: [analyzer] Disable direct binding from list initialization for constant arrays of local storage duration.

2021-08-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 363454.
ASDenysPetrov added a comment.

Fixed clang-tidy complaints.


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

https://reviews.llvm.org/D107073

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/initialization.c
  clang/test/Analysis/initialization.cpp

Index: clang/test/Analysis/initialization.cpp
===
--- clang/test/Analysis/initialization.cpp
+++ clang/test/Analysis/initialization.cpp
@@ -167,7 +167,7 @@
   clang_analyzer_eval(glob_arr3[3][1] == 0); // expected-warning{{TRUE}}
 }
 
-void negative_index1() {
+void glob_arr_negative_index1() {
   int x = 2, y = -2;
   clang_analyzer_eval(glob_arr3[x][y] == 3); // expected-warning{{TRUE}}
   x = 4;
@@ -175,12 +175,12 @@
   clang_analyzer_eval(glob_arr3[x][y] == 7); // expected-warning{{TRUE}}
 }
 
-void out_of_bound_index1() {
+void glob_arr_out_of_bound_index1() {
   int x = -3, y = 2;
   int res = glob_arr3[x][y]; // expected-warning{{garbage or undefined}}
 }
 
-void out_of_bound_index2() {
+void glob_arr_out_of_bound_index2() {
   int x = 3, y = 2;
   int res = glob_arr3[x][y]; // expected-warning{{garbage or undefined}}
 }
@@ -197,12 +197,101 @@
   clang_analyzer_eval(glob_arr4[7] == 0); // expected-warning{{TRUE}}
 }
 
-void out_of_bound_index3() {
+void glob_arr_out_of_bound_index3() {
   int x = -42;
   int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
 }
 
-void out_of_bound_index4() {
+void glob_arr_out_of_bound_index4() {
   int x = 42;
   int res = glob_arr4[x]; // expected-warning{{garbage or undefined}}
 }
+
+void local_arr_index1() {
+  const int local_arr[2][2][3] = {{{1, 2}}, {{7}}};
+  clang_analyzer_eval(local_arr[0][0][0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][0][1] == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][0][2] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1][2] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0][0] == 7); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0][2] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1][2] == 0); // expected-warning{{TRUE}}
+}
+
+void local_arr_index2() {
+  int const local_arr[2][2][3] = {{{1, 2}, {}}, {{7, 8}, {10, 11, 12}}};
+  clang_analyzer_eval(local_arr[0][0][0] == 1);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][0][1] == 2);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][0][2] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1][0] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1][1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1][2] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0][0] == 7);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0][1] == 8);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0][2] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1][0] == 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1][1] == 11); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1][2] == 12); // expected-warning{{TRUE}}
+}
+
+void local_arr_index3() {
+  const int local_arr[4][2] = {{}, {3}, {}, {7}};
+  clang_analyzer_eval(local_arr[0][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[0][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][0] == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[1][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[2][0] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[2][1] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[3][0] == 7); // expected-warning{{TRUE}}
+  clang_analyzer_eval(local_arr[3][1] == 0); // expected-warning{{TRUE}}
+}
+
+void local_arr_negative_index1() {
+  const int local_arr[4][2] = {{}, {3}, {}, {7}};
+  int x = 2, y = -2;
+  clang_analyzer_eval(local_arr[x][y] == 3); // expected-warning{{TRUE}}
+  x = 4;
+  y = -2;
+  clang_analyzer_eval(local_arr[x][y] == 7); // expected-warning{{TRUE}}
+}
+
+void local_arr_out_of_bound_index1() {
+  const int local_arr[4][2] = {{}, {3}, {}, {7}};
+  int x = -3, y = 2;
+  int res = local_arr[x][y]; // expected-warning{{garbage or undefined}}
+}
+
+void local_arr_out_of_bound_index2() {
+  const int local_arr[4][2] = {{}, {3}, {}, {7}};
+  int x = 3, y = 2;
+  int res

[PATCH] D107269: [clan-format] detect function definitions more conservatively

2021-08-02 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

https://reviews.llvm.org/D105964 updated the detection of function
definitions. It had the unfortunate effect to start marking object
definitions with attribute-like macros as function definitions.

This addresses this issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107269

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8235,6 +8235,11 @@
"  return a + b < c;\n"
"}",
Style);
+  // The return breaking style doesn't affect object definitions with
+  // attribute-like macros.
+  verifyFormat("Tttt ppp\n"
+   "ABSL_GUARDED_BY(mutex) = {};",
+   getGoogleStyleWithColumns(40));
 
   Style = getGNUStyle();
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2482,7 +2482,8 @@
   // return i + 1;
   //   }
   if (Next->Next && Next->Next->is(tok::identifier) &&
-  !(Next->MatchingParen->Next && Next->MatchingParen->Next->is(tok::semi)))
+  (!Next->MatchingParen->Next ||
+   Next->MatchingParen->Next->is(tok::l_brace)))
 return true;
   for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
Tok = Tok->Next) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8235,6 +8235,11 @@
"  return a + b < c;\n"
"}",
Style);
+  // The return breaking style doesn't affect object definitions with
+  // attribute-like macros.
+  verifyFormat("Tttt ppp\n"
+   "ABSL_GUARDED_BY(mutex) = {};",
+   getGoogleStyleWithColumns(40));
 
   Style = getGNUStyle();
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2482,7 +2482,8 @@
   // return i + 1;
   //   }
   if (Next->Next && Next->Next->is(tok::identifier) &&
-  !(Next->MatchingParen->Next && Next->MatchingParen->Next->is(tok::semi)))
+  (!Next->MatchingParen->Next ||
+   Next->MatchingParen->Next->is(tok::l_brace)))
 return true;
   for (const FormatToken *Tok = Next->Next; Tok && Tok != Next->MatchingParen;
Tok = Tok->Next) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b13fc73 - [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL mode.

2021-08-02 Thread Justas Janickas via cfe-commits
Author: Justas Janickas
Date: 2021-08-02T14:10:15+01:00
New Revision: b13fc7311eabca27b3baea99b7be6edef0213406

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

LOG: [OpenCL] __cpp_threadsafe_static_init is by default undefined in OpenCL 
mode.

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

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

Fixes llvm.org/PR48012

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

Added: 
clang/test/Driver/threadsafe-statics.clcpp

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e13302528cbd1..7042bf5fc9e2a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6192,7 +6192,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   // than 19.
   if (!Args.hasFlag(options::OPT_fthreadsafe_statics,
 options::OPT_fno_threadsafe_statics,
-!IsWindowsMSVC || IsMSVC2015Compatible))
+!types::isOpenCL(InputType) &&
+(!IsWindowsMSVC || IsMSVC2015Compatible)))
 CmdArgs.push_back("-fno-threadsafe-statics");
 
   // -fno-delayed-template-parsing is default, except when targeting MSVC.

diff  --git a/clang/test/Driver/threadsafe-statics.clcpp 
b/clang/test/Driver/threadsafe-statics.clcpp
new file mode 100644
index 0..3e71293e7ce7e
--- /dev/null
+++ b/clang/test/Driver/threadsafe-statics.clcpp
@@ -0,0 +1,11 @@
+// RUN: %clang -### -c -DNO_THREADSAFE_STATICS %s 2>&1 | FileCheck 
--check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+// RUN: %clang -### -fno-threadsafe-statics -DNO_THREADSAFE_STATICS -c %s 2>&1 
| FileCheck --check-prefix=CHECK-NO-THREADSAFE-STATICS %s
+
+// CHECK-NO-THREADSAFE-STATICS: "-cc1"
+// CHECK-NO-THREADSAFE-STATICS: "-fno-threadsafe-statics"
+// CHECK-NO-THREADSAFE-STATICS-NOT: "-fthreadsafe-statics"
+
+// RUN: %clang -### -fthreadsafe-statics -DTHREADSAFE_STATICS -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-THREADSAFE-STATICS %s
+
+// CHECK-THREADSAFE-STATICS: "-cc1"
+// CHECK-THREADSAFE-STATICS-NOT: "-fno-threadsafe-statics"



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


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

2021-08-02 Thread Justas Janickas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Topotuna marked an inline comment as done.
Closed by commit rGb13fc7311eab: [OpenCL] __cpp_threadsafe_static_init is by 
default undefined in OpenCL mode. (authored by Topotuna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107163

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


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


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


[clang] 12dc13b - prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

2021-08-02 Thread Hans Wennborg via cfe-commits
Author: Hans Wennborg
Date: 2021-08-02T15:16:04+02:00
New Revision: 12dc13b73cf8c11da1bcc354c78bd6a9c92408e8

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

LOG: prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

For some reason, Microsoft declares _m_prefetch to take a const void*,
but _m_prefetchw to take a /volatile/ const void*.

Do the same for compatibility.

Differential revision: https://reviews.llvm.org/D106790

Added: 


Modified: 
clang/lib/Headers/prfchwintrin.h

Removed: 




diff  --git a/clang/lib/Headers/prfchwintrin.h 
b/clang/lib/Headers/prfchwintrin.h
index 6e8a4ef2ec971..d2f91aa0123e0 100644
--- a/clang/lib/Headers/prfchwintrin.h
+++ b/clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@ _m_prefetch(void *__P)
 /// \param __P
 ///A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */



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


[PATCH] D106790: prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

2021-08-02 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG12dc13b73cf8: prfchwintrin.h: Make _m_prefetchw take a 
pointer to volatile (PR49124) (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106790

Files:
  clang/lib/Headers/prfchwintrin.h


Index: clang/lib/Headers/prfchwintrin.h
===
--- clang/lib/Headers/prfchwintrin.h
+++ clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@
 /// \param __P
 ///A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */


Index: clang/lib/Headers/prfchwintrin.h
===
--- clang/lib/Headers/prfchwintrin.h
+++ clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@
 /// \param __P
 ///A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107231: [clang-repl] Fix building with win32 dylibs

2021-08-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

@mstorsjo Yes, go ahead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107231

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


[PATCH] D99353: [driver] Make `clang` warn rather then error on `flang` options

2021-08-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

This is something we could merge, just need a code owner ack.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99353

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


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

2021-08-02 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

Do we have all the issues fixed in trunk yet or do we need to revert in the 
release/13.x branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


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

2021-08-02 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes accepted this revision.
c-rhodes added a comment.
This revision is now accepted and ready to land.

thanks @bsmith, just left one minor nit but otherwise LGTM




Comment at: clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c:10
 typedef svint32_t fixed_int32_t __attribute__((arm_sve_vector_bits(N)));
+typedef svint64_t fixed_int64_t __attribute__((arm_sve_vector_bits(N)));
 typedef svfloat64_t fixed_float64_t __attribute__((arm_sve_vector_bits(N)));

nit: unused?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106860

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


[PATCH] D107082: [X86][RFC] Enable `_Float16` type support on X86 following the psABI

2021-08-02 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

After the last refactor, I think this patch is mostly ready.
This patch strips most of the ABI and _Float16 type related code from D105263 
, which can be leaving with only AVX512-FP16 
ISA enabling code.
I think it should be more friendly for review. The defect is we make all FP16 
enabling patches depend on and been blocked by this one. So I hope we could 
have a quick review and land it earlier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107082

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


[PATCH] D107275: [Sema] a[x] has type T when a has type T* or T[], even when T is dependent

2021-08-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: kadircet, rsmith.
Herald added a subscriber: usaxena95.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This more precise type is useful for tools, e.g.
fixes https://github.com/clangd/clangd/issues/831


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107275

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-array.cpp


Index: clang/test/AST/ast-dump-array.cpp
===
--- clang/test/AST/ast-dump-array.cpp
+++ clang/test/AST/ast-dump-array.cpp
@@ -25,3 +25,32 @@
   // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent   

 };
 
+template 
+void testDependentSubscript() {
+  U* a;
+  U b[5];
+  Idx i{};
+
+  // Can types of subscript expressions can be determined?
+  // LHS is a type-dependent array
+  a[1];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+  b[1];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+
+  // LHS is a type-dependent array, RHS is type-dependent.
+  a[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+  b[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+
+  struct V;
+  V *a2;
+  V b2[5];
+
+  // LHS is a known array, RHS is type-dependent.
+  a2[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'V' lvalue
+  b2[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'V' lvalue
+};
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4785,8 +4785,17 @@
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus &&
   (base->isTypeDependent() || idx->isTypeDependent())) {
-return new (Context) ArraySubscriptExpr(base, idx, Context.DependentTy,
-VK_LValue, OK_Ordinary, rbLoc);
+QualType Type = Context.DependentTy;
+// Refine type if LHS is an array or pointer.
+// This is safe because overloading is not possible in this case, and
+// arrays/pointers can't be the index of of a builtin subscript.
+// Don't bother for RHS, that case is very rare.
+if (const PointerType *PT = base->getType()->getAs())
+  Type = PT->getPointeeType();
+else if (const ArrayType *AT = base->getType()->getAsArrayTypeUnsafe())
+  Type = AT->getElementType();
+return new (Context)
+ArraySubscriptExpr(base, idx, Type, VK_LValue, OK_Ordinary, rbLoc);
   }
 
   // MSDN, property (C++)
@@ -5541,6 +5550,13 @@
 BaseExpr = LHSExp;
 IndexExpr = RHSExp;
 ResultType = Context.DependentTy;
+// One of LHS and RHS must be pointer, the other must be array.
+// We don't know in general, but determine a more specific type if we can.
+// Don't bother for the uncommon case where the index is on the left.
+if (const PointerType *PT = LHSTy->getAs())
+  ResultType = PT->getPointeeType();
+else if (const ArrayType *AT = LHSTy->getAsArrayTypeUnsafe())
+  ResultType = AT->getElementType();
   } else if (const PointerType *PTy = LHSTy->getAs()) {
 BaseExpr = LHSExp;
 IndexExpr = RHSExp;


Index: clang/test/AST/ast-dump-array.cpp
===
--- clang/test/AST/ast-dump-array.cpp
+++ clang/test/AST/ast-dump-array.cpp
@@ -25,3 +25,32 @@
   // CHECK: `-DependentSizedArrayType 0x{{[^ ]*}} 'T [Size]' dependent   
 };
 
+template 
+void testDependentSubscript() {
+  U* a;
+  U b[5];
+  Idx i{};
+
+  // Can types of subscript expressions can be determined?
+  // LHS is a type-dependent array
+  a[1];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+  b[1];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+
+  // LHS is a type-dependent array, RHS is type-dependent.
+  a[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+  b[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'U' lvalue
+
+  struct V;
+  V *a2;
+  V b2[5];
+
+  // LHS is a known array, RHS is type-dependent.
+  a2[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'V' lvalue
+  b2[i];
+  // CHECK: ArraySubscriptExpr {{.*}} 'V' lvalue
+};
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4785,8 +4785,17 @@
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus &&
   (base->isTypeDependent() || idx->isTypeDependent())) {
-return new (Context) ArraySubscriptExpr(base, idx, Context.DependentTy,
-VK_LValue, OK_Ordinary, rbLoc);
+QualType Type = Context.DependentTy;
+// Refine type if LHS is an array or pointer.
+// This is safe because overloading is not possible in this case, and
+// arrays/pointers can't be the index of of a builtin subscript.
+// Don't 

[PATCH] D107275: [Sema] a[x] has type T when a has type T* or T[], even when T is dependent

2021-08-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

@rsmith: we have two open questions here...

---

1: Expressions whose types are no longer dependent.

In the rare case where RHS is type-dependent and LHS is a known pointer, e.g.

  template 
  int access(int *arr, Idx i) {
return arr[i];
  }

we're now changing the ArraySubscriptExpr's type from DependentTy to int, while 
keeping the expr type-dependent.

Is this OK, or should we avoid it by artificially requiring LHS specifically to 
be type-dependent to do the refinement?

---

2: LHS vs RHS symmetry.

We only bother to check if **LHS** is a pointer, so 
`type_dependent_pointer[integer]` gets a specific dependent type, while the 
obscure `integer[type_dependent_pointer]` remains DependentTy.

Is this OK, or must we handle the rare case in the same way?

---

Functionally, doing the "safe" thing in both cases seems fine. But I don't want 
to spray unnecessary defensive code around, for maintenance reasons.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107275

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


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

2021-08-02 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Headers/openmp_wrappers/math.h:53
+#pragma omp begin declare variant match(device = {arch(amdgcn)})
+
+#define __OPENMP_AMDGCN__

That's quite worrying. Declare variant match amdgcn is supposed to have the 
same effect here as the older style macro. I wonder if we have any test 
coverage for whether declare variant works for amdgcn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


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

2021-08-02 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei added a comment.

@jyu2, Thanks for the detailed information.

> Besides, if we change "=rm" to "=r"
> or "=m", GCC and ICC will report error differently. Which gives me an
> impression that the use of constraint is undefined behavior.
> To me it is defined behavior. Or I may missing some thing here.

Sorry, I didn't describe it clearly. I meant it's ub when they are used 
together with structure type. E.g., https://godbolt.org/z/ssY5K4xEP
As you can see, when we use "=rm", GCC and ICC happen to work, that's because 
GCC only allows the structure to be passed on register with ICC only allows 
memory. I didn't find a document which describes the relationships between 
structure and its output constraint.
Besides, https://godbolt.org/z/5ex9x3dvv shows GCC and ICC have some rules when 
we passing a structure (Adding one more element in the exapmles will fail on 
both GCC and ICC). I didn't find the document either.

> code doesn't make much sense to me.

This patch doesn't change any functionality of Clang. We just adding more sema 
checks to avoid the ugly crash. This is required from our user.
I believe we can do more things to march the behavior of GCC and ICC. I have 
added a FIXME in the code. Considering we don't have a clear document and such 
a case is in rare. And we don't have such requirment from user. I think this 
patch is till better than none.
Does it make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107141

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


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

2021-08-02 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.

Latest patch can only misfire on amdgpu so lets go with it and try to work out 
variant vs ifdef subsequently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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


[clang] 713a5d1 - [OpenMP][AMDGCN] Initial math headers support

2021-08-02 Thread Pushpinder Singh via cfe-commits
Author: Pushpinder Singh
Date: 2021-08-02T14:38:52Z
New Revision: 713a5d12cde58a5dff90cc3e2d1e67c2a78fe52f

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

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

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

Reviewed By: JonChesterfield, jdoerfert, scchan

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

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

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

Removed: 




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

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

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

2021-08-02 Thread Pushpinder Singh via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG713a5d12cde5: [OpenMP][AMDGCN] Initial math headers support 
(authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104904

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

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

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1839-1840
   StringRef getString() const {
-assert(getCharByteWidth() == 1 &&
-   "This function is used in places that assume strings use char");
+assert(isUnevaluated() ||
+   getCharByteWidth() == 1 &&
+   "This function is used in places that assume strings use char");

This should silence some diagnostics about mixed && and || in the same 
expression.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:248
+def err_unevaluated_string_udl : Error<
+  "an unevaluated string literal cannot be a user defined literal">;
+def err_unevaluated_string_invalid_escape_sequence : Error<





Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:250
+def err_unevaluated_string_invalid_escape_sequence : Error<
+  "Invalid escape sequence '%0' in an unevaluated string literal">;
 def err_string_concat_mixed_suffix : Error<





Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:59-60
+
+def err_expected_unevaluated_string : Error<
+  "expected a string literal!">;
+

No need for this diagnostic,  you can use `err_expected_string_literal` from 
DiagnosticCommonKinds.td instead.



Comment at: clang/include/clang/Lex/LiteralSupport.h:220
   tok::TokenKind Kind;
+  SmallString<512> UnevaluatedBuf;
   SmallString<512> ResultBuf;

This seems to be unused.



Comment at: clang/include/clang/Lex/LiteralSupport.h:235
   MaxTokenLength(0), SizeBound(0), CharByteWidth(0), Kind(tok::unknown),
   ResultPtr(ResultBuf.data()), hadError(false), Pascal(false) {
 init(StringToks);

Alternatively, you could use an in-class initializer and drop the changes to 
both ctor init lists.



Comment at: clang/lib/AST/Expr.cpp:1076
+
   unsigned ByteLength = Str.size();
+  unsigned Length = ByteLength;

Basically unused and is shadowed by a declaration below (on line 1087).



Comment at: clang/lib/AST/Expr.cpp:1157-1158
   switch (getKind()) {
+  case Unevaluated:
+break;   // no prefic
   case Ascii: break; // no prefix.





Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?



Comment at: clang/lib/Lex/LiteralSupport.cpp:242
+ diag::err_unevaluated_string_invalid_escape_sequence)
+<< std::string(1, EscapeBegin[1]);
+  }





Comment at: clang/lib/Lex/LiteralSupport.cpp:1539
 
-  // Implement Translation Phase #6: concatenation of string literals
+  // Determines the kind of string from the prefix
+  Kind = tok::string_literal;





Comment at: clang/lib/Lex/LiteralSupport.cpp:1541
+  Kind = tok::string_literal;
+  for (const auto &Tok : StringToks) {
+// Unevaluated string literals can never have a prefix

This means we're looping over (almost) all the string tokens three times -- 
once here, once below on line 1562, and again on 1605.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1542
+  for (const auto &Tok : StringToks) {
+// Unevaluated string literals can never have a prefix
+if (Unevaluated && Tok.getKind() != tok::string_literal) {





Comment at: clang/lib/Lex/LiteralSupport.cpp:1545
+  if (Diags)
+Diags->Report(Tok.getLocation(), diag::err_unevaluated_string_prefix);
+  hadError = true;

This diagnostic might be somewhat odd for Pascal strings because those sort of 
have a prefix but it's not really the kind of prefix we're talking about. I 
don't know of a better way to word the diagnostic though. If you think of a way 
to improve it, then yay, but otherwise, I think it's fine as-is.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1963
+FullSourceLoc(Tok.getLocation(), SM), CharByteWidth * 
8,
+Diags, Features, false);
   --ByteNo;





Comment at: clang/lib/Parse/ParseDecl.cpp:422-423
 
-ExprResult ArgExpr(
-Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
+ExprResult ArgExpr(Actions.CorrectDelayedTyposInExpr(
+ParseAttributeArgAsUnevaluatedLiteralOrExpression(AttrKind)));
 if (ArgExpr.isInvalid()) {

Hmmm, I'm not certain about these changes.

For some attributes, the standard currently requires accepting any kind of 
string literal (like `[[deprecated]]` 
https://eel.is/c++draft/dcl.attr.deprecated#1). P2361 is proposing to change 
that, but it's not yet accepted by WG21 (l

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

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

> No matter what happens during analysis, as of now, the NoteTag message is 
> unambiguous at the point of the tags construction.

The stream error state is designed to store a "superposition" of different 
error states. This is part of `evalFseek`:

  StateFailed = StateFailed->set(
  StreamSym,
  StreamState::getOpened(Desc, ErrorNone | ErrorFEof | ErrorFError, true));
  C.addTransition(StateFailed,
  constructNoteTag(C, StreamSym,
   {&BT_StreamEof, &BT_IndeterminatePosition}));

The code above means the same as this code:

  StateFailedFEof = StateFailed->set(
  StreamSym,
  StreamState::getOpened(Desc, ErrorFEof, false));
  C.addTransition(StateFailedFEof, constructNoteTag(C, StreamSym, 
{&BT_StreamEof}));
  
  StateFailedFErrorIndeterminate = StateFailed->set(
  StreamSym,
  StreamState::getOpened(Desc, ErrorFError, true));
  C.addTransition(StateFailedFErrorIndeterminate, constructNoteTag(C, 
StreamSym, {&BT_IndeterminatePosition}));
  
  StateFailedIndeterminate = StateFailed->set(
  StreamSym,
  StreamState::getOpened(Desc, ErrorNone, true));
  C.addTransition(StateFailedIndeterminate, constructNoteTag(C, StreamSym, 
{&BT_IndeterminatePosition}));

In this code the NoteTag message is unambiguous. The code above is a 
"compression" of this and at the construction of the NoteTag message is in 
"superposition" state too (like the error state that determines the message).

`freopen` is a different case: At failure it returns a NULL pointer and the 
stream becomes in an invalid state. But if the return value of `freopen` is not 
assigned to it, the stream pointer is not set to NULL:

- `F = freopen(0, "w", F);` F will be NULL at failure, this makes a bug with 
`BT_FileNull` bug type.
- `freopen(0, "w", F);` F becomes invalid but not NULL, if used then a 
`BT_UseAfterOpenFailed` bug is detected (this is the only case for this bug 
type).

At failure of `freopen` we can not tell which case will occur later (it depends 
on the analyzed code). (It may be possible to have only one bug for these cases 
but a differentation is needed to tell the user if a file was NULL or invalid 
but not NULL.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


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

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

> Do we ever intend to create a warning for FERROR?

Probably not (but there may be some not yet modeled stream operation where this 
may be useful.). This is when FERROR is set but not the indeterminate position. 
It indicates that the last operation failed but it is OK to use the stream. But 
this can be a "ErrorReturn" checker problem (a failed operation was not 
observed by the program).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


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

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

> Will there ever be a way to get rid of the indeterminate position indicator 
> tag?

Currently the `fseek` can reset this flag, and the `freopen` is another case 
for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106262

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


[PATCH] D107267: [clang-format] don't break between function and function name in JS

2021-08-02 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay 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/D107267/new/

https://reviews.llvm.org/D107267

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


[PATCH] D106614: [Clang] add btf_tag attribute

2021-08-02 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 363480.
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

address Aaron and Andrii's comments:

- warned and ignored if a btf_tag attribute is added to record forward 
declaration.
- warned and ignored if a btf_tag attribute is in a prototype declaration but 
that attribute is not in later redeclaration or definition
- added tests to cover the above warn situations and unsupported declaration 
like enum
- fixed some missing points and formats in docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106614

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-btf_tag.c

Index: clang/test/Sema/attr-btf_tag.c
===
--- /dev/null
+++ clang/test/Sema/attr-btf_tag.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+#define __tag __attribute__((btf_tag("tag")))
+#define __tag2 __attribute__((btf_tag("tag2")))
+#define __tag_no_arg __attribute__((btf_tag()))
+#define __tag_2_arg __attribute__((btf_tag("tag1", "tag2")))
+#define __invalid __attribute__((btf_tag(1)))
+
+struct __tag t1; // expected-warning {{attribute 'btf_tag("tag")' in forward declaration ignored}}
+struct t1 {
+  int a __tag;
+} __tag;
+
+int g1 __tag;
+int g2 __tag_no_arg; // expected-error {{'btf_tag' attribute takes one argument}}
+int g3 __tag_2_arg; // expected-error {{'btf_tag' attribute takes one argument}}
+int i1 __invalid; // expected-error {{'btf_tag' attribute requires a string}}
+
+enum e1 {
+  E1
+} __tag; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
+
+enum e2 {
+  E2
+} __tag_no_arg; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
+
+enum e3 {
+  E3
+} __tag_2_arg; // expected-error {{'btf_tag' attribute only applies to variables, functions, structs, unions, classes, and non-static data members}}
+
+int __tag2 foo(struct t1 *arg); // expected-warning {{attribute 'btf_tag("tag2")' ignored as not in later redeclaration or definition}}
+int __tag foo(struct t1 *arg);
+int __tag foo(struct t1 *arg __tag) {
+  return arg->a;
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -22,6 +22,7 @@
 // CHECK-NEXT: Assumption (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
 // CHECK-NEXT: BPFPreserveAccessIndex (SubjectMatchRule_record)
+// CHECK-NEXT: BTFTag (SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field)
 // CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
 // CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6831,6 +6831,35 @@
   Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
 }
 
+static void handleBTFTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  StringRef Str;
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
+return;
+
+  // Ignore forward declaration btf_tag attributes.
+  if (auto *Rec = dyn_cast(D)) {
+if (!Rec->isCompleteDefinition()) {
+  S.Diag(AL.getLoc(), diag::warn_btftag_attribute_fwd_decl_ignored) << Str;
+  return;
+}
+  }
+
+  D->addAttr(::new (S.Context) BTFTagAttr(S.Context, AL, Str));
+}
+
+BTFTagAttr *Sema::mergeBTFTagAttr(Decl *D, const BTFTagAttr &AL) {
+  // Any to-be-merged attribute must be in later redeclaration or actual
+  // definition.
+  for (const auto *I : D->specific_attrs()) {
+if (I->getBTFTag() == AL.getBTFTag())
+  return nullptr;
+  }
+
+  Diag(AL.getLoc(), diag::warn_btftag_attribute_conflict_ignored) <<
+ 

[PATCH] D105759: [WIP] Implement P2361 Unevaluated string literals

2021-08-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:95-96
+  case '?':
+  case 'n':
+  case 't':
+return true;

aaron.ballman wrote:
> Do you intend to miss a bunch of escapes like `\'` and `\r` (etc)?
\' is there. I am less sure about '\r' and '\a'. for example. This is something 
I realized after writing P2361.
what does '\a` in static assert mean? even '\r' is not so obvious



Comment at: clang/lib/Parse/ParseDecl.cpp:422-423
 
-ExprResult ArgExpr(
-Actions.CorrectDelayedTyposInExpr(ParseAssignmentExpression()));
+ExprResult ArgExpr(Actions.CorrectDelayedTyposInExpr(
+ParseAttributeArgAsUnevaluatedLiteralOrExpression(AttrKind)));
 if (ArgExpr.isInvalid()) {

aaron.ballman wrote:
> Hmmm, I'm not certain about these changes.
> 
> For some attributes, the standard currently requires accepting any kind of 
> string literal (like `[[deprecated]]` 
> https://eel.is/c++draft/dcl.attr.deprecated#1). P2361 is proposing to change 
> that, but it's not yet accepted by WG21 (let alone WG14). So giving errors in 
> those cases is a bit of a hard sell -- I think warnings would be a bit more 
> reasonable.
> 
> But for other attributes (like `annotate`), it's a bit less clear whether we 
> should *prevent* literal prefixes because the attribute can be used to have 
> runtime impacts (for example, I can imagine someone using `annotate` to emit 
> the string literal bytes into the resulting binary). In some cases, I think 
> it's very reasonable (e.g., `diagnose_if` should behave the same as 
> `deprecated` and `nodiscard` because those are purely about generating 
> diagnostics at compile time).
> 
> I kind of wonder whether we're going to want to tablegenerate whether the 
> argument needs to be parsed as unevaluated or not on an 
> attribute-by-attribute basis.
Yep, I would not expect this to get merge before P2361 but I think the 
implementation experience is useful and raised a bunch of good questions.
I don't think it ever makes sense to have `L` outside of literals - but people 
*might* do it currently, in which case there is a concern about whether it 
breaks code (I have found no evidence of that though).

If we wanted to inject these strings in the binary - in some form, then we 
might have to transcode them at that point.
I don't think the user would know if the string would be injected as wide or 
narrow (or something else) by the compiler.

`L` is really is want to convert that string _at that point_. in an attribute, 
strings might have multiple usages so it's better to delay any transcoding.
Does that make sense?

But I agree that a survey of what each attribute expects is in order.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[PATCH] D106252: Make simple requirements starting with requires ill-formed in in requirement body

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106252

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


[PATCH] D106277: [SVE] Remove the interface for getMaxVScale in favour of the IR attributes

2021-08-02 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.h:100
+  Optional>
+  getVScaleRange(const LangOptions &LangOpts) const;
+

This clang-tidy warning needs satisfied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106277

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


[PATCH] D92928: [analyzer] Highlight arrows for currently selected event

2021-08-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D92928#2913552 , @ASDenysPetrov 
wrote:

> Or, we can find another symbiotic way. You can make changes the way without 
> painfull part of thinking about IE. And I will prepare the next patch 
> adjusting it. Thus, revisions would be smaller. That's would be easier for 
> you to test all the things before the load. I will take a charge for IE part 
> on my own and prepare a new revision.

That actually can work!  Thanks!

> Let's load this patch and I will prepare the adjustment for IE in pursuit.

Ah, OK.  Sure, let's do it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92928

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


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

2021-08-02 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 363484.
gandhi21299 added a comment.

refreshing patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  Optimization Remark Emitter
 ; GCN-O1-OPTS-NEXT:  Expand Atomic instructions
 ; GCN-O1-OPTS-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
@@ -715,6 +730,11 @@
 ; GCN-O2-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O2-NEXT:FunctionPass Manager
 ; GCN-O2-NEXT:  Infer address spaces
+; GCN-O2-NEXT:  Dominator Tree Constru

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

2021-08-02 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 363490.
gandhi21299 marked 3 inline comments as done.
gandhi21299 added a comment.

generalizing the description of the remark for conversion into CAS loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  Optimization Remark Emitter
 ; GCN-O1-OPTS-NEXT:  Expand Atomic instructions
 ; GCN-O1-OPTS-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
@@ -715,6 +730,11 @@
 ; GCN-O2-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O2-NEXT:FunctionPass Manager
 ; GCN-O2-NEXT:  Infer 

[PATCH] D105904: [clangd] Support `#pragma mark` in the outline

2021-08-02 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:535
+/// by range.
+std::vector mergePragmas(std::vector &Syms,
+ std::vector 
&Pragmas,

kadircet wrote:
> dgoldman wrote:
> > kadircet wrote:
> > > dgoldman wrote:
> > > > sammccall wrote:
> > > > > FWIW the flow control/how we make progress seem hard to follow here 
> > > > > to me.
> > > > > 
> > > > > In particular I think I'm struggling with the statefulness of "is 
> > > > > there an open mark group".
> > > > > 
> > > > > Possible simplifications:
> > > > >  - define a dummy root symbol, which seems clearer than the 
> > > > > vector + range
> > > > >  - avoid reverse-sorting the list of pragma symbols, and just consume 
> > > > > from the front of an ArrayRef instead
> > > > >  - make the outer loop over pragmas, rather than symbols. It would 
> > > > > first check if the pragma belongs directly here or not, and if so, 
> > > > > loop over symbols to work out which should become children. This 
> > > > > seems very likely to be efficient enough in practice (few pragmas, or 
> > > > > most children are grouped into pragmas)
> > > > > define a dummy root symbol, which seems clearer than the 
> > > > > vector + range
> > > > 
> > > > I guess? Then we'd take in a `DocumentSymbol & and a 
> > > > ArrayRef & (or just by value and then return it as 
> > > > well). The rest would be the same though
> > > > 
> > > > > In particular I think I'm struggling with the statefulness of "is 
> > > > > there an open mark group".
> > > > 
> > > > We need to track the current open group if there is one in order to 
> > > > move children to it.
> > > > 
> > > > > make the outer loop over pragmas, rather than symbols. It would first 
> > > > > check if the pragma belongs directly here or not, and if so, loop 
> > > > > over symbols to work out which should become children. This seems 
> > > > > very likely to be efficient enough in practice (few pragmas, or most 
> > > > > children are grouped into pragmas)
> > > > 
> > > > The important thing here is knowing where the pragma mark ends - if it 
> > > > doesn't, it actually gets all of the children. So we'd have to peak at 
> > > > the next pragma mark, add all symbols before it to us as children, and 
> > > > then potentially recurse to nest it inside of a symbol. I'll try it out 
> > > > and see if it's simpler.
> > > > 
> > > > 
> > > ```
> > > while(Pragmas) {
> > > // We'll figure out where the Pragmas.front() should go.
> > > Pragma P = Pragmas.front();
> > > DocumentSymbol *Cur = Root;
> > > while(Cur->contains(P)) {
> > >   auto *OldCur = Cur;
> > >   for(auto *C : Cur->children) {
> > >  // We assume at most 1 child can contain the pragma (as pragmas are 
> > > on a single line, and children have disjoint ranges)
> > >  if (C->contains(P)) {
> > >  Cur = C;
> > >  break;
> > >  }
> > >   }
> > >   // Cur is immediate parent of P
> > >   if (OldCur == Cur) {
> > > // Just insert P into children if it is not a group and we are done.
> > > // Otherwise we need to figure out when current pragma is terminated:
> > > // if next pragma is not contained in Cur, or is contained in one of the 
> > > children, It is at the end of Cur, nest all the children that appear 
> > > after P under the symbol node for P.
> > > // Otherwise nest all the children that appear after P but before next 
> > > pragma under the symbol node for P.
> > > // Pop Pragmas and break
> > >   }
> > > }
> > > }
> > > ```
> > > 
> > > Does that make sense, i hope i am not missing something obvious? 
> > > Complexity-wise in the worst case we'll go all the way down to a leaf 
> > > once per pragma, since there will only be a handful of pragmas most of 
> > > the time it shouldn't be too bad.
> > I've implemented your suggestion. I don't think it's simpler, but LMK, 
> > maybe it can be improved.
> oops, i was looking into an older revision and missed mergepragmas2, i think 
> it looks quite similar to this one but we can probably get rid of the 
> recursion as well and simplify a couple more cases
This makes sense,  I think that works for the most part besides dropping the 
recursion, specifically for

```
  // Next pragma is contained in the Sym, it belongs there and doesn't
  // affect us at all.
  if (Sym.range.contains(NextPragma.DocSym.range)) {
Sym.children = mergePragmas2(Sym.children, Pragmas, Sym.range);
continue;
  }
```

I guess we could explicitly forbid 3+ layers of nesting and handle it inline 
there? But I'm not sure it's worth the effort to rewrite all of this - the 
recursion shouldn't be deep and we avoid needing to shift vector elements over 
by recreating a new one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105904

___
cfe-c

[clang] 97bcafa - [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-08-02 Thread Valeriy Savchenko via cfe-commits
Author: Valeriy Savchenko
Date: 2021-08-02T19:15:00+03:00
New Revision: 97bcafa28deb95ad32f83fe339d78454d899ca1b

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

LOG: [analyzer] Add control flow arrows to the analyzer's HTML reports

This commit adds a very first version of this feature.
It is off by default and has to be turned on by checking the
corresponding box.  For this reason, HTML reports still keep
control notes (aka grey bubbles).

Further on, we plan on attaching arrows to events and having all arrows
not related to a currently selected event barely visible.  This will
help with reports where control flow goes back and forth (eg in loops).
Right now, it can get pretty crammed with all the arrows.

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

Added: 
clang/test/Analysis/html_diagnostics/control-arrows.cpp

Modified: 
clang/include/clang/Analysis/PathDiagnostic.h
clang/lib/Rewrite/HTMLRewrite.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/PathDiagnostic.h 
b/clang/include/clang/Analysis/PathDiagnostic.h
index 539aa20b81682..04bef1fa5334d 100644
--- a/clang/include/clang/Analysis/PathDiagnostic.h
+++ b/clang/include/clang/Analysis/PathDiagnostic.h
@@ -151,11 +151,14 @@ class PathDiagnosticConsumer {
 /// Only runs visitors, no output generated.
 None,
 
-/// Used for HTML, SARIF, and text output.
+/// Used for SARIF and text output.
 Minimal,
 
 /// Used for plist output, used for "arrows" generation.
 Extensive,
+
+/// Used for HTML, shows both "arrows" and control notes.
+Everything
   };
 
   virtual PathGenerationScheme getGenerationScheme() const { return Minimal; }
@@ -164,7 +167,11 @@ class PathDiagnosticConsumer {
 return getGenerationScheme() != None;
   }
 
-  bool shouldAddPathEdges() const { return getGenerationScheme() == Extensive; 
}
+  bool shouldAddPathEdges() const { return getGenerationScheme() >= Extensive; 
}
+  bool shouldAddControlNotes() const {
+return getGenerationScheme() == Minimal ||
+   getGenerationScheme() == Everything;
+  }
 
   virtual bool supportsLogicalOpControlFlow() const { return false; }
 

diff  --git a/clang/lib/Rewrite/HTMLRewrite.cpp 
b/clang/lib/Rewrite/HTMLRewrite.cpp
index 2f5f2734aa46b..496b8c575dfcb 100644
--- a/clang/lib/Rewrite/HTMLRewrite.cpp
+++ b/clang/lib/Rewrite/HTMLRewrite.cpp
@@ -371,6 +371,7 @@ h1 { font-size:14pt }
 .msg { border-radius:5px }
 .msg { font-family:Helvetica, sans-serif; font-size:8pt }
 .msg { float:left }
+.msg { position:relative }
 .msg { padding:0.25em 1ex 0.25em 1ex }
 .msg { margin-top:10px; margin-bottom:10px }
 .msg { font-weight:bold }

diff  --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp 
b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index d6f69ae03afe5..da441dcdf0183 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -188,6 +188,9 @@ class PathDiagnosticConstruct {
   PathPieces &getMutablePieces() { return PD->getMutablePieces(); }
 
   bool shouldAddPathEdges() const { return Consumer->shouldAddPathEdges(); }
+  bool shouldAddControlNotes() const {
+return Consumer->shouldAddControlNotes();
+  }
   bool shouldGenerateDiagnostics() const {
 return Consumer->shouldGenerateDiagnostics();
   }
@@ -1232,8 +1235,11 @@ void 
PathDiagnosticBuilder::generatePathDiagnosticsForNode(
 
   } else if (auto BE = P.getAs()) {
 
-if (!C.shouldAddPathEdges()) {
+if (C.shouldAddControlNotes()) {
   generateMinimalDiagForBlockEdge(C, *BE);
+}
+
+if (!C.shouldAddPathEdges()) {
   return;
 }
 
@@ -1254,12 +1260,14 @@ void 
PathDiagnosticBuilder::generatePathDiagnosticsForNode(
   // do-while statements are explicitly excluded here
 
   auto p = std::make_shared(
-  L, "Looping back to the head "
-  "of the loop");
+  L, "Looping back to the head of the loop");
   p->setPrunable(true);
 
   addEdgeToPath(C.getActivePath(), PrevLoc, p->getLocation());
-  C.getActivePath().push_front(std::move(p));
+  // We might've added a very similar control node already
+  if (!C.shouldAddControlNotes()) {
+C.getActivePath().push_front(std::move(p));
+  }
 
   if (const auto *CS = dyn_cast_or_null(Body)) {
 addEdgeToPath(C.getActivePath(), PrevLoc,
@@ -1300,10 +1308,14 @@ void 
PathDiagnosticBuilder::generatePathDiagnosticsForNode(
   auto PE = std::make_shared(L, str);
   PE->setPrunable(true);
   addEdgeToPath(C.getActivePath(), PrevLoc, PE->getLocation());
-  C.getActivePath().push_front(std::move(PE));
+
+  // W

[clang] 9e02f58 - [analyzer] Highlight arrows for currently selected event

2021-08-02 Thread Valeriy Savchenko via cfe-commits
Author: Valeriy Savchenko
Date: 2021-08-02T19:15:01+03:00
New Revision: 9e02f58780ab8734e5d27a0138bd477d18ae64a1

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

LOG: [analyzer] Highlight arrows for currently selected event

In some cases, when the execution path of the diagnostic
goes back and forth, arrows can overlap and create a mess.
Dimming arrows that are not relevant at the moment, solves this issue.
They are still visible, but don't draw too much attention.

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

Added: 


Modified: 
clang/lib/Rewrite/HTMLRewrite.cpp
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/test/Analysis/html_diagnostics/control-arrows.cpp

Removed: 




diff  --git a/clang/lib/Rewrite/HTMLRewrite.cpp 
b/clang/lib/Rewrite/HTMLRewrite.cpp
index 496b8c575dfcb..371557a624c9c 100644
--- a/clang/lib/Rewrite/HTMLRewrite.cpp
+++ b/clang/lib/Rewrite/HTMLRewrite.cpp
@@ -392,7 +392,7 @@ h1 { font-size:14pt }
 .CodeInsertionHint { font-weight: bold; background-color: #10dd10 }
 .CodeRemovalHint { background-color:#de1010 }
 .CodeRemovalHint { border-bottom:1px solid #6F9DBE }
-.selected{ background-color:orange !important; }
+.msg.selected{ background-color:orange !important; }
 
 table.simpletable {
   padding: 5px;

diff  --git a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp 
b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
index f301378c02d6c..3ee12c0bdf651 100644
--- a/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ b/clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -27,6 +27,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
@@ -58,6 +59,8 @@ using namespace ento;
 
 namespace {
 
+class ArrowMap;
+
 class HTMLDiagnostics : public PathDiagnosticConsumer {
   PathDiagnosticConsumerOptions DiagOpts;
   std::string Directory;
@@ -119,7 +122,8 @@ class HTMLDiagnostics : public PathDiagnosticConsumer {
   }
 
 private:
-  void addArrowSVGs(Rewriter &R, FileID BugFileID, unsigned NumberOfArrows);
+  void addArrowSVGs(Rewriter &R, FileID BugFileID,
+const ArrowMap &ArrowIndices);
 
   /// \return Javascript for displaying shortcuts help;
   StringRef showHelpJavascript();
@@ -150,6 +154,20 @@ unsigned getPathSizeWithoutArrows(const PathPieces &Path) {
   return TotalPieces - TotalArrowPieces;
 }
 
+class ArrowMap : public std::vector {
+  using Base = std::vector;
+
+public:
+  ArrowMap(unsigned Size) : Base(Size, 0) {}
+  unsigned getTotalNumberOfArrows() const { return at(0); }
+};
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ArrowMap &Indices) {
+  OS << "[ ";
+  llvm::interleave(Indices, OS, ",");
+  return OS << " ]";
+}
+
 } // namespace
 
 void ento::createHTMLDiagnosticConsumer(
@@ -761,6 +779,7 @@ void HTMLDiagnostics::RewriteFile(Rewriter &R, const 
PathPieces &path,
   unsigned NumberOfArrows = 0;
   // Stores the count of the regular piece indices.
   std::map IndexMap;
+  ArrowMap ArrowIndices(TotalRegularPieces + 1);
 
   // Stores the 
diff erent ranges where we have reported something.
   std::vector PopUpRanges;
@@ -779,13 +798,30 @@ void HTMLDiagnostics::RewriteFile(Rewriter &R, const 
PathPieces &path,
 } else if (isArrowPiece(Piece)) {
   NumberOfArrows = ProcessControlFlowPiece(
   R, FID, cast(Piece), NumberOfArrows);
+  ArrowIndices[NumRegularPieces] = NumberOfArrows;
 
 } else {
   HandlePiece(R, FID, Piece, PopUpRanges, NumRegularPieces,
   TotalRegularPieces);
   --NumRegularPieces;
+  ArrowIndices[NumRegularPieces] = ArrowIndices[NumRegularPieces + 1];
 }
   }
+  ArrowIndices[0] = NumberOfArrows;
+
+  // At this point ArrowIndices represent the following data structure:
+  //   [a_0, a_1, ..., a_N]
+  // where N is the number of events in the path.
+  //
+  // Then for every event with index i \in [0, N - 1], we can say that
+  // arrows with indices \in [a_(i+1), a_i) correspond to that event.
+  // We can say that because arrows with these indices appeared in the
+  // path in between the i-th and the (i+1)-th events.
+  assert(ArrowIndices.back() == 0 &&
+ "No arrows should be after the last event");
+  // This assertion also guarantees that all indices in are <= NumberOfArrows.
+  assert(llvm::is_sorted(ArrowIndices, std::greater()) &&
+ "Incorrect arrow indices map");
 
   // Secondary indexing if we are having multiple pop-ups between two notes.
   // (e.g. [(13) 'a' is 'true'];  [(13.1) 'b' is 'false'];  [(13.2) 'c' is...)
@@ -819,7 +855,7 @@ void HTMLDiagnostics:

[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-08-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97bcafa28deb: [analyzer] Add control flow arrows to the 
analyzer's HTML reports (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

Files:
  clang/include/clang/Analysis/PathDiagnostic.h
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/StaticAnalyzer/Core/BugReporter.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/control-arrows.cpp

Index: clang/test/Analysis/html_diagnostics/control-arrows.cpp
===
--- /dev/null
+++ clang/test/Analysis/html_diagnostics/control-arrows.cpp
@@ -0,0 +1,27 @@
+// RUN: rm -fR %t
+// RUN: mkdir %t
+// RUN: %clang_analyze_cc1 -analyzer-checker=core \
+// RUN:-analyzer-output=html -o %t -verify %s
+// RUN: cat %t/report-*.html | FileCheck %s
+
+int dereference(int *x) {
+  return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
+}
+
+int foobar(bool cond, int *x) {
+  if (cond)
+x = 0;
+  return dereference(x);
+}
+
+// CHECK:  
+// CHECK-NOT:  
+// CHECK:
+// CHECK-NEXT: 
+//
+// Except for arrows we still want to have grey bubbles with control notes.
+// CHECK:  2
+// CHECK-SAME:   Taking true branch
Index: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
===
--- clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
+++ clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
@@ -27,6 +27,7 @@
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Sequence.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -77,60 +78,78 @@
   void FlushDiagnosticsImpl(std::vector &Diags,
 FilesMade *filesMade) override;
 
-  StringRef getName() const override {
-return "HTMLDiagnostics";
-  }
+  StringRef getName() const override { return "HTMLDiagnostics"; }
 
   bool supportsCrossFileDiagnostics() const override {
 return SupportsCrossFileDiagnostics;
   }
 
-  unsigned ProcessMacroPiece(raw_ostream &os,
- const PathDiagnosticMacroPiece& P,
+  unsigned ProcessMacroPiece(raw_ostream &os, const PathDiagnosticMacroPiece &P,
  unsigned num);
 
+  unsigned ProcessControlFlowPiece(Rewriter &R, FileID BugFileID,
+   const PathDiagnosticControlFlowPiece &P,
+   unsigned Number);
+
   void HandlePiece(Rewriter &R, FileID BugFileID, const PathDiagnosticPiece &P,
const std::vector &PopUpRanges, unsigned num,
unsigned max);
 
-  void HighlightRange(Rewriter& R, FileID BugFileID, SourceRange Range,
+  void HighlightRange(Rewriter &R, FileID BugFileID, SourceRange Range,
   const char *HighlightStart = "",
   const char *HighlightEnd = "");
 
-  void ReportDiag(const PathDiagnostic& D,
-  FilesMade *filesMade);
+  void ReportDiag(const PathDiagnostic &D, FilesMade *filesMade);
 
   // Generate the full HTML report
-  std::string GenerateHTML(const PathDiagnostic& D, Rewriter &R,
-   const SourceManager& SMgr, const PathPieces& path,
+  std::string GenerateHTML(const PathDiagnostic &D, Rewriter &R,
+   const SourceManager &SMgr, const PathPieces &path,
const char *declName);
 
   // Add HTML header/footers to file specified by FID
-  void FinalizeHTML(const PathDiagnostic& D, Rewriter &R,
-const SourceManager& SMgr, const PathPieces& path,
+  void FinalizeHTML(const PathDiagnostic &D, Rewriter &R,
+const SourceManager &SMgr, const PathPieces &path,
 FileID FID, const FileEntry *Entry, const char *declName);
 
   // Rewrite the file specified by FID with HTML formatting.
-  void RewriteFile(Rewriter &R, const PathPieces& path, FileID FID);
+  void RewriteFile(Rewriter &R, const PathPieces &path, FileID FID);
 
+  PathGenerationScheme getGenerationScheme() const override {
+return Everything;
+  }
 
 private:
+  void addArrowSVGs(Rewriter &R, FileID BugFileID, unsigned NumberOfArrows);
+
   /// \return Javascript for displaying shortcuts help;
   StringRef showHelpJavascript();
 
   /// \return Javascript for navigating the HTML report using j/k keys.
   StringRef generateKeyboardNavigationJavascript();
 
+  /// \return Javascript for drawing control-flow arrows.
+  StringRef generateArrowDrawingJavascript();
+
   /// \return JavaScript for an opt

[PATCH] D92928: [analyzer] Highlight arrows for currently selected event

2021-08-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e02f58780ab: [analyzer] Highlight arrows for currently 
selected event (authored by vsavchenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92928

Files:
  clang/lib/Rewrite/HTMLRewrite.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/test/Analysis/html_diagnostics/control-arrows.cpp

Index: clang/test/Analysis/html_diagnostics/control-arrows.cpp
===
--- clang/test/Analysis/html_diagnostics/control-arrows.cpp
+++ clang/test/Analysis/html_diagnostics/control-arrows.cpp
@@ -16,10 +16,13 @@
 
 // CHECK:  
-// CHECK-NOT:  
+// CHECK-COUNT-9:  
+// CHECK-NOT:  
 // CHECK:
 // CHECK-NEXT: 
+// CHECK-NEXT: 
+// CHECK-NEXT: const arrowIndices = [ 9,8,6,5,3,2,0 ]
+// CHECK-NEXT: 
 //
 // Except for arrows we still want to have grey bubbles with control notes.
 // CHECK:   {
+  using Base = std::vector;
+
+public:
+  ArrowMap(unsigned Size) : Base(Size, 0) {}
+  unsigned getTotalNumberOfArrows() const { return at(0); }
+};
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const ArrowMap &Indices) {
+  OS << "[ ";
+  llvm::interleave(Indices, OS, ",");
+  return OS << " ]";
+}
+
 } // namespace
 
 void ento::createHTMLDiagnosticConsumer(
@@ -761,6 +779,7 @@
   unsigned NumberOfArrows = 0;
   // Stores the count of the regular piece indices.
   std::map IndexMap;
+  ArrowMap ArrowIndices(TotalRegularPieces + 1);
 
   // Stores the different ranges where we have reported something.
   std::vector PopUpRanges;
@@ -779,13 +798,30 @@
 } else if (isArrowPiece(Piece)) {
   NumberOfArrows = ProcessControlFlowPiece(
   R, FID, cast(Piece), NumberOfArrows);
+  ArrowIndices[NumRegularPieces] = NumberOfArrows;
 
 } else {
   HandlePiece(R, FID, Piece, PopUpRanges, NumRegularPieces,
   TotalRegularPieces);
   --NumRegularPieces;
+  ArrowIndices[NumRegularPieces] = ArrowIndices[NumRegularPieces + 1];
 }
   }
+  ArrowIndices[0] = NumberOfArrows;
+
+  // At this point ArrowIndices represent the following data structure:
+  //   [a_0, a_1, ..., a_N]
+  // where N is the number of events in the path.
+  //
+  // Then for every event with index i \in [0, N - 1], we can say that
+  // arrows with indices \in [a_(i+1), a_i) correspond to that event.
+  // We can say that because arrows with these indices appeared in the
+  // path in between the i-th and the (i+1)-th events.
+  assert(ArrowIndices.back() == 0 &&
+ "No arrows should be after the last event");
+  // This assertion also guarantees that all indices in are <= NumberOfArrows.
+  assert(llvm::is_sorted(ArrowIndices, std::greater()) &&
+ "Incorrect arrow indices map");
 
   // Secondary indexing if we are having multiple pop-ups between two notes.
   // (e.g. [(13) 'a' is 'true'];  [(13.1) 'b' is 'false'];  [(13.2) 'c' is...)
@@ -819,7 +855,7 @@
   html::EscapeText(R, FID);
   html::AddLineNumbers(R, FID);
 
-  addArrowSVGs(R, FID, NumberOfArrows);
+  addArrowSVGs(R, FID, ArrowIndices);
 
   // If we have a preprocessor, relex the file and syntax highlight.
   // We might not have a preprocessor if we come from a deserialized AST file,
@@ -1088,7 +1124,7 @@
 }
 
 void HTMLDiagnostics::addArrowSVGs(Rewriter &R, FileID BugFileID,
-   unsigned NumberOfArrows) {
+   const ArrowMap &ArrowIndices) {
   std::string S;
   llvm::raw_string_ostream OS(S);
 
@@ -1103,27 +1139,52 @@
   pointer-events: none;
   overflow: visible
   }
+  .arrow {
+  stroke-opacity: 0.2;
+  stroke-width: 1;
+  marker-end: url(#arrowhead);
+  }
+
+  .arrow.selected {
+  stroke-opacity: 0.6;
+  stroke-width: 2;
+  marker-end: url(#arrowheadSelected);
+  }
+
+  .arrowhead {
+  orient: auto;
+  stroke: none;
+  opacity: 0.6;
+  fill: blue;
+  }
 
 http://www.w3.org/2000/svg";>
   
-
+
+  
+
+
   
 
   
-  
+  
 )<<<";
 
-  for (unsigned Index : llvm::seq(0u, NumberOfArrows)) {
-OS << "\n";
+  for (unsigned Index : llvm::seq(0u, ArrowIndices.getTotalNumberOfArrows())) {
+OS << "\n";
   }
 
   OS << R"<<<(
   
 
-)<<<";
+
+const arrowIndices = )<<<";
+
+  OS << ArrowIndices << "\n\n";
 
   R.InsertTextBefore(R.getSourceMgr().getLocForStartOfFile(BugFileID),
  OS.str());
@@ -1220,7 +1281,7 @@
 });
 
 var findNum = function() {
-var s = document.querySelector(".selected");
+var s = document.querySelector(".msg.selected");
 if (!s || s.id == "EndPath") {
 return 0;
 }
@@ -1235,6 +1296,7 @@
 el.classList.add("selected");
 window.scrollBy(0, el.getBoundingClientRect().top -
 (window.innerHeight / 2));
+highli

[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-08-02 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 363495.
adamcz added a comment.

ActOnInializerError instead of SetInvalidDecl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/ast-dump-undeduced-expr.cpp
  clang/test/SemaCXX/crash-auto-36064.cpp
  clang/test/SemaCXX/cxx11-crashes.cpp


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -104,3 +104,22 @@
   bool baz() { return __has_nothrow_constructor(B); }
   bool qux() { return __has_nothrow_copy(B); }
 }
+
+namespace undeduced_field {
+template
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+   // expected-error@-1 {{declaration of variable 
'A' with deduced type 'const auto' requires an initializer}}
+
+  Foo::type B;  // The type of B is also undeduced (wrapped in 
Elaborated).
+};
+
+// This used to crash when trying to get the layout of B.
+Bar x;
+}
Index: clang/test/SemaCXX/crash-auto-36064.cpp
===
--- clang/test/SemaCXX/crash-auto-36064.cpp
+++ clang/test/SemaCXX/crash-auto-36064.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
-template  // expected-error{{new expression for 
type 'auto' requires a constructor argument}}
+template 
 struct b;
 struct d {
   static auto c = ;  // expected-error{{expected expression}}
+ // expected-error@-1 {{declaration of 
variable 'c' with deduced type 'auto' requires an initializer}}
+
   decltype(b); // expected-error{{expected '(' for 
function-style cast or type construction}}
- // expected-note@-1{{while substituting prior 
template arguments into non-type template parameter [with A = auto]}}
 };
Index: clang/test/AST/ast-dump-undeduced-expr.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-undeduced-expr.cpp
@@ -0,0 +1,7 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck 
%s
+
+struct Foo {
+  static constexpr auto Bar = ;
+};
+
+// CHECK: -VarDecl {{.*}} invalid Bar 'const auto' static constexpr
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2989,9 +2989,11 @@
   ExprResult Init = ParseCXXMemberInitializer(
   ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
 
-  if (Init.isInvalid())
+  if (Init.isInvalid()) {
+if (ThisDecl)
+  Actions.ActOnUninitializedDecl(ThisDecl);
 SkipUntil(tok::comma, StopAtSemi | StopBeforeMatch);
-  else if (ThisDecl)
+  } else if (ThisDecl)
 Actions.AddInitializerToDecl(ThisDecl, Init.get(), 
EqualLoc.isInvalid());
 } else if (ThisDecl && DS.getStorageClassSpec() == DeclSpec::SCS_static)
   // No initializer.


Index: clang/test/SemaCXX/cxx11-crashes.cpp
===
--- clang/test/SemaCXX/cxx11-crashes.cpp
+++ clang/test/SemaCXX/cxx11-crashes.cpp
@@ -104,3 +104,22 @@
   bool baz() { return __has_nothrow_constructor(B); }
   bool qux() { return __has_nothrow_copy(B); }
 }
+
+namespace undeduced_field {
+template
+struct Foo {
+  typedef T type;
+};
+
+struct Bar {
+  Bar();
+  // The missing expression makes A undeduced.
+  static constexpr auto A = ;  // expected-error {{expected expression}}
+   // expected-error@-1 {{declaration of variable 'A' with deduced type 'const auto' requires an initializer}}
+
+  Foo::type B;  // The type of B is also undeduced (wrapped in Elaborated).
+};
+
+// This used to crash when trying to get the layout of B.
+Bar x;
+}
Index: clang/test/SemaCXX/crash-auto-36064.cpp
===
--- clang/test/SemaCXX/crash-auto-36064.cpp
+++ clang/test/SemaCXX/crash-auto-36064.cpp
@@ -1,8 +1,9 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
-template  // expected-error{{new expression for type 'auto' requires a constructor argument}}
+template 
 struct b;
 struct d {
   static auto c = ;  // expected-error{{expected expression}}
+ // expected-error@-1 {{declaration of variable 'c' with deduced type 'auto' requires an initializer}}
+
   decltype(b); // expected-error{{expected '(' for function-style cast or type construction}}
- // expected-note@-1{{while substituting prior template arguments into non-type template par

[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-08-02 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:2987
+if (ThisDecl)
+  ThisDecl->setInvalidDecl();
 SkipUntil(tok::comma, StopAtSemi | StopBeforeMatch);

hokein wrote:
> it seems to me calling `Sema::ActOnInitializerError(ThisDecl)` is a better 
> fit, rather than invalidating the decl once the initializer is failed to 
> parse, for example `static const int Member = ;` we want to keep the decl 
> valid.
Amusingly, this change led me to discover 
https://bugs.llvm.org/show_bug.cgi?id=36064, which seems like the same issue, 
only solved for a very specific example. I had to update the test for that, 
since now we solve it more generically and thus error messages are different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

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


[libunwind] d6d0b65 - unwind: repair register restoration for OR1K

2021-08-02 Thread Saleem Abdulrasool via cfe-commits
Author: Saleem Abdulrasool
Date: 2021-08-02T16:36:37Z
New Revision: d6d0b6559e97a3d0b258814e870d3e19f3a7ffcc

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

LOG: unwind: repair register restoration for OR1K

Currently, OR1K architecture put the program counter at offset 0x128 of
the current `or1k_thread_state_t`. However, the PC is restored after
updating the thread pointer in `r3`, which causes the PC to be fetched
incorrectly.

This patch swaps the order of restoration of `r9` and `r3`, such that
the PC is restored to `r9` using the current thread state.

Patch by Oi Chee Cheung!

Reviewed By: whitequark, compnerd

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

Added: 


Modified: 
libunwind/src/UnwindRegistersRestore.S

Removed: 




diff  --git a/libunwind/src/UnwindRegistersRestore.S 
b/libunwind/src/UnwindRegistersRestore.S
index d8bf1adee4168..c2106f32ee9f0 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -800,11 +800,12 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind14Registers_or1k6jumptoEv)
   l.lwzr30,120(r3)
   l.lwzr31,124(r3)
 
+  # load new pc into ra
+  l.lwzr9, 128(r3)
+
   # at last, restore r3
   l.lwzr3,  12(r3)
 
-  # load new pc into ra
-  l.lwzr9, 128(r3)
   # jump to pc
   l.jr r9
l.nop



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


[PATCH] D100810: Use `GNUInstallDirs` to support custom installation dirs. -- LLVM

2021-08-02 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: llvm/CMakeLists.txt:589
 CACHE STRING "Doxygen-generated HTML documentation install directory")
-set(LLVM_INSTALL_OCAMLDOC_HTML_DIR "share/doc/llvm/ocaml-html"
+set(LLVM_INSTALL_OCAMLDOC_HTML_DIR 
"${CMAKE_INSTALL_DOCDIR}/${project}/ocaml-html"
 CACHE STRING "OCamldoc-generated HTML documentation install directory")

Why the change from `llvm` -> `${project}`?  (not that it really makes a 
difference)



Comment at: llvm/cmake/modules/AddSphinxTarget.cmake:77
 if (CMAKE_INSTALL_MANDIR)
-  set(INSTALL_MANDIR ${CMAKE_INSTALL_MANDIR}/)
+  set(INSTALL_MANDIR "${CMAKE_INSTALL_MANDIR}/")
 else()

Nit: trailing slash is unnecessary, `CMAKE_INSTALL_MANDIR` should be defined, 
and if not, you do not want installation into `/` anyway.



Comment at: llvm/cmake/modules/CMakeLists.txt:3
 
-set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
+set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm CACHE STRING 
"Path for CMake subdirectory (defaults to 'cmake/llvm')")
 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")

Why is this variable being put into the cache now?



Comment at: llvm/cmake/modules/LLVMInstallSymlink.cmake:7
   set(DESTDIR $ENV{DESTDIR})
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
+  set(bindir "${DESTDIR}${outdir}/")
 

Nit: trailing slash shouldn't be there.



Comment at: llvm/tools/llvm-config/llvm-config.cpp:361
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_INCLUDEDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);

Why the temporary `StringRef`?  Can you not just initialize `Path` with the 
literal?



Comment at: llvm/tools/llvm-config/llvm-config.cpp:366
+{
+  SmallString<256> Path(StringRef(LLVM_INSTALL_BINDIR));
+  sys::fs::make_absolute(ActivePrefix, Path);

Similar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


[PATCH] D107290: [PoC][RISCV] Add support for the vscale_range attribute

2021-08-02 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck created this revision.
frasercrmck added reviewers: craig.topper, rogfer01, HsiangKai, evandro, 
arcbbb, khchen.
Herald added subscribers: vkmr, luismarques, apazos, sameer.abuasal, s.egerton, 
Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb.
frasercrmck requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This patch begins the process of supporting the `vscale_range` attribute
for RVV. It implements it according to our supported v0.10 version of
the specification, as opposed to the imminent v1.0.

Most notably, this patch implements the attribute conservatively
according to the minimum and maximum values of VLEN according to the
specification. However, the backend can be given more information about
VLEN using the `-riscv-v-vector-bits-min` and `-riscv-v-vector-bits-max`
flags. This means that the API it aims to replace,
`TargetTransformInfo::getMaxVScale`, may still generate better code with
its better knowledge.

It is unclear whether we want to move those backend options up into the
frontend, whether we are able to allow the backend to infer all
information from the IR attribute, or whether we even want to do that;
that's a wider discussion.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107290

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/riscv-vscale-range.c


Index: clang/test/CodeGen/riscv-vscale-range.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-vscale-range.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -S 
-emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @func() #0
+// CHECK: attributes #0 = { {{.*}} vscale_range(2,1024) {{.*}} }
+void func() {}
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -111,7 +111,11 @@
 DiagnosticsEngine &Diags) override;
 
   bool hasExtIntType() const override { return true; }
+
+  Optional>
+  getVScaleRange(const LangOptions &LangOpts) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:
   RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -335,6 +335,20 @@
   return true;
 }
 
+Optional>
+RISCVTargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
+  if (!HasV)
+return None;
+  // VLEN is defined in v0.10 to be at least 128 bits and at most 65536 bits,
+  // and vscale is VLEN/64.
+  // FIXME: v1.0 removes the minimum value.
+  // FIXME: The backend can be told about the more specific minimum/maximum
+  // VLEN but the frontend can't access this information.
+  unsigned VLENMin = 128;
+  unsigned VLENMax = 65536;
+  return std::make_pair(VLENMin / 64, VLENMax / 64);
+}
+
 bool RISCV32TargetInfo::isValidCPUName(StringRef Name) const {
   return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name),
/*Is64Bit=*/false);


Index: clang/test/CodeGen/riscv-vscale-range.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-vscale-range.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: @func() #0
+// CHECK: attributes #0 = { {{.*}} vscale_range(2,1024) {{.*}} }
+void func() {}
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -111,7 +111,11 @@
 DiagnosticsEngine &Diags) override;
 
   bool hasExtIntType() const override { return true; }
+
+  Optional>
+  getVScaleRange(const LangOptions &LangOpts) const override;
 };
+
 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
 public:
   RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -335,6 +335,20 @@
   return true;
 }
 
+Optional>
+RISCVTargetInfo::getVScaleRange(const LangOptions &LangOpts) const {
+  if (!HasV)
+return None;
+  // VLEN is defined in v0.10 to be at least 128 bits and at most 65536 bits,
+  // and vscale is VLEN/64.
+  // FIXME: v1.0 removes the minimum value.
+  // FIXME: The backend can be told about the more specific m

[PATCH] D107291: [clang][lexer] adds a way for tokens to track their physical spelling

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Tokens don't currently have a way to track their source-based spelling,
which makes implementing some warnings difficult.

This patch is the basis for two independent warnings, and should be
a non-functional change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107291

Files:
  clang/include/clang/Lex/Token.h
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -3264,6 +3264,7 @@
 
   // Read a character, advancing over it.
   char Char = getAndAdvanceChar(CurPtr, Result);
+  Result.setSpelling(CurPtr - 1);
   tok::TokenKind Kind;
 
   if (!isVerticalWhitespace(Char))
@@ -3590,12 +3591,14 @@
 Char = getCharAndSize(CurPtr, SizeTmp);
 if (Char == '&') {
   Kind = tok::ampamp;
+  // Result.setSpelling(CurPtr - 1);
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else if (Char == '=') {
   Kind = tok::ampequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
   Kind = tok::amp;
+  // Result.setSpelling(CurPtr - 1);
 }
 break;
   case '*':
@@ -3639,6 +3642,7 @@
 }
 break;
   case '~':
+// Result.setSpelling(CurPtr - 1);
 Kind = tok::tilde;
 break;
   case '!':
@@ -3646,6 +3650,7 @@
   Kind = tok::exclaimequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::exclaim;
 }
 break;
@@ -3846,6 +3851,7 @@
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
   Kind = tok::caretcaret;
 } else {
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::caret;
 }
 break;
@@ -3858,9 +3864,11 @@
   // If this is '|||' and we're in a conflict marker, ignore it.
   if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1))
 goto LexNextToken;
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::pipepipe;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::pipe;
 }
 break;
Index: clang/include/clang/Lex/Token.h
===
--- clang/include/clang/Lex/Token.h
+++ clang/include/clang/Lex/Token.h
@@ -67,6 +67,9 @@
   /// Flags - Bits we track about this token, members of the TokenFlags enum.
   unsigned short Flags;
 
+  /// Spelling - How a token is spelt in the source.
+  const char *Spelling;
+
 public:
   // Various flags set per token:
   enum TokenFlags {
@@ -237,6 +240,10 @@
 Flags |= Flag;
   }
 
+  StringRef getSpelling() const { return {Spelling, getLength()}; }
+
+  void setSpelling(const char *S) { Spelling = S; }
+
   /// Get the specified flag.
   bool getFlag(TokenFlags Flag) const {
 return (Flags & Flag) != 0;


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -3264,6 +3264,7 @@
 
   // Read a character, advancing over it.
   char Char = getAndAdvanceChar(CurPtr, Result);
+  Result.setSpelling(CurPtr - 1);
   tok::TokenKind Kind;
 
   if (!isVerticalWhitespace(Char))
@@ -3590,12 +3591,14 @@
 Char = getCharAndSize(CurPtr, SizeTmp);
 if (Char == '&') {
   Kind = tok::ampamp;
+  // Result.setSpelling(CurPtr - 1);
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else if (Char == '=') {
   Kind = tok::ampequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
   Kind = tok::amp;
+  // Result.setSpelling(CurPtr - 1);
 }
 break;
   case '*':
@@ -3639,6 +3642,7 @@
 }
 break;
   case '~':
+// Result.setSpelling(CurPtr - 1);
 Kind = tok::tilde;
 break;
   case '!':
@@ -3646,6 +3650,7 @@
   Kind = tok::exclaimequal;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::exclaim;
 }
 break;
@@ -3846,6 +3851,7 @@
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
   Kind = tok::caretcaret;
 } else {
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::caret;
 }
 break;
@@ -3858,9 +3864,11 @@
   // If this is '|||' and we're in a conflict marker, ignore it.
   if (CurPtr[1] == '|' && HandleEndOfConflictMarker(CurPtr-1))
 goto LexNextToken;
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::pipepipe;
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);
 } else {
+  // Result.setSpelling(CurPtr - 1);
   Kind = tok::pipe;
 }
 break;
Index: clang/include/clang/Lex/Token.h
===
--- clang/include/clang/Lex/Token.h
+++ 

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

2021-08-02 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added a comment.

In D106939#2915784 , @HsiangKai wrote:

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

Hmm, unsure, the test changes are pretty much unreviewable given how large the 
diff would be. There's nothing unexpected in there, presumably?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106939

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


[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens as references

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Although the alternative tokens `bitand` and `and` _can_ respectively be
used in place of `&` and `&&` for declarations, this is arguably misuse
of the tokens in contemporary programming. As of this commit, Clang will
warn—by default—when a programmer attempts to declare a name using
alternative tokens in place of reference symbols.

Depends on D107291 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107292

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/cxx-decl.cpp
  clang/test/Parser/cxx0x-decl.cpp
  clang/test/Parser/warn-declare-references-with-symbols.cpp

Index: clang/test/Parser/warn-declare-references-with-symbols.cpp
===
--- /dev/null
+++ clang/test/Parser/warn-declare-references-with-symbols.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeclare-references-with-symbols -verify %s
+
+int i = 0;
+
+int bitand lr1 = i; // expected-warning{{use '&' when declaring lvalue references}}
+int &lr2 = i; // no warning
+
+using bad_lr = int bitand; // expected-warning{{use '&' when declaring lvalue references}}
+using good_lr = int &; // no warning
+
+template
+void f(T bitand); // expected-warning{{use '&' when declaring lvalue references}}
+
+template
+void f(T &); // no warning
+
+// C++11
+int and rr1 = 0; // expected-warning{{use '&&' when declaring rvalue and forwarding references}}
+int &&rr2 = 0; // no warning
+
+using bad_rr = int and; // expected-warning{{use '&&' when declaring rvalue and forwarding references}}
+using good_rr = int &&; // no warning
+
+auto and fr1 = i; // expected-warning{{use '&&' when declaring rvalue and forwarding references}}
+auto &&fr2 = i; // no warning
+
+auto and fr3 = 0; // expected-warning{{use '&&' when declaring rvalue and forwarding references}}
+auto &&fr4 = 0; // no warning
+
+template
+void f(T and); // expected-warning{{use '&&' when declaring rvalue and forwarding references}}
+
+template
+void f(T &&); // no warning
+
+// C++14
+template
+T bitand lr3 = i; // expected-warning{{use '&' when declaring lvalue references}}
+
+template
+T &lr4 = i; // no warning
+
+template
+T and rr3 = i; // expected-warning{{use '&&' when declaring rvalue and forwarding references}}
+
+template
+T &&rr4 = i; // no warning
+
+// C++20
+template
+concept C1 = requires(T bitand x) { x; };
+// expected-warning@-1{{use '&' when declaring lvalue references}}
+
+template
+concept C2 = requires(T &x) { x; }; // no warning
+
+template
+concept C3 = requires(T and x) { x; };
+// expected-warning@-1{{use '&&' when declaring rvalue and forwarding references}}
+
+template
+concept C4 = requires(T &&x) { x; }; // no warning
Index: clang/test/Parser/cxx0x-decl.cpp
===
--- clang/test/Parser/cxx0x-decl.cpp
+++ clang/test/Parser/cxx0x-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -std=c++2a -pedantic-errors -triple x86_64-linux-gnu %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++2a -Wno-declare-references-with-symbols -pedantic-errors -triple x86_64-linux-gnu %s
 
 // Make sure we know these are legitimate commas and not typos for ';'.
 namespace Commas {
Index: clang/test/Parser/cxx-decl.cpp
===
--- clang/test/Parser/cxx-decl.cpp
+++ clang/test/Parser/cxx-decl.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -pedantic-errors -fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -Wno-declare-references-with-symbols -pedantic-errors -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -Wno-declare-references-with-symbols -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens -Wno-declare-references-with-symbols -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s
 
 const char const *x10; // expected-error {{duplicate 'const' declaration specifier}}
 
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5797,6 +5797,7 @@
 
   // Otherwise, '*' -> pointer, '^'

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2021-08-02 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

In D86671#2919077 , @thakis wrote:

> This breaks tests on windows: http://45.33.8.238/win/43180/step_8.txt
>
> "The command line is too long" Maybe some arts could be passed via a response 
> file instead?

Hi @thakis :
Thank you.

I'm a newbie. I tried to arc diff but arc shows `ERR_CLOSED: This revision has 
already been closed.`. Should I create a new differential diff for it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D107294: [clang] adds warning to suggest users replace symbols with alt tokens

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

C++'s alternative tokens are a good way to improve readability and
minimise bugs by expressing intention using words instead of symbols
(which can both be more easily misspelt _and_ misread).

This warning analyses the binary logical and bitwise operators and warns
if they aren't spelt using the alternative tokens. Bitwise compound
assignment and `!=` operators are not in scope since there's nothing to
misspel or misread.

Future work:

- add a fixit
- add a way for the compiler to detect when the pipe operator (`|`) is not 
being used for a bitwise-or operation
- possibly extend this warning beyond C++

Depends on D107291 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107294

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExpr.cpp
  clang/test/Parser/warn-use-alternative-tokens.c
  clang/test/Parser/warn-use-alternative-tokens.cpp
  clang/test/Sema/vector-gcc-compat.cpp

Index: clang/test/Sema/vector-gcc-compat.cpp
===
--- clang/test/Sema/vector-gcc-compat.cpp
+++ clang/test/Sema/vector-gcc-compat.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -Wno-unused-but-set-variable -std=c++11 -triple x86_64-apple-darwin10
+// RUN: %clang_cc1 %s -verify -fsyntax-only -Weverything -Wno-unused-but-set-variable -Wno-use-alternative-tokens-in-expressions -std=c++11 -triple x86_64-apple-darwin10
 
 // Test the compatibility of clang++'s vector extensions with g++'s vector
 // extensions. In comparison to the extensions available in C, the !, ?:, && and
Index: clang/test/Parser/warn-use-alternative-tokens.cpp
===
--- /dev/null
+++ clang/test/Parser/warn-use-alternative-tokens.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wuse-alternative-tokens-in-expressions -verify %s
+
+void f1()
+{
+  (void)(true && false); // expected-warning{{use 'and' for logical conjunctions}}
+  (void)(true and false); // no warning
+
+  (void)(0 & 1); // expected-warning{{use 'bitand' for bitwise conjunctions}}
+  (void)(0 bitand 1); // no warning
+
+  (void)(0 | 1); // expected-warning{{use 'bitor' for bitwise disjunctions}}
+  (void)(0 bitor 1); // no warning
+
+  (void)(~0); // expected-warning{{use 'compl' for bitwise negation}}
+  (void)(compl 0); // no warning
+
+  (void)(!false); // expected-warning{{use 'not' for logical negation}}
+  (void)(not false); // no warning
+
+  (void)(false || true); // expected-warning{{use 'or' for logical disjunctions}}
+  (void)(false or true); // no warning
+
+  (void)(0 ^ 1); // expected-warning{{use 'xor' for exclusive or}}
+  (void)(0 xor 1); // no warning
+}
+
+template
+requires true && false // expected-warning{{use 'and' for logical conjunctions}}
+void f2();
+
+template
+requires true and false // no warning
+void f2();
+
+template
+requires true || false // expected-warning{{use 'or' for logical disjunctions}}
+void f3();
+
+template
+requires true or false // no warning
+void f3();
+
+template
+requires (!true) // expected-warning{{use 'not' for logical negation}}
+void f4();
+
+template
+requires (not true) // no warning
+void f4();
+
+struct S {
+  S operator and(S) const;
+  S operator bitand(S) const;
+  S operator bitor(S) const;
+  S operator compl() const;
+  S operator not() const;
+  S operator or(S) const;
+  S operator xor(S) const;
+};
+
+void f5()
+{
+  S x;
+  S y;
+
+  (void)(x && y); // expected-warning{{use 'and' for logical conjunctions}}
+  (void)(x and y); // no warning
+
+  (void)(x & y); // expected-warning{{use 'bitand' for bitwise conjunctions}}
+  (void)(x bitand y); // no warning
+
+  (void)(x | y); // expected-warning{{use 'bitor' for bitwise disjunctions}}
+  (void)(x bitor y); // no warning
+
+  (void)(~x); // expected-warning{{use 'compl' for bitwise negation}}
+  (void)(compl x); // no warning
+
+  (void)(!x); // expected-warning{{use 'not' for logical negation}}
+  (void)(not x); // no warning
+
+  (void)(x || y); // expected-warning{{use 'or' for logical disjunctions}}
+  (void)(x or y); // no warning
+
+  (void)(x ^ y); // expected-warning{{use 'xor' for exclusive or}}
+  (void)(x xor y); // no warning
+}
Index: clang/test/Parser/warn-use-alternative-tokens.c
===
--- /dev/null
+++ clang/test/Parser/warn-use-alternative-tokens.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -Wuse-alternative-tokens-in-expressions -verify %s
+
+// expected-no-diagnostics
+
+void f1()
+{
+  (void)(1 && 0);
+  (void)(0 & 1);
+  (void)(0 | 1);
+  (void)(~0);
+  (void)(!0);
+  (void)(0 || 1);
+  (void)(0 ^ 1);
+}
Index: clang/lib/Parse/ParseExpr.cpp
===

[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens as references

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/test/Parser/warn-declare-references-with-symbols.cpp:2
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeclare-references-with-symbols 
-verify %s
+

I'm pretty confident there's a lit way for me to test specific lines with 
specific C++ modes, but I can't find it :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292

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


[PATCH] D107294: [clang] adds warning to suggest users replace symbols with alt tokens

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The usual community viewpoint on off-by-default diagnostics is that they're 
generally low value and not something that users will manually enable. Because 
I don't think this will ever be reasonable to enable by default due to it 
inherently being a matter of style, I think this functionality is better 
handled by clang-tidy as a check in the `readability` module. I would note that 
it should also be supported in C (C99 and later) by also inserting `#include 
` using the usual fix-it utilities.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107294

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


[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens as references

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1552
+  "use '%select{&|&&}0' when declaring %select{lvalue|rvalue and forwarding}1 
references">,
+  InGroup>, DefaultWarn;
+

Pretty sure you don't need `DefaultWarn` here (I think you'd use that for 
warnings that are off by default, like ones spelled with `Extension` instead of 
`Warning` or `ExtWarn`).



Comment at: clang/lib/Parse/ParseDecl.cpp:5847-5849
+constexpr int AmpAmp = 1;
+Diag(Loc, diag::warn_declare_references_with_symbols)
+<< AmpAmp << AmpAmp;

For consistency with the `Lvalue` case above.



Comment at: clang/test/Parser/warn-declare-references-with-symbols.cpp:2
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeclare-references-with-symbols 
-verify %s
+

cjdb wrote:
> I'm pretty confident there's a lit way for me to test specific lines with 
> specific C++ modes, but I can't find it :(
Are you thinking of `-verify=prefix` and `// prefix-warning {{whatever}}` 
combinations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292

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


[PATCH] D107296: Treat inttypes.h as a built-in header

2021-08-02 Thread Mark Rowe via Phabricator via cfe-commits
markrowe created this revision.
markrowe requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It wraps a system header. This allows the system module map to declare a
module for it.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107296

Files:
  clang/lib/Lex/ModuleMap.cpp


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -375,6 +375,7 @@
 bool ModuleMap::isBuiltinHeader(StringRef FileName) {
   return llvm::StringSwitch(FileName)
.Case("float.h", true)
+   .Case("inttypes.h", true)
.Case("iso646.h", true)
.Case("limits.h", true)
.Case("stdalign.h", true)


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -375,6 +375,7 @@
 bool ModuleMap::isBuiltinHeader(StringRef FileName) {
   return llvm::StringSwitch(FileName)
.Case("float.h", true)
+   .Case("inttypes.h", true)
.Case("iso646.h", true)
.Case("limits.h", true)
.Case("stdalign.h", true)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107291: [clang][lexer] adds a way for tokens to track their physical spelling

2021-08-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

A few questions, also for @aaron.ballman

Can we have a "isDigraph" flag instead of keeping a pointer for the spelling?

Do we maybe want to promote `and` etc to proper keywords and maybe add 
functions to check `isAndOrAmpAmp` ? so that we can in the future make `void 
f(auto and)` ill-formed in the committee?
This second solution is more long term and maybe the patch is good enough as an 
intermediate step




Comment at: clang/lib/Lex/Lexer.cpp:3594
   Kind = tok::ampamp;
+  // Result.setSpelling(CurPtr - 1);
   CurPtr = ConsumeChar(CurPtr, SizeTmp, Result);

Did you intend to remove these?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107291

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


[PATCH] D106302: Implement P1937 consteval in unevaluated contexts

2021-08-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@rsmith Ping again! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106302

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


[PATCH] D107291: [clang][lexer] adds a way for tokens to track their physical spelling

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You should always be able to go back to the token's spelling through the 
`SourceManager` object. Is there a reason why 
`SourceManager::getCharacterData()` is insufficient? I'm a bit worried about 
adding another pointer to `Token` because we sometimes store these in 
containers (like we do for cached tokens), so the overhead might be noticeable 
(or it might not, I don't know).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107291

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


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

2021-08-02 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 363498.
gandhi21299 added a comment.

correction in the CUDA LIT check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  clang/test/CodeGenOpenCL/fp-atomics-optremarks-gfx90a.cl
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll

Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -16,15 +16,20 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Type-Based Alias Analysis
 ; CHECK-NEXT: Scoped NoAlias Alias Analysis
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -10,13 +10,18 @@
 ; CHECK-NEXT: Target Pass Configuration
 ; CHECK-NEXT: Machine Module Information
 ; CHECK-NEXT: Target Transform Information
+; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Create Garbage Collector Module Metadata
 ; CHECK-NEXT: Assumption Cache Tracker
-; CHECK-NEXT: Profile summary info
 ; CHECK-NEXT: Machine Branch Probability Analysis
 ; CHECK-NEXT:   ModulePass Manager
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
+; CHECK-NEXT:   Dominator Tree Construction 
+; CHECK-NEXT:   Natural Loop Information 
+; CHECK-NEXT:   Lazy Branch Probability Analysis 
+; CHECK-NEXT:   Lazy Block Frequency Analysis 
+; CHECK-NEXT:   Optimization Remark Emitter
 ; CHECK-NEXT:   Expand Atomic instructions
 ; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
===
--- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
@@ -44,6 +44,11 @@
 ; GCN-O0-NEXT:Lower OpenCL enqueued blocks
 ; GCN-O0-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O0-NEXT:FunctionPass Manager
+; GCN-O0-NEXT:  Dominator Tree Construction
+; GCN-O0-NEXT:  Natural Loop Information
+; GCN-O0-NEXT:  Lazy Branch Probability Analysis
+; GCN-O0-NEXT:  Lazy Block Frequency Analysis
+; GCN-O0-NEXT:  Optimization Remark Emitter
 ; GCN-O0-NEXT:  Expand Atomic instructions
 ; GCN-O0-NEXT:  Lower constant intrinsics
 ; GCN-O0-NEXT:  Remove unreachable blocks from the CFG
@@ -180,6 +185,11 @@
 ; GCN-O1-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-NEXT:FunctionPass Manager
 ; GCN-O1-NEXT:  Infer address spaces
+; GCN-O1-NEXT:  Dominator Tree Construction
+; GCN-O1-NEXT:  Natural Loop Information
+; GCN-O1-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-NEXT:  Optimization Remark Emitter
 ; GCN-O1-NEXT:  Expand Atomic instructions
 ; GCN-O1-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-NEXT:  Dominator Tree Construction
@@ -431,6 +441,11 @@
 ; GCN-O1-OPTS-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O1-OPTS-NEXT:FunctionPass Manager
 ; GCN-O1-OPTS-NEXT:  Infer address spaces
+; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
+; GCN-O1-OPTS-NEXT:  Natural Loop Information
+; GCN-O1-OPTS-NEXT:  Lazy Branch Probability Analysis
+; GCN-O1-OPTS-NEXT:  Lazy Block Frequency Analysis
+; GCN-O1-OPTS-NEXT:  Optimization Remark Emitter
 ; GCN-O1-OPTS-NEXT:  Expand Atomic instructions
 ; GCN-O1-OPTS-NEXT:  AMDGPU Promote Alloca
 ; GCN-O1-OPTS-NEXT:  Dominator Tree Construction
@@ -715,6 +730,11 @@
 ; GCN-O2-NEXT:Lower uses of LDS variables from non-kernel functions
 ; GCN-O2-NEXT:FunctionPass Manager
 ; GCN-O2-NEXT:  Infer address spaces
+; GCN-O2-NEXT:  Dominator Tree Construction
+; GCN-O2-NEXT:  N

[clang] 635c5ba - [AMDGPU][HIP] Switch default DWARF version to 5

2021-08-02 Thread Scott Linder via cfe-commits
Author: Scott Linder
Date: 2021-08-02T18:04:01Z
New Revision: 635c5ba45baee5c6a8841fbac06f6868ddae5a6d

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

LOG: [AMDGPU][HIP] Switch default DWARF version to 5

Another attempt at changing this default, now that tooling has greater
support for DWARF 5.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/HIP.h
clang/test/Driver/amdgpu-toolchain.c
clang/test/Driver/hip-toolchain-dwarf.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index a4bcf315ca76..b93d554683ff 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -60,7 +60,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
 public:
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
 

diff  --git a/clang/lib/Driver/ToolChains/HIP.h 
b/clang/lib/Driver/ToolChains/HIP.h
index 3cced0a320dc..00df4a5addb0 100644
--- a/clang/lib/Driver/ToolChains/HIP.h
+++ b/clang/lib/Driver/ToolChains/HIP.h
@@ -92,7 +92,7 @@ class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public 
ROCMToolChain {
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList &Args) const override;
 
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
 
   const ToolChain &HostTC;
   void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;

diff  --git a/clang/test/Driver/amdgpu-toolchain.c 
b/clang/test/Driver/amdgpu-toolchain.c
index ac558e0e26eb..cb92744eee6a 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -8,7 +8,7 @@
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s

diff  --git a/clang/test/Driver/hip-toolchain-dwarf.hip 
b/clang/test/Driver/hip-toolchain-dwarf.hip
index 44d66fe52e04..c853d5cf07cf 100644
--- a/clang/test/Driver/hip-toolchain-dwarf.hip
+++ b/clang/test/Driver/hip-toolchain-dwarf.hip
@@ -6,4 +6,4 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 %s \
 // RUN:   -Xarch_gfx803 -g 2>&1 | FileCheck %s -check-prefix=DWARF_VER
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"



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


[PATCH] D107190: [AMDGPU][HIP] Switch default DWARF version to 5

2021-08-02 Thread Scott Linder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG635c5ba45bae: [AMDGPU][HIP] Switch default DWARF version to 
5 (authored by scott.linder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107190

Files:
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/Driver/amdgpu-toolchain.c
  clang/test/Driver/hip-toolchain-dwarf.hip


Index: clang/test/Driver/hip-toolchain-dwarf.hip
===
--- clang/test/Driver/hip-toolchain-dwarf.hip
+++ clang/test/Driver/hip-toolchain-dwarf.hip
@@ -6,4 +6,4 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 %s \
 // RUN:   -Xarch_gfx803 -g 2>&1 | FileCheck %s -check-prefix=DWARF_VER
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -8,7 +8,7 @@
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
Index: clang/lib/Driver/ToolChains/HIP.h
===
--- clang/lib/Driver/ToolChains/HIP.h
+++ clang/lib/Driver/ToolChains/HIP.h
@@ -92,7 +92,7 @@
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList &Args) const override;
 
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
 
   const ToolChain &HostTC;
   void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -60,7 +60,7 @@
 public:
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
 


Index: clang/test/Driver/hip-toolchain-dwarf.hip
===
--- clang/test/Driver/hip-toolchain-dwarf.hip
+++ clang/test/Driver/hip-toolchain-dwarf.hip
@@ -6,4 +6,4 @@
 // RUN:   -x hip --cuda-gpu-arch=gfx803 %s \
 // RUN:   -Xarch_gfx803 -g 2>&1 | FileCheck %s -check-prefix=DWARF_VER
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -8,7 +8,7 @@
 // AS_LINK: clang{{.*}} "-cc1as"
 // AS_LINK: ld.lld{{.*}} "-shared"
 
-// DWARF_VER: "-dwarf-version=4"
+// DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### -target amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -flto %s 2>&1 | FileCheck -check-prefix=LTO %s
Index: clang/lib/Driver/ToolChains/HIP.h
===
--- clang/lib/Driver/ToolChains/HIP.h
+++ clang/lib/Driver/ToolChains/HIP.h
@@ -92,7 +92,7 @@
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList &Args) const override;
 
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
 
   const ToolChain &HostTC;
   void checkTargetID(const llvm::opt::ArgList &DriverArgs) const override;
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -60,7 +60,7 @@
 public:
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
-  unsigned GetDefaultDwarfVersion() const override { return 4; }
+  unsigned GetDefaultDwarfVersion() const override { return 5; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D107294: [clang] adds warning to suggest users replace symbols with alt tokens

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

In D107294#2920355 , @aaron.ballman 
wrote:

> The usual community viewpoint on off-by-default diagnostics is that they're 
> generally low value and not something that users will manually enable.

I was under the impression many warnings weren't enabled by default?

> I think this functionality is better handled by clang-tidy

Ack. I've not touched clang-tidy yet; how different do you expect the code to 
look to what I've got right now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107294

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


[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2021-08-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D86671#2920294 , @dougpuob wrote:

> In D86671#2919077 , @thakis wrote:
>
>> This breaks tests on windows: http://45.33.8.238/win/43180/step_8.txt
>>
>> "The command line is too long" Maybe some arts could be passed via a 
>> response file instead?
>
> Hi @thakis :
> Thank you.
>
> I'm a newbie. I tried to arc diff but arc shows `ERR_CLOSED: This revision 
> has already been closed.`. Should I create a new differential diff for it?

Yes :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D107291: [clang][lexer] adds a way for tokens to track their physical spelling

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

In D107291#2920408 , @aaron.ballman 
wrote:

> You should always be able to go back to the token's spelling through the 
> `SourceManager` object. Is there a reason why 
> `SourceManager::getCharacterData()` is insufficient? I'm a bit worried about 
> adding another pointer to `Token` because we sometimes store these in 
> containers (like we do for cached tokens), so the overhead might be 
> noticeable (or it might not, I don't know).

I found it very strange that there wasn't already a way for me to do this. 
Thanks, I've abandoned this patch and will adjust the dependents accordingly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107291

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


[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens as references

2021-08-02 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:5847-5849
+constexpr int AmpAmp = 1;
+Diag(Loc, diag::warn_declare_references_with_symbols)
+<< AmpAmp << AmpAmp;

aaron.ballman wrote:
> For consistency with the `Lvalue` case above.
I originally had `Rvalue`, but this is //technically// diagnosing both rvalue 
refs and forwarding refs (hence the awkward name). I guess it doesn't really 
matter at the parsing stage though, so this is just commentary.



Comment at: clang/test/Parser/warn-declare-references-with-symbols.cpp:2
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeclare-references-with-symbols 
-verify %s
+

aaron.ballman wrote:
> cjdb wrote:
> > I'm pretty confident there's a lit way for me to test specific lines with 
> > specific C++ modes, but I can't find it :(
> Are you thinking of `-verify=prefix` and `// prefix-warning {{whatever}}` 
> combinations?
I thought it was possible to do have a RUN line where C++98 mode would only 
check lines 4-17, for example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292

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


[PATCH] D106614: [Clang] add btf_tag attribute

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2019
+targets. This attribute may be attached to a struct/union, struct/union field,
+function, function argument or variables declaration. If -g is specified,
+the ``ARGUMENT`` info will be preserved in IR and be emitted to dwarf.





Comment at: clang/include/clang/Basic/AttrDocs.td:2021
+the ``ARGUMENT`` info will be preserved in IR and be emitted to dwarf.
+For BPF target, the ``ARGUMENT`` info will be emitted to .BTF ELF section too.
+  }];





Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6841
+  if (auto *Rec = dyn_cast(D)) {
+if (!Rec->isCompleteDefinition()) {
+  S.Diag(AL.getLoc(), diag::warn_btftag_attribute_fwd_decl_ignored) << Str;

Does this work for code like:
```
struct __attribute__((btf_tag(""))) S {
  int x;
};
```
(I didn't see a test case for the attribute being written in that location.)



Comment at: clang/test/Sema/attr-btf_tag.c:31
+
+int __tag2 foo(struct t1 *arg); // expected-warning {{attribute 
'btf_tag("tag2")' ignored as not in later redeclaration or definition}}
+int __tag foo(struct t1 *arg);

This looks backwards to me -- I think the initial declaration of `foo()` is 
fine and shouldn't be diagnosed, it's the subsequent declarations of `foo()` 
with a different `btf_tag` argument that should be diagnosed.

I think additional test cases for these semantics is:
```
void bar();
void __tag bar(); // (I think I understood that you want this to diagnose.)

void __tag bar();
void bar(); // (But that you don't want this to diagnose.)
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106614

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


[PATCH] D107294: [clang] adds warning to suggest users replace symbols with alt tokens

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D107294#2920477 , @cjdb wrote:

> In D107294#2920355 , @aaron.ballman 
> wrote:
>
>> The usual community viewpoint on off-by-default diagnostics is that they're 
>> generally low value and not something that users will manually enable.
>
> I was under the impression many warnings weren't enabled by default?

We certainly have some! My understanding is that many of those were added 
before we realized most people don't actually enable off-by-default warnings, 
so it's only "recently" (within the past 5-10 years) that we've pushed back 
more consistently on off-by-default diagnostics (and even then, we still allow 
them sometimes; `-Wfallthrough` is a good example of that).

>> I think this functionality is better handled by clang-tidy
>
> Ack. I've not touched clang-tidy yet; how different do you expect the code to 
> look to what I've got right now?

Because you're doing this at the AST node level, I would expect it to be pretty 
easy. If you want to do it within preprocessor expressions (or other places 
where the information isn't in the AST node), it's still doable but might be a 
bit more complex.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107294

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


[PATCH] D99353: [driver] Make `clang` warn rather then error on `flang` options

2021-08-02 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a subscriber: rsmith.
awarzynski added a comment.

In D99353#2919774 , @tstellar wrote:

> This is something we could merge, just need a code owner ack.

Let me add @rsmith as a reviewer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99353

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


[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens as references

2021-08-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:5847-5849
+constexpr int AmpAmp = 1;
+Diag(Loc, diag::warn_declare_references_with_symbols)
+<< AmpAmp << AmpAmp;

cjdb wrote:
> aaron.ballman wrote:
> > For consistency with the `Lvalue` case above.
> I originally had `Rvalue`, but this is //technically// diagnosing both rvalue 
> refs and forwarding refs (hence the awkward name). I guess it doesn't really 
> matter at the parsing stage though, so this is just commentary.
Oh, good point on forwarding refs. Maybe change the previous one to `Amp` in 
that case?



Comment at: clang/test/Parser/warn-declare-references-with-symbols.cpp:2
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdeclare-references-with-symbols 
-verify %s
+

cjdb wrote:
> aaron.ballman wrote:
> > cjdb wrote:
> > > I'm pretty confident there's a lit way for me to test specific lines with 
> > > specific C++ modes, but I can't find it :(
> > Are you thinking of `-verify=prefix` and `// prefix-warning {{whatever}}` 
> > combinations?
> I thought it was possible to do have a RUN line where C++98 mode would only 
> check lines 4-17, for example.
Ah, I usually use `#if __cplusplus < NN` in the code for that sort of thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292

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


[PATCH] D106216: Disallow narrowing conversions to bool in explicit specififers.

2021-08-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 363534.
cor3ntin added a comment.

Fix tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106216

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/except/except.spec/p1.cpp
  clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
  clang/test/SemaCXX/cxx2a-explicit-bool.cpp
  clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1296,7 +1296,7 @@
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5";>P1401R5
-  Clang 13
+  Clang 13
 
 
   Trimming whitespaces before line splicing
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -876,7 +876,7 @@
   EXPECT_TRUE(
   matches("void foo() noexcept; bool bar = noexcept(foo());", NoExcept));
   EXPECT_TRUE(notMatches("void foo() noexcept;", NoExcept));
-  EXPECT_TRUE(notMatches("void foo() noexcept(1+1);", NoExcept));
+  EXPECT_TRUE(notMatches("void foo() noexcept(0+1);", NoExcept));
   EXPECT_TRUE(matches("void foo() noexcept(noexcept(1+1));", NoExcept));
 }
 
Index: clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
===
--- clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
+++ clang/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp
@@ -151,7 +151,7 @@
 void (*q[])() = { p... };
 consume((p(),0)...);
   }
-  template void g(void (*...p)() noexcept (B)) {
+  template  void g(void (*...p)() noexcept(B)) {
 consume((p(),0)...);
 check();
   }
Index: clang/test/SemaCXX/cxx2a-explicit-bool.cpp
===
--- clang/test/SemaCXX/cxx2a-explicit-bool.cpp
+++ clang/test/SemaCXX/cxx2a-explicit-bool.cpp
@@ -727,3 +727,18 @@
 Str b = "not so short";// expected-error {{no viable conversion}}
 
 }
+
+namespace P1401 {
+
+const int *ptr;
+
+struct S {
+  explicit(sizeof(char[2])) S(char); // expected-error {{explicit specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+  explicit(ptr) S(long); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
+  explicit(nullptr) S(int);  // expected-error {{conversion from 'nullptr_t' to 'bool' is not allowed in a converted constant expression}}
+  explicit(42L) S(int, int); // expected-error {{explicit specifier argument evaluates to 42, which cannot be narrowed to type 'bool'}}
+  explicit(sizeof(char)) S();
+  explicit(0) S(char, char);
+  explicit(1L) S(char, char, char);
+};
+} // namespace P1401
Index: clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
===
--- clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
+++ clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
@@ -77,6 +77,17 @@
 }
 
 struct pr_44514 {
-  // expected-error@+1{{value of type 'void' is not contextually convertible to 'bool'}}
+  // expected-error@+1{{value of type 'void' is not implicitly convertible to 'bool'}}
   void foo(void) const &noexcept(f());
 };
+
+namespace P1401 {
+const int *ptr = nullptr;
+void f() noexcept(sizeof(char[2])); // expected-error {{noexcept specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+void g() noexcept(sizeof(char));
+void h() noexcept(ptr); // expected-error {{conversion from 'const int *' to 'bool' is not allowed in a converted constant expression}}
+void i() noexcept(nullptr); // expected-error {{conversion from 'nullptr_t' to 'bool' is not allowed in a converted constant expression}}
+void j() noexcept(0);
+void k() noexcept(1);
+void l() noexcept(2); // expected-error {{noexcept specifier argument evaluates to 2, which cannot be narrowed to type 'bool'}}
+} // namespace P1401
Index: clang/test/CXX/except/except.spec/p1.cpp
===
--- clang/test/CXX/except/except.spec/p1.cpp
+++ clang/test/CXX/except/except.spec/p1.cpp
@@ -54,9 +54,8 @@
 
   struct A {};
 
-  void g1() noexcept(A()); // expected-error {{not contextually convertible}}
-  void g2(bool b) noexcept(b); // expected-error {{argument to noexcept specifier must be a constant expression}} expected-note {{function parameter 'b' with unknown value}} expected-note {{here}}
-
+  void g1() noexcept(A()); // exp

[PATCH] D106252: Make simple requirements starting with requires ill-formed in in requirement body

2021-08-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@Quuxplusone Are you happy with the fix? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106252

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


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

2021-08-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

First I did not say "code doesn't make much sense to me".  This is copy form 
your description.

Okay, thank for explanation.   So if I understand right, both gcc and icc 
generated code is not making sense to you.  So instead, you want clang give 
error for this when output size greater than input size.
A question:
What about input size greater than output size?  It seems the error already 
emit for that case in Sema.   Should also handle the same with your case in 
Sema?




Comment at: clang/lib/Sema/SemaStmtAsm.cpp:670
+OutputConstraintInfos[TiedTo].allowsRegister() &&
+(OutputDomain != AD_Other || OutSize <= InSize))
   continue;

Why not emit error in here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107141

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


[PATCH] D107200: Stop emit incomplete type error for a variable in an omp map clause where should not.

2021-08-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 363538.
jyu2 added a comment.

Fix format problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107200

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_shared_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_shared_messages.cpp
  clang/test/OpenMP/distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_messages.cpp
  clang/test/OpenMP/distribute_simd_linear_messages.cpp
  clang/test/OpenMP/distribute_simd_reduction_messages.cpp
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_parallel_map_messages.cpp
  clang/test/OpenMP/target_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_distribute_simd_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_lastprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_lastprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_reduction_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_shared_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_aligned_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_lastprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_reduction_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_shared_messages.cpp
  clang/test/OpenMP/teams_distribute_reduction_messages.cpp
  clang/test/OpenMP/teams_distribute_shared_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_aligned_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_lastprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_linear_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_reduction_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_shared_messages.cpp
  clang/test/OpenMP/teams_firstprivate_messages.cpp
  clang/test/OpenMP/teams_reduction_messages.cpp
  clang/test/OpenMP/teams_shared_messages.cpp

Index: clang/test/OpenMP/teams_shared_messages.cpp
===
--- clang/test/OpenMP/teams_shared_messages.cpp
+++ clang/test/OpenMP/teams_shared_messages.cpp
@@ -8,8 +8,7 @@
 bool foobool(int argc) {
   return argc;
 }
-
-struct S1; // expected-note {{declared here}}
+struct S1; // expected-note {{declared here}}  // expected-note {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
   mutable int a;
Index: clang/test/OpenMP/teams_reduction_messages.cpp
===
--- clang/test/OpenMP/teams_reduction_messages.cpp
+++ clang/test/OpenMP/teams_reduction_messages.cpp
@@ -34,7 +34,7 @@
   foo();
 }
 
-struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
+struct S1; // expected-note {{declared here}} expected-note 6 {{forward declaration of 'S1'}}
 extern S1 a;
 class S2 {
   mutable int a;
Index: clang/test/OpenMP/teams_firstprivate_messages.cpp
===
--- clang/test/OpenMP/teams_firstprivate_messages.cpp
+++ clang/test/OpenMP/teams_firstprivate_messages.cpp
@@ -18,7 +18,7 @@
 ;
 }
 
-struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
+struct S1; // expected-note {{declared here}} expected-note 2 {{forward declaration of '

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2021-08-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

you can reopen the revision via "Add Action..."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


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

2021-08-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

Sounds good to me


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

https://reviews.llvm.org/D107155

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


[PATCH] D105478: [clang] Make CXXRecrdDecl invalid if it contains any undeduced fields.

2021-08-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105478

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


[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-08-02 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag updated this revision to Diff 363542.
AMDChirag added a comment.

minor fix in test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93373

Files:
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/taskloop_simd_ast_print.cpp
  flang/lib/Semantics/resolve-directives.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/omp-taskgroup01.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -473,8 +473,8 @@
 }
 def OMP_TaskGroup : Directive<"taskgroup"> {
   let allowedClauses = [
-VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Flush : Directive<"flush"> {
Index: flang/test/Semantics/omp-taskgroup01.f90
===
--- /dev/null
+++ flang/test/Semantics/omp-taskgroup01.f90
@@ -0,0 +1,49 @@
+! RUN: %S/test_errors.sh %s %t %flang -fopenmp
+! REQUIRES: shell
+
+use omp_lib
+  implicit none
+  integer :: xyz, abc
+  real :: reduction_var
+  !$omp parallel num_threads(4)
+!$omp single
+  print *, "The"
+!$omp taskgroup
+  !$omp task
+  print *, "almighty"
+  !$omp end task
+  !$omp task
+  print *, "sun"
+  !$omp end task
+!$omp end taskgroup
+!$omp end single
+  !$omp end parallel
+
+  !$omp parallel private(xyz)
+!$omp taskgroup allocate(xyz)
+  !$omp task
+print *, "The "
+!$omp taskgroup allocate(omp_large_cap_mem_space: abc)
+  !$omp task
+  print *, "almighty sun"
+  !$omp end task
+!$omp end taskgroup
+  !$omp end task
+!$omp end taskgroup
+  !$omp end parallel
+
+  !ERROR: PRIVATE clause is not allowed on the TASKGROUP directive
+  !$omp taskgroup private(abc)
+  !$omp end taskgroup
+
+  !$omp parallel
+!$omp task
+  !$omp taskgroup task_reduction(+ : reduction_var)
+  print *, "The "
+!$omp taskgroup task_reduction(.or. : reduction_var) task_reduction(.and. : reduction_var)
+  print *, "almighty sun"
+!$omp end taskgroup
+  !$omp end taskgroup
+!$omp end task
+  !$omp end parallel
+end program
\ No newline at end of file
Index: flang/lib/Semantics/resolve-names.cpp
===
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -1288,6 +1288,7 @@
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_master:
   case llvm::omp::Directive::OMPD_ordered:
+  case llvm::omp::Directive::OMPD_taskgroup:
 return false;
   default:
 return true;
Index: flang/lib/Semantics/resolve-directives.cpp
===
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -1069,12 +1069,12 @@
   case llvm::omp::Directive::OMPD_target:
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_task:
+  case llvm::omp::Directive::OMPD_taskgroup:
   case llvm::omp::Directive::OMPD_teams:
   case llvm::omp::Directive::OMPD_workshare:
   case llvm::omp::Directive::OMPD_parallel_workshare:
   case llvm::omp::Directive::OMPD_target_teams:
   case llvm::omp::Directive::OMPD_target_parallel:
-  case llvm::omp::Directive::OMPD_taskgroup:
 PushContext(beginDir.source, beginDir.v);
 break;
   default:
Index: clang/test/OpenMP/taskloop_simd_ast_print.cpp
===
--- clang/test/OpenMP/taskloop_simd_ast_print.cpp
+++ clang/test/OpenMP/taskloop_simd_ast_print.cpp
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -DO

[PATCH] D107095: Implement #pragma clang header_unsafe

2021-08-02 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a reviewer: lattner.
beanz added a subscriber: lattner.
beanz added a comment.

+@lattner,

Chris provided some post-commit feedback on the macro deprecation patch, I'll 
address his feedback here since I'm touching the same code.

Chris' feedback is:

> /clang/lib/Lex/Preprocessor.cpp:1417 Random drive-by, but in non-LTO builds 
> of clang, this is adding an unnecessary call/return on the expansion path for 
> all non-deprecated macros (the common case).  I'd recommend something like:
>
> // Inline in header:
> void emitMacroExpansionWarnings(const Token &Identifier) {
>  if (Identifier.getIdentifierInfo()->isDeprecatedMacro())
>
>   emitMacroExpansionWarningsImpl(Identifier);
>
> }
>
> and then put emitMacroExpansionWarningsImpl in the .cpp file.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107095

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


  1   2   >