[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

I don't believe that there is NativeBFloat16Type. AArch64 learned bf16 with 
ARMv8.6-A, but very limited operations and only in SIMD. X86 supports bf16 
since Cooperlake, but very limited operations and only in SIMD.

Maybe GPUs?


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

https://reviews.llvm.org/D149573

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs added a comment.

In D149573#4309378 , @tschuett wrote:

> I don't believe that there is NativeBFloat16Type. AArch64 learned bf16 with 
> ARMv8.6-A, but very limited operations and only in SIMD. X86 supports bf16 
> since Cooperlake, but very limited operations and only in SIMD.
>
> Maybe GPUs?



In D149573#4309378 , @tschuett wrote:

> I don't believe that there is NativeBFloat16Type. AArch64 learned bf16 with 
> ARMv8.6-A, but very limited operations and only in SIMD. X86 supports bf16 
> since Cooperlake, but very limited operations and only in SIMD.
>
> Maybe GPUs?

Dear @tschuett,

Thank you for your input. It seems that NativeBFloat16Type is indeed limited in 
availability. As you mentioned, AArch64 and X86 offer some bf16 support, but 
only in SIMD and with limited operations. This flag is intended to guard 
changes for targets with full bf16 support, as discussed in this RFC: 
https://discourse.llvm.org/t/rfc-c-23-p1467r9-extended-floating-point-types-and-standard-names/70033/12.
 While few public targets currently have native bf16 support, this still serves 
as a useful precaution.


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

https://reviews.llvm.org/D149573

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Agreed.


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

https://reviews.llvm.org/D149573

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


[clang-tools-extra] 5e74a3d - [clangd][IncludeCleaner] Use a proper comparator for deduplicating findings

2023-05-01 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-05-01T12:19:33+02:00
New Revision: 5e74a3dc2da879d98204f2360e2e33571b93b91b

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

LOG: [clangd][IncludeCleaner] Use a proper comparator for deduplicating findings

Previous one didn't have strict weak ordering guarantees.

Added: 


Modified: 
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/clangd/test/include-cleaner-batch-fix.test

Removed: 




diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index d3754de689eb0..3b913d851abe2 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -422,13 +422,17 @@ IncludeCleanerFindings 
computeIncludeCleanerFindings(ParsedAST &AST) {
   // times.
   llvm::stable_sort(MissingIncludes, [](const MissingIncludeDiagInfo &LHS,
 const MissingIncludeDiagInfo &RHS) {
-if (LHS.Symbol == RHS.Symbol) {
+// First sort by reference location.
+if (LHS.SymRefRange != RHS.SymRefRange) {
   // We can get away just by comparing the offsets as all the ranges are in
   // main file.
   return LHS.SymRefRange.beginOffset() < RHS.SymRefRange.beginOffset();
 }
-// If symbols are 
diff erent we don't care about the ordering.
-return true;
+// For the same location, break ties using the symbol. Note that this won't
+// be stable across runs.
+using MapInfo = llvm::DenseMapInfo;
+return MapInfo::getHashValue(LHS.Symbol) <
+   MapInfo::getHashValue(RHS.Symbol);
   });
   MissingIncludes.erase(llvm::unique(MissingIncludes), MissingIncludes.end());
   std::vector UnusedIncludes =

diff  --git a/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test 
b/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
index 4b2208ba3e146..b7e9661b79b08 100644
--- a/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
+++ b/clang-tools-extra/clangd/test/include-cleaner-batch-fix.test
@@ -33,14 +33,14 @@
 # CHECK-NEXT: "diagnostics": [
 # CHECK-NEXT:   {
 # CHECK-NEXT: "code": "missing-includes",
-# CHECK-NEXT: "message": "No header providing \"Bar\" is directly 
included (fixes available)",
+# CHECK-NEXT: "message": "No header providing \"Foo\" is directly 
included (fixes available)",
 # CHECK-NEXT: "range": {
 # CHECK-NEXT:   "end": {
-# CHECK-NEXT: "character": 14,
+# CHECK-NEXT: "character": 4,
 # CHECK-NEXT: "line": 2
 # CHECK-NEXT:   },
 # CHECK-NEXT:   "start": {
-# CHECK-NEXT: "character": 11,
+# CHECK-NEXT: "character": 1,
 # CHECK-NEXT: "line": 2
 # CHECK-NEXT:   }
 # CHECK-NEXT: },
@@ -49,14 +49,14 @@
 # CHECK-NEXT:   },
 # CHECK-NEXT:   {
 # CHECK-NEXT: "code": "missing-includes",
-# CHECK-NEXT: "message": "No header providing \"Foo\" is directly 
included (fixes available)",
+# CHECK-NEXT: "message": "No header providing \"Bar\" is directly 
included (fixes available)",
 # CHECK-NEXT: "range": {
 # CHECK-NEXT:   "end": {
-# CHECK-NEXT: "character": 4,
+# CHECK-NEXT: "character": 14,
 # CHECK-NEXT: "line": 2
 # CHECK-NEXT:   },
 # CHECK-NEXT:   "start": {
-# CHECK-NEXT: "character": 1,
+# CHECK-NEXT: "character": 11,
 # CHECK-NEXT: "line": 2
 # CHECK-NEXT:   }
 # CHECK-NEXT: },



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


[PATCH] D149165: [clangd] Deduplicate missing-include findings

2023-05-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks @ArturGainullin ! you're right, i've sent out 
5e74a3dc2da879d98204f2360e2e33571b93b91b 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149165

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


[clang] ea3a870 - Fix the clang sphinx bot

2023-05-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-05-01T07:31:03-04:00
New Revision: ea3a8700328050a4dec29904b2c72d53a3be0660

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

LOG: Fix the clang sphinx bot

Addresses the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/43478

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 9f3dcb1cee419..f62350f33013c 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2344,7 +2344,7 @@ The attribute will be rejected unless
 is enabled under the ``-mrvv-vector-bits`` flag. ``__riscv_v_fixed_vlen`` can
 only be a power of 2 between 64 and 65536.
 
-Only `*m1_t`(LMUL=1) types are supported at this time.
+Only ``*m1_t`` (LMUL=1) types are supported at this time.
 }];
 }
 



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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-01 Thread Rishabh Bali via Phabricator via cfe-commits
Ris-Bali updated this revision to Diff 518425.
Ris-Bali marked 2 inline comments as done.
Ris-Bali added a comment.

Removed redundant code


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

https://reviews.llvm.org/D149514

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,17 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible 
integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+  return a[0];
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32); 
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7979,7 +7979,8 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+/// Type-check first argument normally.
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
 TheCall->setArg(0, FirstArgResult.get());
   }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,9 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,17 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+  return a[0];
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32); 
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7979,7 +7979,8 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+/// Type-check first argument normally.
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
 TheCall->setArg(0, FirstArgResult.get());
   }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,9 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148458: [clang-tidy][NFC] Split bugprone-exception-escape tests

2023-05-01 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

In D148458#4309010 , @isuckatcs wrote:

> Do we really want to split these two functions apart to different test files? 
> Is this really NFC?

Yes, `throw specifier` is removed in C++17, split allows to support C++17 and 
above in main test file

In D148458#4309010 , @isuckatcs wrote:

> The way `ExceptionEscapeCheck` works is that it creates an 
> `ExceptionAnalyzer` upon instantiation.

And ? This has nothing to do with test split.

In D148458#4309010 , @isuckatcs wrote:

> //By the way upon looking at the constructor of the check I see that 
> `std::bad_alloc` is always ignored.
> Maybe we want to turn this into an option, so that users can enable it if 
> they want.//

Not a scope of this change, please raise an issue.

> `ExceptionAnalyzer` caches functions based on their `FunctionDecl *` in
> `std::map FunctionCache;`.
>
> The `FunctionDecl` lives in the AST of the translation unit, so the same 
> function declaration in two
> different translation units will have different `FunctionDecl *`s. //Maybe 
> `ODRHash` would be more
> suitable to be used as key in the map.//
>
> By moving throwing functions into a different TU than non-throwing functions, 
> I think the correctness
> of the caching inside `ExceptionAnalyzer` no longer will be tested properly. 
> Maybe this is something
> we want to preserve.

Those tests never tested caching (not failing if you disable cache), and here 
cache will be executed on things
like `recursion_helper` anyway. I see no issue here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148458

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


[PATCH] D93031: Enable fexec-charset option

2023-05-01 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D93031#4308764 , @barannikov88 
wrote:

> @abhina.sreeskantharajan
> What is the status of this patch?

Hello, I was waiting for the CharSetConverter patch to land. Now that this 
patch has landed https://reviews.llvm.org/D148821 to add limited EBCDIC <-> 
UTF-8 conversion support, I have started to refactor my patch to use this 
instead. This implementation also heavily relies on iconv support which is 
still being discussed in the CharSet Converter RFC here 
https://discourse.llvm.org/t/rfc-adding-a-charset-converter-to-the-llvm-support-library/69795/16


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D142401: [Clang] Fix a crash when recursively callig a default member initializer.

2023-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D142401#4307493 , @cor3ntin wrote:

> I don't think this is actually testable, ultimately we may run out of stack
> any way, the warning (when emitted) even say so.

Okay, that's a fair point and makes my suggestion invalid. I think you're 
right, testing this consistently will be tricky -- LGTM once the test is 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142401

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


[PATCH] D149561: [clang-format] Recognize Verilog edge identifiers

2023-05-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Could you add anotator tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149561

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-01 Thread Rishabh Bali via Phabricator via cfe-commits
Ris-Bali marked an inline comment as done.
Ris-Bali added a comment.

I have made the requested changes. Please do let me know if any other changes 
are required


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

https://reviews.llvm.org/D149514

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


