[PATCH] D78598: [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

2020-04-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> Is there an easy way to transplant patches written against the old repo, into 
> the new one?

I don't know whether there is an easy way, I'd just copy the changed file from 
the old repo to new repo, and regenerate a diff, I think this is not too 
terrible given that we don't have too much source files in our extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78598



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


[PATCH] D78598: [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

2020-04-22 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 for doing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78598



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-04-22 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv added a comment.

@dexonsmith, @erik.pilkington - how about this ?

Z7my_mainv_block_invoke_ZTSi_ZTSj_ZTSPVK3sss

demangled as:

invocation function for block with params '(int, unsigned int, sss const 
volatile*)' in my_main()


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

https://reviews.llvm.org/D74813



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-04-22 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv updated this revision to Diff 259181.

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

https://reviews.llvm.org/D74813

Files:
  clang/lib/AST/Mangle.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h


Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -5524,14 +5524,35 @@
 Node *Encoding = getDerived().parseEncoding();
 if (Encoding == nullptr || !consumeIf("_block_invoke"))
   return nullptr;
-bool RequireNumber = consumeIf('_');
-if (parseNumber().empty() && RequireNumber)
-  return nullptr;
+
+OutputStream ParamOS;
+if (!initializeOutputStream(nullptr, nullptr, ParamOS, 1024)) {
+  std::terminate();
+}
+
+while (consumeIf("_ZTS")) {
+  Node *paramType = getDerived().parseType();
+  ParamOS += ParamOS.empty() ? "(" : ", ";
+
+  paramType->print(ParamOS);
+}
+if (!ParamOS.empty()) {
+  ParamOS += ")";
+}
+
 if (look() == '.')
   First = Last;
 if (numLeft() != 0)
   return nullptr;
-return make("invocation function for block in ", Encoding);
+
+OutputStream DescOS;
+if (!initializeOutputStream(nullptr, nullptr, DescOS, 1024)) {
+  std::terminate();
+}
+DescOS += "invocation function for block with params '";
+DescOS += ParamOS.getBuffer();
+DescOS += "' in ";
+return make(DescOS.getBuffer(), Encoding);
   }
 
   Node *Ty = getDerived().parseType();
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -36,11 +36,14 @@
 StringRef Outer,
 const BlockDecl *BD,
 raw_ostream &Out) {
-  unsigned discriminator = Context.getBlockId(BD, true);
-  if (discriminator == 0)
-Out << "__" << Outer << "_block_invoke";
-  else
-Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+  Out << "__" << Outer << "_block_invoke";
+
+  ArrayRef params = BD->parameters();
+  for(unsigned i = 0; i < params.size(); i++) {
+ParmVarDecl *param = params[i];
+Context.mangleTypeName(param->getType(), Out);
+  }
+  llvm::raw_svector_ostream *Out2 = (llvm::raw_svector_ostream*)&Out;
 }
 
 void MangleContext::anchor() { }


Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -5524,14 +5524,35 @@
 Node *Encoding = getDerived().parseEncoding();
 if (Encoding == nullptr || !consumeIf("_block_invoke"))
   return nullptr;
-bool RequireNumber = consumeIf('_');
-if (parseNumber().empty() && RequireNumber)
-  return nullptr;
+
+OutputStream ParamOS;
+if (!initializeOutputStream(nullptr, nullptr, ParamOS, 1024)) {
+  std::terminate();
+}
+
+while (consumeIf("_ZTS")) {
+  Node *paramType = getDerived().parseType();
+  ParamOS += ParamOS.empty() ? "(" : ", ";
+
+  paramType->print(ParamOS);
+}
+if (!ParamOS.empty()) {
+  ParamOS += ")";
+}
+
 if (look() == '.')
   First = Last;
 if (numLeft() != 0)
   return nullptr;
-return make("invocation function for block in ", Encoding);
+
+OutputStream DescOS;
+if (!initializeOutputStream(nullptr, nullptr, DescOS, 1024)) {
+  std::terminate();
+}
+DescOS += "invocation function for block with params '";
+DescOS += ParamOS.getBuffer();
+DescOS += "' in ";
+return make(DescOS.getBuffer(), Encoding);
   }
 
   Node *Ty = getDerived().parseType();
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -36,11 +36,14 @@
 StringRef Outer,
 const BlockDecl *BD,
 raw_ostream &Out) {
-  unsigned discriminator = Context.getBlockId(BD, true);
-  if (discriminator == 0)
-Out << "__" << Outer << "_block_invoke";
-  else
-Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+  Out << "__" << Outer << "_block_invoke";
+
+  ArrayRef params = BD->parameters();
+  for(unsigned i = 0; i < params.size(); i++) {
+ParmVarDecl *param = params[i];
+Context.mangleTypeName(param->getType(), Out);
+  }
+  llvm::raw_svector_ostream *Out2 = (llvm::raw_svector_ostream*)&Out;
 }
 
 void MangleContext::anchor() { }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 35cf2f4 - [Driver][docs] Document option -mtune as a no-op.

2020-04-22 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-04-22T09:15:48+01:00
New Revision: 35cf2f42dda4d708741e06570b2dbe91cec4dc41

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

LOG: [Driver][docs] Document option -mtune as a no-op.

This documents that option -mtune is accepted for compatibility with GCC,
currently it has no effect, and thus does not currently perform any CPU type
specific tuning.

Corresponding discussion on the cfe dev list:
http://lists.llvm.org/pipermail/cfe-dev/2020-April/065169.html

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

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index c7afcf7cf605..a10e747153e2 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2735,6 +2735,8 @@ Specify bit size of immediate TLS offsets (AArch64 ELF 
only): 12 (for 4KB) \| 24
 .. option:: -mtune=
 .. program:: clang
 
+Accepted for compatibility with GCC. Currently has no effect.
+
 .. option:: -mtvos-version-min=, -mappletvos-version-min=
 
 .. option:: -municode

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2ec7269372b1..f9850c60f62d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2721,7 +2721,8 @@ def muclibc : Flag<["-"], "muclibc">, 
Group, Flags<[HelpHidden]>;
 def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[DriverOption,CC1Option]>, Group,
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
-def mtune_EQ : Joined<["-"], "mtune=">, Group;
+def mtune_EQ : Joined<["-"], "mtune=">, Group,
+  HelpText<"Accepted for compatibility with GCC. Currently has no effect.">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;



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


[PATCH] D78511: [Driver][doc] Document option -mtune as a no-op. NFC.

2020-04-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35cf2f42dda4: [Driver][docs] Document option -mtune as a 
no-op. (authored by SjoerdMeijer).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78511

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2721,7 +2721,8 @@
 def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[DriverOption,CC1Option]>, Group,
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
-def mtune_EQ : Joined<["-"], "mtune=">, Group;
+def mtune_EQ : Joined<["-"], "mtune=">, Group,
+  HelpText<"Accepted for compatibility with GCC. Currently has no effect.">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -2735,6 +2735,8 @@
 .. option:: -mtune=
 .. program:: clang
 
+Accepted for compatibility with GCC. Currently has no effect.
+
 .. option:: -mtvos-version-min=, -mappletvos-version-min=
 
 .. option:: -municode


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2721,7 +2721,8 @@
 def module_file_info : Flag<["-"], "module-file-info">, Flags<[DriverOption,CC1Option]>, Group,
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
-def mtune_EQ : Joined<["-"], "mtune=">, Group;
+def mtune_EQ : Joined<["-"], "mtune=">, Group,
+  HelpText<"Accepted for compatibility with GCC. Currently has no effect.">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
 def multiply__defined : Separate<["-"], "multiply_defined">;
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -2735,6 +2735,8 @@
 .. option:: -mtune=
 .. program:: clang
 
+Accepted for compatibility with GCC. Currently has no effect.
+
 .. option:: -mtvos-version-min=, -mappletvos-version-min=
 
 .. option:: -municode
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78030: [TimeProfiler] Emit clock synchronization point

2020-04-22 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop accepted this revision.
russell.gallop added a comment.

LGTM, with a few small comments.

For the record, I wondered whether the time profiler could emit all ts as 
absolute, so I tried it out. This has two problems. 1). The "Total" numbers 
also need adjusting to be at the beginning of the trace time rather than zero, 
which feels a little odd, and it hard to see how long things are on the time 
scale. 2). All of the times end up being very large numbers so this bloats 
traces considerably.




Comment at: clang/test/Driver/check-time-trace-sections.py:23
+
+# Make sure that the 'beginningOfTime' is not earlier than 10 seconds ago.
+if seconds_since_epoch - beginning_of_time > 10:

Could also check that beginningOfTime isn't after seconds_since_epoch.



Comment at: llvm/lib/Support/TimeProfiler.cpp:78
   TimeTraceProfiler(unsigned TimeTraceGranularity = 0, StringRef ProcName = "")
