[PATCH] D136162: [analyzer] Fix assertion failure with conflicting prototype calls

2022-10-21 Thread Balázs Benics via Phabricator via cfe-commits
steakhal marked an inline comment as done.
steakhal added a comment.

In D136162#3873392 , @NoQ wrote:

> Ok so you're saying that it's not just a wrong Decl but there's like an 
> entire cast-expression missing in the AST? This fix is probably good enough 
> for us but it begs a question, what does CodeGen do in such cases? Does it 
> also need to emit a cast instruction into LLVM IR that doesn't correspond to 
> anything in the AST? Or is this entirely about our weird pointer cast 
> handling, that needs to act even when the numeric value of the pointer 
> doesn't change?

Good question. The IR is identical for the two cases - except for metadata 
markers e.g. for deb info, etc.
So, it might be simply that the "C" language just doesn't care if there is a 
bitcast or not in the AST, because the hardware register is just an untyped 
register; hence this `ImplicitCastExpr` (bitcast) is getting lowered as a noop 
at the IR level.

Unfortunately, it's beyond my expertise. Do you think we should invite someone, 
like Shafik or Aaron?




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:490
+// edge-cases.
+ArgVal = castArgToParamTypeIfNeeded(Call, Idx, ArgVal, SVB);
+

tomasz-kaminski-sonarsource wrote:
> Previously we didng make bindings if `ArgVal` was unknown, and we may want to 
> preserve this invariant.
IDK what are the implications of not having a binding or having a binding to 
unknown.
I'll change this anyway. Thanks for noticing.



Comment at: clang/test/Analysis/region-store.c:66
+  // expected-warning@+1 {{passing arguments to 'b' without a prototype is 
deprecated in all versions of C and is not supported in C2x}}
+  b(&buffer);
+}

NoQ wrote:
> steakhal wrote:
> > tomasz-kaminski-sonarsource wrote:
> > > tomasz-kaminski-sonarsource wrote:
> > > > I would like to see an example where the called function is implicitly 
> > > > defined.
> > > After rethinking it, I have not idea how to construct that example.
> > I could not construct such an example.
> > It seems like clang errors out for cases when an implicit declaration of a 
> > call mismatches with the definition of that function.
> > https://godbolt.org/z/rM9ajeTf7
> Yeah, if you scroll really far to the right, you'll see that the first error 
> is actually a warning auto-promoted to an error. So you can pass 
> `-Wno-implicit-function-declaration` and it'll disappear. Not sure what to do 
> with the other error though, it really does notice that the implicit 
> definition conflicts with the later explicit definition. So, dunno.
Yup, I should have been more clear on this. See the test, I'm also passing the 
`-Wno-implicit-function-declaration` :)
Maybe Shafik or Aaron knows some weird stuff about how to make it 'compile'. 
WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136162

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


[PATCH] D135972: [clang-format] Don't crash on malformed preprocessor conditions