[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142630

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


[PATCH] D143334: [clang][Interp] Fix diagnosing uninitialized ctor record arrays

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143334

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


[PATCH] D144164: [clang][Interp] Handle PtrMemOps

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144164

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144457

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


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D144943

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


[PATCH] D146030: [clang][Interp] Handle LambdaExprs

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146030

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


[PATCH] D147591: [clang][Interp] Handle CXXTemporaryObjectExprs

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147591

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


[PATCH] D147621: [clang][Interp] Start handling mutable record members

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147621

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


[PATCH] D147840: [clang][Interp] Handle DiscardResult for DeclRef- and ParenExprs

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D147840

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


[PATCH] D148614: [clang][Interp] Add frame depth checking

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D148614

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


[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148689

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


[PATCH] D148690: [clang][Interp] Handle __extension__ unary operators

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148690

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


[PATCH] D148982: [clang][Interp] Fix ignoring conditional operators

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148982

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


[PATCH] D149133: [clang][Interp] BaseToDerived casts

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D149133

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


[PATCH] D149013: [clang][Interp] Check pointers when accessing base class

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149013

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


[PATCH] D149149: [clang][Interp] Check one-past-the-end pointers in GetPtrField

2023-05-01 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149149

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs added inline comments.



Comment at: libcxxabi/test/test_demangle.pass.cpp:10921
 {"_ZNK5clang4Type10isRealTypeEv", "clang::Type::isRealType() const"},
-{"_ZNK5clang4Type16isArithmeticTypeEv", "clang::Type::isArithmeticType() 
const"},
+{"_ZNK5clang4Type16isArithmeticTypeEv", 
"clang::Type::isArithmeticType(clang::ASTContext&) const"},
 {"_ZNK5clang4Type12isScalarTypeEv", "clang::Type::isScalarType() const"},

Forgot to update the mangled name as these tests don't seem to run locally with 
cmake check-all 


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

https://reviews.llvm.org/D149573

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


[PATCH] D142967: [clangd] Introduce source.organizeImports code action.

2023-05-01 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1035
   }
+  if (KindAllowed(CodeAction::SOURCE_ORGANIZE_IMPORT)) {
+std::lock_guard Lock(FixItsMutex);

instead of doing this in here, what about introducing a new "tweak" that'll 
perform include-cleaner fixes?
Pros are:
- We can use it in places that don't use LSPServer.
- We can later on extend "organize imports" behaviour to do other things if 
needed.
- Results will be always up-to-date, as we can use the AST and compute the 
fixes. rather than making use of the "latest" cached version.
- Implementation would be a little bit neater (and contained), as we can just 
re-use the existing components in IncludeCleaner, rather than doing some ad-hoc 
matching & retrieval.

WDYT?



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1072-1074
+  AddFix(RemoveAllUnused);
+  AddFix(AddAllMissing);
+  AddFix(FixAll);

what does the UI look like when there are multiple code actions with "organize 
imports" kind?
e.g. 1&2 can actually be applied together, but 3rd one can't be combined with 
others, and in theory these can also be triggered on save (if the user opts 
in). so I am not sure if having multiple code actions, especially when they 
can't be merged together, really makes much sense on the editor side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142967

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-01 Thread Yurong via Phabricator via cfe-commits
yronglin added reviewers: rsmith, rjmccall.
yronglin added a comment.

Looks good from my side




Comment at: clang/lib/Sema/SemaChecking.cpp:7987
+  return true;
 TheCall->setArg(0, FirstArgResult.get());
   }

Can we add a comments here that we ignored the in-place updating for 1st arg 
from checkBuiltinArgument?



Comment at: clang/test/Sema/builtin-assume-aligned.c:79
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};

Please add a test for function type


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

https://reviews.llvm.org/D149514

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


[PATCH] D149585: [clang][dataflow] Optimize case of degenerate `do-while` loops.

2023-05-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, gribozavr2, sgatev.
Herald added subscribers: martong, rnkovacs.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

In general, the iteration algorithm would be closer to optimal if it stabilized
loop bodies before visiting their successors. There is a special case of this
situation which is particularly problematic in practice: degenerate loops of the
form `do { ... } while(0)`, which are used in some macro definitions, for
syntactic reasons.  When a series of these loops appear in sequence, as in uses
of logging or tracing macro, the resulting iteration can become exponential in
running time.

This patch is a short term fix for the particular degenerate case. Long-term, we
intend to implement an iteration order (like Bourdoncle's WTO) which takes loop
stabilization into account.

Issue #60273.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149585

Files:
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp


Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -20,6 +20,7 @@
 
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/Stmt.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Analysis/Analyses/PostOrderCFGView.h"
 #include "clang/Analysis/CFG.h"
@@ -34,6 +35,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
 
 #define DEBUG_TYPE "clang-dataflow"
 
@@ -50,6 +52,15 @@
   return BlockPos - Pred.succ_begin();
 }
 
+// Detects a degenerate `do-while` loop of the form `do { ... } while(0)`. This
+// form is sometimes used in macro definitions.
+static bool isDegenerateDoWhile(const CFGBlock &B) {
+  if (const auto *D = dyn_cast_or_null(B.getTerminatorStmt()))
+if (const auto *Cond = dyn_cast(D->getCond()))
+  return Cond->getValue().isZero();
+  return false;
+}
+
 static bool isLoopHead(const CFGBlock &B) {
   if (const auto *T = B.getTerminatorStmt())
 switch (T->getStmtClass()) {
@@ -468,7 +479,15 @@
 if (Block->hasNoReturnElement())
   continue;
 
-Worklist.enqueueSuccessors(Block);
+if (isDegenerateDoWhile(*Block) && Block->succ_size() == 2)
+  // Visit the loop body only. Avoid visiting the successor of the loop to
+  // ensure that the body is visited first. Otherwise, the successor will
+  // likely be revisited after the loop body. When a series of these loops
+  // appear in sequence (such as with the use of certain macros), the 
wasted
+  // work can result in exponential running times.
+  Worklist.enqueueBlock(*Block->succ_begin());
+else
+  Worklist.enqueueSuccessors(Block);
   }
   // FIXME: Consider evaluating unreachable basic blocks (those that have a
   // state set to `std::nullopt` at this point) to also analyze dead code.


Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -20,6 +20,7 @@
 
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/Stmt.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Analysis/Analyses/PostOrderCFGView.h"
 #include "clang/Analysis/CFG.h"
@@ -34,6 +35,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
 
 #define DEBUG_TYPE "clang-dataflow"
 
@@ -50,6 +52,15 @@
   return BlockPos - Pred.succ_begin();
 }
 
+// Detects a degenerate `do-while` loop of the form `do { ... } while(0)`. This
+// form is sometimes used in macro definitions.
+static bool isDegenerateDoWhile(const CFGBlock &B) {
+  if (const auto *D = dyn_cast_or_null(B.getTerminatorStmt()))
+if (const auto *Cond = dyn_cast(D->getCond()))
+  return Cond->getValue().isZero();
+  return false;
+}
+
 static bool isLoopHead(const CFGBlock &B) {
   if (const auto *T = B.getTerminatorStmt())
 switch (T->getStmtClass()) {
@@ -468,7 +479,15 @@
 if (Block->hasNoReturnElement())
   continue;
 
-Worklist.enqueueSuccessors(Block);
+if (isDegenerateDoWhile(*Block) && Block->succ_size() == 2)
+  // Visit the loop body only. Avoid visiting the successor of the loop to
+  // ensure that the body is visited first. Otherwise, the successor will
+  // likely be revisited after the loop body. When a series of these loops
+  // appear in sequence (such as with the use of certain macros), the wasted
+  // work can result i

[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Generally looks good to me, but there were a few minor things. Do you need 
someone to commit on your behalf once those are addressed? If so, what name and 
email address would you like used for patch attribution?




Comment at: clang/docs/ReleaseNotes.rst:343
+  ``__builtin_assume_aligned``.
+  (`#62305 `)
 





Comment at: clang/lib/Sema/SemaChecking.cpp:7982-7983
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+/// Type-check first argument normally.
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;

The comment doesn't really add too much value, so removing it.



Comment at: clang/test/Sema/builtin-assume-aligned.c:79
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};

yronglin wrote:
> Please add a test for function type
+1, test to make sure function to pointer decay happens.



Comment at: clang/test/Sema/builtin-assume-aligned.c:75
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{passing 
'int' to parameter of incompatible type 'int *'}}
+  return a[0];

barannikov88 wrote:
> The expected type is not `int *`, it is `cost void *` (according to the 
> definition of the builtin in Builtins.def).
> 
The GCC documentation for this builtin says `const void *`, Clang has no 
documentation for this one specifically.


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

https://reviews.llvm.org/D149514

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


[PATCH] D149548: [IR] Update to use new shufflevector semantics

2023-05-01 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito updated this revision to Diff 518434.
ManuelJBrito added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change is visible in clang in particular in codegen for the vec_promote 
builtin.
It now produces poison instead of undef for the undefined elements.
I think this is OK according to IBM's 
documentation[https://www.ibm.com/docs/en/epfz/5.3?topic=book-semantics]:

> When a result or behavior is undefined, it is something you “must not” do.
> Use of an undefined feature is likely to produce different results on 
> different > implementations or releases of a PL/I product.
> The application program is considered to be in error.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

Files:
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/test/Transforms/InstCombine/shufflevec-constant.ll

Index: llvm/test/Transforms/InstCombine/shufflevec-constant.ll
===
--- llvm/test/Transforms/InstCombine/shufflevec-constant.ll
+++ llvm/test/Transforms/InstCombine/shufflevec-constant.ll
@@ -18,7 +18,7 @@
 
 define <4 x i1> @shuffle_undef_fixed() {
 ; CHECK-LABEL: @shuffle_undef_fixed(
-; CHECK-NEXT:ret <4 x i1> undef
+; CHECK-NEXT:ret <4 x i1> poison
 ;
   %S = shufflevector <4 x i1> zeroinitializer, <4 x i1> zeroinitializer, <4 x i32> undef
   ret <4 x i1> %S
@@ -26,7 +26,7 @@
 
 define  @suffle_undef_scalable() {
 ; CHECK-LABEL: @suffle_undef_scalable(
-; CHECK-NEXT:ret  undef
+; CHECK-NEXT:ret  poison
 ;
   %S = shufflevector  zeroinitializer,  zeroinitializer,  undef
   ret  %S
Index: llvm/lib/IR/Instructions.cpp
===
--- llvm/lib/IR/Instructions.cpp
+++ llvm/lib/IR/Instructions.cpp
@@ -2290,7 +2290,7 @@
   SmallVector MaskConst;
   for (int Elem : Mask) {
 if (Elem == PoisonMaskElem)
-  MaskConst.push_back(UndefValue::get(Int32Ty));
+  MaskConst.push_back(PoisonValue::get(Int32Ty));
 else
   MaskConst.push_back(ConstantInt::get(Int32Ty, Elem));
   }
Index: llvm/lib/IR/ConstantFold.cpp
===
--- llvm/lib/IR/ConstantFold.cpp
+++ llvm/lib/IR/ConstantFold.cpp
@@ -710,9 +710,9 @@
   ElementCount::get(MaskNumElts, isa(V1VTy));
   Type *EltTy = V1VTy->getElementType();
 
-  // Undefined shuffle mask -> undefined value.
+  // Poison shuffle mask -> poison value.
   if (all_of(Mask, [](int Elt) { return Elt == PoisonMaskElem; })) {
-return UndefValue::get(VectorType::get(EltTy, MaskEltCount));
+return PoisonValue::get(VectorType::get(EltTy, MaskEltCount));
   }
 
   // If the mask is all zeros this is a splat, no need to go through all
Index: clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
===
--- clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
+++ clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
@@ -102,10 +102,10 @@
   // CHECK-ASM: vlvgg
 
   vf = vec_promote(f, idx);
-  // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 %{{.*}}
+  // CHECK: insertelement <4 x float> poison, float %{{.*}}, i32 %{{.*}}
   // CHECK-ASM: vlvgf
   vd = vec_promote(d, idx);
-  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 %{{.*}}
+  // CHECK: insertelement <2 x double> poison, double %{{.*}}, i32 %{{.*}}
   // CHECK-ASM: vlvgg
 
   vf = vec_insert_and_zero(cptrf);
Index: clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
===
--- clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
+++ clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-constrained.c
@@ -70,10 +70,10 @@
   // CHECK-ASM: vlvgg
 
   vf = vec_promote(f, idx);
-  // CHECK: insertelement <4 x float> undef, float %{{.*}}, i32 %{{.*}}
+  // CHECK: insertelement <4 x float> poison, float %{{.*}}, i32 %{{.*}}
   // CHECK-ASM: vlvgf
   vd = vec_promote(d, idx);
-  // CHECK: insertelement <2 x double> undef, double %{{.*}}, i32 %{{.*}}
+  // CHECK: insertelement <2 x double> poison, double %{{.*}}, i32 %{{.*}}
   // CHECK-ASM: vlvgg
 
   vf = vec_insert_and_zero(cptrf);
Index: clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
===
--- clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
+++ clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
@@ -166,31 +166,31 @@
   // CHECK-ASM: vlvgg
 
   vsc = vec_promote(sc, idx);
-  // CHECK: insertelement <16 x i8> undef, i8 %{{.*}}, i32 %{{

[PATCH] D133202: [Clang] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2023-05-01 Thread Yurong via Phabricator via cfe-commits
yronglin marked 2 inline comments as done.
yronglin added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:7651-7652
+  Expr *FirstArg = TheCall->getArg(0);
+  if (auto *CE = dyn_cast(FirstArg))
+FirstArg = CE->getSubExprAsWritten();
 

rsmith wrote:
> rjmccall wrote:
> > yronglin wrote:
> > > rjmccall wrote:
> > > > rsmith wrote:
> > > > > This looks very suspicious to me: this will remove a cast expression 
> > > > > that was written in the source code from the AST. That loses source 
> > > > > fidelity, can give the wrong answer if the cast changed the value 
> > > > > (such as a C++ derived-to-base conversion to a non-primary base 
> > > > > class), and in any case this is only done once where there could be 
> > > > > multiple explicit casts written on an argument to the builtin, so if 
> > > > > it's necessary, then it's not being done fully.
> > > > > 
> > > > > Can this be removed?
> > > > Somehow I missed this in my review.  Yes, this line should be 
> > > > unnecessary, and as you say, it is definitely wrong.
> > > CodeGen need real `user-written-type` to generate 
> > > `__ubsan_handle_alignment_assumption ` 's arg, but not `const void *`
> > Because we're using custom type-checking here, there is no conversion to 
> > `const void *` in the first place; that conversion was an artifact of the 
> > earlier implementation.
> > 
> > Also, if the previous code in CodeGen looked like this, then it was buggy: 
> > it is incorrect in the case that someone wrote `(const void*) foo` as the 
> > argument, because it would inappropriately look through the explicit, 
> > user-provided cast.
> The old implementation could get the pointer value wrong, not only the 
> alignment. For example:
> ```
> struct A { virtual ~A(); };
> 
> void *f(A *a) {
>   // Incorrectly returns `a` rather than the address of the complete object.
>   return __builtin_assume_aligned(dynamic_cast(a), 8);
> }
> ```
> The new implementation gets the pointer value wrong in more cases, such as:
> ```
> struct A { int n; };
> struct B { int n; };
> struct C : A, B {};
> 
> void *f(C *c) {
>   // Incorrectly returns `c` rather than the address of the B base class.
>   return __builtin_assume_aligned((B*)c, 8);
> }
> ```
Thanks for your tips, and is this an error in clang, 
https://godbolt.org/z/91qxq73Mb, if lose return 0 in main, ubsan will emit an 
error, but it will pass when there has a return statement. and I have submit an 
issue https://github.com/llvm/llvm-project/issues/62478


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D145435: [clang-format] Choose style (file) from within code for use in IDEs

2023-05-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

if we don't plan on fixing the issues please abandon the review


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

https://reviews.llvm.org/D145435

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


[PATCH] D125171: [clang-format] Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2023-05-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:347
+IO.enumCase(Value, "false", FormatStyle::FPBS_Leave);
+IO.enumCase(Value, "true", FormatStyle::FPBS_Always);
+  }

yes remove these... this is why you need to mark the comments done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125171

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


[PATCH] D149464: [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

2023-05-01 Thread Samira Bazuzi via Phabricator via cfe-commits
bazuzi added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:189
 
+  /// Deprecated. Use *getDataflowAnalysisContext().getOptions().Log instead.
   Logger &logger() const { return *DACtx->getOptions().Log; }

xazax.hun wrote:
> Any reason for a comment as opposed to the deprecated attribute? 
I couldn't tell exactly what the conventions were or whether all of the chained 
replacements could be used as the FIX very well.

If you can confirm that `LLVM_DEPRECATED("DataflowAnalysisContext is now 
directly exposed.", "*getDataflowAnalysisContext().getOptions().Log")`, 
`LLVM_DEPRECATED(..., "getDataflowAnalysisContext().arena")`, etc. will provide 
useful fixes, happy to replace with those. Or with replacements just in the MSG 
and "" for FIX otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149464

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


[PATCH] D149562: [clang-format] Stop comment disrupting indentation of Verilog ports

2023-05-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/include/clang/Format/Format.h:4027
+  /// is probably for the port on the following line instead of the parenthesis
+  /// it follows.
   /// \code

This seems an odd corner case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149562

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


[PATCH] D149165: [clangd] Deduplicate missing-include findings

2023-05-01 Thread Artur Gainullin via Phabricator via cfe-commits
ArturGainullin added a comment.

In D149165#4309463 , @kadircet wrote:

> Thanks @ArturGainullin ! you're right, i've sent out 
> 5e74a3dc2da879d98204f2360e2e33571b93b91b 
> .

@kadircet Thanks a lot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149165

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


[PATCH] D149585: [clang][dataflow] Optimize case of degenerate `do-while` loops.

2023-05-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel abandoned this revision.
ymandel added a comment.

This approach is buggy. Pulling back until I have a proper fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149585

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


[PATCH] D148944: [clang][Driver] Fix crash with unsupported architectures in MinGW and CrossWindows.

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

LGTM. If you don’t have commit access, please say your preferred git author 
name for the commit, i.e. `Real Name `.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148944

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


[PATCH] D148997: [clang] Add a new annotation token: annot_repl_input_end

2023-05-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 518448.
junaire added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148997

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp

Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -320,6 +320,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   // Stop before we change submodules. They generally indicate a "good"
   // place to pick up parsing again (except in the special case where
   // we're trying to skip to EOF).
@@ -616,8 +617,8 @@
 
   // Skip over the EOF token, flagging end of previous input for incremental
   // processing
-  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
-ConsumeToken();
+  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::annot_repl_input_end))
+ConsumeAnnotationToken();
 
   Result = nullptr;
   switch (Tok.getKind()) {
@@ -697,6 +698,7 @@
 return false;
 
   case tok::eof:
+  case tok::annot_repl_input_end:
 // Check whether -fmax-tokens= was reached.
 if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
   PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -543,9 +543,25 @@
 return ParseCaseStatement(StmtCtx, /*MissingCase=*/true, Expr);
   }
 
-  // Otherwise, eat the semicolon.
-  ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
-  return handleExprStmt(Expr, StmtCtx);
+  Token *CurTok = nullptr;
+  // If we're parsing an ExprStmt and the last semicolon is missing and the
+  // incremental externsion is enabled and we're reaching the end, consider we
+  // want to do value printing. Note this is only enable in C++ mode
+  // since part of the implementation requires C++ language features.
+  //
+  // Note we shouldn't eat the token since the callback need it.
+  if (PP.isIncrementalProcessingEnabled() &&
+  Tok.is(tok::annot_repl_input_end) && Actions.getLangOpts().CPlusPlus)
+CurTok = &Tok;
+  else
+// Otherwise, eat the semicolon.
+ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
+
+  StmtResult R = handleExprStmt(Expr, StmtCtx);
+  if (CurTok && !R.isInvalid())
+CurTok->setAnnotationValue(R.get());
+
+  return R;
 }
 
 /// ParseSEHTryBlockCommon
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2069,6 +2069,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   return;
 
 default:
@@ -5453,6 +5454,13 @@
 
   SmallVector DeclsInGroup;
   DeclsInGroup.push_back(Actions.ActOnTopLevelStmtDecl(R.get()));
+
+  if (Tok.is(tok::annot_repl_input_end) &&
+  Tok.getAnnotationValue() != nullptr) {
+ConsumeAnnotationToken();
+cast(DeclsInGroup.back())->setValuePrinting();
+  }
+
   // Currently happens for things like  -fms-extensions and use `__if_exists`.
   for (Stmt *S : Stmts)
 DeclsInGroup.push_back(Actions.ActOnTopLevelStmtDecl(S));
Index: clang/lib/Parse/ParseCXXInlineMethods.cpp
===
--- clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -836,6 +836,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   // Ran out of tokens.
   return false;
 
@@ -1242,6 +1243,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   // Ran out of tokens.
   return false;
 
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -535,13 +535,19 @@
   return LeavingSubmodule;
 }
   }
-
   // If this is the end of the main file, form an EOF token.
   assert(CurLexer && "Got EOF but no current lexer set!");
   const char *EndPos = getCurLexerEndPos();
   Result.startToken();
   CurLexer->BufferPtr = EndPos;
-  CurLexer

[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

2023-05-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 518450.
junaire added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -17,6 +17,7 @@
 #include "clang/AST/Mangle.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Interpreter/Value.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/Sema.h"
 
@@ -33,6 +34,11 @@
 #define CLANG_INTERPRETER_NO_SUPPORT_EXEC
 #endif
 
+int Global = 42;
+// JIT reports symbol not found on Windows without the visibility attribute.
+REPL_EXTERNAL_VISIBILITY int getGlobal() { return Global; }
+REPL_EXTERNAL_VISIBILITY void setGlobal(int val) { Global = val; }
+
 namespace {
 using Args = std::vector;
 static std::unique_ptr
@@ -276,8 +282,7 @@
   std::vector Args = {"-fno-delayed-template-parsing"};
   std::unique_ptr Interp = createInterpreter(Args);
 
-  llvm::cantFail(Interp->Parse("void* operator new(__SIZE_TYPE__, void* __p);"
-   "extern \"C\" int printf(const char*,...);"
+  llvm::cantFail(Interp->Parse("extern \"C\" int printf(const char*,...);"
"class A {};"
"struct B {"
"  template"
@@ -315,4 +320,93 @@
   free(NewA);
 }
 
+TEST(InterpreterTest, Value) {
+  std::unique_ptr Interp = createInterpreter();
+
+  Value V1;
+  llvm::cantFail(Interp->ParseAndExecute("int x = 42;"));
+  llvm::cantFail(Interp->ParseAndExecute("x", &V1));
+  EXPECT_TRUE(V1.isValid());
+  EXPECT_TRUE(V1.hasValue());
+  EXPECT_EQ(V1.getInt(), 42);
+  EXPECT_TRUE(V1.getType()->isIntegerType());
+  EXPECT_EQ(V1.getKind(), Value::K_Int);
+  EXPECT_FALSE(V1.isManuallyAlloc());
+
+  Value V2;
+  llvm::cantFail(Interp->ParseAndExecute("double y = 3.14;"));
+  llvm::cantFail(Interp->ParseAndExecute("y", &V2));
+  EXPECT_TRUE(V2.isValid());
+  EXPECT_TRUE(V2.hasValue());
+  EXPECT_EQ(V2.getDouble(), 3.14);
+  EXPECT_TRUE(V2.getType()->isFloatingType());
+  EXPECT_EQ(V2.getKind(), Value::K_Double);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V3;
+  llvm::cantFail(Interp->ParseAndExecute(
+  "struct S { int* p; S() { p = new int(42); } ~S() { delete p; }};"));
+  llvm::cantFail(Interp->ParseAndExecute("S{}", &V3));
+  EXPECT_TRUE(V3.isValid());
+  EXPECT_TRUE(V3.hasValue());
+  EXPECT_TRUE(V3.getType()->isRecordType());
+  EXPECT_EQ(V3.getKind(), Value::K_PtrOrObj);
+  EXPECT_TRUE(V3.isManuallyAlloc());
+
+  Value V4;
+  llvm::cantFail(Interp->ParseAndExecute("int getGlobal();"));
+  llvm::cantFail(Interp->ParseAndExecute("void setGlobal(int);"));
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", &V4));
+  EXPECT_EQ(V4.getInt(), 42);
+  EXPECT_TRUE(V4.getType()->isIntegerType());
+
+  Value V5;
+  // Change the global from the compiled code.
+  setGlobal(43);
+  llvm::cantFail(Interp->ParseAndExecute("getGlobal()", &V5));
+  EXPECT_EQ(V5.getInt(), 43);
+  EXPECT_TRUE(V5.getType()->isIntegerType());
+
+  // Change the global from the interpreted code.
+  llvm::cantFail(Interp->ParseAndExecute("setGlobal(44);"));
+  EXPECT_EQ(getGlobal(), 44);
+
+  Value V6;
+  llvm::cantFail(Interp->ParseAndExecute("void foo() {}"));
+  llvm::cantFail(Interp->ParseAndExecute("foo()", &V6));
+  EXPECT_TRUE(V6.isValid());
+  EXPECT_FALSE(V6.hasValue());
+  EXPECT_TRUE(V6.getType()->isVoidType());
+  EXPECT_EQ(V6.getKind(), Value::K_Void);
+  EXPECT_FALSE(V2.isManuallyAlloc());
+
+  Value V7;
+  llvm::cantFail(Interp->ParseAndExecute("foo", &V7));
+  EXPECT_TRUE(V7.isValid());
+  EXPECT_TRUE(V7.hasValue());
+  EXPECT_TRUE(V7.getType()->isFunctionProtoType());
+  EXPECT_EQ(V7.getKind(), Value::K_PtrOrObj);
+  EXPECT_FALSE(V7.isManuallyAlloc());
+
+  Value V8;
+  llvm::cantFail(Interp->ParseAndExecute("struct SS{ void f() {} };"));
+  llvm::cantFail(Interp->ParseAndExecute("&SS::f", &V8));
+  EXPECT_TRUE(V8.isValid());
+  EXPECT_TRUE(V8.hasValue());
+  EXPECT_TRUE(V8.getType()->isMemberFunctionPointerType());
+  EXPECT_EQ(V8.getKind(), Value::K_PtrOrObj);
+  EXPECT_TRUE(V8.isManuallyAlloc());
+
+  Value V9;
+  llvm::cantFail(Interp->ParseAndExecute("struct A { virtual int f(); };"));
+  llvm:

[PATCH] D141215: [clang-repl] Introduce Value to capture expression results

2023-05-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire marked an inline comment as done.
junaire added inline comments.



Comment at: clang/lib/Interpreter/Interpreter.cpp:211
+void __clang_Interpreter_SetValueNoAlloc(void*,void*,void*,unsigned long 
long);
+template 
+void __clang_Interpreter_SetValueCopyArr(T* Src, void* Placement, unsigned 
long Size) {

v.g.vassilev wrote:
> Can you add an `#ifdef __cplusplus` and add a value printing tests that run 
> in clang-repl in C mode?
After a private chat, we decide to disable the feature in C mode because it 
sounds like a bad idea to give C incomplete value printing support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-01 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:7985
   return true;
 TheCall->setArg(0, FirstArgResult.get());
   }

This looks suspicious to me, but I'm no clang expert.
Is it safe to ignore casts inserted by checkBuiltinArgument, or, in other words,
is it correct to pass an argument of incompatible type?



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

https://reviews.llvm.org/D149514

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


[PATCH] D93031: Enable fexec-charset option

2023-05-01 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D93031#4309546 , 
@abhina.sreeskantharajan wrote:

> In D93031#4308764 , @barannikov88 
> wrote:
>
>> @abhina.sreeskantharajan
>> What is the status of this patch?
>
> Hello, I was waiting for the CharSetConverter patch to land. Now that this 
> patch has landed https://reviews.llvm.org/D148821 to add limited EBCDIC <-> 
> UTF-8 conversion support, I have started to refactor my patch to use this 
> instead. This implementation also heavily relies on iconv support which is 
> still being discussed in the CharSet Converter RFC here 
> https://discourse.llvm.org/t/rfc-adding-a-charset-converter-to-the-llvm-support-library/69795/16

Thanks! I was beginning to think it is forgotten/abandoned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[clang] 99fe4d3 - Set EnableAIXExtendedAltivecABI in BackendUtils from LangOpts

2023-05-01 Thread Zarko Todorovski via cfe-commits

Author: Zarko Todorovski
Date: 2023-05-01T10:39:14-04:00
New Revision: 99fe4d38266ec2527266d996ac95e20c08f498f1

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

LOG: Set EnableAIXExtendedAltivecABI in BackendUtils from LangOpts

Fix a bug where after
github.com/llvm/llvm-project/commit/68dd51421f16f1e17cd453cb1730fcca99a6cfb7
refactor where we are not passing -mabi=vec-extabi to th backend.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index ea38cc402575a..a0cf26006d16f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -428,7 +428,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
   Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
-  Options.EnableAIXExtendedAltivecABI = 
CodeGenOpts.EnableAIXExtendedAltivecABI;
+  Options.EnableAIXExtendedAltivecABI = LangOpts.EnableAIXExtendedAltivecABI;
   Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
   Options.LoopAlignment = CodeGenOpts.LoopAlignment;
   Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf;



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


[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 518458.
junaire added a comment.

Fix AutoType sugar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_interpreter_runtime_printvalue.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterUtils.cpp
  clang/lib/Interpreter/InterpreterUtils.h
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValuePrinter.cpp
  clang/test/Interpreter/pretty-print.cpp

Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,163 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+extern "C" int printf(const char*,...);
+
+char c = 'a';
+c
+// CHECK: (char) 'a'
+
+const char* c_str = "Goodbye, world!";
+c_str
+// CHECK-NEXT: (const char *) "Goodbye, world!"
+
+const char* c_null_str = 0;
+c_null_str
+// CHECK-NEXT: (const char *) nullptr
+
+int x = 42;
+x
+// CHECK-NEXT: (int) 42
+
+&x
+// CHECK-NEXT: (int *) [[Addr:@0x.*]]
+
+x - 2
+// CHECK-NEXT: (int) 40
+
+float f = 4.2f;
+f
+// CHECK-NEXT: (float) 4.2f
+
+double d = 4.21;
+d
+// CHECK-NEXT: (double) 4.210
+
+struct S1{};
+S1 s1;
+s1
+// CHECK-NEXT: (S1 &) [[Addr:@0x.*]]
+
+S1{}
+// CHECK-NEXT: (S1) [[Addr:@0x.*]]
+
+struct S2 {int d;} E = {22};
+E
+// CHECK-NEXT: (struct S2 &) [[Addr:@0x.*]]
+E.d
+// CHECK-NEXT: (int) 22
+
+struct S3 { int* p; S3() { p = new int(42); } ~S3() { delete p; } };
+S3{}
+// CHECK-NEXT: (S3) [[Addr:@0x.*]]
+S3 s3;
+s3
+// CHECK-NEXT: (S3 &) [[Addr:@0x.*]]
+
+struct S4 { ~S4() { printf("~S4()\n"); }};
+S4{}
+// CHECK-NEXT: (S4) [[Addr:@0x.*]]
+
+enum Enum{ e1 = -12, e2, e3=33, e4, e5 = 33};
+e2
+// CHECK-NEXT: (Enum) (e2) : int -11
+::e1
+// CHECK-NEXT: (Enum) (e1) : int -12
+
+enum class Color { Black = 0, Red, Green };
+Color::Black
+// CHECK-NEXT: (Color) (Color::Black) : int 0
+
+int arr[3] = {1,2,3};
+arr
+// CHECK-NEXT: (int[3]) { 1, 2, 3 }
+
+auto Lambda1 = []{};
+Lambda1
+// CHECK-NEXT: ((lambda) &) [[Addr:@0x.*]]
+[]{}
+// CHECK-NEXT: ((lambda at input_line_81:1:1)) [[Addr:@0x.*]]
+
+template struct F{ enum {RET=F::RET*n} ; };
+template<> struct F<0> { enum {RET = 1}; };
+F<7>::RET
+// CHECK-NEXT: (F<7>::(unnamed enum at input_line_84:1:27)) (F<7>::RET) : unsigned int 5040
+
+int foo() { return 42; }
+foo()
+// CHECK-NEXT: (int) 42
+
+void bar() {}
+bar()
+
+struct S5 { int foo() { return 42; }};
+&S5::foo
+// CHECK-NEXT: (int (S5::*)()) Function [[Addr:@0x.*]]
+
+#include 
+
+auto p1 = std::make_shared(42);
+p1
+// CHECK-NEXT: (std::shared_ptr &) std::shared_ptr -> [[Addr:@0x.*]]
+
+auto p2 = std::make_unique(42);
+p2
+// CHECK-NEXT: (std::unique_ptr > &) std::unique_ptr -> [[Addr:@0x.*]]
+
+#include 
+std::array a{1, 2, 3};
+a
+// CHECK-NEXT: (std::array &) { 1, 2, 3 }
+
+#include 
+std::vector v = {7, 5, 16, 8};
+v
+// CHECK-NEXT: (std::vector &) { 7, 5, 16, 8 }
+
+#include 
+std::deque dq = {7, 5, 16, 8};
+dq
+// CHECK-NEXT: (std::deque &) { 7, 5, 16, 8 }
+
+#include 
+std::forward_list fl {3,4,5,6};
+fl
+// CHECK-NEXT: (std::forward_list &) { 3, 4, 5, 6 }
+
+#include 
+std::set z = {2,4,6,8};
+z
+// CHECK-NEXT: (std::set &) { 2, 4, 6, 8 }
+
+std::multiset e {3,2,1,2,4,7,3};
+e
+// CHECK-NEXT: (std::multiset &) { 1, 2, 2, 3, 3, 4, 7 }
+
+#include 
+std::string std_str = "Hello, world!";
+std_str
+// CHECK-NEXT: (std::string &) "Hello, world!"
+
+#include 
+std::pair pr(42,'a');
+pr
+// CHECK-NEXT: (std::pair &) { 42, 'a' }
+
+#include 
+std::tuple tu(42,3.14,'a');
+tu
+// CHECK-NEXT: (std::tuple &) { 42, 3.140, 'a' }
+
+#include 
+std::map m{{"CPU", 10}, {"GPU", 15}, {"RAM", 20}};
+m
+// CHECK-NEXT: (std::map &) { "CPU" => 10, "GPU" => 15, "RAM" => 20 }
+
+struct MyType {};
+std::string PrintValueRuntime(const MyType*) { return "My pretty printer!"; }
+MyType{}
+// CHECK-NEXT: (MyType) My pretty printer!
+%quit
+
Index: clang/lib/Interpreter/ValuePrinter.cpp
===
--- /dev/null
+++ clang/lib/Interpreter/ValuePrinter.cpp
@@ -0,0 +1,526 @@
+#include "InterpreterUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/PrettyPrinter.h"
+#include "clang/AST/Type.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Interpreter/Interpreter.h"
+#include "clang/Interpreter/Value.h"
+#include "clang/Parse/Pars

[PATCH] D146809: [clang-repl] Implement Value pretty printing

2023-05-01 Thread Jun Zhang via Phabricator via cfe-commits
junaire added inline comments.



Comment at: clang/test/Interpreter/pretty-print.cpp:107
+p2
+// CHECK-NEXT: (std::_MakeUniq::__single_object &) std::unique_ptr -> 
[[Addr:@0x.*]]
+

junaire wrote:
> Hi @mizvekov, do you have a clue about why it doesn't print the correct type? 
> So in `ValuePrinter.cpp:50` I dumped the type it shows:
> ```
> AutoType 0x62d000533c00 'typename _MakeUniq::__single_object' sugar
> `-ElaboratedType 0x62d000450500 'typename _MakeUniq::__single_object' 
> sugar
>   `-TypedefType 0x62d0004501e0 'std::_MakeUniq::__single_object' sugar
> |-Typedef 0x62d000450160 '__single_object'
> `-ElaboratedType 0x62d000450100 'unique_ptr' sugar
>   `-TemplateSpecializationType 0x62d0004500b0 'unique_ptr' sugar 
> unique_ptr
> |-TemplateArgument type 'int':'int'
> | `-SubstTemplateTypeParmType 0x62d00044fd50 'int' sugar typename 
> depth 0 index 0 _Tp
> |   |-ClassTemplateSpecialization 0x62d00044fa08 '_MakeUniq'
> |   `-BuiltinType 0x62119220 'int'
> `-RecordType 0x62d000450080 'class std::unique_ptr'
>   `-ClassTemplateSpecialization 0x62d00044ff70 'unique_ptr'
> ```
> 
> But in Cling it only has the RecordType. Do you think it's affected by your 
> type resugaring patches?
Looks like below diff fixes this:
```
diff --git a/clang/lib/Interpreter/InterpreterUtils.cpp 
b/clang/lib/Interpreter/InterpreterUtils.cpp
index 05e6be0e9df2..da5da55e8e95 100644
--- a/clang/lib/Interpreter/InterpreterUtils.cpp
+++ b/clang/lib/Interpreter/InterpreterUtils.cpp
@@ -425,7 +425,7 @@ QualType GetFullyQualifiedType(QualType QT, const 
ASTContext &Ctx) {
   // Strip deduced types.
   if (const auto *AutoTy = dyn_cast(QT.getTypePtr())) {
 if (!AutoTy->getDeducedType().isNull())
-  return GetFullyQualifiedType(AutoTy->getDeducedType(), Ctx);
+  return 
GetFullyQualifiedType(AutoTy->getDeducedType().getDesugaredType(Ctx), Ctx);
   }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs updated this revision to Diff 518468.
codemzs added a comment.
Herald added subscribers: mstorsjo, mgrang, fedor.sergeev.

Fix Clang format failures.


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

https://reviews.llvm.org/D149573

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGenCXX/cxx2b-fp-ext-std-names-p1467r9.cpp
  clang/test/Sema/cxx2b-fp-ext-std-names-p1467r9.cpp
  libcxxabi/test/test_demangle.pass.cpp

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread M. Zeeshan Siddiqui via Phabricator via cfe-commits
codemzs added a comment.

My change to libcxxabi/test/test_demangle.pass.cpp (last file in the change) is 
one is only one line i.e 
{"_ZNK5clang4Type16isArithmeticTypeERNS_10ASTContextE", 
"clang::Type::isArithmeticType(clang::ASTContext&) const"}, but running 
clang-format on it changes bunch of lines.


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

https://reviews.llvm.org/D149573

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


[clang] da0089c - [clang] Fix default initializers being ignored when initializing templated aggregate types

2023-05-01 Thread Alan Zhao via cfe-commits

Author: Alan Zhao
Date: 2023-05-01T09:27:52-07:00
New Revision: da0089c99ba1507b876cf3d2a205ba108aad65ff

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

LOG: [clang] Fix default initializers being ignored when initializing templated 
aggregate types

Previously, when checking whether an in-class initializer exists when
performing parenthesized aggregate initialization, Clang checks that the
output of FieldDecl::getInClassInitializer() is non-null. This is
incorrect; if the field is part of a templated type, then
getInClassInitializer() will return nullptr if we haven't called
Sem::BuildCXXDefaultInitExpr(...) before, even if
FieldDecl::hasInClassInitializer() returns true. The end result is that
Clang incorrectly ignores the in class initializer and
value-initializes the field. The fix therefore is to instead call
FieldDecl::hasInClassInitializer(), which is what we do for braced init
lists [0].

Before this patch, Clang does correctly recognize the in-class field
initializer in certain cases. This is Sema::BuildCXXDefaultInitExpr(...)
populates the in class initializer of the corresponding FieldDecl
object. Therefore, if that method was previously called with the same
FieldDecl object, as can happen with a decltype(...) or a braced list
initialization, FieldDecl::getInClassInitializer() will return a
non-null expression, and the field becomes properly initialized.

Fixes 62266

[0]: 
https://github.com/llvm/llvm-project/blob/be5f35e24f4c15caf3c4aeccddc54c52560c28a0/clang/lib/Sema/SemaInit.cpp#L685

Reviewed By: shafik

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaInit.cpp
clang/test/CodeGen/paren-list-agg-init.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6cc736205dd02..eaabe08599520 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -373,6 +373,9 @@ Bug Fixes to C++ Support
 - Fix bug in the computation of the ``__has_unique_object_representations``
   builtin for types with unnamed bitfields.
   (`#61336 `_)
+- Fix default member initializers sometimes being ignored when performing
+  parenthesized aggregate initialization of templated types.
+  (`#62266 `_)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index c218470d37ae6..55ef72de9b24e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5377,14 +5377,16 @@ static void TryOrBuildParenListInitialization(
   //   The remaining elements are initialized with their default member
   //   initializers, if any
   auto *FD = cast(SubEntity.getDecl());
-  if (Expr *ICE = FD->getInClassInitializer(); ICE && !VerifyOnly) {
-ExprResult DIE = S.BuildCXXDefaultInitExpr(FD->getLocation(), FD);
-if (DIE.isInvalid())
-  return false;
-S.checkInitializerLifetime(SubEntity, DIE.get());
-InitExprs.push_back(DIE.get());
+  if (FD->hasInClassInitializer()) {
+if (!VerifyOnly) {
+  ExprResult DIE = S.BuildCXXDefaultInitExpr(FD->getLocation(), 
FD);
+  if (DIE.isInvalid())
+return false;
+  S.checkInitializerLifetime(SubEntity, DIE.get());
+  InitExprs.push_back(DIE.get());
+}
 continue;
-  };
+  }
 }
 // Remaining class elements without default member initializers and
 // array elements are value initialized:

diff  --git a/clang/test/CodeGen/paren-list-agg-init.cpp 
b/clang/test/CodeGen/paren-list-agg-init.cpp
index a860196d8f500..7e06a466b6c0a 100644
--- a/clang/test/CodeGen/paren-list-agg-init.cpp
+++ b/clang/test/CodeGen/paren-list-agg-init.cpp
@@ -90,6 +90,15 @@ namespace gh61145 {
   };
 }
 
+namespace gh62266 {
+  // CHECK-DAG: [[STRUCT_H:%.*H.*]] = type { i32, i32 }
+  template 
+  struct H {
+int i;
+int j = J;
+  };
+}
+
 // CHECK-DAG: [[A1:@.*a1.*]] = internal constant [[STRUCT_A]] { i8 3, double 
2.00e+00 }, align 8
 constexpr A a1(3.1, 2.0);
 // CHECK-DAG: [[A2:@.*a2.*]] = internal constant [[STRUCT_A]] { i8 99, double 
0.00e+00 }, align 8
@@ -421,3 +430,17 @@ namespace gh61145 {
 make2<0>();
   }
 }
+
+namespace gh62266 {
+  // CHECK: define {{.*}} void {{.*foo20.*}}
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT: [[H:%.*h.*]] = alloca [[STRUCT_H]], align 4
+  // CHECK-NEXT: [[I:%.*i.*]] = getelementptr inbounds [[STRUCT_H]], ptr 
[[H]], i32 0, i32 0
+  // CHECK-NEXT: store i32 1, ptr [[I]], align 4
+  // CHEC

[PATCH] D149389: [clang] Fix default initializers being ignored when initializing templated aggregate types

2023-05-01 Thread Alan Zhao 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 rGda0089c99ba1: [clang] Fix default initializers being ignored 
when initializing templated… (authored by ayzhao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149389

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGen/paren-list-agg-init.cpp


Index: clang/test/CodeGen/paren-list-agg-init.cpp
===
--- clang/test/CodeGen/paren-list-agg-init.cpp
+++ clang/test/CodeGen/paren-list-agg-init.cpp
@@ -90,6 +90,15 @@
   };
 }
 
+namespace gh62266 {
+  // CHECK-DAG: [[STRUCT_H:%.*H.*]] = type { i32, i32 }
+  template 
+  struct H {
+int i;
+int j = J;
+  };
+}
+
 // CHECK-DAG: [[A1:@.*a1.*]] = internal constant [[STRUCT_A]] { i8 3, double 
2.00e+00 }, align 8
 constexpr A a1(3.1, 2.0);
 // CHECK-DAG: [[A2:@.*a2.*]] = internal constant [[STRUCT_A]] { i8 99, double 
0.00e+00 }, align 8
@@ -421,3 +430,17 @@
 make2<0>();
   }
 }
+
+namespace gh62266 {
+  // CHECK: define {{.*}} void {{.*foo20.*}}
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT: [[H:%.*h.*]] = alloca [[STRUCT_H]], align 4
+  // CHECK-NEXT: [[I:%.*i.*]] = getelementptr inbounds [[STRUCT_H]], ptr 
[[H]], i32 0, i32 0
+  // CHECK-NEXT: store i32 1, ptr [[I]], align 4
+  // CHECK-NEXT: [[J:%.*j.*]] = getelementptr inbounds [[STRUCT_H]], ptr 
[[H]], i32 0, i32 1
+  // CHECK-NEXT: store i32 2, ptr [[J]], align 4
+  // CHECK-NEXT: ret void
+  void foo20() {
+H<2> h(1);
+  }
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5377,14 +5377,16 @@
   //   The remaining elements are initialized with their default member
   //   initializers, if any
   auto *FD = cast(SubEntity.getDecl());
-  if (Expr *ICE = FD->getInClassInitializer(); ICE && !VerifyOnly) {
-ExprResult DIE = S.BuildCXXDefaultInitExpr(FD->getLocation(), FD);
-if (DIE.isInvalid())
-  return false;
-S.checkInitializerLifetime(SubEntity, DIE.get());
-InitExprs.push_back(DIE.get());
+  if (FD->hasInClassInitializer()) {
+if (!VerifyOnly) {
+  ExprResult DIE = S.BuildCXXDefaultInitExpr(FD->getLocation(), 
FD);
+  if (DIE.isInvalid())
+return false;
+  S.checkInitializerLifetime(SubEntity, DIE.get());
+  InitExprs.push_back(DIE.get());
+}
 continue;
-  };
+  }
 }
 // Remaining class elements without default member initializers and
 // array elements are value initialized:
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -373,6 +373,9 @@
 - Fix bug in the computation of the ``__has_unique_object_representations``
   builtin for types with unnamed bitfields.
   (`#61336 `_)
+- Fix default member initializers sometimes being ignored when performing
+  parenthesized aggregate initialization of templated types.
+  (`#62266 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/CodeGen/paren-list-agg-init.cpp
===
--- clang/test/CodeGen/paren-list-agg-init.cpp
+++ clang/test/CodeGen/paren-list-agg-init.cpp
@@ -90,6 +90,15 @@
   };
 }
 
+namespace gh62266 {
+  // CHECK-DAG: [[STRUCT_H:%.*H.*]] = type { i32, i32 }
+  template 
+  struct H {
+int i;
+int j = J;
+  };
+}
+
 // CHECK-DAG: [[A1:@.*a1.*]] = internal constant [[STRUCT_A]] { i8 3, double 2.00e+00 }, align 8
 constexpr A a1(3.1, 2.0);
 // CHECK-DAG: [[A2:@.*a2.*]] = internal constant [[STRUCT_A]] { i8 99, double 0.00e+00 }, align 8
@@ -421,3 +430,17 @@
 make2<0>();
   }
 }
+
+namespace gh62266 {
+  // CHECK: define {{.*}} void {{.*foo20.*}}
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT: [[H:%.*h.*]] = alloca [[STRUCT_H]], align 4
+  // CHECK-NEXT: [[I:%.*i.*]] = getelementptr inbounds [[STRUCT_H]], ptr [[H]], i32 0, i32 0
+  // CHECK-NEXT: store i32 1, ptr [[I]], align 4
+  // CHECK-NEXT: [[J:%.*j.*]] = getelementptr inbounds [[STRUCT_H]], ptr [[H]], i32 0, i32 1
+  // CHECK-NEXT: store i32 2, ptr [[J]], align 4
+  // CHECK-NEXT: ret void
+  void foo20() {
+H<2> h(1);
+  }
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5377,14 +5377,16 @@
   //   The remaining elements are initialized with their

[PATCH] D129951: adds `__disable_adl` attribute

2023-05-01 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

Ping (moving my pings from Thursday afternoon to Monday mornings)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2023-05-01 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko added a comment.

Friendly ping

@arphaman, @jansvoboda11, I have made the patch buildable on all platforms and 
have all tests passed. There was also a small fix (temp path for modules 
artefact) at the test that could fix its run on some platforms. Could you look 
at it? Does it have any issues on your side?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

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


[PATCH] D148274: [clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

2023-05-01 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 518479.
ayzhao added a comment.

rebase + fix merge conflicts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148274

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGen/paren-list-agg-init.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp

Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -9,7 +9,7 @@
 struct B {
   A a;
   int b[20];
-  int &&c; // expected-note {{reference member declared here}}
+  int &&c;
 };
 
 struct C { // expected-note 5{{candidate constructor}}
@@ -21,9 +21,9 @@
   int a;
 };
 
-struct E { // expected-note 3{{candidate constructor}}
-  struct F {
-F(int, int);
+struct E {
+  struct F { // expected-note 2{{candidate constructor}}
+F(int, int); // expected-note {{candidate constructor}}
   };
   int a;
   F f;
@@ -56,6 +56,22 @@
   int b[]; // expected-note {{initialized flexible array member 'b' is here}}
 };
 
+enum K { K0, K1, K2 };
+
+struct L {
+  K k : 1;
+};
+
+struct M {
+  struct N {
+private:
+N(int);
+// expected-note@-1 {{declared private here}}
+  };
+  int i;
+  N n;
+};
+
 union U {
   int a;
   char* b;
@@ -74,7 +90,7 @@
   // beforecxx20-warning@-1 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
 }
 
-void foo() {
+void foo(int n) {
   A a1(1954, 9, 21);
   // expected-error@-1 {{excess elements in struct initializer}}
   A a2(2.1);
@@ -96,9 +112,8 @@
   B b1(2022, {7, 8});
   // expected-error@-1 {{no viable conversion from 'int' to 'A'}}
   B b2(A(1), {}, 1);
-  // expected-error@-1 {{reference member 'c' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
-  // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
-  // beforecxx20-warning@-3 {{aggregate initialization of type 'B' from a parenthesized list of values is a C++20 extension}}
+  // beforecxx20-warning@-1 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
+  // beforecxx20-warning@-2 {{aggregate initialization of type 'B' from a parenthesized list of values is a C++20 extension}}
 
   C c(A(1), 1, 2, 3, 4);
   // expected-error@-1 {{array initializer must be an initializer list}}
@@ -130,7 +145,7 @@
   // expected-error@-1 {{excess elements in union initializer}}
 
   E e1(1);
-  // expected-error@-1 {{no matching constructor for initialization of 'E'}}
+  // expected-error@-1 {{no matching constructor for initialization of 'F'}}
 
   constexpr F f1(1);
   // expected-error@-1 {{constexpr variable 'f1' must be initialized by a constant expression}}
@@ -148,18 +163,29 @@
   A a7 = Construct('i', 2.2);
   // beforecxx20-note@-1 {{in instantiation of function template specialization 'Construct' requested here}}
 
+  L l(K::K2);
+  // expected-warning@-1 {{implicit truncation}}
+  // beforecxx20-warning@-2 {{aggregate initialization of type 'L' from a parenthesized list of values is a C++20 extension}}
+
   int arr4[](1, 2);
   // beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a parenthesized list of values is a C++20 extension}}
 
   int arr5[2](1, 2);
   // beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a parenthesized list of values is a C++20 extension}}
 
+  int arr6[n](1, 2, 3);
+  // expected-error@-1 {{variable-sized object may not be initialized}}
+
   I i(1, 2);
   // expected-error@-1 {{no matching constructor for initialization of 'I'}}
 
   J j(1, {2, 3});
   // expected-error@-1 {{initialization of flexible array member is not allowed}}
 
+  M m(1, 1);
+  // expected-error@-1 {{field of type 'N' has private constructor}}
+  // beforecxx20-warning@-2 {{aggregate initialization of type 'M' from a parenthesized list of values is a C++20 extension}}
+
   static_assert(__is_trivially_constructible(A, char, double));
   static_assert(__is_trivially_constructible(A, char, int));
   static_assert(__is_trivially_constructible(A, char));
@@ -221,5 +247,22 @@
 N n(43);
 // expected-error@-1 {{field of type 'L' has protected constructor}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'N' from a parenthesized list of values is a C++20 extension}}
+}
+
+namespace gh61567 {
+struct O {
+  int i;
+  int &&j;
+  // expected-note@-1 {{uninitialized reference member is here}}
+  int &&k = 1;
+};
+
+O o1(0, 0, 0); // no-error
+// beforecxx20-warning@-1 {{aggregate initialization of type 'O' from a parenthesized list of values is a C++20 extension}}
+
+O o2(0, 0); // no-e

[clang] 9b4faa1 - [clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

2023-05-01 Thread Alan Zhao via cfe-commits

Author: Alan Zhao
Date: 2023-05-01T10:02:15-07:00
New Revision: 9b4faa11c68be4b45ddf29acd575bb52a3c2fad7

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

LOG: [clang] Fix overly aggressive lifetime checks for parenthesized aggregate 
initialization

Before this patch, initialized class members would have the LifetimeKind
LK_MemInitializer, which does not allow for binding a temporary to a
reference. Binding to a temporary however is allowed in parenthesized
aggregate initialization, even if it leads to a dangling reference. To
fix this, we create a new EntityKind, EK_ParenAggInitMember, which has
LifetimeKind LK_FullExpression.

This patch does *not* attempt to diagnose dangling references as a
result of using this feature.

This patch also refactors TryOrBuildParenListInitialization(...) to
accomodate creating different InitializedEntity objects.

Fixes #61567

[0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html

Reviewed By: shafik

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Initialization.h
clang/lib/Sema/SemaAccess.cpp
clang/lib/Sema/SemaInit.cpp
clang/test/CodeGen/paren-list-agg-init.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index eaabe08599520..ec0dc0adc58b0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -373,9 +373,15 @@ Bug Fixes to C++ Support
 - Fix bug in the computation of the ``__has_unique_object_representations``
   builtin for types with unnamed bitfields.
   (`#61336 `_)
+<<< HEAD
 - Fix default member initializers sometimes being ignored when performing
   parenthesized aggregate initialization of templated types.
   (`#62266 `_)
+===
+- Fix overly aggressive lifetime checks for parenthesized aggregate
+  initialization.
+  (`#61567 `_)
+>>> c7422b289522 ([clang] Fix overly aggressive lifetime checks for 
parenthesized aggregate initialization)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7d0ee502eabfc..17585752edf8e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2126,7 +2126,8 @@ def err_init_conversion_failed : Error<
   "exception object|a member subobject|an array element|a new value|a value|a "
   "base class|a constructor delegation|a vector element|a block element|a "
   "block element|a complex element|a lambda capture|a compound literal "
-  "initializer|a related result|a parameter of CF audited function}0 "
+  "initializer|a related result|a parameter of CF audited function|a "
+  "structured binding|a member subobject}0 "
   "%
diff {of type $ with an %select{rvalue|lvalue}2 of type $|"
   "with an %select{rvalue|lvalue}2 of incompatible type}1,3"
   "%select{|: 
diff erent classes%
diff { ($ vs $)|}5,6"

diff  --git a/clang/include/clang/Sema/Initialization.h 
b/clang/include/clang/Sema/Initialization.h
index fcfb56f9731ef..2072cd8d1c3ef 100644
--- a/clang/include/clang/Sema/Initialization.h
+++ b/clang/include/clang/Sema/Initialization.h
@@ -123,6 +123,10 @@ class alignas(8) InitializedEntity {
 /// decomposition declaration.
 EK_Binding,
 
+/// The entity being initialized is a non-static data member subobject of 
an
+/// object initialized via parenthesized aggregate initialization.
+EK_ParenAggInitMember,
+
 // Note: err_init_conversion_failed in DiagnosticSemaKinds.td uses this
 // enum as an index for its first %select.  When modifying this list,
 // that diagnostic text needs to be updated as well.
@@ -227,8 +231,10 @@ class alignas(8) InitializedEntity {
 
   /// Create the initialization entity for a member subobject.
   InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent,
-bool Implicit, bool DefaultMemberInit)
-  : Kind(EK_Member), Parent(Parent), Type(Member->getType()),
+bool Implicit, bool DefaultMemberInit,
+bool IsParenAggInit = false)
+  : Kind(IsParenAggInit ? EK_ParenAggInitMember : EK_Member),
+Parent(Parent), Type(Member->getType()),
 Variable{Member, Implicit, DefaultMemberInit} {}
 
   /// Create the initialization entity for an array element.
@@ -388,6 +394,14 @@ class alignas(8) InitializedEntity {
 return InitializedEnti

[PATCH] D148274: [clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

2023-05-01 Thread Alan Zhao 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 rG9b4faa11c68b: [clang] Fix overly aggressive lifetime checks 
for parenthesized aggregate… (authored by ayzhao).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148274

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGen/paren-list-agg-init.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp

Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -9,7 +9,7 @@
 struct B {
   A a;
   int b[20];
-  int &&c; // expected-note {{reference member declared here}}
+  int &&c;
 };
 
 struct C { // expected-note 5{{candidate constructor}}
@@ -21,9 +21,9 @@
   int a;
 };
 
-struct E { // expected-note 3{{candidate constructor}}
-  struct F {
-F(int, int);
+struct E {
+  struct F { // expected-note 2{{candidate constructor}}
+F(int, int); // expected-note {{candidate constructor}}
   };
   int a;
   F f;
@@ -56,6 +56,22 @@
   int b[]; // expected-note {{initialized flexible array member 'b' is here}}
 };
 
+enum K { K0, K1, K2 };
+
+struct L {
+  K k : 1;
+};
+
+struct M {
+  struct N {
+private:
+N(int);
+// expected-note@-1 {{declared private here}}
+  };
+  int i;
+  N n;
+};
+
 union U {
   int a;
   char* b;
@@ -74,7 +90,7 @@
   // beforecxx20-warning@-1 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
 }
 
-void foo() {
+void foo(int n) {
   A a1(1954, 9, 21);
   // expected-error@-1 {{excess elements in struct initializer}}
   A a2(2.1);
@@ -96,9 +112,8 @@
   B b1(2022, {7, 8});
   // expected-error@-1 {{no viable conversion from 'int' to 'A'}}
   B b2(A(1), {}, 1);
-  // expected-error@-1 {{reference member 'c' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}}
-  // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
-  // beforecxx20-warning@-3 {{aggregate initialization of type 'B' from a parenthesized list of values is a C++20 extension}}
+  // beforecxx20-warning@-1 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
+  // beforecxx20-warning@-2 {{aggregate initialization of type 'B' from a parenthesized list of values is a C++20 extension}}
 
   C c(A(1), 1, 2, 3, 4);
   // expected-error@-1 {{array initializer must be an initializer list}}
@@ -130,7 +145,7 @@
   // expected-error@-1 {{excess elements in union initializer}}
 
   E e1(1);
-  // expected-error@-1 {{no matching constructor for initialization of 'E'}}
+  // expected-error@-1 {{no matching constructor for initialization of 'F'}}
 
   constexpr F f1(1);
   // expected-error@-1 {{constexpr variable 'f1' must be initialized by a constant expression}}
@@ -148,18 +163,29 @@
   A a7 = Construct('i', 2.2);
   // beforecxx20-note@-1 {{in instantiation of function template specialization 'Construct' requested here}}
 
+  L l(K::K2);
+  // expected-warning@-1 {{implicit truncation}}
+  // beforecxx20-warning@-2 {{aggregate initialization of type 'L' from a parenthesized list of values is a C++20 extension}}
+
   int arr4[](1, 2);
   // beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a parenthesized list of values is a C++20 extension}}
 
   int arr5[2](1, 2);
   // beforecxx20-warning@-1 {{aggregate initialization of type 'int[2]' from a parenthesized list of values is a C++20 extension}}
 
+  int arr6[n](1, 2, 3);
+  // expected-error@-1 {{variable-sized object may not be initialized}}
+
   I i(1, 2);
   // expected-error@-1 {{no matching constructor for initialization of 'I'}}
 
   J j(1, {2, 3});
   // expected-error@-1 {{initialization of flexible array member is not allowed}}
 
+  M m(1, 1);
+  // expected-error@-1 {{field of type 'N' has private constructor}}
+  // beforecxx20-warning@-2 {{aggregate initialization of type 'M' from a parenthesized list of values is a C++20 extension}}
+
   static_assert(__is_trivially_constructible(A, char, double));
   static_assert(__is_trivially_constructible(A, char, int));
   static_assert(__is_trivially_constructible(A, char));
@@ -221,5 +247,22 @@
 N n(43);
 // expected-error@-1 {{field of type 'L' has protected constructor}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'N' from a parenthesized list of values is a C++20 extension}}
+}
+
+namespace gh61567 {
+struct O {
+  int i;
+  int &&j;
+  // expected-note@-1 {{uninitialized reference member is here}}
+  int &&k = 1;
+};
+
+O o1(0, 0, 0)

[PATCH] D149596: [AIX][TLS] Relax front end diagnostics to accept the local-exec TLS model

2023-05-01 Thread Amy Kwan via Phabricator via cfe-commits
amyk created this revision.
amyk added reviewers: PowerPC, stefanp, kamaub, nemanjai.
amyk added projects: LLVM, PowerPC, clang.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
amyk requested review of this revision.
Herald added a subscriber: cfe-commits.

This patch relaxes the front end AIX diagnostics added in D102070 
 to accept the
local-exec TLS model, as we plan to support this model in a series of future 
patches.

The diagnostics are relaxed when `local-exec` is used as a compiler option to 
`-ftls-model=*`
and in the `__attribute__((tls_model("local-exec")))` attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149596

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/PowerPC/aix-tls-model.cpp
  clang/test/Sema/aix-attr-tls_model.c


Index: clang/test/Sema/aix-attr-tls_model.c
===
--- clang/test/Sema/aix-attr-tls_model.c
+++ clang/test/Sema/aix-attr-tls_model.c
@@ -8,4 +8,4 @@
 static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning
 static __thread int y __attribute((tls_model("local-dynamic"))); // 
expected-error {{TLS model 'local-dynamic' is not yet supported on AIX}}
 static __thread int y __attribute((tls_model("initial-exec"))); // 
expected-error {{TLS model 'initial-exec' is not yet supported on AIX}}
-static __thread int y __attribute((tls_model("local-exec"))); // 
expected-error {{TLS model 'local-exec' is not yet supported on AIX}}
+static __thread int y __attribute((tls_model("local-exec"))); // no-warning
Index: clang/test/CodeGen/PowerPC/aix-tls-model.cpp
===
--- clang/test/CodeGen/PowerPC/aix-tls-model.cpp
+++ clang/test/CodeGen/PowerPC/aix-tls-model.cpp
@@ -2,12 +2,12 @@
 // RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LD-ERROR
 // RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s 
-check-prefix=CHECK-IE-ERROR
-// RUN: not %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
 // RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD
 // RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-dynamic -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LD-ERROR
 // RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=initial-exec -emit-llvm  2>&1 | FileCheck %s 
-check-prefix=CHECK-IE-ERROR
-// RUN: not %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm 2>&1 | FileCheck %s 
-check-prefix=CHECK-LE-ERROR
+// RUN: %clang_cc1 %s -triple powerpc64-unknown-aix -target-cpu pwr8 
-ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE
 
 int z1 = 0;
 int z2;
@@ -23,4 +23,7 @@
 // CHECK-GD: @_ZZ1fvE1y = internal thread_local global i32 0
 // CHECK-LD-ERROR:  error: TLS model 'local-dynamic' is not yet supported on 
AIX
 // CHECK-IE-ERROR:  error: TLS model 'initial-exec' is not yet supported on AIX
-// CHECK-LE-ERROR:  error: TLS model 'local-exec' is not yet supported on AIX
+// CHECK-LE: @z1 ={{.*}} global i32 0
+// CHECK-LE: @z2 ={{.*}} global i32 0
+// CHECK-LE: @x ={{.*}} thread_local(localexec) global i32 0
+// CHECK-LE: @_ZZ1fvE1y = internal thread_local(localexec) global i32 0
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2033,7 +2033,7 @@
   }
 
   if (S.Context.getTargetInfo().getTriple().isOSAIX() &&
-  Model != "global-dynamic") {
+  Model != "global-dynamic" && Model != "local-exec") {
 S.Diag(LiteralLoc, diag::err_aix_attr_unsupported_tls_model) << Model;
 return;
   }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1891,7 +1891,7 @@
   if (Arg *A = Args.getLastArg(OPT_ftlsmodel_EQ)) {
 if (T.isOSAIX()) {
   StringRef Name = A->getValue();
-  if (Name != "global-dynamic")
+

[clang] f762798 - Fix ReleaseNotes.rst unresolved merge conflict

2023-05-01 Thread Alan Zhao via cfe-commits

Author: Alan Zhao
Date: 2023-05-01T10:26:15-07:00
New Revision: f762798599171efca03964f4371cc8104d2392f9

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

LOG: Fix ReleaseNotes.rst unresolved merge conflict

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ec0dc0adc58b..a3ee06ba1c22 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -373,15 +373,12 @@ Bug Fixes to C++ Support
 - Fix bug in the computation of the ``__has_unique_object_representations``
   builtin for types with unnamed bitfields.
   (`#61336 `_)
-<<< HEAD
 - Fix default member initializers sometimes being ignored when performing
   parenthesized aggregate initialization of templated types.
   (`#62266 `_)
-===
 - Fix overly aggressive lifetime checks for parenthesized aggregate
   initialization.
   (`#61567 `_)
->>> c7422b289522 ([clang] Fix overly aggressive lifetime checks for 
parenthesized aggregate initialization)
 
 Bug Fixes to AST Handling
 ^



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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-01 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[clang] 8f0dd4e - [clang] Canonicalize system headers in dependency file when -canonical-prefixes

2023-05-01 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-05-01T10:40:18-07:00
New Revision: 8f0dd4ef3ed2137d1e2554204127434fc46ee190

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

LOG: [clang] Canonicalize system headers in dependency file when 
-canonical-prefixes

Clang was writing paths to the dependency file that don't exist when using a 
sysroot with symlinks, causing everything to get rebuilt every time. This is 
reproducible on Linux by creating a symlink to '/', using that as the sysroot, 
and trying to build something with ninja that includes the C++ stdlib (e.g. a 
typical build of LLVM).

This fixes https://github.com/ninja-build/ninja/issues/1330 and somewhat 
matches gcc.

gcc canonicalizes system headers in dependency files under a 
-f[no-]canonical-system-headers, but it makes more sense to look at 
-canonical-prefixes.

D37954 was a previous attempt at this.

Reviewed By: hans

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

Added: 
clang/test/Driver/canonical-system-headers.c
clang/test/Preprocessor/Inputs/canonical-system-headers/a.h
clang/test/Preprocessor/canonical-system-headers.c

Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/DependencyOutputOptions.h
clang/include/clang/Frontend/Utils.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/DependencyFile.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8c80c7f5ff56a..182f0290736d8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5835,6 +5835,9 @@ let Flags = [CC1Option, NoDriverOption] in {
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
+def canonical_system_headers : Flag<["-"], "canonical-system-headers">,
+  HelpText<"Canonicalize system headers in dependency output">,
+  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h 
b/clang/include/clang/Frontend/DependencyOutputOptions.h
index e0f445bb5970c..e140ff9baa117 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -34,6 +34,8 @@ enum ExtraDepKind {
 class DependencyOutputOptions {
 public:
   unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
+  unsigned
+  CanonicalSystemHeaders : 1; ///< canonicalize system header dependencies.
   unsigned ShowHeaderIncludes : 1;   ///< Show header inclusions (-H).
   unsigned UsePhonyTargets : 1;  ///< Include phony targets for each
  /// dependency, which can avoid some 
'make'
@@ -85,10 +87,11 @@ class DependencyOutputOptions {
 
 public:
   DependencyOutputOptions()
-  : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0),
-ShowSkippedHeaderIncludes(0), HeaderIncludeFormat(HIFMT_Textual),
-HeaderIncludeFiltering(HIFIL_None) {}
+  : IncludeSystemHeaders(0), CanonicalSystemHeaders(0),
+ShowHeaderIncludes(0), UsePhonyTargets(0), AddMissingHeaderDeps(0),
+IncludeModuleFiles(0), ShowSkippedHeaderIncludes(0),
+HeaderIncludeFormat(HIFMT_Textual), HeaderIncludeFiltering(HIFIL_None) 
{
+  }
 };
 
 }  // end namespace clang

diff  --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 143cf4359f00b..8300e45d15fe5 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -41,6 +41,7 @@ class ExternalSemaSource;
 class FrontendOptions;
 class PCHContainerReader;
 class Preprocessor;
+class FileManager;
 class PreprocessorOptions;
 class PreprocessorOutputOptions;
 
@@ -79,11 +80,14 @@ class DependencyCollector {
   /// Return true if system files should be passed to sawDependency().
   virtual bool needSystemDependencies() { return false; }
 
+  /// Return true if system files should be canonicalized.
+  virtual bool shouldCanonicalizeSystemDependencies() { return false; }
+
   /// Add a dependency \p Filename if it has not been seen before and
   /// sawDependency() returns true.
   virtual void maybeAddDependency(StringRef Filename, bool FromModule,
   bool IsSystem, bool IsModuleFile,
-  bool IsMissing);
+  FileManager *FileMgr, bool IsMissing);
 
 protected:
   /// Return true if the filename was added to the list of dependencies, false
@@ -112,6 +116,10 @@ 

[PATCH] D149187: [clang] Canonicalize system headers in dependency file when -canonical-prefixes

2023-05-01 Thread Arthur Eubanks 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 rG8f0dd4ef3ed2: [clang] Canonicalize system headers in 
dependency file when -canonical-prefixes (authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149187

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/DependencyOutputOptions.h
  clang/include/clang/Frontend/Utils.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/test/Driver/canonical-system-headers.c
  clang/test/Preprocessor/Inputs/canonical-system-headers/a.h
  clang/test/Preprocessor/canonical-system-headers.c

Index: clang/test/Preprocessor/canonical-system-headers.c
===
--- /dev/null
+++ clang/test/Preprocessor/canonical-system-headers.c
@@ -0,0 +1,16 @@
+// don't create symlinks on windows
+// UNSUPPORTED: system-windows
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/foo/
+// RUN: ln -f -s %S/Inputs/canonical-system-headers %t/foo/include
+// RUN: %clang_cc1 -isystem %T/foo/include -sys-header-deps -MT foo.o -dependency-file %t2 %s -fsyntax-only
+// RUN: FileCheck %s --check-prefix=NOCANON --implicit-check-not=a.h < %t2
+// RUN: %clang_cc1 -isystem %T/foo/include -sys-header-deps -MT foo.o -dependency-file %t2 %s -fsyntax-only -canonical-system-headers
+// RUN: FileCheck %s --check-prefix=CANON --implicit-check-not=a.h < %t2
+
+// NOCANON: foo/include/a.h
+// CANON: Inputs/canonical-system-headers/a.h
+
+#include 
Index: clang/test/Driver/canonical-system-headers.c
===
--- /dev/null
+++ clang/test/Driver/canonical-system-headers.c
@@ -0,0 +1,6 @@
+// RUN: %clang -MD -no-canonical-prefixes -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO
+// RUN: %clang -MD -canonical-prefixes -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-YES
+// RUN: %clang -MD -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-YES
+
+// CHECK-YES: "-canonical-system-headers"
+// CHECK-NO-NOT: "-canonical-system-headers"
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -49,6 +49,7 @@
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
+  &PP.getFileManager(),
   /*IsMissing*/ false);
   }
 
@@ -56,9 +57,11 @@
SrcMgr::CharacteristicKind FileType) override {
 StringRef Filename =
 llvm::sys::path::remove_leading_dotslash(SkippedFile.getName());
-DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
+DepCollector.maybeAddDependency(Filename,
+/*FromModule=*/false,
 /*IsSystem=*/isSystem(FileType),
 /*IsModuleFile=*/false,
+&PP.getFileManager(),
 /*IsMissing=*/false);
   }
 
@@ -69,9 +72,12 @@
   StringRef RelativePath, const Module *Imported,
   SrcMgr::CharacteristicKind FileType) override {
 if (!File)
-  DepCollector.maybeAddDependency(FileName, /*FromModule*/false,
- /*IsSystem*/false, /*IsModuleFile*/false,
- /*IsMissing*/true);
+  DepCollector.maybeAddDependency(FileName,
+  /*FromModule*/ false,
+  /*IsSystem*/ false,
+  /*IsModuleFile*/ false,
+  &PP.getFileManager(),
+  /*IsMissing*/ true);
 // Files that actually exist are handled by FileChanged.
   }
 
@@ -82,9 +88,11 @@
   return;
 StringRef Filename =
 llvm::sys::path::remove_leading_dotslash(File->getName());
-DepCollector.maybeAddDependency(Filename, /*FromModule=*/false,
+DepCollector.maybeAddDependency(Filename,
+/*FromModule=*/false,
 /*IsSystem=*/isSystem(FileType),
 /*IsModuleFile=*/false,
+&PP.getFileManager(),
 /*IsMissing=*/false);
   }
 
@@ -100,10 +108,12 @@
   void moduleMapFileRead(SourceLocation Loc, const FileEntry &Entry,
  bool IsSystem) override {
 StringRef Filename = Entry.getName();
-DepCollector.maybeAddDependency(Filename, /*FromModule*/false,
-   

[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

2023-05-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/Frontend/backend-attribute-error-warning-optimize.c:12
   foo(); // expected-error {{call to 'foo' declared with 'error' attribute: oh 
no foo}}
+ // expected-note@* {{In function 'baz'}}
   if (x())

cjdb wrote:
> aaron.ballman wrote:
> > nickdesaulniers wrote:
> > > cjdb wrote:
> > > > aaron.ballman wrote:
> > > > > nickdesaulniers wrote:
> > > > > > nickdesaulniers wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > Instead of allowing this note to appear anywhere in the file, I 
> > > > > > > > think it's better to use "bookmark" comments. e.g.,
> > > > > > > > ```
> > > > > > > > void baz() { // #baz_defn
> > > > > > > > }
> > > > > > > > 
> > > > > > > > void foo() {
> > > > > > > >   baz(); // expected-note@#baz_defn {{whatever note text}}
> > > > > > > > }
> > > > > > > > ```
> > > > > > > > so that we're testing where the diagnostic is emitted. (This is 
> > > > > > > > especially important given that the changes are about location 
> > > > > > > > tracking.)
> > > > > > > oh, that's new (to me)! will do
> > > > > > It looks like the "bookmarks" don't work because the notes do not 
> > > > > > line+col info. They follow the warning/error diagnostic which does, 
> > > > > > on the bottom most call site.
> > > > > > 
> > > > > > The warning is supposed to be emitted on the callsite, not the 
> > > > > > definition.
> > > > > I still don't think this is reasonable for test coverage because this 
> > > > > means we'll accept the note *anywhere* in the file. This makes it 
> > > > > much too easy to regress the behavior accidentally (e.g., 
> > > > > accidentally emit all the notes on line 1 of the file). I think we 
> > > > > need *some* way to nail down where these notes are emitted in the 
> > > > > test. However, I might be asking you to solve "please track location 
> > > > > information through the backend" for that, so perhaps this isn't a 
> > > > > reasonable request?
> > > > > 
> > > > > Also, CC @cjdb for awareness of how this kind of diagnostic is 
> > > > > produced (Chris is working on an idea for how we emit diagnostics so 
> > > > > we get better structured information from them, so knowing about this 
> > > > > novel approach might impact that idea).
> > > > Very interesting, thanks for the heads up! Cross-phase diagnostics are 
> > > > definitely something I hadn't considered, and it **does** impact the 
> > > > design (but not in a derailing way).
> > > I think we're back at "please track location information through the 
> > > backend".
> > > 
> > > That is the tradeoff with this approach; not measurably regressing 
> > > performance when these attributes aren't used in source in exchange for 
> > > Note diagnostics that lack precise line+col info, but in practice provide 
> > > enough info for the user to understand what's going wrong where.
> > > 
> > > Your call if the tradeoff is worth it.
> > Here's my thinking, please correct any misunderstandings I have:
> > 
> > * This functionality is primarily for use with `_FORTIFY_SOURCE` (but not 
> > solely for that purpose), and that's an important security feature used by 
> > glibc and the Linux kernel.
> > * Security of C and C++ source code is Very Important, especially now that 
> > various gov't agencies [1][2] are suggesting to not use C or C++ for new 
> > projects specifically because the security posture of the languages and 
> > their tools.
> > * Therefore, the ergonomics of this functionality are quite important for 
> > the intended use cases and the ecosystem as a whole.
> > * Emitting only the function name but without location information does not 
> > give a good user experience, especially in circumstances where the function 
> > has multiple overloads, because it pushes the burden onto the programmer to 
> > figure out which functions are actually involved in the call chain. This 
> > issue is also present in C because of support for 
> > `__attribute__((overloadable))` and is not just a C++ concern.
> > * The compile-time performance costs of tracking this location information 
> > are roughly 1%, and there are no runtime or binary size overhead costs 
> > unless other functionality is enabled (such as emitting debug info).
> > * We can determine whether we need to enable this location tracking while 
> > building the AST when we see one of these two attributes being used, so we 
> > could enable this functionality selectively without burdening the user with 
> > enabling it manually via a flag. (We could still consider giving the user a 
> > flag to never track this even in the presence of the attributes if a user 
> > had a compelling use case for it.)
> > 
> > If this is all reasonably accurate, I think it's worth seriously 
> > considering accepting the costs. I don't want to increase our compile time 
> > overhead, but at the same time, if ~1% is a "make or break" amount of 
> > compile-time performa

[clang] f9fbda7 - Revert "[clang] Canonicalize system headers in dependency file when -canonical-prefixes"

2023-05-01 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-05-01T10:55:53-07:00
New Revision: f9fbda7102fb6da79dedf9b15694d7a61e8c49b7

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

LOG: Revert "[clang] Canonicalize system headers in dependency file when 
-canonical-prefixes"

This reverts commit 8f0dd4ef3ed2137d1e2554204127434fc46ee190.

Causes bot failures: https://lab.llvm.org/buildbot/#builders/139/builds/39964

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/DependencyOutputOptions.h
clang/include/clang/Frontend/Utils.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/DependencyFile.cpp

Removed: 
clang/test/Driver/canonical-system-headers.c
clang/test/Preprocessor/Inputs/canonical-system-headers/a.h
clang/test/Preprocessor/canonical-system-headers.c



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 182f0290736d8..8c80c7f5ff56a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5835,9 +5835,6 @@ let Flags = [CC1Option, NoDriverOption] in {
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
-def canonical_system_headers : Flag<["-"], "canonical-system-headers">,
-  HelpText<"Canonicalize system headers in dependency output">,
-  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h 
b/clang/include/clang/Frontend/DependencyOutputOptions.h
index e140ff9baa117..e0f445bb5970c 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -34,8 +34,6 @@ enum ExtraDepKind {
 class DependencyOutputOptions {
 public:
   unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
-  unsigned
-  CanonicalSystemHeaders : 1; ///< canonicalize system header dependencies.
   unsigned ShowHeaderIncludes : 1;   ///< Show header inclusions (-H).
   unsigned UsePhonyTargets : 1;  ///< Include phony targets for each
  /// dependency, which can avoid some 
'make'
@@ -87,11 +85,10 @@ class DependencyOutputOptions {
 
 public:
   DependencyOutputOptions()
-  : IncludeSystemHeaders(0), CanonicalSystemHeaders(0),
-ShowHeaderIncludes(0), UsePhonyTargets(0), AddMissingHeaderDeps(0),
-IncludeModuleFiles(0), ShowSkippedHeaderIncludes(0),
-HeaderIncludeFormat(HIFMT_Textual), HeaderIncludeFiltering(HIFIL_None) 
{
-  }
+  : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
+AddMissingHeaderDeps(0), IncludeModuleFiles(0),
+ShowSkippedHeaderIncludes(0), HeaderIncludeFormat(HIFMT_Textual),
+HeaderIncludeFiltering(HIFIL_None) {}
 };
 
 }  // end namespace clang

diff  --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 8300e45d15fe5..143cf4359f00b 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -41,7 +41,6 @@ class ExternalSemaSource;
 class FrontendOptions;
 class PCHContainerReader;
 class Preprocessor;
-class FileManager;
 class PreprocessorOptions;
 class PreprocessorOutputOptions;
 
@@ -80,14 +79,11 @@ class DependencyCollector {
   /// Return true if system files should be passed to sawDependency().
   virtual bool needSystemDependencies() { return false; }
 
-  /// Return true if system files should be canonicalized.
-  virtual bool shouldCanonicalizeSystemDependencies() { return false; }
-
   /// Add a dependency \p Filename if it has not been seen before and
   /// sawDependency() returns true.
   virtual void maybeAddDependency(StringRef Filename, bool FromModule,
   bool IsSystem, bool IsModuleFile,
-  FileManager *FileMgr, bool IsMissing);
+  bool IsMissing);
 
 protected:
   /// Return true if the filename was added to the list of dependencies, false
@@ -116,10 +112,6 @@ class DependencyFileGenerator : public DependencyCollector 
{
   bool sawDependency(StringRef Filename, bool FromModule, bool IsSystem,
  bool IsModuleFile, bool IsMissing) final;
 
-  bool shouldCanonicalizeSystemDependencies() override {
-return CanonicalSystemHeaders;
-  }
-
 protected:
   void outputDependencyFile(llvm::raw_ostream &OS);
 
@@ -129,7 +121,6 @@ class DependencyFileGenerator : public DependencyCollector {
   std::string OutputFile;
   std::vector Targets;
   bool IncludeSystemHeaders;
-  bool Canoni

cfe-commits@lists.llvm.org

2023-05-01 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

bumping for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149104

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


[PATCH] D149600: [MemProf] Recognize hot/cold operator new as replaceable allocations

2023-05-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: rsmith, snehasish.
Herald added a project: All.
tejohnson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Follow up to LLVM-side change to allow conversion to hot/cold hinted
operator new, not yet standard but supported by open source tcmalloc.
The LLVM change in a35206d78280e0ebcf48cd21bc5fff5c3b9c73fa 
 added the
necessary support to recognize these as library functions, and we
subsequently found that a clang-side change is needed to give them
builtin/nobuiltin attributes as appropriate so they have consistent
removeability.

Based on discussion with Richard Smith, converted the parameter type to
a reserved identifier (39f7b48671dae5fbe3afc49f33f50c2b6340bb89 
) and
added support in this patch to recognize it in clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149600

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGenCXX/new_hot_cold.cpp

Index: clang/test/CodeGenCXX/new_hot_cold.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/new_hot_cold.cpp
@@ -0,0 +1,125 @@
+// Test to check that the appropriate attributes are added to the __hot_cold_t
+// versions of operator new.
+
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -faligned-allocation -emit-llvm -o - | FileCheck %s
+
+typedef __typeof__(sizeof(0)) size_t;
+
+namespace std {
+struct nothrow_t {};
+enum class align_val_t : size_t;
+} // namespace std
+std::nothrow_t nothrow;
+
+typedef unsigned char uint8_t;
+
+enum class __hot_cold_t : uint8_t;
+namespace malloc_namespace {
+using hot_cold_t = __hot_cold_t;
+}
+
+void *operator new(size_t size,
+   malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new[](size_t size,
+ malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new(size_t size, const std::nothrow_t &,
+   malloc_namespace::hot_cold_t hot_cold) noexcept;
+void *operator new[](size_t size, const std::nothrow_t &,
+ malloc_namespace::hot_cold_t hot_cold) noexcept;
+void *operator new(size_t size, std::align_val_t alignment,
+   malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new[](size_t size, std::align_val_t alignment,
+ malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new(size_t size, std::align_val_t alignment,
+   const std::nothrow_t &,
+   malloc_namespace::hot_cold_t hot_cold) noexcept;
+void *operator new[](size_t size, std::align_val_t alignment,
+ const std::nothrow_t &,
+ malloc_namespace::hot_cold_t hot_cold) noexcept;
+
+// All explicit operator new calls should not get any builtin attribute, whereas
+// all implicit new expressions should get builtin attributes. All of the
+// declarations should get nobuiltin attributes.
+
+void hot_cold_new() {
+  // CHECK: call noalias noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  operator new(1, (__hot_cold_t)0);
+  // CHECK: call noalias noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  new ((__hot_cold_t)0) int;
+}
+
+// CHECK: declare noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+
+void hot_cold_new_array() {
+  // CHECK: call noalias noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  operator new[](1, (__hot_cold_t)0);
+  // CHECK: call noalias noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  new ((__hot_cold_t)0) int[1];
+}
+
+// CHECK: declare noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+
+void hot_cold_new_nothrow() {
+  // CHECK: call noalias noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  operator new(1, nothrow, (__hot_cold_t)0);
+  // CHECK: call noalias noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef 4, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  new (nothrow, (__hot_cold_t)0) int;
+}
+
+// CHECK: declare noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) [[ATTR_NOBUILTIN_NOTHROW:#[^ ]*]]
+
+void hot_cold_new_nothrow_array() {
+  // CHECK: call noalias noundef ptr @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+

[PATCH] D149600: [MemProf] Recognize hot/cold operator new as replaceable allocations

2023-05-01 Thread Snehasish Kumar via Phabricator via cfe-commits
snehasish accepted this revision.
snehasish added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: clang/test/CodeGenCXX/new_hot_cold.cpp:16
+
+enum class __hot_cold_t : uint8_t;
+namespace malloc_namespace {

Can we skip the typedef and just say `enum class __hot_cold_t : unsigned char;`?

Also it might be useful to link to the tcmalloc documentation for hot_cold_t to 
document the expected underlying type?
https://github.com/google/tcmalloc/blob/220043886d4e2efff7a5702d5172cb8065253664/tcmalloc/malloc_extension.h#L53




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149600

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


[PATCH] D149562: [clang-format] Stop comment disrupting indentation of Verilog ports

2023-05-01 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

I don't see the problem, could you elaborate a bit more? (Keep in mind, I have 
no idea about Verilog.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149562

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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I think you're missing changes in ASTReaderStmt.cpp and ASTWriterStmt.cpp, so 
serialization through modules or PCH won't work without that.




Comment at: clang/include/clang/AST/Expr.h:1996
   PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
- StringLiteral *SL);
+ bool TreatAsStringLiteral, StringLiteral *SL);
 

I think we should keep `PredefinedExpr` general, so how about `IsTransparent` 
instead? Then we can add a comment above `Create()` that explains what 
`IsTransparent` does.

(This makes it easier for us to add predefined expressions that aren't string 
literals but are still transparently handled.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D149606: [RISCV] Move RISCV::RVVBitsPerBlock to be a static member of RISCVISAInfo class.

2023-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: reames, asb, luismarques, frasercrmck, 
kito-cheng, rogfer01, pcwang-thead.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, evandro, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, niosHD, 
sabuasal, simoncook, johnrusso, rbar, hiraditya, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, eopXD, MaskRay.
Herald added projects: clang, LLVM.

This constant is used by clang and llvm so needs to be shared.

It can't be in RISCVTargetParser.h where it is today because that
file depends on a tablegen output.

I don't want to create a new header file so I figured RISCVISAInfo.h
could be a new home for it.

lld imports RISCVISAInfo.h and lld has a class named llvm::RISCV.
So we can't expose the llvm::RISCV namespace to lld.

Thus this patch to put it inside the RISCVISAInfo class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149606

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaType.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Index: llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
===
--- llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -210,15 +210,15 @@
 
 std::optional RISCVTTIImpl::getMaxVScale() const {
   if (ST->hasVInstructions())
-return ST->getRealMaxVLen() / RISCV::RVVBitsPerBlock;
+return ST->getRealMaxVLen() / RISCVISAInfo::RVVBitsPerBlock;
   return BaseT::getMaxVScale();
 }
 
 std::optional RISCVTTIImpl::getVScaleForTuning() const {
   if (ST->hasVInstructions())
 if (unsigned MinVLen = ST->getRealMinVLen();
-MinVLen >= RISCV::RVVBitsPerBlock)
-  return MinVLen / RISCV::RVVBitsPerBlock;
+MinVLen >= RISCVISAInfo::RVVBitsPerBlock)
+  return MinVLen / RISCVISAInfo::RVVBitsPerBlock;
   return BaseT::getVScaleForTuning();
 }
 
@@ -235,8 +235,8 @@
   case TargetTransformInfo::RGK_ScalableVector:
 return TypeSize::getScalable(
 (ST->hasVInstructions() &&
- ST->getRealMinVLen() >= RISCV::RVVBitsPerBlock)
-? LMUL * RISCV::RVVBitsPerBlock
+ ST->getRealMinVLen() >= RISCVISAInfo::RVVBitsPerBlock)
+? LMUL * RISCVISAInfo::RVVBitsPerBlock
 : 0);
   }
 
@@ -1193,7 +1193,8 @@
   if (isa(Ty)) {
 const unsigned EltSize = DL.getTypeSizeInBits(Ty->getElementType());
 const unsigned MinSize = DL.getTypeSizeInBits(Ty).getKnownMinValue();
-const unsigned VectorBits = *getVScaleForTuning() * RISCV::RVVBitsPerBlock;
+const unsigned VectorBits =
+*getVScaleForTuning() * RISCVISAInfo::RVVBitsPerBlock;
 return RISCVTargetLowering::computeVLMAX(VectorBits, EltSize, MinSize);
   }
   return cast(Ty)->getNumElements();
@@ -1673,7 +1674,7 @@
   TypeSize Size = DL.getTypeSizeInBits(Ty);
   if (Ty->isVectorTy()) {
 if (Size.isScalable() && ST->hasVInstructions())
-  return divideCeil(Size.getKnownMinValue(), RISCV::RVVBitsPerBlock);
+  return divideCeil(Size.getKnownMinValue(), RISCVISAInfo::RVVBitsPerBlock);
 
 if (ST->useRVVForFixedLengthVectors())
   return divideCeil(Size, ST->getRealMinVLen());
Index: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
===
--- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -140,10 +140,11 @@
   Attribute VScaleRangeAttr = F.getFnAttribute(Attribute::VScaleRange);
   if (VScaleRangeAttr.isValid()) {
 if (!RVVVectorBitsMinOpt.getNumOccurrences())
-  RVVBitsMin = VScaleRangeAttr.getVScaleRangeMin() * RISCV::RVVBitsPerBlock;
+  RVVBitsMin =
+  VScaleRangeAttr.getVScaleRangeMin() * RISCVISAInfo::RVVBitsPerBlock;
 std::optional VScaleMax = VScaleRangeAttr.getVScaleRangeMax();
 if (VScaleMax.has_value() && !RVVVectorBitsMaxOpt.getNumOccurrences())
-  RVVBitsMax = *VScaleMax * RISCV::RVVBitsPerBlock;
+  RVVBitsMax = *VScaleMax * RISCVISAInfo::RVVBitsPerBlock;
   }
 
   if (RVVBitsMin != -1U) {
Index: llvm/lib/Target/RISCV/RISCVISelLowering.h
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -18,7 +18,6 @@
 #include "llvm/CodeGen/CallingConvLower.h"
 #include "llvm/CodeGen/SelectionDAG.h"
 #i

[PATCH] D149600: [MemProf] Recognize hot/cold operator new as replaceable allocations

2023-05-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/test/CodeGenCXX/new_hot_cold.cpp:16
+
+enum class __hot_cold_t : uint8_t;
+namespace malloc_namespace {

snehasish wrote:
> Can we skip the typedef and just say `enum class __hot_cold_t : unsigned 
> char;`?
> 
> Also it might be useful to link to the tcmalloc documentation for hot_cold_t 
> to document the expected underlying type?
> https://github.com/google/tcmalloc/blob/220043886d4e2efff7a5702d5172cb8065253664/tcmalloc/malloc_extension.h#L53
> 
> 
> Can we skip the typedef and just say enum class __hot_cold_t : unsigned char;?

I did that specifically to test the way it is declared in tcmalloc. In 
particular, this tests the TypedefType while loop at lines 3301-2 in Decl.cpp 
which was required to "see through" that and handle that case properly. I can 
add a comment here to the test. Will also add the link to tcmalloc here and in 
Decl.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149600

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


[PATCH] D109210: [clang-tidy] Attach fixit to warning, not note, in add_new_check.py example

2023-05-01 Thread Matt Beardsley via Phabricator via cfe-commits
mattbeardsley added a comment.
Herald added a subscriber: carlosgalvezp.
Herald added a project: All.

Someone else ultimately fixed this (slightly differently) last month:
https://reviews.llvm.org/D146875


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109210

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


[PATCH] D148997: [clang] Add a new annotation token: annot_repl_input_end

2023-05-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This looks like a nice improvement to me.




Comment at: clang/lib/Interpreter/IncrementalParser.cpp:162
+  if (P->getCurToken().is(tok::annot_repl_input_end)) {
+P->ConsumeAnyToken();
 // FIXME: Clang does not call ExitScope on finalizing the regular TU, we





Comment at: clang/lib/Interpreter/IncrementalParser.cpp:254-268
   if (PP.getLangOpts().DelayedTemplateParsing) {
 // Microsoft-specific:
 // Late parsed templates can leave unswallowed "macro"-like tokens.
 // They will seriously confuse the Parser when entering the next
 // source file. So lex until we are EOF.
 Token Tok;
 do {

Not really related to this patch, but in `DelayedTemplateParsing` mode this 
code appears to expect two `annot_repl_input_end` tokens in a row.



Comment at: clang/lib/Parse/ParseStmt.cpp:546-556
+  Token *CurTok = nullptr;
+  // If we're parsing an ExprStmt and the last semicolon is missing and the
+  // incremental externsion is enabled and we're reaching the end, consider we
+  // want to do value printing. Note this is only enable in C++ mode
+  // since part of the implementation requires C++ language features.
+  //
+  // Note we shouldn't eat the token since the callback need it.

I don't think we need to check whether incremental processing is enabled here 
-- if not, we shouldn't see the "end of REPL input" token at all.



Comment at: clang/lib/Parse/Parser.cpp:620-621
   // processing
-  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
-ConsumeToken();
+  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::annot_repl_input_end))
+ConsumeAnnotationToken();
 

Do we need to do this here? `IncrementalParser` already seems to take care of 
this, and the logic here would be easier to reason about if `Parser` never 
steps past an `annot_repl_input_end` token, and such tokens instead are only 
ever consumed by the REPL.

Are there other users of incremental processing mode, other than the REPL / 
`IncrementalParser`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148997

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D145088#4308840 , @akyrtzi wrote:

> `CodeGen` has the same issue:
>
>   $ ninja 
> tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetInfo.cpp.o
>   In file included from /llvm-project/clang/lib/CodeGen/TargetInfo.cpp:36:
>   /llvm-project/llvm/include/llvm/TargetParser/RISCVTargetParser.h:32:10: 
> fatal error: 'llvm/TargetParser/RISCVTargetParserDef.inc' file not found

I just posted https://reviews.llvm.org/D149606 to move the constant to a file 
that doesn't depend on tablegen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145088

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


[PATCH] D149464: [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

2023-05-01 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:189
 
+  /// Deprecated. Use *getDataflowAnalysisContext().getOptions().Log instead.
   Logger &logger() const { return *DACtx->getOptions().Log; }

bazuzi wrote:
> xazax.hun wrote:
> > Any reason for a comment as opposed to the deprecated attribute? 
> I couldn't tell exactly what the conventions were or whether all of the 
> chained replacements could be used as the FIX very well.
> 
> If you can confirm that `LLVM_DEPRECATED("DataflowAnalysisContext is now 
> directly exposed.", "*getDataflowAnalysisContext().getOptions().Log")`, 
> `LLVM_DEPRECATED(..., "getDataflowAnalysisContext().arena")`, etc. will 
> provide useful fixes, happy to replace with those. Or with replacements just 
> in the MSG and "" for FIX otherwise.
Unfortunately, I am also not 100% sure what is the convention. But I am OK with 
not providing a FIXIT here. I do not expect too many clients yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149464

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


[PATCH] D149553: [clang] Use -std=c++23 instead of -std=c++2b

2023-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this! The Clang changes are mostly all good, but I 
think we should hold off on changing the value of `__cplusplus` for the moment 
as it's not set in stone in the standard yet (I thought it was though, so I'm 
checking with the editor).




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6638
  .Case("c++20", "-std=c++20")
- .Case("c++latest", "-std=c++2b")
+ // TODO add c++23 when MSVC supports it.
+ .Case("c++latest", "-std=c++23")

Good catch!



Comment at: clang/lib/Frontend/InitPreprocessor.cpp:455
+if (LangOpts.CPlusPlus23)
+  Builder.defineMacro("__cplusplus", "202302L");
 //  [C++20] The integer literal 202002L.

I think this might still be premature. I noticed that the draft C++ standard 
does not have this value set yet: 
https://github.com/cplusplus/draft/blob/main/source/config.tex#L6

I've emailed the editor to find out if that's a mistake (I am pretty sure we're 
sending this off to PDTS at some point shortly).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149553

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


[PATCH] D149600: [MemProf] Recognize hot/cold operator new as replaceable allocations

2023-05-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 518526.
tejohnson added a comment.

Address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149600

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGenCXX/new_hot_cold.cpp

Index: clang/test/CodeGenCXX/new_hot_cold.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/new_hot_cold.cpp
@@ -0,0 +1,130 @@
+// Test to check that the appropriate attributes are added to the __hot_cold_t
+// versions of operator new.
+
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -faligned-allocation -emit-llvm -o - | FileCheck %s
+
+typedef __typeof__(sizeof(0)) size_t;
+
+namespace std {
+struct nothrow_t {};
+enum class align_val_t : size_t;
+} // namespace std
+std::nothrow_t nothrow;
+
+typedef unsigned char uint8_t;
+
+// See the following link for how this type is declared in tcmalloc:
+// https://github.com/google/tcmalloc/blob/220043886d4e2efff7a5702d5172cb8065253664/tcmalloc/malloc_extension.h#L53.
+enum class __hot_cold_t : uint8_t;
+
+// Test handling of declaration that uses a type alias, ensuring that it still
+// recognizes the expected __hot_cold_t type name.
+namespace malloc_namespace {
+using hot_cold_t = __hot_cold_t;
+}
+
+void *operator new(size_t size,
+   malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new[](size_t size,
+ malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new(size_t size, const std::nothrow_t &,
+   malloc_namespace::hot_cold_t hot_cold) noexcept;
+void *operator new[](size_t size, const std::nothrow_t &,
+ malloc_namespace::hot_cold_t hot_cold) noexcept;
+void *operator new(size_t size, std::align_val_t alignment,
+   malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new[](size_t size, std::align_val_t alignment,
+ malloc_namespace::hot_cold_t hot_cold) noexcept(false);
+void *operator new(size_t size, std::align_val_t alignment,
+   const std::nothrow_t &,
+   malloc_namespace::hot_cold_t hot_cold) noexcept;
+void *operator new[](size_t size, std::align_val_t alignment,
+ const std::nothrow_t &,
+ malloc_namespace::hot_cold_t hot_cold) noexcept;
+
+// All explicit operator new calls should not get any builtin attribute, whereas
+// all implicit new expressions should get builtin attributes. All of the
+// declarations should get nobuiltin attributes.
+
+void hot_cold_new() {
+  // CHECK: call noalias noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  operator new(1, (__hot_cold_t)0);
+  // CHECK: call noalias noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  new ((__hot_cold_t)0) int;
+}
+
+// CHECK: declare noundef nonnull ptr @_Znwm12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+
+void hot_cold_new_array() {
+  // CHECK: call noalias noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef 1, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_CALL:#[^ ]*]]
+  operator new[](1, (__hot_cold_t)0);
+  // CHECK: call noalias noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef 4, i8 noundef zeroext 0) [[ATTR_BUILTIN_CALL:#[^ ]*]]
+  new ((__hot_cold_t)0) int[1];
+}
+
+// CHECK: declare noundef nonnull ptr @_Znam12__hot_cold_t(i64 noundef, i8 noundef zeroext) [[ATTR_NOBUILTIN:#[^ ]*]]
+
+void hot_cold_new_nothrow() {
+  // CHECK: call noalias noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  operator new(1, nothrow, (__hot_cold_t)0);
+  // CHECK: call noalias noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef 4, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  new (nothrow, (__hot_cold_t)0) int;
+}
+
+// CHECK: declare noundef ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) [[ATTR_NOBUILTIN_NOTHROW:#[^ ]*]]
+
+void hot_cold_new_nothrow_array() {
+  // CHECK: call noalias noundef ptr @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 noundef 1, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_NO_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  operator new[](1, nothrow, (__hot_cold_t)0);
+  // CHECK: call noalias noundef ptr @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 noundef 4, {{.*}} @nothrow, i8 noundef zeroext 0) [[ATTR_BUILTIN_NOTHROW_CALL:#[^ ]*]]
+  new (nothrow, (__hot_cold_t)0) int[1];
+}
+
+// CHECK: declare noundef ptr @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 noundef, ptr noundef nonnull align 1 dereferenceable(1), i8 noundef zeroext) [[ATTR_NOBUILTIN_NOTHROW:#[^ ]*]]
+
+class alignas(32) alignedstruct {
+  int x;
+};
+
+void hot_cold_

[PATCH] D146386: [MS ABI] Fix mangling references to declarations.

2023-05-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM

(Do you have commit access?  If not, please specify the name/email you want for 
the "author" field.)


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

https://reviews.llvm.org/D146386

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


[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

2023-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Frontend/backend-attribute-error-warning-optimize.c:12
   foo(); // expected-error {{call to 'foo' declared with 'error' attribute: oh 
no foo}}
+ // expected-note@* {{In function 'baz'}}
   if (x())

nickdesaulniers wrote:
> cjdb wrote:
> > aaron.ballman wrote:
> > > nickdesaulniers wrote:
> > > > cjdb wrote:
> > > > > aaron.ballman wrote:
> > > > > > nickdesaulniers wrote:
> > > > > > > nickdesaulniers wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > Instead of allowing this note to appear anywhere in the file, 
> > > > > > > > > I think it's better to use "bookmark" comments. e.g.,
> > > > > > > > > ```
> > > > > > > > > void baz() { // #baz_defn
> > > > > > > > > }
> > > > > > > > > 
> > > > > > > > > void foo() {
> > > > > > > > >   baz(); // expected-note@#baz_defn {{whatever note text}}
> > > > > > > > > }
> > > > > > > > > ```
> > > > > > > > > so that we're testing where the diagnostic is emitted. (This 
> > > > > > > > > is especially important given that the changes are about 
> > > > > > > > > location tracking.)
> > > > > > > > oh, that's new (to me)! will do
> > > > > > > It looks like the "bookmarks" don't work because the notes do not 
> > > > > > > line+col info. They follow the warning/error diagnostic which 
> > > > > > > does, on the bottom most call site.
> > > > > > > 
> > > > > > > The warning is supposed to be emitted on the callsite, not the 
> > > > > > > definition.
> > > > > > I still don't think this is reasonable for test coverage because 
> > > > > > this means we'll accept the note *anywhere* in the file. This makes 
> > > > > > it much too easy to regress the behavior accidentally (e.g., 
> > > > > > accidentally emit all the notes on line 1 of the file). I think we 
> > > > > > need *some* way to nail down where these notes are emitted in the 
> > > > > > test. However, I might be asking you to solve "please track 
> > > > > > location information through the backend" for that, so perhaps this 
> > > > > > isn't a reasonable request?
> > > > > > 
> > > > > > Also, CC @cjdb for awareness of how this kind of diagnostic is 
> > > > > > produced (Chris is working on an idea for how we emit diagnostics 
> > > > > > so we get better structured information from them, so knowing about 
> > > > > > this novel approach might impact that idea).
> > > > > Very interesting, thanks for the heads up! Cross-phase diagnostics 
> > > > > are definitely something I hadn't considered, and it **does** impact 
> > > > > the design (but not in a derailing way).
> > > > I think we're back at "please track location information through the 
> > > > backend".
> > > > 
> > > > That is the tradeoff with this approach; not measurably regressing 
> > > > performance when these attributes aren't used in source in exchange for 
> > > > Note diagnostics that lack precise line+col info, but in practice 
> > > > provide enough info for the user to understand what's going wrong where.
> > > > 
> > > > Your call if the tradeoff is worth it.
> > > Here's my thinking, please correct any misunderstandings I have:
> > > 
> > > * This functionality is primarily for use with `_FORTIFY_SOURCE` (but not 
> > > solely for that purpose), and that's an important security feature used 
> > > by glibc and the Linux kernel.
> > > * Security of C and C++ source code is Very Important, especially now 
> > > that various gov't agencies [1][2] are suggesting to not use C or C++ for 
> > > new projects specifically because the security posture of the languages 
> > > and their tools.
> > > * Therefore, the ergonomics of this functionality are quite important for 
> > > the intended use cases and the ecosystem as a whole.
> > > * Emitting only the function name but without location information does 
> > > not give a good user experience, especially in circumstances where the 
> > > function has multiple overloads, because it pushes the burden onto the 
> > > programmer to figure out which functions are actually involved in the 
> > > call chain. This issue is also present in C because of support for 
> > > `__attribute__((overloadable))` and is not just a C++ concern.
> > > * The compile-time performance costs of tracking this location 
> > > information are roughly 1%, and there are no runtime or binary size 
> > > overhead costs unless other functionality is enabled (such as emitting 
> > > debug info).
> > > * We can determine whether we need to enable this location tracking while 
> > > building the AST when we see one of these two attributes being used, so 
> > > we could enable this functionality selectively without burdening the user 
> > > with enabling it manually via a flag. (We could still consider giving the 
> > > user a flag to never track this even in the presence of the attributes if 
> > > a user had a compelling use case for it.)
> > > 
> > > If this is all reasonably accurate, I think it's worth s

[PATCH] D148944: [clang][Driver] Fix crash with unsupported architectures in MinGW and CrossWindows.

2023-05-01 Thread KOMATA Manabu via Phabricator via cfe-commits
k-mana added a comment.

I don't have commit access.
Please commit at KOMATA Manabu .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148944

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-01 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 created this revision.
HerrCai0907 added reviewers: aaron.ballman, rjmccall, shafik.
Herald added a project: All.
HerrCai0907 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

fixed: https://github.com/llvm/llvm-project/issues/62447
Ill-formatted type will break `mergeTypes`. So it needs to add more
strict checker for VarDecl in `MergeVarDeclTypes`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149612

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/merge-decls.c


Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(&x); // expected-warning {{incompatible pointer types passing 'int 
(*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 
'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 
'char' is not a structure or union}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4392,7 +4392,7 @@
 /// is attached.
 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
  bool MergeTypeWithOld) {
-  if (New->isInvalidDecl() || Old->isInvalidDecl())
+  if (New->isInvalidDecl() || Old->isInvalidDecl() || 
New->getType()->containsErrors() || Old->getType()->containsErrors())
 return;
 
   QualType MergedT;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,8 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when redefine variant with invalid type as another invalid type.
+  (`#62447 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4392,7 +4392,7 @@
 /// is attached.
 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
  bool MergeTypeWithOld) {
-  if (New->isInvalidDecl() || Old->isInvalidDecl())
+  if (New->isInvalidDecl() || Old->isInvalidDecl() || New->getType()->containsErrors() || Old->getType()->containsErrors())
 return;
 
   QualType MergedT;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,8 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when redefine variant with invalid type as another invalid type.
+  (`#62447 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 578a471 - Reland [clang] Canonicalize system headers in dependency file when -canonical-prefixes

2023-05-01 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-05-01T12:44:52-07:00
New Revision: 578a4716f549167165a2ec3bac89c86706136d4e

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

LOG: Reland [clang] Canonicalize system headers in dependency file when 
-canonical-prefixes

Clang was writing paths to the dependency file that don't exist when using a 
sysroot with symlinks, causing everything to get rebuilt every time. This is 
reproducible on Linux by creating a symlink to '/', using that as the sysroot, 
and trying to build something with ninja that includes the C++ stdlib (e.g. a 
typical build of LLVM).

This fixes https://github.com/ninja-build/ninja/issues/1330 and somewhat 
matches gcc.

gcc canonicalizes system headers in dependency files under a 
-f[no-]canonical-system-headers, but it makes more sense to look at 
-canonical-prefixes.

D37954 was a previous attempt at this.

Fixed use of %T instead of %t in test, causing bots to fail the test on the 
initial commit.

Reviewed By: hans

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

Added: 
clang/test/Driver/canonical-system-headers.c
clang/test/Preprocessor/Inputs/canonical-system-headers/a.h
clang/test/Preprocessor/canonical-system-headers.c

Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/DependencyOutputOptions.h
clang/include/clang/Frontend/Utils.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/DependencyFile.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8c80c7f5ff56a..182f0290736d8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5835,6 +5835,9 @@ let Flags = [CC1Option, NoDriverOption] in {
 def sys_header_deps : Flag<["-"], "sys-header-deps">,
   HelpText<"Include system headers in dependency output">,
   MarshallingInfoFlag>;
+def canonical_system_headers : Flag<["-"], "canonical-system-headers">,
+  HelpText<"Canonicalize system headers in dependency output">,
+  MarshallingInfoFlag>;
 def module_file_deps : Flag<["-"], "module-file-deps">,
   HelpText<"Include module files in dependency output">,
   MarshallingInfoFlag>;

diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h 
b/clang/include/clang/Frontend/DependencyOutputOptions.h
index e0f445bb5970c..e140ff9baa117 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -34,6 +34,8 @@ enum ExtraDepKind {
 class DependencyOutputOptions {
 public:
   unsigned IncludeSystemHeaders : 1; ///< Include system header dependencies.
+  unsigned
+  CanonicalSystemHeaders : 1; ///< canonicalize system header dependencies.
   unsigned ShowHeaderIncludes : 1;   ///< Show header inclusions (-H).
   unsigned UsePhonyTargets : 1;  ///< Include phony targets for each
  /// dependency, which can avoid some 
'make'
@@ -85,10 +87,11 @@ class DependencyOutputOptions {
 
 public:
   DependencyOutputOptions()
-  : IncludeSystemHeaders(0), ShowHeaderIncludes(0), UsePhonyTargets(0),
-AddMissingHeaderDeps(0), IncludeModuleFiles(0),
-ShowSkippedHeaderIncludes(0), HeaderIncludeFormat(HIFMT_Textual),
-HeaderIncludeFiltering(HIFIL_None) {}
+  : IncludeSystemHeaders(0), CanonicalSystemHeaders(0),
+ShowHeaderIncludes(0), UsePhonyTargets(0), AddMissingHeaderDeps(0),
+IncludeModuleFiles(0), ShowSkippedHeaderIncludes(0),
+HeaderIncludeFormat(HIFMT_Textual), HeaderIncludeFiltering(HIFIL_None) 
{
+  }
 };
 
 }  // end namespace clang

diff  --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 143cf4359f00b..8300e45d15fe5 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -41,6 +41,7 @@ class ExternalSemaSource;
 class FrontendOptions;
 class PCHContainerReader;
 class Preprocessor;
+class FileManager;
 class PreprocessorOptions;
 class PreprocessorOutputOptions;
 
@@ -79,11 +80,14 @@ class DependencyCollector {
   /// Return true if system files should be passed to sawDependency().
   virtual bool needSystemDependencies() { return false; }
 
+  /// Return true if system files should be canonicalized.
+  virtual bool shouldCanonicalizeSystemDependencies() { return false; }
+
   /// Add a dependency \p Filename if it has not been seen before and
   /// sawDependency() returns true.
   virtual void maybeAddDependency(StringRef Filename, bool FromModule,
   bool IsSystem, bool IsModuleFile,
-  bool IsMissing);
+  FileManager *FileMgr, bool IsMissing);
 
 protected:

[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

2023-05-01 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D149573#4310009 , @codemzs wrote:

> My change to libcxxabi/test/test_demangle.pass.cpp (last file in the change) 
> is only one line i.e {"_ZNK5clang4Type16isArithmeticTypeERNS_10ASTContextE", 
> "clang::Type::isArithmeticType(clang::ASTContext&) const"}, but running 
> clang-format on it changes bunch of lines.

Please don't clang-format the test then. There is no need to do it, and the 
changes look rather confusing. I don't really understand why you add it at all 
TBH. This doesn't look like it tests anything from this patch.


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

https://reviews.llvm.org/D149573

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


[clang] fa42e7b - [RISCV] Merge RISCV::parseCPUKind and RISCV::checkCPUKind.

2023-05-01 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-05-01T13:00:05-07:00
New Revision: fa42e7b6bc430941f42cf50b5c4e55b3c19ccc08

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

LOG: [RISCV] Merge RISCV::parseCPUKind and RISCV::checkCPUKind.

Similar for RISCV::parseTuneCPU and RISCV::checkTuneCPUKind.

This makes the CPUKind enum no longer part of the API. It wasn't
providing much value. It was only used to pass between the two
functions.

By removing it, we can remove a dependency on a tablegen generated
file from the RISCVTargetParser.h file. Then we can remove a
dependency from several CMakeLists.txt.

Added: 


Modified: 
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/lib/Sema/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/TargetParser/RISCVTargetParser.h
llvm/lib/TargetParser/RISCVTargetParser.cpp

Removed: 




diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index c05036a216c74..caa1b6002e6f1 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -125,7 +125,6 @@ add_clang_library(clangBasic
 
   DEPENDS
   omp_gen
-  RISCVTargetParserTableGen
   )
 
 target_link_libraries(clangBasic

diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index dd99d96b5f4d3..6720fcd567ac8 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -325,7 +325,7 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
 
 bool RISCVTargetInfo::isValidCPUName(StringRef Name) const {
   bool Is64Bit = getTriple().isArch64Bit();
-  return llvm::RISCV::checkCPUKind(llvm::RISCV::parseCPUKind(Name), Is64Bit);
+  return llvm::RISCV::parseCPU(Name, Is64Bit);
 }
 
 void RISCVTargetInfo::fillValidCPUList(
@@ -336,8 +336,7 @@ void RISCVTargetInfo::fillValidCPUList(
 
 bool RISCVTargetInfo::isValidTuneCPUName(StringRef Name) const {
   bool Is64Bit = getTriple().isArch64Bit();
-  return llvm::RISCV::checkTuneCPUKind(
-  llvm::RISCV::parseTuneCPUKind(Name, Is64Bit), Is64Bit);
+  return llvm::RISCV::parseTuneCPU(Name, Is64Bit);
 }
 
 void RISCVTargetInfo::fillValidTuneCPUList(

diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 3d83c86100bec..a6bd2d41e7975 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -95,7 +95,6 @@ add_clang_library(clangDriver
 
   DEPENDS
   ClangDriverOptions
-  RISCVTargetParserTableGen
 
   LINK_LIBS
   clangBasic

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 7cf01ad8a72b8..a26c9caf64c70 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -54,11 +54,11 @@ static void getRISCFeaturesFromMcpu(const Driver &D, const 
Arg *A,
 StringRef Mcpu,
 std::vector &Features) {
   bool Is64Bit = Triple.isRISCV64();
-  llvm::RISCV::CPUKind CPUKind = llvm::RISCV::parseCPUKind(Mcpu);
-  if (!llvm::RISCV::checkCPUKind(CPUKind, Is64Bit)) {
+  if (!llvm::RISCV::parseCPU(Mcpu, Is64Bit)) {
 // Try inverting Is64Bit in case the CPU is valid, but for the wrong 
target.
-if (llvm::RISCV::checkCPUKind(CPUKind, !Is64Bit))
-  D.Diag(clang::diag::err_drv_invalid_riscv_cpu_name_for_target) << Mcpu 
<< Is64Bit;
+if (llvm::RISCV::parseCPU(Mcpu, !Is64Bit))
+  D.Diag(clang::diag::err_drv_invalid_riscv_cpu_name_for_target)
+  << Mcpu << Is64Bit;
 else
   D.Diag(clang::diag::err_drv_unsupported_option_argument)
   << A->getSpelling() << Mcpu;

diff  --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index 843a269dac720..629fafadcf9f4 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -71,7 +71,6 @@ add_clang_library(clangSema
   DEPENDS
   ClangOpenCLBuiltinsImpl
   omp_gen
-  RISCVTargetParserTableGen
 
   LINK_LIBS
   clangAST

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 334365fa0a8a4..c764a50f88b22 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -171,6 +171,10 @@ Changes to the RISC-V Backend
 * Updated support experimental vector crypto extensions to version 0.5.1 of
   the specification.
 * Removed N extension (User-Level Interrupts) CSR names in the assembler.
+* ``RISCV::parseCPUKind`` and ``RISCV::checkCPUKind`` were merged into a single
+  ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
+  RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
+  ``checkTuneCPUKind``.
 
 Changes to the WebAssembly Backend
 

[PATCH] D149606: [RISCV] Move RISCV::RVVBitsPerBlock to be a static member of RISCVISAInfo class.

2023-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper abandoned this revision.
craig.topper added a comment.

fa42e7b  
made this unnecessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149606

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


[PATCH] D145088: [RISCV] Add attribute(riscv_rvv_vector_bits(N)) based on AArch64 arm_sve_vector_bits.

2023-05-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D145088#4310464 , @craig.topper 
wrote:

> In D145088#4308840 , @akyrtzi wrote:
>
>> `CodeGen` has the same issue:
>>
>>   $ ninja 
>> tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/TargetInfo.cpp.o
>>   In file included from /llvm-project/clang/lib/CodeGen/TargetInfo.cpp:36:
>>   /llvm-project/llvm/include/llvm/TargetParser/RISCVTargetParser.h:32:10: 
>> fatal error: 'llvm/TargetParser/RISCVTargetParserDef.inc' file not found
>
> I just posted https://reviews.llvm.org/D149606 to move the constant to a file 
> that doesn't depend on tablegen.

I found an even better fix fa42e7b 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145088

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


[PATCH] D148425: [clang-repl] Correctly disambiguate dtor declarations from statements

2023-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseTentative.cpp:91
 return true;
-  case tok::annot_cxxscope: // Check if this is a dtor.
-if (NextToken().is(tok::tilde))

Are you sure you can remove this? Wouldn't this be used for a case like:
```
struct Foo {
  struct Bar {
struct Baz {
  ~Baz();
};
  };
};

Foo::Bar::Baz::~Baz() {}
```
(I could be reading the code wrong, but I thought we had a reason to check for 
`annot_cxxscope` -- seems we missed test coverage for it!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148425

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-01 Thread Rishabh Bali via Phabricator via cfe-commits
Ris-Bali updated this revision to Diff 518543.
Ris-Bali added a comment.

Added test for function type


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

https://reviews.llvm.org/D149514

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,26 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible 
integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+  return a[0];
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32); 
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int*)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7979,8 +7979,9 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,9 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,26 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+  return a[0];
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32); 
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int*)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7979,8 +7979,9 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());
   }
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -338,6 +338,9 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commi

[PATCH] D149613: [NFC] fix clang-tidy `prefer-isa-or-dyn-cast-in-conditionals` and `namespace-comment`

2023-05-01 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 created this revision.
Herald added a subscriber: carlosgalvezp.
Herald added a project: All.
HerrCai0907 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/D149613

Files:
  clang/lib/Sema/SemaDeclCXX.cpp

Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1189,7 +1189,7 @@
 S.popCodeSynthesisContext();
   }
 };
-}
+} // namespace
 
 static bool checkTupleLikeDecomposition(Sema &S,
 ArrayRef Bindings,
@@ -4213,7 +4213,7 @@
   CXXRecordDecl *ClassDecl;
 };
 
-}
+} // namespace
 
 ValueDecl *Sema::tryLookupCtorInitMemberDecl(CXXRecordDecl *ClassDecl,
  CXXScopeSpec &SS,
@@ -5055,7 +5055,7 @@
 return false;
   }
 };
-}
+} // namespace
 
 /// Determine whether the given type is an incomplete or zero-lenfgth
 /// array type.
@@ -5994,7 +5994,7 @@
   CheckAbstractUsage(*this, D).Visit(TL, Sel);
 }
 
-}
+} // namespace
 
 /// Check for invalid uses of an abstract type in a function declaration.
 static void CheckAbstractClassUsage(AbstractUsageInfo &Info,
@@ -7386,7 +7386,7 @@
 S.popCodeSynthesisContext();
   }
 };
-}
+} // namespace
 
 static Sema::ImplicitExceptionSpecification
 ComputeDefaultedSpecialMemberExceptionSpec(
@@ -8534,7 +8534,7 @@
SourceRange(Loc, Loc), SourceRange(Loc, Loc));
   }
 };
-}
+} // namespace
 
 /// Perform the unqualified lookups that might be needed to form a defaulted
 /// comparison function for the given operator.
@@ -9079,7 +9079,7 @@
 return false;
   }
 };
-}
+} // namespace
 
 namespace {
 struct SpecialMemberDeletionInfo
@@ -9119,7 +9119,7 @@
 
   bool isAccessible(Subobject Subobj, CXXMethodDecl *D);
 };
-}
+} // namespace
 
 /// Is the given special member inaccessible when used on the given
 /// sub-object.
@@ -11068,7 +11068,7 @@
   Sema::SemaDiagnosticBuilder Diagnostic;
   std::string Specifiers;
 };
-}
+} // namespace
 
 /// Check the validity of a declarator that we parsed for a deduction-guide.
 /// These aren't actually declarators in the grammar, so we need to check that
