[clang] 452fbbd - [Driver] Use addOptInFlag. NFC

2022-08-13 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-08-13T00:51:04-07:00
New Revision: 452fbbda391815fef7874170fab6faa2bd4f7ae2

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

LOG: [Driver] Use addOptInFlag. NFC

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0356259be1642..69e6e63839093 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6270,9 +6270,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   Args.AddLastArg(CmdArgs, options::OPT_pthread);
 
-  if (Args.hasFlag(options::OPT_mspeculative_load_hardening,
-   options::OPT_mno_speculative_load_hardening, false))
-CmdArgs.push_back(Args.MakeArgString("-mspeculative-load-hardening"));
+  Args.addOptInFlag(CmdArgs, options::OPT_mspeculative_load_hardening,
+options::OPT_mno_speculative_load_hardening);
 
   RenderSSPOptions(D, TC, Args, CmdArgs, KernelOrKext);
   RenderSCPOptions(TC, Args, CmdArgs);
@@ -6280,10 +6279,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   Args.AddLastArg(CmdArgs, options::OPT_fswift_async_fp_EQ);
 
-  // Translate -mstackrealign
-  if (Args.hasFlag(options::OPT_mstackrealign, options::OPT_mno_stackrealign,
-   false))
-CmdArgs.push_back(Args.MakeArgString("-mstackrealign"));
+  Args.addOptInFlag(CmdArgs, options::OPT_mstackrealign,
+options::OPT_mno_stackrealign);
 
   if (Args.hasArg(options::OPT_mstack_alignment)) {
 StringRef alignment = Args.getLastArgValue(options::OPT_mstack_alignment);
@@ -6776,10 +6773,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.addOptInFlag(CmdArgs, options::OPT_fasm_blocks,
 options::OPT_fno_asm_blocks);
 
-  // -fgnu-inline-asm is default.
-  if (!Args.hasFlag(options::OPT_fgnu_inline_asm,
-options::OPT_fno_gnu_inline_asm, true))
-CmdArgs.push_back("-fno-gnu-inline-asm");
+  Args.addOptOutFlag(CmdArgs, options::OPT_fgnu_inline_asm,
+ options::OPT_fno_gnu_inline_asm);
 
   // Enable vectorization per default according to the optimization level
   // selected. For optimization levels that want vectorization we use the alias
@@ -6831,9 +6826,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   if (RewriteImports)
 CmdArgs.push_back("-frewrite-imports");
 
-  if (Args.hasFlag(options::OPT_fdirectives_only,
-   options::OPT_fno_directives_only, false))
-CmdArgs.push_back("-fdirectives-only");
+  Args.addOptInFlag(CmdArgs, options::OPT_fdirectives_only,
+options::OPT_fno_directives_only);
 
   // Enable rewrite includes if the user's asked for it or if we're generating
   // diagnostics.
@@ -7191,10 +7185,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 options::OPT_fno_keep_static_consts);
   Args.addOptInFlag(CmdArgs, options::OPT_fcomplete_member_pointers,
 options::OPT_fno_complete_member_pointers);
-
-  if (!Args.hasFlag(options::OPT_fcxx_static_destructors,
-options::OPT_fno_cxx_static_destructors, true))
-CmdArgs.push_back("-fno-c++-static-destructors");
+  Args.addOptOutFlag(CmdArgs, options::OPT_fcxx_static_destructors,
+ options::OPT_fno_cxx_static_destructors);
 
   addMachineOutlinerArgs(D, Args, CmdArgs, Triple, /*IsLTO=*/false);
 



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


[PATCH] D119296: KCFI sanitizer

2022-08-13 Thread Joao Moreira via Phabricator via cfe-commits
joaomoreira added inline comments.



Comment at: llvm/lib/Target/X86/X86AsmPrinter.cpp:121
+if (N == Value)
+  return ~Value;
+  }

samitolvanen wrote:
> joaomoreira wrote:
> > Can we use another constant blinding scheme, such as a Value++ or anything 
> > else? This way, we would prevent endbrs from being emitted in the indirect 
> > branch guards too.
> > 
> > Since we are using Value (prologue) and ~Value (caller/guard) for doing the 
> > checks, we also need to check if ~ENDBR was picked as a KCFIType, otherwise 
> > ENDBR will be emitted in the ibranch guards.
> > Can we use another constant blinding scheme, such as a Value++ or anything 
> > else? This way, we would prevent endbrs from being emitted in the indirect 
> > branch guards too.
> >
> > Since we are using Value (prologue) and ~Value (caller/guard) for doing the 
> > checks, we also need to check if ~ENDBR was picked as a KCFIType, otherwise 
> > ENDBR will be emitted in the ibranch guards.
> 
> I don't mind changing this to `Value + 1`, but that actually doesn't change 
> anything because we emit `-Value` in indirect call checks, not `~Value`. 
> Therefore, using `~Value` works equally well here.
> 
> Specifically, this code currently emits `~Value`in the preamble and 
> `-(~Value) == Value + 1` in the indirect call check. Switching to `Value + 1` 
> simply reverses the order; we'll emit `Value + 1` in the preamble and 
> `-(Value + 1) == ~Value` in the indirect call check.
> 
> However, you are right that we also need to avoid `-ENDBR` in this function. 
> I'll fix that and clarify the comment.
Oops, got confused with the operands, tks for clearing it up. Otherwise, 
changes LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D131780: [clang-tidy] Do not trigger cppcoreguidelines-avoid-const-or-ref-data-members on lambda captures

2022-08-13 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

In D131780#3719881 , @Eugene.Zelenko 
wrote:

> Please mention changes in Release Notes.

Thanks for the quick review, @Eugene.Zelenko !

This check was newly added a couple of days ago (as per the "New checks" 
section in the Release Notes). I thought the "Changes to exiting checks" 
section was only meant for checks already existing prior to the new release, to 
avoid adding excessive clutter to the documentation. New checks typically take 
a few iterations to polish when testing on larger projects.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131780

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

This is primarily a Clang change, so added some Clang reviewers. I will review 
shortly - thanks for taking this on!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131780: [clang-tidy] Do not trigger cppcoreguidelines-avoid-const-or-ref-data-members on lambda captures

2022-08-13 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 452391.
carlosgalvezp added a comment.

Test also capture by reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131780

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
@@ -167,3 +167,25 @@
 TemplatedConstRef t3{123};
 TemplatedRefRef t4{123};
 TemplatedRef t5{t1.t};
