[PATCH] D120334: [NFC][Lexer] Use more appropriate LangOptionsBase type for Lexer::LangOpts

2022-02-22 Thread Dawid Jurczak via Phabricator via cfe-commits
yurai007 added a comment.

In D120334#3338367 , @jansvoboda11 
wrote:

> In D120334#3338314 , @yurai007 
> wrote:
>
>> In D120334#3337961 , @jansvoboda11 
>> wrote:
>>
>>> The performance implications are pretty interesting! Have you tried 
>>> avoiding the copy altogether by just storing the reference?
>>
>> Yes, actually that was my first attempt but I failed miserably. 
>> LangOpts::LineComment is mutated in Lexer so LangOpts cannot be simply 
>> const&. Making it non-const reference is technically doable with some extra 
>> adjustment for Lexer constructors.
>> However I'm worried a bit how it would impact external LangOpts users after 
>> mutating LineComment member by Lexer.  As long as LangOpts acts as simple 
>> cache it's easy to reason about but when we start to share it with Lexer 
>> callers I'm not longer sure. That's why eventually base class approach was 
>> chosen.
>
> Got it. It seems like getting rid of the `LineComment` mutation would be 
> pretty straightforward though. I don't expect any big perf win by replacing 
> copy of a handful of bitfields with indirection, but it would be interesting 
> to see the experiment nonetheless.

Ok. I can explore more this direction and come back with results.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120334

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


[PATCH] D120374: [clang-format] Do not insert space after new/delete keywords in C function declarations

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

In D120374#3339337 , @penagos wrote:

> Though it's still unclear to me whether or not it'd make more sense to 
> continue to pursue a change to introduce `C` as a language. Thoughts?

I prefer your current approach (and there should be not that many cases that we 
need a special treatment for C).
Adding a new language would be to disruptive and difficult, as well as hard to 
use in some cases (headers in C and C++ often share the same extension).




Comment at: clang/unittests/Format/FormatTest.cpp:9926
+format("void new (link p);\n"
+   "void delete(link p);\n"));
 }

Why there's no space after `delete` in the input?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120374

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


[PATCH] D120387: [clang-tidy][run-clang-tidy.py] Whitespace addition

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker updated this revision to Diff 410719.
SAtacker added a comment.

Attempt to update this commit appropriately


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120387

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,7 +96,7 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config_path, 
+extra_arg, extra_arg_before, quiet, config_path,
 config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
@@ -235,10 +235,10 @@
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
   group.add_argument('-config-file', default=None,
-  help='Specify the path of .clang-tidy or custom config'
-  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
-  'This option internally works exactly the same way as'
-  '-config option after reading specified config file.'
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
   'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
@@ -292,7 +292,7 @@
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config_path, 
args.config, 
+ args.quiet, args.config_path, args.config,
  args.line_filter, args.use_color)
 invocation.append('-list-checks')
 invocation.append('-')


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,7 +96,7 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config_path, 
+extra_arg, extra_arg_before, quiet, config_path,
 config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
@@ -235,10 +235,10 @@
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
   group.add_argument('-config-file', default=None,
-  help='Specify the path of .clang-tidy or custom config'
-  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
-  'This option internally works exactly the same way as'
-  '-config option after reading specified config file.'
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
   'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
@@ -292,7 +292,7 @@
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config_path, args.config, 
+ args.quiet, args.config_path, args.config,
  args.line_filter, args.use_color)
 invocation.append('-list-checks')
 invocation.append('-')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D120387: [clang-tidy][run-clang-tidy.py] Whitespace addition

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker updated this revision to Diff 410718.
SAtacker added a comment.

Removed whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120387

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,8 +96,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path,
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -127,7 +127,9 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
-  if config:
+  if config_path:
+  start.append('--config-file=' + config_path)
+  elif config:
   start.append('-config=' + config)
   start.append(f)
   return start
