[PATCH] D147764: Fix the two gmoules-prefered-name-* tests

2023-04-07 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment.

This is an obvious fix and builds are still broken. Go ahead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147764

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


[clang] 53d8b59 - Fix the two gmoules-prefered-name-* tests

2023-04-07 Thread YongKang Zhu via cfe-commits

Author: YongKang Zhu
Date: 2023-04-07T00:12:29-07:00
New Revision: 53d8b59307d4e1bbaa1632efbe762014c9f6575e

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

LOG: Fix the two gmoules-prefered-name-* tests

Add missing "REQUIRES: asserts" for the two tests added in commit
711a64412749ae73709562b591ab1609a3ee7751 (Diff: D145803).

Reviewed By: chapuni

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

Added: 


Modified: 
clang/test/Modules/gmodules-preferred-name-alias.cpp
clang/test/Modules/gmodules-preferred-name-typedef.cpp

Removed: 




diff  --git a/clang/test/Modules/gmodules-preferred-name-alias.cpp 
b/clang/test/Modules/gmodules-preferred-name-alias.cpp
index 4eba07c7d2594..687125c86e9fb 100644
--- a/clang/test/Modules/gmodules-preferred-name-alias.cpp
+++ b/clang/test/Modules/gmodules-preferred-name-alias.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: asserts
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
 // RUN: 
-fmodule-map-file=%S/Inputs/gmodules-preferred-name-alias.modulemap \

diff  --git a/clang/test/Modules/gmodules-preferred-name-typedef.cpp 
b/clang/test/Modules/gmodules-preferred-name-typedef.cpp
index e4738089d9893..e6a8f3ef4c68e 100644
--- a/clang/test/Modules/gmodules-preferred-name-typedef.cpp
+++ b/clang/test/Modules/gmodules-preferred-name-typedef.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: asserts
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
 // RUN: 
-fmodule-map-file=%S/Inputs/gmodules-preferred-name-typedef.modulemap \



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


[PATCH] D147764: Fix the two gmoules-prefered-name-* tests

2023-04-07 Thread YongKang Zhu 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 rG53d8b59307d4: Fix the two gmoules-prefered-name-* tests 
(authored by yozhu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147764

Files:
  clang/test/Modules/gmodules-preferred-name-alias.cpp
  clang/test/Modules/gmodules-preferred-name-typedef.cpp


Index: clang/test/Modules/gmodules-preferred-name-typedef.cpp
===
--- clang/test/Modules/gmodules-preferred-name-typedef.cpp
+++ clang/test/Modules/gmodules-preferred-name-typedef.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: asserts
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
 // RUN: 
-fmodule-map-file=%S/Inputs/gmodules-preferred-name-typedef.modulemap \
Index: clang/test/Modules/gmodules-preferred-name-alias.cpp
===
--- clang/test/Modules/gmodules-preferred-name-alias.cpp
+++ clang/test/Modules/gmodules-preferred-name-alias.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: asserts
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
 // RUN: 
-fmodule-map-file=%S/Inputs/gmodules-preferred-name-alias.modulemap \


Index: clang/test/Modules/gmodules-preferred-name-typedef.cpp
===
--- clang/test/Modules/gmodules-preferred-name-typedef.cpp
+++ clang/test/Modules/gmodules-preferred-name-typedef.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: asserts
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
 // RUN: -fmodule-map-file=%S/Inputs/gmodules-preferred-name-typedef.modulemap \
Index: clang/test/Modules/gmodules-preferred-name-alias.cpp
===
--- clang/test/Modules/gmodules-preferred-name-alias.cpp
+++ clang/test/Modules/gmodules-preferred-name-alias.cpp
@@ -1,3 +1,4 @@
+// REQUIRES: asserts
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -std=c++11 -dwarf-ext-refs -fmodule-format=obj \
 // RUN: -fmodule-map-file=%S/Inputs/gmodules-preferred-name-alias.modulemap \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147742: [python] Enable bindings tests on Windows

2023-04-07 Thread Artur Ryt via Phabricator via cfe-commits
R2RT added a comment.

According to CI logs, these tests are still not run on Windows builder.
Line below, present in Debian's log, is missing.

  [9746/10613] cd 
/var/lib/buildkite-agent/builds/llvm-project/clang/bindings/python && 
/usr/bin/cmake -E env CLANG_NO_DEFAULT_CONFIG=1 
CLANG_LIBRARY_PATH=/var/lib/buildkite-agent/builds/llvm-project/build/lib 
/usr/bin/python3.9 -m unittest discover

Further investigation is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147742

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


[clang] f197521 - [Clang] Fix markup in cxx_status

2023-04-07 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-04-07T09:42:54+02:00
New Revision: f1975216846ed69d608e669c37efa5ee0e16276e

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

LOG: [Clang] Fix markup in cxx_status

This reverts the changes to cxx_status introduced
by https://reviews.llvm.org/D146178, as it did
break the html markup

While This PR resolves a bug related to concepts,
it doesn't seem useful to change the advertised implementation
of that paper many years after the fact, especially as the
paper encompasses many issue resolution.

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 601908b58a8f7..fe2a16d9cee1f 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -947,6 +947,9 @@ C++20 implementation status
   
 https://wg21.link/p1980r0";>P1980R0
   
+   
+https://wg21.link/p2103r0";>P2103R0
+  

 https://wg21.link/p2493r0";>P2493R0
   
@@ -958,9 +961,6 @@ C++20 implementation status
 https://wg21.link/p2113r0";>P2113R0
 Clang 16
   
-  
-https://wg21.link/p2103r0";>P2103R0
-  
 
 
   Range-based for statements with initializer



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


[PATCH] D146376: Update static_assert message for redundant cases

2023-04-07 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 511630.
Krishna-13-cyber added a comment.

Thanks a lot everyone for helping me out with my first patch. I have uploaded 
the patch again after rebase.
Yes, It would be great if you could land it on my behalf.
Name: Krishna Narayanan
Email: 

Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/static-assert.cpp


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error 
{{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note 
{{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion 
failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error 
{{static assertion failed due to requirement 'invert(true) || invert(true) || 
false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error 
{{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error 
{{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16718,7 +16718,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast(E)) {
+  if (const auto *Op = dyn_cast(E);
+  Op && Op->getOpcode() != BO_LOr) {
 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -213,6 +213,9 @@
 - There were some cases in which the diagnostic for the unavailable attribute
   might not be issued, this fixes those cases.
   (`61815 `_)
+- Clang now avoids unnecessary diagnostic warnings for obvious expressions in
+  the case of binary operators with logical OR operations.
+  (`#57906 `_)
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note {{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error {{static assertion failed due to requirement 'invert(true) || invert(true) || false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error {{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error {{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16718,7 +16718,8 @@
 /// Try to pri

[PATCH] D137782: [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 511634.
courbet added a comment.

Fix release note placement and phrase it more consistenly with other notes in 
that section.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137782

Files:
  clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
@@ -1,39 +1,67 @@
-// RUN: %check_clang_tidy %s bugprone-fold-init-type %t
+// RUN: %check_clang_tidy %s bugprone-fold-init-type -std=c++17 %t
 
 namespace std {
 template 
-T accumulate(InputIt first, InputIt last, T init);
+T accumulate(InputIt first, InputIt last, T init) {
+  // When `InputIt::operator*` returns a deduced `auto` type that refers to a
+  // dependent type, the return type is deduced only if `InputIt::operator*`
+  // is instantiated. In practice this happens somewhere in the implementation
+  // of `accumulate`. For tests, do it here.
+  (void)*first;
+}
 
 template 
-T reduce(InputIt first, InputIt last, T init);
+T reduce(InputIt first, InputIt last, T init) { (void)*first; }
 template 
 T reduce(ExecutionPolicy &&policy,
- InputIt first, InputIt last, T init);
+ InputIt first, InputIt last, T init) { (void)*first; }
 
 struct parallel_execution_policy {};
 constexpr parallel_execution_policy par{};
 
 template 
 T inner_product(InputIt1 first1, InputIt1 last1,
-InputIt2 first2, T value);
+InputIt2 first2, T value) { (void)*first1; (void)*first2; }
 
 template 
 T inner_product(ExecutionPolicy &&policy, InputIt1 first1, InputIt1 last1,
-InputIt2 first2, T value);
+InputIt2 first2, T value) { (void)*first1; (void)*first2; }
 
 } // namespace std
 
 struct FloatIterator {
-  typedef float value_type;
+  const float &operator*() const;
 };
+
+struct DerivedFloatIterator : public FloatIterator {
+};
+
+template  struct ByValueTemplateIterator {
+  ValueType operator*() const;
+};
+
+template  struct ByRefTemplateIterator {
+  ValueType &operator*();
+};
+
+template  struct ByRefTemplateIteratorWithAlias {
+  using reference = const ValueType&;
+  reference operator*();
+};
+
+template  struct AutoByValueTemplateIterator {
+  auto operator*() const { return ValueType{}; }
+};
+
+template  struct AutoByRefTemplateIterator {
+  decltype(auto) operator*() const { return value_; }
+  ValueType value_;
+};
+
 template 
-struct TypedefTemplateIterator { typedef ValueType value_type; };
-template 
-struct UsingTemplateIterator { using value_type = ValueType; };
-template 
-struct DependentTypedefTemplateIterator { typedef typename ValueType::value_type value_type; };
-template 
-struct DependentUsingTemplateIterator : public TypedefTemplateIterator { using typename TypedefTemplateIterator::value_type; };
+struct InheritingByConstRefTemplateIterator
+: public ByRefTemplateIterator {};
+
 using TypedeffedIterator = FloatIterator;
 
 // Positives.
@@ -51,39 +79,57 @@
 }
 
 int accumulatePositive3() {
+  DerivedFloatIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive4() {
   double a[1] = {0.0};
   return std::accumulate(a, a + 1, 0.0f);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'double' into type 'float'
 }
 
-int accumulatePositive4() {
-  TypedefTemplateIterator it;
+int accumulatePositive5() {
+  ByValueTemplateIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
 }
 
-int accumulatePositive5() {
-  UsingTemplateIterator it;
+int accumulatePositive6() {
+  ByRefTemplateIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
 }
 
-int accumulatePositive6() {
-  DependentTypedefTemplateIterator> it;
+int accumulatePositive7() {
+  AutoByValueTemplateIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
 }
 
-int accumulatePositive7() {
+int accumulatePositive8() {
   TypedeffedIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
 }
 
-int accumulatePositive8() {
-  DependentUsingTemplateIterator it;
+int accumulatePositive9() {
+  InheritingByConstRefTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned 

[PATCH] D147731: [3/N][POC][Clang] Add typedef of the tuple type and define tuple type variant of vlseg2e32

2023-04-07 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 511635.
eopXD added a comment.

Change: Add overloaded name `vlseg2e32_tuple` for the tuple type variant
to avoid naming collision to the existing non-tuple type overloaded
intrinsics of `vlseg2e32`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147731

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32_tuple.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -68,6 +68,7 @@
   bool HasMaskedOffOperand :1;
   bool HasTailPolicy : 1;
   bool HasMaskPolicy : 1;
+  bool IsTuple : 1;
   uint8_t UnMaskedPolicyScheme : 2;
   uint8_t MaskedPolicyScheme : 2;
 };
@@ -366,6 +367,16 @@
 TypeModifier::UnsignedInteger));
 printType(*UT);
   }
+  // FIXME: Expand more type declaration
+  if (I == 'i' && Log2LMUL == 0) { // vint32m1x2_t
+auto TupleT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector,
+VectorTypeModifier::Tuple2,
+TypeModifier::SignedInteger));
+if (TupleT)
+  printType(*TupleT);
+  }
 }
   }
 
@@ -515,6 +526,7 @@
 StringRef IRName = R->getValueAsString("IRName");
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
+bool IsTuple = R->getValueAsBit("IsTuple");
 
 const Policy DefaultPolicy;
 SmallVector SupportedUnMaskedPolicies =
@@ -535,10 +547,10 @@
 auto Prototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF, UnMaskedPolicyScheme,
-DefaultPolicy);
+DefaultPolicy, IsTuple);
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-MaskedPolicyScheme, DefaultPolicy);
+MaskedPolicyScheme, DefaultPolicy, IsTuple);
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -560,14 +572,14 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-DefaultPolicy));
+DefaultPolicy, IsTuple));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
 RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF,
-UnMaskedPolicyScheme, P);
+UnMaskedPolicyScheme, P, IsTuple);
 std::optional PolicyTypes =
 TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
 Out.push_back(std::make_unique(
@@ -575,7 +587,7 @@
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
-NF, P));
+NF, P, IsTuple));
   }
 if (!HasMasked)
   continue;
@@ -586,14 +598,14 @@
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
 SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
-IntrinsicTypes, RequiredFeatures, NF, DefaultPolicy));
+IntrinsicTypes, RequiredFeatures, NF, DefaultPolicy, IsTuple));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
   SmallVector PolicyPrototype =
   RVVIntrinsic::computeBuiltinTypes(
   BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  NF, MaskedPolicyScheme, P);
