[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (!VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),

This seems to trigger even when the type is dependent:
```
:1:36: warning: definition of a variable of non-literal type in a 
constexpr function is incompatible with C++ standards before C++2b 
[-Wpre-c++2b-compat]
auto qq = [](auto x) { decltype(x) n; };
   ^
1 warning generated.
```

This also seems to emit even when `Kind` is not 
`Sema::CheckConstexprKind::Diagnose` (unlike the `static`/`thread_local` case 
above). Is the `CheckLiteralType` logic not reusable for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417534.
cor3ntin added a comment.

- Check That the type is dependant
- Only emit the warning when Kind == Sema::CheckConstexprKind::Diagnose


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -96,7 +96,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +164,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,8 +228,8 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
-  return [](bool b) { // cxx2a-note {{declared here}}
+constexpr auto dependent_var_def_lambda() {
+  return [](bool b) {
 if (!b)
   T t;
 return 0;
@@ -237,4 +238,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -30,12 +30,13 @@
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,10 +1901,16 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_non_literal_type,
- isa(Dcl)))
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (Kind == Sema::CheckConstexprKind::Diagnose &&
+  !VD->getType()->isDependentType() && !VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),
+ diag::warn_cxx20_compat_constexpr_var)
+<< isa(Dcl) << 2;
+} else if (CheckLiteralType(
+   SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::err_constexpr_local_var_non_literal_type,
+   isa(Dcl)))
   return false;
 if (!VD->getType()->isDependentType() &&
  

[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 417533.
thieta added a comment.

Added back removed blank line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122298

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -396,6 +396,8 @@
 // RUN:/volatile:iso \
 // RUN:/w12345 \
 // RUN:/wd1234 \
+// RUN:/Wv \
+// RUN:/Wv:17 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
 // RUN:/Zc:forScope \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2493,12 +2493,12 @@
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
   HelpText<"Assert no thread in a parallel region modifies an ICV">,
   MarshallingInfoFlag>;
-def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, 
Group, 
-  Flags<[CC1Option, NoArgumentUnused]>, 
+def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, 
Group,
+  Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Do not create a host fallback if offloading to the device fails.">,
   MarshallingInfoFlag>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
@@ -6528,6 +6528,7 @@
 def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
   HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -396,6 +396,8 @@
 // RUN:/volatile:iso \
 // RUN:/w12345 \
 // RUN:/wd1234 \
+// RUN:/Wv \
+// RUN:/Wv:17 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
 // RUN:/Zc:forScope \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2493,12 +2493,12 @@
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], "fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], "fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], "fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
   HelpText<"Assert no thread in a parallel region modifies an ICV">,
   MarshallingInfoFlag>;
-def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, Group, 
-  Flags<[CC1Option, NoArgumentUnused]>, 
+def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, Group,
+  Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Do not create a host fallback if offloading to the device fails.">,
   MarshallingInfoFlag>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
@@ -6528,6 +6528,7 @@
 def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
   HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417535.