2022-10-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1216
+  // Don't crash when there is an #else without an #if.
+  if (PPBranchLevel <= -1) {
+conditionalCompilationStart(/*Unreachable=*/true);

Nit.



Comment at: clang/unittests/Format/FormatTest.cpp:5196-5206
+  std::function FormatBadBranches =
+  [&](std::string Prefix, unsigned Lines) {
+const std::string Directives[] = {"", "#if X\n", "#else X\n",
+  "#endif\n"};
+if (Lines == 0)
+  verifyNoCrash(Prefix);
+else

Can we have individual `verifyFormat` or `verifyNoCrash`tests for easy reading 
and to avoid the overhead? Some examples:
```
#else
a;
#if X
b;
#endif
#endif

#elif X
a;
#endif
#ifdef X
b;
#endif
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135972

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


[PATCH] D136423: [clang][Interp] Implement inc/dec postfix and prefix operators

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This only works on integrals for now.

Add four new opcodes, `Inc`, `IncPop`, `Dec` and `DecPop`. The `*Pop` variants 
don't leave anything on the stack and exist because the common case is that the 
result is unused.

There are still a few corner cases left like floating values, pointers, and 
over/underflow handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136423

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/arrays.cpp
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -361,3 +361,52 @@
   constexpr double db = true;
   static_assert(db == 1.0, "");
 };
+
+#if __cplusplus >= 202002L
+namespace IncDec {
+  constexpr int zero() {
+int a = 0;
+a++;
+++a;
+a--;
+--a;
+return a;
+  }
+  static_assert(zero() == 0, "");
+
+  constexpr int three() {
+int a = 0;
+return ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}} \
+  // ref-warning {{multiple unsequenced modifications to 'a'}} \
+
+  }
+  static_assert(three() == 3, "");
+
+  constexpr bool incBool() {
+bool b = false;
+return ++b; // expected-error {{ISO C++17 does not allow incrementing expression of type bool}} \
+// ref-error {{ISO C++17 does not allow incrementing expression of type bool}}
+  }
+  static_assert(incBool(), "");
+
+  constexpr int uninit() {
+int a;
+++a; // ref-note {{increment of uninitialized}} \
+ // FIXME: Should also be rejected by new interpreter
+return 1;
+  }
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'uninit()'}}
+
+  constexpr int OverUnderFlow() { // ref-error {{never produces a constant expression}}
+int a = INT_MAX;
+++a; // ref-note {{is outside the range}}
+// FIXME: Overflow
+
+int b = INT_MIN;
+--b; // FIXME: Underflow
+
+return -1;
+  }
+};
+#endif
Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -180,3 +180,18 @@
  constexpr int x = arr.a[0];
   }
 };
+
+namespace IncDec {
+  // FIXME: Pointer arithmethic needs to be supported in inc/dec
+  //   unary operators
+#if 0
+  constexpr int getNextElem(const int *A, int I) {
+const int *B = (A + I);
+++B;
+return *B;
+  }
+  constexpr int E[] = {1,2,3,4};
+
+  static_assert(getNextElem(E, 1) == 3);
+#endfi
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -452,6 +452,11 @@
   let HasGroup = 1;
 }
 
+def Inc: IntegerOpcode;
+def IncPop : IntegerOpcode;
+def Dec: IntegerOpcode;
+def DecPop: IntegerOpcode;
+
 // [Real] -> [Real]
 def Neg: Opcode {
   let Types = [NonPtrTypeClass];
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -328,6 +328,70 @@
   return true;
 }
 
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value increased by one back to the pointer
+/// 4) Pushes the original (pre-inc) value on the stack.
+template ::T>
+bool Inc(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::increment(Value, &Result))
+return false;
+  Ptr.deref() = Result;
+  S.Stk.push(Value);
+  return true;
+}
+
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value increased by one back to the pointer
+template ::T>
+bool IncPop(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::increment(Value, &Result))
+return false;
+  Ptr.deref() = Result;
+  return true;
+}
+
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value decreased by one back to the pointer
+/// 4) Pushes the original (pre-dec) value on the stack.
+template ::T>
+bool Dec(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::decrement(Value, &Result))
+return false;
+  

[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Jan Kasper via Phabricator via cfe-commits
DerKasper created this revision.
DerKasper added a reviewer: njames93.
DerKasper added a project: clang-tools-extra.
Herald added a subscriber: carlosgalvezp.
Herald added a project: All.
DerKasper requested review of this revision.
Herald added a subscriber: cfe-commits.

Update links to googletest documentation
No automatic tests, but local manual test: i click it, it opens the googletest 
documentation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136424

Files:
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
@@ -30,5 +30,5 @@
 
 This check does not propose any fixes.
 
-.. _Underscores are not allowed: 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
-.. _disable individual tests: 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _Underscores are not allowed: 
https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _disable individual tests: 
https://google.github.io/googletest/advanced.html#temporarily-disabling-tests
Index: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
===
--- clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.html


Index: clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
+++ clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
@@ -30,5 +30,5 @@
 
 This check does not propose any fixes.
 
-.. _Underscores are not allowed: https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
-.. _disable individual tests: https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _Underscores are not allowed: https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _disable individual tests: https://google.github.io/googletest/advanced.html#temporarily-disabling-tests
Index: clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
===
--- clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.html
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135013: [clang][Interp] Array initialization via ImplicitValueInitExpr

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:726
+  } else if (const auto *IVIE = dyn_cast(Initializer)) {
+const ArrayType *ArrayType = IVIE->getType()->getAsArrayTypeUnsafe();
+assert(ArrayType);

aaron.ballman wrote:
> (Sorry, I hadn't noticed you were using a type name as a variable name 
> before! That sometimes confuses IDEs, so suggesting a different name.)
I can't say I saw that when making the change, but now that I see it, yes, that 
might've been the reason I used `auto` here. Anyway, I changed that, thanks.


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

https://reviews.llvm.org/D135013

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


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru accepted this revision.
sylvestre.ledru added a comment.
This revision is now accepted and ready to land.

Thanks for carrying about the doc!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[clang] 9c422ab - [clang-format] Add option for aligning requires clause body

2022-10-21 Thread Emilia Dreamer via cfe-commits

Author: Danil Sidoruk
Date: 2022-10-21T10:42:45+03:00
New Revision: 9c422ab7ce82ec13155629f1e5e4e11d608fe1de

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

LOG: [clang-format] Add option for aligning requires clause body

Adds an option whether requires clause body should be aligned with
the `requires` keyword.
This option is now the default, both without configuration and in LLVM
style.

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

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

Co-authored-by: Emilia Dreamer 

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index cdbc23ae43eb8..b52cf49ef5636 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3861,6 +3861,35 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+**RequiresExpressionIndentation** (``RequiresExpressionIndentationKind``) 
:versionbadge:`clang-format 16`
+  The indentation used for requires expression bodies.
+
+  Possible values:
+
+  * ``REI_OuterScope`` (in configuration: ``OuterScope``)
+Align requires expression body relative to the indentation level of the
+outer scope the requires expression resides in.
+This is the default.
+
+.. code-block:: c++
+
+   template 
+   concept C = requires(T t) {
+ ...
+   }
+
+  * ``REI_Keyword`` (in configuration: ``Keyword``)
+Align requires expression body relative to the `requires` keyword.
+
+.. code-block:: c++
+
+   template 
+   concept C = requires(T t) {
+ ...
+   }
+
+
+
 **SeparateDefinitionBlocks** (``SeparateDefinitionStyle``) 
:versionbadge:`clang-format 14`
   Specifies the use of empty lines to separate definition blocks, including
   classes, structs, enums, and functions.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8198d62bc8d5f..e87a4eea552df 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -629,7 +629,10 @@ AST Matchers
 
 clang-format
 
-- Add `RemoveSemicolon` option for removing `;` after a non-empty function 
definition.
+- Add ``RemoveSemicolon`` option for removing ``;`` after a non-empty function 
definition.
+- Add ``RequiresExpressionIndentation`` option for configuring the alignment 
of requires-expressions.
+  The default value of this option is ``OuterScope``, which 
diff ers in behavior from clang-format 15.
+  To match the default behavior of clang-format 15, use the ``Keyword`` value.
 
 clang-extdef-mapping
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 7c1721064727c..3205b502ac195 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3153,6 +3153,32 @@ struct FormatStyle {
   /// \version 15
   RequiresClausePositionStyle RequiresClausePosition;
 
+  /// Indentation logic for requires expression bodies.
+  enum RequiresExpressionIndentationKind : int8_t {
+/// Align requires expression body relative to the indentation level of the
+/// outer scope the requires expression resides in.
+/// This is the default.
+/// \code
+///template 
+///concept C = requires(T t) {
+///  ...
+///}
+/// \endcode
+REI_OuterScope,
+/// Align requires expression body relative to the `requires` keyword.
+/// \code
+///template 
+///concept C = requires(T t) {
+///  ...
+///}
+/// \endcode
+REI_Keyword,
+  };
+
+  /// The indentation used for requires expression bodies.
+  /// \version 16
+  RequiresExpressionIndentationKind RequiresExpressionIndentation;
+
   /// \brief The style if definition blocks should be separated.
   enum SeparateDefinitionStyle : int8_t {
 /// Leave definition blocks as they are.
@@ -3988,6 +4014,7 @@ struct FormatStyle {
RemoveBracesLLVM == R.RemoveBracesLLVM &&
RemoveSemicolon == R.RemoveSemicolon &&
RequiresClausePosition == R.RequiresClausePosition &&
+   RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
SeparateDefinitionBlocks == R.SeparateDefinitionBlocks &&
ShortNamespaceLines == R.ShortNamespaceLines &&
SortIncludes == R.SortIncludes &&

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 00a9

[PATCH] D129443: [clang-format] Add option for aligning requires clause body

2022-10-21 Thread Emilia Dreamer via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c422ab7ce82: [clang-format] Add option for aligning 
requires clause body (authored by eoanermine, committed by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129443

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -24334,6 +24334,12 @@
 TEST_F(FormatTest, Concepts) {
   EXPECT_EQ(getLLVMStyle().BreakBeforeConceptDeclarations,
 FormatStyle::BBCDS_Always);
+
+  // The default in LLVM style is REI_OuterScope, but these tests were written
+  // when the default was REI_Keyword.
+  FormatStyle Style = getLLVMStyle();
+  Style.RequiresExpressionIndentation = FormatStyle::REI_Keyword;
+
   verifyFormat("template \n"
"concept True = true;");
 
@@ -24350,13 +24356,15 @@
"concept DelayedCheck = true && requires(T t) {\n"
" t.bar();\n"
" t.baz();\n"
-   "   } && sizeof(T) <= 8;");
+   "   } && sizeof(T) <= 8;",
+   Style);
 
   verifyFormat("template \n"
"concept DelayedCheck = true && requires(T t) { // Comment\n"
" t.bar();\n"
" t.baz();\n"
-   "   } && sizeof(T) <= 8;");
+   "   } && sizeof(T) <= 8;",
+   Style);
 
   verifyFormat("template \n"
"concept DelayedCheck = false || requires(T t) { t.bar(); } && "
@@ -24458,26 +24466,30 @@
"concept Hashable = requires(T a) {\n"
" { std::hash{}(a) } -> "
"std::convertible_to;\n"
-   "   };");
+   "   };",
+   Style);
 
   verifyFormat(
   "template \n"
   "concept EqualityComparable = requires(T a, T b) {\n"
   "   { a == b } -> std::same_as;\n"
-  " };");
+  " };",
+  Style);
 
   verifyFormat(
   "template \n"
   "concept EqualityComparable = requires(T a, T b) {\n"
   "   { a == b } -> std::same_as;\n"
   "   { a != b } -> std::same_as;\n"
-  " };");
+  " };",
+  Style);
 
   verifyFormat("template \n"
"concept WeakEqualityComparable = requires(T a, T b) {\n"
"   { a == b };\n"
"   { a != b };\n"
-   " };");
+   " };",
+   Style);
 
   verifyFormat("template \n"
"concept HasSizeT = requires { typename T::size_t; };");
@@ -24493,7 +24505,8 @@
"  requires Same;\n"
"  { delete new T; };\n"
"  { delete new T[n]; };\n"
-   "};");
+   "};",
+   Style);
 
   verifyFormat("template \n"
"concept Semiregular =\n"
@@ -24506,7 +24519,8 @@
"  { delete new T[n]; };\n"
"  { new T } -> std::same_as;\n"
"} && DefaultConstructible && CopyConstructible && "
-   "CopyAssignable;");
+   "CopyAssignable;",
+   Style);
 
   verifyFormat(
   "template \n"
@@ -24520,14 +24534,16 @@
   " { delete new T; };\n"
   " { delete new T[n]; };\n"
   "   } && CopyConstructible && "
-  "CopyAssignable;");
+  "CopyAssignable;",
+  Style);
 
   verifyFormat("template \n"
"concept Two = requires(T t) {\n"
"{ t.foo() } -> std::same_as;\n"
"  } && requires(T &&t) {\n"
" { t.foo() } -> std::same_as;\n"
-   "   };");
+   "   };",
+   Style);
 
   verifyFormat(
  

[PATCH] D136413: [Clang][LoongArch] Define more LoongArch specific built-in macros

2022-10-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

> I've formatted the patch summary for you. Please familiarize yourself with 
> Markdown syntax so next time your rendering would look better.

Thanks. Got it.

> For minimum churn and hassle, I'm afraid we have to add it for now. I didn't 
> realize [[ 
> https://github.com/loongson/LoongArch-Documentation/pull/28#discussion_r917367794
>  | it's the equivalent of `__mips64` ]] until too much software has been 
> ported with it...

OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136413

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


[PATCH] D136413: [Clang][LoongArch] Define more LoongArch specific built-in macros

2022-10-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 469497.
SixWeining added a comment.

Define `__loongarch64` which is equal to `__loongarch_grlen == 64`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136413

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/test/Preprocessor/init-loongarch.c

Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -322,6 +322,7 @@
 // LA32-LINUX: #define __gnu_linux__ 1
 // LA32-LINUX: #define __linux 1
 // LA32-LINUX: #define __linux__ 1
+// LA32-NOT: #define __loongarch64 1
 // LA32: #define __loongarch__ 1
 // LA32-LINUX: #define __unix 1
 // LA32-LINUX: #define __unix__ 1
@@ -634,8 +635,149 @@
 // LA64-LINUX: #define __gnu_linux__ 1
 // LA64-LINUX: #define __linux 1
 // LA64-LINUX: #define __linux__ 1
+// LA64: #define __loongarch64 1
 // LA64: #define __loongarch__ 1
 // LA64-LINUX: #define __unix 1
 // LA64-LINUX: #define __unix__ 1
 // LA64-LINUX: #define linux 1
 // LA64-LINUX: #define unix 1
+
+
+/// Check various macros prefixed with "__loongarch_" in different cases.
+/// "__loongarch__"" is not listed here as it has been checked above.
+
+// RUN: %clang --target=loongarch32 -mfpu=64 -mabi=ilp32d -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU64-ILP32D %s
+// RUN: %clang --target=loongarch32 -mdouble-float -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU64-ILP32D %s
+// LA32-FPU64-ILP32D: __loongarch_double_float 1
+// LA32-FPU64-ILP32D-NEXT: __loongarch_frlen 64
+// LA32-FPU64-ILP32D-NEXT: __loongarch_grlen 32
+// LA32-FPU64-ILP32D-NEXT: __loongarch_hard_float 1
+// LA32-FPU64-ILP32D-NOT: __loongarch_lp64
+// LA32-FPU64-ILP32D-NOT: __loongarch_single_float
+// LA32-FPU64-ILP32D-NOT: __loongarch_soft_float
+
+// RUN: %clang --target=loongarch32 -mfpu=64 -mabi=ilp32f -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU64-ILP32F %s
+// LA32-FPU64-ILP32F-NOT: __loongarch_double_float
+// LA32-FPU64-ILP32F: __loongarch_frlen 64
+// LA32-FPU64-ILP32F-NEXT: __loongarch_grlen 32
+// LA32-FPU64-ILP32F-NEXT: __loongarch_hard_float 1
+// LA32-FPU64-ILP32F-NOT: __loongarch_lp64
+// LA32-FPU64-ILP32F-NEXT: __loongarch_single_float 1
+// LA32-FPU64-ILP32F-NOT: __loongarch_soft_float
+
+// RUN: %clang --target=loongarch32 -mfpu=64 -mabi=ilp32s -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU64-ILP32S %s
+// LA32-FPU64-ILP32S-NOT: __loongarch_double_float
+// LA32-FPU64-ILP32S: __loongarch_frlen 64
+// LA32-FPU64-ILP32S-NEXT: __loongarch_grlen 32
+// LA32-FPU64-ILP32S-NOT: __loongarch_hard_float
+// LA32-FPU64-ILP32S-NOT: __loongarch_lp64
+// LA32-FPU64-ILP32S-NOT: __loongarch_single_float
+// LA32-FPU64-ILP32S-NEXT: __loongarch_soft_float 1
+
+// RUN: %clang --target=loongarch32 -mfpu=32 -mabi=ilp32f -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU32-ILP32F %s
+// RUN: %clang --target=loongarch32 -msingle-float -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU32-ILP32F %s
+// LA32-FPU32-ILP32F-NOT: __loongarch_double_float
+// LA32-FPU32-ILP32F: __loongarch_frlen 32
+// LA32-FPU32-ILP32F-NEXT: __loongarch_grlen 32
+// LA32-FPU32-ILP32F-NEXT: __loongarch_hard_float 1
+// LA32-FPU32-ILP32F-NOT: __loongarch_lp64
+// LA32-FPU32-ILP32F-NEXT: __loongarch_single_float 1
+// LA32-FPU32-ILP32F-NOT: __loongarch_soft_float
+
+// RUN: %clang --target=loongarch32 -mfpu=32 -mabi=ilp32s -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU32-ILP32S %s
+// LA32-FPU32-ILP32S-NOT: __loongarch_double_float
+// LA32-FPU32-ILP32S: __loongarch_frlen 32
+// LA32-FPU32-ILP32S-NEXT: __loongarch_grlen 32
+// LA32-FPU32-ILP32S-NOT: __loongarch_hard_float
+// LA32-FPU32-ILP32S-NOT: __loongarch_lp64
+// LA32-FPU32-ILP32S-NOT: __loongarch_single_float
+// LA32-FPU32-ILP32S-NEXT: __loongarch_soft_float 1
+
+// RUN: %clang --target=loongarch32 -mfpu=0 -mabi=ilp32s -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU0-ILP32S %s
+// RUN: %clang --target=loongarch32 -mfpu=none -mabi=ilp32s -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU0-ILP32S %s
+// RUN: %clang --target=loongarch32 -msoft-float -x c -E -dM %s -o - \
+// RUN:   | grep __loongarch_ | FileCheck --check-prefix=LA32-FPU0-ILP32S %s
+// LA32-FPU0-ILP32S-NOT: __loongarch_double_float
+// LA32-FPU0-ILP32S: __loongarch_frlen 0
+// LA32-FPU0-ILP32S-NEXT: __loongarch_grlen 32
+// LA32-FPU0-ILP32S-NOT: __loongarch_hard_float
+// LA32-FPU0-ILP32S-NOT: __loongarch_lp64
+// LA32-FPU0-ILP32S-NOT: __loongarch_single_float
+// LA32-FPU0-ILP32S-NEXT

[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-21 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:5643-5653
+case Intrinsic::x86_cmpccxadd32:
+case Intrinsic::x86_cmpccxadd64: {
+  Info.opc = ISD::INTRINSIC_W_CHAIN;
+  Info.ptrVal = I.getArgOperand(0);
+  unsigned Size = I.getType()->getScalarSizeInBits();
+  Info.memVT = EVT::getIntegerVT(I.getType()->getContext(), Size);
+  Info.align = Align(Size);

This can be merged with above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-21 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:28251
+  SDLoc DL(Op);
+  SDVTList VTs = DAG.getVTList(MVT::i32, MVT::Other);
+  SDValue Chain = Op.getOperand(0);

Unused?



Comment at: llvm/lib/Target/X86/X86InstrInfo.td:3024
+//
+let Predicates = [HasCMPCCXADD, In64BitMode], Defs = [EFLAGS],
+Constraints = "$dstsrc2 = $dst" in {

Should we set isCodeGenOnly =1 here?



Comment at: llvm/utils/TableGen/X86RecognizableInstr.h:109
 PrefixByte= 10,
+MRMDestMem4VOp3CC = 18,
 MRMr0  = 21,

Should we use 20 here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-21 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

It starting to look great.
Should we add an extension warning? Note that I'm not suggesting to support 
that in earlier modes, just an off-by-default warning that says "this is a 
c++20 feature". but we are a bit inconsistent with those.

can you rename `test/SemaCXX/P0960R3.cpp` to something like 
`test/SemaCXX/cxx20-paren-list-init.cpp` (and same for other tests?) it's more 
consistent with other existing tests.




Comment at: clang/include/clang/Sema/Sema.h:6200
 
-
   /// Instantiate or parse a C++ default argument expression as necessary.

Whitespace change



Comment at: clang/lib/Sema/SemaInit.cpp:3528
 delete ICS;
+break;
   }

It seems unrelated. but reasonable.



Comment at: clang/lib/Sema/SemaInit.cpp:5379-5380
+} else {
+  Sequence.SetFailed(
+  InitializationSequence::FK_ParenthesizedListInitFailed);
+}

Shouldn't we do that unconditionally?



Comment at: clang/lib/Sema/SemaInit.cpp:6106
+
+  // We fall back to the "no matching constructor "path iff the
+  // failed candidate set has function other than the three default





Comment at: clang/lib/Sema/SemaInit.cpp:6107
+  // We fall back to the "no matching constructor "path iff the
+  // failed candidate set has function other than the three default
+  // constructors. For example, conversion function.





Comment at: clang/lib/Sema/SemaInit.cpp:6114-6116
+// const ValueDecl *VD = Entity.getDecl();
+// if (const VarDecl *VarD = dyn_cast_or_null(VD);
+// VarD && VarD->hasInit() && !VarD->getInit()->containsErrors())

Is that code meant to be commented?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[clang] d6cb1fd - [clang][Interp][NFC] Remove some unused aliases.

2022-10-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-21T10:49:45+02:00
New Revision: d6cb1fd7b366b7e3fa3cbe8129f11298279e72c4

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

LOG: [clang][Interp][NFC] Remove some unused aliases.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index ffe8e83725436..6cc45bd4d0154 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -41,12 +41,6 @@ template 
 class ByteCodeExprGen : public ConstStmtVisitor, 
bool>,
 public Emitter {
 protected:
-  // Emitters for opcodes of various arities.
-  using NullaryFn = bool (ByteCodeExprGen::*)(const SourceInfo &);
-  using UnaryFn = bool (ByteCodeExprGen::*)(PrimType, const SourceInfo &);
-  using BinaryFn = bool (ByteCodeExprGen::*)(PrimType, PrimType,
- const SourceInfo &);
-
   // Aliases for types defined in the emitter.
   using LabelTy = typename Emitter::LabelTy;
   using AddrTy = typename Emitter::AddrTy;



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


[clang] 09bbc90 - [clang][Interp] Array initialization via ImplicitValueInitExpr

2022-10-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-21T10:49:45+02:00
New Revision: 09bbc903a5b454d39d5ce69cf8bf6d5e1b46e3c4

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

LOG: [clang][Interp] Array initialization via ImplicitValueInitExpr

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/arrays.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index ad3348cee4e2f..872bbf045cef2 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -721,6 +721,27 @@ bool ByteCodeExprGen::visitArrayInitializer(const 
Expr *Initializer) {
   if (!this->emitPopPtr(Initializer))
 return false;
 }
+return true;
+  } else if (const auto *IVIE = dyn_cast(Initializer)) {
+const ArrayType *AT = IVIE->getType()->getAsArrayTypeUnsafe();
+assert(AT);
+const auto *CAT = cast(AT);
+size_t NumElems = CAT->getSize().getZExtValue();
+
+if (Optional ElemT = classify(CAT->getElementType())) {
+  // TODO(perf): For int and bool types, we can probably just skip this
+  //   since we memset our Block*s to 0 and so we have the desired value
+  //   without this.
+  for (size_t I = 0; I != NumElems; ++I) {
+if (!this->emitZero(*ElemT, Initializer))
+  return false;
+if (!this->emitInitElem(*ElemT, I, Initializer))
+  return false;
+  }
+} else {
+  assert(false && "default initializer for non-primitive type");
+}
+
 return true;
   }
 

diff  --git a/clang/test/AST/Interp/arrays.cpp 
b/clang/test/AST/Interp/arrays.cpp
index 318793ff777a0..d41999414f5b6 100644
--- a/clang/test/AST/Interp/arrays.cpp
+++ b/clang/test/AST/Interp/arrays.cpp
@@ -117,3 +117,15 @@ namespace indices {
// expected-error {{must be initialized 
by a constant expression}} \
// expected-note {{cannot refer to 
element -2 of array of 10}}
 };
+
+namespace DefaultInit {
+  template 
+  struct B {
+T a[N];
+  };
+
+  int f() {
+ constexpr B arr = {};
+ constexpr int x = arr.a[0];
+  }
+};



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


[clang] 9cb4e90 - [clang][Interp] Support base class constructors

2022-10-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-10-21T10:49:45+02:00
New Revision: 9cb4e90e72602e0974b2eb9e5eb56fd2cc998db7

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

LOG: [clang][Interp] Support base class constructors

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 872bbf045cef2..c785d3cafdad6 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -107,6 +107,21 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 });
   }
 
+  case CK_UncheckedDerivedToBase: {
+if (!this->visit(SubExpr))
+  return false;
+
+const CXXRecordDecl *FromDecl = getRecordDecl(SubExpr);
+assert(FromDecl);
+const CXXRecordDecl *ToDecl = getRecordDecl(CE);
+assert(ToDecl);
+const Record *R = getRecord(FromDecl);
+const Record::Base *ToBase = R->getBase(ToDecl);
+assert(ToBase);
+
+return this->emitGetPtrBase(ToBase->Offset, CE);
+  }
+
   case CK_ArrayToPointerDecay:
   case CK_AtomicToNonAtomic:
   case CK_ConstructorConversion:

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 6cc45bd4d0154..a254a1baee8f9 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -244,6 +244,15 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
 return (*InitFn)();
   }
 
+  /// Returns the CXXRecordDecl for the type of the given expression,
+  /// or nullptr if no such decl exists.
+  const CXXRecordDecl *getRecordDecl(const Expr *E) const {
+QualType T = E->getType();
+if (const auto *RD = T->getPointeeCXXRecordDecl())
+  return RD;
+return T->getAsCXXRecordDecl();
+  }
+
 protected:
   /// Variable to storage mapping.
   llvm::DenseMap Locals;

diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 3cdb87fcd7f6e..addcb4dff1ff8 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -100,31 +100,45 @@ bool ByteCodeStmtGen::visitFunc(const 
FunctionDecl *F) {
 const Record *R = this->getRecord(RD);
 
 for (const auto *Init : Ctor->inits()) {
-  const FieldDecl *Member = Init->getMember();
   const Expr *InitExpr = Init->getInit();
-  const Record::Field *F = R->getField(Member);
-
-  if (Optional T = this->classify(InitExpr->getType())) {
-if (!this->emitThis(InitExpr))
-  return false;
-
-if (!this->visit(InitExpr))
-  return false;
-
-if (!this->emitInitField(*T, F->Offset, InitExpr))
+  if (const FieldDecl *Member = Init->getMember()) {
+const Record::Field *F = R->getField(Member);
+
+if (Optional T = this->classify(InitExpr->getType())) {
+  if (!this->emitThis(InitExpr))
+return false;
+
+  if (!this->visit(InitExpr))
+return false;
+
+  if (!this->emitInitField(*T, F->Offset, InitExpr))
+return false;
+} else {
+  // Non-primitive case. Get a pointer to the field-to-initialize
+  // on the stack and call visitInitialzer() for it.
+  if (!this->emitThis(InitExpr))
+return false;
+
+  if (!this->emitGetPtrField(F->Offset, InitExpr))
+return false;
+
+  if (!this->visitInitializer(InitExpr))
+return false;
+
+  if (!this->emitPopPtr(InitExpr))
+return false;
+}
+  } else if (const Type *Base = Init->getBaseClass()) {
+// Base class initializer.
+// Get This Base and call initializer on it.
+auto *BaseDecl = Base->getAsCXXRecordDecl();
+assert(BaseDecl);
+const Record::Base *B = R->getBase(BaseDecl);
+assert(B);
+if (!this->emitGetPtrThisBase(B->Offset, InitExpr))
   return false;
-  } else {
-// Non-primitive case. Get a pointer to the field-to-initialize
-// on the stack and call visitInitialzer() for it.
-if (!this->emitThis(InitExpr))
-  return false;
-
-if (!this->emitGetPtrField(F->Offset, InitExpr))
-  return false;
-
 if (!this->visitInitializer(InitExpr))
   return false;
-
 if (!this->emitPopPtr(InitExpr))
   return false;
   }

diff  --git a/clang/test/AST/Interp/records.cpp 
b/clang/test/AST/Interp/records.cpp
index d0a40c8d25838..98d4582b961b7 100644
--- a/clang/test/AST/In

[PATCH] D135013: [clang][Interp] Array initialization via ImplicitValueInitExpr

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
tbaeder marked an inline comment as done.
Closed by commit rG09bbc903a5b4: [clang][Interp] Array initialization via 
ImplicitValueInitExpr (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D135013?vs=469243&id=469507#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135013

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/arrays.cpp


Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -117,3 +117,15 @@
// expected-error {{must be initialized 
by a constant expression}} \
// expected-note {{cannot refer to 
element -2 of array of 10}}
 };
+
+namespace DefaultInit {
+  template 
+  struct B {
+T a[N];
+  };
+
+  int f() {
+ constexpr B arr = {};
+ constexpr int x = arr.a[0];
+  }
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -721,6 +721,27 @@
   if (!this->emitPopPtr(Initializer))
 return false;
 }
+return true;
+  } else if (const auto *IVIE = dyn_cast(Initializer)) {
+const ArrayType *AT = IVIE->getType()->getAsArrayTypeUnsafe();
+assert(AT);
+const auto *CAT = cast(AT);
+size_t NumElems = CAT->getSize().getZExtValue();
+
+if (Optional ElemT = classify(CAT->getElementType())) {
+  // TODO(perf): For int and bool types, we can probably just skip this
+  //   since we memset our Block*s to 0 and so we have the desired value
+  //   without this.
+  for (size_t I = 0; I != NumElems; ++I) {
+if (!this->emitZero(*ElemT, Initializer))
+  return false;
+if (!this->emitInitElem(*ElemT, I, Initializer))
+  return false;
+  }
+} else {
+  assert(false && "default initializer for non-primitive type");
+}
+
 return true;
   }
 


Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -117,3 +117,15 @@
// expected-error {{must be initialized by a constant expression}} \
// expected-note {{cannot refer to element -2 of array of 10}}
 };
+
+namespace DefaultInit {
+  template 
+  struct B {
+T a[N];
+  };
+
+  int f() {
+ constexpr B arr = {};
+ constexpr int x = arr.a[0];
+  }
+};
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -721,6 +721,27 @@
   if (!this->emitPopPtr(Initializer))
 return false;
 }
+return true;
+  } else if (const auto *IVIE = dyn_cast(Initializer)) {
+const ArrayType *AT = IVIE->getType()->getAsArrayTypeUnsafe();
+assert(AT);
+const auto *CAT = cast(AT);
+size_t NumElems = CAT->getSize().getZExtValue();
+
+if (Optional ElemT = classify(CAT->getElementType())) {
+  // TODO(perf): For int and bool types, we can probably just skip this
+  //   since we memset our Block*s to 0 and so we have the desired value
+  //   without this.
+  for (size_t I = 0; I != NumElems; ++I) {
+if (!this->emitZero(*ElemT, Initializer))
+  return false;
+if (!this->emitInitElem(*ElemT, I, Initializer))
+  return false;
+  }
+} else {
+  assert(false && "default initializer for non-primitive type");
+}
+
 return true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D135025: [clang][Interp] Support base class constructors

2022-10-21 Thread Timm Bäder 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 rG9cb4e90e7260: [clang][Interp] Support base class 
constructors (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D135025?vs=467699&id=469508#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135025

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -5,8 +5,6 @@
 // RUN: %clang_cc1 -verify=ref -std=c++14 %s
 // RUN: %clang_cc1 -verify=ref -triple i686 %s
 
-// expected-no-diagnostics
-
 struct BoolPair {
   bool first;
   bool second;
@@ -181,3 +179,116 @@
 static_assert(LT2.v[0].second == false, "");
 static_assert(LT2.v[2].first == true, "");
 static_assert(LT2.v[2].second == false, "");
+
+class Base {
+public:
+  int i;
+  constexpr Base() : i(10) {}
+  constexpr Base(int i) : i(i) {}
+};
+
+class A : public Base {
+public:
+  constexpr A() : Base(100) {}
+  constexpr A(int a) : Base(a) {}
+};
+constexpr A a{};
+static_assert(a.i == 100, "");
+constexpr A a2{12};
+static_assert(a2.i == 12, "");
+static_assert(a2.i == 200, ""); // ref-error {{static assertion failed}} \
+// ref-note {{evaluates to '12 == 200'}} \
+// expected-error {{static assertion failed}} \
+// expected-note {{evaluates to '12 == 200'}}
+
+namespace MI {
+  class A {
+  public:
+int a;
+constexpr A(int a) : a(a) {}
+  };
+
+  class B {
+  public:
+int b;
+constexpr B(int b) : b(b) {}
+  };
+
+  class C : public A, public B {
+  public:
+constexpr C() : A(10), B(20) {}
+  };
+  constexpr C c = {};
+  static_assert(c.a == 10, "");
+  static_assert(c.b == 20, "");
+
+
+  class D : private A, private B {
+public:
+constexpr D() : A(20), B(30) {}
+constexpr int getA() const { return a; }
+constexpr int getB() const { return b; }
+  };
+  constexpr D d = {};
+  static_assert(d.getA() == 20, "");
+  static_assert(d.getB() == 30, "");
+};
+
+namespace DeriveFailures {
+  struct Base { // ref-note 2{{declared here}}
+int Val;
+  };
+
+  struct Derived : Base {
+int OtherVal;
+
+constexpr Derived(int i) : OtherVal(i) {} // ref-error {{never produces a constant expression}} \
+  // ref-note 2{{non-constexpr constructor 'Base' cannot be used in a constant expression}}
+  };
+
+  // FIXME: This is currently not being diagnosed with the new constant interpreter.
+  constexpr Derived D(12); // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{in call to 'Derived(12)'}} \
+   // ref-note {{declared here}} \
+   // expected-error {{must be initialized by a constant expression}}
+  static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{initializer of 'D' is not a constant expression}}
+
+#if 0
+  // FIXME: This test is currently disabled because the failing constructor call
+  //   causes us to run into an assertion later on in the new interpreter.
+  //   Once that is fixed, we fail successfully but the diagnostic uses the
+  //   wrong value.
+  struct AnotherBase {
+int Val;
+constexpr AnotherBase(int i) : Val(12 / i) {} //ref-note {{division by zero}} \
+  //expected-note {{division by zero}}
+  };
+
+  struct AnotherDerived : AnotherBase {
+constexpr AnotherDerived(int i) : AnotherBase(i) {}
+  };
+  constexpr AnotherBase Derp(0); // ref-error {{must be initialized by a constant expression}} \
+ // ref-note {{in call to 'AnotherBase(0)'}} \
+ // expected-error {{must be initialized by a constant expression}} \
+ // expected-note {{in call to 'AnotherBase(}}
+ // FIXME Previous note uses the wrong value
+#endif
+
+  struct YetAnotherBase {
+int Val;
+constexpr YetAnotherBase(int i) : Val(i) {}
+  };
+
+  struct YetAnotherDerived : YetAnotherBase {
+using YetAnotherBase::YetAnotherBase; //ref-note {{declared here}}
+int OtherVal;
+
+constexpr bool doit() const { return Val == OtherVal; }
+  };
+
+  constexpr YetAnotherDerived Oops(0); // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{constructor inherited from base class 'YetAnotherBase' cannot be used in a

[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-21 Thread Sheng via Phabricator via cfe-commits
0x59616e added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:6114-6116
+// const ValueDecl *VD = Entity.getDecl();
+// if (const VarDecl *VarD = dyn_cast_or_null(VD);
+// VarD && VarD->hasInit() && !VarD->getInit()->containsErrors())

cor3ntin wrote:
> Is that code meant to be commented?
This is a legacy from me. I guess it is for debugging purpose IIRC (sorry, it 
is too long ago to remember clearly). If so, t should be deleted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D135933: [X86] Add CMPCCXADD instructions.

2022-10-21 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/Target/X86/X86InstrInfo.td:3028
+  (ins i32mem:$dstsrc1, GR32:$dstsrc2, GR32:$src3, ccode:$cond),
+  "cmp${cond}xadd\t{$src3, $dst, $dstsrc1|$dstsrc1, $dst, $src3}",
+  [(set GR32:$dst, (X86cmpccxadd addr:$dstsrc1, GR32:$dstsrc2, 
GR32:$src3, timm:$cond))]>,

+1 for craig. Usually if the input is tied to ouput, it should be the 1st 
input. These two instructions use a new Format MRMDestMem4VOp3CC rather than an 
existing one, I belive it won't increase the complexity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135933

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


[PATCH] D135937: [WIP][X86] Support -march=raptorlake, meteorlake

2022-10-21 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: compiler-rt/lib/builtins/cpu_model.c:111
+  ZHAOXIN_FAM7H_LUJIAZUI,
+  INTEL_COREI7_RAPTORLAKE,
+  INTEL_COREI7_METEORLAKE,

I see. But if possible, could we split "ZHAOXIN_FAM7H_LUJIAZUI" to another 
patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135937

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


[PATCH] D135932: [X86] Add AVX-IFMA instructions.

2022-10-21 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:781
+Builder.defineMacro("__AVXIFMA__");
+  Builder.defineMacro("__AVXIFMA_SUPPORTED__");
   if (HasAVXVNNI)

Why do we need this line?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135932

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


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-21 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

Thanks for working on it! It looks really good. Please remember to update the 
feature test macro (__cpp_aggregate_paren_init).

Also, I think there's no test coverage for the ASTReader/Writer changes? I 
would like to see some as well.




Comment at: clang/docs/ReleaseNotes.rst:546
   ([temp.func.order]p6.2.1 is not implemented, matching GCC).
+- Implemented `P0634R3: 
`_
+  and `P1975R0: 
`_,




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


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

2022-10-21 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead marked an inline comment as done.
pcwang-thead added a comment.

In D70401#3873347 , @luojia wrote:

> Hello! Any further updates to this patch? It seems like all the inline 
> comments have been resolved.

We have done some works in this patch to make it compatible with GCC, it can be 
combined with GNU toolchain now.

But as what have been discussed[1, 2], we may proceed with this patch when 
RV32E/ilp32e is ratified.

1. https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/269
2. https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/257


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D129531: [clang][C++20] P0960R3: Allow initializing aggregates from a parenthesized list of values

2022-10-21 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added inline comments.



Comment at: clang/test/SemaCXX/P0960R3.cpp:54
+}
+
+void foo() {

Could you add test that this works with variadic templates? Something like

```
template
T construct(Args... args) {
  return T(args...);
}
```

Similar to the intended use case of make_unique/emplace_back etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129531

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


[PATCH] D136435: [clang][Driver] Add gcc-toolset-12 and devtoolset-12 prefixes

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: thieta, MaskRay, tstellar.
Herald added a subscriber: StephenFan.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 35aaf548237a4f213ba9d95de53b33c5ce1eadce 
 and 
commit 9f97720268911abae2ad9d90e270358db234a1c1 
 and adds 
the prefix like we did before.

The issues with the approach are explained in 
https://github.com/llvm/llvm-project/issues/57843. If clang16 stops doing the 
gcc/devtoolset detection and relies on a config file instead, that's fine but 
for the time being (and for a backport to clang15), we need to fix this problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136435

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/unittests/Driver/ToolChainTest.cpp

Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -20,7 +20,6 @@
 #include "clang/Frontend/CompilerInstance.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/MC/TargetRegistry.h"
-#include "llvm/Support/Host.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
@@ -394,96 +393,6 @@
   std::vector> Errors;
 };
 
-TEST(ToolChainTest, Toolsets) {
-  // Ignore this test on Windows hosts.
-  llvm::Triple Host(llvm::sys::getProcessTriple());
-  if (Host.isOSWindows())
-GTEST_SKIP();
-
-  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
-  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
-
-  // Check (newer) GCC toolset installation.
-  {
-IntrusiveRefCntPtr InMemoryFileSystem(
-new llvm::vfs::InMemoryFileSystem);
-
-// These should be ignored.
-InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-2", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-InMemoryFileSystem->addFile("/opt/rh/gcc-toolset--", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-InMemoryFileSystem->addFile("/opt/rh/gcc-toolset--1", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-
-// File needed for GCC installation detection.
-InMemoryFileSystem->addFile("/opt/rh/gcc-toolset-12/root/usr/lib/gcc/"
-"x86_64-redhat-linux/11/crtbegin.o",
-0, llvm::MemoryBuffer::getMemBuffer("\n"));
-
-DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
-Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
- "clang LLVM compiler", InMemoryFileSystem);
-std::unique_ptr C(
-TheDriver.BuildCompilation({"clang", "--gcc-toolchain="}));
-ASSERT_TRUE(C);
-std::string S;
-{
-  llvm::raw_string_ostream OS(S);
-  C->getDefaultToolChain().printVerboseInfo(OS);
-}
-EXPECT_EQ("Found candidate GCC installation: "
-  "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
-  "Selected GCC installation: "
-  "/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/11\n"
-  "Candidate multilib: .;@m64\n"
-  "Selected multilib: .;@m64\n",
-  S);
-  }
-
-  // And older devtoolset.
-  {
-IntrusiveRefCntPtr InMemoryFileSystem(
-new llvm::vfs::InMemoryFileSystem);
-
-// These should be ignored.
-InMemoryFileSystem->addFile("/opt/rh/devtoolset-2", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-InMemoryFileSystem->addFile("/opt/rh/devtoolset-", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-InMemoryFileSystem->addFile("/opt/rh/devtoolset--", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-InMemoryFileSystem->addFile("/opt/rh/devtoolset--1", 0,
-llvm::MemoryBuffer::getMemBuffer("\n"));
-
-// File needed for GCC installation detection.
-InMemoryFileSystem->addFile("/opt/rh/devtoolset-12/root/usr/lib/gcc/"
-"x86_64-redhat-linux/11/crtbegin.o",
-0, llvm::MemoryBuffer::getMemBuffer("\n"));
-
-DiagnosticsEngine Diags(DiagID, &*DiagOpts, new SimpleDiagnosticConsumer);
-Driver TheDriver("/bin/clang", "x86_64-redhat-linux", Diags,
- "clang LLVM compiler", InMemoryFileSystem);
-std::unique_ptr C(
-TheDriver.BuildCompilation({"clang", "--gcc-toolchain="}));
-ASSERT_TRUE(C);
-std::string S;
-{
-  

[PATCH] D136436: [Clang][LoongArch] Add register alias handling without `$` prefix

2022-10-21 Thread Youling Tang via Phabricator via cfe-commits
tangyouling created this revision.
tangyouling added reviewers: SixWeining, xen0n, xry111, MaskRay, wangleiat.
Herald added subscribers: jeroen.dobbelaere, StephenFan.
Herald added a project: All.
tangyouling requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add `a0`, `r4` without the prefix `$` is handled in inline assembly,
while keeping in line with gcc.
GCC recognizes four methods (`a0`, `$a0`, `r4`, `$r4`), but only for
`GPR`. for `FPR`, gcc only supports `f0` and `$f0` writing styles,
but not `fa0` and `$fa0`.

Also solve the following build problem:
In file included from 
/home/loongson/llvm-work/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp:196:
llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc:27:23:
 error: unknown register name 'a7' in asm

  register u64 a7 asm("a7") = nr;
  ^

llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc:28:23:
 error: unknown register name 'a0' in asm

  register u64 a0 asm("a0");  ^


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136436

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/test/CodeGen/LoongArch/inline-asm-gcc-regs-error.c
  clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c

Index: clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c
===
--- clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c
+++ clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c
@@ -7,96 +7,124 @@
 // CHECK: call void asm sideeffect "", "{$r0}"(i32 undef)
 void test_r0() {
 register int a asm ("$r0");
+register int b asm ("r0");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_r12
 // CHECK: call void asm sideeffect "", "{$r12}"(i32 undef)
 void test_r12() {
 register int a asm ("$r12");
+register int b asm ("r12");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_r31
 // CHECK: call void asm sideeffect "", "{$r31}"(i32 undef)
 void test_r31() {
 register int a asm ("$r31");
+register int b asm ("r31");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_zero
 // CHECK: call void asm sideeffect "", "{$r0}"(i32 undef)
 void test_zero() {
 register int a asm ("$zero");
+register int b asm ("zero");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_a0
 // CHECK: call void asm sideeffect "", "{$r4}"(i32 undef)
 void test_a0() {
 register int a asm ("$a0");
+register int b asm ("a0");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_t1
 // CHECK: call void asm sideeffect "", "{$r13}"(i32 undef)
 void test_t1() {
 register int a asm ("$t1");
+register int b asm ("t1");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_fp
 // CHECK: call void asm sideeffect "", "{$r22}"(i32 undef)
 void test_fp() {
 register int a asm ("$fp");
+register int b asm ("fp");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_s2
 // CHECK: call void asm sideeffect "", "{$r25}"(i32 undef)
 void test_s2() {
 register int a asm ("$s2");
+register int b asm ("s2");
 asm ("" :: "r" (a));
+asm ("" :: "r" (b));
 }
 
 // CHECK-LABEL: @test_f0
 // CHECK: call void asm sideeffect "", "{$f0}"(float undef)
 void test_f0() {
 register float a asm ("$f0");
+register float b asm ("f0");
 asm ("" :: "f" (a));
+asm ("" :: "f" (b));
 }
 
 // CHECK-LABEL: @test_f14
 // CHECK: call void asm sideeffect "", "{$f14}"(float undef)
 void test_f14() {
 register float a asm ("$f14");
+register float b asm ("f14");
 asm ("" :: "f" (a));
+asm ("" :: "f" (b));
 }
 
 // CHECK-LABEL: @test_f31
 // CHECK: call void asm sideeffect "", "{$f31}"(float undef)
 void test_f31() {
 register float a asm ("$f31");
+register float b asm ("f31");
 asm ("" :: "f" (a));
+asm ("" :: "f" (b));
 }
 
 // CHECK-LABEL: @test_fa0
 // CHECK: call void asm sideeffect "", "{$f0}"(float undef)
 void test_fa0() {
 register float a asm ("$fa0");
+register float b asm ("fa0");
 asm ("" :: "f" (a));
+asm ("" :: "f" (b));
 }
 
 // CHECK-LABEL: @test_ft1
 // CHECK: call void asm sideeffect "", "{$f9}"(float undef)
 void test_ft1() {
 register float a asm ("$ft1");
+register float b asm ("ft1");
 asm ("" :: "f" (a));
+asm ("" :: "f" (b));
 }
 
 // CHECK-LABEL: @test_fs2
 // CHECK: call void asm sideeffect "", "{$f26}"(float undef)
 void test_fs2() {
 register float a asm ("$fs2");
+register float b asm ("fs2");
 asm ("" :: "f" (a));
+asm ("" :: "f" (b));
 }
Index: clang/test/CodeGen/LoongArch/inline-asm-gcc-regs-error.c
===
--- clang/test/CodeGen/LoongArch/inline-asm-gcc-regs-

[PATCH] D136436: [Clang][LoongArch] Add register alias handling without `$` prefix

2022-10-21 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added a comment.

Commit message is unclear. You added non-prefixed aliases for all registers, 
yet only `$a0` is mentioned. I'd like to see what improvement you could come up 
with before amending it myself, to hopefully make you better at writing those 
"small compositions".




Comment at: clang/lib/Basic/Targets/LoongArch.cpp:52
+  {{"t8", "$t8", "r20"}, "$r20"},{{"r21"}, "$r21"},
+  {{"fp", "$fp", "r22", "$s9"}, "$r22"}, {{"s0", "$s0", "r23"}, "$r23"},
+  {{"s1", "$s1", "r24"}, "$r24"},{{"s2", "$s2", "r25"}, "$r25"},

Missing `"s9"`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136436

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


[PATCH] D136436: [Clang][LoongArch] Add register alias handling without `$` prefix

2022-10-21 Thread Youling Tang via Phabricator via cfe-commits
tangyouling added a comment.

  $ cat prefix_regalias.c 
  int main()
  {
register unsigned long a0 asm("a0");
register unsigned long a1 asm("$a1");
register unsigned long a2 asm("r6");
register unsigned long a3 asm("$r7");
register float f0 asm("fa0");
register float f1 asm("$fa1");
register float f2 asm("f2");
register float f3 asm("$f3");
  
return 0;
  }
  
  clang before applying patch:
  $ clang prefix_regalias.c 
  prefix_regalias.c:3:32: error: unknown register name 'a0' in asm
  register unsigned long a0 asm("a0");
^
  prefix_regalias.c:5:32: error: unknown register name 'r6' in asm
  register unsigned long a2 asm("r6");
^
  prefix_regalias.c:7:24: error: unknown register name 'fa0' in asm
  register float f0 asm("fa0");
^
  prefix_regalias.c:9:24: error: unknown register name 'f2' in asm
  register float f2 asm("f2");
^
  4 errors generated.
  
  
  clang after applying patch:
  $ clang prefix_regalias.c 
  
  gcc:
  $ gcc prefix_regalias.c 
  prefix_regalias.c: In function ‘main’:
  prefix_regalias.c:7:24: error: invalid register name for ‘f0’
  7 | register float f0 asm("fa0");
|^~
  prefix_regalias.c:8:24: error: invalid register name for ‘f1’
  8 | register float f1 asm("$fa1");
|  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136436

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


[PATCH] D136436: [Clang][LoongArch] Add register alias handling without `$` prefix

2022-10-21 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

How about the asm code in `.s`? Do we need to support `addi.d a0, a1, a2`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136436

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


[clang] 39d8597 - [clang] Fix typo in error message

2022-10-21 Thread Paulo Matos via cfe-commits

Author: Paulo Matos
Date: 2022-10-21T12:06:28+02:00
New Revision: 39d8597927a5887bcfde2229491d793f3edcedbd

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

LOG: [clang] Fix typo in error message

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 54eb520a47526..2a3da01febe2b 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18853,7 +18853,7 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
   IntNo = Intrinsic::wasm_extadd_pairwise_unsigned;
   break;
 default:
-  llvm_unreachable("unexptected builtin ID");
+  llvm_unreachable("unexpected builtin ID");
 }
 
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));



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


[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 469527.
tbaeder marked 5 inline comments as done.

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

https://reviews.llvm.org/D134859

Files:
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Floating.cpp
  clang/lib/AST/Interp/Floating.h
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/InterpState.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/lib/AST/Interp/Primitives.h
  clang/lib/AST/Interp/State.h
  clang/test/AST/Interp/literals.cpp
  clang/test/SemaCXX/rounding-math.cpp

Index: clang/test/SemaCXX/rounding-math.cpp
===
--- clang/test/SemaCXX/rounding-math.cpp
+++ clang/test/SemaCXX/rounding-math.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify=norounding -Wno-unknown-pragmas %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -Wno-unknown-pragmas
+// RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -fexperimental-new-constant-interpreter -Wno-unknown-pragmas
 // rounding-no-diagnostics
 
 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -322,3 +322,42 @@
   // expected-error{{wide character literals may not contain multiple characters}}
 #pragma clang diagnostic pop
 };
+
+namespace floats {
+  constexpr int i = 2;
+  constexpr float f = 1.0f;
+  static_assert(f == 1.0f, "");
+
+  constexpr float f2 = 1u * f;
+  static_assert(f2 == 1.0f, "");
+
+  static_assert(1.0f + 3u == 4, "");
+  static_assert(4.0f / 1.0f == 4, "");
+  static_assert(10.0f * false == 0, "");
+
+  constexpr float floats[] = {1.0f, 2.0f, 3.0f, 4.0f};
+
+  constexpr float m = 5.0f / 0.0f; // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{division by zero}} \
+   // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{division by zero}}
+
+  static_assert(~2.0f == 3, ""); // ref-error {{invalid argument type 'float' to unary expression}} \
+ // expected-error {{invalid argument type 'float' to unary expression}}
+
+  /// Initialized by a double.
+  constexpr float df = 0.0;
+  /// The other way around.
+  constexpr double fd = 0.0f;
+
+  static_assert(0.0f == -0.0f, "");
+
+  const int k = 3 * (1.0f / 3.0f);
+  static_assert(k == 1, "");
+
+  constexpr bool b = 1.0;
+  static_assert(b, "");
+
+  constexpr double db = true;
+  static_assert(db == 1.0, "");
+};
Index: clang/lib/AST/Interp/State.h
===
--- clang/lib/AST/Interp/State.h
+++ clang/lib/AST/Interp/State.h
@@ -71,6 +71,7 @@
   virtual unsigned getCallStackDepth() = 0;
 
 public:
+  State() : InConstantContext(false) {}
   // Diagnose that the evaluation could not be folded (FF => FoldFailure)
   OptionalDiagnostic
   FFDiag(SourceLocation Loc,
@@ -118,6 +119,10 @@
 
   const LangOptions &getLangOpts() const;
 
+  /// Whether or not we're in a context where the front end requires a
+  /// constant value.
+  bool InConstantContext;
+
 private:
   void addCallStack(unsigned Limit);
 
Index: clang/lib/AST/Interp/Primitives.h
===
--- /dev/null
+++ clang/lib/AST/Interp/Primitives.h
@@ -0,0 +1,36 @@
+//===-- Primitives.h - Types for the constexpr VM ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Utilities and helper functions for all primitive types:
+//  - Integral
+//  - Floating
+//  - Boolean
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_INTERP_PRIMITIVES_H
+#define LLVM_CLANG_AST_INTERP_PRIMITIVES_H
+
+#include "clang/AST/ComparisonCategories.h"
+
+namespace clang {
+namespace interp {
+
+/// Helper to compare two comparable types.
+template  ComparisonCategoryResult Compare(const T &X, const T &Y) {
+  if (X < Y)
+return ComparisonCategoryResult::Less;
+  if (X > Y)
+return ComparisonCategoryResult::Greater;
+  return ComparisonCategoryRe

[PATCH] D135932: [X86] Add AVX-IFMA instructions.

2022-10-21 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 469529.
FreddyYe marked 3 inline comments as done.
FreddyYe added a comment.

Address comments. THX for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135932

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/avxifmaintrin.h
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/test/CodeGen/attr-target-x86.c
  clang/test/CodeGen/avxifma-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrAVX512.td
  llvm/lib/Target/X86/X86InstrFoldTables.cpp
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrSSE.td
  llvm/lib/Target/X86/X86IntrinsicsInfo.h
  llvm/test/CodeGen/X86/avx-ifma-intrinsics.ll
  llvm/test/MC/Disassembler/X86/avx-ifma-32.txt
  llvm/test/MC/Disassembler/X86/avx-ifma-64.txt
  llvm/test/MC/X86/avx-ifma-att-32.s
  llvm/test/MC/X86/avx-ifma-att-64.s
  llvm/test/MC/X86/avx-ifma-intel-32.s
  llvm/test/MC/X86/avx-ifma-intel-64.s

Index: llvm/test/MC/X86/avx-ifma-intel-64.s
===
--- /dev/null
+++ llvm/test/MC/X86/avx-ifma-intel-64.s
@@ -0,0 +1,114 @@
+// RUN: llvm-mc -triple x86_64-unknown-unknown -mattr=+avxifma -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymm14
+// CHECK: encoding: [0xc4,0x42,0x95,0xb5,0xe6]
+ {vex} vpmadd52huq ymm12, ymm13, ymm14
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmm14
+// CHECK: encoding: [0xc4,0x42,0x91,0xb5,0xe6]
+ {vex} vpmadd52huq xmm12, xmm13, xmm14
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rbp + 8*r14 + 268435456]
+// CHECK: encoding: [0xc4,0x22,0x95,0xb5,0xa4,0xf5,0x00,0x00,0x00,0x10]
+ {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rbp + 8*r14 + 268435456]
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [r8 + 4*rax + 291]
+// CHECK: encoding: [0xc4,0x42,0x95,0xb5,0xa4,0x80,0x23,0x01,0x00,0x00]
+ {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [r8 + 4*rax + 291]
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rip]
+// CHECK: encoding: [0xc4,0x62,0x95,0xb5,0x25,0x00,0x00,0x00,0x00]
+ {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rip]
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [2*rbp - 1024]
+// CHECK: encoding: [0xc4,0x62,0x95,0xb5,0x24,0x6d,0x00,0xfc,0xff,0xff]
+ {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [2*rbp - 1024]
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rcx + 4064]
+// CHECK: encoding: [0xc4,0x62,0x95,0xb5,0xa1,0xe0,0x0f,0x00,0x00]
+ {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rcx + 4064]
+
+// CHECK: {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rdx - 4096]
+// CHECK: encoding: [0xc4,0x62,0x95,0xb5,0xa2,0x00,0xf0,0xff,0xff]
+ {vex} vpmadd52huq ymm12, ymm13, ymmword ptr [rdx - 4096]
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rbp + 8*r14 + 268435456]
+// CHECK: encoding: [0xc4,0x22,0x91,0xb5,0xa4,0xf5,0x00,0x00,0x00,0x10]
+ {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rbp + 8*r14 + 268435456]
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [r8 + 4*rax + 291]
+// CHECK: encoding: [0xc4,0x42,0x91,0xb5,0xa4,0x80,0x23,0x01,0x00,0x00]
+ {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [r8 + 4*rax + 291]
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rip]
+// CHECK: encoding: [0xc4,0x62,0x91,0xb5,0x25,0x00,0x00,0x00,0x00]
+ {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rip]
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [2*rbp - 512]
+// CHECK: encoding: [0xc4,0x62,0x91,0xb5,0x24,0x6d,0x00,0xfe,0xff,0xff]
+ {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [2*rbp - 512]
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rcx + 2032]
+// CHECK: encoding: [0xc4,0x62,0x91,0xb5,0xa1,0xf0,0x07,0x00,0x00]
+ {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rcx + 2032]
+
+// CHECK: {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rdx - 2048]
+// CHECK: encoding: [0xc4,0x62,0x91,0xb5,0xa2,0x00,0xf8,0xff,0xff]
+ {vex} vpmadd52huq xmm12, xmm13, xmmword ptr [rdx - 2048]
+
+// CHECK: {vex} vpmadd52luq ymm12, ymm13, ymm14
+// CHECK: encoding: [0xc4,0x42,0x95,0xb4,0xe6]
+ {vex} vpmadd52luq ymm12, ymm13, ymm14
+
+// CHECK: {vex} vpmadd52luq xmm12, xmm13, xmm14
+// CHECK: encoding: [0xc4,0x42,0x91,0xb4,0xe6]
+ {vex} vpmadd52luq xmm12, xmm13, xmm14
+
+// CHECK: {vex} vpmadd52luq ymm12, ymm13, ymmword ptr [rbp + 8*r14 + 26

[PATCH] D136423: [clang][Interp] Implement inc/dec postfix and prefix operators

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 469530.

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

https://reviews.llvm.org/D136423

Files:
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Boolean.h
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Floating.cpp
  clang/lib/AST/Interp/Floating.h
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpStack.h
  clang/lib/AST/Interp/InterpState.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/lib/AST/Interp/Primitives.h
  clang/lib/AST/Interp/State.h
  clang/test/AST/Interp/literals.cpp
  clang/test/SemaCXX/rounding-math.cpp

Index: clang/test/SemaCXX/rounding-math.cpp
===
--- clang/test/SemaCXX/rounding-math.cpp
+++ clang/test/SemaCXX/rounding-math.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify=norounding -Wno-unknown-pragmas %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -Wno-unknown-pragmas
+// RUN: %clang_cc1 -triple x86_64-linux -verify=rounding %s -frounding-math -fexperimental-new-constant-interpreter -Wno-unknown-pragmas
 // rounding-no-diagnostics
 
 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -322,3 +322,42 @@
   // expected-error{{wide character literals may not contain multiple characters}}
 #pragma clang diagnostic pop
 };
+
+namespace floats {
+  constexpr int i = 2;
+  constexpr float f = 1.0f;
+  static_assert(f == 1.0f, "");
+
+  constexpr float f2 = 1u * f;
+  static_assert(f2 == 1.0f, "");
+
+  static_assert(1.0f + 3u == 4, "");
+  static_assert(4.0f / 1.0f == 4, "");
+  static_assert(10.0f * false == 0, "");
+
+  constexpr float floats[] = {1.0f, 2.0f, 3.0f, 4.0f};
+
+  constexpr float m = 5.0f / 0.0f; // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{division by zero}} \
+   // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{division by zero}}
+
+  static_assert(~2.0f == 3, ""); // ref-error {{invalid argument type 'float' to unary expression}} \
+ // expected-error {{invalid argument type 'float' to unary expression}}
+
+  /// Initialized by a double.
+  constexpr float df = 0.0;
+  /// The other way around.
+  constexpr double fd = 0.0f;
+
+  static_assert(0.0f == -0.0f, "");
+
+  const int k = 3 * (1.0f / 3.0f);
+  static_assert(k == 1, "");
+
+  constexpr bool b = 1.0;
+  static_assert(b, "");
+
+  constexpr double db = true;
+  static_assert(db == 1.0, "");
+};
Index: clang/lib/AST/Interp/State.h
===
--- clang/lib/AST/Interp/State.h
+++ clang/lib/AST/Interp/State.h
@@ -71,6 +71,7 @@
   virtual unsigned getCallStackDepth() = 0;
 
 public:
+  State() : InConstantContext(false) {}
   // Diagnose that the evaluation could not be folded (FF => FoldFailure)
   OptionalDiagnostic
   FFDiag(SourceLocation Loc,
@@ -118,6 +119,10 @@
 
   const LangOptions &getLangOpts() const;
 
+  /// Whether or not we're in a context where the front end requires a
+  /// constant value.
+  bool InConstantContext;
+
 private:
   void addCallStack(unsigned Limit);
 
Index: clang/lib/AST/Interp/Primitives.h
===
--- /dev/null
+++ clang/lib/AST/Interp/Primitives.h
@@ -0,0 +1,36 @@
+//===-- Primitives.h - Types for the constexpr VM ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Utilities and helper functions for all primitive types:
+//  - Integral
+//  - Floating
+//  - Boolean
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_INTERP_PRIMITIVES_H
+#define LLVM_CLANG_AST_INTERP_PRIMITIVES_H
+
+#include "clang/AST/ComparisonCategories.h"
+
+namespace clang {
+namespace interp {
+
+/// Helper to compare two comparable types.
+template  ComparisonCategoryResult Compare(const T &X, const T &Y) {
+  if (X < Y)
+return ComparisonCategoryResult::Less;
+  if (X > Y)
+return ComparisonCategoryResult::Greater;
+  return ComparisonCategoryResult::Equal;
+}
+
+} // namespace interp
+

[PATCH] D136436: [Clang][LoongArch] Add register alias handling without `$` prefix

2022-10-21 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added a comment.

In D136436#3873949 , @SixWeining 
wrote:

> How about the asm code in `.s`? Do we need to support `addi.d a0, a1, a2`?

For the assembler part of this support, I think we need to coordinate with the 
GNU toolchain maintainers of LoongArch port (Chenghua, Zhensong and Lulu I 
think). Maybe raising an issue on the LoongArch documentation repo 
 would help.

For the GCC part, consistency is of course welcomed, and I think the Loongson 
maintainers or @xry111 could just submit the respective support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136436

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


[PATCH] D136437: [clang-format] Insert closing braces of unaffected lines

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

The closing braces to be inserted are on unaffected lines by definition as 
those lines don't exist yet. Extra work is required in order for them to be 
inserted after the matching opening braces are inserted.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136437

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1874,26 +1874,32 @@
   void insertBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
+int OpeningBraceSurplus = 0;
 for (AnnotatedLine *Line : Lines) {
   insertBraces(Line->Children, Result);
-  if (!Line->Affected)
+  if (!Line->Affected && OpeningBraceSurplus == 0)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->BraceCount == 0)
+const int BraceCount = Token->BraceCount;
+if (BraceCount == 0)
   continue;
 std::string Brace;
-if (Token->BraceCount < 0) {
-  assert(Token->BraceCount == -1);
+if (BraceCount < 0) {
+  assert(BraceCount == -1);
   Brace = Token->is(tok::comment) ? "\n{" : "{";
+  ++OpeningBraceSurplus;
 } else {
-  Brace = '\n' + std::string(Token->BraceCount, '}');
+  Brace = '\n' + std::string(BraceCount, '}');
+  OpeningBraceSurplus -= BraceCount;
+  assert(OpeningBraceSurplus >= 0);
 }
 Token->BraceCount = 0;
 const auto Start = Token->Tok.getEndLoc();
 cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
   }
 }
+assert(OpeningBraceSurplus == 0);
   }
 };
 


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1874,26 +1874,32 @@
   void insertBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
+int OpeningBraceSurplus = 0;
 for (AnnotatedLine *Line : Lines) {
   insertBraces(Line->Children, Result);
-  if (!Line->Affected)
+  if (!Line->Affected && OpeningBraceSurplus == 0)
 continue;
   for (FormatToken *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->BraceCount == 0)
+const int BraceCount = Token->BraceCount;
+if (BraceCount == 0)
   continue;
 std::string Brace;
-if (Token->BraceCount < 0) {
-  assert(Token->BraceCount == -1);
+if (BraceCount < 0) {
+  assert(BraceCount == -1);
   Brace = Token->is(tok::comment) ? "\n{" : "{";
+  ++OpeningBraceSurplus;
 } else {
-  Brace = '\n' + std::string(Token->BraceCount, '}');
+  Brace = '\n' + std::string(BraceCount, '}');
+  OpeningBraceSurplus -= BraceCount;
+  assert(OpeningBraceSurplus >= 0);
 }
 Token->BraceCount = 0;
 const auto Start = Token->Tok.getEndLoc();
 cantFail(Result.add(tooling::Replacement(SourceMgr, Start, 0, Brace)));
   }
 }
+assert(OpeningBraceSurplus == 0);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136017: [clang][Interp] Materializing primitive temporaries

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:574
+/// 3) Initialized global with index \I with that
+template ::T>
+bool InitGlobalTemp(InterpState &S, CodePtr OpPC, uint32_t I,

shafik wrote:
> tbaeder wrote:
> > shafik wrote:
> > > Is `Name` really a `TypeName`?
> > Not sure I understand the question, that's just the pattern for templating 
> > that's used for all the interp functions. `Name` is our `PrimType` and `T` 
> > is the underlying type we use, as defined in `PrimConv`.
> I realize that this is the convention we have been using but it struck me 
> (maybe I am wrong) that `Name` really is a type name and now I can't unsee 
> it. 
`Name` is the `PrimType`, so will be e.g. `Sint32` in the end, `T` is then the 
integral type we use for it, e.g. `Integral<32, true>`.


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

https://reviews.llvm.org/D136017

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


[PATCH] D136440: Do not hide base member using decls with different template head.

2022-10-21 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added a project: All.
usaxena95 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136440

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/SemaTemplate/concepts-using-decl.cpp

Index: clang/test/SemaTemplate/concepts-using-decl.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-using-decl.cpp
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// expected-no-diagnostics
+
+namespace heads_without_concepts {
+struct base {
+  template 
+  int foo() { return 1; };
+};
+
+struct bar : public base {
+  using base::foo;
+  template  
+  int foo() { return 2; };
+};
+
+void func() {
+  bar f;
+  f.foo<10>();
+  f.foo<10, 10>();
+}
+}
+
+namespace static_methods {
+template concept False = false;
+
+struct Base {
+static void foo(auto);
+};
+struct Derived : public Base {
+using Base::foo;
+static void foo(False auto);
+};
+void func() {
+Derived::foo(42);
+}
+}
+
+namespace members_not_hidden {
+template  struct Opaque {};
+template  void expect(Opaque _) {}
+
+struct Empty{};
+constexpr int EmptySize = sizeof(Empty);
+
+template concept IsEmpty = sizeof(T) == EmptySize;
+
+namespace base_members_not_hidden {
+struct base {
+  template 
+  Opaque<0> foo() { return Opaque<0>(); };
+};
+
+struct bar1 : public base {
+  using base::foo;
+  template  requires IsEmpty 
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+
+struct bar2 : public base {
+  using base::foo;
+  template 
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+
+struct bar3 : public base {
+  using base::foo;
+  template 
+  Opaque<1> foo() requires IsEmpty { return Opaque<1>(); };
+};
+
+void func() {
+  expect<0>(base{}.foo());
+  expect<0>(base{}.foo());
+  expect<1>(bar1{}.foo());
+  expect<0>(bar1{}.foo());
+  expect<1>(bar2{}.foo());
+  expect<0>(bar2{}.foo());
+  expect<1>(bar3{}.foo());
+  expect<0>(bar3{}.foo());
+}
+}
+namespace base_members_hidden {
+struct base {
+  template  requires IsEmpty
+  Opaque<0> foo() { return Opaque<0>(); };
+};
+struct bar : public base {
+  using base::foo;
+  template  requires IsEmpty
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+void func() { 
+  expect<0>(base{}.foo());
+  expect<1>(bar{}.foo());
+}
+}
+}
\ No newline at end of file
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -719,11 +719,11 @@
 using A::g;
 using A::h;
 int &f(int);
-template int &g(int); // expected-note {{candidate}}
+template int &g(int);
 int &h();
   } b;
   int &w = b.f(0);
-  int &x = b.g(0); // expected-error {{no match}}
+  int &x = b.g(0); // expected-error {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'void'}}
   int &y = b.h();
   float &z = const_cast(b).h();
 
Index: clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
===
--- clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
+++ clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
@@ -9,7 +9,7 @@
 //   parameter types in a base class (rather than conflicting).
 
 template  struct Opaque {};
-template  void expect(Opaque _) {} // expected-note 4 {{candidate function template not viable}}
+template  void expect(Opaque _) {}
 
 // PR5727
 // This just shouldn't crash.
@@ -113,35 +113,35 @@
 
   struct Derived1 : Base {
 using Base::foo;
-template  Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
+template  Opaque<2> foo() { return Opaque<2>(); }
   };
 
   struct Derived2 : Base {
-template  Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
+template  Opaque<2> foo() { return Opaque<2>(); }
 using Base::foo;
   };
 
   struct Derived3 : Base {
 using Base::foo;
-template  Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
+template  Opaque<3> foo() { return Opaque<3>(); }
   };
 
   struct Derived4 : Base {
-template  Opaque<3> foo() { return Opaque<3>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'T'}}
+template  Opaque<3> foo() { return Opaque<3>(); }
 using Base::foo;
   };
 
   void test() {
 expect<0>(Base().foo());
 expect<1>(Base().foo<0>());
-expect<0>(Derived1().foo()); // expected-error {{no matching member function for call to 'foo'}} expected-error {{no matching function for call to 'expect'}}
+expect<0>(Der

[clang] 5b56763 - [Clang] Add __has_constexpr_builtin support

2022-10-21 Thread Evgeny Shulgin via cfe-commits

Author: Evgeny Shulgin
Date: 2022-10-21T11:23:10Z
New Revision: 5b567637e22bfa128514a5a9de7f3296423e8acd

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

LOG: [Clang] Add __has_constexpr_builtin support

The `__has_constexpr_builtin` macro can be used to check
whether the builtin in constant-evaluated by Clang frontend.

Reviewed By: aaron.ballman, shafik

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/include/clang/Lex/Preprocessor.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/feature_tests.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c0f086554e245..c4a8f7e6b399c 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -66,6 +66,35 @@ It can be used like this:
   ``__has_builtin`` should not be used to detect support for a builtin macro;
   use ``#ifdef`` instead.
 
+``__has_constexpr_builtin``
+---
+
+This function-like macro takes a single identifier argument that is the name of
+a builtin function, a builtin pseudo-function (taking one or more type
+arguments), or a builtin template.
+It evaluates to 1 if the builtin is supported and can be constant evaluated or
+0 if not. It can be used for writing conditionally constexpr code like this:
+
+.. code-block:: c++
+
+  #ifndef __has_constexpr_builtin // Optional of course.
+#define __has_constexpr_builtin(x) 0  // Compatibility with non-clang 
compilers.
+  #endif
+
+  ...
+  #if __has_constexpr_builtin(__builtin_fmax)
+constexpr
+  #endif
+double money_fee(double amount) {
+return __builtin_fmax(amount * 0.03, 10.0);
+}
+  ...
+
+For example, ``__has_constexpr_builtin`` is used in libcxx's implementation of
+the  header file to conditionally make a function constexpr whenever
+the constant evaluation of the corresponding builtin (for example,
+``std::fmax`` calls ``__builtin_fmax``) is supported in Clang.
+
 .. _langext-__has_feature-__has_extension:
 
 ``__has_feature`` and ``__has_extension``

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e87a4eea552df..3f952334c3d9a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -360,6 +360,9 @@ Non-comprehensive list of changes in this release
   timestamp to be used in replacement of the current date and time in
   the ``__DATE__``, ``__TIME__``, and ``__TIMESTAMP__`` macros. See
   ``_.
+- Clang now supports ``__has_constexpr_builtin`` function-like macro that
+  evaluates to 1 if the builtin is supported and can be constant evaluated.
+  It can be used to writing conditionally constexpr code that uses builtins.
 
 New Compiler Flags
 --

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index b7c52a7292c8c..d9faafd8813ef 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -105,6 +105,7 @@
 //  C -> callback behavior: argument N is called with argument
 //  M_0, ..., M_k as payload
 //  z -> this is a function in (possibly-versioned) namespace std
+//  E -> this function can be constant evaluated by Clang frontend
 //  FIXME: gcc has nonnull
 
 #if defined(BUILTIN) && !defined(LIBBUILTIN)
@@ -121,16 +122,16 @@ BUILTIN(__builtin_atan2f, "fff"  , "Fne")
 BUILTIN(__builtin_atan2l, "LdLdLd", "Fne")
 BUILTIN(__builtin_atan2f128, "LLdLLdLLd", "Fne")
 BUILTIN(__builtin_abs  , "ii"  , "ncF")
-BUILTIN(__builtin_copysign, "ddd", "ncF")
-BUILTIN(__builtin_copysignf, "fff", "ncF")
+BUILTIN(__builtin_copysign, "ddd", "ncFE")
+BUILTIN(__builtin_copysignf, "fff", "ncFE")
 BUILTIN(__builtin_copysignf16, "hhh", "ncF")
-BUILTIN(__builtin_copysignl, "LdLdLd", "ncF")
-BUILTIN(__builtin_copysignf128, "LLdLLdLLd", "ncF")
-BUILTIN(__builtin_fabs , "dd"  , "ncF")
-BUILTIN(__builtin_fabsf, "ff"  , "ncF")
-BUILTIN(__builtin_fabsl, "LdLd", "ncF")
+BUILTIN(__builtin_copysignl, "LdLdLd", "ncFE")
+BUILTIN(__builtin_copysignf128, "LLdLLdLLd", "ncFE")
+BUILTIN(__builtin_fabs , "dd"  , "ncFE")
+BUILTIN(__builtin_fabsf, "ff"  , "ncFE")
+BUILTIN(__builtin_fabsl, "LdLd", "ncFE")
 BUILTIN(__builtin_fabsf16, "hh"  , "ncF")
-BUILTIN(__builtin_fabsf128, "LLdLLd", "ncF")
+BUILTIN(__builtin_fabsf128, "LLdLLd", "ncFE")
 BUILTIN(__builtin_fmod , "ddd"  , "Fne")
 BUILTIN(__builtin_fmodf, "fff"  , "Fne")
 BUILTIN(__builtin_fmodf16, "hhh"  , "Fne")
@@ -140,16 +141,16 @@ BUILTIN(__builtin_

[PATCH] D136036: [Clang] Add __has_constexpr_builtin support

2022-10-21 Thread Evgeny Shulgin 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 rG5b567637e22b: [Clang] Add __has_constexpr_builtin support 
(authored by Izaron).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136036

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/feature_tests.cpp

Index: clang/test/Preprocessor/feature_tests.cpp
===
--- clang/test/Preprocessor/feature_tests.cpp
+++ clang/test/Preprocessor/feature_tests.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -verify -DVERIFY
-// expected-no-diagnostics
 
 #ifndef __has_feature
 #error Should have __has_feature
@@ -42,3 +41,29 @@
 #if __has_builtin(__builtin_insanity)
 #error Clang should not have this
 #endif
+
+// Check __has_constexpr_builtin
+#if  !__has_constexpr_builtin(__builtin_fmax) || \
+ !__has_constexpr_builtin(__builtin_fmin)
+#error Clang should have these constexpr builtins
+#endif
+
+#if  __has_constexpr_builtin(__builtin_cbrt)
+#error This builtin should not be constexpr in Clang
+#endif
+
+#if  __has_constexpr_builtin(__builtin_insanity)
+#error This is not a builtin in Clang
+#endif
+
+// expected-error@+1 {{missing '(' after '__has_constexpr_builtin'}} expected-error@+1 {{expected value}}
+#if __has_constexpr_builtin
+#endif
+
+// expected-error@+1 {{builtin feature check macro requires a parenthesized identifier}}
+#if  __has_constexpr_builtin("__builtin_fmax")
+#endif
+
+// expected-error@+1 {{too many arguments}}
+#if __has_constexpr_builtin(__builtin_fmax, __builtin_fmin)
+#endif
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -371,6 +371,8 @@
   Ident__has_feature  = RegisterBuiltinMacro(*this, "__has_feature");
   Ident__has_extension= RegisterBuiltinMacro(*this, "__has_extension");
   Ident__has_builtin  = RegisterBuiltinMacro(*this, "__has_builtin");
+  Ident__has_constexpr_builtin =
+  RegisterBuiltinMacro(*this, "__has_constexpr_builtin");
   Ident__has_attribute= RegisterBuiltinMacro(*this, "__has_attribute");
   if (!getLangOpts().CPlusPlus)
 Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
@@ -1735,6 +1737,18 @@
   .Default(false);
 }
   });
+  } else if (II == Ident__has_constexpr_builtin) {
+EvaluateFeatureLikeBuiltinMacro(
+OS, Tok, II, *this, false,
+[this](Token &Tok, bool &HasLexedNextToken) -> int {
+  IdentifierInfo *II = ExpectFeatureIdentifierInfo(
+  Tok, *this, diag::err_feature_check_malformed);
+  if (!II)
+return false;
+  unsigned BuiltinOp = II->getBuiltinID();
+  return BuiltinOp != 0 &&
+ this->getBuiltinInfo().isConstantEvaluated(BuiltinOp);
+});
   } else if (II == Ident__is_identifier) {
 EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [](Token &Tok, bool &HasLexedNextToken) -> int {
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -1954,8 +1954,8 @@
   return true;
 }
 
-/// Should this call expression be treated as a constant?
-static bool IsConstantCall(const CallExpr *E) {
+/// Should this call expression be treated as a no-op?
+static bool IsNoOpCall(const CallExpr *E) {
   unsigned Builtin = E->getBuiltinCallee();
   return (Builtin == Builtin::BI__builtin___CFStringMakeConstantString ||
   Builtin == Builtin::BI__builtin___NSStringMakeConstantString ||
@@ -2006,7 +2006,7 @@
   case Expr::ObjCBoxedExprClass:
 return cast(E)->isExpressibleAsConstantInitializer();
   case Expr::CallExprClass:
-return IsConstantCall(cast(E));
+return IsNoOpCall(cast(E));
   // For GCC compatibility, &&label has static storage duration.
   case Expr::AddrLabelExprClass:
 return true;
@@ -7405,6 +7405,12 @@
 
   bool ZeroInitialization(const Expr *E) { return Error(E); }
 
+  bool IsConstantEvaluatedBuiltinCall(const CallExpr *E) {
+unsigned BuiltinOp = E->getBuiltinCallee();
+return BuiltinOp != 0 &&
+   Info.Ctx.BuiltinInfo.isConstantEvaluated(BuiltinOp);
+  }
+
 public:
   ExprEvaluatorBase(EvalInfo &Info) : Info(Info) {}
 
@@ -8317,7 +8323,12 @@
 }
 
 bool LValueExprEvaluator::VisitCallExpr(const CallExpr *E) {
+  if (!IsConstantEvaluatedBuiltinCall(E))
+return ExprEvaluatorBaseTy::VisitCallExpr(E);
+
   switch (E->getBuiltin

[PATCH] D136440: [clang] Do not hide base member using-decls with different template head.

2022-10-21 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 469552.
usaxena95 added a comment.

Added more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136440

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/SemaTemplate/concepts-using-decl.cpp

Index: clang/test/SemaTemplate/concepts-using-decl.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-using-decl.cpp
@@ -0,0 +1,114 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+namespace heads_without_concepts {
+struct base {
+  template 
+  int foo() { return 1; };
+};
+
+struct bar : public base {
+  using base::foo;
+  template  
+  int foo() { return 2; };
+};
+
+void func() {
+  bar f;
+  f.foo<10>();
+  f.foo<10, 10>();
+}
+}
+
+namespace static_methods {
+template concept False = false;
+
+struct Base {
+static void foo(auto);
+};
+struct Derived : public Base {
+using Base::foo;
+static void foo(False auto);
+};
+void func() {
+Derived::foo(42);
+}
+}
+
+namespace members_not_hidden {
+template  struct Opaque {};
+template  void expect(Opaque _) {}
+
+struct Empty{};
+constexpr int EmptySize = sizeof(Empty);
+
+template concept IsEmpty = sizeof(T) == EmptySize;
+
+namespace base_members_not_hidden {
+struct base {
+  template 
+  Opaque<0> foo() { return Opaque<0>(); };
+};
+
+struct bar1 : public base {
+  using base::foo;
+  template  requires IsEmpty 
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+
+struct bar2 : public base {
+  using base::foo;
+  template 
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+
+struct bar3 : public base {
+  using base::foo;
+  template 
+  Opaque<1> foo() requires IsEmpty { return Opaque<1>(); };
+};
+
+void func() {
+  expect<0>(base{}.foo());
+  expect<0>(base{}.foo());
+  expect<1>(bar1{}.foo());
+  expect<0>(bar1{}.foo());
+  expect<1>(bar2{}.foo());
+  expect<0>(bar2{}.foo());
+  expect<1>(bar3{}.foo());
+  expect<0>(bar3{}.foo());
+}
+}
+namespace base_members_hidden {
+struct base1 {
+  template  requires IsEmpty
+  Opaque<0> foo() { return Opaque<0>(); }; // expected-note {{candidate function [with T = members_not_hidden::Empty]}}
+};
+struct bar1 : public base1 {
+  using base1::foo;
+  template  requires IsEmpty
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+struct base2 {
+  template 
+  Opaque<0> foo() { return Opaque<0>(); };
+};
+struct bar2 : public base2 {
+  using base2::foo;
+  template 
+  Opaque<1> foo() { return Opaque<1>(); };
+};
+struct baz : public base1 {
+  using base1::foo;
+  template  requires IsEmpty && IsEmpty
+  Opaque<1> foo() { return Opaque<1>(); };  // expected-note {{candidate function [with T = members_not_hidden::Empty]}}
+};
+void func() { 
+  expect<0>(base1{}.foo());
+  expect<1>(bar1{}.foo());
+  expect<0>(base2{}.foo());
+  expect<1>(bar2{}.foo());
+  // FIXME: Candidates from using-decls should be dropped in case of ambiguity.
+  expect<1>(baz{}.foo()); // expected-error {{call to member function 'foo' is ambiguous}}
+}
+}
+}
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -719,11 +719,11 @@
 using A::g;
 using A::h;
 int &f(int);
-template int &g(int); // expected-note {{candidate}}
+template int &g(int);
 int &h();
   } b;
   int &w = b.f(0);
-  int &x = b.g(0); // expected-error {{no match}}
+  int &x = b.g(0); // expected-error {{non-const lvalue reference to type 'int' cannot bind to a temporary of type 'void'}}
   int &y = b.h();
   float &z = const_cast(b).h();
 
Index: clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
===
--- clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
+++ clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p12.cpp
@@ -9,7 +9,7 @@
 //   parameter types in a base class (rather than conflicting).
 
 template  struct Opaque {};
-template  void expect(Opaque _) {} // expected-note 4 {{candidate function template not viable}}
+template  void expect(Opaque _) {}
 
 // PR5727
 // This just shouldn't crash.
@@ -113,35 +113,35 @@
 
   struct Derived1 : Base {
 using Base::foo;
-template  Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
+template  Opaque<2> foo() { return Opaque<2>(); }
   };
 
   struct Derived2 : Base {
-template  Opaque<2> foo() { return Opaque<2>(); } // expected-note {{invalid explicitly-specified argument for template parameter 'n'}}
+template  Opaque<2> foo() { return Opaque<2>(); }
 using Base::foo;
   };
 
   struct Derived3 : Base {
 using Base::foo;
-template  Opaque<3> foo() { return Opaque<3>(); } // expected-note

[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Jan Kasper via Phabricator via cfe-commits
DerKasper added a comment.

In D136424#3873635 , @sylvestre.ledru 
wrote:

> Thanks for carrying about the doc!

I am so happy about the functionality of clang and all the tools around, that 
this is a nice form of giving back something.

I am not sure, what i have to do now, after this was accepted? 
In the documentation i find: 
"If you do not have commit access, please let people know during the review and 
someone should commit it on your behalf."

> I strongly believe i have no commit access but forgot to mention that in the 
> review.
==


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

np, let me land this for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D136424#3874180 , @DerKasper wrote:

> I am not sure, what i have to do now, after this was accepted? 
> In the documentation i find: 
> "If you do not have commit access, please let people know during the review 
> and someone should commit it on your behalf."
>
>> I strongly believe i have no commit access but forgot to mention that in the 
>> review.
> ==

Thanks for letting us know! What name and email address would you like us to 
use for patch attribution when we land the patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[clang-tools-extra] b814d85 - Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2022-10-21T13:55:44+02:00
New Revision: b814d85e5b9d8acd146cef59141b2764107b3df9

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

LOG: Update links to googletest documentation

Update links to googletest documentation
No automatic tests, but local manual test: i click it, it opens the googletest 
documentation.

Reviewed By: sylvestre.ledru

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h

clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h 
b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
index 53bfb737cb01a..b1f597a40a97c 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ b/clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@ namespace google {
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.html

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
index 75b1a9ab5c73f..f2053b4d2fcd3 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
@@ -30,5 +30,5 @@ still checked.
 
 This check does not propose any fixes.
 
-.. _Underscores are not allowed: 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
-.. _disable individual tests: 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _Underscores are not allowed: 
https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _disable individual tests: 
https://google.github.io/googletest/advanced.html#temporarily-disabling-tests



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


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb814d85e5b9d: Update links to googletest documentation 
(authored by sylvestre.ledru).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

Files:
  clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst


Index: 
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
===
--- 
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
+++ 
clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
@@ -30,5 +30,5 @@
 
 This check does not propose any fixes.
 
-.. _Underscores are not allowed: 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
-.. _disable individual tests: 
https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _Underscores are not allowed: 
https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _disable individual tests: 
https://google.github.io/googletest/advanced.html#temporarily-disabling-tests
Index: 
clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
===
--- clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// 
https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// 
https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.html


Index: clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
+++ clang-tools-extra/docs/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.rst
@@ -30,5 +30,5 @@
 
 This check does not propose any fixes.
 
-.. _Underscores are not allowed: https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
-.. _disable individual tests: https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _Underscores are not allowed: https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
+.. _disable individual tests: https://google.github.io/googletest/advanced.html#temporarily-disabling-tests
Index: clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
===
--- clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
+++ clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h
@@ -17,7 +17,7 @@
 namespace readability {
 
 // Check for underscores in the names of googletest tests, per
-// https://github.com/google/googletest/blob/master/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
+// https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/google/readability-avoid-underscore-in-googletest-name.html
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

pushed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

oh, crappy, i forgot to update the author of the patch  :(
really sorry about that... :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[PATCH] D136080: [flang] Add -ffp-contract option processing

2022-10-21 Thread Tom Eccles via Phabricator via cfe-commits
tblah added inline comments.



Comment at: flang/include/flang/Frontend/LangOptions.h:29
+
+// Enable the floating point pragma
+FPM_On,

vzakhari wrote:
> tblah wrote:
> > vzakhari wrote:
> > > tblah wrote:
> > > > awarzynski wrote:
> > > > > What are these pragmas? Perhaps you can add a test that would include 
> > > > > them?
> > > > I copied this comment from clang. I believe the pragma is 
> > > > ```
> > > > #pragma clang fp contract(fast)
> > > > ```
> > > > 
> > > > See 
> > > > https://clang.llvm.org/docs/LanguageExtensions.html#extensions-to-specify-floating-point-flags
> > > > 
> > > > This patch only adds support for argument processing, so I can't test 
> > > > for the pragmas.
> > > I do not think we should blindly copy this from clang.  I believe 
> > > `-ffp-contract=on`  is there to do the contraction complying to the 
> > > language standard - but Fortran standard says nothing about contraction.  
> > > I am also not aware about a Fortran compiler that supports directives 
> > > related to contraction, so `fast-honor-pragmas` does not seem to be 
> > > applicable as well.  Basically, we end up with just `off` and `fast`.
> > > 
> > > Now, it may be reasonable to support the same `-ffp-contract=` arguments 
> > > so that users can apply the same options sets for C/C++ and Fortran 
> > > compilations.  If we want to do this, we need to map `on` and 
> > > `fast-honor-pragmas` to something, e.g. `fast`.  A driver warning (not an 
> > > error) may be useful to make the option's behavior clear when `on` and 
> > > `fast-honor-pragmas` are passed.
> > From the clang help text:
> > ```
> > Form fused FP ops (e.g. FMAs):
> > fast (fuses across statements disregarding pragmas)
> > | on (only fuses in the same statement unless dictated by pragmas)
> > | off (never fuses)
> > Default is 'on'
> > ```
> > 
> > So if we removed `on` and set the default to `off` we would no longer fuse 
> > within the same statement by default.
> > 
> > Classic-flang seems to support `on`, `off` and `fast`: 
> > https://github.com/flang-compiler/flang/blob/master/test/llvm_ir_correct/fma.f90
> Not talking about defaults just yet, I think Flang cannot currently support 
> the `on` mode as documented.
> 
> I do not have the latest classic flang readily availalbe, but I am curious 
> what it will generate for this example:
> ```
> function fn(x,y,z)
>   real :: x,y,z
>   fn = x * y
>   fn = fn + z
> end function
> ```
> 
> With a very old classic flang I get just `fast` math flags on the multiple 
> and add instructions, which is obviously not what `on` is supposed to do:
> ```
> $ flang -target aarch64-linux-gnu -O1 -c -S -emit-llvm -ffp-contract=on 
> fma.f90
> $ cat fma.ll
>   %4 = fmul fast float %3, %1, !dbg !10
>   %5 = bitcast i64* %z to float*, !dbg !11
>   %6 = load float, float* %5, align 4, !dbg !11
>   %7 = fadd fast float %6, %4, !dbg !11
> ```
> 
> Maybe the latest classic flang does support it properly, e.g. it only 
> contracts operations from the same statement.  But I do not see a way to 
> support this in Flang right now, so documenting the `on` mode as it is in 
> clang seems confusing.
> 
> We can still support `on` in the Flang option, but I think we need to issue a 
> warning saying that it defaults to something else, e.g. to `fast`.  If 
> mapping `on` to `fast` is not appropriate to some users, then they will have 
> to explicitly specify `-ffp-contract=off` for Fortran compilations in their 
> build system.
> 
> I am also curious what `fuses in the same statement` means for Fortran.  For 
> example:
> ```
>   x1 = DOT_PRODUCT(x2, x3)+x4*x5+x6
> ```
> 
> If Fortran processor decides to implement `DOT_PRODUCT` as inline 
> multiply+add loop, does `-ffp-contract=on` apply to them or it only applies 
> to `x4*x5+x6`?
Thanks for your feedback.

I've updated my patch. Now flang only supports `off` and `fast`. The other two 
map to `fast` and we default to `off`.

gfortran seems to default to `fast`:
```
-ffp-contract=style

-ffp-contract=off disables floating-point expression contraction. 
-ffp-contract=fast enables floating-point expression contraction such as 
forming of fused multiply-add operations if the target has native support for 
them. -ffp-contract=on enables floating-point expression contraction if allowed 
by the language standard. This is currently not implemented and treated equal 
to -ffp-contract=off.

The default is -ffp-contract=fast.
```

https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html



Comment at: flang/test/Driver/driver-help-hidden.f90:34
 ! CHECK-NEXT: Use  as character line width in fixed mode
+! CHECK-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast (fuses 
across statements disregarding pragmas) | on (only fuses in the same statement 
unless dictated by pragmas) | off (never fuses) | fast-honor-pragmas (fuses 
across statements unless diectated by pragmas). Default is 'fast' for CUDA, 
'fast-ho

[PATCH] D136080: [flang] Add -ffp-contract option processing

2022-10-21 Thread Tom Eccles via Phabricator via cfe-commits
tblah updated this revision to Diff 469556.

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

https://reviews.llvm.org/D136080

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/LangOptions.def
  flang/include/flang/Frontend/LangOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/LangOptions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/flang_f_opts.f90
  flang/test/Driver/flang_fp_opts.f90
  flang/test/Driver/frontend-forwarding.f90

Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -8,6 +8,7 @@
 ! RUN: -fdefault-real-8 \
 ! RUN: -flarge-sizes \
 ! RUN: -fconvert=little-endian \
+! RUN: -ffp-contract=fast \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -18,5 +19,6 @@
 ! CHECK: "-fdefault-integer-8"
 ! CHECK: "-fdefault-real-8"
 ! CHECK: "-flarge-sizes"
+! CHECK: "-ffp-contract=fast"
 ! CHECK: "-fconvert=little-endian"
 ! CHECK:  "-mllvm" "-print-before-all"
Index: flang/test/Driver/flang_fp_opts.f90
===
--- /dev/null
+++ flang/test/Driver/flang_fp_opts.f90
@@ -0,0 +1,4 @@
+! Test for handling of floating point options within the frontend driver
+
+! RUN: %flang_fc1 -ffp-contract=fast %s 2>&1 | FileCheck %s
+! CHECK: ffp-contract= is not currently implemented
Index: flang/test/Driver/flang_f_opts.f90
===
--- flang/test/Driver/flang_f_opts.f90
+++ flang/test/Driver/flang_f_opts.f90
@@ -1,8 +1,10 @@
 ! Test for warnings generated when parsing driver options. You can use this file for relatively small tests and to avoid creating
 ! new test files.
 
-! RUN: %flang -### -S -O4 %s 2>&1 | FileCheck %s
+! RUN: %flang -### -S -O4 -ffp-contract=on %s 2>&1 | FileCheck %s
 
+! CHECK: warning: the argument 'on' is not supported for option 'ffp-contract='. Mapping to 'ffp-contract=fast'
 ! CHECK: warning: -O4 is equivalent to -O3
 ! CHECK-LABEL: "-fc1"
+! CHECK: -ffp-contract=fast
 ! CHECK: -O3
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -31,6 +31,7 @@
 ! HELP-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-NEXT: -ffixed-line-length=
 ! HELP-NEXT: Use  as character line width in fixed mode
+! HELP-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast | off (clang, flang), on | fast-honor-pragmas (clang only)
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
@@ -105,6 +106,7 @@
 ! HELP-FC1-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-FC1-NEXT: -ffixed-line-length=
 ! HELP-FC1-NEXT: Use  as character line width in fixed mode
+! HELP-FC1-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast | off (clang, flang), on | fast-honor-pragmas (clang only)
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fget-definition   
 ! HELP-FC1-NEXT:Get the symbol definition from   
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -31,6 +31,7 @@
 ! CHECK-NEXT: -ffixed-form   Process source files in fixed form
 ! CHECK-NEXT: -ffixed-line-length=
 ! CHECK-NEXT: Use  as character line width in fixed mode
+! CHECK-NEXT: -ffp-contract= Form fused FP ops (e.g. FMAs): fast | off (clang, flang), on | fast-honor-pragmas (clang only)
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
Index: flang/lib/Frontend/LangOptions.cpp
===
--- /dev/null
+++ flang/lib/Frontend/LangOptions.cpp
@@ -0,0 +1,24 @@
+//===-- LangOptions.cpp ---===//
+//
+// 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
+//
+//===--

[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D136424#3874196 , @sylvestre.ledru 
wrote:

> oh, crappy, i forgot to update the author of the patch  :(
> really sorry about that... :(

No worries, it happens (I've made the same mistake a few times as well)! If 
@DerKasper would appreciate the attribution, they can ask and we can revert and 
re-land.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[PATCH] D136424: Update links to googletest documentation

2022-10-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

yeah, happy to do that if the author wants :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136424

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


[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:612
+  case PT_Float:
+assert(false);
   }

I left the implementation of this out since `visitZeroInitializer()` is dead 
code right now anyway and the patch is already large enough.


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

https://reviews.llvm.org/D134859

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


[PATCH] D136416: [AST] Support Bool type in va_arg

2022-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> Currently, if the second argument is "Bool", it will be casted to "int".

That behavior is required by the standard, which is why we give a warning about 
it being undefined behavior due to the promotion. For C, see C2x 7.16.1.1p2 
("If //type// is not compatible with the type of the actual next argument (as 
promoted according to the default argument promotions), the behavior is 
undefined, except for the following cases: ..." and none of the cases apply to 
bool.) and for C++, see https://eel.is/c++draft/cstdarg.syn#1.sentence-4 which 
says the same thing in different words.

You'll see the same kind of UB if you try to use `short` instead of `bool`: 
https://godbolt.org/z/Kz95vbaY4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136416

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


[PATCH] D136355: [clang][Sema] Fix caret position to be on the non null parameter

2022-10-21 Thread Arthur Grillo Queiroz Cabral via Phabricator via cfe-commits
Grillo updated this revision to Diff 469559.
Grillo added a comment.

Add test coverage and release note about the fix to 
`clang/docs/ReleaseNotes.rst`


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

https://reviews.llvm.org/D136355

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/non-null-warning.c


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+   return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -321,6 +321,9 @@
   on the previous undocumented behavior. As a side effect of this change,
   constructor calls outside of initializer expressions are no longer ignored,
   which can result in new warnings (or make existing warnings disappear).
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 
`_.
 
 Non-comprehensive list of changes in this release
 -


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+	return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -321,6 +321,9 @@
   on the previous undocumented behavior. As a side effect of this change,
   constructor calls outside of initializer expressions are no longer ignored,
   which can result in new warnings (or make existing warnings disappear).
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 `_.
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136343: [Lex] Add compatibility with MSVC

2022-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D136343#3873284 , @Qfrost911 wrote:

> I understand you mean, but I can't get function name at macro expedition 
> stage.

Correct! We have a `PredefinedExpr` AST node type 
(https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/Expr.h#L1968)
 to handle this, and it seems we already support `__FUNCTION__` (and friends): 
https://godbolt.org/z/cEWh1Prnx. However, we're matching the GCC behavior for 
printing a member function name instead of following the MSVC behavior when in 
`-fms-compatibility` mode, which we might want to consider changing.

The reason your code example in the summary doesn't compile is because a 
`PredefinedExpr` is not a string literal, so there is no way to do string 
concatenation with an adjacent literal. MSVC implements these as actual macros 
that expand to a string literal, which is not a behavior Clang can easily match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136343

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


[PATCH] D136416: [AST] Support Bool type in va_arg

2022-10-21 Thread Qfrost via Phabricator via cfe-commits
Qfrost911 abandoned this revision.
Qfrost911 added a comment.

I see, thank you very much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136416

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


[PATCH] D136416: [AST] Support Bool type in va_arg

2022-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D136416#3874308 , @Qfrost911 wrote:

> I see, thank you very much.

Thank you for trying to improve things in Clang! Even if this wasn't the right 
approach, the effort is still appreciated. :-) BTW, we have been trying to tag 
issues in GitHub with the "good first issue" label if we think it's a good way 
to get introduced to the code base. If you're looking for a way to help 
contribute small fixes to Clang. You can see the list here: 
https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136416

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


[PATCH] D136343: [Lex] Add compatibility with MSVC

2022-10-21 Thread Qfrost via Phabricator via cfe-commits
Qfrost911 added a comment.

I understand you mean. I think I can try to solve this problem, if I have 
enough time.

Thank you very much for your response.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136343

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-10-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:513-534
+  llvm::Optional MLTAL =
+  SetupConstraintCheckingTemplateArgumentsAndScope(
+  const_cast(FD), {}, Scope);
+
   Qualifiers ThisQuals;
   CXXRecordDecl *Record = nullptr;
   if (auto *Method = dyn_cast(FD)) {

mizvekov wrote:
> mizvekov wrote:
> > Unchecked access to MLTAL (Optional).
> > 
> > Following reduction reproduces a crash here: `-cc1 -std=c++20 -fsyntax-only 
> > -ferror-limit 19`.
> > ```
> > template a b < ;
> > template c e ag < ;
> > ah) ;
> > am = ;
> > template  class aq {
> >   aq(ap...; __attribute__) auto aj() requires(am)
> > }
> > f() {  [;  aq d;  d.aj
> > ```
> By the way, disregard that repro, it needs another patch that is not in 
> master.
> 
> The unchecked access still does look suspicious though.
Thanks for the comment!  I'll look into it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[clang-tools-extra] 8b36687 - [clangd] Add highlighting modifier "constructorOrDestructor"

2022-10-21 Thread Christian Kandeler via cfe-commits

Author: Christian Kandeler
Date: 2022-10-21T15:14:38+02:00
New Revision: 8b3668754c889a9412a76035235b6fc581ca9863

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

LOG: [clangd] Add highlighting modifier "constructorOrDestructor"

This is useful for clients that want to highlight constructors and
destructors different from classes, e.g. like functions.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 1a6fa528acced..08cca2203667b 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -649,6 +649,29 @@ class CollectExtraHighlightings
 return true;
   }
 
+  bool VisitCXXDestructorDecl(CXXDestructorDecl *D) {
+if (auto *TI = D->getNameInfo().getNamedTypeInfo()) {
+  SourceLocation Loc = TI->getTypeLoc().getBeginLoc();
+  H.addExtraModifier(Loc, HighlightingModifier::ConstructorOrDestructor);
+  H.addExtraModifier(Loc, HighlightingModifier::Declaration);
+  if (D->isThisDeclarationADefinition())
+H.addExtraModifier(Loc, HighlightingModifier::Definition);
+}
+return true;
+  }
+
+  bool VisitCXXMemberCallExpr(CXXMemberCallExpr *CE) {
+if (isa(CE->getMethodDecl())) {
+  if (auto *ME = dyn_cast(CE->getCallee())) {
+if (auto *TI = ME->getMemberNameInfo().getNamedTypeInfo()) {
+  H.addExtraModifier(TI->getTypeLoc().getBeginLoc(),
+ HighlightingModifier::ConstructorOrDestructor);
+}
+  }
+}
+return true;
+  }
+
   bool VisitDeclaratorDecl(DeclaratorDecl *D) {
 auto *AT = D->getType()->getContainedAutoType();
 if (!AT)
@@ -879,6 +902,8 @@ std::vector 
getSemanticHighlightings(ParsedAST &AST) {
 Tok.addModifier(HighlightingModifier::DefaultLibrary);
   if (Decl->isDeprecated())
 Tok.addModifier(HighlightingModifier::Deprecated);
+  if (isa(Decl))
+Tok.addModifier(HighlightingModifier::ConstructorOrDestructor);
   if (R.IsDecl) {
 // Do not treat an UnresolvedUsingValueDecl as a declaration.
 // It's more common to think of it as a reference to the
@@ -960,6 +985,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, 
HighlightingModifier K) {
 return OS << "decl"; // abbreviation for common case
   case HighlightingModifier::Definition:
 return OS << "def"; // abbrevation for common case
+  case HighlightingModifier::ConstructorOrDestructor:
+return OS << "constrDestr";
   default:
 return OS << toSemanticTokenModifier(K);
   }
@@ -,6 +1138,8 @@ llvm::StringRef 
toSemanticTokenModifier(HighlightingModifier Modifier) {
 return "defaultLibrary";
   case HighlightingModifier::UsedAsMutableReference:
 return "usedAsMutableReference"; // nonstandard
+  case HighlightingModifier::ConstructorOrDestructor:
+return "constructorOrDestructor"; // nonstandard
   case HighlightingModifier::FunctionScope:
 return "functionScope"; // nonstandard
   case HighlightingModifier::ClassScope:

diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.h 
b/clang-tools-extra/clangd/SemanticHighlighting.h
index 4fe2fc7aee54d..79ecb344275d1 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.h
+++ b/clang-tools-extra/clangd/SemanticHighlighting.h
@@ -71,6 +71,7 @@ enum class HighlightingModifier {
   DependentName,
   DefaultLibrary,
   UsedAsMutableReference,
+  ConstructorOrDestructor,
 
   FunctionScope,
   ClassScope,

diff  --git a/clang-tools-extra/clangd/test/initialize-params.test 
b/clang-tools-extra/clangd/test/initialize-params.test
index 031be9e147f74..eb958cac20279 100644
--- a/clang-tools-extra/clangd/test/initialize-params.test
+++ b/clang-tools-extra/clangd/test/initialize-params.test
@@ -68,6 +68,7 @@
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"usedAsMutableReference",
+# CHECK-NEXT:"constructorOrDestructor",
 # CHECK-NEXT:"functionScope",
 # CHECK-NEXT:"classScope",
 # CHECK-NEXT:"fileScope",

diff  --git a/clang-tools-extra/clangd/test/semantic-tokens.test 
b/clang-tools-extra/clangd/test/semantic-tokens.test
index b85d720ff5137..5abe78e9a51e1 100644
--- a/clang-tools-extra/clangd/test/semantic-tokens

[PATCH] D134728: [clangd] Add highlighting modifier "constructorOrDestructor"

2022-10-21 Thread Christian Kandeler via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b3668754c88: [clangd] Add highlighting modifier 
"constructorOrDestructor" (authored by ckandeler).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134728

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -142,16 +142,16 @@
   $Namespace[[abc]]::$Class[[A]] $Variable_def[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]] $Class_decl[[AAA]];
   struct $Class_def[[B]] {
-$Class_decl[[B]]();
-~$Class[[B]](); // FIXME: inconsistent with constructor
+$Class_decl_constrDestr[[B]]();
+~$Class_decl_constrDestr[[B]]();
 void operator<<($Class[[B]]);
 $Class[[AAA]] $Field_decl[[AA]];
   };
-  $Class[[B]]::$Class_def[[B]]() {}
-  $Class[[B]]::~$Class[[B]]() {} // FIXME: inconsistent with constructor
+  $Class[[B]]::$Class_def_constrDestr[[B]]() {}
+  $Class[[B]]::~$Class_def_constrDestr[[B]]() {}
   void $Function_def[[f]] () {
 $Class[[B]] $LocalVariable_def[[BB]] = $Class[[B]]();
-$LocalVariable[[BB]].~$Class[[B]]();
+$LocalVariable[[BB]].~$Class_constrDestr[[B]]();
 $Class[[B]]();
   }
 )cpp",
@@ -310,13 +310,13 @@
 $Class[[Foo]] $Field_decl[[Fo]];
 $Enum[[En]] $Field_decl[[E]];
 int $Field_decl[[I]];
-$Class_def[[Bar]] ($Class[[Foo]] $Parameter_def[[F]],
+$Class_def_constrDestr[[Bar]] ($Class[[Foo]] $Parameter_def[[F]],
 $Enum[[En]] $Parameter_def[[E]])
 : $Field[[Fo]] ($Parameter[[F]]), $Field[[E]] ($Parameter[[E]]),
   $Field[[I]] (123) {}
   };
   class $Class_def[[Bar2]] : public $Class[[Bar]] {
-$Class_def[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant_readonly[[EC]]) {}
+$Class_def_constrDestr[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant_readonly[[EC]]) {}
   };
 )cpp",
   R"cpp(
@@ -757,7 +757,7 @@
 static inline int $StaticField_def_static[[j]] = 0;
 };
 struct $Class_def[[ClassWithRefMembers]] {
-  $Class_def[[ClassWithRefMembers]](int $Parameter_def[[i]])
+  $Class_def_constrDestr[[ClassWithRefMembers]](int $Parameter_def[[i]])
 : $Field[[i1]]($Parameter[[i]]),
   $Field_readonly[[i2]]($Parameter[[i]]),
   $Field[[i3]]($Parameter_usedAsMutableReference[[i]]),
@@ -803,7 +803,7 @@
   $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_def[[S]] {
-  $Class_def[[S]](int&) {
+  $Class_def_constrDestr[[S]](int&) {
 $Class[[S]] $LocalVariable_def[[s1]]($Field_usedAsMutableReference[[field]]);
 $Class[[S]] $LocalVariable_def[[s2]]($LocalVariable[[s1]].$Field_usedAsMutableReference[[field]]);
 
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387
+# CHECK-NEXT:  32771
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387
+# CHECK-NEXT:  32771
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387,
+# CHECK-NEXT:  32771,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  16387
+# CHECK-NEXT:  32771
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -68,6 +68,7 @@
 # CHECK-NEXT:"dependentName",
 # CHECK-NEXT:"defaultLibrary",
 # CHECK-NEXT:"usedAsMutableReference",
+# CHECK-NEXT:"constructorOrDestructor",
 # CHECK-NEXT:"f

[clang] 3770d2b - [X86] Fix typo of mtamx_int8

2022-10-21 Thread via cfe-commits

Author: Luo, Yuanke
Date: 2022-10-21T21:13:07+08:00
New Revision: 3770d2b9cad91e32f33c7cd51c8517e619438218

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

LOG: [X86] Fix typo of mtamx_int8

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3f975d7dd4fd1..0819ab51c922d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4522,7 +4522,7 @@ def m3dnowa : Flag<["-"], "m3dnowa">, 
Group;
 def mno_3dnowa : Flag<["-"], "mno-3dnowa">, Group;
 def mamx_bf16 : Flag<["-"], "mamx-bf16">, Group;
 def mno_amx_bf16 : Flag<["-"], "mno-amx-bf16">, Group;
-def mtamx_int8 : Flag<["-"], "mamx-int8">, Group;
+def mamx_int8 : Flag<["-"], "mamx-int8">, Group;
 def mno_amx_int8 : Flag<["-"], "mno-amx-int8">, Group;
 def mamx_tile : Flag<["-"], "mamx-tile">, Group;
 def mno_amx_tile : Flag<["-"], "mno-amx-tile">, Group;



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


[PATCH] D136355: [clang][Sema] Fix caret position to be on the non null parameter

2022-10-21 Thread Arthur Grillo Queiroz Cabral via Phabricator via cfe-commits
Grillo updated this revision to Diff 469571.

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

https://reviews.llvm.org/D136355

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/non-null-warning.c


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+   return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -325,6 +325,9 @@
   pointers is improved to include the type of the array and whether it's cast
   to another type. This should improve comprehension for why an index is
   out-of-bounds.
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 
`_.
 
 Non-comprehensive list of changes in this release
 -


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+	return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -325,6 +325,9 @@
   pointers is improved to include the type of the array and whether it's cast
   to another type. This should improve comprehension for why an index is
   out-of-bounds.
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 `_.
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

In D136284#3869306 , @nlopes wrote:

>> However, multiple loads of the same memory must be equal
>
> This premise is incorrect w.r.t. with current semantics, which say that loads 
> return undef for uninit memory.
>
> As Nikita mentioned we are working towards changing this semantics. The work 
> is ongoing, but we pivoted to make a couple of improvements in other areas to 
> avoid perf regressions. For example, see the clang !noundef patches.

This is a C/C++ language semantics statement.  Yes, I realize that LLVM is not 
language specific, but this is what is generated for this, and also, what 
freeze appears specifically designed to handle.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D136090: Handle errors in expansion of response files

2022-10-21 Thread Diana Picus via Phabricator via cfe-commits
rovka added inline comments.



Comment at: clang/test/Driver/config-file-errs.c:16
 // RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck 
%s -check-prefix CHECK-NONEXISTENT
-// CHECK-NONEXISTENT: configuration file 
'{{.*}}somewhere/nonexistent-config-file' does not exist
+// CHECK-NONEXISTENT: configuration file 
'{{.*}}somewhere/nonexistent-config-file' cannot be opened: No such file or 
directory
 

I think you might need to use the same trick as [[ 
https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/output-paths.f90
 | this test ]]  to get the test to pass on both Windows and Linux (since they 
use different capitalization).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136090

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


[PATCH] D134588: [clang-tidy] Fix bugprone-exception-escape warn on noexcept calls

2022-10-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Will be good idea to mention changes in Release Notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134588

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


[PATCH] D136012: [clang][Interp] Fix record members of reference type

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 469580.

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

https://reviews.llvm.org/D136012

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/references.cpp


Index: clang/test/AST/Interp/references.cpp
===
--- clang/test/AST/Interp/references.cpp
+++ clang/test/AST/Interp/references.cpp
@@ -88,3 +88,29 @@
   return j;
 }
 static_assert(RefToMemberExpr() == 11, "");
+
+struct Ref {
+  int &a;
+};
+
+constexpr int RecordWithRef() {
+  int m = 100;
+  Ref r{m};
+  m = 200;
+  return r.a;
+}
+static_assert(RecordWithRef() == 200, "");
+
+
+struct Ref2 {
+  int &a;
+  constexpr Ref2(int &a) : a(a) {}
+};
+
+constexpr int RecordWithRef2() {
+  int m = 100;
+  Ref2 r(m);
+  m = 200;
+  return r.a;
+}
+static_assert(RecordWithRef2() == 200, "");
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -483,6 +483,8 @@
   return true;
 }
 
+/// 1) Peeks a pointer on the stack
+/// 2) Pushes the value of the pointer's field on the stack
 template ::T>
 bool GetField(InterpState &S, CodePtr OpPC, uint32_t I) {
   const Pointer &Obj = S.Stk.peek();
@@ -512,6 +514,8 @@
   return true;
 }
 
+/// 1) Pops a pointer from the stack
+/// 2) Pushes the value of the pointer's field on the stack
 template ::T>
 bool GetFieldPop(InterpState &S, CodePtr OpPC, uint32_t I) {
   const Pointer &Obj = S.Stk.pop();
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -104,7 +104,7 @@
   if (const FieldDecl *Member = Init->getMember()) {
 const Record::Field *F = R->getField(Member);
 
-if (Optional T = this->classify(InitExpr->getType())) {
+if (Optional T = this->classify(InitExpr)) {
   if (!this->emitThis(InitExpr))
 return false;
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -392,6 +392,8 @@
 const Record *R = getRecord(RD);
 const Record::Field *F = R->getField(FD);
 // Leave a pointer to the field on the stack.
+if (F->Decl->getType()->isReferenceType())
+  return this->emitGetFieldPop(PT_Ptr, F->Offset, E);
 return this->emitGetPtrField(F->Offset, E);
   }
 
@@ -862,7 +864,7 @@
   if (!this->emitDupPtr(Initializer))
 return false;
 
-  if (Optional T = classify(Init->getType())) {
+  if (Optional T = classify(Init)) {
 if (!this->visit(Init))
   return false;
 


Index: clang/test/AST/Interp/references.cpp
===
--- clang/test/AST/Interp/references.cpp
+++ clang/test/AST/Interp/references.cpp
@@ -88,3 +88,29 @@
   return j;
 }
 static_assert(RefToMemberExpr() == 11, "");
+
+struct Ref {
+  int &a;
+};
+
+constexpr int RecordWithRef() {
+  int m = 100;
+  Ref r{m};
+  m = 200;
+  return r.a;
+}
+static_assert(RecordWithRef() == 200, "");
+
+
+struct Ref2 {
+  int &a;
+  constexpr Ref2(int &a) : a(a) {}
+};
+
+constexpr int RecordWithRef2() {
+  int m = 100;
+  Ref2 r(m);
+  m = 200;
+  return r.a;
+}
+static_assert(RecordWithRef2() == 200, "");
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -483,6 +483,8 @@
   return true;
 }
 
+/// 1) Peeks a pointer on the stack
+/// 2) Pushes the value of the pointer's field on the stack
 template ::T>
 bool GetField(InterpState &S, CodePtr OpPC, uint32_t I) {
   const Pointer &Obj = S.Stk.peek();
@@ -512,6 +514,8 @@
   return true;
 }
 
+/// 1) Pops a pointer from the stack
+/// 2) Pushes the value of the pointer's field on the stack
 template ::T>
 bool GetFieldPop(InterpState &S, CodePtr OpPC, uint32_t I) {
   const Pointer &Obj = S.Stk.pop();
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -104,7 +104,7 @@
   if (const FieldDecl *Member = Init->getMember()) {
 const Record::Field *F = R->getField(Member);
 
-if (Optional T = this->classify(InitExpr->getType())) {
+if (Optional T = this->classify(InitExpr)) {
   if (!this->emitThis(InitExpr))
 return false;
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/Byt

[PATCH] D136449: [Clang] Implement P2513

2022-10-21 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is applied to C++20 as a defect report.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136449

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/char8_t.cpp
  clang/test/SemaCXX/cxx2a-compat.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1506,7 +1506,7 @@
 
   char8_t Compatibility and Portability Fix
   https://wg21.link/P2513R3";>P2513R3
-  No
+  Clang 16
 
 
   Relax requirements on wchar_t to match existing practices
Index: clang/test/SemaCXX/cxx2a-compat.cpp
===
--- clang/test/SemaCXX/cxx2a-compat.cpp
+++ clang/test/SemaCXX/cxx2a-compat.cpp
@@ -33,9 +33,8 @@
 // expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
 // expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
 #else
-// expected-error@-8 {{ISO C++20 does not permit initialization of char array with UTF-8 string literal}}
-// expected-error@-8 {{cannot initialize a variable of type 'const char *' with an lvalue of type 'const char8_t[6]'}}
-// expected-error@-8 {{no viable conversion from 'const char8_t[9]' to 'string'}}
+// expected-error@-7 {{cannot initialize a variable of type 'const char *' with an lvalue of type 'const char8_t[6]'}}
+// expected-error@-7 {{no viable conversion from 'const char8_t[9]' to 'string'}}
 #endif
 
 template
Index: clang/test/SemaCXX/char8_t.cpp
===
--- clang/test/SemaCXX/char8_t.cpp
+++ clang/test/SemaCXX/char8_t.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fchar8_t -std=c++17 -verify %s
-// RUN: %clang_cc1 -std=c++2a -verify %s
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 -fno-signed-char %s
+
 
 char8_t a = u8'a';
 char8_t b[] = u8"foo";
@@ -10,12 +12,24 @@
 char f[] = u8"foo";
 #if __cplusplus <= 201703L
 // expected-error@-2 {{initialization of char array with UTF-8 string literal is not permitted by '-fchar8_t'}}
-#else
-// expected-error@-4 {{ISO C++20 does not permit initialization of char array with UTF-8 string literal}}
 #endif
 char g = 'a';
 char h[] = "foo";
 
+#if __cplusplus >= 201902L
+unsigned char i[] = u8"foo";
+unsigned char j[] = { u8"foo" };
+char k[] = u8"foo";
+char l[] = { u8"foo" };
+signed char m[] = u8"foo"; // expected-error {{initialization of char array with UTF-8 string literal is not permitted by C++20}}
+signed char n[] = { u8"foo" }; // expected-error {{cannot initialize an array element of type 'signed char' with an lvalue of type 'const char8_t[4]'}}
+
+const unsigned char* uptr = u8"foo"; // expected-error {{cannot initialize}}
+const signed char* sptr = u8"foo"; // expected-error {{cannot initialize}}
+const char* ptr = u8"foo"; // expected-error {{cannot initialize}}
+
+#endif
+
 void disambig() {
   char8_t (a) = u8'x';
 }
@@ -48,3 +62,21 @@
 static_assert(sizeof(char8_t) == 1);
 static_assert(char8_t(-1) > 0);
 static_assert(u8"\u0080"[0] > 0);
+
+namespace ambiguous {
+
+struct A {
+	char8_t s[10];
+};
+struct B {
+  char s[10];
+};
+
+void f(A); // cxx20-note {{candidate}}
+void f(B); // cxx20-note {{candidate}}
+
+int test() {
+  f({u8"foo"}); // cxx20-error {{call to 'f' is ambiguous}}
+}
+
+}
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -46,9 +46,9 @@
 #error "wrong value for __cpp_aggregate_paren_init"
 #endif
 
-#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811, 201811) : \
+#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 202207, 202207) : \
 defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0, 0) : \
-check(char8_t, 0, 0, 0, 0, 201811, 201811)
+check(char8_t, 0, 0, 0, 0, 202207, 202207)
 #error "wrong value for __cpp_char8_t"
 #endif
 
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -81,10 +81,20 @@
   const QualType ElemTy =
   Context.getCanonicalType(AT->getElementType()).getUnqualifiedType();
 
+  auto IsCharOrUnsignedChar = [](const QualType &T) {
+const BuiltinType *BT = dyn_cast(T.getTypePtr());
+return BT && BT->isCharType() && BT->getKind() != BuiltinType::SChar;
+  };
+
   switch (SL->getKi

[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

In D136284#3869216 , @nikic wrote:

> The current behavior here is intentional -- in fact, LLVM will move towards 
> returning poison for loads from uninitialized memory in the future (though 
> precisely how this will happen is still uncertain, see 
> https://discourse.llvm.org/t/rfc-making-bit-field-codegen-poison-compatible/63250
>  for some recent discussion on the topic).

The current behaviour implies that the content of uninitialized memory is 
volatile, which is not correct.  One would still need the freeze to ensure that 
2 loads of the same uninitialized memory are the same, whether this is undef or 
poison.  So this would not affect that future change and would still be 
required.  Besides, are you sure that poison is appropriate here?  Loading 
uninitialized memory is not erroneous; it is undefined.  Comparing the same 
uninitialized memory, however, is defined, hence the freeze.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D136423: [clang][Interp] Implement inc/dec postfix and prefix operators

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 469589.

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

https://reviews.llvm.org/D136423

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/arrays.cpp
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -361,3 +361,52 @@
   constexpr double db = true;
   static_assert(db == 1.0, "");
 };
+
+#if __cplusplus >= 202002L
+namespace IncDec {
+  constexpr int zero() {
+int a = 0;
+a++;
+++a;
+a--;
+--a;
+return a;
+  }
+  static_assert(zero() == 0, "");
+
+  constexpr int three() {
+int a = 0;
+return ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}} \
+  // ref-warning {{multiple unsequenced modifications to 'a'}} \
+
+  }
+  static_assert(three() == 3, "");
+
+  constexpr bool incBool() {
+bool b = false;
+return ++b; // expected-error {{ISO C++17 does not allow incrementing expression of type bool}} \
+// ref-error {{ISO C++17 does not allow incrementing expression of type bool}}
+  }
+  static_assert(incBool(), "");
+
+  constexpr int uninit() {
+int a;
+++a; // ref-note {{increment of uninitialized}} \
+ // FIXME: Should also be rejected by new interpreter
+return 1;
+  }
+  static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'uninit()'}}
+
+  constexpr int OverUnderFlow() { // ref-error {{never produces a constant expression}}
+int a = INT_MAX;
+++a; // ref-note {{is outside the range}}
+// FIXME: Overflow
+
+int b = INT_MIN;
+--b; // FIXME: Underflow
+
+return -1;
+  }
+};
+#endif
Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -180,3 +180,18 @@
  constexpr int x = arr.a[0];
   }
 };
+
+namespace IncDec {
+  // FIXME: Pointer arithmethic needs to be supported in inc/dec
+  //   unary operators
+#if 0
+  constexpr int getNextElem(const int *A, int I) {
+const int *B = (A + I);
+++B;
+return *B;
+  }
+  constexpr int E[] = {1,2,3,4};
+
+  static_assert(getNextElem(E, 1) == 3);
+#endif
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -446,6 +446,11 @@
   let HasGroup = 1;
 }
 
+def Inc: IntegerOpcode;
+def IncPop : IntegerOpcode;
+def Dec: IntegerOpcode;
+def DecPop: IntegerOpcode;
+
 // [Real] -> [Real]
 def Neg: Opcode {
   let Types = [NonPtrTypeClass];
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -328,6 +328,70 @@
   return true;
 }
 
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value increased by one back to the pointer
+/// 4) Pushes the original (pre-inc) value on the stack.
+template ::T>
+bool Inc(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::increment(Value, &Result))
+return false;
+  Ptr.deref() = Result;
+  S.Stk.push(Value);
+  return true;
+}
+
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value increased by one back to the pointer
+template ::T>
+bool IncPop(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::increment(Value, &Result))
+return false;
+  Ptr.deref() = Result;
+  return true;
+}
+
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value decreased by one back to the pointer
+/// 4) Pushes the original (pre-dec) value on the stack.
+template ::T>
+bool Dec(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::decrement(Value, &Result))
+return false;
+  Ptr.deref() = Result;
+  S.Stk.push(Value);
+  return true;
+}
+
+/// 1) Pops a pointer from the stack
+/// 2) Load the value from the pointer
+/// 3) Writes the value decreased by one back to the pointer
+template ::T>
+bool DecPop(InterpState &S, CodePtr OpPC) {
+  // FIXME: Check initialization of Ptr
+  const Pointer &Ptr = S.Stk.pop();
+  T Value = Ptr.deref();
+  T Result;
+  if (T::decrement(Value, &Result))
+return false;
+  Ptr.deref() = Result;
+  return true;
+}
+
 /// 1) Pops

[PATCH] D136450: [clang][ExtractAPI] Allow users to specify a list of symbols to ignore

2022-10-21 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added reviewers: zixuw, QuietMisdreavus.
Herald added a reviewer: ributzka.
Herald added a project: All.
dang requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Adds a `--extract-api-ignores=` command line option that allows users to
provide a file containing a new line separated list of symbols to
unconditionally ignore when extracting API information.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136450

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/ExtractAPI/APIIgnoresList.h
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/ExtractAPI/APIIgnoresList.cpp
  clang/lib/ExtractAPI/CMakeLists.txt
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/Driver/extract-api-unknown-ignore-diag.h
  clang/test/ExtractAPI/ignored-symbols.c

Index: clang/test/ExtractAPI/ignored-symbols.c
===
--- /dev/null
+++ clang/test/ExtractAPI/ignored-symbols.c
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   --extract-api-ignores=%t/ignores-list\
+// RUN:   -x c-header %t/input.h -verify -o - | FileCheck %t/input.h
+
+//--- input.h
+#define IGNORED_1 1
+#define IGNORED_2 2
+#define IGNORED_3 3
+#define IGNORED_4 4
+typedef int Ignored;
+typedef float NonIgnored;
+
+// CHECK-NOT: IGNORED_1
+// CHECK-NOT: IGNORED_2
+// CHECK-NOT: IGNORED_3
+// CHECK: NonIgnored
+
+// expected-no-diagnostics
+
+//--- ignores-list
+Ignored
+IGNORED_4
+IGNORED_3   
+IGNORED_2
+IGNORED_1
Index: clang/test/Driver/extract-api-unknown-ignore-diag.h
===
--- /dev/null
+++ clang/test/Driver/extract-api-unknown-ignore-diag.h
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: not %clang -target x86_64-unknown-unknown -extract-api --extract-api-ignores=does-not-exist %s 2>&1 | FileCheck %s
+
+// CHECK: fatal error: file 'does-not-exist' specified by '--extract-api-ignores=' not found
+
+void dummy_function(void);
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -14,6 +14,7 @@
 #include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"
 #include "clang/Basic/Version.h"
 #include "clang/ExtractAPI/API.h"
+#include "clang/ExtractAPI/APIIgnoresList.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/Path.h"
@@ -480,6 +481,10 @@
 }
 
 bool SymbolGraphSerializer::shouldSkip(const APIRecord &Record) const {
+  // Skip explicitly ignored symbols.
+  if (IgnoresList.shouldIgnore(Record.Name))
+return true;
+
   // Skip unconditionally unavailable symbols
   if (Record.Availabilities.isUnconditionallyUnavailable())
 return true;
Index: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
===
--- clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -20,10 +20,12 @@
 #include "clang/AST/ParentMapContext.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/ExtractAPI/API.h"
+#include "clang/ExtractAPI/APIIgnoresList.h"
 #include "clang/ExtractAPI/AvailabilityInfo.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "clang/ExtractAPI/FrontendActions.h"
@@ -38,6 +40,7 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
@@ -858,6 +861,18 @@
   Policy.AnonymousTagLocations = false;
   CI.getASTContext().setPrintingPolicy(Policy);
 
+  if (!CI.getFrontendOpts().ExtractAPIIgnoresFile.empty()) {
+llvm::handleAllErrors(
+APIIgnoresList::create(CI.getFrontendOpts().ExtractAPIIgnoresFile,
+   CI.getFileManager())
+.moveInto(IgnoresList),
+[&CI](const IgnoresFileNotFound &Err) {
+  CI.getDiagnostics().Report(
+  diag::err_extract_api_ignores_file_not_found)
+  << Err.Path;
+});
+  }
+
 

[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

At least in C++, working with uninitialized memory is pretty much always 
immediate undefined behavior, see https://eel.is/c++draft/basic.indet for the 
relevant wording. The only exception are "copy-like" operations on unsigned 
character types, which comparisons do not fall under.

I believe the C specification is less clear cut about this, but Clang and LLVM 
assume basically the same to also hold for C code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D136451: GH58368: Correct concept checking in a lambda defined in concept

2022-10-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added a reviewer: aaron.ballman.
Herald added a subscriber: arphaman.
Herald added a project: All.
erichkeane requested review of this revision.

As that bug reports, the problem here is that the lambda's
'context-decl' was not set to the concept, and the lambda picked up
template arguments from the concept.  SO, we failed to get the correct
template arguments in SemaTemplateInstantiate.

However, a Concept Specialization is NOT a decl, its an expression, so
we weren't able to put the concept in the decl tree like we needed.
This patch introduces a ConceptSpecializationDecl, which is the smallest
type possible to use for this purpose, containing only the template
arguments.

The net memory impliciation of this is turning a
trailing-objects into a pointer to a type with trailing-objects,  so it
should be minor.

As future work, we may consider giving this type more responsibility, or
figuring out how to better merge duplicates, but as this is just a
template-argument collection at the moment, there isn't much value to
it.


https://reviews.llvm.org/D136451

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/AST/ExprConcepts.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/ExprConcepts.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-concepts.cpp
  clang/test/SemaTemplate/concepts-lambda.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6700,6 +6700,7 @@
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
   case Decl::Concept:
+  case Decl::ConceptSpecialization:
   case Decl::LifetimeExtendedTemporary:
   case Decl::RequiresExprBody:
   case Decl::UnresolvedUsingIfExists:
Index: clang/test/SemaTemplate/concepts-lambda.cpp
===
--- clang/test/SemaTemplate/concepts-lambda.cpp
+++ clang/test/SemaTemplate/concepts-lambda.cpp
@@ -55,3 +55,39 @@
   using function_ptr = void(*)(int);
   function_ptr ptr = f;
 }
+
+// GH58368: A lambda defined in a concept requires we store
+// the concept as a part of the lambda context.
+namespace LambdaInConcept {
+using size_t = unsigned long;
+
+template
+struct IdxSeq{};
+
+template 
+concept NotLike = true;
+
+template 
+struct AnyExcept {
+  template  T> operator T&() const;
+  template  T> operator T&&() const;
+};
+
+template 
+  concept ConstructibleWithN = (requires {
+[]
+(IdxSeq)
+requires requires { T{AnyExcept{}}; }
+{ }
+(IdxSeq<1,2,3>{});
+});
+
+struct Foo {
+  int i;
+  double j;
+  char k;
+};
+
+static_assert(ConstructibleWithN);
+
+}
Index: clang/test/AST/ast-dump-concepts.cpp
===
--- clang/test/AST/ast-dump-concepts.cpp
+++ clang/test/AST/ast-dump-concepts.cpp
@@ -19,6 +19,11 @@
 struct Foo {
   // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'binary_concept'
   // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}}  'bool' Concept {{.*}} 'binary_concept'
+  // CHECK-NEXT:   |-ConceptSpecializationDecl {{.*}}  col:9
+  // CHECK-NEXT:   | |-TemplateArgument type 'type-parameter-1-0'  
+  // CHECK-NEXT:   | | `-TemplateTypeParmType {{.*}} 'type-parameter-1-0' dependent {{.*}}depth 1 index 0
+  // CHECK-NEXT:   | `-TemplateArgument type 'int'
+  // CHECK-NEXT:   |   `-BuiltinType {{.*}} 'int'
   // CHECK-NEXT:   |-TemplateArgument {{.*}} type 'R'
   // CHECK-NEXT:   | `-TemplateTypeParmType {{.*}} 'R'
   // CHECK-NEXT:   |   `-TemplateTypeParm {{.*}} 'R'
@@ -29,6 +34,9 @@
 
   // CHECK:  TemplateTypeParmDecl {{.*}} referenced Concept {{.*}} 'unary_concept'
   // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}}  'bool'
+  // CHECK-NEXT:   |-ConceptSpecializationDecl {{.*}}  col:9
+  // CHECK-NEXT:   | `-TemplateArgument type 'type-parameter-1-0'
+  // CHECK-NEXT:   |   `-TemplateTypeParmType {{.*}} 'type-parameter-1-0' dependent {{.*}}depth 1 index 0
   template 
   Foo(R);
 
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===

[PATCH] D136440: [clang] Do not hide base member using-decls with different template head.

2022-10-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for the change. All the behavior changes look reasonable to me, but I'm 
struggling to understand whether we follow the standard closely here.
Left a comment to discuss this in depth.




Comment at: clang/lib/Sema/SemaOverload.cpp:1238
 bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old,
-  bool UseMemberUsingDeclRules, bool ConsiderCudaAttrs,
+  bool IsForUsingDecl, bool ConsiderCudaAttrs,
   bool ConsiderRequiresClauses) {

`UseMemberUsingDeclRules` is used everywhere in the code and in the comments 
for calls to `IsOverload `.

Let's maybe change the name in the header instead to avoid chasing all call 
sites?



Comment at: clang/lib/Sema/SemaOverload.cpp:1298
+  New->getDeclaredReturnType());
+auto IsConstructorOrAssignment = [](FunctionDecl *FD) {
+  auto *CMD = dyn_cast(FD);

Lambda is only used once. Could you inline it to make the code simpler?
```
bool IsConstructorOrAssignment = false;
if (auto *CMD = dyn_cast(FD); CMD && (...)) {
  IsConsutrctorOrAssignment = true;
}
```



Comment at: clang/lib/Sema/SemaOverload.cpp:1307
+// C++ [namespace.udecl]p4:
+//   The member from the base class is hidden or overridden by the
+//   implicitly-declared copy/move constructor or assignment operator of 
the

How is this related to checking whether the template parameter lists check?
I seems to be missing the logical connection that goes from the standard 
wording to the code. Could you explain?

An example that I have in mind is:
```
struct A {
template  A(T);
template  int foo(T);
};
struct B : A {
using A::A;
template  B(T);

using A::foo;
template  int foo(T);
};

namespace detail {
template  int bar(T);
}
using detail::bar;
template  int bar(T);

int a = bar(10); // this is definitely ambiguous.

B b(10); // should this be ambiguous?
int c = b.foo(10); // should this be ambiguous?
// Should constructors and functions behave differently? Why?
```

I [see](https://gcc.godbolt.org/z/z4Ko1ehPe) that both Clang and GCC treat 
member declarations differently, but I don't see why they should given that 
they are supposed to use the same "corresponds" terminology from the standard. 
What am I missing?



Comment at: clang/test/SemaTemplate/concepts-using-decl.cpp:110
+  expect<1>(bar2{}.foo());
+  // FIXME: Candidates from using-decls should be dropped in case of ambiguity.
+  expect<1>(baz{}.foo()); // expected-error {{call to member function 
'foo' is ambiguous}}

Why should they be dropped? Could you provide pointers from the standard?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136440

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


[PATCH] D136449: [Clang] Implement P2513

2022-10-21 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 469595.
cor3ntin added a comment.

Remove unused diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136449

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/char8_t.cpp
  clang/test/SemaCXX/cxx2a-compat.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1506,7 +1506,7 @@
 
   char8_t Compatibility and Portability Fix
   https://wg21.link/P2513R3";>P2513R3
-  No
+  Clang 16
 
 
   Relax requirements on wchar_t to match existing practices
Index: clang/test/SemaCXX/cxx2a-compat.cpp
===
--- clang/test/SemaCXX/cxx2a-compat.cpp
+++ clang/test/SemaCXX/cxx2a-compat.cpp
@@ -33,9 +33,8 @@
 // expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
 // expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
 #else
-// expected-error@-8 {{ISO C++20 does not permit initialization of char array with UTF-8 string literal}}
-// expected-error@-8 {{cannot initialize a variable of type 'const char *' with an lvalue of type 'const char8_t[6]'}}
-// expected-error@-8 {{no viable conversion from 'const char8_t[9]' to 'string'}}
+// expected-error@-7 {{cannot initialize a variable of type 'const char *' with an lvalue of type 'const char8_t[6]'}}
+// expected-error@-7 {{no viable conversion from 'const char8_t[9]' to 'string'}}
 #endif
 
 template
Index: clang/test/SemaCXX/char8_t.cpp
===
--- clang/test/SemaCXX/char8_t.cpp
+++ clang/test/SemaCXX/char8_t.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fchar8_t -std=c++17 -verify %s
-// RUN: %clang_cc1 -std=c++2a -verify %s
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 -fno-signed-char %s
+
 
 char8_t a = u8'a';
 char8_t b[] = u8"foo";
@@ -10,12 +12,24 @@
 char f[] = u8"foo";
 #if __cplusplus <= 201703L
 // expected-error@-2 {{initialization of char array with UTF-8 string literal is not permitted by '-fchar8_t'}}
-#else
-// expected-error@-4 {{ISO C++20 does not permit initialization of char array with UTF-8 string literal}}
 #endif
 char g = 'a';
 char h[] = "foo";
 
+#if __cplusplus >= 201902L
+unsigned char i[] = u8"foo";
+unsigned char j[] = { u8"foo" };
+char k[] = u8"foo";
+char l[] = { u8"foo" };
+signed char m[] = u8"foo"; // expected-error {{initialization of char array with UTF-8 string literal is not permitted by C++20}}
+signed char n[] = { u8"foo" }; // expected-error {{cannot initialize an array element of type 'signed char' with an lvalue of type 'const char8_t[4]'}}
+
+const unsigned char* uptr = u8"foo"; // expected-error {{cannot initialize}}
+const signed char* sptr = u8"foo"; // expected-error {{cannot initialize}}
+const char* ptr = u8"foo"; // expected-error {{cannot initialize}}
+
+#endif
+
 void disambig() {
   char8_t (a) = u8'x';
 }
@@ -48,3 +62,21 @@
 static_assert(sizeof(char8_t) == 1);
 static_assert(char8_t(-1) > 0);
 static_assert(u8"\u0080"[0] > 0);
+
+namespace ambiguous {
+
+struct A {
+	char8_t s[10];
+};
+struct B {
+  char s[10];
+};
+
+void f(A); // cxx20-note {{candidate}}
+void f(B); // cxx20-note {{candidate}}
+
+int test() {
+  f({u8"foo"}); // cxx20-error {{call to 'f' is ambiguous}}
+}
+
+}
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -46,9 +46,9 @@
 #error "wrong value for __cpp_aggregate_paren_init"
 #endif
 
-#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 201811, 201811) : \
+#if defined(CHAR8_T) ? check(char8_t, 201811, 201811, 201811, 201811, 202207, 202207) : \
 defined(NO_CHAR8_T) ? check(char8_t, 0, 0, 0, 0, 0, 0) : \
-check(char8_t, 0, 0, 0, 0, 201811, 201811)
+check(char8_t, 0, 0, 0, 0, 202207, 202207)
 #error "wrong value for __cpp_char8_t"
 #endif
 
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -81,10 +81,20 @@
   const QualType ElemTy =
   Context.getCanonicalType(AT->getElementType()).getUnqualifiedType();
 
+  auto IsCharOrUnsignedChar = [](const QualType &T) {
+const BuiltinType *BT = dyn_cast(T.getTypePtr());
+return BT && BT->isCharType() && BT->getKind() != BuiltinType::SChar;
+  };
+
   switch (SL->getKind()) {
   case StringLiteral::UTF8:
 // char8_t arr

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-10-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:513-534
+  llvm::Optional MLTAL =
+  SetupConstraintCheckingTemplateArgumentsAndScope(
+  const_cast(FD), {}, Scope);
+
   Qualifiers ThisQuals;
   CXXRecordDecl *Record = nullptr;
   if (auto *Method = dyn_cast(FD)) {

erichkeane wrote:
> mizvekov wrote:
> > mizvekov wrote:
> > > Unchecked access to MLTAL (Optional).
> > > 
> > > Following reduction reproduces a crash here: `-cc1 -std=c++20 
> > > -fsyntax-only -ferror-limit 19`.
> > > ```
> > > template a b < ;
> > > template c e ag < ;
> > > ah) ;
> > > am = ;
> > > template  class aq {
> > >   aq(ap...; __attribute__) auto aj() requires(am)
> > > }
> > > f() {  [;  aq d;  d.aj
> > > ```
> > By the way, disregard that repro, it needs another patch that is not in 
> > master.
> > 
> > The unchecked access still does look suspicious though.
> Thanks for the comment!  I'll look into it.
Huh... that must be leftover from some other attempt I made at that, the MLTAL 
is always set.  I'll do an NFC patch to remove it, but thanks for looking!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D136355: [clang][Sema] Fix caret position to be on the non null parameter

2022-10-21 Thread Arthur Grillo Queiroz Cabral via Phabricator via cfe-commits
Grillo updated this revision to Diff 469604.

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

https://reviews.llvm.org/D136355

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/non-null-warning.c


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+   return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -325,6 +325,9 @@
   pointers is improved to include the type of the array and whether it's cast
   to another type. This should improve comprehension for why an index is
   out-of-bounds.
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 
`_.
 
 Non-comprehensive list of changes in this release
 -


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+	return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -325,6 +325,9 @@
   pointers is improved to include the type of the array and whether it's cast
   to another type. This should improve comprehension for why an index is
   out-of-bounds.
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 `_.
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136355: [clang][Sema] Fix caret position to be on the non null parameter

2022-10-21 Thread Arthur Grillo Queiroz Cabral via Phabricator via cfe-commits
Grillo updated this revision to Diff 469605.

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

https://reviews.llvm.org/D136355

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/non-null-warning.c


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a 
non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+  return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a 
non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a 
non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -325,6 +325,9 @@
   pointers is improved to include the type of the array and whether it's cast
   to another type. This should improve comprehension for why an index is
   out-of-bounds.
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 
`_.
 
 Non-comprehensive list of changes in this release
 -


Index: clang/test/Sema/non-null-warning.c
===
--- clang/test/Sema/non-null-warning.c
+++ clang/test/Sema/non-null-warning.c
@@ -37,9 +37,16 @@
   return 0; // expected-warning {{null returned from function that requires a non-null return value}}
 }
 
+int foo4(int * _Nonnull x, int * y) {
+  return 0;
+}
+
 #define SAFE_CALL(X) if (X) foo(X)
 int main (void) {
   foo(0); // expected-warning {{null passed to a callee that requires a non-null argument}}
   (void)sizeof(foo(0)); // expect no diagnostic in unevaluated context.
   SAFE_CALL(0); // expect no diagnostic for unreachable code.
+  foo4(
+   0, // expected-warning {{null passed to a callee that requires a non-null argument}}
+   0);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5638,7 +5638,7 @@
   for (unsigned ArgIndex = 0, ArgIndexEnd = NonNullArgs.size();
ArgIndex != ArgIndexEnd; ++ArgIndex) {
 if (NonNullArgs[ArgIndex])
-  CheckNonNullArgument(S, Args[ArgIndex], CallSiteLoc);
+  CheckNonNullArgument(S, Args[ArgIndex], Args[ArgIndex]->getExprLoc());
   }
 }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -325,6 +325,9 @@
   pointers is improved to include the type of the array and whether it's cast
   to another type. This should improve comprehension for why an index is
   out-of-bounds.
+- Clang now correctly point to the problematic parameter for the ``-Wnonnull``
+  warning.
+  This fixes `Issue 58273 `_.
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

In D136284#3874492 , @nikic wrote:

> At least in C++, working with uninitialized memory is pretty much always 
> immediate undefined behavior, see https://eel.is/c++draft/basic.indet for the 
> relevant wording. The only exception are "copy-like" operations on unsigned 
> character types, which comparisons do not fall under.
>
> I believe the C specification is less clear cut about this, but Clang and 
> LLVM assume basically the same to also hold for C code.

What version of the C++ standard is this?  Every version that I have seen has 
basics as section 3 and I cannot find this section, nor anything similar.  
Section 6 is Statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-10-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:513-534
+  llvm::Optional MLTAL =
+  SetupConstraintCheckingTemplateArgumentsAndScope(
+  const_cast(FD), {}, Scope);
+
   Qualifiers ThisQuals;
   CXXRecordDecl *Record = nullptr;
   if (auto *Method = dyn_cast(FD)) {

erichkeane wrote:
> erichkeane wrote:
> > mizvekov wrote:
> > > mizvekov wrote:
> > > > Unchecked access to MLTAL (Optional).
> > > > 
> > > > Following reduction reproduces a crash here: `-cc1 -std=c++20 
> > > > -fsyntax-only -ferror-limit 19`.
> > > > ```
> > > > template a b < ;
> > > > template c e ag < ;
> > > > ah) ;
> > > > am = ;
> > > > template  class aq {
> > > >   aq(ap...; __attribute__) auto aj() requires(am)
> > > > }
> > > > f() {  [;  aq d;  d.aj
> > > > ```
> > > By the way, disregard that repro, it needs another patch that is not in 
> > > master.
> > > 
> > > The unchecked access still does look suspicious though.
> > Thanks for the comment!  I'll look into it.
> Huh... that must be leftover from some other attempt I made at that, the 
> MLTAL is always set.  I'll do an NFC patch to remove it, but thanks for 
> looking!
Woops... nvm... you're right, in an error condition we can get an errored one.  
I'll add a check.  Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[clang] a726be3 - [NFC] Make sure we check an optional when checking function constraints

2022-10-21 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-10-21T07:32:57-07:00
New Revision: a726be38756bf65dbe15912e779f0813fe5af01e

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

LOG: [NFC] Make sure we check an optional when checking function constraints

For some reason the initial deferred concepts patch didn't add this
check, which someone noticed could cause a problem with other patches
applied.  This makes sure we check these, so that an error condition
cannot cause us to crash.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6091a0be01089..e84e6b22f2817 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -7211,7 +7211,7 @@ class Sema final {
   FunctionDecl *FD, llvm::Optional> 
TemplateArgs,
   MultiLevelTemplateArgumentList MLTAL, LocalInstantiationScope &Scope);
 
-  /// Used during constraint checking, sets up the constraint template arguemnt
+  /// Used during constraint checking, sets up the constraint template argument
   /// lists, and calls SetupConstraintScope to set up the
   /// LocalInstantiationScope to have the proper set of ParVarDecls configured.
   llvm::Optional

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 5d8d7a41f821c..9809ccb2ccc00 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -511,7 +511,7 @@ Sema::SetupConstraintCheckingTemplateArgumentsAndScope(
/*Pattern=*/nullptr,
/*ForConstraintInstantiation=*/true);
   if (SetupConstraintScope(FD, TemplateArgs, MLTAL, Scope))
-return {};
+return llvm::None;
 
   return MLTAL;
 }
@@ -547,6 +547,9 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
   SetupConstraintCheckingTemplateArgumentsAndScope(
   const_cast(FD), {}, Scope);
 
+  if (!MLTAL)
+return true;
+
   Qualifiers ThisQuals;
   CXXRecordDecl *Record = nullptr;
   if (auto *Method = dyn_cast(FD)) {



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


[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

In D136284#3874596 , @jamieschmeiser 
wrote:

> In D136284#3874492 , @nikic wrote:
>
>> At least in C++, working with uninitialized memory is pretty much always 
>> immediate undefined behavior, see https://eel.is/c++draft/basic.indet for 
>> the relevant wording. The only exception are "copy-like" operations on 
>> unsigned character types, which comparisons do not fall under.
>>
>> I believe the C specification is less clear cut about this, but Clang and 
>> LLVM assume basically the same to also hold for C code.
>
> What version of the C++ standard is this?  Every version that I have seen has 
> basics as section 3 and I cannot find this section, nor anything similar.  
> Section 6 is Statements.

That discussion is orthogonal to this patch.
This patch is not desired because it's not needed per the current LLVM IR 
semantics. If you want to change something, you need to start by proposing a 
change to the LLVM IR semantics. You'll need to justify why it's needed, why 
it's correct, the perf impact, how to make it backwards compatible, why it's 
better than the proposals over the table right now.

Anyway, a patch like this solves no problem. LLVM allows loads to be 
duplicated. Your patch does nothing to prevent that and to ensure all loads see 
the same value. The issue is way more complicated than what this patch implies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D136454: [clangd] Make file limit for textDocument/rename configurable

2022-10-21 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Without this, clients are unable to rename often-used symbols in larger
projects.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136454

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -327,6 +327,14 @@
 init(1000),
 };
 
+opt RenameFileLimit{
+"rename-file-limit",
+cat(Features),
+desc("Limit the number of files to be affected by symbol renaming. "
+ "0 means no limit (default=50)"),
+init(50),
+};
+
 list TweakList{
 "tweaks",
 cat(Features),
@@ -891,6 +899,7 @@
   Opts.BackgroundIndex = EnableBackgroundIndex;
   Opts.BackgroundIndexPriority = BackgroundIndexPriority;
   Opts.ReferencesLimit = ReferencesLimit;
+  Opts.Rename.LimitFiles = RenameFileLimit;
   auto PAI = createProjectAwareIndex(loadExternalIndex, Sync);
   if (StaticIdx) {
 IdxStack.emplace_back(std::move(StaticIdx));


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -327,6 +327,14 @@
 init(1000),
 };
 
+opt RenameFileLimit{
+"rename-file-limit",
+cat(Features),
+desc("Limit the number of files to be affected by symbol renaming. "
+ "0 means no limit (default=50)"),
+init(50),
+};
+
 list TweakList{
 "tweaks",
 cat(Features),
@@ -891,6 +899,7 @@
   Opts.BackgroundIndex = EnableBackgroundIndex;
   Opts.BackgroundIndexPriority = BackgroundIndexPriority;
   Opts.ReferencesLimit = ReferencesLimit;
+  Opts.Rename.LimitFiles = RenameFileLimit;
   auto PAI = createProjectAwareIndex(loadExternalIndex, Sync);
   if (StaticIdx) {
 IdxStack.emplace_back(std::move(StaticIdx));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136455: [clang][ExtractAPI] Add targetFallback to relationships in symbol graph

2022-10-21 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added reviewers: zixuw, QuietMisdreavus, ributzka.
Herald added a subscriber: yaxunl.
Herald added a project: All.
dang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adds a 'targetFallback' field to relationships in symbol graph that
contains the plain name of the relationship target. This is useful for
clients when the relationship target symbol is not available.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136455

Files:
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/anonymous_record_no_typedef.c
  clang/test/ExtractAPI/enum.c
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_interface.m
  clang/test/ExtractAPI/objc_property.m
  clang/test/ExtractAPI/objc_protocol.m
  clang/test/ExtractAPI/struct.c
  clang/test/ExtractAPI/underscored.c

Index: clang/test/ExtractAPI/underscored.c
===
--- clang/test/ExtractAPI/underscored.c
+++ clang/test/ExtractAPI/underscored.c
@@ -65,7 +65,8 @@
 {
   "kind": "memberOf",
   "source": "c:@S@ExposedRecord@FI@a",
-  "target": "c:@S@ExposedRecord"
+  "target": "c:@S@ExposedRecord",
+  "targetFallback": "ExposedRecord"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/struct.c
===
--- clang/test/ExtractAPI/struct.c
+++ clang/test/ExtractAPI/struct.c
@@ -52,22 +52,26 @@
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Red",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Green",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Blue",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 },
 {
   "kind": "memberOf",
   "source": "c:@S@Color@FI@Alpha",
-  "target": "c:@S@Color"
+  "target": "c:@S@Color",
+  "targetFallback": "Color"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/objc_protocol.m
===
--- clang/test/ExtractAPI/objc_protocol.m
+++ clang/test/ExtractAPI/objc_protocol.m
@@ -49,7 +49,8 @@
 {
   "kind": "conformsTo",
   "source": "c:objc(pl)AnotherProtocol",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/objc_property.m
===
--- clang/test/ExtractAPI/objc_property.m
+++ clang/test/ExtractAPI/objc_property.m
@@ -55,37 +55,44 @@
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(cpy)myInterfaceTypeProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(py)myInterfaceInstanceProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(cpy)myCategoryTypeProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Interface(py)myCategoryInstanceProp",
-  "target": "c:objc(cs)Interface"
+  "target": "c:objc(cs)Interface",
+  "targetFallback": "Interface"
 },
 {
   "kind": "conformsTo",
   "source": "c:objc(cs)Interface",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(pl)Protocol(cpy)myProtocolTypeProp",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(pl)Protocol(py)myProtocolInstanceProp",
-  "target": "c:objc(pl)Protocol"
+  "target": "c:objc(pl)Protocol",
+  "targetFallback": "Protocol"
 }
   ],
   "symbols": [
Index: clang/test/ExtractAPI/objc_interface.m
===
--- clang/test/ExtractAPI/objc_interface.m
+++ clang/test/ExtractAPI/objc_interface.m
@@ -57,37 +57,44 @@
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Super(cm)getWithProperty:",
-  "target": "c:objc(cs)Super"
+  "target": "c:objc(cs)Super",
+  "targetFallback": "Super"
 },
 {
   "kind": "memberOf",
   "source": "c:objc(cs)Super(im)setProperty:andOtherThing:"

[PATCH] D136454: [clangd] Make file limit for textDocument/rename configurable

2022-10-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136454

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


[PATCH] D136090: Handle errors in expansion of response files

2022-10-21 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

Nice tests! :) I have one microscopic nit and one question (because I don't 
know an awful lot about config files). Thanks for working on this.




Comment at: llvm/lib/Support/CommandLine.cpp:1188
+  // macros.
+  if (!RelativeNames && !InConfigFile)
 return Error::success();

Why do you need to add `!InConfigFile` here and below? 



Comment at: llvm/lib/Support/CommandLine.cpp:1204
+StringRef FileName;
+if (ArgStr[0] == '@') {
+  FileName = ArgStr.drop_front(1);

Nit: Why reverse this branch? The code around it `continue`s early, so it's 
easier to read if this `continue`s early too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136090

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


[PATCH] D136090: Handle errors in expansion of response files

2022-10-21 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: llvm/lib/Support/CommandLine.cpp:1205
+if (ArgStr[0] == '@') {
+  FileName = ArgStr.drop_front(1);
+  if (!llvm::sys::path::is_relative(FileName))

Also, I think you can use `consume_front()` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136090

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


[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser abandoned this revision.
jamieschmeiser added a comment.

I checked with a member of the C++ standards committee and he verified that 
comparing an uninitialized value against itself is, indeed, undefined 
behaviour, in the general case.  I am abandoning this revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser added a comment.

In D136284#3874614 , @nlopes wrote:

> In D136284#3874596 , 
> @jamieschmeiser wrote:
>
>> In D136284#3874492 , @nikic wrote:
>>
>>> At least in C++, working with uninitialized memory is pretty much always 
>>> immediate undefined behavior, see https://eel.is/c++draft/basic.indet for 
>>> the relevant wording. The only exception are "copy-like" operations on 
>>> unsigned character types, which comparisons do not fall under.
>>>
>>> I believe the C specification is less clear cut about this, but Clang and 
>>> LLVM assume basically the same to also hold for C code.
>>
>> What version of the C++ standard is this?  Every version that I have seen 
>> has basics as section 3 and I cannot find this section, nor anything 
>> similar.  Section 6 is Statements.
>
> That discussion is orthogonal to this patch.
> This patch is not desired because it's not needed per the current LLVM IR 
> semantics. If you want to change something, you need to start by proposing a 
> change to the LLVM IR semantics. You'll need to justify why it's needed, why 
> it's correct, the perf impact, how to make it backwards compatible, why it's 
> better than the proposals over the table right now.
>
> Anyway, a patch like this solves no problem. LLVM allows loads to be 
> duplicated. Your patch does nothing to prevent that and to ensure all loads 
> see the same value. The issue is way more complicated than what this patch 
> implies.

I'm not trying to flog a dead horse (I've already abandoned this) but I am 
trying to understand this statement.  I do not dispute that there may be other 
situations similar to this but, assuming that we did want to ensure that the 
loads had the same value, why is freezing them at this point not the correct 
thing to do?  Whether they are poison or undef, freezing them would ensure that 
they compare equal.  Yes, I understand it may have performance impacts, there 
may be better ways, etc.  But, ignoring all that, isn't this exactly what 
freeze is designed for?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D133698: [clang][dataflow] SignAnalysis, edgeTransfer, branchTransfer

2022-10-21 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 469625.
martong marked 8 inline comments as done.
martong added a comment.

- Add comments
- Assumption -> ConditionValue
- Use CRTP
- branchTransfer -> transferBranch
- Make just one simple test case for transferBranch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133698

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
@@ -0,0 +1,129 @@
+//===- unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines a simplistic version of Sign Analysis as an example
+//  of a forward, monotonic dataflow analysis. The analysis tracks all
+//  variables in the scope, but lacks escape analysis.
+//
+//===--===//
+
+#include "TestingSupport.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace dataflow {
+namespace {
+using namespace ast_matchers;
+using namespace test;
+
+struct TestLattice {
+  enum class Branch : int { True, False };
+  llvm::Optional TheBranch;
+  static TestLattice bottom() { return {}; }
+
+  // Does not matter for this test, but we must provide some definition of join.
+  LatticeJoinEffect join(const TestLattice &Other) {
+return LatticeJoinEffect::Unchanged;
+  }
+  friend bool operator==(const TestLattice &Lhs, const TestLattice &Rhs) {
+return Lhs.TheBranch == Rhs.TheBranch;
+  }
+};
+
+class TestPropagationAnalysis
+: public DataflowAnalysis {
+public:
+  explicit TestPropagationAnalysis(ASTContext &Context)
+  : DataflowAnalysis(Context) {}
+  static TestLattice initialElement() { return TestLattice::bottom(); }
+  void transferBranch(bool Branch, const Stmt *S, TestLattice &L,
+  Environment &Env) {
+L.TheBranch =
+Branch ? TestLattice::Branch::True : TestLattice::Branch::False;
+  }
+};
+
+using ::testing::UnorderedElementsAre;
+
+MATCHER_P(Var, name,
+  (llvm::Twine(negation ? "isn't" : "is") + " a variable named `" +
+   name + "`")
+  .str()) {
+  assert(isa(arg));
+  return arg->getName() == name;
+}
+
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ llvm::StringRef TargetFun = "fun") {
+  using ast_matchers::hasName;
+  ASSERT_THAT_ERROR(
+  checkDataflow(
+  AnalysisInputs(
+  Code, hasName(TargetFun),
+  [](ASTContext &C, Environment &) {
+return TestPropagationAnalysis(C);
+  })
+  .withASTBuildArgs(
+  {"-fsyntax-only", "-fno-delayed-template-parsing",
+   "-std=" +
+   std::string(LangStandard::getLangStandardForKind(Std)
+   .getName())}),
+  /*VerifyResults=*/
+  [&Match](const llvm::StringMap>
+   &Results,
+   const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); }),
+  llvm::Succeeded());
+}
+
+template 
+const LatticeT &getLatticeAtAnnotation(
+const llvm::StringMap> &AnnotationStates,
+llvm::StringRef Annotation) {
+  auto It = AnnotationStates.find(Annotation);
+  assert(It != AnnotationStates.end());
+  return It->getValue().Lattice;
+}
+
+TEST(TransferBranchTest, IfElse) {
+  std::string Code = R"(
+void fun(int a) {
+  if (a > 0) {
+(void)1;
+// [[p]]
+  } else {
+(void)0;
+// [[q]]
+  }
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p", "q"));
+
+const TestLattice &LP = getLatticeAtAnnotation(Results, "p");
+EXPECT_TRUE(LP.TheBranch == TestLattice::Branch::True);
+
+

[PATCH] D136457: [clang][Interp] Fix discarding non-primitive function call return values

2022-10-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As briefly discussed in https://reviews.llvm.org/D136013

This creates a temporary local variable and puts the RVO pointer on the stack 
for the function to write the result into.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136457

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -214,6 +214,10 @@
 this->a; // expected-warning {{expression result unused}} \
  // ref-warning {{expression result unused}}
 get5();
+#if __cplusplus >= 201703L
+// FIXME: Enable once we support MaterializeConstantExpr properly.
+getInts();
+#endif
   }
 
   constexpr int m() const {
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1152,6 +1152,19 @@
 if (Func->isFullyCompiled() && !Func->isConstexpr())
   return false;
 
+QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
+Optional T = classify(ReturnType);
+
+if (DiscardResult && !T) {
+  // If we need to discard the return value but the function returns its
+  // value via an RVO pointer, we need to create one such pointer just
+  // for this call.
+  if (Optional LocalIndex = allocateLocal(E)) {
+if (!this->emitGetPtrLocal(*LocalIndex, E))
+  return false;
+  }
+}
+
 // Put arguments on the stack.
 for (const auto *Arg : E->arguments()) {
   if (!this->visit(Arg))
@@ -1164,13 +1177,8 @@
 if (!this->emitCall(Func, E))
   return false;
 
-QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
-if (DiscardResult && !ReturnType->isVoidType()) {
-  Optional T = classify(ReturnType);
-  if (T)
-return this->emitPop(*T, E);
-  // TODO: This is a RVO function and we need to ignore the return value.
-}
+if (DiscardResult && !ReturnType->isVoidType() && T)
+  return this->emitPop(*T, E);
 
 return true;
   } else {


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -214,6 +214,10 @@
 this->a; // expected-warning {{expression result unused}} \
  // ref-warning {{expression result unused}}
 get5();
+#if __cplusplus >= 201703L
+// FIXME: Enable once we support MaterializeConstantExpr properly.
+getInts();
+#endif
   }
 
   constexpr int m() const {
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1152,6 +1152,19 @@
 if (Func->isFullyCompiled() && !Func->isConstexpr())
   return false;
 
+QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
+Optional T = classify(ReturnType);
+
+if (DiscardResult && !T) {
+  // If we need to discard the return value but the function returns its
+  // value via an RVO pointer, we need to create one such pointer just
+  // for this call.
+  if (Optional LocalIndex = allocateLocal(E)) {
+if (!this->emitGetPtrLocal(*LocalIndex, E))
+  return false;
+  }
+}
+
 // Put arguments on the stack.
 for (const auto *Arg : E->arguments()) {
   if (!this->visit(Arg))
@@ -1164,13 +1177,8 @@
 if (!this->emitCall(Func, E))
   return false;
 
-QualType ReturnType = E->getCallReturnType(Ctx.getASTContext());
-if (DiscardResult && !ReturnType->isVoidType()) {
-  Optional T = classify(ReturnType);
-  if (T)
-return this->emitPop(*T, E);
-  // TODO: This is a RVO function and we need to ignore the return value.
-}
+if (DiscardResult && !ReturnType->isVoidType() && T)
+  return this->emitPop(*T, E);
 
 return true;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D136437: [clang-format] Insert closing braces of unaffected lines

2022-10-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Does this need a unit test? or are we good?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136437

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


[PATCH] D133698: [clang][dataflow] Implement transferBranch

2022-10-21 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 469636.
martong edited the summary of this revision.
martong added a comment.

- Rebase to latest llvm/main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133698

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp
@@ -0,0 +1,130 @@
+//===- unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file defines a simplistic version of Sign Analysis as an example
+//  of a forward, monotonic dataflow analysis. The analysis tracks all
+//  variables in the scope, but lacks escape analysis.
+//
+//===--===//
+
+#include "TestingSupport.h"
+#include "clang/Analysis/FlowSensitive/DataflowAnalysis.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace dataflow {
+namespace {
+using namespace ast_matchers;
+using namespace test;
+
+struct TestLattice {
+  enum class Branch : int { True, False };
+  llvm::Optional TheBranch;
+  static TestLattice bottom() { return {}; }
+
+  // Does not matter for this test, but we must provide some definition of join.
+  LatticeJoinEffect join(const TestLattice &Other) {
+return LatticeJoinEffect::Unchanged;
+  }
+  friend bool operator==(const TestLattice &Lhs, const TestLattice &Rhs) {
+return Lhs.TheBranch == Rhs.TheBranch;
+  }
+};
+
+class TestPropagationAnalysis
+: public DataflowAnalysis {
+public:
+  explicit TestPropagationAnalysis(ASTContext &Context)
+  : DataflowAnalysis(Context) {}
+  static TestLattice initialElement() { return TestLattice::bottom(); }
+  void transfer(const CFGElement *, TestLattice &, Environment &) {}
+  void transferBranch(bool Branch, const Stmt *S, TestLattice &L,
+  Environment &Env) {
+L.TheBranch =
+Branch ? TestLattice::Branch::True : TestLattice::Branch::False;
+  }
+};
+
+using ::testing::UnorderedElementsAre;
+
+MATCHER_P(Var, name,
+  (llvm::Twine(negation ? "isn't" : "is") + " a variable named `" +
+   name + "`")
+  .str()) {
+  assert(isa(arg));
+  return arg->getName() == name;
+}
+
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+ LangStandard::Kind Std = LangStandard::lang_cxx17,
+ llvm::StringRef TargetFun = "fun") {
+  using ast_matchers::hasName;
+  ASSERT_THAT_ERROR(
+  checkDataflow(
+  AnalysisInputs(
+  Code, hasName(TargetFun),
+  [](ASTContext &C, Environment &) {
+return TestPropagationAnalysis(C);
+  })
+  .withASTBuildArgs(
+  {"-fsyntax-only", "-fno-delayed-template-parsing",
+   "-std=" +
+   std::string(LangStandard::getLangStandardForKind(Std)
+   .getName())}),
+  /*VerifyResults=*/
+  [&Match](const llvm::StringMap>
+   &Results,
+   const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); }),
+  llvm::Succeeded());
+}
+
+template 
+const LatticeT &getLatticeAtAnnotation(
+const llvm::StringMap> &AnnotationStates,
+llvm::StringRef Annotation) {
+  auto It = AnnotationStates.find(Annotation);
+  assert(It != AnnotationStates.end());
+  return It->getValue().Lattice;
+}
+
+TEST(TransferBranchTest, IfElse) {
+  std::string Code = R"(
+void fun(int a) {
+  if (a > 0) {
+(void)1;
+// [[p]]
+  } else {
+(void)0;
+// [[q]]
+  }
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p", "q"));
+
+const TestLattice &LP = getLatticeAtAnnotation(Results, "p");
+EXPECT_TRUE(LP.TheBranch == TestLattice::Branch::True);
+
+const TestLattice &LQ = getLatticeAtAn

[PATCH] D133698: [clang][dataflow] Implement transferBranch

2022-10-21 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h:127
+  // Default implementation is a Noop.
+  virtual void branchTransfer(bool Branch, const Stmt *S, Lattice &L,
+  Environment &Env) {}

gribozavr2 wrote:
> Please use CRTP (a non-virtual function here), and you'll need SFINAE to 
> detect the presence of the overload of branchTransfer in 
> branchTransferTypeErased.
Ok, changed it to use CRTP.



Comment at: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h:86
   Environment &) = 0;
+  virtual void branchTransferTypeErased(bool Branch, const Stmt *,
+TypeErasedLattice &, Environment &) = 
0;

gribozavr2 wrote:
> gribozavr2 wrote:
> > Please add a doc comment. Please add a parameter name for the condition, it 
> > is not obvious what it is.
> > 
> > Could you think of a more descriptive name for `Branch`? For example, if 
> > the second parameter is `Cond`, WDYT about `CondValue`?
> > 
> > 
> WDYT about calling it `transferBranch...` instead of `branchTransfer...`?
Ok, added a doc comment and renamed to transferBranch.



Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:148
 
+bool Assumption = true;
 // The condition must be inverted for the successor that encompasses the

gribozavr2 wrote:
> `CondValue`?
Ok, changed to `ConditionValue`.



Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:253
+auto [Cond, Assumption] =
+TerminatorVisitor(Analysis, StmtToEnv, PredState.Env,
+  blockIndexInPredecessor(*Pred, Block),

gribozavr2 wrote:
> It would be nice to still call `branchTransfer` even when 
> `BuiltinTransferOpts == false`. Please leave a TODO if you don't want to 
> implement that.
Ok, I've added a TODO.



Comment at: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp:241
+? SignLattice(R.Val.getInt().getExtValue())
+: SignLattice::bottom();
+  } else {

dkrupp wrote:
> Isn't this SignLattice::top() instead?
> 
> This is an initialization expression, which we cannot evaluate to int, but 
> the variable is initialized.
I am moving the sign analysis out of this patch.



Comment at: clang/unittests/Analysis/FlowSensitive/SignAnalysisTest.cpp:586
+   HoldsSignLattice(UnorderedElementsAre(Pair(Var("a"), 
Top()));
+}
+

gribozavr2 wrote:
> This file is an amazing example of how to use the framework, but could you 
> add a more direct unit test with a simpler lattice and analysis that 
> exercises the new callback?
Ok. I've removed the sign analysis from this patch and added a very simple test 
file with a very simple lattice to check the effect of transferBranch.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferBranchTest.cpp:60-66
+MATCHER_P(Var, name,
+  (llvm::Twine(negation ? "isn't" : "is") + " a variable named `" +
+   name + "`")
+  .str()) {
+  assert(isa(arg));
+  return arg->getName() == name;
+}

This is unused (a leftover). I am going remove this matcher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133698

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


[PATCH] D122573: [TBAA] Emit distinct TBAA tags for pointers with different depths,types.

2022-10-21 Thread Rui Zhang via Phabricator via cfe-commits
rui.zhang added subscribers: mcberg2021, craig.topper.
rui.zhang added a comment.

In D122573#3872138 , @fhahn wrote:

> Rebased on current main
>
> In D122573#3630767 , @rui.zhang 
> wrote:
>
>> I like the direction where this change is leading to and hope there is some 
>> way to land it incrementally. Since BuiltinType has the above mentioned 
>> concern on `void *`, how about we focus on `RecordType` pointers as a first 
>> step instead? Are there any pitfalls if we distinguish `RecordType` pointers 
>> by depth?
>
> An initial restriction like that sounds reasonable to me. @jcranmer-intel 
> @efriedma @rjmccall WDYT?
>
> I also updated the type sanitizer patches and posted 
> https://discourse.llvm.org/t/reviving-typesanitizer-a-sanitizer-to-catch-type-based-aliasing-violations/66092
>  to discuss ways to move forward with the sanitizer.

@craig.topper @mcberg2021 FYI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122573

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


[PATCH] D136449: [Clang] Implement P2513

2022-10-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thanks for this! Can you add more details to the patch summary as to what this 
paper does? Paper numbers help, but don't convey a whole lot of information at 
a glance if we need to come back to this review for code archeology.

Please also add a test to the correct file in clang/test/CXX/drs/ and 
regenerate our C++ DR status page.

Are we missing changes for "with an integral conversion [conv.integral] if 
necessary for the source and destination value." ?




Comment at: clang/lib/Frontend/InitPreprocessor.cpp:701
+Builder.defineMacro("__cpp_char8_t",
+LangOpts.CPlusPlus20 ? "202207L" : "201811L");
   Builder.defineMacro("__cpp_impl_destroying_delete", "201806L");

Why do we not want to go with `202207L` regardless of language mode if this is 
being applied as a DR?



Comment at: clang/lib/Sema/SemaInit.cpp:4466-4467
 }
+}
   }
   }

Unintentional indentation changes?



Comment at: clang/lib/Sema/SemaInit.cpp:5858-5861
+  case SIF_UTF8StringIntoPlainChar: {
 SetFailed(FK_UTF8StringIntoPlainChar);
 return;
+  }

Unrelated change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136449

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


[PATCH] D136284: SROA should freeze undefs for loads with no prior stores

2022-10-21 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

In D136284#3874755 , @jamieschmeiser 
wrote:

> In D136284#3874614 , @nlopes wrote:
>
>> In D136284#3874596 , 
>> @jamieschmeiser wrote:
>>
>>> In D136284#3874492 , @nikic wrote:
>>>
 At least in C++, working with uninitialized memory is pretty much always 
 immediate undefined behavior, see https://eel.is/c++draft/basic.indet for 
 the relevant wording. The only exception are "copy-like" operations on 
 unsigned character types, which comparisons do not fall under.

 I believe the C specification is less clear cut about this, but Clang and 
 LLVM assume basically the same to also hold for C code.
>>>
>>> What version of the C++ standard is this?  Every version that I have seen 
>>> has basics as section 3 and I cannot find this section, nor anything 
>>> similar.  Section 6 is Statements.
>>
>> That discussion is orthogonal to this patch.
>> This patch is not desired because it's not needed per the current LLVM IR 
>> semantics. If you want to change something, you need to start by proposing a 
>> change to the LLVM IR semantics. You'll need to justify why it's needed, why 
>> it's correct, the perf impact, how to make it backwards compatible, why it's 
>> better than the proposals over the table right now.
>>
>> Anyway, a patch like this solves no problem. LLVM allows loads to be 
>> duplicated. Your patch does nothing to prevent that and to ensure all loads 
>> see the same value. The issue is way more complicated than what this patch 
>> implies.
>
> I'm not trying to flog a dead horse (I've already abandoned this) but I am 
> trying to understand this statement.  I do not dispute that there may be 
> other situations similar to this but, assuming that we did want to ensure 
> that the loads had the same value, why is freezing them at this point not the 
> correct thing to do?  Whether they are poison or undef, freezing them would 
> ensure that they compare equal.  Yes, I understand it may have performance 
> impacts, there may be better ways, etc.  But, ignoring all that, isn't this 
> exactly what freeze is designed for?

It's not enough to ensure the semantics you want. What about optimizations that 
happen before and after SROA? This patch only deals with a subset of the cases 
(the ones that are detected by SROA's algorithm). Again, load duplication 
happens, and this patch doesn't deal with it. So it's inconsistent.
To implement the proposed semantics, you would need to change quite a few 
optimizations, not just SROA.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136284

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


[PATCH] D135951: [X86][1/2] SUPPORT RAO-INT

2022-10-21 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 469642.
pengfei added a comment.

Add intrinsic support first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135951

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/raointintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/test/CodeGen/X86/raoint-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86InstrRAOINT.td
  llvm/test/CodeGen/X86/raoint-intrinsics-32.ll
  llvm/test/CodeGen/X86/raoint-intrinsics-64.ll
  llvm/test/MC/Disassembler/X86/rao-int.txt
  llvm/test/MC/Disassembler/X86/x86-64-rao-int.txt
  llvm/test/MC/X86/rao-int-att.s
  llvm/test/MC/X86/rao-int-intel.s
  llvm/test/MC/X86/x86-64-rao-int-att.s
  llvm/test/MC/X86/x86-64-rao-int-intel.s

Index: llvm/test/MC/X86/x86-64-rao-int-intel.s
===
--- /dev/null
+++ llvm/test/MC/X86/x86-64-rao-int-intel.s
@@ -0,0 +1,193 @@
+// RUN: llvm-mc -triple x86_64-unknown-unknown -x86-asm-syntax=intel -output-asm-variant=1 --show-encoding %s | FileCheck %s
+
+// CHECK:  aadd qword ptr [rbp + 8*r14 + 268435456], r9
+// CHECK: encoding: [0x4e,0x0f,0x38,0xfc,0x8c,0xf5,0x00,0x00,0x00,0x10]
+   aadd qword ptr [rbp + 8*r14 + 268435456], r9
+
+// CHECK:  aadd qword ptr [r8 + 4*rax + 291], r9
+// CHECK: encoding: [0x4d,0x0f,0x38,0xfc,0x8c,0x80,0x23,0x01,0x00,0x00]
+   aadd qword ptr [r8 + 4*rax + 291], r9
+
+// CHECK:  aadd qword ptr [rip], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x0d,0x00,0x00,0x00,0x00]
+   aadd qword ptr [rip], r9
+
+// CHECK:  aadd qword ptr [2*rbp - 512], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x0c,0x6d,0x00,0xfe,0xff,0xff]
+   aadd qword ptr [2*rbp - 512], r9
+
+// CHECK:  aadd qword ptr [rcx + 2032], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x89,0xf0,0x07,0x00,0x00]
+   aadd qword ptr [rcx + 2032], r9
+
+// CHECK:  aadd qword ptr [rdx - 2048], r9
+// CHECK: encoding: [0x4c,0x0f,0x38,0xfc,0x8a,0x00,0xf8,0xff,0xff]
+   aadd qword ptr [rdx - 2048], r9
+
+// CHECK:  aadd dword ptr [esp + 8*esi + 268435456], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x9c,0xf4,0x00,0x00,0x00,0x10]
+   aadd dword ptr [esp + 8*esi + 268435456], ebx
+
+// CHECK:  aadd dword ptr [edi + 4*eax + 291], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x9c,0x87,0x23,0x01,0x00,0x00]
+   aadd dword ptr [edi + 4*eax + 291], ebx
+
+// CHECK:  aadd dword ptr [eax], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x18]
+   aadd dword ptr [eax], ebx
+
+// CHECK:  aadd dword ptr [2*ebp - 512], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x1c,0x6d,0x00,0xfe,0xff,0xff]
+   aadd dword ptr [2*ebp - 512], ebx
+
+// CHECK:  aadd dword ptr [ecx + 2032], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x99,0xf0,0x07,0x00,0x00]
+   aadd dword ptr [ecx + 2032], ebx
+
+// CHECK:  aadd dword ptr [edx - 2048], ebx
+// CHECK: encoding: [0x67,0x0f,0x38,0xfc,0x9a,0x00,0xf8,0xff,0xff]
+   aadd dword ptr [edx - 2048], ebx
+
+// CHECK:  aand qword ptr [rbp + 8*r14 + 268435456], r9
+// CHECK: encoding: [0x66,0x4e,0x0f,0x38,0xfc,0x8c,0xf5,0x00,0x00,0x00,0x10]
+   aand qword ptr [rbp + 8*r14 + 268435456], r9
+
+// CHECK:  aand qword ptr [r8 + 4*rax + 291], r9
+// CHECK: encoding: [0x66,0x4d,0x0f,0x38,0xfc,0x8c,0x80,0x23,0x01,0x00,0x00]
+   aand qword ptr [r8 + 4*rax + 291], r9
+
+// CHECK:  aand qword ptr [rip], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x0d,0x00,0x00,0x00,0x00]
+   aand qword ptr [rip], r9
+
+// CHECK:  aand qword ptr [2*rbp - 512], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x0c,0x6d,0x00,0xfe,0xff,0xff]
+   aand qword ptr [2*rbp - 512], r9
+
+// CHECK:  aand qword ptr [rcx + 2032], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x89,0xf0,0x07,0x00,0x00]
+   aand qword ptr [rcx + 2032], r9
+
+// CHECK:  aand qword ptr [rdx - 2048], r9
+// CHECK: encoding: [0x66,0x4c,0x0f,0x38,0xfc,0x8a,0x00,0xf8,0xff,0xff]
+   aand qword ptr [rdx - 2048], r9
+
+// CHECK:  aand dword ptr [esp + 8*esi + 268435456], ebx
+// CHECK: encoding: [0x67,0x66,0x0f,0x38,0xfc,0x9c,0x

[PATCH] D136162: [analyzer] Fix assertion failure with conflicting prototype calls

2022-10-21 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks for the update. Nice Work!




Comment at: clang/test/Analysis/region-store.c:66
+  // expected-warning@+1 {{passing arguments to 'b' without a prototype is 
deprecated in all versions of C and is not supported in C2x}}
+  b(&buffer);
+}

steakhal wrote:
> NoQ wrote:
> > steakhal wrote:
> > > tomasz-kaminski-sonarsource wrote:
> > > > tomasz-kaminski-sonarsource wrote:
> > > > > I would like to see an example where the called function is 
> > > > > implicitly defined.
> > > > After rethinking it, I have not idea how to construct that example.
> > > I could not construct such an example.
> > > It seems like clang errors out for cases when an implicit declaration of 
> > > a call mismatches with the definition of that function.
> > > https://godbolt.org/z/rM9ajeTf7
> > Yeah, if you scroll really far to the right, you'll see that the first 
> > error is actually a warning auto-promoted to an error. So you can pass 
> > `-Wno-implicit-function-declaration` and it'll disappear. Not sure what to 
> > do with the other error though, it really does notice that the implicit 
> > definition conflicts with the later explicit definition. So, dunno.
> Yup, I should have been more clear on this. See the test, I'm also passing 
> the `-Wno-implicit-function-declaration` :)
> Maybe Shafik or Aaron knows some weird stuff about how to make it 'compile'. 
> WDYT?
Interestingly,  GCC trunk compiles it without errors, the warnings are there 
though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136162

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


  1   2   >