@@ -11169,7 +11169,7 @@
 // This could still instantiate to the right type, unless we know it
 // names the wrong class template.
 auto *TD = SpecifiedName.getAsTemplateDecl();
-MightInstantiateToSpecialization = !(TD && isa(TD) &&
+MightInstantiateToSpecialization = !(isa_and_nonnull(TD) &&
  !TemplateMatches);
   }
 } else if (!RetTy.hasQualifiers() && RetTy->isDependentType()) {
@@ -11714,7 +11714,7 @@
   }
 };
 
-}
+} // namespace
 
 static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc,
CXXScopeSpec &SS,
@@ -12190,7 +12190,7 @@
 NonTemplateTarget = TargetTD->getTemplatedDecl();
 
   UsingShadowDecl *Shadow;
-  if (NonTemplateTarget && isa(NonTemplateTarget)) {
+  if (isa_and_nonnull(NonTemplateTarget)) {
 UsingDecl *Using = cast(BUD);
 bool IsVirtualBase =
 isVirtualDirectBase(cast(CurContext),
@@ -13313,7 +13313,7 @@
   void visitSubobjectCall(Subobject Subobj,
   Sema::SpecialMemberOverloadResult SMOR);
 };
-}
+} // namespace
 
 bool SpecialMemberExceptionSpecInfo::visitBase(CXXBaseSpecifier *Base) {
   auto *RT = Base->getType()->getAs();
@@ -13477,7 +13477,7 @@
 return WasAlreadyBeingDeclared;
   }
 };