cor3ntin added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -96,7 +96,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +164,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,8 +228,8 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
-  return [](bool b) { // cxx2a-note {{declared here}}
+constexpr auto dependent_var_def_lambda() {
+  return [](bool b) {
 if (!b)
   T t;
 return 0;
@@ -237,4 +238,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -30,12 +30,13 @@
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,10 +1901,17 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_non_literal_type,
- isa(Dcl)))
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (Kind == Sema::CheckConstexprKind::Diagnose &&
+  !VD->getType()->isDependentType() &&
+  !VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),
+ diag::warn_cxx20_compat_constexpr_var)
+<< isa(Dcl) << 2;
+} else if (CheckLiteralType(
+   SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::err_constexpr_local_var_non_literal_type,
+   isa(Dcl)))
   return false;
 if (!VD->getType()->isDependentType() &&
 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
Index: 

[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2496
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,

Do we mind removing these trailing whitespaces in the same commit? I can fix 
that - but they shouldn't be there anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122298

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


[PATCH] D118052: [X86] Fix CodeGen Module Flag for -mibt-seal

2022-03-23 Thread Joao Moreira via Phabricator via cfe-commits
joaomoreira updated this revision to Diff 417539.
joaomoreira edited the summary of this revision.
joaomoreira added a reviewer: nickdesaulniers.
This revision is now accepted and ready to land.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118052

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/X86/x86-cf-protection.c


Index: clang/test/CodeGen/X86/x86-cf-protection.c
===
--- clang/test/CodeGen/X86/x86-cf-protection.c
+++ clang/test/CodeGen/X86/x86-cf-protection.c
@@ -1,8 +1,17 @@
 // RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - 
-fcf-protection=return %s | FileCheck %s --check-prefix=RETURN
 // RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - 
-fcf-protection=branch %s | FileCheck %s --check-prefix=BRANCH
 // RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - 
-fcf-protection=full %s   | FileCheck %s --check-prefix=FULL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S 
-fcf-protection=branch -mibt-seal -flto %s | FileCheck %s --check-prefix=IBTSEAL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S 
-fcf-protection=branch -flto %s | FileCheck %s --check-prefix=NOIBTSEAL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S 
-fcf-protection=branch -mibt-seal %s | FileCheck %s --check-prefix=NOLTO
 
 // RETURN: #define __CET__ 2
 // BRANCH: #define __CET__ 1
 // FULL: #define __CET__ 3
+// IBTSEAL: "cf-protection-branch", i32 1
+// IBTSEAL: "ibt-seal", i32 1
+// NOIBTSEAL: "cf-protection-branch", i32 1
+// NOIBTSEAL-NOT: "ibt-seal", i32 1
+// NOLTO: "cf-protection-branch", i32 1
+// NOLTO-NOT: "ibt-seal", i32 1
 void foo() {}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1478,6 +1478,9 @@
   else if (Opts.CFProtectionBranch)
 GenerateArg(Args, OPT_fcf_protection_EQ, "branch", SA);
 
+  if (Opts.IBTSeal)
+GenerateArg(Args, OPT_mibt_seal, SA);
+
   for (const auto  : Opts.LinkBitcodeFiles) {
 bool Builtint = F.LinkFlags == llvm::Linker::Flags::LinkOnlyNeeded &&
 F.PropagateAttrs && F.Internalize;


Index: clang/test/CodeGen/X86/x86-cf-protection.c
===
--- clang/test/CodeGen/X86/x86-cf-protection.c
+++ clang/test/CodeGen/X86/x86-cf-protection.c
@@ -1,8 +1,17 @@
 // RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=return %s | FileCheck %s --check-prefix=RETURN
 // RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=branch %s | FileCheck %s --check-prefix=BRANCH
 // RUN: %clang -target i386-unknown-unknown -x c -E -dM -o - -fcf-protection=full %s   | FileCheck %s --check-prefix=FULL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S -fcf-protection=branch -mibt-seal -flto %s | FileCheck %s --check-prefix=IBTSEAL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S -fcf-protection=branch -flto %s | FileCheck %s --check-prefix=NOIBTSEAL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S -fcf-protection=branch -mibt-seal %s | FileCheck %s --check-prefix=NOLTO
 
 // RETURN: #define __CET__ 2
 // BRANCH: #define __CET__ 1
 // FULL: #define __CET__ 3
+// IBTSEAL: "cf-protection-branch", i32 1
+// IBTSEAL: "ibt-seal", i32 1
+// NOIBTSEAL: "cf-protection-branch", i32 1
+// NOIBTSEAL-NOT: "ibt-seal", i32 1
+// NOLTO: "cf-protection-branch", i32 1
+// NOLTO-NOT: "ibt-seal", i32 1
 void foo() {}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1478,6 +1478,9 @@
   else if (Opts.CFProtectionBranch)
 GenerateArg(Args, OPT_fcf_protection_EQ, "branch", SA);
 
+  if (Opts.IBTSeal)
+GenerateArg(Args, OPT_mibt_seal, SA);
+
   for (const auto  : Opts.LinkBitcodeFiles) {
 bool Builtint = F.LinkFlags == llvm::Linker::Flags::LinkOnlyNeeded &&
 F.PropagateAttrs && F.Internalize;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122277: [analyzer] Fix crash in RangedConstraintManager.cpp

2022-03-23 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 417525.
vabridgers added a comment.

update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122277

Files:
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/symbol-simplification-bo-div.c

Index: clang/test/Analysis/symbol-simplification-bo-div.c
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-bo-div.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \
+// RUN:-triple x86_64-pc-linux-gnu -verify
+
+// don't crash
+// expected-no-diagnostics
+
+int a, b;
+int c(void) {
+  unsigned d = a;
+  --d;
+  short e = b / b - a;
+  ++e;
+  return d <= 0 && e && e;
+}
Index: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -48,47 +48,48 @@
 
   if (const auto *SSE = dyn_cast(Sym)) {
 BinaryOperator::Opcode Op = SSE->getOpcode();
-assert(BinaryOperator::isComparisonOp(Op));
-
-// We convert equality operations for pointers only.
-if (Loc::isLocType(SSE->getLHS()->getType()) &&
-Loc::isLocType(SSE->getRHS()->getType())) {
-  // Translate "a != b" to "(b - a) != 0".
-  // We invert the order of the operands as a heuristic for how loop
-  // conditions are usually written ("begin != end") as compared to length
-  // calculations ("end - begin"). The more correct thing to do would be to
-  // canonicalize "a - b" and "b - a", which would allow us to treat
-  // "a != b" and "b != a" the same.
-
-  SymbolManager  = getSymbolManager();
-  QualType DiffTy = SymMgr.getContext().getPointerDiffType();
-  SymbolRef Subtraction =
-  SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
-
-  const llvm::APSInt  = getBasicVals().getValue(0, DiffTy);
-  Op = BinaryOperator::reverseComparisonOp(Op);
-  if (!Assumption)
-Op = BinaryOperator::negateComparisonOp(Op);
-  return assumeSymRel(State, Subtraction, Op, Zero);
-}
+if (BinaryOperator::isComparisonOp(Op)) {
+
+  // We convert equality operations for pointers only.
+  if (Loc::isLocType(SSE->getLHS()->getType()) &&
+  Loc::isLocType(SSE->getRHS()->getType())) {
+// Translate "a != b" to "(b - a) != 0".
+// We invert the order of the operands as a heuristic for how loop
+// conditions are usually written ("begin != end") as compared to length
+// calculations ("end - begin"). The more correct thing to do would be
+// to canonicalize "a - b" and "b - a", which would allow us to treat
+// "a != b" and "b != a" the same.
+
+SymbolManager  = getSymbolManager();
+QualType DiffTy = SymMgr.getContext().getPointerDiffType();
+SymbolRef Subtraction =
+SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
+
+const llvm::APSInt  = getBasicVals().getValue(0, DiffTy);
+Op = BinaryOperator::reverseComparisonOp(Op);
+if (!Assumption)
+  Op = BinaryOperator::negateComparisonOp(Op);
+return assumeSymRel(State, Subtraction, Op, Zero);
+  }
 
-if (BinaryOperator::isEqualityOp(Op)) {
-  SymbolManager  = getSymbolManager();
+  if (BinaryOperator::isEqualityOp(Op)) {
+SymbolManager  = getSymbolManager();
 
-  QualType ExprType = SSE->getType();
-  SymbolRef CanonicalEquality =
-  SymMgr.getSymSymExpr(SSE->getLHS(), BO_EQ, SSE->getRHS(), ExprType);
+QualType ExprType = SSE->getType();
+SymbolRef CanonicalEquality =
+SymMgr.getSymSymExpr(SSE->getLHS(), BO_EQ, SSE->getRHS(), ExprType);
 
-  bool WasEqual = SSE->getOpcode() == BO_EQ;
-  bool IsExpectedEqual = WasEqual == Assumption;
+bool WasEqual = SSE->getOpcode() == BO_EQ;
+bool IsExpectedEqual = WasEqual == Assumption;
 
-  const llvm::APSInt  = getBasicVals().getValue(0, ExprType);
+const llvm::APSInt  = getBasicVals().getValue(0, ExprType);
 
-  if (IsExpectedEqual) {
-return assumeSymNE(State, CanonicalEquality, Zero, Zero);
-  }
+if (IsExpectedEqual) {
+  return assumeSymNE(State, CanonicalEquality, Zero, Zero);
+}
 
-  return assumeSymEQ(State, CanonicalEquality, Zero, Zero);
+return assumeSymEQ(State, CanonicalEquality, Zero, Zero);
+  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (!VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),

hubert.reinterpretcast wrote:
> This seems to trigger even when the type is dependent:
> ```
> :1:36: warning: definition of a variable of non-literal type in a 
> constexpr function is incompatible with C++ standards before C++2b 
> [-Wpre-c++2b-compat]
> auto qq = [](auto x) { decltype(x) n; };
>^
> 1 warning generated.
> ```
> 
> This also seems to emit even when `Kind` is not 
> `Sema::CheckConstexprKind::Diagnose` (unlike the `static`/`thread_local` case 
> above). Is the `CheckLiteralType` logic not reusable for this?
You are right, thanks for noticing that, it was rather bogus.
The reason I'm not using CheckLiteralType is to avoid duplicating a diagnostics 
message, as CheckLiteralType doesn't allow us to pass parameter to the 
diagnostic message.

It leaves us with an uncovered scenario though: We do not emit the warning on 
template instantiation, and I don't think there is an  easy way to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

The patch itself seems sensible to me.




Comment at: clang/include/clang/Driver/Options.td:2496
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,

thieta wrote:
> Do we mind removing these trailing whitespaces in the same commit? I can fix 
> that - but they shouldn't be there anyway.
I think it'd be fine to just push such a commit without taking it through 
review, marked as NFC (no functional changes). Or keep it here but split it out 
into a separate commit before pushing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122298

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


[PATCH] D122231: [clang][dataflow] Add support for `value_or` in a comparison.

2022-03-23 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:119
+  auto NonEmptyStringOptional = unaryOperator(
+  hasOperatorName("!"),
+  hasUnaryOperand(cxxMemberCallExpr(

Why handle negation here? Would it work for `if (opt.value_or("").empty()) { 
... } else { opt.value(); }`?



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:148
+anyOf(ComparesToSame(cxxNullPtrLiteralExpr()),
+  
ComparesToSame(integerLiteral(equals(0)));
+}

Why `0`? How about `opt_p->value_or(21) != 21`?



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:480
 
+  // opt.value_or(X) != X, !opt.value_or("").empty():
+  .CaseOf(

Extreme nit for consistency with all comments above.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:482
+  .CaseOf(
+  isValueOrCondition("ValueOrCall"),
+  [](const clang::Expr *E, const MatchFinder::MatchResult ,

Why not hard-code this in the `isValueOrCondition` matcher?



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:483
+  isValueOrCondition("ValueOrCall"),
+  [](const clang::Expr *E, const MatchFinder::MatchResult ,
+ LatticeTransferState ) {

The `clang` namespace can be removed. Same comment for other instances in the 
patch.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:485
+ LatticeTransferState ) {
+transferOptionalValueOrCall(
+E,

Why not pass `transferOptionalValueOrCall` as argument instead of wrapping it 
in a lambda? The function can take the "ValueOrCall" node from the 
`MatchResult`.



Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1722
+  if (opt.value_or(nullptr) != nullptr) {
+return *opt;
+/*[[check-ptrs-1]]*/

Is the `return` important? I think having `void` return type would be simpler. 
Same comment for the cases below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122231

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


[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

Looks great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122298

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


[PATCH] D115248: [Clang] Fix PR28101

2022-03-23 Thread PoYao Chang via Phabricator via cfe-commits
rZhBoYao updated this revision to Diff 417504.
rZhBoYao set the repository for this revision to rG LLVM Github Monorepo.
rZhBoYao added a comment.

Diagnose "same name as its class" before setting the declarator invalid as 
otherwise it would not be diagnosed. This also aligns with gcc's behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115248

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/PR28101.cpp


Index: clang/test/SemaCXX/PR28101.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR28101.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_1 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_2 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_3 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_4 -std=c++17 %s
+
+// Don't crash.
+
+#ifdef CASE_1
+
+template  struct A {
+  A(void *) {}
+  T(A){}; // expected-error{{member 'A' cannot have template arguments}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};
+
+A instantiate() { return {nullptr}; }
+
+#elifdef CASE_2
+
+template  struct A {
+  A(void *) {}
+  T A{}; // expected-error{{member 'A' cannot have template arguments}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};
+
+A instantiate() { return {nullptr}; }
+
+#elifdef CASE_3
+
+template  struct S {};
+
+template  struct A {
+  A(void *) {}
+  T S{}; // expected-error{{member 'S' cannot have template arguments}}
+};
+
+A instantiate() { return {nullptr}; }
+
+#elifdef CASE_4
+
+template  typename U> class A {
+public:
+  A(void *) {}
+  T(A>) {} // expected-error{{member 'A' cannot have template 
arguments}}\
+  // expected-error{{expected ';' at end of declaration list}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};
+
+template  struct S {};
+
+A foo() { return A(nullptr); }
+
+#endif
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3427,6 +3427,9 @@
   << SourceRange(D.getName().TemplateId->LAngleLoc,
  D.getName().TemplateId->RAngleLoc)
   << D.getName().TemplateId->LAngleLoc;
+  if (cast(CurContext)->getDeclName() == Name)
+Diag(Loc, diag::err_member_name_of_class) << Name;
+  D.setInvalidType();
 }
 
 if (SS.isSet() && !SS.isInvalid()) {


Index: clang/test/SemaCXX/PR28101.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/PR28101.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_1 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_2 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_3 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -DCASE_4 -std=c++17 %s
+
+// Don't crash.
+
+#ifdef CASE_1
+
+template  struct A {
+  A(void *) {}
+  T(A){}; // expected-error{{member 'A' cannot have template arguments}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};
+
+A instantiate() { return {nullptr}; }
+
+#elifdef CASE_2
+
+template  struct A {
+  A(void *) {}
+  T A{}; // expected-error{{member 'A' cannot have template arguments}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};
+
+A instantiate() { return {nullptr}; }
+
+#elifdef CASE_3
+
+template  struct S {};
+
+template  struct A {
+  A(void *) {}
+  T S{}; // expected-error{{member 'S' cannot have template arguments}}
+};
+
+A instantiate() { return {nullptr}; }
+
+#elifdef CASE_4
+
+template  typename U> class A {
+public:
+  A(void *) {}
+  T(A>) {} // expected-error{{member 'A' cannot have template arguments}}\
+  // expected-error{{expected ';' at end of declaration list}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};
+
+template  struct S {};
+
+A foo() { return A(nullptr); }
+
+#endif
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3427,6 +3427,9 @@
   << SourceRange(D.getName().TemplateId->LAngleLoc,
  D.getName().TemplateId->RAngleLoc)
   << D.getName().TemplateId->LAngleLoc;
+  if (cast(CurContext)->getDeclName() == Name)
+Diag(Loc, diag::err_member_name_of_class) << Name;
+  D.setInvalidType();
 }
 
 if (SS.isSet() && !SS.isInvalid()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 417509.

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

https://reviews.llvm.org/D121201

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCL/address-spaces.cl

Index: clang/test/SemaOpenCL/address-spaces.cl
===
--- clang/test/SemaOpenCL/address-spaces.cl
+++ clang/test/SemaOpenCL/address-spaces.cl
@@ -258,7 +258,7 @@
 
 void func_multiple_addr2(void) {
   typedef __private int private_int_t;
-  __private __attribute__((opencl_global)) int var1;   // expected-error {{multiple address spaces specified for type}} \
+  __attribute__((opencl_global)) __private int var1;   // expected-error {{multiple address spaces specified for type}} \
// expected-error {{function scope variable cannot be declared in global address space}}
   __private __attribute__((opencl_global)) int *var2;  // expected-error {{multiple address spaces specified for type}}
   __attribute__((opencl_global)) private_int_t var3;   // expected-error {{multiple address spaces specified for type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -368,7 +368,8 @@
 };
 
 static void processTypeAttrs(TypeProcessingState , QualType ,
- TypeAttrLocation TAL, ParsedAttributesView );
+ TypeAttrLocation TAL,
+ const ParsedAttributesView );
 
 static bool handleFunctionTypeAttr(TypeProcessingState , ParsedAttr ,
QualType );
@@ -8138,7 +8139,12 @@
 
 static void processTypeAttrs(TypeProcessingState , QualType ,
  TypeAttrLocation TAL,
- ParsedAttributesView ) {
+ const ParsedAttributesView ) {
+
+  state.setParsedNoDeref(false);
+  if (attrs.empty())
+return;
+
   // Scan through and apply attributes to this type where it makes sense.  Some
   // attributes (such as __address_space__, __vector_size__, etc) apply to the
   // type, but others can be present in the type specifiers even though they
@@ -8148,9 +8154,6 @@
   // sure we visit every element once. Copy the attributes list, and iterate
   // over that.
   ParsedAttributesView AttrsCopy{attrs};
-
-  state.setParsedNoDeref(false);
-
   for (ParsedAttr  : AttrsCopy) {
 
 // Skip attributes that were marked to be invalid.
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -495,8 +495,7 @@
   }
 }
 
-void Sema::ProcessStmtAttributes(Stmt *S,
- const ParsedAttributesWithRange ,
+void Sema::ProcessStmtAttributes(Stmt *S, const ParsedAttributes ,
  SmallVectorImpl ) {
   for (const ParsedAttr  : InAttrs) {
 if (const Attr *A = ProcessStmtAttribute(*this, S, AL, InAttrs.Range))
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -587,7 +587,7 @@
   return AttributedStmt::Create(Context, AttrsLoc, Attrs, SubStmt);
 }
 
-StmtResult Sema::ActOnAttributedStmt(const ParsedAttributesWithRange ,
+StmtResult Sema::ActOnAttributedStmt(const ParsedAttributes ,
  Stmt *SubStmt) {
   SmallVector SemanticAttrs;
   ProcessStmtAttributes(SubStmt, Attrs, SemanticAttrs);
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2615,12 +2615,11 @@
 /// example:
 ///class foo : public bar, virtual private baz {
 /// 'public bar' and 'virtual private baz' are each base-specifiers.
-BaseResult
-Sema::ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange,
- ParsedAttributes ,
- bool Virtual, AccessSpecifier Access,
- ParsedType basetype, SourceLocation BaseLoc,
- SourceLocation EllipsisLoc) {

[PATCH] D122237: [clang][lex] Fix failures with Microsoft header search rules

2022-03-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 417527.
jansvoboda11 added a comment.

Remove slash from test to make it pass on Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122237

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Preprocessor/microsoft-header-search-fail.c


Index: clang/test/Preprocessor/microsoft-header-search-fail.c
===
--- /dev/null
+++ clang/test/Preprocessor/microsoft-header-search-fail.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly -fms-compatibility %t/test.c -I %t/include -verify
+
+//--- test.c
+#include "x/header.h"
+#include "z/header.h"
+
+// expected-warning-re@include/y/header.h:1 {{#include resolved using 
non-portable Microsoft search rules as: {{.*}}x/culprit.h}}
+// expected-error@include/z/header.h:1 {{'culprit.h' file not found}}
+
+//--- include/x/header.h
+#include "y/header.h"
+
+//--- include/y/header.h
+#include "culprit.h"
+
+//--- include/x/culprit.h
+
+//--- include/z/header.h
+#include "culprit.h"
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -976,7 +976,8 @@
   // this is a matching hit.
   if (!SkipCache && CacheLookup.StartIt == NextIt) {
 // Skip querying potentially lots of directories for this lookup.
-It = CacheLookup.HitIt;
+if (CacheLookup.HitIt)
+  It = CacheLookup.HitIt;
 if (CacheLookup.MappedName) {
   Filename = CacheLookup.MappedName;
   if (IsMapped)


Index: clang/test/Preprocessor/microsoft-header-search-fail.c
===
--- /dev/null
+++ clang/test/Preprocessor/microsoft-header-search-fail.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly -fms-compatibility %t/test.c -I %t/include -verify
+
+//--- test.c
+#include "x/header.h"
+#include "z/header.h"
+
+// expected-warning-re@include/y/header.h:1 {{#include resolved using non-portable Microsoft search rules as: {{.*}}x/culprit.h}}
+// expected-error@include/z/header.h:1 {{'culprit.h' file not found}}
+
+//--- include/x/header.h
+#include "y/header.h"
+
+//--- include/y/header.h
+#include "culprit.h"
+
+//--- include/x/culprit.h
+
+//--- include/z/header.h
+#include "culprit.h"
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -976,7 +976,8 @@
   // this is a matching hit.
   if (!SkipCache && CacheLookup.StartIt == NextIt) {
 // Skip querying potentially lots of directories for this lookup.
-It = CacheLookup.HitIt;
+if (CacheLookup.HitIt)
+  It = CacheLookup.HitIt;
 if (CacheLookup.MappedName) {
   Filename = CacheLookup.MappedName;
   if (IsMapped)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118052: [X86] Fix CodeGen Module Flag for -mibt-seal

2022-03-23 Thread Joao Moreira via Phabricator via cfe-commits
joaomoreira added a comment.

I did track down the problem to clang/lib/Frontend/CompilerInvocation.cpp -- 
RoundTrip method. There, we can se the following statement:

  #ifndef NDEBUG
bool DoRoundTripDefault = true;
  #else
bool DoRoundTripDefault = false;
  #endif

Comment in the file says: "By default, the round-trip is enabled in assert 
builds... During round-trip, the command line arguments are parsed into a dummy 
instance of CompilerInvocation which is used to generate the command line 
arguments again. The real CompilerInvocation instance is then created by 
parsing the generated arguments, not the original ones.". Then, because the 
arguments set through this latest patch were not being generated, they would be 
missing in the dummy instance of CompilerInvocation and then not repassed into 
the real instance.

Given the above, my understanding is that there was never an actual bug that 
made ibt-seal stop working. The patch was just not tested enough and a 
confusion in different build setups blinded me against what was really 
happening.

Thank you for pushing me into looking into this @aaron.ballman. Also, with all 
this said, I'm no expert in clang/front-end, so it would be great if you could 
give an additional look into it and confirm the above.

If all is right, the patch remains correct and there are no hidden bugs. I'll 
update the patch shortly to add the test requested by @pengfei.


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

https://reviews.llvm.org/D118052

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


[clang] 09c0685 - [NFC] Remove trailing whitespaces in clang/Driver/Options.td

2022-03-23 Thread Tobias Hieta via cfe-commits

Author: Tobias Hieta
Date: 2022-03-23T10:23:33+01:00
New Revision: 09c0685a043dd4028545c134b562c2605e294855

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

LOG: [NFC] Remove trailing whitespaces in clang/Driver/Options.td

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2a23695c149fa..c56578b34641a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2493,12 +2493,12 @@ def fno_openmp_assume_teams_oversubscription : 
Flag<["-"], "fno-openmp-assume-te
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
   HelpText<"Assert no thread in a parallel region modifies an ICV">,
   MarshallingInfoFlag>;
-def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, 
Group, 
-  Flags<[CC1Option, NoArgumentUnused]>, 
+def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, 
Group,
+  Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Do not create a host fallback if offloading to the device fails.">,
   MarshallingInfoFlag>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",



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


[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Pushed the whitespace fix as a NFC here: 
https://github.com/llvm/llvm-project/commit/09c0685a043dd4028545c134b562c2605e294855


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122298

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


[PATCH] D122141: [clang][extract-api] Suppprt for the module name property in SymbolGraph

2022-03-23 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

In D122141#3400578 , @zixuw wrote:

> LGTM. Need to rebase. Do you think `ProductName` should be a general property 
> of `APISerializer` or something specific to the `SymbolGraphSerializer`?

Good question! I think I am going to make it a general property of the 
APISerializer as it isn't a symbol graph specific concept IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122141

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


[PATCH] D122285: [analyzer] Add path note tags to standard library function summaries.

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

> The notes are prunable, i.e. they won't bring-in entire stack frames worth of 
> notes just because they're there, but they will be always visible regardless 
> of whether the value is of interest to the bug report. I think this is 
> debatable, the arguably better solution is to make them non-prunable but 
> conditional to the value being tracked back to the call, which would probably 
> need a better tracking infrastructure.

I was thinking of passing a lambda and doing the rest there. We could have 
lambda factories to make it less cumbersome to define - and also reuse code.

IMO this is a nice increment.


Repository:
  rC Clang

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

https://reviews.llvm.org/D122285

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


[PATCH] D121593: [clangd][WIP] Provide clang-include-cleaner

2022-03-23 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

This sounds really cool!

>> Overall I suspect making this a tidy check would make it more useful to more 
>> people.

Yup, it would be super useful addition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121593

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


[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

2022-03-23 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I'm a little uncomfortable with

  //#

becoming

  // #


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx2b.cpp:219
+  NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be 
used in a constant expression}} \
+// cxx2b-warning {{definition of a variable of non-literal 
type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;

Not sure how much we want the message in this case. The lambda is not marked 
`constexpr` (although it is implicitly `constexpr` in C++2b).

Note that we don't get a message for this:
```
auto qq = [] { return 0; static int x = 42; };
constexpr int qx = qq();
```

I am not sure how difficult it would be to come at this from the 
used-in-constant-evaluation side, but there is probably a larger class of 
messages in the same situation (so it would probably be a separate endeavour).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[PATCH] D122278: [clang] Improve diagnostic for reopened inline namespace

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

This looks good to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122278

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


[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 417537.
thieta added a comment.

Split whitespace to it's own commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122298

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -396,6 +396,8 @@
 // RUN:/volatile:iso \
 // RUN:/w12345 \
 // RUN:/wd1234 \
+// RUN:/Wv \
+// RUN:/Wv:17 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
 // RUN:/Zc:forScope \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6528,6 +6528,7 @@
 def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
   HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -396,6 +396,8 @@
 // RUN:/volatile:iso \
 // RUN:/w12345 \
 // RUN:/wd1234 \
+// RUN:/Wv \
+// RUN:/Wv:17 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
 // RUN:/Zc:forScope \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6528,6 +6528,7 @@
 def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
   HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a451a29 - [CodeGen][OpenMP] Add alignment to test (NFC)

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T10:28:04+01:00
New Revision: a451a291278b22b031b2b6d8ca4a3b2517a491f6

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

LOG: [CodeGen][OpenMP] Add alignment to test (NFC)

Check which alignments are generated for loads and stores.

Added: 


Modified: 
clang/test/OpenMP/task_codegen.c

Removed: 




diff  --git a/clang/test/OpenMP/task_codegen.c 
b/clang/test/OpenMP/task_codegen.c
index fa5c0e9f425ca..ae606c202c651 100644
--- a/clang/test/OpenMP/task_codegen.c
+++ b/clang/test/OpenMP/task_codegen.c
@@ -32,87 +32,87 @@ int main(void) {
   // CHECK: [[ALLOC:%.+]] = call i8* @__kmpc_omp_task_alloc(%struct.ident_t* 
@{{.+}}, i32 [[GTID]], i32 65, i64 48, i64 0, i32 (i32, i8*)* bitcast (i32 
(i32, [[PRIVATES_TY:%.+]]*)* [[TASK_ENTRY:@.+]] to i32 (i32, i8*)*))
   // CHECK: [[EVT_VAL:%.+]] = call i8* 
@__kmpc_task_allow_completion_event(%struct.ident_t* @{{.+}}, i32 [[GTID]], i8* 
[[ALLOC]])
   // CHECK: [[CAST_EVT_VAL:%.+]] = ptrtoint i8* [[EVT_VAL]] to i64
-  // CHECK: store i64 [[CAST_EVT_VAL]], i64* [[EVT_ADDR]],
+  // CHECK: store i64 [[CAST_EVT_VAL]], i64* [[EVT_ADDR]], align 8
   // CHECK: [[DATA:%.+]] = bitcast i8* [[ALLOC]] to [[PRIVATES_TY]]*
-  // CHECK: [[D:%.+]] = load i8*, i8** [[D_ADDR]],
+  // CHECK: [[D:%.+]] = load i8*, i8** [[D_ADDR]], align 8
   // CHECK: [[D_DEP:%.+]] = bitcast i8* [[D]] to %struct.kmp_depend_info*
   // CHECK: [[D_DEP_BASE:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[D_DEP]], i{{.+}} -1
   // CHECK: [[D_DEP_BASE_SIZE:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[D_DEP_BASE]], i{{.+}} 0, 
i{{.+}} 0
-  // CHECK: [[SIZE1:%.+]] = load i64, i64* [[D_DEP_BASE_SIZE]],
-  // CHECK-DAG: store i64 0, i64* [[DEPOBJ_SIZE_ADDR]],
-  // CHECK: [[SZ:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR]],
+  // CHECK: [[SIZE1:%.+]] = load i64, i64* [[D_DEP_BASE_SIZE]], align 8
+  // CHECK-DAG: store i64 0, i64* [[DEPOBJ_SIZE_ADDR]], align 8
+  // CHECK: [[SZ:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR]], align 8
   // CHECK: [[SIZE:%.+]] = add nuw i64 [[SZ]], [[SIZE1]]
-  // CHECK: store i64 [[SIZE]], i64* [[DEPOBJ_SIZE_ADDR]],
-  // CHECK: [[X:%.+]] = load i8*, i8** [[X_ADDR]],
+  // CHECK: store i64 [[SIZE]], i64* [[DEPOBJ_SIZE_ADDR]], align 8
+  // CHECK: [[X:%.+]] = load i8*, i8** [[X_ADDR]], align 8
   // CHECK: [[X_DEP:%.+]] = bitcast i8* [[X]] to %struct.kmp_depend_info*
   // CHECK: [[X_DEP_BASE:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[X_DEP]], i{{.+}} -1
   // CHECK: [[X_DEP_BASE_SIZE:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[X_DEP_BASE]], i{{.+}} 0, 
i{{.+}} 0
-  // CHECK: [[SIZE2:%.+]] = load i64, i64* [[X_DEP_BASE_SIZE]],
-  // CHECK-DAG: store i64 0, i64* [[DEPOBJ_SIZE_ADDR1]],
-  // CHECK: [[SZ:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR1]],
+  // CHECK: [[SIZE2:%.+]] = load i64, i64* [[X_DEP_BASE_SIZE]], align 8
+  // CHECK-DAG: store i64 0, i64* [[DEPOBJ_SIZE_ADDR1]], align 8
+  // CHECK: [[SZ:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR1]], align 8
   // CHECK: [[SIZE3:%.+]] = add nuw i64 [[SZ]], [[SIZE2]]
-  // CHECK: store i64 [[SIZE3]], i64* [[DEPOBJ_SIZE_ADDR1]],
-  // CHECK: [[SZ:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR]],
-  // CHECK: [[SZ1:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR1]],
+  // CHECK: store i64 [[SIZE3]], i64* [[DEPOBJ_SIZE_ADDR1]], align 8
+  // CHECK: [[SZ:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR]], align 8
+  // CHECK: [[SZ1:%.+]] = load i64, i64* [[DEPOBJ_SIZE_ADDR1]], align 8
   // CHECK: [[SIZE1:%.+]] = add nuw i64 0, [[SZ]]
   // CHECK: [[SIZE2:%.+]] = add nuw i64 [[SIZE1]], [[SZ1]]
   // CHECK: [[SIZE:%.+]] = add nuw i64 [[SIZE2]], 2
   // CHECK: [[SV:%.+]] = call i8* @llvm.stacksave()
-  // CHECK: store i8* [[SV]], i8** [[SV_ADDR:%.+]],
+  // CHECK: store i8* [[SV]], i8** [[SV_ADDR:%.+]], align 8
   // CHECK: [[VLA:%.+]] = alloca %struct.kmp_depend_info, i64 [[SIZE]],
   // CHECK: [[SIZE32:%.+]] = trunc i64 [[SIZE]] to i32
   // CHECK: [[VLA0:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[VLA]], i64 0
   // CHECK: [[BASE_ADDR:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[VLA0]], i{{.+}} 0, i{{.+}} 0
   // CHECK: [[A_ADDR_CAST:%.+]] = ptrtoint i32* [[A_ADDR]] to i64
-  // CHECK: store i64 [[A_ADDR_CAST]], i64* [[BASE_ADDR]],
+  // CHECK: store i64 [[A_ADDR_CAST]], i64* [[BASE_ADDR]], align 16
   // CHECK: [[SIZE_ADDR:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[VLA0]], i{{.+}} 0, i{{.+}} 1
-  // CHECK: store i64 4, i64* [[SIZE_ADDR]],
+  // CHECK: store i64 4, i64* [[SIZE_ADDR]], align 8
   // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds 

[clang] eb5ecbb - [llvm][AArch64] Insert "bti j" after call to setjmp

2022-03-23 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2022-03-23T09:51:02Z
New Revision: eb5ecbbcbb6ce38e29237ab5d17156fcb2e96e74

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

LOG: [llvm][AArch64] Insert "bti j" after call to setjmp

Some implementations of setjmp will end with a br instead of a ret.
This means that the next instruction after a call to setjmp must be
a "bti j" (j for jump) to make this work when branch target identification
is enabled.

The BTI extension was added in armv8.5-a but the bti instruction is in the
hint space. This means we can emit it for any architecture version as long
as branch target enforcement flags are passed.

The starting point for the hint number is 32 then call adds 2, jump adds 4.
Hence "hint #36" for a "bti j" (and "hint #34" for the "bti c" you see
at the start of functions).

The existing Arm command line option -mno-bti-at-return-twice has been
applied to AArch64 as well.

Support is added to SelectionDAG Isel and GlobalIsel. FastIsel will
defer to SelectionDAG.

Based on the change done for M profile Arm in https://reviews.llvm.org/D112427

Fixes #4

Reviewed By: danielkiss

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

Added: 
llvm/test/CodeGen/AArch64/setjmp-bti-no-enforcement.ll
llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
llvm/test/CodeGen/AArch64/setjmp-bti.ll

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 6815dca1f1529..9d097ccae6aab 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3329,7 +3329,7 @@ Work around VLLDM erratum CVE-2021-35465 (ARM only)
 
 .. option:: -mno-bti-at-return-twice
 
-Do not add a BTI instruction after a setjmp or other return-twice construct 
(Arm only)
+Do not add a BTI instruction after a setjmp or other return-twice construct 
(AArch32/AArch64 only)
 
 .. option:: -mno-movt
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c30512c80e0b7..105d501073174 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -193,6 +193,11 @@ DWARF Support in Clang
 Arm and AArch64 Support in Clang
 
 
+- When using ``-mbranch-protection=bti`` with AArch64, calls to setjmp will
+  now be followed by a BTI instruction. This is done to be compatible with
+  setjmp implementations that return with a br instead of a ret. You can
+  disable this behaviour using the ``-mno-bti-at-return-twice`` option.
+
 Floating Point Support in Clang
 ---
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c56578b34641a..41b3ca5a4583e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3414,7 +3414,7 @@ def mmark_bti_property : Flag<["-"], 
"mmark-bti-property">,
 def mno_bti_at_return_twice : Flag<["-"], "mno-bti-at-return-twice">,
   Group,
   HelpText<"Do not add a BTI instruction after a setjmp or other"
-   " return-twice construct (Arm only)">;
+   " return-twice construct (Arm/AArch64 only)">;
 
 foreach i = {1-31} in
   def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group,

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index f9557bac5fcdc..610c672feb677 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -588,4 +588,7 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 // Enabled A53 errata (835769) workaround by default on android
 Features.push_back("+fix-cortex-a53-835769");
   }
+
+  if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
+Features.push_back("+no-bti-at-return-twice");
 }

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 84d388d94e596..82161b162ecdf 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -466,6 +466,11 @@ def FeatureEL3 : SubtargetFeature<"el3", "HasEL3", "true",
 def FeatureFixCortexA53_835769 : SubtargetFeature<"fix-cortex-a53-835769",
   "FixCortexA53_835769", "true", "Mitigate Cortex-A53 Erratum 

[PATCH] D121707: [llvm][AArch64] Insert "bti j" after call to setjmp

2022-03-23 Thread David Spickett 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 rGeb5ecbbcbb6c: [llvm][AArch64] Insert bti j after 
call to setjmp (authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121707

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
  llvm/lib/Target/AArch64/AArch64FastISel.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
  llvm/test/CodeGen/AArch64/setjmp-bti-no-enforcement.ll
  llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
  llvm/test/CodeGen/AArch64/setjmp-bti.ll

Index: llvm/test/CodeGen/AArch64/setjmp-bti.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/setjmp-bti.ll
@@ -0,0 +1,55 @@
+; RUN: llc -mtriple=aarch64-none-linux-gnu < %s | FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel < %s | FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel < %s | FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+
+; C source
+; 
+; extern int setjmp(void*);
+; extern void notsetjmp(void);
+;
+; void bbb(void) {
+;   setjmp(0);
+;   int (*fnptr)(void*) = setjmp;
+;   fnptr(0);
+;   notsetjmp();
+; }
+
+define void @bbb() {
+; BTI-LABEL: bbb:
+; BTI:   bl setjmp
+; BTI-NEXT:  hint #36
+; BTI:   blr x{{[0-9]+}}
+; BTI-NEXT:  hint #36
+; BTI:   bl notsetjmp
+; BTI-NOT:   hint #36
+
+; NOBTI-LABEL: bbb:
+; NOBTI: bl setjmp
+; NOBTI-NOT: hint #36
+; NOBTI: blr x{{[0-9]+}}
+; NOBTI-NOT: hint #36
+; NOBTI: bl notsetjmp
+; NOBTI-NOT: hint #36
+entry:
+  %fnptr = alloca i32 (i8*)*, align 8
+  %call = call i32 @setjmp(i8* noundef null) #0
+  store i32 (i8*)* @setjmp, i32 (i8*)** %fnptr, align 8
+  %0 = load i32 (i8*)*, i32 (i8*)** %fnptr, align 8
+  %call1 = call i32 %0(i8* noundef null) #0
+  call void @notsetjmp()
+  ret void
+}
+
+declare i32 @setjmp(i8* noundef) #0
+declare void @notsetjmp()
+
+attributes #0 = { returns_twice }
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"branch-target-enforcement", i32 1}
Index: llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
@@ -0,0 +1,83 @@
+; RUN: llc -mtriple=aarch64-none-linux-gnu -enable-machine-outliner < %s | FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -enable-machine-outliner < %s | \
+; RUN: FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -enable-machine-outliner < %s | \
+; RUN: FileCheck %s --check-prefix=BTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \
+; RUN: FileCheck %s --check-prefix=NOBTI
+
+; Check that the outliner does not split up the call to setjmp and the bti after it.
+; When we do not insert a bti, it is allowed to move the setjmp call into an outlined function.
+
+; C source
+; 
+; extern int setjmp(void*);
+;
+; int f(int a, int b, int c, int d) {
+;   setjmp(0);
+;   return 1 + a * (a + b) / (c + d);
+; }
+;
+; int g(int a, int b, int c, int d) {
+;   setjmp(0);
+;   return 2 + a * (a + b) / (c + d);
+; }
+
+define i32 @f(i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d) {
+; BTI-LABEL: f:
+; BTI: bl  OUTLINED_FUNCTION_1
+; BTI-NEXT:bl  setjmp
+; BTI-NEXT:hint#36
+; BTI-NEXT:bl  OUTLINED_FUNCTION_0
+
+; NOBTI:  f:
+; NOBTI:bl  OUTLINED_FUNCTION_0
+; NOBTI-NEXT:   bl  OUTLINED_FUNCTION_1
+
+entry:
+  %call = call i32 @setjmp(i8* noundef null) #0
+  %add = add nsw i32 %b, %a
+  %mul = mul nsw i32 %add, %a
+  %add1 = add nsw i32 %d, %c
+  %div = sdiv i32 %mul, %add1
+  %add2 = add 

[PATCH] D121983: Driver: Don't warn on -mbranch-protection when linking

2022-03-23 Thread Tom Stellard 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 rG98fd3b359866: Driver: Dont warn on -mbranch-protection 
when linking (authored by tstellar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121983

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/Inputs/main.c
  clang/test/Driver/aarch64-security-options.c


Index: clang/test/Driver/aarch64-security-options.c
===
--- clang/test/Driver/aarch64-security-options.c
+++ clang/test/Driver/aarch64-security-options.c
@@ -27,6 +27,10 @@
 // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=bar   
  2>&1 | \
 // RUN: FileCheck %s --check-prefix=BAD-BP-PROTECTION --check-prefix=WARN
 
+// RUN: %clang -target aarch64--none-eabi -o %t-main.o 
-mbranch-protection=standard -c %S/Inputs/main.c
+// RUN: %clang -target aarch64--none-eabi -o %t-main 
-mbranch-protection=standard %t-main.o 2>&1 | \
+// RUN: FileCheck --allow-empty %s --check-prefix=LINKER-DRIVER
+
 // WARN-NOT: warning: ignoring '-mbranch-protection=' option because the 
'aarch64' architecture does not support it [-Wbranch-protection]
 
 // RA-OFF: "-msign-return-address=none"
@@ -46,3 +50,7 @@
 
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in 
'-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in 
'-mbranch-protection={{.*}}'
+
+// Check that the linker driver doesn't warn about -mbranch-protection=standard
+// as an unused option.
+// LINKER-DRIVER-NOT: warning:
Index: clang/test/Driver/Inputs/main.c
===
--- /dev/null
+++ clang/test/Driver/Inputs/main.c
@@ -0,0 +1,3 @@
+int main(int argc, char **argv) {
+  return 0;
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3442,6 +3442,7 @@
   Flags<[CC1Option]>, Group, Values<"none,all,non-leaf">,
   HelpText<"Select return address signing scope">;
 def mbranch_protection_EQ : Joined<["-"], "mbranch-protection=">,
+  Group,
   HelpText<"Enforce targets of indirect branches and function returns">;
 
 def mharden_sls_EQ : Joined<["-"], "mharden-sls=">,


Index: clang/test/Driver/aarch64-security-options.c
===
--- clang/test/Driver/aarch64-security-options.c
+++ clang/test/Driver/aarch64-security-options.c
@@ -27,6 +27,10 @@
 // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=bar 2>&1 | \
 // RUN: FileCheck %s --check-prefix=BAD-BP-PROTECTION --check-prefix=WARN
 
+// RUN: %clang -target aarch64--none-eabi -o %t-main.o -mbranch-protection=standard -c %S/Inputs/main.c
+// RUN: %clang -target aarch64--none-eabi -o %t-main -mbranch-protection=standard %t-main.o 2>&1 | \
+// RUN: FileCheck --allow-empty %s --check-prefix=LINKER-DRIVER
+
 // WARN-NOT: warning: ignoring '-mbranch-protection=' option because the 'aarch64' architecture does not support it [-Wbranch-protection]
 
 // RA-OFF: "-msign-return-address=none"
@@ -46,3 +50,7 @@
 
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in '-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in '-mbranch-protection={{.*}}'
+
+// Check that the linker driver doesn't warn about -mbranch-protection=standard
+// as an unused option.
+// LINKER-DRIVER-NOT: warning:
Index: clang/test/Driver/Inputs/main.c
===
--- /dev/null
+++ clang/test/Driver/Inputs/main.c
@@ -0,0 +1,3 @@
+int main(int argc, char **argv) {
+  return 0;
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3442,6 +3442,7 @@
   Flags<[CC1Option]>, Group, Values<"none,all,non-leaf">,
   HelpText<"Select return address signing scope">;
 def mbranch_protection_EQ : Joined<["-"], "mbranch-protection=">,
+  Group,
   HelpText<"Enforce targets of indirect branches and function returns">;
 
 def mharden_sls_EQ : Joined<["-"], "mharden-sls=">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 98fd3b3 - Driver: Don't warn on -mbranch-protection when linking

2022-03-23 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2022-03-22T23:17:42-07:00
New Revision: 98fd3b359866f474ab1c097c22fb5c3be356b996

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

LOG: Driver: Don't warn on -mbranch-protection when linking

The -mbranch-protection definition in Options.td was not given a Group,
so this was causing clang to emit a -Wunused-command-line-argument
warning when this flag was passed to the linker driver.  This was a
problem, because some build systems, like cmake, automatically pass the
C flags to the linker.  Therefore, any program that was compiled with
-Werror and -mbranch-protection would fail to link with the error:

argument unused during compilation: '-mbranch-protection=standard' 
[-Werror,-Wunused-command-line-argument]

Reviewed By: vhscampos

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

Added: 
clang/test/Driver/Inputs/main.c

Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/aarch64-security-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2a23695c149fa..e35b36af91c33 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3442,6 +3442,7 @@ def msign_return_address_EQ : Joined<["-"], 
"msign-return-address=">,
   Flags<[CC1Option]>, Group, Values<"none,all,non-leaf">,
   HelpText<"Select return address signing scope">;
 def mbranch_protection_EQ : Joined<["-"], "mbranch-protection=">,
+  Group,
   HelpText<"Enforce targets of indirect branches and function returns">;
 
 def mharden_sls_EQ : Joined<["-"], "mharden-sls=">,

diff  --git a/clang/test/Driver/Inputs/main.c b/clang/test/Driver/Inputs/main.c
new file mode 100644
index 0..5c2fa9bb6a78e
--- /dev/null
+++ b/clang/test/Driver/Inputs/main.c
@@ -0,0 +1,3 @@
+int main(int argc, char **argv) {
+  return 0;
+}

diff  --git a/clang/test/Driver/aarch64-security-options.c 
b/clang/test/Driver/aarch64-security-options.c
index 6ea4b8ae58385..e9db540d53ede 100644
--- a/clang/test/Driver/aarch64-security-options.c
+++ b/clang/test/Driver/aarch64-security-options.c
@@ -27,6 +27,10 @@
 // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=bar   
  2>&1 | \
 // RUN: FileCheck %s --check-prefix=BAD-BP-PROTECTION --check-prefix=WARN
 
+// RUN: %clang -target aarch64--none-eabi -o %t-main.o 
-mbranch-protection=standard -c %S/Inputs/main.c
+// RUN: %clang -target aarch64--none-eabi -o %t-main 
-mbranch-protection=standard %t-main.o 2>&1 | \
+// RUN: FileCheck --allow-empty %s --check-prefix=LINKER-DRIVER
+
 // WARN-NOT: warning: ignoring '-mbranch-protection=' option because the 
'aarch64' architecture does not support it [-Wbranch-protection]
 
 // RA-OFF: "-msign-return-address=none"
@@ -46,3 +50,7 @@
 
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in 
'-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in 
'-mbranch-protection={{.*}}'
+
+// Check that the linker driver doesn't warn about -mbranch-protection=standard
+// as an unused option.
+// LINKER-DRIVER-NOT: warning:



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


[clang] 1089cdd - Revert "Driver: Don't warn on -mbranch-protection when linking"

2022-03-23 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2022-03-22T23:36:57-07:00
New Revision: 1089cdda776bbd437d6507242f2621ec83af7118

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

LOG: Revert "Driver: Don't warn on -mbranch-protection when linking"

This reverts commit 98fd3b359866f474ab1c097c22fb5c3be356b996.

This patch broke multiple bots.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/aarch64-security-options.c

Removed: 
clang/test/Driver/Inputs/main.c



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e35b36af91c33..2a23695c149fa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3442,7 +3442,6 @@ def msign_return_address_EQ : Joined<["-"], 
"msign-return-address=">,
   Flags<[CC1Option]>, Group, Values<"none,all,non-leaf">,
   HelpText<"Select return address signing scope">;
 def mbranch_protection_EQ : Joined<["-"], "mbranch-protection=">,
-  Group,
   HelpText<"Enforce targets of indirect branches and function returns">;
 
 def mharden_sls_EQ : Joined<["-"], "mharden-sls=">,

diff  --git a/clang/test/Driver/Inputs/main.c b/clang/test/Driver/Inputs/main.c
deleted file mode 100644
index 5c2fa9bb6a78e..0
--- a/clang/test/Driver/Inputs/main.c
+++ /dev/null
@@ -1,3 +0,0 @@
-int main(int argc, char **argv) {
-  return 0;
-}

diff  --git a/clang/test/Driver/aarch64-security-options.c 
b/clang/test/Driver/aarch64-security-options.c
index e9db540d53ede..6ea4b8ae58385 100644
--- a/clang/test/Driver/aarch64-security-options.c
+++ b/clang/test/Driver/aarch64-security-options.c
@@ -27,10 +27,6 @@
 // RUN: %clang -target aarch64--none-eabi -c %s -### -mbranch-protection=bar   
  2>&1 | \
 // RUN: FileCheck %s --check-prefix=BAD-BP-PROTECTION --check-prefix=WARN
 
-// RUN: %clang -target aarch64--none-eabi -o %t-main.o 
-mbranch-protection=standard -c %S/Inputs/main.c
-// RUN: %clang -target aarch64--none-eabi -o %t-main 
-mbranch-protection=standard %t-main.o 2>&1 | \
-// RUN: FileCheck --allow-empty %s --check-prefix=LINKER-DRIVER
-
 // WARN-NOT: warning: ignoring '-mbranch-protection=' option because the 
'aarch64' architecture does not support it [-Wbranch-protection]
 
 // RA-OFF: "-msign-return-address=none"
@@ -50,7 +46,3 @@
 
 // BAD-B-KEY-COMBINATION: invalid branch protection option 'b-key' in 
'-mbranch-protection={{.*}}'
 // BAD-LEAF-COMBINATION: invalid branch protection option 'leaf' in 
'-mbranch-protection={{.*}}'
-
-// Check that the linker driver doesn't warn about -mbranch-protection=standard
-// as an unused option.
-// LINKER-DRIVER-NOT: warning:



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


[PATCH] D70401: [RISCV] Complete RV32E/ilp32e implementation

2022-03-23 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.
Herald added a subscriber: StephenFan.

In D70401#3391561 , @khchen wrote:

> I found 
> https://github.com/llvm/llvm-test-suite/blob/main/SingleSource/UnitTests/2003-05-26-Shorts.c
>  result is mismatched with gcc's (-march=rv32e -mabi=ilp32e).
> Did you have same issue?

I got the same issue, but it may be not this patch's problem.
Here is the reduced case:

  #include 
  
  unsigned long long getL() { return 0xafafafafc5c5b8a3ull; }
  int main(int argc, char **argv) {
unsigned long long UL = getL(); /* 0xafafafafc5c5b8a3 */
unsigned int ui = (unsigned int)UL; /* 0xc5c5b8a3 =  3318069411 */
printf("ui = %u (0x%x)\t\tUL-ui = %lld (0x%llx)\n", ui, ui, UL - ui, UL - 
ui);
  }

GCC output is:

  ui = 3318069411 (0xc5c5b8a3)UL-ui = -5787213829993660416 
(0xafafafaf)

LLVM output is:

  ui = 3318069411 (0xc5c5b8a3)UL-ui = 0 (0xafafafaf)

The problem is the way to pass arguments to `printf`.
GCC asm:

li  a4,-1347440640
addisp,sp,-24
addia4,a4,-81
sw  a4,8(sp)
lw  a5,8(sp)
li  a2,-976896000
addia2,a2,-1885
lui a0,%hi(.LC1)
sw  a5,0(sp)
li  a3,0
li  a5,0
mv  a1,a2
addia0,a0,%lo(.LC1)
sw  ra,20(sp)
sw  a3,4(sp)
callprintf

LLVM asm:

addisp, sp, -16
sw  ra, 12(sp)  # 4-byte Folded Spill
sw  s0, 8(sp)   # 4-byte Folded Spill
addis0, sp, 16
andisp, sp, -8
lui a0, 719611
addia5, a0, -81
sw  a5, 4(sp)
lui a0, %hi(.L.str)
addia0, a0, %lo(.L.str)
lui a1, 810076
addia1, a1, -1885
sw  zero, 0(sp)
mv  a2, a1
mv  a4, zero
callprintf

Both GCC and LLVM pass format string and two `ui` by `a0, a1, a2`, the 
difference is how they pass rest variadic arguments.
`UL-ui` is with 2*XLEN size, so it will be spilt to two part (low and high 
32-bits). Low part is 0x, high part is 0xafafafaf.
For GCC:

  First UL-ui  : low -> a3, high -> a4
  Second UL-ui : low -> a5, high -> stack.0

For LLVM:

  First UL-ui  : low -> a4, high -> a5
  Second UL-ui : low -> stack.0, high -> stack.1

Because we use GLIBC compiled by GCC  while linking with LLVM's output, so in 
`printf`'s view:

  a3 -> undefined, so it is zero.
  a4 -> low part, 0x
  a5 -> high part, 0xafafafaf
  stack.0 -> low part, 0x
  stack.1 -> not used

It get `0x` and `0xafafafaf` for two `UL-ui` (seen as 
the output).

In the ABI specification, it says (Integer Calling Convention 
):

  In the base integer calling convention, variadic arguments are passed in the 
same manner as named arguments, with one exception. Variadic arguments with 
2×XLEN-bit alignment and size at most 2×XLEN bits are passed in an aligned 
register pair (i.e., the first register in the pair is even-numbered), or on 
the stack by value if none is available. After a variadic argument has been 
passed on the stack, all future arguments will also be passed on the stack 
(i.e. the last argument register may be left unused due to the aligned register 
pair rule).

And this is what LLVM do for ILP32E currently.

I saw the same issue on Github(Inconsistent variadic argument passing behavior 
between ilp32 and ilp32e for long long/double 
), so shall LLVM be 
compatible with GCC's behavior?
@kito-cheng @khchen


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D121824: [clang] Do not crash on arrow operator on dependent type.

2022-03-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.

OK, let's move forward with it. Thanks for the investigation and the fix!

I will take a look on the invalid-bit problem, and monitor the crash report 
more closely.




Comment at: clang/lib/Sema/TreeTransform.h:14708
   } else if (Op == OO_Arrow) {
+if (First->getType()->isDependentType())
+  return ExprError();

sammccall wrote:
> hokein wrote:
> > I'm not sure this is the only place triggering the crash, it looks like 
> > that we're fixing a symptom.
> > 
> > While here, `First` refers to a dependent-type `RecoveryExpr` (which is 
> > built from the code path: `TransformDeclRefExpr` -> `RebuildDeclRefExpr`-> 
> > `Sema::BuildDeclarationNameExpr`). So I think we have a high chance that 
> > the `RecoveryExpr` will spread multiple places in the `TreeTransform` and 
> > cause similar violations in other places.
> > 
> > A safe fix will be to not build the `RecoveryExpr` in 
> > `TreeTransform::TransformDeclRefExpr` -- `Sema::BuildDeclarationNameExpr` 
> > has a `AcceptInvalidDecl` parameter (by default it is false), we could 
> > reuse it to control whether we should build a `RecoveryExpr`.
> >  
> I agree with this FWIW: in principle it makes sense to have RecoveryExpr 
> produced in template instantiation, in practice we probably haven't weakened 
> the assumptions in template instantiation enough to do so safely, in the way 
> that we have for "regular" sema.
> 
> We could try to do so in an ongoing way, but at least for syntax based tools 
> like clangd the payoff won't be large as long as we keep mostly ignoring 
> template instantiations.
> 
> That said, the current form of the patch is simple and fixes the crash in an 
> obvious way, if this really is a more general problem then we'll see it again 
> and have more data to generalize.
yeah, I'm more worry about this is a more general problem in template 
instantiation. 
I agree that having RecoveryExpr produced in template instantiation makes 
sensible (mostly for diagnostics), but it seems to me that we're opening a can 
of worms, and I'm not sure this is a good tradeoff -- from our experience, 
tracing and fixing these kind of crashes is quite painful and requires large 
amount of effort (personally, I will be more conservative).

Given the current patch is a definitely crash fix, I'm fine with it.



Comment at: clang/lib/Sema/TreeTransform.h:14708
   } else if (Op == OO_Arrow) {
+if (First->getType()->isDependentType())
+  return ExprError();

hokein wrote:
> sammccall wrote:
> > hokein wrote:
> > > I'm not sure this is the only place triggering the crash, it looks like 
> > > that we're fixing a symptom.
> > > 
> > > While here, `First` refers to a dependent-type `RecoveryExpr` (which is 
> > > built from the code path: `TransformDeclRefExpr` -> 
> > > `RebuildDeclRefExpr`-> `Sema::BuildDeclarationNameExpr`). So I think we 
> > > have a high chance that the `RecoveryExpr` will spread multiple places in 
> > > the `TreeTransform` and cause similar violations in other places.
> > > 
> > > A safe fix will be to not build the `RecoveryExpr` in 
> > > `TreeTransform::TransformDeclRefExpr` -- `Sema::BuildDeclarationNameExpr` 
> > > has a `AcceptInvalidDecl` parameter (by default it is false), we could 
> > > reuse it to control whether we should build a `RecoveryExpr`.
> > >  
> > I agree with this FWIW: in principle it makes sense to have RecoveryExpr 
> > produced in template instantiation, in practice we probably haven't 
> > weakened the assumptions in template instantiation enough to do so safely, 
> > in the way that we have for "regular" sema.
> > 
> > We could try to do so in an ongoing way, but at least for syntax based 
> > tools like clangd the payoff won't be large as long as we keep mostly 
> > ignoring template instantiations.
> > 
> > That said, the current form of the patch is simple and fixes the crash in 
> > an obvious way, if this really is a more general problem then we'll see it 
> > again and have more data to generalize.
> yeah, I'm more worry about this is a more general problem in template 
> instantiation. 
> I agree that having RecoveryExpr produced in template instantiation makes 
> sensible (mostly for diagnostics), but it seems to me that we're opening a 
> can of worms, and I'm not sure this is a good tradeoff -- from our 
> experience, tracing and fixing these kind of crashes is quite painful and 
> requires large amount of effort (personally, I will be more conservative).
> 
> Given the current patch is a definitely crash fix, I'm fine with it.
nit: please add some comments explaining why we hit a dependent-type express 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121824

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

[clang] 27f6cee - Revert "[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()"

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T10:24:39+01:00
New Revision: 27f6cee12d2ab52e44e78d26733ab92ced730f13

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

LOG: Revert "[CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()"

This reverts commit 767ec883e37510a247ea5695921876ef67cf5b3f.

This results in a some incorrect alignments which are not covered
by existing tests.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 2ee62f97399ac..b0eeddd98fce6 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2547,10 +2547,10 @@ Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
LValueBaseInfo *BaseInfo,
TBAAAccessInfo *TBAAInfo) {
   llvm::Value *Addr = Builder.CreateLoad(Ptr);
-  return Address(Addr, ConvertTypeForMem(PtrTy->getPointeeType()),
- CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo,
- TBAAInfo,
- /*forPointeeType=*/true));
+  return Address::deprecated(
+  Addr,
+  CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo, TBAAInfo,
+  /*forPointeeType=*/true));
 }
 
 LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 24cd78a64cfd4..b7ee9ce10e02b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4652,7 +4652,8 @@ CGOpenMPRuntime::getDepobjElements(CodeGenFunction , 
LValue DepobjLVal,
   RecordDecl *KmpDependInfoRD =
   cast(KmpDependInfoTy->getAsTagDecl());
   LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs());
+  DepobjLVal.getAddress(CGF),
+  C.getPointerType(C.VoidPtrTy).castAs());
   QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
   Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy),
@@ -4749,7 +4750,8 @@ emitDepobjElementsSizes(CodeGenFunction , QualType 
,
 for (const Expr *E : Data.DepExprs) {
   LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts());
   LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs());
+  DepobjLVal.getAddress(CGF),
+  C.getPointerType(C.VoidPtrTy).castAs());
   Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   Base.getAddress(CGF), KmpDependInfoPtrT,
   CGF.ConvertTypeForMem(KmpDependInfoTy));
@@ -4806,7 +4808,8 @@ static void emitDepobjElements(CodeGenFunction , 
QualType ,
   const Expr *E = Data.DepExprs[I];
   LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts());
   LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs());
+  DepobjLVal.getAddress(CGF),
+  C.getPointerType(C.VoidPtrTy).castAs());
   Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   Base.getAddress(CGF), KmpDependInfoPtrT,
   CGF.ConvertTypeForMem(KmpDependInfoTy));
@@ -5055,7 +5058,8 @@ void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction 
, LValue DepobjLVal,
   QualType FlagsTy;
   getDependTypes(C, KmpDependInfoTy, FlagsTy);
   LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs());
+  DepobjLVal.getAddress(CGF),
+  C.getPointerType(C.VoidPtrTy).castAs());
   QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
   Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy),
@@ -6037,7 +6041,8 @@ static llvm::Value *emitReduceFiniFunction(CodeGenModule 
,
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
   Address PrivateAddr = CGF.EmitLoadOfPointer(
-  CGF.GetAddrOfLocalVar(), C.VoidPtrTy.castAs());
+  CGF.GetAddrOfLocalVar(),
+  C.getPointerType(C.VoidPtrTy).castAs());
   llvm::Value *Size = nullptr;
   // If the size of the reduction item is non-constant, load it from global
   // threadprivate variable.

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index f4228cfb3086e..1814102f749af 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ 

[PATCH] D122189: [Clang][NeonEmitter] emit ret decl first for -Wdeclaration-after-statement

2022-03-23 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

This LGTM with the test only requiring Arm.

Please mention in the commit that it is possible to ignore this warning in 
system headers, but we chose not to because of potential false positives.




Comment at: clang/test/Sema/arm-neon-decl-after-stmt.c:3
+// RUN:  -Wdeclaration-after-statement -fsyntax-only -verify %s
+// REQUIRES: aarch64-registered-target || arm-registered-target
+// https://github.com/llvm/llvm-project/issues/54062

DavidSpickett wrote:
> Does `armebv7` work when you only have aarch64?
> 
> It probably does just by virtue of aarch64 not knowing what v7 is and 
> defaulting to v8 but double check what happens there.
> 
> If the emitter is used for both arm and aarch64 then testing one would be 
> acceptable. Since you can't really do an if has arm do this else in a lit 
> test like this.
Maybe this is phabricator showing me the diff strangely, but it seems like you 
removed the aarch64 requirement from a different test instead of this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122189

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


[PATCH] D122298: [clang-cl] Ignore /Wv and /Wv:17 flags

2022-03-23 Thread Tobias Hieta via Phabricator via cfe-commits
thieta created this revision.
thieta added reviewers: hans, mstorsjo, rnk.
Herald added a project: All.
thieta requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

MSVC supports passing /Wv and /Wv:17 to ignore warnings added
since that version. Clang doesn't have a option like this - but
we can ignore this flag instead of error.

MSVC documentation: 
https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122298

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -396,6 +396,8 @@
 // RUN:/volatile:iso \
 // RUN:/w12345 \
 // RUN:/wd1234 \
+// RUN:/Wv \
+// RUN:/Wv:17 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
 // RUN:/Zc:forScope \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2493,12 +2493,12 @@
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], 
"fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
   HelpText<"Assert no thread in a parallel region modifies an ICV">,
   MarshallingInfoFlag>;
-def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, 
Group, 
-  Flags<[CC1Option, NoArgumentUnused]>, 
+def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, 
Group,
+  Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Do not create a host fallback if offloading to the device fails.">,
   MarshallingInfoFlag>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
@@ -6528,6 +6528,7 @@
 def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
   HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
@@ -6542,7 +6543,6 @@
 def _SLASH_Zo : CLIgnoredFlag<"Zo">;
 def _SLASH_Zo_ : CLIgnoredFlag<"Zo-">;
 
-
 // Unsupported:
 
 def _SLASH_await : CLFlag<"await">;


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -396,6 +396,8 @@
 // RUN:/volatile:iso \
 // RUN:/w12345 \
 // RUN:/wd1234 \
+// RUN:/Wv \
+// RUN:/Wv:17 \
 // RUN:/Zc:__cplusplus \
 // RUN:/Zc:auto \
 // RUN:/Zc:forScope \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2493,12 +2493,12 @@
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fno_openmp_assume_threads_oversubscription : Flag<["-"], "fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_no_thread_state : Flag<["-"], "fopenmp-assume-no-thread-state">, Group, 
-  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>, 
+def fopenmp_assume_no_thread_state : Flag<["-"], "fopenmp-assume-no-thread-state">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
   HelpText<"Assert no thread in a parallel region modifies an ICV">,
   MarshallingInfoFlag>;
-def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, Group, 
-  Flags<[CC1Option, NoArgumentUnused]>, 
+def fopenmp_offload_mandatory : Flag<["-"], "fopenmp-offload-mandatory">, Group,
+  Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Do not create a host fallback if offloading to the device fails.">,
   MarshallingInfoFlag>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
@@ -6528,6 +6528,7 @@
 def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
   HelpText<"Set source and runtime encoding to UTF-8 (default)">;
 def _SLASH_w : CLIgnoredJoined<"w">;
+def _SLASH_Wv_ : CLIgnoredJoined<"Wv">;
 def _SLASH_Zc___cplusplus : CLIgnoredFlag<"Zc:__cplusplus">;
 def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
 def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
@@ -6542,7 +6543,6 @@
 def _SLASH_Zo : CLIgnoredFlag<"Zo">;
 def _SLASH_Zo_ : 

[PATCH] D122141: [clang][extract-api] Suppprt for the module name property in SymbolGraph

2022-03-23 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 417551.
dang added a comment.

Rebasing on top of latest main which includes 
https://reviews.llvm.org/rG89f6b26f1beb2c1344f5cfeb34e405128544c76b


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122141

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/ExtractAPI/global_record.c

Index: clang/test/ExtractAPI/global_record.c
===
--- clang/test/ExtractAPI/global_record.c
+++ clang/test/ExtractAPI/global_record.c
@@ -2,7 +2,7 @@
 // RUN: split-file %s %t
 // RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
 // RUN: %t/reference.output.json
-// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %clang -extract-api --product-name=GlobalRecord -target arm64-apple-macosx \
 // RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
 
 // Generator version is not consistent across test runs, normalize it.
@@ -37,7 +37,7 @@
 "generator": "?"
   },
   "module": {
-"name": "",
+"name": "GlobalRecord",
 "platform": {
   "architecture": "arm64",
   "operatingSystem": {
Index: clang/lib/SymbolGraph/Serialization.cpp
===
--- /dev/null
+++ clang/lib/SymbolGraph/Serialization.cpp
@@ -0,0 +1,331 @@
+//===- SymbolGraph/Serialization.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// \brief Defines the SymbolGraph serializer and parser.
+///
+//===--===//
+
+#include "clang/SymbolGraph/Serialization.h"
+#include "clang/Basic/Version.h"
+#include "clang/SymbolGraph/API.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VersionTuple.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+using namespace clang::symbolgraph;
+using namespace llvm;
+using namespace llvm::json;
+
+namespace {
+
+static void serializeObject(Object , StringRef Key,
+Optional Obj) {
+  if (Obj)
+Paren[Key] = std::move(Obj.getValue());
+}
+
+static void serializeArray(Object , StringRef Key,
+   Optional Array) {
+  if (Array)
+Paren[Key] = std::move(Array.getValue());
+}
+
+// SymbolGraph: SemanticVersion
+static Optional serializeSemanticVersion(const VersionTuple ) {
+  if (V.empty())
+return None;
+
+  Object Version;
+  Version["major"] = V.getMajor();
+  Version["minor"] = V.getMinor().getValueOr(0);
+  Version["patch"] = V.getSubminor().getValueOr(0);
+  return Version;
+}
+
+static Object serializeOperatingSystem(const Triple ) {
+  Object OS;
+  OS["name"] = T.getOSTypeName(T.getOS());
+  serializeObject(OS, "minimumVersion",
+  serializeSemanticVersion(T.getMinimumSupportedOSVersion()));
+  return OS;
+}
+
+// SymbolGraph: Platform
+static Object serializePlatform(const Triple ) {
+  Object Platform;
+  Platform["architecture"] = T.getArchName();
+  Platform["vendor"] = T.getVendorName();
+  Platform["operatingSystem"] = serializeOperatingSystem(T);
+  return Platform;
+}
+
+// SymbolGraph: SourcePosition
+static Object serializeSourcePosition(const PresumedLoc ,
+  bool IncludeFileURI = false) {
+  assert(Loc.isValid() && "invalid source position");
+
+  Object SourcePosition;
+  SourcePosition["line"] = Loc.getLine();
+  SourcePosition["character"] = Loc.getColumn();
+
+  if (IncludeFileURI) {
+std::string FileURI = "file://";
+FileURI += sys::path::convert_to_slash(Loc.getFilename());
+SourcePosition["uri"] = FileURI;
+  }
+
+  return SourcePosition;
+}
+
+// SymbolGraph: SourceRange
+static Object serializeSourceRange(const PresumedLoc ,
+   const PresumedLoc ) {
+  Object SourceRange;
+  serializeObject(SourceRange, "start", serializeSourcePosition(BeginLoc));
+  serializeObject(SourceRange, "end", serializeSourcePosition(EndLoc));
+  return SourceRange;
+}
+
+// SymbolGraph: AvailabilityItem
+static Optional serializeAvailability(const AvailabilityInfo ) {
+  if (Avail.isDefault())
+return None;
+
+  Object Availbility;
+  serializeObject(Availbility, "introducedVersion",
+  

[PATCH] D118493: Set rpath on openmp executables

2022-03-23 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

In D118493#3401448 , @tstellar wrote:

> The rule that is broken is "standard RPATHs" Fedora installs libomp to 
> /usr/lib64.
>
> ...
>
>   I think what we'll do in Fedora is just add -fno-openmp-implicit-rpath to 
> the default CFLAGS so we can get the old behavior for official RPMs.

Sounds good to me. I especially like the rapid unblocking.

Slightly longer term, we might want to adjust clang to notice when the rpath it 
is about to set coincides with a system directory. The purpose of this patch is 
to have clang -fopenmp -o a.out && ./a.out work without setting environment 
variables, but where the openmp libs in question are on the system search path 
the rpath is not necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118493

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


[PATCH] D120874: [C++20] [Modules] Use '-' as the separator of partitions when searching in filesystems

2022-03-23 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

I have no comment the patch itself, that seems fine, I even agree that this 
could be convenient :-)

However, I am concerned that this now means that '-fprebuilt-module-path' has 
meaning for both clang modules and c++20 modules - which is something we agree 
is generally undesirable (AFAIU, we agree it would be better to have orthogonal 
command line switch sets).

At some stage, we need to abstract the general mapping between module names and 
BMI names; I think the ownership of that mapping needs to be in the module 
loader (or, at least, available when the compiler instance has no 
pre-processor).
This is because when building a pre-processed source that imports a module we 
could still need to carry out the module-name to BMI name translation (the 
alternative seems bad, which would be to bake the BMI path in the pre-processed 
output).

So, I'm not 100% convinced about lookup schemes for BMI names that depend on 
header search being available.

maybe other modules folks have a view?


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

https://reviews.llvm.org/D120874

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


[PATCH] D121099: [C++20][Modules][HU 5/5] Add fdirectives-only mode for preprocessing output.

2022-03-23 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan accepted this revision.
urnathan added a comment.
This revision is now accepted and ready to land.

Kind of surprised this wasn't already a thing :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121099

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


[PATCH] D120397: [C++20] [Modules] Make the linkage consistent for template and its specialization

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D120397#3401380 , @ChuanqiXu wrote:

> In D120397#3399808 , @aaron.ballman 
> wrote:
>
>> Can you also add a release note that explains we've fixed the crash?
>
> My thought is to edit a release note standalone. Since there are already many 
> works in modules now. I guess it might be better to try to give a summarize.

SGTM!

In D120397#3402081 , @iains wrote:

> for the record, I experimented with adding the linkage as an output for AST 
> dumps (adding to TextNodeDumper / DeclPrinter), since it seems that this 
> could be generally useful.
> this works fine, but, it would create a lot of testsuite churn - around 350 
> tests would need amendment, so I've punted on it for now (perhaps unit tests 
> can always accomplish the same).

Yeah, our AST dumping tests are very fragile to changes to the AST dump, 
unfortunately. It's very reasonable to punt on that, but thank you for looking 
into it!


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

https://reviews.llvm.org/D120397

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


[PATCH] D122141: [clang][extract-api] Suppprt for the module name property in SymbolGraph

2022-03-23 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 417572.
dang added a comment.

Accidentally re-added some of the old files in SymbolGraph/ during the rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122141

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/global_record.c

Index: clang/test/ExtractAPI/global_record.c
===
--- clang/test/ExtractAPI/global_record.c
+++ clang/test/ExtractAPI/global_record.c
@@ -2,7 +2,7 @@
 // RUN: split-file %s %t
 // RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
 // RUN: %t/reference.output.json
-// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %clang -extract-api --product-name=GlobalRecord -target arm64-apple-macosx \
 // RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
 
 // Generator version is not consistent across test runs, normalize it.
@@ -37,7 +37,7 @@
 "generator": "?"
   },
   "module": {
-"name": "",
+"name": "GlobalRecord",
 "platform": {
   "architecture": "arm64",
   "operatingSystem": {
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -376,10 +376,9 @@
 
 Object SymbolGraphSerializer::serializeModule() const {
   Object Module;
-  // FIXME: We might not be building a module, some Clang-based languages might
-  // not have a "module" concept. Figure out a way to provide a name to
-  // describe the API set.
-  Module["name"] = "";
+  // The user is expected to always pass `--product-name=` on the command line
+  // to populate this field.
+  Module["name"] = ProductName;
   serializeObject(Module, "platform", serializePlatform(API.getTarget()));
   return Module;
 }
Index: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
===
--- clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -183,8 +183,9 @@
 
 class ExtractAPIConsumer : public ASTConsumer {
 public:
-  ExtractAPIConsumer(ASTContext , std::unique_ptr OS)
-  : Visitor(Context), OS(std::move(OS)) {}
+  ExtractAPIConsumer(ASTContext , StringRef ProductName,
+ std::unique_ptr OS)
+  : Visitor(Context), ProductName(ProductName), OS(std::move(OS)) {}
 
   void HandleTranslationUnit(ASTContext ) override {
 // Use ExtractAPIVisitor to traverse symbol declarations in the context.
@@ -193,12 +194,13 @@
 // Setup a SymbolGraphSerializer to write out collected API information in
 // the Symbol Graph format.
 // FIXME: Make the kind of APISerializer configurable.
-SymbolGraphSerializer SGSerializer(Visitor.getAPI());
+SymbolGraphSerializer SGSerializer(Visitor.getAPI(), ProductName);
 SGSerializer.serialize(*OS);
   }
 
 private:
   ExtractAPIVisitor Visitor;
+  std::string ProductName;
   std::unique_ptr OS;
 };
 
@@ -209,8 +211,9 @@
   std::unique_ptr OS = CreateOutputFile(CI, InFile);
   if (!OS)
 return nullptr;
-  return std::make_unique(CI.getASTContext(),
-  std::move(OS));
+  return std::make_unique(
+  CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
+  std::move(OS));
 }
 
 std::unique_ptr
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4641,6 +4641,8 @@
 assert(JA.getType() == types::TY_API_INFO &&
"Extract API actions must generate a API information.");
 CmdArgs.push_back("-extract-api");
+if (Arg *ProductNameArg = Args.getLastArg(options::OPT_product_name_EQ))
+  ProductNameArg->render(Args, CmdArgs);
   } else {
 assert((isa(JA) || isa(JA)) &&
"Invalid action for clang tool.");
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -410,6 +410,10 @@
   /// The name of the action to run when using a plugin action.
   std::string ActionName;
 
+  // Currently this is only used as part of the `-extract-api` action.
+  /// The name of the product the input files belong too.
+  std::string ProductName;
+
   /// Args to pass to the plugins
 

[PATCH] D121916: [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

2022-03-23 Thread Marek Kurdej 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 rGa45ad3ca8ce7: [clang-format] [doc] Add script to 
automatically update help output in… (authored by curdeius).

Changed prior to commit:
  https://reviews.llvm.org/D121916?vs=416185=417573#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121916

Files:
  clang/docs/ClangFormat.rst
  clang/docs/tools/dump_format_help.py
  clang/tools/clang-format/ClangFormat.cpp

Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -100,17 +100,16 @@
 "clang-format from an editor integration"),
cl::init(0), cl::cat(ClangFormatCategory));
 
-static cl::opt SortIncludes(
-"sort-includes",
-cl::desc("If set, overrides the include sorting behavior determined by the "
- "SortIncludes style flag"),
-cl::cat(ClangFormatCategory));
+static cl::opt
+SortIncludes("sort-includes",
+ cl::desc("If set, overrides the include sorting behavior\n"
+  "determined by the SortIncludes style flag"),
+ cl::cat(ClangFormatCategory));
 
 static cl::opt QualifierAlignment(
 "qualifier-alignment",
-cl::desc(
-"If set, overrides the qualifier alignment style determined by the "
-"QualifierAlignment style flag"),
+cl::desc("If set, overrides the qualifier alignment style\n"
+ "determined by the QualifierAlignment style flag"),
 cl::init(""), cl::cat(ClangFormatCategory));
 
 static cl::opt
@@ -148,8 +147,9 @@
 
 static cl::opt ErrorLimit(
 "ferror-limit",
-cl::desc("Set the maximum number of clang-format errors to emit before "
- "stopping (0 = no limit). Used only with --dry-run or -n"),
+cl::desc("Set the maximum number of clang-format errors to emit\n"
+ "before stopping (0 = no limit).\n"
+ "Used only with --dry-run or -n"),
 cl::init(0), cl::cat(ClangFormatCategory));
 
 static cl::opt
Index: clang/docs/tools/dump_format_help.py
===
--- /dev/null
+++ clang/docs/tools/dump_format_help.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# A tool to parse the output of `clang-format --help` and update the
+# documentation in ../ClangFormat.rst automatically.
+
+import os
+import re
+import subprocess
+import sys
+
+CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
+DOC_FILE = os.path.join(CLANG_DIR, 'docs/ClangFormat.rst')
+
+
+def substitute(text, tag, contents):
+replacement = '\n.. START_%s\n\n%s\n\n.. END_%s\n' % (tag, contents, tag)
+pattern = r'\n\.\. START_%s\n.*\n\.\. END_%s\n' % (tag, tag)
+return re.sub(pattern, '%s', text, flags=re.S) % replacement
+
+
+def indent(text, columns, indent_first_line=True):
+indent_str = ' ' * columns
+s = re.sub(r'\n([^\n])', '\n' + indent_str + '\\1', text, flags=re.S)
+if not indent_first_line or s.startswith('\n'):
+return s
+return indent_str + s
+
+
+def get_help_output():
+args = ["clang-format", "--help"]
+cmd = subprocess.Popen(args, stdout=subprocess.PIPE,
+   stderr=subprocess.STDOUT)
+out, _ = cmd.communicate()
+out = out.decode(sys.stdout.encoding)
+return out
+
+
+def get_help_text():
+out = get_help_output()
+out = re.sub(r' clang-format\.exe ', ' clang-format ', out)
+
+out = '''.. code-block:: console
+
+$ clang-format -help
+''' + out
+out = indent(out, 2, indent_first_line=False)
+return out
+
+
+def validate(text, columns):
+for line in text.splitlines():
+if len(line) > columns:
+print('warning: line too long:\n', line, file=sys.stderr)
+
+
+help_text = get_help_text()
+validate(help_text, 95)
+
+with open(DOC_FILE) as f:
+contents = f.read()
+
+contents = substitute(contents, 'FORMAT_HELP', help_text)
+
+with open(DOC_FILE, 'wb') as output:
+output.write(contents.encode())
Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -13,6 +13,8 @@
 :program:`clang-format` is located in `clang/tools/clang-format` and can be used
 to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
 
+.. START_FORMAT_HELP
+
 .. code-block:: console
 
   $ clang-format -help
@@ -51,7 +53,9 @@
  -style=file, but can not find the .clang-format
  file to use.
  Use -fallback-style=none to skip formatting.
---ferror-limit=  - Set the maximum number of clang-format errors to emit 

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 417586.
cor3ntin added a comment.

- Fix test
- Add a comment explaining why we do not use CheckLiteralType

@aaron,ballman I completely missed that...!

However, CheckLiteralType does a bunch of tests that we do not need
to diagnose *why* a type is not literal, which we do not care about here.

I tried to play around with the code and trying to use CheckLiteralType, or to 
modify
it for this scenario does not appear to me an improvenent, so I rather keep the 
change as is.

I also fixed the fail test, i think i accidentally removed a line from the test 
file...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -96,7 +96,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +164,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,7 +228,7 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
+constexpr auto dependent_var_def_lambda() {
   return [](bool b) { // cxx2a-note {{declared here}}
 if (!b)
   T t;
@@ -237,4 +238,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -30,12 +30,13 @@
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,10 +1901,19 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_non_literal_type,
- isa(Dcl)))
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  // We do not use CheckLiteralType here because we want to
+  // emit a warning but no notes explaining why the type is not literal.
+  if (Kind == Sema::CheckConstexprKind::Diagnose &&
+   

[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-23 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Hello. We've got some problem in our downstream tests after this patch and I'm 
trying to figure out how things are supposed to work. Maybe someone being part 
of this review knows.

Problem is that we have some libc verification suites that include test cases 
using `float_t`. But in math.h from for example newlib the type float_t isn't 
defined if FLT_EVAL_METHOD is set to -1.
The standard says that float_t is implementation defined when FLT_EVAL_METHOD 
isn't 0/1/2. But I'm not quite sure how that is supposed to be handled (such as 
where to define float_t if not in math.h).

One question is: If I have a piece of C99 code using float_t, is that code not 
allowed to be compiled using fast-math?

I guess it should be seen as with fast-math the float_t precision is unknown. 
But the type still has to be defined somewhere or else the frontend will 
complain about "unknown type name". But I'm not sure where this is supposed to 
be handled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121122

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


[PATCH] D121328: Disable -Wmissing-prototypes for internal linkage functions that aren't explicitly marked "static"""

2022-03-23 Thread Dean Sturtevant via Phabricator via cfe-commits
deansturtevant added a comment.

Note that some fix is important to make if we think that the 
-Wmissing-prototypes warning is valuable, because there are cases where it 
currently would fire where the function cannot explicitly be given internal 
linkage, e.g.
namespace {
struct Initialized {};
}  // namespace
void* operator new(size_t size, const Initialized&) {

  void* p = malloc(size);
  memset(p, 0, size);
  return p;

}
operator new is only allowed to be defined in the global namespace.
Currently this will cause the warning to be emitted, even though there is no 
way to declare it outside the TU.

jyknight clarified that what he was proposing was that instead of calling 
FD->isExternallyVisible() as currently written, call a function which does the 
same thing except that it doesn't check whether the struct has a visible name 
(because that can be assumed here).
This function *could* be isExternallyVisible with a new boolean argument (WDYT?)
Another approach would be to move the call to 
ShouldWarnAboutMissingPrototypes() to a different point in the process, where 
calling isExternallyVisible() is *not* problematic. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121328

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


[PATCH] D122301: [clang-format] Fix invalid code generation with comments in lambda

2022-03-23 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes:
https://github.com/llvm/llvm-project/issues/51234
https://github.com/llvm/llvm-project/issues/54496


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122301

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -21888,6 +21888,30 @@
   "auto k = []() // \n"
   "{ return; }",
   LLVMWithBeforeLambdaBody);
+
+  LLVMWithBeforeLambdaBody.ColumnLimit = 0;
+
+  verifyFormat("foo([]()\n"
+   "{\n"
+   "  bar();//\n"
+   "  return 1; // comment\n"
+   "}());",
+   "foo([]() {\n"
+   "  bar(); //\n"
+   "  return 1; // comment\n"
+   "}());",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("foo(\n"
+   "1, MACRO {\n"
+   "  baz();\n"
+   "  bar(); // comment\n"
+   "},\n"
+   "[]() {});",
+   "foo(\n"
+   "  1, MACRO { baz(); bar(); // comment\n"
+   "  }, []() {}\n"
+   ");",
+   LLVMWithBeforeLambdaBody);
 }
 
 TEST_F(FormatTest, EmptyLinesInLambdas) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2762,12 +2762,16 @@
   Current->SpacesRequiredBefore = 1;
 }
 
-Current->MustBreakBefore =
-Current->MustBreakBefore || mustBreakBefore(Line, *Current);
-
-if (!Current->MustBreakBefore && InFunctionDecl &&
-Current->is(TT_FunctionDeclarationName))
-  Current->MustBreakBefore = mustBreakForReturnType(Line);
+const auto  = Prev->Children;
+if (!Children.empty() && Children.back()->Last->is(TT_LineComment)) {
+  Current->MustBreakBefore = true;
+} else {
+  Current->MustBreakBefore =
+  Current->MustBreakBefore || mustBreakBefore(Line, *Current);
+  if (!Current->MustBreakBefore && InFunctionDecl &&
+  Current->is(TT_FunctionDeclarationName))
+Current->MustBreakBefore = mustBreakForReturnType(Line);
+}
 
 Current->CanBreakBefore =
 Current->MustBreakBefore || canBreakBefore(Line, *Current);


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -21888,6 +21888,30 @@
   "auto k = []() // \n"
   "{ return; }",
   LLVMWithBeforeLambdaBody);
+
+  LLVMWithBeforeLambdaBody.ColumnLimit = 0;
+
+  verifyFormat("foo([]()\n"
+   "{\n"
+   "  bar();//\n"
+   "  return 1; // comment\n"
+   "}());",
+   "foo([]() {\n"
+   "  bar(); //\n"
+   "  return 1; // comment\n"
+   "}());",
+   LLVMWithBeforeLambdaBody);
+  verifyFormat("foo(\n"
+   "1, MACRO {\n"
+   "  baz();\n"
+   "  bar(); // comment\n"
+   "},\n"
+   "[]() {});",
+   "foo(\n"
+   "  1, MACRO { baz(); bar(); // comment\n"
+   "  }, []() {}\n"
+   ");",
+   LLVMWithBeforeLambdaBody);
 }
 
 TEST_F(FormatTest, EmptyLinesInLambdas) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2762,12 +2762,16 @@
   Current->SpacesRequiredBefore = 1;
 }
 
-Current->MustBreakBefore =
-Current->MustBreakBefore || mustBreakBefore(Line, *Current);
-
-if (!Current->MustBreakBefore && InFunctionDecl &&
-Current->is(TT_FunctionDeclarationName))
-  Current->MustBreakBefore = mustBreakForReturnType(Line);
+const auto  = Prev->Children;
+if (!Children.empty() && Children.back()->Last->is(TT_LineComment)) {
+  Current->MustBreakBefore = true;
+} else {
+  Current->MustBreakBefore =
+  Current->MustBreakBefore || mustBreakBefore(Line, *Current);
+  if (!Current->MustBreakBefore && InFunctionDecl &&
+  Current->is(TT_FunctionDeclarationName))
+Current->MustBreakBefore = mustBreakForReturnType(Line);
+}
 
 

[PATCH] D120397: [C++20] [Modules] Make the linkage consistent for template and its specialization

2022-03-23 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

for the record, I experimented with adding the linkage as an output for AST 
dumps (adding to TextNodeDumper / DeclPrinter), since it seems that this could 
be generally useful.
this works fine, but, it would create a lot of testsuite churn - around 350 
tests would need amendment, so I've punted on it for now (perhaps unit tests 
can always accomplish the same).


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

https://reviews.llvm.org/D120397

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


[PATCH] D122303: [pseudo] Sort nonterminals based on their reduction order.

2022-03-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 417567.
hokein added a comment.

some tweaks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122303

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/lib/GrammarBNF.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/unittests/CMakeLists.txt
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/TestGrammar.cpp
  clang-tools-extra/pseudo/unittests/TestGrammar.h

Index: clang-tools-extra/pseudo/unittests/TestGrammar.h
===
--- /dev/null
+++ clang-tools-extra/pseudo/unittests/TestGrammar.h
@@ -0,0 +1,33 @@
+//===--- TestGrammar.h ===//
+
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides shared grammar-related test facilities among tests.
+//
+//===--===//
+
+#include "clang-pseudo/Grammar.h"
+
+namespace clang {
+namespace pseudo {
+
+struct TestGrammar {
+  static TestGrammar build(llvm::StringRef BNF);
+
+  // Returns the symbol id for the given name.
+  SymbolID symbol(llvm::StringRef Name) const;
+
+  // Returns the rule id for the given nonterminal name.
+  // The nonterminal symbo is expected to have a single rule in the grammar.
+  RuleID singleRuleFor(llvm::StringRef NonterminalName) const;
+
+  std::unique_ptr G;
+  std::vector Diags;
+};
+
+} // namespace pseudo
+} // namespace clang
Index: clang-tools-extra/pseudo/unittests/TestGrammar.cpp
===
--- /dev/null
+++ clang-tools-extra/pseudo/unittests/TestGrammar.cpp
@@ -0,0 +1,43 @@
+//===--- TestGrammar.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestGrammar.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace pseudo {
+
+TestGrammar TestGrammar::build(llvm::StringRef BNF) {
+  TestGrammar T;
+  T.G = Grammar::parseBNF(BNF, T.Diags);
+  return T;
+}
+
+SymbolID TestGrammar::symbol(llvm::StringRef Name) const {
+  for (unsigned I = 0; I < NumTerminals; ++I)
+if (G->table().Terminals[I] == Name)
+  return tokenSymbol(static_cast(I));
+  for (SymbolID ID = 0; ID < G->table().Nonterminals.size(); ++ID)
+if (G->table().Nonterminals[ID].Name == Name)
+  return ID;
+  llvm::errs() << "No such symbol found: " << Name;
+  std::abort();
+}
+
+RuleID TestGrammar::singleRuleFor(llvm::StringRef NonterminalName) const {
+  auto RuleRange = G->table().Nonterminals[symbol(NonterminalName)].RuleRange;
+  if (RuleRange.End - RuleRange.Start == 1)
+return G->table().Nonterminals[symbol(NonterminalName)].RuleRange.Start;
+  llvm::errs() << "Expected a single rule for " << NonterminalName
+   << ", but it has " << RuleRange.End - RuleRange.Start
+   << " rule!\n";
+  std::abort();
+}
+
+} // namespace pseudo
+} // namespace clang
Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang-pseudo/Grammar.h"
+#include "TestGrammar.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -26,76 +27,78 @@
   return testing::Property(::seq, ElementsAre(IDs...));
 }
 
-class GrammarTest : public ::testing::Test {
-public:
-  void build(llvm::StringRef BNF) {
-Diags.clear();
-G = Grammar::parseBNF(BNF, Diags);
-  }
-
-  SymbolID id(llvm::StringRef Name) const {
-for (unsigned I = 0; I < NumTerminals; ++I)
-  if (G->table().Terminals[I] == Name)
-return tokenSymbol(static_cast(I));
-for (SymbolID ID = 0; ID < G->table().Nonterminals.size(); ++ID)
-  if (G->table().Nonterminals[ID].Name == Name)
-return ID;
-ADD_FAILURE() << "No such symbol found: " << Name;
-return 0;
-  }
-
-protected:
-  std::unique_ptr G;
-  std::vector Diags;
-};
-
-TEST_F(GrammarTest, Basic) {
-  build("_ := IDENTIFIER + _ # comment");
-  EXPECT_THAT(Diags, IsEmpty());
+TEST(GrammarTest, 

[PATCH] D121201: [clang] Merge the SourceRange into ParsedAttributes

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, feel free to add the assert when you land.




Comment at: clang/include/clang/Sema/ParsedAttr.h:813
   void takeAllFrom(AttributePool ) {
 takePool(pool);
 pool.Attrs.clear();

tbaeder wrote:
> erichkeane wrote:
> > so: `assert( != this && "Stealing from yourself?  Super bad...")`.
> RIght, that's what I had locally.
That's a reasonable assert to add.


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

https://reviews.llvm.org/D121201

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


[PATCH] D115248: [Clang] Fix PR28101

2022-03-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3430
   << D.getName().TemplateId->LAngleLoc;
+  if (cast(CurContext)->getDeclName() == Name)
+Diag(Loc, diag::err_member_name_of_class) << Name;

I see we are diagnosing this ONLY inside of the case where it is a template.  
Where is this caught when we are in the non-template case, why doesn't THAT 
catch these cases, and what would it take to do so?



Comment at: clang/test/SemaCXX/PR28101.cpp:8
+
+#ifdef CASE_1
+

This isn't necessary, the compiler in verify mode should see all errors.  I see 
above at most 2 invocations of the compiler as necessary.



Comment at: clang/test/SemaCXX/PR28101.cpp:13
+  T(A){}; // expected-error{{member 'A' cannot have template arguments}}\
+  // expected-error{{member 'A' has the same name as its class}}
+};

This second error here is strange, I don't see it as particularly useful here.

I see gcc at least gives the full name (int `A::A`), perhaps that makes 
this more useful?



Comment at: clang/test/SemaCXX/PR28101.cpp:16
+
+A instantiate() { return {nullptr}; }
+

How come there are no notes in this test that say 'in instantiation of...'?  I 
would expect those in at least some of these cases, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115248

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


[PATCH] D122303: [pseudo] Sort nonterminals based on their reduction order.

2022-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I think my main suggestion is to sort the symbols, not just the rules.
Having the rules in blocks grouped by the symbol they produce, but not in 
symbol order, seems confusing to reason about.

The extraction of TestGrammar seems unrelated to the rest of the patch and it 
*isn't* actually shared between tests yet, which makes it a bit hard to review.




Comment at: clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h:168
 
-  // The rules are sorted (and thus grouped) by target symbol.
+  // The rules are topological sorted (and thus grouped) by the target symbol.
+  //

I think it's easier to understand if we sort the *symbols* and leave this 
comment as-is.
It feels a bit strange to sort the symbols alphabetically but sort the rules by 
some other property of the symbols.

It's also important to describe what relation we're sorting by!

I'd say "The symbols are topologically sorted: if `S := T` then S has a higher 
SymbolID than T."



Comment at: clang-tools-extra/pseudo/lib/GrammarBNF.cpp:55
 };
 for (const auto  : Specs) {
   Consider(Spec.Target);

You could identify dependencies here, and then use them to sort the 
uniquenonterminals before  allocating SymbolIDs



Comment at: clang-tools-extra/pseudo/lib/GrammarBNF.cpp:122
+  std::vector getTopologicalOrder(GrammarTable *T) {
+llvm::DenseMap> DependencyGraph;
+for (const auto  : T->Rules) {

The map seems unneccesary - just a vector> 
Dependencies, and sort them?



Comment at: clang-tools-extra/pseudo/lib/GrammarBNF.cpp:135
+};
+std::vector VisitStates(T->Nonterminals.size(), NotVisited);
+std::function DFS = [&](SymbolID SID) -> void {

(is a vector of symbol id, or of states?)



Comment at: clang-tools-extra/pseudo/unittests/TestGrammar.h:18
+
+struct TestGrammar {
+  static TestGrammar build(llvm::StringRef BNF);

doc



Comment at: clang-tools-extra/pseudo/unittests/TestGrammar.h:26
+  // The nonterminal symbo is expected to have a single rule in the grammar.
+  RuleID singleRuleFor(llvm::StringRef NonterminalName) const;
+

I think this puts too much to much emphasis on the "single" and breaks the 
symmetry with "symbol" - i'd prefer just "ruleFor".

(The failure mode here is just that the test crashes 100% of the time, so the 
risk seems low)



Comment at: clang-tools-extra/pseudo/unittests/TestGrammar.h:28
+
+  std::unique_ptr G;
+  std::vector Diags;

shouldn't these be private, or have better names, and docs when they're set etc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122303

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


[clang] ba2be80 - [CGOpenMPRuntime] Reuse getDepobjElements() (NFC)

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T11:31:49+01:00
New Revision: ba2be802b04a19c2398401867de3746df1bad7d6

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

LOG: [CGOpenMPRuntime] Reuse getDepobjElements() (NFC)

There were two more places repeating this code, reuse the helper.
This requires moving the static functions into the class.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b7ee9ce10e02b..ee51420c65026 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4728,44 +4728,25 @@ static void emitDependData(CodeGenFunction , 
QualType ,
   }
 }
 
-static SmallVector
-emitDepobjElementsSizes(CodeGenFunction , QualType ,
-const OMPTaskDataTy::DependData ) {
+SmallVector CGOpenMPRuntime::emitDepobjElementsSizes(
+CodeGenFunction , QualType ,
+const OMPTaskDataTy::DependData ) {
   assert(Data.DepKind == OMPC_DEPEND_depobj &&
  "Expected depobj dependecy kind.");
   SmallVector Sizes;
   SmallVector SizeLVals;
   ASTContext  = CGF.getContext();
-  QualType FlagsTy;
-  getDependTypes(C, KmpDependInfoTy, FlagsTy);
-  RecordDecl *KmpDependInfoRD =
-  cast(KmpDependInfoTy->getAsTagDecl());
-  QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
-  llvm::Type *KmpDependInfoPtrT = CGF.ConvertTypeForMem(KmpDependInfoPtrTy);
   {
 OMPIteratorGeneratorScope IteratorScope(
 CGF, cast_or_null(
  Data.IteratorExpr ? Data.IteratorExpr->IgnoreParenImpCasts()
: nullptr));
 for (const Expr *E : Data.DepExprs) {
+  llvm::Value *NumDeps;
+  LValue Base;
   LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts());
-  LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF),
-  C.getPointerType(C.VoidPtrTy).castAs());
-  Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-  Base.getAddress(CGF), KmpDependInfoPtrT,
-  CGF.ConvertTypeForMem(KmpDependInfoTy));
-  Base = CGF.MakeAddrLValue(Addr, KmpDependInfoTy, Base.getBaseInfo(),
-Base.getTBAAInfo());
-  Address DepObjAddr = CGF.Builder.CreateGEP(
-  Addr, llvm::ConstantInt::get(CGF.IntPtrTy, -1, /*isSigned=*/true));
-  LValue NumDepsBase = CGF.MakeAddrLValue(
-  DepObjAddr, KmpDependInfoTy, Base.getBaseInfo(), Base.getTBAAInfo());
-  // NumDeps = deps[i].base_addr;
-  LValue BaseAddrLVal = CGF.EmitLValueForField(
-  NumDepsBase, *std::next(KmpDependInfoRD->field_begin(), BaseAddr));
-  llvm::Value *NumDeps =
-  CGF.EmitLoadOfScalar(BaseAddrLVal, E->getExprLoc());
+  std::tie(NumDeps, Base) =
+  getDepobjElements(CGF, DepobjLVal, E->getExprLoc());
   LValue NumLVal = CGF.MakeAddrLValue(
   CGF.CreateMemTemp(C.getUIntPtrType(), "depobj.size.addr"),
   C.getUIntPtrType());
@@ -4785,19 +4766,13 @@ emitDepobjElementsSizes(CodeGenFunction , QualType 
,
   return Sizes;
 }
 
-static void emitDepobjElements(CodeGenFunction , QualType ,
-   LValue PosLVal,
-   const OMPTaskDataTy::DependData ,
-   Address DependenciesArray) {
+void CGOpenMPRuntime::emitDepobjElements(CodeGenFunction ,
+ QualType ,
+ LValue PosLVal,
+ const OMPTaskDataTy::DependData ,
+ Address DependenciesArray) {
   assert(Data.DepKind == OMPC_DEPEND_depobj &&
  "Expected depobj dependecy kind.");
-  ASTContext  = CGF.getContext();
-  QualType FlagsTy;
-  getDependTypes(C, KmpDependInfoTy, FlagsTy);
-  RecordDecl *KmpDependInfoRD =
-  cast(KmpDependInfoTy->getAsTagDecl());
-  QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
-  llvm::Type *KmpDependInfoPtrT = CGF.ConvertTypeForMem(KmpDependInfoPtrTy);
   llvm::Value *ElSize = CGF.getTypeSize(KmpDependInfoTy);
   {
 OMPIteratorGeneratorScope IteratorScope(
@@ -4806,26 +4781,11 @@ static void emitDepobjElements(CodeGenFunction , 
QualType ,
: nullptr));
 for (unsigned I = 0, End = Data.DepExprs.size(); I < End; ++I) {
   const Expr *E = Data.DepExprs[I];
+  llvm::Value *NumDeps;
+  LValue Base;
   LValue DepobjLVal = CGF.EmitLValue(E->IgnoreParenImpCasts());
-  LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF),
-  

[PATCH] D118052: [X86] Fix CodeGen Module Flag for -mibt-seal

2022-03-23 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.

LGTM.




Comment at: clang/test/CodeGen/X86/x86-cf-protection.c:6
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S 
-fcf-protection=branch -flto %s | FileCheck %s --check-prefix=NOIBTSEAL
+// RUN: %clang -target i386-unknown-unknown -o - -emit-llvm -S 
-fcf-protection=branch -mibt-seal %s | FileCheck %s --check-prefix=NOLTO
 

I think we can use `NOIBTSEAL` here too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118052

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


[clang] 8b62dd3 - Reapply [CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T12:06:11+01:00
New Revision: 8b62dd3cd6d775a9c6ae3bfe841bf965dc2c944d

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

LOG: Reapply [CodeGen] Avoid deprecated Address ctor in EmitLoadOfPointer()

This requires some adjustment in caller code, because there was
a confusion regarding the meaning of the PtrTy argument: This
argument is the type of the pointer being loaded, not the addresses
being loaded from.

Reapply after fixing the specified pointer type for one call in
47eb4f7dcd845878b16a53dadd765195b9c24b6e, where the used type is
important for determining alignment.

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index b0eeddd98fce6..2ee62f97399ac 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2547,10 +2547,10 @@ Address CodeGenFunction::EmitLoadOfPointer(Address Ptr,
LValueBaseInfo *BaseInfo,
TBAAAccessInfo *TBAAInfo) {
   llvm::Value *Addr = Builder.CreateLoad(Ptr);
-  return Address::deprecated(
-  Addr,
-  CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo, TBAAInfo,
-  /*forPointeeType=*/true));
+  return Address(Addr, ConvertTypeForMem(PtrTy->getPointeeType()),
+ CGM.getNaturalTypeAlignment(PtrTy->getPointeeType(), BaseInfo,
+ TBAAInfo,
+ /*forPointeeType=*/true));
 }
 
 LValue CodeGenFunction::EmitLoadOfPointerLValue(Address PtrAddr,

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 17bd9dbbedd34..e5bab2284699b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -5016,8 +5016,7 @@ void CGOpenMPRuntime::emitDestroyClause(CodeGenFunction 
, LValue DepobjLVal,
   QualType FlagsTy;
   getDependTypes(C, KmpDependInfoTy, FlagsTy);
   LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF),
-  C.getPointerType(C.VoidPtrTy).castAs());
+  DepobjLVal.getAddress(CGF), C.VoidPtrTy.castAs());
   QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
   Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy),
@@ -5999,8 +5998,7 @@ static llvm::Value *emitReduceFiniFunction(CodeGenModule 
,
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
   Address PrivateAddr = CGF.EmitLoadOfPointer(
-  CGF.GetAddrOfLocalVar(),
-  C.getPointerType(C.VoidPtrTy).castAs());
+  CGF.GetAddrOfLocalVar(), C.VoidPtrTy.castAs());
   llvm::Value *Size = nullptr;
   // If the size of the reduction item is non-constant, load it from global
   // threadprivate variable.

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 1814102f749af..f4228cfb3086e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3558,8 +3558,7 @@ llvm::Function 
*CGOpenMPRuntimeGPU::createParallelDataSharingWrapper(
   isOpenMPLoopBoundSharingDirective(D.getDirectiveKind())) {
 SharedArgListAddress = CGF.EmitLoadOfPointer(
 GlobalArgs, CGF.getContext()
-.getPointerType(CGF.getContext().getPointerType(
-CGF.getContext().VoidPtrTy))
+.getPointerType(CGF.getContext().VoidPtrTy)
 .castAs());
   }
   unsigned Idx = 0;

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 24000b99608f7..bda447339d42d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -2527,6 +2527,9 @@ class CodeGenFunction : public CodeGenTypeCache {
 return EmitLoadOfReferenceLValue(RefLVal);
   }
 
+  /// Load a pointer with type \p PtrTy stored at address \p Ptr.
+  /// Note that \p PtrTy is the type of the loaded pointer, not the addresses
+  /// it is loaded from.
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
 LValueBaseInfo *BaseInfo = nullptr,
 TBAAAccessInfo *TBAAInfo = nullptr);



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


[PATCH] D121992: [Clang] [Driver] Add option to set alternative toolchain path

2022-03-23 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 417566.
qiucf marked 3 inline comments as done.
qiucf added a comment.

- Move test to another file
- Add documentation on option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121992

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/include/.keep
  clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib64/.keep
  clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-8.3.0/include/.keep
  
clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-8.3.0/lib/gcc/powerpc64le-linux-gnu/8.3.0/.keep
  clang/test/Driver/Inputs/powerpc64le-linux-gnu-tree/gcc-8.3.0/lib64/.keep
  clang/test/Driver/overlay-toolchain.cpp

Index: clang/test/Driver/overlay-toolchain.cpp
===
--- /dev/null
+++ clang/test/Driver/overlay-toolchain.cpp
@@ -0,0 +1,18 @@
+// RUN: %clangxx %s -### --target=powerpc64le-linux-gnu \
+// RUN:   --overlay-platform-toolchain=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0 \
+// RUN:   2>&1 | FileCheck %s --check-prefix=OVERLAY
+// RUN: %clangxx %s -### --target=powerpc64le-linux-gnu \
+// RUN:   --sysroot=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-8.3.0 \
+// RUN:   --overlay-platform-toolchain=%S/Inputs/powerpc64le-linux-gnu-tree/gcc-11.2.0 \
+// RUN:   2>&1 | FileCheck %s --check-prefixes=OVERLAY,ROOT
+
+// OVERLAY: "-internal-externc-isystem"
+// OVERLAY: "[[TOOLCHAIN:[^"]+]]/powerpc64le-linux-gnu-tree/gcc-11.2.0/include"
+// ROOT: "-internal-externc-isystem"
+// ROOT: "[[TOOLCHAIN]]/powerpc64le-linux-gnu-tree/gcc-8.3.0/include"
+// OVERLAY: "-dynamic-linker"
+// OVERLAY: "[[TOOLCHAIN]]/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib64/ld64.so.2"
+// OVERLAY: "-L[[TOOLCHAIN]]/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib/../lib64"
+// ROOT: "-L[[TOOLCHAIN]]/powerpc64le-linux-gnu-tree/gcc-8.3.0/lib/../lib64"
+// OVERLAY: "-L[[TOOLCHAIN]]/powerpc64le-linux-gnu-tree/gcc-11.2.0/lib"
+// ROOT: "-L[[TOOLCHAIN]]/powerpc64le-linux-gnu-tree/gcc-8.3.0/lib"
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -260,6 +260,14 @@
 
   const std::string OSLibDir = std::string(getOSLibDir(Triple, Args));
   const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
+  const std::string  = D.OverlayToolChainPath;
+
+  if (!D.OverlayToolChainPath.empty()) {
+addPathIfExists(D, ExtraPath + "/lib/" + MultiarchTriple, Paths);
+addPathIfExists(D, ExtraPath + "/lib/../" + OSLibDir, Paths);
+addPathIfExists(D, ExtraPath + "/usr/lib/" + MultiarchTriple, Paths);
+addPathIfExists(D, ExtraPath + "/usr/lib/../" + OSLibDir, Paths);
+  }
 
   // mips32: Debian multilib, we use /libo32, while in other case, /lib is
   // used. We need add both libo32 and /lib.
@@ -314,6 +322,11 @@
   addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
   }
 
+  if (!D.OverlayToolChainPath.empty()) {
+addPathIfExists(D, ExtraPath + "/lib", Paths);
+addPathIfExists(D, ExtraPath + "/usr/lib", Paths);
+  }
+
   addPathIfExists(D, SysRoot + "/lib", Paths);
   addPathIfExists(D, SysRoot + "/usr/lib", Paths);
 }
@@ -567,6 +580,10 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
+  if (!D.OverlayToolChainPath.empty())
+addExternCSystemInclude(DriverArgs, CC1Args,
+D.OverlayToolChainPath + "/include");
+
   // LOCAL_INCLUDE_DIR
   addSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/local/include");
   // TOOL_INCLUDE_DIR
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1867,6 +1867,10 @@
   if (A)
 return A->getValue();
 
+  if (const Arg *X = Args.getLastArg(
+  clang::driver::options::OPT__overlay_platform_toolchain_EQ))
+return X->getValue();
+
   // If we have a SysRoot, ignore GCC_INSTALL_PREFIX.
   // GCC_INSTALL_PREFIX specifies the gcc installation for the default
   // sysroot and is likely not valid with a different sysroot.
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1208,6 +1208,11 @@
   CompilerPath = Split.second;
 }
   }
+  if (const Arg *A =
+  Args.getLastArg(options::OPT__overlay_platform_toolchain_EQ)) {
+OverlayToolChainPath = A->getValue();
+DyldPrefix = A->getValue();
+  }
   if (const Arg *A = Args.getLastArg(options::OPT__sysroot_EQ))
 SysRoot = 

[PATCH] D118052: [X86] Fix CodeGen Module Flag for -mibt-seal

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D118052#3401861 , @joaomoreira 
wrote:

> I did track down the problem to clang/lib/Frontend/CompilerInvocation.cpp -- 
> RoundTrip method. There, we can se the following statement:
>
>   #ifndef NDEBUG
> bool DoRoundTripDefault = true;
>   #else
> bool DoRoundTripDefault = false;
>   #endif
>
> Comment in the file says: "By default, the round-trip is enabled in assert 
> builds... During round-trip, the command line arguments are parsed into a 
> dummy instance of CompilerInvocation which is used to generate the command 
> line arguments again. The real CompilerInvocation instance is then created by 
> parsing the generated arguments, not the original ones.". Then, because the 
> arguments set through this latest patch were not being generated, they would 
> be missing in the dummy instance of CompilerInvocation and then not repassed 
> into the real instance.
>
> Given the above, my understanding is that there was never an actual bug that 
> made ibt-seal stop working. The patch was just not tested enough and a 
> confusion in different build setups blinded me against what was really 
> happening.
>
> Thank you for pushing me into looking into this @aaron.ballman. Also, with 
> all this said, I'm no expert in clang/front-end, so it would be great if you 
> could give an additional look into it and confirm the above.
>
> If all is right, the patch remains correct and there are no hidden bugs. I'll 
> update the patch shortly to add the test requested by @pengfei.

That sounds like the correct analysis to me! Thanks for tracking that down.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118052

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


[PATCH] D121451: [clang-format] Add space to comments starting with '#'.

2022-03-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D121451#3401947 , @MyDeveloperDay 
wrote:

> I'm a little uncomfortable with
>
>   //#
>
> becoming
>
>   // #
>
> At least without an option for it to not make changes

Don't you think that `//#PPdirective` should be indented the same way as other 
code?
E.g. in:

  #include 
  
  int something;

You comment the whole block and it becomes (with this patch):

  // #include 
  //
  // int something;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121451

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


[PATCH] D122141: [clang][extract-api] Suppprt for the module name property in SymbolGraph

2022-03-23 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 417570.
dang added a comment.

Missed some stuff in the previous rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122141

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/include/clang/SymbolGraph/Serialization.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/lib/SymbolGraph/Serialization.cpp
  clang/test/ExtractAPI/global_record.c

Index: clang/test/ExtractAPI/global_record.c
===
--- clang/test/ExtractAPI/global_record.c
+++ clang/test/ExtractAPI/global_record.c
@@ -2,7 +2,7 @@
 // RUN: split-file %s %t
 // RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
 // RUN: %t/reference.output.json
-// RUN: %clang -extract-api -target arm64-apple-macosx \
+// RUN: %clang -extract-api --product-name=GlobalRecord -target arm64-apple-macosx \
 // RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
 
 // Generator version is not consistent across test runs, normalize it.
@@ -37,7 +37,7 @@
 "generator": "?"
   },
   "module": {
-"name": "",
+"name": "GlobalRecord",
 "platform": {
   "architecture": "arm64",
   "operatingSystem": {
Index: clang/lib/SymbolGraph/Serialization.cpp
===
--- /dev/null
+++ clang/lib/SymbolGraph/Serialization.cpp
@@ -0,0 +1,331 @@
+//===- SymbolGraph/Serialization.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// \brief Defines the SymbolGraph serializer and parser.
+///
+//===--===//
+
+#include "clang/SymbolGraph/Serialization.h"
+#include "clang/Basic/Version.h"
+#include "clang/SymbolGraph/API.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/VersionTuple.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+using namespace clang::symbolgraph;
+using namespace llvm;
+using namespace llvm::json;
+
+namespace {
+
+static void serializeObject(Object , StringRef Key,
+Optional Obj) {
+  if (Obj)
+Paren[Key] = std::move(Obj.getValue());
+}
+
+static void serializeArray(Object , StringRef Key,
+   Optional Array) {
+  if (Array)
+Paren[Key] = std::move(Array.getValue());
+}
+
+// SymbolGraph: SemanticVersion
+static Optional serializeSemanticVersion(const VersionTuple ) {
+  if (V.empty())
+return None;
+
+  Object Version;
+  Version["major"] = V.getMajor();
+  Version["minor"] = V.getMinor().getValueOr(0);
+  Version["patch"] = V.getSubminor().getValueOr(0);
+  return Version;
+}
+
+static Object serializeOperatingSystem(const Triple ) {
+  Object OS;
+  OS["name"] = T.getOSTypeName(T.getOS());
+  serializeObject(OS, "minimumVersion",
+  serializeSemanticVersion(T.getMinimumSupportedOSVersion()));
+  return OS;
+}
+
+// SymbolGraph: Platform
+static Object serializePlatform(const Triple ) {
+  Object Platform;
+  Platform["architecture"] = T.getArchName();
+  Platform["vendor"] = T.getVendorName();
+  Platform["operatingSystem"] = serializeOperatingSystem(T);
+  return Platform;
+}
+
+// SymbolGraph: SourcePosition
+static Object serializeSourcePosition(const PresumedLoc ,
+  bool IncludeFileURI = false) {
+  assert(Loc.isValid() && "invalid source position");
+
+  Object SourcePosition;
+  SourcePosition["line"] = Loc.getLine();
+  SourcePosition["character"] = Loc.getColumn();
+
+  if (IncludeFileURI) {
+std::string FileURI = "file://";
+FileURI += sys::path::convert_to_slash(Loc.getFilename());
+SourcePosition["uri"] = FileURI;
+  }
+
+  return SourcePosition;
+}
+
+// SymbolGraph: SourceRange
+static Object serializeSourceRange(const PresumedLoc ,
+   const PresumedLoc ) {
+  Object SourceRange;
+  serializeObject(SourceRange, "start", serializeSourcePosition(BeginLoc));
+  serializeObject(SourceRange, "end", serializeSourcePosition(EndLoc));
+  return SourceRange;
+}
+
+// SymbolGraph: AvailabilityItem
+static Optional serializeAvailability(const AvailabilityInfo ) {
+  if (Avail.isDefault())
+return None;
+
+  Object Availbility;
+  serializeObject(Availbility, "introducedVersion",
+  

[PATCH] D122278: [clang] Improve diagnostic for reopened inline namespace

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for the fix! This LGTM with a minor nit, but please also add a 
release note for the fix.




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:11062-11066
+  if (auto *FirstNS = PrevNS->getFirstDecl())
+// 'inline' must appear on the original definition, but not necessarily
+// on all extension definitions, so the note should point to the first
+// definition to avoid confusion.
+PrevNS = FirstNS;

There are no circumstances under which `getFirstDecl()` should return null, so 
I think this can be simplified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122278

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


[clang] 5fdc4dd - [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)

2022-03-23 Thread via cfe-commits

Author: Vince Bridgers
Date: 2022-03-23T08:26:37-05:00
New Revision: 5fdc4dd7770486c0127dc5919aafea3f8ff2e61e

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

LOG: [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth 
(NFC)

This is a NFC refactoring to change makeIntValWithPtrWidth
and remove getZeroWithPtrWidth to use types when forming values to match
pointer widths. Some targets may have different pointer widths depending
upon address space, so this needs to be comprehended.

Reviewed By: steakhal

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
index 8a778389bcbe1..e7d64313ea42c 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -220,14 +220,6 @@ class BasicValueFactory {
 return getValue(0, Ctx.getTypeSize(T), true);
   }
 
-  const llvm::APSInt (bool isUnsigned = true) {
-return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
-  }
-
-  const llvm::APSInt (uint64_t X, bool isUnsigned) {
-return getValue(X, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
-  }
-
   const llvm::APSInt (bool b, QualType T) {
 return getValue(b ? 1 : 0, Ctx.getIntWidth(T),
 T->isUnsignedIntegerOrEnumerationType());

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
index 1f02ee84c898a..8452cf0ab 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -332,9 +332,8 @@ class SValBuilder {
 return nonloc::ConcreteInt(BasicVals.getIntValue(integer, isUnsigned));
   }
 
-  NonLoc makeIntValWithPtrWidth(uint64_t integer, bool isUnsigned) {
-return nonloc::ConcreteInt(
-BasicVals.getIntWithPtrWidth(integer, isUnsigned));
+  NonLoc makeIntValWithWidth(QualType ptrType, uint64_t integer) {
+return nonloc::ConcreteInt(BasicVals.getValue(integer, ptrType));
   }
 
   NonLoc makeLocAsInteger(Loc loc, unsigned bits) {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 63b1065ae4de0..790a2fa4059d1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2608,8 +2608,9 @@ MallocChecker::ReallocMemAux(CheckerContext , const 
CallEvent ,
 
   // Compare the size argument to 0.
   DefinedOrUnknownSVal SizeZero =
-svalBuilder.evalEQ(State, TotalSize.castAs(),
-   svalBuilder.makeIntValWithPtrWidth(0, false));
+  svalBuilder.evalEQ(State, TotalSize.castAs(),
+ svalBuilder.makeIntValWithWidth(
+ svalBuilder.getContext().getSizeType(), 0));
 
   ProgramStateRef StatePtrIsNull, StatePtrNotNull;
   std::tie(StatePtrIsNull, StatePtrNotNull) = State->assume(PtrEQ);

diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index e38c90603299a..6ad6eaf6dd468 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1345,8 +1345,9 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
 case Stmt::GNUNullExprClass: {
   // GNU __null is a pointer-width integer, not an actual pointer.
   ProgramStateRef state = Pred->getState();
-  state = state->BindExpr(S, Pred->getLocationContext(),
-  svalBuilder.makeIntValWithPtrWidth(0, false));
+  state = state->BindExpr(
+  S, Pred->getLocationContext(),
+  svalBuilder.makeIntValWithWidth(getContext().VoidPtrTy, 0));
   Bldr.generateNode(S, Pred, state);
   break;
 }

diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index a4a65ad20b577..e9a1ec3173a94 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -742,9 +742,6 @@ SVal SValBuilder::evalCastSubKind(loc::MemRegionVal V, 
QualType CastTy,
   // This change is needed for architectures with varying
 

[clang] 9ef7ac5 - [analyzer] Fix crash in RangedConstraintManager.cpp

2022-03-23 Thread via cfe-commits

Author: Vince Bridgers
Date: 2022-03-23T08:26:40-05:00
New Revision: 9ef7ac51af67d08212dc69e5a932c4aa447ee9b7

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

LOG: [analyzer] Fix crash in RangedConstraintManager.cpp

This change fixes a crash in RangedConstraintManager.cpp:assumeSym due to an
unhandled BO_Div case.

clang: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp:51:
  virtual clang::ento::ProgramStateRef
  clang::ento::RangedConstraintManager::assumeSym(clang::ento::ProgramStateRef,
clang::ento::SymbolRef, bool):
  Assertion `BinaryOperator::isComparisonOp(Op)' failed.

Reviewed By: NoQ

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

Added: 
clang/test/Analysis/symbol-simplification-bo-div.c

Modified: 
clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
index 892d64ea4e4e2..4bbe933be2129 100644
--- a/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -48,47 +48,48 @@ ProgramStateRef 
RangedConstraintManager::assumeSym(ProgramStateRef State,
 
   if (const auto *SSE = dyn_cast(Sym)) {
 BinaryOperator::Opcode Op = SSE->getOpcode();
-assert(BinaryOperator::isComparisonOp(Op));
-
-// We convert equality operations for pointers only.
-if (Loc::isLocType(SSE->getLHS()->getType()) &&
-Loc::isLocType(SSE->getRHS()->getType())) {
-  // Translate "a != b" to "(b - a) != 0".
-  // We invert the order of the operands as a heuristic for how loop
-  // conditions are usually written ("begin != end") as compared to length
-  // calculations ("end - begin"). The more correct thing to do would be to
-  // canonicalize "a - b" and "b - a", which would allow us to treat
-  // "a != b" and "b != a" the same.
-
-  SymbolManager  = getSymbolManager();
-  QualType DiffTy = SymMgr.getContext().getPointerDiffType();
-  SymbolRef Subtraction =
-  SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
-
-  const llvm::APSInt  = getBasicVals().getValue(0, DiffTy);
-  Op = BinaryOperator::reverseComparisonOp(Op);
-  if (!Assumption)
-Op = BinaryOperator::negateComparisonOp(Op);
-  return assumeSymRel(State, Subtraction, Op, Zero);
-}
+if (BinaryOperator::isComparisonOp(Op)) {
+
+  // We convert equality operations for pointers only.
+  if (Loc::isLocType(SSE->getLHS()->getType()) &&
+  Loc::isLocType(SSE->getRHS()->getType())) {
+// Translate "a != b" to "(b - a) != 0".
+// We invert the order of the operands as a heuristic for how loop
+// conditions are usually written ("begin != end") as compared to 
length
+// calculations ("end - begin"). The more correct thing to do would be
+// to canonicalize "a - b" and "b - a", which would allow us to treat
+// "a != b" and "b != a" the same.
+
+SymbolManager  = getSymbolManager();
+QualType DiffTy = SymMgr.getContext().getPointerDiffType();
+SymbolRef Subtraction =
+SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
+
+const llvm::APSInt  = getBasicVals().getValue(0, DiffTy);
+Op = BinaryOperator::reverseComparisonOp(Op);
+if (!Assumption)
+  Op = BinaryOperator::negateComparisonOp(Op);
+return assumeSymRel(State, Subtraction, Op, Zero);
+  }
 
-if (BinaryOperator::isEqualityOp(Op)) {
-  SymbolManager  = getSymbolManager();
+  if (BinaryOperator::isEqualityOp(Op)) {
+SymbolManager  = getSymbolManager();
 
-  QualType ExprType = SSE->getType();
-  SymbolRef CanonicalEquality =
-  SymMgr.getSymSymExpr(SSE->getLHS(), BO_EQ, SSE->getRHS(), ExprType);
+QualType ExprType = SSE->getType();
+SymbolRef CanonicalEquality =
+SymMgr.getSymSymExpr(SSE->getLHS(), BO_EQ, SSE->getRHS(), 
ExprType);
 
-  bool WasEqual = SSE->getOpcode() == BO_EQ;
-  bool IsExpectedEqual = WasEqual == Assumption;
+bool WasEqual = SSE->getOpcode() == BO_EQ;
+bool IsExpectedEqual = WasEqual == Assumption;
 
-  const llvm::APSInt  = getBasicVals().getValue(0, ExprType);
+const llvm::APSInt  = getBasicVals().getValue(0, ExprType);
 
-  if (IsExpectedEqual) {
-return assumeSymNE(State, CanonicalEquality, Zero, Zero);
-  }
+if (IsExpectedEqual) {
+  return assumeSymNE(State, CanonicalEquality, Zero, Zero);
+}
 
-  return assumeSymEQ(State, CanonicalEquality, Zero, Zero);
+return assumeSymEQ(State, CanonicalEquality, Zero, 

[PATCH] D120134: [analyzer] refactor makeIntValWithPtrWidth, remove getZeroWithPtrWidth (NFC)

2022-03-23 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5fdc4dd77704: [analyzer] refactor makeIntValWithPtrWidth, 
remove getZeroWithPtrWidth (NFC) (authored by vabridgers, committed by einvbri 
vince.a.bridg...@ericsson.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120134

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -742,9 +742,6 @@
   // This change is needed for architectures with varying
   // pointer widths. See the amdgcn opencl reproducer with
   // this change as an example: solver-sym-simplification-ptr-bool.cl
-  // FIXME: Cleanup remainder of `getZeroWithPtrWidth ()`
-  //and `getIntWithPtrWidth()` functions to prevent future
-  //confusion
   if (!Ty->isReferenceType())
 return makeNonLoc(Sym, BO_NE, BasicVals.getZeroWithTypeSize(Ty),
   CastTy);
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1345,8 +1345,9 @@
 case Stmt::GNUNullExprClass: {
   // GNU __null is a pointer-width integer, not an actual pointer.
   ProgramStateRef state = Pred->getState();
-  state = state->BindExpr(S, Pred->getLocationContext(),
-  svalBuilder.makeIntValWithPtrWidth(0, false));
+  state = state->BindExpr(
+  S, Pred->getLocationContext(),
+  svalBuilder.makeIntValWithWidth(getContext().VoidPtrTy, 0));
   Bldr.generateNode(S, Pred, state);
   break;
 }
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2608,8 +2608,9 @@
 
   // Compare the size argument to 0.
   DefinedOrUnknownSVal SizeZero =
-svalBuilder.evalEQ(State, TotalSize.castAs(),
-   svalBuilder.makeIntValWithPtrWidth(0, false));
+  svalBuilder.evalEQ(State, TotalSize.castAs(),
+ svalBuilder.makeIntValWithWidth(
+ svalBuilder.getContext().getSizeType(), 0));
 
   ProgramStateRef StatePtrIsNull, StatePtrNotNull;
   std::tie(StatePtrIsNull, StatePtrNotNull) = State->assume(PtrEQ);
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -332,9 +332,8 @@
 return nonloc::ConcreteInt(BasicVals.getIntValue(integer, isUnsigned));
   }
 
-  NonLoc makeIntValWithPtrWidth(uint64_t integer, bool isUnsigned) {
-return nonloc::ConcreteInt(
-BasicVals.getIntWithPtrWidth(integer, isUnsigned));
+  NonLoc makeIntValWithWidth(QualType ptrType, uint64_t integer) {
+return nonloc::ConcreteInt(BasicVals.getValue(integer, ptrType));
   }
 
   NonLoc makeLocAsInteger(Loc loc, unsigned bits) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -220,14 +220,6 @@
 return getValue(0, Ctx.getTypeSize(T), true);
   }
 
-  const llvm::APSInt (bool isUnsigned = true) {
-return getValue(0, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
-  }
-
-  const llvm::APSInt (uint64_t X, bool isUnsigned) {
-return getValue(X, Ctx.getTypeSize(Ctx.VoidPtrTy), isUnsigned);
-  }
-
   const llvm::APSInt (bool b, QualType T) {
 return getValue(b ? 1 : 0, Ctx.getIntWidth(T),
 T->isUnsignedIntegerOrEnumerationType());


Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -742,9 +742,6 @@
   // This change is needed for architectures with varying
   // pointer widths. See the amdgcn opencl reproducer with
   // this change as an example: solver-sym-simplification-ptr-bool.cl
-  // FIXME: Cleanup 

[PATCH] D122277: [analyzer] Fix crash in RangedConstraintManager.cpp

2022-03-23 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ef7ac51af67: [analyzer] Fix crash in 
RangedConstraintManager.cpp (authored by vabridgers, committed by einvbri 
vince.a.bridg...@ericsson.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122277

Files:
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/symbol-simplification-bo-div.c

Index: clang/test/Analysis/symbol-simplification-bo-div.c
===
--- /dev/null
+++ clang/test/Analysis/symbol-simplification-bo-div.c
@@ -0,0 +1,14 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core %s \
+// RUN:-triple x86_64-pc-linux-gnu -verify
+
+// don't crash
+// expected-no-diagnostics
+
+int a, b;
+int c(void) {
+  unsigned d = a;
+  --d;
+  short e = b / b - a;
+  ++e;
+  return d <= 0 && e && e;
+}
Index: clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -48,47 +48,48 @@
 
   if (const auto *SSE = dyn_cast(Sym)) {
 BinaryOperator::Opcode Op = SSE->getOpcode();
-assert(BinaryOperator::isComparisonOp(Op));
-
-// We convert equality operations for pointers only.
-if (Loc::isLocType(SSE->getLHS()->getType()) &&
-Loc::isLocType(SSE->getRHS()->getType())) {
-  // Translate "a != b" to "(b - a) != 0".
-  // We invert the order of the operands as a heuristic for how loop
-  // conditions are usually written ("begin != end") as compared to length
-  // calculations ("end - begin"). The more correct thing to do would be to
-  // canonicalize "a - b" and "b - a", which would allow us to treat
-  // "a != b" and "b != a" the same.
-
-  SymbolManager  = getSymbolManager();
-  QualType DiffTy = SymMgr.getContext().getPointerDiffType();
-  SymbolRef Subtraction =
-  SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
-
-  const llvm::APSInt  = getBasicVals().getValue(0, DiffTy);
-  Op = BinaryOperator::reverseComparisonOp(Op);
-  if (!Assumption)
-Op = BinaryOperator::negateComparisonOp(Op);
-  return assumeSymRel(State, Subtraction, Op, Zero);
-}
+if (BinaryOperator::isComparisonOp(Op)) {
+
+  // We convert equality operations for pointers only.
+  if (Loc::isLocType(SSE->getLHS()->getType()) &&
+  Loc::isLocType(SSE->getRHS()->getType())) {
+// Translate "a != b" to "(b - a) != 0".
+// We invert the order of the operands as a heuristic for how loop
+// conditions are usually written ("begin != end") as compared to length
+// calculations ("end - begin"). The more correct thing to do would be
+// to canonicalize "a - b" and "b - a", which would allow us to treat
+// "a != b" and "b != a" the same.
+
+SymbolManager  = getSymbolManager();
+QualType DiffTy = SymMgr.getContext().getPointerDiffType();
+SymbolRef Subtraction =
+SymMgr.getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
+
+const llvm::APSInt  = getBasicVals().getValue(0, DiffTy);
+Op = BinaryOperator::reverseComparisonOp(Op);
+if (!Assumption)
+  Op = BinaryOperator::negateComparisonOp(Op);
+return assumeSymRel(State, Subtraction, Op, Zero);
+  }
 
-if (BinaryOperator::isEqualityOp(Op)) {
-  SymbolManager  = getSymbolManager();
+  if (BinaryOperator::isEqualityOp(Op)) {
+SymbolManager  = getSymbolManager();
 
-  QualType ExprType = SSE->getType();
-  SymbolRef CanonicalEquality =
-  SymMgr.getSymSymExpr(SSE->getLHS(), BO_EQ, SSE->getRHS(), ExprType);
+QualType ExprType = SSE->getType();
+SymbolRef CanonicalEquality =
+SymMgr.getSymSymExpr(SSE->getLHS(), BO_EQ, SSE->getRHS(), ExprType);
 
-  bool WasEqual = SSE->getOpcode() == BO_EQ;
-  bool IsExpectedEqual = WasEqual == Assumption;
+bool WasEqual = SSE->getOpcode() == BO_EQ;
+bool IsExpectedEqual = WasEqual == Assumption;
 
-  const llvm::APSInt  = getBasicVals().getValue(0, ExprType);
+const llvm::APSInt  = getBasicVals().getValue(0, ExprType);
 
-  if (IsExpectedEqual) {
-return assumeSymNE(State, CanonicalEquality, Zero, Zero);
-  }
+if (IsExpectedEqual) {
+  return assumeSymNE(State, CanonicalEquality, Zero, Zero);
+}
 
-  return assumeSymEQ(State, CanonicalEquality, Zero, Zero);
+return assumeSymEQ(State, CanonicalEquality, Zero, Zero);
+  }
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c070d5c - [CGOpenMPRuntime] Remove uses of deprecated Address constructor

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T12:40:44+01:00
New Revision: c070d5ceff05c3459b9a9add6d18aae9a3fa5916

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

LOG: [CGOpenMPRuntime] Remove uses of deprecated Address constructor

And as these are the last remaining uses, also remove the
constructor itself.

Added: 


Modified: 
clang/lib/CodeGen/Address.h
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index e1cec561653f6..bddeac1d6dcbd 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -87,12 +87,6 @@ class Address {
"Incorrect pointer element type");
   }
 
-  // Deprecated: Use constructor with explicit element type instead.
-  static Address deprecated(llvm::Value *Pointer, CharUnits Alignment) {
-return Address(Pointer, Pointer->getType()->getPointerElementType(),
-   Alignment);
-  }
-
   static Address invalid() { return Address(nullptr); }
   bool isValid() const { return A.getPointer() != nullptr; }
 

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e5bab2284699b..a1986c2f8796b 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -937,8 +937,7 @@ static LValue loadToBegin(CodeGenFunction , QualType 
BaseTy, QualType ElTy,
 }
 
 static Address castToBase(CodeGenFunction , QualType BaseTy, QualType ElTy,
-  llvm::Type *BaseLVType, CharUnits BaseLVAlignment,
-  llvm::Value *Addr) {
+  Address OriginalBaseAddress, llvm::Value *Addr) {
   Address Tmp = Address::invalid();
   Address TopTmp = Address::invalid();
   Address MostTopTmp = Address::invalid();
@@ -953,15 +952,17 @@ static Address castToBase(CodeGenFunction , QualType 
BaseTy, QualType ElTy,
 TopTmp = Tmp;
 BaseTy = BaseTy->getPointeeType();
   }
-  llvm::Type *Ty = BaseLVType;
-  if (Tmp.isValid())
-Ty = Tmp.getElementType();
-  Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Addr, Ty);
+
   if (Tmp.isValid()) {
+Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+Addr, Tmp.getElementType());
 CGF.Builder.CreateStore(Addr, Tmp);
 return MostTopTmp;
   }
-  return Address::deprecated(Addr, BaseLVAlignment);
+
+  Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Addr, OriginalBaseAddress.getType());
+  return OriginalBaseAddress.withPointer(Addr);
 }
 
 static const VarDecl *getBaseDecl(const Expr *Ref, const DeclRefExpr *) {
@@ -1004,8 +1005,7 @@ Address 
ReductionCodeGen::adjustPrivateAddress(CodeGenFunction , unsigned N,
 SharedAddr.getElementType(), PrivatePointer, Adjustment);
 return castToBase(CGF, OrigVD->getType(),
   SharedAddresses[N].first.getType(),
-  OriginalBaseLValue.getAddress(CGF).getType(),
-  OriginalBaseLValue.getAlignment(), Ptr);
+  OriginalBaseLValue.getAddress(CGF), Ptr);
   }
   BaseDecls.emplace_back(
   cast(cast(ClausesData[N].Ref)->getDecl()));
@@ -4046,12 +4046,12 @@ emitTaskDupFunction(CodeGenModule , SourceLocation 
Loc,
 KmpTaskTWithPrivatesPtrQTy->castAs());
 LValue Base = CGF.EmitLValueForField(
 TDBase, *KmpTaskTWithPrivatesQTyRD->field_begin());
-KmpTaskSharedsPtr = Address::deprecated(
+KmpTaskSharedsPtr = Address(
 CGF.EmitLoadOfScalar(CGF.EmitLValueForField(
  Base, *std::next(KmpTaskTQTyRD->field_begin(),
   KmpTaskTShareds)),
  Loc),
-CGM.getNaturalTypeAlignment(SharedsTy));
+CGF.Int8Ty, CGM.getNaturalTypeAlignment(SharedsTy));
   }
   emitPrivatesInit(CGF, D, KmpTaskSharedsPtr, TDBase, 
KmpTaskTWithPrivatesQTyRD,
SharedsTy, SharedsPtrTy, Data, Privates, /*ForDup=*/true);
@@ -4531,13 +4531,13 @@ CGOpenMPRuntime::emitTaskInit(CodeGenFunction , 
SourceLocation Loc,
   // Copy shareds if there are any.
   Address KmpTaskSharedsPtr = Address::invalid();
   if (!SharedsTy->getAsStructureType()->getDecl()->field_empty()) {
-KmpTaskSharedsPtr = Address::deprecated(
+KmpTaskSharedsPtr = Address(
 CGF.EmitLoadOfScalar(
 CGF.EmitLValueForField(
 TDBase,
 *std::next(KmpTaskTQTyRD->field_begin(), KmpTaskTShareds)),
 Loc),
-CGM.getNaturalTypeAlignment(SharedsTy));
+CGF.Int8Ty, CGM.getNaturalTypeAlignment(SharedsTy));
 LValue Dest = CGF.MakeAddrLValue(KmpTaskSharedsPtr, SharedsTy);
 LValue Src = CGF.MakeAddrLValue(Shareds, SharedsTy);
 

[clang] 0254f59 - Forgot to add a release note for WG14 N2412.

2022-03-23 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-03-23T07:39:53-04:00
New Revision: 0254f59fef86f9b4f4489490795f3e31d3d324d3

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

LOG: Forgot to add a release note for WG14 N2412.

This support was completed in bf7d9970ba0ac5ecfa1a469086f5789de5c94e3f

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c30512c80e0b7..680bdbe4dbfa0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C2x Feature Support
 - Implemented `WG14 N2935 Make false and true first-class language features 
`_.
 - Implemented `WG14 N2763 Adding a fundamental type for N-bit integers 
`_.
 - Implemented `WG14 N2775 Literal suffixes for bit-precise integers 
`_.
+- Implemented the `*_WIDTH` macros to complete support for
+  `WG14 N2412 Two's complement sign representation for C2x 
`_.
 
 C++ Language Changes in Clang
 -



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


[PATCH] D122119: [C++20][Modules] Adjust handling of exports of namespaces and using-decls.

2022-03-23 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

In D122119#3401322 , @ChuanqiXu wrote:

> 



> I think the example is invalid since it violates [[ 
> http://eel.is/c++draft/module.interface#6 | [module.interface]p6 ]] 
> explicitly. If this is intended behavior or by design, we should change the 
> wording.

That wording failed to be updated when the linkage-decl changes went in.  I'll 
add a note to DR 2541. Linkage specifications, module purview, and module 
attachment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122119

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


[clang] b0bc93d - Revert "[clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable""."

2022-03-23 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2022-03-23T04:54:00-07:00
New Revision: b0bc93da926a943cdc2d8b04f8dcbe23a774520c

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

LOG: Revert "[clang] roll-forward "[clang] Mark `trivial_abi` types as 
"trivially relocatable""."

This reverts commit 56d46b36fc231a0beb518602503035bba92043e0.

The LIT test SemaCXX/attr-trivial-abi.cpp is failing with 32bit build on
Windows. All the lines with the ifdef WIN32 are asserting but they are
not expected to. It looks like the LIT test was not tested on a 32bit
build of the compiler.

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/TokenKinds.def
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp
clang/test/SemaCXX/type-traits.cpp
clang/test/SemaObjCXX/arc-type-traits.mm
clang/test/SemaObjCXX/objc-weak-type-traits.mm

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 685f834a8495a..05d8d53d44c1c 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1434,11 +1434,6 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__is_trivially_constructible`` (C++, GNU, Microsoft)
 * ``__is_trivially_copyable`` (C++, GNU, Microsoft)
 * ``__is_trivially_destructible`` (C++, MSVC 2013)
-* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
-  of the given type, and then destroying the source object, is known to be
-  functionally equivalent to copying the underlying bytes and then dropping the
-  source object on the floor. This is true of trivial types and types which
-  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 050391563f889..448dd2fdd8e49 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -830,8 +830,6 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;
 
-  /// Return true if this is a trivially relocatable type.
-  bool isTriviallyRelocatableType(const ASTContext ) const;
 
   /// Returns true if it is a class and it might be dynamic.
   bool mayBeDynamicClass() const;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index d7cd31174bc5b..ebf0725a0a392 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -,9 +,6 @@ If a type is trivial for the purposes of calls, has a 
non-trivial destructor,
 and is passed as an argument by value, the convention is that the callee will
 destroy the object before returning.
 
-If a type is trivial for the purpose of calls, it is assumed to be trivially
-relocatable for the purpose of ``__is_trivially_relocatable``.
-
 Attribute ``trivial_abi`` has no effect in the following cases:
 
 - The class directly declares a virtual base or virtual methods.

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 1d2082717bf97..1f07cad9459cd 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -510,7 +510,6 @@ TYPE_TRAIT_1(__has_unique_object_representations,
 KEYWORD(__underlying_type   , KEYCXX)
 
 // Clang-only C++ Type Traits
-TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 1803fe12d69c8..a7fdcdd99c2fd 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2506,25 +2506,6 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
) const {
   return false;
 }
 
-bool QualType::isTriviallyRelocatableType(const ASTContext ) const {
-  QualType BaseElementType = Context.getBaseElementType(*this);
-
-  if (BaseElementType->isIncompleteType()) {
-return false;
-  } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
-return RD->canPassInRegisters();
-  } else {
-switch (isNonTrivialToPrimitiveDestructiveMove()) {
-case PCK_Trivial:
-  return !isDestructedType();
-case PCK_ARCStrong:
-  return true;
-default:
-  return false;
-}
-  }
-}
-
 bool 

[clang] b26466d - Update the C and C++ status pages now that Clang 14 is out

2022-03-23 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-03-23T07:59:52-04:00
New Revision: b26466d0019582f9b3dc65587cf8043da144b45d

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

LOG: Update the C and C++ status pages now that Clang 14 is out

Added: 


Modified: 
clang/www/c_status.html
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index f81ac19cce702..3a00648000e3f 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -715,7 +715,7 @@ C2x implementation status
 
   Two's complement sign representation
   http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2412.pdf;>N2412
-  Clang 14
+  Clang 14
 
 
   Adding the u8 character prefix

diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index a7596230da754..79da75dee0d23 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1009,12 +1009,12 @@ C++20 implementation status
   
   
 https://wg21.link/p2085r0;>P2085R0
-Clang 14
+Clang 14
   
 
   Access checking on specializations
   https://wg21.link/p0692r1;>P0692R1
-  Clang 14
+  Clang 14
 
 
   Default constructible and assignable stateless lambdas
@@ -1124,7 +1124,7 @@ C++20 implementation status
 

 https://wg21.link/p1937r2;>P1937R2
-Clang 14
+Clang 14
   
 
   std::is_constant_evaluated
@@ -1247,7 +1247,7 @@ C++20 implementation status
 
   Permit conversions to arrays of unknown bound
   https://wg21.link/p0388r4;>P0388R4
-  Clang 14
+  Clang 14
 
 
   constinit
@@ -1310,7 +1310,7 @@ C++2b implementation status
 
   if consteval
   https://wg21.link/P1938R3;>P1938R3
-  Clang 14
+  Clang 14
 
 
   Allow duplicate attributes
@@ -1320,7 +1320,7 @@ C++2b implementation status
 
   Narrowing contextual conversions to bool
   https://wg21.link/P1401R5;>P1401R5
-  Clang 14
+  Clang 14
 
 
   Trimming whitespaces before line splicing
@@ -1335,7 +1335,7 @@ C++2b implementation status
 
   C++ identifier syntax using UAX 31
   https://wg21.link/P1949R7;>P1949R7
-  Clang 14
+  Clang 14
 
 
   Mixed string literal concatenation
@@ -1386,7 +1386,7 @@ C++2b implementation status
 
   Extend init-statement to allow alias-declaration
   https://wg21.link/P2360R0;>P2360R0
-  Clang 14
+  Clang 14
 
 
   auto(x): decay-copy in the language



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


[PATCH] D122301: [clang-format] Fix invalid code generation with comments in lambda

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

Great! LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122301

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


[PATCH] D122303: [pseudo] Sort nonterminals based on their reduction order.

2022-03-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: mgrang, mgorny.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

Reductions need to be performed in a careful order in GLR parser, to
make sure we gather all alternatives before creating an ambigous forest
node.

This patch encodes the nonterminal order into the rule id, so that we
can efficiently to determinal ordering of reductions in GLR parser.

This patch also abstracts to a TestGrammar, which is shared among tests.

This is a part of the GLR parser, https://reviews.llvm.org/D121368,
https://reviews.llvm.org/D121150


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122303

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/lib/GrammarBNF.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/unittests/CMakeLists.txt
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/TestGrammar.cpp
  clang-tools-extra/pseudo/unittests/TestGrammar.h

Index: clang-tools-extra/pseudo/unittests/TestGrammar.h
===
--- /dev/null
+++ clang-tools-extra/pseudo/unittests/TestGrammar.h
@@ -0,0 +1,34 @@
+//===-- TestGrammar.h *- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file provides shared grammar-related test facilities among tests.
+//
+//===--===//
+
+#include "clang-pseudo/Grammar.h"
+
+namespace clang {
+namespace pseudo {
+
+struct TestGrammar {
+  static TestGrammar build(llvm::StringRef BNF);
+
+  // Returns the symbol id for the given name.
+  SymbolID symbol(llvm::StringRef Name) const;
+
+  // Returns the rule id for the given nonterminal name.
+  // The nonterminal symbo is expected to have a single rule in the grammar.
+  RuleID singleRuleFor(llvm::StringRef NonterminalName) const;
+
+  std::unique_ptr G;
+  std::vector Diags;
+};
+
+} // namespace pseudo
+} // namespace clang
Index: clang-tools-extra/pseudo/unittests/TestGrammar.cpp
===
--- /dev/null
+++ clang-tools-extra/pseudo/unittests/TestGrammar.cpp
@@ -0,0 +1,43 @@
+//===-- TestGrammar.cpp -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestGrammar.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace pseudo {
+
+TestGrammar TestGrammar::build(llvm::StringRef BNF) {
+  TestGrammar T;
+  T.G = Grammar::parseBNF(BNF, T.Diags);
+  return T;
+}
+
+SymbolID TestGrammar::symbol(llvm::StringRef Name) const {
+  for (unsigned I = 0; I < NumTerminals; ++I)
+if (G->table().Terminals[I] == Name)
+  return tokenSymbol(static_cast(I));
+  for (SymbolID ID = 0; ID < G->table().Nonterminals.size(); ++ID)
+if (G->table().Nonterminals[ID].Name == Name)
+  return ID;
+  llvm::errs() << "No such symbol found: " << Name;
+  std::abort();
+}
+
+RuleID TestGrammar::singleRuleFor(llvm::StringRef NonterminalName) const {
+  auto RuleRange = G->table().Nonterminals[symbol(NonterminalName)].RuleRange;
+  if (RuleRange.End - RuleRange.Start == 1)
+return G->table().Nonterminals[symbol(NonterminalName)].RuleRange.Start;
+  llvm::errs() << "Expected a single rule for " << NonterminalName
+   << ", but it has " << RuleRange.End - RuleRange.Start
+   << " rule!\n";
+  std::abort();
+}
+
+} // namespace pseudo
+} // namespace clang
Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang-pseudo/Grammar.h"
+#include "TestGrammar.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
@@ -26,76 +27,78 @@
   return testing::Property(::seq, ElementsAre(IDs...));
 }
 
-class GrammarTest : public ::testing::Test {
-public:
-  void build(llvm::StringRef BNF) {
-Diags.clear();
-G = Grammar::parseBNF(BNF, Diags);
-  }
-
-  SymbolID 

[PATCH] D121593: [clangd][WIP] Provide clang-include-cleaner

2022-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

We'd like to proceed here by extracting the include-cleaner functionality from 
clangd into a library.
It would be used by:

- clangd
- a new clang-tidy check
- possibly a standalone tool, if clang-tidy doesn't fit well into the cleanup 
workflow
- some out-of-tree cleanup tools internal to google (nothing that would 
interest upstream, just integrating with our source control/code review etc)

The design would be a little different than what's currently in clangd as the 
scope is larger: it would support suggesting insertions as well as removals, 
and some limited policy knobs.

I'll post a proposal on discourse shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121593

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


[PATCH] D122083: [Concepts] Fix placeholder constraints when references are involved

2022-03-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Can you add some tests for the OTHER forms of 'auto' as well?  We have 
`decltype(auto)` and `auto_type`, and I want to make sure whatever we do with 
those 'looks right'.




Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:4773
+  QualType MaybeAuto = Type.getType().getNonReferenceType();
+  while (MaybeAuto->isPointerType()) {
+MaybeAuto = MaybeAuto->getPointeeType();

We don't do curley braces on single-line blocks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122083

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


[PATCH] D122285: [analyzer] Add path note tags to standard library function summaries.

2022-03-23 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

LGTM on my end, this is awesome!

In D122285#3401754 , @steakhal wrote:

>> The notes are prunable, i.e. they won't bring-in entire stack frames worth 
>> of notes just because they're there, but they will be always visible 
>> regardless of whether the value is of interest to the bug report. I think 
>> this is debatable, the arguably better solution is to make them non-prunable 
>> but conditional to the value being tracked back to the call, which would 
>> probably need a better tracking infrastructure.
>
> I was thinking of passing a lambda and doing the rest there. We could have 
> lambda factories to make it less cumbersome to define - and also reuse code.

Could you think of a scenario where a lambda would be required? It sure is more 
general, but I don't immediately see the gain.


Repository:
  rC Clang

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

https://reviews.llvm.org/D122285

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


[clang] edb7ba7 - Revert "[llvm][AArch64] Insert "bti j" after call to setjmp"

2022-03-23 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2022-03-23T10:43:20Z
New Revision: edb7ba714acba1d18a20d9f4986d2e38aee1d109

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

LOG: Revert "[llvm][AArch64] Insert "bti j" after call to setjmp"

This reverts commit eb5ecbbcbb6ce38e29237ab5d17156fcb2e96e74
due to failures on buildbots with expensive checks enabled.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp

Removed: 
llvm/test/CodeGen/AArch64/setjmp-bti-no-enforcement.ll
llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
llvm/test/CodeGen/AArch64/setjmp-bti.ll



diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 9d097ccae6aab..6815dca1f1529 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3329,7 +3329,7 @@ Work around VLLDM erratum CVE-2021-35465 (ARM only)
 
 .. option:: -mno-bti-at-return-twice
 
-Do not add a BTI instruction after a setjmp or other return-twice construct 
(AArch32/AArch64 only)
+Do not add a BTI instruction after a setjmp or other return-twice construct 
(Arm only)
 
 .. option:: -mno-movt
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 105d501073174..c30512c80e0b7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -193,11 +193,6 @@ DWARF Support in Clang
 Arm and AArch64 Support in Clang
 
 
-- When using ``-mbranch-protection=bti`` with AArch64, calls to setjmp will
-  now be followed by a BTI instruction. This is done to be compatible with
-  setjmp implementations that return with a br instead of a ret. You can
-  disable this behaviour using the ``-mno-bti-at-return-twice`` option.
-
 Floating Point Support in Clang
 ---
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 41b3ca5a4583e..c56578b34641a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3414,7 +3414,7 @@ def mmark_bti_property : Flag<["-"], 
"mmark-bti-property">,
 def mno_bti_at_return_twice : Flag<["-"], "mno-bti-at-return-twice">,
   Group,
   HelpText<"Do not add a BTI instruction after a setjmp or other"
-   " return-twice construct (Arm/AArch64 only)">;
+   " return-twice construct (Arm only)">;
 
 foreach i = {1-31} in
   def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group,

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 610c672feb677..f9557bac5fcdc 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -588,7 +588,4 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 // Enabled A53 errata (835769) workaround by default on android
 Features.push_back("+fix-cortex-a53-835769");
   }
-
-  if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
-Features.push_back("+no-bti-at-return-twice");
 }

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 82161b162ecdf..84d388d94e596 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -466,11 +466,6 @@ def FeatureEL3 : SubtargetFeature<"el3", "HasEL3", "true",
 def FeatureFixCortexA53_835769 : SubtargetFeature<"fix-cortex-a53-835769",
   "FixCortexA53_835769", "true", "Mitigate Cortex-A53 Erratum 835769">;
 
-def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
- "NoBTIAtReturnTwice", "true",
- "Don't place a BTI 
instruction "
- "after a return-twice">;
-
 
//===--===//
 // Architectures.
 //

diff  --git a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp 
b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
index 910f8cdede753..b0f739cc26e69 100644
--- a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
@@ -86,7 +86,6 @@ class AArch64ExpandPseudo : public MachineFunctionPass {
   unsigned N);
   

[clang] 47eb4f7 - [CGOpenMPRuntime] Specify correct type in EmitLoadOfPointerLValue()

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T11:51:14+01:00
New Revision: 47eb4f7dcd845878b16a53dadd765195b9c24b6e

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

LOG: [CGOpenMPRuntime] Specify correct type in EmitLoadOfPointerLValue()

Perform a bitcast first, so we can specify the correct pointer type
inf EmitLoadOfPointerLValue(), rather than using a dummy void pointer.

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/depobj_codegen.cpp
clang/test/OpenMP/task_codegen.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ee51420c65026..17bd9dbbedd34 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4651,17 +4651,15 @@ CGOpenMPRuntime::getDepobjElements(CodeGenFunction 
, LValue DepobjLVal,
   getDependTypes(C, KmpDependInfoTy, FlagsTy);
   RecordDecl *KmpDependInfoRD =
   cast(KmpDependInfoTy->getAsTagDecl());
-  LValue Base = CGF.EmitLoadOfPointerLValue(
-  DepobjLVal.getAddress(CGF),
-  C.getPointerType(C.VoidPtrTy).castAs());
   QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
-  Address Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-  Base.getAddress(CGF), CGF.ConvertTypeForMem(KmpDependInfoPtrTy),
-  CGF.ConvertTypeForMem(KmpDependInfoTy));
-  Base = CGF.MakeAddrLValue(Addr, KmpDependInfoTy, Base.getBaseInfo(),
-Base.getTBAAInfo());
+  LValue Base = CGF.EmitLoadOfPointerLValue(
+  CGF.Builder.CreateElementBitCast(
+  DepobjLVal.getAddress(CGF),
+  CGF.ConvertTypeForMem(KmpDependInfoPtrTy)),
+  KmpDependInfoPtrTy->castAs());
   Address DepObjAddr = CGF.Builder.CreateGEP(
-  Addr, llvm::ConstantInt::get(CGF.IntPtrTy, -1, /*isSigned=*/true));
+  Base.getAddress(CGF),
+  llvm::ConstantInt::get(CGF.IntPtrTy, -1, /*isSigned=*/true));
   LValue NumDepsBase = CGF.MakeAddrLValue(
   DepObjAddr, KmpDependInfoTy, Base.getBaseInfo(), Base.getTBAAInfo());
   // NumDeps = deps[i].base_addr;

diff  --git a/clang/test/OpenMP/depobj_codegen.cpp 
b/clang/test/OpenMP/depobj_codegen.cpp
index 202538c31952a..05a552529e3a6 100644
--- a/clang/test/OpenMP/depobj_codegen.cpp
+++ b/clang/test/OpenMP/depobj_codegen.cpp
@@ -68,8 +68,8 @@ int main(int argc, char **argv) {
 // CHECK: [[B_REF:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[B_BASE]], i{{.+}} -1
 // CHECK: [[B:%.+]] = bitcast %struct.kmp_depend_info* [[B_REF]] to i8*
 // CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[B]], i8* null)
-// CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]],
-// CHECK: [[B_BASE:%.+]] = bitcast i8* [[B]] to %struct.kmp_depend_info*
+// CHECK: [[B_ADDR_CAST:%.+]] = bitcast i8** [[B_ADDR]] to 
%struct.kmp_depend_info**
+// CHECK: [[B_BASE:%.+]] = load %struct.kmp_depend_info*, 
%struct.kmp_depend_info** [[B_ADDR_CAST]], align 8
 // CHECK: [[NUMDEPS_BASE:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[B_BASE]], i64 -1
 // CHECK: [[NUMDEPS_ADDR:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[NUMDEPS_BASE]], i{{.+}} 0, 
i{{.+}} 0
 // CHECK: [[NUMDEPS:%.+]] = load i64, i64* [[NUMDEPS_ADDR]],
@@ -226,8 +226,8 @@ int main(int argc, char **argv) {
 // CHECK: [[ARGC_REF:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[ARGC_BASE]], i{{.+}} -1
 // CHECK: [[ARGC:%.+]] = bitcast %struct.kmp_depend_info* [[ARGC_REF]] to i8*
 // CHECK: call void @__kmpc_free(i32 [[GTID]], i8* [[ARGC]], i8* null)
-// CHECK: [[ARGC:%.+]] = load i8*, i8** [[ARGC_ADDR]],
-// CHECK: [[ARGC_BASE:%.+]] = bitcast i8* [[ARGC]] to %struct.kmp_depend_info*
+// CHECK: [[ARGC_ADDR_CAST:%.+]] = bitcast i8** [[ARGC_ADDR]] to 
%struct.kmp_depend_info**
+// CHECK: [[ARGC_BASE:%.+]] = load %struct.kmp_depend_info*, 
%struct.kmp_depend_info** [[ARGC_ADDR_CAST]], align 8
 // CHECK: [[NUMDEPS_BASE:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[ARGC_BASE]], i64 -1
 // CHECK: [[NUMDEPS_ADDR:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[NUMDEPS_BASE]], i{{.+}} 0, 
i{{.+}} 0
 // CHECK: [[NUMDEPS:%.+]] = load i64, i64* [[NUMDEPS_ADDR]],

diff  --git a/clang/test/OpenMP/task_codegen.c 
b/clang/test/OpenMP/task_codegen.c
index ae606c202c651..d6954cf9dac91 100644
--- a/clang/test/OpenMP/task_codegen.c
+++ b/clang/test/OpenMP/task_codegen.c
@@ -34,8 +34,8 @@ int main(void) {
   // CHECK: [[CAST_EVT_VAL:%.+]] = ptrtoint i8* [[EVT_VAL]] to i64
   // CHECK: store i64 [[CAST_EVT_VAL]], i64* [[EVT_ADDR]], align 8
   // CHECK: [[DATA:%.+]] = bitcast i8* [[ALLOC]] to [[PRIVATES_TY]]*
-  // CHECK: [[D:%.+]] = load i8*, i8** [[D_ADDR]], align 8
-  // 

[clang] aaf2bcc - [CodeGen][OpenMP] Add alignment to test (NFC)

2022-03-23 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2022-03-23T12:01:00+01:00
New Revision: aaf2bccf1fa2f5c96de7354298bede139f8cb7e5

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

LOG: [CodeGen][OpenMP] Add alignment to test (NFC)

Check which alignments are generated for loads/stores.

Added: 


Modified: 
clang/test/OpenMP/depobj_codegen.cpp

Removed: 




diff  --git a/clang/test/OpenMP/depobj_codegen.cpp 
b/clang/test/OpenMP/depobj_codegen.cpp
index 05a552529e3a6..ed0f14493454d 100644
--- a/clang/test/OpenMP/depobj_codegen.cpp
+++ b/clang/test/OpenMP/depobj_codegen.cpp
@@ -45,25 +45,25 @@ int main(int argc, char **argv) {
 // CHECK: [[DEP_ADDR_VOID:%.+]] = call i8* @__kmpc_alloc(i32 [[GTID]], i64 72, 
i8* null)
 // CHECK: [[DEP_ADDR:%.+]] = bitcast i8* [[DEP_ADDR_VOID]] to 
%struct.kmp_depend_info*
 // CHECK: [[SZ_BASE:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[DEP_ADDR]], i{{.+}} 0, i{{.+}} 0
-// CHECK: store i64 2, i64* [[SZ_BASE]],
+// CHECK: store i64 2, i64* [[SZ_BASE]], align 8
 // CHECK: [[BASE_ADDR:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[DEP_ADDR]], i{{.+}} 1
 // CHECK: [[ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0
-// CHECK: store i64 %{{.+}}, i64* [[ADDR]],
+// CHECK: store i64 %{{.+}}, i64* [[ADDR]], align 8
 // CHECK: [[SZ_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 1
-// CHECK: store i64 4, i64* [[SZ_ADDR]],
+// CHECK: store i64 4, i64* [[SZ_ADDR]], align 8
 // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 2
-// CHECK: store i8 3, i8* [[FLAGS_ADDR]],
+// CHECK: store i8 3, i8* [[FLAGS_ADDR]], align 8
 // CHECK: [[BASE_ADDR:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[DEP_ADDR]], i{{.+}} 2
 // CHECK: [[ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 0
-// CHECK: store i64 %{{.+}}, i64* [[ADDR]],
+// CHECK: store i64 %{{.+}}, i64* [[ADDR]], align 8
 // CHECK: [[SZ_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 1
-// CHECK: store i64 8, i64* [[SZ_ADDR]],
+// CHECK: store i64 8, i64* [[SZ_ADDR]], align 8
 // CHECK: [[FLAGS_ADDR:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[BASE_ADDR]], i{{.+}} 0, i{{.+}} 2
-// CHECK: store i8 3, i8* [[FLAGS_ADDR]],
+// CHECK: store i8 3, i8* [[FLAGS_ADDR]], align 8
 // CHECK: [[BASE_ADDR:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[DEP_ADDR]], i{{.+}} 1
 // CHECK: [[DEP:%.+]] = bitcast %struct.kmp_depend_info* [[BASE_ADDR]] to i8*
-// CHECK: store i8* [[DEP]], i8** [[MAIN_A]],
-// CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]],
+// CHECK: store i8* [[DEP]], i8** [[MAIN_A]], align 8
+// CHECK: [[B:%.+]] = load i8*, i8** [[B_ADDR]], align 8
 // CHECK: [[B_BASE:%.+]] = bitcast i8* [[B]] to %struct.kmp_depend_info*
 // CHECK: [[B_REF:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[B_BASE]], i{{.+}} -1
 // CHECK: [[B:%.+]] = bitcast %struct.kmp_depend_info* [[B_REF]] to i8*
@@ -72,13 +72,13 @@ int main(int argc, char **argv) {
 // CHECK: [[B_BASE:%.+]] = load %struct.kmp_depend_info*, 
%struct.kmp_depend_info** [[B_ADDR_CAST]], align 8
 // CHECK: [[NUMDEPS_BASE:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[B_BASE]], i64 -1
 // CHECK: [[NUMDEPS_ADDR:%.+]] = getelementptr inbounds 
%struct.kmp_depend_info, %struct.kmp_depend_info* [[NUMDEPS_BASE]], i{{.+}} 0, 
i{{.+}} 0
-// CHECK: [[NUMDEPS:%.+]] = load i64, i64* [[NUMDEPS_ADDR]],
+// CHECK: [[NUMDEPS:%.+]] = load i64, i64* [[NUMDEPS_ADDR]], align 8
 // CHECK: [[END:%.+]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[B_BASE]], i64 [[NUMDEPS]]
 // CHECK: br label %[[BODY:.+]]
 // CHECK: [[BODY]]:
 // CHECK: [[EL:%.+]] = phi %struct.kmp_depend_info* [ [[B_BASE]], %{{.+}} ], [ 
[[EL_NEXT:%.+]], %[[BODY]] ]
 // CHECK: [[FLAG_BASE:%.+]] = getelementptr inbounds %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[EL]], i{{.+}} 0, i{{.+}} 2
-// CHECK: store i8 4, i8* [[FLAG_BASE]],
+// CHECK: store i8 4, i8* [[FLAG_BASE]], align 8
 // CHECK: [[EL_NEXT]] = getelementptr %struct.kmp_depend_info, 
%struct.kmp_depend_info* [[EL]], i{{.+}} 1
 // CHECK: [[IS_DONE:%.+]] = icmp eq %struct.kmp_depend_info* [[EL_NEXT]], 
[[END]]
 // CHECK: br i1 [[IS_DONE]], label %[[DONE:.+]], label %[[BODY]]
@@ -86,14 +86,14 @@ int main(int argc, char **argv) {
 
 // Claculate toal number of elements.
 // 

[clang] c3b9819 - Reland "[llvm][AArch64] Insert "bti j" after call to setjmp"

2022-03-23 Thread David Spickett via cfe-commits

Author: David Spickett
Date: 2022-03-23T11:43:43Z
New Revision: c3b98194df5572bc9b33024b48457538a7213b4c

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

LOG: Reland "[llvm][AArch64] Insert "bti j" after call to setjmp"

This reverts commit edb7ba714acba1d18a20d9f4986d2e38aee1d109.

This changes BLR_BTI to take variable_ops meaning that we can accept
a register or a label. The pattern still expects one argument so we'll
never get more than one. Then later we can check the type of the operand
to choose BL or BLR to emit.

(this is what BLR_RVMARKER does but I missed this detail of it first time 
around)

Also require NoSLSBLRMitigation which I missed in the first version.

Added: 
llvm/test/CodeGen/AArch64/setjmp-bti-no-enforcement.ll
llvm/test/CodeGen/AArch64/setjmp-bti-outliner.ll
llvm/test/CodeGen/AArch64/setjmp-bti.ll

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
llvm/lib/Target/AArch64/AArch64FastISel.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.h
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 6815dca1f1529..9d097ccae6aab 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -3329,7 +3329,7 @@ Work around VLLDM erratum CVE-2021-35465 (ARM only)
 
 .. option:: -mno-bti-at-return-twice
 
-Do not add a BTI instruction after a setjmp or other return-twice construct 
(Arm only)
+Do not add a BTI instruction after a setjmp or other return-twice construct 
(AArch32/AArch64 only)
 
 .. option:: -mno-movt
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 680bdbe4dbfa0..403bc08eec9be 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -195,6 +195,11 @@ DWARF Support in Clang
 Arm and AArch64 Support in Clang
 
 
+- When using ``-mbranch-protection=bti`` with AArch64, calls to setjmp will
+  now be followed by a BTI instruction. This is done to be compatible with
+  setjmp implementations that return with a br instead of a ret. You can
+  disable this behaviour using the ``-mno-bti-at-return-twice`` option.
+
 Floating Point Support in Clang
 ---
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c56578b34641a..41b3ca5a4583e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3414,7 +3414,7 @@ def mmark_bti_property : Flag<["-"], 
"mmark-bti-property">,
 def mno_bti_at_return_twice : Flag<["-"], "mno-bti-at-return-twice">,
   Group,
   HelpText<"Do not add a BTI instruction after a setjmp or other"
-   " return-twice construct (Arm only)">;
+   " return-twice construct (Arm/AArch64 only)">;
 
 foreach i = {1-31} in
   def ffixed_x#i : Flag<["-"], "ffixed-x"#i>, Group,

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index f9557bac5fcdc..610c672feb677 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -588,4 +588,7 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 // Enabled A53 errata (835769) workaround by default on android
 Features.push_back("+fix-cortex-a53-835769");
   }
+
+  if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))
+Features.push_back("+no-bti-at-return-twice");
 }

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 84d388d94e596..82161b162ecdf 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -466,6 +466,11 @@ def FeatureEL3 : SubtargetFeature<"el3", "HasEL3", "true",
 def FeatureFixCortexA53_835769 : SubtargetFeature<"fix-cortex-a53-835769",
   "FixCortexA53_835769", "true", "Mitigate Cortex-A53 Erratum 835769">;
 
+def FeatureNoBTIAtReturnTwice : SubtargetFeature<"no-bti-at-return-twice",
+ "NoBTIAtReturnTwice", "true",
+ "Don't place a BTI 
instruction "
+ "after a return-twice">;
+
 
//===--===//
 // Architectures.
 //

diff  --git 

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm seeing precommit CI failures:

Failed Tests (1):

  Clang :: SemaCXX/constant-expression-cxx2b.cpp




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (!VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),

cor3ntin wrote:
> hubert.reinterpretcast wrote:
> > This seems to trigger even when the type is dependent:
> > ```
> > :1:36: warning: definition of a variable of non-literal type in a 
> > constexpr function is incompatible with C++ standards before C++2b 
> > [-Wpre-c++2b-compat]
> > auto qq = [](auto x) { decltype(x) n; };
> >^
> > 1 warning generated.
> > ```
> > 
> > This also seems to emit even when `Kind` is not 
> > `Sema::CheckConstexprKind::Diagnose` (unlike the `static`/`thread_local` 
> > case above). Is the `CheckLiteralType` logic not reusable for this?
> You are right, thanks for noticing that, it was rather bogus.
> The reason I'm not using CheckLiteralType is to avoid duplicating a 
> diagnostics message, as CheckLiteralType doesn't allow us to pass parameter 
> to the diagnostic message.
> 
> It leaves us with an uncovered scenario though: We do not emit the warning on 
> template instantiation, and I don't think there is an  easy way to do that.
> The reason I'm not using CheckLiteralType is to avoid duplicating a 
> diagnostics message, as CheckLiteralType doesn't allow us to pass parameter 
> to the diagnostic message.

Huh?

```
static bool CheckLiteralType(Sema , Sema::CheckConstexprKind Kind,
 SourceLocation Loc, QualType T, unsigned DiagID,
 Ts &&...DiagArgs) {
  ...
}
```
I would hope `DiagArgs` should do exactly that? :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[clang] a45ad3c - [clang-format] [doc] Add script to automatically update help output in ClangFormat.rst.

2022-03-23 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-03-23T13:17:50+01:00
New Revision: a45ad3ca8ce78988a4d51b432455ce0bbf13

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

LOG: [clang-format] [doc] Add script to automatically update help output in 
ClangFormat.rst.

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

Reviewed By: MyDeveloperDay

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

Added: 
clang/docs/tools/dump_format_help.py

Modified: 
clang/docs/ClangFormat.rst
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 5fc9656a4756a..745c66efa9e0e 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -13,6 +13,8 @@ Standalone Tool
 :program:`clang-format` is located in `clang/tools/clang-format` and can be 
used
 to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
 
+.. START_FORMAT_HELP
+
 .. code-block:: console
 
   $ clang-format -help
@@ -51,7 +53,9 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# 
code.
  -style=file, but can not find the 
.clang-format
  file to use.
  Use -fallback-style=none to skip 
formatting.
---ferror-limit=  - Set the maximum number of clang-format 
errors to emit before stopping (0 = no limit). Used only with --dry-run or -n
+--ferror-limit=  - Set the maximum number of clang-format 
errors to emit
+ before stopping (0 = no limit).
+ Used only with --dry-run or -n
 --files=   - Provide a list of files to run 
clang-format
 -i - Inplace edit s, if specified.
 --length=- Format a range of this length (in bytes).
@@ -73,8 +77,10 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# 
code.
  several -offset and -length pairs.
  Can only be used with one input file.
 --output-replacements-xml  - Output replacements as XML.
---qualifier-alignment= - If set, overrides the qualifier alignment 
style determined by the QualifierAlignment style flag
---sort-includes- If set, overrides the include sorting 
behavior determined by the SortIncludes style flag
+--qualifier-alignment= - If set, overrides the qualifier alignment 
style
+ determined by the QualifierAlignment 
style flag
+--sort-includes- If set, overrides the include sorting 
behavior
+ determined by the SortIncludes style flag
 --style=   - Coding style, currently supports:
LLVM, GNU, Google, Chromium, Microsoft, 
Mozilla, WebKit.
  Use -style=file to load style 
configuration from
@@ -95,6 +101,8 @@ to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# 
code.
 --version  - Display the version of this program
 
 
+.. END_FORMAT_HELP
+
 When the desired code formatting style is 
diff erent from the available options,
 the style can be customized using the ``-style="{key: value, ...}"`` option or
 by putting your style configuration in the ``.clang-format`` or 
``_clang-format``

diff  --git a/clang/docs/tools/dump_format_help.py 
b/clang/docs/tools/dump_format_help.py
new file mode 100644
index 0..68869d91056ce
--- /dev/null
+++ b/clang/docs/tools/dump_format_help.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# A tool to parse the output of `clang-format --help` and update the
+# documentation in ../ClangFormat.rst automatically.
+
+import os
+import re
+import subprocess
+import sys
+
+CLANG_DIR = os.path.join(os.path.dirname(__file__), '../..')
+DOC_FILE = os.path.join(CLANG_DIR, 'docs/ClangFormat.rst')
+
+
+def substitute(text, tag, contents):
+replacement = '\n.. START_%s\n\n%s\n\n.. END_%s\n' % (tag, contents, tag)
+pattern = r'\n\.\. START_%s\n.*\n\.\. END_%s\n' % (tag, tag)
+return re.sub(pattern, '%s', text, flags=re.S) % replacement
+
+
+def indent(text, columns, indent_first_line=True):
+indent_str = ' ' * columns
+s = re.sub(r'\n([^\n])', '\n' + indent_str + '\\1', text, flags=re.S)
+if not indent_first_line or s.startswith('\n'):
+return s
+return indent_str + s
+
+
+def get_help_output():
+args = ["clang-format", "--help"]
+cmd = subprocess.Popen(args, stdout=subprocess.PIPE,
+   stderr=subprocess.STDOUT)
+out, _ = cmd.communicate()
+out = 

[PATCH] D122175: [clang][extract-api] Enable processing of multiple headers

2022-03-23 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 417593.
dang added a comment.

Rebase on top of latest changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122175

Files:
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/test/ExtractAPI/global_record_multifile.c

Index: clang/test/ExtractAPI/global_record_multifile.c
===
--- /dev/null
+++ clang/test/ExtractAPI/global_record_multifile.c
@@ -0,0 +1,371 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=GlobalRecord -target arm64-apple-macosx \
+// RUN: %t/input1.h %t/input2.h %t/input3.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input1.h
+int num;
+
+//--- input2.h
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+//--- input3.h
+char unavailable __attribute__((unavailable));
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "GlobalRecord",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Global Variable",
+"identifier": "c.var"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input1.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "y"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " *"
+},
+{
+  "kind": "internalParam",
+  "spelling": "res"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "docComment": {
+"lines": [
+  {
+"range": {
+  "end": {
+"character": 4,
+"line": 1
+  },
+  "start": {
+"character": 4,
+  

[clang] 59dadd1 - [clang][lex] Fix failures with Microsoft header search rules

2022-03-23 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2022-03-23T14:49:17+01:00
New Revision: 59dadd178b0b12cb4a975a262ed20e7c3822aedc

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

LOG: [clang][lex] Fix failures with Microsoft header search rules

`HeaderSearch` currently assumes `LookupFileCache` is eventually populated in 
`LookupFile`. However, that's not always the case with `-fms-compatibility` and 
its early returns.

This patch adds a defensive check that the iterator pulled out of the cache is 
actually valid before using it.

(This bug was introduced in D119721. Before that, the cache was initialized to 
`0` - essentially the `search_dir_begin()` iterator.)

Reviewed By: dexonsmith, erichkeane

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

Added: 
clang/test/Preprocessor/microsoft-header-search-fail.c

Modified: 
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 087bd1df860ad..082e62da124f1 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -976,7 +976,8 @@ Optional HeaderSearch::LookupFile(
   // this is a matching hit.
   if (!SkipCache && CacheLookup.StartIt == NextIt) {
 // Skip querying potentially lots of directories for this lookup.
-It = CacheLookup.HitIt;
+if (CacheLookup.HitIt)
+  It = CacheLookup.HitIt;
 if (CacheLookup.MappedName) {
   Filename = CacheLookup.MappedName;
   if (IsMapped)

diff  --git a/clang/test/Preprocessor/microsoft-header-search-fail.c 
b/clang/test/Preprocessor/microsoft-header-search-fail.c
new file mode 100644
index 0..1468fc5445b60
--- /dev/null
+++ b/clang/test/Preprocessor/microsoft-header-search-fail.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly -fms-compatibility %t/test.c -I %t/include -verify
+
+//--- test.c
+#include "x/header.h"
+#include "z/header.h"
+
+// expected-warning-re@include/y/header.h:1 {{#include resolved using 
non-portable Microsoft search rules as: {{.*}}x/culprit.h}}
+// expected-error@include/z/header.h:1 {{'culprit.h' file not found}}
+
+//--- include/x/header.h
+#include "y/header.h"
+
+//--- include/y/header.h
+#include "culprit.h"
+
+//--- include/x/culprit.h
+
+//--- include/z/header.h
+#include "culprit.h"



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


[PATCH] D121868: [cc1as] Add support for emitting the build version load command for -darwin-target-variant

2022-03-23 Thread Byoungchan Lee via Phabricator via cfe-commits
bc-lee updated this revision to Diff 417595.
bc-lee added a comment.

Addressing review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121868

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Misc/cc1as-darwin-target-variant-triple.s
  clang/tools/driver/cc1as_main.cpp

Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -144,6 +144,9 @@
   /// otherwise.
   std::string TargetABI;
 
+  /// Darwin target variant triple, the variant of the deployment target
+  /// for which the code is being compiled.
+  llvm::Optional DarwinTargetVariantTriple;
   /// @}
 
 public:
@@ -209,6 +212,9 @@
 
   // Target Options
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+  if (Arg *A = Args.getLastArg(options::OPT_darwin_target_variant_triple))
+Opts.DarwinTargetVariantTriple = llvm::Triple(A->getValue());
+
   Opts.CPU = std::string(Args.getLastArgValue(OPT_target_cpu));
   Opts.Features = Args.getAllArgValues(OPT_target_feature);
 
@@ -407,6 +413,8 @@
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
   std::unique_ptr MOFI(
   TheTarget->createMCObjectFileInfo(Ctx, PIC));
+  if (Opts.DarwinTargetVariantTriple)
+MOFI->setDarwinTargetVariantTriple(*Opts.DarwinTargetVariantTriple);
   Ctx.setObjectFileInfo(MOFI.get());
 
   if (Opts.SaveTemporaryLabels)
Index: clang/test/Misc/cc1as-darwin-target-variant-triple.s
===
--- /dev/null
+++ clang/test/Misc/cc1as-darwin-target-variant-triple.s
@@ -0,0 +1,33 @@
+// Run cc1as using darwin-target-variant-triple
+// RUN: %clang -cc1as -triple x86_64-apple-macos10.9 -darwin-target-variant-triple x86_64-apple-ios13.1-macabi -filetype obj %s -o - \
+// RUN: | llvm-readobj --file-headers --macho-version-min - \
+// RUN: | FileCheck --check-prefix=CHECK %s
+
+// CHECK: File: 
+// CHECK: Format: Mach-O 64-bit x86-64
+// CHECK: Arch: x86_64
+// CHECK: AddressSize: 64bit
+// CHECK: MachHeader {
+// CHECK:   Magic: Magic64 (0xFEEDFACF)
+// CHECK:   CpuType: X86-64 (0x107)
+// CHECK:   CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)
+// CHECK:   FileType: Relocatable (0x1)
+// CHECK:   NumOfLoadCommands: 3
+// CHECK:   SizeOfLoadCommands: 192
+// CHECK:   Flags [ (0x0)
+// CHECK:   ]
+// CHECK:   Reserved: 0x0
+// CHECK: }
+// CHECK: MinVersion {
+// CHECK:   Cmd: LC_VERSION_MIN_MACOSX
+// CHECK:   Size: 16
+// CHECK:   Version: 10.9
+// CHECK:   SDK: n/a
+// CHECK: }
+// CHECK: MinVersion {
+// CHECK:   Cmd: LC_BUILD_VERSION
+// CHECK:   Size: 24
+// CHECK:   Platform: macCatalyst
+// CHECK:   Version: 13.1
+// CHECK:   SDK: n/a
+// CHECK: }
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -489,6 +489,12 @@
 : TargetVersion) < VersionTuple(V0, V1, V2);
   }
 
+  /// Returns the darwin target variant triple, the variant of the deployment
+  /// target for which the code is being compiled.
+  Optional getTargetVariantTriple() const override {
+return TargetVariantTriple;
+  }
+
 protected:
   /// Return true if c++17 aligned allocation/deallocation functions are not
   /// implemented in the c++ standard library of the deployment target we are
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7754,6 +7754,8 @@
 
   const llvm::Triple  = getToolChain().getEffectiveTriple();
   const std::string  = Triple.getTriple();
+  const Optional TargetVariantTriple =
+  getToolChain().getTargetVariantTriple();
   const auto  = getToolChain().getDriver();
 
   // Don't warn about "clang -w -c foo.s"
@@ -7771,6 +7773,10 @@
   // Add the "effective" target triple.
   CmdArgs.push_back("-triple");
   CmdArgs.push_back(Args.MakeArgString(TripleStr));
+  if (TargetVariantTriple) {
+CmdArgs.push_back("-darwin-target-variant-triple");
+CmdArgs.push_back(Args.MakeArgString(TargetVariantTriple->getTriple()));
+  }
 
   // Set the output mode, we currently only expect to be used as a real
   // assembler.
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -717,6 +717,10 @@
 return llvm::DenormalMode::getIEEE();
   }
 
+  virtual Optional getTargetVariantTriple() const {
+return llvm::Optional();
+  }
+
   // We want to expand the shortened versions 

[PATCH] D122237: [clang][lex] Fix failures with Microsoft header search rules

2022-03-23 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG59dadd178b0b: [clang][lex] Fix failures with Microsoft 
header search rules (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122237

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Preprocessor/microsoft-header-search-fail.c


Index: clang/test/Preprocessor/microsoft-header-search-fail.c
===
--- /dev/null
+++ clang/test/Preprocessor/microsoft-header-search-fail.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly -fms-compatibility %t/test.c -I %t/include -verify
+
+//--- test.c
+#include "x/header.h"
+#include "z/header.h"
+
+// expected-warning-re@include/y/header.h:1 {{#include resolved using 
non-portable Microsoft search rules as: {{.*}}x/culprit.h}}
+// expected-error@include/z/header.h:1 {{'culprit.h' file not found}}
+
+//--- include/x/header.h
+#include "y/header.h"
+
+//--- include/y/header.h
+#include "culprit.h"
+
+//--- include/x/culprit.h
+
+//--- include/z/header.h
+#include "culprit.h"
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -976,7 +976,8 @@
   // this is a matching hit.
   if (!SkipCache && CacheLookup.StartIt == NextIt) {
 // Skip querying potentially lots of directories for this lookup.
-It = CacheLookup.HitIt;
+if (CacheLookup.HitIt)
+  It = CacheLookup.HitIt;
 if (CacheLookup.MappedName) {
   Filename = CacheLookup.MappedName;
   if (IsMapped)


Index: clang/test/Preprocessor/microsoft-header-search-fail.c
===
--- /dev/null
+++ clang/test/Preprocessor/microsoft-header-search-fail.c
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -Eonly -fms-compatibility %t/test.c -I %t/include -verify
+
+//--- test.c
+#include "x/header.h"
+#include "z/header.h"
+
+// expected-warning-re@include/y/header.h:1 {{#include resolved using non-portable Microsoft search rules as: {{.*}}x/culprit.h}}
+// expected-error@include/z/header.h:1 {{'culprit.h' file not found}}
+
+//--- include/x/header.h
+#include "y/header.h"
+
+//--- include/y/header.h
+#include "culprit.h"
+
+//--- include/x/culprit.h
+
+//--- include/z/header.h
+#include "culprit.h"
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -976,7 +976,8 @@
   // this is a matching hit.
   if (!SkipCache && CacheLookup.StartIt == NextIt) {
 // Skip querying potentially lots of directories for this lookup.
-It = CacheLookup.HitIt;
+if (CacheLookup.HitIt)
+  It = CacheLookup.HitIt;
 if (CacheLookup.MappedName) {
   Filename = CacheLookup.MappedName;
   if (IsMapped)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122175: [clang][extract-api] Enable processing of multiple headers

2022-03-23 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 417596.
dang added a comment.

Clarify doc comment for ExtractAPIAction::PrepareToExecuteAction


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122175

Files:
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/test/ExtractAPI/global_record_multifile.c

Index: clang/test/ExtractAPI/global_record_multifile.c
===
--- /dev/null
+++ clang/test/ExtractAPI/global_record_multifile.c
@@ -0,0 +1,371 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=GlobalRecord -target arm64-apple-macosx \
+// RUN: %t/input1.h %t/input2.h %t/input3.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input1.h
+int num;
+
+//--- input2.h
+/**
+ * \brief Add two numbers.
+ * \param [in]  x   A number.
+ * \param [in]  y   Another number.
+ * \param [out] res The result of x + y.
+ */
+void add(const int x, const int y, int *res);
+
+//--- input3.h
+char unavailable __attribute__((unavailable));
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "GlobalRecord",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "num"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@num"
+  },
+  "kind": {
+"displayName": "Global Variable",
+"identifier": "c.var"
+  },
+  "location": {
+"character": 5,
+"line": 1,
+"uri": "file://INPUT_DIR/input1.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "num"
+  }
+],
+"title": "num"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "add"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "keyword",
+  "spelling": "const"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "internalParam",
+  "spelling": "y"
+},
+{
+  "kind": "text",
+  "spelling": ", "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:I",
+  "spelling": "int"
+},
+{
+  "kind": "text",
+  "spelling": " *"
+},
+{
+  "kind": "internalParam",
+  "spelling": "res"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "docComment": {
+"lines": [
+  {
+"range": {
+  "end": {
+"character": 4,
+"line": 1
+  },
+  "start": {
+   

[PATCH] D122083: [Concepts] Fix placeholder constraints when references are involved

2022-03-23 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

In D122083#3402440 , @royjacobson 
wrote:

> In D122083#3402289 , @erichkeane 
> wrote:
>
>> Can you add some tests for the OTHER forms of 'auto' as well?  We have 
>> `decltype(auto)` and `auto_type`, and I want to make sure whatever we do 
>> with those 'looks right'.
>
> Can we have constraints on `__auto_type`? As far as I understand it, it's a C 
> extension with very limited C++ support.

I tried a couple and cannot convince GCC to let me deduce it.

> About decltype(auto) - we can't have `*`/`&` modifiers with it, and that's 
> already covered by tests like p7-cxx14.

Ah, right, thanks!

> So (I think?) it's always invalid code and it fails earlier during parsing.

Yep, thanks for that.

1 more test I'd like to see that doesn't seem covered (ref to ptr), AND 
according to @aaron.ballman we need "Release Notes" for this.  Otherwise LGTM.  
Do you have commit rights yet?




Comment at: clang/test/SemaTemplate/concepts.cpp:207
   }
-  C auto *f2() {
-return (int*)nullptr; // FIXME: should error
+  C auto *f2() { // expected-error {{deduced type 'int' does not satisfy 'C'}}
+return (int*)nullptr;

would also like `C auto*&`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122083

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


[PATCH] D121122: Set FLT_EVAL_METHOD to -1 when fast-math is enabled.

2022-03-23 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D121122#3402442 , @aaron.ballman 
wrote:

> In D121122#3402334 , @bjope wrote:
>
>> Hello. We've got some problem in our downstream tests after this patch and 
>> I'm trying to figure out how things are supposed to work. Maybe someone 
>> being part of this review knows.
>
> Sorry for the troubles!
>
>> Problem is that we have some libc verification suites that include test 
>> cases using `float_t`. But in math.h from for example newlib the type 
>> float_t isn't defined if FLT_EVAL_METHOD is set to -1.
>> The standard says that float_t is implementation defined when 
>> FLT_EVAL_METHOD isn't 0/1/2. But I'm not quite sure how that is supposed to 
>> be handled (such as where to define float_t if not in math.h).
>
> The way I read the requirements in C2x 7.12p3 are that the types `float_t` 
> and `double_t` are always defined in ``, but in the event 
> `FLT_EVAL_METHOD` isn't 0, 1, or 2, the implementation has to pick whatever 
> type makes the most sense for the underlying types.
>
>> One question is: If I have a piece of C99 code using float_t, is that code 
>> not allowed to be compiled using fast-math?
>
> The standard doesn't admit that fast math is a thing; it's up to the 
> implementations to define what their fast math extension does.
>
>> I guess it should be seen as with fast-math the float_t precision is 
>> unknown. But the type still has to be defined somewhere or else the frontend 
>> will complain about "unknown type name". But I'm not sure where this is 
>> supposed to be handled.
>
> I think it should still be handled in ``. *I am not a C floating 
> point expert, so take this suggestion with a grain of salt*: I think it is 
> defensible to fallback to defining `float_t` as `float` and `double_t` as 
> `double` when the eval method is indeterminable. @andrew.w.kaylor may have 
> more nuanced thoughts here.

Thanks for the answer @aaron.ballman.
Looking at this https://godbolt.org/z/drhGEjvns i see that float_t  is defined 
in math.h (if I remove the include it will fail).  Not sure what version of 
libs godbolt is using, but I tend to agree that it should be defined in math.h 
too. But Andy will have a more definite answer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121122

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


[PATCH] D122265: [Clang][NFC] Cleanup dcl.constexpr/p3 tests

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

LGTM, thanks for the cleanup!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122265

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


[libunwind] a749e32 - Replace links to archived mailing lists by links to Discourse forums

2022-03-23 Thread Aaron Ballman via cfe-commits

Author: Danny Mösch
Date: 2022-03-23T10:10:20-04:00
New Revision: a749e3295df4aee18a0ad723875a6501f30ac744

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

LOG: Replace links to archived mailing lists by links to Discourse forums

Added: 


Modified: 
clang-tools-extra/README.txt
clang/README.txt
clang/www/analyzer/menu.html.incl
clang/www/demo/index.cgi
clang/www/menu.html.incl
compiler-rt/www/menu.html.incl
flang/docs/GettingInvolved.md
libcxx/docs/index.rst
libunwind/docs/index.rst
lldb/docs/index.rst
llvm/docs/Contributing.rst
llvm/docs/ExtendingLLVM.rst
llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst

Removed: 




diff  --git a/clang-tools-extra/README.txt b/clang-tools-extra/README.txt
index 9809cc38ccf4f..9c859a052c4b4 100644
--- a/clang-tools-extra/README.txt
+++ b/clang-tools-extra/README.txt
@@ -11,8 +11,8 @@ This repository is only intended to be checked out inside of 
a full LLVM+Clang
 tree, and in the 'tools/extra' subdirectory of the Clang checkout.
 
 All discussion regarding Clang, Clang-based tools, and code in this repository
-should be held using the standard Clang mailing lists:
-  http://lists.llvm.org/mailman/listinfo/cfe-dev
+should be held using the standard Clang forum:
+  https://discourse.llvm.org/c/clang
 
 Code review for this tree should take place on the standard Clang patch and
 commit lists:

diff  --git a/clang/README.txt b/clang/README.txt
index 91527b094856f..63842d42bc208 100644
--- a/clang/README.txt
+++ b/clang/README.txt
@@ -19,8 +19,8 @@ Clang Static Analyzer:
http://clang-analyzer.llvm.org/
 Information on the LLVM project:  http://llvm.org/
 
 If you have questions or comments about Clang, a great place to discuss them is
-on the Clang development mailing list:
-  http://lists.llvm.org/mailman/listinfo/cfe-dev
+on the Clang forums:
+  https://discourse.llvm.org/c/clang/
 
 If you find a bug in Clang, please file it in the LLVM bug tracker:
   http://llvm.org/bugs/

diff  --git a/clang/www/analyzer/menu.html.incl 
b/clang/www/analyzer/menu.html.incl
index ce24834eb164b..7e97efcdcde01 100644
--- a/clang/www/analyzer/menu.html.incl
+++ b/clang/www/analyzer/menu.html.incl
@@ -32,9 +32,9 @@
   
 
 
-  Mailing Lists
+  Mailing List & Forums
   
-http://lists.llvm.org/mailman/listinfo/cfe-dev;>cfe-dev
+https://discourse.llvm.org/c/clang;>Clang Frontend 
Forums
 http://lists.llvm.org/mailman/listinfo/cfe-commits;>cfe-commits
   
 

diff  --git a/clang/www/demo/index.cgi b/clang/www/demo/index.cgi
index 0fded355b67ce..d20a3f9474b5f 100644
--- a/clang/www/demo/index.cgi
+++ b/clang/www/demo/index.cgi
@@ -20,7 +20,7 @@ if ( !-d $ROOT ) { mkdir( $ROOT, 0777 ); }
 my $LOGFILE = "$ROOT/log.txt";
 my $FORM_URL= 'index.cgi';
 my $MAILADDR= 'sa...@nondot.org';
-my $CONTACT_ADDRESS = 'Questions or comments?  Email the http://lists.llvm.org/mailman/listinfo/llvm-dev;>LLVM-dev mailing 
list.';
+my $CONTACT_ADDRESS = 'Questions or comments?  Discuss on the https://discourse.llvm.org;>LLVM forum.';
 my $LOGO_IMAGE_URL  = 'cathead.png';
 my $TIMEOUTAMOUNT   = 20;
 $ENV{'LD_LIBRARY_PATH'} = '/home/vadve/shared/localtools/fc1/lib/';

diff  --git a/clang/www/menu.html.incl b/clang/www/menu.html.incl
index 72c483d273453..372e1492f827e 100755
--- a/clang/www/menu.html.incl
+++ b/clang/www/menu.html.incl
@@ -33,8 +33,7 @@
 
   
 Communication
-http://lists.llvm.org/mailman/listinfo/cfe-users;>cfe-users 
List
-http://lists.llvm.org/mailman/listinfo/cfe-dev;>cfe-dev List
+https://discourse.llvm.org/c/clang;>Clang Forum
 http://lists.llvm.org/mailman/listinfo/cfe-commits;>cfe-commits 
List
 https://github.com/llvm/llvm-project/issues;>Bug Reports
 http://planet.clang.org/;>Planet Clang

diff  --git a/compiler-rt/www/menu.html.incl b/compiler-rt/www/menu.html.incl
index 9f8273967c73d..e128cc7137e4a 100644
--- a/compiler-rt/www/menu.html.incl
+++ b/compiler-rt/www/menu.html.incl
@@ -10,7 +10,7 @@
 
   
 Quick Links
-http://lists.llvm.org/mailman/listinfo/llvm-dev;>llvm-dev
+https://discourse.llvm.org;>LLVM Forum
 http://lists.llvm.org/mailman/listinfo/llvm-commits;>llvm-commits
 http://llvm.org/bugs/;>Bug Reports
 https://github.com/llvm/llvm-project/tree/main/compiler-rt/;>Browse 
Sources

diff  --git a/flang/docs/GettingInvolved.md b/flang/docs/GettingInvolved.md
index ae6f05f7f93b6..efae97ee4b50b 100644
--- a/flang/docs/GettingInvolved.md
+++ b/flang/docs/GettingInvolved.md
@@ -16,12 +16,11 @@ The Flang Project welcomes contributions of all kinds.
 Please feel free to join the mailing list or the slack channel for discussions 
related to development of Flang.
 To understand the status of various 

[clang-tools-extra] a749e32 - Replace links to archived mailing lists by links to Discourse forums

2022-03-23 Thread Aaron Ballman via cfe-commits

Author: Danny Mösch
Date: 2022-03-23T10:10:20-04:00
New Revision: a749e3295df4aee18a0ad723875a6501f30ac744

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

LOG: Replace links to archived mailing lists by links to Discourse forums

Added: 


Modified: 
clang-tools-extra/README.txt
clang/README.txt
clang/www/analyzer/menu.html.incl
clang/www/demo/index.cgi
clang/www/menu.html.incl
compiler-rt/www/menu.html.incl
flang/docs/GettingInvolved.md
libcxx/docs/index.rst
libunwind/docs/index.rst
lldb/docs/index.rst
llvm/docs/Contributing.rst
llvm/docs/ExtendingLLVM.rst
llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl10.rst

Removed: 




diff  --git a/clang-tools-extra/README.txt b/clang-tools-extra/README.txt
index 9809cc38ccf4f..9c859a052c4b4 100644
--- a/clang-tools-extra/README.txt
+++ b/clang-tools-extra/README.txt
@@ -11,8 +11,8 @@ This repository is only intended to be checked out inside of 
a full LLVM+Clang
 tree, and in the 'tools/extra' subdirectory of the Clang checkout.
 
 All discussion regarding Clang, Clang-based tools, and code in this repository
-should be held using the standard Clang mailing lists:
-  http://lists.llvm.org/mailman/listinfo/cfe-dev
+should be held using the standard Clang forum:
+  https://discourse.llvm.org/c/clang
 
 Code review for this tree should take place on the standard Clang patch and
 commit lists:

diff  --git a/clang/README.txt b/clang/README.txt
index 91527b094856f..63842d42bc208 100644
--- a/clang/README.txt
+++ b/clang/README.txt
@@ -19,8 +19,8 @@ Clang Static Analyzer:
http://clang-analyzer.llvm.org/
 Information on the LLVM project:  http://llvm.org/
 
 If you have questions or comments about Clang, a great place to discuss them is
-on the Clang development mailing list:
-  http://lists.llvm.org/mailman/listinfo/cfe-dev
+on the Clang forums:
+  https://discourse.llvm.org/c/clang/
 
 If you find a bug in Clang, please file it in the LLVM bug tracker:
   http://llvm.org/bugs/

diff  --git a/clang/www/analyzer/menu.html.incl 
b/clang/www/analyzer/menu.html.incl
index ce24834eb164b..7e97efcdcde01 100644
--- a/clang/www/analyzer/menu.html.incl
+++ b/clang/www/analyzer/menu.html.incl
@@ -32,9 +32,9 @@
   
 
 
-  Mailing Lists
+  Mailing List & Forums
   
-http://lists.llvm.org/mailman/listinfo/cfe-dev;>cfe-dev
+https://discourse.llvm.org/c/clang;>Clang Frontend 
Forums
 http://lists.llvm.org/mailman/listinfo/cfe-commits;>cfe-commits
   
 

diff  --git a/clang/www/demo/index.cgi b/clang/www/demo/index.cgi
index 0fded355b67ce..d20a3f9474b5f 100644
--- a/clang/www/demo/index.cgi
+++ b/clang/www/demo/index.cgi
@@ -20,7 +20,7 @@ if ( !-d $ROOT ) { mkdir( $ROOT, 0777 ); }
 my $LOGFILE = "$ROOT/log.txt";
 my $FORM_URL= 'index.cgi';
 my $MAILADDR= 'sa...@nondot.org';
-my $CONTACT_ADDRESS = 'Questions or comments?  Email the http://lists.llvm.org/mailman/listinfo/llvm-dev;>LLVM-dev mailing 
list.';
+my $CONTACT_ADDRESS = 'Questions or comments?  Discuss on the https://discourse.llvm.org;>LLVM forum.';
 my $LOGO_IMAGE_URL  = 'cathead.png';
 my $TIMEOUTAMOUNT   = 20;
 $ENV{'LD_LIBRARY_PATH'} = '/home/vadve/shared/localtools/fc1/lib/';

diff  --git a/clang/www/menu.html.incl b/clang/www/menu.html.incl
index 72c483d273453..372e1492f827e 100755
--- a/clang/www/menu.html.incl
+++ b/clang/www/menu.html.incl
@@ -33,8 +33,7 @@
 
   
 Communication
-http://lists.llvm.org/mailman/listinfo/cfe-users;>cfe-users 
List
-http://lists.llvm.org/mailman/listinfo/cfe-dev;>cfe-dev List
+https://discourse.llvm.org/c/clang;>Clang Forum
 http://lists.llvm.org/mailman/listinfo/cfe-commits;>cfe-commits 
List
 https://github.com/llvm/llvm-project/issues;>Bug Reports
 http://planet.clang.org/;>Planet Clang

diff  --git a/compiler-rt/www/menu.html.incl b/compiler-rt/www/menu.html.incl
index 9f8273967c73d..e128cc7137e4a 100644
--- a/compiler-rt/www/menu.html.incl
+++ b/compiler-rt/www/menu.html.incl
@@ -10,7 +10,7 @@
 
   
 Quick Links
-http://lists.llvm.org/mailman/listinfo/llvm-dev;>llvm-dev
+https://discourse.llvm.org;>LLVM Forum
 http://lists.llvm.org/mailman/listinfo/llvm-commits;>llvm-commits
 http://llvm.org/bugs/;>Bug Reports
 https://github.com/llvm/llvm-project/tree/main/compiler-rt/;>Browse 
Sources

diff  --git a/flang/docs/GettingInvolved.md b/flang/docs/GettingInvolved.md
index ae6f05f7f93b6..efae97ee4b50b 100644
--- a/flang/docs/GettingInvolved.md
+++ b/flang/docs/GettingInvolved.md
@@ -16,12 +16,11 @@ The Flang Project welcomes contributions of all kinds.
 Please feel free to join the mailing list or the slack channel for discussions 
related to development of Flang.
 To understand the status of various 

[PATCH] D121829: [clang][AArc64][SVE] Implement vector-scalar operators

2022-03-23 Thread David Truby via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG683fc6203cfa: [clang][AArc64][SVE] Implement vector-scalar 
operators (authored by DavidTruby).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121829

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/aarch64-sve-vector-arith-ops.c
  clang/test/Sema/aarch64-sve-vector-arith-ops.c

Index: clang/test/Sema/aarch64-sve-vector-arith-ops.c
===
--- clang/test/Sema/aarch64-sve-vector-arith-ops.c
+++ clang/test/Sema/aarch64-sve-vector-arith-ops.c
@@ -20,6 +20,12 @@
   (void)(i8 + f16); // expected-error{{invalid operands to binary expression}}
   (void)(i8 + f32); // expected-error{{invalid operands to binary expression}}
   (void)(i8 + f64); // expected-error{{invalid operands to binary expression}}
+  (void)(i8 + 0);   // expected-error{{invalid operands to binary expression}}
+  (void)(i8 + 0l);  // expected-error{{invalid operands to binary expression}}
+  (void)(i8 + 0u);  // expected-error{{invalid operands to binary expression}}
+  (void)(i8 + 0ul); // expected-error{{invalid operands to binary expression}}
+  (void)(i8 + 0.f); // expected-error{{invalid operands to binary expression}}
+  (void)(i8 + 0.);  // expected-error{{invalid operands to binary expression}}
 
   (void)(u8 + b);   // expected-error{{invalid operands to binary expression}}
   (void)(u8 + i16); // expected-error{{invalid operands to binary expression}}
@@ -31,6 +37,12 @@
   (void)(u8 + f16); // expected-error{{invalid operands to binary expression}}
   (void)(u8 + f32); // expected-error{{invalid operands to binary expression}}
   (void)(u8 + f64); // expected-error{{invalid operands to binary expression}}
+  (void)(u8 + 0);   // expected-error{{invalid operands to binary expression}}
+  (void)(u8 + 0l);  // expected-error{{invalid operands to binary expression}}
+  (void)(u8 + 0u);  // expected-error{{invalid operands to binary expression}}
+  (void)(u8 + 0ul); // expected-error{{invalid operands to binary expression}}
+  (void)(u8 + 0.f); // expected-error{{invalid operands to binary expression}}
+  (void)(u8 + 0.);  // expected-error{{invalid operands to binary expression}}
 
   (void)(i16 + b);   // expected-error{{invalid operands to binary expression}}
   (void)(i16 + i8);  // expected-error{{invalid operands to binary expression}}
@@ -42,6 +54,12 @@
   (void)(i16 + f16); // expected-error{{invalid operands to binary expression}}
   (void)(i16 + f32); // expected-error{{invalid operands to binary expression}}
   (void)(i16 + f64); // expected-error{{invalid operands to binary expression}}
+  (void)(i16 + 0);   // expected-error{{invalid operands to binary expression}}
+  (void)(i16 + 0l);  // expected-error{{invalid operands to binary expression}}
+  (void)(i16 + 0u);  // expected-error{{invalid operands to binary expression}}
+  (void)(i16 + 0ul); // expected-error{{invalid operands to binary expression}}
+  (void)(i16 + 0.f); // expected-error{{invalid operands to binary expression}}
+  (void)(i16 + 0.);  // expected-error{{invalid operands to binary expression}}
 
   (void)(u16 + b);   // expected-error{{invalid operands to binary expression}}
   (void)(u16 + i8);  // expected-error{{invalid operands to binary expression}}
@@ -53,6 +71,12 @@
   (void)(u16 + f16); // expected-error{{invalid operands to binary expression}}
   (void)(u16 + f32); // expected-error{{invalid operands to binary expression}}
   (void)(u16 + f64); // expected-error{{invalid operands to binary expression}}
+  (void)(u16 + 0);   // expected-error{{invalid operands to binary expression}}
+  (void)(u16 + 0l);  // expected-error{{invalid operands to binary expression}}
+  (void)(u16 + 0u);  // expected-error{{invalid operands to binary expression}}
+  (void)(u16 + 0ul); // expected-error{{invalid operands to binary expression}}
+  (void)(u16 + 0.f); // expected-error{{invalid operands to binary expression}}
+  (void)(u16 + 0.);  // expected-error{{invalid operands to binary expression}}
 
   (void)(i32 + b);   // expected-error{{invalid operands to binary expression}}
   (void)(i32 + i8);  // expected-error{{invalid operands to binary expression}}
@@ -64,6 +88,11 @@
   (void)(i32 + f16); // expected-error{{invalid operands to binary expression}}
   (void)(i32 + f32); // expected-error{{invalid operands to binary expression}}
   (void)(i32 + f64); // expected-error{{invalid operands to binary expression}}
+  (void)(i32 + 0l);  // expected-error{{invalid operands to binary expression}}
+  (void)(i32 + 0u);  // expected-error{{invalid operands to binary expression}}
+  (void)(i32 + 0ul); // expected-error{{invalid operands to binary expression}}
+  (void)(i32 + 0.f); // expected-error{{invalid operands to binary expression}}
+  (void)(i32 + 0.); 

[PATCH] D121812: [clang][deps] NFC: De-duplicate clang-cl tests

2022-03-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/ClangScanDeps/cl-resource-dir.c:3
+
+// REQUIRES: shell
+

saudi wrote:
> I was wondering whether it could be a concern that this test will be skipped 
> on Windows systems, where `clang-cl` specific development would most likely 
> occur.
> 
> However I'm pretty sure it's ok, since this test is pretty simple and small, 
> has little chances to break during most development iterations, and we would 
> run the tests under linux at some point anyway.
I agree it's not great, but we need to be able to create an executable here (to 
simulate `clang -print-resource-dir`). Since Windows doesn't have the concept 
of shebangs, I don't think there's a way to make this work. I remember also 
trying to achieve this by creating a `.py` script and relying on Windows' "run 
`.py` files with the Python interpreter" rule. Unfortunately, that doesn't kick 
in when we run the command from within Clang.

This page https://llvm.org/docs/GettingStartedVS.html#software says Git for 
Windows with bash tools is required for building LLVM, so I think it's 
reasonable to expect `REQUIRES: shell` will pass for a lot of Windows 
developers. Is that not the case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121812

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


[PATCH] D122265: [Clang][NFC] Cleanup dcl.constexpr/p3 tests

2022-03-23 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f63cd763ec8: [Clang][NFC] Cleanup dcl.constexpr/p3 tests 
(authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122265

Files:
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp

Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++11 -Werror=c++14-extensions -Werror=c++20-extensions -Werror=c++2b-extensions %s
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++14 -DCXX14 -Werror=c++20-extensions -Werror=c++2b-extensions %s
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++20 -DCXX14 -DCXX20 -Werror=c++2b-extensions %s
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++2b -DCXX14 -DCXX20 -DCXX2b %s
+// RUN: %clang_cc1 -fcxx-exceptions -verify=expected,beforecxx14,beforecxx20,beforecxx2b -std=c++11 %s
+// RUN: %clang_cc1 -fcxx-exceptions -verify=expected,aftercxx14,beforecxx20,beforecxx2b -std=c++14 %s
+// RUN: %clang_cc1 -fcxx-exceptions -verify=expected,aftercxx14,aftercxx20,beforecxx2b -std=c++20  %s
+// RUN: %clang_cc1 -fcxx-exceptions -verify=expected,aftercxx14,aftercxx20 -std=c++2b %s
 
 namespace N {
   typedef char C;
@@ -21,10 +21,7 @@
 };
 
 struct S {
-  virtual int ImplicitlyVirtual() const = 0;
-#if __cplusplus <= 201703L
-  // expected-note@-2 {{overridden virtual function}}
-#endif
+  virtual int ImplicitlyVirtual() const = 0; // beforecxx20-note {{overridden virtual function}}
 };
 struct SS : S {
   int ImplicitlyVirtual() const;
@@ -37,31 +34,17 @@
   constexpr int f() const;
 
   //  - it shall not be virtual; [until C++20]
-  virtual constexpr int ExplicitlyVirtual() const { return 0; }
-#if __cplusplus <= 201703L
-  // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+  virtual constexpr int ExplicitlyVirtual() const { return 0; } // beforecxx20-error {{virtual function cannot be constexpr}}
 
-  constexpr int ImplicitlyVirtual() const { return 0; }
-#if __cplusplus <= 201703L
-  // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+  constexpr int ImplicitlyVirtual() const { return 0; } // beforecxx20-error {{virtual function cannot be constexpr}}
 
-  virtual constexpr int OutOfLineVirtual() const;
-#if __cplusplus <= 201703L
-  // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+  virtual constexpr int OutOfLineVirtual() const; // beforecxx20-error {{virtual function cannot be constexpr}}
 
   //  - its return type shall be a literal type;
   constexpr NonLiteral NonLiteralReturn() const { return {}; } // expected-error {{constexpr function's return type 'NonLiteral' is not a literal type}}
-  constexpr void VoidReturn() const { return; }
-#ifndef CXX14
-  // expected-error@-2 {{constexpr function's return type 'void' is not a literal type}}
-#endif
-  constexpr ~T();
-#ifndef CXX20
-  // expected-error@-2 {{destructor cannot be declared constexpr}}
-#endif
+  constexpr void VoidReturn() const { return; }// beforecxx14-error {{constexpr function's return type 'void' is not a literal type}}
+  constexpr ~T();  // beforecxx20-error {{destructor cannot be declared constexpr}}
+
   typedef NonLiteral F() const;
   constexpr F NonLiteralReturn2; // ok until definition
 
@@ -78,29 +61,21 @@
   // destructor can be defaulted. Destructors can't be constexpr since they
   // don't have a literal return type. Defaulted assignment operators can't be
   // constexpr since they can't be const.
-  constexpr T =(const T&) = default;
-#ifndef CXX14
-  // expected-error@-2 {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}}
-  // expected-warning@-3 {{C++14}}
-#else
-  // expected-error@-5 {{defaulted definition of copy assignment operator is not constexpr}}
-#endif
+  constexpr T =(const T &) = default; // beforecxx14-error {{an explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' or 'volatile' qualifiers}} \
+   // beforecxx14-warning {{C++14}} \
+   // aftercxx14-error{{defaulted definition of copy assignment operator is not constexpr}}
 };
 
 constexpr int T::OutOfLineVirtual() const { return 0; }
-#ifdef CXX14
+#if __cplusplus >= 201402L
 struct T2 {
   int n = 0;
   constexpr T2 =(const T2&) = default; // ok
 };
 struct T3 {
-  constexpr T3 =(const T3&) const = default;
-#ifndef CXX20
-  // expected-error@-2 {{an explicitly-defaulted copy assignment 

[clang] 9f63cd7 - [Clang][NFC] Cleanup dcl.constexpr/p3 tests

2022-03-23 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-03-23T15:37:48+01:00
New Revision: 9f63cd763ec85e89212e071d5d50ae5a3d5f384d

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

LOG: [Clang][NFC] Cleanup dcl.constexpr/p3 tests

* Check for warnings instead of using -Werror, to avoid masking the
type of diagnostic emitted

* use different -verify labels instead of using conditional
compilation of diagnostic checks

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp

Removed: 




diff  --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index 3dbe3e9a7212b..2db0995127506 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu 
-std=c++11 -Werror=c++14-extensions -Werror=c++20-extensions 
-Werror=c++2b-extensions %s
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu 
-std=c++14 -DCXX14 -Werror=c++20-extensions -Werror=c++2b-extensions %s
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu 
-std=c++20 -DCXX14 -DCXX20 -Werror=c++2b-extensions %s
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu 
-std=c++2b -DCXX14 -DCXX20 -DCXX2b %s
+// RUN: %clang_cc1 -fcxx-exceptions 
-verify=expected,beforecxx14,beforecxx20,beforecxx2b -std=c++11 %s
+// RUN: %clang_cc1 -fcxx-exceptions 
-verify=expected,aftercxx14,beforecxx20,beforecxx2b -std=c++14 %s
+// RUN: %clang_cc1 -fcxx-exceptions 
-verify=expected,aftercxx14,aftercxx20,beforecxx2b -std=c++20  %s
+// RUN: %clang_cc1 -fcxx-exceptions -verify=expected,aftercxx14,aftercxx20 
-std=c++2b %s
 
 namespace N {
   typedef char C;
@@ -21,10 +21,7 @@ struct Literal {
 };
 
 struct S {
-  virtual int ImplicitlyVirtual() const = 0;
-#if __cplusplus <= 201703L
-  // expected-note@-2 {{overridden virtual function}}
-#endif
+  virtual int ImplicitlyVirtual() const = 0; // beforecxx20-note {{overridden 
virtual function}}
 };
 struct SS : S {
   int ImplicitlyVirtual() const;
@@ -37,31 +34,17 @@ struct T : SS, NonLiteral {
   constexpr int f() const;
 
   //  - it shall not be virtual; [until C++20]
-  virtual constexpr int ExplicitlyVirtual() const { return 0; }
-#if __cplusplus <= 201703L
-  // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+  virtual constexpr int ExplicitlyVirtual() const { return 0; } // 
beforecxx20-error {{virtual function cannot be constexpr}}
 
-  constexpr int ImplicitlyVirtual() const { return 0; }
-#if __cplusplus <= 201703L
-  // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+  constexpr int ImplicitlyVirtual() const { return 0; } // beforecxx20-error 
{{virtual function cannot be constexpr}}
 
-  virtual constexpr int OutOfLineVirtual() const;
-#if __cplusplus <= 201703L
-  // expected-error@-2 {{virtual function cannot be constexpr}}
-#endif
+  virtual constexpr int OutOfLineVirtual() const; // beforecxx20-error 
{{virtual function cannot be constexpr}}
 
   //  - its return type shall be a literal type;
   constexpr NonLiteral NonLiteralReturn() const { return {}; } // 
expected-error {{constexpr function's return type 'NonLiteral' is not a literal 
type}}
-  constexpr void VoidReturn() const { return; }
-#ifndef CXX14
-  // expected-error@-2 {{constexpr function's return type 'void' is not a 
literal type}}
-#endif
-  constexpr ~T();
-#ifndef CXX20
-  // expected-error@-2 {{destructor cannot be declared constexpr}}
-#endif
+  constexpr void VoidReturn() const { return; }// 
beforecxx14-error {{constexpr function's return type 'void' is not a literal 
type}}
+  constexpr ~T();  // 
beforecxx20-error {{destructor cannot be declared constexpr}}
+
   typedef NonLiteral F() const;
   constexpr F NonLiteralReturn2; // ok until definition
 
@@ -78,29 +61,21 @@ struct T : SS, NonLiteral {
   // destructor can be defaulted. Destructors can't be constexpr since they
   // don't have a literal return type. Defaulted assignment operators can't be
   // constexpr since they can't be const.
-  constexpr T =(const T&) = default;
-#ifndef CXX14
-  // expected-error@-2 {{an explicitly-defaulted copy assignment operator may 
not have 'const', 'constexpr' or 'volatile' qualifiers}}
-  // expected-warning@-3 {{C++14}}
-#else
-  // expected-error@-5 {{defaulted definition of copy assignment operator is 
not constexpr}}
-#endif
+  constexpr T =(const T &) = default; // beforecxx14-error {{an 
explicitly-defaulted copy assignment operator may not have 'const', 'constexpr' 
or 

Re: [PATCH] D122255: Meta directive runtime support

2022-03-23 Thread Abid Malik via cfe-commits
I quickly went through the D120573. There are many overlapping.


On Tue, Mar 22, 2022 at 4:23 PM Johannes Doerfert via Phabricator <
revi...@reviews.llvm.org> wrote:

> jdoerfert added subscribers: ggeorgakoudis, mikerice, cchen.
> jdoerfert added a comment.
>
> This contains a lot of unrelated changes, leftover comments, etc. As you
> clean up the code, please also include tests. Clang format the patch, go
> over the new code and make sure you follow the coding style. Remove
> unneeded parts (e.g., a map into which you simply push objects then take
> them out to push them into a vector).
>
> Also, have you seen D120573 ?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D122255/new/
>
> https://reviews.llvm.org/D122255
>
>

-- 
Abid M. Malik
**
"I have learned silence from the talkative, toleration from the intolerant,
and kindness from the unkind"---Gibran
"Success is not for the chosen few, but for the few who choose" --- John
Maxwell
"Being a good person does not depend on your religion or status in life,
your race or skin color, political views or culture. IT DEPENDS ON HOW GOOD
YOU TREAT OTHERS"--- Abid
"The Universe is talking to us, and the language of the Universe is
mathematics."Abid
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 94fd00f - [Concepts] Fix placeholder constraints when references are involved

2022-03-23 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2022-03-23T11:14:58-04:00
New Revision: 94fd00f41ebddf84148f494410130527169d9573

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

LOG: [Concepts] Fix placeholder constraints when references are involved

Placeholder types were not checked for constraint satisfaction when modified by 
references or pointers.
The behavior now matches that of GCC and MSVC.

Are there other modifiers we might need to "peel"? I'm not sure my approach to 
this is the 'right' way to fix this, the loop feels a bit clunky.

GitHub issues [[ https://github.com/llvm/llvm-project/issues/54443 | #54443 ]], 
[[ https://github.com/llvm/llvm-project/issues/53911 | #53911 ]]

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 403bc08eec9be..865da1eb2aa1b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -65,6 +65,10 @@ Bug Fixes
   fixes `Issue 53044 `_.
 - Allow `-Wno-gnu` to silence GNU extension diagnostics for pointer arithmetic
   diagnostics. Fixes `Issue 5 
`_.
+- Placeholder constraints, as in `Concept auto x = f();`, were not checked 
when modifiers
+  like ``auto&`` or ``auto**`` were added. These constraints are now checked.
+  This fixes  `Issue 53911 
`_
+  and  `Issue 54443 `_.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index a53d83ea700b6..cb273aa285906 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4769,12 +4769,13 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *, 
QualType ,
   return DAR_FailedAlreadyDiagnosed;
   }
 
-  if (const auto *AT = Type.getType()->getAs()) {
+  QualType MaybeAuto = Type.getType().getNonReferenceType();
+  while (MaybeAuto->isPointerType())
+MaybeAuto = MaybeAuto->getPointeeType();
+  if (const auto *AT = MaybeAuto->getAs()) {
 if (AT->isConstrained() && !IgnoreConstraints) {
-  auto ConstraintsResult =
-  CheckDeducedPlaceholderConstraints(*this, *AT,
- Type.getContainedAutoTypeLoc(),
- DeducedType);
+  auto ConstraintsResult = CheckDeducedPlaceholderConstraints(
+  *this, *AT, Type.getContainedAutoTypeLoc(), DeducedType);
   if (ConstraintsResult != DAR_Succeeded)
 return ConstraintsResult;
 }

diff  --git a/clang/test/SemaTemplate/concepts.cpp 
b/clang/test/SemaTemplate/concepts.cpp
index 132761b2d68ae..23c79421bb6f8 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -171,7 +171,7 @@ namespace PR50561 {
 }
 
 namespace PR49188 {
-  template concept C = false; // expected-note 6 {{because 
'false' evaluated to false}}
+  template concept C = false; // expected-note 7 {{because 
'false' evaluated to false}}
 
   C auto f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
 return void();
@@ -189,7 +189,7 @@ namespace PR49188 {
   }
   C decltype(auto) f6() { // expected-error {{deduced type 'void' does not 
satisfy 'C'}}
   }
-  C auto& f7() { // expected-error {{cannot form a reference to 'void'}}
+  C auto& f7() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
 return void();
   }
   C auto& f8() {
@@ -199,13 +199,16 @@ namespace PR49188 {
   }
 }
 namespace PR53911 {
-  template concept C = false;
+  template concept C = false; // expected-note 3 {{because 'false' 
evaluated to false}}
 
-  C auto *f1() {
-return (void*)nullptr; // FIXME: should error
+  C auto *f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+return (void*)nullptr;
   }
-  C auto *f2() {
-return (int*)nullptr; // FIXME: should error
+  C auto *f2() { // expected-error {{deduced type 'int' does not satisfy 'C'}}
+return (int*)nullptr;
+  }
+  C auto *f3() { // expected-error {{deduced type 'int' does not satisfy 
'C'}}
+return (int*)nullptr;
   }
 }
 
@@ -222,3 +225,34 @@ struct B {
 };
 void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' 
does not match required type}}
 }
+
+namespace PR54443 {
+
+template 
+struct is_same { static constexpr bool value = false; };
+
+template 
+struct is_same { 

[PATCH] D122083: [Concepts] Fix placeholder constraints when references are involved

2022-03-23 Thread Roy Jacobson 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 rG94fd00f41ebd: [Concepts] Fix placeholder constraints when 
references are involved (authored by royjacobson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122083

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaTemplate/concepts.cpp

Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -171,7 +171,7 @@
 }
 
 namespace PR49188 {
-  template concept C = false; // expected-note 6 {{because 'false' evaluated to false}}
+  template concept C = false; // expected-note 7 {{because 'false' evaluated to false}}
 
   C auto f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
 return void();
@@ -189,7 +189,7 @@
   }
   C decltype(auto) f6() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
   }
-  C auto& f7() { // expected-error {{cannot form a reference to 'void'}}
+  C auto& f7() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
 return void();
   }
   C auto& f8() {
@@ -199,13 +199,16 @@
   }
 }
 namespace PR53911 {
-  template concept C = false;
+  template concept C = false; // expected-note 3 {{because 'false' evaluated to false}}
 
-  C auto *f1() {
-return (void*)nullptr; // FIXME: should error
+  C auto *f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}}
+return (void*)nullptr;
   }
-  C auto *f2() {
-return (int*)nullptr; // FIXME: should error
+  C auto *f2() { // expected-error {{deduced type 'int' does not satisfy 'C'}}
+return (int*)nullptr;
+  }
+  C auto *f3() { // expected-error {{deduced type 'int' does not satisfy 'C'}}
+return (int*)nullptr;
   }
 }
 
@@ -222,3 +225,34 @@
 };
 void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' does not match required type}}
 }
+
+namespace PR54443 {
+
+template 
+struct is_same { static constexpr bool value = false; };
+
+template 
+struct is_same { static constexpr bool value = true; };
+
+template 
+concept same_as = is_same::value; // expected-note-re 4 {{because {{.*}} evaluated to false}}
+
+int const ();
+
+same_as auto i1 = f(); // expected-error {{deduced type 'int' does not satisfy 'same_as'}}
+same_as auto  = f();
+same_as auto & = f(); // expected-error {{deduced type 'const int &' does not satisfy 'same_as'}}
+
+same_as auto i4 = f(); // expected-error {{deduced type 'int' does not satisfy 'same_as'}}
+same_as auto  = f(); // expected-error {{deduced type 'const int' does not satisfy 'same_as'}}
+same_as auto & = f();
+
+template 
+concept C = false; // expected-note 3 {{because 'false' evaluated to false}}
+
+int **const ();
+
+C auto **j1 = g();   // expected-error {{deduced type 'int' does not satisfy 'C'}}
+C auto ** = g();  // expected-error {{deduced type 'int' does not satisfy 'C'}}
+C auto **& = g(); // expected-error {{deduced type 'int' does not satisfy 'C'}}
+}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -4769,12 +4769,13 @@
   return DAR_FailedAlreadyDiagnosed;
   }
 
-  if (const auto *AT = Type.getType()->getAs()) {
+  QualType MaybeAuto = Type.getType().getNonReferenceType();
+  while (MaybeAuto->isPointerType())
+MaybeAuto = MaybeAuto->getPointeeType();
+  if (const auto *AT = MaybeAuto->getAs()) {
 if (AT->isConstrained() && !IgnoreConstraints) {
-  auto ConstraintsResult =
-  CheckDeducedPlaceholderConstraints(*this, *AT,
- Type.getContainedAutoTypeLoc(),
- DeducedType);
+  auto ConstraintsResult = CheckDeducedPlaceholderConstraints(
+  *this, *AT, Type.getContainedAutoTypeLoc(), DeducedType);
   if (ConstraintsResult != DAR_Succeeded)
 return ConstraintsResult;
 }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -65,6 +65,10 @@
   fixes `Issue 53044 `_.
 - Allow `-Wno-gnu` to silence GNU extension diagnostics for pointer arithmetic
   diagnostics. Fixes `Issue 5 `_.
+- Placeholder constraints, as in `Concept auto x = f();`, were not checked when modifiers
+  like ``auto&`` or ``auto**`` were added. These constraints are now checked.
+  This fixes  `Issue 53911 `_
+  and  `Issue 54443 

[PATCH] D121450: [clang-format] Handle attributes before case label.

2022-03-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Relanded in 
https://github.com/llvm/llvm-project/commit/4e88cb6825eefca3c0eb66b5ae40ab123fcc7073
 with a fix and a regression test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121450

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


[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-23 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905-1907
+  CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::warn_cxx20_compat_constexpr_var,
+   isa(Dcl), 2);

Apply Aaron's suggestion 
(https://reviews.llvm.org/D122249?id=417358#inline-1168823) to the updated code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[clang-tools-extra] b857a50 - [clangd] Support include-fixer inside macro arguments.

2022-03-23 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-03-23T17:12:33+01:00
New Revision: b857a5092c5e07121426196e79d51400382ff27a

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

LOG: [clangd] Support include-fixer inside macro arguments.

Motivating case: EXPECT_EQ(42, missingFunction(bar));

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

Added: 


Modified: 
clang-tools-extra/clangd/IncludeFixer.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeFixer.cpp 
b/clang-tools-extra/clangd/IncludeFixer.cpp
index 66e9552709141..6f527a48a9c0e 100644
--- a/clang-tools-extra/clangd/IncludeFixer.cpp
+++ b/clang-tools-extra/clangd/IncludeFixer.cpp
@@ -343,8 +343,8 @@ llvm::Optional qualifiedByUnresolved(const 
SourceManager ,
   SourceLocation Loc,
   const LangOptions ) 
{
   std::string Result;
-
-  SourceLocation NextLoc = Loc;
+  // Accept qualifier written within macro arguments, but not macro bodies.
+  SourceLocation NextLoc = SM.getTopMacroCallerLoc(Loc);
   while (auto CCTok = Lexer::findNextToken(NextLoc, SM, LangOpts)) {
 if (!CCTok->is(tok::coloncolon))
   break;
@@ -373,40 +373,46 @@ struct CheapUnresolvedName {
   llvm::Optional UnresolvedScope;
 };
 
+llvm::Optional getSpelledSpecifier(const CXXScopeSpec ,
+const SourceManager ) {
+  // Support specifiers written within a single macro argument.
+  if (!SM.isWrittenInSameFile(SS.getBeginLoc(), SS.getEndLoc()))
+return llvm::None;
+  SourceRange Range(SM.getTopMacroCallerLoc(SS.getBeginLoc()), 
SM.getTopMacroCallerLoc(SS.getEndLoc()));
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+return llvm::None;
+
+  return (toSourceCode(SM, Range) + "::").str();
+}
+
 // Extracts unresolved name and scope information around \p Unresolved.
 // FIXME: try to merge this with the scope-wrangling code in CodeComplete.
 llvm::Optional extractUnresolvedNameCheaply(
 const SourceManager , const DeclarationNameInfo ,
 CXXScopeSpec *SS, const LangOptions , bool UnresolvedIsSpecifier) 
{
-  bool Invalid = false;
-  llvm::StringRef Code = SM.getBufferData(
-  SM.getDecomposedLoc(Unresolved.getBeginLoc()).first, );
-  if (Invalid)
-return llvm::None;
   CheapUnresolvedName Result;
   Result.Name = Unresolved.getAsString();
   if (SS && SS->isNotEmpty()) { // "::" or "ns::"
 if (auto *Nested = SS->getScopeRep()) {
-  if (Nested->getKind() == NestedNameSpecifier::Global)
+  if (Nested->getKind() == NestedNameSpecifier::Global) {
 Result.ResolvedScope = "";
-  else if (const auto *NS = Nested->getAsNamespace()) {
-auto SpecifiedNS = printNamespaceScope(*NS);
+  } else if (const auto *NS = Nested->getAsNamespace()) {
+std::string SpecifiedNS = printNamespaceScope(*NS);
+llvm::Optional Spelling = getSpelledSpecifier(*SS, SM);
 
 // Check the specifier spelled in the source.
-// If the resolved scope doesn't end with the spelled scope. The
-// resolved scope can come from a sema typo correction. For example,
+// If the resolved scope doesn't end with the spelled scope, the
+// resolved scope may come from a sema typo correction. For example,
 // sema assumes that "clangd::" is a typo of "clang::" and uses
 // "clang::" as the specified scope in:
 // namespace clang { clangd::X; }
 // In this case, we use the "typo" specifier as extra scope instead
 // of using the scope assumed by sema.
-auto B = SM.getFileOffset(SS->getBeginLoc());
-auto E = SM.getFileOffset(SS->getEndLoc());
-std::string Spelling = (Code.substr(B, E - B) + "::").str();
-if (llvm::StringRef(SpecifiedNS).endswith(Spelling))
-  Result.ResolvedScope = SpecifiedNS;
-else
-  Result.UnresolvedScope = Spelling;
+if (!Spelling || llvm::StringRef(SpecifiedNS).endswith(*Spelling)) {
+  Result.ResolvedScope = std::move(SpecifiedNS);
+} else {
+  Result.UnresolvedScope = std::move(*Spelling);
+}
   } else if (const auto *ANS = Nested->getAsNamespaceAlias()) {
 Result.ResolvedScope = printNamespaceScope(*ANS->getNamespace());
   } else {

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index a1b66b43a87b8..f62b452353dcb 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -36,6 +36,7 @@ namespace {
 using ::testing::_;
 using ::testing::AllOf;
 using ::testing::Contains;
+using 

[PATCH] D120619: [clangd] Support include-fixer inside macro arguments.

2022-03-23 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb857a5092c5e: [clangd] Support include-fixer inside macro 
arguments. (authored by sammccall).
Herald added a project: All.

Changed prior to commit:
  https://reviews.llvm.org/D120619?vs=411622=417655#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120619

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -36,6 +36,7 @@
 using ::testing::_;
 using ::testing::AllOf;
 using ::testing::Contains;
+using ::testing::Each;
 using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
@@ -1094,6 +1095,24 @@
 "Include \"x.h\" for symbol ns::X");
 }
 
+TEST(IncludeFixerTest, TypoInMacro) {
+  auto TU = TestTU::withCode(R"cpp(// error-ok
+#define ID(T) T
+X a1;
+ID(X a2);
+ns::X a3;
+ID(ns::X a4);
+namespace ns{};
+ns::X a5;
+ID(ns::X a6);
+)cpp");
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"X", "unittest:///x.h", "\"x.h\""},
+   SymbolWithHeader{"ns::X", "unittest:///ns.h", "\"x.h\""}});
+  TU.ExternalIndex = Index.get();
+  EXPECT_THAT(*TU.build().getDiagnostics(), Each(withFix(_)));
+}
+
 TEST(IncludeFixerTest, MultipleMatchedSymbols) {
   Annotations Test(R"cpp(// error-ok
 $insert[[]]namespace na {
Index: clang-tools-extra/clangd/IncludeFixer.cpp
===
--- clang-tools-extra/clangd/IncludeFixer.cpp
+++ clang-tools-extra/clangd/IncludeFixer.cpp
@@ -343,8 +343,8 @@
   SourceLocation Loc,
   const LangOptions ) {
   std::string Result;
-
-  SourceLocation NextLoc = Loc;
+  // Accept qualifier written within macro arguments, but not macro bodies.
+  SourceLocation NextLoc = SM.getTopMacroCallerLoc(Loc);
   while (auto CCTok = Lexer::findNextToken(NextLoc, SM, LangOpts)) {
 if (!CCTok->is(tok::coloncolon))
   break;
@@ -373,40 +373,46 @@
   llvm::Optional UnresolvedScope;
 };
 
+llvm::Optional getSpelledSpecifier(const CXXScopeSpec ,
+const SourceManager ) {
+  // Support specifiers written within a single macro argument.
+  if (!SM.isWrittenInSameFile(SS.getBeginLoc(), SS.getEndLoc()))
+return llvm::None;
+  SourceRange Range(SM.getTopMacroCallerLoc(SS.getBeginLoc()), SM.getTopMacroCallerLoc(SS.getEndLoc()));
+  if (Range.getBegin().isMacroID() || Range.getEnd().isMacroID())
+return llvm::None;
+
+  return (toSourceCode(SM, Range) + "::").str();
+}
+
 // Extracts unresolved name and scope information around \p Unresolved.
 // FIXME: try to merge this with the scope-wrangling code in CodeComplete.
 llvm::Optional extractUnresolvedNameCheaply(
 const SourceManager , const DeclarationNameInfo ,
 CXXScopeSpec *SS, const LangOptions , bool UnresolvedIsSpecifier) {
-  bool Invalid = false;
-  llvm::StringRef Code = SM.getBufferData(
-  SM.getDecomposedLoc(Unresolved.getBeginLoc()).first, );
-  if (Invalid)
-return llvm::None;
   CheapUnresolvedName Result;
   Result.Name = Unresolved.getAsString();
   if (SS && SS->isNotEmpty()) { // "::" or "ns::"
 if (auto *Nested = SS->getScopeRep()) {
-  if (Nested->getKind() == NestedNameSpecifier::Global)
+  if (Nested->getKind() == NestedNameSpecifier::Global) {
 Result.ResolvedScope = "";
-  else if (const auto *NS = Nested->getAsNamespace()) {
-auto SpecifiedNS = printNamespaceScope(*NS);
+  } else if (const auto *NS = Nested->getAsNamespace()) {
+std::string SpecifiedNS = printNamespaceScope(*NS);
+llvm::Optional Spelling = getSpelledSpecifier(*SS, SM);
 
 // Check the specifier spelled in the source.
-// If the resolved scope doesn't end with the spelled scope. The
-// resolved scope can come from a sema typo correction. For example,
+// If the resolved scope doesn't end with the spelled scope, the
+// resolved scope may come from a sema typo correction. For example,
 // sema assumes that "clangd::" is a typo of "clang::" and uses
 // "clang::" as the specified scope in:
 // namespace clang { clangd::X; }
 // In this case, we use the "typo" specifier as extra scope instead
 // of using the scope assumed by sema.
-auto B = SM.getFileOffset(SS->getBeginLoc());
-auto E = SM.getFileOffset(SS->getEndLoc());
-std::string Spelling = (Code.substr(B, E - B) + "::").str();
-if (llvm::StringRef(SpecifiedNS).endswith(Spelling))
-  Result.ResolvedScope = 

  1   2   3   4   >