+  NF, MaskedPolicyScheme, P, IsTuple);
   std::optional PolicyTypes =
   TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
   Out.push_back(std::make_unique(
@@ -601,7 +613,7 @@
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   MaskedPolicySc

[PATCH] D146376: Update static_assert message for redundant cases

2023-04-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

So.. new diagnostic is:

  :4:1: error: static assertion failed due to requirement 'is_gitlab'
  static_assert(is_gitlab and is_weekend);
  ^ ~

Okay, a dev changes is_gitlab to true, compiles it again and boom, new error: 
static assertion failed due to requirement 'is_weekend'. With previous version 
of this diagnostic one can see all problems immediatelly. So I am not sure if I 
consider this change as a real improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

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


[PATCH] D147774: [4/N][POC][Clang] Define tuple type variant of vsseg2e32

2023-04-07 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, rogfer01, frasercrmck, reames, kito-cheng, 
nikic.
Herald added subscribers: luke, StephenFan, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

For the cover letter of this patch-set, please checkout D146872 
.

Depends on D147731 .

This is the 4th patch of the patch-set.

This patch is a proof-of-concept and will be extended to full coverage
in the future. Currently, the old non-tuple unit-stride segment store is
not removed, and only signed integer unit-strided segment store of NF=2,
EEW=32 is defined here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147774

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
@@ -0,0 +1,31 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } undef,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_tuple_i32m1(int32_t *base, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_v_tuple_i32m1(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[V0:%.*]],  [[V1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.mask.nxv2i32.i64( [[V0]],  [[V1]], ptr [[BASE]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_i32m1_m(vbool32_t mask, int32_t *base, vint32m1_t v0, vint32m1_t v1, size_t vl) {
+  return __riscv_vsseg2e32_v_i32m1_m(mask, base, v0, v1, vl);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -19602,6 +19602,14 @@
   }
 
   for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
+// Handle aggregate argument, namely RVV tuple types in segment load/store
+if (hasAggregateEvaluationKind(E->getArg(i)->getType())) {
+  LValue L = EmitAggExprToLValue(E->getArg(i));
+  llvm::Value *AggValue = Builder.CreateLoad(L.getAddress(*this));
+  Ops.push_back(AggValue);
+  continue;
+}
+
 // If this is a normal argument, just emit it as a scalar.
 if ((ICEArguments & (1 << i)) == 0) {
   Ops.push_back(EmitScalarExpr(E->getArg(i)));
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1779,11 +1779,57 @@
 }
   }
 }
-// TODO: Extend for policy
+
+multiclass RVVUnitStridedSegStoreTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+foreach nf = [2] in {
+  let Name = op # nf # "e" # eew # "_v_tuple",
+  OverloadedName = op # nf # "e" # eew # "_tuple",
+  IRName = op # nf,
+  MaskedIRName = op # nf # "_mask",
+  NF = nf,
+  HasMaskedOffOperand = false,
+  ManualCodegen = [{
+{
+  // Masked
+  // Builtin: (mask, ptr, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, mask, vl)
+  // Unmasked
+  // Builtin: (ptr, v_tuple, vl)
+ 

[PATCH] D146591: [dataflow] add HTML logger: browse code/cfg/analysis timeline/state

2023-04-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

doh, forgot to send




Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp:128
+*OS << "" << HTMLLogger_css << "\n";
+*OS << "" << HTMLLogger_js << "\n";
+

gribozavr2 wrote:
> Now that we have an HTML template file, you could inline css and js into the 
> file - if you like.
I find having them out of line much easier to navigate and edit.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.html:19
+Function
+
+

gribozavr2 wrote:
> sammccall wrote:
> > gribozavr2 wrote:
> > > Could you add the file name and line number of the start location of the 
> > > function?
> > > 
> > > It might be helpful not only for the reader (to confirm that they are 
> > > debugging the right thing), but also when finding the right html file 
> > > using grep.
> > Added filename to the top of the code, and line numbers to each line.
> > (This seems nice for display, but doesn't allow you to grep for 
> > `foo.cpp:42` - is that critical?)
> Imagine you're debugging an analysis on a relatively big file. How would you 
> find the html file that corresponds to a function where the analysis is 
> misbehaving? What if the function has a relatively common name?
Fair enough, added the function name and file:line to the  (in HTML 
rather than JS so they can be easily grepped)



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.js:45
+  }
+  root.hidden = false;
+  if (changed) {

gribozavr2 wrote:
> Should `hidden = false` be under `if (changed)`?
> 
> Or can it be the case that nothing changed, but we still need to show the 
> element?
Moved it under the element, I'm not sure which is conceptually simpler.

It's not possible that we need to show but `!changed`, because either:
 - this is the first call (and changed is initialized to true), or
 - the previous call early-returned, in which case root.selection[key] was set 
to null for some key on the last call, and because we got here it was nonnull 
on this call, so again changed is true.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.js:47-50
+for (tmpl of root.getElementsByTagName('template')) {
+  // Clear previously rendered template contents.
+  while (tmpl.nextSibling && tmpl.nextSibling.inflated)
+tmpl.parentNode.removeChild(tmpl.nextSibling);

gribozavr2 wrote:
> Would it make sense to move this removal logic into `inflate` itself?
> 
> (Of course the recursive part of `inflate` would stay as a separate function, 
> `inflateImpl` or something.)
I think we end up with a 60 line function wrapped in a +4 line function, and 
the nesting causes more confusion than it solves. I don't think clearing the 
old content matches the name `inflate` either.

Happy to pull out `reinflate()` as a sibling if you think it helps - with one 
callsite I'm not sure it does.



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.js:124
+//   hover: a function from target to the class name to highlight
+//   bb: a function from target to the basic-block name to select (BB4)A
+//   elt: a function from target to the CFG element name to select (BB4.5)

gribozavr2 wrote:
> What's "A" in "(BB4)A"?
a typo :-(



Comment at: clang/lib/Analysis/FlowSensitive/HTMLLogger.js:184
+}
+function classSelector(cls) {
+  if (cls == null) return null;

gribozavr2 wrote:
> Could you add a doc comment that describes what cls is?
> 
> Specifically, I see that in the array case we assume that the dot is already 
> present, and in the single-value case we prepend the dot - is that 
> intentional?
> Could you add a doc comment that describes what cls is?
Added a comment.
I can also make this function a bit less magic at the cost of a bit more 
verbosity elsewhere (`id="foo"` => `id="foo" class="foo"` in the HTML, `e => 
e.id` => `e => [e.id]` in the JS).

> Specifically, I see that in the array case we assume that the dot is already 
> present, and in the single-value case we prepend the dot - is that 
> intentional?

In the array case we call `classSelector` on each element recursively, so the 
dot gets added there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146591

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


[PATCH] D147764: Fix the two gmoules-prefered-name-* tests

2023-04-07 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

Thanks for fixing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147764

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


[PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

2023-04-07 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D147655#4250056 , @rsmith wrote:

> There has not been any stable ABI from any compiler targeting the Itanium C++ 
> ABI for constrained templates prior to this change. I don't think we need to 
> worry too much about people using unfinished compiler features being broken 
> when those features are finished.

The ABI has been stable for quite some time and people have been using concepts 
with it for almost 3 years now. I'm not sure we can still break ABI this 
easily. But then, I also have no data to say we can't.

> The ABI proposals haven't been accepted yet; I'm not intending to land this 
> change until the proposals have reached consensus in the Itanium C++ ABI 
> group.

Thanks for clarifying!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147655

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


[PATCH] D147779: [clang-tidy] Fix hungarian notation failed to indicate the number of asterisks in check-clang-extra-clang-tidy-checkers-readability

2023-04-07 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob created this revision.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
dougpuob requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fix hungarian notation failed to indicate the number of asterisks for the 
pointers of multiple word types.

- WRONG: `unsigned char* value`  : `value` --> `ucValue`
- RIGHT: `unsigned cahr* value`  : `value' --> `pucValue`
- RIGHT: `unsigned char** value` : `value' --> 'ppucValue'


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147779

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-c-language.c
  
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation.cpp
@@ -355,6 +355,14 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global pointer 'ValueU8Ptr' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}uint8_t *pu8ValueU8Ptr;
 
+unsigned char *ValueUcPtr;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'ValueUcPtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}unsigned char *pucValueUcPtr;
+
+unsigned char **ValueUcPtr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global pointer 'ValueUcPtr2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}unsigned char **ppucValueUcPtr2;
+
 void MyFunc2(void* Val){}
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for pointer parameter 'Val' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}void MyFunc2(void* pVal){}
Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-cfgfile.cpp
@@ -355,6 +355,14 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global pointer 'ValueU8Ptr' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}uint8_t *custpcustu8ValueU8Ptr;
 
+unsigned char *ValueUcPtr;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'ValueUcPtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}unsigned char *custpcustucValueUcPtr;
+
+unsigned char **ValueUcPtr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global pointer 'ValueUcPtr2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}unsigned char **custpcustpcustucValueUcPtr2;
+
 void MyFunc2(void* Val){}
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for pointer parameter 'Val' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}void MyFunc2(void* custpcustvVal){}
Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-c-language.c
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-c-language.c
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-hungarian-notation-c-language.c
@@ -283,6 +283,14 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for global pointer 'ValueU8Ptr' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}uint8_t *pu8ValueU8Ptr;
 
+unsigned char *ValueUcPtr;
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for global pointer 'ValueUcPtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}unsigned char *pucValueUcPtr;
+
+unsigned char **ValueUcPtr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: invalid case style for global pointer 'ValueUcPtr2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}unsigned char **ppucValueUcPtr2;
+
 void MyFunc2(void* Val){}
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: invalid case style for pointer parameter 'Val' [readability-identifier-naming]
 // CHECK-FIXES: {{^}}void MyFunc2(void* pVal){}
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
+++ cl

[PATCH] D147655: Implement mangling rules for C++20 concepts and requires-expressions.

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147655#4250922 , @royjacobson 
wrote:

> In D147655#4250056 , @rsmith wrote:
>
>> There has not been any stable ABI from any compiler targeting the Itanium 
>> C++ ABI for constrained templates prior to this change. I don't think we 
>> need to worry too much about people using unfinished compiler features being 
>> broken when those features are finished.
>
> The ABI has been stable for quite some time and people have been using 
> concepts with it for almost 3 years now. I'm not sure we can still break ABI 
> this easily. But then, I also have no data to say we can't.

We've never claimed full support for concepts, so those folks would be relying 
on an unstable ABI. However, if it turns out this causes significant pain in 
practice, perhaps we could use ABI tags to give folks the older ABI? I'd prefer 
to avoid that in this case given that the feature isn't yet fully supported (I 
don't like the idea of setting a precedent for relying on the ABI of incomplete 
features in general), but concepts is a sufficiently important use case that I 
could imagine doing it as a one-off if needed.

>> The ABI proposals haven't been accepted yet; I'm not intending to land this 
>> change until the proposals have reached consensus in the Itanium C++ ABI 
>> group.
>
> Thanks for clarifying!




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147655

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-04-07 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2357-2361
+if (SubobjectDecl) {
+  Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << 
SubobjectDecl;
+  Info.Note(SubobjectDecl->getLocation(),
+diag::note_constexpr_subobject_declared_here);
+}

tbaeder wrote:
> aaron.ballman wrote:
> > hazohelet wrote:
> > > aaron.ballman wrote:
> > > > Hmm, this breaks one of the contracts of our constexpr evaluation 
> > > > engine, doesn't it? My understanding is that if constexpr evaluation 
> > > > fails, we will have emitted a note diagnostic for why it failed. But if 
> > > > the caller doesn't pass a nonnull `SubobjectDecl`, we'll return `false` 
> > > > but we won't issue a diagnostic.
> > > > 
> > > > I'm surprised no tests lost notes as a result of this change, that 
> > > > suggests we're missing test coverage for the cases where nullptr is 
> > > > passed in explicitly to this function.
> > > Yeah, I was looking into when `SubobjectDecl` can be null here. I 
> > > `assert`ed the non-nullness of `SubobjectDecl` before and found that 
> > > there exists two lines of code 
> > > (https://github.com/llvm/llvm-project/blob/22a3f974d35da89247c0396594f2e4cd592742eb/clang/test/SemaCXX/attr-weak.cpp#L49
> > >  and 
> > > https://github.com/llvm/llvm-project/blob/abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1/clang/test/CodeGenCXX/weak-external.cpp#L97)
> > >  in the test codes that nulls here.
> > > It seems they are doing the same thing, doing comparison against a 
> > > pointer to a `[[gnu::weak]]` member. A simple reproducing code is here: 
> > > https://godbolt.org/z/qn997n85n
> > > As you can see from the compiler explorer, there's no note emitted here 
> > > before the patch.
> > > I inserted some `printf` into the code before this patch  and confirmed 
> > > `Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << true << 
> > > Type` was actually called when compiling the reproducing code and that 
> > > somehow it is ignored. FWIW, `SubobjectLoc.isValid()` was `false` here.
> > > It seems they are doing the same thing, doing comparison against a 
> > > pointer to a [[gnu::weak]] member. A simple reproducing code is here: 
> > > https://godbolt.org/z/qn997n85n
> > > As you can see from the compiler explorer, there's no note emitted here 
> > > before the patch.
> > 
> > I see a note generated there:
> > ```
> > :4:41: note: comparison against pointer to weak member 
> > 'Weak::weak_method' can only be performed at runtime
> > constexpr bool val = &Weak::weak_method != nullptr;
> > ^
> > ```
> > The situations I'm concerned about are the changes to ExprConstant.cpp:2270 
> > or line 2399 and so on.
> The `FFDiag` call can just stay as it was, right? And then only the 
> `Info.Note` call needs to be conditional for whether we have  a 
> `SubobjectDecl`.
In my understanding, the concern is that there could be note loss when 
`Value.hasValue()` evaluates to `false` and at the same time `SubobjectDecl` is 
`nullptr` explicitly passed in this change. 
`[[gnu::weak]]` member pointer comparison is the only example of this happening 
in the clang test codes where `Subobject` is `nullptr` passed at 
ExprConstant.cpp:2454 in `CheckFullyInitialized`. In this case the 
"uninitialized subobject" note was not displayed before this patch as well 
because there is another note issued elsewhere. Thus, the note loss does not 
happen.

BTW, I checked where the `[[gnu::weak]]` note is issued and I think there might 
be a mistake in the return statements. The `return true` should be `return 
false` because the constexpr evaluator fails to evaluate the expression, right? 
Correct me if I am wrong. Here's the reference:
https://github.com/llvm/llvm-project/blob/e58a49300e757ff61142f6abd227bd1437c1cf87/clang/lib/AST/ExprConstant.cpp#L13140-L13151

If we change them to `false`, `CheckFullyInitialized` will not be called in 
this scenario, and we will  have no test cases where `SubobjectDecl` is 
`nullptr` and at the same time `Value.hasValue()` is `false`. I am unsure 
whether this is due to the lack of test coverage or it is guaranteed that this 
condition does not hold here.

> The `FFDiag` call can just stay as it was, right? And then only the 
> `Info.Note` call needs to be conditional for whether we have  a 
> `SubobjectDecl`.
If `SubobjectDecl` is null, it would cause segfault when the `FFDiag` note is 
displayed, I think.

The best way I can think of would be to `assert(SubobjectDecl)` here, but I am 
still struggling and would like to ask for comments.


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

https://reviews.llvm.org/D146358

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-04-07 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 511659.

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

https://reviews.llvm.org/D146358

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
  clang/test/SemaCXX/constant-expression-cxx2a.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -761,7 +761,7 @@
 };
 
 S s1; // expected-error {{call to consteval function 'NamespaceScopeConsteval::S::S' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject 'Val' is not initialized}}
 
 template 
 struct T {
@@ -770,7 +770,7 @@
 };
 
 T t; // expected-error {{call to consteval function 'NamespaceScopeConsteval::T::T' is not a constant expression}} \
- expected-note {{subobject of type 'int' is not initialized}}
+ expected-note {{subobject 'Val' is not initialized}}
 
 } // namespace NamespaceScopeConsteval
 
Index: clang/test/SemaCXX/constant-expression-cxx2a.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2a.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2a.cpp
@@ -409,12 +409,12 @@
 b.a.x = 2;
 return b;
   }
-  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr B uninit = return_uninit(); // expected-error {{constant expression}} expected-note {{subobject 'y' is not initialized}}
   static_assert(return_uninit().a.x == 2);
   constexpr A return_uninit_struct() {
 B b = {.b = 1};
 b.a.x = 2;
-return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject of type 'int' is not initialized}}
+return b.a; // expected-note {{in call to 'A(b.a)'}} expected-note {{subobject 'y' is not initialized}}
   }
   // Note that this is rejected even though return_uninit() is accepted, and
   // return_uninit() copies the same stuff wrapped in a union.
@@ -558,7 +558,7 @@
 }
   };
   constinit X x1(true);
-  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject of type 'int' is not initialized}}
+  constinit X x2(false); // expected-error {{constant initializer}} expected-note {{constinit}} expected-note {{subobject 'n' is not initialized}}
 
   struct Y {
 struct Z { int n; }; // expected-note {{here}}
@@ -577,7 +577,7 @@
   };
   // FIXME: This is working around clang not implementing DR2026. With that
   // fixed, we should be able to test this without the injected copy.
-  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr Y copy(Y y) { return y; } // expected-note {{in call to 'Y(y)'}} expected-note {{subobject 'n' is not initialized}}
   constexpr Y y1 = copy(Y());
   static_assert(y1.z1.n == 1 && y1.z2.n == 2 && y1.z3.n == 3);
 
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
@@ -359,7 +359,7 @@
   // The constructor is still 'constexpr' here, but the result is not intended
   // to be a constant expression. The standard is not clear on how this should
   // work.
-  constexpr V v; // expected-error {{constant expression}} expected-note {{subobject of type 'int' is not initialized}}
+  constexpr V v; // expected-error {{constant expression}} expected-note {{subobject 'y' is not initialized}}
 
   constexpr int k = V().x; // FIXME: ok?
 }
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -143,9 +143,9 @@
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant expression}} \
- // expected-note {{subobject of type 'int' is not initialized}} \
+ // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} \
- // ref-note {{subobject of type 'int' is not initialized}}
+ // ref-note {{subobject 'a' is not initialized}}
 
 
   class Base {
@@ -161,18 +161,18 @@
 constexpr Derived() : Base() {}   };
 
   constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \
-   // expected-note {{subobject of 