-}
+} // namespace
 
 void Sema::CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD) {
   // Look up any existing declarations, but don't trigger declaration of all
@@ -16821,7 +16821,7 @@
   std::string InnerCondDescription;
   std::tie(InnerCond, InnerCondDescription) =
 findFailedBooleanCondition(Converted.get());
-  if (InnerCond && isa(InnerCond)) {
+  if (isa_and_nonnull(InnerCond)) {
 // Drill down into concept specialization expressions to see why they
 // weren't satisfied.
 Diag(AssertExpr->getBeginLoc(), diag::err_static_assert_failed)
@@ -18275,7 +18275,7 @@
   return false;
 }
   };
-}
+} // namespace
 
 bool Sema::checkThisInStaticMemberFunctionType(CXXMethodDecl *Method) {
   TypeSourceInfo *TSInfo = Method->getTypeSourceInfo();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148381: [WIP][Clang] Add element_count attribute

2023-05-01 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 518546.
void added a comment.

Improve error message to use the unknown field's name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148381

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTImporter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -61,6 +61,7 @@
 // CHECK-NEXT: DiagnoseAsBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: DisableSanitizerInstrumentation (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: DisableTailCalls (SubjectMatchRule_function, SubjectMatchRule_objc_method)
+// CHECK-NEXT: ElementCount (SubjectMatchRule_field)
 // CHECK-NEXT: EnableIf (SubjectMatchRule_function)
 // CHECK-NEXT: EnforceTCB (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: EnforceTCBLeaf (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -8238,6 +8238,29 @@
   D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL));
 }
 