-  : StartTime(steady_clock::now()), ProcName(ProcName),
-Pid(sys::Process::getProcessId()), Tid(llvm::get_threadid()),
-TimeTraceGranularity(TimeTraceGranularity) {
+  : BeginningOfTime(system_clock::now()), StartTime(steady_clock::now()),
+ProcName(ProcName), Pid(sys::Process::getProcessId()),

Note that this will record BeginningOfTime for each TimeTraceProfiler started 
on a thread, but that won't be used. This shouldn't cause any harm  and I don't 
think that is very frequent so I think that this is okay.



Comment at: llvm/lib/Support/TimeProfiler.cpp:238
+
+// Emit the absolute time of the moment when this TimeProfiler started
+// measurements. This can be used to combine the profiling data from

Nit. This is a bit wordy. How about "Emit the absolute time when this 
TimeProfiler started."?


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

https://reviews.llvm.org/D78030



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


[PATCH] D78565: [clang][doc] Clang ARM CPU command line argument reference

2020-04-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer abandoned this revision.
SjoerdMeijer added a comment.

Fair enough, perhaps the audience is too small here on llvm.org for this and 
this is too niche. In A-profile we have the same problem, so could the exercise 
for an A-core here, but can't spend time on that now, so will abandon this.


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

https://reviews.llvm.org/D78565



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


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-04-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D78478#1994923 , @jdoerfert wrote:

> I feel there is a lot of good stuff here but it seems to mix two things. A 
> rewrite of the script infrastructure and the UTC_ARGS stuff. If so, do you 
> think we could split them? I feel there are also minor NFC changes that could 
> go in on their own without review, I marked on of them below.
>
> (Partially related: Does this handle the mismatch between `enabled` 
> configuration status and the flag names `enable/disable` or will it still add 
> `--enabled` to the UTC_ARGS?)


It will now read the command line flag that was specified when calling 
parser.add_argument() and should do the right thing.

I'll split out the unrelated changes to separate reviews.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78478



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


[clang-tools-extra] 161afc0 - [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

2020-04-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-22T11:11:13+02:00
New Revision: 161afc01064bd5bef42d1655f1b81b3030596527

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

LOG: [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

Summary:
Moving this out of the monorepo for consistency with other editor plugins.
There's no version lock with clangd itself, and we never ran tests with lit.

The first version from the new repo has been published.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 


Removed: 
clang-tools-extra/clangd/clients/clangd-vscode/.gitignore
clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
clang-tools-extra/clangd/clients/clangd-vscode/.vscode/settings.json
clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
clang-tools-extra/clangd/clients/clangd-vscode/.vscodeignore
clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
clang-tools-extra/clangd/clients/clangd-vscode/LICENSE
clang-tools-extra/clangd/clients/clangd-vscode/README.md
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/complete.png
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/diagnostics.png
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/extract.png
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/format.png
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/include.png
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/symbolsearch.png
clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/xrefs.png
clang-tools-extra/clangd/clients/clangd-vscode/icon.png
clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
clang-tools-extra/clangd/clients/clangd-vscode/package.json
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts

clang-tools-extra/clangd/clients/clangd-vscode/test/assets/includeTheme.jsonc
clang-tools-extra/clangd/clients/clangd-vscode/test/assets/simpleTheme.jsonc
clang-tools-extra/clangd/clients/clangd-vscode/test/extension.test.ts
clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts

clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json



diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/.gitignore 
b/clang-tools-extra/clangd/clients/clangd-vscode/.gitignore
deleted file mode 100644
index a73617e32b4b..
--- a/clang-tools-extra/clangd/clients/clangd-vscode/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-out
-node_modules
-.vscode-test

diff  --git 
a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
deleted file mode 100644
index 7d414bc00f32..
--- a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
+++ /dev/null
@@ -1,28 +0,0 @@
-// A launch configuration that compiles extension and opens it inside a new 
window.
-{
-"version": "0.1.0",
-"configurations": [
-{
-"name": "Launch Extension",
-"type": "extensionHost",
-"request": "launch",
-"runtimeExecutable": "${execPath}",
-"args": ["--extensionDevelopmentPath=${workspaceRoot}" ],
-"stopOnEntry": false,
-"sourceMaps": true,
-"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
-"preLaunchTask": "npm"
-},
-{
-"name": "Launch Tests",
-"type": "extensionHost",
-"request": "launch",
-"runtimeExecutable": "${execPath}",
-"args": ["--extensionDevelopmentPath=${workspaceRoot}", 
"--extensionTestsPath=${workspaceRoot}/out/test" ],
-"stopOnEntry": false,
-"sourceMaps": true,
-"outFiles": [ "${workspaceRoot}/out/test/**/*.js" ],
-"preLaunchTask": "npm"
-}
-]
-}

diff  --git 
a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/settings.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/settings.json
deleted file mode 100644
index d13713339847..
--- a/clang-tools-extra/clangd/clients/clangd-vscode/.vscode/settings.json
+++ /dev/null
@@ -1,9 +0,0 @@
-// Place your settings in this file to overwrite default and user settings.
-{
-"files.exclude": {
-"out": false // set this to true to hide the "out" folder with the 
comp

[PATCH] D78598: [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D78598#1995939 , @nridge wrote:

> Is there an easy way to transplant patches written against the old repo, into 
> the new one?


If you have a patch file (from git format-patch or downloaded from phab), you 
should be able to use `patch -p`

  cd vscode-clangd # new repo
  patch -p5 < old.patch

Where -p1 strips off the conventional a/ vs b/ diff prefix, and the other 4 is 
for `clang-tools-extra/clangd/clients/clangd-vscode`.
Disclaimer: haven't tried this, may be off-by-one. Sorry for the hassle!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78598



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


[PATCH] D78478: [UpdateTestChecks] Add UTC_ARGS support for update_{llc,cc}_test_checks.py

2020-04-22 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 259210.
arichardson added a comment.

Split into multiple reviews


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78478

Files:
  clang/test/utils/update_cc_test_checks/Inputs/mangled_names.c.funcsig.expected
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c
  clang/test/utils/update_cc_test_checks/Inputs/on_the_fly_arg_change.c.expected
  clang/test/utils/update_cc_test_checks/mangled_names.test
  clang/test/utils/update_cc_test_checks/on_the_fly_arg_change.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/basic.ll.expected
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/on_the_fly_arg_change.ll.expected
  llvm/test/tools/UpdateTestChecks/update_llc_test_checks/basic.test
  
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/on_the_fly_arg_change.test
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_llc_test_checks.py

Index: llvm/utils/update_llc_test_checks.py
===
--- llvm/utils/update_llc_test_checks.py
+++ llvm/utils/update_llc_test_checks.py
@@ -10,17 +10,10 @@
 from __future__ import print_function
 
 import argparse
-import glob
-import os # Used to advertise this file's name ("autogenerated_note").
-import string
-import subprocess
-import sys
-import re
+import os  # Used to advertise this file's name ("autogenerated_note").
 
 from UpdateTestChecks import asm, common
 
-ADVERT = ' NOTE: Assertions have been autogenerated by '
-
 
 def main():
   parser = argparse.ArgumentParser(description=__doc__)
@@ -40,35 +33,21 @@
   '--no_x86_scrub_mem_shuffle', action='store_true', default=False,
   help='Reduce scrubbing shuffles with memory operands')
   parser.add_argument('tests', nargs='+')
-  args = common.parse_commandline_args(parser)
+  initial_args = common.parse_commandline_args(parser)
 
   script_name = os.path.basename(__file__)
 
-  test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
-  for test in test_paths:
-with open(test) as f:
-  input_lines = [l.rstrip() for l in f]
-
-first_line = input_lines[0] if input_lines else ""
-if 'autogenerated' in first_line and script_name not in first_line:
-  common.warn("Skipping test which wasn't autogenerated by " + script_name, test)
-  continue
-
-if args.update_only:
-  if not first_line or 'autogenerated' not in first_line:
-common.warn("Skipping test which isn't autogenerated: " + test)
-continue
-
+  for ti in common.itertests(initial_args.tests, parser,
+ script_name='utils/' + script_name):
 triple_in_ir = None
-for l in input_lines:
+for l in ti.input_lines:
   m = common.TRIPLE_IR_RE.match(l)
   if m:
 triple_in_ir = m.groups()[0]
 break
 
-run_lines = common.find_run_lines(test, input_lines)
 run_list = []
-for l in run_lines:
+for l in ti.run_lines:
   if '|' not in l:
 common.warn('Skipping unparseable RUN line: ' + l)
 continue
@@ -101,7 +80,7 @@
 
   llc_cmd_args = llc_cmd[len(llc_tool):].strip()
   llc_cmd_args = llc_cmd_args.replace('< %s', '').replace('%s', '').strip()
-  if test.endswith('.mir'):
+  if ti.path.endswith('.mir'):
 llc_cmd_args += ' -x mir'
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
@@ -112,13 +91,10 @@
   # now, we just ignore all but the last.
   run_list.append((check_prefixes, llc_cmd_args, triple_in_cmd, march_in_cmd))
 
-if test.endswith('.mir'):
-  comment_sym = '#'
+if ti.path.endswith('.mir'):
   check_indent = '  '
 else:
-  comment_sym = ';'
   check_indent = ''
-autogenerated_note = (comment_sym + ADVERT + 'utils/' + script_name)
 
 func_dict = {}
 for p in run_list:
@@ -129,12 +105,12 @@
   common.debug('Extracted LLC cmd:', llc_tool, llc_args)
   common.debug('Extracted FileCheck prefixes:', str(prefixes))
 
-  raw_tool_output = common.invoke_tool(args.llc_binary, llc_args, test)
+  raw_tool_output = common.invoke_tool(ti.args.llc_binary, llc_args, ti.path)
   triple = triple_in_cmd or triple_in_ir
   if not triple:
 triple = asm.get_triple_from_march(march_in_cmd)
 
-  asm.build_function_body_dictionary_for_triple(args, raw_tool_output,
+  asm.build_function_body_dictionary_for_triple(ti.args, raw_tool_output,
   triple, prefixes, func_dict)
 
 is_in_function = False
@@ -143,9 +119,9 @@
 prefix_set = set([prefix for p in run_list for prefix in p[0]])
 common.debug('Rewriting FileCheck prefixes:', str(prefix_set))
 output_lines 

[PATCH] D78598: [clangd] Remove vscode plugin: now https://github.com/clangd/vscode-clangd

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG161afc01064b: [clangd] Remove vscode plugin: now 
https://github.com/clangd/vscode-clangd (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78598

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/.gitignore
  clang-tools-extra/clangd/clients/clangd-vscode/.vscode/launch.json
  clang-tools-extra/clangd/clients/clangd-vscode/.vscode/settings.json
  clang-tools-extra/clangd/clients/clangd-vscode/.vscode/tasks.json
  clang-tools-extra/clangd/clients/clangd-vscode/.vscodeignore
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/LICENSE
  clang-tools-extra/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/complete.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/diagnostics.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/extract.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/format.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/include.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/symbolsearch.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/xrefs.png
  clang-tools-extra/clangd/clients/clangd-vscode/icon.png
  clang-tools-extra/clangd/clients/clangd-vscode/package-lock.json
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
  clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/assets/includeTheme.jsonc
  clang-tools-extra/clangd/clients/clangd-vscode/test/assets/simpleTheme.jsonc
  clang-tools-extra/clangd/clients/clangd-vscode/test/extension.test.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/index.ts
  clang-tools-extra/clangd/clients/clangd-vscode/test/runTest.ts
  
clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
  clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json

Index: clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/tsconfig.json
+++ /dev/null
@@ -1,29 +0,0 @@
-{
-"compilerOptions": {
-"module": "commonjs",
-"target": "es6",
-"outDir": "out",
-"lib": [
-"es6",
-"es2015.core",
-"es2015.collection",
-"es2015.generator",
-"es2015.iterable",
-"es2015.promise",
-"es2015.symbol",
-"es2016.array.include"
-],
-"sourceMap": true,
-"rootDir": ".",
-"alwaysStrict": true,
-"noEmitOnError": true,
-"noFallthroughCasesInSwitch": true,
-"noImplicitAny": true,
-"noImplicitReturns": true,
-"noImplicitThis": true
-},
-"exclude": [
-"node_modules",
-".vscode-test"
-]
-}
Index: clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/test/semantic-highlighting.test.ts
+++ /dev/null
@@ -1,174 +0,0 @@
-import * as assert from 'assert';
-import * as path from 'path';
-import * as vscode from 'vscode';
-
-import * as semanticHighlighting from '../src/semantic-highlighting';
-
-suite('SemanticHighlighting Tests', () => {
-  test('Parses arrays of textmate themes.', async () => {
-const themePath =
-path.join(__dirname, '../../test/assets/includeTheme.jsonc');
-const scopeColorRules =
-await semanticHighlighting.parseThemeFile(themePath);
-const getScopeRule = (scope: string) =>
-scopeColorRules.find((v) => v.scope === scope);
-assert.equal(scopeColorRules.length, 3);
-assert.deepEqual(getScopeRule('a'), {scope : 'a', foreground : '#fff'});
-assert.deepEqual(getScopeRule('b'), {scope : 'b', foreground : '#000'});
-assert.deepEqual(getScopeRule('c'), {scope : 'c', foreground : '#bcd'});
-  });
-  test('Decodes tokens correctly', () => {
-const testCases: string[] = [
-  'AAABAAA=', 'AAADAAkEAAEAAA==',
-  'AAADAAkEAAEAAAoAAQAA'
-];
-const expected = [
-  [ {character : 0, scopeIndex : 0, length : 1} ],
-  [
-{character : 0, scopeIndex : 9, length : 3},
-{character : 4, scopeIndex : 0, length : 1}
-  ],
-  [
-{character : 0, scopeIndex : 9, length : 3},
-{character : 4, scopeIndex : 0, length : 1},
-{character : 10, scopeIndex : 0, length : 1}
-  ]
-];
-testCases.forEach(
-(testCase, i) => assert.deepEqual(
-semanticHighlighting.decodeTokens(te

[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-04-22 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

In D76801#1995058 , @dblaikie wrote:

> > It becomes a gdb-index problem because with an index the debugger will do a 
> > (hashed?) string lookup and expect the string to be there. If the strings 
> > differ, the lookup won't find anything. In the no-index scenario, the 
> > debugger has to trawl the debug info itself, and so it has some 
> > opportunities to do fuzzy matching.
>
> That surprises me a bit - given that one of the things debuggers provide is 
> autocomplete (I'm unlikely to write out a type name exactly as the debug info 
> contains it - if two compilers can't agree, it's much less likely that all 
> users will agree with any compiler rendering), which I'd have thought would 
> be facilitated by the index too - in which case lookup via exact match 
> wouldn't be viable, you'd still want a way to list anything with a matching 
> substring (or at least prefix), etc. Which could help facilitate lookup fuzzy 
> matching like in this sort of case.


That is kind of true, and I don't really have a definitive reply to that. I 
suppose there is a difference between the lookups done for type completion and 
those done e.g. in expression evaluation. The latter are probably more frequent 
and are assumed to be correct. Maybe they shouldn't be, but in that cases, then 
there would probably be no use for the hash tables in indexes (I am not very 
familiar with the gdb index, but I know it has hash tables similar to 
debug_names/apple_names). I don't know what gdb does for tab completion, but it 
probably bypasses the hash table (though the index could still be useful even 
then as it has a concise list of all strings in the debug info), or it gets the 
list of strings-to-complete from a completely different source (demangled 
function names?).

Tab completion is always a bit dodgy. E.g., in your example `ptype tmpl` 
completes to `ptype tmpl>`, but then running that produces an error: 
`No symbol "tmpl" in current context.`

In lldb, tab completion in expressions works by hooking into the regular clang 
tab-completion machinery used by editors.  The up- and down-side of that is 
that it uses the same code path used for actual expression evaluation -- i.e. 
all the types will be looked up the same (exact) way.

Speaking of templates and indexes, the thing we would really like in lldb would 
be to have just the bare names of templated class in the indexes -- that way we 
could reliably look up all instantiations of a template and do the filtering 
ourselves. However, this runs afoul of the dwarf specification, which says that 
the index names should match the DW_AT_names of relevant DIEs (and these 
contain the template arguments for other reasons...). This means that currently 
we have outstanding issues when looking up templated types, but we haven't 
really figured out what to do about that...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801



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


[PATCH] D77802: [analyzer] Improved RangeSet::Negate support of unsigned ranges

2020-04-22 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov marked an inline comment as done.
ASDenysPetrov added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:217
+
+  const llvm::APSInt sampleValue = getMinValue();
+  const bool isUnsigned = sampleValue.isUnsigned();

ASDenysPetrov wrote:
> steakhal wrote:
> > Should we take it as `const ref` to prevent copying?
> getMinValue returns APSInt by value, so it wouldn't make sense.
My fault. Yes, you are right. I've missed &. I used to append & to the type, 
since it is more readable and actually is a part of type, but I won't debate 
with clang style guide :).


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

https://reviews.llvm.org/D77802



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


[PATCH] D76929: [AArch64][SVE] Add SVE intrinsic for LD1RQ

2020-04-22 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17f6e18acf5b: [AArch64][SVE] Add SVE intrinsic for LD1RQ 
(authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76929

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
@@ -1,6 +1,179 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
 
 ;
+; LD1RQB
+;
+
+define  @ld1rqb_i8( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %addr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0, #16]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i8 16
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_lower_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_lower_bound:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0, #-128]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i8 -128
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_upper_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_upper_bound:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0, #112]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i8 112
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_out_of_lower_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_out_of_lower_bound:
+; CHECK: sub x8, x0, #129
+; CHECK-NEXT: ld1rqb { z0.b }, p0/z, [x8]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i64 -129
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_out_of_upper_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_out_of_upper_bound:
+; CHECK: add x8, x0, #113
+; CHECK-NEXT: ld1rqb { z0.b }, p0/z, [x8]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i64 113
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+;
+; LD1RQH
+;
+
+define  @ld1rqh_i16( %pred, i16* %addr) {
+; CHECK-LABEL: ld1rqh_i16:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8i16( %pred, i16* %addr)
+  ret  %res
+}
+
+define  @ld1rqh_f16( %pred, half* %addr) {
+; CHECK-LABEL: ld1rqh_f16:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8f16( %pred, half* %addr)
+  ret  %res
+}
+
+define  @ld1rqh_i16_imm( %pred, i16* %addr) {
+; CHECK-LABEL: ld1rqh_i16_imm:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0, #-64]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i16, i16* %addr, i16 -32
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8i16( %pred, i16* %ptr)
+  ret  %res
+}
+
+define  @ld1rqh_f16_imm( %pred, half* %addr) {
+; CHECK-LABEL: ld1rqh_f16_imm:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0, #-16]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds half, half* %addr, i16 -8
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8f16( %pred, half* %ptr)
+  ret  %res
+}
+
+;
+; LD1RQW
+;
+
+define  @ld1rqw_i32( %pred, i32* %addr) {
+; CHECK-LABEL: ld1rqw_i32:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4i32( %pred, i32* %addr)
+  ret  %res
+}
+
+define  @ld1rqw_f32( %pred, float* %addr) {
+; CHECK-LABEL: ld1rqw_f32:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4f32( %pred, float* %addr)
+  ret  %res
+}
+
+define  @ld1rqw_i32_imm( %pred, i32* %addr) {
+; CHECK-LABEL: ld1rqw_i32_imm:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0, #112]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i32, i32* %addr, i32 28
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4i32( %pred, i32* %ptr)
+  ret  %res
+}
+
+define  @ld1rqw_f32_imm( %pred, float* %addr) {
+; CHECK-LABEL: ld1rqw_f32_imm:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0, #32]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds float, float* %addr, i32 8
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4f32( %pred, float* %ptr)
+  ret  %res
+}
+
+;
+; LD1RQD
+;
+
+define  @ld1rqd_i64( %pred, i64* %addr) {
+; CHECK-LABEL: ld1rqd_i64:
+; CHECK: ld1rqd { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv2i64( %pred, i64* %addr)
+ 

[PATCH] D78521: [clangd] Extend dexp to support remote index

2020-04-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 259233.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

Make sure the value of `--remote` flag is stored.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78521

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.cpp
  clang-tools-extra/clangd/index/remote/Index.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/Marshalling.h
  clang-tools-extra/clangd/index/remote/client/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/client/Client.cpp
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -23,11 +23,11 @@
   find_program(PROTOC protoc)
 endif()
 
-# Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
+# Proto headers are generated in ${GeneratedFilesLocation}.
 # Libraries that use these headers should adjust the include path.
 # FIXME(kirillbobyrev): Allow optional generation of gRPC code and give callers
 # control over it via additional parameters.
-function(generate_grpc_protos LibraryName ProtoFile)
+function(generate_grpc_protos LibraryName ProtoFile GeneratedFilesLocation)
   get_filename_component(ProtoSourceAbsolutePath "${CMAKE_CURRENT_SOURCE_DIR}/${ProtoFile}" ABSOLUTE)
   get_filename_component(ProtoSourcePath ${ProtoSourceAbsolutePath} PATH)
 
@@ -35,6 +35,7 @@
   set(GeneratedProtoHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.h")
   set(GeneratedGRPCSource "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.cc")
   set(GeneratedGRPCHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.h")
+  set(${GeneratedFilesLocation} ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
   add_custom_command(
 OUTPUT "${GeneratedProtoSource}" "${GeneratedProtoHeader}" "${GeneratedGRPCSource}" "${GeneratedGRPCHeader}"
 COMMAND ${PROTOC}
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,6 +8,7 @@
 
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/remote/Marshalling.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/LineEditor/LineEditor.h"
@@ -23,6 +24,7 @@
 
 namespace clang {
 namespace clangd {
+namespace remote {
 namespace {
 
 static const std::string Overview = R"(
@@ -33,8 +35,9 @@
 llvm::cl::opt IndexPath(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
-llvm::cl::opt ServerAddress("server-address",
- llvm::cl::init("0.0.0.0:50051"));
+llvm::cl::opt ServerAddress(
+"server-address", llvm::cl::init("0.0.0.0:50051"),
+llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
 std::unique_ptr openIndex(llvm::StringRef Index) {
   return loadIndex(Index, /*UseIndex=*/true);
@@ -47,24 +50,51 @@
 
 private:
   grpc::Status Lookup(grpc::ServerContext *Context,
-  const remote::LookupRequest *Request,
-  grpc::ServerWriter *Reply) override {
-llvm::outs() << "Lookup of symbol with ID " << Request->id() << '\n';
-LookupRequest Req;
-auto SID = SymbolID::fromStr(Request->id());
-if (!SID) {
-  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
-  return grpc::Status::CANCELLED;
+  const LookupRequest *Request,
+  grpc::ServerWriter *Reply) override {
+clangd::LookupRequest Req;
+for (const auto &ID : Request->ids()) {
+  auto SID = SymbolID::fromStr(StringRef(ID));
+  if (!SID)
+return grpc::Status::CANCELLED;
+  Req.IDs.insert(*SID);
 }
-Req.IDs.insert(*SID);
-Index->lookup(Req, [&](const Symbol &Sym) {
-  remote::LookupReply NextSymbol;
-  NextSymbol.set_symbol_yaml(toYAML(Sym));
+Index->lookup(Req, [&](const clangd::Symbol &Sym) {
+  remote::Symbol NextSymbol;
+  NextSymbol.set_yaml_serializatiton(toYAML(Sym));
   Reply->Write(NextSymbol);
 });
 return grpc::Status::OK;
   }
 
+  grpc::Status FuzzyFind(grpc::ServerContext *Context,
+ const FuzzyFindRequest *Request,
+ 

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 259238.
saiislam added a comment.
Herald added subscribers: kerbowa, nhaehnle, jvesely.

Changed the builtin to be AMDGCN-specific

It is named as __builtin_amdgcn_fence(order, scope)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
  clang/test/CodeGenHIP/builtin_memory_fence.cpp
  clang/test/Sema/builtins.c
  clang/test/SemaOpenCL/builtins-amdgcn-error.cl

Index: clang/test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- clang/test/SemaOpenCL/builtins-amdgcn-error.cl
+++ clang/test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -128,3 +128,11 @@
   *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
   *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, 0, a); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
 }
+
+void test_fence() {
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
+  __builtin_amdgcn_fence(__ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
+  __builtin_amdgcn_fence(4); // expected-error {{too few arguments to function call, expected 2}}
+  __builtin_amdgcn_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
+  __builtin_amdgcn_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
+}
Index: clang/test/Sema/builtins.c
===
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -320,15 +320,3 @@
   // expected-error@+1 {{use of unknown builtin '__builtin_is_constant_evaluated'}}
   return __builtin_is_constant_evaluated();
 }
-
-void test_memory_fence_errors() {
-  __builtin_memory_fence(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
-
-  __builtin_memory_fence(__ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
-
-  __builtin_memory_fence(4); // expected-error {{too few arguments to function call, expected 2}}
-
-  __builtin_memory_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
-
-  __builtin_memory_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
-}
Index: clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
===
--- clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
+++ clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
@@ -1,25 +1,22 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 %s -x hip -emit-llvm -O0 -o - \
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - \
 // RUN:   -triple=amdgcn-amd-amdhsa  | opt -instnamer -S | FileCheck %s
 
 void test_memory_fence_success() {
 // CHECK-LABEL: test_memory_fence_success
 
   // CHECK: fence syncscope("workgroup") seq_cst
-  __builtin_memory_fence(__ATOMIC_SEQ_CST,  "workgroup");
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST,  "workgroup");
   
// CHECK: fence syncscope("agent") acquire
-  __builtin_memory_fence(__ATOMIC_ACQUIRE, "agent");
+  __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent");
 
   // CHECK: fence seq_cst
-  __builtin_memory_fence(__ATOMIC_SEQ_CST, "");
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "");
 
   // CHECK: fence syncscope("agent") acq_rel
-  __builtin_memory_fence(4, "agent");
+  __builtin_amdgcn_fence(4, "agent");
 
 // CHECK: fence syncscope("workgroup") release
-  __builtin_memory_fence(3, "workgroup");
-
-  // CHECK: fence syncscope("foobar") release
-  __builtin_memory_fence(3, "foobar");
-}
\ No newline at end of file
+  __builtin_amdgcn_fence(3, "workgroup");
+}
Index: clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: not %clang_cc1 %s -S \
+// RUN:   -triple=amdgcn-amd-amdhsa 2>&1 | FileCheck %s
+
+void test_amdgcn_fence_failure() {
+
+  // CHECK: error: Unsupported atomic synchronization scope 
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "foobar");
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaChecking.cpp
==

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 259239.
saiislam added a comment.

Removed stale commented code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
  clang/test/CodeGenHIP/builtin_memory_fence.cpp
  clang/test/Sema/builtins.c
  clang/test/SemaOpenCL/builtins-amdgcn-error.cl

Index: clang/test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- clang/test/SemaOpenCL/builtins-amdgcn-error.cl
+++ clang/test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -128,3 +128,11 @@
   *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
   *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, 0, a); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
 }
+
+void test_fence() {
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
+  __builtin_amdgcn_fence(__ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
+  __builtin_amdgcn_fence(4); // expected-error {{too few arguments to function call, expected 2}}
+  __builtin_amdgcn_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
+  __builtin_amdgcn_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
+}
Index: clang/test/Sema/builtins.c
===
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -320,15 +320,3 @@
   // expected-error@+1 {{use of unknown builtin '__builtin_is_constant_evaluated'}}
   return __builtin_is_constant_evaluated();
 }
-
-void test_memory_fence_errors() {
-  __builtin_memory_fence(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
-
-  __builtin_memory_fence(__ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
-
-  __builtin_memory_fence(4); // expected-error {{too few arguments to function call, expected 2}}
-
-  __builtin_memory_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
-
-  __builtin_memory_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
-}
Index: clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
===
--- clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
+++ clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
@@ -1,25 +1,22 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 %s -x hip -emit-llvm -O0 -o - \
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - \
 // RUN:   -triple=amdgcn-amd-amdhsa  | opt -instnamer -S | FileCheck %s
 
 void test_memory_fence_success() {
 // CHECK-LABEL: test_memory_fence_success
 
   // CHECK: fence syncscope("workgroup") seq_cst
-  __builtin_memory_fence(__ATOMIC_SEQ_CST,  "workgroup");
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST,  "workgroup");
   
// CHECK: fence syncscope("agent") acquire
-  __builtin_memory_fence(__ATOMIC_ACQUIRE, "agent");
+  __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent");
 
   // CHECK: fence seq_cst
-  __builtin_memory_fence(__ATOMIC_SEQ_CST, "");
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "");
 
   // CHECK: fence syncscope("agent") acq_rel
-  __builtin_memory_fence(4, "agent");
+  __builtin_amdgcn_fence(4, "agent");
 
 // CHECK: fence syncscope("workgroup") release
-  __builtin_memory_fence(3, "workgroup");
-
-  // CHECK: fence syncscope("foobar") release
-  __builtin_memory_fence(3, "foobar");
-}
\ No newline at end of file
+  __builtin_amdgcn_fence(3, "workgroup");
+}
Index: clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: not %clang_cc1 %s -S \
+// RUN:   -triple=amdgcn-amd-amdhsa 2>&1 | FileCheck %s
+
+void test_amdgcn_fence_failure() {
+
+  // CHECK: error: Unsupported atomic synchronization scope 
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "foobar");
+}
\ No newline at end of file
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1870,34 +1

[PATCH] D78626: [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.

2020-04-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/347.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78626

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1286,6 +1286,20 @@
 "1: targets = {}\n"
 "2: targets = {T}\n"
   },
+  // unknown template name should not crash.
+  {R"cpp(
+template  typename T>
+struct Base {};
+namespace foo {
+template 
+struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
+}
+  )cpp",
+  "0: targets = {foo::Derive::T}, decl\n"
+  "1: targets = {foo::Derive}, decl\n"
+  "2: targets = {Base}\n"
+  "3: targets = {foo::Derive::T}\n"
+  "4: targets = {}, qualifier = 'T::'\n"},
 };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -860,15 +860,17 @@
   // TemplateArgumentLoc is the only way to get locations for references to
   // template template parameters.
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc A) {
+llvm::SmallVector Targets;
 switch (A.getArgument().getKind()) {
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion:
+  if (const auto *D = A.getArgument()
+  .getAsTemplateOrTemplatePattern()
+  .getAsTemplateDecl())
+Targets.push_back(D);
   reportReference(ReferenceLoc{A.getTemplateQualifierLoc(),
A.getTemplateNameLoc(),
-   /*IsDecl=*/false,
-   {A.getArgument()
-.getAsTemplateOrTemplatePattern()
-.getAsTemplateDecl()}},
+   /*IsDecl=*/false, Targets},
   DynTypedNode::create(A.getArgument()));
   break;
 case TemplateArgument::Declaration:


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1286,6 +1286,20 @@
 "1: targets = {}\n"
 "2: targets = {T}\n"
   },
+  // unknown template name should not crash.
+  {R"cpp(
+template  typename T>
+struct Base {};
+namespace foo {
+template 
+struct $1^Derive : $2^Base<$3^T::template $4^Unknown> {};
+}
+  )cpp",
+  "0: targets = {foo::Derive::T}, decl\n"
+  "1: targets = {foo::Derive}, decl\n"
+  "2: targets = {Base}\n"
+  "3: targets = {foo::Derive::T}\n"
+  "4: targets = {}, qualifier = 'T::'\n"},
 };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -860,15 +860,17 @@
   // TemplateArgumentLoc is the only way to get locations for references to
   // template template parameters.
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc A) {
+llvm::SmallVector Targets;
 switch (A.getArgument().getKind()) {
 case TemplateArgument::Template:
 case TemplateArgument::TemplateExpansion:
+  if (const auto *D = A.getArgument()
+  .getAsTemplateOrTemplatePattern()
+  .getAsTemplateDecl())
+Targets.push_back(D);
   reportReference(ReferenceLoc{A.getTemplateQualifierLoc(),
A.getTemplateNameLoc(),
-   /*IsDecl=*/false,
-   {A.getArgument()
-.getAsTemplateOrTemplatePattern()
-.getAsTemplateDecl()}},
+   /*IsDecl=*/false, Targets},
   DynTypedNode::create(A.getArgument()));
   break;
 case TemplateArgument::Declaration:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78030: [TimeProfiler] Emit clock synchronization point

2020-04-22 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb added a comment.

@russell.gallop thanks! I'll address your comments and commit the change.


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

https://reviews.llvm.org/D78030



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


[PATCH] D77735: [SveEmitter] Implement builtins for gathers/scatters

2020-04-22 Thread Andrzej Warzynski via Phabricator via cfe-commits
andwar added a comment.

The buildbot failures are unrelated to this patch, and locally `make check-all` 
worked fine. I'll submit this patch as is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77735



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


[PATCH] D78629: [clangd] Look for compilation database in `build` subdirectory of parents.

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This matches the conventional location of cmake build directories.
It also allows creating a `build` symlink, which seems more flexible than the
compile_commands.json symlinks.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78629

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp

Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -8,6 +8,7 @@
 
 #include "GlobalCompilationDatabase.h"
 
+#include "Matchers.h"
 #include "Path.h"
 #include "TestFS.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -164,6 +165,47 @@
"-DFallback", "-DAdjust_baz.cc"));
 }
 
+// Allows placement of files for tests and cleans them up after.
+class ScratchFS {
+  llvm::SmallString<128> Root;
+
+public:
+  ScratchFS() {
+EXPECT_FALSE(llvm::sys::fs::createUniqueDirectory("clangd-cdb-test", Root))
+<< "Failed to create unique directory";
+  }
+
+  ~ScratchFS() {
+EXPECT_FALSE(llvm::sys::fs::remove_directories(Root))
+<< "Failed to cleanup " << Root;
+  }
+
+  llvm::StringRef root() const { return Root; }
+
+  void write(PathRef RelativePath, llvm::StringRef Contents) {
+std::string AbsPath = path(RelativePath);
+EXPECT_FALSE(llvm::sys::fs::create_directories(
+llvm::sys::path::parent_path(AbsPath)))
+<< "Failed to create directories for: " << AbsPath;
+
+std::error_code EC;
+llvm::raw_fd_ostream OS(AbsPath, EC);
+EXPECT_FALSE(EC) << "Failed to open " << AbsPath << " for writing";
+OS << llvm::formatv(Contents.data(),
+llvm::sys::path::convert_to_slash(Root));
+OS.close();
+
+EXPECT_FALSE(OS.has_error());
+  }
+
+  std::string path(PathRef RelativePath) const {
+llvm::SmallString<128> AbsPath(Root);
+llvm::sys::path::append(AbsPath, RelativePath);
+llvm::sys::path::native(AbsPath);
+return AbsPath.str().str();
+  }
+};
+
 TEST(GlobalCompilationDatabaseTest, DiscoveryWithNestedCDBs) {
   const char *const CDBOuter =
   R"cdb(
@@ -195,44 +237,9 @@
 }
   ]
   )cdb";
-  class CleaningFS {
-  public:
-llvm::SmallString<128> Root;
-
-CleaningFS() {
-  EXPECT_FALSE(
-  llvm::sys::fs::createUniqueDirectory("clangd-cdb-test", Root))
-  << "Failed to create unique directory";
-}
-
-~CleaningFS() {
-  EXPECT_FALSE(llvm::sys::fs::remove_directories(Root))
-  << "Failed to cleanup " << Root;
-}
-
-void registerFile(PathRef RelativePath, llvm::StringRef Contents) {
-  llvm::SmallString<128> AbsPath(Root);
-  llvm::sys::path::append(AbsPath, RelativePath);
-
-  EXPECT_FALSE(llvm::sys::fs::create_directories(
-  llvm::sys::path::parent_path(AbsPath)))
-  << "Failed to create directories for: " << AbsPath;
-
-  std::error_code EC;
-  llvm::raw_fd_ostream OS(AbsPath, EC);
-  EXPECT_FALSE(EC) << "Failed to open " << AbsPath << " for writing";
-  OS << llvm::formatv(Contents.data(),
-  llvm::sys::path::convert_to_slash(Root));
-  OS.close();
-
-  EXPECT_FALSE(OS.has_error());
-}
-  };
-
-  CleaningFS FS;
-  FS.registerFile("compile_commands.json", CDBOuter);
-  FS.registerFile("build/compile_commands.json", CDBInner);
-  llvm::SmallString<128> File;
+  ScratchFS FS;
+  FS.write("compile_commands.json", CDBOuter);
+  FS.write("build/compile_commands.json", CDBInner);
 
   // Note that gen2.cc goes missing with our following model, not sure this
   // happens in practice though.
@@ -244,43 +251,50 @@
   DiscoveredFiles = Changes;
 });
 
-File = FS.Root;
-llvm::sys::path::append(File, "build", "..", "a.cc");
-DB.getCompileCommand(File.str());
+DB.getCompileCommand(FS.path("build/../a.cc"));
 EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(AllOf(
  EndsWith("a.cc"), Not(HasSubstr("..");
 DiscoveredFiles.clear();
 
-File = FS.Root;
-llvm::sys::path::append(File, "build", "gen.cc");
-DB.getCompileCommand(File.str());
+DB.getCompileCommand(FS.path("build/gen.cc"));
 EXPECT_THAT(DiscoveredFiles, UnorderedElementsAre(EndsWith("gen.cc")));
   }
 
   // With a custom compile commands dir.
   {
-DirectoryBasedGlobalCompilationDatabase DB(FS.Root.str().str());
+DirectoryBasedGlobalCompilationDatabase DB(FS.root().str());
 std::vector DiscoveredFiles;
 auto Sub =
 DB.watch([&DiscoveredFiles](const 

[clang] 4eca1c0 - [AArch64][FIX] f16 indexed patterns encoding restrictions.

2020-04-22 Thread Pavel Iliin via cfe-commits

Author: Pavel Iliin
Date: 2020-04-22T14:11:28+01:00
New Revision: 4eca1c06a4a9183fcf7bb230d894617caf3cf3be

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

LOG: [AArch64][FIX] f16 indexed patterns encoding restrictions.

Added: 


Modified: 
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
llvm/lib/Target/AArch64/AArch64InstrFormats.td

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
index b72bd3f977dd..6058e6f92832 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -121,7 +121,7 @@ float16x8_t test_vfmaq_lane_f16(float16x8_t a, float16x8_t 
b, float16x4_t c) {
 // COMMONIR:  [[LANE:%.*]] = shufflevector <8 x half> [[TMP5]], <8 x half> 
[[TMP5]], <4 x i32> 
 // UNCONSTRAINED: [[FMLA:%.*]] = call <4 x half> @llvm.fma.v4f16(<4 x half> 
[[LANE]], <4 x half> [[TMP4]], <4 x half> [[TMP3]])
 // CONSTRAINED:   [[FMLA:%.*]] = call <4 x half> 
@llvm.experimental.constrained.fma.v4f16(<4 x half> [[LANE]], <4 x half> 
[[TMP4]], <4 x half> [[TMP3]], metadata !"round.tonearest", metadata 
!"fpexcept.strict")
-// CHECK-ASM: fmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
+// CHECK-ASM: fmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, 
v{{[0-9]+}}.h[{{[0-9]+}}]
 // COMMONIR:  ret <4 x half> [[FMLA]]
 float16x4_t test_vfma_laneq_f16(float16x4_t a, float16x4_t b, float16x8_t c) {
   return vfma_laneq_f16(a, b, c, 7);
@@ -239,7 +239,7 @@ float16x8_t test_vfmsq_lane_f16(float16x8_t a, float16x8_t 
b, float16x4_t c) {
 // COMMONIR:  [[LANE:%.*]] = shufflevector <8 x half> [[TMP5]], <8 x half> 
[[TMP5]], <4 x i32> 
 // UNCONSTRAINED: [[FMLA:%.*]] = call <4 x half> @llvm.fma.v4f16(<4 x half> 
[[LANE]], <4 x half> [[TMP4]], <4 x half> [[TMP3]])
 // CONSTRAINED:   [[FMLA:%.*]] = call <4 x half> 
@llvm.experimental.constrained.fma.v4f16(<4 x half> [[LANE]], <4 x half> 
[[TMP4]], <4 x half> [[TMP3]], metadata !"round.tonearest", metadata 
!"fpexcept.strict")
-// CHECK-ASM: fmls v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
+// CHECK-ASM: fmls v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, 
v{{[0-9]+}}.h[{{[0-9]+}}]
 // COMMONIR:  ret <4 x half> [[FMLA]]
 float16x4_t test_vfms_laneq_f16(float16x4_t a, float16x4_t b, float16x8_t c) {
   return vfms_laneq_f16(a, b, c, 7);

diff  --git a/llvm/lib/Target/AArch64/AArch64InstrFormats.td 
b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
index 061e2a0ec619..29422fa650e6 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrFormats.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrFormats.td
@@ -8068,29 +8068,29 @@ multiclass SIMDFPIndexedTiedPatterns {
   let Predicates = [HasNEON, HasFullFP16] in {
   // Patterns for f16: DUPLANE, DUP scalar and vector_extract.
   def : Pat<(v8f16 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn),
-   (AArch64duplane16 (v8f16 V128:$Rm),
+   (AArch64duplane16 (v8f16 V128_lo:$Rm),
VectorIndexH:$idx))),
 (!cast(INST # "v8i16_indexed")
-V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexH:$idx)>;
+V128:$Rd, V128:$Rn, V128_lo:$Rm, VectorIndexH:$idx)>;
   def : Pat<(v8f16 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn),
(AArch64dup (f16 FPR16Op:$Rm,
 (!cast(INST # "v8i16_indexed") V128:$Rd, V128:$Rn,
 (SUBREG_TO_REG (i32 0), FPR16Op:$Rm, hsub), (i64 0))>;
 
   def : Pat<(v4f16 (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn),
-   (AArch64duplane16 (v8f16 V128:$Rm),
-   VectorIndexS:$idx))),
+   (AArch64duplane16 (v8f16 V128_lo:$Rm),
+   VectorIndexH:$idx))),
 (!cast(INST # "v4i16_indexed")
-V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
+V64:$Rd, V64:$Rn, V128_lo:$Rm, VectorIndexH:$idx)>;
   def : Pat<(v4f16 (OpNode (v4f16 V64:$Rd), (v4f16 V64:$Rn),
(AArch64dup (f16 FPR16Op:$Rm,
 (!cast(INST # "v4i16_indexed") V64:$Rd, V64:$Rn,
 (SUBREG_TO_REG (i32 0), FPR16Op:$Rm, hsub), (i64 0))>;
 
   def : Pat<(f16 (OpNode (f16 FPR16:$Rd), (f16 FPR16:$Rn),
- (vector_extract (v8f16 V128:$Rm), 
VectorIndexH:$idx))),
+ (vector_extract (v8f16 V128_lo:$Rm), 
VectorIndexH:$idx))),
 (!cast(INST # "v1i16_indexed") FPR16:$Rd, FPR16:$Rn,
-V128:$Rm, VectorIndexH:$idx)>;
+V128_lo:$Rm, VectorIndexH:$idx)>;
   } // Predicates = [HasNEON, HasFullFP16]
 
   /

[PATCH] D78521: [clangd] Extend dexp to support remote index

2020-04-22 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 259257.
kbobyrev added a comment.

Stream responses in refs() and fuzzyFind()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78521

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/Serialization.h
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/dexp/CMakeLists.txt
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.cpp
  clang-tools-extra/clangd/index/remote/Index.h
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/Marshalling.h
  clang-tools-extra/clangd/index/remote/client/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/client/Client.cpp
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -23,11 +23,11 @@
   find_program(PROTOC protoc)
 endif()
 
-# Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
+# Proto headers are generated in ${GeneratedFilesLocation}.
 # Libraries that use these headers should adjust the include path.
 # FIXME(kirillbobyrev): Allow optional generation of gRPC code and give callers
 # control over it via additional parameters.
-function(generate_grpc_protos LibraryName ProtoFile)
+function(generate_grpc_protos LibraryName ProtoFile GeneratedFilesLocation)
   get_filename_component(ProtoSourceAbsolutePath "${CMAKE_CURRENT_SOURCE_DIR}/${ProtoFile}" ABSOLUTE)
   get_filename_component(ProtoSourcePath ${ProtoSourceAbsolutePath} PATH)
 
@@ -35,6 +35,7 @@
   set(GeneratedProtoHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.h")
   set(GeneratedGRPCSource "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.cc")
   set(GeneratedGRPCHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.h")
+  set(${GeneratedFilesLocation} ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
   add_custom_command(
 OUTPUT "${GeneratedProtoSource}" "${GeneratedProtoHeader}" "${GeneratedGRPCSource}" "${GeneratedGRPCHeader}"
 COMMAND ${PROTOC}
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -8,6 +8,7 @@
 
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "index/remote/Marshalling.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/LineEditor/LineEditor.h"
@@ -23,6 +24,7 @@
 
 namespace clang {
 namespace clangd {
+namespace remote {
 namespace {
 
 static const std::string Overview = R"(
@@ -33,8 +35,9 @@
 llvm::cl::opt IndexPath(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
-llvm::cl::opt ServerAddress("server-address",
- llvm::cl::init("0.0.0.0:50051"));
+llvm::cl::opt ServerAddress(
+"server-address", llvm::cl::init("0.0.0.0:50051"),
+llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
 std::unique_ptr openIndex(llvm::StringRef Index) {
   return loadIndex(Index, /*UseIndex=*/true);
@@ -47,24 +50,60 @@
 
 private:
   grpc::Status Lookup(grpc::ServerContext *Context,
-  const remote::LookupRequest *Request,
-  grpc::ServerWriter *Reply) override {
-llvm::outs() << "Lookup of symbol with ID " << Request->id() << '\n';
-LookupRequest Req;
-auto SID = SymbolID::fromStr(Request->id());
-if (!SID) {
-  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
-  return grpc::Status::CANCELLED;
+  const LookupRequest *Request,
+  grpc::ServerWriter *Reply) override {
+clangd::LookupRequest Req;
+for (const auto &ID : Request->ids()) {
+  auto SID = SymbolID::fromStr(StringRef(ID));
+  if (!SID)
+return grpc::Status::CANCELLED;
+  Req.IDs.insert(*SID);
 }
-Req.IDs.insert(*SID);
-Index->lookup(Req, [&](const Symbol &Sym) {
-  remote::LookupReply NextSymbol;
-  NextSymbol.set_symbol_yaml(toYAML(Sym));
+Index->lookup(Req, [&](const clangd::Symbol &Sym) {
+  remote::Symbol NextSymbol;
+  NextSymbol.set_yaml_serializatiton(toYAML(Sym));
   Reply->Write(NextSymbol);
 });
 return grpc::Status::OK;
   }
 
+  grpc::Status FuzzyFind(grpc::ServerContext *Context,
+ const FuzzyFindRequest *Request,
+ grpc::ServerWriter *Reply) override {
+   

[PATCH] D78252: [AArch64] FMLA/FMLS patterns improvement.

2020-04-22 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv marked 2 inline comments as done.
ilinpv added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:8058
+  def : Pat<(v8f16 (OpNode (v8f16 V128:$Rd), (v8f16 V128:$Rn),
+   (AArch64duplane16 (v8f16 V128:$Rm),
+   VectorIndexH:$idx))),

ab wrote:
> Should this be V128_lo?  I don't think this is encodable for Rm in V16-V31  
> (same in the other indexed f16 variants I think)
Yep, I double checked encoding, you are right. Thank you very much for this. 
Fixed in 4eca1c06a4a9183fcf7bb230d894617caf3cf3be


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78252



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


[PATCH] D77594: [SveEmitter] Add support for _n form builtins

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:212
+  bool hasSplat() const {
+return Proto.find_first_of("ajfrKLR") != std::string::npos;
+  }

SjoerdMeijer wrote:
> "ajfrKLR" -> bingo ;-)
> 
> This probably makes sense, but who knows :-)
> Not even sure if a comment makes things better here...
> "ajfrKLR" -> bingo ;-)

Haha! You are right these prototype modifiers are not very readable. The 
arm_sve.td file describes the prototype modifiers at the top though, and I've 
added a comment suggesting where to find it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77594



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


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Amdgcn specific is fine by me. Hopefully that unblocks this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-22 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 259272.
baloghadamsoftware added a comment.

First version that seems to be working :-)


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

https://reviews.llvm.org/D77229

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/temporaries.cpp

Index: clang/test/Analysis/temporaries.cpp
===
--- clang/test/Analysis/temporaries.cpp
+++ clang/test/Analysis/temporaries.cpp
@@ -890,12 +890,9 @@
 public:
   ~C() {
 glob = 1;
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_checkInlined(true);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#endif
+// expected-warning@-2{{TRUE}}
 #endif
   }
 };
@@ -914,16 +911,11 @@
   // temporaries returned from functions, so we took the wrong branch.
   coin && is(get()); // no-crash
   if (coin) {
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_eval(glob);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#else
-// expected-warning@-5{{UNKNOWN}}
-#endif
+// expected-warning@-2{{TRUE}}
 #else
-// expected-warning@-8{{UNKNOWN}}
+// expected-warning@-4{{UNKNOWN}}
 #endif
   } else {
 // The destructor is not called on this branch.
Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1862,7 +1862,7 @@
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
-  const auto i0 = V.cbegin();
+  auto i0 = V.cbegin();
   clang_analyzer_printState();
 
 // CHECK:  "checker_messages": [
@@ -1871,7 +1871,8 @@
 // CHECK-NEXT: "i0 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
 
-  const auto i1 = V.cend();
+  ++i0;
+  auto i1 = V.cend();
   clang_analyzer_printState();
   
 // CHECK:  "checker_messages": [
@@ -1879,4 +1880,6 @@
 // CHECK-NEXT: "Iterator Positions :",
 // CHECK-NEXT: "i1 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
+
+  --i1;
 }
Index: clang/test/Analysis/explain-svals.cpp
===
--- clang/test/Analysis/explain-svals.cpp
+++ clang/test/Analysis/explain-svals.cpp
@@ -93,6 +93,6 @@
 } // end of anonymous namespace
 
 void test_6() {
-  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of temporary object constructed at statement 'conjure_S\(\)'$
+  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of parameter 0 of function 'clang_analyzer_explain\(\)'$
   clang_analyzer_explain(conjure_S().z); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure_S\(\)'\) for field 'z' of temporary object constructed at statement 'conjure_S\(\)'$
 }
Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -17,7 +17,7 @@
 void clang_analyzer_warnIfReached();
 
 void begin(const std::vector &V) {
-  V.begin();
+  const auto i0 = V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
@@ -25,7 +25,7 @@
 }
 
 void end(const std::vector &V) {
-  V.end();
+  const auto i0 = V.end();
 
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
   

[PATCH] D78232: [OPENMP50]Codegen for scan directive in simd loops.

2020-04-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 259270.
ABataev added a comment.

ddress comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78232

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/scan_codegen.cpp
  clang/test/OpenMP/scan_messages.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2365,6 +2365,14 @@
   for (auto *E : C->reduction_ops()) {
 Visitor->AddStmt(E);
   }
+  if (C->getModifier() == clang::OMPC_REDUCTION_inscan) {
+for (auto *E : C->copy_temps()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_ops()) {
+  Visitor->AddStmt(E);
+}
+  }
 }
 void OMPClauseEnqueue::VisitOMPTaskReductionClause(
 const OMPTaskReductionClause *C) {
Index: clang/test/OpenMP/scan_messages.cpp
===
--- clang/test/OpenMP/scan_messages.cpp
+++ clang/test/OpenMP/scan_messages.cpp
@@ -19,32 +19,32 @@
 #pragma omp for simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
 if (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 if (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   while (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   do
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc)
   ;
-#pragma omp simd reduction(inscan, +: argc)
+#pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
   for (int i = 0; i < 10; ++i)
   do {
-#pragma omp scan inclusive(argc)
+#pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
   } while (argc);
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   switch (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 switch (argc)
 case 1:
 #pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, p

[PATCH] D78252: [AArch64] FMLA/FMLS patterns improvement.

2020-04-22 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added a comment.

Patterns corrected to comply with encoding 
4eca1c06a4a9183fcf7bb230d894617caf3cf3be 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78252



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


[PATCH] D77871: [AArch64] Armv8.6-a Matrix Mult Assembly + Intrinsics

2020-04-22 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added inline comments.



Comment at: clang/test/CodeGen/aarch64-v8.6a-neon-intrinsics.c:3
+// RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -emit-llvm 
-o - %s \
+// RUN: | opt -S -mem2reg \
+// RUN: | FileCheck %s

Is it possible to use -sroa here as you did for the tests added in D77872? If 
so, I think this might make some of the `_lane` tests below a bit easier to 
follow.



Comment at: llvm/test/MC/AArch64/armv8.6a-simd-matmul-error.s:17
+// For USDOT and SUDOT (indexed), the index is in range [0,3] (regardless of 
data types)
+usdot v31.2s, v1.8b,  v2.4b[4]
+// CHECK: [[@LINE-1]]:{{[0-9]+}}: error: vector lane must be an integer in 
range [0, 3].

The arrangement specifiers of the first two operands don't match for these 
tests, which is what the next set of tests below is checking for. It might be 
worth keeping these tests specific to just the index being out of range.



Comment at: llvm/test/MC/AArch64/armv8.6a-simd-matmul-error.s:26
+
+// The arrangement specifiers of the first two operands muct match.
+usdot v31.4s, v1.8b,  v2.4b[0]

muct -> must :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77871



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-22 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 7 inline comments as done.
baloghadamsoftware added a comment.

Thank you for your comments. Of course I plan to upload all these changes in at 
least three different patches. But first I needed a version that is working. 
However if I split this up I will have to write lots of unit tests.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h:438-442
+  Optional getReturnValueUnderConstruction(unsigned BlockCount) const;
+
+  Optional getArgObject(unsigned Index, unsigned BlockCount) const;
+
+  Optional getReturnObject(unsigned BlockCount) const;

NoQ wrote:
> I believe these functions don't need to be optional. There's always a 
> parameter location and a location to return to (even if the latter is 
> incorrect due to unimplemented construction context, it'll still be some 
> dummy temporary region that you can use).
Do you mean we should return the original `SVal` if parameter or return value 
location fails? (Thus `LazyCompoundVal` in worst case?



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1044
 
+class ParamWithoutVarRegion : public TypedValueRegion {
+  friend class MemRegionManager;

NoQ wrote:
> There should be only one way to express the parameter region. Let's call this 
> one simply `ParamRegion` or something like that, and 
> `assert(!isa(D))` in the constructor of `VarRegion`.
Do you mean that we should use `ParamRegion` in every case, thus also when we 
have the definitioan for the function? I wonder whether it breaks too many 
things.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h:1066
+  QualType getValueType() const override {
+return CallE->getType();
+  }

NoQ wrote:
> This should be the type of the parameter, not the return type of the call.
Yes, sorry, my mistake.



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:278-279
+
+const ConstructionContext
+*CallEvent::getConstructionContext(unsigned BlockCount) const {
+  const CFGBlock *Block;

NoQ wrote:
> This function obviously does not depend on `BlockCount`. You might as well 
> always use `0` as `BlockCount`.
> 
> The ideal solution, of course, is for `CallEvent` to keep a `CFGElementRef` 
> from the start.
I plan to make that change in a separate patch.


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

https://reviews.llvm.org/D77229



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a project: clang.

Static analyzer has a mechanism of clearing redundant nodes when
analysis hits a certain threshold with a number of nodes in exploded
graph (default is 1000).  It is similar to GC and aims removing nodes
not useful for analysis.  Unfortunately nodes corresponding to array
subscript expressions (that actively participate in data propagation)
get removed during the cleanup.  This might prevent the analyzer from
generating useful notes about where it thinks the data came from.

This fix is pretty much consistent with the way analysis works
already.  Lvalue "interestingness" stands for the analyzer's
possibility of tracking values through them.

rdar://problem/53280338


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78638

Files:
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/test/Analysis/PR53280338.cpp


Index: clang/test/Analysis/PR53280338.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR53280338.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+
+class A {
+public:
+  int method();
+};
+
+A *foo();
+void bar(A *);
+
+int index;
+
+void test() {
+  A *array[42];
+  A *found;
+
+  for (index = 0; (array[index] = foo()); ++index) { // expected-note {{Loop 
condition is false. Execution continues on line 26}}
+// expected-note@-1 {{Value assigned to 'index'}}
+// expected-note@-2 {{Assigning value}}
+// expected-note@-3 {{Assuming pointer value is null}}
+if (array[0])
+  break;
+  }
+
+  do {
+found = array[index]; // expected-note {{Null pointer value stored to 
'found'}}
+
+if (found->method()) // expected-warning {{Called C++ object pointer is 
null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+  bar(found);
+  } while (--index);
+}
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -50,9 +50,8 @@
 bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
   if (!Ex->isLValue())
 return false;
-  return isa(Ex) ||
- isa(Ex) ||
- isa(Ex);
+  return isa(Ex) || isa(Ex) ||
+ isa(Ex) || isa(Ex);
 }
 
 bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {


Index: clang/test/Analysis/PR53280338.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR53280338.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
+
+class A {
+public:
+  int method();
+};
+
+A *foo();
+void bar(A *);
+
+int index;
+
+void test() {
+  A *array[42];
+  A *found;
+
+  for (index = 0; (array[index] = foo()); ++index) { // expected-note {{Loop condition is false. Execution continues on line 26}}
+// expected-note@-1 {{Value assigned to 'index'}}
+// expected-note@-2 {{Assigning value}}
+// expected-note@-3 {{Assuming pointer value is null}}
+if (array[0])
+  break;
+  }
+
+  do {
+found = array[index]; // expected-note {{Null pointer value stored to 'found'}}
+
+if (found->method()) // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+  bar(found);
+  } while (--index);
+}
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -50,9 +50,8 @@
 bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
   if (!Ex->isLValue())
 return false;
-  return isa(Ex) ||
- isa(Ex) ||
- isa(Ex);
+  return isa(Ex) || isa(Ex) ||
+ isa(Ex) || isa(Ex);
 }
 
 bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp:5
+
+void test_amdgcn_fence_failure() {
+

Does this really depend on C++? Can it use OpenCL like the other builtin 
tests?This also belongs in a Sema* test directory since it's checking an error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D78637: [OPENMP]Fix PR45383: type dependent array subscripts are diagnosed erroneously.

2020-04-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.

If the array subscript expression is type depent, its analysis must be
delayed before its instantiation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78637

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/task_ast_print.cpp


Index: clang/test/OpenMP/task_ast_print.cpp
===
--- clang/test/OpenMP/task_ast_print.cpp
+++ clang/test/OpenMP/task_ast_print.cpp
@@ -99,7 +99,8 @@
   T arr[argc];
   omp_depend_t x;
   omp_event_handle_t evt;
-#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], 
([argc][sizeof(T)])argv) if (task : argc > 0) depend(depobj: x) detach(evt)
+  double *arr_double;
+#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], 
([argc][sizeof(T)])argv, arr_double[argc]) if (task : argc > 0) depend(depobj: 
x) detach(evt)
   a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) 
if (argc > 0) final(S::TS > 0) priority(argc)
   foo();
@@ -116,7 +117,8 @@
 // CHECK-NEXT: T arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc)
 // CHECK-NEXT: foo()
@@ -130,7 +132,8 @@
 // CHECK-NEXT: int arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc)
 // CHECK-NEXT: foo()
@@ -144,7 +147,8 @@
 // CHECK-NEXT: long arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv) if(task: argc > 0) 
depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : 
argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv,arr_double[argc]) if(task: 
argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) 
firstprivate(argv) shared(d) if(argc > 0) final(S::TS > 0) priority(argc)
 // CHECK-NEXT: foo()
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15904,7 +15904,7 @@
 
 auto *ASE = dyn_cast(SimpleExpr);
 if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
+(ASE && !ASE->getBase()->isTypeDependent() &&
  !ASE->getBase()
   ->getType()
   .getNonReferenceType()


Index: clang/test/OpenMP/task_ast_print.cpp
===
--- clang/test/OpenMP/task_ast_print.cpp
+++ clang/test/OpenMP/task_ast_print.cpp
@@ -99,7 +99,8 @@
   T arr[argc];
   omp_depend_t x;
   omp_event_handle_t evt;
-#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv) if (task : argc > 0) depend(depobj: x) detach(evt)
+  double *arr_double;
+#pragma omp task untied depend(in : argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv, arr_double[argc]) if (task : argc > 0) depend(depobj: x) detach(evt)
   a = 2;
 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S::TS > 0) priority(argc)
   foo();
@@ -116,7 +117,8 @@
 // CHECK-NEXT: T arr[argc];
 // CHECK-NEXT: omp_depend_t x;
 // CHECK-NEXT: omp_event_handle_t evt;
-// CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv) if(task: argc > 0) depend(depobj : x) detach(evt)
+// CHECK-NEXT: double *arr_double;
+// CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv,arr_double[argc]) if(task: argc > 0) depend(depobj : x) detach(evt)
 // CHECK-NEXT: a = 2;
 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final

[PATCH] D78192: Support compiler extensions as a normal component

2020-04-22 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 259284.
serge-sans-paille added a comment.
Herald added subscribers: cfe-commits, dang, dexonsmith, steven_wu, hiraditya.
Herald added a project: clang.

Instead of linking all compiler extensions to the different possible tagets 
(clang, opt lto etc), link them in a new component, named ` Extensions`. That 
way a tool (or component) that needs to use compiler extension can just declare 
that dependency in the traditional way.

This is compatible with llvm-build and llvm-config, through a specific handler 
in llvm-config though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78192

Files:
  clang/lib/CodeGen/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/lib/CMakeLists.txt
  llvm/lib/Extensions/CMakeLists.txt
  llvm/lib/Extensions/Extensions.cpp
  llvm/lib/Extensions/LLVMBuild.txt
  llvm/lib/LLVMBuild.txt
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/LTO/LLVMBuild.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/opt/CMakeLists.txt

Index: llvm/tools/opt/CMakeLists.txt
===
--- llvm/tools/opt/CMakeLists.txt
+++ llvm/tools/opt/CMakeLists.txt
@@ -9,6 +9,7 @@
   CodeGen
   Core
   Coroutines
+  Extensions
   IPO
   IRReader
   InstCombine
@@ -33,8 +34,6 @@
   PrintSCC.cpp
   opt.cpp
 
-  ENABLE_PLUGINS
-
   DEPENDS
   intrinsics_gen
   SUPPORT_PLUGINS
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -46,6 +46,10 @@
 // create entries for pseudo groups like x86 or all-targets.
 #include "LibraryDependencies.inc"
 
+// Built-in extensions also register their dependencies, but in a separate file,
+// later in the process.
+#include "ExtensionDependencies.inc"
+
 // LinkMode determines what libraries and flags are returned by llvm-config.
 enum LinkMode {
   // LinkModeAuto will link with the default link mode for the installation,
@@ -110,6 +114,25 @@
GetComponentLibraryPath, Missing, DirSep);
   }
 
+  // Special handling for the special 'extensions' component. Its content is
+  // not populated by llvm-build, but later in the process and loaded from
+  // ExtensionDependencies.inc.
+  if (Name == "extensions") {
+for (auto const &AvailableExtension : AvailableExtensions) {
+  for (const char *const *Iter = &AvailableExtension.RequiredLibraries[0];
+   *Iter; ++Iter) {
+AvailableComponent *AC = ComponentMap.lookup(*Iter);
+if (!AC) {
+  RequiredLibs.push_back(*Iter);
+} else {
+  VisitComponent(*Iter, ComponentMap, VisitedComponents, RequiredLibs,
+ IncludeNonInstalled, GetComponentNames,
+ GetComponentLibraryPath, Missing, DirSep);
+}
+  }
+}
+  }
+
   if (GetComponentNames) {
 RequiredLibs.push_back(Name);
 return;
Index: llvm/tools/bugpoint/CMakeLists.txt
===
--- llvm/tools/bugpoint/CMakeLists.txt
+++ llvm/tools/bugpoint/CMakeLists.txt
@@ -6,6 +6,7 @@
   Analysis
   BitWriter
   CodeGen
+  Extensions
   Core
   IPO
   IRReader
@@ -32,8 +33,6 @@
   ToolRunner.cpp
   bugpoint.cpp
 
-  ENABLE_PLUGINS
-
   DEPENDS
   intrinsics_gen
   SUPPORT_PLUGINS
Index: llvm/lib/LTO/LLVMBuild.txt
===
--- llvm/lib/LTO/LLVMBuild.txt
+++ llvm/lib/LTO/LLVMBuild.txt
@@ -26,6 +26,7 @@
  BitWriter
  CodeGen
  Core
+ Extensions
  IPO
  InstCombine
  Linker
Index: llvm/lib/LTO/CMakeLists.txt
===
--- llvm/lib/LTO/CMakeLists.txt
+++ llvm/lib/LTO/CMakeLists.txt
@@ -10,9 +10,6 @@
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/LTO
-
-  ENABLE_PLUGINS
-
   DEPENDS
   intrinsics_gen
   llvm_vcsrevision_h
Index: llvm/lib/LLVMBuild.txt
===
--- llvm/lib/LLVMBuild.txt
+++ llvm/lib/LLVMBuild.txt
@@ -25,6 +25,7 @@
  Demangle
  DWARFLinker
  ExecutionEngine
+ Extensions
  Frontend
  FuzzMutate
  LineEditor
Index: llvm/lib/Extensions/LLVMBuild.txt
===
--- /dev/null
+++ llvm/lib/Extensions/LLVMBuild.txt
@@ -0,0 +1,21 @@
+;===- ./lib/Extensions/LLVMBuild.txt ---*- Conf -*--===;
+;
+; Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+; See https://llvm.org/LICENSE.txt for license information.
+; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+;
+;======;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For mo

[PATCH] D78192: Support compiler extensions as a normal component

2020-04-22 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@Meinersbur with the latest updat, it should also be compatible with 
https://github.com/intel/opencl-clang/blob/83837744ef076c1285ed2ee9349febc2208d3252/CMakeLists.txt#L266
 as all contains the `Extensions` component.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78192



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


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp:5
+
+void test_amdgcn_fence_failure() {
+

arsenm wrote:
> Does this really depend on C++? Can it use OpenCL like the other builtin 
> tests?This also belongs in a Sema* test directory since it's checking an error
Making it opencl-only would force some of the openmp runtime to be written in 
opencl, which is not presently the case. Currently that library is written in a 
dialect of hip, but there's a plan to implement it in openmp instead.

I'd much rather this builtin work from any language, instead of tying it to 
opencl, as that means one can use it from openmp target regions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D78000: [ASTImporter] Fix handling of not defined FromRecord in ImportContext(...)

2020-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

LGTM! Thanks!


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

https://reviews.llvm.org/D78000



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


[PATCH] D78192: Support compiler extensions as a normal component

2020-04-22 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

Note that this should solve in an elegant (?) way the multiple link errors 
found when linking clang with LLVM_DYLIB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78192



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


[PATCH] D78521: [clangd] Extend dexp to support remote index

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:161
 if (CLANGD_ENABLE_REMOTE)
+  add_definitions(-D CLANGD_REMOTE)
   include(FindGRPC)

Can we use features.inc.in instead for this?
(I don't have a strong opinion on which one is better, but I'd rather not do 
things two ways)



Comment at: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp:40
+RemoteMode("remote",
+   llvm::cl::desc("Connect to  remote index"));
+

kbobyrev wrote:
> @sammccall do you know why this opt is not being set for some reason? When I 
> try to run `dexp --help` it is displayed in the possible arguments and when I 
> try to pass anything invalid for boolean flags this also fails, but the value 
> is not changed regardless of the values I put here :( Must be something 
> simple I've missed.
I think you need to read it before we `ResetCommandLineParser()`. That part is 
a bit of a hack :-(



Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:1
-generate_grpc_protos(RemoteIndexProtos "Index.proto")
+generate_grpc_protos(RemoteIndexProtos "Index.proto" RemoteProtosLocation)
 

kbobyrev wrote:
> sammccall wrote:
> > why is this extra param needed?
> Because this needs to be included both here and for `dexp` binary.
still? I thought the idea was stuff outside this directory could include the 
client header, whether it's compiled in or not, and that header doesn't require 
protos



Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:9
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
+add_clang_library(clangDaemonRemoteIndex
+  Index.cpp

sammccall wrote:
> let's avoid propagating the clangDaemon name any further. clangdRemoteIndex? 
> or clangdRemoteIndexClient?
clang -> clangd though :-)



Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:15
+
+  protobuf
+  grpc++

do protobuf/grpc++ not get linked in transitively by linking against 
RemoteIndexProtos? Sad :-(



Comment at: clang-tools-extra/clangd/index/remote/Index.cpp:36
+while (Reader->Read(&Reply))
+  Callback(symbolFromYAML(Reply.yaml_serializatiton(), &Strings));
+grpc::Status Status = Reader->Finish();

error-handling: what if the symbol is invalid? (log and skip)



Comment at: clang-tools-extra/clangd/index/remote/Index.cpp:36
+while (Reader->Read(&Reply))
+  Callback(symbolFromYAML(Reply.yaml_serializatiton(), &Strings));
+grpc::Status Status = Reader->Finish();

sammccall wrote:
> error-handling: what if the symbol is invalid? (log and skip)
this should call a function in marshalling, which just does the YAML thing for 
now



Comment at: clang-tools-extra/clangd/index/remote/Index.cpp:38
+grpc::Status Status = Reader->Finish();
+llvm::outs() << "lookup rpc " << (Status.ok() ? "succeeded" : "failed")
+ << '\n';

use log()/vlog if you want to log.
But this should probably be a trace::Span instead so you get the latency.



Comment at: clang-tools-extra/clangd/index/remote/Index.cpp:47
+
+grpc::ClientContext Context;
+std::unique_ptr> Reader(

I'd consider pulling out a streamRPC template, these tend to attract 
cross-cutting code (setting deadlines, tracing/logging, and such)



Comment at: clang-tools-extra/clangd/index/remote/Index.cpp:97
+std::unique_ptr connect(llvm::StringRef Address) {
+#ifdef CLANGD_REMOTE
+  return std::unique_ptr(new IndexClient(Address));

if  remote is disabled we can't compile the rest of this file.
Rather than ifdefs here, I'd suggest doing it at the cmake level:

```
if(CLANGD_ENABLE_REMOTE)
  add_clang_library(... Index.cpp)
else()
  add_clang_library(... IndexUnimplemented.cpp)
endif()
```



Comment at: clang-tools-extra/clangd/index/remote/Index.h:1
+//===--- Index.h -*- 
C++-*-===//
+//

Suggest calling this Client.h



Comment at: clang-tools-extra/clangd/index/remote/Index.h:12
+
+#include "grpcpp/grpcpp.h"
+

no implementation headers should be needed now



Comment at: clang-tools-extra/clangd/index/remote/Index.h:21
+
+std::unique_ptr connect(llvm::StringRef Address);
+

this needs docs:
 - what it does
 - error conditions
 - what happens if support isn't compiled in



Comment at: clang-tools-extra/clangd/index/remote/Index.h:21
+
+std::unique_ptr connect(llvm::StringRef Address);
+

sammccall wrote:
> this needs docs:
>  - what it does
>  - error conditions
>  - what happens if support isn't compiled in
is the address resolved synchronously? is there a timeout?
does this block until the channel i

[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/CrossTU/CrossTranslationUnit.h:227
+/// Identifier.
+virtual LoadResultTy load(StringRef Identifier) = 0;
+virtual ~ASTLoader() = default;

xazax.hun wrote:
> martong wrote:
> > xazax.hun wrote:
> > > I am not sure if this is good design.
> > > Here, if the meaning of the `Identifier` depends on the subclass, the 
> > > caller of this method always needs to be aware of the dynamic type of the 
> > > object. What is the point of a common base class if we always need to 
> > > know the dynamic type?
> > > 
> > > Looking at the code this does not look bad. But it might be a code smell.
> > The way how we process the `extDefMapping` file is identical in both cases. 
> > That's an index, keyed with the `USR`s of functions and then we get back a 
> > value. And the way how we use that value is different. In the PCH case that 
> > holds the path for the `.ast` file, in the ODM case that is the name of the 
> > source file which we must find in the compile db. So, I think the process 
> > of getting the AST for a USR requires the polymorphic behavior from the 
> > loaders.
> > 
> > We discussed other alternatives with Endre. We were thinking that maybe the 
> > `extDefMapping` file should be identical in both cases. But then we would 
> > need to add the `.ast` postfixes for the entries in the PCH case. And we 
> > cannot just do that, because we may not know if what is the correct 
> > postfix. The user may have generated `.pch` files instead. Also, we don't 
> > want to compel any Clang user to use CodeChecker (CC will always create 
> > `.ast` files). CTU should be running fine by manually executing the 
> > independent steps.
> Let me rephrase my concerns a bit. Do we really need a polymorphic 
> `ASTLoader` to be present for the whole analysis? Wouldn't it make more sense 
> to always do the same thing, i.e. if we are given a pch file load it, if we 
> are given a source file, parse it? This way we would not be restricted to 
> on-demand or two pass ctu analysis, but we could do any combination of the 
> two.
> 
Well yeah, we could do that, it is a good idea, thanks! We will consider this 
in the future. I like in this idea that the command line options to Clang would 
be simplified. But then we must be transparent and show/log the user which 
method we are using.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D78642: [clang-format] Handle C# property accessors when parsing lines

2020-04-22 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added reviewers: krasimir, MyDeveloperDay.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Improve C# `{ get; set; } = default;` formatting by handling it in the 
UnwrappedLineParser rather than trying to merge lines later.

Remove old logic to merge lines.

Update tests as formatting output has changed (as intended).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78642

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -245,13 +245,11 @@
"}");
 
   verifyFormat("[TestMethod]\n"
-   "public string Host\n"
-   "{ set; get; }");
+   "public string Host { set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
-   "public string Host\n"
-   "{ set; get; }");
+   "public string Host { set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -132,6 +132,7 @@
   void parseCSharpGenericTypeConstraint();
   bool tryToParseLambda();
   bool tryToParseLambdaIntroducer();
+  bool tryToParsePropertyAccessor();
   void tryToParseJSFunction();
   void addUnwrappedLine();
   bool eof() const;
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1334,7 +1334,7 @@
 parseChildBlock();
   break;
 case tok::l_brace:
-  if (!tryToParseBracedList()) {
+  if (!tryToParsePropertyAccessor() && !tryToParseBracedList()) {
 // A block outside of parentheses must be the last part of a
 // structural element.
 // FIXME: Figure out cases where this is not true, and add projections
@@ -1487,6 +1487,75 @@
   } while (!eof());
 }
 
+bool UnwrappedLineParser::tryToParsePropertyAccessor() {
+  assert(FormatTok->is(tok::l_brace));
+  if(!Style.isCSharp()) 
+return false;
+  // See if it's a property accessor.
+  if (FormatTok->Previous->isNot(tok::identifier))
+return false;
+
+  // Try to parse the property accessor braces and contents:
+  // `{ get; set; } = new MyType(defaultValue);`
+  //  ^
+  //
+  // Record the current tokenPosition so that we can advance and
+  // reset the current token. `Next` is not set yet so we need
+  // another way to advance along the token stream.
+  unsigned int StoredPosition = Tokens->getPosition();
+  FormatToken *Tok = Tokens->getNextToken();
+
+  bool HasGetOrSet = false;
+  while (!eof()) {
+if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
+ tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
+ Keywords.kw_set)) {
+  if (Tok->isOneOf(Keywords.kw_get, Keywords.kw_set))
+  HasGetOrSet = true;
+  Tok = Tokens->getNextToken();
+  continue;
+}
+if (Tok->is(tok::r_brace))
+  break;
+Tokens->setPosition(StoredPosition);
+return false;
+  }
+
+  if(!HasGetOrSet) {
+Tokens->setPosition(StoredPosition);
+return false;
+  }
+
+  Tokens->setPosition(StoredPosition);
+  while (FormatTok->isNot(tok::r_brace)) {
+nextToken();
+  }
+
+  // Try to parse (optional) assignment to default value:
+  // `{ get; set; } = new MyType(defaultValue);`
+  //^^^
+  // There may be some very complicated expressions inside default value
+  // assignment, the simple parse block below will not handle them.
+  // The parse block below would need extending to handle opening parens etc.
+  StoredPosition = Tokens->getPosition();
+  Tok = Tokens->getNextToken();
+  bool NextTokenIsEqual = Tok->is(tok::equal);
+  Tokens->setPosition(StoredPosition);
+
+  if (NextTokenIsEqual) {
+do {
+  nextToken();
+  if (FormatTok->is(tok::semi))
+break;
+} while (!eof());
+  }
+
+  // Add an unwrapped line for the whole property accessor.
+  nextToken();
+  addUnwrappedLine();
+  return true;
+}
+
 bool UnwrappedLineParser::tryToParseLambda() {
   if (!Style.isCpp()) {
 nextToken();
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormat

[clang] d7ab9e7 - [ARM] Release notes for the Custom Datapath Extension (CDE)

2020-04-22 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-04-22T16:34:19+01:00
New Revision: d7ab9e7c9b309ebac094bba209f7c15ad5f01768

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

LOG: [ARM] Release notes for the Custom Datapath Extension (CDE)

Summary:
This change mentions CDE assembly in the LLVM release notes and CDE
intrinsics in both Clang and LLVM release notes.

Reviewers: kristof.beyls, simon_tatham

Reviewed By: kristof.beyls

Subscribers: danielkiss, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6ed00a5be936..1f4bc0f0d0da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,6 +61,8 @@ Non-comprehensive list of changes in this release
   v8.1-M MVE instruction set.  supports the complete API defined
   in the Arm C Language Extensions.
 
+- For the ARM target, C-language intrinsics  for the CDE instruction
+  set are now provided.
 
 * clang adds support for a set of  extended integer types (``_ExtInt(N)``) that
   permit non-power of 2 integers, exposing the LLVM integer types. Since a 
major

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index aad4ea88da1e..3afdce296fcd 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -76,6 +76,11 @@ During this release ...
   set.  now supports the complete API defined in the Arm C
   Language Extensions.
 
+* Added support for assembly for the optional Custom Datapath Extension (CDE)
+  for Arm M-profile targets.
+
+* Implemented C-language intrinsics  for the CDE instruction set.
+
 Changes to the MIPS Target
 --
 



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


[clang] 5daa25f - clang-format: support aligned nested conditionals formatting

2020-04-22 Thread Francois Ferrand via cfe-commits

Author: Francois Ferrand
Date: 2020-04-22T17:36:33+02:00
New Revision: 5daa25fd7a184524759b6ad065a8bd7e95aa149a

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

LOG: clang-format: support aligned nested conditionals formatting

When multiple ternary operators are chained, e.g. like an if/else-if/
else-if/.../else sequence, clang-format will keep aligning the colon
with the question mark, which increases the indent for each
conditionals:

  int a = condition1 ? result1
 : condition2 ? result2
  : condition3 ? result3
   : result4;

This patch detects the situation (e.g. conditionals used in false branch
of another conditional), to avoid indenting in that case:

  int a = condition1   ? result1
  : condition2 ? result2
  : condition3 ? result3
   : result4;

When BreakBeforeTernaryOperators is false, this will format like this:

  int a = condition1 ? result1 :
  condition2 ? result2 :
  conditino3 ? result3 :
   result4;

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index e70ae7efb0c3..8f1089dc81cb 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -367,6 +367,12 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   State.Stack.back().BreakBeforeParameter && !Current.isTrailingComment() 
&&
   !Current.isOneOf(tok::r_paren, tok::r_brace))
 return true;
+  if (State.Stack.back().IsChainedConditional &&
+  ((Style.BreakBeforeTernaryOperators && Current.is(TT_ConditionalExpr) &&
+Current.is(tok::colon)) ||
+   (!Style.BreakBeforeTernaryOperators && Previous.is(TT_ConditionalExpr) 
&&
+Previous.is(tok::colon
+return true;
   if (((Previous.is(TT_DictLiteral) && Previous.is(tok::l_brace)) ||
(Previous.is(TT_ArrayInitializerLSquare) &&
 Previous.ParameterCount > 1) ||
@@ -1022,8 +1028,21 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   if (State.Stack.back().QuestionColumn != 0 &&
   ((NextNonComment->is(tok::colon) &&
 NextNonComment->is(TT_ConditionalExpr)) ||
-   Previous.is(TT_ConditionalExpr)))
+   Previous.is(TT_ConditionalExpr))) {
+if (((NextNonComment->is(tok::colon) && NextNonComment->Next &&
+  !NextNonComment->Next->FakeLParens.empty() &&
+  NextNonComment->Next->FakeLParens.back() == prec::Conditional) ||
+ (Previous.is(tok::colon) && !Current.FakeLParens.empty() &&
+  Current.FakeLParens.back() == prec::Conditional)) &&
+!State.Stack.back().IsWrappedConditional) {
+  //NOTE: we may tweak this slightly:
+  //* not remove the 'lead' ContinuationIndentWidth
+  //* always un-indent by the operator when 
BreakBeforeTernaryOperators=true
+  unsigned Indent = State.Stack.back().Indent - 
Style.ContinuationIndentWidth;
+  return Indent;
+}
 return State.Stack.back().QuestionColumn;
+  }
   if (Previous.is(tok::comma) && State.Stack.back().VariablePos != 0)
 return State.Stack.back().VariablePos;
   if ((PreviousNonComment &&
@@ -1144,6 +1163,10 @@ unsigned 
ContinuationIndenter::moveStateToNextToken(LineState &State,
   if (Current.is(TT_ArraySubscriptLSquare) &&
   State.Stack.back().StartOfArraySubscripts == 0)
 State.Stack.back().StartOfArraySubscripts = State.Column;
+  if (Current.is(TT_ConditionalExpr) && Current.is(tok::question) &&
+  ((Current.MustBreakBefore) ||
+   (Current.getNextNonComment() && 
Current.getNextNonComment()->MustBreakBefore)))
+State.Stack.back().IsWrappedConditional = true;
   if (Style.BreakBeforeTernaryOperators && Current.is(tok::question))
 State.Stack.back().QuestionColumn = State.Column;
   if (!Style.BreakBeforeTernaryOperators && Current.isNot(tok::colon)) {
@@ -1284,6 +1307,8 @@ void 
ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
 NewParenState.Tok = nullptr;
 NewParenState.ContainsLineBreak = false;
 NewParenState.LastOperatorWrapped = true;
+NewParenState.IsChainedConditional = false;
+NewParenState.IsWrappedConditional = false;
 NewParenState.NoLineBreak =
 NewParenState.NoLineBreak || State.Stack.back().NoLineBreakInOperand;
 
@@ -1316,14 +1341,20 @@ void 
ContinuationIndenter::moveStatePastFakeLParens(LineState &State,
 

[clang] 3d61b11 - clang-format: Introduce stricter AlignOperands flag

2020-04-22 Thread Francois Ferrand via cfe-commits

Author: Francois Ferrand
Date: 2020-04-22T17:36:38+02:00
New Revision: 3d61b1120e8267aa39f4c9a33d618dbaec4ec6fa

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

LOG: clang-format: Introduce stricter AlignOperands flag

Summary:
Even when BreakBeforeBinaryOperators is set, AlignOperands kept
aligning the beginning of the line, even when it could align the
actual operands (e.g. after an assignment).

With this patch, there is an option to actually align the operands, so
that the operator gets right-aligned with the equal sign or return
operator:

  int a = bb
+ cc;
  return aaa
  && bbb;

This not happen in parentheses, to avoid 'breaking' the indentation:

  if (a
  && b)
return;

Reviewers: krasimir, djasper

Subscribers: cfe-commits, klimek

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/ContinuationIndenter.h
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6d486224e3c2..e5a69fdb9c5a 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -270,17 +270,49 @@ the configuration (without a prefix: ``Auto``).
 
 
 
-**AlignOperands** (``bool``)
+**AlignOperands** (``OperandAlignmentStyle``)
   If ``true``, horizontally align operands of binary and ternary
   expressions.
 
-  Specifically, this aligns operands of a single expression that needs to be
-  split over multiple lines, e.g.:
+  Possible values:
+
+  * ``OAS_DontAlign`` (in configuration: ``DontAlign``)
+Do not align operands of binary and ternary expressions.
+The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
+the start of the line.
+
+  * ``OAS_Align`` (in configuration: ``Align``)
+Horizontally align operands of binary and ternary expressions.
+
+Specifically, this aligns operands of a single expression that needs
+to be split over multiple lines, e.g.:
+
+.. code-block:: c++
+
+  int aaa = bbb +
+ccc;
+
+When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
+aligned with the operand on the first line.
+
+.. code-block:: c++
+
+  int aaa = bbb
++ ccc;
+
+  * ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
+Horizontally align operands of binary and ternary expressions.
+
+This is similar to ``AO_Align``, except when
+``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
+that the wrapped operand is aligned with the operand on the first line.
+
+.. code-block:: c++
+
+  int aaa = bbb
+  + ccc;
 
-  .. code-block:: c++
 
-int aaa = bbb +
-  ccc;
 
 **AlignTrailingComments** (``bool``)
   If ``true``, aligns trailing comments.

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 2b2edc4adc11..f5fa6b44a127 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -153,16 +153,43 @@ struct FormatStyle {
   /// Options for aligning backslashes in escaped newlines.
   EscapedNewlineAlignmentStyle AlignEscapedNewlines;
 
+  /// Different styles for aligning operands.
+  enum OperandAlignmentStyle {
+/// Do not align operands of binary and ternary expressions.
+/// The wrapped lines are indented ``ContinuationIndentWidth`` spaces from
+/// the start of the line.
+OAS_DontAlign,
+/// Horizontally align operands of binary and ternary expressions.
+///
+/// Specifically, this aligns operands of a single expression that needs
+/// to be split over multiple lines, e.g.:
+/// \code
+///   int aaa = bbb +
+/// ccc;
+/// \endcode
+///
+/// When ``BreakBeforeBinaryOperators`` is set, the wrapped operator is
+/// aligned with the operand on the first line.
+/// \code
+///   int aaa = bbb
+/// + ccc;
+/// \endcode
+OAS_Align,
+/// Horizontally align operands of binary and ternary expressions.
+///
+/// This is similar to ``AO_Align``, except when
+/// ``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
+/// that the wrapped operand is aligned with the operand on the first line.
+/// \code
+///   int aaa = bbb
+ 

[PATCH] D75479: [clangd] go-to-def on names in comments etc that are used nearby.

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 259295.
sammccall marked 15 inline comments as done.
sammccall added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75479

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -685,10 +685,15 @@
 
 auto AST = TU.build();
 auto Index = TU.index();
-auto Results = locateSymbolNamedTextuallyAt(
-AST, Index.get(),
+auto Word = SpelledWord::touching(
 cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-testPath(TU.Filename));
+AST.getTokens(), AST.getLangOpts());
+if (!Word) {
+  ADD_FAILURE() << "No word touching point!" << Test;
+  continue;
+}
+auto Results =
+locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
 
 if (!WantDecl) {
   EXPECT_THAT(Results, IsEmpty()) << Test;
@@ -788,10 +793,12 @@
   auto TU = TestTU::withCode(T.code());
   auto AST = TU.build();
   auto Index = TU.index();
-  auto Results = locateSymbolNamedTextuallyAt(
-  AST, Index.get(),
+  auto Word = SpelledWord::touching(
   cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-  testPath(TU.Filename));
+  AST.getTokens(), AST.getLangOpts());
+  ASSERT_TRUE(Word);
+  auto Results =
+  locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
   EXPECT_THAT(Results,
   UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
Sym("uniqueMethodName", T.range("BarLoc";
@@ -985,6 +992,101 @@
   ElementsAre(Sym("foo", FooWithoutHeader.range(;
 }
 
+TEST(LocateSymbol, NearbyTokenSmoke) {
+  auto T = Annotations(R"cpp(
+// prints e^rr and crashes
+void die(const char* [[err]]);
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  // We don't pass an index, so can't hit index-based fallback.
+  EXPECT_THAT(locateSymbolAt(AST, T.point()),
+  ElementsAre(Sym("err", T.range(;
+}
+
+TEST(LocateSymbol, NearbyIdentifier) {
+  const char *Tests[] = {
+  R"cpp(
+  // regular identifiers (won't trigger)
+  int hello;
+  int y = he^llo;
+)cpp",
+  R"cpp(
+  // disabled preprocessor sections
+  int [[hello]];
+  #if 0
+  int y = ^hello;
+  #endif
+)cpp",
+  R"cpp(
+  // comments
+  // he^llo, world
+  int [[hello]];
+)cpp",
+  R"cpp(
+  // not triggered by string literals
+  int hello;
+  const char* greeting = "h^ello, world";
+)cpp",
+
+  R"cpp(
+  // can refer to macro invocations
+  #define INT int
+  [[INT]] x;
+  // I^NT
+)cpp",
+
+  R"cpp(
+  // can refer to macro invocations (even if they expand to nothing)
+  #define EMPTY
+  [[EMPTY]] int x;
+  // E^MPTY
+)cpp",
+
+  R"cpp(
+  // prefer nearest occurrence, backwards is worse than forwards
+  int hello;
+  int x = hello;
+  // h^ello
+  int y = [[hello]];
+  int z = hello;
+)cpp",
+
+  R"cpp(
+  // short identifiers find near results
+  int [[hi]];
+  // h^i
+)cpp",
+  R"cpp(
+  // short identifiers don't find far results
+  int hi;
+
+
+
+  // h^i
+)cpp",
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+const auto &SM = AST.getSourceManager();
+llvm::Optional Nearby;
+auto Word =
+SpelledWord::touching(cantFail(sourceLocationInMainFile(SM, T.point())),
+  AST.getTokens(), AST.getLangOpts());
+if (!Word) {
+  ADD_FAILURE() << "No word at point! " << Test;
+  continue;
+}
+if (const auto *Tok = findNearbyIdentifier(*Word, AST.getTokens()))
+  Nearby = halfOpenToRange(SM, CharSourceRange::getCharRange(
+   Tok->location(), Tok->endLocation()));
+if (T.ranges().empty())
+  EXPECT_THAT(Nearby, Eq(llvm::None)) << Test;
+else
+  EXPECT_EQ(Nearby, T.range()) << Test;
+  }
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -12,6 +12,7 @@
 #i

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added inline comments.



Comment at: clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp:5
+
+void test_amdgcn_fence_failure() {
+

JonChesterfield wrote:
> arsenm wrote:
> > Does this really depend on C++? Can it use OpenCL like the other builtin 
> > tests?This also belongs in a Sema* test directory since it's checking an 
> > error
> Making it opencl-only would force some of the openmp runtime to be written in 
> opencl, which is not presently the case. Currently that library is written in 
> a dialect of hip, but there's a plan to implement it in openmp instead.
> 
> I'd much rather this builtin work from any language, instead of tying it to 
> opencl, as that means one can use it from openmp target regions.
I thought the question was about this test itself.  The test being in 
CodeGenOpenCL doesn't affect whether other languages can use the builtin.  Why 
not put this test in CodeGenOpenCL alongside all of the other 
builtins-amdgcn-*.cl ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D78644: [LSan] Enable for SystemZ

2020-04-22 Thread Ilya Leoshkevich via Phabricator via cfe-commits
iii created this revision.
iii added reviewers: vitalybuka, eugenis, uweigand, jonpa.
Herald added subscribers: Sanitizers, cfe-commits, mgorny.
Herald added projects: clang, Sanitizers.

Add runtime support, adjust the tests and enable LSan.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78644

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/lsan/lsan_allocator.h
  compiler-rt/lib/lsan/lsan_common.h
  compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
  compiler-rt/test/lsan/TestCases/use_registers.cpp
  compiler-rt/test/lsan/lit.common.cfg.py
  compiler-rt/test/sanitizer_common/print_address.h

Index: compiler-rt/test/sanitizer_common/print_address.h
===
--- compiler-rt/test/sanitizer_common/print_address.h
+++ compiler-rt/test/sanitizer_common/print_address.h
@@ -7,7 +7,8 @@
   va_start(ap, n);
   while (n--) {
 void *p = va_arg(ap, void *);
-#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
+defined(__s390x__)
 // On FreeBSD, the %p conversion specifier works as 0x%x and thus does not
 // match to the format used in the diagnotic message.
 fprintf(stderr, "0x%012lx ", (unsigned long) p);
Index: compiler-rt/test/lsan/lit.common.cfg.py
===
--- compiler-rt/test/lsan/lit.common.cfg.py
+++ compiler-rt/test/lsan/lit.common.cfg.py
@@ -69,8 +69,8 @@
 config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) )
 config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
 
-# LeakSanitizer tests are currently supported on x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, and x86_64 Darwin.
-supported_linux = config.host_os is 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l']
+# LeakSanitizer tests are currently supported on x86-64 Linux, PowerPC64 Linux, arm Linux, mips64 Linux, s390x Linux and x86_64 Darwin.
+supported_linux = config.host_os is 'Linux' and config.host_arch in ['x86_64', 'ppc64', 'ppc64le', 'mips64', 'arm', 'armhf', 'armv7l', 's390x']
 supported_darwin = config.host_os is 'Darwin' and config.target_arch is 'x86_64'
 supported_netbsd = config.host_os is 'NetBSD' and config.target_arch in ['x86_64', 'i386']
 if not (supported_linux or supported_darwin or supported_netbsd):
Index: compiler-rt/test/lsan/TestCases/use_registers.cpp
===
--- compiler-rt/test/lsan/TestCases/use_registers.cpp
+++ compiler-rt/test/lsan/TestCases/use_registers.cpp
@@ -43,6 +43,10 @@
   :
   : "r" (p)
   );
+#elif defined(__s390x__)
+  asm("lgr %%r10, %0"
+  :
+  : "r"(p));
 #else
 #error "Test is not supported on this architecture."
 #endif
Index: compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
===
--- compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
+++ compiler-rt/test/lsan/TestCases/stale_stack_leak.cpp
@@ -5,7 +5,8 @@
 // RUN: %env_lsan_opts=$LSAN_BASE":exitcode=0" %run %t 2>&1 | FileCheck --check-prefix=CHECK-sanity %s
 //
 // x86 passes parameters through stack that may lead to false negatives
-// UNSUPPORTED: x86,powerpc64,arm
+// The same applies to s390x register save areas.
+// UNSUPPORTED: x86,powerpc64,arm,s390x
 
 #include 
 #include 
Index: compiler-rt/lib/lsan/lsan_common.h
===
--- compiler-rt/lib/lsan/lsan_common.h
+++ compiler-rt/lib/lsan/lsan_common.h
@@ -29,10 +29,10 @@
 // To enable LeakSanitizer on a new architecture, one needs to implement the
 // internal_clone function as well as (probably) adjust the TLS machinery for
 // the new architecture inside the sanitizer library.
-#if (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC) && \
-(SANITIZER_WORDSIZE == 64) &&   \
+#if (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC) &&  \
+(SANITIZER_WORDSIZE == 64) &&\
 (defined(__x86_64__) || defined(__mips64) || defined(__aarch64__) || \
- defined(__powerpc64__))
+ defined(__powerpc64__) || defined(__s390x__))
 #define CAN_SANITIZE_LEAKS 1
 #elif defined(__i386__) && \
 (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC)
Index: compiler-rt/lib/lsan/lsan_allocator.h
===
--- compiler-rt/lib/lsan/lsan_allocator.h
+++ compiler-rt/lib/lsan/lsan_allocator.h
@@ -65,13 +65,16 @@
 template 
 using PrimaryAllocatorASVT = SizeClassAllocator32>;
 using PrimaryAllocator = PrimaryAllocatorASVT;
-#elif defined(__x86_64__) || defined(__powerpc64__)
+#elif defined(__x86_64__) || defined(__powerpc64__) 

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 259298.
saiislam added a comment.

Moved builtin-amdgcn-fence-failure.cpp from clang/test/CodeGenCXX/
to clang/test/Sema/ since it is checking an error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
  clang/test/CodeGenHIP/builtin_memory_fence.cpp
  clang/test/Sema/builtin-amdgcn-fence-failure.cpp
  clang/test/Sema/builtins.c
  clang/test/SemaOpenCL/builtins-amdgcn-error.cl

Index: clang/test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- clang/test/SemaOpenCL/builtins-amdgcn-error.cl
+++ clang/test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -128,3 +128,11 @@
   *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, a, false); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
   *out = __builtin_amdgcn_ds_fmaxf(out, src, 0, 0, a); // expected-error {{argument to '__builtin_amdgcn_ds_fmaxf' must be a constant integer}}
 }
+
+void test_fence() {
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
+  __builtin_amdgcn_fence(__ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
+  __builtin_amdgcn_fence(4); // expected-error {{too few arguments to function call, expected 2}}
+  __builtin_amdgcn_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
+  __builtin_amdgcn_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
+}
Index: clang/test/Sema/builtins.c
===
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -320,15 +320,3 @@
   // expected-error@+1 {{use of unknown builtin '__builtin_is_constant_evaluated'}}
   return __builtin_is_constant_evaluated();
 }
-
-void test_memory_fence_errors() {
-  __builtin_memory_fence(__ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
-
-  __builtin_memory_fence(__ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
-
-  __builtin_memory_fence(4); // expected-error {{too few arguments to function call, expected 2}}
-
-  __builtin_memory_fence(4, 4, 4); // expected-error {{too many arguments to function call, expected 2}}
-
-  __builtin_memory_fence(3.14, ""); // expected-warning {{implicit conversion from 'double' to 'unsigned int' changes value from 3.14 to 3}}
-}
Index: clang/test/Sema/builtin-amdgcn-fence-failure.cpp
===
--- /dev/null
+++ clang/test/Sema/builtin-amdgcn-fence-failure.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: not %clang_cc1 %s -S \
+// RUN:   -triple=amdgcn-amd-amdhsa 2>&1 | FileCheck %s
+
+void test_amdgcn_fence_failure() {
+
+  // CHECK: error: Unsupported atomic synchronization scope 
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "foobar");
+}
\ No newline at end of file
Index: clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
===
--- clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
+++ clang/test/CodeGenCXX/builtin-amdgcn-fence.cpp
@@ -1,25 +1,22 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 %s -x hip -emit-llvm -O0 -o - \
+// RUN: %clang_cc1 %s -emit-llvm -O0 -o - \
 // RUN:   -triple=amdgcn-amd-amdhsa  | opt -instnamer -S | FileCheck %s
 
 void test_memory_fence_success() {
 // CHECK-LABEL: test_memory_fence_success
 
   // CHECK: fence syncscope("workgroup") seq_cst
-  __builtin_memory_fence(__ATOMIC_SEQ_CST,  "workgroup");
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST,  "workgroup");
   
// CHECK: fence syncscope("agent") acquire
-  __builtin_memory_fence(__ATOMIC_ACQUIRE, "agent");
+  __builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "agent");
 
   // CHECK: fence seq_cst
-  __builtin_memory_fence(__ATOMIC_SEQ_CST, "");
+  __builtin_amdgcn_fence(__ATOMIC_SEQ_CST, "");
 
   // CHECK: fence syncscope("agent") acq_rel
-  __builtin_memory_fence(4, "agent");
+  __builtin_amdgcn_fence(4, "agent");
 
 // CHECK: fence syncscope("workgroup") release
-  __builtin_memory_fence(3, "workgroup");
-
-  // CHECK: fence syncscope("foobar") release
-  __builtin_memory_fence(3, "foobar");
-}
\ No newline at end of file
+  __builtin_amdgcn_fence(3, "workgroup");
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/S

[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Hana Joo via Phabricator via cfe-commits
h-joo created this revision.
h-joo added a reviewer: ABataev.
h-joo added projects: clang, OpenMP.
Herald added subscribers: cfe-commits, arphaman, guansong, yaxunl.
Herald added a reviewer: jdoerfert.

This is a fix for Bug 45383 .

This revision fixes the error reported for array subscription for the cases 
where the array index is a template parameter.
Note that the `ArraySubscriptExpr::getBase()` might return something which 
might not be a base in the cases where either LHS or RHS of the 
`ArraySubscriptExpr` is a template declaration - I think the fundemental fix 
would include more changes with `ArraySubscriptExpr::getBase()` in the presence 
of template dependent types, but I thought it would involve a bigger scope of 
refactoring since many of the code is touching it.

Please also keep in mind this is my first patch, so I would be very glad for 
any kind of comment if I did something wrong.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78643

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/depend_template_subscription.cpp


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-no-diagnostics
+  {
+;
+  }
+}
+
+int driver(double *A)
+{
+  int k = 0;
+  test(A, k);
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,25 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonReferenceType()
-  ->isPointerType() &&
- !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) 
{
+if (!RefExpr->IgnoreParenImpCasts()->isLValue()) {
   Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
   << (LangOpts.OpenMP >= 50 ? 1 : 0)
   << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange();
   continue;
 }
 
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType();
+  if (!BaseType->isDependentType() &&
+  !BaseType.getNonReferenceType()->isPointerType() &&
+  !BaseType.getNonReferenceType()->isArrayType()) {
+Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0) << 
RefExpr->getSourceRange();
+continue;
+  }
+}
+
 ExprResult Res;
 {
   Sema::TentativeAnalysisScope Trap(*this);


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-no-diagnostics
+  {
+;
+  }
+}
+
+int driver(double *A)
+{
+  int k = 0;
+  test(A, k);
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,25 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonReferenceType()
-  ->isPointerType() &&
- !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) {
+if (!RefExpr->IgnoreParenImpCasts()->isLValue()) {
   Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
   << (LangOpts.OpenMP >= 50 ? 1 : 0)
   << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange();
   continue;
 }
 
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType();
+  if (!BaseType->isDependentType() &&
+  !BaseType.getNonReferenceType()->isPointerType() &&
+  !BaseType.getNonReferenceType()->isArrayType()) {
+Diag(ELoc, diag::err_omp_expected_addressable_lva

[PATCH] D78481: [ARM] Release notes for the Custom Datapath Extension (CDE)

2020-04-22 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls accepted this revision.
kristof.beyls 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/D78481/new/

https://reviews.llvm.org/D78481



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


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-04-22 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked an inline comment as done.
saiislam added inline comments.



Comment at: clang/test/CodeGenCXX/builtin-amdgcn-fence-failure.cpp:5
+
+void test_amdgcn_fence_failure() {
+

b-sumner wrote:
> JonChesterfield wrote:
> > arsenm wrote:
> > > Does this really depend on C++? Can it use OpenCL like the other builtin 
> > > tests?This also belongs in a Sema* test directory since it's checking an 
> > > error
> > Making it opencl-only would force some of the openmp runtime to be written 
> > in opencl, which is not presently the case. Currently that library is 
> > written in a dialect of hip, but there's a plan to implement it in openmp 
> > instead.
> > 
> > I'd much rather this builtin work from any language, instead of tying it to 
> > opencl, as that means one can use it from openmp target regions.
> I thought the question was about this test itself.  The test being in 
> CodeGenOpenCL doesn't affect whether other languages can use the builtin.  
> Why not put this test in CodeGenOpenCL alongside all of the other 
> builtins-amdgcn-*.cl ?
This test is basically relying on implementation of sync scope in the AMDGCN 
backend to check for validity, and is not testing the code generation 
capability. Doesn't it make more sense in Sema directory?

Won't putting it in SemaOpenCL or SemaOpenCLCXX indicate some kind of relation 
with OpenCL?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75917



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


[PATCH] D78648: [CMake] Bump CMake minimum version to 3.13.4

2020-04-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

This review is for the upcoming CMake upgrade once we branch off the LLVM 11 
release branch.

I won't apply it until after the branch has been created, which is around July.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78648



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


[PATCH] D78648: [CMake] Bump CMake minimum version to 3.13.4

2020-04-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
Herald added subscribers: libcxx-commits, openmp-commits, lldb-commits, 
Sanitizers, cfe-commits, frgossen, grosul1, jvesely, Joonsoo, liufengdb, 
lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, 
jpienaar, rriddle, mehdi_amini, lebedev.ri, dexonsmith, jkorous, whisperity, 
mgorny.
Herald added a reviewer: bollu.
Herald added a reviewer: lebedev.ri.
Herald added a reviewer: DavidTruby.
Herald added projects: clang, Sanitizers, LLDB, libc++, OpenMP, libc++abi, 
libunwind.
Herald added a reviewer: libc++.
Herald added a reviewer: libc++abi.
Herald added a reviewer: libunwind.
ldionne added a parent revision: D78646: [CMake] Enforce the minimum CMake 
version to be at least 3.13.4.
Herald added a reviewer: jdoerfert.
ldionne added a comment.
ldionne accepted this revision as: libc++, libc++abi, libunwind.

This review is for the upcoming CMake upgrade once we branch off the LLVM 11 
release branch.

I won't apply it until after the branch has been created, which is around July.


This upgrade should be friction-less because we've already been ensuring
that CMake >= 3.13.4 is used.

This is part of the effort discussed on llvm-dev here:

  http://lists.llvm.org/pipermail/llvm-dev/2020-April/140578.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78648

Files:
  clang/CMakeLists.txt
  clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/Modules/CustomLibcxx/CMakeLists.txt
  compiler-rt/lib/builtins/CMakeLists.txt
  flang/CMakeLists.txt
  libclc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/tools/debugserver/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/docs/CMake.rst
  llvm/docs/CMakePrimer.rst
  llvm/docs/GettingStarted.rst
  llvm/runtimes/CMakeLists.txt
  llvm/utils/benchmark/CMakeLists.txt
  mlir/examples/standalone/CMakeLists.txt
  openmp/CMakeLists.txt
  openmp/cmake/DetectTestCompiler/CMakeLists.txt
  openmp/runtime/cmake/LibompCheckLinkerFlag.cmake
  parallel-libs/CMakeLists.txt
  parallel-libs/acxxel/CMakeLists.txt
  polly/CMakeLists.txt
  pstl/CMakeLists.txt

Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -5,7 +5,7 @@
 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 #
 #===--===##
-cmake_minimum_required(VERSION 3.4.3)
+cmake_minimum_required(VERSION 3.13.4)
 
 set(PARALLELSTL_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/include/pstl/internal/pstl_config.h")
 file(STRINGS "${PARALLELSTL_VERSION_FILE}" PARALLELSTL_VERSION_SOURCE REGEX "#define _PSTL_VERSION .*$")
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -1,7 +1,7 @@
 # Check if this is a in tree build.
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
-  cmake_minimum_required(VERSION 3.4.3)
+  cmake_minimum_required(VERSION 3.13.4)
 
   # Where is LLVM installed?
   find_package(LLVM CONFIG REQUIRED)
Index: parallel-libs/acxxel/CMakeLists.txt
===
--- parallel-libs/acxxel/CMakeLists.txt
+++ parallel-libs/acxxel/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.13.4)
 
 option(ACXXEL_ENABLE_UNIT_TESTS "enable acxxel unit tests" ON)
 option(ACXXEL_ENABLE_MULTI_DEVICE_UNIT_TESTS "enable acxxel multi-device unit tests" OFF)
Index: parallel-libs/CMakeLists.txt
===
--- parallel-libs/CMakeLists.txt
+++ parallel-libs/CMakeLists.txt
@@ -1 +1 @@
-cmake_minimum_required(VERSION 3.1)
+cmake_minimum_required(VERSION 3.13.4)
Index: openmp/runtime/cmake/LibompCheckLinkerFlag.cmake
===
--- openmp/runtime/cmake/LibompCheckLinkerFlag.cmake
+++ openmp/runtime/cmake/LibompCheckLinkerFlag.cmake
@@ -17,7 +17,7 @@
   set(library_source
 "int foo(int a) { return a*a; }")
   set(cmake_source
-"cmake_minimum_required(VERSION 2.8)
+"cmake_minimum_required(VERSION 3.13.4)
  project(foo C)
  set(CMAKE_SHARED_LINKER_FLAGS \"${flag}\")
  add_library(foo SHARED src_to_link.c)")
Index: openmp/cmake/DetectTestCompiler/CMakeLists.txt
===
--- openmp/cmake/DetectTestCompiler/CMakeLists.txt
+++ openmp/cmake/DetectTestCompiler/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.13.4)
 project(DetectTestCompiler C CXX)
 
 include(CheckCCompilerFlag)
Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -1,4 +1,4

[PATCH] D78481: [ARM] Release notes for the Custom Datapath Extension (CDE)

2020-04-22 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd7ab9e7c9b30: [ARM] Release notes for the Custom Datapath 
Extension (CDE) (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78481

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -76,6 +76,11 @@
   set.  now supports the complete API defined in the Arm C
   Language Extensions.
 
+* Added support for assembly for the optional Custom Datapath Extension (CDE)
+  for Arm M-profile targets.
+
+* Implemented C-language intrinsics  for the CDE instruction set.
+
 Changes to the MIPS Target
 --
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -61,6 +61,8 @@
   v8.1-M MVE instruction set.  supports the complete API defined
   in the Arm C Language Extensions.
 
+- For the ARM target, C-language intrinsics  for the CDE instruction
+  set are now provided.
 
 * clang adds support for a set of  extended integer types (``_ExtInt(N)``) that
   permit non-power of 2 integers, exposing the LLVM integer types. Since a 
major


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -76,6 +76,11 @@
   set.  now supports the complete API defined in the Arm C
   Language Extensions.
 
+* Added support for assembly for the optional Custom Datapath Extension (CDE)
+  for Arm M-profile targets.
+
+* Implemented C-language intrinsics  for the CDE instruction set.
+
 Changes to the MIPS Target
 --
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -61,6 +61,8 @@
   v8.1-M MVE instruction set.  supports the complete API defined
   in the Arm C Language Extensions.
 
+- For the ARM target, C-language intrinsics  for the CDE instruction
+  set are now provided.
 
 * clang adds support for a set of  extended integer types (``_ExtInt(N)``) that
   permit non-power of 2 integers, exposing the LLVM integer types. Since a major
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2020-04-22 Thread Francois Ferrand via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Typz marked 2 inline comments as done.
Closed by commit rG3d61b1120e82: clang-format: Introduce stricter AlignOperands 
flag (authored by Typz).

Changed prior to commit:
  https://reviews.llvm.org/D32478?vs=226393&id=259307#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D32478

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

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -277,7 +277,7 @@
   verifyFormat("var x = a() in\n"
".aa.aa;");
   FormatStyle Style = getGoogleJSStyleWithColumns(80);
-  Style.AlignOperands = true;
+  Style.AlignOperands = FormatStyle::OAS_Align;
   verifyFormat("var x = a() in\n"
".aa.aa;",
Style);
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4240,6 +4240,9 @@
"  > c) {\n"
"}",
Style);
+  verifyFormat("return a\n"
+   "   && bbb;",
+   Style);
   verifyFormat("return (a)\n"
"   // comment\n"
"   + b;",
@@ -4268,7 +4271,7 @@
 
   Style.ColumnLimit = 60;
   verifyFormat("zz\n"
-   "= b\n"
+   "= \n"
"  >> (aa);",
Style);
 
@@ -4277,7 +4280,7 @@
   Style.TabWidth = 4;
   Style.UseTab = FormatStyle::UT_Always;
   Style.AlignAfterOpenBracket = FormatStyle::BAS_DontAlign;
-  Style.AlignOperands = false;
+  Style.AlignOperands = FormatStyle::OAS_DontAlign;
   EXPECT_EQ("return someVeryVeryLongConditionThatBarelyFitsOnALine\n"
 "\t&& (someOtherLongishConditionPart1\n"
 "\t\t|| someOtherEvenLongerNestedConditionPart2);",
@@ -4287,6 +4290,107 @@
Style));
 }
 
+TEST_F(FormatTest, ExpressionIndentationStrictAlign) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBinaryOperators = FormatStyle::BOS_All;
+  Style.AlignOperands = FormatStyle::OAS_AlignAfterOperator;
+
+  verifyFormat("bool value = a\n"
+   "   + a\n"
+   "   + a\n"
+   "  == a\n"
+   " * b\n"
+   " + b\n"
+   "  && a\n"
+   " * a\n"
+   " > c;",
+   Style);
+  verifyFormat("if (a\n"
+   "* \n"
+   "+ aa\n"
+   "== bbb) {\n}",
+   Style);
+  verifyFormat("if (a\n"
+   "+ \n"
+   "  * aa\n"
+   "== bbb) {\n}",
+   Style);
+  verifyFormat("if (a\n"
+   "== \n"
+   "   * aa\n"
+   "   + bbb) {\n}",
+   Style);
+  verifyFormat("if () {\n"
+   "} else if (a\n"
+   "   && b // break\n"
+   "  > c) {\n"
+   "}",
+   Style);
+  verifyFormat("return a\n"
+   "&& b

[clang] 662cbaf - [SveEmitter] Add IsOverloadNone flag and builtins for svpfalse and svcnt[bhwd]_pat

2020-04-22 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-04-22T16:42:08+01:00
New Revision: 662cbaf6476b7cc58d0d71ff98d95d00ce5b420e

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

LOG: [SveEmitter] Add IsOverloadNone flag and builtins for svpfalse and 
svcnt[bhwd]_pat

Add the IsOverloadNone flag to tell CGBuiltin that it does not have
an overloaded type. This is used for e.g. svpfalse which does
not take any arguments and always returns a svbool_t.

This patch also adds builtins for svcntb_pat, svcnth_pat, svcntw_pat
and svcntd_pat, as those don't require custom codegen.

Reviewers: SjoerdMeijer, efriedma, rovka

Reviewed By: efriedma

Tags: #clang

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c

Modified: 
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/Basic/arm_sve.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/utils/TableGen/SveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index d07b2d81988d..042f60739f85 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -233,6 +233,8 @@ namespace clang {
 bool isStructStore() const { return Flags & IsStructStore; }
 bool isZExtReturn() const { return Flags & IsZExtReturn; }
 bool isByteIndexed() const { return Flags & IsByteIndexed; }
+bool isOverloadNone() const { return Flags & IsOverloadNone; }
+bool isOverloadDefault() const { return !(Flags & OverloadKindMask); }
 
 uint64_t getBits() const { return Flags; }
 bool isFlagSet(uint64_t Flag) const { return Flags & Flag; }

diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index cc579f773669..c2794356d251 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -70,6 +70,10 @@
 // o: 4x width elements, 1/4 element count
 //
 // i: constant uint64_t
+// k: int32_t
+// l: int64_t
+// m: uint32_t
+// n: uint64_t
 //
 // I: Predicate Pattern (sv_pattern)
 
@@ -163,6 +167,8 @@ def IsScatterStore: FlagType<0x0001>;
 def IsStructLoad  : FlagType<0x0002>;
 def IsStructStore : FlagType<0x0004>;
 def IsZExtReturn  : FlagType<0x0008>; // Return value is 
sign-extend by default
+def IsOverloadNone: FlagType<0x0010>; // Intrinsic does not 
take any overloaded types.
+def OverloadKindMask  : FlagType<0x00E0>; // When the masked 
values are all '0', the default type is used as overload type.
 //  : :
 //  : :
 def IsByteIndexed : FlagType<0x0200>;
@@ -542,6 +548,20 @@ def SVCMLA_M : SInst<"svcmla[_{d}]", "dPdddi", "hfd", 
MergeOp1,  "aarch64_sve_fc
 def SVQDECH_S : SInst<"svqdech_pat[_{d}]",   "ddIi", "s", MergeNone, 
"aarch64_sve_sqdech", [], [ImmCheck<2, ImmCheck1_16>]>;
 def SVQDECH_U : SInst<"svqdech_pat[_{d}]",   "ddIi", "Us", MergeNone, 
"aarch64_sve_uqdech", [], [ImmCheck<2, ImmCheck1_16>]>;
 
+
+
+// Predicate creation
+
+def SVPFALSE : SInst<"svpfalse[_b]", "P", "", MergeNone, "", [IsOverloadNone]>;
+
+
+
+// Counting elements
+
+def SVCNTB_PAT : SInst<"svcntb_pat", "nI", "", MergeNone, "aarch64_sve_cntb", 
[IsOverloadNone]>;
+def SVCNTH_PAT : SInst<"svcnth_pat", "nI", "", MergeNone, "aarch64_sve_cnth", 
[IsOverloadNone]>;
+def SVCNTW_PAT : SInst<"svcntw_pat", "nI", "", MergeNone, "aarch64_sve_cntw", 
[IsOverloadNone]>;
+def SVCNTD_PAT : SInst<"svcntd_pat", "nI", "", MergeNone, "aarch64_sve_cntd", 
[IsOverloadNone]>;
 

 // Integer arithmetic
 def SVDOT_LANE_S : SInst<"svdot_lane[_{d}]",  "ddqqi",  "il",   MergeNone, 
"aarch64_sve_sdot_lane", [], [ImmCheck<3, ImmCheckLaneIndexDot, 2>]>;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3e24f0f53ab8..fa461a5dd9bf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7773,6 +7773,18 @@ static void InsertExplicitUndefOperand(CGBuilderTy 
&Builder, llvm::Type *Ty,
   Ops.insert(Ops.begin(), SplatUndef);
 }
 
+SmallVector
+CodeGenFunction::getSVEOverload

[PATCH] D78637: [OPENMP]Fix PR45383: type dependent array subscripts are diagnosed erroneously.

2020-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Can we merge the test changes into D78643  and 
continue with D78643  as a fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78637



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Macro argument expansion logic relies on skipping file IDs that created
as a result of an include. Unfortunately it fails to do that for
predefined buffer since it doesn't have a valid insertion location.

As a result of that any file ID created for an include inside the
predefined buffers breaks the traversal logic in
SourceManager::computeMacroArgsCache.

To fix this issue we first record number of created FIDs for predefined
buffer, and then skip them explicitly in source manager.

Another solution would be to just give predefined buffers a valid source
location, but it is unclear where that should be..


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78649

Files:
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/unittests/Basic/SourceManagerTest.cpp
  clang/unittests/Lex/LexerTest.cpp


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+PP->Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+  EXPECT_EQ(SourceMgr.getNumCreatedFIDsForFileID(PP->getPredefinesFileID()),
+1U);
+}
 } // anonymous namespace
Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -294,10 +294,16 @@
   TrivialModuleLoader ModLoader;
   HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
   Diags, LangOpts, &*Target);
+
   Preprocessor PP(std::make_shared(), Diags, LangOpts,
   SourceMgr, HeaderInfo, ModLoader,
   /*IILookup =*/nullptr,
   /*OwnsHeaderSearch =*/false);
+  // Ensure we can get expanded locations in presence of implicit includes.
+  // These are different than normal includes since predefines buffer doesn't
+  // have a valid insertion location.
+  PP.setPredefines("#include \"/implicit-header.h\"");
+  FileMgr.getVirtualFile("/implicit-header.h", 0, 0);
   PP.Initialize(*Target);
   PP.EnterMainSourceFile();
 
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -415,7 +415,9 @@
 }
 
 if (!isEndOfMacro && CurPPLexer &&
-SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid()) {
+(SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid() ||
+ // Predefines file doesn't have a valid include location.
+ CurPPLexer->FID == getPredefinesFileID())) {
   // Notify SourceManager to record the number of FileIDs that were created
   // during lexing of the #include'd file.
   unsigned NumFIDs =
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1799,6 +1799,14 @@
 if (Invalid)
   return;
 if (Entry.isFile()) {
+  // Predefined header doesn't have a valid include location in main faile,
+  // but any files created by it should still be skipped when computing
+  // macro args expanded in the main file.
+  if (Entry.getFile().Filename == "" && FID == getMainFileID()) {
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;
+continue;
+  }
   SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc();
   if (IncludeLoc.isInvalid())
 continue;


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+PP->Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+  EXPECT_EQ(SourceMgr.getNumCreatedFIDsForFileID(PP->getPredefinesFileID()),
+1U);
+}
 } // anonymous namespace
Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittest

[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Can we create a test case that shows even if it is a dependent type we will 
eventuall issue an error if it is not an addressable lvalue or array item?
If this is the part that needs refactoring to work, we should add the test with 
a TODO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-04-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

The demangler changes should also be made in `libcxxabi/src/demangle`, as there 
is a copy of the demangler there. This change also needs tests, there should be 
demangler tests (in libcxxabi/test/test_demangle.cpp), and IRGen tests (in 
clang/test/CodeGen) that check the mangled name. Finally, can you please add 
full contexts to your diffs? (by running e.g. `git show -U9`).




Comment at: clang/lib/AST/Mangle.cpp:39
 raw_ostream &Out) {
-  unsigned discriminator = Context.getBlockId(BD, true);
-  if (discriminator == 0)
-Out << "__" << Outer << "_block_invoke";
-  else
-Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+  Out << "__" << Outer << "_block_invoke";
+

We should also probably do this for global blocks, which are handled separately 
below.



Comment at: clang/lib/AST/Mangle.cpp:42
+  ArrayRef params = BD->parameters();
+  for(unsigned i = 0; i < params.size(); i++) {
+ParmVarDecl *param = params[i];

Might be cleaner as a range-for: `for (ParmVarDecl *PVD : BD->parameters)`



Comment at: clang/lib/AST/Mangle.cpp:46
+  }
+  llvm::raw_svector_ostream *Out2 = (llvm::raw_svector_ostream*)&Out;
 }

I'm not sure why Out2 exists.



Comment at: llvm/include/llvm/Demangle/ItaniumDemangle.h:5537
+
+  paramType->print(ParamOS);
+}

Can you make a special BlockInvocationFunction AST node that stores the 
parameter types as AST nodes (rather than strings) in a NodeArray? Right now it 
looks like this code is leaking, since initializeOutputStream allocates a 
buffer that it expects the user of OutputStream to manage (the ownership is a 
bit awkward, but its meant to accommodate the API of `__cxa_demangle`). 


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

https://reviews.llvm.org/D74813



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


[PATCH] D26418: [clang-tidy] Add '-suppress-checks-filter' option to suppress diagnostics from certain files

2020-04-22 Thread Oleg via Phabricator via cfe-commits
okainov added a comment.

Any updates on this one? That sounds so fundamental feature which current 
version is lacking, it's very frustrating it was not merged yet...


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

https://reviews.llvm.org/D26418



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


[PATCH] D76451: [clangd] Enable textual fallback for go-to-definition on dependent names

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for your patience!




Comment at: clang-tools-extra/clangd/XRefs.cpp:154
+getDeclAtPosition(ParsedAST &AST, SourceLocation Pos, DeclRelationSet 
Relations,
+  bool *IsDependentName = nullptr) {
   unsigned Offset = 
AST.getSourceManager().getDecomposedSpellingLoc(Pos).second;

shovelling this IsDependentName bool around seems a bit ad-hoc. The actual node 
doesn't live long enough, but can you make it an ASTNodeKind instead, and move 
the isDependentName check down to locateTextually where it makes sense to be 
that specific?



Comment at: clang-tools-extra/clangd/XRefs.cpp:355
+  bool IsDependent) {
+  // Don't use heuristics if this is a real non-dependent identifier, or not an
+  // identifier.

This sentence is hard to parse now, and also doesn't really justify the 
behaviour.
Suggest leaving it alone and adding:
// Exception: dependent names, because XYZ



Comment at: clang-tools-extra/clangd/XRefs.cpp:569
   ASTResults = locateASTReferent(NearbyIdent->location(), NearbyIdent, AST,
- *MainFilePath, Index);
+ *MainFilePath, Index, &IsDependentName);
   if (!ASTResults.empty())

the way the two (possible!) writes get combined is not obvious here.

I'd suggest using two different variables and writing `IsDependent || 
IsNearbyIdentDependent` in the usage below, if that's the intent.



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:694
+
+TEST(LocateSymbol, TextualDependent) {
+  const char *Tests[] = {

this has a loop but only one test...



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:698
 struct Foo {
-  void uniqueMethodName();
+  void [[uniqueMethodName]]();
 };

move these into the header so it can't be identifier-based heuristics? (And so 
the test doesn't change behaviour when we turn that on)



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:810
 struct Bar {
   void $BarLoc[[uniqueMethodName]]();
 };

this looks like a very close superset of TextualDependent, do we need both?

Again, these decls should move into the header I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76451



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


[PATCH] D78626: [clangd] Fix a crash for accessing a null template decl returned by findExplicitReferences.

2020-04-22 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!




Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:1293
+struct Base {};
+namespace foo {
+template 

is namespace required?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78626



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


[PATCH] D76038: PR45000: Let Sema::SubstParmVarDecl handle default args of lambdas in initializers

2020-04-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

The test I have passes after applying this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76038



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


[PATCH] D78286: [analyzer] Track runtime types represented by Obj-C Class objects

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp:198
+  // 'self' variable of the current class method.
+  if (ReceiverSVal == Message.getSelfSVal()) {
+// In this case, we should return the type of the enclosing class

NoQ wrote:
> NoQ wrote:
> > vsavchenko wrote:
> > > NoQ wrote:
> > > > vsavchenko wrote:
> > > > > NoQ wrote:
> > > > > > I believe this is pretty much always the case. At least whenever 
> > > > > > `getInstanceReceiver()` is available. Another exception seem to be 
> > > > > > when `ReceiverSVal` is an `UnknownVal` (in this case `self` is 
> > > > > > going to be `SymbolRegionValue` because it's never set in the 
> > > > > > Store), but that's it. I inferred this by looking at 
> > > > > > `ObjCMethodCall::getInitialStackFrameContents()`.
> > > > > > 
> > > > > > I think we should have used `getSelfSVal()` to begin with.
> > > > > > I believe this is pretty much always the case.
> > > > > 
> > > > > I didn't quite get what you mean by that
> > > > > 
> > > > > 
> > > > What i'm trying to say is that `C.getSVal(RecE)` and 
> > > > `Message.getSelfSVal()` and `Message.getReceiverSVal()` are basically 
> > > > the same `SVal`. It shouldn't be necessary to check both or check 
> > > > whether they're the same; you must have meant to check for something 
> > > > else, probably something purely syntactic.
> > > > 
> > > > 
> > > > 
> > > > > I inferred this by looking at 
> > > > > ObjCMethodCall::getInitialStackFrameContents().
> > > > 
> > > > Wait, so it's only true for inlined methods. For non-inlined methods 
> > > > `getSelfSVal()` will be unknown :/
> > > Yeah, that might be a bit extraneous to do it with `SVal`s, but this code 
> > > for sure does its job (it is definitely not a redundant check). 
> > > `getSelfSVal()` returns receiver of the function //containing// the call 
> > > and not the call itself. So, it does check if we the receiver of the 
> > > message is `self`.
> > > 
> > > I changed it to this way of doing things because it is consistent with 
> > > how the same thing is done in `getRuntimeDefinition`.
> > > `getSelfSVal()` returns receiver of the function containing the call and 
> > > not the call itself
> > 
> > 😱 looks broken to me.
> Let's rename `getSelfSVal()` so that it screamed that it's the callee's self 
> as opposed to the caller's self, and explain in a long comment why do we even 
> care about the caller's self. I.e., that we heuristically assume that if a 
> class method jumps into another class method on the same class object, it's 
> going to be devirtualized to the same class. Which isn't always the case, 
> hence !Precise.
> 
> 
I don't really think that it's a good idea to mix these two worlds:

  - **world one** - interface function that allows to get an `SVal` for `self` 
of the containing method. It does exactly this, for no specific reason. I'm on 
board with renaming, but we need to come up with an appropriate name that 
describes what it gives and not why.
  - **world two** - use-case of this interface method that tries to figure out 
the type of the receiver (for devirtualization purposes or not).

So, the comment can be only here. I agree, I can add more explanation about 
what we are doing in this particular piece of code, but it won't make any sense 
to add this (or similar) comment for `getSelfSVal()`.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:85-87
+  if (const DynamicTypeInfo *DTI = State->get(Sym))
+return *DTI;
+  return {};

NoQ wrote:
> My favorite idiom for this stuff so far:
> ```lang=c++
>   const DynamicTypeInfo *DTI = State->get(Sym);
>   return DTI ? *DTI : {};
> ```
> (not sure `?:` will typecheck correctly in case of `{}` though)
Yep, initializer lists are not allowed in ternary operators.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicType.cpp:147
+static bool isLive(SymbolReaper &SR, const MemRegion *MR) {
+  return SR.isLiveRegion(MR);
+}

NoQ wrote:
> Feel free to rename `isLiveRegion` instead if it helps :)
Unfortunately, it is named a bit differently for a reason, - compiler couldn't 
decide which function to use `bool isLive(const MemRegion *region)` or `bool 
isLive(const VarRegion *VR, bool includeStoreBindings = false) const` for a 
call `isLive(VarRegion *)` (even though it's pretty obvious). Splitting 
`isLive` for `VarRegion` into two functions doesn't seem like an easy one. The 
only option I can see is the introduction of `isLiveImpl` (not very pretty in a 
header file) and two functions `isLive(const VarRegion*) const ` and 
`isLiveIncludingStoreBindings(const VarRegion *) const`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78286



___
cfe-commits mailing list
cfe-commits@lists.

[PATCH] D70073: [ConstExprPreter] Implemented function calls and if statements

2020-04-22 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70073



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


[PATCH] D78286: [analyzer] Track runtime types represented by Obj-C Class objects

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 259314.
vsavchenko marked 9 inline comments as done.
vsavchenko added a comment.

Fix review remarks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78286

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/class-object-state-dump.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/inlining/ObjCDynTypePopagation.m
  clang/test/Analysis/retain-release-inline.m

Index: clang/test/Analysis/retain-release-inline.m
===
--- clang/test/Analysis/retain-release-inline.m
+++ clang/test/Analysis/retain-release-inline.m
@@ -13,6 +13,7 @@
 // It includes the basic definitions for the test cases below.
 //===--===//
 #define NULL 0
+#define nil ((id)0)
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -21,14 +22,14 @@
 typedef signed long CFIndex;
 typedef CFIndex CFByteOrder;
 typedef struct {
-CFIndex location;
-CFIndex length;
+  CFIndex location;
+  CFIndex length;
 } CFRange;
 static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
-CFRange range;
-range.location = loc;
-range.length = len;
-return range;
+  CFRange range;
+  range.location = loc;
+  range.length = len;
+  return range;
 }
 typedef const void * CFTypeRef;
 typedef const struct __CFString * CFStringRef;
@@ -91,6 +92,7 @@
 - (BOOL)isEqual:(id)object;
 - (id)retain;
 - (oneway void)release;
+- (Class)class;
 - (id)autorelease;
 - (id)init;
 @end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
@@ -100,6 +102,7 @@
 @interface NSObject  {}
 + (id)allocWithZone:(NSZone *)zone;
 + (id)alloc;
++ (Class)class;
 - (void)dealloc;
 @end
 @interface NSObject (NSCoderMethods)
@@ -481,3 +484,33 @@
   [self test_inline_tiny_when_reanalyzing];
 }
 @end
+
+// Original problem: rdar://problem/50739539
+@interface MyClassThatLeaksDuringInit : NSObject
+
++ (MyClassThatLeaksDuringInit *)getAnInstance1;
++ (MyClassThatLeaksDuringInit *)getAnInstance2;
+
+@end
+
+@implementation MyClassThatLeaksDuringInit
+
++ (MyClassThatLeaksDuringInit *)getAnInstance1 {
+  return [[[MyClassThatLeaksDuringInit alloc] init] autorelease]; // expected-warning{{leak}}
+}
+
++ (MyClassThatLeaksDuringInit *)getAnInstance2 {
+  return self class] alloc] init] autorelease]; // expected-warning{{leak}}
+}
+
+- (instancetype)init {
+  if (1) {
+return nil;
+  }
+
+  if (nil != (self = [super init])) {
+  }
+  return self;
+}
+
+@end
Index: clang/test/Analysis/inlining/ObjCDynTypePopagation.m
===
--- clang/test/Analysis/inlining/ObjCDynTypePopagation.m
+++ clang/test/Analysis/inlining/ObjCDynTypePopagation.m
@@ -7,68 +7,67 @@
 PublicSubClass2 *getObj();
 
 @implementation PublicParent
-- (int) getZeroOverridden {
-   return 1;
+- (int)getZeroOverridden {
+  return 1;
 }
-- (int) getZero {
-   return 0;
+- (int)getZero {
+  return 0;
 }
 @end
 
 @implementation PublicSubClass2
-- (int) getZeroOverridden {
-   return 0;
+- (int)getZeroOverridden {
+  return 0;
 }
 
 /* Test that we get the right type from call to alloc. */
-+ (void) testAllocSelf {
++ (void)testAllocSelf {
   id a = [self alloc];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-
-+ (void) testAllocClass {
++ (void)testAllocClass {
   id a = [PublicSubClass2 alloc];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testAllocSuperOverriden {
++ (void)testAllocSuperOverriden {
   id a = [super alloc];
   // Evaluates to 1 in the parent.
-  clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}} 
+  clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}}
 }
 
-+ (void) testAllocSuper {
++ (void)testAllocSuper {
   id a = [super alloc];
   clang_analyzer_eval([a getZero] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testAllocInit {
++ (void)testAllocInit {
   id a = [[self alloc] init];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testNewSelf {
++ (void)testNewSelf {
   id a = [self new];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-// Casting to parent should not pessimize the dynamic type. 
-+ (void) testCastToParent {
- id a = [[self alloc] init];
- PublicPar

[PATCH] D77596: [SveEmitter] Add IsOverloadNone flag and builtins for svpfalse and svcnt[bhwd]_pat

2020-04-22 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG662cbaf6476b: [SveEmitter] Add IsOverloadNone flag and 
builtins for svpfalse and svcnt… (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D77596?vs=257824&id=259318#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77596

Files:
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -264,6 +264,14 @@
 llvm_unreachable("Unsupported imm check");
   }
 
+  /// Returns the enum value for the flag type
+  uint64_t getEnumValueForFlag(StringRef C) const {
+auto Res = FlagTypes.find(C);
+if (Res != FlagTypes.end())
+  return Res->getValue();
+llvm_unreachable("Unsupported flag");
+  }
+
   // Returns the SVETypeFlags for a given value and mask.
   uint64_t encodeFlag(uint64_t V, StringRef MaskName) const {
 auto It = FlagTypes.find(MaskName);
@@ -528,6 +536,13 @@
 Immediate = true;
 PredicatePattern = true;
 break;
+  case 'k':
+Predicate = false;
+Signed = true;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+break;
   case 'l':
 Predicate = false;
 Signed = true;
@@ -535,6 +550,20 @@
 ElementBitwidth = Bitwidth = 64;
 NumVectors = 0;
 break;
+  case 'm':
+Predicate = false;
+Signed = false;
+Float = false;
+ElementBitwidth = Bitwidth = 32;
+NumVectors = 0;
+break;
+  case 'n':
+Predicate = false;
+Signed = false;
+Float = false;
+ElementBitwidth = Bitwidth = 64;
+NumVectors = 0;
+break;
   case 'S':
 Constant = true;
 Pointer = true;
@@ -831,6 +860,13 @@
   for (auto FlagRec : FlagsList)
 Flags |= FlagRec->getValueAsInt("Value");
 
+  // Create a dummy TypeSpec for non-overloaded builtins.
+  if (Types.empty()) {
+assert((Flags & getEnumValueForFlag("IsOverloadNone")) &&
+   "Expect TypeSpec for overloaded builtin!");
+Types = "i";
+  }
+
   // Extract type specs from string
   SmallVector TypeSpecs;
   TypeSpec Acc;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_pfalse.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbool_t test_svpfalse_b()
+{
+  // CHECK-LABEL: test_svpfalse_b
+  // CHECK: ret  zeroinitializer
+  return SVE_ACLE_FUNC(svpfalse,_b,,)();
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+uint64_t test_svcntw_pat()
+{
+  // CHECK-LABEL: test_svcntw_pat
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 0)
+  // CHECK: ret i64 %[[INTRINSIC]]
+  return svcntw_pat(SV_POW2);
+}
+
+uint64_t test_svcntw_pat_1()
+{
+  // CHECK-LABEL: test_svcntw_pat_1
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 1)
+  // CHECK: ret i64 %[[INTRINSIC]]
+  return svcntw_pat(SV_VL1);
+}
+
+uint64_t test_svcntw_pat_2()
+{
+  // CHECK-LABEL: test_svcntw_pat_2
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 2)
+  // CHECK: ret i64 %[[INTRINSIC]]
+  return svcntw_pat(SV_VL2);
+}
+
+uint64_t test_svcntw_pat_3()
+{
+  // CHECK-LABEL: test_svcntw_pat_3
+  // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntw(i32 3)
+  // CHECK: ret i64 %[[INT

[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/test/Analysis/PR53280338.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+

AFAIK rdar is not accessible outside Apple. So, for the rest of the open source 
developers any rdar info is totally useless. Thus, could you please copy the 
relevant parts of the bug description from there into the test file? Would be 
even better if we could just mention the rdar link in the test file and the 
filename itself was better explaining the nature of the bug.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:1805
+  // macro args expanded in the main file.
+  if (Entry.getFile().Filename == "" && FID == getMainFileID()) {
+if (Entry.getFile().NumCreatedFIDs)

nit: reverse the order of this check to avoid the string compare?
You could also consider hoisting `bool IsMainFile` out of the loop, maybe the 
optimizer can see this but I think it's probably a readablity win anyway.



Comment at: clang/lib/Basic/SourceManager.cpp:1806
+  if (Entry.getFile().Filename == "" && FID == getMainFileID()) {
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;

I don't love having this code duplicated.

What about:
```
SourceLocation IncludeLoc = ...
bool IncludedFromMain = isInFileID(IncludeLoc, FID) || (IsMainFile && Filename 
= "");
if (IncludedFromMain) {
  // increment ID
} else if (IncludeLoc.isValid()) { // included, but not from this file
  return
}
continue;
```



Comment at: clang/lib/Lex/PPLexerChange.cpp:420
+ // Predefines file doesn't have a valid include location.
+ CurPPLexer->FID == getPredefinesFileID())) {
   // Notify SourceManager to record the number of FileIDs that were created

Can we ever get spurious equality here because both sides are 0?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649



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


[PATCH] D78577: [OPENMP50]Basic support for uses_allocators clause.

2020-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: rnk.
jdoerfert added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:33
 #include "clang/AST/NSAPI.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/PrettyPrinter.h"

I think @rnk might not be happy with this include as it might be costly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78577



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


[PATCH] D78652: [clang-tidy] Add "ignore related parameters" heuristics to 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity created this revision.
whisperity added reviewers: aaron.ballman, alexfh, hokein, JonasToth, zporky.
whisperity added projects: clang-tools-extra, clang.
Herald added subscribers: cfe-commits, martong, gamesh411, dkrupp, rnkovacs, 
kbarton, nemanjai.
whisperity added a parent revision: D69560: [clang-tidy] Add 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' 
check.
Herald added a subscriber: wuzish.

The basic version of the checker only considers the pseudo-equality between 
types of parameters as the predicate on deciding whether or not the two can be 
mixed up with each other at a potential call site. This, together with a low 
minimum range length requirement, results in an incredibly verbose checker with 
report count potentially in the multiple thousands.

This patch aims to mitigate that problem by silencing warnings about adjacent 
parameter ranges in which the parameters are //related// to each other.
While this change definitely brings in false negatives (as mixing the arguments 
to `max(a, b)` is still a potential issue, but we really can't do better in 
that case...), the sheer amount of reduction in the report count should make up 
for it. Across multiple projects (from both C and C++), the number of reports 
has dropped by **at least 40%**.
This should help to make sure that the dodgiest interfaces are not hidden under 
clumps of naively generated reports.

Currently, three relatedness heuristics are implemented, each in a way that it 
is easy to, in the future, remove them or add new ones.

- Common expression: if both parameters are found in a common expression 
somewhere in the function, they are considered related. This heuristic is an 
absolute blast because it deals with arithmetics, comparisons, and forwarding 
functions all in one.
- Return: if both parameters are returned on different execution paths of the 
function, they are considered related. This deals with switch-like functions.
- Pass to same function: if both parameters are passed to the same function in 
the same index, they are considered related. This is a special case of 
forwarding. I.e. for `a` and `b` if there exists a call `f(foo, a);` and 
`f(bar, b);`, they are deemed related. Thanks to @zporky, our C++ expert, the 
idea.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78652

Files:
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-cvr-on.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-relatedness.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -1,7 +1,8 @@
 // RUN: %check_clang_tidy %s \
 // RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
 // RUN:   -config='{CheckOptions: [ \
-// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1} \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1}, \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CheckRelatedness, value: 0} \
 // RUN:   ]}' --
 
 struct T {};
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-relatedness.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-relatedness.cpp
@@ -0,0 +1,187 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CheckRelatedness, value: 1} \
+// RUN:   ]}' --
+
+namespace std {
+// NO-WARN: Not a definition, the user has no chance to fix this!
+int max(int x, int y);
+int abs(int x);
+
+template 
+bool less(const T &t1, const T &t2);
+} // namespace std
+
+class C {
+public:
+  void foo(int a);
+  void bar(int a, int b);
+};
+
+bool coin();
+int f(int a);
+int g(int b);
+int h(int

[PATCH] D69560: [clang-tidy] Add 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 259320.
whisperity added a comment.

- Better organisation of code, cleanup of debug prints, fix nomenclature of 
functions
- Explicitly mention the first and last param of the range for clarity
- Downlift the logic of joining and breaking ranges to main patch (this isn't 
terribly useful at this point, but both subsequent improvements to the check 
depend on this change)
  - Basically no longer assume that if param N can be swapped with param 1, 
then it can also be swapped with 2, 3, etc. without checking.
- Made the list of ignored parameter and type names configurable as a checker 
option
- Changed the default value of `MinimumLength` to `2`, as prescribed in the 
guideline's text.


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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/experimental/CMakeLists.txt
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  clang-tools-extra/clang-tidy/experimental/ExperimentalTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-cvr-on.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-ignores.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.CVRMixPossible, value: 1} \
+// RUN:   ]}' --
+
+struct T {};
+
+void memcpy(struct T *restrict dest, const struct T *restrict src) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'memcpy' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:32: note: the first parameter in this range is 'dest'
+// CHECK-MESSAGES: :[[@LINE-3]]:63: note: the last parameter in this range is 'src'
+// CHECK-MESSAGES: :[[@LINE-4]]:38: note: at a call site, 'const struct T * restrict' might bind with same force as 'struct T *restrict'
+
+void merge(struct T *dst, const struct T *src1, const struct T *src2) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 3 adjacent parameters for 'merge' of similar type are
+// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in this range is 'dst'
+// CHECK-MESSAGES: :[[@LINE-3]]:65: note: the last parameter in this range is 'src2'
+// CHECK-MESSAGES: :[[@LINE-4]]:27: note: at a call site, 'const struct T *' might bind with same force as 'struct T *'
+// CHECK-MESSAGES: :[[@LINE-5]]:49: note: at a call site, 'const struct T *' might bind with same force as 'struct T *'
+
+int equals(struct T a, struct T b) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 2 adjacent parameters for 'equals' of similar type ('struct T') are
+// CHECK-MESSAGES: :[[@LINE-2]]:21: note: the first parameter in this range is 'a'
+// CHECK-MESSAGES: :[[@LINE-3]]:33: note: the last parameter in this range is 'b'
+
+typedef struct {
+  int x;
+} S;
+
+int equals2(S l, S r) { return l.x == r.x; }
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'equals2' of similar type ('S') are
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in this range is 'l'
+// CHECK-MESSAGES: :[[@LINE-3]]:20: note: the last parameter in this range is 'r'
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
@@ -0,0 +1,205 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.MinimumLength, value: 3} \
+// RUN:

[PATCH] D75041: [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 2 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp:747
 OS << "...";
-  } else
+  } else {
 // There are things like "GCC Vector type" and such that who knows how

'chute, I hate merge conflicts...



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst:113-120
+.. warning::
+Turning the modelling of implicit conversion sequences on
+relaxes the constraints for "type convertibility" significantly,
+however, it also applies a generous performance hit on the check's 
cost.
+The check will have to explore a **polynomially more** possibilities:
+O(n\ :sup:`2`\ ) instead of O(n) for each function's ``n`` parameters.
+The emitted diagnostics will also be more verbose, which might take 
more

This change to check the "left half" of a full graph moved to the main checker 
patch D69560 and there is no significant (few seconds, on large projects like 
LLVM) time difference between the modes at all even on large projects... so 
this fearmongering text should be removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041



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


[PATCH] D69560: [clang-tidy] Add 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity marked an inline comment as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst:136-139
+typedef   T  element_type;
+typedef const Tconst_element_type;
+typedef   T &reference_type;
+typedef const T &  const_reference_type;

Why are these typos still here, `typedef`??? instead of `typename`.


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

https://reviews.llvm.org/D69560



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


[PATCH] D75041: [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'

2020-04-22 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 259324.
whisperity retitled this revision from "[clang-tidy] Approximate implicit 
conversion issues for the 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' 
check" to "[clang-tidy] Approximate implicit conversion issues in 
'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'".
whisperity added a comment.

- Re-organised code, removed debug prints, rebased, the usual tidy-up.
- Bug fixes on certain crashes like incomplete types, conversion operator 
templates, etc.
- Even more bug fixes against crashes, hopefully... sorry I lost the individual 
commits in a `squash` I think


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75041

Files:
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
  
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.c
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
  
clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c

Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
===
--- clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.c
@@ -32,3 +32,6 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 2 adjacent parameters for 'equals2' of similar type ('S') are
 // CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in this range is 'l'
 // CHECK-MESSAGES: :[[@LINE-3]]:20: note: the last parameter in this range is 'r'
+
+void ptrs(int *i, long *l) {}
+// NO-WARN: Mixing fundamentals' pointers is diagnosed by compiler warnings.
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-minlen3.cpp
@@ -203,3 +203,20 @@
 // CHECK-MESSAGES: :[[@LINE-6]]:25: note: after resolving type aliases, type of parameter 'Background' is 'OldSchoolTermColour'
 // CHECK-MESSAGES: :[[@LINE-6]]:25: note: after resolving type aliases, type of parameter 'Foreground' is 'OldSchoolTermColour'
 // CHECK-MESSAGES: :[[@LINE-6]]:25: note: after resolving type aliases, type of parameter 'Border' is 'OldSchoolTermColour'
+
+// NO-WARN: Implicit conversions should not warn if the check option is turned off.
+
+void integral1(signed char sc, int si) {}
+
+struct FromInt {
+  FromInt(int);
+};
+void userConv1(int i, FromInt fi) {}
+
+struct Base {};
+struct Derived1 : Base {};
+struct Derived2 : Base {};
+void upcasting(Base *bp, Derived1 *d1p, Derived2 *d2p) {}
+void upcasting_ref(const Base &br, const Derived1 &d1r, const Derived2 &d2r) {}
+
+// END of NO-WARN.
Index: clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type-implicits.cpp
@@ -0,0 +1,362 @@
+// RUN: %check_clang_tidy %s \
+// RUN:   experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.ImplicitConversion, value: 1} \
+// RUN:   ]}' --
+
+void compare(int a, int b, int c) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 3 adjacent parameters for 'compare' of similar type ('int') are easily swapped by mistake [experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type]
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in this range is 'a'
+// CHECK-MESSAGES: :[[@LINE-3]]:32: note: the last parameter in this range is 'c'
+
+void b(bool b1, bool b2, int i) {}
+// CHECK-MESSAGES: :[

[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-22 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, again :) Thanks for cleaning this up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233



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


[PATCH] D77871: [AArch64] Armv8.6-a Matrix Mult Assembly + Intrinsics

2020-04-22 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson updated this revision to Diff 259327.
LukeGeeson marked 5 inline comments as done.
LukeGeeson added a comment.

- fixed typos
- added sroa as mem2reg arg to reduce redundant mem accesses in tests, 
refactored test
- addressed other comments


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

https://reviews.llvm.org/D77871

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-matmul.cpp
  clang/test/CodeGen/aarch64-v8.6a-neon-intrinsics.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/aarch64-matmul.ll
  llvm/test/MC/AArch64/armv8.6a-simd-matmul-error.s
  llvm/test/MC/AArch64/armv8.6a-simd-matmul.s
  llvm/test/MC/Disassembler/AArch64/armv8.6a-simd-matmul.txt

Index: llvm/test/MC/Disassembler/AArch64/armv8.6a-simd-matmul.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/AArch64/armv8.6a-simd-matmul.txt
@@ -0,0 +1,34 @@
+# RUN: llvm-mc -triple=aarch64  -mattr=+i8mm -disassemble < %s   | FileCheck %s
+# RUN: llvm-mc -triple=aarch64  -mattr=+v8.6a -disassemble < %s  | FileCheck %s
+# RUN: not llvm-mc -triple=aarch64  -mattr=+v8.5a -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOI8MM
+
+[0x01,0xa6,0x9f,0x4e]
+[0x01,0xa6,0x9f,0x6e]
+[0x01,0xae,0x9f,0x4e]
+# CHECK: smmla   v1.4s, v16.16b, v31.16b
+# CHECK: ummla   v1.4s, v16.16b, v31.16b
+# CHECK: usmmla  v1.4s, v16.16b, v31.16b
+# NOI8MM: [[@LINE-6]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-6]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-6]]:{{[0-9]+}}: warning: invalid instruction encoding
+
+[0xe3,0x9d,0x9e,0x0e]
+[0xe3,0x9d,0x9e,0x4e]
+# CHECK: usdot   v3.2s, v15.8b, v30.8b
+# CHECK: usdot   v3.4s, v15.16b, v30.16b
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+
+[0x3f,0xf8,0xa2,0x0f]
+[0x3f,0xf8,0xa2,0x4f]
+# CHECK: usdot   v31.2s, v1.8b, v2.4b[3]
+# CHECK: usdot   v31.4s, v1.16b, v2.4b[3]
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+
+[0x3f,0xf8,0x22,0x0f]
+[0x3f,0xf8,0x22,0x4f]
+# CHECK: sudot   v31.2s, v1.8b, v2.4b[3]
+# CHECK: sudot   v31.4s, v1.16b, v2.4b[3]
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
+# NOI8MM: [[@LINE-4]]:{{[0-9]+}}: warning: invalid instruction encoding
Index: llvm/test/MC/AArch64/armv8.6a-simd-matmul.s
===
--- /dev/null
+++ llvm/test/MC/AArch64/armv8.6a-simd-matmul.s
@@ -0,0 +1,43 @@
+// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+i8mm   < %s  | FileCheck %s
+// RUN: llvm-mc -triple aarch64 -show-encoding -mattr=+v8.6a  < %s  | FileCheck %s
+// RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=+v8.6a-i8mm < %s 2>&1 | FileCheck %s --check-prefix=NOMATMUL
+
+smmla  v1.4s, v16.16b, v31.16b
+ummla  v1.4s, v16.16b, v31.16b
+usmmla v1.4s, v16.16b, v31.16b
+// CHECK: smmla   v1.4s, v16.16b, v31.16b // encoding: [0x01,0xa6,0x9f,0x4e]
+// CHECK: ummla   v1.4s, v16.16b, v31.16b // encoding: [0x01,0xa6,0x9f,0x6e]
+// CHECK: usmmla  v1.4s, v16.16b, v31.16b // encoding: [0x01,0xae,0x9f,0x4e]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: smmla  v1.4s, v16.16b, v31.16b
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: ummla  v1.4s, v16.16b, v31.16b
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usmmla  v1.4s, v16.16b, v31.16b
+
+usdot v3.2s, v15.8b, v30.8b
+usdot v3.4s, v15.16b, v30.16b
+// CHECK: usdot   v3.2s, v15.8b, v30.8b   // encoding: [0xe3,0x9d,0x9e,0x0e]
+// CHECK: usdot   v3.4s, v15.16b, v30.16b // encoding: [0xe3,0x9d,0x9e,0x4e]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot v3.2s, v15.8b, v30.8b
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot v3.4s, v15.16b, v30.16b
+
+usdot v31.2s, v1.8b,  v2.4b[3]
+usdot v31.4s, v1.16b, v2.4b[3]
+// CHECK: usdot   v31.2s, v1.8b, v2.4b[3] // encoding: [0x3f,0xf8,0xa2,0x0f]
+// CHECK: usdot   v31.4s, v1.16b, v2.4b[3] // encoding: [0x3f,0xf8,0xa2,0x4f]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot   v31.2s, v1.8b, v2.4b[3]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: usdot   v31.4s, v1.16b, v2.4b[3]
+
+sudot v31.2s, v1.8b,  v2.4b[3]
+sudot v31.4s, v1.16b, v2.4b[3]
+// CHECK: sudot   v31.2s, v1.8b, v2.4b[3] // encoding: [0x3f,0xf8,0x22,0x0f]
+// CHECK: sudot   v31.4s, v1.16b, v2.4b[3] // encoding: [0x3f,0xf8,0x22,0x4f]
+// NOMATMUL: instruction requires: i8mm
+// NOMATMUL-NEXT: s

[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Hana Joo via Phabricator via cfe-commits
h-joo updated this revision to Diff 259326.
h-joo added a comment.

In D78643#1997103 , @jdoerfert wrote:

> Can we create a test case that shows even if it is a dependent type we will 
> eventuall issue an error if it is not an addressable lvalue or array item?
>  If this is the part that needs refactoring to work, we should add the test 
> with a TODO.


Added a test to check the test triggers in presence of lvalue expression. 
Although the test does not trigger line 15912, but rather line 15905.  I tried 
some examples and it seems like after during  the template instantiation, while 
an ArraySubscriptExpr is being constructed, it already checks whether it's a 
pointer type or an array type, thus, I am thinking this check in line 15912 
might actually be redundant?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/depend_template_subscription.cpp


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+
+  #pragma omp task depend(out: A[k]) // Should not print error Bug #45383
+  {
+;
+  }
+}
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable 
lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function 
template specialization 'test2' requested here}} 
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,25 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonReferenceType()
-  ->isPointerType() &&
- !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) 
{
+if (!RefExpr->IgnoreParenImpCasts()->isLValue()) {
   Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
   << (LangOpts.OpenMP >= 50 ? 1 : 0)
   << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange();
   continue;
 }
 
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType();
+  if (!BaseType->isDependentType() &&
+  !BaseType.getNonReferenceType()->isPointerType() &&
+  !BaseType.getNonReferenceType()->isArrayType()) {
+Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0) << 
RefExpr->getSourceRange();
+continue;
+  }
+}
+
 ExprResult Res;
 {
   Sema::TentativeAnalysisScope Trap(*this);


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wuninitialized
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+
+  #pragma omp task depend(out: A[k]) // Should not print error Bug #45383
+  {
+;
+  }
+}
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function template specialization 'test2' requested here}} 
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,25 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonRef

[clang] 089fbe6 - [Docs] Fixed formatting in release notes, NFC

2020-04-22 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-04-22T18:25:22+01:00
New Revision: 089fbe69193364fee14ed94a58c530d8417dc391

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

LOG: [Docs] Fixed formatting in release notes, NFC

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1f4bc0f0d0da..88edf0092dc5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -61,8 +61,8 @@ Non-comprehensive list of changes in this release
   v8.1-M MVE instruction set.  supports the complete API defined
   in the Arm C Language Extensions.
 
-- For the ARM target, C-language intrinsics  for the CDE instruction
-  set are now provided.
+- For the ARM target, C-language intrinsics  for the CDE
+  instruction set are now provided.
 
 * clang adds support for a set of  extended integer types (``_ExtInt(N)``) that
   permit non-power of 2 integers, exposing the LLVM integer types. Since a 
major

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 3afdce296fcd..e0ff25622704 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -79,7 +79,7 @@ During this release ...
 * Added support for assembly for the optional Custom Datapath Extension (CDE)
   for Arm M-profile targets.
 
-* Implemented C-language intrinsics  for the CDE instruction set.
+* Implemented C-language intrinsics  for the CDE instruction 
set.
 
 Changes to the MIPS Target
 --



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


[clang-tools-extra] 3f1c2bf - [clangd] go-to-def on names in comments etc that are used nearby.

2020-04-22 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-22T19:46:41+02:00
New Revision: 3f1c2bf1712c7496a80a0f89036ab1625ff347a5

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

LOG: [clangd] go-to-def on names in comments etc that are used nearby.

Summary:
This is intended as a companion to (and is inspired by) D72874 which attempts to
resolve these cases using the index.
The intent is we'd try this strategy after the AST-based approach but before the
index-based (I think local usages would be more reliable than index matches).

Reviewers: nridge

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 1943784bfd18..dd4c863cb96a 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -855,6 +855,96 @@ llvm::StringSet<> collectWords(llvm::StringRef Content) {
   return Result;
 }
 
+static bool isLikelyIdentifier(llvm::StringRef Word, llvm::StringRef Before,
+   llvm::StringRef After) {
+  // `foo` is an identifier.
+  if (Before.endswith("`") && After.startswith("`"))
+return true;
+  // In foo::bar, both foo and bar are identifiers.
+  if (Before.endswith("::") || After.startswith("::"))
+return true;
+  // Doxygen tags like \c foo indicate identifiers.
+  // Don't search too far back.
+  // This duplicates clang's doxygen parser, revisit if it gets complicated.
+  Before = Before.take_back(100); // Don't search too far back.
+  auto Pos = Before.find_last_of("\\@");
+  if (Pos != llvm::StringRef::npos) {
+llvm::StringRef Tag = Before.substr(Pos + 1).rtrim(' ');
+if (Tag == "p" || Tag == "c" || Tag == "class" || Tag == "tparam" ||
+Tag == "param" || Tag == "param[in]" || Tag == "param[out]" ||
+Tag == "param[in,out]" || Tag == "retval" || Tag == "throw" ||
+Tag == "throws" || Tag == "link")
+  return true;
+  }
+
+  // Word contains underscore.
+  // This handles things like snake_case and MACRO_CASE.
+  if (Word.contains('_')) {
+return true;
+  }
+  // Word contains capital letter other than at beginning.
+  // This handles things like lowerCamel and UpperCamel.
+  // The check for also containing a lowercase letter is to rule out
+  // initialisms like "HTTP".
+  bool HasLower = Word.find_if(clang::isLowercase) != StringRef::npos;
+  bool HasUpper = Word.substr(1).find_if(clang::isUppercase) != 
StringRef::npos;
+  if (HasLower && HasUpper) {
+return true;
+  }
+  // FIXME: consider mid-sentence Capitalization?
+  return false;
+}
+
+llvm::Optional SpelledWord::touching(SourceLocation SpelledLoc,
+  const syntax::TokenBuffer 
&TB,
+  const LangOptions &LangOpts) 
{
+  const auto &SM = TB.sourceManager();
+  auto Touching = syntax::spelledTokensTouching(SpelledLoc, TB);
+  for (const auto &T : Touching) {
+// If the token is an identifier or a keyword, don't use any heuristics.
+if (tok::isAnyIdentifier(T.kind()) || tok::getKeywordSpelling(T.kind())) {
+  SpelledWord Result;
+  Result.Location = T.location();
+  Result.Text = T.text(SM);
+  Result.LikelyIdentifier = tok::isAnyIdentifier(T.kind());
+  Result.PartOfSpelledToken = &T;
+  Result.SpelledToken = &T;
+  auto Expanded =
+  TB.expandedTokens(SM.getMacroArgExpandedLocation(T.location()));
+  if (Expanded.size() == 1 && Expanded.front().text(SM) == Result.Text)
+Result.ExpandedToken = &Expanded.front();
+  return Result;
+}
+  }
+  FileID File;
+  unsigned Offset;
+  std::tie(File, Offset) = SM.getDecomposedLoc(SpelledLoc);
+  bool Invalid = false;
+  llvm::StringRef Code = SM.getBufferData(File, &Invalid);
+  if (Invalid)
+return llvm::None;
+  unsigned B = Offset, E = Offset;
+  while (B > 0 && isIdentifierBody(Code[B - 1]))
+--B;
+  while (E < Code.size() && isIdentifierBody(Code[E]))
+++E;
+  if (B == E)
+return llvm::None;
+
+  SpelledWord Result;
+  Result.Location = SM.getComposedLoc(File, B);
+  Result.Text = Code.slice(B, E);
+  Result.LikelyIdentifier =
+  isLikelyIdentifier(Result.Text, Code.substr(0, B), Code.substr(E)) &&
+  // should not be a keyword
+  tok::isAnyIdentifier(
+  IdentifierTable(LangOpts).

[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 4 inline comments as done.
kadircet added inline comments.



Comment at: clang/lib/Lex/PPLexerChange.cpp:420
+ // Predefines file doesn't have a valid include location.
+ CurPPLexer->FID == getPredefinesFileID())) {
   // Notify SourceManager to record the number of FileIDs that were created

sammccall wrote:
> Can we ever get spurious equality here because both sides are 0?
the latter is set during `Preprocessor::EnterMainSourceFile()` which 
initializes the PP and all users seem to be calling it first, therefore I 
assumed it would alwyas be a valid file id.

putting a `&& getPredefinesFileID().isValid()` to be on the safe side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649



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


[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts

2020-04-22 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I personally don't think the note is useful. What we're trying to tell the user 
is "don't use X after you've moved out of X" -- whether the move actually has 
an effect or not is not useful information. To me, adding `; move of a 'const' 
argument has no effect` just makes things less clear -- are you trying to tell 
me I shouldn't use-after-move, or something else more subtle?

Just my .02


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

https://reviews.llvm.org/D74692



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 259332.
kadircet marked an inline comment as done.
kadircet added a comment.

- address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649

Files:
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/unittests/Basic/SourceManagerTest.cpp
  clang/unittests/Lex/LexerTest.cpp


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+PP->Lex(tok);
+if (tok.is(tok::eof))
+  break;
+  }
+  EXPECT_EQ(SourceMgr.getNumCreatedFIDsForFileID(PP->getPredefinesFileID()),
+1U);
+}
 } // anonymous namespace
Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -294,10 +294,16 @@
   TrivialModuleLoader ModLoader;
   HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
   Diags, LangOpts, &*Target);
+
   Preprocessor PP(std::make_shared(), Diags, LangOpts,
   SourceMgr, HeaderInfo, ModLoader,
   /*IILookup =*/nullptr,
   /*OwnsHeaderSearch =*/false);
+  // Ensure we can get expanded locations in presence of implicit includes.
+  // These are different than normal includes since predefines buffer doesn't
+  // have a valid insertion location.
+  PP.setPredefines("#include \"/implicit-header.h\"");
+  FileMgr.getVirtualFile("/implicit-header.h", 0, 0);
   PP.Initialize(*Target);
   PP.EnterMainSourceFile();
 
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -415,7 +415,10 @@
 }
 
 if (!isEndOfMacro && CurPPLexer &&
-SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid()) {
+(SourceMgr.getIncludeLoc(CurPPLexer->getFileID()).isValid() ||
+ // Predefines file doesn't have a valid include location.
+ (PredefinesFileID.isValid() &&
+  CurPPLexer->getFileID() == PredefinesFileID))) {
   // Notify SourceManager to record the number of FileIDs that were created
   // during lexing of the #include'd file.
   unsigned NumFIDs =
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -1800,15 +1800,23 @@
   return;
 if (Entry.isFile()) {
   SourceLocation IncludeLoc = Entry.getFile().getIncludeLoc();
-  if (IncludeLoc.isInvalid())
+  bool IncludedInFID =
+  (IncludeLoc.isValid() && isInFileID(IncludeLoc, FID)) ||
+  // Predefined header doesn't have a valid include location in main
+  // file, but any files created by it should still be skipped when
+  // computing macro args expanded in the main file.
+  (FID == MainFileID && Entry.getFile().Filename == "");
+  if (IncludedInFID) {
+// Skip the files/macros of the #include'd file, we only care about
+// macros that lexed macro arguments from our file.
+if (Entry.getFile().NumCreatedFIDs)
+  ID += Entry.getFile().NumCreatedFIDs - 1 /*because of next ++ID*/;
 continue;
-  if (!isInFileID(IncludeLoc, FID))
-return; // No more files/macros that may be "contained" in this file.
-
-  // Skip the files/macros of the #include'd file, we only care about 
macros
-  // that lexed macro arguments from our file.
-  if (Entry.getFile().NumCreatedFIDs)
-ID += Entry.getFile().NumCreatedFIDs - 1/*because of next ++ID*/;
+  } else if (IncludeLoc.isValid()) {
+// If file wasn't included from FID, there is no more files/macros that
+// may be "contained" in this file.
+return;
+  }
   continue;
 }
 


Index: clang/unittests/Lex/LexerTest.cpp
===
--- clang/unittests/Lex/LexerTest.cpp
+++ clang/unittests/Lex/LexerTest.cpp
@@ -556,4 +556,17 @@
   EXPECT_THAT(GeneratedByNextToken, ElementsAre("abcd", "=", "0", ";", "int",
 "xyz", "=", "abcd", ";"));
 }
+
+TEST_F(LexerTest, CreatedFIDCountForPredefinedBuffer) {
+  TrivialModuleLoader ModLoader;
+  auto PP = CreatePP("", ModLoader);
+  while (1) {
+Token tok;
+PP->Lex(tok

[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

This looks reasonable to me. @ABataev WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643



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


[PATCH] D78565: [clang][doc] Clang ARM CPU command line argument reference

2020-04-22 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In D78565#1996297 , @SjoerdMeijer 
wrote:

> Fair enough, perhaps the audience is too small here on llvm.org for this and 
> this is too niche. In A-profile we have the same problem, so could the 
> exercise for an A-core here, but can't spend time on that now, so will 
> abandon this.


I would find this extremely valuable in the clang documentation.  Not sure why 
this should be put on developer.arm.com as it is compiler-specific as wel as 
(sub-)target-specific.


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

https://reviews.llvm.org/D78565



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


[PATCH] D78655: [HIP] Let lambda be host device by default

2020-04-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.

Lambda functions do not have names, therefore they do not need host/device
attribute for overloading resolution. They are also have internal linkage and
is only emitted if used, therefore no need to use host/device attribute to
indicate that they should only be emitted for host or device, since clang
can detect whether they are used and emitted accordingly.

Therefore it seems letting lambda functions have host device attributes
by default should not cause ambiguity or unexpected emission.

On the other hand, inferring host/device attribute of lambda function
by context is inaccurate, since a lambda function can be defined in
a host function and passed to a template kernel as template argument
and called in that kernel, i.e., many cases a lambda function defined in
a host function is intended to be a device function.

This patch let lambda function be host device by default for HIP.
This should make lambda easier to use without unwanted side effect.


https://reviews.llvm.org/D78655

Files:
  clang/lib/Sema/SemaCUDA.cpp
  clang/test/CodeGenCUDA/lambda.cu


Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] 
c"_Z1gIZ4mainEUlvE_EvT_\00"
+// HOST: define internal void @_Z1hIZ4mainEUlvE_EvT_
+// HOST: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+// DEV: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: define internal void @_ZZ4mainENKUlvE_clEv
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;
+
+int main(void) {
+  h([&](){ a=1;});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == CFT_Global || Target == CFT_Device) {
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));


Index: clang/test/CodeGenCUDA/lambda.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/lambda.cu
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple x86_64-linux-gnu | FileCheck -check-prefix=HOST %s
+// RUN: %clang_cc1 -x hip -emit-llvm -std=c++11 %s -o - \
+// RUN:   -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   | FileCheck -check-prefix=DEV %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @[[KERN:[0-9]+]] = private unnamed_addr constant [22 x i8] c"_Z1gIZ4mainEUlvE_EvT_\00"
+// HOST: define internal void @_Z1hIZ4mainEUlvE_EvT_
+// HOST: define internal void @_Z16__device_stub__gIZ4mainEUlvE_EvT_
+// HOST: @__hipRegisterFunction(i8** %0, i8* bitcast ({{.*}}@[[KERN]]
+// HOST-NOT: define{{.*}}@_ZZ4mainENKUlvE_clEv
+// DEV: define amdgpu_kernel void @_Z1gIZ4mainEUlvE_EvT_
+// DEV: define internal void @_ZZ4mainENKUlvE_clEv
+template
+__global__ void g(F f) { f(); }
+
+template
+void h(F f) { g<<<1,1>>>(f); }
+
+__device__ int a;
+
+int main(void) {
+  h([&](){ a=1;});
+}
Index: clang/lib/Sema/SemaCUDA.cpp
===
--- clang/lib/Sema/SemaCUDA.cpp
+++ clang/lib/Sema/SemaCUDA.cpp
@@ -718,6 +718,11 @@
   FunctionDecl *CurFn = dyn_cast(CurContext);
   if (!CurFn)
 return;
+  if (getLangOpts().HIP) {
+Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
+Method->addAttr(CUDAHostAttr::CreateImplicit(Context));
+return;
+  }
   CUDAFunctionTarget Target = IdentifyCUDATarget(CurFn);
   if (Target == CFT_Global || Target == CFT_Device) {
 Method->addAttr(CUDADeviceAttr::CreateImplicit(Context));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78565: [clang][doc] Clang ARM CPU command line argument reference

2020-04-22 Thread David Greene via Phabricator via cfe-commits
greened added a comment.

In D78565#1997372 , @greened wrote:

> In D78565#1996297 , @SjoerdMeijer 
> wrote:
>
> > Fair enough, perhaps the audience is too small here on llvm.org for this 
> > and this is too niche. In A-profile we have the same problem, so could the 
> > exercise for an A-core here, but can't spend time on that now, so will 
> > abandon this.
>
>
> I would find this extremely valuable in the clang documentation.  Not sure 
> why this should be put on developer.arm.com as it is compiler-specific as wel 
> as (sub-)target-specific.


To be clear, I also like Peter's suggestion of documenting all `-m` options as 
gcc does.  There's room for both-and here.


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

https://reviews.llvm.org/D78565



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


[PATCH] D75479: [clangd] go-to-def on names in comments etc that are used nearby.

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f1c2bf1712c: [clangd] go-to-def on names in comments etc 
that are used nearby. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75479

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -685,10 +685,15 @@
 
 auto AST = TU.build();
 auto Index = TU.index();
-auto Results = locateSymbolNamedTextuallyAt(
-AST, Index.get(),
+auto Word = SpelledWord::touching(
 cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-testPath(TU.Filename));
+AST.getTokens(), AST.getLangOpts());
+if (!Word) {
+  ADD_FAILURE() << "No word touching point!" << Test;
+  continue;
+}
+auto Results =
+locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
 
 if (!WantDecl) {
   EXPECT_THAT(Results, IsEmpty()) << Test;
@@ -788,10 +793,12 @@
   auto TU = TestTU::withCode(T.code());
   auto AST = TU.build();
   auto Index = TU.index();
-  auto Results = locateSymbolNamedTextuallyAt(
-  AST, Index.get(),
+  auto Word = SpelledWord::touching(
   cantFail(sourceLocationInMainFile(AST.getSourceManager(), T.point())),
-  testPath(TU.Filename));
+  AST.getTokens(), AST.getLangOpts());
+  ASSERT_TRUE(Word);
+  auto Results =
+  locateSymbolTextually(*Word, AST, Index.get(), testPath(TU.Filename));
   EXPECT_THAT(Results,
   UnorderedElementsAre(Sym("uniqueMethodName", T.range("FooLoc")),
Sym("uniqueMethodName", T.range("BarLoc";
@@ -985,6 +992,101 @@
   ElementsAre(Sym("foo", FooWithoutHeader.range(;
 }
 
+TEST(LocateSymbol, NearbyTokenSmoke) {
+  auto T = Annotations(R"cpp(
+// prints e^rr and crashes
+void die(const char* [[err]]);
+  )cpp");
+  auto AST = TestTU::withCode(T.code()).build();
+  // We don't pass an index, so can't hit index-based fallback.
+  EXPECT_THAT(locateSymbolAt(AST, T.point()),
+  ElementsAre(Sym("err", T.range(;
+}
+
+TEST(LocateSymbol, NearbyIdentifier) {
+  const char *Tests[] = {
+  R"cpp(
+  // regular identifiers (won't trigger)
+  int hello;
+  int y = he^llo;
+)cpp",
+  R"cpp(
+  // disabled preprocessor sections
+  int [[hello]];
+  #if 0
+  int y = ^hello;
+  #endif
+)cpp",
+  R"cpp(
+  // comments
+  // he^llo, world
+  int [[hello]];
+)cpp",
+  R"cpp(
+  // not triggered by string literals
+  int hello;
+  const char* greeting = "h^ello, world";
+)cpp",
+
+  R"cpp(
+  // can refer to macro invocations
+  #define INT int
+  [[INT]] x;
+  // I^NT
+)cpp",
+
+  R"cpp(
+  // can refer to macro invocations (even if they expand to nothing)
+  #define EMPTY
+  [[EMPTY]] int x;
+  // E^MPTY
+)cpp",
+
+  R"cpp(
+  // prefer nearest occurrence, backwards is worse than forwards
+  int hello;
+  int x = hello;
+  // h^ello
+  int y = [[hello]];
+  int z = hello;
+)cpp",
+
+  R"cpp(
+  // short identifiers find near results
+  int [[hi]];
+  // h^i
+)cpp",
+  R"cpp(
+  // short identifiers don't find far results
+  int hi;
+
+
+
+  // h^i
+)cpp",
+  };
+  for (const char *Test : Tests) {
+Annotations T(Test);
+auto AST = TestTU::withCode(T.code()).build();
+const auto &SM = AST.getSourceManager();
+llvm::Optional Nearby;
+auto Word =
+SpelledWord::touching(cantFail(sourceLocationInMainFile(SM, T.point())),
+  AST.getTokens(), AST.getLangOpts());
+if (!Word) {
+  ADD_FAILURE() << "No word at point! " << Test;
+  continue;
+}
+if (const auto *Tok = findNearbyIdentifier(*Word, AST.getTokens()))
+  Nearby = halfOpenToRange(SM, CharSourceRange::getCharRange(
+   Tok->location(), Tok->endLocation()));
+if (T.ranges().empty())
+  EXPECT_THAT(Nearby, Eq(llvm::None)) << Test;
+else
+  EXPECT_EQ(Nearby, T.range()) << Test;
+  }
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clang

[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D78643#1997344 , @jdoerfert wrote:

> This looks reasonable to me. @ABataev WDYT?


I would add a positive test with -ast-print




Comment at: clang/lib/Sema/SemaOpenMP.cpp:15913
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType();
+  if (!BaseType->isDependentType() &&

Just `QualType BaseType = ASE->getBase()->getType().getNonReferenceType();` and 
drop the call for `getNonReferenceType()` in later checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked an inline comment as done.
vsavchenko added inline comments.



Comment at: clang/test/Analysis/PR53280338.cpp:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+

martong wrote:
> AFAIK rdar is not accessible outside Apple. So, for the rest of the open 
> source developers any rdar info is totally useless. Thus, could you please 
> copy the relevant parts of the bug description from there into the test file? 
> Would be even better if we could just mention the rdar link in the test file 
> and the filename itself was better explaining the nature of the bug.
It is a fair point, I'll make it more clear what exactly we are testing here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638



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


[PATCH] D78649: [clang] Make sure argument expansion locations are correct in presence of predefined buffer

2020-04-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Basic/SourceManager.cpp:1816
+  } else if (IncludeLoc.isValid()) {
+// If file wasn't included from FID, there is no more files/macros that
+// may be "contained" in this file.

wasn't included from FID -> was included but not from FID


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78649



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


[PATCH] D78638: [analyzer] Consider array subscripts to be interesting lvalues

2020-04-22 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 259341.
vsavchenko added a comment.

Add more clarity on what we test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78638

Files:
  clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
  clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp


Index: clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
===
--- /dev/null
+++ clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text 
-verify %s
+
+class A {
+public:
+  int method();
+};
+
+A *foo();
+void bar(A *);
+
+int index;
+
+// We want to check here that the notes about the origins of the null pointer
+// (array[index] = foo()) will get to the final report.
+//
+// The analyzer used to drop exploded nodes for array subscripts when it was
+// time to collect redundant nodes. This GC-like mechanism kicks in only when
+// the exploded graph is large enough (>1K nodes). For this reason, 'index'
+// is a global variable, and the sink point is inside of a loop.
+
+void test() {
+  A *array[42];
+  A *found;
+
+  for (index = 0; (array[index] = foo()); ++index) { // expected-note {{Loop 
condition is false. Execution continues on line 34}}
+// expected-note@-1 {{Value assigned to 'index'}}
+// expected-note@-2 {{Assigning value}}
+// expected-note@-3 {{Assuming pointer value is null}}
+if (array[0])
+  break;
+  }
+
+  do {
+found = array[index]; // expected-note {{Null pointer value stored to 
'found'}}
+
+if (found->method()) // expected-warning {{Called C++ object pointer is 
null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+  bar(found);
+  } while (--index);
+}
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -50,9 +50,8 @@
 bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
   if (!Ex->isLValue())
 return false;
-  return isa(Ex) ||
- isa(Ex) ||
- isa(Ex);
+  return isa(Ex) || isa(Ex) ||
+ isa(Ex) || isa(Ex);
 }
 
 bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {


Index: clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
===
--- /dev/null
+++ clang/test/Analysis/CheckThatArraySubsciptNodeIsNotCollected.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
+
+class A {
+public:
+  int method();
+};
+
+A *foo();
+void bar(A *);
+
+int index;
+
+// We want to check here that the notes about the origins of the null pointer
+// (array[index] = foo()) will get to the final report.
+//
+// The analyzer used to drop exploded nodes for array subscripts when it was
+// time to collect redundant nodes. This GC-like mechanism kicks in only when
+// the exploded graph is large enough (>1K nodes). For this reason, 'index'
+// is a global variable, and the sink point is inside of a loop.
+
+void test() {
+  A *array[42];
+  A *found;
+
+  for (index = 0; (array[index] = foo()); ++index) { // expected-note {{Loop condition is false. Execution continues on line 34}}
+// expected-note@-1 {{Value assigned to 'index'}}
+// expected-note@-2 {{Assigning value}}
+// expected-note@-3 {{Assuming pointer value is null}}
+if (array[0])
+  break;
+  }
+
+  do {
+found = array[index]; // expected-note {{Null pointer value stored to 'found'}}
+
+if (found->method()) // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+  bar(found);
+  } while (--index);
+}
Index: clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -50,9 +50,8 @@
 bool ExplodedGraph::isInterestingLValueExpr(const Expr *Ex) {
   if (!Ex->isLValue())
 return false;
-  return isa(Ex) ||
- isa(Ex) ||
- isa(Ex);
+  return isa(Ex) || isa(Ex) ||
+ isa(Ex) || isa(Ex);
 }
 
 bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76801: [AST] Print a> without extra spaces in C++11 or later.

2020-04-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D76801#1996376 , @labath wrote:

> In D76801#1995058 , @dblaikie wrote:
>
> > > It becomes a gdb-index problem because with an index the debugger will do 
> > > a (hashed?) string lookup and expect the string to be there. If the 
> > > strings differ, the lookup won't find anything. In the no-index scenario, 
> > > the debugger has to trawl the debug info itself, and so it has some 
> > > opportunities to do fuzzy matching.
> >
> > That surprises me a bit - given that one of the things debuggers provide is 
> > autocomplete (I'm unlikely to write out a type name exactly as the debug 
> > info contains it - if two compilers can't agree, it's much less likely that 
> > all users will agree with any compiler rendering), which I'd have thought 
> > would be facilitated by the index too - in which case lookup via exact 
> > match wouldn't be viable, you'd still want a way to list anything with a 
> > matching substring (or at least prefix), etc. Which could help facilitate 
> > lookup fuzzy matching like in this sort of case.
>
>
> That is kind of true, and I don't really have a definitive reply to that. I 
> suppose there is a difference between the lookups done for type completion 
> and those done e.g. in expression evaluation. The latter are probably more 
> frequent and are assumed to be correct. Maybe they shouldn't be, but in that 
> cases, then there would probably be no use for the hash tables in indexes (I 
> am not very familiar with the gdb index, but I know it has hash tables 
> similar to debug_names/apple_names). I don't know what gdb does for tab 
> completion, but it probably bypasses the hash table (though the index could 
> still be useful even then as it has a concise list of all strings in the 
> debug info), or it gets the list of strings-to-complete from a completely 
> different source (demangled function names?).
>
> Tab completion is always a bit dodgy. E.g., in your example `ptype tmpl` 
> completes to `ptype tmpl>`, but then running that produces an 
> error: `No symbol "tmpl" in current context.`
>
> In lldb, tab completion in expressions works by hooking into the regular 
> clang tab-completion machinery used by editors.  The up- and down-side of 
> that is that it uses the same code path used for actual expression evaluation 
> -- i.e. all the types will be looked up the same (exact) way.
>
> Speaking of templates and indexes, the thing we would really like in lldb 
> would be to have just the bare names of templated class in the indexes -- 
> that way we could reliably look up all instantiations of a template and do 
> the filtering ourselves. However, this runs afoul of the dwarf specification, 
> which says that the index names should match the DW_AT_names of relevant DIEs 
> (and these contain the template arguments for other reasons...). This means 
> that currently we have outstanding issues when looking up templated types, 
> but we haven't really figured out what to do about that...


Yeah, points all taken - as for this actual issue... I'm kind of inclined to 
say "hey, our template names already diverge somewhat - and this divergence is 
in the realm of acceptable by gdb (without an index) so... *thumbs up*/let's 
stick with it" & as I think you mentioned earlier, this is more a problem for 
the index support, than for the debug info producer. I don't think it's a 
reasonable goal that Clang & GCC produce /exactly/ the same names for templates 
like this... I mean, we /could/ try, but I don't think it's worthwhile 
(especially given that gdb's got support intended to do fuzzy matching/allow 
some divergence)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76801



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


[clang] 1b3f1f4 - Rename warning identifiers from cxx2a to cxx20; NFC.

2020-04-22 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-04-22T14:31:13-04:00
New Revision: 1b3f1f443670f202a0490ccf9d1f7b28e949bfe7

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

LOG: Rename warning identifiers from cxx2a to cxx20; NFC.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/Preprocessor.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 9e0449d34104..ef90bdf84c8a 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -33,7 +33,7 @@ def warn_cxx98_compat_less_colon_colon : Warning<
 def warn_cxx17_compat_spaceship : Warning<
   "'<=>' operator is incompatible with C++ standards before C++20">,
   InGroup, DefaultIgnore;
-def warn_cxx2a_compat_spaceship : Warning<
+def warn_cxx20_compat_spaceship : Warning<
   "'<=>' is a single token in C++20; "
   "add a space to avoid a change in behavior">,
   InGroup;
@@ -78,7 +78,7 @@ def ext_token_used : Extension<"extension used">,
 
 def warn_cxx11_keyword : Warning<"'%0' is a keyword in C++11">,
   InGroup, DefaultIgnore;
-def warn_cxx2a_keyword : Warning<"'%0' is a keyword in C++20">,
+def warn_cxx20_keyword : Warning<"'%0' is a keyword in C++20">,
   InGroup, DefaultIgnore;
 
 def ext_unterminated_char_or_string : ExtWarn<

diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 29497f9c8296..337614c33661 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -676,7 +676,7 @@ def err_ms_property_expected_comma_or_rparen : Error<
 def err_ms_property_initializer : Error<
   "property declaration cannot have an in-class initializer">;
 
-def warn_cxx2a_compat_explicit_bool : Warning<
+def warn_cxx20_compat_explicit_bool : Warning<
   "this expression will be parsed as explicit(bool) in C++20">,
   InGroup, DefaultIgnore;
 def warn_cxx17_compat_explicit_bool : Warning<

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 014ee1c2f2d7..1101bd5a4bb6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2009,7 +2009,7 @@ def err_reference_bind_init_list : Error<
 def err_init_list_bad_dest_type : Error<
   "%select{|non-aggregate }0type %1 cannot be initialized with an initializer "
   "list">;
-def warn_cxx2a_compat_aggregate_init_with_ctors : Warning<
+def warn_cxx20_compat_aggregate_init_with_ctors : Warning<
   "aggregate initialization of type %0 with user-declared constructors "
   "is incompatible with C++20">, DefaultIgnore, InGroup;
 
@@ -2530,7 +2530,7 @@ def warn_cxx11_compat_constexpr_body_invalid_stmt : 
Warning<
   "use of this statement in a constexpr %select{function|constructor}0 "
   "is incompatible with C++ standards before C++14">,
   InGroup, DefaultIgnore;
-def ext_constexpr_body_invalid_stmt_cxx2a : ExtWarn<
+def ext_constexpr_body_invalid_stmt_cxx20 : ExtWarn<
   "use of this statement in a constexpr %select{function|constructor}0 "
   "is a C++20 extension">, InGroup;
 def warn_cxx17_compat_constexpr_body_invalid_stmt : Warning<
@@ -2593,7 +2593,7 @@ def note_constexpr_body_previous_return : Note<
   "previous return statement is here">;
 
 // C++20 function try blocks in constexpr
-def ext_constexpr_function_try_block_cxx2a : ExtWarn<
+def ext_constexpr_function_try_block_cxx20 : ExtWarn<
   "function try block in constexpr %select{function|constructor}0 is "
   "a C++20 extension">, InGroup;
 def warn_cxx17_compat_constexpr_function_try_block : Warning<
@@ -6294,10 +6294,10 @@ def note_array_init_plain_string_into_char8_t : Note<
 def err_array_init_utf8_string_into_char : Error<
   "%select{|ISO C++20 does not permit }0initialization of char array with "
   "UTF-8 string literal%select{ is not permitted by '-fchar8_t'|}0">;
-def warn_cxx2a_compat_utf8_string : Warning<
+def warn_cxx20_compat_utf8_string : Warning<
   "type of UTF-8 string literal will change from array of const char to "
   "array of const char8_t in C++20">, InGroup, DefaultIgnore;
-def note_cxx2a_compat_utf8_string_remove_u8 : Note<
+def note_cxx20_compat_utf8_string_remove_u8 : Note<
   "remove 'u8' prefix to avoid a change of behavior; "
   "Clang encodes unprefixed na

[PATCH] D62368: Add support for Hygon Dhyana processor

2020-04-22 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

Hey,

`clang/lib/Headers/cpuid.h` would have to be in its own CL that would have to 
be sent separately from the Scudo one.
It would have to be reviewed by clang people and likely some tests added.

Once this is done and landed, then the Scudo part can happen.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D78643: [OpenMP] Fix false error report of array subscription for templated indexes.

2020-04-22 Thread Hana Joo via Phabricator via cfe-commits
h-joo updated this revision to Diff 259343.
h-joo added a comment.

In D78643#1997405 , @ABataev wrote:

> In D78643#1997344 , @jdoerfert wrote:
>
> > This looks reasonable to me. @ABataev WDYT?
>
>
> I would add a positive test with -ast-print




1. Changed into a positive test with -ast-print
2. Just `QualType BaseType = ASE->getBase()->getType().getNonReferenceType();` 
and dropped all the call for getNonReferenceType() in later checks.

Thank you for your time for the review! I do have one more question to ask. I 
don't understand the log of the build failure, would you be able to give me a 
bit of a hint?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78643

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/depend_template_subscription.cpp


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) 
+  {
+;
+  }
+}
+// CHECK: template  void test(double *A, IndexT k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+// CHECK: template<> void test(double *A, int k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable 
lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function 
template specialization 'test2' requested here}} 
+  return 0;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15902,20 +15902,24 @@
   continue;
 }
 
-auto *ASE = dyn_cast(SimpleExpr);
-if (!RefExpr->IgnoreParenImpCasts()->isLValue() ||
-(ASE &&
- !ASE->getBase()
-  ->getType()
-  .getNonReferenceType()
-  ->isPointerType() &&
- !ASE->getBase()->getType().getNonReferenceType()->isArrayType())) 
{
+if (!RefExpr->IgnoreParenImpCasts()->isLValue()) {
   Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
   << (LangOpts.OpenMP >= 50 ? 1 : 0)
   << (LangOpts.OpenMP >= 50 ? 1 : 0) << RefExpr->getSourceRange();
   continue;
 }
 
+if (auto *ASE = dyn_cast(SimpleExpr)) {
+  QualType BaseType = ASE->getBase()->getType().getNonReferenceType();
+  if (!BaseType->isDependentType() && !BaseType->isPointerType() &&
+  !BaseType->isArrayType()) {
+Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0)
+<< (LangOpts.OpenMP >= 50 ? 1 : 0) << 
RefExpr->getSourceRange();
+continue;
+  }
+}
+
 ExprResult Res;
 {
   Sema::TentativeAnalysisScope Trap(*this);


Index: clang/test/OpenMP/depend_template_subscription.cpp
===
--- /dev/null
+++ clang/test/OpenMP/depend_template_subscription.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+
+#ifndef HEADER
+#define HEADER
+
+template
+void test(double *A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) 
+  {
+;
+  }
+}
+// CHECK: template  void test(double *A, IndexT k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+// CHECK: template<> void test(double *A, int k) {
+// CHECK: #pragma omp task depend(out : A[k])
+// CHECK: {
+// CHECK: ;
+// CHECK: }
+// CHECK: }
+
+
+struct lValueVector {
+  int operator [] (int index) {
+return index + 42;
+  }
+};
+template
+void test2(BaseTypeT A, IndexT k)
+{
+  #pragma omp task depend(out: A[k]) // expected-error {{expected addressable lvalue expression, array element or array section}}
+  {
+;
+  }
+}
+int driver(double *A)
+{
+  int k = 42;
+  test(A, k);
+  test2(lValueVector(), k); // expected-note {{in instantiation of function template specialization 'test2' requested her

  1   2   >