+
+// Lambdas capturing const or ref members should not trigger warnings
+void lambdas()
+{
+  int x1{123};
+  const int x2{123};
+  const int& x3{123};
+  int&& x4{123};
+  int& x5{x1};
+
+  auto v1 = [x1]{};
+  auto v2 = [x2]{};
+  auto v3 = [x3]{};
+  auto v4 = [x4]{};
+  auto v5 = [x5]{};
+
+  auto r1 = [&x1]{};
+  auto r2 = [&x2]{};
+  auto r3 = [&x3]{};
+  auto r4 = [&x4]{};
+  auto r5 = [&x5]{};
+}
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
@@ -15,12 +15,23 @@
 namespace clang {
 namespace tidy {
 namespace cppcoreguidelines {
+namespace {
+
+AST_MATCHER(FieldDecl, isMemberOfLambda) {
+  return Node.getParent()->isLambda();
+}
+
+} // namespace
 
 void AvoidConstOrRefDataMembersCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  fieldDecl(hasType(hasCanonicalType(referenceType(.bind("ref"), this);
-  Finder->addMatcher(
-  fieldDecl(hasType(qualType(isConstQualified(.bind("const"), this);
+  Finder->addMatcher(fieldDecl(unless(isMemberOfLambda()),
+   hasType(hasCanonicalType(referenceType(
+ .bind("ref"),
+ this);
+  Finder->addMatcher(fieldDecl(unless(isMemberOfLambda()),
+   hasType(qualType(isConstQualified(
+ .bind("const"),
+ this);
 }
 
 void AvoidConstOrRefDataMembersCheck::check(


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-const-or-ref-data-members.cpp
@@ -167,3 +167,25 @@
 TemplatedConstRef t3{123};
 TemplatedRefRef t4{123};
 TemplatedRef t5{t1.t};
+
+// Lambdas capturing const or ref members should not trigger warnings
+void lambdas()
+{
+  int x1{123};
+  const int x2{123};
+  const int& x3{123};
+  int&& x4{123};
+  int& x5{x1};
+
+  auto v1 = [x1]{};
+  auto v2 = [x2]{};
+  auto v3 = [x3]{};
+  auto v4 = [x4]{};
+  auto v5 = [x5]{};
+
+  auto r1 = [&x1]{};
+  auto r2 = [&x2]{};
+  auto r3 = [&x3]{};
+  auto r4 = [&x4]{};
+  auto r5 = [&x5]{};
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
@@ -15,12 +15,23 @@
 namespace clang {
 namespace tidy {
 namespace cppcoreguidelines {
+namespace {
+
+AST_MATCHER(FieldDecl, isMemberOfLambda) {
+  return Node.getParent()->isLambda();
+}
+
+} // namespace
 
 void AvoidConstOrRefDataMembersCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(
-  fieldDecl(hasType(hasCanonicalType(referenceType(.bind("ref"), this);
-  Finder->addMatcher(
-  fieldDecl(hasType(qualType(isConstQualified(.bind("const"), this);
+  Finder->addMatcher(fieldDecl(unless(isMemberOfLambda()),
+   hasType(hasCanonicalType(referenceType(
+ .bind("ref"),
+ this);
+  Finder->addMatcher(fieldDecl(unless(isMemberOfLambda()),
+   hasType(qualType(isConstQualified(
+ .bind("const"),
+ this);
 }
 
 void AvoidConstOrRefDataMembersCheck::check(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thanks, mostly makes sense! https://github.com/llvm/llvm-project/issues/57033 
mentions `-O{n}` as well :) Could you fix that too? More comments inline.

CI is still failing :( Are you able to re-produce that? (I'm traveling atm, so 
can't check).




Comment at: clang/include/clang/Driver/Options.td:2798-2799
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Syntax-check only">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;

Note that:

```
$ gcc --help=common | grep syntax
  -fsyntax-only   Check for syntax errors, then stop.
```

and (from Clang [[ 
https://github.com/llvm/llvm-project/blob/main/clang/docs/CommandGuide/clang.rst
 | docs ]]
>  Run the preprocessor, parser and type checking stages.

For consistency sake, I would replace "Syntax-check only"" with "Run the 
preprocessor, parser and type checking stages.". Technically, there's no 
separate preprocessor in Flang, but that's IMO tangential to this.



Comment at: clang/include/clang/Driver/Options.td:3213-3214
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
-def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
-FlangOption]>, HelpText<"Display available options">,
+def help : Flag<["-", "--"], "help">, 
Flags<[CC1Option,CC1AsOption,FC1Option,FlangOption]>,
+  HelpText<"Display available options">,
 MarshallingInfoFlag>;

Unrelated change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof updated this revision to Diff 452393.
alexiprof added a comment.

fix tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -42,6 +42,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.
+! HELP-NEXT: -fsyntax-only  Syntax-check only
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of 
include search paths
@@ -119,6 +120,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E 
mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! HELP-FC1-NEXT: -fsyntax-only  Syntax-check only
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -init-only Only execute frontend initialization
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -44,6 +44,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! CHECK-NEXT: -fsyntax-only  Syntax-check only
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of 
include search paths
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2795,7 +2795,8 @@
 def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption, 
CoreOption]>,
   Group, HelpText<"Only run the driver.">;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Syntax-check only">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;
 def ftemplate_depth_EQ : Joined<["-"], "ftemplate-depth=">, Group;
 def ftemplate_depth_ : Joined<["-"], "ftemplate-depth-">, Group;
@@ -3209,8 +3210,8 @@
 Flags<[NoXarchOption]>,
 HelpText<"Restore the default behavior of not embedding source text in 
DWARF debug sections">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
-def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
-FlangOption]>, HelpText<"Display available options">,
+def help : Flag<["-", "--"], "help">, 
Flags<[CC1Option,CC1AsOption,FC1Option,FlangOption]>,
+  HelpText<"Display available options">,
 MarshallingInfoFlag>;
 def ibuiltininc : Flag<["-"], "ibuiltininc">,
   HelpText<"Enable builtin #include directories even when -nostdinc is used "
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -4130,6 +4130,7 @@
   behavior. See user manual for available checks
   -fsplit-lto-unitEnables splitting of the LTO unit.
   -fstandalone-debug  Emit full debug info for all types used by the 
program
+  -fsyntax-only   Syntax-check only
   -fwhole-program-vtables Enables whole-program vtable optimization. 
Requires -flto
   -gcodeview-ghashEmit type record hashes in a .debug$H section
   -gcodeview  Generate CodeView debug information
Index: clang/docs/ClangCommandLineReference.rst
===
--- clang/docs/ClangCommandLineReference.rst
+++ clang/docs/ClangCommandLineReference.rst
@@ -831,6 +831,8 @@
 
 .. option:: -fsyntax-only
 
+Syntax-check only
+
 .. option:: -module-file-info
 
 Provide information about a particular module file


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/dri

[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof added a comment.

In D131808#3720910 , @awarzynski 
wrote:

> Thanks, mostly makes sense! https://github.com/llvm/llvm-project/issues/57033 
> mentions `-O{n}` as well :) Could you fix that too? More comments inline.
>
> CI is still failing :( Are you able to re-produce that? (I'm traveling atm, 
> so can't check).

@awarzynski thanks for the feedback
Yes, if is valid phrase for flang and clang "Run the preprocessor, parser and 
type checking stages", I'll put it on.

in `gcc` optimization level displayed:

  -O  Set optimization level to .

I can add this to the list, but I think it's better to make it a separate patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof updated this revision to Diff 452405.
alexiprof added a comment.

Set new text hint for option fsyntax-only


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -42,6 +42,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.
+! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of 
include search paths
@@ -119,6 +120,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E 
mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -init-only Only execute frontend initialization
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -44,6 +44,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of 
include search paths
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2795,7 +2795,8 @@
 def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption, 
CoreOption]>,
   Group, HelpText<"Only run the driver.">;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Run the preprocessor, parser and type checking stages">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;
 def ftemplate_depth_EQ : Joined<["-"], "ftemplate-depth=">, Group;
 def ftemplate_depth_ : Joined<["-"], "ftemplate-depth-">, Group;
@@ -3209,8 +3210,8 @@
 Flags<[NoXarchOption]>,
 HelpText<"Restore the default behavior of not embedding source text in 
DWARF debug sections">;
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
-def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
-FlangOption]>, HelpText<"Display available options">,
+def help : Flag<["-", "--"], "help">, 
Flags<[CC1Option,CC1AsOption,FC1Option,FlangOption]>,
+  HelpText<"Display available options">,
 MarshallingInfoFlag>;
 def ibuiltininc : Flag<["-"], "ibuiltininc">,
   HelpText<"Enable builtin #include directories even when -nostdinc is used "
@@ -6613,7 +6614,7 @@
 def _SLASH_Zp_flag : CLFlag<"Zp">,
   HelpText<"Set default maximum struct packing alignment to 1">,
   Alias, AliasArgs<["1"]>;
-def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">,
+def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Run the preprocessor, parser and type 
checking stages">,
   Alias;
 def _SLASH_openmp_ : CLFlag<"openmp-">,
   HelpText<"Disable OpenMP support">, Alias;
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3999,7 +3999,7 @@
   /Zl Don't mention any default libraries in the 
object file
   /Zp Set the default maximum struct packing alignment 
to 1
   /Zp  Specify the default maximum struct packing 
alignment
-  /Zs Syntax-check only
+  /Zs Run the preprocessor, parser and type checking 
stages
 
 OPTIONS:
   -###   

[PATCH] D128133: [Driver] Support linking to compiler-rt for target AVR

2022-08-13 Thread Ayke via Phabricator via cfe-commits
aykevl accepted this revision.
aykevl added a comment.
This revision is now accepted and ready to land.

Looks good to me!




Comment at: clang/lib/Driver/ToolChains/AVR.cpp:539
+// Link to compiler-rt. We directly put the libclang.builtins.a
+// as input file, other than '-lclang.builtins'.
+if (RtLib == ToolChain::RLT_CompilerRT) {

Suggestion for the second sentence:

> We directly use libclang.builtins.a as input file, instead of using 
> '-lclang.builtins'.


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

https://reviews.llvm.org/D128133

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2798-2799
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Syntax-check only">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;

awarzynski wrote:
> Note that:
> 
> ```
> $ gcc --help=common | grep syntax
>   -fsyntax-only   Check for syntax errors, then stop.
> ```
> 
> and (from Clang [[ 
> https://github.com/llvm/llvm-project/blob/main/clang/docs/CommandGuide/clang.rst
>  | docs ]]
> >  Run the preprocessor, parser and type checking stages.
> 
> For consistency sake, I would replace "Syntax-check only"" with "Run the 
> preprocessor, parser and type checking stages.". Technically, there's no 
> separate preprocessor in Flang, but that's IMO tangential to this.
Yes, i am replace text



Comment at: clang/include/clang/Driver/Options.td:3213-3214
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
-def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
-FlangOption]>, HelpText<"Display available options">,
+def help : Flag<["-", "--"], "help">, 
Flags<[CC1Option,CC1AsOption,FC1Option,FlangOption]>,
+  HelpText<"Display available options">,
 MarshallingInfoFlag>;

awarzynski wrote:
> Unrelated change?
yes, mini fix format.
If it bothers you, I can remove it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131088: [clang] Apply FixIts to members declared via `using` in derived classes

2022-08-13 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin updated this revision to Diff 452408.
denis-fatkulin added a comment.

Patch is updated with context


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131088

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/member-access.cpp


Index: clang/test/CodeCompletion/member-access.cpp
===
--- clang/test/CodeCompletion/member-access.cpp
+++ clang/test/CodeCompletion/member-access.cpp
@@ -311,3 +311,25 @@
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:310:19 %s -o - | 
FileCheck -check-prefix=CHECK-MEMBERS-FROM-BASE-DEPENDENT %s
   // CHECK-MEMBERS-FROM-BASE-DEPENDENT: [#Base4#]base4
 }
+
+namespace members_using_fixits {
+  struct Bar {
+void method();
+int field;
+  };
+  struct Baz: Bar {
+using Bar::method;
+using Bar::field;
+  };
+  void testMethod(Baz* ptr) {
+ptr.m
+  }
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:325:10 %s -o - | FileCheck 
-check-prefix=CHECK-METHOD-DECLARED-VIA-USING %s
+  // CHECK-METHOD-DECLARED-VIA-USING: [#void#]method() (requires fix-it: 
{325:8-325:9} to "->")
+
+  void testField(Baz* ptr) {
+ptr.f
+  }
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits 
-code-completion-at=%s:331:10 %s -o - | FileCheck 
-check-prefix=CHECK-FIELD-DECLARED-VIA-USING %s
+  // CHECK-FIELD-DECLARED-VIA-USING: [#int#]field (requires fix-it: 
{331:8-331:9} to "->")
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1273,7 +1273,8 @@
 getBasePriority(Using->getTargetDecl()),
 R.Qualifier, false,
 (R.Availability == CXAvailability_Available ||
- R.Availability == CXAvailability_Deprecated));
+ R.Availability == CXAvailability_Deprecated),
+std::move(R.FixIts));
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;


Index: clang/test/CodeCompletion/member-access.cpp
===
--- clang/test/CodeCompletion/member-access.cpp
+++ clang/test/CodeCompletion/member-access.cpp
@@ -311,3 +311,25 @@
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:310:19 %s -o - | FileCheck -check-prefix=CHECK-MEMBERS-FROM-BASE-DEPENDENT %s
   // CHECK-MEMBERS-FROM-BASE-DEPENDENT: [#Base4#]base4
 }
+
+namespace members_using_fixits {
+  struct Bar {
+void method();
+int field;
+  };
+  struct Baz: Bar {
+using Bar::method;
+using Bar::field;
+  };
+  void testMethod(Baz* ptr) {
+ptr.m
+  }
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:325:10 %s -o - | FileCheck -check-prefix=CHECK-METHOD-DECLARED-VIA-USING %s
+  // CHECK-METHOD-DECLARED-VIA-USING: [#void#]method() (requires fix-it: {325:8-325:9} to "->")
+
+  void testField(Baz* ptr) {
+ptr.f
+  }
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-with-fixits -code-completion-at=%s:331:10 %s -o - | FileCheck -check-prefix=CHECK-FIELD-DECLARED-VIA-USING %s
+  // CHECK-FIELD-DECLARED-VIA-USING: [#int#]field (requires fix-it: {331:8-331:9} to "->")
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1273,7 +1273,8 @@
 getBasePriority(Using->getTargetDecl()),
 R.Qualifier, false,
 (R.Availability == CXAvailability_Available ||
- R.Availability == CXAvailability_Deprecated));
+ R.Availability == CXAvailability_Deprecated),
+std::move(R.FixIts));
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131091: [clang][index] Index unresolved member expression as reference

2022-08-13 Thread Denis Fatkulin via Phabricator via cfe-commits
denis-fatkulin added a comment.

@hokein, could you please also merge my pacth to code base? I haven't such 
permissions yet.
My git user name and address: Denis Fatkulin (fatkulin.de...@huawei.com)

Thank you for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131091

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


[PATCH] D128133: [Driver] Support linking to compiler-rt for target AVR

2022-08-13 Thread Ben Shi via Phabricator via cfe-commits
benshi001 marked an inline comment as done.
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:539
+// Link to compiler-rt. We directly put the libclang.builtins.a
+// as input file, other than '-lclang.builtins'.
+if (RtLib == ToolChain::RLT_CompilerRT) {

aykevl wrote:
> Suggestion for the second sentence:
> 
> > We directly use libclang.builtins.a as input file, instead of using 
> > '-lclang.builtins'.
I will change the comments in my commit. Thanks !


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

https://reviews.llvm.org/D128133

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


[clang] 44a647d - [Driver] Support linking to compiler-rt for target AVR

2022-08-13 Thread Ben Shi via cfe-commits

Author: Ben Shi
Date: 2022-08-13T20:40:21+08:00
New Revision: 44a647d21d946f8cc3eb7c1fea33311cf778f303

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

LOG: [Driver] Support linking to compiler-rt for target AVR

Reviewed By: aykevl

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

Added: 

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/avr/libclang_rt.builtins.a

Modified: 
clang/lib/Driver/ToolChains/AVR.cpp
clang/lib/Driver/ToolChains/AVR.h
clang/test/Driver/avr-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 89d408823270a..35faa6d2199a5 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -19,6 +19,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -369,8 +370,7 @@ AVRToolChain::AVRToolChain(const Driver &D, const 
llvm::Triple &Triple,
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
-  std::string CPU = getCPUName(D, Args, Triple);
-  if (CPU.empty())
+  if (getCPUName(D, Args, Triple).empty())
 D.Diag(diag::warn_drv_avr_mcu_not_specified);
 
   // Only add default libraries if the user hasn't explicitly opted out.
@@ -418,6 +418,23 @@ Tool *AVRToolChain::buildLinker() const {
   return new tools::AVR::Linker(getTriple(), *this);
 }
 
+std::string
+AVRToolChain::getCompilerRT(const llvm::opt::ArgList &Args, StringRef 
Component,
+FileType Type = ToolChain::FT_Static) const {
+  assert(Type == ToolChain::FT_Static && "AVR only supports static libraries");
+  // Since AVR can never be a host environment, its compiler-rt library files
+  // should always have ".a" suffix, even on windows.
+  SmallString<32> File("/libclang_rt.");
+  File += Component.str();
+  File += ".a";
+  // Return the default compiler-rt path appended with
+  // "avr/libclang_rt.$COMPONENT.a".
+  SmallString<256> Path(ToolChain::getCompilerRTPath());
+  llvm::sys::path::append(Path, "avr");
+  llvm::sys::path::append(Path, File.str());
+  return std::string(Path.str());
+}
+
 void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs, const ArgList 
&Args,
@@ -448,6 +465,12 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
+  // Currently we only support libgcc and compiler-rt.
+  auto RtLib = TC.GetRuntimeLibType(Args);
+  assert(
+  (RtLib == ToolChain::RLT_Libgcc || RtLib == ToolChain::RLT_CompilerRT) &&
+  "unknown runtime library");
+
   // Only add default libraries if the user hasn't explicitly opted out.
   bool LinkStdlib = false;
   if (!Args.hasArg(options::OPT_nostdlib) &&
@@ -463,10 +486,12 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 D.Diag(diag::warn_drv_avr_libc_not_found);
   } else {
 std::string SubPath = GetMCUSubPath(CPU);
+// Add path of avr-libc.
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-L") + *AVRLibcRoot + "/lib/" + 
SubPath));
-CmdArgs.push_back(
-Args.MakeArgString("-L" + TC.getGCCInstallPath() + "/" + SubPath));
+if (RtLib == ToolChain::RLT_Libgcc)
+  CmdArgs.push_back(Args.MakeArgString("-L" + TC.getGCCInstallPath() +
+   "/" + SubPath));
 LinkStdlib = true;
   }
 }
@@ -495,14 +520,29 @@ void AVR::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 std::string CrtFileName = std::string("-l:crt") + CPU + std::string(".o");
 CmdArgs.push_back(Args.MakeArgString(CrtFileName));
 
-CmdArgs.push_back("-lgcc");
+// Link to libgcc.
+if (RtLib == ToolChain::RLT_Libgcc)
+  CmdArgs.push_back("-lgcc");
+
+// Link to generic libraries of avr-libc.
 CmdArgs.push_back("-lm");
 CmdArgs.push_back("-lc");
 
 // Add the link library specific to the MCU.
 CmdArgs.push_back(Args.MakeArgString(std::string("-l") + CPU));
 
+// Add the relocatable inputs.
 AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+
+// We directly use libclang_rt.builtins.a as input file, instead of using
+// '-lclang_rt.builtins'.
+if (RtLib == ToolChain::RLT_CompilerRT) {
+  std::string RtLib =
+  getToolChain().getCompilerRT(Args, "builtins", ToolChain::FT_Static);
+  if (llvm::sys::fs::exists(RtLib))
+CmdA

[PATCH] D128133: [Driver] Support linking to compiler-rt for target AVR

2022-08-13 Thread Ben Shi 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 rG44a647d21d94: [Driver] Support linking to compiler-rt for 
target AVR (authored by benshi001).

Changed prior to commit:
  https://reviews.llvm.org/D128133?vs=438238&id=452416#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128133

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/avr/libclang_rt.builtins.a
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -72,3 +72,17 @@
 // RUN: %clang -### --target=avr --sysroot=%S/Inputs/basic_avr_tree -mmcu=atmega328 %s -fuse-ld=%S/Inputs/basic_avr_tree/usr/bin/ld.lld -T avr.lds 2>&1 | FileCheck --check-prefix=LDS1 %s
 // LDS1: "-T" "avr.lds"
 // LDS1-NOT: "-mavr5"
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// LIBGCC: "-lgcc"
+// LIBGCC-NOT: libclang_rt
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// COMRT: avr/libclang_rt.builtins.a
+// COMRT-NOT: "-lgcc"
+
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=NOMCU %s
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=NOMCU %s
+// NOMCU-NOT: libclang_rt
+// NOMCU-NOT: "-lgcc"
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -33,6 +33,8 @@
 
   llvm::Optional findAVRLibcInstallation() const;
   StringRef getGCCInstallPath() const { return GCCInstallPath; }
+  std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
+FileType Type) const override;
 
 protected:
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -19,6 +19,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -369,8 +370,7 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
-  std::string CPU = getCPUName(D, Args, Triple);
-  if (CPU.empty())
+  if (getCPUName(D, Args, Triple).empty())
 D.Diag(diag::warn_drv_avr_mcu_not_specified);
 
   // Only add default libraries if the user hasn't explicitly opted out.
@@ -418,6 +418,23 @@
   return new tools::AVR::Linker(getTriple(), *this);
 }
 
+std::string
+AVRToolChain::getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
+FileType Type = ToolChain::FT_Static) const {
+  assert(Type == ToolChain::FT_Static && "AVR only supports static libraries");
+  // Since AVR can never be a host environment, its compiler-rt library files
+  // should always have ".a" suffix, even on windows.
+  SmallString<32> File("/libclang_rt.");
+  File += Component.str();
+  File += ".a";
+  // Return the default compiler-rt path appended with
+  // "avr/libclang_rt.$COMPONENT.a".
+  SmallString<256> Path(ToolChain::getCompilerRTPath());
+  llvm::sys::path::append(Path, "avr");
+  llvm::sys::path::append(Path, File.str());
+  return std::string(Path.str());
+}
+
 void AVR::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs, const ArgList &Args,
@@ -448,6 +465,12 @@
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   getToolChain().AddFilePathLibArgs(Args, CmdArgs);
 
+  // Currently we only support libgcc and compiler-rt.
+  auto RtLib = TC.GetRuntimeLibType(Args);
+  assert(
+  (RtLib == ToolChain::RLT_Libgcc || RtLib == ToolChain::RLT_CompilerRT) &&
+  "unknown runtime library");
+
   // Only add default libraries if the user 

[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

2022-08-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13069
-  // therefore don't strictly fit into a signed bitfield of width 1.
-  if (FieldWidth == 1 && Value == 1)
-return false;

aaron.ballman wrote:
> ShawnZhong wrote:
> > ShawnZhong wrote:
> > > ShawnZhong wrote:
> > > > aaron.ballman wrote:
> > > > > thakis wrote:
> > > > > > This was to suppress false positives. All instances we've seen of 
> > > > > > this are in fact false positives.
> > > > > > 
> > > > > > Was there any analysis on true / false positives for this change?
> > > > > > 
> > > > > > At least for our code, this seems to make the warning strictly 
> > > > > > worse.
> > > > > I've not performed any such analysis, but it would be good to know. 
> > > > > FWIW, this is the kind of situation I was thinking this diagnostic 
> > > > > would help make far more clear: https://godbolt.org/z/336n9xex3 (not 
> > > > > that I expect people to write that static assert, but I very much 
> > > > > expect people who assign the value 1 into a bit-field and then check 
> > > > > for the value 1 to come back out are going to be surprised).
> > > > > 
> > > > > That said, another approach to that specific scenario, which might 
> > > > > have a better true positive rate would be:
> > > > > ```
> > > > > struct S {
> > > > >   int bit : 1;
> > > > > };
> > > > > 
> > > > > int main() {
> > > > >   constexpr S s{1}; // No warning
> > > > >   if (s.bit == 1) { // Warn about explicit comparison of a 1-bit 
> > > > > bit-field
> > > > > ...
> > > > >   } else if (s.bit == 0) { // Warn about explicit comparison of a 
> > > > > 1-bit bit-field?
> > > > > ...
> > > > >   } else if (s.bit) { // No warning
> > > > > ...
> > > > >   } else if (!s.bit) { // No warning
> > > > > ...
> > > > >   }
> > > > > }
> > > > > ```
> > > > Do you have something in mind that counts as false positives? 
> > > BTW, I realized that no warning is reported when a bool is assigned to a 
> > > single-bit signed bit-field:
> > > 
> > > https://godbolt.org/z/M5ex48T8s
> > > 
> > > ```
> > > int main() {
> > >   struct S { int b : 1; } s;
> > >   s.b = true;
> > >   if (s.b == true) { puts("T"); } else { puts("F"); }
> > > }
> > > ```
> > > 
> > > 
> > For reference, I found this issue on chromium: 
> > 
> > https://bugs.chromium.org/p/chromium/issues/detail?id=1352183
> > Do you have something in mind that counts as false positives?
> 
> In my example above, I consider the use of `s.bit` and `!s.bit` to count as 
> false positives. The value in the bit-field being 1 or -1 has no bearing on 
> the semantics of the program, the only thing that matters is zero vs nonzero 
> because of the boolean conversion.
> 
> > BTW, I realized that no warning is reported when a bool is assigned to a 
> > single-bit signed bit-field:
> 
> Good catch, the conversion from bool to integer does give the value `1` 
> explicitly. At the same time, I would consider the assignment to the 
> bit-field from a boolean to be a non-issue, the problem only stems from 
> attempting to use inspect the value.
>>BTW, I realized that no warning is reported when a bool is assigned to a 
>>single-bit signed bit-field:
> Good catch, the conversion from bool to integer does give the value 1 
> explicitly. At the same time, I would consider the assignment to the 
> bit-field from a boolean to be a non-issue, the problem only stems from 
> attempting to use inspect the value.

Actually, that's a more interesting case than I had originally realized. See 
C2x 6.7.2.1p12. "If the value 0 or 1 is stored into a nonzero-width bit-field 
of type bool, the value of the bit-field shall compare equal to the value 
stored; a bool bit-field has the semantics of a bool."

So if you store a 1 into a bool bit-field, you have to get a 1 back out of it. 
The bit-field is implicitly unsigned, effectively.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131255

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


[clang] ba79c2a - Update the implementation status of some C11 features

2022-08-13 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-08-13T10:17:47-04:00
New Revision: ba79c2a25069f09728625982c424920452fa6b83

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

LOG: Update the implementation status of some C11 features

This also starts to add some test coverage for specific papers to
validate conformance against.

Added: 
clang/test/C/C11/n1316.c
clang/test/C/C11/n1330.c
clang/test/C/C11/n1356.c
clang/test/C/C11/n1391.c
clang/test/C/C11/n1460.c

Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/test/C/C11/n1316.c b/clang/test/C/C11/n1316.c
new file mode 100644
index ..ade895fc893f
--- /dev/null
+++ b/clang/test/C/C11/n1316.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -verify %s
+
+/* WG14 N1316: Yes
+ * Conversion between pointers and floating types
+ */
+
+void call_ptr(void *);  // expected-note {{passing argument to parameter here}}
+void call_float(float); // expected-note {{passing argument to parameter here}}
+
+void test(float in_f, void *in_vp) {
+  float f = in_vp; // expected-error {{initializing 'float' with an expression 
of incompatible type 'void *'}}
+  void *vp = in_f; // expected-error {{initializing 'void *' with an 
expression of incompatible type 'float'}}
+
+  call_ptr(f);// expected-error {{passing 'float' to parameter of 
incompatible type 'void *'}}
+  call_float(vp); // expected-error {{passing 'void *' to parameter of 
incompatible type 'float'}}
+
+  vp = f; // expected-error {{assigning to 'void *' from incompatible type 
'float'}}
+  f = vp; // expected-error {{assigning to 'float' from incompatible type 
'void *'}}
+
+  struct S {
+void *ptr;
+float flt;
+  } s = { f, vp }; // expected-error {{initializing 'void *' with an 
expression of incompatible type 'float'}} \
+  expected-error {{initializing 'float' with an expression 
of incompatible type 'void *'}}
+}
+

diff  --git a/clang/test/C/C11/n1330.c b/clang/test/C/C11/n1330.c
new file mode 100644
index ..4208464610b6
--- /dev/null
+++ b/clang/test/C/C11/n1330.c
@@ -0,0 +1,78 @@
+// RUN: %clang_cc1 -verify %s
+
+/* WG14 N1330: Yes
+ * Static assertions
+ */
+
+// Test syntactic requirements: first argument must be a constant expression,
+// and the second argument must be a string literal. We support the C2x
+// extension that allows you to elide the second argument.
+int a;
+_Static_assert(a, ""); // expected-error {{static assertion expression is not 
an integral constant expression}}
+_Static_assert(1); // expected-warning {{'_Static_assert' with no message 
is a C2x extension}}
+
+// Test functional requirements
+_Static_assert(1, "this works");
+_Static_assert(0, "this fails"); // expected-error {{static assertion failed: 
this fails}}
+_Static_assert(0); // expected-error {{static assertion failed}} \
+  expected-warning {{'_Static_assert' with no message is a 
C2x extension}}
+
+// Test declaration contexts. We've already demonstrated that file scope works.
+struct S {
+  _Static_assert(1, "this works");
+  union U {
+long l;
+_Static_assert(1, "this works");
+  } u;
+  enum E {
+_Static_assert(1, "this should not compile"); // expected-error {{expected 
identifier}}
+One
+  } e;
+};
+
+void func( // expected-note {{to match 
this '('}}
+  _Static_assert(1, "this should not compile") // expected-error {{expected 
parameter declarator}} \
+  expected-error {{expected 
')'}}
+);
+void func( // expected-note {{to match 
this '('}}
+  _Static_assert(1, "this should not compile") // expected-error {{expected 
parameter declarator}} \
+  expected-error {{expected 
')'}}
+) {}
+
+void test(void) {
+  _Static_assert(1, "this works");
+  _Static_assert(0, "this fails"); // expected-error {{static assertion 
failed: this fails}}
+
+  // The use of a _Static_assert in a for loop declaration is prohibited per
+  // 6.8.5p3 requiring the declaration to only declare identifiers for objects
+  // having auto or register storage class; a static assertion does not declare
+  // an identifier nor an object.
+  // FIXME: this diagnostic is pretty terrible.
+  int i = 0;
+  for (_Static_assert(1, "this should not compile"); i < 10; ++i) // 
expected-error {{expected identifier or '('}} \
+ 
expected-error {{expected ';' in 'for' statement specifier}}
+;
+
+  // Ensure that only an integer constant expression can be used as the
+  // controlling expression.
+  _Static_assert(1.0f, "this should not compile"); // expected-error {{static 
assertion expre

