[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

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

@rsmith Sorry about that, I will investigate. We found preexisting issues - 
attributes seem to ODR use when they should maybe not and I could not thing of 
attributes that would refer to capture, so i didn't spent enough time looking 
at attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[clang] 376c2df - [Driver] Sort Generic_GCC::IsIntegratedAssemblerDefault, NFC

2022-04-13 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-04-14T02:41:30-04:00
New Revision: 376c2df0baeb6c7bf1b37d4ef25844d77d298cb3

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

LOG: [Driver] Sort Generic_GCC::IsIntegratedAssemblerDefault, NFC

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 4f1f2a69a149a..bc681e4d180ef 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2804,8 +2804,6 @@ bool Generic_GCC::isPICDefaultForced() const {
 
 bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   switch (getTriple().getArch()) {
-  case llvm::Triple::x86:
-  case llvm::Triple::x86_64:
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
   case llvm::Triple::arm:
@@ -2815,8 +2813,12 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   case llvm::Triple::bpfeb:
   case llvm::Triple::csky:
   case llvm::Triple::hexagon:
-  case llvm::Triple::thumb:
-  case llvm::Triple::thumbeb:
+  case llvm::Triple::m68k:
+  case llvm::Triple::mips:
+  case llvm::Triple::mipsel:
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+  case llvm::Triple::msp430:
   case llvm::Triple::ppc:
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
@@ -2827,13 +2829,11 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   case llvm::Triple::sparcel:
   case llvm::Triple::sparcv9:
   case llvm::Triple::systemz:
-  case llvm::Triple::mips:
-  case llvm::Triple::mipsel:
-  case llvm::Triple::mips64:
-  case llvm::Triple::mips64el:
-  case llvm::Triple::msp430:
-  case llvm::Triple::m68k:
+  case llvm::Triple::thumb:
+  case llvm::Triple::thumbeb:
   case llvm::Triple::ve:
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64:
 return true;
   default:
 return false;



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


[clang] 26dbb93 - [Driver] Fix -fpascal-strings on Darwin

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

Author: Fangrui Song
Date: 2022-04-13T23:00:57-07:00
New Revision: 26dbb93704bf39a198909d04ad8c49b4bde46cce

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

LOG: [Driver] Fix -fpascal-strings on Darwin

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 9f0eeea8d54e2..aaa4c6e5aabb8 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2554,11 +2554,11 @@ DerivedArgList *MachO::TranslateArgs(const 
DerivedArgList &Args,
   break;
 
 case options::OPT_fpascal_strings:
-  DAL->AddFlagArg(A, Opts.getOption(options::OPT_mpascal_strings));
+  DAL->AddFlagArg(A, Opts.getOption(options::OPT_fpascal_strings));
   break;
 
 case options::OPT_fno_pascal_strings:
-  DAL->AddFlagArg(A, Opts.getOption(options::OPT_mno_pascal_strings));
+  DAL->AddFlagArg(A, Opts.getOption(options::OPT_fno_pascal_strings));
   break;
 }
   }



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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const check

2022-04-13 Thread Fangrui Song 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 rG73da7eed8fac: [clang-tidy] Add 
portability-std-allocator-const check (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D123655?vs=422640&id=422748#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

Files:
  clang-tools-extra/clang-tidy/portability/CMakeLists.txt
  clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
  clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-std-allocator-const %t --
+
+namespace std {
+typedef unsigned size_t;
+
+template 
+class allocator {};
+template 
+class hash {};
+template 
+class equal_to {};
+template 
+class less {};
+
+template >
+class deque {};
+template >
+class forward_list {};
+template >
+class list {};
+template >
+class vector {};
+
+template , class A = std::allocator>
+class multiset {};
+template , class A = std::allocator>
+class set {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_multiset {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_set {};
+
+template >
+class stack {};
+} // namespace std
+
+namespace absl {
+template , class Eq = std::equal_to, class A = std::allocator>
+class flat_hash_set {};
+} // namespace absl
+
+template 
+class allocator {};
+
+void simple(const std::vector &v, std::deque *d) {
+  // CHECK-MESSAGES: [[#@LINE-1]]:24: warning: container using std::allocator is a deprecated libc++ extension; remove const for compatibility with other standard libraries
+  // CHECK-MESSAGES: [[#@LINE-2]]:52: warning: container
+  std::list l;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::multiset ms;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::set> s;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_multiset ums;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_set us;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  absl::flat_hash_set fhs;
+  // CHECK-MESSAGES: [[#@LINE-1]]:9: warning: container
+
+  using my_vector = std::vector;
+  // CHECK-MESSAGES: [[#@LINE-1]]:26: warning: container
+  my_vector v1;
+  using my_vector2 = my_vector;
+
+  std::vector neg1;
+  std::vector neg2; // not const T
+  std::vector> neg3; // not use std::allocator
+  std::allocator a;   // not caught, but rare
+  std::forward_list forward;  // not caught, but rare
+  std::stack stack;   // not caught, but rare
+}
+
+template 
+void temp1() {
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg1;
+  std::forward_list neg2;
+}
+void use_temp1() { temp1(); }
+
+template 
+void temp2() {
+  // Match std::vector for the uninstantiated temp2.
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg1;
+  std::forward_list neg2;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
@@ -0,0 +1,31 @@
+.. title:: clang-tidy - portability-std-allocator-const
+
+portability-std-allocator-const
+===
+
+Report use of ``std::vector`` (and similar containers of const
+elements). These are not allowed in standard C++, and should usually be
+``std::vector`` instead."
+
+Per C++ ``[allocator.requirements.general]``: "T is any cv-unqualified object
+type", ``std::allocator`` is undefined. Many standard containers use
+``std::allocator`` by default and therefore their ``const T`` instantiations are
+undefined.
+
+libc++ defines ``std::allocator`` as an extension which will be removed
+in the future.
+
+libstdc++ and MSVC do not support ``std::allocator``:
+
+.. code:: c++
+
+  // libstdc++ has a better diagnostic since https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48101
+  std::deque deque; // error: static assertion failed: std::deque must have a non-const, non-volatile value_type
+  std::set set; // error

[clang-tools-extra] 73da7ee - [clang-tidy] Add portability-std-allocator-const check

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

Author: Fangrui Song
Date: 2022-04-13T22:35:11-07:00
New Revision: 73da7eed8fac84c9005518740f12d58389998d95

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

LOG: [clang-tidy] Add portability-std-allocator-const check

Report use of ``std::vector`` (and similar containers of const
elements). These are now allowed in standard C++ due to undefined
``std::allocator``. They do not compile with libstdc++ or MSVC.
Future libc++ will remove the extension (D120996).
See docs/clang-tidy/checks/portability-std-allocator-const.rst for detail.

I have attempted clean-up in a large code base. Here are some statistics:

* 98% are related to the container `std::vector`, among 
`deque/forward_list/list/multiset/queue/set/stack/vector`.
* 24% are related to `std::vector`.
* Both `std::vector` and `std::vector` 
contribute 2%. The other contributors spread over various class types.

The check can be useful to other large code bases and may serve as an example
for future libc++ strictness improvement.

Reviewed By: sammccall

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

Added: 
clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.h
clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst

clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp

Modified: 
clang-tools-extra/clang-tidy/portability/CMakeLists.txt
clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/portability/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/portability/CMakeLists.txt
index a0de5871e036a..579e459bc72bc 100644
--- a/clang-tools-extra/clang-tidy/portability/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/portability/CMakeLists.txt
@@ -7,6 +7,7 @@ add_clang_library(clangTidyPortabilityModule
   PortabilityTidyModule.cpp
   RestrictSystemIncludesCheck.cpp
   SIMDIntrinsicsCheck.cpp
+  StdAllocatorConstCheck.cpp
 
   LINK_LIBS
   clangTidy

diff  --git 
a/clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp 
b/clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
index c87a119aa81fc..1e4f1d5de1d97 100644
--- a/clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModuleRegistry.h"
 #include "RestrictSystemIncludesCheck.h"
 #include "SIMDIntrinsicsCheck.h"
+#include "StdAllocatorConstCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -23,6 +24,8 @@ class PortabilityModule : public ClangTidyModule {
 "portability-restrict-system-includes");
 CheckFactories.registerCheck(
 "portability-simd-intrinsics");
+CheckFactories.registerCheck(
+"portability-std-allocator-const");
   }
 };
 

diff  --git 
a/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
new file mode 100644
index 0..a95048d71ef92
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
@@ -0,0 +1,71 @@
+//===-- StdAllocatorConstCheck.cpp - clang-tidy --===//
+//
+// 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 "StdAllocatorConstCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace portability {
+
+void StdAllocatorConstCheck::registerMatchers(MatchFinder *Finder) {
+  // Match std::allocator.
+  auto allocatorConst =
+  recordType(hasDeclaration(classTemplateSpecializationDecl(
+  hasName("::std::allocator"),
+  hasTemplateArgument(0, 
refersToType(qualType(isConstQualified()));
+
+  auto hasContainerName =
+  hasAnyName("::std::vector", "::std::deque", "::std::list",
+ "::std::multiset", "::std::set", "::std::unordered_multiset",
+ "::std::unordered_set", "::absl::flat_hash_set");
+
+  // Match `std::vector var;` and other common containers like deque,
+  // list, and absl::flat_hash_set. Containers like queue and stack use deque
+  // but do not directly use std::allocator as a template argument, so they
+  // aren't caught.
+  Finder->addMatcher(
+  typeLoc(
+  templateSpecializationTypeLoc(),
+   

[PATCH] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-04-13 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1791
+tokenCanStartNewLine(*FormatTok) && Text == Text.upper() &&
+!PreviousToken->isTypeFinalized()) {
   PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestandingMacro);

owenpan wrote:
> Can we simply do this and leave `FormatTokenLexer` alone?
We can too. It seemed hacky to me because we can miss `TT_UntouchableMacroFunc` 
in other places.
Setting the token type finalized in the lexer will avoid such problems in the 
future.
I'm okay however to just apply your suggestion.



Comment at: clang/unittests/Format/FormatTest.cpp:23545
+  // Newlines are important here.
+  EXPECT_EQ("FOO(1+2  );\n", format("FOO(1+2  );\n", Style));
+  EXPECT_EQ("FOO(1+2  )\n", format("FOO(1+2  )\n", Style));

owenpan wrote:
> Do we really need this test case?
Not really. I just wrote it to cover both cases but it's covered by existing 
cases indeed. Will remove.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123676

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


[PATCH] D123737: [clang-format] Skip preprocessor lines when finding the record lbrace

2022-04-13 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.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123737

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


[PATCH] D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name

2022-04-13 Thread Wang Yihan via Phabricator via cfe-commits
yihanaa added a comment.

Could you please help me review the code?@rsmith,thanks😊


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122920

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


[clang] bfafa10 - [Driver] Simplify some hasFlag patterns with addOptInFlag/addOptOutFlag. NFC

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

Author: Fangrui Song
Date: 2022-04-13T22:00:44-07:00
New Revision: bfafa105aab05e2c243e74114739b7d37f8ab0be

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

LOG: [Driver] Simplify some hasFlag patterns with addOptInFlag/addOptOutFlag. 
NFC

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5cba45d0102cb..bf47212374ce4 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3962,9 +3962,8 @@ static void RenderDiagnosticsOptions(const Driver &D, 
const ArgList &Args,
   if (Args.hasArg(options::OPT_fansi_escape_codes))
 CmdArgs.push_back("-fansi-escape-codes");
 
-  if (!Args.hasFlag(options::OPT_fshow_source_location,
-options::OPT_fno_show_source_location, true))
-CmdArgs.push_back("-fno-show-source-location");
+  Args.addOptOutFlag(CmdArgs, options::OPT_fshow_source_location,
+ options::OPT_fno_show_source_location);
 
   if (Args.hasArg(options::OPT_fdiagnostics_absolute_paths))
 CmdArgs.push_back("-fdiagnostics-absolute-paths");
@@ -3973,9 +3972,8 @@ static void RenderDiagnosticsOptions(const Driver &D, 
const ArgList &Args,
 ColumnDefault))
 CmdArgs.push_back("-fno-show-column");
 
-  if (!Args.hasFlag(options::OPT_fspell_checking,
-options::OPT_fno_spell_checking, true))
-CmdArgs.push_back("-fno-spell-checking");
+  Args.addOptOutFlag(CmdArgs, options::OPT_fspell_checking,
+ options::OPT_fno_spell_checking);
 }
 
 enum class DwarfFissionKind { None, Split, Single };
@@ -5512,17 +5510,12 @@ void Clang::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-fdata-sections");
   }
 
-  if (!Args.hasFlag(options::OPT_funique_section_names,
-options::OPT_fno_unique_section_names, true))
-CmdArgs.push_back("-fno-unique-section-names");
-
-  if (Args.hasFlag(options::OPT_funique_internal_linkage_names,
-   options::OPT_fno_unique_internal_linkage_names, false))
-CmdArgs.push_back("-funique-internal-linkage-names");
-
-  if (Args.hasFlag(options::OPT_funique_basic_block_section_names,
-   options::OPT_fno_unique_basic_block_section_names, false))
-CmdArgs.push_back("-funique-basic-block-section-names");
+  Args.addOptOutFlag(CmdArgs, options::OPT_funique_section_names,
+ options::OPT_fno_unique_section_names);
+  Args.addOptInFlag(CmdArgs, options::OPT_funique_internal_linkage_names,
+options::OPT_fno_unique_internal_linkage_names);
+  Args.addOptInFlag(CmdArgs, options::OPT_funique_basic_block_section_names,
+options::OPT_fno_unique_basic_block_section_names);
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
@@ -6050,9 +6043,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 Args.AddLastArg(CmdArgs, options::OPT_fopenmp_simd,
 options::OPT_fno_openmp_simd);
 Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
-if (!Args.hasFlag(options::OPT_fopenmp_extensions,
-  options::OPT_fno_openmp_extensions, /*Default=*/true))
-  CmdArgs.push_back("-fno-openmp-extensions");
+Args.addOptOutFlag(CmdArgs, options::OPT_fopenmp_extensions,
+   options::OPT_fno_openmp_extensions);
   }
 
   SanitizeArgs.addArgs(TC, Args, CmdArgs, InputType);
@@ -6195,9 +6187,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   CmdArgs.push_back("-mstack-probe-size=0");
   }
 
-  if (!Args.hasFlag(options::OPT_mstack_arg_probe,
-options::OPT_mno_stack_arg_probe, true))
-CmdArgs.push_back(Args.MakeArgString("-mno-stack-arg-probe"));
+  Args.addOptOutFlag(CmdArgs, options::OPT_mstack_arg_probe,
+ options::OPT_mno_stack_arg_probe);
 
   if (Arg *A = Args.getLastArg(options::OPT_mrestrict_it,
options::OPT_mno_restrict_it)) {
@@ -6278,9 +6269,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   }
   RenderBuiltinOptions(TC, RawTriple, Args, CmdArgs);
 
-  if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
-options::OPT_fno_assume_sane_operator_new, true))
-CmdArgs.push_back("-fno-assume-sane-operator-new");
+  Args.addOptOutFlag(CmdArgs, options::OPT_fassume_sane_operator_new,
+ options::OPT_fno_assume_sane_operator_new);
 
   // -fblocks=0 is default.
   if (Args.hasFlag(options::OPT_fblocks, options::OPT_fno_blocks,
@@ -6307,1

[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Hey @cor3ntin, sorry, I reverted this again. It's breaking thread-safety  
annotations on lambdas in a pretty severe way:

  Mutex m;
  auto lambda = [=]() EXCLUSIVE_LOCKS_REQUIRED(m) {...}

doesn't compile any more. Presumably we should be parsing the attribute in the 
enclosing context rather than in the half-way-inside-the-lambda context in 
which we parse parameters?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[clang] 836e610 - Revert "[clang] Implement Change scope of lambda trailing-return-type"

2022-04-13 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2022-04-13T21:34:08-07:00
New Revision: 836e610d9332772ad4511e86ef126a200f1ab281

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

LOG: Revert "[clang] Implement Change scope of lambda trailing-return-type"

This reverts commit c729d5be781a8e80137c11ab28aa14d9ace148db.

This change breaks thread safety annotations on lambdas.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Scope.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
clang/www/cxx_status.html

Removed: 
clang/test/SemaCXX/lambda-capture-type-deduction.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 016aafee016c2..91fc57dfac595 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -247,9 +247,6 @@ C++2b Feature Support
 - Implemented `P2128R6: Multidimensional subscript operator 
`_.
 - Implemented `P0849R8: auto(x): decay-copy in the language 
`_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in 
constexpr functions`_.
-- Implemented `P2036R3: Change scope of lambda trailing-return-type 
`_.
-  This proposal modifies how variables captured in lambdas can appear in 
trailing return type
-  expressions and how their types are deduced therein, in all C++ language 
versions.
 
 CUDA Language Changes in Clang
 --

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index c640f7f7ba63f..04a9daa14e05e 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1799,20 +1799,6 @@ class CXXRecordDecl : public RecordDecl {
 return getLambdaData().MethodTyInfo;
   }
 
-  void setLambdaTypeInfo(TypeSourceInfo *TS) {
-auto *DD = DefinitionData;
-assert(DD && DD->IsLambda && "setting lambda property of non-lambda 
class");
-auto &DL = static_cast(*DD);
-DL.MethodTyInfo = TS;
-  }
-
-  void setLambdaIsGeneric(bool IsGeneric) {
-auto *DD = DefinitionData;
-assert(DD && DD->IsLambda && "setting lambda property of non-lambda 
class");
-auto &DL = static_cast(*DD);
-DL.IsGenericLambda = IsGeneric;
-  }
-
   // Determine whether this type is an Interface Like type for
   // __interface inheritance purposes.
   bool isInterfaceLike() const;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e154925538f3a..3213163ee7876 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7704,8 +7704,6 @@ let CategoryName = "Lambda Issue" in {
   def err_lambda_impcap : Error<
 "variable %0 cannot be implicitly captured in a lambda with no "
 "capture-default specified">;
-  def err_lambda_used_before_capture: Error<
-"captured variable %0 cannot appear here">;
   def note_lambda_variable_capture_fixit : Note<
 "capture %0 by %select{value|reference}1">;
   def note_lambda_default_capture_fixit : Note<

diff  --git a/clang/include/clang/Sema/Scope.h 
b/clang/include/clang/Sema/Scope.h
index 5a2d51b63d909..872951a0829b4 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -44,11 +44,11 @@ class Scope {
   enum ScopeFlags {
 /// This indicates that the scope corresponds to a function, which
 /// means that labels are set here.
-FnScope = 0x01,
+FnScope   = 0x01,
 
 /// This is a while, do, switch, for, etc that can have break
 /// statements embedded into it.
-BreakScope = 0x02,
+BreakScope= 0x02,
 
 /// This is a while, do, for, which can have continue statements
 /// embedded into it.
@@ -140,12 +140,6 @@ class Scope {
 /// parsed. If such a scope is a ContinueScope, it's invalid to jump to the
 /// continue block from here.
 ConditionVarScope = 0x200,
-
-/// This is the scope for a lambda, after the lambda introducer.
-/// Lambdas need 2 FunctionPrototypeScope scopes (because there is a
-/// template scope in between), the outer scope does not increase the
-/// depth of recursion.
-LambdaScope = 0x400,
   };

[PATCH] D121915: RISCV] Add clang builtins for CLZ instruction.

2022-04-13 Thread Chang Hu 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 rGa4f47a99aafe: RISCV] Add clang builtins for CLZ instruction. 
(authored by joker881).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121915

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -25,3 +25,27 @@
 long orc_b_64(long a) {
   return __builtin_riscv_orc_b_64(a);
 }
+
+// RV64ZBB-LABEL: @clz_32(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
+// RV64ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
+
+// RV64ZBB-LABEL: @clz_64(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBB-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 
false)
+// RV64ZBB-NEXT:ret i64 [[TMP1]]
+//
+long clz_64(long a) {
+  return __builtin_riscv_clz_64(a);
+}
\ No newline at end of file
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -13,3 +13,15 @@
 int orc_b_32(int a) {
   return __builtin_riscv_orc_b_32(a);
 }
+
+// RV32ZBB-LABEL: @clz_32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
\ No newline at end of file
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -18992,6 +18992,8 @@
   default: llvm_unreachable("unexpected builtin ID");
   case RISCV::BI__builtin_riscv_orc_b_32:
   case RISCV::BI__builtin_riscv_orc_b_64:
+  case RISCV::BI__builtin_riscv_clz_32:
+  case RISCV::BI__builtin_riscv_clz_64:
   case RISCV::BI__builtin_riscv_clmul:
   case RISCV::BI__builtin_riscv_clmulh:
   case RISCV::BI__builtin_riscv_clmulr:
@@ -19037,6 +19039,11 @@
 case RISCV::BI__builtin_riscv_orc_b_64:
   ID = Intrinsic::riscv_orc_b;
   break;
+case RISCV::BI__builtin_riscv_clz_32:
+case RISCV::BI__builtin_riscv_clz_64: {
+  Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType());
+  return Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+}
 
 // Zbc
 case RISCV::BI__builtin_riscv_clmul:
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -18,6 +18,8 @@
 // Zbb extension
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb,64bit")
 
 // Zbc or Zbkc extension
 TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -25,3 +25,27 @@
 long orc_b_64(long a) {
   return __builtin_riscv_orc_b_64(a);
 }
+
+// RV64ZBB-LABEL: @clz_32(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 false)
+// RV64ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
+
+// RV64ZBB-LABEL: @clz_64(
+// RV64ZBB

[clang] a4f47a9 - RISCV] Add clang builtins for CLZ instruction.

2022-04-13 Thread via cfe-commits

Author: joker881
Date: 2022-04-14T12:29:15+08:00
New Revision: a4f47a99aafe57db0176ef7dad1a9ba72854439f

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

LOG: RISCV] Add clang builtins for CLZ instruction.

add intrinsic for CLZ

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 73ec6eae7e955..74b8c9ea6a949 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -18,6 +18,8 @@
 // Zbb extension
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb,64bit")
 
 // Zbc or Zbkc extension
 TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "zbc|zbkc")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 4ad4acc0be6b1..3adabcbf4bc97 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18992,6 +18992,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   default: llvm_unreachable("unexpected builtin ID");
   case RISCV::BI__builtin_riscv_orc_b_32:
   case RISCV::BI__builtin_riscv_orc_b_64:
+  case RISCV::BI__builtin_riscv_clz_32:
+  case RISCV::BI__builtin_riscv_clz_64:
   case RISCV::BI__builtin_riscv_clmul:
   case RISCV::BI__builtin_riscv_clmulh:
   case RISCV::BI__builtin_riscv_clmulr:
@@ -19037,6 +19039,11 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 case RISCV::BI__builtin_riscv_orc_b_64:
   ID = Intrinsic::riscv_orc_b;
   break;
+case RISCV::BI__builtin_riscv_clz_32:
+case RISCV::BI__builtin_riscv_clz_64: {
+  Function *F = CGM.getIntrinsic(Intrinsic::ctlz, Ops[0]->getType());
+  return Builder.CreateCall(F, {Ops[0], Builder.getInt1(false)});
+}
 
 // Zbc
 case RISCV::BI__builtin_riscv_clmul:

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
index 1eb0250893f25..c1827b1edbf5b 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -13,3 +13,15 @@
 int orc_b_32(int a) {
   return __builtin_riscv_orc_b_32(a);
 }
+
+// RV32ZBB-LABEL: @clz_32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
\ No newline at end of file

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
index 013096743078c..da2930c891201 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -25,3 +25,27 @@ int orc_b_32(int a) {
 long orc_b_64(long a) {
   return __builtin_riscv_orc_b_64(a);
 }
+
+// RV64ZBB-LABEL: @clz_32(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV64ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.ctlz.i32(i32 [[TMP0]], i1 
false)
+// RV64ZBB-NEXT:ret i32 [[TMP1]]
+//
+int clz_32(int a) {
+  return __builtin_riscv_clz_32(a);
+}
+
+// RV64ZBB-LABEL: @clz_64(
+// RV64ZBB-NEXT:  entry:
+// RV64ZBB-NEXT:[[A_ADDR:%.*]] = alloca i64, align 8
+// RV64ZBB-NEXT:store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
+// RV64ZBB-NEXT:[[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
+// RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.ctlz.i64(i64 [[TMP0]], i1 
false)
+// RV64ZBB-NEXT:ret i64 [[TMP1]]
+//
+long clz_64(long a) {
+  return __builtin_riscv_clz_64(a);
+}
\ No newline at end of file



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


[PATCH] D123167: [HLSL] Pointers are unsupported in HLSL

2022-04-13 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 422738.
beanz added a comment.

Updating based on PR feedback.

I've moved the error reporting into Sema, and added additional errors for 
unsupported operators.

I've also expanded the test coverage with some of @aaron.ballman's cursed code, 
which improves coverage substantailly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123167

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaHLSL/prohibit_pointer.hlsl
  clang/test/SemaHLSL/prohibit_reference.hlsl

Index: clang/test/SemaHLSL/prohibit_reference.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/prohibit_reference.hlsl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - -fsyntax-only %s -verify
+
+int& bark(int); // expected-error {{references are unsupported in HLSL}}
+void meow(int&); // expected-error {{references are unsupported in HLSL}}
+
+struct Foo {
+  int X;
+  int Y;
+};
+
+int entry() {
+  int X;
+  int &Y = X; // expected-error {{references are unsupported in HLSL}}
+}
+
+int roar(Foo &F) { // expected-error {{references are unsupported in HLSL}}
+  return F.X;
+}
Index: clang/test/SemaHLSL/prohibit_pointer.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/prohibit_pointer.hlsl
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - -fsyntax-only %s -verify
+
+// expected-error@+1 {{pointers are unsupported in HLSL}}
+typedef int (*fn_int)(int);
+void* bark(int); // expected-error {{pointers are unsupported in HLSL}}
+void meow(int*); // expected-error {{pointers are unsupported in HLSL}}
+
+struct Foo {
+  int X;
+  int Y;
+} *bad; // expected-error {{pointers are unsupported in HLSL}}
+
+// expected-error@+1 {{pointers are unsupported in HLSL}}
+void woof(int Foo::*Member);
+
+int entry() {
+  int X;
+  Foo F;
+  
+  // expected-error@+2 {{the address of (&) operator is unsupported in HLSL}}
+  // expected-error@+1 {{pointers are unsupported in HLSL}}
+  int Foo::*Member = &F.X;
+  
+  // expected-error@+1 {{the address of (&) operator is unsupported in HLSL}}
+  int *Y = &X; // expected-error {{pointers are unsupported in HLSL}}
+  
+  // expected-error@+2 {{the arrow (->) operator is unsupported in HLSL}}
+  // expected-error@+1 {{the address of (&) operator is unsupported in HLSL}}
+  int W = (&F)->X;
+
+  int Array[2];
+  // expected-error@+1 {{the address of (&) operator is unsupported in HLSL}}
+  *(&Array[0] + 1) = 12;
+  // expected-error@+1 {{the dereference (*) operator is unsupported in HLSL}}
+  *Array = 12;
+}
+
+int roar(Foo *F) { // expected-error {{pointers are unsupported in HLSL}}
+  // expected-error@+1 {{the arrow (->) operator is unsupported in HLSL}}
+  return F->X;
+}
+
+template 
+void devilish_language(T look_ma_no_pointers);
+
+void make_me_cry() {
+  int X;
+  // expected-error@+1 {{the address of (&) operator is unsupported in HLSL}}
+  devilish_language(&X);
+
+  // not-expected-error@+1 {{pointers are unsupported in HLSL}}
+  devilish_language(roar); // allow function pointer decay
+
+  // not-expected-error@+1 {{pointers are unsupported in HLSL}}
+  devilish_language("roar"); // allow array pointer decay
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2143,6 +2143,11 @@
 return QualType();
   }
 
+  if (getLangOpts().HLSL) {
+Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
+return QualType();
+  }
+
   if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer))
 return QualType();
 
@@ -2208,6 +2213,11 @@
 return QualType();
   }
 
+  if (getLangOpts().HLSL) {
+Diag(Loc, diag::err_hlsl_pointers_unsupported) << 1;
+return QualType();
+  }
+
   if (checkQualifiedFunction(*this, T, Loc, QFK_Reference))
 return QualType();
 
@@ -2967,6 +2977,11 @@
 return QualType();
   }
 
+  if (getLangOpts().HLSL) {
+Diag(Loc, diag::err_hlsl_pointers_unsupported) << 0;
+return QualType();
+  }
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/lib/Sema/SemaExprMember.cpp
===
--- clang/lib/Sema/SemaExprMember.cpp
+++ clang/lib/Sema/SemaExprMember.cpp
@@ -1736,6 +1736,9 @@
   DeclarationName Name = NameInfo.getName();
   bool IsArrow = (OpKind == tok::arrow);
 
+  if (getLangOpts().HLSL && IsArrow)
+return ExprError(Diag(OpLoc, diag::err_hlsl_operator_unsupported) << 2);
+
   NamedDecl *FirstQualifierInScope
 = (!SS.isSet() ? nullptr : FindFirstQualifierInScope(S, SS.

[PATCH] D123438: [Clang] Move Hexagon / VE IAS enabling to Generic_GCC::IsIntegratedAssemblerDefault, NFC

2022-04-13 Thread Brad Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d88b4ba8b0: [Clang] Move Hexagon / VE IAS enabling to 
Generic_GCC… (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123438

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Hexagon.h
  clang/lib/Driver/ToolChains/VEToolchain.h


Index: clang/lib/Driver/ToolChains/VEToolchain.h
===
--- clang/lib/Driver/ToolChains/VEToolchain.h
+++ clang/lib/Driver/ToolChains/VEToolchain.h
@@ -26,7 +26,6 @@
   Tool *buildLinker() const override;
 
 public:
-  bool IsIntegratedAssemblerDefault() const override { return true; }
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefaultForced() const override;
Index: clang/lib/Driver/ToolChains/Hexagon.h
===
--- clang/lib/Driver/ToolChains/Hexagon.h
+++ clang/lib/Driver/ToolChains/Hexagon.h
@@ -94,9 +94,6 @@
llvm::opt::ArgStringList &CmdArgs) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
-  bool IsIntegratedAssemblerDefault() const override {
-return true;
-  }
 
   std::string getHexagonTargetDir(
   const std::string &InstalledDir,
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2814,6 +2814,7 @@
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
   case llvm::Triple::csky:
+  case llvm::Triple::hexagon:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
   case llvm::Triple::ppc:
@@ -2832,6 +2833,7 @@
   case llvm::Triple::mips64el:
   case llvm::Triple::msp430:
   case llvm::Triple::m68k:
+  case llvm::Triple::ve:
 return true;
   default:
 return false;


Index: clang/lib/Driver/ToolChains/VEToolchain.h
===
--- clang/lib/Driver/ToolChains/VEToolchain.h
+++ clang/lib/Driver/ToolChains/VEToolchain.h
@@ -26,7 +26,6 @@
   Tool *buildLinker() const override;
 
 public:
-  bool IsIntegratedAssemblerDefault() const override { return true; }
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefaultForced() const override;
Index: clang/lib/Driver/ToolChains/Hexagon.h
===
--- clang/lib/Driver/ToolChains/Hexagon.h
+++ clang/lib/Driver/ToolChains/Hexagon.h
@@ -94,9 +94,6 @@
llvm::opt::ArgStringList &CmdArgs) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
-  bool IsIntegratedAssemblerDefault() const override {
-return true;
-  }
 
   std::string getHexagonTargetDir(
   const std::string &InstalledDir,
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2814,6 +2814,7 @@
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
   case llvm::Triple::csky:
+  case llvm::Triple::hexagon:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
   case llvm::Triple::ppc:
@@ -2832,6 +2833,7 @@
   case llvm::Triple::mips64el:
   case llvm::Triple::msp430:
   case llvm::Triple::m68k:
+  case llvm::Triple::ve:
 return true;
   default:
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 71d88b4 - [Clang] Move Hexagon / VE IAS enabling to Generic_GCC::IsIntegratedAssemblerDefault, NFC

2022-04-13 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-04-13T23:56:09-04:00
New Revision: 71d88b4ba8b0d45070b2f52b807f461fec737638

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

LOG: [Clang] Move Hexagon / VE IAS enabling to 
Generic_GCC::IsIntegratedAssemblerDefault, NFC

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Hexagon.h
clang/lib/Driver/ToolChains/VEToolchain.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index a10edc3db409f..4f1f2a69a149a 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2814,6 +2814,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
   case llvm::Triple::csky:
+  case llvm::Triple::hexagon:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
   case llvm::Triple::ppc:
@@ -2832,6 +2833,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   case llvm::Triple::mips64el:
   case llvm::Triple::msp430:
   case llvm::Triple::m68k:
+  case llvm::Triple::ve:
 return true;
   default:
 return false;

diff  --git a/clang/lib/Driver/ToolChains/Hexagon.h 
b/clang/lib/Driver/ToolChains/Hexagon.h
index 8996305553524..c742012444b44 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.h
+++ b/clang/lib/Driver/ToolChains/Hexagon.h
@@ -94,9 +94,6 @@ class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux 
{
llvm::opt::ArgStringList &CmdArgs) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
-  bool IsIntegratedAssemblerDefault() const override {
-return true;
-  }
 
   std::string getHexagonTargetDir(
   const std::string &InstalledDir,

diff  --git a/clang/lib/Driver/ToolChains/VEToolchain.h 
b/clang/lib/Driver/ToolChains/VEToolchain.h
index 964b0d0dd8d4f..8b9ccaa7fadaf 100644
--- a/clang/lib/Driver/ToolChains/VEToolchain.h
+++ b/clang/lib/Driver/ToolChains/VEToolchain.h
@@ -26,7 +26,6 @@ class LLVM_LIBRARY_VISIBILITY VEToolChain : public Linux {
   Tool *buildLinker() const override;
 
 public:
-  bool IsIntegratedAssemblerDefault() const override { return true; }
   bool isPICDefault() const override;
   bool isPIEDefault(const llvm::opt::ArgList &Args) const override;
   bool isPICDefaultForced() const override;



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


[PATCH] D123297: [flang][driver] Add support for -mmlir

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3272
   MarshallingInfoStringVector>;
+def mmlir : Separate<["-"], "mmlir">,Flags<[CoreOption,FC1Option,FlangOption]>,
+  HelpText<"Additional arguments to forward to MLIR's option processing">;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123297

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


[PATCH] D122865: [HLSL][clang][Driver] Support target profile command line option.

2022-04-13 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122865

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


[PATCH] D123676: [clang-format] Fix WhitespaceSensitiveMacros not being honoured when macro closing parenthesis is followed by a newline.

2022-04-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1791
+tokenCanStartNewLine(*FormatTok) && Text == Text.upper() &&
+!PreviousToken->isTypeFinalized()) {
   PreviousToken->setFinalizedType(TT_FunctionLikeOrFreestandingMacro);

Can we simply do this and leave `FormatTokenLexer` alone?



Comment at: clang/unittests/Format/FormatTest.cpp:23545
+  // Newlines are important here.
+  EXPECT_EQ("FOO(1+2  );\n", format("FOO(1+2  );\n", Style));
+  EXPECT_EQ("FOO(1+2  )\n", format("FOO(1+2  )\n", Style));

Do we really need this test case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123676

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


[clang] c98b601 - [randstruct] Fix -Wunused-but-set-variable with Clang>=D122271 in -DLLVM_ENABLE_ASSERTIONS=off builds

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

Author: Fangrui Song
Date: 2022-04-13T17:09:30-07:00
New Revision: c98b601b7fad9500742a9221bd8de4a86d68175e

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

LOG: [randstruct] Fix -Wunused-but-set-variable with Clang>=D122271 in 
-DLLVM_ENABLE_ASSERTIONS=off builds

Added: 


Modified: 
clang/lib/AST/Randstruct.cpp

Removed: 




diff  --git a/clang/lib/AST/Randstruct.cpp b/clang/lib/AST/Randstruct.cpp
index f6d7ba1c24164..fadc727bbc4ed 100644
--- a/clang/lib/AST/Randstruct.cpp
+++ b/clang/lib/AST/Randstruct.cpp
@@ -216,6 +216,7 @@ bool randomizeStructureLayout(const ASTContext &Context, 
StringRef Name,
 
   assert(TotalNumFields == FinalOrdering.size() &&
  "Decl count has been altered after Randstruct randomization!");
+  (void)TotalNumFields;
   return true;
 }
 



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


[PATCH] D123744: [Driver] Change CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver default instead of cc1 default

2022-04-13 Thread Fangrui Song 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 rGab8abeaf48ab: [Driver] Change 
CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver default… (authored by 
MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D123744?vs=422692&id=422694#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123744

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CMakeLists.txt
  clang/test/Driver/opaque-pointers-off.c
  clang/test/Driver/rewrite-legacy-objc.m
  clang/test/Driver/rewrite-objc.m
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -23,6 +23,7 @@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
+config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -131,6 +131,9 @@
 if config.clang_default_pie_on_linux:
 config.available_features.add('default-pie-on-linux')
 
+if config.clang_enable_opaque_pointers:
+config.available_features.add('enable-opaque-pointers')
+
 # Set available features we allow tests to conditionalize on.
 #
 if config.clang_default_cxx_stdlib != '':
Index: clang/test/Driver/rewrite-objc.m
===
--- clang/test/Driver/rewrite-objc.m
+++ clang/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
Index: clang/test/Driver/rewrite-legacy-objc.m
===
--- clang/test/Driver/rewrite-legacy-objc.m
+++ clang/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
-// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
-// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
+// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
+// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-ve

[clang] ab8abea - [Driver] Change CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver default instead of cc1 default

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

Author: Fangrui Song
Date: 2022-04-13T16:58:00-07:00
New Revision: ab8abeaf48abb3addcbdb6136b1975b4afa3b37c

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

LOG: [Driver] Change CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver 
default instead of cc1 default

The current cc1 CLANG_ENABLE_OPAQUE_POINTERS=on default difference is not ideal
in that people contribute %clang_cc1 tests may assume the default ON behavior,
which will cause failures on systems set to OFF.

cc1 option default dependent on CMake options should be used prudently
(generally avoided). We prefer to limit target differences to Driver.

Change the CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL mechanism introduced in D123122
to use a driver default instead. This is similar to the mechanism used for the
-flegacy-pass-manager transition to new PM transition.

Reviewed By: #opaque-pointers, rsmith, aeubanks

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

Added: 
clang/test/Driver/opaque-pointers-off.c

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CMakeLists.txt
clang/test/Driver/rewrite-legacy-objc.m
clang/test/Driver/rewrite-objc.m
clang/test/lit.cfg.py
clang/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 483f0cc549ab4..87b5ef2d39c33 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5533,7 +5533,7 @@ defm enable_noundef_analysis : BoolOption<"",
 defm opaque_pointers : BoolOption<"",
   "opaque-pointers",
   CodeGenOpts<"OpaquePointers">,
-  Default<"CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL">,
+  DefaultTrue,
   PosFlag,
   NegFlag,
   BothFlags<[], " opaque pointers">>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 97b2ded5821f6..5cba45d0102cb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -6506,6 +6507,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
false))
 CmdArgs.push_back("-fmodules-debuginfo");
 
+  if (!CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL)
+CmdArgs.push_back("-no-opaque-pointers");
+
   ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, Inputs, CmdArgs, rewriteKind);
   RenderObjCOptions(TC, D, RawTriple, Args, Runtime, rewriteKind != RK_None,
 Input, CmdArgs);

diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 7d050b2080b6a..9e8fa9c5c4388 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -4,6 +4,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANG_BUILD_EXAMPLES
   CLANG_DEFAULT_PIE_ON_LINUX
+  CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL
   CLANG_ENABLE_ARCMT
   CLANG_ENABLE_STATIC_ANALYZER
   CLANG_PLUGIN_SUPPORT

diff  --git a/clang/test/Driver/opaque-pointers-off.c 
b/clang/test/Driver/opaque-pointers-off.c
new file mode 100644
index 0..d498c1a5f82bf
--- /dev/null
+++ b/clang/test/Driver/opaque-pointers-off.c
@@ -0,0 +1,11 @@
+// UNSUPPORTED: enable-opaque-pointers
+/// Test -DCLANG_ENABLE_OPAQUE_POINTERS=OFF.
+
+// RUN: %clang -### --target=aarch64-linux-gnu %s 2>&1 | FileCheck %s
+/// User -Xclang -opaque-pointers overrides the default.
+// RUN: %clang -### --target=aarch64-linux-gnu -Xclang -opaque-pointers %s 
2>&1 | FileCheck %s --check-prefix=CHECK2
+
+// CHECK:   "-no-opaque-pointers"
+
+// CHECK2:  "-no-opaque-pointers"
+// CHECK2-SAME: "-opaque-pointers"

diff  --git a/clang/test/Driver/rewrite-legacy-objc.m 
b/clang/test/Driver/rewrite-legacy-objc.m
index fb7df4b97c061..3fd35b1c91d5d 100644
--- a/clang/test/Driver/rewrite-legacy-objc.m
+++ b/clang/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency 
instead.
-// TEST0: "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" 
"-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" 
"-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" 
"-fmax-type-align=1

[PATCH] D123744: [Driver] Change CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver default instead of cc1 default

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 422692.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added a subscriber: mgorny.

Add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123744

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CMakeLists.txt
  clang/test/Driver/rewrite-legacy-objc.m
  clang/test/Driver/rewrite-objc.m
  clang/test/lit.cfg.py
  clang/test/lit.site.cfg.py.in

Index: clang/test/lit.site.cfg.py.in
===
--- clang/test/lit.site.cfg.py.in
+++ clang/test/lit.site.cfg.py.in
@@ -23,6 +23,7 @@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@
 config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
+config.clang_enable_opaque_pointers = @CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@
 config.clang_staticanalyzer_z3 = @LLVM_WITH_Z3@
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -131,6 +131,9 @@
 if config.clang_default_pie_on_linux:
 config.available_features.add('default-pie-on-linux')
 
+if config.clang_enable_opaque_pointers:
+config.available_features.add('enable-opaque-pointers')
+
 # Set available features we allow tests to conditionalize on.
 #
 if config.clang_default_cxx_stdlib != '':
Index: clang/test/Driver/rewrite-objc.m
===
--- clang/test/Driver/rewrite-objc.m
+++ clang/test/Driver/rewrite-objc.m
@@ -3,4 +3,4 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
Index: clang/test/Driver/rewrite-legacy-objc.m
===
--- clang/test/Driver/rewrite-legacy-objc.m
+++ clang/test/Driver/rewrite-legacy-objc.m
@@ -3,11 +3,11 @@
 // TEST0: clang{{.*}}" "-cc1"
 // TEST0: "-rewrite-objc"
 // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
-// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
+// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
 // TEST0: rewrite-legacy-objc.m"
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST1 %s
 // RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=TEST2 %s
-// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
-// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
+// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
+// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1"{{.*}} "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
Index: clang/test/CMakeLists.txt
===

[PATCH] D121915: [RISCV] CLZ Instruction

2022-04-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM though I think the title needs to be updated. Should be something like 
"[RISCV] Add clang builtins for CLZ instruction."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121915

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


[PATCH] D122008: [flang][driver] Add support for generating executables

2022-04-13 Thread Damian Rouson via Phabricator via cfe-commits
rouson added a comment.

@awarzynski I'll echo your comment that "... most people new to LLVM Flang use 
flang rather than flang-new and most (all?) find it very confusing."  I've 
known of flang in various forms (including a flang predated classic flang) and 
yet I'm still finding new information that clears up confusion on my part.  I 
only just realized today that the phrase "LLVM flang" is used to differentiate 
from "classic flang." And although I've known about armflang for several years 
and AOCC (which seemingly should be AOCCF or some such) for a month or so, I 
only just realized today that they are based on classic flang, which finally 
makes sense because I couldn't figure out how they could be based on what is 
currently on the main branch of LLVM flang.  For users and testers, it will be 
really nice if the community coalesces around the main branch of LLVM flang as 
the default meaning when someone says "flang" and if that default flang 
produces executables even if  it's buggy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122008

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


[PATCH] D123744: [Driver] Change CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL to affect driver default instead of cc1 default

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: opaque-pointers, rsmith, aeubanks, nikic.
Herald added a subscriber: StephenFan.
Herald added a reviewer: ctetreau.
Herald added a reviewer: ctetreau.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

cc1 option default dependent on CMake options should be used prudently
(generally avoided), as they may leave large differences in code
generation tests. We generally limit the target difference to Driver.

The current CLANG_ENABLE_OPAQUE_POINTERS=on default may attract people to
contribute %clang_cc1 tests that assume ON behavior, which will cause failures
on systems set to OFF.

Change the CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL mechanism introduced in 
D123122 
to be a driver default. This is similar to the mechanism used for the
-flegacy-pass-manager transition to new PM transition.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123744

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -6506,6 +6507,9 @@
false))
 CmdArgs.push_back("-fmodules-debuginfo");
 
+  if (!CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL)
+CmdArgs.push_back("-no-opaque-pointers");
+
   ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, Inputs, CmdArgs, rewriteKind);
   RenderObjCOptions(TC, D, RawTriple, Args, Runtime, rewriteKind != RK_None,
 Input, CmdArgs);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5533,7 +5533,7 @@
 defm opaque_pointers : BoolOption<"",
   "opaque-pointers",
   CodeGenOpts<"OpaquePointers">,
-  Default<"CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL">,
+  DefaultTrue,
   PosFlag,
   NegFlag,
   BothFlags<[], " opaque pointers">>;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -29,6 +29,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Distro.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -6506,6 +6507,9 @@
false))
 CmdArgs.push_back("-fmodules-debuginfo");
 
+  if (!CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL)
+CmdArgs.push_back("-no-opaque-pointers");
+
   ObjCRuntime Runtime = AddObjCRuntimeArgs(Args, Inputs, CmdArgs, rewriteKind);
   RenderObjCOptions(TC, D, RawTriple, Args, Runtime, rewriteKind != RK_None,
 Input, CmdArgs);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5533,7 +5533,7 @@
 defm opaque_pointers : BoolOption<"",
   "opaque-pointers",
   CodeGenOpts<"OpaquePointers">,
-  Default<"CLANG_ENABLE_OPAQUE_POINTERS_INTERNAL">,
+  DefaultTrue,
   PosFlag,
   NegFlag,
   BothFlags<[], " opaque pointers">>;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-04-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D122766#3450348 , @dexonsmith 
wrote:

> - Only canonicalize `__FILE__` for the target platform when there's a 
> command-line flag that suggests it's okay. I suggest adding 
> `-ffile-reproducible`, which could be implied by `-ffile-prefix-map` but also 
> specified separately when `-ffile-prefix-map` isn't being used.

(Could also be implied by `-ffile-compilation-dir=`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122766

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


[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-04-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D122766#3450298 , @ayzhao wrote:

> So, the general consensus seems to be that we should use backslashes when 
> targeting Windows.
>
> I implemented using only backslashes for Windows; however, 
> clang/test/SemaCXX/destructor.cpp 
> 
>  fails when running on Linux with the following error (among other errors, 
> but the one below is the most important).
>
>   ...
>   error: 'error' diagnostics seen but not expected:
> Line 32: 
> '\\clang\\test\\SemaCXX\\destructor.cpp'
>  file not found
>   ...
>
> The reason for this is that the test has Clang target windows 
> 
>  and the test also has the statement #include __FILE__ 
> .
>
> One way to fix this would be to have every macro that accepts a path 
> internally convert the path to the build environment's path format, but TBH 
> I'm not sure. What do you all think?

Wow, `#include __FILE__` is kind of amazing...

It sounds like you're suggesting changing the `#include` directive to start 
canonicalizing its argument. I'm not a fan of that idea; header search is hard 
enough to reason about.

I suggest, instead:

- Only canonicalize `__FILE__` for the target platform when there's a 
command-line flag that suggests it's okay. I suggest adding 
`-ffile-reproducible`, which could be implied by `-ffile-prefix-map` but also 
specified separately when `-ffile-prefix-map` isn't being used.
- When `__FILE__` is being canonicalized, it's okay to fail on `#include 
__FILE__` if the canonicalized path doesn't work as an argument to `#include` 
in the current build environment.

This would mean that `-ffile-reproducible` makes `#include __FILE__` 
non-portable, which would be fine as long as `#include __FILE__` isn't 
load-bearing for real life usecases. My guess is that it'd be okay?

What do others think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122766

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


[PATCH] D122008: [flang][driver] Add support for generating executables

2022-04-13 Thread Damian Rouson via Phabricator via cfe-commits
rouson added a comment.

@awarzynski based on @h-vetinari's optimism about adding flags, I still like 
option 2.  If it's not possible to add flags, then I would prefer option 1.  If 
we go with option 3, then I am at least encouraged by reviewing the upstreaming 
project status links that @kiran posted in the Slack flang workspace #general 
channel.  I don't know the time required to complete the remaining tasks, but 
the following issues show 216 of 235 tasks completed with 2 in progress:

Statement Lowering Upstreaming 
: 
12 To Do/1 In Progress/30 Done

FIR Codegen Upstreaming 
: 
2 To Do/0 In Progress/81 Done

Intrinsic Lowering Upstreaming: 
:
0 To Do/0 In Progress/94 Done

FIR passes upstreaming 
:
3 To Do/1 In Progress/11 Done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122008

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


[PATCH] D67678: PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2022-04-13 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In D67678#3446526 , @rsmith wrote:

> @dexonsmith @arphaman What do we need to do to get this re-landed?

FWIW, on the PPC side, we are working on cleaning up `altivec.h` and plan to 
eventually make `-fno-lax-vector-conversions` the default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67678

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


[PATCH] D119296: KCFI sanitizer

2022-04-13 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen updated this revision to Diff 422687.
samitolvanen added a comment.

Dropped `-fsanitize-kcfi-offset` and added an error when used with 
`-fpatchable-function-entry=N,M`, where M > 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ControlFlowIntegrity.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Sanitizers.def
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/test/CodeGen/kcfi.c
  clang/test/Driver/fsanitize.c
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/MC/MCObjectFileInfo.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCObjectFileInfo.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/test/CodeGen/AArch64/kcfi-check.ll
  llvm/test/CodeGen/X86/kcfi-check.ll

Index: llvm/test/CodeGen/X86/kcfi-check.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/kcfi-check.ll
@@ -0,0 +1,29 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK:  .Ltmp0
+; CHECK-NEXT:   .section .kcfi_types,"awo",@progbits,.text
+; CHECK-NEXT:   .quad .Ltmp0
+; CHECK-NEXT:   .text
+; CHECK-NEXT:   .long 12345678
+; CHECK-NEXT:   .zero 2
+define void @f1(i8* %x) #0 prefix i32 12345678 {
+; CHECK-LABEL: f1:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:cmpl $12345678, -6(%rdi) # imm = 0xBC614E
+; CHECK-NEXT:je .Ltmp1
+; CHECK-NEXT:  .Ltmp2:
+; CHECK-NEXT:ud2
+; CHECK-NEXT:.section .kcfi_traps,"awo",@progbits,.text
+; CHECK-NEXT:.quad .Ltmp2
+; CHECK-NEXT:.text
+; CHECK-NEXT:  .Ltmp1:
+; CHECK-NEXT:retq
+  call void @llvm.kcfi.check(i8* %x, i32 12345678)
+  ret void
+}
+
+declare void @llvm.kcfi.check(i8*, i32 immarg)
+
+attributes #0 = { "kcfi" }
Index: llvm/test/CodeGen/AArch64/kcfi-check.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/kcfi-check.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "aarch64--"
+
+; CHECK:  .Ltmp0
+; CHECK-NEXT:   .section .kcfi_types,"awo",@progbits,.text
+; CHECK-NEXT:   .xword .Ltmp0
+; CHECK-NEXT:   .text
+; CHECK-NEXT:   .word 12345678
+define void @f1(i8* %x) #0 prefix i32 12345678 {
+; CHECK-LABEL: f1:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldur w16, [x0, #-4]
+; CHECK-NEXT:movk w17, #24910
+; CHECK-NEXT:movk w17, #188, lsl #16
+; CHECK-NEXT:cmp w16, w17
+; CHECK-NEXT:b.eq .Ltmp1
+; CHECK-NEXT:  .Ltmp2:
+; CHECK-NEXT:brk #0x801
+; CHECK-NEXT:.section .kcfi_traps,"awo",@progbits,.text
+; CHECK-NEXT:.xword .Ltmp2
+; CHECK-NEXT:.text
+; CHECK-NEXT:  .Ltmp1:
+; CHECK-NEXT:ret
+  call void @llvm.kcfi.check(i8* %x, i32 12345678)
+  ret void
+}
+
+declare void @llvm.kcfi.check(i8*, i32 immarg)
+
+attributes #0 = { "kcfi" }
Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1336,6 +1336,31 @@
   .addExpr(Op));
 }
 
+void X86AsmPrinter::LowerKCFI_CHECK(const MachineInstr &MI) {
+  const MachineFunction &MF = *MI.getMF();
+
+  EmitAndCountInstruction(MCInstBuilder(X86::CMP32mi)
+  .addReg(MI.getOperand(0).getReg())
+  .addImm(1)
+  .addReg(X86::NoRegister)
+  .addImm(-6)
+  .addReg(X86::NoRegister)
+  .addImm(MI.getOperand(1).getImm()));
+
+  MCSymbol *Pass = OutContext.createTempSymbol();
+  EmitAndCountInstruction(
+  MCInstBuilder(X86::JCC_1)
+  .addExpr(MCSymbolRefExpr::create(Pass, OutContext))
+  .addImm(X86::COND_E));
+
+  MCSymbol *Trap = OutContext.createTempSymbol();
+  OutStreamer->emitLabel(Trap);
+  EmitAndCountInstruction(MCInstBuilder(X86::TRAP));
+  emitKCFITrapEntry(MF, Trap);
+
+  OutStreamer->emitLabel(Pass);
+}
+
 void X86AsmPrinter::LowerASAN_CHECK_MEMACCESS(const MachineInstr &MI) {
   // FIXME: Make this work on non-ELF.
   if (!TM.getTargetTriple().isOSBinFormatELF()) {
@@ -2618,6 +2643,9 @@
 EmitAndCountInstruction(MCInstBuilder(getRetOpcode(*Subtarget)));
 return;
 
+  case X86::KCFI_CHECK:
+return LowerKCFI_CHECK(*MI);
+
   case X86::ASAN_CHECK_MEMACCESS:
 return LowerASAN_CHECK_MEMACCESS(*MI);
 
Index: llvm/l

[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-04-13 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

So, the general consensus seems to be that we should use backslashes when 
targeting Windows.

I implemented using only backslashes for Windows; however, 
clang/test/SemaCXX/destructor.cpp 

 fails when running on Linux with the following error (among other errors, but 
the one below is the most important).

  ...
  error: 'error' diagnostics seen but not expected:
Line 32: 
'\\clang\\test\\SemaCXX\\destructor.cpp'
 file not found
  ...

The reason for this is that the test has Clang target windows 

 and the test also has the statement #include __FILE__ 
.

One way to fix this would be to have every macro that accepts a path internally 
convert the path to the build environment's path format, but TBH I'm not sure. 
What do you all think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122766

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


[PATCH] D122865: [HLSL][clang][Driver] Support target profile command line option.

2022-04-13 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 422677.
python3kgae added a comment.

Code cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122865

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Driver.h
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/HLSL.cpp
  clang/lib/Driver/ToolChains/HLSL.h
  clang/lib/Driver/Types.cpp
  clang/test/lit.cfg.py
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -300,6 +300,12 @@
   EXPECT_TRUE(Res.ModeSuffix == "clang-cl");
   EXPECT_STREQ(Res.DriverMode, "--driver-mode=cl");
   EXPECT_FALSE(Res.TargetIsValid);
+
+  Res = ToolChain::getTargetAndModeFromProgramName("clang-dxc");
+  EXPECT_TRUE(Res.TargetPrefix.empty());
+  EXPECT_TRUE(Res.ModeSuffix == "clang-dxc");
+  EXPECT_STREQ(Res.DriverMode, "--driver-mode=dxc");
+  EXPECT_FALSE(Res.TargetIsValid);
 }
 
 TEST(ToolChainTest, CommandOutput) {
@@ -361,4 +367,141 @@
   EXPECT_EQ(getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)), "bar");
 }
 
+TEST(DxcModeTest, TargetProfileValidation) {
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  struct SimpleDiagnosticConsumer : public DiagnosticConsumer {
+void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+  const Diagnostic &Info) override {
+  if (DiagLevel == DiagnosticsEngine::Level::Error) {
+Errors.emplace_back();
+Info.FormatDiagnostic(Errors.back());
+  } else {
+Msgs.emplace_back();
+Info.FormatDiagnostic(Msgs.back());
+  }
+}
+void clear() override {
+  Msgs.clear();
+  Errors.clear();
+  DiagnosticConsumer::clear();
+}
+std::vector> Msgs;
+std::vector> Errors;
+  };
+
+  IntrusiveRefCntPtr InMemoryFileSystem(
+  new llvm::vfs::InMemoryFileSystem);
+
+  InMemoryFileSystem->addFile("foo.hlsl", 0,
+  llvm::MemoryBuffer::getMemBuffer("\n"));
+
+  auto *DiagConsumer = new SimpleDiagnosticConsumer;
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagConsumer);
+  Driver TheDriver("/bin/clang", "", Diags, "", InMemoryFileSystem);
+  std::unique_ptr C(
+  TheDriver.BuildCompilation({"clang", "--driver-mode=dxc", "foo.hlsl"}));
+  EXPECT_TRUE(C);
+  EXPECT_TRUE(!C->containsError());
+
+  auto &TC = C->getDefaultToolChain();
+  bool ContainsError = false;
+  auto Args = TheDriver.ParseArgStrings({"-Tvs_6_0"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  auto Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.0-vertex");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Ths_6_1"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.1-hull");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tds_6_2"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.2-domain");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tds_6_2"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.2-domain");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tgs_6_3"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.3-geometry");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tps_6_4"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.4-pixel");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tcs_6_5"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.5-compute");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tms_6_6"}, false, ContainsError);
+  EXPECT_FALSE(ContainsError);
+  Triple = TC.ComputeEffectiveClangTriple(Args);
+  EXPECT_STREQ(Triple.c_str(), "dxil--shadermodel6.6-mesh");
+  EXPECT_EQ(Diags.getNumErrors(), 0);
+
+  Args = TheDriver.ParseArgStrings({"-Tas_6_7"}, false, ContainsError);
+  EXPEC

[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-04-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:133-136
-(isKeywordWithCondition(*Line.First) ||
- CurrentToken->getStartOfNonWhitespace() ==
- 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
- -1)))

Can you split it to a separate patch? Unlike the rest of this patch, it's 
likely to get accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121756

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


[PATCH] D123682: [clang-tblgen] Automatically document options values

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added subscribers: dexonsmith, aaron.ballman.
MaskRay added a comment.

  cd clang
  path/to/clang-tblgen --gen-opt-docs -I ../llvm/include -I 
include/clang/Driver include/clang/Driver/ClangOptionDocs.td > /tmp/0
  nvim -d docs/ClangCommandLineReference.rst /tmp/0

Hope a native speaker (@aaron.ballman @dexonsmith ) can suggest the usage here.

For an option with more than 2 choices: the current documentation is ` can 
be one of 'return', 'branch', 'full' or 'none'`,
I'm thinking of: ` should be 'return', 'branch', 'full', or 'none'`

When there are two choices (`-gsplit-dwarf=`), currently the documentation 
is ` can be one of 'split' or 'single'.`
I am thinking of ` should be 'split' or 'single'.`




Comment at: clang/utils/TableGen/ClangOptionDocEmitter.cpp:241
 
+static StringRef DefaultMetaVarName = "";
+

constexpr StringLiteral

const variable at a namespace scope is automatically internal linkage, except 
some weird corner cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123682

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


[PATCH] D122008: [flang][driver] Add support for generating executables

2022-04-13 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added a comment.

Speaking as a relative outside (but who's been waiting for flang in LLVM since 
well before it joined the monorepo), I'd much prefer 
code-generation-with-rough-edges in LLVM 15 (to start testing and raising 
eventual bugs), rather than a more polished flang (realistically still with 
bugs that need to be shaken out) in LLVM 16.

I can understand why Option 2 would be more attractive for those not wanting to 
attract too much attention yet (and shouldn't be a blocker for my purposes), 
hence I looked a bit into:

In D122008#3448529 , @awarzynski 
wrote:

> I investigated a bit and discovered that internally CMake calls try_compile 
> 
>  (CMake docs ). 
> I don't see  any way to pass custom compiler options there (i.e. 
> `try_compile` expects `flang-new file.f90` to just work). This makes me 
> rather hesitant to pursue Option 2 at all.

I'd be more than a little surprised that there's no way to do this. Have you 
tried CMAKE_Fortran_FLAGS 
? AFAICT, 
the environment variables should be respected. After a bit of googling, a very 
similar issue came up 
  
already at least 15 years ago, and here's a recent SO answer 
 
about it. Worst case, one can always ask on the CMake discourse 
, people are very helpful and responsive in my 
experience.

Given that Option 2 might be the path of highest consensus, I think it would be 
worth a bit more investigation if it's really impossible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122008

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


[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-04-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Please see D123741 . It should make it easier 
to see if you are making NFC changes at other places as well.




Comment at: clang/lib/Format/TokenAnnotator.cpp:252-256
+} else if (OpeningParen.isConditionLParen(/*IncludeFor=*/false) ||
+   (OpeningParen.Previous &&
+OpeningParen.Previous->isOneOf(TT_BinaryOperator, tok::l_paren,
+   tok::comma,
+   tok::kw_static_assert))) {

sstwcw wrote:
> owenpan wrote:
> > owenpan wrote:
> > > I don't think this is NFC.
> > > Before:
> > > ```
> > > } else if (OpeningParen.Previous &&
> > >(OpeningParen.Previous->isOneOf(tok::kw_static_assert,
> > >tok::kw_while, 
> > > tok::l_paren,
> > >tok::comma, tok::kw_if,
> > >TT_BinaryOperator) ||
> > > OpeningParen.Previous->endsSequence(tok::kw_constexpr,
> > > tok::kw_if) ||
> > > OpeningParen.Previous->endsSequence(tok::identifier,
> > > tok::kw_if))) {
> > > ```
> > > After:
> > > ```
> > > } else if ((OpeningParen.is(tok::l_paren) &&
> > > OpeningParen.is(TT_ConditionLParen)) ||
> > >// PreviousNonComment = 
> > > OpeningParen.getPreviousNonComment()
> > >(PreviousNonComment &&
> > > PreviousNonComment->isOneOf(tok::kw_if, tok::kw_while,
> > > tok::kw_switch, tok::kw_case,
> > > tok::kw_constexpr)) ||
> > >(OpeningParen.Previous &&
> > > OpeningParen.Previous->isOneOf(tok::kw_static_assert,
> > >tok::l_paren, tok::comma,
> > >TT_BinaryOperator))) {
> > > ```
> > > After:
> > > ```
> > > } else if ((OpeningParen.is(tok::l_paren) &&
> > > OpeningParen.is(TT_ConditionLParen)) ||
> > > ...
> > > tok::kw_constexpr)) ||
> > >...
> > > ```
> > 
> > After:
> > ```
> > } else if ((OpeningParen.is(tok::l_paren) &&
> > (OpeningParen.is(TT_ConditionLParen) ||
> > ...
> >  tok::kw_constexpr ||
> >...
> > ```
> I removed NFC from the title.  It would affect things like this:
> 
> ```
> new:
> switch (x * x)
> old:
> switch (x *x)
> ```
> However the entire llvm codebase doesn't seem to have such things.
Nevertheless, your example is valid C++ and may exists in other codebases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121756

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


[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

It seems surprising to me for the diagnostic to change from warn-by-default to 
error-by-default when changing from C99 to C11, given that the language rule 
did not change between C99 and C11 (as a Clang user, when changing my `-std=` 
flag, I don't want other changes to come in that are unrelated to the language 
mode change I requested). I think we should just make this an error by default 
in C99 onwards; if we're happy promoting this from warning-by-default to 
error-by-default for the folks using `-std=c11` and later (and I think we are), 
then we should be happy doing the same for the `-std=c99` folks too -- 
especially given that C17 is the default everywhere other than on PS4.




Comment at: clang/lib/Sema/SemaDecl.cpp:15269
   if (II.getName().startswith("__builtin_"))
 diag_id = diag::warn_builtin_unknown;
   // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.

For consistency, this case should be an `ExtWarn`, not just a `Warning`, in C99 
onwards (and an `Error` in C2x, which it will be because we don't get here in 
that case). But given that this is within the implementation namespace and it's 
currently a `DefaultError`, perhaps we should instead fully replace this 
`Warning` with an `Error` in all language modes?


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

https://reviews.llvm.org/D122983

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


[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

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

FWIW I interpreted dexonsmith's resign from the patch as his ambivalence or 
minor objection to the direction, otherwise I'd expect a LGTM.


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

https://reviews.llvm.org/D121560

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


[PATCH] D121560: [clang][Opt] Add NoArgUnusedWith to not warn for unused redundant options

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

In D121560#3448733 , @abrachet wrote:

> In D121560#3439570 , @MaskRay wrote:
>
>> If you need a -static-libstdc++ not subject to unused argument warning, 
>> --start-no-unused-arguments and D53238  
>> (-static=c++stdlib) may be better choices.
>
> That patch might help for `-static-libstdc++` in particular and other 
> -static-* flags, however there are other flags that this will help with in 
> the future. What about `-nostdlib -noprofilelib`. I'm currently only 
> interested with `-nostdlib` and haven't looked into other flags but I suspect 
> this could help in other instances too. Could be helpful with sanitizers too, 
> but all their flags get read into SanitizerArgs so there are never warnings 
> there.
>
> I don't think --start-no-unused arguments is as good as a solution here. For 
> a large project build, I think `--{start,end}-no-unused-arguments` is too 
> heavy a hand. You would just end up putting it everywhere and lose any 
> warnings that might be useful. This patch is specifically trying to reduce 
> the need for those.

I have run into situation where I find the unused argument warning for 
`-nostdlib` is inconvenient (musl clang wrapper), but I can think of users who 
actually want to the diagnostic.
I am concerned that the decision suitable for your use case may not be desired 
by other groups.
This is why I'd like keep suggesting `--start-no-unused-arguments`: it encodes 
the intention clearly and cannot get in the way of others while achieving your 
goals.
It's just longer, less ergonomic.


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

https://reviews.llvm.org/D121560

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


[PATCH] D123642: [clang codegen] Assume arguments of __atomic_* are aligned.

2022-04-13 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added subscribers: jwakely, jakubjelinek, msebor.
xbolva00 added a comment.

>> IMO, it is basically a historical bug in GCC that it ignores the type 
>> alignment

Do you have any comments related to this issue by gcc devs that this is a 
"known" bug?

cc @jakubjelinek @msebor @jwakely


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123642

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


[PATCH] D123649: Allow flexible array initialization in C++.

2022-04-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 422671.
efriedma added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123649

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGenCXX/flexible-array-init.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp

Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2383,9 +2383,11 @@
   static_assert(b[2].x == 3, "");
   static_assert(b[2].arr[0], ""); // expected-error {{constant expression}} expected-note {{array member without known bound}}
 
-  // If we ever start to accept this, we'll need to ensure we can
-  // constant-evaluate it properly.
-  constexpr A c = {1, 2, 3}; // expected-error {{initialization of flexible array member}}
+  // Flexible array initialization is currently not supported by constant
+  // evaluation. Make sure we emit an error message, for now.
+  constexpr A c = {1, 2, 3}; // expected-error {{constexpr variable 'c' must be initialized by a constant expression}}
+  // expected-note@-1 {{flexible array initialization is not yet supported}}
+  // expected-warning@-2 {{flexible array initialization is a GNU extension}}
 }
 
 void local_constexpr_var() {
Index: clang/test/CodeGenCXX/flexible-array-init.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/flexible-array-init.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-only -verify -DFAIL1 %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-only -verify -DFAIL2 %s
+
+struct A { int x; int y[]; };
+A a = { 1, 7, 11 };
+// CHECK: @a ={{.*}} global { i32, [2 x i32] } { i32 1, [2 x i32] [i32 7, i32 11] }
+
+A b = { 1, { 13, 15 } };
+// CHECK: @b ={{.*}} global { i32, [2 x i32] } { i32 1, [2 x i32] [i32 13, i32 15] }
+
+int f();
+#ifdef FAIL1
+A c = { f(), { f(), f() } }; // expected-error {{cannot compile this flexible array initializer yet}}
+#endif
+#ifdef FAIL2
+void g() {
+  static A d = { f(), { f(), f() } }; // expected-error {{cannot compile this flexible array initializer yet}}
+}
+#endif
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2004,10 +2004,6 @@
   cast(InitExpr)->getNumInits() == 0) {
 // Empty flexible array init always allowed as an extension
 FlexArrayDiag = diag::ext_flexible_array_init;
-  } else if (SemaRef.getLangOpts().CPlusPlus) {
-// Disallow flexible array init in C++; it is not required for gcc
-// compatibility, and it needs work to IRGen correctly in general.
-FlexArrayDiag = diag::err_flexible_array_init;
   } else if (!TopLevelObject) {
 // Disallow flexible array init on non-top-level object
 FlexArrayDiag = diag::err_flexible_array_init;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4615,6 +4615,8 @@
 T = D->getType();
 
   if (getLangOpts().CPlusPlus) {
+if (!InitDecl->getFlexibleArrayInitChars(getContext()).isZero())
+  ErrorUnsupported(D, "flexible array initializer");
 Init = EmitNullConstant(T);
 NeedsGlobalCtor = true;
   } else {
@@ -4628,6 +4630,14 @@
   // also don't need to register a destructor.
   if (getLangOpts().CPlusPlus && !NeedsGlobalDtor)
 DelayedCXXInitPosition.erase(D);
+
+#ifndef NDEBUG
+  CharUnits VarSize = getContext().getTypeSizeInChars(ASTTy) +
+  InitDecl->getFlexibleArrayInitChars(getContext());
+  CharUnits CstSize = CharUnits::fromQuantity(
+  getDataLayout().getTypeAllocSize(Init->getType()));
+  assert(VarSize == CstSize && "Emitted constant has unexpected size");
+#endif
 }
   }
 
Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -342,6 +342,8 @@
   if (!Init) {
 if (!getLangOpts().CPlusPlus)
   CGM.ErrorUnsupported(D.getInit(), "constant l-value expression");
+else if (!D.getFlexibleArrayInitChars(getContext()).isZero())
+  CGM.ErrorUnsupported(D.getInit(), "flexible array initializer");
 else if (HaveInsertPoint()) {
   // Since we have a static initializer, this global variable can't

[PATCH] D123642: [clang codegen] Assume arguments of __atomic_* are aligned.

2022-04-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> I disagree with this on principle -- IMO, it is basically a historical bug in 
> GCC that it ignores the type alignment, and we should NOT try to match that 
> -- it's dangerous.

gcc has always behaved this way, and I don't see any indication they intend to 
change it.  I mean, you can call it a bug, but at the end of the day the bug 
reports will land in our bugtracker, not gcc's.

> As a workaround: add alignas(uint64_t) to the affected struct in lld. (is 
> GHashCell the only one?)

I think that's the only one, at least according to `git grep std::atomic`; I 
guess that works.  (Assuming you meant `alignas(sizeof(uint64_t))`.)

> Ask GCC to modify libstdc++ so that `__builtin_addressof` is called directly, 
> instead of going through `std::__addressof`.

Even if gcc did this today, it would take years to reach people on Linux.

I guess this is motivation to implement namespaced builtins...?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123642

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


[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-04-13 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thanks for working on this!




Comment at: clang/include/clang/AST/DeclBase.h:228
 
+/// This declaration has an owninig module, and is visible to lookups
+/// that occurs within that module. And it is reachable to other module





Comment at: clang/include/clang/AST/DeclBase.h:230
+/// that occurs within that module. And it is reachable to other module
+/// when the owninig module is imported.
+ReachableWhenImported,





Comment at: clang/lib/Sema/SemaLookup.cpp:1589
+  llvm::SmallVectorImpl *Modules,
+  bool RequireReachable = false) {
   if (!D->hasDefaultArgument())

I think this should be `AllowReachable` not `RequireReachable`, since what it 
means is "allow default arguments that are reachable but not visible".

But more generally I'd like to see this `bool` replaced by an `enum`, eg:

```
enum class AcceptableKind { Visible, Reachable };
```

... and rename functions like this that take the `enum` to 
`hasAcceptableDefaultArgument`. It'd be nice to still provide `hasVisibleFoo` 
and `hasReachableFoo` as simple wrappers around the function that has the 
`enum` parameter to make the call sites more readable, but we should try to not 
duplicate the definitions of these functions.



Comment at: clang/lib/Sema/SemaLookup.cpp:1596-1599
+  if (S.isVisible(D))
+return true;
+  if (RequireReachable && S.hasReachableDeclaration(D))
+return true;

There's no need to check both visibility and reachability here.

Also, you shouldn't be asking whether `D` has any reachable redeclaration; you 
should be asking whether `D` itself is reachable.

What I'd really like to see here is:

```
if (S.isAcceptable(D, Kind))
```

with a `Sema::isAcceptable(const Decl *D, AcceptableKind Kind)`



Comment at: clang/lib/Sema/SemaLookup.cpp:1625-1627
+  // It is meaningless to talk about reachable if we are not in C++20 modules.
+  if (!getLangOpts().CPlusPlusModules)
+return hasVisibleDefaultArgument(D, Modules);

Please remove this check: we should define what "reachable" means for module 
map modules, even if we define it as being the same as "visible", rather than 
adding special cases that try to distinguish the two modes. We support 
combining module map modules and C++ modules in the same compilation, so we 
need a semantic model that supports both at once.



Comment at: clang/lib/Sema/SemaLookup.cpp:1650-1654
 if (S.isVisible(R))
   return true;
 
+if (RequireReachable && S.hasReachableDeclaration(R))
+  return true;

As previously, it's redundant to check both. (And if there were somehow a 
declaration that was visible but not reachable, this would be wrong -- but that 
should never happen.)



Comment at: clang/lib/Sema/SemaLookup.cpp:1669-1734
 bool Sema::hasVisibleExplicitSpecialization(
 const NamedDecl *D, llvm::SmallVectorImpl *Modules) {
   return hasVisibleDeclarationImpl(*this, D, Modules, [](const NamedDecl *D) {
 if (auto *RD = dyn_cast(D))
   return RD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization;
 if (auto *FD = dyn_cast(D))
   return FD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization;

I don't like duplicating this code for the reachable / visible checks. Instead, 
please add a parameter for the kind (visible / reachable).



Comment at: clang/lib/Sema/SemaLookup.cpp:1831-1832
+  // case, the global module fragment shouldn't own an AST File.
+  if (M->isGlobalModule() && M->getASTFile())
+return false;
+

This is wrong; whether the declaration came from an AST file is irrelevant. 
Keep in mind that declarations in the same source file may come from an AST 
file if we're using a PCH, and declarations in a different source file may 
*not* come from an AST file if parse multiple source files into the same 
`ASTContext`. What we need to check here is whether `M` is the global module 
fragment of the current source file.



Comment at: clang/lib/Sema/SemaLookup.cpp:2000-2004
+  // Class and enumeration member names can be found by name lookup in any
+  // context in which a definition of the type is reachable.
+  if (auto *ECD = dyn_cast(ND))
+return getSema().hasReachableDeclaration(
+cast(ECD->getDeclContext()));

I don't think this is quite right. Given:

```
export module M {
export enum E1 { e1 };
enum E2 { e2 };
export using E2U = E2;
enum E3 { e3 };
export E3 f();
```

... the intent is:

```
import M;
int main() {
  auto a = E1::e1; // OK, namespace-scope name E1 is visible and e1 is reachable
  auto b = e1; // OK, namespace-scope name e1 is visible
  auto c = E2::e2; // error, namespace-sc

[PATCH] D123737: [clang-format] Skip preprocessor lines when finding the record lbrace

2022-04-13 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

With D117142 , we would now format

  struct A {
  #define A
void f() { a(); }
  #endif
  };

into

  struct A {
  #ifdef A
void f() {
  a();
}
  #endif
  };

because we were looking for the record lbrace without skipping preprocess lines.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123737

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12766,6 +12766,13 @@
"};",
MergeInlineOnly);
 
+  verifyFormat("class C {\n"
+   "#ifdef A\n"
+   "  int f() { return 42; }\n"
+   "#endif\n"
+   "};",
+   MergeInlineOnly);
+
   // Also verify behavior when BraceWrapping.AfterFunction = true
   MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
   MergeInlineOnly.BraceWrapping.AfterFunction = true;
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -308,7 +308,7 @@
   // Find the last line with lower level.
   auto J = I - 1;
   for (; J != AnnotatedLines.begin(); --J)
-if ((*J)->Level < TheLine->Level)
+if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
   break;
   if ((*J)->Level >= TheLine->Level)
 return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12766,6 +12766,13 @@
"};",
MergeInlineOnly);
 
+  verifyFormat("class C {\n"
+   "#ifdef A\n"
+   "  int f() { return 42; }\n"
+   "#endif\n"
+   "};",
+   MergeInlineOnly);
+
   // Also verify behavior when BraceWrapping.AfterFunction = true
   MergeInlineOnly.BreakBeforeBraces = FormatStyle::BS_Custom;
   MergeInlineOnly.BraceWrapping.AfterFunction = true;
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -308,7 +308,7 @@
   // Find the last line with lower level.
   auto J = I - 1;
   for (; J != AnnotatedLines.begin(); --J)
-if ((*J)->Level < TheLine->Level)
+if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
   break;
   if ((*J)->Level >= TheLine->Level)
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D123533: [clang][extract-api] Add support for true anonymous enums

2022-04-13 Thread Daniel Grumberg 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 rG7443a504bf6c: [clang][extract-api] Add support for true 
anonymous enums (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123533

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/test/ExtractAPI/enum.c

Index: clang/test/ExtractAPI/enum.c
===
--- clang/test/ExtractAPI/enum.c
+++ clang/test/ExtractAPI/enum.c
@@ -30,6 +30,14 @@
   West
 };
 
+enum {
+  Constant = 1
+};
+
+enum {
+  OtherConstant = 2
+};
+
 //--- reference.output.json.in
 {
   "metadata": {
@@ -100,6 +108,16 @@
   "kind": "memberOf",
   "source": "c:@E@Direction@West",
   "target": "c:@E@Direction"
+},
+{
+  "kind": "memberOf",
+  "source": "c:@Ea@Constant@Constant",
+  "target": "c:@Ea@Constant"
+},
+{
+  "kind": "memberOf",
+  "source": "c:@Ea@OtherConstant@OtherConstant",
+  "target": "c:@Ea@OtherConstant"
 }
   ],
   "symbols": [
@@ -641,6 +659,182 @@
 "Direction",
 "West"
   ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "enum"
+},
+{
+  "kind": "text",
+  "spelling": ": "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:i",
+  "spelling": "unsigned int"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@Ea@Constant"
+  },
+  "kind": {
+"displayName": "Enumeration",
+"identifier": "c.enum"
+  },
+  "location": {
+"position": {
+  "character": 1,
+  "line": 17
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "(anonymous)"
+  }
+],
+"title": "(anonymous)"
+  },
+  "pathComponents": [
+"(anonymous)"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "identifier",
+  "spelling": "Constant"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@Ea@Constant@Constant"
+  },
+  "kind": {
+"displayName": "Enumeration Case",
+"identifier": "c.enum.case"
+  },
+  "location": {
+"position": {
+  "character": 3,
+  "line": 18
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Constant"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Constant"
+  }
+],
+"title": "Constant"
+  },
+  "pathComponents": [
+"(anonymous)",
+"Constant"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "enum"
+},
+{
+  "kind": "text",
+  "spelling": ": "
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:i",
+  "spelling": "unsigned int"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@Ea@OtherConstant"
+  },
+  "kind": {
+"displayName": "Enumeration",
+"identifier": "c.enum"
+  },
+  "location": {
+"position": {
+  "character": 1,
+  "line": 21
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "(anonymous)"
+  }
+],
+"title": "(anonymous)"
+  },
+  "pathComponents": [
+"(anonymous)"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "identifier",
+  "spelling": "OtherConstant"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c",
+"precise": "c:@Ea@OtherConstant@OtherConstant"
+  },
+  "kind": {
+"displayName": "Enumeration Case",
+"identifier": "c.enum.case"
+  },
+  "location": {
+"position": {
+  "character": 3,
+  "line": 22
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Ot

[clang] c729d5b - [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-04-13T23:07:39+02:00
New Revision: c729d5be781a8e80137c11ab28aa14d9ace148db

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

LOG: [clang] Implement Change scope of lambda trailing-return-type

Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start
of the body would  be parsed in the parent scope, such that
captures would not be available to look up.

The scoping is changed to have an outer lambda scope,
followed by the lambda prototype and body.

The lambda scope is necessary because there may be a template scope
between the start of the lambda (to which we want to attach
the captured variable) and the prototype scope.

We also need to introduce a declaration context to attach the captured
variable to (and several parts of clang assume captures are handled from
the call operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope
* Introduce a lambda scope
* Create the lambda class and call operator
* Add the init captures to the call operator context and the lambda scope.
  But the variables are not capured yet (because we don't know their type).
  Instead, explicit  captures are stored in a temporary map that
  conserves the order of capture (for the purpose of having a stable order in 
the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected 
the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses 
in the parent context,
  we couldn't mangle a lambda that is attached to the context of a lambda whose 
type is not yet known).

* The lambda qualifiers are parsed, at this point,
  we can switch (for the second time) inside the lambda context,
  unset the flag indicating that we have not parsed the lambda qualifiers,
  record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call 
operator's types and also
  transform the call operator to a template function decl where necessary.

At this point, both captures and parameters can be injected in the body's scope.
When trying to capture an implicit variable, if we are before the qualifiers of 
a lambda,
we need to remember that the variables are still in the parent's context 
(rather than in the call operator's).

This is a recommit of adff142dc2 after a fix in d8d793f29b4

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

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

Added: 
clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Scope.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 91fc57dfac595..016aafee016c2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -247,6 +247,9 @@ C++2b Feature Support
 - Implemented `P2128R6: Multidimensional subscript operator 
`_.
 - Implemented `P0849R8: auto(x): decay-copy in the language 
`_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in 
constexpr functions`_.
+- Implemented `P2036R3: Change scope of lambda trailing-return-type 
`_.
+  This proposal modifies how variables captured in lambdas can appear in 
trailing return type
+  expressions and how their types are deduced therein, in all C++ language 
versions.
 
 CUDA Language Changes in Clang
 --

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 04a9daa14e05e..c640f7f7ba63f 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1799,6 +1799,20 @@ class CXXRecordDecl : public RecordDecl {
 return getLambdaData().MethodTyInfo;
   }
 
+  void setLambdaTypeInfo(TypeSourceInfo *TS) {
+auto *DD = DefinitionData;
+as

[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 422643.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

Update based on review feedback.

- Removed a typo correction note so that we don't recommend a previous 
declaration which was implicitly declared
- Removed several -std=c99 options from various RUN lines; other updates to 
tests


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

https://reviews.llvm.org/D122983

Files:
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/Analysis/OSAtomic_mac.c
  clang/test/Analysis/ObjCProperties.m
  clang/test/Analysis/PR49642.c
  clang/test/Analysis/diagnostics/no-store-func-path-notes.c
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/novoidtypecrash.c
  clang/test/Analysis/plist-macros-with-expansion.c
  clang/test/CodeGen/2002-07-14-MiscTests3.c
  clang/test/CodeGen/2002-07-31-SubregFailure.c
  clang/test/CodeGen/2003-08-18-SigSetJmp.c
  clang/test/CodeGen/2004-11-27-StaticFunctionRedeclare.c
  clang/test/CodeGen/2005-01-02-ConstantInits.c
  clang/test/CodeGen/2005-01-02-VAArgError-ICE.c
  clang/test/CodeGen/2006-01-13-StackSave.c
  clang/test/CodeGen/2006-03-03-MissingInitializer.c
  clang/test/CodeGen/2008-05-12-TempUsedBeforeDef.c
  clang/test/CodeGen/2008-07-30-redef-of-bitcasted-decl.c
  clang/test/CodeGen/2008-08-19-cast-of-typedef.c
  clang/test/CodeGen/2008-10-13-FrontendCrash.c
  clang/test/CodeGen/PowerPC/builtins-ppc-p8vector.c
  clang/test/CodeGen/X86/bmi2-builtins.c
  clang/test/CodeGen/aarch64-mops.c
  clang/test/CodeGen/aarch64-neon-sm4-sm3.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/attribute_constructor.c
  clang/test/CodeGen/builtins-arm-microsoft.c
  clang/test/CodeGen/builtins-arm-msvc-compat-only.c
  clang/test/CodeGen/cast-emit.c
  clang/test/CodeGen/debug-info-block-vars.c
  clang/test/CodeGen/debug-info-crash.c
  clang/test/CodeGen/decl.c
  clang/test/CodeGen/init-with-member-expr.c
  clang/test/CodeGen/misaligned-param.c
  clang/test/CodeGen/neon-crypto.c
  clang/test/CodeGen/struct-comma.c
  clang/test/CodeGen/variable-array.c
  clang/test/Frontend/warning-mapping-2.c
  clang/test/Headers/arm-cmse-header-ns.c
  clang/test/Import/objc-arc/test-cleanup-object.m
  clang/test/Modules/config_macros.m
  clang/test/Modules/modulemap-locations.m
  clang/test/OpenMP/declare_mapper_messages.c
  clang/test/PCH/chain-macro-override.c
  clang/test/Rewriter/rewrite-foreach-2.m
  clang/test/Rewriter/rewrite-try-catch.m
  clang/test/Sema/__try.c
  clang/test/Sema/aarch64-tme-errors.c
  clang/test/Sema/arm-no-fp16.c
  clang/test/Sema/bitfield.c
  clang/test/Sema/builtin-setjmp.c
  clang/test/Sema/builtins.c
  clang/test/Sema/cxx-as-c.c
  clang/test/Sema/implicit-builtin-decl.c
  clang/test/Sema/implicit-decl.c
  clang/test/Sema/implicit-ms-builtin-decl.c
  clang/test/Sema/typo-correction.c
  clang/test/Sema/vla.c
  clang/test/Sema/warn-strict-prototypes.c
  clang/test/SemaOpenCL/arm-integer-dot-product.cl
  clang/test/SemaOpenCL/clang-builtin-version.cl
  clang/test/SemaOpenCL/to_addr_builtin.cl
  clang/test/VFS/module_missing_vfs.m
  compiler-rt/test/safestack/pthread-cleanup.c

Index: compiler-rt/test/safestack/pthread-cleanup.c
===
--- compiler-rt/test/safestack/pthread-cleanup.c
+++ compiler-rt/test/safestack/pthread-cleanup.c
@@ -17,6 +17,8 @@
   return buffer;
 }
 
+extern unsigned sleep(unsigned seconds);
+
 int main(int argc, char **argv)
 {
   int arg = atoi(argv[1]);
Index: clang/test/VFS/module_missing_vfs.m
===
--- clang/test/VFS/module_missing_vfs.m
+++ clang/test/VFS/module_missing_vfs.m
@@ -1,12 +1,12 @@
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: echo "void funcA(void);" >> %t/a.h
 
-// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
+// RUN: not %clang_cc1 -std=c99 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
 // ERROR: virtual filesystem overlay file '{{.*}}' not found
 // RUN: find %t/mcp -name "A-*.pcm" | count 1
 
 // RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/MissingVFS/vfsoverlay.yaml > %t/vfs.yaml
-// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml
+// RUN: %clang_cc1 -std=c99 -f

[PATCH] D122983: [C11/C2x] Change the behavior of the implicit function declaration warning

2022-04-13 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 10 inline comments as done.
aaron.ballman added a comment.

Thank you for the thorough double-check on the test changes, @jyknight! I was 
able to remove most of the ones you called out (I commented where I couldn't) 
plus a few more `-std=c99` from RUN lines, but there are quite a few left 
because it's entirely unclear what the test is actually testing (especially in 
CodeGen tests -- we have these RUN lines but they don't check anything, so I'm 
assuming these are "don't crash" tests reduced from user code, so I left the 
-std=c99 for them).




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c:76
 
 void pointeeConverison(int *IP, double *DP) { pointeeConversion(DP, IP); }
 // NO-WARN: Even though this is possible in C, a swap is diagnosed by the 
compiler.

jyknight wrote:
> This is just a typo, you won't need the -std=c99 on this test if you fix 
> pointeeConverison -> pointeeConversion
Good catch, I'll fix this up in an NFC change.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:423-426
+def ext_implicit_function_decl_c11 : ExtWarn<
+  "implicit declaration of function %0 is invalid in C99 and later and "
+  "unsupported in C2x">,
+  InGroup, DefaultError;

jyknight wrote:
> I think it'd be good to use the same message for both variants. (Even if 
> you're building in c99, might as well note it's gone in C2x).
Heh, I waffled on doing exactly that, so I'm glad for this feedback!



Comment at: clang/test/CodeGen/misaligned-param.c:1
-// RUN: %clang_cc1 %s -triple i386-apple-darwin -emit-llvm -o - | FileCheck %s
 // Misaligned parameter must be memcpy'd to correctly aligned temporary.

jyknight wrote:
> Declare `int bar(struct s*, struct s*);` instead
Good catch; I think I was worried this was intending to test the function call, 
which is why I added the `-std=c89`.



Comment at: clang/test/Sema/implicit-decl.c:30
+  __builtin_is_les(1, 3); // expected-error{{use of unknown builtin 
'__builtin_is_les'}} \
+ c2x-error {{unknown type name '__builtin_is_les'; 
did you mean '__builtin_va_list'?}} \
+ c2x-error {{expected identifier or '('}} \

jyknight wrote:
> Yikes! That's a particularly awful typo-fix suggestion. I assume from those 
> messages, it decided this should be a function declaration instead of a call, 
> and is parsing as a function declaration?
> 
> I'd say that's unrelated to this change, EXCEPT, that doesn't happen in C++ 
> mode. So I'm guessing there's some weird interaction here that triggers ONLY 
> in the C mode of the parser, which causes it to prefer to parse unknown 
> identifiers as a type name instead of a variable/function name (on the 
> assumption that implicit function decls exist, and would've triggered 
> already, if relevant, perhaps?).
> Yikes! That's a particularly awful typo-fix suggestion. I assume from those 
> messages, it decided this should be a function declaration instead of a call, 
> and is parsing as a function declaration?

That's correct.

> I'd say that's unrelated to this change, EXCEPT, that doesn't happen in C++ 
> mode. So I'm guessing there's some weird interaction here that triggers ONLY 
> in the C mode of the parser, which causes it to prefer to parse unknown 
> identifiers as a type name instead of a variable/function name (on the 
> assumption that implicit function decls exist, and would've triggered 
> already, if relevant, perhaps?).

That seems to be correct. It appears we get into this state because of implicit 
int. So I'd like to leave this alone for now and try to revisit later when I 
try to treat implicit int similar to what I've done in this patch for implicit 
function declarations.



Comment at: clang/test/VFS/module_missing_vfs.m:2
 // RUN: rm -rf %t && mkdir -p %t
 // RUN: echo "void funcA(void);" >> %t/a.h
 

jyknight wrote:
> I can't quite follow what this test is doing, but it looks like it does 
> intend to have a prototype available?
Yeah, I struggled mightily to figure out what this test was doing and 
eventually gave up. I *think* the behavior of the test is that it's putting the 
declaration in a.h and then overlaying with an a.h (in Inputs/MissingVFS) that 
does not have the declaration, and demonstrating that you can still call it? 
But I honestly don't know.


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

https://reviews.llvm.org/D122983

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


[PATCH] D123636: [randstruct] Add test for "-frandomize-layout-seed-file" flag

2022-04-13 Thread Bill Wendling via Phabricator via cfe-commits
void added inline comments.



Comment at: clang/unittests/AST/RandstructTest.cpp:56
+  llvm::SmallString<256> SeedFilename;
+  EXPECT_FALSE(llvm::sys::fs::createTemporaryFile("seed", "rng", SeedFileFD,
+  SeedFilename));

aaron.ballman wrote:
> I think this is a case where you want to use `ASSERT_FALSE` because if this 
> fails, the rest of the test also fails.
There's an explanation below.



Comment at: clang/unittests/AST/RandstructTest.cpp:72
+
+  return std::tuple(AST.release(), 
ASTFileSeed.release());
+};

aaron.ballman wrote:
> Why not keep these as unique pointers and move them into the tuple? Then the 
> callers don't have to call delete manually.
The d'tors for the `unique_ptr`s is called if I place them in the tuple. I 
think it's because I can't do something like this:

```
const unique_ptr std::tie(AST, ASTFileSeed) = makeAST(...);
```

in the test functions. When I assign it as a non-initializer, it apparently 
calls the d'tor. So, kinda stumped on what to do.

And the `EXPECT_FALSE` above is used because the `ASSERT_FALSE` adds an extra 
return point, which messes with the lambda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123636

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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp:76
+void temp() {
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container

sammccall wrote:
> This case will always be an error, but isn't diagnosed until you see an 
> instantiation.
> 
> If it's important to catch these standalone e.g. when analyzing headers, you 
> could adapt the matcher like:
> 
> ```
> hasUnqualifiedDesugaredType(anyOf(
>   recordDecl(...), // current case
>   templateSpecializationType( // when dependent, TST is canonical
> templateArgumentCountIs(1), // std::vector
> hasTemplateArgument(0, refersToType(qualType(isConstQualified(
>   )
> ))
> ```
Thanks for Sam's offline help! Incorporated this to the matcher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 422640.
MaskRay added a comment.

improve test.
mention in the diagnostic this is a deprecated libc++ extension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

Files:
  clang-tools-extra/clang-tidy/portability/CMakeLists.txt
  clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
  clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-std-allocator-const %t --
+
+namespace std {
+typedef unsigned size_t;
+
+template 
+class allocator {};
+template 
+class hash {};
+template 
+class equal_to {};
+template 
+class less {};
+
+template >
+class deque {};
+template >
+class forward_list {};
+template >
+class list {};
+template >
+class vector {};
+
+template , class A = std::allocator>
+class multiset {};
+template , class A = std::allocator>
+class set {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_multiset {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_set {};
+
+template >
+class stack {};
+} // namespace std
+
+namespace absl {
+template , class Eq = std::equal_to, class A = std::allocator>
+class flat_hash_set {};
+} // namespace absl
+
+template 
+class allocator {};
+
+void simple(const std::vector &v, std::deque *d) {
+  // CHECK-MESSAGES: [[#@LINE-1]]:24: warning: container using std::allocator is a deprecated libc++ extension; remove const for compatibility with other standard libraries
+  // CHECK-MESSAGES: [[#@LINE-2]]:52: warning: container
+  std::list l;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::multiset ms;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::set> s;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_multiset ums;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_set us;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  absl::flat_hash_set fhs;
+  // CHECK-MESSAGES: [[#@LINE-1]]:9: warning: container
+
+  using my_vector = std::vector;
+  // CHECK-MESSAGES: [[#@LINE-1]]:26: warning: container
+  my_vector v1;
+  using my_vector2 = my_vector;
+
+  std::vector neg1;
+  std::vector neg2; // not const T
+  std::vector> neg3; // not use std::allocator
+  std::allocator a;   // not caught, but rare
+  std::forward_list forward;  // not caught, but rare
+  std::stack stack;   // not caught, but rare
+}
+
+template 
+void temp1() {
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg1;
+  std::forward_list neg2;
+}
+void use_temp1() { temp1(); }
+
+template 
+void temp2() {
+  // Match std::vector for the uninstantiated temp2.
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg1;
+  std::forward_list neg2;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - portability-std-allocator-const
+
+portability-std-allocator-const
+=
+
+Report use of ``std::vector`` (and similar containers of const
+elements). These are not allowed in standard C++, and should usually be
+``std::vector`` instead."
+
+Per C++ ``[allocator.requirements.general]``: "T is any cv-unqualified object
+type", ``std::allocator`` is undefined. Many standard containers use
+``std::allocator`` by default and therefore their ``const T`` instantiations are
+undefined.
+
+libc++ defines ``std::allocator`` as an extension which may be removed
+in the future.
+
+libstdc++ and MSVC do not support ``std::allocator``. Modern libstdc++
+(since `GCC 8.0 `) and MSVC
+have diagnostics like the following:
+
+.. code:: c++
+
+  // libstdc++
+  std::deque deque; // error: static assertion failed: std::deque must have a non-const, non-volatile value_type
+  std::set set; // error: static assertion failed: std::set must have a non-const, non-volatile value_type
+  std::vector vector; // error: stat

[PATCH] D67678: PR17164: Change clang's default behavior from -flax-vector-conversions=all to -flax-vector-conversions=integer.

2022-04-13 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D67678#3446526 , @rsmith wrote:

> @dexonsmith @arphaman What do we need to do to get this re-landed?

(I'm sorry I missed your ping two years ago :(... I was on an extended leave at 
the time and never ended up catching up on the email I missed.)

@arphaman is probably the best person to figure this out with you, but I'll 
start an internal thread to see if someone else can help too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67678

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


[PATCH] D123544: [randstruct] Automatically randomize a structure of function pointers

2022-04-13 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D123544#3448046 , @aaron.ballman 
wrote:

> In D123544#3446814 , @void wrote:
>
>> Let me work on that. But otherwise are you okay with this patch?
>
> Yes, I'm okay with the direction of this patch. However, because this still 
> automatically randomizes some structure layouts once the user passes the 
> flag, I think the diagnostic above should perhaps land first unless there's 
> some strong reason not to. (To be honest, I probably should have insisted on 
> it in the first patch, but this one feels significantly more dangerous 
> because it involves function pointers specifically and is more of an 
> "automatic" feature than the first patch.)

It was definitely an oversight on my part as well. This patch will be going in 
llvm 15, not 14, so there's probably not a huge rush to get this in first. I'll 
focus on the error and have a patch out soon-ish.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123544

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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 422619.
MaskRay marked 3 inline comments as done.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Catch std::vector


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

Files:
  clang-tools-extra/clang-tidy/portability/CMakeLists.txt
  clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
  clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
@@ -0,0 +1,91 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-std-allocator-const %t --
+
+namespace std {
+typedef unsigned size_t;
+
+template 
+class allocator {};
+template 
+class hash {};
+template 
+class equal_to {};
+template 
+class less {};
+
+template >
+class deque {};
+template >
+class forward_list {};
+template >
+class list {};
+template >
+class vector {};
+
+template , class A = std::allocator>
+class multiset {};
+template , class A = std::allocator>
+class set {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_multiset {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_set {};
+
+template >
+class stack {};
+} // namespace std
+
+namespace absl {
+template , class Eq = std::equal_to, class A = std::allocator>
+class flat_hash_set {};
+} // namespace absl
+
+template 
+class allocator {};
+
+void simple(const std::vector &v, std::deque *d) {
+  // CHECK-MESSAGES: [[#@LINE-1]]:24: warning: container using std::allocator is a libc++ extension; remove const for compatibility with other standard libraries
+  // CHECK-MESSAGES: [[#@LINE-2]]:52: warning: container
+  std::list l;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::multiset ms;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::set> s;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_multiset ums;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_set us;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  absl::flat_hash_set fhs;
+  // CHECK-MESSAGES: [[#@LINE-1]]:9: warning: container
+
+  using my_vector = std::vector;
+  // CHECK-MESSAGES: [[#@LINE-1]]:26: warning: container
+  my_vector v1;
+  using my_vector2 = my_vector;
+
+  std::vector neg0;
+  std::vector neg1; // not const T
+  std::vector> neg2; // not use std::allocator
+  std::forward_list forward;  // rare, don't bother
+  std::stack stack;   // not caught, but rare
+}
+
+template 
+void temp1() {
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg;
+}
+void use_temp1() { temp1(); }
+
+template 
+void temp2() {
+  // Match std::vector for the uninstantiated temp2.
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - portability-std-allocator-const
+
+portability-std-allocator-const
+=
+
+Report use of ``std::vector`` (and similar containers of const
+elements). These are not allowed in standard C++, and should usually be
+``std::vector`` instead."
+
+Per C++ ``[allocator.requirements.general]``: "T is any cv-unqualified object
+type", ``std::allocator`` is undefined. Many standard containers use
+``std::allocator`` by default and therefore their ``const T`` instantiations are
+undefined.
+
+libc++ defines ``std::allocator`` as an extension which may be removed
+in the future.
+
+libstdc++ and MSVC do not support ``std::allocator``. Modern libstdc++
+(since `GCC 8.0 `) and MSVC
+have diagnostics like the following:
+
+.. code:: c++
+
+  // libstdc++
+  std::deque deque; // error: static assertion failed: std::deque must have a non-const, non-volatile value_type
+  std::set set; // error: static assertion failed: std::set must have a non-const, non-volatile value_type
+  std::vector vector; // error: static assertion failed: std::vector must have a non-const, non-volatile value_type
+
+  // MSVC
+  // error C233

[PATCH] D123586: [clang][dataflow] Weaken abstract comparison to enable loop termination.

2022-04-13 Thread Yitzhak Mandelbaum 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 rGbbcf11f5af98: [clang][dataflow] Weaken abstract comparison 
to enable loop termination. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123586

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

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -365,8 +365,10 @@
 if (HasValue2 == nullptr)
   return false;
 
-assert(HasValue1 != HasValue2);
-cast(&MergedVal)->setProperty("has_value", HasValueTop);
+if (HasValue1 == HasValue2)
+  cast(&MergedVal)->setProperty("has_value", *HasValue1);
+else
+  cast(&MergedVal)->setProperty("has_value", HasValueTop);
 return true;
   }
 
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2944,4 +2944,71 @@
   });
 }
 
+TEST_F(TransferTest, LoopWithAssignmentConverges) {
+  std::string Code = R"(
+
+bool &foo();
+
+void target() {
+   do {
+bool Bar = foo();
+if (Bar) break;
+(void)Bar;
+/*[[p]]*/
+  } while (true);
+}
+  )";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment &Env = Results[0].second.Env;
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+auto &BarVal = *cast(Env.getValue(*BarDecl, SkipPast::None));
+EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal)));
+  });
+}
+
+TEST_F(TransferTest, LoopWithReferenceAssignmentConverges) {
+  std::string Code = R"(
+
+bool &foo();
+
+void target() {
+   do {
+bool& Bar = foo();
+if (Bar) break;
+(void)Bar;
+/*[[p]]*/
+  } while (true);
+}
+  )";
+  // The key property that we are verifying is implicit in `runDataflow` --
+  // namely, that the analysis succeeds, rather than hitting the maximum number
+  // of iterations.
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("p", _)));
+const Environment &Env = Results[0].second.Env;
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+auto &BarVal =
+*cast(Env.getValue(*BarDecl, SkipPast::Reference));
+EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(BarVal)));
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -59,7 +59,8 @@
   if (auto *IndVal1 = dyn_cast(Val1)) {
 auto *IndVal2 = cast(Val2);
 assert(IndVal1->getKind() == IndVal2->getKind());
-return &IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc();
+if (&IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc())
+  return true;
   }
 
   return Model.compareEquivalent(Type, *Val1, Env1, *Val2, Env2);