@@ -188,8 +190,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -223,7 +225,8 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
-  parser.add_argument('-config', default=None,
+  group = parser.add_mutually_exclusive_group()
+  group.add_argument('-config', default=None,
   help='Specifies a configuration in YAML/JSON format: '
   '  -config="{Checks: \'*\', '
   '   CheckOptions: [{key: x, '
@@ -231,6 +234,12 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
+  group.add_argument('-config-file', default=None,
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
+  'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '
@@ -283,8 +292,8 @@
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 invocation.append('-list-checks')
 invocation.append('-')
 if args.quiet:


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,8 +96,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path,
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -127,7 +127,9 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
-  if config:
+  if config_path:
+  start.append('--config-file=' + config_path)
+ 

[PATCH] D120387: [clang-tidy][run-clang-tidy.py] Whitespace addition

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker updated this revision to Diff 410717.
SAtacker added a comment.

Suspected reason why the patch isn't applied: trailing space


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120387

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,8 +96,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path, 
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -127,7 +127,9 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
-  if config:
+  if config_path:
+  start.append('--config-file=' + config_path)
+  elif config:
   start.append('-config=' + config)
   start.append(f)
   return start
@@ -188,8 +190,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -223,7 +225,8 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
-  parser.add_argument('-config', default=None,
+  group = parser.add_mutually_exclusive_group()
+  group.add_argument('-config', default=None,
   help='Specifies a configuration in YAML/JSON format: '
   '  -config="{Checks: \'*\', '
   '   CheckOptions: [{key: x, '
@@ -231,6 +234,12 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
+  group.add_argument('-config-file', default=None,
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
+  'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '
@@ -283,8 +292,8 @@
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 invocation.append('-list-checks')
 invocation.append('-')
 if args.quiet:


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,8 +96,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path, 
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -127,7 +127,9 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
-  if config:
+  if config_path:
+  

[PATCH] D120387: [clang-tidy][run-clang-tidy.py] Whitespace addition

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker updated this revision to Diff 410715.
SAtacker retitled this revision from "[clang-tidy][run-clang-tidy.py] 
Whitespace addition

Depends on D120385" to "[clang-tidy][run-clang-tidy.py] Whitespace addition".
SAtacker edited the summary of this revision.
SAtacker added a comment.

Fix CI build bot error using suggested solution


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120387

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,8 +96,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path, 
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   start = [clang_tidy_binary]
   if allow_enabling_alpha_checkers:
@@ -127,7 +127,9 @@
   start.append('-p=' + build_path)
   if quiet:
   start.append('-quiet')
-  if config:
+  if config_path:
+  start.append('--config-file=' + config_path)
+  elif config:
   start.append('-config=' + config)
   start.append(f)
   return start
@@ -188,8 +190,8 @@
  tmpdir, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, args.config,
+ args.line_filter, args.use_color)
 
 proc = subprocess.Popen(invocation, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE)
 output, err = proc.communicate()
@@ -223,7 +225,8 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
-  parser.add_argument('-config', default=None,
+  group = parser.add_mutually_exclusive_group()
+  group.add_argument('-config', default=None,
   help='Specifies a configuration in YAML/JSON format: '
   '  -config="{Checks: \'*\', '
   '   CheckOptions: [{key: x, '
@@ -231,6 +234,12 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
+  group.add_argument('-config-file', default=None,
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
+  'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
   'headers to output diagnostics from. Diagnostics from '
@@ -283,8 +292,8 @@
  None, build_path, args.header_filter,
  args.allow_enabling_alpha_checkers,
  args.extra_arg, args.extra_arg_before,
- args.quiet, args.config, args.line_filter,
- args.use_color)
+ args.quiet, args.config_path, 
args.config, 
+ args.line_filter, args.use_color)
 invocation.append('-list-checks')
 invocation.append('-')
 if args.quiet:


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -96,8 +96,8 @@
 
 def get_tidy_invocation(f, clang_tidy_binary, checks, tmpdir, build_path,
 header_filter, allow_enabling_alpha_checkers,
-extra_arg, extra_arg_before, quiet, config,
-line_filter, use_color):
+extra_arg, extra_arg_before, quiet, config_path, 
+config, line_filter, use_color):
   """Gets a command line for clang-tidy."""
   

[PATCH] D120387: [clang-tidy][run-clang-tidy.py] Whitespace addition Depends on D120385

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker created this revision.
SAtacker added a reviewer: JonasToth.
Herald added subscribers: carlosgalvezp, xazax.hun.
SAtacker requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

- spaces:
  - Consistent with the rest of the options
  - Added missing spaces

Signed-off-by: Shreyas Atre 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120387

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -235,10 +235,10 @@
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
   group.add_argument('-config-file', default=None,
-  help='Specify the path of .clang-tidy or custom config'
-  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
-  'This option internally works exactly the same way as'
-  '-config option after reading specified config file.'
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
   'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -235,10 +235,10 @@
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
   group.add_argument('-config-file', default=None,
-  help='Specify the path of .clang-tidy or custom config'
-  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
-  'This option internally works exactly the same way as'
-  '-config option after reading specified config file.'
+  help='Specify the path of .clang-tidy or custom config '
+  'file: e.g. -config-file=/some/path/myTidyConfigFile. '
+  'This option internally works exactly the same way as '
+  '-config option after reading specified config file. '
   'Use either -config-file or -config, not both.')
   parser.add_argument('-header-filter', default=None,
   help='regular expression matching the names of the '
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120385: [clang-tidy][run-clang-tidy.py] Mutual exclusion of -config and -config-file

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker accepted this revision.
SAtacker added a comment.
This revision is now accepted and ready to land.

In D120385#3339440 , @Eugene.Zelenko 
wrote:

> I think will be good to merge these changes to D120331 
> .

Thanks for the review. Will land this and make the required changes in the next 
one.




Comment at: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py:239
   help='Specify the path of .clang-tidy or custom config'
-  'file: e.g. -config-file=/some/path/myTidyConfigFile'
+  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
   'This option internally works exactly the same way as'

Eugene.Zelenko wrote:
> In other options spaces are place at the end of string. Please also add 
> missing spaces.
Yes, sure. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120385

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


[PATCH] D120366: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-22 Thread Shangwu Yao via Phabricator via cfe-commits
shangwuyao added a comment.

Looking into the (new) build failure on Windows, since the change has already 
been reviewed, will try to commit after resolving the build failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120366

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


[PATCH] D120385: [clang-tidy][run-clang-tidy.py] Mutual exclusion of -config and -config-file

2022-02-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I think will be good to merge these changes to D120331 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120385

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


[PATCH] D120385: [clang-tidy][run-clang-tidy.py] Mutual exclusion of -config and -config-file

2022-02-22 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py:239
   help='Specify the path of .clang-tidy or custom config'
-  'file: e.g. -config-file=/some/path/myTidyConfigFile'
+  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
   'This option internally works exactly the same way as'

In other options spaces are place at the end of string. Please also add missing 
spaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120385

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


[PATCH] D120385: [clang-tidy][run-clang-tidy.py] Mutual exclusion of -config and -config-file

2022-02-22 Thread Shreyas via Phabricator via cfe-commits
SAtacker created this revision.
SAtacker added a reviewer: JonasToth.
Herald added subscribers: carlosgalvezp, xazax.hun.
SAtacker published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Depends on D120331 

- Ensures that both options -config and -config-file exclude each other

Signed-off-by: Shreyas Atre 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120385

Files:
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -225,7 +225,8 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
-  parser.add_argument('-config', default=None,
+  group = parser.add_mutually_exclusive_group()
+  group.add_argument('-config', default=None,
   help='Specifies a configuration in YAML/JSON format: '
   '  -config="{Checks: \'*\', '
   '   CheckOptions: [{key: x, '
@@ -233,9 +234,9 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
-  parser.add_argument('-config-file', default=None,
+  group.add_argument('-config-file', default=None,
   help='Specify the path of .clang-tidy or custom config'
-  'file: e.g. -config-file=/some/path/myTidyConfigFile'
+  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
   'This option internally works exactly the same way as'
   '-config option after reading specified config file.'
   'Use either -config-file or -config, not both.')


Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -225,7 +225,8 @@
   parser.add_argument('-checks', default=None,
   help='checks filter, when not specified, use clang-tidy '
   'default')
-  parser.add_argument('-config', default=None,
+  group = parser.add_mutually_exclusive_group()
+  group.add_argument('-config', default=None,
   help='Specifies a configuration in YAML/JSON format: '
   '  -config="{Checks: \'*\', '
   '   CheckOptions: [{key: x, '
@@ -233,9 +234,9 @@
   'When the value is empty, clang-tidy will '
   'attempt to find a file named .clang-tidy for '
   'each source file in its parent directories.')
-  parser.add_argument('-config-file', default=None,
+  group.add_argument('-config-file', default=None,
   help='Specify the path of .clang-tidy or custom config'
-  'file: e.g. -config-file=/some/path/myTidyConfigFile'
+  ' file: e.g. -config-file=/some/path/myTidyConfigFile'
   'This option internally works exactly the same way as'
   '-config option after reading specified config file.'
   'Use either -config-file or -config, not both.')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120383: [CMake] Use CMAKE_SYSROOT to build libs for Win to ARM cross tooolchain.

2022-02-22 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka created this revision.
vvereschaka added a reviewer: vvereschaka.
Herald added subscribers: kristof.beyls, mgorny.
vvereschaka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Provide CMAKE_SYSROOT for the libc++/libc++abi/libunwind libraries instead of 
specific _SYSROOT for each of them.

  

Fixed passing some CMake arguments for the runtimes.

  

Referenced Differentials:

- https://reviews.llvm.org/D119836
- https://reviews.llvm.org/D112155
- https://reviews.llvm.org/D111672

Buildbot Updates:

- https://reviews.llvm.org/D120293


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120383

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake

Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -10,7 +10,7 @@
 #
 # Configure:
 #  cmake -G Ninja ^
-#   -DTARGET_TRIPLE=armv7-linux-gnueabihf ^
+#   -DTARGET_TRIPLE=armv7-unknown-linux-gnueabihf ^
 #   -DCMAKE_INSTALL_PREFIX=../install ^
 #   -DDEFAULT_SYSROOT= ^
 #   -DLLVM_AR=/bin/llvm-ar[.exe] ^
@@ -25,10 +25,10 @@
 #  cmake --build . --target check-llvm
 #  cmake --build . --target check-clang
 #  cmake --build . --target check-lld
-#  cmake --build . --target check-compiler-rt
-#  cmake --build . --target check-cxxabi
-#  cmake --build . --target check-unwind
-#  cmake --build . --target check-cxx
+#  cmake --build . --target check-compiler-rt-
+#  cmake --build . --target check-cxxabi-
+#  cmake --build . --target check-unwind-
+#  cmake --build . --target check-cxx-
 
 # LLVM_PROJECT_DIR is the path to the llvm-project directory.
 # The right way to compute it would probably be to use "${CMAKE_SOURCE_DIR}/../",
@@ -86,49 +86,20 @@
 set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
 set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE STRING "")
 # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
-set(CMAKE_C_COMPILER_TARGET "${TARGET_TRIPLE}" CACHE STRING "")
+set(CMAKE_C_COMPILER_TARGET "${TARGET_TRIPLE}" CACHE STRING "")
+set(CMAKE_CXX_COMPILER_TARGET   "${TARGET_TRIPLE}" CACHE STRING "")
 
-set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIRON CACHE BOOL "")
+set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR  ON CACHE BOOL "")
 set(LLVM_DEFAULT_TARGET_TRIPLE  "${TARGET_TRIPLE}" CACHE STRING "")
 set(LLVM_TARGET_ARCH"${TARGET_TRIPLE}" CACHE STRING "")
 set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
 
 set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
 
-set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
-set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
-set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
-set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
-set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
-set(COMPILER_RT_BUILD_CRT   OFF CACHE BOOL "")
-set(COMPILER_RT_BUILD_ORC   OFF CACHE BOOL "")
-set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
-set(COMPILER_RT_INCLUDE_TESTS   ON CACHE BOOL "")
-
-set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
-set(LIBUNWIND_TARGET_TRIPLE "${TARGET_TRIPLE}" CACHE STRING "")
-set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
-set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
-
-set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
-set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
-set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
-set(LIBCXXABI_TARGET_TRIPLE "${TARGET_TRIPLE}" CACHE STRING "")
-set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
-set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
-set(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXOFF CACHE BOOL "")
-set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABIOFF CACHE BOOL "")
-set(LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
-
-set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
-set(LIBCXX_TARGET_TRIPLE"${TARGET_TRIPLE}" CACHE STRING "")
-set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
-set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
-set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
-set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
-set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}" CACHE PATH "")
-set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONSON CACHE BOOL "")
+if(WIN32)
+  

[PATCH] D101322: [clang-format] Add comment justification for https://reviews.llvm.org/D100778

2022-02-22 Thread Luis Penagos via Phabricator via cfe-commits
penagos abandoned this revision.
penagos added a comment.

Closing old review request.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101322

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


[PATCH] D120374: [clang-format] Do not insert space after new/delete keywords in C function declarations

2022-02-22 Thread Luis Penagos via Phabricator via cfe-commits
penagos created this revision.
penagos added reviewers: curdeius, MyDeveloperDay, HazardyKnusperkeks.
penagos updated this revision to Diff 410700.
penagos added a comment.
penagos published this revision for review.
penagos added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The windows build failure appears to be unrelated to this change. I found the 
need to include `!Left.Previous` in the conditional so as to account for the 
existing unittest in the form of:

  new (expr)

To not wind up formatting this case as:

  new(expr)

Though it's still unclear to me whether or not it'd make more sense to continue 
to pursue a change to introduce `C` as a language. Thoughts?


Fixes https://github.com/llvm/llvm-project/issues/46915.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120374

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9919,6 +9919,11 @@
   verifyFormat("void operator new(void *foo) ATTRIB;");
   verifyFormat("void operator delete[](void *foo) ATTRIB;");
   verifyFormat("void operator delete(void *ptr) noexcept;");
+
+  EXPECT_EQ("void new(link p);\n"
+"void delete(link p);\n",
+format("void new (link p);\n"
+   "void delete(link p);\n"));
 }
 
 TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3299,11 +3299,15 @@
   if (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch))
 return Style.SpaceBeforeParensOptions.AfterControlStatements ||
spaceRequiredBeforeParens(Right);
-  if (Left.isOneOf(tok::kw_new, tok::kw_delete) ||
-  (Left.is(tok::r_square) && Left.MatchingParen &&
-   Left.MatchingParen->Previous &&
-   Left.MatchingParen->Previous->is(tok::kw_delete)))
-return Style.SpaceBeforeParens != FormatStyle::SBPO_Never ||
+  if (Left.isOneOf(tok::kw_new, tok::kw_delete))
+return ((!Line.MightBeFunctionDecl || !Left.Previous) &&
+Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
+   spaceRequiredBeforeParens(Right);
+
+  if (Left.is(tok::r_square) && Left.MatchingParen &&
+  Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->is(tok::kw_delete))
+return (Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
spaceRequiredBeforeParens(Right);
 }
 if (Line.Type != LT_PreprocessorDirective &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9919,6 +9919,11 @@
   verifyFormat("void operator new(void *foo) ATTRIB;");
   verifyFormat("void operator delete[](void *foo) ATTRIB;");
   verifyFormat("void operator delete(void *ptr) noexcept;");
+
+  EXPECT_EQ("void new(link p);\n"
+"void delete(link p);\n",
+format("void new (link p);\n"
+   "void delete(link p);\n"));
 }
 
 TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3299,11 +3299,15 @@
   if (Left.isOneOf(tok::kw_try, Keywords.kw___except, tok::kw_catch))
 return Style.SpaceBeforeParensOptions.AfterControlStatements ||
spaceRequiredBeforeParens(Right);
-  if (Left.isOneOf(tok::kw_new, tok::kw_delete) ||
-  (Left.is(tok::r_square) && Left.MatchingParen &&
-   Left.MatchingParen->Previous &&
-   Left.MatchingParen->Previous->is(tok::kw_delete)))
-return Style.SpaceBeforeParens != FormatStyle::SBPO_Never ||
+  if (Left.isOneOf(tok::kw_new, tok::kw_delete))
+return ((!Line.MightBeFunctionDecl || !Left.Previous) &&
+Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
+   spaceRequiredBeforeParens(Right);
+
+  if (Left.is(tok::r_square) && Left.MatchingParen &&
+  Left.MatchingParen->Previous &&
+  Left.MatchingParen->Previous->is(tok::kw_delete))
+return (Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
spaceRequiredBeforeParens(Right);
 }
 if (Line.Type != LT_PreprocessorDirective &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120246: [flang][driver] Add support for `--target`/`--triple`

2022-02-22 Thread Thorsten via Phabricator via cfe-commits
tschuett added subscribers: MaskRay, tschuett.
tschuett added a comment.

https://reviews.llvm.org/D117809

There was a discussion that `-emit-llvm` is considered a mistake.

@MaskRay


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120246

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


[PATCH] D120246: [flang][driver] Add support for `--target`/`--triple`

2022-02-22 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

Nit: Should we also have a test for print-effective-triple?

Otherwise LGTM, although I'm not sure that -emit-llvm is necessarily something 
we'd want flang users to be exposed to.




Comment at: flang/include/flang/Frontend/TargetOptions.h:20
+/// Options for controlling the target. Currently this is just a placeholder.
+/// In the future we will use this for options to specify various target
+/// options that will affect the generated code e.g.:




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120246

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


[PATCH] D118875: [compiler-rt][builtins] build the macOS compiler-rt built-ins with Mac Catalyst support

2022-02-22 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5153d9e7262: [compiler-rt][builtins] build the macOS 
compiler-rt built-ins with Mac Catalyst… (authored by arphaman).
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Changed prior to commit:
  https://reviews.llvm.org/D118875?vs=408621=410693#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118875

Files:
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake


Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -3,6 +3,7 @@
 # .o files. This is particularly useful in producing larger, more complex
 # runtime libraries.
 
+include(BuiltinTests)
 include(CheckIncludeFile)
 include(CheckCXXSourceCompiles)
 include(GNUInstallDirs)
@@ -138,6 +139,12 @@
 set(OSX_SYSROOT_FLAG "")
   endif()
 
+  try_compile_only(COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG
+   FLAGS
+   "-target" "x86_64-apple-macos10.15"
+   "-darwin-target-variant" "x86_64-apple-ios13.1-macabi"
+   "-Werror")
+  option(COMPILER_RT_ENABLE_MACCATALYST "Enable building for Mac Catalyst" 
${COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG})
   option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)
   option(COMPILER_RT_ENABLE_WATCHOS "Enable building for watchOS - 
Experimental" Off)
   option(COMPILER_RT_ENABLE_TVOS "Enable building for tvOS - Experimental" Off)
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -298,6 +298,14 @@
  -target 
"${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
   endif()
 
+  if ("${COMPILER_RT_ENABLE_MACCATALYST}" AND
+  "${LIB_OS}" MATCHES "^osx$")
+# Build the macOS builtins with Mac Catalyst support.
+list(APPEND builtin_cflags
+  -target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER}
+  -darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi)
+  endif()
+
   set_target_compile_flags(${libname}
 ${sysroot_flag}
 ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}


Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -3,6 +3,7 @@
 # .o files. This is particularly useful in producing larger, more complex
 # runtime libraries.
 
+include(BuiltinTests)
 include(CheckIncludeFile)
 include(CheckCXXSourceCompiles)
 include(GNUInstallDirs)
@@ -138,6 +139,12 @@
 set(OSX_SYSROOT_FLAG "")
   endif()
 
+  try_compile_only(COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG
+   FLAGS
+   "-target" "x86_64-apple-macos10.15"
+   "-darwin-target-variant" "x86_64-apple-ios13.1-macabi"
+   "-Werror")
+  option(COMPILER_RT_ENABLE_MACCATALYST "Enable building for Mac Catalyst" ${COMPILER_RT_HAS_DARWIN_TARGET_VARIANT_FLAG})
   option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)
   option(COMPILER_RT_ENABLE_WATCHOS "Enable building for watchOS - Experimental" Off)
   option(COMPILER_RT_ENABLE_TVOS "Enable building for tvOS - Experimental" Off)
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -298,6 +298,14 @@
  -target "${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
   endif()
 
+  if ("${COMPILER_RT_ENABLE_MACCATALYST}" AND
+  "${LIB_OS}" MATCHES "^osx$")
+# Build the macOS builtins with Mac Catalyst support.
+list(APPEND builtin_cflags
+  -target ${LIB_ARCH}-apple-macos${DARWIN_osx_BUILTIN_MIN_VER}
+  -darwin-target-variant ${LIB_ARCH}-apple-ios13.1-macabi)
+  endif()
+
   set_target_compile_flags(${libname}
 ${sysroot_flag}
 ${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120375: Trim unnecessary component/library dependencies.

2022-02-22 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Please expand the description and include how you figured this out and how do 
we know it is actually correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120375

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


[PATCH] D120298: [HIP] Support `-fgpu-default-stream`

2022-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 410691.
yaxunl marked an inline comment as done.
yaxunl retitled this revision from "[HIP] Support `--default-stream`" to "[HIP] 
Support `-fgpu-default-stream`".
yaxunl edited the summary of this revision.
yaxunl added a comment.

rename the option and use preprocessor to emit the macro definition


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

https://reviews.llvm.org/D120298

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/kernel-call.cu
  clang/test/Driver/hip-options.hip
  clang/test/Preprocessor/predefined-macros.c

Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -247,6 +247,7 @@
 // CHECK-HIP-NEG-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-NEG-NOT: #define __HIP_DEVICE_COMPILE__ 1
 // CHECK-HIP-NEG-NOT: #define __CLANG_RDC__ 1
+// CHECK-HIP-NEG-NOT: #define HIP_API_PER_THREAD_DEFAULT_STREAM
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
 // RUN:   -fcuda-is-device \
@@ -265,6 +266,7 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-HIP-DEV-NEG
 // CHECK-HIP-DEV-NEG-NOT: #define __CUDA_ARCH__
 // CHECK-HIP-DEV-NEG-NOT: #define __CLANG_RDC__ 1
+// CHECK-HIP-DEV-NEG-NOT: #define HIP_API_PER_THREAD_DEFAULT_STREAM
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cuda -triple x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc | FileCheck %s --check-prefix=CHECK-RDC
@@ -277,3 +279,11 @@
 // RUN:   -fgpu-rdc -fcuda-is-device \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-RDC
 // CHECK-RDC: #define __CLANG_RDC__ 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x hip -triple x86_64-unknown-linux-gnu \
+// RUN:   -fgpu-default-stream=per-thread \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-PTH
+// RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -fgpu-default-stream=per-thread \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-PTH
+// CHECK-PTH: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -14,6 +14,14 @@
 // DEVINIT: clang{{.*}}" "-cc1" {{.*}}"-fgpu-allow-device-init"
 // DEVINIT: clang{{.*}}" "-cc1" {{.*}}"-fgpu-allow-device-init"
 
+// Check -fgpu-default-stream=per-thread.
+// RUN: %clang -### -nogpuinc -nogpulib -fgpu-default-stream=per-thread \
+// RUN:   %s -save-temps 2>&1 | FileCheck -check-prefix=PTH %s
+// PTH: clang{{.*}}" "-cc1" {{.*}}"-E" {{.*}}"-fgpu-default-stream=per-thread"
+// PTH: clang{{.*}}" "-cc1" {{.*}}"-fgpu-default-stream=per-thread" {{.*}}"-x" "hip-cpp-output"
+// PTH: clang{{.*}}" "-cc1" {{.*}}"-E" {{.*}}"-fgpu-default-stream=per-thread"
+// PTH: clang{{.*}}" "-cc1" {{.*}}"-fgpu-default-stream=per-thread" {{.*}}"-x" "hip-cpp-output"
+
 // RUN: %clang -### -x hip -target x86_64-pc-windows-msvc -fms-extensions \
 // RUN:   -mllvm -amdgpu-early-inline-all=true  %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=MLLVM %s
Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -5,7 +5,13 @@
 // RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefixes=HIP-OLD,CHECK
 // RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes=HIP-NEW,CHECK
+// RUN: | FileCheck %s --check-prefixes=HIP-NEW,LEGACY,CHECK
+// RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=legacy \
+// RUN:   | FileCheck %s --check-prefixes=HIP-NEW,LEGACY,CHECK
+// RUN: %clang_cc1 -fhip-new-launch-api -x hip -emit-llvm %s -o - \
+// RUN:   -fgpu-default-stream=per-thread -DHIP_API_PER_THREAD_DEFAULT_STREAM \
+// RUN:   | FileCheck %s --check-prefixes=HIP-NEW,PTH,CHECK
 
 #include "Inputs/cuda.h"
 
@@ -13,7 +19,8 @@
 // HIP-OLD: call{{.*}}hipSetupArgument
 // HIP-OLD: call{{.*}}hipLaunchByPtr
 // HIP-NEW: call{{.*}}__hipPopCallConfiguration
-// HIP-NEW: call{{.*}}hipLaunchKernel
+// LEGACY: call{{.*}}hipLaunchKernel
+// PTH: call{{.*}}hipLaunchKernel_spt
 // CUDA-OLD: call{{.*}}cudaSetupArgument
 // CUDA-OLD: call{{.*}}cudaLaunch
 // CUDA-NEW: call{{.*}}__cudaPopCallConfiguration
Index: clang/test/CodeGenCUDA/Inputs/cuda.h
===
--- clang/test/CodeGenCUDA/Inputs/cuda.h
+++ clang/test/CodeGenCUDA/Inputs/cuda.h
@@ -35,11 +35,18 @@
 extern "C" hipError_t 

[PATCH] D120372: [clang] 'unused-but-set-variable' warning should not apply to __attribute__((objc_precise_lifetime) Objective-C pointers

2022-02-22 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added inline comments.



Comment at: clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m:7
+  // no diagnostics for objects with precise lifetime semantics.
+  __attribute__((objc_precise_lifetime)) id x;
+  x = getFoo();

dmaclach wrote:
> what happens in the case that x is never assigned to anything? Do we still 
> get a warning?
The code implementing `-Wunused-variable` checking already explicitly excludes 
`objc_precise_lifetime`-attributed variables: 
https://github.com/llvm/llvm-project/blob/36e335eeb577b6dc559de3a66bc832afae1f56c4/clang/lib/Sema/SemaDecl.cpp#L1847


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120372

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


[PATCH] D120307: [X86] Add helper enum for ternary intrinsics

2022-02-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Headers/avx512fintrin.h:5944
+  (__v16si)(__m512i)(A), (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), 
\
+  (unsigned char)(imm), (__mmask16)-1))
+

craig.topper wrote:
> Why do we need to change the type on `imm` here? The builtin takes an int, 
> and the enum you created defaults to int. Is this so we truncate ~ to 8-bits?
Yes. By the way, ICC and MSVC don't error out for it. 
https://godbolt.org/z/s1bG1sq9q


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120307

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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

There is a circular dependency if you use `-DBUILD_SHARED_LIBS=on`:

  CMake Error: The inter-target dependency graph contains the following 
strongly connected component (cycle):
"clangFrontend" of type SHARED_LIBRARY
  depends on "clangIndex" (weak)
"clangIndex" of type SHARED_LIBRARY
  depends on "clangFrontend" (weak)
  At least one of these targets is not a STATIC_LIBRARY.  Cyclic dependencies 
are allowed only among static libraries.
  CMake Generate step failed.  Build files cannot be regenerated correctly.
  FAILED: build.ninja


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

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


[clang] 36e335e - [clang] Remove Address::deprecated() calls in CodeGenFunction.cpp

2022-02-22 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-22T18:28:49-08:00
New Revision: 36e335eeb577b6dc559de3a66bc832afae1f56c4

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

LOG: [clang] Remove Address::deprecated() calls in CodeGenFunction.cpp

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index c4ccc8e1b042..9c3e5d546001 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1103,9 +1103,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
 EI->getType()->getPointerElementType(), &*EI, Idx);
 llvm::Type *Ty =
 cast(Addr)->getResultElementType();
-ReturnValuePointer = Address::deprecated(Addr, getPointerAlign());
+ReturnValuePointer = Address(Addr, Ty, getPointerAlign());
 Addr = Builder.CreateAlignedLoad(Ty, Addr, getPointerAlign(), 
"agg.result");
-ReturnValue = Address::deprecated(Addr, 
CGM.getNaturalTypeAlignment(RetTy));
+ReturnValue =
+Address(Addr, ConvertType(RetTy), CGM.getNaturalTypeAlignment(RetTy));
   } else {
 ReturnValue = CreateIRTemp(RetTy, "retval");
 
@@ -2481,7 +2482,7 @@ Address CodeGenFunction::EmitFieldAnnotations(const 
FieldDecl *D,
 V = Builder.CreateBitCast(V, VTy);
   }
 
-  return Address::deprecated(V, Addr.getAlignment());
+  return Address(V, Addr.getElementType(), Addr.getAlignment());
 }
 
 CodeGenFunction::CGCapturedStmtInfo::~CGCapturedStmtInfo() { }



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


[clang] 6a0b78a - [OpenMP] Remove static allocator in linker wrapper

2022-02-22 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-22T21:22:19-05:00
New Revision: 6a0b78af9175af45641c854a88761f284361aaee

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

LOG: [OpenMP] Remove static allocator in linker wrapper

Summary:
We don't need this static allocator to survive the entire file, the
strings stored have a defined lifetime.

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 60a5a0fab59f..2d73e0e574cb 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -142,9 +142,6 @@ static SmallVector TempFiles;
 /// Codegen flags for LTO backend.
 static codegen::RegisterCodeGenFlags CodeGenFlags;
 
-/// Static buffer to hold StringRef values.
-static BumpPtrAllocator Alloc;
-
 /// Magic section string that marks the existence of offloading data. The
 /// section string will be formatted as `.llvm.offloading..`.
 #define OFFLOAD_SECTION_MAGIC_STR ".llvm.offloading."
@@ -866,6 +863,7 @@ Error linkBitcodeFiles(SmallVectorImpl 
,
   SmallVector NewInputFiles;
   DenseSet UsedInRegularObj;
   DenseSet UsedInSharedLib;
+  BumpPtrAllocator Alloc;
   StringSaver Saver(Alloc);
 
   // Search for bitcode files in the input and create an LTO input file. If it



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


[clang] 55cb84d - [OpenMP] Unrecognized objects should not be considered failure

2022-02-22 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-22T21:22:18-05:00
New Revision: 55cb84d9fbea1ead9434de519e1b4e1d2d803048

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

LOG: [OpenMP] Unrecognized objects should not be considered failure

Summary:
This patch removes the error we recieve when attempting to extract
offloading sections. We shouldn't consider this a failure because
extracting bitcode isn't necessarily required.

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 4aca707348b2d..60a5a0fab59f6 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -517,7 +517,7 @@ extractFromBuffer(std::unique_ptr Buffer,
 return extractFromArchive(*LibFile->get(), DeviceFiles);
   }
   default:
-return errorCodeToError(object_error::invalid_file_type);
+return None;
   }
 }
 
@@ -1227,8 +1227,7 @@ int main(int argc, const char **argv) {
 if (Optional Library = searchLibrary(Arg, LibraryPaths))
   Filename = *Library;
 
-if ((sys::path::extension(Filename) == ".o" ||
- sys::path::extension(Filename) == ".a")) {
+if (sys::fs::exists(Filename) && !sys::fs::is_directory(Filename)) {
   ErrorOr> BufferOrErr =
   MemoryBuffer::getFileOrSTDIN(Filename);
   if (std::error_code EC = BufferOrErr.getError())



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


[PATCH] D120352: [C++20][Modules] Rework testcase to use split file [NFC].

2022-02-22 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu 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/D120352/new/

https://reviews.llvm.org/D120352

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


[PATCH] D120372: [clang] 'unused-but-set-variable' warning should not apply to __attribute__((objc_precise_lifetime) Objective-C pointers

2022-02-22 Thread Dave MacLachlan via Phabricator via cfe-commits
dmaclach accepted this revision.
dmaclach added inline comments.



Comment at: clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m:7
+  // no diagnostics for objects with precise lifetime semantics.
+  __attribute__((objc_precise_lifetime)) id x;
+  x = getFoo();

what happens in the case that x is never assigned to anything? Do we still get 
a warning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120372

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


[PATCH] D117611: [Sema] Warn about printf %n on Android and Fuchsia

2022-02-22 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

This doesn't leave much room to use `__attribute__((format(printf)))` on custom 
printf implementations that do support `%n` on Android does it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117611

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


[PATCH] D120372: [clang] 'unused-but-set-variable' warning should not apply to __attribute__((objc_precise_lifetime) Objective-C pointers

2022-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore added a comment.

Maybe ahatanak might be a good reviewer based on 
https://reviews.llvm.org/D112850?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120372

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


[PATCH] D120372: [clang] 'unused-but-set-variable' warning should not apply to __attribute__((objc_precise_lifetime) Objective-C pointers

2022-02-22 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore added a comment.
This revision is now accepted and ready to land.

Make sense to me.

I don't know offhand who might be a good second pair of eyes to take a look.




Comment at: clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m:6-8
+  // no diagnostics for objects with precise lifetime semantics.
+  __attribute__((objc_precise_lifetime)) id x;
+  x = getFoo();

Is it worth adding some cases with nested scopes? I think that's a common 
scenario where `objc_precise_lifetime` is often used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120372

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


[PATCH] D120372: [clang] 'unused-but-set-variable' warning should not apply to __attribute__((objc_precise_lifetime) Objective-C pointers

2022-02-22 Thread Michael Wyman via Phabricator via cfe-commits
mwyman created this revision.
mwyman added reviewers: stephanemoore, dmaclach.
mwyman added a project: clang.
mwyman requested review of this revision.
Herald added a subscriber: cfe-commits.

The `objc_precise_lifetime` attribute is applied to Objective-C pointers to 
ensure the optimizer does not prematurely release an object under Automatic 
Reference Counting (ARC). It is a common enough pattern to assign values to 
these variables but not reference them otherwise, and annotating them with 
`__unused` is not really correct as they //are// being used to ensure an 
object's lifetime.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120372

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m


Index: clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m
===
--- /dev/null
+++ clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos11 -fsyntax-only -fobjc-arc 
-fblocks -verify -Wunused-but-set-variable -Wno-objc-root-class %s
+
+id getFoo(void);
+
+void test() {
+  // no diagnostics for objects with precise lifetime semantics.
+  __attribute__((objc_precise_lifetime)) id x;
+  x = getFoo();
+
+  id x2; // expected-warning {{variable 'x2' set but not used}}
+  x2 = getFoo();
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2008,6 +2008,12 @@
   if (VD->hasAttr() && Ty->isObjCObjectPointerType())
 return;
 
+  // Don't warn about Objective-C pointer variables with precise lifetime
+  // semantics; they can be used to ensure ARC releases the object at a known
+  // time, which may mean assignment but no other references.
+  if (VD->hasAttr() && Ty->isObjCObjectPointerType())
+return;
+
   auto iter = RefsMinusAssignments.find(VD);
   if (iter == RefsMinusAssignments.end())
 return;


Index: clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m
===
--- /dev/null
+++ clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos11 -fsyntax-only -fobjc-arc -fblocks -verify -Wunused-but-set-variable -Wno-objc-root-class %s
+
+id getFoo(void);
+
+void test() {
+  // no diagnostics for objects with precise lifetime semantics.
+  __attribute__((objc_precise_lifetime)) id x;
+  x = getFoo();
+
+  id x2; // expected-warning {{variable 'x2' set but not used}}
+  x2 = getFoo();
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2008,6 +2008,12 @@
   if (VD->hasAttr() && Ty->isObjCObjectPointerType())
 return;
 
+  // Don't warn about Objective-C pointer variables with precise lifetime
+  // semantics; they can be used to ensure ARC releases the object at a known
+  // time, which may mean assignment but no other references.
+  if (VD->hasAttr() && Ty->isObjCObjectPointerType())
+return;
+
   auto iter = RefsMinusAssignments.find(VD);
   if (iter == RefsMinusAssignments.end())
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cde658f - [clang] Remove Address::deprecated() calls in CGVTables.cpp

2022-02-22 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-22T16:54:28-08:00
New Revision: cde658fa1f1449d2ec966b8c0df0444b882eb69f

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

LOG: [clang] Remove Address::deprecated() calls in CGVTables.cpp

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 34df7da7985b4..536db8dc4b41a 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -91,7 +91,10 @@ static RValue PerformReturnAdjustment(CodeGenFunction ,
   auto ClassDecl = ResultType->getPointeeType()->getAsCXXRecordDecl();
   auto ClassAlign = CGF.CGM.getClassPointerAlignment(ClassDecl);
   ReturnValue = CGF.CGM.getCXXABI().performReturnAdjustment(
-  CGF, Address::deprecated(ReturnValue, ClassAlign), Thunk.Return);
+  CGF,
+  Address(ReturnValue, CGF.ConvertTypeForMem(ResultType->getPointeeType()),
+  ClassAlign),
+  Thunk.Return);
 
   if (NullCheckValue) {
 CGF.Builder.CreateBr(AdjustEnd);
@@ -198,7 +201,8 @@ CodeGenFunction::GenerateVarArgsThunk(llvm::Function *Fn,
   // Find the first store of "this", which will be to the alloca associated
   // with "this".
   Address ThisPtr =
-  Address::deprecated(&*AI, CGM.getClassPointerAlignment(MD->getParent()));
+  Address(&*AI, ConvertTypeForMem(MD->getThisType()->getPointeeType()),
+  CGM.getClassPointerAlignment(MD->getParent()));
   llvm::BasicBlock *EntryBB = >front();
   llvm::BasicBlock::iterator ThisStore =
   llvm::find_if(*EntryBB, [&](llvm::Instruction ) {



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


[PATCH] D120369: [analyzer] Add more propagations to Taint analysis

2022-02-22 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 created this revision.
gamesh411 added a reviewer: steakhal.
Herald added subscribers: ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
gamesh411 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add more functions as taint propators to GenericTaintChecker.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120369

Files:
  clang/docs/analyzer/checkers.rst
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/test/Analysis/taint-generic.c

Index: clang/test/Analysis/taint-generic.c
===
--- clang/test/Analysis/taint-generic.c
+++ clang/test/Analysis/taint-generic.c
@@ -1,11 +1,13 @@
-// RUN: %clang_analyze_cc1 -Wno-format-security -Wno-pointer-to-int-cast -verify %s \
+// RUN: %clang_analyze_cc1 -Wno-format-security -Wno-pointer-to-int-cast \
+// RUN:   -Wno-incompatible-library-redeclaration -verify %s \
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=alpha.security.ArrayBoundV2 \
 // RUN:   -analyzer-config \
 // RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml
 
-// RUN: %clang_analyze_cc1 -Wno-format-security -Wno-pointer-to-int-cast -verify %s \
+// RUN: %clang_analyze_cc1 -Wno-format-security -Wno-pointer-to-int-cast \
+// RUN:   -Wno-incompatible-library-redeclaration -verify %s \
 // RUN:   -DFILE_IS_STRUCT \
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-checker=core \
@@ -13,7 +15,8 @@
 // RUN:   -analyzer-config \
 // RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml
 
-// RUN: not %clang_analyze_cc1 -Wno-pointer-to-int-cast -verify %s \
+// RUN: not %clang_analyze_cc1 -Wno-pointer-to-int-cast \
+// RUN:   -Wno-incompatible-library-redeclaration -verify %s \
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-config \
 // RUN: alpha.security.taint.TaintPropagation:Config=justguessit \
@@ -24,7 +27,8 @@
 // CHECK-INVALID-FILE-SAME:that expects a valid filename instead of
 // CHECK-INVALID-FILE-SAME:'justguessit'
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -Wno-incompatible-library-redeclaration \
+// RUN:   -verify %s \
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-config \
 // RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config-ill-formed.yaml \
@@ -34,7 +38,8 @@
 // CHECK-ILL-FORMED-SAME:'alpha.security.taint.TaintPropagation:Config',
 // CHECK-ILL-FORMED-SAME:that expects a valid yaml file: [[MSG]]
 
-// RUN: not %clang_analyze_cc1 -verify %s \
+// RUN: not %clang_analyze_cc1 -Wno-incompatible-library-redeclaration \
+// RUN:   -verify %s \
 // RUN:   -analyzer-checker=alpha.security.taint \
 // RUN:   -analyzer-config \
 // RUN: alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config-invalid-arg.yaml \
@@ -45,6 +50,8 @@
 // CHECK-INVALID-ARG-SAME:that expects an argument number for propagation
 // CHECK-INVALID-ARG-SAME:rules greater or equal to -1
 
+extern int some_global_flag_to_branch_on;
+
 int scanf(const char *restrict format, ...);
 char *gets(char *str);
 int getchar(void);
@@ -58,6 +65,8 @@
 
 #define bool _Bool
 
+FILE *fopen(const char *name, const char *mode);
+
 int fscanf(FILE *restrict stream, const char *restrict format, ...);
 int sprintf(char *str, const char *format, ...);
 void setproctitle(const char *fmt, ...);
@@ -352,6 +361,596 @@
   return 1 / x; // expected-warning {{Division by a tainted value, possibly zero}}
 }
 
+int fscanf_s(FILE *stream, const char *format, ...);
+int testFscanf_s(const char *fname, int *d) {
+  FILE *f = fopen(fname, "r");
+  fscanf_s(f, "%d", d);
+  return 1 / *d; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+int vscanf(const char *format, ...);
+int testVscanf(int *d) {
+  char format[10];
+  scanf("%9s", format); // fake a tainted a file descriptor
+
+  vscanf(format, );
+  return 1 / *d; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+int vfscanf(FILE *stream, const char *format, ...);
+int testVfscanf(const char *fname, int *d) {
+  FILE *f = fopen(fname, "r");
+  vfscanf(f, "%d", d);
+  return 1 / *d; // expected-warning {{Division by a tainted value, possibly zero}}
+}
+
+int fread(void *buffer, size_t size, size_t count, FILE *stream);
+int testFread(const char *fname, int *buffer, size_t size, size_t count) {
+  FILE *f = fopen(fname, "r");
+  size_t read = fread(buffer, size, count, f);
+
+  if (some_global_flag_to_branch_on) // just to have 2 branches, and assert 2 division by zero messages
+return 1 / *buffer;  // expected-warning 

[clang] 3ef7e6c - [clang] Remove an Address::deprecated() call in CGClass.cpp

2022-02-22 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2022-02-22T16:19:06-08:00
New Revision: 3ef7e6c53c825903d77a8d004a82c865f493e1bf

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

LOG: [clang] Remove an Address::deprecated() call in CGClass.cpp

Added: 


Modified: 
clang/lib/CodeGen/CGClass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 612209ef8fe8f..f6cacd07a66f2 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2148,7 +2148,7 @@ void CodeGenFunction::EmitCXXConstructorCall(const 
CXXConstructorDecl *D,
 assert(Args.size() == 2 && "unexpected argcount for trivial ctor");
 
 QualType SrcTy = D->getParamDecl(0)->getType().getNonReferenceType();
-Address Src = Address::deprecated(Args[1].getRValue(*this).getScalarVal(),
+Address Src = Address(Args[1].getRValue(*this).getScalarVal(), 
ConvertTypeForMem(SrcTy),
   CGM.getNaturalTypeAlignment(SrcTy));
 LValue SrcLVal = MakeAddrLValue(Src, SrcTy);
 QualType DestTy = getContext().getTypeDeclType(ClassDecl);



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


[PATCH] D120366: [CUDA][SPIRV] Assign global address space to CUDA kernel arguments

2022-02-22 Thread Shangwu Yao via Phabricator via cfe-commits
shangwuyao created this revision.
shangwuyao added reviewers: jlebar, tra, yaxunl.
Herald added subscribers: carlosgalvezp, ThomasRaoux, Anastasia.
shangwuyao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch converts CUDA pointer kernel arguments with default address space to
CrossWorkGroup address space (__global in OpenCL). This is because Generic or
Function (OpenCL's private) is not supported as storage class for kernel 
pointer types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120366

Files:
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDASPIRV/kernel-argument.cu


Index: clang/test/CodeGenCUDASPIRV/kernel-argument.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDASPIRV/kernel-argument.cu
@@ -0,0 +1,18 @@
+// Tests CUDA kernel arguments get global address space when targetting SPIR-V.
+
+// REQUIRES: clang-driver
+
+// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv32 \
+// RUN:   -nocudalib -nocudainc %s -o %t.bc -c 2>&1
+// RUN: llvm-dis %t.bc -o %t.ll
+// RUN: FileCheck %s --input-file=%t.ll
+
+// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv64 \
+// RUN:   -nocudalib -nocudainc %s -o %t.bc -c 2>&1
+// RUN: llvm-dis %t.bc -o %t.ll
+// RUN: FileCheck %s --input-file=%t.ll
+
+// CHECK: define
+// CHECK-SAME: spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef
+
+__attribute__((global)) void kernel(int* output) { *output = 1; }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10320,10 +10320,10 @@
 }
 
 ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
-  if (getContext().getLangOpts().HIP) {
+  if (getContext().getLangOpts().CUDAIsDevice) {
 // Coerce pointer arguments with default address space to CrossWorkGroup
-// pointers for HIPSPV. When the language mode is HIP, the SPIRTargetInfo
-// maps cuda_device to SPIR-V's CrossWorkGroup address space.
+// pointers for HIPSPV/CUDASPV. When the language mode is HIP/CUDA, the
+// SPIRTargetInfo maps cuda_device to SPIR-V's CrossWorkGroup address 
space.
 llvm::Type *LTy = CGT.ConvertType(Ty);
 auto DefaultAS = getContext().getTargetAddressSpace(LangAS::Default);
 auto GlobalAS = getContext().getTargetAddressSpace(LangAS::cuda_device);
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -144,16 +144,16 @@
 // FIXME: SYCL specification considers unannotated pointers and references
 // to be pointing to the generic address space. See section 5.9.3 of
 // SYCL 2020 specification.
-// Currently, there is no way of representing SYCL's and HIP's default
+// Currently, there is no way of representing SYCL's and HIP/CUDA's default
 // address space language semantic along with the semantics of embedded C's
 // default address space in the same address space map. Hence the map needs
 // to be reset to allow mapping to the desired value of 'Default' entry for
-// SYCL and HIP.
+// SYCL and HIP/CUDA.
 setAddressSpaceMap(
 /*DefaultIsGeneric=*/Opts.SYCLIsDevice ||
-// The address mapping from HIP language for device code is only 
defined
-// for SPIR-V.
-(getTriple().isSPIRV() && Opts.HIP && Opts.CUDAIsDevice));
+// The address mapping from HIP/CUDA language for device code is only
+// defined for SPIR-V.
+(getTriple().isSPIRV() && Opts.CUDAIsDevice));
   }
 
   void setSupportedOpenCLOpts() override {


Index: clang/test/CodeGenCUDASPIRV/kernel-argument.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDASPIRV/kernel-argument.cu
@@ -0,0 +1,18 @@
+// Tests CUDA kernel arguments get global address space when targetting SPIR-V.
+
+// REQUIRES: clang-driver
+
+// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv32 \
+// RUN:   -nocudalib -nocudainc %s -o %t.bc -c 2>&1
+// RUN: llvm-dis %t.bc -o %t.ll
+// RUN: FileCheck %s --input-file=%t.ll
+
+// RUN: %clang -emit-llvm --cuda-device-only --offload=spirv64 \
+// RUN:   -nocudalib -nocudainc %s -o %t.bc -c 2>&1
+// RUN: llvm-dis %t.bc -o %t.ll
+// RUN: FileCheck %s --input-file=%t.ll
+
+// CHECK: define
+// CHECK-SAME: spir_kernel void @_Z6kernelPi(i32 addrspace(1)* noundef
+
+__attribute__((global)) void kernel(int* output) { *output = 1; }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10320,10 +10320,10 @@
 }
 
 ABIArgInfo SPIRVABIInfo::classifyKernelArgumentType(QualType Ty) const {
-  

[PATCH] D120266: [clang][CodeGen] Avoid emitting ifuncs with undefined resolvers

2022-02-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.h:358
+  /// function declarations when we do not emit a definition for the resolver.
+  std::vector MultiVersionIFuncs;
+

Optional: `SmallVector` typically compiles to less code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120266

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


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-02-22 Thread sstwcw via Phabricator via cfe-commits
sstwcw marked 18 inline comments as done.
sstwcw added a comment.

The YAML stuff are now in D120363 .




Comment at: clang/docs/ClangFormatStyleOptions.rst:1408-1415
+  Precise control over the wrapping of braces.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+BreakBeforeBraces: Custom
+BraceWrapping:

curdeius wrote:
> That's an unrelated change. Could you please do it in another (NFC) revision?
It's in D120361.



Comment at: clang/docs/tools/dump_format_style.py:121
   def __str__(self):
-return '\n'.join(map(str, self.values))
+return self.comment + '\n' + '\n'.join(map(str, self.values))
 

MyDeveloperDay wrote:
> Can this change be separate? why is this needed? Could you add a screengrab 
> of the html that it generates?
It's in D120361.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D119949: [Clang-tidy] Check the existence of ElaboratedType's qualifiers

2022-02-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

Gentle ping~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119949

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


[PATCH] D120361: [clang-format] Extract doc for entire configuration structs

2022-02-22 Thread sstwcw via Phabricator via cfe-commits
sstwcw created this revision.
sstwcw added a reviewer: clang-format.
sstwcw added a project: clang-format.
sstwcw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously the comments for configuration structs as a whole like
``BraceWrappingFlags`` did not go into the doc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120361

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/tools/dump_format_style.py


Index: clang/docs/tools/dump_format_style.py
===
--- clang/docs/tools/dump_format_style.py
+++ clang/docs/tools/dump_format_style.py
@@ -118,7 +118,7 @@
 self.values = []
 
   def __str__(self):
-return '\n'.join(map(str, self.values))
+return self.comment + '\n' + '\n'.join(map(str, self.values))
 
 class NestedField(object):
   def __init__(self, name, comment):
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1209,6 +1209,14 @@
 
   Nested configuration flags:
 
+  Precise control over the wrapping of braces.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterClass: true
 
   * ``bool AfterCaseLabel`` Wrap case labels.
 
@@ -3989,6 +3997,15 @@
 
   Nested configuration flags:
 
+  Precise control over the spacing before parentheses.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+  AfterControlStatements: true
+  AfterFunctionDefinitionName: true
 
   * ``bool AfterControlStatements`` If ``true``, put space betwee control 
statement keywords
 (for/if/while...) and opening parentheses.
@@ -4218,6 +4235,7 @@
 
   Nested configuration flags:
 
+  Control of spaces within a single line comment
 
   * ``unsigned Minimum`` The minimum number of spaces at the start of the 
comment.
 


Index: clang/docs/tools/dump_format_style.py
===
--- clang/docs/tools/dump_format_style.py
+++ clang/docs/tools/dump_format_style.py
@@ -118,7 +118,7 @@
 self.values = []
 
   def __str__(self):
-return '\n'.join(map(str, self.values))
+return self.comment + '\n' + '\n'.join(map(str, self.values))
 
 class NestedField(object):
   def __init__(self, name, comment):
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1209,6 +1209,14 @@
 
   Nested configuration flags:
 
+  Precise control over the wrapping of braces.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+BreakBeforeBraces: Custom
+BraceWrapping:
+AfterClass: true
 
   * ``bool AfterCaseLabel`` Wrap case labels.
 
@@ -3989,6 +3997,15 @@
 
   Nested configuration flags:
 
+  Precise control over the spacing before parentheses.
+
+  .. code-block:: c++
+
+# Should be declared this way:
+SpaceBeforeParens: Custom
+SpaceBeforeParensOptions:
+  AfterControlStatements: true
+  AfterFunctionDefinitionName: true
 
   * ``bool AfterControlStatements`` If ``true``, put space betwee control statement keywords
 (for/if/while...) and opening parentheses.
@@ -4218,6 +4235,7 @@
 
   Nested configuration flags:
 
+  Control of spaces within a single line comment
 
   * ``unsigned Minimum`` The minimum number of spaces at the start of the comment.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120353: [OpenMP] Add option to make offloading mandatory

2022-02-22 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D120353#3338718 , @ABataev wrote:

> In D120353#3338647 , @jhuber6 wrote:
>
>> But the main reason I made this patch is for interoperability. Without this 
>> if you want to call a CUDA function from the OpenMP device you'd need a 
>> variant and a dummy implementation. If you don't write a dummy 
>> implementation you'll get a linker error, if you don't use a variant you'll 
>> override the CUDA function.
>
> Ah, ok, I see. How is supposed to be used? In Cuda code or in plain C/C++ 
> code?

I haven't finalized the implementation, but the basic support I've tested was 
calling a `__device__` function compiled from another file with OpenMP, with 
this patch the source files would look like this for example. I think the 
inverse would also be possible given some code on the CUDA side. Calling CUDA 
kernels would take some extra work.

  __device__ int cuda() { return 0; }



  int cuda(void);
  #pragma omp declare target device_type(nohost) to(cuda)
  
  int main() {
int x = 1;
  #pragma omp target map(from : x)
x = cuda();
  
return x;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120353

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


[PATCH] D120331: [clang-tidy][run-clang-tidy.py] Add --config-file= option

2022-02-22 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py:236
   'each source file in its parent directories.')
+  parser.add_argument('-config-file', default=None,
+  help='Specify the path of .clang-tidy or custom config'

please ensure that those option exclude each other. right now it could be used 
with both options which is a contradiction for `clang-tidy`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120331

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


[PATCH] D120360: [libTooling] Generalize string explanation as Any metadata

2022-02-22 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua added inline comments.



Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:68
 
+using AnyGenerator2 = std::shared_ptr>;
+

Placeholder name; suggestions welcome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120360

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


[PATCH] D120360: [libTooling] Generalize string explanation as Any metadata

2022-02-22 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua created this revision.
li.zhe.hua added a reviewer: ymandel.
Herald added a subscriber: carlosgalvezp.
li.zhe.hua requested review of this revision.
Herald added projects: clang, clang-tools-extra.

Change RewriteRule from holding an `Explanation` to being able to generate
arbitrary metadata. Where TransformerClangTidyCheck was interested in a string
description for the diagnostic, other tools may be interested in richer metadata
at a higher level of abstraction than at the edit level (which is currently
available as ASTEdit::Metadata).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120360

Files:
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang/include/clang/Tooling/Transformer/RewriteRule.h
  clang/include/clang/Tooling/Transformer/Transformer.h
  clang/lib/Tooling/Transformer/RewriteRule.cpp
  clang/lib/Tooling/Transformer/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -31,6 +31,7 @@
 using ::clang::transformer::member;
 using ::clang::transformer::name;
 using ::clang::transformer::node;
+using ::clang::transformer::noEdits;
 using ::clang::transformer::remove;
 using ::clang::transformer::rewriteDescendants;
 using ::clang::transformer::RewriteRule;
@@ -137,27 +138,59 @@
 };
   }
 
-  template 
-  void testRule(R Rule, StringRef Input, StringRef Expected) {
+  std::function>)>
+  consumerWithStringMetadata() {
+return [this](Expected> C) {
+  if (C) {
+Changes.insert(Changes.end(),
+   std::make_move_iterator(C->Changes.begin()),
+   std::make_move_iterator(C->Changes.end()));
+StringMetadata.push_back(std::move(C->Metadata));
+  } else {
+// FIXME: stash this error rather then printing.
+llvm::errs() << "Error generating changes: "
+ << llvm::toString(C.takeError()) << "\n";
+++ErrorCount;
+  }
+};
+  }
+
+  void testRule(RewriteRule Rule, StringRef Input, StringRef Expected) {
 Transformers.push_back(
 std::make_unique(std::move(Rule), consumer()));
 Transformers.back()->registerMatchers();
 compareSnippets(Expected, rewrite(Input));
   }
 
-  template  void testRuleFailure(R Rule, StringRef Input) {
+  void testRuleWithMetadata(RewriteRule Rule, StringRef Input,
+StringRef Expected) {
+Transformers.push_back(std::make_unique(
+std::move(Rule), consumerWithStringMetadata()));
+Transformers.back()->registerMatchers();
+compareSnippets(Expected, rewrite(Input));
+  }
+
+  void testRuleFailure(RewriteRule Rule, StringRef Input) {
 Transformers.push_back(
 std::make_unique(std::move(Rule), consumer()));
 Transformers.back()->registerMatchers();
 ASSERT_FALSE(rewrite(Input)) << "Expected failure to rewrite code";
   }
 
+  void testRuleFailureWithMetadata(RewriteRule Rule, StringRef Input) {
+Transformers.push_back(std::make_unique(
+std::move(Rule), consumerWithStringMetadata()));
+Transformers.back()->registerMatchers();
+ASSERT_FALSE(rewrite(Input)) << "Expected failure to rewrite code";
+  }
+
   // Transformers are referenced by MatchFinder.
   std::vector> Transformers;
   clang::ast_matchers::MatchFinder MatchFinder;
   // Records whether any errors occurred in individual changes.
   int ErrorCount = 0;
   AtomicChanges Changes;
+  std::vector StringMetadata;
 
 private:
   FileContentMappings FileContents = {{"header.h", ""}};
@@ -1682,4 +1715,40 @@
"./input.h";
 }
 
+TEST_F(TransformerTest, GeneratesMetadata) {
+  std::string Input = R"cc(int target = 0;)cc";
+  std::string Expected = R"cc(REPLACE)cc";
+  testRuleWithMetadata(makeRule(varDecl(hasName("target")),
+edit(changeTo(cat("REPLACE"))),
+cat("METADATA")),
+   Input, Expected);
+  EXPECT_EQ(ErrorCount, 0);
+  EXPECT_THAT(StringMetadata, UnorderedElementsAre("METADATA"));
+}
+
+TEST_F(TransformerTest, GeneratesMetadataWithNoEdits) {
+  std::string Input = R"cc(int target = 0;)cc";
+  testRuleWithMetadata(makeRule(varDecl(hasName("target")).bind("var"),
+noEdits(), cat("METADATA")),
+   Input, Input);
+  EXPECT_EQ(ErrorCount, 0);
+  EXPECT_THAT(StringMetadata, UnorderedElementsAre("METADATA"));
+}
+
+TEST_F(TransformerTest, PropagateMetadataErrors) {
+  class AlwaysFail : public transformer::MatchComputation {
+llvm::Error eval(const ast_matchers::MatchFinder::MatchResult &,
+ std::string *) const override {
+  return llvm::createStringError(llvm::errc::invalid_argument, "ERROR");
+}
+std::string toString() const override { return 

[PATCH] D120353: [OpenMP] Add option to make offloading mandatory

2022-02-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D120353#3338647 , @jhuber6 wrote:

> In D120353#3338589 , @ABataev wrote:
>
>>> This is necessary for implementing features like conditional offloading and 
>>> ensuring that unhandled pragmas don't result in missing symbols.
>>
>> This behavior is part of the standard.
>
> I believe it's reasonable to have this as an option flag to defy the 
> standard, we have other flags that do this already (e.g. -fopenmp-cuda-mode).

I mean it is not the implementation feature.

>>> For offloading tests we can silently fail to the host without realizing 
>>> that offloading failed.
>>
>> It is controlled by the OMP_TARGET_OFFLOAD env variable, no? You can set 
>> this env var to mandatory to avoid this problem.
>
> Yes, I don't think we set it in the tests right now for some reason.

I thought it is the default behavior. But we need to set it for offloading 
tests to be sure in their behavior.

> But the main reason I made this patch is for interoperability. Without this 
> if you want to call a CUDA function from the OpenMP device you'd need a 
> variant and a dummy implementation. If you don't write a dummy implementation 
> you'll get a linker error, if you don't use a variant you'll override the 
> CUDA version.

Ah, ok, I see. How is supposed to be used? In Cuda code or in plain C/C++ code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120353

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


[PATCH] D120359: [clang-format][NFC] Remove redundant semi

2022-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: owenpan, curdeius, MyDeveloperDay.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

All "calls" have a semi, as they should, remove the one from the macro.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120359

Files:
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -42,7 +42,7 @@
   do { 
\
 EXPECT_TOKEN_KIND(FormatTok, Kind);
\
 EXPECT_TOKEN_TYPE(FormatTok, Type);
\
-  } while (false)
+  } while (false);
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmpInMacroDefinition) {
   // This is a regression test for mis-parsing the & after decltype as a binary


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -42,7 +42,7 @@
   do { \
 EXPECT_TOKEN_KIND(FormatTok, Kind);\
 EXPECT_TOKEN_TYPE(FormatTok, Type);\
-  } while (false)
+  } while (false);
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfStarAndAmpInMacroDefinition) {
   // This is a regression test for mis-parsing the & after decltype as a binary
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120353: [OpenMP] Add option to make offloading mandatory

2022-02-22 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D120353#3338589 , @ABataev wrote:

>> This is necessary for implementing features like conditional offloading and 
>> ensuring that unhandled pragmas don't result in missing symbols.
>
> This behavior is part of the standard.

I believe it's reasonable to have this as an option flag to defy the standard, 
we have other flags that do this already (e.g. -fopenmp-cuda-mode).

>> For offloading tests we can silently fail to the host without realizing that 
>> offloading failed.
>
> It is controlled by the OMP_TARGET_OFFLOAD env variable, no? You can set this 
> env var to mandatory to avoid this problem.

Yes, I don't think we set it in the tests right now for some reason. But the 
main reason I made this patch is for interoperability. Without this if you want 
to call a CUDA function from the OpenMP device you'd need a variant and a dummy 
implementation. If you don't write a dummy implementation you'll get a linker 
error, if you don't use a variant you'll override the CUDA version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120353

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D113319#3338290 , 
@HazardyKnusperkeks wrote:

> 



> That means someone guesses this is a binary op and guesses wrong. I try to 
> take a look at it.

Yeah, I just found out that it is set in `determineStarAmpUsage` here:

  if (PrevToken->Tok.isLiteral() ||
  PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true,
 tok::kw_false, tok::r_brace) ||
  NextToken->Tok.isLiteral() ||
  NextToken->isOneOf(tok::kw_true, tok::kw_false) ||
  NextToken->isUnaryOperator() ||
  // If we know we're in a template argument, there are no named
  // declarations. Thus, having an identifier on the right-hand side
  // indicates a binary operator.
  (InTemplateArgument && NextToken->Tok.isAnyIdentifier()))
return TT_BinaryOperator;

Strangely, `InTemplateArgument` is true here, but not sure how that happens, as 
it wasn't something you changed directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[PATCH] D120140: [clang-format] Avoid inserting space after C++ casts.

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested review of this revision.
curdeius added a comment.

I took another approach to fix the problem found in polly tests.
I added CppCastLParen kind so as not to interfere with C-style casts.
I also added a test case taken from lib/Format that got misformatted by the 
previous version (`if (static_cast(A) + B >= 0)\n  ;` got the spaces 
around `+` removed: `if (static_cast(A)+B >= 0)\n  ;`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120140

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


[PATCH] D120140: [clang-format] Avoid inserting space after C++ casts.

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 410638.
curdeius added a comment.
This revision is now accepted and ready to land.

- Fix. Add tests from inspired by polly and lib/Format that had misformats.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120140

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10565,6 +10565,19 @@
 
 TEST_F(FormatTest, FormatsCasts) {
   verifyFormat("Type *A = static_cast(P);");
+  verifyFormat("static_cast(P);");
+  verifyFormat("static_cast(Fun)(Args);");
+  verifyFormat("static_cast(*Fun)(Args);");
+  verifyFormat("if (static_cast(A) + B >= 0)\n  ;");
+  // Check that static_cast<...>(...) does not require the next token to be on
+  // the same line.
+  verifyFormat("some_lng_output << something_something__ << "
+   "static_cast(R)\n"
+   "<< something;");
+  verifyFormat("a = static_cast(*Fun)(Args);");
+  verifyFormat("const_cast(*Fun)(Args);");
+  verifyFormat("dynamic_cast(*Fun)(Args);");
+  verifyFormat("reinterpret_cast(*Fun)(Args);");
   verifyFormat("Type *A = (Type *)P;");
   verifyFormat("Type *A = (vector)P;");
   verifyFormat("int a = (int)(2.0f);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -358,7 +358,8 @@
   if (CurrentToken->Previous->is(TT_BinaryOperator))
 Contexts.back().IsExpression = true;
   if (CurrentToken->is(tok::r_paren)) {
-if (MightBeFunctionType && ProbablyFunctionType && CurrentToken->Next 
&&
+if (Left->isNot(TT_CppCastLParen) && MightBeFunctionType &&
+ProbablyFunctionType && CurrentToken->Next &&
 (CurrentToken->Next->is(tok::l_paren) ||
  (CurrentToken->Next->is(tok::l_square) && 
Line.MustBeDeclaration)))
   Left->setType(Left->Next->is(tok::caret) ? TT_ObjCBlockLParen
@@ -1733,6 +1734,9 @@
   Current.Tok.setKind(tok::unknown);
   else
 Current.setType(TT_LineComment);
+} else if (Current.is(tok::l_paren)) {
+  if (lParenStartsCppCast(Current))
+Current.setType(TT_CppCastLParen);
 } else if (Current.is(tok::r_paren)) {
   if (rParenEndsCast(Current))
 Current.setType(TT_CastRParen);
@@ -1880,6 +1884,25 @@
 return Style.isJavaScript() && PreviousNotConst->is(tok::kw_const);
   }
 
+  /// Determine whether '(' is starting a C++ cast.
+  bool lParenStartsCppCast(const FormatToken ) {
+// C-style casts are only used in C++.
+if (!Style.isCpp())
+  return false;
+
+FormatToken *LeftOfParens = Tok.getPreviousNonComment();
+if (LeftOfParens && LeftOfParens->is(TT_TemplateCloser) &&
+LeftOfParens->MatchingParen) {
+  auto *Prev = LeftOfParens->MatchingParen->getPreviousNonComment();
+  if (Prev && Prev->isOneOf(tok::kw_const_cast, tok::kw_dynamic_cast,
+tok::kw_reinterpret_cast, tok::kw_static_cast))
+// FIXME: Maybe we should handle identifiers ending with "_cast",
+// e.g. any_cast?
+return true;
+}
+return false;
+  }
+
   /// Determine whether ')' is ending a cast.
   bool rParenEndsCast(const FormatToken ) {
 // C-style casts are only used in C++, C# and Java.
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -43,6 +43,7 @@
   TYPE(ConflictAlternative)
\
   TYPE(ConflictEnd)
\
   TYPE(ConflictStart)  
\
+  TYPE(CppCastLParen)  
\
   TYPE(CtorInitializerColon)   
\
   TYPE(CtorInitializerComma)   
\
   TYPE(DesignatedInitializerLSquare)   
\


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10565,6 +10565,19 @@
 
 TEST_F(FormatTest, FormatsCasts) {
   verifyFormat("Type *A = static_cast(P);");
+  verifyFormat("static_cast(P);");
+  verifyFormat("static_cast(Fun)(Args);");
+  verifyFormat("static_cast(*Fun)(Args);");
+  verifyFormat("if (static_cast(A) + B >= 0)\n  ;");
+  // Check that static_cast<...>(...) does not require the next 

[PATCH] D120353: [OpenMP] Add option to make offloading mandatory

2022-02-22 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

> This is necessary for implementing features like conditional offloading and 
> ensuring that unhandled pragmas don't result in missing symbols.

This behavior is part of the standard.

> For offloading tests we can silently fail to the host without realizing that 
> offloading failed.

It is controlled by the OMP_TARGET_OFFLOAD env variable, no? You can set this 
env var to mandatory to avoid this problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120353

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


[PATCH] D120353: [OpenMP] Add option to make offloading mandatory

2022-02-22 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, ABataev.
Herald added subscribers: dexonsmith, dang, guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Currently when we generate OpenMP offloading code we always make
fallback code for the CPU. This is necessary for implementing features
like conditional offloading and ensuring that unhandled pragmas don't
result in missing symbols. However, this is problematic for a few cases.
For offloading tests we can silently fail to the host without realizing
that offloading failed. Additionally, this makes it impossible to
provide interoperabiility to other offloading schemes like HIP or CUDA
because those methods do not provide any such host fallback guaruntee.
this patch adds the `-fopenmp-offload-mandatory` flag to prevent
generating the fallback symbol on the CPU and instead replaces the
function with a dummy global and the failed branch with 'unreachable'.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120353

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp

Index: clang/test/OpenMP/target_offload_mandatory_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_offload_mandatory_codegen.cpp
@@ -0,0 +1,32 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+"
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-offload-mandatory -emit-llvm %s -o - | FileCheck %s --check-prefix=MANDATORY
+// expected-no-diagnostics
+
+int x;
+#pragma omp declare target(x)
+
+void foo(int) {}
+#pragma omp declare target device_type(nohost) to(foo)
+
+void host() {
+#pragma omp target
+  { foo(x); }
+}
+// MANDATORY-LABEL: define {{[^@]+}}@_Z4hostv
+// MANDATORY-SAME: () #[[ATTR1:[0-9]+]] {
+// MANDATORY-NEXT:  entry:
+// MANDATORY-NEXT:[[TMP0:%.*]] = call i32 @__tgt_target_mapper(%struct.ident_t* @[[GLOB1:[0-9]+]], i64 -1, i8* @.{{__omp_offloading_[0-9a-z]+_[0-9a-z]+}}__Z4hostv_l12.region_id, i32 0, i8** null, i8** null, i64* null, i64* null, i8** null, i8** null)
+// MANDATORY-NEXT:[[TMP1:%.*]] = icmp ne i32 [[TMP0]], 0
+// MANDATORY-NEXT:br i1 [[TMP1]], label [[OMP_OFFLOAD_FAILED:%.*]], label [[OMP_OFFLOAD_CONT:%.*]]
+// MANDATORY:   omp_offload.failed:
+// MANDATORY-NEXT:unreachable
+// MANDATORY:   omp_offload.cont:
+// MANDATORY-NEXT:ret void
+//
+//
+// MANDATORY-LABEL: define {{[^@]+}}@.omp_offloading.requires_reg
+// MANDATORY-SAME: () #[[ATTR3:[0-9]+]] {
+// MANDATORY-NEXT:  entry:
+// MANDATORY-NEXT:call void @__tgt_register_requires(i64 1)
+// MANDATORY-NEXT:ret void
+//
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -2517,7 +2517,7 @@
 << HostDevTy;
 return;
   }
-  if (!LangOpts.OpenMPIsDevice && DevTy &&
+  if (!LangOpts.OpenMPIsDevice && !LangOpts.OpenMPOffloadMandatory && DevTy &&
   *DevTy == OMPDeclareTargetDeclAttr::DT_NoHost) {
 // Diagnose nohost function called during host codegen.
 StringRef NoHostDevTy = getOpenMPSimpleClauseTypeName(
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5997,6 +5997,8 @@
 CmdArgs.push_back("-fopenmp-assume-threads-oversubscription");
   if (Args.hasArg(options::OPT_fopenmp_assume_no_thread_state))
 CmdArgs.push_back("-fopenmp-assume-no-thread-state");
+  if (Args.hasArg(options::OPT_fopenmp_offload_mandatory))
+CmdArgs.push_back("-fopenmp-offload-mandatory");
   break;
 default:
   // By default, if Clang doesn't know how to generate useful OpenMP code
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6538,6 +6538,8 @@
   // mangled name of the function that encloses the target region and BB is the
   // line number of the target region.
 
+  const bool BuildOutlinedFn = CGM.getLangOpts().OpenMPIsDevice ||
+   !CGM.getLangOpts().OpenMPOffloadMandatory;
   unsigned DeviceID;
   unsigned FileID;
   unsigned Line;
@@ -6556,7 +6558,8 @@
   CGOpenMPTargetRegionInfo CGInfo(CS, CodeGen, EntryFnName);
   

[PATCH] D120258: [clangd] Add inlay hints for auto-typed parameters with one instantiation.

2022-02-22 Thread Trass3r via Phabricator via cfe-commits
Trass3r added a comment.

For a callback like

  [](auto) {...}

the inlay hint is displayed after the `)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120258

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


[PATCH] D120278: [clang-format] Don't break semi after requires clause regardless of the chosen style

2022-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG923c3755ea80: [clang-format] Dont break semi after 
requires clause ... (authored by HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120278

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23861,6 +23861,11 @@
"}",
Style);
 
+  verifyFormat("template \n"
+   "int bar(T t)\n"
+   "  requires F;",
+   Style);
+
   Style.IndentRequiresClause = false;
   verifyFormat("template \n"
"requires F\n"
@@ -23881,6 +23886,7 @@
   verifyFormat("template  requires Foo struct Bar {};\n"
"template  requires Foo void bar() {}\n"
"template  void bar() requires Foo {}\n"
+   "template  void bar() requires Foo;\n"
"template  requires Foo Bar(T) -> Bar;",
Style);
 
@@ -23933,6 +23939,9 @@
"void bar()\n"
"requires Foo {}\n"
"template \n"
+   "void bar()\n"
+   "requires Foo;\n"
+   "template \n"
"requires Foo Bar(T) -> Bar;",
Style);
 
@@ -23992,6 +24001,7 @@
"template \n"
"void bar() requires Foo\n"
"{}\n"
+   "template  void bar() requires Foo;\n"
"template  requires Foo\n"
"Bar(T) -> Bar;",
Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3963,7 +3963,7 @@
   return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always;
 return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes;
   }
-  if (Left.ClosesRequiresClause) {
+  if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) {
 switch (Style.RequiresClausePosition) {
 case FormatStyle::RCPS_OwnLine:
 case FormatStyle::RCPS_WithPreceding:


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -23861,6 +23861,11 @@
"}",
Style);
 
+  verifyFormat("template \n"
+   "int bar(T t)\n"
+   "  requires F;",
+   Style);
+
   Style.IndentRequiresClause = false;
   verifyFormat("template \n"
"requires F\n"
@@ -23881,6 +23886,7 @@
   verifyFormat("template  requires Foo struct Bar {};\n"
"template  requires Foo void bar() {}\n"
"template  void bar() requires Foo {}\n"
+   "template  void bar() requires Foo;\n"
"template  requires Foo Bar(T) -> Bar;",
Style);
 
@@ -23933,6 +23939,9 @@
"void bar()\n"
"requires Foo {}\n"
"template \n"
+   "void bar()\n"
+   "requires Foo;\n"
+   "template \n"
"requires Foo Bar(T) -> Bar;",
Style);
 
@@ -23992,6 +24001,7 @@
"template \n"
"void bar() requires Foo\n"
"{}\n"
+   "template  void bar() requires Foo;\n"
"template  requires Foo\n"
"Bar(T) -> Bar;",
Style);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3963,7 +3963,7 @@
   return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always;
 return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes;
   }
-  if (Left.ClosesRequiresClause) {
+  if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) {
 switch (Style.RequiresClausePosition) {
 case FormatStyle::RCPS_OwnLine:
 case FormatStyle::RCPS_WithPreceding:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120237: [clang-format][NFC] Simplify if in ContinuationIndenter::addTokenOCL

2022-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7ebb00a22e7e: [clang-format][NFC] Simplify if in 
ContinuationIndenter::addTokenOCL (authored by HazardyKnusperkeks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120237

Files:
  clang/lib/Format/ContinuationIndenter.cpp


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -784,14 +784,12 @@
 //   OuterFunction(InnerFunctionCall( // break
 //   ParameterToInnerFunction))   // break
 //   .SecondInnerFunctionCall();
-bool HasTrailingCall = false;
 if (Previous.MatchingParen) {
   const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
-  HasTrailingCall = Next && Next->isMemberAccess();
+  if (Next && Next->isMemberAccess() && State.Stack.size() > 1 &&
+  State.Stack[State.Stack.size() - 2].CallContinuation == 0)
+CurrentState.LastSpace = State.Column;
 }
-if (HasTrailingCall && State.Stack.size() > 1 &&
-State.Stack[State.Stack.size() - 2].CallContinuation == 0)
-  CurrentState.LastSpace = State.Column;
   }
 }
 


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -784,14 +784,12 @@
 //   OuterFunction(InnerFunctionCall( // break
 //   ParameterToInnerFunction))   // break
 //   .SecondInnerFunctionCall();
-bool HasTrailingCall = false;
 if (Previous.MatchingParen) {
   const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
-  HasTrailingCall = Next && Next->isMemberAccess();
+  if (Next && Next->isMemberAccess() && State.Stack.size() > 1 &&
+  State.Stack[State.Stack.size() - 2].CallContinuation == 0)
+CurrentState.LastSpace = State.Column;
 }
-if (HasTrailingCall && State.Stack.size() > 1 &&
-State.Stack[State.Stack.size() - 2].CallContinuation == 0)
-  CurrentState.LastSpace = State.Column;
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 923c375 - [clang-format] Don't break semi after requires clause ...

2022-02-22 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-02-22T22:08:03+01:00
New Revision: 923c3755ea809275d6c06caf547525452568eb5f

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

LOG: [clang-format] Don't break semi after requires clause ...

..regardless of the chosen style.

Fixes https://github.com/llvm/llvm-project/issues/53818

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 7649263a18a1e..42c271f35be44 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3963,7 +3963,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
,
   return Style.BreakBeforeConceptDeclarations == FormatStyle::BBCDS_Always;
 return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes;
   }
-  if (Left.ClosesRequiresClause) {
+  if (Left.ClosesRequiresClause && Right.isNot(tok::semi)) {
 switch (Style.RequiresClausePosition) {
 case FormatStyle::RCPS_OwnLine:
 case FormatStyle::RCPS_WithPreceding:

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 7d8b74c9c455f..98a0111d1ea40 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -23861,6 +23861,11 @@ TEST_F(FormatTest, RequiresClausesPositions) {
"}",
Style);
 
+  verifyFormat("template \n"
+   "int bar(T t)\n"
+   "  requires F;",
+   Style);
+
   Style.IndentRequiresClause = false;
   verifyFormat("template \n"
"requires F\n"
@@ -23881,6 +23886,7 @@ TEST_F(FormatTest, RequiresClausesPositions) {
   verifyFormat("template  requires Foo struct Bar {};\n"
"template  requires Foo void bar() {}\n"
"template  void bar() requires Foo {}\n"
+   "template  void bar() requires Foo;\n"
"template  requires Foo Bar(T) -> Bar;",
Style);
 
@@ -23933,6 +23939,9 @@ TEST_F(FormatTest, RequiresClausesPositions) {
"void bar()\n"
"requires Foo {}\n"
"template \n"
+   "void bar()\n"
+   "requires Foo;\n"
+   "template \n"
"requires Foo Bar(T) -> Bar;",
Style);
 
@@ -23992,6 +24001,7 @@ TEST_F(FormatTest, RequiresClausesPositions) {
"template \n"
"void bar() requires Foo\n"
"{}\n"
+   "template  void bar() requires Foo;\n"
"template  requires Foo\n"
"Bar(T) -> Bar;",
Style);



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


[clang] 7ebb00a - [clang-format][NFC] Simplify if in ContinuationIndenter::addTokenOCL

2022-02-22 Thread Björn Schäpers via cfe-commits

Author: Björn Schäpers
Date: 2022-02-22T22:08:02+01:00
New Revision: 7ebb00a22e7ec78a3090ecc15f59d247e0f390db

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

LOG: [clang-format][NFC] Simplify if in ContinuationIndenter::addTokenOCL

Setting a boolean within an if and only using it in the very next if is
a bit confusing. Merge it into one if.

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 62e0d01871e8d..69508c44dc436 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -784,14 +784,12 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState , bool DryRun,
 //   OuterFunction(InnerFunctionCall( // break
 //   ParameterToInnerFunction))   // break
 //   .SecondInnerFunctionCall();
-bool HasTrailingCall = false;
 if (Previous.MatchingParen) {
   const FormatToken *Next = Previous.MatchingParen->getNextNonComment();
-  HasTrailingCall = Next && Next->isMemberAccess();
+  if (Next && Next->isMemberAccess() && State.Stack.size() > 1 &&
+  State.Stack[State.Stack.size() - 2].CallContinuation == 0)
+CurrentState.LastSpace = State.Column;
 }
-if (HasTrailingCall && State.Stack.size() > 1 &&
-State.Stack[State.Stack.size() - 2].CallContinuation == 0)
-  CurrentState.LastSpace = State.Column;
   }
 }
 



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


[PATCH] D120352: [C++20][Modules] Rework testcase to use split file [NFC].

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains created this revision.
iains added reviewers: urnathan, ChuanqiXu.
iains published this revision for review.
iains added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

probably qualifies as trivial/obvious but in case anyone has any comments.


This switches the testcase committed for initial C++20 modules import tracking 
to
use split-file rather than preprocessor directives.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D120352

Files:
  clang/test/Modules/cxx20-import-diagnostics-a.cpp

Index: clang/test/Modules/cxx20-import-diagnostics-a.cpp
===
--- clang/test/Modules/cxx20-import-diagnostics-a.cpp
+++ clang/test/Modules/cxx20-import-diagnostics-a.cpp
@@ -1,42 +1,43 @@
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
+// RUN: split-file %s %t
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=0 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu1.cpp \
 // RUN:  -o %t/B.pcm
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=1 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu2.cpp \
 // RUN:  -o %t/C.pcm
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=2 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu3.cpp \
 // RUN:  -fmodule-file=%t/B.pcm -fmodule-file=%t/C.pcm -o %t/AOK1.pcm
 
-// RUN: %clang_cc1 -std=c++20 -S -D TU=3 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -S %t/import-diags-tu4.cpp \
 // RUN:  -fmodule-file=%t/AOK1.pcm -o %t/tu_3.s -verify
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=4 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu5.cpp \
 // RUN:  -fmodule-file=%t/B.pcm -fmodule-file=%t/C.pcm -o %t/BC.pcm -verify
 
-// RUN: %clang_cc1 -std=c++20 -S -D TU=5 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -S %t/import-diags-tu6.cpp \
 // RUN:  -fmodule-file=%t/B.pcm -fmodule-file=%t/C.pcm -o %t/tu_5.s -verify
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=6 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu7.cpp \
 // RUN:  -fmodule-file=%t/B.pcm -o %t/D.pcm -verify
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=7 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu8.cpp \
 // RUN:  -fmodule-file=%t/B.pcm -o %t/D.pcm -verify
 
-// RUN: %clang_cc1 -std=c++20 -S -D TU=8 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -S %t/import-diags-tu9.cpp \
 // RUN:  -fmodule-file=%t/B.pcm -o %t/tu_8.s -verify
 
-// RUN: %clang_cc1 -std=c++20 -emit-module-interface -D TU=9 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/import-diags-tu10.cpp \
 // RUN:  -o %t/B.pcm -verify
 
-// RUN: %clang_cc1 -std=c++20 -emit-obj -D TU=10 -x c++ %s \
+// RUN: %clang_cc1 -std=c++20 -emit-obj %t/import-diags-tu11.cpp \
 // RUN:  -fmodule-file=%t/C.pcm  -o %t/impl.o
 
 // Test diagnostics for incorrect module import sequences.
 
-#if TU == 0
+//--- import-diags-tu1.cpp
 
 export module B;
 
@@ -44,7 +45,7 @@
 
 // expected-no-diagnostics
 
-#elif TU == 1
+//--- import-diags-tu2.cpp
 
 export module C;
 
@@ -52,7 +53,7 @@
 
 // expected-no-diagnostics
 
-#elif TU == 2
+//--- import-diags-tu3.cpp
 
 export module AOK1;
 
@@ -63,7 +64,7 @@
 
 // expected-no-diagnostics
 
-#elif TU == 3
+//--- import-diags-tu4.cpp
 
 module;
 
@@ -73,7 +74,7 @@
 
 int theAnswer () { return 42; }
 
-#elif TU == 4
+//--- import-diags-tu5.cpp
 
 export module BC;
 
@@ -83,7 +84,7 @@
 
 import C; // expected-error {{imports must immediately follow the module declaration}}
 
-#elif TU == 5
+//--- import-diags-tu6.cpp
 
 module B; // implicitly imports B.
 
@@ -91,7 +92,7 @@
 
 import C; // expected-error {{imports must immediately follow the module declaration}}
 
-#elif TU == 6
+//--- import-diags-tu7.cpp
 
 module;
 // We can only have preprocessor commands here, which could include an include
@@ -103,7 +104,7 @@
 
 int delta ();
 
-#elif TU == 7
+//--- import-diags-tu8.cpp
 
 export module D;
 
@@ -113,19 +114,19 @@
 
 import B; // expected-error {{module imports cannot be in the private module fragment}}
 
-#elif TU == 8
+//--- import-diags-tu9.cpp
 
 module B;
 
 import B; // expected-error {{import of module 'B' appears within same top-level module 'B'}}
 
-#elif TU == 9
+//--- import-diags-tu10.cpp
 
 export module B;
 
 import B; // expected-error {{import of module 'B' appears within same top-level module 'B'}}
 
-#elif TU == 10
+//--- import-diags-tu11.cpp
 
 int x;
 
@@ -134,7 +135,3 @@
 int baz() { return 6174; }
 
 // expected-no-diagnostics
-
-#else
-#error "no MODE set"
-#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120309: [clang-format] Fix QualifierOrder breaking the code with requires clause.

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 410618.
curdeius added a comment.

Add a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120309

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -858,6 +858,21 @@
Style);
 }
 
+TEST_F(QualifierFixerTest, WithConstraints) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"constexpr", "type"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "constexpr constructor();",
+   Style);
+  verifyFormat("template \n"
+   "  requires Concept1 && Concept2\n"
+   "constexpr constructor();",
+   Style);
+}
+
 TEST_F(QualifierFixerTest, DisableRegions) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Custom;
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -328,14 +328,17 @@
   if (Next->is(tok::comment) && Next->getNextNonComment())
 Next = Next->getNextNonComment();
   assert(Next->MatchingParen && "Missing template closer");
-  Next = Next->MatchingParen->Next;
+  Next = Next->MatchingParen;
+  if (Next->ClosesRequiresClause)
+return Next;
+  Next = Next->Next;
 
   // Move to the end of any template class members e.g.
   // `Foo::iterator`.
   if (Next && Next->startsSequence(tok::coloncolon, tok::identifier))
 Next = Next->Next->Next;
   if (Next && Next->is(QualifierType)) {
-// Remove the const.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;
@@ -344,7 +347,7 @@
 if (Next && Next->Next &&
 Next->Next->isOneOf(tok::amp, tok::ampamp, tok::star)) {
   if (Next->is(QualifierType)) {
-// Remove the qualifier.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -858,6 +858,21 @@
Style);
 }
 
+TEST_F(QualifierFixerTest, WithConstraints) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"constexpr", "type"};
+
+  verifyFormat("template \n"
+   "  requires Concept\n"
+   "constexpr constructor();",
+   Style);
+  verifyFormat("template \n"
+   "  requires Concept1 && Concept2\n"
+   "constexpr constructor();",
+   Style);
+}
+
 TEST_F(QualifierFixerTest, DisableRegions) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Custom;
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -328,14 +328,17 @@
   if (Next->is(tok::comment) && Next->getNextNonComment())
 Next = Next->getNextNonComment();
   assert(Next->MatchingParen && "Missing template closer");
-  Next = Next->MatchingParen->Next;
+  Next = Next->MatchingParen;
+  if (Next->ClosesRequiresClause)
+return Next;
+  Next = Next->Next;
 
   // Move to the end of any template class members e.g.
   // `Foo::iterator`.
   if (Next && Next->startsSequence(tok::coloncolon, tok::identifier))
 Next = Next->Next->Next;
   if (Next && Next->is(QualifierType)) {
-// Remove the const.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;
@@ -344,7 +347,7 @@
 if (Next && Next->Next &&
 Next->Next->isOneOf(tok::amp, tok::ampamp, tok::star)) {
   if (Next->is(QualifierType)) {
-// Remove the qualifier.
+// Move the qualifier.
 insertQualifierBefore(SourceMgr, Fixes, Tok, Qualifier);
 removeToken(SourceMgr, Fixes, Next);
 return Next;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D120309: [clang-format] Fix QualifierOrder breaking the code with requires clause.

2022-02-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D120309#3338265 , 
@HazardyKnusperkeks wrote:

> Does it work with a more complex requires clause? Or were they unaffected 
> before? Like `Foo && Bar`?

They were unaffected but I'll add a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120309

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


[PATCH] D120334: [NFC][Lexer] Use more appropriate LangOptionsBase type for Lexer::LangOpts

2022-02-22 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D120334#3338314 , @yurai007 wrote:

> In D120334#3337961 , @jansvoboda11 
> wrote:
>
>> The performance implications are pretty interesting! Have you tried avoiding 
>> the copy altogether by just storing the reference?
>
> Yes, actually that was my first attempt but I failed miserably. 
> LangOpts::LineComment is mutated in Lexer so LangOpts cannot be simply 
> const&. Making it non-const reference is technically doable with some extra 
> adjustment for Lexer constructors.
> However I'm worried a bit how it would impact external LangOpts users after 
> mutating LineComment member by Lexer.  As long as LangOpts acts as simple 
> cache it's easy to reason about but when we start to share it with Lexer 
> callers I'm not longer sure. That's why eventually base class approach was 
> chosen.

Got it. It seems like getting rid of the `LineComment` mutation would be pretty 
straightforward though. I don't expect any big perf win by replacing copy of a 
handful of bitfields with indirection, but it would be interesting to see the 
experiment nonetheless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120334

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


[PATCH] D117355: [PowerPC] Fix the undef virtual register reading failure for PPC backend trap optimization

2022-02-22 Thread Victor Huang via Phabricator via cfe-commits
NeHuang added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117355

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


[PATCH] D120334: [NFC][Lexer] Use more appropriate LangOptionsBase type for Lexer::LangOpts

2022-02-22 Thread Dawid Jurczak via Phabricator via cfe-commits
yurai007 added a comment.

In D120334#3337961 , @jansvoboda11 
wrote:

> The performance implications are pretty interesting! Have you tried avoiding 
> the copy altogether by just storing the reference?

Yes, actually that was my first attempt but I failed miserably. 
LangOpts::LineComment is mutated in Lexer so LangOpts cannot be simply const&. 
Making it non-const reference is technically doable with some extra adjustment 
for Lexer constructors.
However I'm worried a bit how it would impact external LangOpts users after 
mutating LineComment member by Lexer.  As long as LangOpts acts as simple cache 
it's easy to reason about but when we start to share it with Lexer callers I'm 
not longer sure.
That's why eventually base class approach was chosen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120334

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


[PATCH] D119823: [Modules] Add module structure output to -module-file-info.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410599.
iains added a comment.

reformat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119823

Files:
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Modules/cxx20-module-file-info.cpp

Index: clang/test/Modules/cxx20-module-file-info.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-module-file-info.cpp
@@ -0,0 +1,64 @@
+// Test output from -module-file-info about C++20 modules.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu1.cpp \
+// RUN:  -o %t/A.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info %t/A.pcm | FileCheck \
+// RUN:  --check-prefix=CHECK-A %s
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu2.cpp \
+// RUN:  -o %t/B.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info %t/B.pcm | FileCheck \
+// RUN:  --check-prefix=CHECK-B %s
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu3.cpp \
+// RUN:  -fmodule-file=%t/A.pcm -fmodule-file=%t/B.pcm -o %t/Foo.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info %t/Foo.pcm | FileCheck \
+// RUN:  --check-prefix=CHECK-FOO %s
+
+// expected-no-diagnostics
+
+//--- mod-info-tu1.cpp
+export module A;
+
+void a();
+
+// CHECK-A: == C++20
+// CHECK-A-NEXT: Interface Unit 'A' is the Primary Module at index #1
+
+//--- mod-info-tu2.cpp
+export module B;
+
+void b();
+
+// CHECK-B: == C++20
+// CHECK-B-NEXT: Interface Unit 'B' is the Primary Module at index #1
+
+//--- mod-info-tu3.cpp
+module;
+
+export module Foo;
+
+import A;
+export import B;
+
+namespace hello {
+export void say(const char *);
+}
+
+void foo() {}
+
+// CHECK-FOO: == C++20
+// CHECK-FOO-NEXT:  Interface Unit 'Foo' is the Primary Module at index #3
+// CHECK-FOO-NEXT:   Sub Modules:
+// CHECK-FOO-NEXT:Global Module Fragment '' is at index #4
+// CHECK-FOO-NEXT:   Imports:
+// CHECK-FOO-NEXT:Interface Unit 'A' is at index #1
+// CHECK-FOO-NEXT:   Exports:
+// CHECK-FOO-NEXT:Interface Unit 'B' is at index #2
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -11,6 +11,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangStandard.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -24,6 +25,7 @@
 #include "clang/Sema/TemplateInstCallback.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
+#include "clang/Serialization/ModuleFile.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -806,7 +808,25 @@
   return true;
 }
 
+static StringRef ModuleKindName(Module::ModuleKind MK) {
+  switch (MK) {
+  case Module::ModuleMapModule:
+return "Module Map Module";
+  case Module::ModuleInterfaceUnit:
+return "Interface Unit";
+  case Module::ModulePartitionInterface:
+return "Partition Interface";
+  case Module::ModulePartitionImplementation:
+return "Partition Implementation";
+  case Module::GlobalModuleFragment:
+return "Global Module Fragment";
+  case Module::PrivateModuleFragment:
+return "Private Module Fragment";
+  }
+}
+
 void DumpModuleInfoAction::ExecuteAction() {
+  assert(isCurrentFileAST() && "dumping non-AST?");
   // Set up the output file.
   std::unique_ptr OutFile;
   StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
@@ -827,8 +847,87 @@
 
   Preprocessor  = getCompilerInstance().getPreprocessor();
   DumpModuleInfoListener Listener(Out);
-  HeaderSearchOptions  =
-  PP.getHeaderSearchInfo().getHeaderSearchOpts();
+  HeaderSearchOptions  = PP.getHeaderSearchInfo().getHeaderSearchOpts();
+
+  // The FrontendAction::BeginSourceFile () method loads the AST so that much
+  // of the information is already available and modules should have been
+  // loaded.
+
+  const LangOptions  = getCurrentASTUnit().getLangOpts();
+  if (LO.CPlusPlusModules && !LO.CurrentModule.empty()) {
+
+ASTReader *R = getCurrentASTUnit().getASTReader().get();
+unsigned SubModuleCount = R->getTotalNumSubmodules();
+serialization::ModuleFile  = R->getModuleManager().getPrimaryModule();
+Out << "  == C++20 Module structure ==\n";
+
+if (MF.ModuleName != LO.CurrentModule)
+  Out << "  Mismatched module names : " << MF.ModuleName << " and "
+  << LO.CurrentModule << "\n";
+
+struct SubModInfo {
+  unsigned Idx;
+  Module *Mod;
+  Module::ModuleKind Kind;
+  std::string 
+  bool Seen;
+};
+std::map SubModMap;
+auto 

[PATCH] D109239: Add support for floating-option `-ffp-eval-method` and for new `pragma clang fp eval-method`

2022-02-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 410597.

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

https://reviews.llvm.org/D109239

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/X86/32bit-behavior-no-eval.c
  clang/test/CodeGen/X86/32bit-behavior.c
  clang/test/CodeGen/X86/fp-eval-method.c
  clang/test/CodeGen/flt_eval_macro.cpp
  clang/test/CodeGen/fp-floatcontrol-pragma.cpp
  clang/test/Misc/warning-flags.c
  clang/test/Preprocessor/flt_eval_macro.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-arm.c
  clang/test/Preprocessor/init-mips.c
  clang/test/Preprocessor/init-ppc.c
  clang/test/Preprocessor/init-ppc64.c
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-v7k-compat.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c
  clang/test/Sema/fp-eval-pragma.cpp
  clang/test/Sema/x86-eval-method.c
  clang/test/Sema/x86_64-eval-method.c

Index: clang/test/Sema/x86_64-eval-method.c
===
--- /dev/null
+++ clang/test/Sema/x86_64-eval-method.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple x86_64-linux-gnu -target-feature -sse -emit-llvm \
+// RUN: -o - -verify=warn %s
+//
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify=no-warn %s
+
+// no-warn-no-diagnostics
+
+float add2(float a, float b, float c) {
+#pragma clang fp eval_method(source)
+  return a + b + c;
+} // warn-warning{{Setting the floating point evaluation method to `source` on a target without SSE is not supported.}}
Index: clang/test/Sema/x86-eval-method.c
===
--- /dev/null
+++ clang/test/Sema/x86-eval-method.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple i386-pc-windows -target-cpu pentium4 -target-feature -sse \
+// RUN: -emit-llvm -ffp-eval-method=source  -o - -verify=warn %s
+//
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple i386-pc-windows -target-cpu pentium4 \
+// RUN: -emit-llvm -ffp-eval-method=source  -o - -verify=no-warn %s
+
+// no-warn-no-diagnostics
+
+float add1(float a, float b, float c) {
+  return a + b + c;
+} // warn-warning{{Setting the floating point evaluation method to `source` on a target without SSE is not supported.}}
+
+float add2(float a, float b, float c) {
+#pragma clang fp eval_method(source)
+  return a + b + c;
+} // warn-warning{{Setting the floating point evaluation method to `source` on a target without SSE is not supported.}}
Index: clang/test/Sema/fp-eval-pragma.cpp
===
--- /dev/null
+++ clang/test/Sema/fp-eval-pragma.cpp
@@ -0,0 +1,87 @@
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s
+//
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \
+// RUN: -ffp-eval-method=source
+//
+// RUN: %clang_cc1 -fexperimental-strict-floating-point \
+// RUN: -triple x86_64-linux-gnu -emit-llvm -o - -verify %s \
+// RUN: -ffp-eval-method=double
+
+extern "C" int printf(const char *, ...);
+
+void foo1() {
+  printf("FP: %d\n", __FLT_EVAL_METHOD__);
+}
+
+void apply_pragma() {
+  // expected-note@+1{{#pragma entered here}}
+#pragma clang fp eval_method(double)
+  // expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
+  printf("FP: %d\n", __FLT_EVAL_METHOD__);
+}
+
+int foo2() {
+  apply_pragma();
+  return 0;
+}
+
+void foo() {
+  auto a = __FLT_EVAL_METHOD__;
+  {
+// expected-note@+1{{#pragma entered here}}
+#pragma clang fp eval_method(double)
+// expected-error@+1{{'__FLT_EVAL_METHOD__' cannot be expanded inside a scope containing '#pragma clang fp eval_method'}}
+auto b = __FLT_EVAL_METHOD__;
+  }
+  auto c = __FLT_EVAL_METHOD__;
+}
+
+void func() {
+  {
+{
+#pragma clang fp eval_method(source)
+}
+int i = 

[PATCH] D88425: Skip -fPIE for AMDGPU and HIP toolchain

2022-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D88425#3337003 , @MaskRay wrote:

> I plan to default CMake `CLANG_DEFAULT_PIE_ON_LINUX` to on in D120305 
>  and hip-fpie-option.hip will fail. Do you 
> mind investigating the issue?

You need the following change. It is due to the default PIE change for the host 
toolchain.

diff --git a/clang/test/Driver/hip-fpie-option.hip 
b/clang/test/Driver/hip-fpie-option.hip
index 2e296a099dea..d8a15ffbaa43 100644

- a/clang/test/Driver/hip-fpie-option.hip

+++ b/clang/test/Driver/hip-fpie-option.hip
@@ -5,11 +5,11 @@

// RUN: %clang -### -target x86_64-unknown-linux-gnu \
 // RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
-// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s

// RUN: %clang -### -target x86_64-unknown-linux-gnu \
 // RUN:   -fgpu-rdc --offload-arch=gfx906 %s -nogpulib -nogpuinc \
-// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-STATIC %s
+// RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s

// RUN: %clang -### -target x86_64-unknown-linux-gnu \
 // RUN:   --offload-arch=gfx906 %s -nogpulib -nogpuinc \
@@ -32,7 +32,6 @@
 // RUN:   2>&1 | FileCheck -check-prefixes=DEV,HOST-PIE %s

// DEV-DAG: {{".*clang.*".* "-triple" "amdgcn-amd-amdhsa".* 
"-mrelocation-model" "pic" "-pic-level" "[1|2]".* "-mframe-pointer=all"}}
-// HOST-STATIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "static"}}
 // HOST-PIC-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "pic" "-pic-level" "2"}}
 // HOST-PIC-NOT: "-pic-is-pie"
 // HOST-PIE-DAG: {{".*clang.*".* "-triple" "x86_64-unknown-linux-gnu".* 
"-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie"}}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88425

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D113319#3337680 <https://reviews.llvm.org/D113319#3337680>, @curdeius wrote:

> In D113319#3337612 <https://reviews.llvm.org/D113319#3337612>, @krasimir 
> wrote:
>
>> It appears that this causes a regression by adding a space in-between 
>> pointer dereferences `*p` -> `* p` in some cases, e.g. formatting this with 
>> llvm style:
>>
>>   // before
>>   void f() {
>> while (p < a && *p == 'a')
>>   p++;
>>   }
>>   // after
>>   void f() {
>> while (p < a && * p == 'a')
>>   p++;
>>   }
>
> `*` in `*p` is indeed annotated as a binary operator now:
>
>   
> clang-format-main-20220110-5ff916ab72b26e667bd5d2e4a762650ba479c781--style=file
>  --debug-only=format-token-annotator test.cpp
>   AnnotatedTokens(L=0):
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=while L=5 PPK=2 FakeLParens= 
> FakeRParens=0 II=0x2f4bf80a6a0 Text='while'
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=l_paren L=7 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text='('
>M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=identifier L=8 PPK=2 
> FakeLParens=10/5/ FakeRParens=0 II=0x2f4bf806fd8 Text='p'
>M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=50 Name=less L=10 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text='<'
>M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=50 Name=identifier L=12 PPK=2 
> FakeLParens= FakeRParens=1 II=0x2f4bf807008 Text='q'
>M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=45 Name=ampamp L=15 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text='&&'
>M=0 C=1 T=UnaryOperator S=1 F=0 B=0 BK=0 P=45 Name=star L=17 PPK=2 
> FakeLParens=0/ FakeRParens=0 II=0x0 Text='*'
>M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=100 Name=identifier L=18 PPK=2 
> FakeLParens= FakeRParens=2 II=0x2f4bf806fd8 Text='p'
>M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=19 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text=')'
>   
>   AnnotatedTokens(L=1):
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=semi L=1 PPK=2 FakeLParens= 
> FakeRParens=0 II=0x0 Text=';'
>   
>   AnnotatedTokens(L=0):
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=eof L=0 PPK=2 FakeLParens= 
> FakeRParens=0 II=0x0 Text=''
>   
>   while (p < q && *p)
> ;
>
> whereas it was (correctly) a unary operator:
>
>   clang-format-main-20220222-e0219872--style=file 
> --debug-only=format-token-annotator test.cpp
>   AnnotatedTokens(L=0):
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=while L=5 PPK=2 FakeLParens= 
> FakeRParens=0 II=0x23639666fa0 Text='while'
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=23 Name=l_paren L=7 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text='('
>M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=identifier L=8 PPK=2 
> FakeLParens=10/5/ FakeRParens=0 II=0x236396a30a0 Text='p'
>M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=50 Name=less L=10 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text='<'
>M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=50 Name=identifier L=12 PPK=2 
> FakeLParens= FakeRParens=1 II=0x236396a30d0 Text='q'
>M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=45 Name=ampamp L=15 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text='&&'
>M=0 C=1 T=BinaryOperator S=1 F=0 B=0 BK=0 P=45 Name=star L=17 PPK=2 
> FakeLParens=14/ FakeRParens=0 II=0x0 Text='*'
>M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=54 Name=identifier L=19 PPK=2 
> FakeLParens= FakeRParens=2 II=0x236396a30a0 Text='p'
>M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=43 Name=r_paren L=20 PPK=2 
> FakeLParens= FakeRParens=0 II=0x0 Text=')'
>   
>   AnnotatedTokens(L=1):
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=semi L=1 PPK=2 FakeLParens= 
> FakeRParens=0 II=0x0 Text=';'
>   
>   AnnotatedTokens(L=0):
>M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=eof L=0 PPK=2 FakeLParens= 
> FakeRParens=0 II=0x0 Text=''
>   
>   while (p < q && * p)
> ;

That means someone guesses this is a binary op and guesses wrong. I try to take 
a look at it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113319

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


[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-02-22 Thread Mario Sanchez Prada via Phabricator via cfe-commits
mariospr added a comment.

In D117238#3338205 , @aaron.ballman 
wrote:

> In D117238#3338092 , @erichkeane 
> wrote:
>
>> Hi Mario!  Thank you for inquiring!  As you may know, we disabled _BitInt 
>> this large since we couldn't handle division/modulus in the code generators. 
>>  There is an RFC currently underway (as of today, we have the patches to 
>> start supporting this in the backend!) here: 
>> https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329
>>
>> I'm hopeful that the answer here is 'in the near future'.  @mgehre-amd 
>> should be able to at least partially revert this patch once the library 
>> changes/llvm code generator changes make it in.
>
> I agree with what Erich is saying here. My intention is to increase back to 
> the LLVM maximum again once the IR we generate stops crashing LLVM. However, 
> there's likely to be performance issues with "very large" bit-precise integer 
> types until we've gone through the backend and optimized for those cases 
> (both compile time and runtime performance concerns), so we might want to 
> bump up to something lower than the theoretical max for a while still (though 
> hopefully usefully bigger than 128!).

Wow, this is some seriously quick response time, kudos for that!

Also, thanks a lot for the clarification: it's more clear to me now what the 
situation actually is, and I'm happy to see there's already an ongoing plan to 
get this fixed, even if it will take some time. It was not clear to me when I 
read this ticket the first time whether there was some active work going on 
already, so thanks a lot for the pointers, that makes things more clear.

Again, thanks a lot for your help, much appreciated! I'll keep an eye on this 
ticket and the RFC to be aware when things change.


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

https://reviews.llvm.org/D117238

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


[PATCH] D120309: [clang-format] Fix QualifierOrder breaking the code with requires clause.

2022-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Does it work with a more complex requires clause? Or were they unaffected 
before? Like `Foo && Bar`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120309

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


[PATCH] D120289: [clang][dataflow] Add SAT solver interface and implementation

2022-02-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D120289#3338244 , @sgatev wrote:

>> I wonder if it would make sense to have a SAT base class for the SMT API and 
>> reuse that here?
>
> I think that on a high level we can either 1) integrate the SMT API types 
> deeply into the dataflow framework and use that solver interface directly or 
> 2) have a layer that translates from the dataflow `BoolValue` types to the 
> SMT API types. At this point I'm not convinced that we should go for 1).

Could you elaborate on what would be the main disadvantage of using 1)? (The 
advantage would be that we could switch to Z3 any time.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120289

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


[PATCH] D119599: [clang-format] Add option to align compound assignments like `+=`

2022-02-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D119599#3336936 , @curdeius wrote:

> Nice job! Please let us a bit of time to review that.
> Also, I think it would be good to get a reviewer that knows well the yaml 
> parts. Or even split it to a separate revision.
> And this part needs tests too.

Yeah really thanks for doing this. But please split it up.




Comment at: clang/lib/Format/Format.cpp:1161
+  LLVMStyle.AlignConsecutiveAssignments = {
+  /*.Enabled=*/false, /*.AcrossEmptyLines=*/false,
+  /*.AcrossComments=*/false, /*.AlignCompound=*/false,

Without the .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119599

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


[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

2022-02-22 Thread Rainer Orth via Phabricator via cfe-commits
ro abandoned this revision.
ro added a comment.

Superceded by D119829  and D120048 
.  If absolutely necessary, D120059 
 could be revived if Illumos cannot implement 
`dlpi_tls_modid`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91605

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


[PATCH] D117090: [clang-tidy] Fix `readability-non-const-parameter` for parameter referenced by an lvalue

2022-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with some small nits, but can you also add a release note for the fix? (If 
there was a bug report for this issue, you should mention that report in the 
release note and close the bug out.)




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-non-const-parameter.cpp:292
+void lvalueReference(int *p) {
+  // CHECK-MESSAGES-NOT: warning:
+  int  = *p;

Please spell out enough of the warning you don't expect to see (in all of these 
cases) so that someone reading the code knows what you expect to miss.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117090

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


[PATCH] D120289: [clang][dataflow] Add SAT solver interface and implementation

2022-02-22 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev added a comment.

> Did you look into reusing existing SAT solvers like miniSAT? What was the 
> main reason for rolling our own instead of picking something up off the 
> shelves?

Mainly to provide a lightweight out-of-the-box alternative. The solver 
interface is simple so one should be able to roll out an implementation for 
their favorite solver with little effort. One concrete use case that I have in 
mind for this solver implementation is unit tests, but we've also used it 
successfully to analyze a large codebase.

> I wonder if it would make sense to have a SAT base class for the SMT API and 
> reuse that here?

I think that on a high level we can either 1) integrate the SMT API types 
deeply into the dataflow framework and use that solver interface directly or 2) 
have a layer that translates from the dataflow `BoolValue` types to the SMT API 
types. At this point I'm not convinced that we should go for 1). For 2) we can 
simply provide an adapter that implements the dataflow solver API using the SMT 
API. This way the dataflow framework can be used with SMT API-compatible 
solvers. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120289

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


[PATCH] D119829: [Driver] Support Solaris/amd64 GetTls

2022-02-22 Thread Rainer Orth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1fc966d2e41: [Driver] Support Solaris/amd64 GetTls 
(authored by ro).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119829

Files:
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld-sanitizer.c


Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- /dev/null
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -0,0 +1,51 @@
+/// General tests that the ld -z relax=transtls workaround is only applied
+/// on Solaris/amd64. Note that we use sysroot to make these tests
+/// independent of the host system.
+
+/// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// CHECK-LD-SPARC32-NOT: -zrelax=transtls
+
+/// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang -fsanitize=undefined --target=sparc-sun-solaris2.11 %s -### 
2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// CHECK-LD-SPARC32-NOT: -zrelax=transtls
+
+/// Check sparc-sun-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
+// CHECK-LD-SPARC64-NOT: -zrelax=transtls
+
+/// Check sparc-sun-solaris2.11, 64bit
+// RUN: %clang -m64 -fsanitize=undefined --target=sparc-sun-solaris2.11 %s 
-### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
+// CHECK-LD-SPARC64-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
+// CHECK-LD-X32-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang -fsanitize=undefined --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
+// CHECK-LD-X32-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X64 %s
+// CHECK-LD-X64-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 -fsanitize=undefined --target=i386-pc-solaris2.11 %s -### 
2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
+// CHECK-LD-X64-UBSAN: -zrelax=transtls
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -14,6 +14,8 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "clang/Driver/ToolChain.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -145,8 +147,18 @@
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
-if (NeedsSanitizerDeps)
+if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
+
+  // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
+  // However, ld -z relax=transtls is available since Solaris 11.2, but not
+  // in Illumos.
+  const SanitizerArgs  = getToolChain().getSanitizerArgs(Args);
+  if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
+  (SA.needsAsanRt() || SA.needsStatsRt() ||
+   (SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
+CmdArgs.push_back("-zrelax=transtls");
+}
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {


Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- /dev/null
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -0,0 +1,51 @@
+/// General tests that the ld -z relax=transtls workaround is only applied
+/// on Solaris/amd64. Note that we use sysroot to make these tests
+/// independent of the host system.
+
+/// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// 

[clang] b1fc966 - [Driver] Support Solaris/amd64 GetTls

2022-02-22 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2022-02-22T20:14:33+01:00
New Revision: b1fc966d2e4176e640cda52c7148f565e93bedd0

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

LOG: [Driver] Support Solaris/amd64 GetTls

This is the driver part of D91605 , a
workaround to allow direct calls to `__tls_get_addr` on Solaris/amd64.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

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

Added: 
clang/test/Driver/solaris-ld-sanitizer.c

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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 24f18b92dd66..2d40598bfc1c 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -14,6 +14,8 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
+#include "clang/Driver/ToolChain.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -145,8 +147,18 @@ void solaris::Linker::ConstructJob(Compilation , const 
JobAction ,
   CmdArgs.push_back("-lgcc");
   CmdArgs.push_back("-lm");
 }
-if (NeedsSanitizerDeps)
+if (NeedsSanitizerDeps) {
   linkSanitizerRuntimeDeps(getToolChain(), CmdArgs);
+
+  // Work around Solaris/amd64 ld bug when calling __tls_get_addr directly.
+  // However, ld -z relax=transtls is available since Solaris 11.2, but not
+  // in Illumos.
+  const SanitizerArgs  = getToolChain().getSanitizerArgs(Args);
+  if (getToolChain().getTriple().getArch() == llvm::Triple::x86_64 &&
+  (SA.needsAsanRt() || SA.needsStatsRt() ||
+   (SA.needsUbsanRt() && !SA.requiresMinimalRuntime(
+CmdArgs.push_back("-zrelax=transtls");
+}
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {

diff  --git a/clang/test/Driver/solaris-ld-sanitizer.c 
b/clang/test/Driver/solaris-ld-sanitizer.c
new file mode 100644
index ..caf01919d467
--- /dev/null
+++ b/clang/test/Driver/solaris-ld-sanitizer.c
@@ -0,0 +1,51 @@
+/// General tests that the ld -z relax=transtls workaround is only applied
+/// on Solaris/amd64. Note that we use sysroot to make these tests
+/// independent of the host system.
+
+/// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang --target=sparc-sun-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// CHECK-LD-SPARC32-NOT: -zrelax=transtls
+
+/// Check sparc-sun-solaris2.11, 32bit
+// RUN: %clang -fsanitize=undefined --target=sparc-sun-solaris2.11 %s -### 
2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
+// CHECK-LD-SPARC32-NOT: -zrelax=transtls
+
+/// Check sparc-sun-solaris2.11, 64bit
+// RUN: %clang -m64 --target=sparc-sun-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
+// CHECK-LD-SPARC64-NOT: -zrelax=transtls
+
+/// Check sparc-sun-solaris2.11, 64bit
+// RUN: %clang -m64 -fsanitize=undefined --target=sparc-sun-solaris2.11 %s 
-### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
+// CHECK-LD-SPARC64-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
+// CHECK-LD-X32-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 32bit
+// RUN: %clang -fsanitize=undefined --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
+// CHECK-LD-X32-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 --target=i386-pc-solaris2.11 %s -### 2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X64 %s
+// CHECK-LD-X64-NOT: -zrelax=transtls
+
+/// Check i386-pc-solaris2.11, 64bit
+// RUN: %clang -m64 -fsanitize=undefined --target=i386-pc-solaris2.11 %s -### 
2>&1 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
+// CHECK-LD-X64-UBSAN: -zrelax=transtls



___
cfe-commits mailing 

[PATCH] D120307: [X86] Add helper enum for ternary intrinsics

2022-02-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/avx512fintrin.h:5944
+  (__v16si)(__m512i)(A), (__v16si)(__m512i)(B), (__v16si)(__m512i)(C), 
\
+  (unsigned char)(imm), (__mmask16)-1))
+

Why do we need to change the type on `imm` here? The builtin takes an int, and 
the enum you created defaults to int. Is this so we truncate ~ to 8-bits?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120307

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


[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D117238#3338092 , @erichkeane 
wrote:

> In D117238#3338071 , @mariospr 
> wrote:
>
>> In D117238#3270125 , 
>> @aaron.ballman wrote:
>>
>>> Updated to allow targets to specify the max bitwidth. I was aware that the 
>>> x86 backend had issues with doing division on larger `_BitInt` objects, but 
>>> it turns out *all* backends fail to support `_BitInt(129)` or wider 
>>> division. Because division is a pretty common operation on numeric data 
>>> types, it seemed to be more user-friendly to specify that we only support 
>>> 128 bits or less. I tried to make it exceptionally clear that I consider 
>>> this to be a backend bug though -- we will support wider bit widths in the 
>>> future once backends have been fixed. These changes make that future path 
>>> easier to opt into.
>>
>> Hi! I know this question might be very hard to answer but even so I hope you 
>> don't mind me trying  ... do you know whether there is any estimation of 
>> when `_BitInt(N) / N > 128` will be supported once again in Clang? I'm not 
>> an expert at all on this topic (just registered here to comment!  ) but 
>> this hit us in a Chromium-based project which relied on `_BITINT(256)` now 
>> that Chromium 100 updated to Clang 15. And while we're already looking into 
>> alternative ways of dealing with is (e.g. maybe using Boost's 
>> `multiprecision` module), it would be very interesting if we could get a 
>> sense (if it's even possible) on how long we could expect the current 
>> situation to last.
>>
>> Again, I understand there might not be a clear answer for this at the moment 
>> but, since I'm no expert on the matter and I couldn't figure out myself the 
>> exact situation by reading this and other tickets in the tracker I thought, 
>> I thought I'd ask just in case.
>>
>> Thanks in advance regardless of the answer!
>> Mario
>
> Hi Mario!  Thank you for inquiring!  As you may know, we disabled _BitInt 
> this large since we couldn't handle division/modulus in the code generators.  
> There is an RFC currently underway (as of today, we have the patches to start 
> supporting this in the backend!) here: 
> https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329
>
> I'm hopeful that the answer here is 'in the near future'.  @mgehre-amd should 
> be able to at least partially revert this patch once the library changes/llvm 
> code generator changes make it in.

I agree with what Erich is saying here. My intention is to increase back to the 
LLVM maximum again once the IR we generate stops crashing LLVM. However, 
there's likely to be performance issues with "very large" bit-precise integer 
types until we've gone through the backend and optimized for those cases (both 
compile time and runtime performance concerns), so we might want to bump up to 
something lower than the theoretical max for a while still (though hopefully 
usefully bigger than 128!).


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

https://reviews.llvm.org/D117238

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


[PATCH] D120132: [HIP] Fix HIP include path

2022-02-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.cpp:531-532
+  DriverArgs.hasArg(options::OPT_nostdlibinc)) {
+CC1Args.push_back("-internal-isystem");
+CC1Args.push_back(HipIncludePath);
+  }

My impression, after reading the problem description, is that the actual issue 
is that we're using `-internal-isystem` for the HIP SDK includes , not that we 
add the include path to them.

Instead of trying to guess whether we happen to match some hardcoded path where 
we think the standard headers may live, I'd rather use `-I` or its internal 
equivalent, if we have it. Hardcoded paths *will* be wrong for someone. E.g. 
I'm pretty sure `/usr/anything` is not going to work on windows. Of for our 
internal builds.


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

https://reviews.llvm.org/D120132

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


[PATCH] D119479: [clang][extract-api] Add global record support

2022-02-22 Thread Zixu Wang via Phabricator via cfe-commits
zixuw added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119479

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


[PATCH] D120298: [HIP] Support `--default-stream`

2022-02-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/include/clang/Driver/Options.td:962
   NegFlag>;
+def default_stream_EQ : Joined<["--"], "default-stream=">,
+  HelpText<"Specify default stream. Valid values are 'legacy' and 
'per-thread'. The default value is 'legacy'. (HIP only)">,

tra wrote:
> Naming, as usual, is hard. :-)
> 
> Considering that the option tweaks codegen, it may be appropriate to use `-f` 
> prefix. 
> On the other hand, `--default-stream` is the option used by NVCC, so it may 
> be more familiar to the end users.
> The third option would be to use `--gpu-default-stream` or 
> `-fgpu-default-stream`.
> 
> I'm leaning towards `-fgpu-default-stream`.
> 
> WDYT?
Agree. -fgpu-default-stream fits clang better.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6906
+CmdArgs.push_back(
+Args.MakeArgString("-DHIP_API_PER_THREAD_DEFAULT_STREAM"));
+}

tra wrote:
> This should probably be done by the preprocessor itself where we define other 
> HIP/CUDA related environment variables. We may need to pass-through the 
> option itself to cc1 for that. I think clang would do that by default if we 
> were using `-f*default-stream`.
Right. Will do it in preprocessor.


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

https://reviews.llvm.org/D120298

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


[PATCH] D119128: [analyzer] Fix taint propagation by remembering to the location context

2022-02-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I'll re-land the whole stack tomorrow, by adding the asserts requirement for 
the tests to make the tests pass on all bots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119128

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


[PATCH] D120289: [clang][dataflow] Add SAT solver interface and implementation

2022-02-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Note that, there are already precedents for Clang using solver tech from LLVM. 
E.g., the clang static analyzer's Z3-based refutation support is using the SMT 
API in LLVM, and there are experiments integrating yet another solver with the 
SA: https://reviews.llvm.org/D110125


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120289

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


[PATCH] D120298: [HIP] Support `--default-stream`

2022-02-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:962
   NegFlag>;
+def default_stream_EQ : Joined<["--"], "default-stream=">,
+  HelpText<"Specify default stream. Valid values are 'legacy' and 
'per-thread'. The default value is 'legacy'. (HIP only)">,

Naming, as usual, is hard. :-)

Considering that the option tweaks codegen, it may be appropriate to use `-f` 
prefix. 
On the other hand, `--default-stream` is the option used by NVCC, so it may be 
more familiar to the end users.
The third option would be to use `--gpu-default-stream` or 
`-fgpu-default-stream`.

I'm leaning towards `-fgpu-default-stream`.

WDYT?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6906
+CmdArgs.push_back(
+Args.MakeArgString("-DHIP_API_PER_THREAD_DEFAULT_STREAM"));
+}

This should probably be done by the preprocessor itself where we define other 
HIP/CUDA related environment variables. We may need to pass-through the option 
itself to cc1 for that. I think clang would do that by default if we were using 
`-f*default-stream`.


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

https://reviews.llvm.org/D120298

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


[PATCH] D120289: [clang][dataflow] Add SAT solver interface and implementation

2022-02-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Hi!

Just a quick high level question. Did you look into reusing existing SAT 
solvers like miniSAT? What was the main reason for rolling our own instead of 
picking something up off the selves?

Also, LLVM already has a SMT API 
(https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/SMTAPI.h).
 I wonder if it would make sense to have a SAT base class for the SMT API and 
reuse that here? Specifically, because solvers could be useful for all of the 
frontends and also optimizations in the backends, it would be great to make 
sure everyone can benefit from these features. What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120289

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


[PATCH] D120149: [clang][dataflow] Add support for global storage values

2022-02-22 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 410580.
sgatev added a comment.

Address reviewers' comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120149

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2153,4 +2153,171 @@
   });
 }
 
+TEST_F(TransferTest, StaticIntSingleVarDecl) {
+  std::string Code = R"(
+void target() {
+  static int Foo;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const StorageLocation *FooLoc =
+Env.getStorageLocation(*FooDecl, SkipPast::None);
+ASSERT_TRUE(isa_and_nonnull(FooLoc));
+
+const Value *FooVal = Env.getValue(*FooLoc);
+EXPECT_TRUE(isa_and_nonnull(FooVal));
+  });
+}
+
+TEST_F(TransferTest, StaticIntGroupVarDecl) {
+  std::string Code = R"(
+void target() {
+  static int Foo, Bar;
+  (void)0;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const StorageLocation *FooLoc =
+Env.getStorageLocation(*FooDecl, SkipPast::None);
+ASSERT_TRUE(isa_and_nonnull(FooLoc));
+
+const StorageLocation *BarLoc =
+Env.getStorageLocation(*BarDecl, SkipPast::None);
+ASSERT_TRUE(isa_and_nonnull(BarLoc));
+
+const Value *FooVal = Env.getValue(*FooLoc);
+EXPECT_TRUE(isa_and_nonnull(FooVal));
+
+const Value *BarVal = Env.getValue(*BarLoc);
+EXPECT_TRUE(isa_and_nonnull(BarVal));
+
+EXPECT_NE(FooVal, BarVal);
+  });
+}
+
+TEST_F(TransferTest, GlobalIntVarDecl) {
+  std::string Code = R"(
+static int Foo;
+
+void target() {
+  int Bar = Foo;
+  int Baz = Foo;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
+ASSERT_THAT(BazDecl, NotNull());
+
+const Value *BarVal =
+cast(Env.getValue(*BarDecl, SkipPast::None));
+const Value *BazVal =
+cast(Env.getValue(*BazDecl, SkipPast::None));
+EXPECT_EQ(BarVal, BazVal);
+  });
+}
+
+TEST_F(TransferTest, StaticMemberIntVarDecl) {
+  std::string Code = R"(
+struct A {
+  static int Foo;
+};
+
+void target(A a) {
+  int Bar = a.Foo;
+  int Baz = a.Foo;
+  // [[p]]
+}
+  )";
+  runDataflow(Code,
+  [](llvm::ArrayRef<
+ std::pair>>
+ Results,
+ ASTContext ) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment  = Results[0].second.Env;
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
+ASSERT_THAT(BazDecl, NotNull());
+
+const Value *BarVal =
+cast(Env.getValue(*BarDecl, SkipPast::None));
+const Value *BazVal =
+cast(Env.getValue(*BazDecl, SkipPast::None));
+   

[PATCH] D120333: [NFC][Lexer] Make access to LangOpts more consistent

2022-02-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

This looks good to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120333

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


[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-02-22 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: mgehre-amd.
erichkeane added a comment.

In D117238#3338071 , @mariospr wrote:

> In D117238#3270125 , @aaron.ballman 
> wrote:
>
>> Updated to allow targets to specify the max bitwidth. I was aware that the 
>> x86 backend had issues with doing division on larger `_BitInt` objects, but 
>> it turns out *all* backends fail to support `_BitInt(129)` or wider 
>> division. Because division is a pretty common operation on numeric data 
>> types, it seemed to be more user-friendly to specify that we only support 
>> 128 bits or less. I tried to make it exceptionally clear that I consider 
>> this to be a backend bug though -- we will support wider bit widths in the 
>> future once backends have been fixed. These changes make that future path 
>> easier to opt into.
>
> Hi! I know this question might be very hard to answer but even so I hope you 
> don't mind me trying  ... do you know whether there is any estimation of 
> when `_BitInt(N) / N > 128` will be supported once again in Clang? I'm not an 
> expert at all on this topic (just registered here to comment!  ) but this 
> hit us in a Chromium-based project which relied on `_BITINT(256)` now that 
> Chromium 100 updated to Clang 15. And while we're already looking into 
> alternative ways of dealing with is (e.g. maybe using Boost's 
> `multiprecision` module), it would be very interesting if we could get a 
> sense (if it's even possible) on how long we could expect the current 
> situation to last.
>
> Again, I understand there might not be a clear answer for this at the moment 
> but, since I'm no expert on the matter and I couldn't figure out myself the 
> exact situation by reading this and other tickets in the tracker I thought, I 
> thought I'd ask just in case.
>
> Thanks in advance regardless of the answer!
> Mario

Hi Mario!  Thank you for inquiring!  As you may know, we disabled _BitInt this 
large since we couldn't handle division/modulus in the code generators.  There 
is an RFC currently underway (as of today, we have the patches to start 
supporting this in the backend!) here: 
https://discourse.llvm.org/t/rfc-add-support-for-division-of-large-bitint-builtins-selectiondag-globalisel-clang/60329

I'm hopeful that the answer here is 'in the near future'.  @mgehre-amd should 
be able to at least partially revert this patch once the library changes/llvm 
code generator changes make it in.


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

https://reviews.llvm.org/D117238

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


[PATCH] D119470: [clang-tidy] Don't check decltype return types in `readability-const-return-type`

2022-02-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D119470#3312223 , @Izaron wrote:

> I think we don't need to update the docs
> (https://clang.llvm.org/extra/clang-tidy/checks/readability-const-return-type.html)
> Because a user would expect this behaviour.
>
> //If this review is eventually approved, kindly please merge the commit on my 
> behalf =) As I don't have merge access. My name is `Evgeny Shulgin` and email 
> is `izaronpl...@gmail.com`. Sorry for inconvenience!//

You've submitted some quality patches already, would you be interested in 
obtaining commit privileges 
(https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)?




Comment at: 
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:56-58
+AST_MATCHER(QualType, isLocalConstQualified) {
+  return Node.isLocalConstQualified();
+}

I think we might as well hit all the local qualifiers instead of just `const`, 
WDYT? e.g., `volatile` et al via `hasLocalQualifiers()`



Comment at: 
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:103
+  // qualified, ignoring decltype types.
+  const auto NonLocalConstDecltypeType = qualType(
+  unless(isLocalConstQualified()), anyOf(decltypeType(), autoType()));

We don't usually use top-level const qualification for locals.



Comment at: 
clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp:104
+  const auto NonLocalConstDecltypeType = qualType(
+  unless(isLocalConstQualified()), anyOf(decltypeType(), autoType()));
   Finder->addMatcher(

How about a `TypeOfType`? (The GCC `typeof(foo)` extension)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119470

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


[PATCH] D117238: [C2x] Add BITINT_MAXWIDTH support

2022-02-22 Thread Mario Sanchez Prada via Phabricator via cfe-commits
mariospr added a comment.

In D117238#3270125 , @aaron.ballman 
wrote:

> Updated to allow targets to specify the max bitwidth. I was aware that the 
> x86 backend had issues with doing division on larger `_BitInt` objects, but 
> it turns out *all* backends fail to support `_BitInt(129)` or wider division. 
> Because division is a pretty common operation on numeric data types, it 
> seemed to be more user-friendly to specify that we only support 128 bits or 
> less. I tried to make it exceptionally clear that I consider this to be a 
> backend bug though -- we will support wider bit widths in the future once 
> backends have been fixed. These changes make that future path easier to opt 
> into.

Hi! I know this question might be very hard to answer but even so I hope you 
don't mind me trying  ... do you know whether there is any estimation of when 
`_BitInt(N) / N > 128` will be supported once again in Clang? I'm not an expert 
at all on this topic (just registered here to comment!  ) but this hit us in a 
Chromium-based project which relied on `_BITINT(256)` now that Chromium 100 
updated to Clang 15. And while we're already looking into alternative ways of 
dealing with is (e.g. maybe using Boost's `multiprecision` module), it would be 
very interesting if we could get a sense (if it's even possible) on how long we 
could expect the current situation to last.

Again, I understand there might not be a clear answer for this at the moment 
but, since I'm no expert on the matter and I couldn't figure out myself the 
exact situation by reading this and other tickets in the tracker I thought, I 
thought I'd ask just in case.

Thanks in advance regardless of the answer!
Mario


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

https://reviews.llvm.org/D117238

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


[PATCH] D120149: [clang][dataflow] Add support for global storage values

2022-02-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D120149#056 , @sgatev wrote:

> I think we should provide such functionality and it probably should also 
> apply to some of the pointer and reference values. Not sure what the default 
> should be, but having the ability to choose the level of soundness for 
> certain analyses is valuable so I think both options should be possible. We 
> don't have that implemented yet and I think it might be better to consider 
> this together with other improvements that we want to make such as lazy value 
> initialization. Would you be ok with deferring this for now? I noted it with 
> a FIXME in the code.

I think the default should be as sound as reasonably possible. If we don't do 
any invalidations, I'd like to see some sort of warning somewhere so early 
users are aware of the behavior. I'm not sure what is the best place to put the 
warning, maybe to the documentation of a class? With that warning in place, I 
think it is ok to commit this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120149

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


[clang] 16994a2 - Fix the Sphinx build after f8cedc642d9b85720cb7175ef25ddde90a3fbca2

2022-02-22 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-02-22T12:50:39-05:00
New Revision: 16994a2cfaac6305f49a02afc1218e5c33199ea4

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

LOG: Fix the Sphinx build after f8cedc642d9b85720cb7175ef25ddde90a3fbca2

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7e92224901d4..68a867409c16 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -60,7 +60,7 @@ Bug Fixes
   wrapping a ``nullptr`` when the ``CXXNewExpr`` did not have an array
   size expression. This was fixed and ``::getArraySize()`` will now always
   either return ``None`` or a ``llvm::Optional`` wrapping a valid ``Expr*``.
-  This fixes `Issue 53742`_.
+  This fixes `Issue 53742 
`_.
 
 Improvements to Clang's diagnostics
 ^^^
@@ -92,7 +92,7 @@ Attribute Changes in Clang
 
 - The ``overloadable`` attribute can now be written in all of the syntactic
   locations a declaration attribute may appear.
-  This fixes `Issue 53805`_.
+  This fixes `Issue 53805 
`_.
 
 Windows Support
 ---



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


[PATCH] D120271: [Clang] Add offload kind to embedded offload object

2022-02-22 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D120271#3338034 , @saiislam wrote:

> Will it be possible to use Bundle Entry ID format [1] for naming sections and 
> being sort of the the primary key to refer an offload object?
> The arch string following the triple will be just offload-arch (or march, or 
> mcpu) for others, but for amdgpu it may contain some more information.
>
> [1] https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id

It might also be useful for PTX, considering when we do LTO we need to know the 
target features (e.g. +ptx74). As long as it's a valid section name anything 
goes, especially as things get more complex like when we may want to embed both 
PTX and cubins, or maybe always embed bitcode for option JIT use. This change 
definitely brings us closer to what we had in the old offload bundler so we 
could unify that somewhat. That could be the topic of a future patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120271

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


[PATCH] D120271: [Clang] Add offload kind to embedded offload object

2022-02-22 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

Will it be possible to use Bundle Entry ID format [1] for naming sections and 
being sort of the the primary key to refer an offload object?
The arch string following the triple will be just offload-arch (or march, or 
mcpu) for others, but for amdgpu it may contain some more information.

[1] https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120271

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


[PATCH] D119823: [Modules] Add module structure output to -module-file-info.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

this now uses the split-file approach to the test case so that we have the test 
case self-contained, but avoid the use of preprocessor directives before the 
module lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119823

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


[PATCH] D119823: [Modules] Add module structure output to -module-file-info.

2022-02-22 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 410568.
iains added a comment.

rebased, amended testcases to use split-file, handle partition enumerations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119823

Files:
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Modules/cxx20-module-file-info.cpp

Index: clang/test/Modules/cxx20-module-file-info.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-module-file-info.cpp
@@ -0,0 +1,65 @@
+// Test output from -module-file-info about C++20 modules.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu1.cpp \
+// RUN:  -o %t/A.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info %t/A.pcm | FileCheck \
+// RUN:  --check-prefix=CHECK-A %s
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu2.cpp \
+// RUN:  -o %t/B.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info %t/B.pcm | FileCheck \
+// RUN:  --check-prefix=CHECK-B %s
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/mod-info-tu3.cpp \
+// RUN:  -fmodule-file=%t/A.pcm -fmodule-file=%t/B.pcm -o %t/Foo.pcm
+
+// RUN: %clang_cc1 -std=c++20 -module-file-info %t/Foo.pcm | FileCheck \
+// RUN:  --check-prefix=CHECK-FOO %s
+
+// expected-no-diagnostics
+
+//--- mod-info-tu1.cpp
+export module A;
+
+void a();
+
+// CHECK-A: == C++20
+// CHECK-A-NEXT: Interface Unit 'A' is the Primary Module at index #1
+
+//--- mod-info-tu2.cpp
+export module B;
+
+void b();
+
+// CHECK-B: == C++20
+// CHECK-B-NEXT: Interface Unit 'B' is the Primary Module at index #1
+
+//--- mod-info-tu3.cpp
+module;
+
+export module Foo;
+
+import A;
+export import B;
+
+namespace hello
+{
+ export void say (const char*);
+}
+
+void foo () {}
+
+// CHECK-FOO: == C++20
+// CHECK-FOO-NEXT:  Interface Unit 'Foo' is the Primary Module at index #3
+// CHECK-FOO-NEXT:   Sub Modules:
+// CHECK-FOO-NEXT:Global Module Fragment '' is at index #4
+// CHECK-FOO-NEXT:   Imports:
+// CHECK-FOO-NEXT:Interface Unit 'A' is at index #1
+// CHECK-FOO-NEXT:   Exports:
+// CHECK-FOO-NEXT:Interface Unit 'B' is at index #2
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -11,6 +11,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangStandard.h"
+#include "clang/Basic/Module.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/ASTConsumers.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -24,6 +25,7 @@
 #include "clang/Sema/TemplateInstCallback.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ASTWriter.h"
+#include "clang/Serialization/ModuleFile.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -806,7 +808,25 @@
   return true;
 }
 
+static StringRef ModuleKindName(Module::ModuleKind MK) {
+  switch (MK) {
+  case Module::ModuleMapModule:
+return "Module Map Module";
+  case Module::ModuleInterfaceUnit:
+return "Interface Unit";
+  case Module::ModulePartitionInterface:
+return "Partition Interface";
+  case Module::ModulePartitionImplementation:
+return "Partition Implementation";
+  case Module::GlobalModuleFragment:
+return "Global Module Fragment";
+  case Module::PrivateModuleFragment:
+return "Private Module Fragment";
+  }
+}
+
 void DumpModuleInfoAction::ExecuteAction() {
+  assert (isCurrentFileAST() && "dumping non-AST?");
   // Set up the output file.
   std::unique_ptr OutFile;
   StringRef OutputFileName = getCompilerInstance().getFrontendOpts().OutputFile;
@@ -827,8 +847,88 @@
 
   Preprocessor  = getCompilerInstance().getPreprocessor();
   DumpModuleInfoListener Listener(Out);
-  HeaderSearchOptions  =
-  PP.getHeaderSearchInfo().getHeaderSearchOpts();
+  HeaderSearchOptions  = PP.getHeaderSearchInfo().getHeaderSearchOpts();
+
+  // The FrontendAction::BeginSourceFile () method loads the AST so that much
+  // of the information is already available and modules should have been
+  // loaded.
+
+  const LangOptions  = getCurrentASTUnit().getLangOpts();
+  if (LO.CPlusPlusModules && !LO.CurrentModule.empty()) {
+
+ASTReader *R = getCurrentASTUnit().getASTReader().get();
+unsigned SubModuleCount = R->getTotalNumSubmodules();
+serialization::ModuleFile  = R->getModuleManager().getPrimaryModule();
+Out << "  == C++20 Module structure ==\n";
+
+if(MF.ModuleName != LO.CurrentModule)
+  Out << "  Mismatched module names : " << MF.ModuleName << " and "
+  << LO.CurrentModule << "\n";
+
+struct SubModInfo {
+  unsigned Idx;
+  Module *Mod;
+  Module::ModuleKind Kind;
+  

[PATCH] D120325: [analyzer] Don't crash if the analyzer-constraint is set to Z3, but llvm is not built with it

2022-02-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM.

Besides abusing the `-analyzer-constraints=z3` option we should really have 
some way displaying whether or not this clang was built w/o Z3.

I'm accepting this, given that you fix the conditional code segment.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:918-922
+#if !LLVM_WITH_Z3
+  if (Value == AnalysisConstraints::Z3ConstraintsModel) {
+Diags.Report(diag::err_analyzer_not_built_with_z3);
+  }
+#endif // LLVM_WITH_Z3

This define is produced by  the `llvm/include/llvm/Config/llvm-config.h.cmake` 
cmake configuration file.
> /* Define if we have z3 and want to build it */
> #cmakedefine LLVM_WITH_Z3 ${LLVM_WITH_Z3}

And according to the [[ 
https://cmake.org/cmake/help/latest/command/configure_file.html | cmake 
configure_file ]]
`#cmakedefine VAR ...` will be either defined or not defined.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120325

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


[PATCH] D120305: [Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON

2022-02-22 Thread Simon Atanasyan via Phabricator via cfe-commits
atanasyan added a comment.

In D120305#3337045 , @atanasyan wrote:

> In D120305#3337019 , @MaskRay wrote:
>
>> @atanasyan A few mips test/Driver tests will fail. Wonder if you have time 
>> making them more portable... Otherwise I'll just add `UNSUPPORTED: 
>> default-pie-on-linux` to them.
>>
>>   Failed Tests (6):
>> Clang :: Driver/hip-fpie-option.hip
>> Clang :: Driver/mips-cs.cpp
>> Clang :: Driver/mips-fsf.cpp
>> Clang :: Driver/mips-img-v2.cpp
>> Clang :: Driver/mips-img.cpp
>> Clang :: Driver/mips-mti-linux.c
>
> I will take a look at the tests. Probably `hip-fpie-option.hip` is unrelated 
> to MIPS?

Fixed MIPS tests at cedc23b 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120305

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


[clang] cedc23b - [MIPS] Add `-no-pie` option to the clang driver's tests depend on it

2022-02-22 Thread Simon Atanasyan via cfe-commits

Author: Simon Atanasyan
Date: 2022-02-22T20:24:21+03:00
New Revision: cedc23bc8612feea61c0a7d92ccaae1ce51520ce

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

LOG: [MIPS] Add `-no-pie` option to the clang driver's tests depend on it

Added: 


Modified: 
clang/test/Driver/mips-cs.cpp
clang/test/Driver/mips-fsf.cpp
clang/test/Driver/mips-img-v2.cpp
clang/test/Driver/mips-img.cpp
clang/test/Driver/mips-mti-linux.c

Removed: 




diff  --git a/clang/test/Driver/mips-cs.cpp b/clang/test/Driver/mips-cs.cpp
index 6ef4c5d4350cd..39f87d8fd8354 100644
--- a/clang/test/Driver/mips-cs.cpp
+++ b/clang/test/Driver/mips-cs.cpp
@@ -4,7 +4,7 @@
 //
 // = Big-endian, hard float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu \
+// RUN: --target=mips-linux-gnu -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-HF-32 %s
 // CHECK-BE-HF-32: "-internal-isystem"
@@ -32,7 +32,7 @@
 //
 // = Big-endian, hard float, uclibc
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -muclibc \
+// RUN: --target=mips-linux-gnu -muclibc -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-UC-HF-32 %s
 // CHECK-BE-UC-HF-32: "-internal-isystem"
@@ -61,7 +61,7 @@
 //
 // = Big-endian, hard float, mips16
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -mips16 \
+// RUN: --target=mips-linux-gnu -mips16 -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-HF-16 %s
 // CHECK-BE-HF-16: "-internal-isystem"
@@ -90,7 +90,7 @@
 //
 // = Big-endian, hard float, mmicromips
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -mmicromips \
+// RUN: --target=mips-linux-gnu -mmicromips -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-HF-MICRO %s
 // CHECK-BE-HF-MICRO: "-internal-isystem"
@@ -119,7 +119,7 @@
 //
 // = Big-endian, hard float, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -mnan=2008 \
+// RUN: --target=mips-linux-gnu -mnan=2008 -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-HF-NAN %s
 // CHECK-BE-HF-NAN: "-internal-isystem"
@@ -148,7 +148,7 @@
 //
 // = Big-endian, hard float, uclibc, nan2008
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -muclibc -mnan=2008 \
+// RUN: --target=mips-linux-gnu -muclibc -mnan=2008 -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-UC-HF-NAN %s
 // CHECK-BE-UC-HF-NAN: "-internal-isystem"
@@ -177,7 +177,7 @@
 //
 // = Big-endian, soft float
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -msoft-float \
+// RUN: --target=mips-linux-gnu -msoft-float -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-SF-32 %s
 // CHECK-BE-SF-32: "-internal-isystem"
@@ -206,7 +206,7 @@
 //
 // = Big-endian, soft float, uclibc
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -muclibc -msoft-float \
+// RUN: --target=mips-linux-gnu -muclibc -msoft-float -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-UC-SF-32 %s
 // CHECK-BE-UC-SF-32: "-internal-isystem"
@@ -235,7 +235,7 @@
 //
 // = Big-endian, soft float, mips16
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -msoft-float -mips16 \
+// RUN: --target=mips-linux-gnu -msoft-float -mips16 -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-SF-16 %s
 // CHECK-BE-SF-16: "-internal-isystem"
@@ -264,7 +264,7 @@
 //
 // = Big-endian, soft float, micromips
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=mips-linux-gnu -msoft-float -mmicromips \
+// RUN: --target=mips-linux-gnu -msoft-float -mmicromips -no-pie \
 // RUN: -stdlib=libstdc++ --gcc-toolchain=%S/Inputs/mips_cs_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-BE-SF-MICRO %s
 // CHECK-BE-SF-MICRO: "-internal-isystem"
@@ -293,7 +293,7 @@
 //
 // = Big-endian, hard 

[PATCH] D120066: [NFC] Fix debug-info-hotpatch.cpp failure due to downstream regex issue.

2022-02-22 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Seems to me there have been other cases where `.*` matching was greedier than 
expected, so this seems like the right fix.


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

https://reviews.llvm.org/D120066

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


  1   2   3   >