[PATCH] D131780: [clang-tidy] Do not trigger cppcoreguidelines-avoid-const-or-ref-data-members on lambda captures

2022-08-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D131780#3720896 , @carlosgalvezp 
wrote:

> In D131780#3719881 , 
> @Eugene.Zelenko wrote:
>
>> Please mention changes in Release Notes.
>
> Thanks for the quick review, @Eugene.Zelenko !
>
> This check was newly added a couple of days ago (as per the "New checks" 
> section in the Release Notes). I thought the "Changes to exiting checks" 
> section was only meant for checks already existing prior to the new release, 
> to avoid adding excessive clutter to the documentation. New checks typically 
> take a few iterations to polish when testing on larger projects.
>
> What do you think?

Sorry, I didn't know history. Sure, it doesn't make sense for checks added in 
`main`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131780

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof updated this revision to Diff 452429.
alexiprof added a comment.

this pull request contains a fix for the problem with displaying options 
-fsyntax_only in clang and fland-new in help
https://github.com/llvm/llvm-project/issues/57033

Before:

  $ clang  -help | grep syntax
   -objcmt-migrate-property-dot-syntax
  Enable migration of setter/getter messages to property-dot syntax

After:

  $ clang -help | grep syntax
   -fsyntax-only   Run the preprocessor, parser and type checking stages
   -objcmt-migrate-property-dot-syntax
  Enable migration of setter/getter messages to property-dot syntax

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -42,6 +42,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.
+! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of 
include search paths
@@ -119,6 +120,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E 
mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -init-only Only execute frontend initialization
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -44,6 +44,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of 
include search paths
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2795,7 +2795,8 @@
 def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption, 