[PATCH] D137782: [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL 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/D137782/new/

https://reviews.llvm.org/D137782

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


[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147175#4249212 , @philnik wrote:

> In D147175#4246513 , @aaron.ballman 
> wrote:
>
>> Ah, I like this approach -- it keeps things roughly in sync with checking 
>> for unique object representations, which is great. I spotted a few 
>> questions, but in general this is heading in the right direction. You should 
>> also add a release note to clang/docs/ReleaseNotes.rst so that users know 
>> there's a new builtin coming.
>>
>> I suppose one thing to double-check: do you know of any other STL 
>> implementations that might be using this identifier as part of their 
>> implementation details? (We've had issues in the past where we accidentally 
>> stole a reserved identifier that was being used by libstdc++ and it caused 
>> issues.)
>
> Neither libstdc++ nor the MSVC STL use the 
> `__is_trivially_equality_comparable` AFAICT. A sourcegraph search also 
> exclusively finds libc++: 
> https://sourcegraph.com/search?q=context%3Aglobal+__is_trivially_equality_comparable&patternType=standard&sm=1&groupBy=repo
>  (which only started using it in this release cycle, so it shouldn't be a 
> problem).

Perfect, thank you for double-checking!

One thing I can't quite determine is whether we expect to call this type trait 
often or not. Are either of the uses in libc++ going to be instantiated 
frequently? I'm trying to figure out whether we want the current implementation 
of `HasNonDeletedDefaultedEqualityComparison()` or whether we should bite the 
bullet up front and add another bit to `CXXRecordDecl::DefinitionData` so we 
compute this property once as the class is being formed and don't have to loop 
over all of the methods and bases each time. We do this for other special 
member functions, as with: 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/DeclCXX.h#L695




Comment at: clang/lib/AST/Type.cpp:2618-2619
+ llvm::all_of(Decl->fields(), [](const FieldDecl *FD) {
+   if (!FD->getType()->isRecordType())
+ return !FD->getType()->isReferenceType();
+   return HasNonDeletedDefaultedEqualityComparison(

Why the check for !RecordType? If any field is a reference, we can bail out 
early, so I think this is better as:
```
if (FD->getType()->isReferenceType())
  return false;
if (const auto *RD = FD->getType()->getAsCXXRecordDecl())
  return HasNonDeletedDefaultedEqualityComparison(RD);
return true;
```
WDYT?



Comment at: clang/lib/AST/Type.cpp:2631-2632
+
+  if (const auto *RecordDecl = CanonicalType->getAsCXXRecordDecl()) {
+if 
(!HasNonDeletedDefaultedEqualityComparison(CanonicalType->getAsCXXRecordDecl()))
+  return false;

Avoids calling the same method twice and avoids using a type name as a 
declaration identifier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147175

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


[PATCH] D147779: [clang-tidy] Fix hungarian notation failed to indicate the number of asterisks in check-clang-extra-clang-tidy-checkers-readability

2023-04-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:367-379
+if (const auto *TD = dyn_cast(ND)) {
+  QualType QT = TD->getType();
+
+  size_t PtrCount = 0;
+  if (QT->isPointerType()) {
+PtrCount = getAsteriskCount(Type);
+  }

this function is already big, extract this to have something like:
```
if (removeReudnantAsterisks(Type, ND))
{
RedundantRemoved = true;
break;
}
```



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:696-702
+const std::string &TypeName) const {
+  size_t Pos = TypeName.find('*');
+  size_t Count = 0;
+  for (; Pos < TypeName.length(); Pos++, Count++) {
+if ('*' != TypeName[Pos])
+  break;
+  }

what if type will be like std::optional, will this function 
also be executed ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147779

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


[PATCH] D147779: [clang-tidy] Fix hungarian notation failed to indicate the number of asterisks in check-clang-extra-clang-tidy-checkers-readability

2023-04-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Missing release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147779

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


[PATCH] D143287: [Clang][X86] Change X86 cast intrinsics to use __builtin_nondeterministic_value

2023-04-07 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito updated this revision to Diff 511663.
ManuelJBrito added a comment.

Update to remove multiple uses of freeze poison.
I am unsure about the code style used in the 128 to 512 casts. Any comments are 
appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143287

Files:
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512fp16intrin.h
  clang/lib/Headers/avxintrin.h
  clang/test/CodeGen/X86/avx-builtins.c
  clang/test/CodeGen/X86/avx-cast-builtins.c
  clang/test/CodeGen/X86/avx512f-builtins.c
  clang/test/CodeGen/X86/avx512fp16-builtins.c

Index: clang/test/CodeGen/X86/avx512fp16-builtins.c
===
--- clang/test/CodeGen/X86/avx512fp16-builtins.c
+++ clang/test/CodeGen/X86/avx512fp16-builtins.c
@@ -325,19 +325,26 @@
 
 __m256h test_mm256_castph128_ph256(__m128h __a) {
   // CHECK-LABEL: test_mm256_castph128_ph256
-  // CHECK: shufflevector <8 x half> %{{.*}}, <8 x half> %{{.*}}, <16 x i32> 
+  // CHECK: [[A:%.*]] = freeze <8 x half> poison 
+  // CHECK: shufflevector <8 x half> %{{.*}}, <8 x half> [[A]], <16 x i32> 
   return _mm256_castph128_ph256(__a);
 }
 
 __m512h test_mm512_castph128_ph512(__m128h __a) {
   // CHECK-LABEL: test_mm512_castph128_ph512
-  // CHECK: shufflevector <8 x half> %{{.*}}, <8 x half> %{{.*}}, <32 x i32> 
+  // CHECK: [[B:%.*]] = freeze <16 x half> poison
+  // CHECK: store <16 x half> [[B]], ptr [[BA:%.*]]
+  // CHECK: [[A:%.*]] = freeze <8 x half> poison
+  // CHECK: [[SV:%.*]] = shufflevector <8 x half> %{{.*}}, <8 x half> [[A]], <16 x i32> 
+  // CHECK: [[C:%.*]] = load <16 x half>, ptr [[BA]]
+  // CHECK: shufflevector <16 x half> [[SV]], <16 x half> [[C]], <32 x i32> 
   return _mm512_castph128_ph512(__a);
 }
 
 __m512h test_mm512_castph256_ph512(__m256h __a) {
   // CHECK-LABEL: test_mm512_castph256_ph512
-  // CHECK: shufflevector <16 x half> %{{.*}}, <16 x half> %{{.*}}, <32 x i32> 
+  // CHECK: [[A:%.*]] = freeze <16 x half> poison 
+  // CHECK: shufflevector <16 x half> %{{.*}}, <16 x half> [[A]], <32 x i32> 
   return _mm512_castph256_ph512(__a);
 }
 
Index: clang/test/CodeGen/X86/avx512f-builtins.c
===
--- clang/test/CodeGen/X86/avx512f-builtins.c
+++ clang/test/CodeGen/X86/avx512f-builtins.c
@@ -8987,13 +8987,23 @@
 
 __m512 test_mm512_castps128_ps512(__m128 __A) {
   // CHECK-LABEL: @test_mm512_castps128_ps512
-  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <16 x i32> 
+  // CHECK: [[B:%.*]] = freeze <8 x float> poison
+  // CHECK: store <8 x float> [[B]], ptr [[BA:%.*]]
+  // CHECK: [[A:%.*]] = freeze <4 x float> poison 
+  // CHECK: [[SV:%.*]] = shufflevector <4 x float> %{{.*}}, <4 x float> [[A]], <8 x i32> 
+  // CHECK: [[C:%.*]] = load <8 x float>, ptr [[BA]]
+  // CHECK: shufflevector <8 x float> [[SV]], <8 x float> [[C]], <16 x i32> 
   return _mm512_castps128_ps512(__A); 
 }
 
 __m512d test_mm512_castpd128_pd512(__m128d __A) {
   // CHECK-LABEL: @test_mm512_castpd128_pd512
-  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <8 x i32> 
+  // CHECK: [[B:%.*]] = freeze <4 x double> poison
+  // CHECK: store <4 x double> [[B]], ptr [[BA:%.*]]
+  // CHECK: [[A:%.*]] = freeze <2 x double> poison 
+  // CHECK: [[SV:%.*]] = shufflevector <2 x double> %{{.*}}, <2 x double> [[A]], <4 x i32> 
+  // CHECK: [[C:%.*]] = load <4 x double>, ptr [[BA]]
+  // CHECK: shufflevector <4 x double> [[SV]], <4 x double> [[C]], <8 x i32> 
   return _mm512_castpd128_pd512(__A); 
 }
 
@@ -9086,7 +9096,8 @@
 __m512d test_mm512_castpd256_pd512(__m256d a)
 {
   // CHECK-LABEL: @test_mm512_castpd256_pd512
-  // CHECK: shufflevector <4 x double> {{.*}} 
+  // CHECK: [[A:%.*]] = freeze <4 x double> poison 
+  // CHECK: shufflevector <4 x double> %{{.}}, <4 x double> [[A]], <8 x i32> 
   return _mm512_castpd256_pd512(a);
 }
 
@@ -9112,13 +9123,19 @@
 }
 __m512i test_mm512_castsi128_si512(__m128i __A) {
   // CHECK-LABEL: @test_mm512_castsi128_si512
-  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <8 x i32> 
+  // CHECK: [[B:%.*]] = freeze <4 x i64> poison
+  // CHECK: store <4 x i64> [[B]], ptr [[BA:%.*]]
+  // CHECK: [[A:%.*]] = freeze <2 x i64> poison 
+  // CHECK: [[SV:%.*]] = shufflevector <2 x i64> %{{.*}}, <2 x i64> [[A]], <4 x i32> 
+  // CHECK: [[C:%.*]] = load <4 x i64>, ptr [[BA]]
+  // CHECK: shufflevector <4 x i64> [[SV]], <4 x i64> [[C]], <8 x i32> 
   return _mm512_castsi128_si512(__A); 
 }
 
 __m512i test_mm512_castsi256_si512(__m256i __A) {
   // CHECK-LABEL: @test_mm512_castsi256_si512
-  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <8 x i32> 
+  // CHECK: [[A:%.*]] = freeze <4 x i64> poison 
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> [[A]], <8 x i32> 
   return _mm512_castsi256_si512(__A); 
 }
 
Index: clang/test/CodeGen/X86/avx-cast-builtins.c
=

[PATCH] D147673: [Clang] Improve designated inits diagnostic location

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/cxx2b-designated-initializers.cpp:13
+  const S result { // expected-error {{field designator (null) does not refer 
to any field in type 'const S'}}
+.a = x
+  };

rsmith wrote:
> Why are we rejecting this?
That's existing behavior: https://godbolt.org/z/48ThKbTor but we don't get the 
behavior when it's not a template (https://godbolt.org/z/f3zWaqdWr) or in C 
(https://godbolt.org/z/P1TqG43nG), so I agree that this should be accepted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147673

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


[PATCH] D143287: [Clang][X86] Change X86 cast intrinsics to use __builtin_nondeterministic_value

2023-04-07 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes accepted this revision.
nlopes added a comment.
This revision is now accepted and ready to land.

LGTM, but please wait for another reviewer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143287

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


[PATCH] D147782: [clang] Fix 'operator=' lookup in nested class

2023-04-07 Thread Jonathan Camilleri via Phabricator via cfe-commits
J-Camilleri created this revision.
Herald added a project: All.
J-Camilleri requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If implicitly declared 'operator=' declarations are generated before
encountering a use in a nested class, custom definitions of the operator
in the nested class are not found.

The issue occurs because when searching for the operator in the nested
class the implicitly declared functions are found in the IdResolver and
returned. The IdResolver does not contain the custom defined operator
and so it is ignored.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147782

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp


Index: clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp
@@ -0,0 +1,18 @@
+/// clang++ incorrectly rejected this program with the following error:
+/// "No matching member function for call to 'operator='"
+///
+/// Refer to github issue 59684
+
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct Outer {
+  void invokeAssign() { operator=({}); }
+
+  struct Inner {
+Inner &operator=(int);
+void invokeAssign(int D) { operator=(D); }
+  };
+};
+
+int main() {}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1325,7 +1325,7 @@
 } else {
   // We found something in this scope, we should not look at the
   // namespace scope
-  SearchNamespaceScope = false;
+  SearchNamespaceScope = Name.getCXXOverloadedOperator() == OO_Equal;
 }
 R.addDecl(ND);
   }


Index: clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/nested-class-assignment-operator-overload.cpp
@@ -0,0 +1,18 @@
+/// clang++ incorrectly rejected this program with the following error:
+/// "No matching member function for call to 'operator='"
+///
+/// Refer to github issue 59684
+
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+struct Outer {
+  void invokeAssign() { operator=({}); }
+
+  struct Inner {
+Inner &operator=(int);
+void invokeAssign(int D) { operator=(D); }
+  };
+};
+
+int main() {}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -1325,7 +1325,7 @@
 } else {
   // We found something in this scope, we should not look at the
   // namespace scope
-  SearchNamespaceScope = false;
+  SearchNamespaceScope = Name.getCXXOverloadedOperator() == OO_Equal;
 }
 R.addDecl(ND);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147717#4249929 , @cjdb wrote:

> In D147717#4248989 , @erichkeane 
> wrote:
>
>> @cjdb has been running some GDB test suites against our compiler: I am 
>> wondering if we could ask him to try the consteval ones too before we set 
>> this?
>
> A lot of that work is manual because I need to interpret LIT messages to know 
> wether something is a config error (e.g. missing `// 
> expected-no-diagnostics`), a difference in opinion between compilers (e.g. 
> GCC says it's an error and Clang says it's a note, reporting diagnostics on 
> different lines, etc.), or actually an error in Clang.
>
> I won't have time to check this week, but perhaps next week if the test set 
> isn't too large (failing that, I'll at least try to get you `// 
> expected-no-diagnostics` for improved confidence). Does this timeframe seem 
> acceptable?

That sounds perfect to me -- there's not a rush on defining the macro/updating 
the status page given that we're not near a release, so we can wait until we 
have more details. Thank you for the help, @cjdb!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D147762: [Clang] Fix filtering of inline namespaces for friend functions

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Good catch! Let's skip the release note for this for now, because I think we 
should cherry-pick this to the 16.0.2 milestone -- but you should add the 
release note when landing on that branch so users know about the fix.


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

https://reviews.llvm.org/D147762

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


[PATCH] D146376: Update static_assert message for redundant cases

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146376#4250814 , @xbolva00 wrote:

> The patch description mixes "or" and "and" in examples, please fix it.
>
> SO probably you meant
>
>   :4:1: error: static assertion failed due to requirement 'is_gitlab'
>   static_assert(is_gitlab or is_weekend);
>   ^ ~

Good catch, I'll fix that when landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

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


[PATCH] D137782: [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

Thanks for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137782

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


[clang-tools-extra] 1012677 - [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Clement Courbet via cfe-commits

Author: Clement Courbet
Date: 2023-04-07T14:17:03+02:00
New Revision: 1012677284b87091f76542c3c79da641101578ae

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

LOG: [clang-tidy]bugprone-fold-init-type

Handle iterators that do not define a `value_type` type alias.

Get the value type from the return type of `Iter::operator*` instead.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
index c7a3032f27c03..d70cd2836c80f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
@@ -24,9 +24,24 @@ void FoldInitTypeCheck::registerMatchers(MatchFinder 
*Finder) {
 return anyOf(
 // Pointer types.
 pointsTo(BuiltinTypeWithId(ID)),
-// Iterator types.
-recordType(hasDeclaration(has(typedefNameDecl(
-hasName("value_type"), hasType(BuiltinTypeWithId(ID)));
+// Iterator types have an `operator*` whose return type is the type we
+// care about.
+// Notes:
+//   - `operator*` can be in one of the bases of the iterator class.
+//   - this does not handle cases when the `operator*` is defined
+// outside the iterator class.
+recordType(
+hasDeclaration(cxxRecordDecl(isSameOrDerivedFrom(has(functionDecl(
+hasOverloadedOperatorName("*"),
+returns(qualType(hasCanonicalType(anyOf(
+// `value_type& operator*();`
+references(BuiltinTypeWithId(ID)),
+// `value_type operator*();`
+BuiltinTypeWithId(ID),
+// `auto operator*();`, `decltype(auto) operator*();`
+autoType(hasDeducedType(BuiltinTypeWithId(ID)))
+//
+)));
   };
 
   const auto IteratorParam = parmVarDecl(

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6a87bcb3903e6..facc7c78ea21b 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -291,6 +291,10 @@ Changes in existing checks
   ` when warning would be
   emitted for a const local variable to which NRVO is applied.
 
+- Improved :doc:`bugprone-fold-init-type
+  ` to handle iterators that do not
+  define `value_type` type aliases.
+
 Removed checks
 ^^
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
index e7fdf395c50b3..2a49960e02895 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
@@ -1,39 +1,67 @@
-// RUN: %check_clang_tidy %s bugprone-fold-init-type %t
+// RUN: %check_clang_tidy %s bugprone-fold-init-type -std=c++17 %t
 
 namespace std {
 template 
-T accumulate(InputIt first, InputIt last, T init);
+T accumulate(InputIt first, InputIt last, T init) {
+  // When `InputIt::operator*` returns a deduced `auto` type that refers to a
+  // dependent type, the return type is deduced only if `InputIt::operator*`
+  // is instantiated. In practice this happens somewhere in the implementation
+  // of `accumulate`. For tests, do it here.
+  (void)*first;
+}
 
 template 
-T reduce(InputIt first, InputIt last, T init);
+T reduce(InputIt first, InputIt last, T init) { (void)*first; }
 template 
 T reduce(ExecutionPolicy &&policy,
- InputIt first, InputIt last, T init);
+ InputIt first, InputIt last, T init) { (void)*first; }
 
 struct parallel_execution_policy {};
 constexpr parallel_execution_policy par{};
 
 template 
 T inner_product(InputIt1 first1, InputIt1 last1,
-InputIt2 first2, T value);
+InputIt2 first2, T value) { (void)*first1; (void)*first2; }
 
 template 
 T inner_product(ExecutionPolicy &&policy, InputIt1 first1, InputIt1 last1,
-InputIt2 first2, T value);
+InputIt2 first2, T value) { (void)*first1; (void)*first2; }
 
 } // namespace std
 
 struct FloatIterator {
-  typedef float value_type;
+  const float &operator*() const;
 };
+
+struct DerivedFloatIterator : public FloatIterator {
+};
+
+template  struct ByValueTemplateIterator {
+  ValueType operator*() const;
+};
+
+template  struct ByRefTemplateIterator {
+  Va

[PATCH] D137782: [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Clement Courbet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1012677284b8: [clang-tidy]bugprone-fold-init-type (authored 
by courbet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137782

Files:
  clang-tools-extra/clang-tidy/bugprone/FoldInitTypeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/fold-init-type.cpp
@@ -1,39 +1,67 @@
-// RUN: %check_clang_tidy %s bugprone-fold-init-type %t
+// RUN: %check_clang_tidy %s bugprone-fold-init-type -std=c++17 %t
 
 namespace std {
 template 
-T accumulate(InputIt first, InputIt last, T init);
+T accumulate(InputIt first, InputIt last, T init) {
+  // When `InputIt::operator*` returns a deduced `auto` type that refers to a
+  // dependent type, the return type is deduced only if `InputIt::operator*`
+  // is instantiated. In practice this happens somewhere in the implementation
+  // of `accumulate`. For tests, do it here.
+  (void)*first;
+}
 
 template 
-T reduce(InputIt first, InputIt last, T init);
+T reduce(InputIt first, InputIt last, T init) { (void)*first; }
 template 
 T reduce(ExecutionPolicy &&policy,
- InputIt first, InputIt last, T init);
+ InputIt first, InputIt last, T init) { (void)*first; }
 
 struct parallel_execution_policy {};
 constexpr parallel_execution_policy par{};
 
 template 
 T inner_product(InputIt1 first1, InputIt1 last1,
-InputIt2 first2, T value);
+InputIt2 first2, T value) { (void)*first1; (void)*first2; }
 
 template 
 T inner_product(ExecutionPolicy &&policy, InputIt1 first1, InputIt1 last1,
-InputIt2 first2, T value);
+InputIt2 first2, T value) { (void)*first1; (void)*first2; }
 
 } // namespace std
 
 struct FloatIterator {
-  typedef float value_type;
+  const float &operator*() const;
 };
+
+struct DerivedFloatIterator : public FloatIterator {
+};
+
+template  struct ByValueTemplateIterator {
+  ValueType operator*() const;
+};
+
+template  struct ByRefTemplateIterator {
+  ValueType &operator*();
+};
+
+template  struct ByRefTemplateIteratorWithAlias {
+  using reference = const ValueType&;
+  reference operator*();
+};
+
+template  struct AutoByValueTemplateIterator {
+  auto operator*() const { return ValueType{}; }
+};
+
+template  struct AutoByRefTemplateIterator {
+  decltype(auto) operator*() const { return value_; }
+  ValueType value_;
+};
+
 template 
-struct TypedefTemplateIterator { typedef ValueType value_type; };
-template 
-struct UsingTemplateIterator { using value_type = ValueType; };
-template 
-struct DependentTypedefTemplateIterator { typedef typename ValueType::value_type value_type; };
-template 
-struct DependentUsingTemplateIterator : public TypedefTemplateIterator { using typename TypedefTemplateIterator::value_type; };
+struct InheritingByConstRefTemplateIterator
+: public ByRefTemplateIterator {};
+
 using TypedeffedIterator = FloatIterator;
 
 // Positives.
@@ -51,39 +79,57 @@
 }
 
 int accumulatePositive3() {
+  DerivedFloatIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
+}
+
+int accumulatePositive4() {
   double a[1] = {0.0};
   return std::accumulate(a, a + 1, 0.0f);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'double' into type 'float'
 }
 
-int accumulatePositive4() {
-  TypedefTemplateIterator it;
+int accumulatePositive5() {
+  ByValueTemplateIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
 }
 
-int accumulatePositive5() {
-  UsingTemplateIterator it;
+int accumulatePositive6() {
+  ByRefTemplateIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
 }
 
-int accumulatePositive6() {
-  DependentTypedefTemplateIterator> it;
+int accumulatePositive7() {
+  AutoByValueTemplateIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned int' into type 'int'
 }
 
-int accumulatePositive7() {
+int accumulatePositive8() {
   TypedeffedIterator it;
   return std::accumulate(it, it, 0);
   // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'float' into type 'int'
 }
 
-int accumulatePositive8() {
-  DependentUsingTemplateIterator it;
+int accumulatePositive9() {
+  InheritingByConstRefTemplateIterator it;
+  return std::accumulate(it, it, 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: folding type 'unsigned

[clang] 06c6fac - Update static_assert message for redundant cases

2023-04-07 Thread Aaron Ballman via cfe-commits

Author: Krishna Narayanan
Date: 2023-04-07T08:22:04-04:00
New Revision: 06c6fac696e46fe58dd48ce8b15fafc308688828

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

LOG: Update static_assert message for redundant cases

There are some simple messages where an expansion isn't particularly
helpful or needed. We aim to eliminate expansions that don't add much
value for user (this will give us slightly more room or prioritise to
have longer diagnostics elsewhere).

The test case for which it has been tested:
```
constexpr auto is_gitlab = false;
constexpr auto is_weekend = false;
static_assert(is_gitlab or is_weekend);
```

Previous warning/error message:
```
:4:1: error: static assertion failed due to requirement 'is_gitlab || 
is_weekend'
static_assert(is_gitlab or is_weekend);
^ ~~~
:4:25: note: expression evaluates to 'false || false'
static_assert(is_gitlab or is_weekend);
  ~~^
```
Currrent warning/error message:
```
:4:1: error: static assertion failed due to requirement 'is_gitlab'
static_assert(is_gitlab or is_weekend);
^ ~
```
This patch aims to remove some redundant cases of static assert messages
where the expansions are particularly unhelpful. In this particular
patch, we have ignored the printing of diagnostic warnings for binary
operators with logical OR operations.

This is done to prioritise and prefer to emit longer diagnostic
warnings for more important concerns elsewhere.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/static-assert.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5de436f94a6be..3fc2839b93e50 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -213,6 +213,9 @@ Improvements to Clang's diagnostics
 - There were some cases in which the diagnostic for the unavailable attribute
   might not be issued, this fixes those cases.
   (`61815 `_)
+- Clang now avoids unnecessary diagnostic warnings for obvious expressions in
+  the case of binary operators with logical OR operations.
+  (`#57906 `_)
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 511e87f229254..eb6a4f3296e15 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16718,7 +16718,8 @@ static bool UsefulToPrintExpr(const Expr *E) {
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast(E)) {
+  if (const auto *Op = dyn_cast(E);
+  Op && Op->getOpcode() != BO_LOr) {
 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 

diff  --git a/clang/test/SemaCXX/static-assert.cpp 
b/clang/test/SemaCXX/static-assert.cpp
index 97a3aaec0a08e..ea8037815a203 100644
--- a/clang/test/SemaCXX/static-assert.cpp
+++ b/clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@ namespace Diagnostics {
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error 
{{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note 
{{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion 
failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error 
{{static assertion failed due to requirement 'invert(true) || invert(true) || 
false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error 
{{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error 
{{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}



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


[PATCH] D146376: Update static_assert message for redundant cases

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06c6fac696e4: Update static_assert message for redundant 
cases (authored by Krishna-13-cyber, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146376

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/static-assert.cpp


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error 
{{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static 
assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note 
{{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion 
failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error 
{{static assertion failed due to requirement 'invert(true) || invert(true) || 
false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error 
{{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error 
{{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16718,7 +16718,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Sema::DiagnoseStaticAssertDetails(const Expr *E) {
-  if (const auto *Op = dyn_cast(E)) {
+  if (const auto *Op = dyn_cast(E);
+  Op && Op->getOpcode() != BO_LOr) {
 const Expr *LHS = Op->getLHS()->IgnoreParenImpCasts();
 const Expr *RHS = Op->getRHS()->IgnoreParenImpCasts();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -213,6 +213,9 @@
 - There were some cases in which the diagnostic for the unavailable attribute
   might not be issued, this fixes those cases.
   (`61815 `_)
+- Clang now avoids unnecessary diagnostic warnings for obvious expressions in
+  the case of binary operators with logical OR operations.
+  (`#57906 `_)
 
 Bug Fixes in This Version
 -


Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -258,8 +258,14 @@
   constexpr bool invert(bool b) {
 return !b;
   }
-  static_assert(invert(true) == invert(false), ""); // expected-error {{failed}} \
+
+  static_assert(invert(true) || invert(true), ""); // expected-error {{static assertion failed due to requirement 'invert(true) || invert(true)'}}
+  static_assert(invert(true) == invert(false), ""); // expected-error {{static assertion failed due to requirement 'invert(true) == invert(false)'}} \
 // expected-note {{evaluates to 'false == true'}}
+  static_assert(true && false, ""); // expected-error {{static assertion failed due to requirement 'true && false'}}
+  static_assert(invert(true) || invert(true) || false, ""); // expected-error {{static assertion failed due to requirement 'invert(true) || invert(true) || false'}}
+  static_assert((true && invert(true)) || false, ""); // expected-error {{static assertion failed due to requirement '(true && invert(true)) || false'}}
+  static_assert(true && invert(false) && invert(true), ""); // expected-error {{static assertion failed due to requirement 'invert(true)'}}
 
   /// No notes here since we compare a bool expression with a bool literal.
   static_assert(invert(true) == true, ""); // expected-error {{failed}}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -16718,7 +16718,8 @@
 /// Try to print more useful information about a failed static_assert
 /// with expression \E
 void Se

[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: erichkeane.
aaron.ballman added a comment.

In D147714#4249531 , @xbolva00 wrote:

> Added location when emiting diagnostic about failed TCO in the backend.

Will the diagnostic behavior change based on optimization level? Will the 
diagnostic be emitted to the correct location if there's no debug info? Are 
there frontend tests for this diagnostic?

Higher-level question: are we sure there's enough evidence this will be used in 
practice to warrant adding it to Clang?


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

https://reviews.llvm.org/D147714

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


[PATCH] D147722: [Concepts] Fix Function Template Concepts comparisons

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I think it is probably a good idea to revert that one until you get a chance to 
figure out that problem (and #61993 if it is related!).  Other than the test 
being dependent on your change (and perhaps failing without your change), this 
is otherwise unrelated, so I might commit it anyway.


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

https://reviews.llvm.org/D147722

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


[PATCH] D147782: [clang] Fix 'operator=' lookup in nested class

2023-04-07 Thread Jonathan Camilleri via Phabricator via cfe-commits
J-Camilleri added a reviewer: aaron.ballman.
J-Camilleri added a comment.

Firstly, If there are other reviewers which I should include instead please let 
me know, the developers that changed around this area did so a long time ago 
and I do not know who to add.

I have described the problem in the github issue 
(https://github.com/llvm/llvm-project/issues/59684) and as I said there I am 
uncertain about my solution.
Given the issue and my limited knowledge of the code base, I am thinking about 
three possible solutions to this issue.

1. Have the user defined operator present in the `IdResolver` so that it is 
returned with the implicitly declared declarations.
  - I have seen cases where the declaration is kept in an `FETokenInfo` section 
but not added to the `IdResolver`, it gets removed at some point and leads to 
it not being present when `CppLookupName` is called

2. Have the `IdResolver` declarations ordered by scope, going from most nested 
to least nested.
  - This suggestion stems from how the ommition of `Outer::invokeAssign` is 
handled.
  - Seems expensive to maintain.

I do not understand the role of the `IdResolver` well so I do not know if the 
suggestions above misuse it/ change it's intended role.

3. Do not end the search at the `IdResolver` if we are searching for an 
'operator='.
  - I went for this solution because it is simplest to implement and has the 
least changes.
  - This causes the `LookupResult` to temporary contain duplicate declarations, 
they are cleaned later by a call to `LookupResult::resolveKind` but it still 
feels like this should not happen. I guess we can skip the loop alltogether to 
not have duplications but I did not check to see if this is viable.

I guess my main issue with this is understanding the role of `IdResolver`, 
should the order to implicit declarations change what it returns, should it 
already contain the user defined operator declaration?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147782

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Yeah, I think the diagnostics result of this attribute are unacceptable.  I 
understand the goal here, but I suspect the more ergonomic (albeit, perhaps 
surprising) is a `[[should_tail]]` attribute sort of thing: a tail-hint where 
we do 'best effort with no promises', and make no guarantees that we're going 
to tail it.  I'm sure this would require more work in the backends + require an 
additional IR tag, but even that seems difficult to use properly.

Could we instead encode the platform specific tail-call rules in Sema?  We 
definitely have attributes that differ in behavior between platforms, and this 
seems like a perfect candidate.


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

https://reviews.llvm.org/D147714

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


[PATCH] D146101: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-07 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 marked 29 inline comments as done.
jp4a50 added a comment.

Marked comments as done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a subscriber: jacobsa.
xbolva00 added a comment.

>> Could we instead encode the platform specific tail-call rules in Sema? We 
>> definitely have attributes that differ in behavior between platforms, and 
>> this seems like a perfect candidate.

But then you break promise of musttail that code with musttail will work on any 
target supported by LLVM.

Plus, while we can relax frontend checks (based on target info), it is true 
that current LLVM LangRef says that there must be a  match between prototypes.

>> Higher-level question: are we sure there's enough evidence this will be used 
>> in practice to warrant adding it to Clang?

Originally mentioned as request for CTRE project, I have use cases as well, 
@jacobsa (Github issue) mentioned it:

> Personally I would like the semantics "give me an error if this can't be a 
> tail call on this target", not the semantics "give me an error if this can't 
> be a tail call on all targets clang supports". I suspect most people would be 
> looking for the former, since most people care about nearly none of the 
> supported targets by volume.

I agree with that.


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

https://reviews.llvm.org/D147714

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D147714#4251208 , @xbolva00 wrote:

>>> Could we instead encode the platform specific tail-call rules in Sema? We 
>>> definitely have attributes that differ in behavior between platforms, and 
>>> this seems like a perfect candidate.
>
> But then you break promise of musttail that code with musttail will work on 
> any target supported by LLVM.

I should have been clearer: I meant this with a new attribute.

> Plus, while we can relax frontend checks (based on target info), it is true 
> that current LLVM LangRef says that there must be a  match between prototypes.

Right, this would require its own llvm-level concept as well.

>>> Higher-level question: are we sure there's enough evidence this will be 
>>> used in practice to warrant adding it to Clang?
>
> Originally mentioned as request for CTRE project, I have use cases as well, 
> @jacobsa (Github issue) mentioned it:
>
>> Personally I would like the semantics "give me an error if this can't be a 
>> tail call on this target", not the semantics "give me an error if this can't 
>> be a tail call on all targets clang supports". I suspect most people would 
>> be looking for the former, since most people care about nearly none of the 
>> supported targets by volume.
>
> I agree with that.

I see value in that, absolutely, but this isn't the way about it. Said new 
attribute (whether it be `[[should_tail]]` for `[[nonportable_musttail]]`) 
shouldn't be diagnosing the code generator, it should be diagnosing in SEMA.  
This requires encoding the platform specific/LLVM-IR specific rules. If LLVM-IR 
docs require `musttail` rules (that this patch seems to be breaking!), we 
perhaps need an alternative at the IR level as well.


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

https://reviews.llvm.org/D147714

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


[PATCH] D141307: Add -f[no-]loop-versioning option

2023-04-07 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Mats, thanks for working on this! Just a few minor suggestions from me.




Comment at: clang/lib/Driver/ToolChains/Flang.cpp:55
 
+static bool shouldLoopVersion(const ArgList &Args) {
+  if (Arg *A = Args.getLastArg(options::OPT_Ofast, options::OPT_O,

Could you add a short Docstring, pls? In particular, is the logic implemented 
by this method consistent with GFortran? Are there any external docs that could 
be referred to here?



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:56
+static bool shouldLoopVersion(const ArgList &Args) {
+  if (Arg *A = Args.getLastArg(options::OPT_Ofast, options::OPT_O,
+   options::OPT_O4, options::OPT_floop_versioning,

Please rewrite this to use [[ 
https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
 | early exit ]], e.g.:
```
  Arg *LoopVersionOption = Args.getLastArg(options::OPT_Ofast, options::OPT_O,
   options::OPT_O4, options::OPT_floop_versioning,
   options::OPT_fno_loop_versioning)
  if !(LoopVersionOption)
return false;

  // The remaining logic HERE
```



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:109-110
   addDebugInfoKind(CmdArgs, DebugInfoKind);
+  if (shouldLoopVersion(Args))
+CmdArgs.push_back("-fversion-loops-for-stride");
 }

Would you classify this as a code-gen option? Alongside `-fstack-arrays` and 
`-flang-experimental-hlfir`? It sound like we could introduce another hook 
here, `adddCodeGenOptions`?



Comment at: flang/test/Driver/version-loops.f90:2
+! Test that flang-new forwards the -f{no-,}version-loops-for-stride 
+! options corredly to flang-new -fc1 for different variants of optimisation
+! and explicit flags.





Comment at: flang/test/Driver/version-loops.f90:5
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 \

[nit] If you are using `-###`, then you can just skip `-fsyntax-only` (it 
doesn't really matter what "action" is requested from the frontend driver).



Comment at: flang/test/Driver/version-loops.f90:33-34
+  
+! CHECK: "-fversion-loops-for-stride"
+! CHECK: "-O3"
+

Similar suggestion for other `CHECK` lines - this will make the test a bit more 
explicit about the expected output.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141307

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


[clang] 8385ee0 - [clang-format] NFC Document the other space before colon option

2023-04-07 Thread via cfe-commits

Author: sstwcw
Date: 2023-04-07T13:52:18Z
New Revision: 8385ee05e59d2e05f0040c5dbdd0580b3e75f36b

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

LOG: [clang-format] NFC Document the other space before colon option

There are two options that do much the same thing, but for different
languages.  With the addition to the doc, the user is less likely to
configure the wrong option and get frustrated that it doesn't work.

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index f8ab42f46ba81..899d5b2df6031 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4782,7 +4782,8 @@ the configuration (without a prefix: ``Auto``).
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
-  If ``true``, a space will be add before a JSON colon.
+  If ``true``, a space will be added before a JSON colon. For other
+  languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
 
   .. code-block:: c++
 
@@ -5100,8 +5101,9 @@ the configuration (without a prefix: ``Auto``).
 .. _SpacesInContainerLiterals:
 
 **SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` 
:ref:`¶ `
-  If ``true``, spaces are inserted inside container literals (e.g.
-  ObjC and Javascript array and dict literals).
+  If ``true``, spaces are inserted inside container literals (e.g.  ObjC and
+  Javascript array and dict literals). For JSON, use
+  ``SpaceBeforeJsonColon`` instead.
 
   .. code-block:: js
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 0dfa052822458..980e6297fd6ac 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3749,7 +3749,8 @@ struct FormatStyle {
   /// \version 7
   bool SpaceBeforeInheritanceColon;
 
-  /// If ``true``, a space will be add before a JSON colon.
+  /// If ``true``, a space will be added before a JSON colon. For other
+  /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
   /// \code
   ///true:  false:
   ///{  {
@@ -4032,8 +4033,9 @@ struct FormatStyle {
   /// \version 10
   bool SpacesInConditionalStatement;
 
-  /// If ``true``, spaces are inserted inside container literals (e.g.
-  /// ObjC and Javascript array and dict literals).
+  /// If ``true``, spaces are inserted inside container literals (e.g.  ObjC 
and
+  /// Javascript array and dict literals). For JSON, use
+  /// ``SpaceBeforeJsonColon`` instead.
   /// \code{.js}
   ///true:  false:
   ///var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];



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


[PATCH] D147422: [clang-format] NFC Document the other space before colon option

2023-04-07 Thread sstwcw 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 rG8385ee05e59d: [clang-format] NFC Document the other space 
before colon option (authored by sstwcw).

Changed prior to commit:
  https://reviews.llvm.org/D147422?vs=510391&id=511681#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147422

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3749,7 +3749,8 @@
   /// \version 7
   bool SpaceBeforeInheritanceColon;
 
-  /// If ``true``, a space will be add before a JSON colon.
+  /// If ``true``, a space will be added before a JSON colon. For other
+  /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
   /// \code
   ///true:  false:
   ///{  {
@@ -4032,8 +4033,9 @@
   /// \version 10
   bool SpacesInConditionalStatement;
 
-  /// If ``true``, spaces are inserted inside container literals (e.g.
-  /// ObjC and Javascript array and dict literals).
+  /// If ``true``, spaces are inserted inside container literals (e.g.  ObjC 
and
+  /// Javascript array and dict literals). For JSON, use
+  /// ``SpaceBeforeJsonColon`` instead.
   /// \code{.js}
   ///true:  false:
   ///var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -4782,7 +4782,8 @@
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ 
`
-  If ``true``, a space will be add before a JSON colon.
+  If ``true``, a space will be added before a JSON colon. For other
+  languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
 
   .. code-block:: c++
 
@@ -5100,8 +5101,9 @@
 .. _SpacesInContainerLiterals:
 
 **SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` 
:ref:`¶ `
-  If ``true``, spaces are inserted inside container literals (e.g.
-  ObjC and Javascript array and dict literals).
+  If ``true``, spaces are inserted inside container literals (e.g.  ObjC and
+  Javascript array and dict literals). For JSON, use
+  ``SpaceBeforeJsonColon`` instead.
 
   .. code-block:: js
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -3749,7 +3749,8 @@
   /// \version 7
   bool SpaceBeforeInheritanceColon;
 
-  /// If ``true``, a space will be add before a JSON colon.
+  /// If ``true``, a space will be added before a JSON colon. For other
+  /// languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
   /// \code
   ///true:  false:
   ///{  {
@@ -4032,8 +4033,9 @@
   /// \version 10
   bool SpacesInConditionalStatement;
 
-  /// If ``true``, spaces are inserted inside container literals (e.g.
-  /// ObjC and Javascript array and dict literals).
+  /// If ``true``, spaces are inserted inside container literals (e.g.  ObjC and
+  /// Javascript array and dict literals). For JSON, use
+  /// ``SpaceBeforeJsonColon`` instead.
   /// \code{.js}
   ///true:  false:
   ///var arr = [ 1, 2, 3 ]; vs. var arr = [1, 2, 3];
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -4782,7 +4782,8 @@
 .. _SpaceBeforeJsonColon:
 
 **SpaceBeforeJsonColon** (``Boolean``) :versionbadge:`clang-format 17` :ref:`¶ `
-  If ``true``, a space will be add before a JSON colon.
+  If ``true``, a space will be added before a JSON colon. For other
+  languages, e.g. JavaScript, use ``SpacesInContainerLiterals`` instead.
 
   .. code-block:: c++
 
@@ -5100,8 +5101,9 @@
 .. _SpacesInContainerLiterals:
 
 **SpacesInContainerLiterals** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`¶ `
-  If ``true``, spaces are inserted inside container literals (e.g.
-  ObjC and Javascript array and dict literals).
+  If ``true``, spaces are inserted inside container literals (e.g.  ObjC and
+  Javascript array and dict literals). For JSON, use
+  ``SpaceBeforeJsonColon`` instead.
 
   .. code-block:: js
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin

[clang] 653a82e - [clang] Add test for CWG191

2023-04-07 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-07T17:54:38+04:00
New Revision: 653a82e95257a7cd3f22c24e40d54459a6608429

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

LOG: [clang] Add test for CWG191

Also mark CWG1200 as "na."

[[https://wg21.link/p1787 | P1787]]: CWG191 and CWG1200 are resolved by 
defining unqualified lookup in terms of every enclosing scope.
Wording: If no declarations are found, the results of the unqualified search 
are the results of an unqualified search in the parent scope of S, if any, from 
P. ([basic.lookup.unqual]/2)

Reviewed By: #clang-language-wg, shafik

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

Added: 


Modified: 
clang/test/CXX/drs/dr12xx.cpp
clang/test/CXX/drs/dr1xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index 9f09ff1f698e5..863e5be9a5d16 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+
+// dr1200: na
 
 namespace dr1213 { // dr1213: 7
 #if __cplusplus >= 201103L

diff  --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 02ad3109bfcb7..f70cd20133ebc 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr100 { // dr100: yes
   template struct A {}; // expected-note 0-1{{declared 
here}}
@@ -999,6 +1000,36 @@ namespace dr188 { // dr188: yes
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g() {
+dr191_j = 5;
+  }
+};
+  }
+};
+  }
+}
+
 // dr193 FIXME: add codegen test
 
 namespace dr194 { // dr194: yes

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 0e1101e3d42ca..8ca6d081379d8 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
@@ -7007,7 +7007,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg1200";>1200
 CD6
 Lookup rules for template parameters
-Unknown
+N/A
   
   
 https://wg21.link/cwg1201";>1201



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


[PATCH] D147530: [clang] Add test for CWG191

2023-04-07 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG653a82e95257: [clang] Add test for CWG191 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147530

Files:
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
@@ -7007,7 +7007,7 @@
 https://wg21.link/cwg1200";>1200
 CD6
 Lookup rules for template parameters
-Unknown
+N/A
   
   
 https://wg21.link/cwg1201";>1201
Index: clang/test/CXX/drs/dr1xx.cpp
===
--- clang/test/CXX/drs/dr1xx.cpp
+++ clang/test/CXX/drs/dr1xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr100 { // dr100: yes
   template struct A {}; // expected-note 0-1{{declared 
here}}
@@ -999,6 +1000,36 @@
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g() {
+dr191_j = 5;
+  }
+};
+  }
+};
+  }
+}
+
 // dr193 FIXME: add codegen test
 
 namespace dr194 { // dr194: yes
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+
+// dr1200: na
 
 namespace dr1213 { // dr1213: 7
 #if __cplusplus >= 201103L


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
@@ -7007,7 +7007,7 @@
 https://wg21.link/cwg1200";>1200
 CD6
 Lookup rules for template parameters
-Unknown
+N/A
   
   
 https://wg21.link/cwg1201";>1201
Index: clang/test/CXX/drs/dr1xx.cpp
===
--- clang/test/CXX/drs/dr1xx.cpp
+++ clang/test/CXX/drs/dr1xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr100 { // dr100: yes
   template struct A {}; // expected-note 0-1{{declared here}}
@@ -999,6 +1000,36 @@
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g() {
+dr191_j = 

[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

>> Will the diagnostic be emitted to the correct location if there's no debug 
>> info?

I did some experiments and with no debug info, I got atleast the location of 
the caller. If we consider than currently there is no location, anything is 
improvement and this is probably best we can do.

>> Are there frontend tests for this diagnostic?

Do you mean C ---> ASM tests? I think we dont have such test, are they even 
allowed in Clang testsuite?


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

https://reviews.llvm.org/D147714

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


[PATCH] D137782: [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please rebase from latest  `main`.




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:294
 
+- Improved :doc:`bugprone-fold-init-type
+  ` to handle iterators that do not

Please keep alphabetical order (by check name) in this section.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137782

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


[PATCH] D147194: [clang-tidy] fix concat-nest-namespace fix hint remove the macro

2023-04-07 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Overall looks +- fine, these are last comments from me.




Comment at: 
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:127
+
+  for (size_t Index = 0; Index < Namespaces.size(); Index++) {
+if (Namespaces[Index]->isNested())

this index looks reundant, you could use range-for



Comment at: 
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:144-153
+  for (SourceRange const &Front : Fronts)
+DB << FixItHint::CreateRemoval(Front);
+  for (SourceRange const &Back : Backs)
+DB << FixItHint::CreateRemoval(Back);
+  NamespaceString ConcatNameSpace = concatNamespaces();
+  DB << FixItHint::CreateReplacement(
+  SourceRange{ND->getBeginLoc(), ND->getLocation()}, ConcatNameSpace);

consider ordering removals from last to first...
personally i sometimes run into issues when we first removed something before 
last change, but that could be already fixed, or we may not run into this issue 
in this check



Comment at: 
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp:88
+  StringRef TokText = getRawStringRef(TokRange, SM, LangOpts);
+  if (TokText != "// namespace " + ND->getNameAsString())
+return DefaultSourceRange;

PiotrZSL wrote:
> what if it is //namespace ? or /* namespace XYZ */
ok, but it still can be things like `//   namespace XYZ`
So instead adding single space, consider using some trim/strip.
but thats minor issues, side effect would be just an leftover namespace comment.
add some test with something like `// namespace XYZ - closing namespace` to 
verify that some custom comments wont be removed, and make sure that 
documentation mention this, that we remove only namespace comments that follow 
some known standard.

you could also check for:
```
namespace C
{
} // C
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147194

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


[PATCH] D143347: [lldb][DWARF] Infer no_unique_address attribute

2023-04-07 Thread Pavel Kosov via Phabricator via cfe-commits
kpdev42 updated this revision to Diff 511683.
kpdev42 edited the summary of this revision.
kpdev42 added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143347

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/test/API/lang/cpp/no_unique_address/Makefile
  lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py
  lldb/test/API/lang/cpp/no_unique_address/main.cpp

Index: lldb/test/API/lang/cpp/no_unique_address/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/no_unique_address/main.cpp
@@ -0,0 +1,67 @@
+struct C
+{
+ long c,d;
+};
+
+struct Q
+{
+ long h;
+};
+
+struct D
+{
+};
+
+struct B
+{
+  [[no_unique_address]] D x;
+};
+
+struct E
+{
+  [[no_unique_address]] D x;
+};
+
+struct Foo1 : B,E,C
+{
+ long a = 42,b = 52;
+} _f1;
+
+struct Foo2 : B,E
+{
+ long v = 42;
+} _f2;
+
+struct Foo3 : C,B,E
+{
+ long v = 42;
+} _f3;
+
+struct Foo4 : B,C,E,Q
+{
+ long v = 42;
+} _f4;
+
+struct Foo5 : B,C,E
+{
+ [[no_unique_address]] D x1;
+ [[no_unique_address]] D x2;
+ long v1 = 42;
+ [[no_unique_address]] D y1;
+ [[no_unique_address]] D y2;
+ long v2 = 52;
+ [[no_unique_address]] D z1;
+ [[no_unique_address]] D z2;
+} _f5;
+
+struct Foo6 : B,E
+{
+ long v1 = 42;
+ [[no_unique_address]] D y1;
+ [[no_unique_address]] D y2;
+ long v2 = 52;
+} _f6;
+
+int main() {
+  return 0; // Set breakpoint here.
+}
Index: lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/no_unique_address/TestNoUniqueAddress.py
@@ -0,0 +1,28 @@
+"""
+Test that we correctly handle [[no_unique_address]] attribute.
+"""
+
+import lldb
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestInlineNamespace(TestBase):
+
+def test(self):
+self.build()
+
+lldbutil.run_to_source_breakpoint(self,
+"// Set breakpoint here.", lldb.SBFileSpec("main.cpp"))
+
+self.expect_expr("_f1.a", result_type="long", result_value="42")
+self.expect_expr("_f1.b", result_type="long", result_value="52")
+self.expect_expr("_f2.v", result_type="long", result_value="42")
+self.expect_expr("_f3.v", result_type="long", result_value="42")
+self.expect_expr("_f4.v", result_type="long", result_value="42")
+self.expect_expr("_f5.v1", result_type="long", result_value="42")
+self.expect_expr("_f5.v2", result_type="long", result_value="52")
+self.expect_expr("_f6.v1", result_type="long", result_value="42")
+self.expect_expr("_f6.v2", result_type="long", result_value="52")
Index: lldb/test/API/lang/cpp/no_unique_address/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/no_unique_address/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -223,6 +223,7 @@
 uint64_t bit_size = 0;
 uint64_t bit_offset = 0;
 bool is_bitfield = false;
+clang::FieldDecl *field_decl = nullptr;
 
 FieldInfo() = default;
 
@@ -275,6 +276,10 @@
   const ParsedDWARFTypeAttributes &attrs);
   lldb::TypeSP ParsePointerToMemberType(const DWARFDIE &die,
 const ParsedDWARFTypeAttributes &attrs);
+  void FixupBaseClasses(
+  std::vector> &base_classes,
+  const lldb_private::ClangASTImporter::LayoutInfo &layout_info,
+  long byte_offset);
 
   /// Parses a DW_TAG_inheritance DIE into a base/super class.
   ///
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1366,6 +1366,28 @@
   return nullptr;
 }
 
+void DWARFASTParserClang::FixupBaseClasses(
+std::vector> &base_classes,
+const ClangASTImporter::LayoutInfo &layout_info, long byte_offset) {
+  for (auto it = base_classes.rbegin(); it != base_classes.rend(); ++it) {
+clang::CXXRecordDecl *prev_base_decl =
+(*it)->getType()->getAsCXXRecordDecl();
+// We've already marked this class, exit.
+if (prev_base_decl->isEmpty())
+  break;
+auto it_layout = layout_info.base_offsets.find(prev_base_decl);
+if (it_layout == layout_info.base_offsets.end())
+  continue;
+// We found a normal base 

[PATCH] D143347: [lldb][DWARF] Infer no_unique_address attribute

2023-04-07 Thread Pavel Kosov via Phabricator via cfe-commits
kpdev42 added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1483
+// base with all fields having [[no_unique_address]] attribute.
+for (auto it = base_classes.rbegin(); it != base_classes.rend(); ++it) {
+  clang::CXXRecordDecl *prev_base_decl =

Michael137 wrote:
> Michael137 wrote:
> > The main problem I still see with this is that if we have something like:
> > ```
> > struct A : C, B {
> > 
> > };
> > ```
> > 
> > then we mark `C`'s fields as empty and leave `B` as is. This still leads to 
> > the same crash later on.
> > 
> > Perhaps we should mark we could check the size of the struct and decide 
> > based on that which one is the "empty" one
> Interestingly there was a discussion on the DWARF mailing list about this 
> some time ago: 
> https://www.mail-archive.com/dwarf-discuss@lists.dwarfstd.org/msg00880.html
> 
> There might be room to changing the emitted DWARF to make it easier to 
> determine the empty structure. I will gauge opinions on this thread later 
> today
Unfortunately we cannot analyze record size, because it is always 1 for empty 
records, whether or not [[no_unique_address]] is used. However we still can 
analyze field offsets, I think. This what an updated patch does and it seems to 
handle more different cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143347

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


[PATCH] D143347: [lldb][DWARF] Infer no_unique_address attribute

2023-04-07 Thread Pavel Kosov via Phabricator via cfe-commits
kpdev42 added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1483
+// base with all fields having [[no_unique_address]] attribute.
+for (auto it = base_classes.rbegin(); it != base_classes.rend(); ++it) {
+  clang::CXXRecordDecl *prev_base_decl =

kpdev42 wrote:
> Michael137 wrote:
> > Michael137 wrote:
> > > The main problem I still see with this is that if we have something like:
> > > ```
> > > struct A : C, B {
> > > 
> > > };
> > > ```
> > > 
> > > then we mark `C`'s fields as empty and leave `B` as is. This still leads 
> > > to the same crash later on.
> > > 
> > > Perhaps we should mark we could check the size of the struct and decide 
> > > based on that which one is the "empty" one
> > Interestingly there was a discussion on the DWARF mailing list about this 
> > some time ago: 
> > https://www.mail-archive.com/dwarf-discuss@lists.dwarfstd.org/msg00880.html
> > 
> > There might be room to changing the emitted DWARF to make it easier to 
> > determine the empty structure. I will gauge opinions on this thread later 
> > today
> Unfortunately we cannot analyze record size, because it is always 1 for empty 
> records, whether or not [[no_unique_address]] is used. However we still can 
> analyze field offsets, I think. This what an updated patch does and it seems 
> to handle more different cases
Yes, this will help a lot, however many people use older versions of clang 
compiler and also gcc. This fix might be useful for them so far


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143347

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


[clang-tools-extra] d880d4e - [doc][clang-tidy] Sort release notes by check name.

2023-04-07 Thread Clement Courbet via cfe-commits

Author: Clement Courbet
Date: 2023-04-07T16:11:37+02:00
New Revision: d880d4e7c228e27bd8040e7e2616cfd8c02678bf

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

LOG: [doc][clang-tidy] Sort release notes by check name.

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index facc7c78ea21..c10c6fd9d93d 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -170,6 +170,10 @@ Changes in existing checks
   ` check.
   Global options of the same name should be used instead.
 
+- Improved :doc:`bugprone-fold-init-type
+  ` to handle iterators that do not
+  define `value_type` type aliases.
+
 - Deprecated check-local options `HeaderFileExtensions` and 
`ImplementationFileExtensions`
   in :doc:`bugprone-suspicious-include
   ` check.
@@ -291,10 +295,6 @@ Changes in existing checks
   ` when warning would be
   emitted for a const local variable to which NRVO is applied.
 
-- Improved :doc:`bugprone-fold-init-type
-  ` to handle iterators that do not
-  define `value_type` type aliases.
-
 Removed checks
 ^^
 



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


[PATCH] D137782: [clang-tidy]bugprone-fold-init-type

2023-04-07 Thread Clement Courbet via Phabricator via cfe-commits
courbet marked an inline comment as done.
courbet added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:294
 
+- Improved :doc:`bugprone-fold-init-type
+  ` to handle iterators that do not

Eugene.Zelenko wrote:
> Please keep alphabetical order (by check name) in this section.
Done (in d880d4e7c228).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137782

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


[clang] 33e8431 - [clang] Add test for CWG255

2023-04-07 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-07T18:33:33+04:00
New Revision: 33e84315e7d674cf6327d23f035aa4a2f28ac8ee

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

LOG: [clang] Add test for CWG255

[[https://wg21.link/p1787 | P1787]]: CWG255 (partially resolved by N3778 is 
resolved by generally specifying the restriction to usual deallocation 
functions.
Wording: In any case, any declarations other than of usual deallocation 
functions ([basic.stc.dynamic.deallocation]) are discarded. ([expr.delete]/9)

Reviewed By: #clang-language-wg, cor3ntin

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

Added: 


Modified: 
clang/test/CXX/drs/dr2xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 31ac31b088105..d8fb8941121de 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@ namespace dr254 { // dr254: yes
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 8ca6d081379d8..8d3268b34f52a 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg255";>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256";>256



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


[PATCH] D147549: [clang] Add test for CWG255

2023-04-07 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33e84315e7d6: [clang] Add test for CWG255 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147549

Files:
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@
 https://wg21.link/cwg255";>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256";>256
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@
 https://wg21.link/cwg255";>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256";>256
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 154825b - [clang] Mark CWG562 as N/A

2023-04-07 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-07T18:33:56+04:00
New Revision: 154825bdf6fb5ec5b4cd7d53cf93d68b185ca55d

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

LOG: [clang] Mark CWG562 as N/A

[[https://wg21.link/p1787 | P1787]]: CWG562 is resolved by defining lookup as 
occurring from a program point.
Wording: A single search in a scope S for a name N from a program point P finds 
all declarations that precede P to which any name that is the same as N 
([basic.pre]) is bound in S. ([basic.lookup]/2)

Reviewed By: #clang-language-wg, cor3ntin, shafik

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

Added: 


Modified: 
clang/test/CXX/drs/dr5xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index b5b7be179248..d75b1b5bba16 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@ namespace dr561 { // dr561: yes
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 8d3268b34f52..7cbb729adb9c 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg562";>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563";>563



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


[PATCH] D147554: [clang] Mark CWG562 as N/A

2023-04-07 Thread Vlad Serebrennikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG154825bdf6fb: [clang] Mark CWG562 as N/A (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147554

Files:
  clang/test/CXX/drs/dr5xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@
 https://wg21.link/cwg562";>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563";>563
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@
 https://wg21.link/cwg562";>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563";>563
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147590: [clang] Add test for CWG607

2023-04-07 Thread Vlad Serebrennikov 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 rG4b0386940255: [clang] Add test for CWG607 (authored by 
Endill).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147590

Files:
  clang/test/CXX/drs/dr6xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3683,7 +3683,7 @@
 https://wg21.link/cwg607";>607
 CD6
 Lookup of mem-initializer-ids
-Unknown
+Yes
   
   
 https://wg21.link/cwg608";>608
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -100,6 +100,34 @@
 #endif
 }
 
+namespace dr607 { // dr607: yes
+namespace example1 {
+struct Y {};
+
+template  struct X : public virtual Y {};
+
+template  class A : public X {
+  template  A(S) : S() {}
+};
+
+template A::A(Y);
+} // namespace example1
+
+namespace example2 {
+namespace N {
+struct B {
+  B(int);
+};
+typedef B typedef_B;
+struct D : B {
+  D();
+};
+} // namespace N
+
+N::D::D() : typedef_B(0) {}
+} // namespace example2
+} // namespace dr607
+
 namespace dr608 { // dr608: yes
   struct A { virtual void f(); };
   struct B : A {};


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3683,7 +3683,7 @@
 https://wg21.link/cwg607";>607
 CD6
 Lookup of mem-initializer-ids
-Unknown
+Yes
   
   
 https://wg21.link/cwg608";>608
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -100,6 +100,34 @@
 #endif
 }
 
+namespace dr607 { // dr607: yes
+namespace example1 {
+struct Y {};
+
+template  struct X : public virtual Y {};
+
+template  class A : public X {
+  template  A(S) : S() {}
+};
+
+template A::A(Y);
+} // namespace example1
+
+namespace example2 {
+namespace N {
+struct B {
+  B(int);
+};
+typedef B typedef_B;
+struct D : B {
+  D();
+};
+} // namespace N
+
+N::D::D() : typedef_B(0) {}
+} // namespace example2
+} // namespace dr607
+
 namespace dr608 { // dr608: yes
   struct A { virtual void f(); };
   struct B : A {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4b03869 - [clang] Add test for CWG607

2023-04-07 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-04-07T18:40:35+04:00
New Revision: 4b03869402558d6aa24ce08766825eef34d6aff6

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

LOG: [clang] Add test for CWG607

[[https://wg21.link/p1787 | P1787]]: CWG607 is resolved by looking up 
unqualified names in a mem-initializer-id from outside the parameter scope.
Wording: Lookup for an unqualified name in a mem-initializer-id ignores the 
constructor’s function parameter scope. ([class.base.init]/2)

Reviewed By: #clang-language-wg, shafik

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

Added: 


Modified: 
clang/test/CXX/drs/dr6xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr6xx.cpp b/clang/test/CXX/drs/dr6xx.cpp
index f9925e22085b..b74e466c62ee 100644
--- a/clang/test/CXX/drs/dr6xx.cpp
+++ b/clang/test/CXX/drs/dr6xx.cpp
@@ -100,6 +100,34 @@ namespace dr606 { // dr606: yes
 #endif
 }
 
+namespace dr607 { // dr607: yes
+namespace example1 {
+struct Y {};
+
+template  struct X : public virtual Y {};
+
+template  class A : public X {
+  template  A(S) : S() {}
+};
+
+template A::A(Y);
+} // namespace example1
+
+namespace example2 {
+namespace N {
+struct B {
+  B(int);
+};
+typedef B typedef_B;
+struct D : B {
+  D();
+};
+} // namespace N
+
+N::D::D() : typedef_B(0) {}
+} // namespace example2
+} // namespace dr607
+
 namespace dr608 { // dr608: yes
   struct A { virtual void f(); };
   struct B : A {};

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 7cbb729adb9c..7498753836d6 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -3683,7 +3683,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg607";>607
 CD6
 Lookup of mem-initializer-ids
-Unknown
+Yes
   
   
 https://wg21.link/cwg608";>608



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


[PATCH] D147535: [clang][Interp] Don't create global variables more than once

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

I keep trying to find some way to test this change... and instead, I've filed 
several new crashing issues in the issue tracker. The changes look correct to 
me despite the lack of a test, but if anyone else can dream up some way to tell 
a ctor is being called twice instead of once, that would be great. If not, LGTM 
otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147535

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


[PATCH] D146101: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-07 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/docs/tools/dump_format_style.py:72
 
-  subtype, napplied = re.subn(r'^std::vector<(.*)>$', r'\1', typestr)
-  if napplied == 1:
-return 'List of ' + pluralize(to_yaml_type(subtype))
+  match = re.match(r'std::vector<(.*)>$', typestr)
+  if match:

rymiel wrote:
> jp4a50 wrote:
> > I changed this from `subn` to `match` here since it's just a simpler way of 
> > expressing the same thing.
> (Just FYI, those pythons sources are pretty ancient and untouched, I planned 
> on refactoring the whole thing using more modern, idiomatic Python but then 
> concluded that it's not really necessary)
Is curdeius the one who knows about the Python scripts and the YAML parser?  
Did he move on to meaningful things?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146101

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


[PATCH] D147534: [clang][Interp] Make sure we have a variable scope for initializers

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

Generally LGTM but had an additional test request.




Comment at: clang/test/AST/Interp/records.cpp:315
+  auto T = Test(Arr, Pos);
+  // End of scope, should destroy Test.
+}

Would it make sense to give `Test` a constexpr destructor so that we can 
validate it's being called? e.g. https://godbolt.org/z/fhE7xzE4e


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

https://reviews.llvm.org/D147534

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


[clang] b7e20aa - [Doc][NFC] Fix a typo

2023-04-07 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2023-04-07T23:34:26+08:00
New Revision: b7e20aa9b7d31e91db6df82baba30b8d33050638

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

LOG: [Doc][NFC] Fix a typo

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 031d8a9b624d..193ba4786a48 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1687,7 +1687,7 @@ floating point semantic models: precise (the default), 
strict, and fast.
Details:
 
* ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
-   * ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
+   * ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACCESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 
Note: If your command line specifies multiple instances



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


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-07 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 511697.
python3kgae added a comment.

Revert change for self-assign-field which deserve its own pull request.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146897

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/warn-self-assign-overloaded.cpp


Index: clang/test/SemaCXX/warn-self-assign-overloaded.cpp
===
--- clang/test/SemaCXX/warn-self-assign-overloaded.cpp
+++ clang/test/SemaCXX/warn-self-assign-overloaded.cpp
@@ -53,15 +53,15 @@
 
 #ifndef DUMMY
   a *= a;
-  a /= a; // expected-warning {{explicitly assigning}}
-  a %= a; // expected-warning {{explicitly assigning}}
+  a /= a;
+  a %= a;
   a += a;
-  a -= a; // expected-warning {{explicitly assigning}}
+  a -= a;
   a <<= a;
   a >>= a;
-  a &= a; // expected-warning {{explicitly assigning}}
-  a |= a; // expected-warning {{explicitly assigning}}
-  a ^= a; // expected-warning {{explicitly assigning}}
+  a &= a;
+  a |= a;
+  a ^= a;
 #endif
 }
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15657,13 +15657,15 @@
Expr *LHS, Expr *RHS) {
   switch (Opc) {
   case BO_Assign:
+// Skip diagnose on compound assignment.
+DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
+[[fallthrough]];
   case BO_DivAssign:
   case BO_RemAssign:
   case BO_SubAssign:
   case BO_AndAssign:
   case BO_OrAssign:
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;
   default:


Index: clang/test/SemaCXX/warn-self-assign-overloaded.cpp
===
--- clang/test/SemaCXX/warn-self-assign-overloaded.cpp
+++ clang/test/SemaCXX/warn-self-assign-overloaded.cpp
@@ -53,15 +53,15 @@
 
 #ifndef DUMMY
   a *= a;
-  a /= a; // expected-warning {{explicitly assigning}}
-  a %= a; // expected-warning {{explicitly assigning}}
+  a /= a;
+  a %= a;
   a += a;
-  a -= a; // expected-warning {{explicitly assigning}}
+  a -= a;
   a <<= a;
   a >>= a;
-  a &= a; // expected-warning {{explicitly assigning}}
-  a |= a; // expected-warning {{explicitly assigning}}
-  a ^= a; // expected-warning {{explicitly assigning}}
+  a &= a;
+  a |= a;
+  a ^= a;
 #endif
 }
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15657,13 +15657,15 @@
Expr *LHS, Expr *RHS) {
   switch (Opc) {
   case BO_Assign:
+// Skip diagnose on compound assignment.
+DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
+[[fallthrough]];
   case BO_DivAssign:
   case BO_RemAssign:
   case BO_SubAssign:
   case BO_AndAssign:
   case BO_OrAssign:
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;
   default:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146240: [libc++][format] Use granularized charconv.

2023-04-07 Thread Mark de Wever 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 rG57e20cab5a1d: [libc++][format] Use granularized charconv. 
(authored by Mordante).
Herald added projects: clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146240

Files:
  libcxx/include/__format/formatter_floating_point.h
  libcxx/include/__format/formatter_integral.h
  libcxx/include/__format/formatter_output.h
  libcxx/include/chrono
  libcxx/test/libcxx/transitive_includes/cxx03.csv
  libcxx/test/libcxx/transitive_includes/cxx11.csv
  libcxx/test/libcxx/transitive_includes/cxx14.csv
  libcxx/test/libcxx/transitive_includes/cxx17.csv
  libcxx/test/libcxx/transitive_includes/cxx20.csv
  libcxx/test/libcxx/transitive_includes/cxx2b.csv

Index: libcxx/test/libcxx/transitive_includes/cxx2b.csv
===
--- libcxx/test/libcxx/transitive_includes/cxx2b.csv
+++ libcxx/test/libcxx/transitive_includes/cxx2b.csv
@@ -68,7 +68,6 @@
 charconv initializer_list
 charconv limits
 chrono array
-chrono charconv
 chrono cmath
 chrono compare
 chrono cstddef
@@ -227,7 +226,7 @@
 filesystem system_error
 filesystem version
 format array
-format charconv
+format cmath
 format cstddef
 format cstdint
 format cstdlib
Index: libcxx/test/libcxx/transitive_includes/cxx20.csv
===
--- libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -326,7 +326,7 @@
 filesystem type_traits
 filesystem version
 format array
-format charconv
+format cmath
 format cstddef
 format cstdint
 format cstdlib
Index: libcxx/test/libcxx/transitive_includes/cxx17.csv
===
--- libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -319,7 +319,7 @@
 filesystem type_traits
 filesystem version
 format array
-format charconv
+format cmath
 format cstddef
 format cstdint
 format cstdlib
Index: libcxx/test/libcxx/transitive_includes/cxx14.csv
===
--- libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -319,7 +319,7 @@
 filesystem type_traits
 filesystem version
 format array
-format charconv
+format cmath
 format cstddef
 format cstdint
 format cstdlib
Index: libcxx/test/libcxx/transitive_includes/cxx11.csv
===
--- libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -317,7 +317,7 @@
 filesystem type_traits
 filesystem version
 format array
-format charconv
+format cmath
 format cstddef
 format cstdint
 format cstdlib
Index: libcxx/test/libcxx/transitive_includes/cxx03.csv
===
--- libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -317,7 +317,7 @@
 filesystem type_traits
 filesystem version
 format array
-format charconv
+format cmath
 format cstddef
 format cstdint
 format cstdlib
Index: libcxx/include/chrono
===
--- libcxx/include/chrono
+++ libcxx/include/chrono
@@ -797,4 +797,8 @@
 #  include 
 #endif
 
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
+#  include 
+#endif
+
 #endif // _LIBCPP_CHRONO
Index: libcxx/include/__format/formatter_output.h
===
--- libcxx/include/__format/formatter_output.h
+++ libcxx/include/__format/formatter_output.h
@@ -14,9 +14,12 @@
 #include <__algorithm/ranges_fill_n.h>
 #include <__algorithm/ranges_for_each.h>
 #include <__algorithm/ranges_transform.h>
+#include <__charconv/to_chars_integral.h>
+#include <__charconv/to_chars_result.h>
 #include <__chrono/statically_widen.h>
 #include <__concepts/same_as.h>
 #include <__config>
+#include <__errc>
 #include <__format/buffer.h>
 #include <__format/concepts.h>
 #include <__format/escaped_output_table.h>
@@ -29,7 +32,6 @@
 #include <__type_traits/make_unsigned.h>
 #include <__utility/move.h>
 #include <__utility/unreachable.h>
-#include 
 #include 
 #include 
 #include 
Index: libcxx/include/__format/formatter_integral.h
===
--- libcxx/include/__format/formatter_integral.h
+++ libcxx/include/__format/formatter_integral.h
@@ -10,9 +10,13 @@
 #ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
 #define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
 
+#include <__charconv/to_chars_integral.h>

[PATCH] D144328: [libc++][format][chrono] Addresses LWG3842.

2023-04-07 Thread Mark de Wever via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf07b882e2c1: [libc++][format][chrono] Addresses LWG3842. 
(authored by Mordante).
Herald added projects: clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.

Changed prior to commit:
  https://reviews.llvm.org/D144328?vs=498582&id=511700#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144328

Files:
  libcxx/docs/Status/Cxx2bIssues.csv


Index: libcxx/docs/Status/Cxx2bIssues.csv
===
--- libcxx/docs/Status/Cxx2bIssues.csv
+++ libcxx/docs/Status/Cxx2bIssues.csv
@@ -266,7 +266,7 @@
 "`3834 `__","Missing ``constexpr`` for 
``std::intmax_t`` math functions in ","February 2023","","",""
 "`3839 `__","``range_formatter``'s 
``set_separator``, ``set_brackets``, and ``underlying`` functions should be 
``noexcept``","February 2023","|Complete|","17.0","|format|"
 "`3841 `__"," should not be ""all 
freestanding""","February 2023","","",""
-"`3842 `__","Unclear wording for ``precision`` in 
``chrono-format-spec``","February 2023","","","|format|"
+"`3842 `__","Unclear wording for ``precision`` in 
``chrono-format-spec``","February 2023","|Complete|","16.0","|format|"
 "`3848 `__","``adjacent_view``, 
``adjacent_transform_view`` and ``slide_view`` missing ``base`` 
accessor","February 2023","","","|ranges|"
 "`3849 `__","``cartesian_product_view::iterator``'s 
default constructor is overconstrained","February 2023","","","|ranges|"
 "`3850 `__","``views::as_const`` on 
``empty_view`` should return ``empty_view``","February 
2023","","","|ranges|"


Index: libcxx/docs/Status/Cxx2bIssues.csv
===
--- libcxx/docs/Status/Cxx2bIssues.csv
+++ libcxx/docs/Status/Cxx2bIssues.csv
@@ -266,7 +266,7 @@
 "`3834 `__","Missing ``constexpr`` for ``std::intmax_t`` math functions in ","February 2023","","",""
 "`3839 `__","``range_formatter``'s ``set_separator``, ``set_brackets``, and ``underlying`` functions should be ``noexcept``","February 2023","|Complete|","17.0","|format|"
 "`3841 `__"," should not be ""all freestanding""","February 2023","","",""
-"`3842 `__","Unclear wording for ``precision`` in ``chrono-format-spec``","February 2023","","","|format|"
+"`3842 `__","Unclear wording for ``precision`` in ``chrono-format-spec``","February 2023","|Complete|","16.0","|format|"
 "`3848 `__","``adjacent_view``, ``adjacent_transform_view`` and ``slide_view`` missing ``base`` accessor","February 2023","","","|ranges|"
 "`3849 `__","``cartesian_product_view::iterator``'s default constructor is overconstrained","February 2023","","","|ranges|"
 "`3850 `__","``views::as_const`` on ``empty_view`` should return ``empty_view``","February 2023","","","|ranges|"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-04-07 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 511702.
njames93 added a comment.

Rebased and sorted release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
@@ -0,0 +1,119 @@
+// RUN: %check_clang_tidy -std=c++14 %s modernize-type-traits %t -check-suffixes=',MACRO'
+// RUN: %check_clang_tidy -std=c++14 %s modernize-type-traits %t -- \
+// RUN:   -config='{CheckOptions: {modernize-type-traits.IgnoreMacros: true}}'
+// RUN: %check_clang_tidy -std=c++17 %s modernize-type-traits %t -check-suffixes=',CXX17,MACRO,CXX17MACRO'
+
+namespace std {
+  template 
+  struct is_const {
+static constexpr bool value = true;
+  };
+
+  template 
+  struct is_same {
+static constexpr bool value = true;
+  };
+
+  template
+  struct enable_if {
+using type = T;
+  };
+
+inline namespace __std_lib_version1 {
+  template
+  struct add_const {
+using type = T;
+  };
+} // namespace __std_lib_version1
+
+namespace ext {
+  template
+  struct add_const {
+using type = T;
+  };
+} // namespace ext
+
+} // namespace std
+
+bool NoTemplate = std::is_const::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:19: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: bool NoTemplate = std::is_const_v
+
+template
+constexpr bool InTemplate = std::is_const::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:29: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: constexpr bool InTemplate = std::is_const_v;
+
+template
+constexpr bool Template2Params = std::is_same::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:34: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: constexpr bool Template2Params = std::is_same_v;
+
+template
+typename std::enable_if::type inTemplate();
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tinTemplate();
+
+typename std::enable_if::type noTemplate();
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tnoTemplate();
+
+std::enable_if::type noTemplateOrTypename();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tnoTemplateOrTypename();
+
+using UsingNoTypename = std::enable_if::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use c++14 style type templates
+// CHECK-FIXES: using UsingNoTypename = std::enable_if_t;
+
+using UsingSpace = std::enable_if ::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use c++14 style type templates
+// CHECK-FIXES: using UsingSpace = std::enable_if_t ;
+
+template
+using UsingSpaceTemplate = typename std::enable_if ::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use c++14 style type templates
+// CHECK-FIXES: using UsingSpaceTemplate = std::enable_if_t ;
+
+bool NoTemplateSpace = std::is_const  ::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:24: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: bool NoTemplateSpace = std::is_const_v  ;
+
+template
+constexpr bool InTemplateSpace = std::is_const   ::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:34: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: constexpr bool InTemplateSpace = std::is_const_v   ;
+
+// For macros, no diagnostics if IgnoreMacros is set,
+// No fixes emitted even if IgnoreMacros is unset.
+
+#define VALUE_MACRO std::is_same::value
+bool MacroValue = VALUE_MACRO;
+// CHECK-MESSAGES-CXX17MACRO: :[[@LINE-1]]:19: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17MACRO: #define VALUE_MACRO std::is_same::value
+
+#define TYPE_MACRO typename std::enable_if::type
+using MacroType = TYPE_MACRO;
+// CHECK-MESSAGES-MACRO: :[[@LINE-1]]:19: warning: use c++14 style type templates
+// CHECK-FIXES-MACRO: #define TYPE_MACRO typename std::enable_if::type
+
+
+// Names defined and accessed inside an inline namespace should be converted.
+// Whether or not the inline namespace is specified
+
+using InlineUnspecified = std::add_const::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use c++14 style type templates
+// CHECK-FIXES: using InlineUnspecified = std::add_const_t;
+
+using Inline = std::__std_lib_version1::add_const::type;
+// CHECK-MESSAGES: :[[

[clang] d89c653 - [Clang] Fix filtering of inline namespaces for friend functions

2023-04-07 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2023-04-07T08:58:39-07:00
New Revision: d89c6530fdb57da31f4750bf941a0e4a090c4474

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

LOG: [Clang] Fix filtering of inline namespaces for friend functions

PR D135370 implemented a performance improvement but it restricted the filtering
of declaration from inline namespace too much. In particular it did not filter
for the function template case.

This led to a regression and this PR removes that check.

This fixes: https://github.com/llvm/llvm-project/issues/61851

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/friend.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index ba64591c96498..f9418829186ed 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2293,7 +2293,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
 // Filter out previous declarations that don't match the scope. The only
 // effect this has is to remove declarations found in inline namespaces
 // for friend declarations with unqualified names.
-if (isFriend && !QualifierLoc && !FunctionTemplate) {
+if (isFriend && !QualifierLoc) {
   SemaRef.FilterLookupForScope(Previous, DC, /*Scope=*/ nullptr,
/*ConsiderLinkage=*/ true,
QualifierLoc.hasQualifier());

diff  --git a/clang/test/SemaTemplate/friend.cpp 
b/clang/test/SemaTemplate/friend.cpp
index 1427db093ec94..b039f10e14d8b 100644
--- a/clang/test/SemaTemplate/friend.cpp
+++ b/clang/test/SemaTemplate/friend.cpp
@@ -148,3 +148,21 @@ namespace PR42513_comment3 {
   template struct T;
   int n = f((X1*)nullptr); // expected-error {{cannot initialize a variable of 
type 'int' with an rvalue of type 'std::nullptr_t'}}
 }
+
+namespace GH61851 {
+namespace A {
+inline namespace B {
+  inline constexpr struct {} foo;
+}
+
+template 
+class Bar {
+  template 
+  friend void foo(U &&arg) {} // no diagnostic expected
+};
+}
+
+void foobar() {
+  A::Bar b;
+}
+}



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


[PATCH] D147762: [Clang] Fix filtering of inline namespaces for friend functions

2023-04-07 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd89c6530fdb5: [Clang] Fix filtering of inline namespaces for 
friend functions (authored by shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147762

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaTemplate/friend.cpp


Index: clang/test/SemaTemplate/friend.cpp
===
--- clang/test/SemaTemplate/friend.cpp
+++ clang/test/SemaTemplate/friend.cpp
@@ -148,3 +148,21 @@
   template struct T;
   int n = f((X1*)nullptr); // expected-error {{cannot initialize a variable of 
type 'int' with an rvalue of type 'std::nullptr_t'}}
 }
+
+namespace GH61851 {
+namespace A {
+inline namespace B {
+  inline constexpr struct {} foo;
+}
+
+template 
+class Bar {
+  template 
+  friend void foo(U &&arg) {} // no diagnostic expected
+};
+}
+
+void foobar() {
+  A::Bar b;
+}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2293,7 +2293,7 @@
 // Filter out previous declarations that don't match the scope. The only
 // effect this has is to remove declarations found in inline namespaces
 // for friend declarations with unqualified names.
-if (isFriend && !QualifierLoc && !FunctionTemplate) {
+if (isFriend && !QualifierLoc) {
   SemaRef.FilterLookupForScope(Previous, DC, /*Scope=*/ nullptr,
/*ConsiderLinkage=*/ true,
QualifierLoc.hasQualifier());


Index: clang/test/SemaTemplate/friend.cpp
===
--- clang/test/SemaTemplate/friend.cpp
+++ clang/test/SemaTemplate/friend.cpp
@@ -148,3 +148,21 @@
   template struct T;
   int n = f((X1*)nullptr); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'std::nullptr_t'}}
 }
+
+namespace GH61851 {
+namespace A {
+inline namespace B {
+  inline constexpr struct {} foo;
+}
+
+template 
+class Bar {
+  template 
+  friend void foo(U &&arg) {} // no diagnostic expected
+};
+}
+
+void foobar() {
+  A::Bar b;
+}
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2293,7 +2293,7 @@
 // Filter out previous declarations that don't match the scope. The only
 // effect this has is to remove declarations found in inline namespaces
 // for friend declarations with unqualified names.
-if (isFriend && !QualifierLoc && !FunctionTemplate) {
+if (isFriend && !QualifierLoc) {
   SemaRef.FilterLookupForScope(Previous, DC, /*Scope=*/ nullptr,
/*ConsiderLinkage=*/ true,
QualifierLoc.hasQualifier());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147791: [NFC][CLANG] Fix static analyzer tool remarks about unchecked return values

2023-04-07 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Reported by Coverity:

Unchecked return value
If the function returns an error value, the error value may be mistaken for a 
normal value.

1. Inside "Parser.cpp" file, in 
clang::Parser::ParseKNRParamDeclarations(clang::Declarator &): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TryConsumeToken without checking return value (as is done 
elsewhere 75 out of 86 times).

2. Inside "CallGraph.h" file, in clang::CallGraph::addToCallGraph(clang::Decl 
*): Value returned from a function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 22 out of 23 times).

3. Inside "TokenAnnotator.cpp" file ,in 
clang::​format::​::​AnnotatingParser::​consumeToken(): Value returned 
from a function is not checked for errors before being used.

  check_return: Calling consumeToken without checking return value (as is done 
elsewhere 6 out of 7 times).

4. Inside "UnsafeBufferUsage.cpp" file, In 
clang::​ast_matchers::​MatchDescendantVisitor::​findMatch(clang::​DynTypedNode 
const &): Value returned from a function is not checked for errors before being 
used.

check_return: Calling TraverseStmt without checking return value (as is done 
elsewhere 485 out of 489 times)

5. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser::​CanonicalizerAllocator>,
 ::​CanonicalizerAllocator>::​parseFunctionType(): Value returned from 
a function is not checked for errors before being used.

  check_return: Calling consumeIf without checking return value (as is done 
elsewhere 47 out of 50 times).

6. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser::​CanonicalizerAllocator>,
 ::​CanonicalizerAllocator>::​parseBaseUnresolvedName(): Value 
returned from a function is not checked for errors before being used.

check_return: Calling consumeIf without checking return value (as is done 
elsewhere 47 out of 50 times).

7. Inside "ItaniumDemangle.h" file, in 
llvm::​itanium_demangle::​AbstractManglingParser,
 llvm::​esimd::​SimpleAllocator>::​parseNumber(bool): Value returned from a 
function is not checked for errors before being used.

check_return: Calling consumeIf without checking return value (as is done 
elsewhere 95 out of 102 times).

8. Inside "ExprConstant.cpp" file, in 
clang::​Expr::​isPotentialConstantExprUnevaluated(clang::​Expr *, 
clang::​FunctionDecl const *, 
llvm::​SmallVectorImpl> &): Value returned from a function is not checked 
for errors before being used.

check_return: Calling Evaluate without checking return value (as is done 
elsewhere 23 out of 27 times).

9. Inside "ASTMatchFinder.cpp" file, in 
clang::​ast_matchers::​internal::​::​MatchASTVisitor::​dataTraverseNode(clang::​Stmt
 *, llvm::​SmallVectorImpl, 
llvm::​PointerIntPairInfo>>> *): Value returned from a 
function is not checked for errors before being used.

check_return: Calling TraverseDecl without checking return value (as is done 
elsewhere 29 out of 33 times).

10. Inside "ParseObjc.cpp" file, in 
clang::​Parser::​isStartOfObjCClassMessageMissingOpenBracket(): Value returned 
from a function is not checked for errors before being used.

check_return: Calling TryAnnotateTypeOrScopeToken without checking return value 
(as is done elsewhere 19 out of 21 times).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147791

Files:
  clang/include/clang/Analysis/CallGraph.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Parse/Parser.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h

Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -,7 +,7 @@
   if (consumeIf("dn"))
 return getDerived().parseDestructorName();
 
-  consumeIf("on");
+  (void)consumeIf("on");
 
   Node *Oper = getDerived().parseOperatorName(/*NameState=*/nullptr);
   if (Oper == nullptr)
@@ -3466,7 +3466,7 @@
 AbstractManglingParser::parseNumber(bool AllowNegative) {
   const char *Tmp = First;
   if (AllowNegative)
-consumeIf('n');
+(void)consumeIf('n');
   if (numLeft() == 0 || !std::isdigit(*First))
 return StringView();
   while (numLeft() != 0 && std::isdigit(*First))
@@ -3535,7 +353

[PATCH] D146463: [CodeGen][RISCV] Change Shadow Call Stack Register to X3

2023-04-07 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 511704.
paulkirth marked an inline comment as done.
paulkirth added a comment.

Remove unrelated whitespace changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146463

Files:
  clang/docs/ShadowCallStack.rst
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/test/shadowcallstack/lit.cfg.py
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVSubtarget.cpp
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/test/CodeGen/RISCV/reserved-regs.ll
  llvm/test/CodeGen/RISCV/saverestore-scs.ll
  llvm/test/CodeGen/RISCV/shadowcallstack.ll

Index: llvm/test/CodeGen/RISCV/shadowcallstack.ll
===
--- llvm/test/CodeGen/RISCV/shadowcallstack.ll
+++ llvm/test/CodeGen/RISCV/shadowcallstack.ll
@@ -1,7 +1,7 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=riscv32 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s --check-prefix=RV32
-; RUN: llc -mtriple=riscv64 -mattr=+reserve-x18 -verify-machineinstrs < %s \
+; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
 ; RUN:   | FileCheck %s --check-prefix=RV64
 
 define void @f1() shadowcallstack {
@@ -34,9 +34,9 @@
 define i32 @f3() shadowcallstack {
 ; RV32-LABEL: f3:
 ; RV32:   # %bb.0:
-; RV32-NEXT:sw ra, 0(s2)
-; RV32-NEXT:addi s2, s2, 4
-; RV32-NEXT:.cfi_escape 0x16, 0x12, 0x02, 0x82, 0x7c #
+; RV32-NEXT:sw ra, 0(gp)
+; RV32-NEXT:addi gp, gp, 4
+; RV32-NEXT:.cfi_escape 0x16, 0x03, 0x02, 0x73, 0x7c #
 ; RV32-NEXT:addi sp, sp, -16
 ; RV32-NEXT:.cfi_def_cfa_offset 16
 ; RV32-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
@@ -44,16 +44,16 @@
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32-NEXT:addi sp, sp, 16
-; RV32-NEXT:lw ra, -4(s2)
-; RV32-NEXT:addi s2, s2, -4
-; RV32-NEXT:.cfi_restore s2
+; RV32-NEXT:lw ra, -4(gp)
+; RV32-NEXT:addi gp, gp, -4
+; RV32-NEXT:.cfi_restore gp
 ; RV32-NEXT:ret
 ;
 ; RV64-LABEL: f3:
 ; RV64:   # %bb.0:
-; RV64-NEXT:sd ra, 0(s2)
-; RV64-NEXT:addi s2, s2, 8
-; RV64-NEXT:.cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78 #
+; RV64-NEXT:sd ra, 0(gp)
+; RV64-NEXT:addi gp, gp, 8
+; RV64-NEXT:.cfi_escape 0x16, 0x03, 0x02, 0x73, 0x78 #
 ; RV64-NEXT:addi sp, sp, -16
 ; RV64-NEXT:.cfi_def_cfa_offset 16
 ; RV64-NEXT:sd ra, 8(sp) # 8-byte Folded Spill
@@ -61,9 +61,9 @@
 ; RV64-NEXT:call bar@plt
 ; RV64-NEXT:ld ra, 8(sp) # 8-byte Folded Reload
 ; RV64-NEXT:addi sp, sp, 16
-; RV64-NEXT:ld ra, -8(s2)
-; RV64-NEXT:addi s2, s2, -8
-; RV64-NEXT:.cfi_restore s2
+; RV64-NEXT:ld ra, -8(gp)
+; RV64-NEXT:addi gp, gp, -8
+; RV64-NEXT:.cfi_restore gp
 ; RV64-NEXT:ret
   %res = call i32 @bar()
   %res1 = add i32 %res, 1
@@ -73,72 +73,72 @@
 define i32 @f4() shadowcallstack {
 ; RV32-LABEL: f4:
 ; RV32:   # %bb.0:
-; RV32-NEXT:sw ra, 0(s2)
-; RV32-NEXT:addi s2, s2, 4
-; RV32-NEXT:.cfi_escape 0x16, 0x12, 0x02, 0x82, 0x7c #
+; RV32-NEXT:sw ra, 0(gp)
+; RV32-NEXT:addi gp, gp, 4
+; RV32-NEXT:.cfi_escape 0x16, 0x03, 0x02, 0x73, 0x7c #
 ; RV32-NEXT:addi sp, sp, -16
 ; RV32-NEXT:.cfi_def_cfa_offset 16
 ; RV32-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
 ; RV32-NEXT:sw s0, 8(sp) # 4-byte Folded Spill
 ; RV32-NEXT:sw s1, 4(sp) # 4-byte Folded Spill
-; RV32-NEXT:sw s3, 0(sp) # 4-byte Folded Spill
+; RV32-NEXT:sw s2, 0(sp) # 4-byte Folded Spill
 ; RV32-NEXT:.cfi_offset ra, -4
 ; RV32-NEXT:.cfi_offset s0, -8
 ; RV32-NEXT:.cfi_offset s1, -12
-; RV32-NEXT:.cfi_offset s3, -16
+; RV32-NEXT:.cfi_offset s2, -16
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:mv s0, a0
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:mv s1, a0
 ; RV32-NEXT:call bar@plt
-; RV32-NEXT:mv s3, a0
+; RV32-NEXT:mv s2, a0
 ; RV32-NEXT:call bar@plt
 ; RV32-NEXT:add s0, s0, s1
-; RV32-NEXT:add a0, s3, a0
+; RV32-NEXT:add a0, s2, a0
 ; RV32-NEXT:add a0, s0, a0
 ; RV32-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32-NEXT:lw s0, 8(sp) # 4-byte Folded Reload
 ; RV32-NEXT:lw s1, 4(sp) # 4-byte Folded Reload
-; RV32-NEXT:lw s3, 0(sp) # 4-byte Folded Reload
+; RV32-NEXT:lw s2, 0(sp) # 4-byte Folded Reload
 ; RV32-NEXT:addi sp, sp, 16
-; RV32-NEXT:lw ra, -4(s2)
-; RV32-NEXT:addi s2, s2, -4
-; RV32-NEXT:.cfi_restore s2
+; RV32-NEXT:lw ra, -4(gp)
+; RV32-NEXT:addi gp, gp, -4
+; RV32-NEXT:.cfi_restore gp
 ; RV32-NEXT:ret
 ;
 ; RV64-LABEL: 

[clang] f9b854b - [Clang] Fix buildbots after Fix filtering of inline namespaces for friend functions commit

2023-04-07 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2023-04-07T09:18:15-07:00
New Revision: f9b854bc8f0bfe2a38b00fab401bb1982eb8e61e

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

LOG: [Clang] Fix buildbots after Fix filtering of inline namespaces for friend 
functions commit

In commit cffadbd951e9 the test I added was using a C++17 feature and this
breaking some build bots. I don't need the feature and so I will modify
the test to not use it.

Added: 


Modified: 
clang/test/SemaTemplate/friend.cpp

Removed: 




diff  --git a/clang/test/SemaTemplate/friend.cpp 
b/clang/test/SemaTemplate/friend.cpp
index b039f10e14d8b..9a1ed46812ca9 100644
--- a/clang/test/SemaTemplate/friend.cpp
+++ b/clang/test/SemaTemplate/friend.cpp
@@ -152,7 +152,7 @@ namespace PR42513_comment3 {
 namespace GH61851 {
 namespace A {
 inline namespace B {
-  inline constexpr struct {} foo;
+  constexpr struct {} foo;
 }
 
 template 



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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked 4 inline comments as done.
Mordante added a comment.
Herald added projects: clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.

Thanks for the review!




Comment at: 
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h:17
+template 
+void format_tests(TestFunction check, ExceptionTest check_exception) {
+  // Note the output of std::thread::id is unspecified. The output text is the

ldionne wrote:
> ```
> std::stringstream s; s << id;
> assert(s.str() == std::format("{}", id);
> ```
As discussed this change is already done in `stream.pass.cpp`.



Comment at: 
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp:27
 #include "test_macros.h"
 
+template 

ldionne wrote:
> While we're at it, can we also test the output stream version on an empty 
> `std::thread::id`?
Based on [thread.thread.id]/1
```
An object of type thread​::​id provides a unique identifier for each thread of 
execution and a single distinct value for all thread objects that do not 
represent a thread of execution ([thread.thread.class]).
Each thread of execution has an associated thread​::​id object that is not 
equal to the thread​::​id object of any other thread of execution and that is 
not equal to the thread​::​id object of any thread object that does not 
represent threads of execution.
```
That value is unspecified and may differ between implementations; I expect it 
will be different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 511705.
Mordante marked 2 inline comments as done.
Mordante added a comment.

Rebased, addresses review comment, and get a CI run.


Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

Files:
  libcxx/docs/FeatureTestMacroTable.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx2b.rst
  libcxx/docs/Status/Cxx2bPapers.csv
  libcxx/docs/Status/FormatPaper.csv
  libcxx/include/__format/parser_std_format_spec.h
  libcxx/include/__threading_support
  libcxx/include/thread
  libcxx/include/version
  libcxx/test/libcxx/transitive_includes/cxx03.csv
  libcxx/test/libcxx/transitive_includes/cxx11.csv
  libcxx/test/libcxx/transitive_includes/cxx14.csv
  libcxx/test/libcxx/transitive_includes/cxx17.csv
  libcxx/test/libcxx/transitive_includes/cxx20.csv
  libcxx/test/libcxx/transitive_includes/cxx2b.csv
  
libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
  
libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
  libcxx/utils/generate_feature_test_macro_components.py

Index: libcxx/utils/generate_feature_test_macro_components.py
===
--- libcxx/utils/generate_feature_test_macro_components.py
+++ libcxx/utils/generate_feature_test_macro_components.py
@@ -327,6 +327,13 @@
 "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
 "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
 "unimplemented": True,
+  }, {
+"name": "__cpp_lib_formatters",
+"values": { "c++2b": 202302 },
+"headers": ["stacktrace", "thread"],
+"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
+"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
+"unimplemented": True,
   }, {
 "name": "__cpp_lib_forward_like",
 "values": { "c++2b": 202207 },
Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
===
--- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
+++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
@@ -175,7 +175,8 @@
 // Tests for P1636 Formatters for library types
 //
 // The paper hasn't been voted in so currently all formatters are disabled.
-// TODO validate whether the test is correct after the paper has been accepted.
+// Note the paper has been abandoned, the types are kept since other papers may
+// introduce these formatters.
 template 
 void test_P1636() {
   assert_is_not_formattable, CharT>();
@@ -191,7 +192,7 @@
 assert_is_not_formattable, CharT>();
 #endif
 #ifndef TEST_HAS_NO_THREADS
-  assert_is_not_formattable();
+  assert_is_formattable();
 #endif
   assert_is_not_formattable, CharT>();
 }
Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
===
--- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
+++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cp

[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 511709.
Mordante added a comment.

CI fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

Files:
  libcxx/docs/FeatureTestMacroTable.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx2b.rst
  libcxx/docs/Status/Cxx2bPapers.csv
  libcxx/docs/Status/FormatPaper.csv
  libcxx/include/__format/parser_std_format_spec.h
  libcxx/include/__threading_support
  libcxx/include/thread
  libcxx/include/version
  libcxx/test/libcxx/transitive_includes/cxx03.csv
  libcxx/test/libcxx/transitive_includes/cxx11.csv
  libcxx/test/libcxx/transitive_includes/cxx14.csv
  libcxx/test/libcxx/transitive_includes/cxx17.csv
  libcxx/test/libcxx/transitive_includes/cxx20.csv
  libcxx/test/libcxx/transitive_includes/cxx2b.csv
  
libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
  
libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
  libcxx/utils/generate_feature_test_macro_components.py

Index: libcxx/utils/generate_feature_test_macro_components.py
===
--- libcxx/utils/generate_feature_test_macro_components.py
+++ libcxx/utils/generate_feature_test_macro_components.py
@@ -327,6 +327,13 @@
 "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
 "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
 "unimplemented": True,
+  }, {
+"name": "__cpp_lib_formatters",
+"values": { "c++2b": 202302 },
+"headers": ["stacktrace", "thread"],
+"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
+"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
+"unimplemented": True,
   }, {
 "name": "__cpp_lib_forward_like",
 "values": { "c++2b": 202207 },
Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
===
--- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
+++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
@@ -175,7 +175,8 @@
 // Tests for P1636 Formatters for library types
 //
 // The paper hasn't been voted in so currently all formatters are disabled.
-// TODO validate whether the test is correct after the paper has been accepted.
+// Note the paper has been abandoned, the types are kept since other papers may
+// introduce these formatters.
 template 
 void test_P1636() {
   assert_is_not_formattable, CharT>();
@@ -191,7 +192,7 @@
 assert_is_not_formattable, CharT>();
 #endif
 #ifndef TEST_HAS_NO_THREADS
-  assert_is_not_formattable();
+  assert_is_formattable();
 #endif
   assert_is_not_formattable, CharT>();
 }
Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
===
--- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
+++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
@@ -18,16 +18,38 @@
 // operator<<(basic_ostream& out, thread::id id);
 
 #include 
+#include 
 #include 
 #include 
 
+#include "make_string.h"
 #include "test_macros.h"
 
-int main(int, char**)
-{
-std::thread::id id0 = std::this_thread::get_id();
-std::ostringstream os;
-os << id0;
+template 
+static void test() {
+  std::thread::id id0 = std::this_thread::get_id();
+  std::basic_ostringstream os;
+  os << id0;
+
+#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+  // C++23 added a formatter specialization for thread::id.
+  // This changed the requirement of ostream to have a
+  // [thread.thread.id]/2
+  //   The text representation for the character type charT of an object of
+  //   type thread::id is an unspecified sequence of charT ...
+  // This definition is used for both streaming and formatting.
+  //
+  // Test whether the output is identical.
+  std::bas

[PATCH] D147791: [NFC][CLANG] Fix static analyzer tool remarks about unchecked return values

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I don't see much value in these changes.  In the cases I know anything about, 
the change in state (or out params) is the error checking that we need.  The 
casts add nothing but noise, so I don't think these are good changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147791

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


[PATCH] D147733: Set rounding_mode to tonearest in presence of a #pragma STDC FENV_ACCESS OFF.

2023-04-07 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: clang/lib/Sema/SemaAttr.cpp:1340
+  if (!IsEnabled)
+NewFPFeatures.setDisallowFenvAccess(IsEnabled);
   FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);

Why is this only needed for "!IsEnabled"? Where is the rounding mode set in the 
IsEnabled case? It looks like setAllowFEnvAccessOverride() is defined by a 
macro and just sets a bit in the OverrideMask, but somehow it seems to be 
setting the rounding mode to Round.Dynamic. I'm just concerned that there is a 
disconnect in the implementation here.


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

https://reviews.llvm.org/D147733

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


[PATCH] D147791: [NFC][CLANG] Fix static analyzer tool remarks about unchecked return values

2023-04-07 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D147791#4251497 , @erichkeane 
wrote:

> I don't see much value in these changes.  In the cases I know anything about, 
> the change in state (or out params) is the error checking that we need.  The 
> casts add nothing but noise, so I don't think these are good changes.

Thanks @erichkeane for reviews and feedback. I agree with you that all changes 
will silence the static analyzer tool but will not make any big impact. I can 
close them as a False positive if you are OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147791

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


[PATCH] D147733: Set rounding_mode to tonearest in presence of a #pragma STDC FENV_ACCESS OFF.

2023-04-07 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor added inline comments.



Comment at: clang/test/CodeGen/pragma-fenv_access.c:239
+// CHECK-LABEL: @func_20
+// STRICT: call float @llvm.experimental.constrained.fadd.f32(float {{.*}}, 
float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+// DEFAULT: fadd float

pengfei wrote:
> Should this be `ignore`?
This is a tricky case. By a strict reading of the C standard, this could be 
ignore, because the standard says the compiler can assume the default floating 
point environment when FENV_ACCESS is OFF and that if code compiled with 
FENV_ACCESS OFF is executed with anything other than the default environment 
the behavior is undefined. However, in this case strict exception semantics 
have been enabled elsewhere in the compilation unit, so floating point 
exceptions may be unmasked. The standard allows us to ignore exceptions, but 
raising a spurious exception may be bad for users.

I'm unsure about this case. I lean towards leaving it as Zahira has it here 
because I don't think the use of strict exception semantics will be common 
enough to justify the less conservative behavior.


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

https://reviews.llvm.org/D147733

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


[PATCH] D147791: [NFC][CLANG] Fix static analyzer tool remarks about unchecked return values

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

That sounds appropriate to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147791

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


[PATCH] D144331: [libc++][format] Implements formatter thread::id.

2023-04-07 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 511715.
Mordante added a comment.

CI fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144331

Files:
  libcxx/docs/FeatureTestMacroTable.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx2b.rst
  libcxx/docs/Status/Cxx2bPapers.csv
  libcxx/docs/Status/FormatPaper.csv
  libcxx/include/__format/parser_std_format_spec.h
  libcxx/include/__threading_support
  libcxx/include/thread
  libcxx/include/version
  libcxx/test/libcxx/transitive_includes/cxx03.csv
  libcxx/test/libcxx/transitive_includes/cxx11.csv
  libcxx/test/libcxx/transitive_includes/cxx14.csv
  libcxx/test/libcxx/transitive_includes/cxx17.csv
  libcxx/test/libcxx/transitive_includes/cxx20.csv
  libcxx/test/libcxx/transitive_includes/cxx2b.csv
  
libcxx/test/std/language.support/support.limits/support.limits.general/thread.version.compile.pass.cpp
  
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.format.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.tests.h
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.functions.vformat.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/format.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/parse.pass.cpp
  
libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
  
libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
  libcxx/utils/generate_feature_test_macro_components.py

Index: libcxx/utils/generate_feature_test_macro_components.py
===
--- libcxx/utils/generate_feature_test_macro_components.py
+++ libcxx/utils/generate_feature_test_macro_components.py
@@ -327,6 +327,13 @@
 "test_suite_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
 "libcxx_guard": "!defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
 "unimplemented": True,
+  }, {
+"name": "__cpp_lib_formatters",
+"values": { "c++2b": 202302 },
+"headers": ["stacktrace", "thread"],
+"test_suite_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
+"libcxx_guard": "!defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)",
+"unimplemented": True,
   }, {
 "name": "__cpp_lib_forward_like",
 "values": { "c++2b": 202207 },
Index: libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
===
--- libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
+++ libcxx/test/std/utilities/format/format.formattable/concept.formattable.compile.pass.cpp
@@ -175,7 +175,8 @@
 // Tests for P1636 Formatters for library types
 //
 // The paper hasn't been voted in so currently all formatters are disabled.
-// TODO validate whether the test is correct after the paper has been accepted.
+// Note the paper has been abandoned, the types are kept since other papers may
+// introduce these formatters.
 template 
 void test_P1636() {
   assert_is_not_formattable, CharT>();
@@ -191,7 +192,7 @@
 assert_is_not_formattable, CharT>();
 #endif
 #ifndef TEST_HAS_NO_THREADS
-  assert_is_not_formattable();
+  assert_is_formattable();
 #endif
   assert_is_not_formattable, CharT>();
 }
Index: libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
===
--- libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
+++ libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.id/stream.pass.cpp
@@ -18,16 +18,38 @@
 // operator<<(basic_ostream& out, thread::id id);
 
 #include 
+#include 
 #include 
 #include 
 
+#include "make_string.h"
 #include "test_macros.h"
 
-int main(int, char**)
-{
-std::thread::id id0 = std::this_thread::get_id();
-std::ostringstream os;
-os << id0;
+template 
+static void test() {
+  std::thread::id id0 = std::this_thread::get_id();
+  std::basic_ostringstream os;
+  os << id0;
+
+#if TEST_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+  // C++23 added a formatter specialization for thread::id.
+  // This changed the requirement of ostream to have a
+  // [thread.thread.id]/2
+  //   The text representation for the character type charT of an object of
+  //   type thread::id is an unspecified sequence of charT ...
+  // This definition is used for both streaming and formatting.
+  //
+  // Test whether the output is identical.
+  std::basi

[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-04-07 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 2 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:170
+
+static constexpr char Bind[] = "";
+

ccotter wrote:
> NIT: should the bound node have some meaningful non-empty name?
Not strictly required as we only ever bind one node.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:197
+  const llvm::StringSet<> &Set) {
+  return ND->isInStdNamespace() && ND->getDeclName().isIdentifier() &&
+ Set.contains(ND->getName());

ccotter wrote:
> For a future release, could we add an option to allow replacing "standard 
> type traits" defined in separate namespaces, as the [BSL 
> library](https://github.com/bloomberg/bde/blob/main/groups/bsl/bslmf/bslmf_removereference.h#L137)
>  does? This would be useful in my case at least.
This could definitely be extended in the future to support extended traits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

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


[clang-tools-extra] 376168b - [clang-tidy] Add modernize-type-traits check

2023-04-07 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2023-04-07T18:38:15+01:00
New Revision: 376168babb51aa08bc864d4797db4a6dbd53fdbc

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

LOG: [clang-tidy] Add modernize-type-traits check

This check will look for usages of standard library type traits of the form 
`traits<...>::type` and `traits<...>::value` and convert them into 
`traits_t<...>` and `traits_v<...>` respectively.
This expands on the work in D135404 by supporting dependent traits with no 
instantiations as well as types.

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

Added: 
clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h
clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp

Modified: 
clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.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/modernize/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
index 9d13001037b8e..91e2d8d5ee4e5 100644
--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
@@ -25,6 +25,7 @@ add_clang_library(clangTidyModernizeModule
   ReplaceRandomShuffleCheck.cpp
   ReturnBracedInitListCheck.cpp
   ShrinkToFitCheck.cpp
+  TypeTraitsCheck.cpp
   UnaryStaticAssertCheck.cpp
   UseAutoCheck.cpp
   UseBoolLiteralsCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp 
b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
index 9f116f92c1fb1..ee0fab18d2068 100644
--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -26,6 +26,7 @@
 #include "ReplaceRandomShuffleCheck.h"
 #include "ReturnBracedInitListCheck.h"
 #include "ShrinkToFitCheck.h"
+#include "TypeTraitsCheck.h"
 #include "UnaryStaticAssertCheck.h"
 #include "UseAutoCheck.h"
 #include "UseBoolLiteralsCheck.h"
@@ -76,6 +77,7 @@ class ModernizeModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "modernize-return-braced-init-list");
 CheckFactories.registerCheck("modernize-shrink-to-fit");
+CheckFactories.registerCheck("modernize-type-traits");
 CheckFactories.registerCheck(
 "modernize-unary-static-assert");
 CheckFactories.registerCheck("modernize-use-auto");

diff  --git a/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
new file mode 100644
index 0..c0766395ec5cc
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
@@ -0,0 +1,316 @@
+//===--- TypeTraitsCheck.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 "TypeTraitsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+static const llvm::StringSet<> ValueTraits = {
+"alignment_of",
+"conjunction",
+"disjunction",
+"extent",
+"has_unique_object_representations",
+"has_virtual_destructor",
+"is_abstract",
+"is_aggregate",
+"is_arithmetic",
+"is_array",
+"is_assignable",
+"is_base_of",
+"is_bounded_array",
+"is_class",
+"is_compound",
+"is_const",
+"is_constructible",
+"is_convertible",
+"is_copy_assignable",
+"is_copy_constructible",
+"is_default_constructible",
+"is_destructible",
+"is_empty",
+"is_enum",
+"is_final",
+"is_floating_point",
+"is_function",
+"is_fundamental",
+"is_integral",
+"is_invocable",
+"is_invocable_r",
+"is_layout_compatible",
+"is_lvalue_reference",
+"is_member_function_pointer",
+"is_member_object_pointer",
+"is_member_pointer",
+"is_move_assignable",
+"is_move_constructible",
+"is_nothrow_assignable",
+"is_nothrow_constructible",
+"is_nothrow_convertible",
+"is_nothrow_copy_assignable",
+"is_nothrow_copy_constructible",
+"is_nothrow_default_constructible",
+"is_nothrow_destructible",
+"is_nothrow_invocable",
+"is_nothrow_invocable_r",

[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-04-07 Thread Nathan James via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
njames93 marked 2 inline comments as done.
Closed by commit rG376168babb51: [clang-tidy] Add modernize-type-traits check 
(authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp
@@ -0,0 +1,119 @@
+// RUN: %check_clang_tidy -std=c++14 %s modernize-type-traits %t -check-suffixes=',MACRO'
+// RUN: %check_clang_tidy -std=c++14 %s modernize-type-traits %t -- \
+// RUN:   -config='{CheckOptions: {modernize-type-traits.IgnoreMacros: true}}'
+// RUN: %check_clang_tidy -std=c++17 %s modernize-type-traits %t -check-suffixes=',CXX17,MACRO,CXX17MACRO'
+
+namespace std {
+  template 
+  struct is_const {
+static constexpr bool value = true;
+  };
+
+  template 
+  struct is_same {
+static constexpr bool value = true;
+  };
+
+  template
+  struct enable_if {
+using type = T;
+  };
+
+inline namespace __std_lib_version1 {
+  template
+  struct add_const {
+using type = T;
+  };
+} // namespace __std_lib_version1
+
+namespace ext {
+  template
+  struct add_const {
+using type = T;
+  };
+} // namespace ext
+
+} // namespace std
+
+bool NoTemplate = std::is_const::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:19: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: bool NoTemplate = std::is_const_v
+
+template
+constexpr bool InTemplate = std::is_const::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:29: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: constexpr bool InTemplate = std::is_const_v;
+
+template
+constexpr bool Template2Params = std::is_same::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:34: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: constexpr bool Template2Params = std::is_same_v;
+
+template
+typename std::enable_if::type inTemplate();
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tinTemplate();
+
+typename std::enable_if::type noTemplate();
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tnoTemplate();
+
+std::enable_if::type noTemplateOrTypename();
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tnoTemplateOrTypename();
+
+using UsingNoTypename = std::enable_if::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use c++14 style type templates
+// CHECK-FIXES: using UsingNoTypename = std::enable_if_t;
+
+using UsingSpace = std::enable_if ::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use c++14 style type templates
+// CHECK-FIXES: using UsingSpace = std::enable_if_t ;
+
+template
+using UsingSpaceTemplate = typename std::enable_if ::type;
+// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use c++14 style type templates
+// CHECK-FIXES: using UsingSpaceTemplate = std::enable_if_t ;
+
+bool NoTemplateSpace = std::is_const  ::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:24: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: bool NoTemplateSpace = std::is_const_v  ;
+
+template
+constexpr bool InTemplateSpace = std::is_const   ::value;
+// CHECK-MESSAGES-CXX17: :[[@LINE-1]]:34: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17: constexpr bool InTemplateSpace = std::is_const_v   ;
+
+// For macros, no diagnostics if IgnoreMacros is set,
+// No fixes emitted even if IgnoreMacros is unset.
+
+#define VALUE_MACRO std::is_same::value
+bool MacroValue = VALUE_MACRO;
+// CHECK-MESSAGES-CXX17MACRO: :[[@LINE-1]]:19: warning: use c++17 style variable templates
+// CHECK-FIXES-CXX17MACRO: #define VALUE_MACRO std::is_same::value
+
+#define TYPE_MACRO typename std::enable_if::type
+using MacroType = TYPE_MACRO;
+// CHECK-MESSAGES-MACRO: :[[@LINE-1]]:19: warning: use c++14 style type templates
+// CHECK-FIXES-MACRO: #define TYPE_MACRO typename std::enable_if::type
+
+
+// Names defined and accessed inside an inline namespace should be converted.
+// Whether or not the inline namespace is specified
+
+using InlineUnspecified = std::add_const::type;
+// CHECK-MESSAGES: :[[@LI

[PATCH] D147733: Set rounding_mode to tonearest in presence of a #pragma STDC FENV_ACCESS OFF.

2023-04-07 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/Sema/SemaAttr.cpp:1340
+  if (!IsEnabled)
+NewFPFeatures.setDisallowFenvAccess(IsEnabled);
   FpPragmaStack.Act(Loc, PSK_Set, StringRef(), NewFPFeatures);

andrew.w.kaylor wrote:
> Why is this only needed for "!IsEnabled"? Where is the rounding mode set in 
> the IsEnabled case? It looks like setAllowFEnvAccessOverride() is defined by 
> a macro and just sets a bit in the OverrideMask, but somehow it seems to be 
> setting the rounding mode to Round.Dynamic. I'm just concerned that there is 
> a disconnect in the implementation here.
That all depends on if we are using the -frounding-math in the command line 
option or not. The LIT test that exercices the pragma is not using this option 
so it's actually not testing the pragma in a strict mode. Using 
-ffp-model=strict trigger -frounding-math **and** 
-ffp-exception-behavior=strict.

I think I want to make this change only when we are in real strict mode. 
Meaning we need both of these options to be set.
#pragma STDC FENV_ACCESS OFF should trigger the round.tonearest when both these 
options are used. So when IsEnabled is false and RoundingMath is 1.


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

https://reviews.llvm.org/D147733

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Josh Haberman via Phabricator via cfe-commits
haberman added a comment.

> is a [[should_tail]] attribute sort of thing: a tail-hint where we do 'best 
> effort with no promises', and make no guarantees that we're going to tail it.

I'm not sure I see the value in that. The compiler already optimizes tail calls 
when it can in a best-effort manner. The purpose of `[[musttail]]` is to 
support algorithms that would blow the stack if tail calls were not optimized. 
It's better to get a compiler error than to get a stack overflow at runtime 
(especially if stack overflow only occurs with certain inputs).


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

https://reviews.llvm.org/D147714

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


[PATCH] D147722: [Concepts] Fix Function Template Concepts comparisons

2023-04-07 Thread Alexander Yermolovich via Phabricator via cfe-commits
ayermolo added a comment.

OK was able to create small(ish) repro

main.h

  #include 
  enum class Enums {
  ACCESS = 0,
  MAP = 1,
  };
  
  template 
  class DMap {
   public:
  template 
  requires std::is_convertible_v
void getOrCreate(TIDR v);
  };
  
  template 
  class DMap {
   public:
  template 
  requires std::is_convertible_v
void getOrCreate(TIDR v);
  
  };

main.cpp

  #include "main.h"
  
  // broken with original patch, broken with follow up fix
  template 
  template 
  requires std::is_convertible_v
  inline void
  DMap::getOrCreate(TIDR v) {
  }
  
  // broken with original patch, fixed with follow up fix
  template 
  template 
requires std::is_convertible_v
  inline void
  DMap::getOrCreate(TIDR v) {
  }
  
  
  int foo() {
  DMap map;
  long i;
  map.getOrCreate(i);
  }


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

https://reviews.llvm.org/D147722

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D147714#4251690 , @haberman wrote:

>> is a [[should_tail]] attribute sort of thing: a tail-hint where we do 'best 
>> effort with no promises', and make no guarantees that we're going to tail it.
>
> I'm not sure I see the value in that. The compiler already optimizes tail 
> calls when it can in a best-effort manner. The purpose of `[[musttail]]` is 
> to support algorithms that would blow the stack if tail calls were not 
> optimized. It's better to get a compiler error than to get a stack overflow 
> at runtime (especially if stack overflow only occurs with certain inputs).

I see, yes, that makes sense.  Then I go back to my other suggestion: we this 
needs to encode the per-platform limitations in Sema.

I could definitely see this being an 'alias' for `musttail` on most platforms, 
and us reducing the restrictions over time on a per-platform basis though, so 
long as we knew codegen would be compatible with it.


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

https://reviews.llvm.org/D147714

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

So to make some conclusion - there is a need for less strict version of 
musttail in LLVM, right? Ideally platform specific, like x86_musttail?


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

https://reviews.llvm.org/D147714

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


[PATCH] D146240: [libc++][format] Use granularized charconv.

2023-04-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan removed a reviewer: owenpan.
Herald added a reviewer: owenpan.
Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146240

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


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D147714#4251752 , @xbolva00 wrote:

> So to make some conclusion - there is a need for less strict version of 
> musttail in LLVM, right? Ideally platform specific, like x86_musttail?

I'm not sure what the rules for the LLVM definition of musttail should be, but 
from the CFE's perspective, something like `[[nonportable_musttail]]` that 
always enforced the rules of the CURRENT platform(note: or stricter, and 
relaxing would be allowed later) would be acceptable.


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

https://reviews.llvm.org/D147714

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


[PATCH] D147673: [Clang] Improve designated inits diagnostic location

2023-04-07 Thread Bill Wendling via Phabricator via cfe-commits
void marked an inline comment as done.
void added inline comments.



Comment at: clang/test/SemaCXX/cxx2b-designated-initializers.cpp:13
+  const S result { // expected-error {{field designator (null) does not refer 
to any field in type 'const S'}}
+.a = x
+  };

aaron.ballman wrote:
> rsmith wrote:
> > Why are we rejecting this?
> That's existing behavior: https://godbolt.org/z/48ThKbTor but we don't get 
> the behavior when it's not a template (https://godbolt.org/z/f3zWaqdWr) or in 
> C (https://godbolt.org/z/P1TqG43nG), so I agree that this should be accepted.
Also, if the "auto" above is changed to "int" this compiles just fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147673

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


[clang] 2cbf512 - [Clang] Improve designated inits diagnostic location

2023-04-07 Thread Bill Wendling via cfe-commits

Author: Bill Wendling
Date: 2023-04-07T11:37:05-07:00
New Revision: 2cbf5127d58553fd6224a1ec809536bccc5b8510

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

LOG: [Clang] Improve designated inits diagnostic location

A "null" designator won't have a valid location. Try to approximate this
location as best we can in that situation.

Closes 61118
Closes 46132

Reviewed By: shafik

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

Added: 
clang/test/SemaCXX/cxx2b-designated-initializers.cpp

Modified: 
clang/lib/Sema/SemaInit.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 5fe417fa6351d..be46191a19b93 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -2641,8 +2641,15 @@ InitListChecker::CheckDesignatedInitializer(const 
InitializedEntity &Entity,
   hadError = true;
 } else {
   // Typo correction didn't find anything.
-  SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown)
-<< FieldName << CurrentObjectType;
+  SourceLocation Loc = D->getFieldLoc();
+
+  // The loc can be invalid with a "null" designator (i.e. an anonymous
+  // union/struct). Do our best to approximate the location.
+  if (Loc.isInvalid())
+Loc = IList->getBeginLoc();
+
+  SemaRef.Diag(Loc, diag::err_field_designator_unknown)
+<< FieldName << CurrentObjectType << DIE->getSourceRange();
   ++Index;
   return true;
 }

diff  --git a/clang/test/SemaCXX/cxx2b-designated-initializers.cpp 
b/clang/test/SemaCXX/cxx2b-designated-initializers.cpp
new file mode 100644
index 0..3cddb5d6410ec
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+namespace PR61118 {
+
+union S {
+  struct {
+int a;
+  };
+};
+
+void f(int x, auto) {
+  const S result { // expected-error {{field designator (null) does not refer 
to any field in type 'const S'}}
+.a = x
+  };
+}
+
+void g(void) {
+  f(0, 0); // expected-note {{in instantiation of function template 
specialization 'PR61118::f' requested here}}
+}
+
+} // end namespace PR61118



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


[PATCH] D147673: [Clang] Improve designated inits diagnostic location

2023-04-07 Thread Bill Wendling 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 rG2cbf5127d585: [Clang] Improve designated inits diagnostic 
location (authored by void).

Changed prior to commit:
  https://reviews.llvm.org/D147673?vs=511529&id=511749#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147673

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2b-designated-initializers.cpp


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+namespace PR61118 {
+
+union S {
+  struct {
+int a;
+  };
+};
+
+void f(int x, auto) {
+  const S result { // expected-error {{field designator (null) does not refer 
to any field in type 'const S'}}
+.a = x
+  };
+}
+
+void g(void) {
+  f(0, 0); // expected-note {{in instantiation of function template 
specialization 'PR61118::f' requested here}}
+}
+
+} // end namespace PR61118
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2641,8 +2641,15 @@
   hadError = true;
 } else {
   // Typo correction didn't find anything.
-  SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown)
-<< FieldName << CurrentObjectType;
+  SourceLocation Loc = D->getFieldLoc();
+
+  // The loc can be invalid with a "null" designator (i.e. an anonymous
+  // union/struct). Do our best to approximate the location.
+  if (Loc.isInvalid())
+Loc = IList->getBeginLoc();
+
+  SemaRef.Diag(Loc, diag::err_field_designator_unknown)
+<< FieldName << CurrentObjectType << DIE->getSourceRange();
   ++Index;
   return true;
 }


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s
+
+namespace PR61118 {
+
+union S {
+  struct {
+int a;
+  };
+};
+
+void f(int x, auto) {
+  const S result { // expected-error {{field designator (null) does not refer to any field in type 'const S'}}
+.a = x
+  };
+}
+
+void g(void) {
+  f(0, 0); // expected-note {{in instantiation of function template specialization 'PR61118::f' requested here}}
+}
+
+} // end namespace PR61118
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -2641,8 +2641,15 @@
   hadError = true;
 } else {
   // Typo correction didn't find anything.
-  SemaRef.Diag(D->getFieldLoc(), diag::err_field_designator_unknown)
-<< FieldName << CurrentObjectType;
+  SourceLocation Loc = D->getFieldLoc();
+
+  // The loc can be invalid with a "null" designator (i.e. an anonymous
+  // union/struct). Do our best to approximate the location.
+  if (Loc.isInvalid())
+Loc = IList->getBeginLoc();
+
+  SemaRef.Diag(Loc, diag::err_field_designator_unknown)
+<< FieldName << CurrentObjectType << DIE->getSourceRange();
   ++Index;
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147714: [Attr] Introduce [[clang::nonportable_musttail]] as less strict version of [[clang::musttail]]

2023-04-07 Thread Josh Haberman via Phabricator via cfe-commits
haberman added a comment.

`[[nonportable_musttail]]` makes sense to me as a semantic. It indicates that 
the algorithm requires tail calls, but the author is willing to accept that the 
algorithm may be non-portable.

"Non-portable" here can mean architecture-specific, but it can also mean 
"sensitive to compiler flags." For example, I think there are architectures 
where tail calls can be optimized for statically-linked code but not across a 
shared library boundary.

Since the circumstances for when tail calls are supported can be complicated 
and subtle, architecture-specific attributes don't make as much sense to me.


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

https://reviews.llvm.org/D147714

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


[clang] 13d44a8 - Revert "[Clang][Sema] Fix comparison of constraint expressions"

2023-04-07 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-04-07T18:41:57Z
New Revision: 13d44a8f5647819efd3ef57af384a3666f99d066

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

LOG: Revert "[Clang][Sema] Fix comparison of constraint expressions"

This temporarily reverts commit
60bee9ff544541e83ffbd4be31923d0e8b644690.
The diff will be recommitted once the newly discovered
regressions are fixed.

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/concepts-out-of-line-def.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 4e7033c9d588..2882b10613fd 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -260,9 +260,6 @@ calculateConstraintSatisfaction(Sema &S, const Expr 
*ConstraintExpr,
 return SubstitutedAtomicExpr;
   }
 
-  if (SubstitutedAtomicExpr.get()->isValueDependent())
-return SubstitutedAtomicExpr;
-
   EnterExpressionEvaluationContext ConstantEvaluated(
   S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
   SmallVector EvaluationDiags;
@@ -755,43 +752,27 @@ namespace {
   };
 } // namespace
 
-static const Expr *SubstituteConstraintExpression(Sema &S, const NamedDecl *ND,
-  const Expr *ConstrExpr) {
-  MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
-  ND, /*Final=*/false, /*Innermost=*/nullptr,
-  /*RelativeToPrimary=*/true,
-  /*Pattern=*/nullptr,
-  /*ForConstraintInstantiation=*/true, /*SkipForSpecialization*/ false);
-  if (MLTAL.getNumSubstitutedLevels() == 0)
-return ConstrExpr;
-  Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/false);
-  std::optional ThisScope;
-  if (auto *RD = dyn_cast(ND->getDeclContext()))
-ThisScope.emplace(S, const_cast(RD), Qualifiers());
-  ExprResult SubstConstr =
-  S.SubstConstraintExpr(const_cast(ConstrExpr), MLTAL);
-  if (SFINAE.hasErrorOccurred() || !SubstConstr.isUsable())
-return nullptr;
-  return SubstConstr.get();
-}
-
 bool Sema::AreConstraintExpressionsEqual(const NamedDecl *Old,
  const Expr *OldConstr,
  const NamedDecl *New,
  const Expr *NewConstr) {
-  if (OldConstr == NewConstr)
-return true;
   if (Old && New && Old != New) {
-if (const Expr *SubstConstr =
-SubstituteConstraintExpression(*this, Old, OldConstr))
-  OldConstr = SubstConstr;
-else
-  return false;
-if (const Expr *SubstConstr =
-SubstituteConstraintExpression(*this, New, NewConstr))
-  NewConstr = SubstConstr;
-else
-  return false;
+unsigned Depth1 = CalculateTemplateDepthForConstraints(
+*this, Old);
+unsigned Depth2 = CalculateTemplateDepthForConstraints(
+*this, New);
+
+// Adjust the 'shallowest' verison of this to increase the depth to match
+// the 'other'.
+if (Depth2 > Depth1) {
+  OldConstr = AdjustConstraintDepth(*this, Depth2 - Depth1)
+  .TransformExpr(const_cast(OldConstr))
+  .get();
+} else if (Depth1 > Depth2) {
+  NewConstr = AdjustConstraintDepth(*this, Depth1 - Depth2)
+  .TransformExpr(const_cast(NewConstr))
+  .get();
+}
   }
 
   llvm::FoldingSetNodeID ID1, ID2;

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index aa40bff4c575..ab4300518ecf 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1294,7 +1294,7 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl 
*Old,
 // We check the return type and template parameter lists for function
 // templates first; the remaining checks follow.
 bool SameTemplateParameterList = TemplateParameterListsAreEqual(
-NewTemplate, NewTemplate->getTemplateParameters(), OldTemplate,
+NewTemplate->getTemplateParameters(),
 OldTemplate->getTemplateParameters(), false, TPL_TemplateMatch);
 bool SameReturnType = Context.hasSameType(Old->getDeclaredReturnType(),
   New->getDeclaredReturnType());

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index bdcee77ce67c..526f19b8aedc 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -208,10 +208,6 @@ Response HandleFunction(const FunctionDecl *Function,
   return Response::UseNextDecl(Function);

[PATCH] D147580: [Clang][NFC] Refactor "Designators" to be more similar

2023-04-07 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D147580#4250232 , @shafik wrote:

> I guess I should have waited till I saw: https://reviews.llvm.org/D147673

Yeah, sorry about that. I realized that I still needed to add the testcase 
before continuing. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147580

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


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15660
   case BO_Assign:
+// Skip diagnose on compound assignment.
+DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146897

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


[PATCH] D147802: [clangd] Handle destructors in DefineOutline tweak

2023-04-07 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: kadircet, sammccall.
Herald added a subscriber: arphaman.
Herald added a project: All.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fix destructors being incorrectly defined in the DefineOutline tweak
Currently it doesn't prepend the class name to the destructor

  class A { ~A() {} };
  // Destructor definition after outline
  ~A() {}
  // After this fix
  A::~A() {}


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147802

Files:
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -319,6 +319,11 @@
 };)cpp",
   "  Foo::Foo(int) {}\n",
   },
+  { 
+"class A { ~A^(){} };",
+"class A { ~A(); };",
+"A::~A(){} ",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
@@ -532,6 +537,18 @@
   // account. This can be spelled as b::foo instead.
   "using namespace a;void a::b::foo() {} ",
   },
+  { 
+"namespace a { class A { ~A^(){} }; }",
+"",
+"namespace a { class A { ~A(); }; }",
+"a::A::~A(){} ",
+  },
+  { 
+"namespace a { class A { ~A^(){} }; }",
+"namespace a{}",
+"namespace a { class A { ~A(); }; }",
+"namespace a{A::~A(){} }",
+  },
   };
   llvm::StringMap EditedFiles;
   for (auto &Case : Cases) {
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -183,6 +183,15 @@
   },
   Resolver);
 
+  if (const auto *Destructor = llvm::dyn_cast(FD)) {
+if (auto Err = DeclarationCleanups.add(tooling::Replacement(
+SM, Destructor->getLocation(), 0,
+getQualification(AST, *TargetContext,
+ SM.getLocForStartOfFile(SM.getMainFileID()),
+ Destructor
+  Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
+  }
+
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {


Index: clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
@@ -319,6 +319,11 @@
 };)cpp",
   "  Foo::Foo(int) {}\n",
   },
+  { 
+"class A { ~A^(){} };",
+"class A { ~A(); };",
+"A::~A(){} ",
+  },
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Test);
@@ -532,6 +537,18 @@
   // account. This can be spelled as b::foo instead.
   "using namespace a;void a::b::foo() {} ",
   },
+  { 
+"namespace a { class A { ~A^(){} }; }",
+"",
+"namespace a { class A { ~A(); }; }",
+"a::A::~A(){} ",
+  },
+  { 
+"namespace a { class A { ~A^(){} }; }",
+"namespace a{}",
+"namespace a { class A { ~A(); }; }",
+"namespace a{A::~A(){} }",
+  },
   };
   llvm::StringMap EditedFiles;
   for (auto &Case : Cases) {
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -183,6 +183,15 @@
   },
   Resolver);
 
+  if (const auto *Destructor = llvm::dyn_cast(FD)) {
+if (auto Err = DeclarationCleanups.add(tooling::Replacement(
+SM, Destructor->getLocation(), 0,
+getQualification(AST, *TargetContext,
+ SM.getLocForStartOfFile(SM.getMainFileID()),
+ Destructor
+  Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
+  }
+
   // Get rid of default arguments, since they should not be specified in
   // out-of-line definition.
   for (const auto *PVD : FD->parameters()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147722: [Concepts] Fix Function Template Concepts comparisons

2023-04-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 511753.
erichkeane added a comment.

Made changes as requested by Richard.  "SkipForInstantiation" needed to be 
added when we added levels, but I think this is something that probably needs 
to be looked at and removed in the future.

I also see the change that this means to fix is reverted, so 
@alexander-shaposhnikov : feel free to take this and integrated it into your 
patch if you'd like.


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

https://reviews.llvm.org/D147722

Files:
  clang/include/clang/Sema/Template.h
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/concepts.cpp

Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -825,3 +825,53 @@
   template U> friend constexpr auto decltype(L)::operator()() const;
 };
 } // namespace TemplateInsideNonTemplateClass
+
+namespace GH61959 {
+template 
+concept C = (sizeof(T0) >= 4);
+
+template
+struct Orig { };
+
+template
+struct Orig {
+  template requires C
+  void f() { }
+
+  template requires true
+  void f() { }
+};
+
+template  struct Mod {};
+
+template 
+struct Mod {
+  template  requires C
+  constexpr static int f() { return 1; }
+
+  template  requires C
+  constexpr static int f() { return 2; }
+};
+
+static_assert(Mod::f() == 1);
+static_assert(Mod::f() == 2);
+
+template
+struct Outer {
+  template
+  struct Inner {};
+
+  template
+  struct Inner {
+template
+void foo()  requires C && C && C{}
+template
+void foo()  requires true{}
+  };
+};
+
+void bar() {
+  Outer::Inner I;
+  I.foo();
+}
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -131,6 +131,38 @@
   return Response::Done();
 }
 
+Response HandlePartialClassTemplateSpec(
+const ClassTemplatePartialSpecializationDecl *PartialClassTemplSpec,
+MultiLevelTemplateArgumentList &Result, bool SkipForSpecialization) {
+  // We don't want the arguments from the Partial Specialization, since
+  // anything instantiating here cannot access the arguments from the
+  // specialized template anyway, so any substitution we would do with these
+  // partially specialized arguments would 'wrong' and confuse constraint
+  // instantiation. We only do this in the case of a constraint check, since
+  // code elsewhere actually uses these and replaces them later with what
+  // they mean.
+  // If we know this is the 'top level', we can replace this with an
+  // OuterRetainedLevel, else we have to generate a set of identity arguments.
+
+  // If this is the top-level template entity, we can just add a retained level
+  // and be done.
+  if (!PartialClassTemplSpec->getTemplateDepth()) {
+if (!SkipForSpecialization)
+  Result.addOuterRetainedLevel();
+return Response::Done();
+  }
+
+  // Else, we can replace this with an 'empty' level, and the checking will just
+  // alter the 'depth', since this we don't have the 'Index' for this level.
+  if (!SkipForSpecialization)
+Result.addOuterTemplateArguments(
+const_cast(
+PartialClassTemplSpec),
+{}, /*Final=*/false);
+
+  return Response::UseNextDecl(PartialClassTemplSpec);
+}
+
 // Add template arguments from a class template instantiation.
 Response
 HandleClassTemplateSpec(const ClassTemplateSpecializationDecl *ClassTemplSpec,
@@ -310,6 +342,10 @@
 if (const auto *VarTemplSpec =
 dyn_cast(CurDecl)) {
   R = HandleVarTemplateSpec(VarTemplSpec, Result, SkipForSpecialization);
+} else if (const auto *PartialClassTemplSpec =
+   dyn_cast(CurDecl)) {
+  R = HandlePartialClassTemplateSpec(PartialClassTemplSpec, Result,
+ SkipForSpecialization);
 } else if (const auto *ClassTemplSpec =
dyn_cast(CurDecl)) {
   R = HandleClassTemplateSpec(ClassTemplSpec, Result,
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -2854,7 +2854,7 @@
 template <>
 bool DeducedArgsNeedReplacement(
 ClassTemplatePartialSpecializationDecl *Spec) {
-  return !Spec->isClassScopeExplicitSpecialization();
+  return true;
 }
 
 template 
@@ -2881,7 +2881,7 @@
   // not class-scope explicit specialization, so replace with Deduced Args
   // instead of adding to inner-most.
   if (NeedsReplacement)
-MLTAL.replaceInnermostTemplateArguments(CanonicalDeducedArgs);
+MLTAL.replaceInnermostTemplateArguments(Template, CanonicalDeducedArgs);
 
   if (S.CheckConstraintSatisfaction(Template, AssociatedConstraints, MLTAL,
   

  1   2   >