+static void handleElementCountAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // TODO: Probably needs more processing here. See Sema::AddAlignValueAttr.
+  SmallVector Names;
+  SmallVector Ranges;
+  for (unsigned ArgNo = 0; ArgNo < getNumAttributeArgs(AL); ++ArgNo) {
+if (!AL.isArgIdent(ArgNo)) {
+  S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+  << AL << AANT_ArgumentIdentifier;
+  return;
+}
+
+IdentifierLoc *IL = AL.getArgAsIdent(ArgNo);
+Names.push_back(IL->Ident);
+Ranges.push_back(IL->Loc);
+  }
+
+  ElementCountAttr *ECA = ::new (S.Context) ElementCountAttr(S.Context, AL,
+ Names.data(),
+ Names.size());
+  ECA->addCountFieldSourceRange(Ranges);
+  D->addAttr(ECA);
+}
+
 static void handleFunctionReturnThunksAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
   StringRef KindStr;
@@ -9136,6 +9159,9 @@
   case ParsedAttr::AT_FunctionReturnThunks:
 handleFunctionReturnThunksAttr(S, D, AL);
 break;
+  case ParsedAttr::AT_ElementCount:
+handleElementCountAttr(S, D, AL);
+break;
 
   // Microsoft attributes:
   case ParsedAttr::AT_LayoutVersion:
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17692,6 +17692,44 @@
  "Broken injected-class-name");
 }
 