@@ -88,6 +89,9 @@
   // depends on `FC1` and `FC2`) and modify `flowConditionImplies` to construct
   // a formula that includes the bi-conditionals for all flow condition atoms in
   // the transitive set, before invoking the solver.
+  //
+  // FIXME: Does not work for backedges, since the two (or more) paths will not
+  // have mutually exclusive conditions.
   if (auto *Expr1 = dyn_cast(Val1)) {
 for (BoolValue *Constraint : Env1.getFlowConditionConstraints()) {
   Expr1 = &Env1.makeAnd(*Expr1, *Constraint);
@@ -285,9 +289,7 @@
   if (MemberLocToStruct != Other.MemberLocToStruct)
 return false;
 
-  if (LocToVal.size() != Other.LocToVal.size())
-return false;
-
+  // Compare the contents for the intersection of their dom

[clang] bbcf11f - [clang][dataflow] Weaken abstract comparison to enable loop termination.

2022-04-13 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2022-04-13T19:49:50Z
New Revision: bbcf11f5af98a6e0fa008e180404cfc397f336fa

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

LOG: [clang][dataflow] Weaken abstract comparison to enable loop termination.

Currently, when the framework is used with an analysis that does not override
`compareEquivalent`, it does not terminate for most loops. The root cause is the
interaction of (the default implementation of) environment comparison
(`compareEquivalent`) and the means by which locations and values are
allocated. Specifically, the creation of certain values (including: reference
and pointer values; merged values) results in allocations of fresh locations in
the environment. As a result, analysis of even trivial loop bodies produces
different (if isomorphic) environments, on identical inputs. At the same time,
the default analysis relies on strict equality (versus some relaxed notion of
equivalence). Together, when the analysis compares these isomorphic, yet
unequal, environments, to determine whether the successors of the given block
need to be (re)processed, the result is invariably "yes", thus preventing loop
analysis from reaching a fixed point.

There are many possible solutions to this problem, including equivalence that is
less than strict pointer equality (like structural equivalence) and/or the
introduction of an explicit widening operation. However, these solutions will
require care to be implemented correctly. While a high priority, it seems more
urgent that we fix the current default implentation to allow
termination. Therefore, this patch proposes, essentially, to change the default
comparison to trivally equate any two values. As a result, we can say precisely
that the analysis will process the loop exactly twice -- once to establish an
initial result state and the second to produce an updated result which will
(always) compare equal to the previous. While clearly unsound -- we are not
reaching a fix point of the transfer function, in practice, this level of
analysis will find many practical issues where a single iteration of the loop
impacts abstract program state.

Note, however, that the change to the default `merge` operation does not affect
soundness, because the framework already produces a fresh (sound) abstraction of
the value when the two values are distinct. The previous setting was overly
conservative.

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 68d6e6345f639..bf4b7e5cc5bd9 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -77,7 +77,11 @@ class Environment {
const Environment &Env2) {
   // FIXME: Consider adding QualType to StructValue and removing the Type
   // argument here.
-  return false;
+  //
+  // FIXME: default to a sound comparison and/or expand the comparison 
logic
+  // built into the framework to support broader forms of equivalence than
+  // strict pointer equality.
+  return true;
 }
 
 /// Modifies `MergedVal` to approximate both `Val1` and `Val2`. This could
@@ -101,7 +105,7 @@ class Environment {
const Environment &Env1, const Value &Val2,
const Environment &Env2, Value &MergedVal,
Environment &MergedEnv) {
-  return false;
+  return true;
 }
   };
 

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 5b372dde89532..75618fddae444 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -59,7 +59,8 @@ static bool equivalentValues(QualType Type, Value *Val1,
   if (auto *IndVal1 = dyn_cast(Val1)) {
 auto *IndVal2 = cast(Val2);
 assert(IndVal1->getKind() == IndVal2->getKind());
-return &IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc();
+if (&IndVal1->getPointeeLoc() == &IndVal2->getPointeeLoc())
+  return true;
   }
 
   return Model.compareEquivalent(Type, *Val1, Env1, *Val2, Env2);
@@ -88,6 +89,9 @@ static Value *mergeDistinctValues(QualType Type, Value *Val1, 
Environment &Env1,
   // depends on `FC1` a

[clang] 26eec9e - Revert "[clang] Implement Change scope of lambda trailing-return-type"

2022-04-13 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2022-04-13T19:35:13Z
New Revision: 26eec9e9dbc20186f6b810fe01d3a01aac8ae6f4

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

LOG: Revert "[clang] Implement Change scope of lambda trailing-return-type"

This reverts commit adff142dc253d65b6560e420bba6b858d88d4a98.
This broke clang bootstrap: it made existing C++ code in LLVM invalid:

llvm/include/llvm/CodeGen/LiveInterval.h:630:53: error: captured variable 'Idx' 
cannot appear here
  [=](std::remove_reference_t V,
^

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Scope.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
clang/www/cxx_status.html

Removed: 
clang/test/SemaCXX/lambda-capture-type-deduction.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 016aafee016c2..91fc57dfac595 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -247,9 +247,6 @@ C++2b Feature Support
 - Implemented `P2128R6: Multidimensional subscript operator 
`_.
 - Implemented `P0849R8: auto(x): decay-copy in the language 
`_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in 
constexpr functions`_.
-- Implemented `P2036R3: Change scope of lambda trailing-return-type 
`_.
-  This proposal modifies how variables captured in lambdas can appear in 
trailing return type
-  expressions and how their types are deduced therein, in all C++ language 
versions.
 
 CUDA Language Changes in Clang
 --

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index c640f7f7ba63f..04a9daa14e05e 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1799,20 +1799,6 @@ class CXXRecordDecl : public RecordDecl {
 return getLambdaData().MethodTyInfo;
   }
 
-  void setLambdaTypeInfo(TypeSourceInfo *TS) {
-auto *DD = DefinitionData;
-assert(DD && DD->IsLambda && "setting lambda property of non-lambda 
class");
-auto &DL = static_cast(*DD);
-DL.MethodTyInfo = TS;
-  }
-
-  void setLambdaIsGeneric(bool IsGeneric) {
-auto *DD = DefinitionData;
-assert(DD && DD->IsLambda && "setting lambda property of non-lambda 
class");
-auto &DL = static_cast(*DD);
-DL.IsGenericLambda = IsGeneric;
-  }
-
   // Determine whether this type is an Interface Like type for
   // __interface inheritance purposes.
   bool isInterfaceLike() const;

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e154925538f3a..3213163ee7876 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7704,8 +7704,6 @@ let CategoryName = "Lambda Issue" in {
   def err_lambda_impcap : Error<
 "variable %0 cannot be implicitly captured in a lambda with no "
 "capture-default specified">;
-  def err_lambda_used_before_capture: Error<
-"captured variable %0 cannot appear here">;
   def note_lambda_variable_capture_fixit : Note<
 "capture %0 by %select{value|reference}1">;
   def note_lambda_default_capture_fixit : Note<

diff  --git a/clang/include/clang/Sema/Scope.h 
b/clang/include/clang/Sema/Scope.h
index 5a2d51b63d909..872951a0829b4 100644
--- a/clang/include/clang/Sema/Scope.h
+++ b/clang/include/clang/Sema/Scope.h
@@ -44,11 +44,11 @@ class Scope {
   enum ScopeFlags {
 /// This indicates that the scope corresponds to a function, which
 /// means that labels are set here.
-FnScope = 0x01,
+FnScope   = 0x01,
 
 /// This is a while, do, switch, for, etc that can have break
 /// statements embedded into it.
-BreakScope = 0x02,
+BreakScope= 0x02,
 
 /// This is a while, do, for, which can have continue statements
 /// embedded into it.
@@ -140,12 +140,6 @@ class Scope {
 /// parsed. If such a scope is a ContinueScope, it's invalid to jump to the
 /// continue block from here.
 ConditionVarScope = 0x200,
-
-/// This is the scope for a lambda, after the lambda introducer.
-//

[PATCH] D123648: Restrict lvalue-to-rvalue conversions in CGExprConstant.

2022-04-13 Thread Eli Friedman 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 rGd791de0e25e1: Restrict lvalue-to-rvalue conversions in 
CGExprConstant. (authored by efriedma).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123648

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -9,7 +9,7 @@
 
 // CHECK: @_ZN7PR507872x_E = external global i32, align 4
 // CHECK-NEXT: @_ZN7PR507872x1E = constant i32* @_ZN7PR507872x_E, align 8
-// CHECK-NEXT: @_ZN7PR507872x2E = global i32* @_ZN7PR507872x_E, align 4
+// CHECK-NEXT: @_ZN7PR507872x2E = global i32 0, align 4
 }
 
 namespace PR51484 {
@@ -18,7 +18,7 @@
 consteval X g() { return {0}; }
 void f() { g(); }
 
-// CHECK: define dso_local void @_ZN7PR514841fEv() #0 {
+// CHECK: define dso_local void @_ZN7PR514841fEv() #1 {
 // CHECK: entry:
 // CHECK-NOT: call i32 @_ZN7PR514841gEv()
 // CHECK:  ret void
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1092,7 +1092,16 @@
  destAS, destTy);
 }
 
-case CK_LValueToRValue:
+case CK_LValueToRValue: {
+  // We don't really support doing lvalue-to-rvalue conversions here; any
+  // interesting conversions should be done in Evaluate().  But as a
+  // special case, allow compound literals to support the gcc extension
+  // allowing "struct x {int x;} x = (struct x) {};".
+  if (auto *E = dyn_cast(subExpr->IgnoreParens()))
+return Visit(E->getInitializer(), destType);
+  return nullptr;
+}
+
 case CK_AtomicToNonAtomic:
 case CK_NonAtomicToAtomic:
 case CK_NoOp:


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -9,7 +9,7 @@
 
 // CHECK: @_ZN7PR507872x_E = external global i32, align 4
 // CHECK-NEXT: @_ZN7PR507872x1E = constant i32* @_ZN7PR507872x_E, align 8
-// CHECK-NEXT: @_ZN7PR507872x2E = global i32* @_ZN7PR507872x_E, align 4
+// CHECK-NEXT: @_ZN7PR507872x2E = global i32 0, align 4
 }
 
 namespace PR51484 {
@@ -18,7 +18,7 @@
 consteval X g() { return {0}; }
 void f() { g(); }
 
-// CHECK: define dso_local void @_ZN7PR514841fEv() #0 {
+// CHECK: define dso_local void @_ZN7PR514841fEv() #1 {
 // CHECK: entry:
 // CHECK-NOT: call i32 @_ZN7PR514841gEv()
 // CHECK:  ret void
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1092,7 +1092,16 @@
  destAS, destTy);
 }
 
-case CK_LValueToRValue:
+case CK_LValueToRValue: {
+  // We don't really support doing lvalue-to-rvalue conversions here; any
+  // interesting conversions should be done in Evaluate().  But as a
+  // special case, allow compound literals to support the gcc extension
+  // allowing "struct x {int x;} x = (struct x) {};".
+  if (auto *E = dyn_cast(subExpr->IgnoreParens()))
+return Visit(E->getInitializer(), destType);
+  return nullptr;
+}
+
 case CK_AtomicToNonAtomic:
 case CK_NonAtomicToAtomic:
 case CK_NoOp:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d791de0 - Restrict lvalue-to-rvalue conversions in CGExprConstant.

2022-04-13 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2022-04-13T12:34:57-07:00
New Revision: d791de0e25e13cd8ae066e6f0fa03b384502b02e

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

LOG: Restrict lvalue-to-rvalue conversions in CGExprConstant.

We were generating wrong code for cxx20-consteval-crash.cpp: instead of
loading a value of a variable, we were using its address as the
initializer.

Found while adding code to verify the size of constant initializers.

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGenCXX/cxx20-consteval-crash.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 6397ff5909942..92122f0df7b9a 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1092,7 +1092,16 @@ class ConstExprEmitter :
  destAS, destTy);
 }
 
-case CK_LValueToRValue:
+case CK_LValueToRValue: {
+  // We don't really support doing lvalue-to-rvalue conversions here; any
+  // interesting conversions should be done in Evaluate().  But as a
+  // special case, allow compound literals to support the gcc extension
+  // allowing "struct x {int x;} x = (struct x) {};".
+  if (auto *E = dyn_cast(subExpr->IgnoreParens()))
+return Visit(E->getInitializer(), destType);
+  return nullptr;
+}
+
 case CK_AtomicToNonAtomic:
 case CK_NonAtomicToAtomic:
 case CK_NoOp:

diff  --git a/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp 
b/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
index c8ca6a56fb29a..c7f03776f56db 100644
--- a/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ b/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -9,7 +9,7 @@ auto x2 = X();
 
 // CHECK: @_ZN7PR507872x_E = external global i32, align 4
 // CHECK-NEXT: @_ZN7PR507872x1E = constant i32* @_ZN7PR507872x_E, align 8
-// CHECK-NEXT: @_ZN7PR507872x2E = global i32* @_ZN7PR507872x_E, align 4
+// CHECK-NEXT: @_ZN7PR507872x2E = global i32 0, align 4
 }
 
 namespace PR51484 {
@@ -18,7 +18,7 @@ struct X { int val; };
 consteval X g() { return {0}; }
 void f() { g(); }
 
-// CHECK: define dso_local void @_ZN7PR514841fEv() #0 {
+// CHECK: define dso_local void @_ZN7PR514841fEv() #1 {
 // CHECK: entry:
 // CHECK-NOT: call i32 @_ZN7PR514841gEv()
 // CHECK:  ret void



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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D119136#3449325 , @cor3ntin wrote:

> Yes, working on a fix as we speak.
> The meaning of that code changed (in all c++ language modes), I'm
> currently trying to find if we have any other issue of that sort and will
> commit a fix in a few hours

OK, I'll revert in the meantime to unbreak bots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D123649: Allow flexible array initialization in C++.

2022-04-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:2388
+  // evaluation. Make sure we emit a sane error message, for now.
+  constexpr A c = {1, 2, 3}; // expected-warning {{flexible array 
initialization is a GNU extension}}
+  static_assert(c.arr[0] == 1, ""); // expected-error {{constant expression}} 
expected-note {{array member without known bound}}

erichkeane wrote:
> I would expect this to be an error, not the static-assert.  The constexpr 
> variable means 'initializable as a constant expression'.  
> 
> I'm guessing the problem is ACTUALLY that we support constexpr init, but not 
> the operator[].  I think I'd like to have us have the initialization fail 
> here, since it isn't otherwise usable.
I think we end up computing the initializer "correctly", but have no way to 
actually access the elements in constant evaluation.  Seems to come out of 
CGExprConstant lowering okay, but I guess we don't really need that to work at 
the moment; we fall back to the old CGExprConstant direct lowering code.

I'll add a bailout to constant evaluation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123649

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


[PATCH] D123586: [clang][dataflow] Weaken abstract comparison to enable loop termination.

2022-04-13 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D123586#3449291 , @xazax.hun wrote:

> In D123586#3449256 , @ymandel wrote:
>
>> In D123586#3446956 , @xazax.hun 
>> wrote:
>>
>>> Yeah, this is a hard problem in general. This looks like a sensible 
>>> workaround for the short term, but I'm looking forward to a better 
>>> solution. I'm a bit worried that the memory model will need some upgrades 
>>> to properly solve this problem.
>>
>> Thanks for the quick review!  Yes, I have my concerns as well. It seems like 
>> some amount of a) additional allocation stabilization/memoization, b) 
>> introduction of explicit widening operator and c) structural comparison will 
>> fully solve the problem. Solving this properly is a high priority.
>
> This is a complicated topic. If you have a plan I think it might be a good 
> idea to share it on the forums just in case someone has some input before 
> fully implementing it.

Yes, definitely! At the least, I was hoping for *your* input before we start 
sending you patches. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123586

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Yes, working on a fix as we speak.
The meaning of that code changed (in all c++ language modes), I'm
currently trying to find if we have any other issue of that sort and will
commit a fix in a few hours


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D123586: [clang][dataflow] Weaken abstract comparison to enable loop termination.

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

In D123586#3449256 , @ymandel wrote:

> In D123586#3446956 , @xazax.hun 
> wrote:
>
>> Yeah, this is a hard problem in general. This looks like a sensible 
>> workaround for the short term, but I'm looking forward to a better solution. 
>> I'm a bit worried that the memory model will need some upgrades to properly 
>> solve this problem.
>
> Thanks for the quick review!  Yes, I have my concerns as well. It seems like 
> some amount of a) additional allocation stabilization/memoization, b) 
> introduction of explicit widening operator and c) structural comparison will 
> fully solve the problem. Solving this properly is a high priority.

This is a complicated topic. If you have a plan I think it might be a good idea 
to share it on the forums just in case someone has some input before fully 
implementing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123586

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Seems like this is breaking clang bootstrapping?

  llvm/include/llvm/CodeGen/LiveInterval.h:630:53: error: captured variable 
'Idx' cannot appear here
[=](std::remove_reference_t V,
  ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D123586: [clang][dataflow] Weaken abstract comparison to enable loop termination.

2022-04-13 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D123586#3446956 , @xazax.hun wrote:

> Yeah, this is a hard problem in general. This looks like a sensible 
> workaround for the short term, but I'm looking forward to a better solution. 
> I'm a bit worried that the memory model will need some upgrades to properly 
> solve this problem.

Thanks for the quick review!  Yes, I have my concerns as well. It seems like 
some amount of a) additional allocation stabilization/memoization, b) 
introduction of explicit widening operator and c) structural comparison will 
fully solve the problem. Solving this properly is a high priority.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123586

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


[PATCH] D123498: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets

2022-04-13 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

In D123498#3448554 , @DavidSpickett 
wrote:

> Is there any reason to have an AArch64 specific section? A lot of the files 
> do apply to both Arm and AArch64 but for example the mve file Momchil 
> mentioned does not.
>
> Would make sense if you wanted AArch64 only there'd be an 
> `aarch64-resource-headers`, even if it just makes the config command clearer. 
> (I would expect some overlap in the file list though)

Sure, we can have an AArch64 specific section. I have no AArch64/arm background 
to comment on what the lists should look like. Could you provide a pointer on 
how to decide what should be AArch64 specific? Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123498

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


[PATCH] D97121: [clang-tidy] Add a Standalone diagnostics mode to clang-tidy

2022-04-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thank you!

(I'm sorry, somehow I had misunderstood what this patch was about, and wasn't 
paying attention)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97121

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


[PATCH] D123498: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets

2022-04-13 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 422589.
qiongsiwu1 added subscribers: abdulras, compnerd.
qiongsiwu1 added a comment.
Herald added subscribers: pcwang-thead, luke957, s.egerton, simoncook.

Addressing review comments:

1. @chill pointed out that the generated headers are missing. The generated 
headers are added now.
2. @pengfei pointed out that some x86 headers are listed out of order. The list 
is sorted now.
3. @pengfei also commented on `mm_malloc.h`. I think it is needed for `x86` and 
`ppc`. The header is added to these two targets.

@abdulras @compnerd May I get your comments on the `riscv` target?

Thank you all!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123498

Files:
  clang/lib/Headers/CMakeLists.txt

Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -1,19 +1,100 @@
-set(files
-  adxintrin.h
-  altivec.h
-  ammintrin.h
-  amxintrin.h
+# core_files list contains the headers shared by all platforms.
+# Please consider adding new platform specific headers
+# to platform specific lists below.
+set(core_files
+  builtins.h
+  float.h
+  inttypes.h
+  iso646.h
+  limits.h
+  module.modulemap
+  stdalign.h
+  stdarg.h
+  stdatomic.h
+  stdbool.h
+  stddef.h
+  __stddef_max_align_t.h
+  stdint.h
+  stdnoreturn.h
+  tgmath.h
+  unwind.h
+  varargs.h
+  )
+
+set(arm_files
   arm_acle.h
   arm_cmse.h
   armintr.h
   arm64intr.h
+  )
+
+set(cuda_files
+  __clang_cuda_builtin_vars.h
+  __clang_cuda_math.h
+  __clang_cuda_cmath.h
+  __clang_cuda_complex_builtins.h
+  __clang_cuda_device_functions.h
+  __clang_cuda_intrinsics.h
+  __clang_cuda_texture_intrinsics.h
+  __clang_cuda_libdevice_declares.h
+  __clang_cuda_math_forward_declares.h
+  __clang_cuda_runtime_wrapper.h
+  )
+
+set(hexagon_files
+  hexagon_circ_brev_intrinsics.h
+  hexagon_protos.h
+  hexagon_types.h
+  hvx_hexagon_protos.h
+  )
+
+set(hip_files
+  __clang_hip_libdevice_declares.h
+  __clang_hip_cmath.h
+  __clang_hip_math.h
+  __clang_hip_runtime_wrapper.h
+  )
+
+set(mips_msa_files
+  msa.h
+  )
+
+set(opencl_files
+  opencl-c.h
+  opencl-c-base.h
+  )
+
+set(ppc_files
+  altivec.h
+  htmintrin.h
+  htmxlintrin.h
+  )
+
+set(systemz_files
+  s390intrin.h
+  vecintrin.h
+  )
+
+set(ve_files
+  velintrin.h
+  velintrin_gen.h
+  velintrin_approx.h
+  )
+
+set(webassembly_files
+  wasm_simd128.h
+  )
+
+set(x86_files
+# Intrinsics
+  adxintrin.h
+  ammintrin.h
+  amxintrin.h
   avx2intrin.h
   avx512bf16intrin.h
-  avx512bwintrin.h
   avx512bitalgintrin.h
-  avx512vlbitalgintrin.h
+  avx512bwintrin.h
   avx512cdintrin.h
-  avx512vpopcntdqintrin.h
   avx512dqintrin.h
   avx512erintrin.h
   avx512fintrin.h
@@ -21,86 +102,55 @@
   avx512ifmaintrin.h
   avx512ifmavlintrin.h
   avx512pfintrin.h
+  avx512vbmi2intrin.h
   avx512vbmiintrin.h
   avx512vbmivlintrin.h
-  avx512vbmi2intrin.h
-  avx512vlvbmi2intrin.h
   avx512vlbf16intrin.h
+  avx512vlbitalgintrin.h
   avx512vlbwintrin.h
   avx512vlcdintrin.h
   avx512vldqintrin.h
   avx512vlfp16intrin.h
   avx512vlintrin.h
-  avx512vp2intersectintrin.h
+  avx512vlvbmi2intrin.h
+  avx512vlvnniintrin.h
   avx512vlvp2intersectintrin.h
-  avx512vpopcntdqvlintrin.h
   avx512vnniintrin.h
-  avx512vlvnniintrin.h
+  avx512vp2intersectintrin.h
+  avx512vpopcntdqintrin.h
+  avx512vpopcntdqvlintrin.h
   avxintrin.h
   avxvnniintrin.h
   bmi2intrin.h
   bmiintrin.h
-  builtins.h
-  __clang_cuda_builtin_vars.h
-  __clang_cuda_math.h
-  __clang_cuda_cmath.h
-  __clang_cuda_complex_builtins.h
-  __clang_cuda_device_functions.h
-  __clang_cuda_intrinsics.h
-  __clang_cuda_texture_intrinsics.h
-  __clang_cuda_libdevice_declares.h
-  __clang_cuda_math_forward_declares.h
-  __clang_cuda_runtime_wrapper.h
-  __clang_hip_libdevice_declares.h
-  __clang_hip_cmath.h
-  __clang_hip_math.h
-  __clang_hip_runtime_wrapper.h
   cetintrin.h
-  cet.h
   cldemoteintrin.h
-  clzerointrin.h
-  crc32intrin.h
-  cpuid.h
   clflushoptintrin.h
   clwbintrin.h
+  clzerointrin.h
+  crc32intrin.h
   emmintrin.h
   enqcmdintrin.h
   f16cintrin.h
-  float.h
   fma4intrin.h
   fmaintrin.h
   fxsrintrin.h
   gfniintrin.h
-  hexagon_circ_brev_intrinsics.h
-  hexagon_protos.h
-  hexagon_types.h
-  hvx_hexagon_protos.h
   hresetintrin.h
-  htmintrin.h
-  htmxlintrin.h
   ia32intrin.h
   immintrin.h
-  intrin.h
-  inttypes.h
   invpcidintrin.h
-  iso646.h
   keylockerintrin.h
-  limits.h
   lwpintrin.h
   lzcntintrin.h
   mm3dnow.h
   mmintrin.h
-  mm_malloc.h
-  module.modulemap
   movdirintrin.h
-  msa.h
   mwaitxintrin.h
   nmmintrin.h
-  opencl-c.h
-  opencl-c-base.h
+  pconfigintrin.h
   pkuintrin.h
   pmmintrin.h
-  pconfigintrin.h
   popcntintrin.h
   prfchwintrin.h
   ptwriteintrin.h
@@ -108,33 +158,18 @@
   rtmintrin.h
   serializeintrin.h
   sgxintrin.h
-  s390intrin.h
   shaintrin.h
   smmintrin.h
-  stdalign

[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst:6
+
+This check reports use of ``vector`` (and similar containers of const
+elements). These are not allowed in standard C++, and should usually be

Please omit `This check`. Also please make first sentence same as in Release 
Notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG from my side. It won't catch all cases, but I think it gets the common ones.

Up to you/Louis how best to describe the libc++ behavior.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp:65
+  // CHECK-MESSAGES: [[#@LINE-1]]:26: warning: container
+  my_vector v1;
+

maybe `using my_vector2 = my_vector;`, with no extra diagnostics



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp:76
+void temp() {
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container

This case will always be an error, but isn't diagnosed until you see an 
instantiation.

If it's important to catch these standalone e.g. when analyzing headers, you 
could adapt the matcher like:

```
hasUnqualifiedDesugaredType(anyOf(
  recordDecl(...), // current case
  templateSpecializationType( // when dependent, TST is canonical
templateArgumentCountIs(1), // std::vector
hasTemplateArgument(0, refersToType(qualType(isConstQualified(
  )
))
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

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


[PATCH] D123127: [AST] Add a new TemplateName for templates found via a using declaration.

2022-04-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 422586.
hokein marked 4 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123127

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang/include/clang/AST/PropertiesBase.td
  clang/include/clang/AST/TemplateName.h
  clang/include/clang/AST/TextNodeDumper.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/TemplateName.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/AST/ast-dump-using-template.cpp
  clang/test/CXX/temp/temp.deduct.guide/p3.cpp
  clang/tools/libclang/CIndex.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/TemplateNameTest.cpp

Index: clang/unittests/AST/TemplateNameTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/TemplateNameTest.cpp
@@ -0,0 +1,62 @@
+//===- unittests/AST/TemplateNameTest.cpp --- Tests for TemplateName --===//
+//
+// 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 "ASTPrint.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace {
+using namespace ast_matchers;
+
+std::string printTemplateName(TemplateName TN, const PrintingPolicy &Policy,
+  TemplateName::Qualified Qual) {
+  std::string Result;
+  llvm::raw_string_ostream Out(Result);
+  TN.print(Out, Policy, Qual);
+  return Out.str();
+}
+
+TEST(TemplateName, PrintUsingTemplate) {
+  std::string Code = R"cpp(
+namespace std {
+  template  struct vector {};
+}
+namespace absl { using std::vector; }
+
+template class T> class X;
+
+using absl::vector;
+using A = X;
+  )cpp";
+  auto AST = tooling::buildASTFromCode(Code);
+  ASTContext &Ctx = AST->getASTContext();
+  // Match the template argument vector in X.
+  auto MatchResults = match(templateArgumentLoc().bind("id"), Ctx);
+  const auto *Template = selectFirst("id", MatchResults);
+  ASSERT_TRUE(Template);
+
+  TemplateName TN = Template->getArgument().getAsTemplate();
+  EXPECT_EQ(TN.getKind(), TemplateName::UsingTemplate);
+  EXPECT_EQ(TN.getAsUsingShadowDecl()->getTargetDecl(), TN.getAsTemplateDecl());
+
+  EXPECT_EQ(printTemplateName(TN, Ctx.getPrintingPolicy(),
+  TemplateName::Qualified::Fully),
+"std::vector");
+  EXPECT_EQ(printTemplateName(TN, Ctx.getPrintingPolicy(),
+  TemplateName::Qualified::AsWritten),
+"vector");
+  EXPECT_EQ(printTemplateName(TN, Ctx.getPrintingPolicy(),
+  TemplateName::Qualified::None),
+"vector");
+}
+
+} // namespace
+} // namespace clang
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -31,6 +31,7 @@
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   StructuralEquivalenceTest.cpp
+  TemplateNameTest.cpp
   TypePrinterTest.cpp
   )
 
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -890,6 +890,18 @@
  functionDecl(hasDescendant(usingDecl(hasName("bar");
 }
 
+TEST_P(ImportDecl, ImportUsingTemplate) {
+  MatchVerifier Verifier;
+  testImport("namespace ns { template  struct S {}; }"
+ "template  class T> class X {};"
+ "void declToImport() {"
+ "using ns::S;  X xi; }",
+ Lang_CXX11, "", Lang_CXX11, Verifier,
+ functionDecl(
+ hasDescendant(varDecl(hasTypeLoc(templateSpecializationTypeLoc(
+ hasAnyTemplateArgumentLoc(templateArgumentLoc(;
+}
+
 TEST_P(ImportDecl, ImportUsingEnumDecl) {
   MatchVerifier Verifier;
   testImport("namespace foo { enum bar { baz, toto, quux }; }"
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1442,6 +1442,7 @@
 bool CursorVisitor::VisitTemplateName(TemplateName Name, SourceLocation Loc) {
   switch (Name.g

[clang-tools-extra] a3b73b6 - Fix a typo with this test function name

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

Author: Aaron Ballman
Date: 2022-04-13T14:44:27-04:00
New Revision: a3b73b60be4467d2194d3c95e7b943f1644cf92b

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

LOG: Fix a typo with this test function name

The call and the function name don't line up correctly, so this was
accidentally using an implicit function declaration when it didn't
intend to.

Added: 


Modified: 

clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
index b7d92ce43f64b..e73b439ba43bf 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-implicits.c
@@ -73,5 +73,5 @@ void numericConversion8(double D, enum UnscopedFixed UF) { 
numericConversion8(UF
 // CHECK-MESSAGES: :[[@LINE-3]]:54: note: the last parameter in the range is 
'UF'
 // CHECK-MESSAGES: :[[@LINE-4]]:35: note: 'double' and 'enum UnscopedFixed' 
may be implicitly converted{{$}}
 
-void pointeeConverison(int *IP, double *DP) { pointeeConversion(DP, IP); }
+void pointeeConversion(int *IP, double *DP) { pointeeConversion(DP, IP); }
 // NO-WARN: Even though this is possible in C, a swap is diagnosed by the 
compiler.



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


[PATCH] D122673: Add kcfi_unchecked attribute

2022-04-13 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen abandoned this revision.
samitolvanen added a comment.

Alright, thanks for the feedback everyone! I'll abandon this patch and look 
into adding a built-in function instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122673

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


[PATCH] D122683: [OpenMP] Use new offloading binary when embedding offloading images

2022-04-13 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 422580.
jhuber6 added a comment.

Fix test after move to opaque pointers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122683

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Frontend/embed-object.c
  clang/test/Frontend/embed-object.ll
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  llvm/include/llvm/Object/OffloadBinary.h
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/Transforms/Utils/ModuleUtils.cpp

Index: llvm/lib/Transforms/Utils/ModuleUtils.cpp
===
--- llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -265,15 +265,15 @@
 }
 
 void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf,
-   StringRef SectionName) {
-  // Embed the buffer into the module.
+   StringRef SectionName, Align Alignment) {
+  // Embed the memory buffer into the module.
   Constant *ModuleConstant = ConstantDataArray::get(
   M.getContext(), makeArrayRef(Buf.getBufferStart(), Buf.getBufferSize()));
   GlobalVariable *GV = new GlobalVariable(
-  M, ModuleConstant->getType(), true, GlobalValue::ExternalLinkage,
-  ModuleConstant, SectionName.drop_front());
+  M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage,
+  ModuleConstant, "llvm.embedded.object");
   GV->setSection(SectionName);
-  GV->setVisibility(GlobalValue::HiddenVisibility);
+  GV->setAlignment(Alignment);
 
   appendToCompilerUsed(M, GV);
 }
Index: llvm/include/llvm/Transforms/Utils/ModuleUtils.h
===
--- llvm/include/llvm/Transforms/Utils/ModuleUtils.h
+++ llvm/include/llvm/Transforms/Utils/ModuleUtils.h
@@ -14,6 +14,7 @@
 #define LLVM_TRANSFORMS_UTILS_MODULEUTILS_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include  // for std::pair
 
@@ -109,7 +110,8 @@
 
 /// Embed the memory buffer \p Buf into the module \p M as a global using the
 /// specified section name.
-void embedBufferInModule(Module &M, MemoryBufferRef Buf, StringRef SectionName);
+void embedBufferInModule(Module &M, MemoryBufferRef Buf, StringRef SectionName,
+ Align Alignment = Align(1));
 
 class CallInst;
 namespace VFABI {
Index: llvm/include/llvm/Object/OffloadBinary.h
===
--- llvm/include/llvm/Object/OffloadBinary.h
+++ llvm/include/llvm/Object/OffloadBinary.h
@@ -73,6 +73,7 @@
 
   ImageKind getImageKind() const { return TheEntry->TheImageKind; }
   OffloadKind getOffloadKind() const { return TheEntry->TheOffloadKind; }
+  uint32_t getVersion() const { return TheHeader->Version; }
   uint32_t getFlags() const { return TheEntry->Flags; }
   uint64_t getSize() const { return TheHeader->Size; }
 
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileOutputBuffer.h"
@@ -146,8 +147,8 @@
 static codegen::RegisterCodeGenFlags CodeGenFlags;
 
 /// Magic section string that marks the existence of offloading data. The
-/// section string will be formatted as `.llvm.offloading..`.
-#define OFFLOAD_SECTION_MAGIC_STR ".llvm.offloading."
+/// section will contain one or more offloading binaries stored contiguously.
+#define OFFLOAD_SECTION_MAGIC_STR ".llvm.offloading"
 
 /// Information for a device offloading file extracted from the host.
 struct DeviceFile {
@@ -201,16 +202,6 @@
 llvm::errs() << *IC << (std::next(IC) != IE ? " " : "\n");
 }
 
-static StringRef getDeviceFileExtension(StringRef DeviceTriple,
-bool IsBitcode = false) {
-  Triple TheTriple(DeviceTriple);
-  if (TheTriple.isAMDGPU() || IsBitcode)
-return "bc";
-  if (TheTriple.isNVPTX())
-return "cubin";
-  return "o";
-}
-
 std::string getMainExecutable(const char *Name) {
   void *Ptr = (void *)(intptr_t)&getMainExecutable;
   auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
@@ -296,39 +287,58 @@
   StringRef Prefix = sys::path::stem(Obj.getFileName());
   SmallVector ToBeStripped;
 
-  // Extract data from sections of the form `.llvm.offloading..`.
+  // Extract offloading binaries from sections with the name `.llvm.offloading`.
   f

[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp:28
+CheckFactories.registerCheck(
+"portability-std-allocator-const-t");
   }

sammccall wrote:
> without the punctuation, the "t" AllocatorConstT/allocator-const-t doesn't 
> seem so obvious IMO, I'd consider dropping it from the check name.
> 
> Also the docs and even the implementation are focused on containers, 
> "portability-const-container" might be easier to remember/understand for 
> people not immersed in the details here.
> 
> All up to you though.
Renamed to portability-std-allocator-const. The intention is to catch 
std::allocator. If the check gets improved to catch more cases, we won't need 
to rename it from std-container-const to std-allocator-const :)



Comment at: 
clang-tools-extra/clang-tidy/portability/StdAllocatorConstTCheck.cpp:30
+  Finder->addMatcher(
+  varDecl(
+  hasType(hasUnqualifiedDesugaredType(

sammccall wrote:
> Matching VarDecl specifically is an interesting choice. Maybe a good one: it 
> does a good job of ensuring we diagnose at an appropriate place and only once.
> 
> Other tempting choices are:
>  - typeloc(loc(...)) - requires the type to be spelled somewhere, I think 
> this can work even in template instantiations
>  - expr(hasType(...)) - problem is it's likely to find multiple matches for 
> the same root cause
> 
> My guess is matching the TypeLoc would work better: catching some extra cases 
> without much downside.
Thanks for Sam's offline help. I've got a form which is able to match many 
cases:)



Comment at: 
clang-tools-extra/clang-tidy/portability/StdAllocatorConstTCheck.cpp:50
+   "container using std::allocator is "
+   "undefined; remove const to work with libstdc++ and future libc++");
+}

sammccall wrote:
> I'm a bit concerned that the second half:
>  - is jargon that will confuse some people
>  - excludes MSVC (are there others?)
>  - will be inaccurate once libc++ changes
> 
> Also nits: "undefined" might be confusingly close to "not defined" in the "no 
> visible definition" sense, and "remove const to work with" reads a little 
> oddly because it's a person that's removing but the code that's working.
> 
> What about "container using std::allocator is invalid; remove const"
> or if focusing on the libc++ situation: "container using std::allocator T> is a libc++ extension; remove const for compatibility with other standard 
> libraries"?
Thanks for the suggestion! Adopted the libc++ oriented diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 422579.
MaskRay marked 10 inline comments as done.
MaskRay edited the summary of this revision.
MaskRay added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

Files:
  clang-tools-extra/clang-tidy/portability/CMakeLists.txt
  clang-tools-extra/clang-tidy/portability/PortabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
  clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
  clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/portability-std-allocator-const.cpp
@@ -0,0 +1,83 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s portability-std-allocator-const %t --
+
+namespace std {
+typedef unsigned size_t;
+
+template 
+class allocator {};
+template 
+class hash {};
+template 
+class equal_to {};
+template 
+class less {};
+
+template >
+class deque {};
+template >
+class forward_list {};
+template >
+class list {};
+template >
+class vector {};
+
+template , class A = std::allocator>
+class multiset {};
+template , class A = std::allocator>
+class set {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_multiset {};
+template , class Eq = std::equal_to, class A = std::allocator>
+class unordered_set {};
+
+template >
+class stack {};
+} // namespace std
+
+namespace absl {
+template , class Eq = std::equal_to, class A = std::allocator>
+class flat_hash_set {};
+} // namespace absl
+
+template 
+class allocator {};
+
+void simple(const std::vector &v, std::deque *d) {
+  // CHECK-MESSAGES: [[#@LINE-1]]:24: warning: container using std::allocator is a libc++ extension; remove const for compatibility with other standard libraries
+  // CHECK-MESSAGES: [[#@LINE-2]]:52: warning: container
+  std::list l;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::multiset ms;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::set> s;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_multiset ums;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+  std::unordered_set us;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  absl::flat_hash_set fhs;
+  // CHECK-MESSAGES: [[#@LINE-1]]:9: warning: container
+
+  using my_vector = std::vector;
+  // CHECK-MESSAGES: [[#@LINE-1]]:26: warning: container
+  my_vector v1;
+
+  std::vector neg0;
+  std::vector neg1; // not const T
+  std::vector> neg2; // not use std::allocator
+  std::forward_list forward;  // rare, don't bother
+  std::stack stack;   // not caught, but rare
+}
+
+template 
+void temp() {
+  std::vector v;
+  // CHECK-MESSAGES: [[#@LINE-1]]:8: warning: container
+
+  std::vector neg;
+}
+void use_temp() {
+  temp();
+}
Index: clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const.rst
@@ -0,0 +1,33 @@
+.. title:: clang-tidy - portability-std-allocator-const
+
+portability-std-allocator-const
+=
+
+This check reports use of ``vector`` (and similar containers of const
+elements). These are not allowed in standard C++, and should usually be
+``vector`` instead."
+
+Per C++ ``[allocator.requirements.general]``: "T is any cv-unqualified object
+type", ``std::allocator`` is undefined. Many standard containers use
+``std::allocator`` by default and therefore their ``const T`` instantiations are
+undefined.
+
+libc++ defines ``std::allocator`` as an extension which may be removed
+in the future.
+
+libstdc++ and MSVC do not support ``std::allocator``. Modern libstdc++
+(since `GCC 8.0 `) and MSVC
+have diagnostics like the following:
+
+.. code:: c++
+
+  // libstdc++
+  std::deque deque; // error: static assertion failed: std::deque must have a non-const, non-volatile value_type
+  std::set set; // error: static assertion failed: std::set must have a non-const, non-volatile value_type
+  std::vector vector; // error: static assertion failed: std::vector must have a non-const, non-volatile value_type
+
+  // MSVC
+  // error C2338: static_assert failed: 'The C++ Standard forbids containers of const elements because allocator is ill-formed.'
+
+Code bases only compiled with libc++ may accrue such undefined usage. This
+check finds such cod

[clang] 925acfe - [Clang] Fix html error in cxx_status.html [NFC]

2022-04-13 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-04-13T20:27:34+02:00
New Revision: 925acfea8836ffe97a1c1d76d31df3229e978a11

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

LOG: [Clang] Fix html error in cxx_status.html [NFC]

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 97634b1b0cd8b..44dfcbe98e2c1 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1405,7 +1405,7 @@ C++2b implementation status
   Clang 13
 
 
-  constexpr for  and cstdlib
+  constexpr for  and 

   https://wg21.link/P0533R9";>P0533R9
   No
 



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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman @ChuanqiXu Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D123648: Restrict lvalue-to-rvalue conversions in CGExprConstant.

2022-04-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1096
+case CK_LValueToRValue: {
+  // We don't really support doing lvalue-to-rvalue conversions here; any
+  // interesting conversions should be done in Evaluate().  But as a

Miss_Grape wrote:
> Could you add a test case?
Compound literals are covered by existing testcases, if that's what you're 
asking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123648

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot 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 rGadff142dc253: [clang] Implement Change scope of lambda 
trailing-return-type (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1356,7 +1356,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 15
 
 
   Multidimensional subscript operator
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+
+  static_assert(noexcept([&] mutable noexcept(!is_same) {}())); //expected-error {{static_assert failed due}}
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} (); //expected-error {{no matching function for call to object of type}} \
+   // expected-note {{candidate function not viable}} \
+   // expected-note {{'is_same' evaluated to false}}
+  [x = 1]() mutable requires is_same {} (); // expected-error {{no matching function for call to object of type}} \
+ // expected-note {{candidate function not viable}} \
+ // expected-note {{'is_same' evaluated to false}}
+}
+
+void err() {
+  int y, z;// expected-note 2{{declared here}}
+  auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
+  decltype(
+  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+

[clang] 38823b7 - Fix Werror build issue from 6f20744b7ff875

2022-04-13 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-04-13T11:00:09-07:00
New Revision: 38823b7f5f01e01c44360b17b4ab99b2729b7197

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

LOG: Fix Werror build issue from 6f20744b7ff875

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 848c56dd61dd1..664ca605fc7ea 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -4623,7 +4623,8 @@ ConditionalInfo EmitConditionalBlocks(CodeGenFunction 
&CGF,
   const AbstractConditionalOperator *E,
   const FuncTy &BranchGenFunc) {
   ConditionalInfo Info{CGF.createBasicBlock("cond.true"),
-   CGF.createBasicBlock("cond.false")};
+   CGF.createBasicBlock("cond.false"), llvm::None,
+   llvm::None};
   llvm::BasicBlock *endBlock = CGF.createBasicBlock("cond.end");
 
   CodeGenFunction::ConditionalEvaluation eval(CGF);



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


[clang] adff142 - [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-04-13T20:00:03+02:00
New Revision: adff142dc253d65b6560e420bba6b858d88d4a98

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

LOG: [clang] Implement Change scope of lambda trailing-return-type

Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start of the body would 
be parsed in the parent scope, such that capture would not be available to look 
up.

The scoping is changed to have an outer lambda scope, followed by the lambda 
prototype and body.

The lambda scope is necessary because there may be a template scope between the 
start of the lambda (to which we want to attach the captured variable) and the 
prototype scope.

We also need to introduce a declaration context to attach the captured variable 
to (and several parts of clang assume captures are handled from the call 
operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope

* Introduce a lambda scope

* Create the lambda class and call operator

* Add the init captures to the call operator context and the lambda scope. But 
the variables are not capured yet (because we don't know their type).
Instead, explicit  captures are stored in a temporary map that conserves the 
order of capture (for the purpose of having a stable order in the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected 
the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses 
in the parent context, we couldn't mangle a lambda that is attached to the 
context of a lambda whose type is not yet known).

* The lambda qualifiers are parsed, at this point We can switch (for the second 
time) inside the lambda context, unset the flag indicating that we have not 
parsed the lambda qualifiers,
record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call 
operator's types and also transform the call operator to a template function 
decl where necessary.

At this point, both captures and parameters can be injected in the body's 
scope. When trying to capture an implicit variable, if we are before the 
qualifiers of a lambda, we need to remember that the variables are still in the 
parent's context (rather than in the call operator's).

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

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

Added: 
clang/test/SemaCXX/lambda-capture-type-deduction.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Scope.h
clang/include/clang/Sema/ScopeInfo.h
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/Scope.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 91fc57dfac595..016aafee016c2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -247,6 +247,9 @@ C++2b Feature Support
 - Implemented `P2128R6: Multidimensional subscript operator 
`_.
 - Implemented `P0849R8: auto(x): decay-copy in the language 
`_.
 - Implemented `P2242R3: Non-literal variables (and labels and gotos) in 
constexpr functions`_.
+- Implemented `P2036R3: Change scope of lambda trailing-return-type 
`_.
+  This proposal modifies how variables captured in lambdas can appear in 
trailing return type
+  expressions and how their types are deduced therein, in all C++ language 
versions.
 
 CUDA Language Changes in Clang
 --

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 04a9daa14e05e..c640f7f7ba63f 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1799,6 +1799,20 @@ class CXXRecordDecl : public RecordDecl {
 return getLambdaData().MethodTyInfo;
   }
 
+  void setLambdaTypeInfo(TypeSourceInfo *TS) {
+auto *DD = DefinitionData;
+assert(DD && DD->IsLambda && "setting lambda property of non-lambda

[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/portability-std-allocator-const-t.rst:11
+
+libstdc++ never supports ``std::allocator`` and containers using them.
+Since GCC 8.0 (`PR48101 `),

sammccall wrote:
> It's a little confusing to call out only libstdc++ here without context when 
> libc++ is the odd-one out.
> 
> Maybe first mention that libc++ supports this as an extension that may be 
> removed in the future?
> 
> And if we're mentioning libstdc++'s behavior we should probably mention MS 
> STL too which is similar to libstdc++: https://godbolt.org/z/c4o5nc66v
I think I'd rather not mention libc++ at all -- I don't know that we ever 
documented that extension, and since we're actively trying to remove it, it 
might be better to just not say anything. Or we could say "It works on libc++, 
but it's non-standard and it may not work in the future".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

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


[PATCH] D122691: [clang][Sema] Add flag to LookupName to force C/ObjC codepath

2022-04-13 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

The change itself LGTM.

It would be really good if we can have a unit test that tests the new API when 
it lands, to ensure that this is tested in LLVM-project itself , in addition to 
Swift. Do you think it's possible to write a unit tests that constructs a 
compiler instance, parses a sample C++ file, and then you can use the Sema to 
try to invoke this `LookupName` API to perform the lookup to verify that it 
works as expected? I think it should be possible to construct such a unit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122691

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


[PATCH] D123655: [clang-tidy] Add portability-std-allocator-const-t check

2022-04-13 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D123655#3448472 , @Eugene.Zelenko 
wrote:

> Shouldn't this check be enabled only when libstdc++ is used?

No, because we would like to enforce this in libc++ as well!

Thanks @MaskRay for pursuing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123655

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


[PATCH] D122748: [Sema] Don't check bounds for function pointer

2022-04-13 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2c3ae0b6f05: [Sema] Don't check bounds for function 
pointer (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122748

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/unbounded-array-bounds.c


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15495,6 +15495,8 @@
 ND = ME->getMemberDecl();
 
   if (IsUnboundedArray) {
+if (EffectiveType->isFunctionType())
+  return;
 if (index.isUnsigned() || !index.isNegative()) {
   const auto &ASTC = getASTContext();
   unsigned AddrBits =


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15495,6 +15495,8 @@
 ND = ME->getMemberDecl();
 
   if (IsUnboundedArray) {
+if (EffectiveType->isFunctionType())
+  return;
 if (index.isUnsigned() || !index.isNegative()) {
   const auto &ASTC = getASTContext();
   unsigned AddrBits =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b2c3ae0 - [Sema] Don't check bounds for function pointer

2022-04-13 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2022-04-13T20:39:38+03:00
New Revision: b2c3ae0b6f05fd0c2184aea82637685a13b8dc4f

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

LOG: [Sema] Don't check bounds for function pointer

Currently, clang crashes with i386 target on the following code:
```
void f() {
  f + 0xdeadUL;
}
```
This problem is similar to the problem fixed in D104424, but that fix can't 
handle function pointer case, because `getTypeSizeInCharsIfKnown()` says that 
size is known and equal to 0 for function type.

This patch prevents bounds checking for function pointer, thus fixes the crash.

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

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/unbounded-array-bounds.c

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 9331d169f800f..03f9b692c0631 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -15495,6 +15495,8 @@ void Sema::CheckArrayAccess(const Expr *BaseExpr, const 
Expr *IndexExpr,
 ND = ME->getMemberDecl();
 
   if (IsUnboundedArray) {
+if (EffectiveType->isFunctionType())
+  return;
 if (index.isUnsigned() || !index.isNegative()) {
   const auto &ASTC = getASTContext();
   unsigned AddrBits =

diff  --git a/clang/test/Sema/unbounded-array-bounds.c 
b/clang/test/Sema/unbounded-array-bounds.c
index e7636c2a9249f..01463158418c6 100644
--- a/clang/test/Sema/unbounded-array-bounds.c
+++ b/clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@ void pr50741(void) {
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}



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


[PATCH] D123680: Add support for ignored bitfield conditional codegen.

2022-04-13 Thread Erich Keane 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 rG6f20744b7ff8: Add support for ignored bitfield conditional 
codegen. (authored by erichkeane).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123680

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp

Index: clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp
@@ -0,0 +1,147 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+struct S {
+  int field1 : 5;
+  int field2 : 6;
+  int field3 : 3;
+};
+
+void use(bool cond, struct S s1, struct S s2, int val1, int val2) {
+  // CHECK: define {{.*}}use{{.*}}(
+  // CHECK: %[[S1:.+]] = alloca %struct.S
+  // CHECK: %[[S2:.+]] = alloca %struct.S
+  // CHECK: %[[COND:.+]] = alloca i8
+  // CHECK: %[[VAL1:.+]] = alloca i32
+  // CHECK: %[[VAL2:.+]] = alloca i32
+
+  cond ? s1.field1 = val1 : s1.field2 = val2;
+  // Condition setup, branch.
+  // CHECK: %[[CONDLD:.+]] = load i8, ptr %[[COND]]
+  // CHECK: %[[TO_BOOL:.+]] = trunc i8 %[[CONDLD]] to i1
+  // CHECK: br i1 %[[TO_BOOL]], label %[[TRUE:.+]], label %[[FALSE:.+]]
+
+  // 'True', branch set the BF, branch to 'end'.
+  // CHECK: [[TRUE]]:
+  // CHECK: %[[VAL1LD:.+]] = load i32, ptr %[[VAL1]]
+  // CHECK: %[[VAL1TRUNC:.+]] = trunc i32 %[[VAL1LD]] to i16
+  // CHECK: %[[BF_LOAD:.+]] = load i16, ptr %[[S1]]
+  // CHECK: %[[BF_VAL:.+]] = and i16 %[[VAL1TRUNC]], 31
+  // CHECK: %[[BF_CLEAR:.+]] = and i16 %[[BF_LOAD]], -32
+  // CHECK: %[[BF_SET:.+]] = or i16 %[[BF_CLEAR]], %[[BF_VAL]]
+  // CHECK: store i16 %[[BF_SET]], ptr %[[S1]]
+  // CHECK: br label %[[END:.+]]
+
+  // 'False', branch set the OTHER BF, branch to 'end'.
+  // CHECK: [[FALSE]]:
+  // CHECK: %[[VAL2LD:.+]] = load i32, ptr %[[VAL2]]
+  // CHECK: %[[VAL2TRUNC:.+]] = trunc i32 %[[VAL2LD]] to i16
+  // CHECK: %[[BF_LOAD:.+]] = load i16, ptr %[[S1]]
+  // CHECK: %[[BF_VAL:.+]] = and i16 %[[VAL2TRUNC]], 63 
+  // CHECK: %[[BF_SHIFT:.+]] = shl i16 %[[BF_VAL]], 5
+  // CHECK: %[[BF_CLEAR:.+]] = and i16 %[[BF_LOAD]], -2017
+  // CHECK: %[[BF_SET:.+]] = or i16 %[[BF_CLEAR]], %[[BF_SHIFT]]
+  // CHECK: store i16 %[[BF_SET]], ptr %[[S1]]
+  // CHECK: br label %[[END:.+]]
+
+  // CHECK: [[END]]:
+  // There is nothing in the 'end' block associated with this, but it is the
+  // 'continuation' block for the rest of the function.
+
+  // Same test, has a no-op cast and parens.
+  (void)(cond ? s2.field1 = val1 : s2.field2 = val2);
+  // Condition setup, branch.
+  // CHECK: %[[CONDLD:.+]] = load i8, ptr %[[COND]]
+  // CHECK: %[[TO_BOOL:.+]] = trunc i8 %[[CONDLD]] to i1
+  // CHECK: br i1 %[[TO_BOOL]], label %[[TRUE:.+]], label %[[FALSE:.+]]
+
+  // 'True', branch set the BF, branch to 'end'.
+  // CHECK: [[TRUE]]:
+  // CHECK: %[[VAL1LD:.+]] = load i32, ptr %[[VAL1]]
+  // CHECK: %[[VAL1TRUNC:.+]] = trunc i32 %[[VAL1LD]] to i16
+  // CHECK: %[[BF_LOAD:.+]] = load i16, ptr %[[S2]]
+  // CHECK: %[[BF_VAL:.+]] = and i16 %[[VAL1TRUNC]], 31
+  // CHECK: %[[BF_CLEAR:.+]] = and i16 %[[BF_LOAD]], -32
+  // CHECK: %[[BF_SET:.+]] = or i16 %[[BF_CLEAR]], %[[BF_VAL]]
+  // CHECK: store i16 %[[BF_SET]], ptr %[[S2]]
+  // CHECK: br label %[[END:.+]]
+
+  // 'False', branch set the OTHER BF, branch to 'end'.
+  // CHECK: [[FALSE]]:
+  // CHECK: %[[VAL2LD:.+]] = load i32, ptr %[[VAL2]]
+  // CHECK: %[[VAL2TRUNC:.+]] = trunc i32 %[[VAL2LD]] to i16
+  // CHECK: %[[BF_LOAD:.+]] = load i16, ptr %[[S2]]
+  // CHECK: %[[BF_VAL:.+]] = and i16 %[[VAL2TRUNC]], 63 
+  // CHECK: %[[BF_SHIFT:.+]] = shl i16 %[[BF_VAL]], 5
+  // CHECK: %[[BF_CLEAR:.+]] = and i16 %[[BF_LOAD]], -2017
+  // CHECK: %[[BF_SET:.+]] = or i16 %[[BF_CLEAR]], %[[BF_SHIFT]]
+  // CHECK: store i16 %[[BF_SET]], ptr %[[S2]]
+  // CHECK: br label %[[END:.+]]
+
+  // CHECK: [[END]]:
+  // CHECK-NOT: phi
+  // There is nothing in the 'end' block associated with this, but it is the
+  // 'continuation' block for the rest of the function.
+
+}
+
+
+void use2(bool cond1, bool cond2, struct S s1, int val1, int val2, int val3) {
+  // CHECK: define {{.*}}use2{{.*}}(
+  // CHECK: %[[S1:.+]] = alloca %struct.S
+  // CHECK: %[[COND1:.+]] = alloca i8
+  // CHECK: %[[COND2:.+]] = alloca i8
+  // CHECK: %[[VAL1:.+]] = alloca i32
+  // CHECK: %[[VAL2:.+]] = alloca i32
+  // CHECK: %[[VAL3:.+]] = alloca i32
+
+  cond1 ? s1.field1 = val1 : cond2 ? s1.field2 = val2 : s1.field3 = val3;
+  // First Condition setup, branch.
+  // CHECK: %[[CONDLD:.+]] = load i8, ptr %[[COND1]]
+  // CHECK: %[[TO_BOOL:.+]] = trunc i8 %[[CONDLD]] to i1
+  // CHECK: br i1 %[[TO_BOOL]], label %[[TRUE:.+]], label %[[FALSE:.+]]
+
+  // First '

[clang] 6f20744 - Add support for ignored bitfield conditional codegen.

2022-04-13 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-04-13T10:33:55-07:00
New Revision: 6f20744b7ff875bb5eb735d1e7636ad6a66d4526

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

LOG: Add support for ignored bitfield conditional codegen.

Currently we emit an error in just about every case of conditionals
with a 'non simple' branch if treated as an LValue.  This patch adds
support for the special case where this is an 'ignored' lvalue, which
permits the side effects from happening.

It also splits up the emit for conditional LValue in a way that should
be usable to handle simple assignment expressions in similar situations.

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

Added: 
clang/test/CodeGenCXX/ignored-bitfield-conditional.cpp

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

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 0c1b201037ff1..848c56dd61dd1 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -189,7 +189,17 @@ llvm::Value *CodeGenFunction::EvaluateExprAsBool(const 
Expr *E) {
 /// ignoring the result.
 void CodeGenFunction::EmitIgnoredExpr(const Expr *E) {
   if (E->isPRValue())
-return (void) EmitAnyExpr(E, AggValueSlot::ignored(), true);
+return (void)EmitAnyExpr(E, AggValueSlot::ignored(), true);
+
+  // if this is a bitfield-resulting conditional operator, we can special case
+  // emit this. The normal 'EmitLValue' version of this is particularly
+  // 
diff icult to codegen for, since creating a single "LValue" for two
+  // 
diff erent sized arguments here is not particularly doable.
+  if (const auto *CondOp = dyn_cast(
+  E->IgnoreParenNoopCasts(getContext( {
+if (CondOp->getObjectKind() == OK_BitField)
+  return EmitIgnoredConditionalOperator(CondOp);
+  }
 
   // Just emit it as an l-value and drop the result.
   EmitLValue(E);
@@ -4570,94 +4580,139 @@ static Optional 
EmitLValueOrThrowExpression(CodeGenFunction &CGF,
   return CGF.EmitLValue(Operand);
 }
 
-LValue CodeGenFunction::
-EmitConditionalOperatorLValue(const AbstractConditionalOperator *expr) {
-  if (!expr->isGLValue()) {
-// ?: here should be an aggregate.
-assert(hasAggregateEvaluationKind(expr->getType()) &&
-   "Unexpected conditional operator!");
-return EmitAggExprToLValue(expr);
-  }
-
-  OpaqueValueMapping binding(*this, expr);
-
-  const Expr *condExpr = expr->getCond();
+namespace {
+// Handle the case where the condition is a constant evaluatable simple 
integer,
+// which means we don't have to separately handle the true/false blocks.
+llvm::Optional HandleConditionalOperatorLValueSimpleCase(
+CodeGenFunction &CGF, const AbstractConditionalOperator *E) {
+  const Expr *condExpr = E->getCond();
   bool CondExprBool;
-  if (ConstantFoldsToSimpleInteger(condExpr, CondExprBool)) {
-const Expr *live = expr->getTrueExpr(), *dead = expr->getFalseExpr();
-if (!CondExprBool) std::swap(live, dead);
+  if (CGF.ConstantFoldsToSimpleInteger(condExpr, CondExprBool)) {
+const Expr *Live = E->getTrueExpr(), *Dead = E->getFalseExpr();
+if (!CondExprBool)
+  std::swap(Live, Dead);
 
-if (!ContainsLabel(dead)) {
+if (!CGF.ContainsLabel(Dead)) {
   // If the true case is live, we need to track its region.
   if (CondExprBool)
-incrementProfileCounter(expr);
+CGF.incrementProfileCounter(E);
   // If a throw expression we emit it and return an undefined lvalue
   // because it can't be used.
-  if (auto *ThrowExpr = dyn_cast(live->IgnoreParens())) {
-EmitCXXThrowExpr(ThrowExpr);
-llvm::Type *ElemTy = ConvertType(dead->getType());
+  if (auto *ThrowExpr = dyn_cast(Live->IgnoreParens())) {
+CGF.EmitCXXThrowExpr(ThrowExpr);
+llvm::Type *ElemTy = CGF.ConvertType(Dead->getType());
 llvm::Type *Ty = llvm::PointerType::getUnqual(ElemTy);
-return MakeAddrLValue(
+return CGF.MakeAddrLValue(
 Address(llvm::UndefValue::get(Ty), ElemTy, CharUnits::One()),
-dead->getType());
+Dead->getType());
   }
-  return EmitLValue(live);
+  return CGF.EmitLValue(Live);
 }
   }
+  return llvm::None;
+}
+struct ConditionalInfo {
+  llvm::BasicBlock *lhsBlock, *rhsBlock;
+  Optional LHS, RHS;
+};
 
-  llvm::BasicBlock *lhsBlock = createBasicBlock("cond.true");
-  llvm::BasicBlock *rhsBlock = createBasicBlock("cond.false");
-  llvm::BasicBlock *contBlock = createBasicBlock("cond.end");
+// Create and generate the 3 blocks for a conditional operator.
+// Leaves the 'current block' in the continuation basic block.
+template
+ConditionalInfo EmitConditionalBlocks(CodeGenFunction &CGF,
+ 

[PATCH] D123680: Add support for ignored bitfield conditional codegen.

2022-04-13 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D123680

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


[libunwind] 7165edc - [libunwind][AIX] implementation of the unwinder for AIX

2022-04-13 Thread Xing Xue via cfe-commits

Author: Xing Xue
Date: 2022-04-13T13:18:10-04:00
New Revision: 7165edcad76fec2e025414ddf44e76363806fc3d

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

LOG: [libunwind][AIX] implementation of the unwinder for AIX

NFC - revert identation changes in AddressSpace.hpp from the previous commit

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

Added: 


Modified: 
libunwind/src/AddressSpace.hpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 3d5c001608d05..5fc9ee3fe6c38 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -24,11 +24,11 @@
 #include "Registers.hpp"
 
 #ifndef _LIBUNWIND_USE_DLADDR
-#if !(defined(_LIBUNWIND_IS_BAREMETAL) || defined(_WIN32) || defined(_AIX))
-#define _LIBUNWIND_USE_DLADDR 1
-#else
-#define _LIBUNWIND_USE_DLADDR 0
-#endif
+  #if !(defined(_LIBUNWIND_IS_BAREMETAL) || defined(_WIN32) || defined(_AIX))
+#define _LIBUNWIND_USE_DLADDR 1
+  #else
+#define _LIBUNWIND_USE_DLADDR 0
+  #endif
 #endif
 
 #if _LIBUNWIND_USE_DLADDR



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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 422557.
cor3ntin added a comment.

Cleanup SemaLambda as discussed with Aaron


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1356,7 +1356,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 15
 
 
   Multidimensional subscript operator
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,156 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+
+  static_assert(noexcept([&] mutable noexcept(!is_same) {}())); //expected-error {{static_assert failed due}}
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}
+  ();
+  [x = 1]() mutable requires is_same {}
+  ();
+  [x]() requires is_same {}
+  ();
+  [x]() mutable requires is_same {}
+  ();
+  [=]() requires is_same {}
+  ();
+  [=]() mutable requires is_same {}
+  ();
+  [&]() requires is_same {}
+  ();
+  [&]() mutable requires is_same {}
+  ();
+  [&x]() requires is_same {}
+  ();
+  [&x]() mutable requires is_same {}
+  ();
+
+  [x = 1]() requires is_same {} (); //expected-error {{no matching function for call to object of type}} \
+   // expected-note {{candidate function not viable}} \
+   // expected-note {{'is_same' evaluated to false}}
+  [x = 1]() mutable requires is_same {} (); // expected-error {{no matching function for call to object of type}} \
+ // expected-note {{candidate function not viable}} \
+ // expected-note {{'is_same' evaluated to false}}
+}
+
+void err() {
+  int y, z;// expected-note 2{{declared here}}
+  auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
+  decltype(
+  [&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear here}}
+return y;
+  };
+
+  auto init_tpl = [x = 1](  // expected-note{{explicitly captured her

[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

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



Comment at: clang/lib/Sema/SemaLambda.cpp:1127-1132
+  auto it = LSI->DelayedCaptures.end();
+  if (Var)
+it = llvm::find_if(LSI->DelayedCaptures, [&Var](auto &&Pair) {
+  return Pair.second.Var == Var;
+});
+  if (it != LSI->DelayedCaptures.end()) {

cor3ntin wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > ChuanqiXu wrote:
> > > > I feel like my suggested change is simpler.
> > > +1 to this suggestion being a bit easier to read.
> > With that changes, a capture that is not in the delayed capture list forces 
> > us to go through the list of capture anyway, which seems like a waste.
> > So this is not just about readability. it should still work,  and only 
> > really matter for error cases, but it's still not identical code.
> Alternatively, I guess I can change the order of operation to ensure Var is 
> never null here, and that would probably be cleaner!
Ah, thank you for pointing out that this was also about performance. If you're 
able to clean it up by changing the order of operations, that'd be good, but if 
it turns into a slog, I don't insist.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:1127-1132
+  auto it = LSI->DelayedCaptures.end();
+  if (Var)
+it = llvm::find_if(LSI->DelayedCaptures, [&Var](auto &&Pair) {
+  return Pair.second.Var == Var;
+});
+  if (it != LSI->DelayedCaptures.end()) {

cor3ntin wrote:
> aaron.ballman wrote:
> > ChuanqiXu wrote:
> > > I feel like my suggested change is simpler.
> > +1 to this suggestion being a bit easier to read.
> With that changes, a capture that is not in the delayed capture list forces 
> us to go through the list of capture anyway, which seems like a waste.
> So this is not just about readability. it should still work,  and only really 
> matter for error cases, but it's still not identical code.
Alternatively, I guess I can change the order of operation to ensure Var is 
never null here, and that would probably be cleaner!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-04-13 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:1127-1132
+  auto it = LSI->DelayedCaptures.end();
+  if (Var)
+it = llvm::find_if(LSI->DelayedCaptures, [&Var](auto &&Pair) {
+  return Pair.second.Var == Var;
+});
+  if (it != LSI->DelayedCaptures.end()) {

aaron.ballman wrote:
> ChuanqiXu wrote:
> > I feel like my suggested change is simpler.
> +1 to this suggestion being a bit easier to read.
With that changes, a capture that is not in the delayed capture list forces us 
to go through the list of capture anyway, which seems like a waste.
So this is not just about readability. it should still work,  and only really 
matter for error cases, but it's still not identical code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D122683: [OpenMP] Use new offloading binary when embedding offloading images

2022-04-13 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 422547.
jhuber6 added a comment.

Cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122683

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Frontend/embed-object.c
  clang/test/Frontend/embed-object.ll
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  llvm/include/llvm/Object/OffloadBinary.h
  llvm/include/llvm/Transforms/Utils/ModuleUtils.h
  llvm/lib/Transforms/Utils/ModuleUtils.cpp

Index: llvm/lib/Transforms/Utils/ModuleUtils.cpp
===
--- llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -265,15 +265,15 @@
 }
 
 void llvm::embedBufferInModule(Module &M, MemoryBufferRef Buf,
-   StringRef SectionName) {
-  // Embed the buffer into the module.
+   StringRef SectionName, Align Alignment) {
+  // Embed the memory buffer into the module.
   Constant *ModuleConstant = ConstantDataArray::get(
   M.getContext(), makeArrayRef(Buf.getBufferStart(), Buf.getBufferSize()));
   GlobalVariable *GV = new GlobalVariable(
-  M, ModuleConstant->getType(), true, GlobalValue::ExternalLinkage,
-  ModuleConstant, SectionName.drop_front());
+  M, ModuleConstant->getType(), true, GlobalValue::PrivateLinkage,
+  ModuleConstant, "llvm.embedded.object");
   GV->setSection(SectionName);
-  GV->setVisibility(GlobalValue::HiddenVisibility);
+  GV->setAlignment(Alignment);
 
   appendToCompilerUsed(M, GV);
 }
Index: llvm/include/llvm/Transforms/Utils/ModuleUtils.h
===
--- llvm/include/llvm/Transforms/Utils/ModuleUtils.h
+++ llvm/include/llvm/Transforms/Utils/ModuleUtils.h
@@ -14,6 +14,7 @@
 #define LLVM_TRANSFORMS_UTILS_MODULEUTILS_H
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Alignment.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include  // for std::pair
 
@@ -109,7 +110,8 @@
 
 /// Embed the memory buffer \p Buf into the module \p M as a global using the
 /// specified section name.
-void embedBufferInModule(Module &M, MemoryBufferRef Buf, StringRef SectionName);
+void embedBufferInModule(Module &M, MemoryBufferRef Buf, StringRef SectionName,
+ Align Alignment = Align(1));
 
 class CallInst;
 namespace VFABI {
Index: llvm/include/llvm/Object/OffloadBinary.h
===
--- llvm/include/llvm/Object/OffloadBinary.h
+++ llvm/include/llvm/Object/OffloadBinary.h
@@ -73,6 +73,7 @@
 
   ImageKind getImageKind() const { return TheEntry->TheImageKind; }
   OffloadKind getOffloadKind() const { return TheEntry->TheOffloadKind; }
+  uint32_t getVersion() const { return TheHeader->Version; }
   uint32_t getFlags() const { return TheEntry->Flags; }
   uint64_t getSize() const { return TheHeader->Size; }
 
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -29,6 +29,7 @@
 #include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/Binary.h"
 #include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/FileOutputBuffer.h"
@@ -146,8 +147,8 @@
 static codegen::RegisterCodeGenFlags CodeGenFlags;
 
 /// Magic section string that marks the existence of offloading data. The
-/// section string will be formatted as `.llvm.offloading..`.
-#define OFFLOAD_SECTION_MAGIC_STR ".llvm.offloading."
+/// section will contain one or more offloading binaries stored contiguously.
+#define OFFLOAD_SECTION_MAGIC_STR ".llvm.offloading"
 
 /// Information for a device offloading file extracted from the host.
 struct DeviceFile {
@@ -201,16 +202,6 @@
 llvm::errs() << *IC << (std::next(IC) != IE ? " " : "\n");
 }
 
-static StringRef getDeviceFileExtension(StringRef DeviceTriple,
-bool IsBitcode = false) {
-  Triple TheTriple(DeviceTriple);
-  if (TheTriple.isAMDGPU() || IsBitcode)
-return "bc";
-  if (TheTriple.isNVPTX())
-return "cubin";
-  return "o";
-}
-
 std::string getMainExecutable(const char *Name) {
   void *Ptr = (void *)(intptr_t)&getMainExecutable;
   auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
@@ -296,39 +287,58 @@
   StringRef Prefix = sys::path::stem(Obj.getFileName());
   SmallVector ToBeStripped;
 
-  // Extract data from sections of the form `.llvm.offloading..`.
+  // Extract offloading binaries from sections with the name `.llvm.offloading`.
   for (const SectionRef &Sec : Obj

[PATCH] D123498: [clang] Adding Platform/Architecture Specific Resource Header Installation Targets

2022-04-13 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:173
   __wmmintrin_pclmul.h
   x86gprintrin.h
   x86intrin.h

qiongsiwu1 wrote:
> abhina.sreeskantharajan wrote:
> > nit: There are some x86 headers here that appear to be x86 only. Should 
> > these be moved to x86_files list?
> Thanks for the comment! Yes indeed. I think currently the `x86gprintrin.h` 
> header is in the `x86_files` list (list starts at line 88). Did I miss some 
> other x86 files? 
Ah sorry, you're right, I think I read the list wrong. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123498

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


[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

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

LGTM! When landing, please revert the changes to SemaDecl.cpp (no need to churn 
that file) and apply the one suggested refactoring (I commented to make it more 
clear which one I mean).




Comment at: clang/lib/Sema/SemaLambda.cpp:1127-1132
+  auto it = LSI->DelayedCaptures.end();
+  if (Var)
+it = llvm::find_if(LSI->DelayedCaptures, [&Var](auto &&Pair) {
+  return Pair.second.Var == Var;
+});
+  if (it != LSI->DelayedCaptures.end()) {

ChuanqiXu wrote:
> I feel like my suggested change is simpler.
+1 to this suggestion being a bit easier to read.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


  1   2   >