CoreOption]>,
   Group, HelpText<"Only run the driver.">;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Run the preprocessor, parser and type checking stages">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;
 def ftemplate_depth_EQ : Joined<["-"], "ftemplate-depth=">, Group;
 def ftemplate_depth_ : Joined<["-"], "ftemplate-depth-">, Group;
@@ -3211,6 +3212,7 @@
 def headerpad__max__install__names : Joined<["-"], 
"headerpad_max_install_names">;
 def help : Flag<["-", "--"], "help">, Flags<[CC1Option,CC1AsOption, FC1Option,
 FlangOption]>, HelpText<"Display available options">,
+  HelpText<"Display available options">,
 MarshallingInfoFlag>;
 def ibuiltininc : Flag<["-"], "ibuiltininc">,
   HelpText<"Enable builtin #include directories even when -nostdinc is used "
@@ -6613,7 +6615,7 @@
 def _SLASH_Zp_flag : CLFlag<"Zp">,
   HelpText<"Set default maximum struct packing alignment to 1">,
   Alias, AliasArgs<["1"]>;
-def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">,
+def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Run the preprocessor, parser and type 
checking stages">,
   Alias;
 def _SLASH_openmp_ : CLFlag<"openmp-">,
   HelpText<"Disable OpenMP support">, Alias;
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3999,7 +3999,7 @@
   /Zl Don't mention any default libraries in the