+static const FieldDecl *FindFieldWithElementCountAttr(const RecordDecl *RD) {
+  for (const Decl *D : RD->decls()) {
+if (const auto *FD = dyn_cast(D))
+  if (FD->hasAttr())
+return FD;
+
+if (const auto *SubRD = dyn_cast(D))
+  if (const FieldDecl *FD = FindFieldWithElementCountAttr(SubRD))
+return FD;
+  }
+
+  return nullptr;
+}
+
+static const IdentifierInfo *
+CheckElementCountAttr(const RecordDecl *RD, const FieldDecl *FD,
+  SourceRange &Loc) {
+  const ElementCountAttr *ECA = FD->getAttr();
+  unsigned Idx = 0;
+
+  for (const IdentifierInfo *II : ECA->elementCountFields()) {
+Loc = ECA->getCountFieldSourceRange(Idx++);
+
+auto DeclIter = llvm::find_if(
+RD->fields(), [&](const FieldDecl *FD){
+  return II->getName() == FD->getName();
+});
+
+if (DeclIter == RD->field_end())
+  return II;
+
+if (auto *SubRD = DeclIter->getType()->getAsRecordDecl())
+  RD = SubRD;
+  }
+
+  return nullptr;
+}
+
 void Sema::ActOnTagFinishDefinition(Scope *S, Decl *TagD,
 SourceRange BraceRange) {
   AdjustDeclIfTemplate(TagD);
@@ -17749,6 +17787,17 @@
  [](const FieldDecl *FD) { return FD->isBitField(); }))
   Diag(BraceRange.getBegin(), diag::warn_pragma_align_not_xl_compatible);
   }
+
+  // Check the "element_count" attribute to ensure that the count field exists
+  // in the struct.
+  if (const RecordDecl *RD = dyn_cast(Tag)) {
+if (const FieldDecl *FD = FindFieldWithElementCountAttr(RD)) {
+  SourceRange SR;
+  if (const IdentifierInfo *II = CheckElementCountAttr(RD, FD, SR))
+Diag(SR.getBegin(), diag::warn_element_count_placeholder)

[PATCH] D145343: [AMDGPU] Emit predefined macro `__AMDGCN_CUMODE`

2023-05-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Basic/Targets/AMDGPU.cpp:318
   Builder.defineMacro("__AMDGCN_WAVEFRONT_SIZE", Twine(WavefrontSize));
+  Builder.defineMacro("__AMDGCN_CUMODE", Twine(CUMode));
 }

Why do we sometimes use __ on both sides, and sometimes only leading __?


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

https://reviews.llvm.org/D145343

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


[PATCH] D149464: [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

2023-05-01 Thread Samira Bazuzi via Phabricator via cfe-commits
bazuzi updated this revision to Diff 518547.
bazuzi added a comment.

Use LLVM_DEPRECATED in place of comments indicating deprecation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149464

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -53,9 +53,10 @@
   [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext &C,
   Environment &Env) {
 return NoopAnalysis(
-C, DataflowAnalysisOptions{UseBuiltinModel
-   ? Env.getAnalysisOptions()
-   : std::optional()});
+C,
+DataflowAnalysisOptions{
+UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
+: std::optional()});
   });
   AI.ASTBuildArgs = ASTBuildArgs;
   if (Options.BuiltinOpts)
Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -37,14 +37,16 @@
 
   static TestLattice initialElement() { return TestLattice{}; }
   void transfer(const CFGElement &, TestLattice &L, Environment &E) {
-E.logger().log([](llvm::raw_ostream &OS) { OS << "transfer()"; });
+E.getDataflowAnalysisContext().getOptions().Log->log(
+[](llvm::raw_ostream &OS) { OS << "transfer()"; });
 ++L.Elements;
   }
   void transferBranch(bool Branch, const Stmt *S, TestLattice &L,
   Environment &E) {
-E.logger().log([&](llvm::raw_ostream &OS) {
-  OS << "transferBranch(" << Branch << ")";
-});
+E.getDataflowAnalysisContext().getOptions().Log->log(
+[&](llvm::raw_ostream &OS) {
+  OS << "transferBranch(" << Branch << ")";
+});
 ++L.Branches;
   }
 };
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -168,7 +168,8 @@
   llvm::ArrayRef>
   BlockStates)
   : CFCtx(CFCtx), Analysis(Analysis), InitEnv(InitEnv),