[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof updated this revision to Diff 452431.
alexiprof added a comment.

remove Unrelated change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90


Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -42,6 +42,7 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.
+! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of 
include search paths
@@ -119,6 +120,7 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E 
mode
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! HELP-FC1-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! HELP-FC1-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-FC1-NEXT: -help  Display available options
 ! HELP-FC1-NEXT: -init-only Only execute frontend initialization
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -44,6 +44,7 @@
 ! CHECK-NEXT: -fno-integrated-as Disable the integrated assembler
 ! CHECK-NEXT: -fopenacc  Enable OpenACC
 ! CHECK-NEXT: -fopenmp   Parse OpenMP pragmas and generate 
parallel code.
+! CHECK-NEXT: -fsyntax-only  Run the preprocessor, parser and type 
checking stages
 ! CHECK-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! CHECK-NEXT: -help Display available options
 ! CHECK-NEXT: -IAdd directory to the end of the list of 
include search paths
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2795,7 +2795,8 @@
 def fdriver_only : Flag<["-"], "fdriver-only">, Flags<[NoXarchOption, 
CoreOption]>,
   Group, HelpText<"Only run the driver.">;
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Run the preprocessor, parser and type checking stages">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;
 def ftemplate_depth_EQ : Joined<["-"], "ftemplate-depth=">, Group;
 def ftemplate_depth_ : Joined<["-"], "ftemplate-depth-">, Group;
@@ -6613,7 +6614,7 @@
 def _SLASH_Zp_flag : CLFlag<"Zp">,
   HelpText<"Set default maximum struct packing alignment to 1">,
   Alias, AliasArgs<["1"]>;
-def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Syntax-check only">,
+def _SLASH_Zs : CLFlag<"Zs">, HelpText<"Run the preprocessor, parser and type 
checking stages">,
   Alias;
 def _SLASH_openmp_ : CLFlag<"openmp-">,
   HelpText<"Disable OpenMP support">, Alias;
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -3999,7 +3999,7 @@
   /Zl Don't mention any default libraries in the 
object file
   /Zp Set the default maximum struct packing alignment 
to 1
   /Zp  Specify the default maximum struct packing 
alignment
-  /Zs Syntax-check only
+  /Zs Run the preprocessor, parser and type checking 
stages
 
 OPTIONS:
   -###Print (but do not run) the commands to run for 
this compilation
@@ -4130,6 +4130,7 @@
   behavior. See user manual for available checks
   -fsplit-lto-unitEnables splitting of the LTO unit.
   -fstandalone-debug  Emit full debug info for all types used by the 
program
+  -fsyntax-only   Run the preprocessor, parser and type checking 
stages
   -fwhole-program-vtables Enables whole-program vtable optimization. 
Requires -flto
   -gcodeview-ghashEmit type record hashes in a .debug$H section
   -gcodeview  Generate CodeView debug information
Index: clang/docs/ClangCommandLineRe

[PATCH] D131255: Fix Wbitfield-constant-conversion on 1-bit signed bitfield

2022-08-13 Thread Shawn Zhong via Phabricator via cfe-commits
ShawnZhong added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13069
-  // therefore don't strictly fit into a signed bitfield of width 1.
-  if (FieldWidth == 1 && Value == 1)
-return false;

aaron.ballman wrote:
> aaron.ballman wrote:
> > ShawnZhong wrote:
> > > ShawnZhong wrote:
> > > > ShawnZhong wrote:
> > > > > aaron.ballman wrote:
> > > > > > thakis wrote:
> > > > > > > This was to suppress false positives. All instances we've seen of 
> > > > > > > this are in fact false positives.
> > > > > > > 
> > > > > > > Was there any analysis on true / false positives for this change?
> > > > > > > 
> > > > > > > At least for our code, this seems to make the warning strictly 
> > > > > > > worse.
> > > > > > I've not performed any such analysis, but it would be good to know. 
> > > > > > FWIW, this is the kind of situation I was thinking this diagnostic 
> > > > > > would help make far more clear: https://godbolt.org/z/336n9xex3 
> > > > > > (not that I expect people to write that static assert, but I very 
> > > > > > much expect people who assign the value 1 into a bit-field and then 
> > > > > > check for the value 1 to come back out are going to be surprised).
> > > > > > 
> > > > > > That said, another approach to that specific scenario, which might 
> > > > > > have a better true positive rate would be:
> > > > > > ```
> > > > > > struct S {
> > > > > >   int bit : 1;
> > > > > > };
> > > > > > 
> > > > > > int main() {
> > > > > >   constexpr S s{1}; // No warning
> > > > > >   if (s.bit == 1) { // Warn about explicit comparison of a 1-bit 
> > > > > > bit-field
> > > > > > ...
> > > > > >   } else if (s.bit == 0) { // Warn about explicit comparison of a 
> > > > > > 1-bit bit-field?
> > > > > > ...
> > > > > >   } else if (s.bit) { // No warning
> > > > > > ...
> > > > > >   } else if (!s.bit) { // No warning
> > > > > > ...
> > > > > >   }
> > > > > > }
> > > > > > ```
> > > > > Do you have something in mind that counts as false positives? 
> > > > BTW, I realized that no warning is reported when a bool is assigned to 
> > > > a single-bit signed bit-field:
> > > > 
> > > > https://godbolt.org/z/M5ex48T8s
> > > > 
> > > > ```
> > > > int main() {
> > > >   struct S { int b : 1; } s;
> > > >   s.b = true;
> > > >   if (s.b == true) { puts("T"); } else { puts("F"); }
> > > > }
> > > > ```
> > > > 
> > > > 
> > > For reference, I found this issue on chromium: 
> > > 
> > > https://bugs.chromium.org/p/chromium/issues/detail?id=1352183
> > > Do you have something in mind that counts as false positives?
> > 
> > In my example above, I consider the use of `s.bit` and `!s.bit` to count as 
> > false positives. The value in the bit-field being 1 or -1 has no bearing on 
> > the semantics of the program, the only thing that matters is zero vs 
> > nonzero because of the boolean conversion.
> > 
> > > BTW, I realized that no warning is reported when a bool is assigned to a 
> > > single-bit signed bit-field:
> > 
> > Good catch, the conversion from bool to integer does give the value `1` 
> > explicitly. At the same time, I would consider the assignment to the 
> > bit-field from a boolean to be a non-issue, the problem only stems from 
> > attempting to use inspect the value.
> >>BTW, I realized that no warning is reported when a bool is assigned to a 
> >>single-bit signed bit-field:
> > Good catch, the conversion from bool to integer does give the value 1 
> > explicitly. At the same time, I would consider the assignment to the 
> > bit-field from a boolean to be a non-issue, the problem only stems from 
> > attempting to use inspect the value.
> 
> Actually, that's a more interesting case than I had originally realized. See 
> C2x 6.7.2.1p12. "If the value 0 or 1 is stored into a nonzero-width bit-field 
> of type bool, the value of the bit-field shall compare equal to the value 
> stored; a bool bit-field has the semantics of a bool."
> 
> So if you store a 1 into a bool bit-field, you have to get a 1 back out of 
> it. The bit-field is implicitly unsigned, effectively.
> In my example above, I consider the use of `s.bit` and `!s.bit` to count as 
> false positives. The value in the bit-field being 1 or -1 has no bearing on 
> the semantics of the program, the only thing that matters is zero vs nonzero 
> because of the boolean conversion.

I agree with you that if `s.bit` is only used to be converted to `bool`, then 
the value stored being 1 or -1 does not matter that much. But hypothetically, 
one could use `s.bit` for arithmetic (e.g., index into an array), assignment 
(say into another int or enum), or, in your example, comparison against another 
value.  If a warning is not generated during conversion, handling them in other 
places would be harder. 

> Actually, that's a more interesting case than I had originally realized. See 
> C2x 6.7.2.1p12. "If the value 0 or 1 is stored into a nonzero-width bit-field 
> of type bool, the va

[clang] f385eaf - [OpenMP] Fix use after scope after D129608

2022-08-13 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-13T09:40:51-07:00
New Revision: f385eaf48f5c4123b61272cd243c339d6f8526ed

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

LOG: [OpenMP] Fix use after scope after D129608

Broken builder https://lab.llvm.org/buildbot/#/builders/5/builds/26764

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a2d36e7df6f12..b2f393e352879 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9075,7 +9075,7 @@ class MappableExprsHandler {
 // DeclComponentLists for generating components info.
 auto It = DevPointersMap.find(VD);
 if (It != DevPointersMap.end())
-  for (const auto MCL : It->second)
+  for (const auto& MCL : It->second)
 DeclComponentLists.emplace_back(
 MCL, OMPC_MAP_to, OMPC_MAP_MODIFIER_unknown, /*IsImpicit = */ true,
 nullptr, nullptr);



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


[clang] 2117fcb - Use Optional::transform instead of Optional::map (NFC)

2022-08-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-13T11:48:26-07:00
New Revision: 2117fcb1c06207b5eea09b66fb8e0ff58314afa8

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

LOG: Use Optional::transform instead of Optional::map (NFC)

I'm planning to deprecate map in favor of transform for consistency
with std::optional::transform in C++23.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang/include/clang/AST/PropertiesBase.td
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index cced230300db0..75326e0ab1d19 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -131,7 +131,8 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace,
 };
 auto InProgressFixup = [&] {
   return Info
-  .map([](const FailureInfo &Info) { return StringRef(Info.Fixup); })
+  .transform(
+  [](const FailureInfo &Info) { return StringRef(Info.Fixup); })
   .value_or(Name);
 };
 if (auto Fixup = getDoubleUnderscoreFixup(InProgressFixup(), LangOpts))

diff  --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index ec310a459927d..0dc27b67beb86 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -786,13 +786,13 @@ let Class = PropertyTypeCase in {
   def : Property<"numExpansions", Optional> {
 let Read = [{
   // Translate unsigned -> uint32_t just in case.
-  node.getNumTemplateExpansions().map(
+  node.getNumTemplateExpansions().transform(
 [](unsigned i) { return uint32_t(i); })
 }];
   }
   def : Creator<[{
 auto numExpansionsUnsigned =
-  numExpansions.map([](uint32_t i) { return unsigned(i); });
+  numExpansions.transform([](uint32_t i) { return unsigned(i); });
 return TemplateArgument(name, numExpansionsUnsigned);
   }]>;
 }

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
index 4c785b21526da..4d1f5248f2115 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -153,7 +153,7 @@ runDataflowAnalysis(
 
   llvm::transform(std::move(*TypeErasedBlockStates),
   std::back_inserter(BlockStates), [](auto &OptState) {
-return std::move(OptState).map([](auto &&State) {
+return std::move(OptState).transform([](auto &&State) {
   return DataflowAnalysisState{
   llvm::any_cast(
   std::move(State.Lattice.Value)),

diff  --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp 
b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 3f0dad7ee7694..c1e3e6031ec98 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1967,7 +1967,7 @@ static bool eliminateDeadStores(Function &F, 
AliasAnalysis &AA, MemorySSA &MSSA,
 
 Optional MaybeKillingLoc;
 if (State.isMemTerminatorInst(KillingI))
-  MaybeKillingLoc = State.getLocForTerminator(KillingI).map(
+  MaybeKillingLoc = State.getLocForTerminator(KillingI).transform(
   [](const std::pair &P) { return P.first; });
 else
   MaybeKillingLoc = State.getLocForWrite(KillingI);



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


[clang] 2f9be69 - [OpenMP] Fix another after scope after D129608

2022-08-13 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-13T12:13:54-07:00
New Revision: 2f9be69d843d12864128f4e23920ba214c5e212d

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

LOG: [OpenMP] Fix another after scope after D129608

https://lab.llvm.org/buildbot/#/builders/5/builds/26770

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b2f393e35287..67f4d238200c 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9070,15 +9070,18 @@ class MappableExprsHandler {
 std::tuple, bool,
const ValueDecl *, const Expr *>;
+static const OpenMPMapModifierKind ModifierKinds[] = {
+OMPC_MAP_MODIFIER_unknown,
+};
 SmallVector DeclComponentLists;
 // For member fields list in is_device_ptr, store it in
 // DeclComponentLists for generating components info.
 auto It = DevPointersMap.find(VD);
 if (It != DevPointersMap.end())
   for (const auto& MCL : It->second)
-DeclComponentLists.emplace_back(
-MCL, OMPC_MAP_to, OMPC_MAP_MODIFIER_unknown, /*IsImpicit = */ true,
-nullptr, nullptr);
+DeclComponentLists.emplace_back(MCL, OMPC_MAP_to, ModifierKinds,
+/*IsImpicit = */ true, nullptr,
+nullptr);
 assert(CurDir.is() &&
"Expect a executable directive");
 const auto *CurExecDir = CurDir.get();



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


[PATCH] D131541: [Sema] Fix friend destructor declarations after D130936

2022-08-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 452447.
royjacobson added a comment.

Update to handle some edge cases better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131541

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/member-class-11.cpp


Index: clang/test/SemaCXX/member-class-11.cpp
===
--- clang/test/SemaCXX/member-class-11.cpp
+++ clang/test/SemaCXX/member-class-11.cpp
@@ -26,4 +26,51 @@
   ~B(); // expected-error {{expected the class name after '~' to name the 
enclosing class}}
 };
 
+template 
+struct D {
+  friend T::S::~S();
+private:
+  static constexpr int secret = 42;
+};
+
+template 
+struct E {
+  friend T::S::~V();
+};
+
+struct BadInstantiation {
+  struct S {
+struct V {};
+  };
+};
+
+struct GoodInstantiation {
+  struct V {
+~V();
+  };
+  using S = V;
+};
+
+// FIXME: We should diagnose this while instantiating.
+E x;
+E y;
+
+struct Q {
+  struct S { ~S(); };
+};
+
+Q::S::~S() {
+  void foo(int);
+  foo(D::secret);
+}
+
+struct X {
+  ~X();
+};
+struct Y;
+
+struct Z {
+  friend X::~Y(); // expected-error {{expected the class name after '~' to 
name the enclosing class}}
+};
+
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11514,16 +11514,25 @@
 if (CXXConstructorDecl *Constructor = dyn_cast(NewFD)) 
{
   CheckConstructor(Constructor);
 } else if (CXXDestructorDecl *Destructor =
-dyn_cast(NewFD)) {
-  CXXRecordDecl *Record = Destructor->getParent();
-  QualType ClassType = Context.getTypeDeclType(Record);
-
-  DeclarationName Name = Context.DeclarationNames.getCXXDestructorName(
-  Context.getCanonicalType(ClassType));
-  if (NewFD->getDeclName() != Name) {
-Diag(NewFD->getLocation(), diag::err_destructor_name);
-NewFD->setInvalidDecl();
-return Redeclaration;
+   dyn_cast(NewFD)) {
+  // We check here for invalid destructor names.
+  // If we have a friend destructor declaration that is dependent, we can't
+  // diagnose right away because cases like this are still valid:
+  // template  struct A { friend T::X::~Y(); };
+  // struct B { struct Y { ~Y(); }; using X = Y; };
+  // template struct A;
+  if (NewFD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None ||
+  !Destructor->getThisType()->isDependentType()) {
+CXXRecordDecl *Record = Destructor->getParent();
+QualType ClassType = Context.getTypeDeclType(Record);
+
+DeclarationName Name = Context.DeclarationNames.getCXXDestructorName(
+Context.getCanonicalType(ClassType));
+if (NewFD->getDeclName() != Name) {
+  Diag(NewFD->getLocation(), diag::err_destructor_name);
+  NewFD->setInvalidDecl();
+  return Redeclaration;
+}
   }
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())


Index: clang/test/SemaCXX/member-class-11.cpp
===
--- clang/test/SemaCXX/member-class-11.cpp
+++ clang/test/SemaCXX/member-class-11.cpp
@@ -26,4 +26,51 @@
   ~B(); // expected-error {{expected the class name after '~' to name the enclosing class}}
 };
 
+template 
+struct D {
+  friend T::S::~S();
+private:
+  static constexpr int secret = 42;
+};
+
+template 
+struct E {
+  friend T::S::~V();
+};
+
+struct BadInstantiation {
+  struct S {
+struct V {};
+  };
+};
+
+struct GoodInstantiation {
+  struct V {
+~V();
+  };
+  using S = V;
+};
+
+// FIXME: We should diagnose this while instantiating.
+E x;
+E y;
+
+struct Q {
+  struct S { ~S(); };
+};
+
+Q::S::~S() {
+  void foo(int);
+  foo(D::secret);
+}
+
+struct X {
+  ~X();
+};
+struct Y;
+
+struct Z {
+  friend X::~Y(); // expected-error {{expected the class name after '~' to name the enclosing class}}
+};
+
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11514,16 +11514,25 @@
 if (CXXConstructorDecl *Constructor = dyn_cast(NewFD)) {
   CheckConstructor(Constructor);
 } else if (CXXDestructorDecl *Destructor =
-dyn_cast(NewFD)) {
-  CXXRecordDecl *Record = Destructor->getParent();
-  QualType ClassType = Context.getTypeDeclType(Record);
-
-  DeclarationName Name = Context.DeclarationNames.getCXXDestructorName(
-  Context.getCanonicalType(ClassType));
-  if (NewFD->getDeclName() != Name) {
-Diag(NewFD->getLocation(), diag::err_destructor_name);
-NewFD->setInvalidDecl();
-return Redeclaration;
+   dyn_cast(NewFD)) {
+  // We check here for invalid destru

[PATCH] D131541: [Sema] Fix friend destructor declarations after D130936

2022-08-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 452448.
royjacobson added a comment.

Add another test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131541

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/member-class-11.cpp

Index: clang/test/SemaCXX/member-class-11.cpp
===
--- clang/test/SemaCXX/member-class-11.cpp
+++ clang/test/SemaCXX/member-class-11.cpp
@@ -26,4 +26,56 @@
   ~B(); // expected-error {{expected the class name after '~' to name the enclosing class}}
 };
 
+template 
+struct D {
+  friend T::S::~S();
+private:
+  static constexpr int secret = 42;
+};
+
+template 
+struct E {
+  friend T::S::~V();
+};
+
+struct BadInstantiation {
+  struct S {
+struct V {};
+  };
+};
+
+struct GoodInstantiation {
+  struct V {
+~V();
+  };
+  using S = V;
+};
+
+// FIXME: We should diagnose this while instantiating.
+E x;
+E y;
+
+struct Q {
+  struct S { ~S(); };
+};
+
+Q::S::~S() {
+  void foo(int);
+  foo(D::secret);
+}
+
+struct X {
+  ~X();
+};
+struct Y;
+
+struct Z1 {
+  friend X::~Y(); // expected-error {{expected the class name after '~' to name the enclosing class}}
+};
+
+template 
+struct Z2 {
+  friend X::~Y(); // expected-error {{expected the class name after '~' to name the enclosing class}}
+};
+
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11514,16 +11514,25 @@
 if (CXXConstructorDecl *Constructor = dyn_cast(NewFD)) {
   CheckConstructor(Constructor);
 } else if (CXXDestructorDecl *Destructor =
-dyn_cast(NewFD)) {
-  CXXRecordDecl *Record = Destructor->getParent();
-  QualType ClassType = Context.getTypeDeclType(Record);
-
-  DeclarationName Name = Context.DeclarationNames.getCXXDestructorName(
-  Context.getCanonicalType(ClassType));
-  if (NewFD->getDeclName() != Name) {
-Diag(NewFD->getLocation(), diag::err_destructor_name);
-NewFD->setInvalidDecl();
-return Redeclaration;
+   dyn_cast(NewFD)) {
+  // We check here for invalid destructor names.
+  // If we have a friend destructor declaration that is dependent, we can't
+  // diagnose right away because cases like this are still valid:
+  // template  struct A { friend T::X::~Y(); };
+  // struct B { struct Y { ~Y(); }; using X = Y; };
+  // template struct A;
+  if (NewFD->getFriendObjectKind() == Decl::FriendObjectKind::FOK_None ||
+  !Destructor->getThisType()->isDependentType()) {
+CXXRecordDecl *Record = Destructor->getParent();
+QualType ClassType = Context.getTypeDeclType(Record);
+
+DeclarationName Name = Context.DeclarationNames.getCXXDestructorName(
+Context.getCanonicalType(ClassType));
+if (NewFD->getDeclName() != Name) {
+  Diag(NewFD->getLocation(), diag::err_destructor_name);
+  NewFD->setInvalidDecl();
+  return Redeclaration;
+}
   }
 } else if (auto *Guide = dyn_cast(NewFD)) {
   if (auto *TD = Guide->getDescribedFunctionTemplate())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131541: [Sema] Fix friend destructor declarations after D130936

2022-08-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added reviewers: erichkeane, hubert.reinterpretcast, shafik.
royjacobson added a comment.

Updated the patch and added more test coverage.

I still don't diagnose the dependent friend case, but I didn't see how to do it 
easily.




Comment at: clang/lib/Sema/SemaDecl.cpp:11518-11520
+  // FIXME: We still don't diagnose on this case
+  // template 
+  // struct A { friend T::S::~V(); };

hubert.reinterpretcast wrote:
> There's nothing we can diagnose about this without an instantiation (because 
> `S` could be an alias for a class having `V` as the injected-class-name).
> 
> It is, however, true that we don't diagnose this even with problematic 
> instantiations:
> ```
> struct R { struct V; ~R(); };
> struct QQ { using S = R; };
> 
> template 
> struct A { friend T::S::~V(); };
> 
> A a;
> ```
Wow, thanks! That's some edge case I haven't thought about..




Comment at: clang/test/SemaCXX/member-class-11.cpp:36-40
+// FIXME: We should diagnose here.
+template 
+struct E {
+  friend T::S::~V();
+};

hubert.reinterpretcast wrote:
> Please replace this with the case where there is an instantiation. Also, the 
> prior change to the release notes in https://reviews.llvm.org/D130936 should 
> be adjusted to reflect the new scope of what is fixed.
Updated the test cases accordingly.

I don't think there's things to add in the release notes as this is just fixing 
breakage from my previous patch, not really diagnosing new cases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131541

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


[clang] 64f0f7e - __has_trivial_copy should map to __is_trivially_copyable

2022-08-13 Thread Roy Jacobson via cfe-commits

Author: Zachary Henkel
Date: 2022-08-13T22:54:52+03:00
New Revision: 64f0f7e6460019a38fe2f1cbe4b9446a3268af18

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

LOG:  __has_trivial_copy should map to __is_trivially_copyable

Found during clang 15 RC1 testing due to the new diagnostic added by 
@royjacobson since clang 14.  Uncertain if this fix meets the bar to also be 
applied to the release branch.

If accepted, I'll need someone with commit access to submit on my behalf.

Reviewed By: royjacobson, aaron.ballman, erichkeane

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/deprecated-builtins.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 3adf0a12fc4c3..0e8028d2cc066 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1373,7 +1373,7 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__has_trivial_move_assign`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_assignable`` instead.
 * ``__has_trivial_copy`` (GNU, Microsoft):
-  Deprecated, use ``__is_trivially_constructible`` instead.
+  Deprecated, use ``__is_trivially_copyable`` instead.
 * ``__has_trivial_constructor`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_constructible`` instead.
 * ``__has_trivial_move_constructor`` (GNU, Microsoft):

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index e3e2df03a5025..c43c9dc21bd5e 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5412,6 +5412,8 @@ void DiagnoseBuiltinDeprecation(Sema& S, TypeTrait Kind,
   Replacement = BTT_IsTriviallyAssignable;
   break;
 case UTT_HasTrivialCopy:
+  Replacement = UTT_IsTriviallyCopyable;
+  break;
 case UTT_HasTrivialDefaultConstructor:
 case UTT_HasTrivialMoveConstructor:
   Replacement = TT_IsTriviallyConstructible;

diff  --git a/clang/test/SemaCXX/deprecated-builtins.cpp 
b/clang/test/SemaCXX/deprecated-builtins.cpp
index 2bb687c1ef129..849b9b014fff2 100644
--- a/clang/test/SemaCXX/deprecated-builtins.cpp
+++ b/clang/test/SemaCXX/deprecated-builtins.cpp
@@ -11,7 +11,7 @@ void f() {
 a = __has_nothrow_constructor(A);  // expected-warning-re 
{{__has_nothrow_constructor {{.*}} use __is_nothrow_constructible}}
 a = __has_trivial_assign(A);  // expected-warning-re 
{{__has_trivial_assign {{.*}} use __is_trivially_assignable}}
 a = __has_trivial_move_assign(A);  // expected-warning-re 
{{__has_trivial_move_assign {{.*}} use __is_trivially_assignable}}
-a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy 
{{.*}} use __is_trivially_constructible}}
+a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy 
{{.*}} use __is_trivially_copyable}}
 a = __has_trivial_constructor(A);  // expected-warning-re 
{{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
 a = __has_trivial_move_constructor(A);  // expected-warning-re 
{{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
 a = __has_trivial_destructor(A);  // expected-warning-re 
{{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}



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


[PATCH] D131730: __has_trivial_copy should map to __is_trivially_copyable

2022-08-13 Thread Roy Jacobson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG64f0f7e64600:  __has_trivial_copy should map to 
__is_trivially_copyable (authored by zahen, committed by royjacobson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131730

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/deprecated-builtins.cpp


Index: clang/test/SemaCXX/deprecated-builtins.cpp
===
--- clang/test/SemaCXX/deprecated-builtins.cpp
+++ clang/test/SemaCXX/deprecated-builtins.cpp
@@ -11,7 +11,7 @@
 a = __has_nothrow_constructor(A);  // expected-warning-re 
{{__has_nothrow_constructor {{.*}} use __is_nothrow_constructible}}
 a = __has_trivial_assign(A);  // expected-warning-re 
{{__has_trivial_assign {{.*}} use __is_trivially_assignable}}
 a = __has_trivial_move_assign(A);  // expected-warning-re 
{{__has_trivial_move_assign {{.*}} use __is_trivially_assignable}}
-a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy 
{{.*}} use __is_trivially_constructible}}
+a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy 
{{.*}} use __is_trivially_copyable}}
 a = __has_trivial_constructor(A);  // expected-warning-re 
{{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
 a = __has_trivial_move_constructor(A);  // expected-warning-re 
{{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
 a = __has_trivial_destructor(A);  // expected-warning-re 
{{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5412,6 +5412,8 @@
   Replacement = BTT_IsTriviallyAssignable;
   break;
 case UTT_HasTrivialCopy:
+  Replacement = UTT_IsTriviallyCopyable;
+  break;
 case UTT_HasTrivialDefaultConstructor:
 case UTT_HasTrivialMoveConstructor:
   Replacement = TT_IsTriviallyConstructible;
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1373,7 +1373,7 @@
 * ``__has_trivial_move_assign`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_assignable`` instead.
 * ``__has_trivial_copy`` (GNU, Microsoft):
-  Deprecated, use ``__is_trivially_constructible`` instead.
+  Deprecated, use ``__is_trivially_copyable`` instead.
 * ``__has_trivial_constructor`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_constructible`` instead.
 * ``__has_trivial_move_constructor`` (GNU, Microsoft):


Index: clang/test/SemaCXX/deprecated-builtins.cpp
===
--- clang/test/SemaCXX/deprecated-builtins.cpp
+++ clang/test/SemaCXX/deprecated-builtins.cpp
@@ -11,7 +11,7 @@
 a = __has_nothrow_constructor(A);  // expected-warning-re {{__has_nothrow_constructor {{.*}} use __is_nothrow_constructible}}
 a = __has_trivial_assign(A);  // expected-warning-re {{__has_trivial_assign {{.*}} use __is_trivially_assignable}}
 a = __has_trivial_move_assign(A);  // expected-warning-re {{__has_trivial_move_assign {{.*}} use __is_trivially_assignable}}
-a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy {{.*}} use __is_trivially_constructible}}
+a = __has_trivial_copy(A);  // expected-warning-re {{__has_trivial_copy {{.*}} use __is_trivially_copyable}}
 a = __has_trivial_constructor(A);  // expected-warning-re {{__has_trivial_constructor {{.*}} use __is_trivially_constructible}}
 a = __has_trivial_move_constructor(A);  // expected-warning-re {{__has_trivial_move_constructor {{.*}} use __is_trivially_constructible}}
 a = __has_trivial_destructor(A);  // expected-warning-re {{__has_trivial_destructor {{.*}} use __is_trivially_destructible}}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5412,6 +5412,8 @@
   Replacement = BTT_IsTriviallyAssignable;
   break;
 case UTT_HasTrivialCopy:
+  Replacement = UTT_IsTriviallyCopyable;
+  break;
 case UTT_HasTrivialDefaultConstructor:
 case UTT_HasTrivialMoveConstructor:
   Replacement = TT_IsTriviallyConstructible;
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1373,7 +1373,7 @@
 * ``__has_trivial_move_assign`` (GNU, Microsoft):
   Deprecated, use ``__is_trivially_assignable`` instead.
 * ``__has_trivial_copy`` (GNU, Microsoft):
-  Deprecated, use ``__is_trivially_c

[clang-tools-extra] 7c69476 - [clangd] Drop unnecessary const from return types (NFC)

2022-08-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-13T12:55:44-07:00
New Revision: 7c6947656496cb66f592e4e556a2f1fa40324b76

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

LOG: [clangd] Drop unnecessary const from return types (NFC)

Identified with readability-const-return-type.

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 12aa9dacc2dfe..16e70d36640df 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -118,7 +118,7 @@ std::string detectClangPath() {
 
 // On mac, /usr/bin/clang sets SDKROOT and then invokes the real clang.
 // The effect of this is to set -isysroot correctly. We do the same.
-const llvm::Optional detectSysroot() {
+llvm::Optional detectSysroot() {
 #ifndef __APPLE__
   return llvm::None;
 #endif



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


[clang] 2b43bd0 - Remove unused forward declarations (NFC)

2022-08-13 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-13T12:55:47-07:00
New Revision: 2b43bd0bd98a4ae556b0a75b8016e27a0642b8a4

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

LOG: Remove unused forward declarations (NFC)

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h
clang/include/clang/AST/Stmt.h
clang/lib/CodeGen/CGHLSLRuntime.h

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h
index 2c6b1d2805697..e9af9a5bb04fd 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/DirectiveTree.h
@@ -34,7 +34,6 @@
 #include 
 
 namespace clang {
-class LangOptions;
 namespace pseudo {
 
 /// Describes the structure of a source file, as seen by the preprocessor.

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 52c0ca51ea866..49a66a1ea5b86 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -59,7 +59,6 @@ class RecordDecl;
 class SourceManager;
 class StringLiteral;
 class Token;
-class ValueDecl;
 class VarDecl;
 
 
//===--===//

diff  --git a/clang/lib/CodeGen/CGHLSLRuntime.h 
b/clang/lib/CodeGen/CGHLSLRuntime.h
index a8a7c9c7929e6..a7246f7f8919b 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.h
+++ b/clang/lib/CodeGen/CGHLSLRuntime.h
@@ -18,13 +18,10 @@
 #include "clang/Basic/HLSLRuntime.h"
 
 namespace llvm {
-class Value;
 class GlobalVariable;
 class Function;
 } // namespace llvm
 namespace clang {
-class CallExpr;
-class Type;
 class VarDecl;
 
 class FunctionDecl;



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


[PATCH] D131730: __has_trivial_copy should map to __is_trivially_copyable

2022-08-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

Added a backport request here - 
https://github.com/llvm/llvm-project/issues/57140


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131730

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


[PATCH] D3976: -Wcomma, a new warning for questionable uses of the comma operator

2022-08-13 Thread Gregory PAKOSZ via Phabricator via cfe-commits
gpakosz added a comment.
Herald added a project: All.

Hello,

As of today, `-Wcomma` is not really documented: 
https://clang.llvm.org/docs/DiagnosticsReference.html#wcomma

> The current whitelisted expressions are increments, decrements, assignments, 
> compound assignments, overloaded versions of these operators, **and void 
> returning functions**

About `void` returning functions, the following example 
 emits `-Wcomma`:

  void foo()
  {
  
  }
  
  int bar(int i)
  {
return i;
  }
  
  int main(int argc, char* argv[])
  {
if (foo(), bar(argc))
  return 0;
  
return -1;
  }



  :13:12: warning: possible misuse of comma operator here [-Wcomma]
if (foo(), bar(argc))
 ^
  :13:7: note: cast expression to void to silence warning
if (foo(), bar(argc))
^
(void)( )
  1 warning generated.

Should I open a bug?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D3976

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


[PATCH] D128750: [C++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-08-13 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson accepted this revision.
royjacobson added a comment.
This revision is now accepted and ready to land.

Some documentation/test nits, and one question, but otherwise LGTM.
Could you fix the merge conflict? It would be nice to see pre-commit CI results.

Given the complexity of the technical details here, as long as it doesn't 
unreasonably delay this, please wait for other people to also review it.




Comment at: clang/include/clang/AST/DeclTemplate.h:848-856
+
+/// The set of "injected" template arguments used within this
+/// class template.
+///
+/// This pointer refers to the template arguments (there are as
+/// many template arguments as template parameaters) for the class
+/// template, and is allocated lazily, since most class templates do not





Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5161-5163
 /// \param AllowOrderingByConstraints If \c is false, don't check whether one
 /// of the templates is more constrained than the other. Default is true.
 ///

update docs here



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5183
   if (!Better1 && !Better2) // Neither is better than the other
-return JudgeByConstraints();
+return nullptr;
+

Previously we continued to check by constraints, now we directly return 
`nullptr`, doesn't this mean we don't perform constraints checks that we've 
done before? Or was it a bug?



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5234
+  {
+// C++20 [temp.func.order]p6.3:
+//   Otherwise, if the context in which the partial ordering is done is

This comment should be moved down to the `if (TPOC == TPOC_Conversion &&` check.



Comment at: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp:23
 
-template  struct X {};
-
 template  bool operator==(X, V) = delete;
+template bool operator==(X, T);

This is an explicit example from the standard, so I don't like changing it so 
subtly. Could you revert the change and document we're deviating from the 
standard here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D131385: [clangd] Support for standard type hierarchy

2022-08-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Related issue: https://github.com/clangd/clangd/issues/826


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131385

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


[PATCH] D130308: [clang] extend getCommonSugaredType to merge sugar nodes

2022-08-13 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 452459.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1,2 +1,3 @@
 D111283
 D111509
+D130308
Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -38,3 +38,77 @@
 N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}
 N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}
 N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}
+
+template  struct S1 {
+  template  struct S2 {};
+};
+
+N t10 = 0 ? S1() : S1(); // expected-error {{from 'S1' (aka 'S1')}}
+N t11 = 0 ? S1::S2() : S1::S2(); // expected-error {{from 'S1::S2' (aka 'S2')}}
+
+template  using Al = S1;
+
+N t12 = 0 ? Al() : Al(); // expected-error {{from 'Al' (aka 'S1')}}
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(1)))
+using AS1X1 = AS1 B1;
+using AS1Y1 = AS1 B1;
+using AS2Y1 = AS2 B1;
+N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}
+N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}
+
+using FX1 = X1 ();
+using FY1 = Y1 ();
+N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}
+
+struct SS1 {};
+using SB1 = SS1;
+using SX1 = SB1;
+using SY1 = SB1;
+
+using MFX1 = X1 SX1::*();
+using MFY1 = Y1 SY1::*();
+
+N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}
+
+N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}
+
+N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}
+
+struct Enums {
+  enum X : B1;
+  enum Y : ::B1;
+};
+using EnumsB = Enums;
+using EnumsX = EnumsB;
+using EnumsY = EnumsB;
+
+N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};
+// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}
+
+N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};
+// expected-error@-1 {{rvalue of type '__underlying_type(Enums::X)' (aka 'int')}}
+
+using SBTF1 = SS1 [[clang::btf_type_tag("1")]];
+using SBTF2 = ::SS1 [[clang::btf_type_tag("1")]];
+using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
+
+N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 btf_type_tag(1)' (aka 'SS1')}}
+
+using QX = const SB1 *;
+using QY = const ::SB1 *;
+N t23 = 0 ? (QX){} : (QY){}; // expected-error {{rvalue of type 'const SB1 *' (aka 'const SS1 *')}}
+
+template  using Alias = short;
+N t24 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'Alias' (aka 'short')}}
+N t25 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'short'}}
+
+template  concept C1 = true;
+template  concept C2 = true;
+C1 auto t26_1 = (SB1){};
+C1 auto t26_2 = (::SB1){};
+C2 auto t26_3 = (::SB1){};
+N t26 = 0 ? t26_1 : t26_2; // expected-error {{from 'SB1' (aka 'SS1')}}
+N t27 = 0 ? t26_1 : t26_3; // expected-error {{from 'SB1' (aka 'SS1')}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3781,13 +3781,11 @@
 //   - If A is an array type, the pointer type produced by the
 // array-to-pointer standard conversion (4.2) is used in place of
 // A for type deduction; otherwise,
-if (ArgType->isArrayType())
-  ArgType = S.Context.getArrayDecayedType(ArgType);
 //   - If A is a function type, the pointer type produced by the
 // function-to-pointer standard conversion (4.3) is used in place
 // of A for type deduction; otherwise,
-else if (ArgType->isFunctionType())
-  ArgType = S.Context.getPointerType(ArgType);
+if (ArgType->canDecayToPointerType())
+  ArgType = S.Context.getDecayedType(ArgType);
 else {
   // - If A is a cv-qualified type, the top level cv-qualifiers

[PATCH] D130831: [CodeGen] Track DeferredDecls that have been emitted

2022-08-13 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/D130831/new/

https://reviews.llvm.org/D130831

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

> Subject: [clang,flang] Add missing options fsyntax-only in help

Prefer `-fsyntax-only` to `fsyntax-only` since the former is what a user writes.

> this pull request contains a fix for the problem with displaying options 
> -fsyntax_only in clang and fland-new in help

typo: `-fsyntax-only`

"this pull request contains a fix" is verbose. Just use an imperative sentence: 
"Fix ..."




Comment at: clang/include/clang/Driver/Options.td:2798-2799
 def fsyntax_only : Flag<["-"], "fsyntax-only">,
-  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option]>, Group;
+  Flags<[NoXarchOption,CoreOption,CC1Option,FC1Option,FlangOption]>, 
Group,
+  HelpText<"Syntax-check only">;
 def ftabstop_EQ : Joined<["-"], "ftabstop=">, Group;

alexiprof wrote:
> awarzynski wrote:
> > Note that:
> > 
> > ```
> > $ gcc --help=common | grep syntax
> >   -fsyntax-only   Check for syntax errors, then stop.
> > ```
> > 
> > and (from Clang [[ 
> > https://github.com/llvm/llvm-project/blob/main/clang/docs/CommandGuide/clang.rst
> >  | docs ]]
> > >  Run the preprocessor, parser and type checking stages.
> > 
> > For consistency sake, I would replace "Syntax-check only"" with "Run the 
> > preprocessor, parser and type checking stages.". Technically, there's no 
> > separate preprocessor in Flang, but that's IMO tangential to this.
> Yes, i am replace text
semantic analysis is probably better than "type checking".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> https://github.com/llvm/llvm-project/issues/57033

Use `Fix https://github.com/llvm/llvm-project/issues/57033` or `Fixes 
https://github.com/llvm/llvm-project/issues/57033` or (I usually prefer this 
for non-bugs but still some issues worth addressing) `Close ...`, then the 
issue will be automatically closed when you push the commit to origin/main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Alexander Malkov via Phabricator via cfe-commits
alexiprof added a comment.

I do not have commit access, i do not have merge :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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


[PATCH] D131808: [clang,flang] Add missing options fsyntax-only in help

2022-08-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

To be clear, some issues should be addressed before someone lands this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131808

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