-Log(InitEnv.logger()), BlockStates(BlockStates) {
+Log(*InitEnv.getDataflowAnalysisContext().getOptions().Log),
+BlockStates(BlockStates) {
 Log.beginAnalysis(CFCtx, Analysis);
   }
   ~AnalysisContext() { Log.endAnalysis(); }
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -496,7 +496,7 @@
   }
 
   void VisitReturnStmt(const ReturnStmt *S) {
-if (!Env.getAnalysisOptions().ContextSensitiveOpts)
+if (!Env.getDataflowAnalysisContext().getOptions().ContextSensitiveOpts)
   return;
 
 auto *Ret = S->getRetValue();
@@ -863,12 +863,13 @@
   // `F` of `S`. The type `E` must be either `CallExpr` or `CXXConstructExpr`.
   template 
   void transferInlineCall(const E *S, const FunctionDecl *F) {
-const auto &Options = Env.getAnalysisOptions();
+const auto &Options = Env.getDataflowAnalysisContext().getOptions();
 if (!(Options.ContextSensitiveOpts &&
   Env.canDescend(Options.ContextSensitiveOpts->Depth, F)))
   return;
 
-const ControlFlowContext *CFCtx = Env.getControlFlowContext(F);
+const ControlFlowContext *CFCtx =
+Env.getDataflowAnalysisContext().getControlFlowContext(F);
 if (!CFCtx)
   return;
 
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -381,7 +381,7 @@
 
 QualType ParamType = Param->getType();
 if (ParamType->isReferenceType()) {
-  auto &Val = arena().create(*ArgLoc);
+  auto &Val = DACtx->arena().create(*ArgLoc);
   setValue(Loc, Val);
 } else if (auto *ArgVal = getValue(*ArgLoc)) {
   setValue(Loc, *ArgVal);
@@ -707,7 +707,7 @@
 // with integers, and so di

[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-01 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 518548.
aeubanks added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/IgnoreExpr.h
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Sema/ms_predefined_expr.cpp

Index: clang/test/Sema/ms_predefined_expr.cpp
===
--- /dev/null
+++ clang/test/Sema/ms_predefined_expr.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wmicrosoft -verify -fms-extensions
+// expected-no-diagnostics
+
+void f() {
+ const char a[] = __FUNCTION__;
+ const char b[] = __FUNCDNAME__;
+ const char c[] = __FUNCSIG__;
+ const char d[] = __func__;
+ const char e[] = __PRETTY_FUNCTION__;
+}
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -593,6 +593,7 @@
   bool HasFunctionName = E->getFunctionName() != nullptr;
   Record.push_back(HasFunctionName);
   Record.push_back(E->getIdentKind()); // FIXME: stable encoding
+  Record.push_back(E->isTransparent());
   Record.AddSourceLocation(E->getLocation());
   if (HasFunctionName)
 Record.AddStmt(E->getFunctionName());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -582,6 +582,7 @@
   bool HasFunctionName = Record.readInt();
   E->PredefinedExprBits.HasFunctionName = HasFunctionName;
   E->PredefinedExprBits.Kind = Record.readInt();
+  E->PredefinedExprBits.IsTransparent = Record.readInt();
   E->setLocation(readSourceLocation());
   if (HasFunctionName)
 E->setFunctionName(cast(Record.readSubExpr()));
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -173,6 +173,8 @@
   E = GSE->getResultExpr();
 } else if (ChooseExpr *CE = dyn_cast(E)) {
   E = CE->getChosenSubExpr();
+} else if (PredefinedExpr *PE = dyn_cast(E)) {
+  E = PE->getFunctionName();
 } else {
   llvm_unreachable("unexpected expr in string literal init");
 }
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -3580,7 +3580,8 @@
 }
   }
 
-  return PredefinedExpr::Create(Context, Loc, ResTy, IK, SL);
+  return PredefinedExpr::Create(Context, Loc, ResTy, IK, LangOpts.MicrosoftExt,
+SL);
 }
 
 ExprResult Sema::BuildSYCLUniqueStableNameExpr(SourceLocation OpLoc,
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -663,13 +663,14 @@
 }
 
 PredefinedExpr::PredefinedExpr(SourceLocation L, QualType FNTy, IdentKind IK,
-   StringLiteral *SL)
+   bool IsTransparent, StringLiteral *SL)
 : Expr(PredefinedExprClass, FNTy, VK_LValue, OK_Ordinary) {
   PredefinedExprBits.Kind = IK;
   assert((getIdentKind() == IK) &&
  "IdentKind do not fit in PredefinedExprBitfields!");
   bool HasFunctionName = SL != nullptr;
   PredefinedExprBits.HasFunctionName = HasFunctionName;
+  PredefinedExprBits.IsTransparent = IsTransparent;
   PredefinedExprBits.Loc = L;
   if (HasFunctionName)
 setFunctionName(SL);
@@ -683,11 +684,11 @@
 
 PredefinedExpr *PredefinedExpr::Create(const ASTContext &Ctx, SourceLocation L,
QualType FNTy, IdentKind IK,
-   StringLiteral *SL) {
+   bool IsTransparent, StringLiteral *SL) {
   bool HasFunctionName = SL != nullptr;
   void *Mem = Ctx.Allocate(totalSizeToAlloc(HasFunctionName),
alignof(PredefinedExpr));
-  return new (Mem) PredefinedExpr(L, FNTy, IK, SL);
+  return new (Mem) PredefinedExpr(L, FNTy, IK, IsTransparent, SL);
 }
 
 PredefinedExpr *PredefinedExpr::CreateEmpty(const ASTContext &Ctx,
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -7068,7 +7068,8 @@
 return std::move(Err);
 
   return PredefinedExpr::Create(Importer.getToContext(), ToBeginLoc, ToType,
-E->getIdentKind(), ToFunctionName);
+E->getI

[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-01 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks marked an inline comment as done.
aeubanks added a comment.

In D146764#4310398 , @aaron.ballman 
wrote:

> I think you're missing changes in ASTReaderStmt.cpp and ASTWriterStmt.cpp, so 
> serialization through modules or PCH won't work without that.

done. how would this sort of change be tested?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D145441: [AMDGPU] Define data layout entries for buffers

2023-05-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM. It may not be the end step and may be annoying to make further changes 
from this point, but on its own this isn't worse than before




Comment at: llvm/lib/Target/AMDGPU/SIISelLowering.cpp:998
 
 // TODO: Should images get their own address space?
+Info.fallbackAddressSpace = AMDGPUAS::BUFFER_RESOURCE;

Should this todo be dropped?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145441

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


[PATCH] D149451: [NVPTX] Add NVPTXCtorDtorLoweringPass to handle global ctors / dtors

2023-05-01 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

LGTM overall.




Comment at: llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp:58
+((IsCtor ? "__init_array_object_" : "__fini_array_object_") +
+ F->getName() + "_" + getHash(M.getName()) + "_" +
+ std::to_string(Priority))

Source file name may be a little bit better, though it's still easy to clash if 
someone does `cd A; clang ./foo.c; cd ../B; clang ./foo.c` and the file name 
uses relative paths.

I think we'll need a way to override this unique suffix explicitly as an escape 
hatch for cases where someone runs into a clash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149451

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


[PATCH] D146386: [MS ABI] Fix mangling references to declarations.

2023-05-01 Thread Andrey Ali Khan Bolshakov via Phabricator via cfe-commits
bolshakov-a added a comment.

No, I don't have commit access. You could use just `Bolshakov 
`


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

https://reviews.llvm.org/D146386

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


[PATCH] D149451: [NVPTX] Add NVPTXCtorDtorLoweringPass to handle global ctors / dtors

2023-05-01 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: llvm/lib/Target/NVPTX/NVPTXCtorDtorLowering.cpp:58
+((IsCtor ? "__init_array_object_" : "__fini_array_object_") +
+ F->getName() + "_" + getHash(M.getName()) + "_" +
+ std::to_string(Priority))

tra wrote:
> Source file name may be a little bit better, though it's still easy to clash 
> if someone does `cd A; clang ./foo.c; cd ../B; clang ./foo.c` and the file 
> name uses relative paths.
> 
> I think we'll need a way to override this unique suffix explicitly as an 
> escape hatch for cases where someone runs into a clash.
I figured it'd be good enough since this is admittedly *very* niche. So someone 
would need to have a file called `foo.c` that also had a constructor called 
`foo` in it. For it to clash. Isn't it too late to grab the source filename 
while we're in the backend lowering stage?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149451

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


  1   2   >