[clang] [Clang] Remove some dead code in getNumTeamsExprForTargetDirective (PR #95695)

2024-07-25 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-x86_64-debian-fast` 
running on `gribozavr4` while building `clang` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/56/builds/3353

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang Tools :: clang-doc/basic-project.test' FAILED 

Exit Code: 1

Command Output (stdout):
--
Emiting docs in html format.
Mapping decls...
Collecting infos...
Reducing 5 infos...
Generating docs...
Generating assets for docs...

--
Command Output (stderr):
--
RUN: at line 1: rm -rf 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
 && mkdir -p 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
+ rm -rf 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
+ mkdir -p 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
RUN: at line 2: sed 
's|$test_dir|/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc|g'
 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
 > 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ sed 
's|$test_dir|/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc|g'
 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
RUN: at line 3: clang-doc --format=html 
--output=/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 --executor=all-TUs 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ clang-doc --format=html 
--output=/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 --executor=all-TUs 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
[1/3] Processing file 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Rectangle.cpp
[2/3] Processing file 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Circle.cpp
[3/3] Processing file 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
RUN: at line 4: FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/index_json.js
 -check-prefix=JSON-INDEX
+ FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/index_json.js
 -check-prefix=JSON-INDEX
RUN: at line 5: FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html
 -check-prefix=HTML-SHAPE
+ FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html
 -check-prefix=HTML-SHAPE
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/test/clang-doc/basic-project.test:64:16:
 error: HTML-SHAPE: expected string not found in input
// HTML-SHAPE: area
   ^
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html:27:53:
 note: scanning from here
 Defined at line 13 of file ./include/Shape.h
^
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html:47:41:
 note: possible intended match here
 area
^

Input file: 
/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/test/clang-doc/Output/ba

[clang] [clang][analyzer] MmapWriteExecChecker improvements (PR #97078)

2024-07-25 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/97078

From 1f04ce794a3aefc0f5622a9dea0a92a1e2b50be9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Tue, 25 Jun 2024 16:27:00 +0200
Subject: [PATCH 1/3] [clang][analyzer] MmapWriteExecChecker improvements

Read the 'mmap' flags from macro values and use a better test
for the error situation .
---
 .../Checkers/MmapWriteExecChecker.cpp | 49 +--
 clang/test/Analysis/mmap-writeexec.c  |  9 ++--
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
index cd1dd1b2fc511..a5a2bd62b47d6 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -21,30 +21,55 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 
 using namespace clang;
 using namespace ento;
 
 namespace {
-class MmapWriteExecChecker : public Checker {
+class MmapWriteExecChecker
+: public Checker {
   CallDescription MmapFn{CDM::CLibrary, {"mmap"}, 6};
   CallDescription MprotectFn{CDM::CLibrary, {"mprotect"}, 3};
-  static int ProtWrite;
-  static int ProtExec;
-  static int ProtRead;
   const BugType BT{this, "W^X check fails, Write Exec prot flags set",
"Security"};
 
+  mutable bool FlagsInitialized = false;
+  mutable int ProtRead = 0x01;
+  mutable int ProtWrite = 0x02;
+  mutable int ProtExec = 0x04;
+
 public:
+  void checkBeginFunction(CheckerContext &C) const;
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
+
   int ProtExecOv;
   int ProtReadOv;
 };
 }
 
-int MmapWriteExecChecker::ProtWrite = 0x02;
-int MmapWriteExecChecker::ProtExec  = 0x04;
-int MmapWriteExecChecker::ProtRead  = 0x01;
+void MmapWriteExecChecker::checkBeginFunction(CheckerContext &C) const {
+  if (FlagsInitialized)
+return;
+
+  FlagsInitialized = true;
+
+  const std::optional FoundProtRead =
+  tryExpandAsInteger("PROT_READ", C.getPreprocessor());
+  const std::optional FoundProtWrite =
+  tryExpandAsInteger("PROT_WRITE", C.getPreprocessor());
+  const std::optional FoundProtExec =
+  tryExpandAsInteger("PROT_EXEC", C.getPreprocessor());
+  if (FoundProtRead && FoundProtWrite && FoundProtExec) {
+ProtRead = *FoundProtRead;
+ProtWrite = *FoundProtWrite;
+ProtExec = *FoundProtExec;
+  } else {
+// FIXME: Are these useful?
+ProtRead = ProtReadOv;
+ProtExec = ProtExecOv;
+  }
+}
 
 void MmapWriteExecChecker::checkPreCall(const CallEvent &Call,
  CheckerContext &C) const {
@@ -54,16 +79,8 @@ void MmapWriteExecChecker::checkPreCall(const CallEvent 
&Call,
 if (!ProtLoc)
   return;
 int64_t Prot = ProtLoc->getValue().getSExtValue();
-if (ProtExecOv != ProtExec)
-  ProtExec = ProtExecOv;
-if (ProtReadOv != ProtRead)
-  ProtRead = ProtReadOv;
-
-// Wrong settings
-if (ProtRead == ProtExec)
-  return;
 
-if ((Prot & (ProtWrite | ProtExec)) == (ProtWrite | ProtExec)) {
+if ((Prot & ProtWrite) && (Prot & ProtExec)) {
   ExplodedNode *N = C.generateNonFatalErrorNode();
   if (!N)
 return;
diff --git a/clang/test/Analysis/mmap-writeexec.c 
b/clang/test/Analysis/mmap-writeexec.c
index 8fd86ceb9d2a2..88fcc7788e683 100644
--- a/clang/test/Analysis/mmap-writeexec.c
+++ b/clang/test/Analysis/mmap-writeexec.c
@@ -1,13 +1,14 @@
 // RUN: %clang_analyze_cc1 -triple i686-unknown-linux 
-analyzer-checker=alpha.security.MmapWriteExec -analyzer-config 
alpha.security.MmapWriteExec:MmapProtExec=1 -analyzer-config 
alpha.security.MmapWriteExec:MmapProtRead=4 
-DUSE_ALTERNATIVE_PROT_EXEC_DEFINITION -verify %s
 // RUN: %clang_analyze_cc1 -triple x86_64-unknown-apple-darwin10 
-analyzer-checker=alpha.security.MmapWriteExec -verify %s
 
-#define PROT_WRITE  0x02
 #ifndef USE_ALTERNATIVE_PROT_EXEC_DEFINITION
-#define PROT_EXEC   0x04
-#define PROT_READ   0x01
-#else
 #define PROT_EXEC   0x01
+#define PROT_WRITE  0x02
 #define PROT_READ   0x04
+#else
+#define PROT_EXEC   0x08
+#define PROT_WRITE  0x04
+#define PROT_READ   0x02
 #endif
 #define MAP_PRIVATE 0x0002
 #define MAP_ANON0x1000

From dbdfe92c4b89e4af1bd549fe07a4743c05685286 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Tue, 23 Jul 2024 17:49:54 +0200
Subject: [PATCH 2/3] using checkASTDecl, added PP variable, removed options

---
 .../clang/StaticAnalyzer/Checkers/Checkers.td | 12 -
 .../Checkers/MmapWriteExecChecker.cpp | 47 ++-
 2 files changed, 15 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/Static

[clang] [clang][analyzer] MmapWriteExecChecker improvements (PR #97078)

2024-07-25 Thread Balázs Kéri via cfe-commits


@@ -1,13 +1,14 @@
 // RUN: %clang_analyze_cc1 -triple i686-unknown-linux 
-analyzer-checker=alpha.security.MmapWriteExec -analyzer-config 
alpha.security.MmapWriteExec:MmapProtExec=1 -analyzer-config 
alpha.security.MmapWriteExec:MmapProtRead=4 
-DUSE_ALTERNATIVE_PROT_EXEC_DEFINITION -verify %s

balazske wrote:

There was really a test failure, fixed now.

https://github.com/llvm/llvm-project/pull/97078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] prevent checking destructor reference with an invalid initializer (PR #97860)

2024-07-25 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/97860
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] remove unneeded nullptr checks after dereference (PR #100489)

2024-07-25 Thread via cfe-commits

https://github.com/cor3ntin approved this pull request.


https://github.com/llvm/llvm-project/pull/100489
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Remove some dead code in getNumTeamsExprForTargetDirective (PR #95695)

2024-07-25 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-armv8-quick` running 
on `linaro-clang-armv8-quick` while building `clang` at step 5 "ninja check 1".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/154/builds/1917

Here is the relevant piece of the build log for the reference:
```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang Tools :: clang-doc/basic-project.test' FAILED 

Exit Code: 1

Command Output (stdout):
--
Emiting docs in html format.
Mapping decls...
Collecting infos...
Reducing 5 infos...
Generating docs...
Generating assets for docs...

--
Command Output (stderr):
--
RUN: at line 1: rm -rf 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
 && mkdir -p 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
+ rm -rf 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
+ mkdir -p 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
RUN: at line 2: sed 
's|$test_dir|/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc|g'
 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
 > 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ sed 
's|$test_dir|/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc|g'
 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
RUN: at line 3: clang-doc --format=html 
--output=/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 --executor=all-TUs 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ clang-doc --format=html 
--output=/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 --executor=all-TUs 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
[1/3] Processing file 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
[2/3] Processing file 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Circle.cpp
[3/3] Processing file 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Rectangle.cpp
RUN: at line 4: FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/index_json.js
 -check-prefix=JSON-INDEX
+ FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/index_json.js
 -check-prefix=JSON-INDEX
RUN: at line 5: FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html
 -check-prefix=HTML-SHAPE
+ FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html
 -check-prefix=HTML-SHAPE
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang-tools-extra/test/clang-doc/basic-project.test:64:16:
 error: HTML-SHAPE: expected string not found in input
// HTML-SHAPE: area
   ^
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html:32:53:
 note: scanning from here
 Defined at line 13 of file ./include/Shape.h
^
/home/tcwg-bui

[clang] [Clang] Remove `IDNS_Ordinary` flag in `IndirectField::IdentifierNamespace` (PR #100525)

2024-07-25 Thread Yanzuo Liu via cfe-commits

https://github.com/zwuis created 
https://github.com/llvm/llvm-project/pull/100525

There is a `IDNS_Ordinary` flag in `IndirectField::IdentifierNamespace` so that 
members in nested anonymous struct/union can be found as ordinary identifiers.

```c
struct S {
  struct { int x; };
  // Previous behaviour: `x` in previous line is found
  // Expected: nothing is found
  int arr[sizeof(x)];
};
```

This PR fixes this issue.

Fixes #31295.

>From 217d3978f48ea074420fecd432b0b65b7e1c5b58 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Thu, 25 Jul 2024 14:50:21 +0800
Subject: [PATCH] Remove `IDNS_Ordinary` flag in
 `IndirectField::IdentifierNamespace`

---
 clang/docs/ReleaseNotes.rst | 3 +++
 clang/lib/AST/DeclBase.cpp  | 3 +--
 clang/test/Parser/namelookup-anonymous-struct.c | 6 ++
 3 files changed, 10 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Parser/namelookup-anonymous-struct.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 83fd5dc31547e..24be9e26a9adf 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -137,6 +137,9 @@ Miscellaneous Bug Fixes
 Miscellaneous Clang Crashes Fixed
 ^
 
+- Fixed a crash in C due to incorrect lookup that members in nested anonymous 
struct/union
+  can be found as ordinary identifiers in struct/union definition. (#GH31295)
+
 OpenACC Specific Changes
 
 
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index bc5a9206c0db2..a1f70546bde42 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -879,8 +879,6 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) 
{
   return IDNS_Ordinary;
 case Label:
   return IDNS_Label;
-case IndirectField:
-  return IDNS_Ordinary | IDNS_Member;
 
 case Binding:
 case NonTypeTemplateParm:
@@ -918,6 +916,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) 
{
   return IDNS_ObjCProtocol;
 
 case Field:
+case IndirectField:
 case ObjCAtDefsField:
 case ObjCIvar:
   return IDNS_Member;
diff --git a/clang/test/Parser/namelookup-anonymous-struct.c 
b/clang/test/Parser/namelookup-anonymous-struct.c
new file mode 100644
index 0..cb691c22f97ff
--- /dev/null
+++ b/clang/test/Parser/namelookup-anonymous-struct.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c11 -verify %s
+
+struct GH31295 {
+  struct { int x; };
+  int arr[sizeof(x)]; // expected-error{{use of undeclared identifier 'x'}}
+};

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


[clang] [Clang] Remove `IDNS_Ordinary` flag in `IndirectField::IdentifierNamespace` (PR #100525)

2024-07-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yanzuo Liu (zwuis)


Changes

There is a `IDNS_Ordinary` flag in `IndirectField::IdentifierNamespace` so that 
members in nested anonymous struct/union can be found as ordinary identifiers.

```c
struct S {
  struct { int x; };
  // Previous behaviour: `x` in previous line is found
  // Expected: nothing is found
  int arr[sizeof(x)];
};
```

This PR fixes this issue.

Fixes #31295.

---
Full diff: https://github.com/llvm/llvm-project/pull/100525.diff


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/lib/AST/DeclBase.cpp (+1-2) 
- (added) clang/test/Parser/namelookup-anonymous-struct.c (+6) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 83fd5dc31547e..24be9e26a9adf 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -137,6 +137,9 @@ Miscellaneous Bug Fixes
 Miscellaneous Clang Crashes Fixed
 ^
 
+- Fixed a crash in C due to incorrect lookup that members in nested anonymous 
struct/union
+  can be found as ordinary identifiers in struct/union definition. (#GH31295)
+
 OpenACC Specific Changes
 
 
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index bc5a9206c0db2..a1f70546bde42 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -879,8 +879,6 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) 
{
   return IDNS_Ordinary;
 case Label:
   return IDNS_Label;
-case IndirectField:
-  return IDNS_Ordinary | IDNS_Member;
 
 case Binding:
 case NonTypeTemplateParm:
@@ -918,6 +916,7 @@ unsigned Decl::getIdentifierNamespaceForKind(Kind DeclKind) 
{
   return IDNS_ObjCProtocol;
 
 case Field:
+case IndirectField:
 case ObjCAtDefsField:
 case ObjCIvar:
   return IDNS_Member;
diff --git a/clang/test/Parser/namelookup-anonymous-struct.c 
b/clang/test/Parser/namelookup-anonymous-struct.c
new file mode 100644
index 0..cb691c22f97ff
--- /dev/null
+++ b/clang/test/Parser/namelookup-anonymous-struct.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -std=c11 -verify %s
+
+struct GH31295 {
+  struct { int x; };
+  int arr[sizeof(x)]; // expected-error{{use of undeclared identifier 'x'}}
+};

``




https://github.com/llvm/llvm-project/pull/100525
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 693d757 - Internalize a clang Sarif function

2024-07-25 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2024-07-25T00:13:00-07:00
New Revision: 693d757b63e5020e0fa78bb71fc16acdad5f8232

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

LOG: Internalize a clang Sarif function

Added: 


Modified: 
clang/lib/Basic/Sarif.cpp

Removed: 




diff  --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp
index 8c144df341673..980b0ae40ae22 100644
--- a/clang/lib/Basic/Sarif.cpp
+++ b/clang/lib/Basic/Sarif.cpp
@@ -141,7 +141,7 @@ static unsigned int adjustColumnPos(FullSourceLoc Loc,
 /// @{
 
 /// \internal
-json::Object createMessage(StringRef Text) {
+static json::Object createMessage(StringRef Text) {
   return json::Object{{"text", Text.str()}};
 }
 



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


[clang] [compiler-rt] [libcxx] [libunwind] [llvm] [openmp] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)

2024-07-25 Thread via cfe-commits

https://github.com/h-vetinari updated 
https://github.com/llvm/llvm-project/pull/96171

>From 1df587efeb71fb1929667f008d7e9b251863d9d8 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" 
Date: Thu, 20 Jun 2024 21:43:31 +1100
Subject: [PATCH 1/5] [cmake] switch to CMake's native check_linker_flag,
 delete LLVMCheckLinkerFlag.cmake

now that CMake baseline has moved past 3.18; see
https://cmake.org/cmake/help/latest/module/CheckLinkerFlag.html
---
 clang/tools/driver/CMakeLists.txt|  4 +--
 llvm/cmake/modules/AddLLVM.cmake |  4 +--
 llvm/cmake/modules/HandleLLVMOptions.cmake   |  8 +++---
 llvm/cmake/modules/HandleLLVMStdlib.cmake|  6 ++---
 llvm/cmake/modules/LLVMCheckLinkerFlag.cmake | 28 
 5 files changed, 11 insertions(+), 39 deletions(-)
 delete mode 100644 llvm/cmake/modules/LLVMCheckLinkerFlag.cmake

diff --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 290bf2a42536d..018605c2fd4f2 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -107,7 +107,7 @@ endif()
 
 if(CLANG_ORDER_FILE AND
 (LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
-  include(LLVMCheckLinkerFlag)
+  include(CheckLinkerFlag)
 
   if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -118,7 +118,7 @@ if(CLANG_ORDER_FILE AND
   endif()
 
   # This is a test to ensure the actual order file works with the linker.
-  llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} 
LINKER_ORDER_FILE_WORKS)
+  check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
 
   # Passing an empty order file disables some linker layout optimizations.
   # To work around this and enable workflows for re-linking when the order file
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 03f4e1f190fd9..cac5470435d91 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -327,8 +327,8 @@ function(add_link_opts target_name)
   elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
 # Support for ld -z discard-unused=sections was only added in
 # Solaris 11.4.  GNU ld ignores it, but warns every time.
-include(LLVMCheckLinkerFlag)
-llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" 
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+include(CheckLinkerFlag)
+check_linker_flag(CXX "-Wl,-z,discard-unused=sections" 
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
 if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
   set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,discard-unused=sections")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..bdbd36174fc7a 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1061,8 +1061,8 @@ if (LLVM_USE_SPLIT_DWARF AND
   if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
   CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
 add_compile_options($<$:-gsplit-dwarf>)
-include(LLVMCheckLinkerFlag)
-llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
+include(CheckLinkerFlag)
+check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
 append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
   CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS 
CMAKE_SHARED_LINKER_FLAGS)
   endif()
@@ -1083,8 +1083,8 @@ endif()
 
 # lld doesn't print colored diagnostics when invoked from Ninja
 if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
-  include(LLVMCheckLinkerFlag)
-  llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" 
LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+  include(CheckLinkerFlag)
+  check_linker_flag(CXX "-Wl,--color-diagnostics" 
LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
   append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
 CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
 endif()
diff --git a/llvm/cmake/modules/HandleLLVMStdlib.cmake 
b/llvm/cmake/modules/HandleLLVMStdlib.cmake
index 7afc10cff74ff..a7e138aa0789b 100644
--- a/llvm/cmake/modules/HandleLLVMStdlib.cmake
+++ b/llvm/cmake/modules/HandleLLVMStdlib.cmake
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
   endfunction()
 
   include(CheckCXXCompilerFlag)
-  include(LLVMCheckLinkerFlag)
+  include(CheckLinkerFlag)
   set(LLVM_LIBCXX_USED 0)
   if(LLVM_ENABLE_LIBCXX)
 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
   check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
-  llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+  check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
   if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
 append("-stdlib=libc++"
   CMAKE_CXX_FLAGS CMAKE_EXE_

[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr edited 
https://github.com/llvm/llvm-project/pull/100400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread Timm Baeder via cfe-commits


@@ -3593,8 +3593,14 @@ VarCreationState Compiler::visitDecl(const 
VarDecl *VD) {
   if (R.notCreated())
 return R;
 
-  if (R)
-return true;
+  if (R) {

tbaederr wrote:

Yes, remove it please.

https://github.com/llvm/llvm-project/pull/100400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr approved this pull request.

LGTM with the suggested changes. This might not be perfect wrt. revisiting 
`DecompositionDecl`s, but we can handle problems when they arise.

https://github.com/llvm/llvm-project/pull/100400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread Timm Baeder via cfe-commits


@@ -5234,6 +5240,9 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
   return false;
 };
 
+if (isa(VD))

tbaederr wrote:

```suggestion
   // DecompositionDecls are just proxies for us.
if (isa(VD))
```

https://github.com/llvm/llvm-project/pull/100400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] MmapWriteExecChecker improvements (PR #97078)

2024-07-25 Thread Balazs Benics via cfe-commits
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= ,
=?utf-8?q?Bal=C3=A1zs_K=C3=A9ri?= 
Message-ID:
In-Reply-To: 


steakhal wrote:

Please make sure that the premerge bots are happy before merging.

https://github.com/llvm/llvm-project/pull/97078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Disallow applying `onwership_returns` to functions that return non-pointers (PR #99564)

2024-07-25 Thread Balazs Benics via cfe-commits

https://github.com/steakhal approved this pull request.

LGTM, thanks.

https://github.com/llvm/llvm-project/pull/99564
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [libcxx] [libunwind] [llvm] [openmp] [cmake] switch to CMake's native `check_{compiler,linker}_flag` (PR #96171)

2024-07-25 Thread via cfe-commits

https://github.com/h-vetinari updated 
https://github.com/llvm/llvm-project/pull/96171

>From 1df587efeb71fb1929667f008d7e9b251863d9d8 Mon Sep 17 00:00:00 2001
From: "H. Vetinari" 
Date: Thu, 20 Jun 2024 21:43:31 +1100
Subject: [PATCH 1/6] [cmake] switch to CMake's native check_linker_flag,
 delete LLVMCheckLinkerFlag.cmake

now that CMake baseline has moved past 3.18; see
https://cmake.org/cmake/help/latest/module/CheckLinkerFlag.html
---
 clang/tools/driver/CMakeLists.txt|  4 +--
 llvm/cmake/modules/AddLLVM.cmake |  4 +--
 llvm/cmake/modules/HandleLLVMOptions.cmake   |  8 +++---
 llvm/cmake/modules/HandleLLVMStdlib.cmake|  6 ++---
 llvm/cmake/modules/LLVMCheckLinkerFlag.cmake | 28 
 5 files changed, 11 insertions(+), 39 deletions(-)
 delete mode 100644 llvm/cmake/modules/LLVMCheckLinkerFlag.cmake

diff --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 290bf2a42536d..018605c2fd4f2 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -107,7 +107,7 @@ endif()
 
 if(CLANG_ORDER_FILE AND
 (LLVM_LINKER_IS_APPLE OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
-  include(LLVMCheckLinkerFlag)
+  include(CheckLinkerFlag)
 
   if (LLVM_LINKER_IS_APPLE OR (LLVM_LINKER_IS_LLD AND APPLE))
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -118,7 +118,7 @@ if(CLANG_ORDER_FILE AND
   endif()
 
   # This is a test to ensure the actual order file works with the linker.
-  llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} 
LINKER_ORDER_FILE_WORKS)
+  check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
 
   # Passing an empty order file disables some linker layout optimizations.
   # To work around this and enable workflows for re-linking when the order file
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 03f4e1f190fd9..cac5470435d91 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -327,8 +327,8 @@ function(add_link_opts target_name)
   elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
 # Support for ld -z discard-unused=sections was only added in
 # Solaris 11.4.  GNU ld ignores it, but warns every time.
-include(LLVMCheckLinkerFlag)
-llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" 
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+include(CheckLinkerFlag)
+check_linker_flag(CXX "-Wl,-z,discard-unused=sections" 
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
 if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
   set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,discard-unused=sections")
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..bdbd36174fc7a 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1061,8 +1061,8 @@ if (LLVM_USE_SPLIT_DWARF AND
   if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
   CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
 add_compile_options($<$:-gsplit-dwarf>)
-include(LLVMCheckLinkerFlag)
-llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
+include(CheckLinkerFlag)
+check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
 append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
   CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS 
CMAKE_SHARED_LINKER_FLAGS)
   endif()
@@ -1083,8 +1083,8 @@ endif()
 
 # lld doesn't print colored diagnostics when invoked from Ninja
 if (UNIX AND CMAKE_GENERATOR MATCHES "Ninja")
-  include(LLVMCheckLinkerFlag)
-  llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" 
LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+  include(CheckLinkerFlag)
+  check_linker_flag(CXX "-Wl,--color-diagnostics" 
LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
   append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
 CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
 endif()
diff --git a/llvm/cmake/modules/HandleLLVMStdlib.cmake 
b/llvm/cmake/modules/HandleLLVMStdlib.cmake
index 7afc10cff74ff..a7e138aa0789b 100644
--- a/llvm/cmake/modules/HandleLLVMStdlib.cmake
+++ b/llvm/cmake/modules/HandleLLVMStdlib.cmake
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
   endfunction()
 
   include(CheckCXXCompilerFlag)
-  include(LLVMCheckLinkerFlag)
+  include(CheckLinkerFlag)
   set(LLVM_LIBCXX_USED 0)
   if(LLVM_ENABLE_LIBCXX)
 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
   check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
-  llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+  check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
   if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
 append("-stdlib=libc++"
   CMAKE_CXX_FLAGS CMAKE_EXE_

[clang] [Clang][Driver] Warn about `-c/-S` with `-fsyntax-only` (PR #98607)

2024-07-25 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

FWIW, in addition to `-c` in combination with `-fsyntax-only`, this now also 
warns for `-c` in combination with `-E`.

That sounds like a reasonable thing to do to me, so it's probably fine, but 
it'd be nice to have that aspect acknowledged as one intended behaviour change 
as well.

https://github.com/llvm/llvm-project/pull/98607
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-07-25 Thread via cfe-commits

https://github.com/martinboehme approved this pull request.

Wow, how can this ever have worked? Appears that the answer is that there 
simply aren't any existing callers of this constructor...

In any case, thanks for the fix!

https://github.com/llvm/llvm-project/pull/95697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] AMDGPU: Handle remote/fine-grained memory in atomicrmw fmin/fmax lowering (PR #96759)

2024-07-25 Thread Matt Arsenault via cfe-commits

arsenm wrote:

ping in

https://github.com/llvm/llvm-project/pull/96759
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Remove `IDNS_Ordinary` flag in `IndirectFieldDecl::IdentifierNamespace` (PR #100525)

2024-07-25 Thread Yanzuo Liu via cfe-commits

https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/100525
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Remove `IDNS_Ordinary` flag in `IndirectFieldDecl::IdentifierNamespace` (PR #100525)

2024-07-25 Thread Yanzuo Liu via cfe-commits

https://github.com/zwuis edited https://github.com/llvm/llvm-project/pull/100525
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread Matt Arsenault via cfe-commits


@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const 
FunctionDecl *FD,
   RValue Call =
   CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
 auto IsErrnoIntrinsic = [&]() -> unsigned {
-  switch (BuiltinID) {
-  case Builtin::BIexpf:
-  case Builtin::BI__builtin_expf:
-  case Builtin::BI__builtin_expf128:
+  // Check whether a FP math builtin function, such as BI__builtin_expf
+  QualType ResultTy = FD->getReturnType();
+  bool IsMathLibCall =
+  Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+  Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+  if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())

arsenm wrote:

The errno-ness is already a builtin property you should be able to query from 
BuiltinInfo 

https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread Matt Arsenault via cfe-commits


@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const 
FunctionDecl *FD,
   RValue Call =
   CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
 auto IsErrnoIntrinsic = [&]() -> unsigned {
-  switch (BuiltinID) {
-  case Builtin::BIexpf:
-  case Builtin::BI__builtin_expf:
-  case Builtin::BI__builtin_expf128:
+  // Check whether a FP math builtin function, such as BI__builtin_expf
+  QualType ResultTy = FD->getReturnType();
+  bool IsMathLibCall =
+  Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+  Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+  if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())

arsenm wrote:

Although in the context of this patch, I don't see why any of this is relevant 
for emitting TBAA 

https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d82df1b - [PS4/PS5][Driver] Always pass LTO options to the linker (#100423)

2024-07-25 Thread via cfe-commits

Author: Edd Dawson
Date: 2024-07-25T09:43:17+01:00
New Revision: d82df1b891fecae0af7de5e970b592ce37178a30

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

LOG: [PS4/PS5][Driver] Always pass LTO options to the linker (#100423)

The driver doesn't know if LTO will occur at link time. That's
determined by the presence or absence of LLVM bitcode objects among
those ingested by the linker.

For this reason, LTO options for codegen etc must be passed to the
linker unconditionally. If LTO does not occur, these options have no
effect.

Also simplify the way LTO options are supplied to the PS4 linker.
`-lto-debug-options` and `-lto-thin-debug-options` are combined and
routed to the same place. So, always use the former, regardless of
full/thin LTO mode.

SIE tracker: TOOLCHAIN-16575

Added: 


Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/lto-jobs.c
clang/test/Driver/ps4-linker.c
clang/test/Driver/ps5-linker.c
clang/test/Driver/unified-lto.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index d6af9388e54a6..813a0fbedd2b1 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -152,48 +152,36 @@ void tools::PS4cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back(Output.getFilename());
   }
 
-  const bool UseLTO = D.isUsingLTO();
   const bool UseJMC =
   Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
 
   const char *LTOArgs = "";
-  auto AddCodeGenFlag = [&](Twine Flag) {
+  auto AddLTOFlag = [&](Twine Flag) {
 LTOArgs = Args.MakeArgString(Twine(LTOArgs) + " " + Flag);
   };
 
-  if (UseLTO) {
-// This tells LTO to perform JustMyCode instrumentation.
-if (UseJMC)
-  AddCodeGenFlag("-enable-jmc-instrument");
+  // If the linker sees bitcode objects it will perform LTO. We can't tell
+  // whether or not that will be the case at this point. So, unconditionally
+  // pass LTO options to ensure proper codegen, metadata production, etc if
+  // LTO indeed occurs.
+  if (Args.hasFlag(options::OPT_funified_lto, options::OPT_fno_unified_lto,
+   true))
+CmdArgs.push_back(D.getLTOMode() == LTOK_Thin ? "--lto=thin"
+  : "--lto=full");
+  if (UseJMC)
+AddLTOFlag("-enable-jmc-instrument");
 
-if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
-  AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
+  if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
+AddLTOFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
 
-StringRef Parallelism = getLTOParallelism(Args, D);
-if (!Parallelism.empty())
-  AddCodeGenFlag(Twine("-threads=") + Parallelism);
+  if (StringRef Threads = getLTOParallelism(Args, D); !Threads.empty())
+AddLTOFlag(Twine("-threads=") + Threads);
 
-const char *Prefix = nullptr;
-if (D.getLTOMode() == LTOK_Thin)
-  Prefix = "-lto-thin-debug-options=";
-else if (D.getLTOMode() == LTOK_Full)
-  Prefix = "-lto-debug-options=";
-else
-  llvm_unreachable("new LTO mode?");
-
-CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + LTOArgs));
-  }
+  CmdArgs.push_back(Args.MakeArgString(Twine("-lto-debug-options=") + 
LTOArgs));
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
 TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
 
-  if (D.isUsingLTO() && Args.hasArg(options::OPT_funified_lto)) {
-if (D.getLTOMode() == LTOK_Thin)
-  CmdArgs.push_back("--lto=thin");
-else if (D.getLTOMode() == LTOK_Full)
-  CmdArgs.push_back("--lto=full");
-  }
-
   Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_s, options::OPT_t});
 
@@ -259,37 +247,34 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back(Output.getFilename());
   }
 
-  const bool UseLTO = D.isUsingLTO();
   const bool UseJMC =
   Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false);
 
-  auto AddCodeGenFlag = [&](Twine Flag) {
+  auto AddLTOFlag = [&](Twine Flag) {
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=") + Flag));
   };
 
-  if (UseLTO) {
-// This tells LTO to perform JustMyCode instrumentation.
-if (UseJMC)
-  AddCodeGenFlag("-enable-jmc-instrument");
+  // If the linker sees bitcode objects it will perform LTO. We can't tell
+  // whether or not that will be the case at this point. So, unconditionally
+  // pass LTO options to ensure proper codegen, metadata production, etc if
+  // LTO indeed occurs.
+  if (Args.hasFlag(options::OPT_funified_lto, options::OPT_fn

[clang] [PS4/PS5][Driver] Always pass LTO options to the linker (PR #100423)

2024-07-25 Thread Edd Dawson via cfe-commits

https://github.com/playstation-edd closed 
https://github.com/llvm/llvm-project/pull/100423
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [PS4/PS5][Driver] Always pass LTO options to the linker (PR #100423)

2024-07-25 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `clang` at step 6 "test".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/59/builds/2206

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py
 (613 of 1994)
PASS: lldb-api :: 
functionalities/progress_reporting/TestTrimmedProgressReporting.py (614 of 1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManyCrash.py (615 of 
1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py (616 
of 1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py (617 of 
1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py (618 of 
1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py (619 
of 1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalDelayBreak.py (620 
of 1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentManySignals.py (621 of 
1994)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalNWatchNBreak.py 
(622 of 1994)
FAIL: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py (623 of 
1994)
 TEST 'lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py' FAILED 

Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/thread/concurrent_events
 -p TestConcurrentSignalWatch.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
d82df1b891fecae0af7de5e970b592ce37178a30)
  clang revision d82df1b891fecae0af7de5e970b592ce37178a30
  llvm revision d82df1b891fecae0af7de5e970b592ce37178a30
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

Watchpoint 1 hit:
old value: 0
new value: 1

--
Command Output (stderr):
--
FAIL: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test (TestConcurrentSignalWatch.ConcurrentSignalWatch)
==
FAIL: test (TestConcurrentSignalWatch.ConcurrentSignalWatch)
   Test a watchpoint and a signal in multiple threads.
--
Traceback (most recent call last):
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 148, in wrapper
return func(*args, **kwargs)
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py",
 line 14, in test
self.do_thread_actions(num_signal_threads=1, num_watchpoint_threads=1)
  File 
"/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/concurrent_base.py",
 line 329, in do_thread_actions
self.assertEqual(
AssertionError: 1 != 2 : Expected 1 stops due to signal delivery, but got 2
Config=aarch64-/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang
--
Ran 1 test in 4.374s


```

https://github.com/llvm/llvm-project/pull/100423
___
cfe-commits mail

[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat approved this pull request.

LGTM, nice improvement.

https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat edited 
https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Donát Nagy via cfe-commits


@@ -923,12 +923,31 @@ SVal AnyCXXConstructorCall::getCXXThisVal() const {
   return UnknownVal();
 }
 
+static bool isWithinStdNamespace(const Decl *D) {

NagyDonat wrote:

I think this function could be useful for other checkers as well; consider 
moving this to an externally visible location (e.g. turn this into a method of 
`Decl`).

https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4ca1a90 - [clang][CUDA] Assume unknown emission status for skipped function definitions (#100124)

2024-07-25 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2024-07-25T11:21:18+02:00
New Revision: 4ca1a901dc6ca1926a594f57e6c4997ea9d185a4

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

LOG: [clang][CUDA] Assume unknown emission status for skipped function 
definitions (#100124)

Emission status seems to be only used by cuda/openmp/hip compiles, to
figure out
when to emit diagnostics. Current logic emits "uknown" when definition
is
missing, so i extended that to skipped-function-bodies as well.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/unittests/Tooling/ToolingTest.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index bb25a0b3a45ae..575bd292f27de 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -20148,8 +20148,10 @@ Sema::FunctionEmissionStatus 
Sema::getEmissionStatus(const FunctionDecl *FD,
 // be emitted, because (say) the definition could include "inline".
 const FunctionDecl *Def = FD->getDefinition();
 
-return Def && !isDiscardableGVALinkage(
-  getASTContext().GetGVALinkageForFunction(Def));
+// We can't compute linkage when we skip function bodies.
+return Def && !Def->hasSkippedBody() &&
+   !isDiscardableGVALinkage(
+   getASTContext().GetGVALinkageForFunction(Def));
   };
 
   if (LangOpts.OpenMPIsTargetDevice) {

diff  --git a/clang/unittests/Tooling/ToolingTest.cpp 
b/clang/unittests/Tooling/ToolingTest.cpp
index 2e3da2cd2a701..f41a44fa0922a 100644
--- a/clang/unittests/Tooling/ToolingTest.cpp
+++ b/clang/unittests/Tooling/ToolingTest.cpp
@@ -586,6 +586,11 @@ TEST(runToolOnCode, TestSkipFunctionBody) {
   EXPECT_FALSE(runToolOnCodeWithArgs(
   std::make_unique(),
   "template int skipMeNot() { an_error_here }", Args2));
+
+  EXPECT_TRUE(runToolOnCodeWithArgs(
+  std::make_unique(),
+  "__inline __attribute__((__gnu_inline__)) void skipMe() {}",
+  {"--cuda-host-only", "-nocudainc", "-xcuda"}));
 }
 
 TEST(runToolOnCodeWithArgs, TestNoDepFile) {



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


[clang] [clang][CUDA] Assume unknown emission status for skipped function definitions (PR #100124)

2024-07-25 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet closed 
https://github.com/llvm/llvm-project/pull/100124
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)

2024-07-25 Thread Brandon Wu via cfe-commits


@@ -608,6 +608,9 @@ class CGFunctionInfo final
   /// Log 2 of the maximum vector width.
   unsigned MaxVectorWidth : 4;
 
+  /// Log2 of ABI_VLEN used in RISCV VLS calling convention.
+  unsigned Log2RISCVABIVLen : 4;

4vtomat wrote:

Yes, we need 5 bits, thanks for finding out that!

https://github.com/llvm/llvm-project/pull/100346
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)

2024-07-25 Thread Brandon Wu via cfe-commits


@@ -1333,6 +1333,15 @@ def Experimental
: SubtargetFeature<"experimental", "HasExperimental",
   "true", "Experimental intrinsics">;
 
+def FeatureABIVLen32B

4vtomat wrote:

Yeah, that's a good idea since the backend doesn't use them~

https://github.com/llvm/llvm-project/pull/100346
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 456c512 - [clang][Driver] Add cc1 flag for setting SkipFunctionBodies (#100135)

2024-07-25 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2024-07-25T11:27:14+02:00
New Revision: 456c5121f8e6f37881f236bdf573ef29cad5af1e

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

LOG: [clang][Driver] Add cc1 flag for setting SkipFunctionBodies (#100135)

This is an option set by certain tools (clangd and ASTUnit). Sometimes
there are crashes in clang, unique to this configuration and it's really
hard to provide reproducers without invoking the tool.

Added: 
clang/test/Frontend/skip-function-bodies.cpp

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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 28a5cb71d2219..26811bf948ae5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7534,6 +7534,9 @@ def code_completion_brief_comments : Flag<["-"], 
"code-completion-brief-comments
 def code_completion_with_fixits : Flag<["-"], "code-completion-with-fixits">,
   HelpText<"Include code completion results which require small fix-its.">,
   MarshallingInfoFlag>;
+def skip_function_bodies : Flag<["-"], "skip-function-bodies">,
+  HelpText<"Skip function bodies when possible">,
+  MarshallingInfoFlag>;
 def disable_free : Flag<["-"], "disable-free">,
   HelpText<"Disable freeing of memory on exit">,
   MarshallingInfoFlag>;

diff  --git a/clang/test/Frontend/skip-function-bodies.cpp 
b/clang/test/Frontend/skip-function-bodies.cpp
new file mode 100644
index 0..d0593b474bda2
--- /dev/null
+++ b/clang/test/Frontend/skip-function-bodies.cpp
@@ -0,0 +1,13 @@
+// Trivial check to ensure skip-function-bodies flag is propagated.
+//
+// RUN: %clang_cc1 -verify -skip-function-bodies -pedantic-errors %s
+// expected-no-diagnostics
+
+int f() {
+  // normally this should emit some diags, but we're skipping it!
+  this is garbage;
+}
+
+// Make sure we only accept it as a cc1 arg.
+// RUN: not %clang -skip-function-bodies %s 2>&1 | FileCheck %s
+// CHECK: clang: error: unknown argument '-skip-function-bodies'; did you mean 
'-Xclang -skip-function-bodies'?



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


[clang] [clang][Driver] Add flag for setting SkipFunctionBodies (PR #100135)

2024-07-25 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet closed 
https://github.com/llvm/llvm-project/pull/100135
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][Driver] Enable config file options (PR #100343)

2024-07-25 Thread Kiran Chandramohan via cfe-commits

kiranchandramohan wrote:

/cherry-pick 8a77961

https://github.com/llvm/llvm-project/pull/100343
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][VLS] Support RISCV VLS calling convention (PR #100346)

2024-07-25 Thread Brandon Wu via cfe-commits

https://github.com/4vtomat updated 
https://github.com/llvm/llvm-project/pull/100346

>From 15161b0b7637d52b6285624a4bf9f52a6664082c Mon Sep 17 00:00:00 2001
From: Brandon Wu 
Date: Sun, 21 Jul 2024 09:49:11 -0700
Subject: [PATCH 1/4] [RISCV][VLS] Support RISCV VLS calling convention

This patch adds a function attribute `riscv_vls_cc` for RISCV VLS calling
convention which takes 0 or 1 argument, the argument is the `ABI_VLEN`
which is the `VLEN` for passing the fixed-vector arguments, it wraps the
argument as a scalable vector(VLA) using the `ABI_VLEN` and uses the
corresponding mechanism to handle it. The range of `ABI_VLEN` is [32, 65536],
if not specified, the default value is 128.

An option `-mriscv-abi-vlen=N` is also added to specify the `ABI_VLEN`
globally, it's used for every functions are being compiled, however if
both function attribute and option are specified, the function attribute
has higher priority than the option which means the function attribute
overwrites the `ABI_VLEN` specified by the option.

Here is an example of VLS argument passing:
Non-VLS call:
```
  void original_call(__attribute__((vector_size(16))) int arg) {}
=>
  define void @original_call(i128 noundef %arg) {
  entry:
...
ret void
  }
```
VLS call:
```
  void __attribute__((riscv_vls_cc(256))) 
vls_call(__attribute__((vector_size(16))) int arg) {}
=>
  define riscv_vls_cc void @vls_call( %arg) {
  entry:
...
ret void
  }
}
```

The first Non-VLS call passes generic vector argument of 16 bytes by
flattened integer.
On the contrary, the VLS call uses `ABI_VLEN=256` which wraps the
vector to  where the number of scalable vector elements
is calaulated by: `ORIG_ELTS * RVV_BITS_PER_BLOCK / ABI_VLEN`.
Note: ORIG_ELTS = Vector Size / Type Size = 128 / 32 = 4.
---
 clang/include/clang-c/Index.h |  1 +
 clang/include/clang/AST/Type.h| 26 +--
 clang/include/clang/AST/TypeProperties.td |  7 +-
 clang/include/clang/Basic/Attr.td |  8 ++
 clang/include/clang/Basic/AttrDocs.td | 11 +++
 clang/include/clang/Basic/Specifiers.h|  1 +
 clang/include/clang/CodeGen/CGFunctionInfo.h  |  9 ++-
 clang/include/clang/Driver/Options.td |  2 +
 clang/lib/AST/ASTContext.cpp  |  2 +
 clang/lib/AST/ItaniumMangle.cpp   |  1 +
 clang/lib/AST/Type.cpp|  2 +
 clang/lib/AST/TypePrinter.cpp |  6 ++
 clang/lib/Basic/Targets/RISCV.cpp |  1 +
 clang/lib/CodeGen/CGCall.cpp  |  5 ++
 clang/lib/CodeGen/CGDebugInfo.cpp |  2 +
 clang/lib/CodeGen/Targets/RISCV.cpp   | 73 ---
 clang/lib/Driver/ToolChains/Arch/RISCV.cpp|  4 +
 clang/lib/Sema/SemaDeclAttr.cpp   | 30 +++-
 clang/lib/Sema/SemaType.cpp   | 17 -
 .../RISCV/riscv-vector-callingconv-llvm-ir.c  | 24 ++
 .../riscv-vector-callingconv-llvm-ir.cpp  | 14 
 .../CodeGen/RISCV/riscv-vector-callingconv.c  | 16 
 .../RISCV/riscv-vector-callingconv.cpp| 17 +
 clang/tools/libclang/CXType.cpp   |  1 +
 llvm/include/llvm/AsmParser/LLToken.h |  1 +
 llvm/include/llvm/BinaryFormat/Dwarf.def  |  1 +
 llvm/include/llvm/IR/CallingConv.h|  3 +
 llvm/lib/AsmParser/LLLexer.cpp|  1 +
 llvm/lib/AsmParser/LLParser.cpp   |  4 +
 llvm/lib/IR/AsmWriter.cpp |  3 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|  9 +++
 llvm/lib/Target/RISCV/RISCVISelLowering.cpp   |  1 +
 llvm/lib/Target/RISCV/RISCVSubtarget.h|  1 +
 33 files changed, 265 insertions(+), 39 deletions(-)

diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 115f5ab090f96..159f21846fc3b 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -3005,6 +3005,7 @@ enum CXCallingConv {
   CXCallingConv_M68kRTD = 19,
   CXCallingConv_PreserveNone = 20,
   CXCallingConv_RISCVVectorCall = 21,
+  CXCallingConv_RISCVVLSCall = 22,
 
   CXCallingConv_Invalid = 100,
   CXCallingConv_Unexposed = 200
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 72723c7c56e07..bb3956b1d2094 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1942,7 +1942,7 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
 LLVM_PREFERRED_TYPE(CallingConv)
-unsigned ExtInfo : 13;
+unsigned ExtInfo : 17;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
@@ -4395,6 +4395,8 @@ class FunctionType : public Type {
 
 // |  CC  
|noreturn|produces|nocallersavedregs|regparm|nocfcheck|cmsenscall|
 // |0 .. 4|   5|6   |   7 |8 .. 10|11   |12
|
+// |RISCV-ABI-VLEN|
+// |13..17|
 //
 // regpa

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-25 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

Given the growing number of OpenMP and/or "offloading" flags, I agree with 
@AnastasiaStulova that it would be good to clarify the overall goal/design. 
That's not clear to me. 

Is there are reference implementation that Flang is meant to follow? For 
example Clang or GFortran? Could we re-use more of Clang logic here? There's 
also a question how various flags impact one another and that seems also 
confusing (see e.g. this 
[question](https://flang-compiler.slack.com/archives/C01PY03PP9P/p1721378390015629)
 by @DominikAdamski ).

Now, this is not really my area of expertise and I tend to stay hands-off. I 
rely on @jhuber6's [expertise in the 
area](https://llvm.org/devmtg/2022-04-03/slides/Improving.the.OpenMP.Offloading.Driver.LTO.libraries.and.toolchains.pdf)
 :) But it does sound like it would be good to discuss the long term goals here.

That's not a blocker for me for this particular change.

https://github.com/llvm/llvm-project/pull/100152
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add _MM_FROUND_TO_NEAREST_TIES_EVEN to avx512fintrin.h (PR #99691)

2024-07-25 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

GCC thread (for reference): 
https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657957.html 

https://github.com/llvm/llvm-project/pull/99691
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][FMV][AArch64] Improve streaming mode compatibility. (PR #100181)

2024-07-25 Thread Sander de Smalen via cfe-commits


@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-Waarch64-sme-attributes -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme 
-Waarch64-sme-attributes -fsyntax-only -verify=expected-cpp -x c++ %s
+
+__attribute__((target_clones("sve", "simd"))) void ok_arm_streaming(void) 
__arm_streaming {}
+__arm_locally_streaming __attribute__((target_version("sme2"))) void 
ok_arm_streaming(void) __arm_streaming {}
+__attribute__((target_version("default"))) void ok_arm_streaming(void) 
__arm_streaming {}
+
+__attribute__((target_clones("sve", "simd"))) void 
ok_arm_streaming_compatible(void) __arm_streaming_compatible {}
+__arm_locally_streaming __attribute__((target_version("sme2"))) void 
ok_arm_streaming_compatible(void) __arm_streaming_compatible {}

sdesmalen-arm wrote:

Yes, the streaming interface can be different from the body of the function. 
`__arm_locally_streaming` is a declaration attribute and applies the 
'streaming' property to the definition (body) of the function, even though the 
interface remains 'streaming compatible'.

https://github.com/llvm/llvm-project/pull/100181
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ASTImporter][NFC] add unittests for unnamed EnumDecl (PR #100545)

2024-07-25 Thread Ding Fei via cfe-commits

https://github.com/danix800 created 
https://github.com/llvm/llvm-project/pull/100545

These tests are for multiple anonymous EnumDecls structural eq test & importing.

We found the anonymous enums importing issue a few days ago and tried to fix it
but 0a6233a68c7b575d05bca0f0c708b7e97cc710d1 already did this. I think these 
tests are still useful for regressions.

>From 2365cb103365994df0669e003a6afdeffb4d34e5 Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Thu, 25 Jul 2024 17:37:56 +0800
Subject: [PATCH] [clang][ASTImporter][NFC] add unittests for unnamed EnumDecl

These tests are for 0a6233a68c7b575d05bca0f0c708b7e97cc710d1
multiple anonymous EnumDecls structural eq test & importing.
---
 clang/unittests/AST/ASTImporterTest.cpp   | 37 +++
 .../AST/StructuralEquivalenceTest.cpp | 14 +++
 2 files changed, 51 insertions(+)

diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 6d987cc7e9ec6..9b12caa37cf79 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -9783,6 +9783,43 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportExistingEmptyAnonymousEnums) {
   EXPECT_EQ(ImportedE2, ToE1);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportMultipleAnonymousEnumDecls) {
+  Decl *ToTU = getToTuDecl("", Lang_CXX03);
+  Decl *FromTU = getTuDecl(
+  R"(
+struct foo {
+  enum { A };
+  enum { B };
+};
+  )",
+  Lang_CXX03);
+
+  auto EnumConstA = enumConstantDecl(hasName("A"));
+  auto EnumConstB = enumConstantDecl(hasName("B"));
+
+  auto *FromA = FirstDeclMatcher().match(FromTU, EnumConstA);
+  auto *FromB = FirstDeclMatcher().match(FromTU, EnumConstB);
+
+  auto *ToA = Import(FromA, Lang_CXX03);
+  auto *ToB = Import(FromB, Lang_CXX03);
+
+  ASSERT_TRUE(ToA);
+  ASSERT_TRUE(ToB);
+
+  auto *ToFooA = FirstDeclMatcher().match(
+  ToTU, tagDecl(has(enumDecl(has(EnumConstA);
+  auto *ToFooB = FirstDeclMatcher().match(
+  ToTU, tagDecl(has(enumDecl(has(EnumConstB);
+  ASSERT_EQ(ToFooA, ToFooB);
+
+  // different EnumDecl
+  auto *ToEnumDeclA =
+  FirstDeclMatcher().match(ToTU, enumDecl(has(EnumConstA)));
+  auto *ToEnumDeclB =
+  FirstDeclMatcher().match(ToTU, enumDecl(has(EnumConstB)));
+  ASSERT_NE(ToEnumDeclA, ToEnumDeclB);
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 
diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 952c83be0cb64..e994086c99d04 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1109,6 +1109,20 @@ TEST_F(StructuralEquivalenceEnumTest, 
EnumsWithDifferentBody) {
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceEnumTest, AnonymousEnumsWithSameConsts) {
+  // field x is required to trigger comparison of the anonymous enum
+  auto t = makeNamedDecls("struct foo { enum { A } x; };",
+  "struct foo { enum { A } x;};", Lang_CXX11);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceEnumTest, AnonymousEnumsWithDiffConsts) {
+  // field x is required to trigger comparison of the anonymous enum
+  auto t = makeNamedDecls("struct foo { enum { A } x; };",
+  "struct foo { enum { B } x;};", Lang_CXX11);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 struct StructuralEquivalenceEnumConstantTest : StructuralEquivalenceTest {};
 
 TEST_F(StructuralEquivalenceEnumConstantTest, EnumConstantsWithSameValues) {

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


[clang] [clang][ASTImporter][NFC] add unittests for unnamed EnumDecl (PR #100545)

2024-07-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Ding Fei (danix800)


Changes

These tests are for multiple anonymous EnumDecls structural eq test & 
importing.

We found the anonymous enums importing issue a few days ago and tried to fix it
but 0a6233a68c7b575d05bca0f0c708b7e97cc710d1 already did this. I think these 
tests are still useful for regressions.

---
Full diff: https://github.com/llvm/llvm-project/pull/100545.diff


2 Files Affected:

- (modified) clang/unittests/AST/ASTImporterTest.cpp (+37) 
- (modified) clang/unittests/AST/StructuralEquivalenceTest.cpp (+14) 


``diff
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 6d987cc7e9ec6..9b12caa37cf79 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -9783,6 +9783,43 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportExistingEmptyAnonymousEnums) {
   EXPECT_EQ(ImportedE2, ToE1);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportMultipleAnonymousEnumDecls) {
+  Decl *ToTU = getToTuDecl("", Lang_CXX03);
+  Decl *FromTU = getTuDecl(
+  R"(
+struct foo {
+  enum { A };
+  enum { B };
+};
+  )",
+  Lang_CXX03);
+
+  auto EnumConstA = enumConstantDecl(hasName("A"));
+  auto EnumConstB = enumConstantDecl(hasName("B"));
+
+  auto *FromA = FirstDeclMatcher().match(FromTU, EnumConstA);
+  auto *FromB = FirstDeclMatcher().match(FromTU, EnumConstB);
+
+  auto *ToA = Import(FromA, Lang_CXX03);
+  auto *ToB = Import(FromB, Lang_CXX03);
+
+  ASSERT_TRUE(ToA);
+  ASSERT_TRUE(ToB);
+
+  auto *ToFooA = FirstDeclMatcher().match(
+  ToTU, tagDecl(has(enumDecl(has(EnumConstA);
+  auto *ToFooB = FirstDeclMatcher().match(
+  ToTU, tagDecl(has(enumDecl(has(EnumConstB);
+  ASSERT_EQ(ToFooA, ToFooB);
+
+  // different EnumDecl
+  auto *ToEnumDeclA =
+  FirstDeclMatcher().match(ToTU, enumDecl(has(EnumConstA)));
+  auto *ToEnumDeclB =
+  FirstDeclMatcher().match(ToTU, enumDecl(has(EnumConstB)));
+  ASSERT_NE(ToEnumDeclA, ToEnumDeclB);
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 
diff --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 952c83be0cb64..e994086c99d04 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1109,6 +1109,20 @@ TEST_F(StructuralEquivalenceEnumTest, 
EnumsWithDifferentBody) {
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceEnumTest, AnonymousEnumsWithSameConsts) {
+  // field x is required to trigger comparison of the anonymous enum
+  auto t = makeNamedDecls("struct foo { enum { A } x; };",
+  "struct foo { enum { A } x;};", Lang_CXX11);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceEnumTest, AnonymousEnumsWithDiffConsts) {
+  // field x is required to trigger comparison of the anonymous enum
+  auto t = makeNamedDecls("struct foo { enum { A } x; };",
+  "struct foo { enum { B } x;};", Lang_CXX11);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
 struct StructuralEquivalenceEnumConstantTest : StructuralEquivalenceTest {};
 
 TEST_F(StructuralEquivalenceEnumConstantTest, EnumConstantsWithSameValues) {

``




https://github.com/llvm/llvm-project/pull/100545
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-25 Thread Anastasia Stulova via cfe-commits

AnastasiaStulova wrote:

Adding ``--offload-target=`` seems like a good idea since it 
will be consistent with ``--target=``.

One related question I have - does Flang compile for one offload model or can 
it mix those (let's say compile sources with mixed OpenACC and OpenMP pragmas)? 
If mixing is allowed then it may also make sense to add a way of setting the 
target per programming model. But generic flag ``--offload-target`` could then 
set the target for all the models that are not set explicitly otherwise.

Btw does the offload target triple have identical format to the main triple? 

https://github.com/llvm/llvm-project/pull/100152
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited 
https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread Matt Arsenault via cfe-commits


@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const 
FunctionDecl *FD,
   RValue Call =
   CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
 auto IsErrnoIntrinsic = [&]() -> unsigned {
-  switch (BuiltinID) {
-  case Builtin::BIexpf:
-  case Builtin::BI__builtin_expf:
-  case Builtin::BI__builtin_expf128:
+  // Check whether a FP math builtin function, such as BI__builtin_expf
+  QualType ResultTy = FD->getReturnType();
+  bool IsMathLibCall =
+  Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+  Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+  if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())

arsenm wrote:

So check isConstWithoutErrnoAndExceptions? 

https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Initializer list on RHS of assignment (PR #100548)

2024-07-25 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok created 
https://github.com/llvm/llvm-project/pull/100548

This implements [CWG2768](https://cplusplus.github.io/CWG/issues/2768.html).

Also fixes a bug where `x op= {v}` was treated as `x op= v` for compound 
assignments, which shouldn't have happened.

Fixes #100527

>From 3de1983173a0281811d9d53cd4f553438fe2b054 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Thu, 25 Jul 2024 10:56:16 +0100
Subject: [PATCH] [Clang] Initializer list on RHS of assignment

---
 clang/docs/ReleaseNotes.rst |  4 ++
 clang/lib/Sema/SemaExpr.cpp | 65 +++--
 clang/test/CXX/drs/cwg27xx.cpp  | 26 +++---
 clang/test/SemaCXX/assign-init-list.cpp | 20 
 clang/www/cxx_dr_status.html|  2 +-
 5 files changed, 95 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/SemaCXX/assign-init-list.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0b79e952b48af..bc048e8bfacba 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,6 +84,9 @@ C++2c Feature Support
 Resolutions to C++ Defect Reports
 ^
 
+- Reject assigning to enums with an initailizer list containing an integer.
+  (`CWG2768: Assignment to enumeration variable with a braced-init-list 
`_).
+
 C Language Changes
 --
 
@@ -150,6 +153,7 @@ Bug Fixes to C++ Support
 
 
 - Fixed a crash when an expression with a dependent ``__typeof__`` type is 
used as the operand of a unary operator. (#GH97646)
+- Reject compound assignment operators with a braced-init-list.
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 74c0e01705905..7b9301cf9c560 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14578,21 +14578,56 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation 
OpLoc,
 BinaryOperatorKind Opc,
 Expr *LHSExpr, Expr *RHSExpr) {
   if (getLangOpts().CPlusPlus11 && isa(RHSExpr)) {
-// The syntax only allows initializer lists on the RHS of assignment,
-// so we don't need to worry about accepting invalid code for
-// non-assignment operators.
-// C++11 5.17p9:
-//   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
-//   of x = {} is x = T().
-InitializationKind Kind = InitializationKind::CreateDirectList(
-RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
-InitializedEntity Entity =
-InitializedEntity::InitializeTemporary(LHSExpr->getType());
-InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
-ExprResult Init = InitSeq.Perform(*this, Entity, Kind, RHSExpr);
-if (Init.isInvalid())
-  return Init;
-RHSExpr = Init.get();
+// C++11 [expr.ass]p9, per CWG2768:
+//   A braced-init-list B may appear on the right-hand side of
+//- an assignment to a scalar of type T, in which case the initializer
+//list shall have at most a single element. The meaning of x=B is x = 
t,
+//where t is an invented temporary variable declared and initialized as
+//T t = B
+switch (Opc) {
+case BO_Assign: {
+  QualType LHSTy = LHSExpr->getType();
+  assert(!LHSTy->isDependentType() &&
+ "Should not have tried to create a builtin binary operator");
+  if (LHSTy->isScalarType()) {
+InitializationKind Kind =
+InitializationKind::CreateCopy(RHSExpr->getBeginLoc(), OpLoc);
+InitializedEntity Entity =
+InitializedEntity::InitializeTemporary(LHSExpr->getType());
+InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
+ExprResult InventedTemporary =
+InitSeq.Perform(*this, Entity, Kind, RHSExpr);
+if (InventedTemporary.isInvalid())
+  return InventedTemporary;
+assert(cast(RHSExpr)->getNumInits() <= 1 &&
+   "The initialization should have failed");
+RHSExpr = InventedTemporary.get();
+  }
+  break;
+}
+case BO_MulAssign:
+case BO_DivAssign:
+case BO_RemAssign:
+case BO_AddAssign:
+case BO_SubAssign:
+case BO_ShlAssign:
+case BO_ShrAssign:
+case BO_AndAssign:
+case BO_XorAssign:
+case BO_OrAssign: {
+  // A compound assignment like `i += {0}` is equivalent to `i = i + {0}`,
+  // which is a parsing error
+  StringRef Op = BinaryOperator::getOpcodeStr(Opc);
+  [[maybe_unused]] bool AssignmentStripped = Op.consume_back("=");
+  assert(AssignmentStripped);
+  Diag(OpLoc, diag::err_init_list_bin_op)
+  << 1 << Op << getExprRange(RHSExpr);
+  return ExprError();
+}
+default:
+  llvm_unreachable("Non-assignment binary operator with braced-init-list "
+   

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Nikolas Klauser via cfe-commits


@@ -1599,13 +1599,66 @@ createTypePackElementParameterList(const ASTContext &C, 
DeclContext *DC) {
nullptr);
 }
 
+static TemplateParameterList *createCommonTypeList(const ASTContext &C,
+   DeclContext *DC) {
+  // class... Args
+  auto *Args = TemplateTypeParmDecl::Create(
+  C, DC, {}, {}, /*Depth=*/1, /*Position=*/0, /*Id=*/nullptr,
+  /*Typename=*/false, /*ParameterPack=*/true);
+  Args->setImplicit();

philnik777 wrote:

Turns out this actually hides the arguments from the diagnostic message, so I 
think none of them should be implicit.

https://github.com/llvm/llvm-project/pull/99473
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Initializer list on RHS of assignment (PR #100548)

2024-07-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mital Ashok (MitalAshok)


Changes

This implements [CWG2768](https://cplusplus.github.io/CWG/issues/2768.html).

Also fixes a bug where `x op= {v}` was treated as `x op= v` for compound 
assignments, which shouldn't have happened.

Fixes #100527

---
Full diff: https://github.com/llvm/llvm-project/pull/100548.diff


5 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+50-15) 
- (modified) clang/test/CXX/drs/cwg27xx.cpp (+20-6) 
- (added) clang/test/SemaCXX/assign-init-list.cpp (+20) 
- (modified) clang/www/cxx_dr_status.html (+1-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0b79e952b48af..bc048e8bfacba 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,6 +84,9 @@ C++2c Feature Support
 Resolutions to C++ Defect Reports
 ^
 
+- Reject assigning to enums with an initailizer list containing an integer.
+  (`CWG2768: Assignment to enumeration variable with a braced-init-list 
`_).
+
 C Language Changes
 --
 
@@ -150,6 +153,7 @@ Bug Fixes to C++ Support
 
 
 - Fixed a crash when an expression with a dependent ``__typeof__`` type is 
used as the operand of a unary operator. (#GH97646)
+- Reject compound assignment operators with a braced-init-list.
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 74c0e01705905..7b9301cf9c560 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14578,21 +14578,56 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation 
OpLoc,
 BinaryOperatorKind Opc,
 Expr *LHSExpr, Expr *RHSExpr) {
   if (getLangOpts().CPlusPlus11 && isa(RHSExpr)) {
-// The syntax only allows initializer lists on the RHS of assignment,
-// so we don't need to worry about accepting invalid code for
-// non-assignment operators.
-// C++11 5.17p9:
-//   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
-//   of x = {} is x = T().
-InitializationKind Kind = InitializationKind::CreateDirectList(
-RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
-InitializedEntity Entity =
-InitializedEntity::InitializeTemporary(LHSExpr->getType());
-InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
-ExprResult Init = InitSeq.Perform(*this, Entity, Kind, RHSExpr);
-if (Init.isInvalid())
-  return Init;
-RHSExpr = Init.get();
+// C++11 [expr.ass]p9, per CWG2768:
+//   A braced-init-list B may appear on the right-hand side of
+//- an assignment to a scalar of type T, in which case the initializer
+//list shall have at most a single element. The meaning of x=B is x = 
t,
+//where t is an invented temporary variable declared and initialized as
+//T t = B
+switch (Opc) {
+case BO_Assign: {
+  QualType LHSTy = LHSExpr->getType();
+  assert(!LHSTy->isDependentType() &&
+ "Should not have tried to create a builtin binary operator");
+  if (LHSTy->isScalarType()) {
+InitializationKind Kind =
+InitializationKind::CreateCopy(RHSExpr->getBeginLoc(), OpLoc);
+InitializedEntity Entity =
+InitializedEntity::InitializeTemporary(LHSExpr->getType());
+InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
+ExprResult InventedTemporary =
+InitSeq.Perform(*this, Entity, Kind, RHSExpr);
+if (InventedTemporary.isInvalid())
+  return InventedTemporary;
+assert(cast(RHSExpr)->getNumInits() <= 1 &&
+   "The initialization should have failed");
+RHSExpr = InventedTemporary.get();
+  }
+  break;
+}
+case BO_MulAssign:
+case BO_DivAssign:
+case BO_RemAssign:
+case BO_AddAssign:
+case BO_SubAssign:
+case BO_ShlAssign:
+case BO_ShrAssign:
+case BO_AndAssign:
+case BO_XorAssign:
+case BO_OrAssign: {
+  // A compound assignment like `i += {0}` is equivalent to `i = i + {0}`,
+  // which is a parsing error
+  StringRef Op = BinaryOperator::getOpcodeStr(Opc);
+  [[maybe_unused]] bool AssignmentStripped = Op.consume_back("=");
+  assert(AssignmentStripped);
+  Diag(OpLoc, diag::err_init_list_bin_op)
+  << 1 << Op << getExprRange(RHSExpr);
+  return ExprError();
+}
+default:
+  llvm_unreachable("Non-assignment binary operator with braced-init-list "
+   "should not be parsed");
+}
   }
 
   ExprResult LHS = LHSExpr, RHS = RHSExpr;
diff --git a/clang/test/CXX/drs/cwg27xx.cpp b/clang/test/CXX/drs/cwg27xx.cpp
index 406c8ea41f3b2..abf669c2c9691 100644
--- a/c

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/99473

>From d6903daf0da6979822b8981ea3641455ff6d06f8 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Tue, 16 Jul 2024 14:48:10 +0200
Subject: [PATCH 1/2] [Clang] Add __common_type builtin

---
 clang/include/clang/AST/ASTContext.h  |  11 ++
 clang/include/clang/AST/DeclID.h  |   5 +-
 clang/include/clang/Basic/Builtins.h  |   5 +-
 clang/include/clang/Sema/Sema.h   |   4 +
 clang/lib/AST/ASTContext.cpp  |   7 +
 clang/lib/AST/ASTImporter.cpp |   3 +
 clang/lib/AST/DeclTemplate.cpp|  53 ++
 clang/lib/Lex/PPMacroExpansion.cpp|   1 +
 clang/lib/Sema/SemaChecking.cpp   |   8 +
 clang/lib/Sema/SemaLookup.cpp |   4 +
 clang/lib/Sema/SemaTemplate.cpp   | 160 +-
 clang/lib/Serialization/ASTReader.cpp |   3 +
 clang/lib/Serialization/ASTWriter.cpp |   2 +
 clang/test/SemaCXX/type-trait-common-type.cpp | 126 ++
 libcxx/include/__type_traits/common_type.h|  16 +-
 libcxx/include/module.modulemap   |   2 +
 16 files changed, 404 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/SemaCXX/type-trait-common-type.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 608bd90fcc3ff..d02e742297898 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -399,6 +399,9 @@ class ASTContext : public RefCountedBase {
   /// The identifier '__type_pack_element'.
   mutable IdentifierInfo *TypePackElementName = nullptr;
 
+  /// The identifier '__common_type'.
+  mutable IdentifierInfo *CommonTypeName = nullptr;
+
   QualType ObjCConstantStringType;
   mutable RecordDecl *CFConstantStringTagDecl = nullptr;
   mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
@@ -606,6 +609,7 @@ class ASTContext : public RefCountedBase {
   mutable ExternCContextDecl *ExternCContext = nullptr;
   mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
   mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
+  mutable BuiltinTemplateDecl *CommonTypeDecl = nullptr;
 
   /// The associated SourceManager object.
   SourceManager &SourceMgr;
@@ -1107,6 +,7 @@ class ASTContext : public RefCountedBase {
   ExternCContextDecl *getExternCContextDecl() const;
   BuiltinTemplateDecl *getMakeIntegerSeqDecl() const;
   BuiltinTemplateDecl *getTypePackElementDecl() const;
+  BuiltinTemplateDecl *getCommonTypeDecl() const;
 
   // Builtin Types.
   CanQualType VoidTy;
@@ -1984,6 +1989,12 @@ class ASTContext : public RefCountedBase {
 return TypePackElementName;
   }
 
+  IdentifierInfo *getCommonTypeName() const {
+if (!CommonTypeName)
+  CommonTypeName = &Idents.get("__common_type");
+return CommonTypeName;
+  }
+
   /// Retrieve the Objective-C "instancetype" type, if already known;
   /// otherwise, returns a NULL type;
   QualType getObjCInstanceType() {
diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
index e5e27389fac60..875e9a72b3951 100644
--- a/clang/include/clang/AST/DeclID.h
+++ b/clang/include/clang/AST/DeclID.h
@@ -84,13 +84,16 @@ enum PredefinedDeclIDs {
 
   /// The internal '__type_pack_element' template.
   PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
+
+  /// The internal '__common_type' template.
+  PREDEF_DECL_COMMON_TYPE_ID = 18,
 };
 
 /// The number of declaration IDs that are predefined.
 ///
 /// For more information about predefined declarations, see the
 /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
-const unsigned int NUM_PREDEF_DECL_IDS = 18;
+const unsigned int NUM_PREDEF_DECL_IDS = 19;
 
 /// GlobalDeclID means DeclID in the current ASTContext and LocalDeclID means
 /// DeclID specific to a certain ModuleFile. Specially, in ASTWriter, the
diff --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index e85ec5b2dca14..4353b72f71383 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int {
   BTK__make_integer_seq,
 
   /// This names the __type_pack_element BuiltinTemplateDecl.
-  BTK__type_pack_element
+  BTK__type_pack_element,
+
+  /// This names the __common_type BuiltinTemplateDecl.
+  BTK__common_type,
 };
 
 } // end namespace clang
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3cb1aa935fe46..5c7945c4c5c58 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2282,6 +2282,10 @@ class Sema final : public SemaBase {
   /// Check to see if a given expression could have '.c_str()' called on it.
   bool hasCStrMethod(const Expr *E);
 
+  // Check whether a type member 'Type::Name' exists, and if yes, return the
+  // type. If there is no type, the QualType is null
+  QualType getTy

[clang] [Clang] Initializer list on RHS of assignment (PR #100548)

2024-07-25 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/100548

>From 2c1d87c025a8caa818dd275560f31d0d4f8d64b8 Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Thu, 25 Jul 2024 10:56:16 +0100
Subject: [PATCH] [Clang] Initializer list on RHS of assignment

---
 clang/docs/ReleaseNotes.rst |  4 ++
 clang/lib/Sema/SemaExpr.cpp | 65 +++--
 clang/test/CXX/drs/cwg27xx.cpp  | 26 +++---
 clang/test/SemaCXX/assign-init-list.cpp | 20 
 clang/www/cxx_dr_status.html|  2 +-
 5 files changed, 95 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/SemaCXX/assign-init-list.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0b79e952b48af..bc048e8bfacba 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,6 +84,9 @@ C++2c Feature Support
 Resolutions to C++ Defect Reports
 ^
 
+- Reject assigning to enums with an initailizer list containing an integer.
+  (`CWG2768: Assignment to enumeration variable with a braced-init-list 
`_).
+
 C Language Changes
 --
 
@@ -150,6 +153,7 @@ Bug Fixes to C++ Support
 
 
 - Fixed a crash when an expression with a dependent ``__typeof__`` type is 
used as the operand of a unary operator. (#GH97646)
+- Reject compound assignment operators with a braced-init-list.
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 74c0e01705905..08ee28c108952 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14578,21 +14578,56 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation 
OpLoc,
 BinaryOperatorKind Opc,
 Expr *LHSExpr, Expr *RHSExpr) {
   if (getLangOpts().CPlusPlus11 && isa(RHSExpr)) {
-// The syntax only allows initializer lists on the RHS of assignment,
-// so we don't need to worry about accepting invalid code for
-// non-assignment operators.
-// C++11 5.17p9:
-//   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
-//   of x = {} is x = T().
-InitializationKind Kind = InitializationKind::CreateDirectList(
-RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
-InitializedEntity Entity =
-InitializedEntity::InitializeTemporary(LHSExpr->getType());
-InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
-ExprResult Init = InitSeq.Perform(*this, Entity, Kind, RHSExpr);
-if (Init.isInvalid())
-  return Init;
-RHSExpr = Init.get();
+// C++11 [expr.ass]p9, per CWG2768:
+//   A braced-init-list B may appear on the right-hand side of
+//- an assignment to a scalar of type T, in which case the initializer
+//  list shall have at most a single element. The meaning of x = B is
+//  x = t, where t is an invented temporary variable declared and
+//  initialized as T t = B.
+switch (Opc) {
+case BO_Assign: {
+  QualType LHSTy = LHSExpr->getType();
+  assert(!LHSTy->isDependentType() &&
+ "Should not have tried to create a builtin binary operator");
+  if (LHSTy->isScalarType()) {
+InitializationKind Kind =
+InitializationKind::CreateCopy(RHSExpr->getBeginLoc(), OpLoc);
+InitializedEntity Entity =
+InitializedEntity::InitializeTemporary(LHSExpr->getType());
+InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
+ExprResult InventedTemporary =
+InitSeq.Perform(*this, Entity, Kind, RHSExpr);
+if (InventedTemporary.isInvalid())
+  return InventedTemporary;
+assert(cast(RHSExpr)->getNumInits() <= 1 &&
+   "The initialization should have failed");
+RHSExpr = InventedTemporary.get();
+  }
+  break;
+}
+case BO_MulAssign:
+case BO_DivAssign:
+case BO_RemAssign:
+case BO_AddAssign:
+case BO_SubAssign:
+case BO_ShlAssign:
+case BO_ShrAssign:
+case BO_AndAssign:
+case BO_XorAssign:
+case BO_OrAssign: {
+  // A compound assignment like `i += {0}` is equivalent to `i = i + {0}`,
+  // which is a parsing error
+  StringRef Op = BinaryOperator::getOpcodeStr(Opc);
+  [[maybe_unused]] bool AssignmentStripped = Op.consume_back("=");
+  assert(AssignmentStripped);
+  Diag(OpLoc, diag::err_init_list_bin_op)
+  << 1 << Op << getExprRange(RHSExpr);
+  return ExprError();
+}
+default:
+  llvm_unreachable("Non-assignment binary operator with braced-init-list "
+   "should not be parsed");
+}
   }
 
   ExprResult LHS = LHSExpr, RHS = RHSExpr;
diff --git a/clang/test/CXX/drs/cwg27xx.cpp b/clang/test/CXX/drs/cwg27xx.cpp
index 406c8ea41f3b2..abf669c

[clang] [Clang] prevent checking destructor reference with an invalid initializer (PR #97860)

2024-07-25 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

@cor3ntin If no further feedback is needed, could you please proceed with the 
merge? Thanks 

https://github.com/llvm/llvm-project/pull/97860
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Balazs Benics via cfe-commits


@@ -923,12 +923,31 @@ SVal AnyCXXConstructorCall::getCXXThisVal() const {
   return UnknownVal();
 }
 
+static bool isWithinStdNamespace(const Decl *D) {

steakhal wrote:

Makes sense. I think I'd prefer moving this utility in a followup patch, as it 
may take a while to reach consensus where to put it. And I don't want to block 
this PR until that happens.

https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Balazs Benics via cfe-commits

https://github.com/steakhal edited 
https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/100400

>From 6ede7586fc4602ab15be59c58fe5f7181ffaca16 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Wed, 24 Jul 2024 23:12:27 +0800
Subject: [PATCH 1/2] [Clang][Interp] Fix handling of DecompositionDecl

Signed-off-by: yronglin 
---
 clang/lib/AST/Interp/Compiler.cpp  | 13 +++--
 clang/test/SemaCXX/cxx1z-decomposition.cpp |  1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 0fc93c14131e6..6e2f0dbc39dcf 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3593,8 +3593,14 @@ VarCreationState Compiler::visitDecl(const 
VarDecl *VD) {
   if (R.notCreated())
 return R;
 
-  if (R)
-return true;
+  if (R) {
+bool Ok = true;
+if (const auto *DD = dyn_cast(VD))
+  for (const auto *BD : DD->bindings())
+if (const auto *HoldingVar = BD->getHoldingVar())
+  Ok &= this->visitDecl(HoldingVar);
+return Ok;
+  }
 
   if (!R && Context::shouldBeGloballyIndexed(VD)) {
 if (auto GlobalIndex = P.getGlobal(VD)) {
@@ -5234,6 +5240,9 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
   return false;
 };
 
+if (isa(VD))
+  return revisit(VD);
+
 // Visit local const variables like normal.
 if ((VD->hasGlobalStorage() || VD->isLocalVarDecl() ||
  VD->isStaticDataMember()) &&
diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index 305a9ac2ebc24..19c730303625e 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++17 -Wc++20-extensions -verify=expected %s
 // RUN: %clang_cc1 -std=c++20 -Wpre-c++20-compat -verify=expected %s
+// RUN: %clang_cc1 -std=c++20 -Wpre-c++20-compat 
-fexperimental-new-constant-interpreter -verify=expected %s
 
 void use_from_own_init() {
   auto [a] = a; // expected-error {{binding 'a' cannot appear in the 
initializer of its own decomposition declaration}}

>From 4a4e2c28d48aa944c28db8865cfa0c76f9ce7e9a Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Thu, 25 Jul 2024 18:57:05 +0800
Subject: [PATCH 2/2] Address review comments

Signed-off-by: yronglin 
---
 clang/lib/AST/Interp/Compiler.cpp | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index 6e2f0dbc39dcf..1de4f3255007e 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -3593,14 +3593,8 @@ VarCreationState Compiler::visitDecl(const 
VarDecl *VD) {
   if (R.notCreated())
 return R;
 
-  if (R) {
-bool Ok = true;
-if (const auto *DD = dyn_cast(VD))
-  for (const auto *BD : DD->bindings())
-if (const auto *HoldingVar = BD->getHoldingVar())
-  Ok &= this->visitDecl(HoldingVar);
-return Ok;
-  }
+  if (R)
+return true;
 
   if (!R && Context::shouldBeGloballyIndexed(VD)) {
 if (auto GlobalIndex = P.getGlobal(VD)) {
@@ -5240,6 +5234,7 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
   return false;
 };
 
+// DecompositionDecls are just proxies for us.
 if (isa(VD))
   return revisit(VD);
 

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


[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread via cfe-commits


@@ -3593,8 +3593,14 @@ VarCreationState Compiler::visitDecl(const 
VarDecl *VD) {
   if (R.notCreated())
 return R;
 
-  if (R)
-return true;
+  if (R) {

yronglin wrote:

Removed.

https://github.com/llvm/llvm-project/pull/100400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ca69444 - [Clang] Fix a variable shadowing in MapLattice (NFC) (#95697)

2024-07-25 Thread via cfe-commits

Author: Shivam Gupta
Date: 2024-07-25T16:33:05+05:30
New Revision: ca69444cef0858ad4facecbfc2232a02422aca9f

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

LOG: [Clang] Fix a variable shadowing in MapLattice (NFC) (#95697)

Reported in https://pvs-studio.com/en/blog/posts/cpp/1126/, fragment
N10.

The PVS-Studio warning:
V570 The 'C' variable is assigned to itself. MapLattice.h:52

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/MapLattice.h

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h 
b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
index 16b0c978779a7..b2d147e4ae444 100644
--- a/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
+++ b/clang/include/clang/Analysis/FlowSensitive/MapLattice.h
@@ -49,7 +49,7 @@ template  class 
MapLattice {
 
   MapLattice() = default;
 
-  explicit MapLattice(Container C) { C = std::move(C); }
+  explicit MapLattice(Container C) : C{std::move(C)} {};
 
   // The `bottom` element is the empty map.
   static MapLattice bottom() { return MapLattice(); }



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


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-07-25 Thread Shivam Gupta via cfe-commits

https://github.com/xgupta closed https://github.com/llvm/llvm-project/pull/95697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-07-25 Thread Shivam Gupta via cfe-commits

xgupta wrote:

Thanks for the review @martinboehme!

https://github.com/llvm/llvm-project/pull/95697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add a test for #100095 (PR #100556)

2024-07-25 Thread Alexander Kornienko via cfe-commits

https://github.com/alexfh created 
https://github.com/llvm/llvm-project/pull/100556

The test is set to XFAIL with assertions enabled.


>From 09cf032759b43e8a30720be9ef2f9caf13bcb0cb Mon Sep 17 00:00:00 2001
From: Alexander Kornienko 
Date: Thu, 25 Jul 2024 13:02:38 +0200
Subject: [PATCH] Add a test for #100095

The test is set to XFAIL with assertions enabled.
---
 clang/test/SemaCXX/pr100095.cpp | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 clang/test/SemaCXX/pr100095.cpp

diff --git a/clang/test/SemaCXX/pr100095.cpp b/clang/test/SemaCXX/pr100095.cpp
new file mode 100644
index 0..15913fec9d5ae
--- /dev/null
+++ b/clang/test/SemaCXX/pr100095.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+// XFAIL: asserts
+
+template  struct Pair;
+template  struct Tuple {
+  template  Tuple(_Up);
+};
+template  struct StatusOr;
+template  using ElementType = int;
+template 
+using Key = Tuple...>;
+template 
+StatusOr>> Parser();
+struct Helper { Helper(Tuple<>, Tuple<>, int, int); };
+struct D : Helper {
+  D(Key<> f, int n, int e) : Helper(f, Parser<>, n, e) {}
+};

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


[clang] Add a test for #100095 (PR #100556)

2024-07-25 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexander Kornienko (alexfh)


Changes

The test is set to XFAIL with assertions enabled.


---
Full diff: https://github.com/llvm/llvm-project/pull/100556.diff


1 Files Affected:

- (added) clang/test/SemaCXX/pr100095.cpp (+17) 


``diff
diff --git a/clang/test/SemaCXX/pr100095.cpp b/clang/test/SemaCXX/pr100095.cpp
new file mode 100644
index 0..15913fec9d5ae
--- /dev/null
+++ b/clang/test/SemaCXX/pr100095.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
+// XFAIL: asserts
+
+template  struct Pair;
+template  struct Tuple {
+  template  Tuple(_Up);
+};
+template  struct StatusOr;
+template  using ElementType = int;
+template 
+using Key = Tuple...>;
+template 
+StatusOr>> Parser();
+struct Helper { Helper(Tuple<>, Tuple<>, int, int); };
+struct D : Helper {
+  D(Key<> f, int n, int e) : Helper(f, Parser<>, n, e) {}
+};

``




https://github.com/llvm/llvm-project/pull/100556
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Avoid accessing unset optional, workaround for #100095 (PR #100408)

2024-07-25 Thread Alexander Kornienko via cfe-commits

alexfh wrote:

> ... I'd like to see at least a test added to this PR.

See #100556. The test would fail with assertions enabled (thus, marked XFAIL: 
asserts), and when compiled against hardened libc++ (e.g. libc++ built with 
`-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST`).

https://github.com/llvm/llvm-project/pull/100408
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread via cfe-commits


@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const 
FunctionDecl *FD,
   RValue Call =
   CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
 auto IsErrnoIntrinsic = [&]() -> unsigned {
-  switch (BuiltinID) {
-  case Builtin::BIexpf:
-  case Builtin::BI__builtin_expf:
-  case Builtin::BI__builtin_expf128:
+  // Check whether a FP math builtin function, such as BI__builtin_expf
+  QualType ResultTy = FD->getReturnType();
+  bool IsMathLibCall =
+  Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+  Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+  if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())

vfdff wrote:

No , we expect it works without explicit disable the MathErrno, just similar to 
the behavior of gcc, https://gcc.godbolt.org/z/rsbqsGWMv. it is discussed on 
[discourse](https://discourse.llvm.org/t/fp-can-we-add-pure-attribute-for-math-library-functions-default/79459/6?u=allen)

https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix a variable shadowing in MapLattice (NFC) (PR #95697)

2024-07-25 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-5` while building `clang` at step 6 
"test-build-unified-tree-check-all".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/190/builds/2624

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang Tools :: clang-doc/basic-project.test' FAILED 

Exit Code: 1

Command Output (stdout):
--
Emiting docs in html format.
Mapping decls...
Collecting infos...
Reducing 5 infos...
Generating docs...
Generating assets for docs...

--
Command Output (stderr):
--
RUN: at line 1: rm -rf 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
 && mkdir -p 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
+ rm -rf 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp
+ mkdir -p 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build
RUN: at line 2: sed 
's|$test_dir|/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc|g'
 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
 > 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ sed 
's|$test_dir|/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc|g'
 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/Inputs/basic-project/database_template.json
RUN: at line 3: clang-doc --format=html 
--output=/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 --executor=all-TUs 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
+ clang-doc --format=html 
--output=/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs
 --executor=all-TUs 
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/build/compile_commands.json
[1/3] Processing file 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Rectangle.cpp
[2/3] Processing file 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Calculator.cpp
[3/3] Processing file 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Circle.cpp
RUN: at line 4: FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/index_json.js
 -check-prefix=JSON-INDEX
+ FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/index_json.js
 -check-prefix=JSON-INDEX
RUN: at line 5: FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html
 -check-prefix=HTML-SHAPE
+ FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/basic-project.test
 
-input-file=/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape.html
 -check-prefix=HTML-SHAPE
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang-tools-extra/test/clang-doc/basic-project.test:64:16:
 error: HTML-SHAPE: expected string not found in input
// HTML-SHAPE: area
   ^
/Users/buildbot/buildbot-root/aarch64-darwin/build/tools/clang/tools/extra/test/clang-doc/Output/basic-project.test.tmp/docs/GlobalNamespace/Shape

[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread A. Jiang via cfe-commits


@@ -1511,6 +1511,43 @@ Attributes (N2335)   
 C2
 ``#embed`` (N3017)
C23   C89, C++
   
= =
 
+Builtin type aliases
+
+
+Clang provides a few builtin aliases to improve the throughput of certain 
metaprogramming facilities.
+
+__common_type
+-
+
+.. code-block:: c++
+  template  class BaseTemplate,
+template  class HasTypeMember,
+class HasNoTypeMember,
+class... Ts>
+  using __common_type = ...;
+
+This alias is used for implementing ``std::common_type``. If 
``std::common_type`` should contain a ``type`` member,
+it is an alias to ``HasTypeMember``. Otherwise it is an alias 
to ``HasNoTypeMember``. The
+``BaseTemplate`` is usually ``std::common_type``. ``Ts`` are the arguments to 
``std::common_type``.
+
+__type_pack_element
+---
+
+.. code-block:: c++
+  template 
+  using __type_pack_element = ...;
+
+This alias returns the type at ``Index`` in the parameter pack ``Ts``.
+
+__make_integer_seq
+--
+
+.. code-block:: c++
+  template  class IntSeq, class T, 
class N>

frederick-vs-ja wrote:

```suggestion
  template  class IntSeq, class T, T 
N>
```
Typo?

https://github.com/llvm/llvm-project/pull/99473
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread via cfe-commits


@@ -692,23 +692,22 @@ static RValue emitLibraryCall(CodeGenFunction &CGF, const 
FunctionDecl *FD,
   RValue Call =
   CGF.EmitCall(E->getCallee()->getType(), callee, E, ReturnValueSlot());
 
-  // Check the supported intrinsic.
+  ASTContext &Context = CGF.getContext();
   if (unsigned BuiltinID = FD->getBuiltinID()) {
 auto IsErrnoIntrinsic = [&]() -> unsigned {
-  switch (BuiltinID) {
-  case Builtin::BIexpf:
-  case Builtin::BI__builtin_expf:
-  case Builtin::BI__builtin_expf128:
+  // Check whether a FP math builtin function, such as BI__builtin_expf
+  QualType ResultTy = FD->getReturnType();
+  bool IsMathLibCall =
+  Context.BuiltinInfo.isLibFunction(BuiltinID) ||
+  Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID);
+  if (IsMathLibCall && CGF.ConvertType(ResultTy)->isFloatingPointTy())

vfdff wrote:

Oh, you are right, I see your idea, the expect list can be get by 
isConstWithoutErrnoAndExceptions

https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang codegen] Emit int TBAA metadata on more FP math libcalls (PR #100302)

2024-07-25 Thread via cfe-commits

https://github.com/vfdff edited https://github.com/llvm/llvm-project/pull/100302
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> Confirmed: reverting the change locally restores the builds, although I don't 
> yet see why.

The fact that there's a missing symbol suggests the STL on the machine is not 
conforming... the symbol that's missing  
(`_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_`)
 demangles to: `std::time_put > >::put(std::ostreambuf_iterator >, std::ios_base&, char, std::tm const*, char const*, 
char const*) const` which has been around since C++98.

https://github.com/llvm/llvm-project/pull/99075
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f8006a5 - [analyzer][NFC] Add some docs for LazyCompoundValue (#97407)

2024-07-25 Thread via cfe-commits

Author: Kristóf Umann
Date: 2024-07-25T13:26:59+02:00
New Revision: f8006a5932b1ccdf3a1eed7b20b5cb608c0a020c

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

LOG: [analyzer][NFC] Add some docs for LazyCompoundValue (#97407)

Yes, I basically copy-pasted some posts from discord and Artem's book,
but these make for a rather decent docs.

-

Co-authored-by: Artem Dergachev 
Co-authored-by: Donát Nagy 
Co-authored-by: Balazs Benics 

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
index 3a4b087257149..def2970d448d4 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
@@ -326,6 +326,10 @@ class LocAsInteger : public NonLoc {
   static bool classof(SVal V) { return V.getKind() == LocAsIntegerKind; }
 };
 
+/// The simplest example of a concrete compound value is nonloc::CompoundVal,
+/// which represents a concrete r-value of an initializer-list or a string.
+/// Internally, it contains an llvm::ImmutableList of SVal's stored inside the
+/// literal.
 class CompoundVal : public NonLoc {
   friend class ento::SValBuilder;
 
@@ -346,6 +350,36 @@ class CompoundVal : public NonLoc {
   static bool classof(SVal V) { return V.getKind() == CompoundValKind; }
 };
 
+/// While nonloc::CompoundVal covers a few simple use cases,
+/// nonloc::LazyCompoundVal is a more performant and flexible way to represent
+/// an rvalue of record type, so it shows up much more frequently during
+/// analysis. This value is an r-value that represents a snapshot of any
+/// structure "as a whole" at a given moment during the analysis. Such value is
+/// already quite far from being referred to as "concrete", as many fields
+/// inside it would be unknown or symbolic. nonloc::LazyCompoundVal operates by
+/// storing two things:
+///   * a reference to the TypedValueRegion being snapshotted (yes, it is 
always
+/// typed), and also
+///   * a reference to the whole Store object, obtained from the ProgramState 
in
+/// which the nonloc::LazyCompoundVal was created.
+///
+/// Note that the old ProgramState and its Store is kept alive during the
+/// analysis because these are immutable functional data structures and each 
new
+/// Store value is represented as "earlier Store" + "additional binding".
+///
+/// Essentially, nonloc::LazyCompoundVal is a performance optimization for the
+/// analyzer. Because Store is immutable, creating a nonloc::LazyCompoundVal is
+/// a very cheap operation. Note that the Store contains all region bindings in
+/// the program state, not only related to the region. Later, if necessary, 
such
+/// value can be unpacked -- eg. when it is assigned to another variable.
+///
+/// If you ever need to inspect the contents of the LazyCompoundVal, you can 
use
+/// StoreManager::iterBindings(). It'll iterate through all values in the 
Store,
+/// but you're only interested in the ones that belong to
+/// LazyCompoundVal::getRegion(); other bindings are immaterial.
+///
+/// NOTE: LazyCompoundVal::getRegion() itself is also immaterial (see the 
actual
+/// method docs for details).
 class LazyCompoundVal : public NonLoc {
   friend class ento::SValBuilder;
 
@@ -363,6 +397,18 @@ class LazyCompoundVal : public NonLoc {
   /// It might return null.
   const void *getStore() const;
 
+  /// This function itself is immaterial. It is only an implementation detail.
+  /// LazyCompoundVal represents only the rvalue, the data (known or unknown)
+  /// that *was* stored in that region *at some point in the past*. The region
+  /// should not be used for any purpose other than figuring out what part of
+  /// the frozen Store you're interested in. The value does not represent the
+  /// *current* value of that region. Sometimes it may, but this should not be
+  /// relied upon. Instead, if you want to figure out what region it 
represents,
+  /// you typically need to see where you got it from in the first place. The
+  /// region is absolutely not analogous to the C++ "this" pointer. It is also
+  /// not a valid way to "materialize" the prvalue into a glvalue in C++,
+  /// because the region represents the *old* storage (sometimes very old), not
+  /// the *future* storage.
   LLVM_ATTRIBUTE_RETURNS_NONNULL
   const TypedValueRegion *getRegion() const;
 



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


[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/99473

>From d6903daf0da6979822b8981ea3641455ff6d06f8 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Tue, 16 Jul 2024 14:48:10 +0200
Subject: [PATCH 1/4] [Clang] Add __common_type builtin

---
 clang/include/clang/AST/ASTContext.h  |  11 ++
 clang/include/clang/AST/DeclID.h  |   5 +-
 clang/include/clang/Basic/Builtins.h  |   5 +-
 clang/include/clang/Sema/Sema.h   |   4 +
 clang/lib/AST/ASTContext.cpp  |   7 +
 clang/lib/AST/ASTImporter.cpp |   3 +
 clang/lib/AST/DeclTemplate.cpp|  53 ++
 clang/lib/Lex/PPMacroExpansion.cpp|   1 +
 clang/lib/Sema/SemaChecking.cpp   |   8 +
 clang/lib/Sema/SemaLookup.cpp |   4 +
 clang/lib/Sema/SemaTemplate.cpp   | 160 +-
 clang/lib/Serialization/ASTReader.cpp |   3 +
 clang/lib/Serialization/ASTWriter.cpp |   2 +
 clang/test/SemaCXX/type-trait-common-type.cpp | 126 ++
 libcxx/include/__type_traits/common_type.h|  16 +-
 libcxx/include/module.modulemap   |   2 +
 16 files changed, 404 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/SemaCXX/type-trait-common-type.cpp

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 608bd90fcc3ff..d02e742297898 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -399,6 +399,9 @@ class ASTContext : public RefCountedBase {
   /// The identifier '__type_pack_element'.
   mutable IdentifierInfo *TypePackElementName = nullptr;
 
+  /// The identifier '__common_type'.
+  mutable IdentifierInfo *CommonTypeName = nullptr;
+
   QualType ObjCConstantStringType;
   mutable RecordDecl *CFConstantStringTagDecl = nullptr;
   mutable TypedefDecl *CFConstantStringTypeDecl = nullptr;
@@ -606,6 +609,7 @@ class ASTContext : public RefCountedBase {
   mutable ExternCContextDecl *ExternCContext = nullptr;
   mutable BuiltinTemplateDecl *MakeIntegerSeqDecl = nullptr;
   mutable BuiltinTemplateDecl *TypePackElementDecl = nullptr;
+  mutable BuiltinTemplateDecl *CommonTypeDecl = nullptr;
 
   /// The associated SourceManager object.
   SourceManager &SourceMgr;
@@ -1107,6 +,7 @@ class ASTContext : public RefCountedBase {
   ExternCContextDecl *getExternCContextDecl() const;
   BuiltinTemplateDecl *getMakeIntegerSeqDecl() const;
   BuiltinTemplateDecl *getTypePackElementDecl() const;
+  BuiltinTemplateDecl *getCommonTypeDecl() const;
 
   // Builtin Types.
   CanQualType VoidTy;
@@ -1984,6 +1989,12 @@ class ASTContext : public RefCountedBase {
 return TypePackElementName;
   }
 
+  IdentifierInfo *getCommonTypeName() const {
+if (!CommonTypeName)
+  CommonTypeName = &Idents.get("__common_type");
+return CommonTypeName;
+  }
+
   /// Retrieve the Objective-C "instancetype" type, if already known;
   /// otherwise, returns a NULL type;
   QualType getObjCInstanceType() {
diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
index e5e27389fac60..875e9a72b3951 100644
--- a/clang/include/clang/AST/DeclID.h
+++ b/clang/include/clang/AST/DeclID.h
@@ -84,13 +84,16 @@ enum PredefinedDeclIDs {
 
   /// The internal '__type_pack_element' template.
   PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
+
+  /// The internal '__common_type' template.
+  PREDEF_DECL_COMMON_TYPE_ID = 18,
 };
 
 /// The number of declaration IDs that are predefined.
 ///
 /// For more information about predefined declarations, see the
 /// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
-const unsigned int NUM_PREDEF_DECL_IDS = 18;
+const unsigned int NUM_PREDEF_DECL_IDS = 19;
 
 /// GlobalDeclID means DeclID in the current ASTContext and LocalDeclID means
 /// DeclID specific to a certain ModuleFile. Specially, in ASTWriter, the
diff --git a/clang/include/clang/Basic/Builtins.h 
b/clang/include/clang/Basic/Builtins.h
index e85ec5b2dca14..4353b72f71383 100644
--- a/clang/include/clang/Basic/Builtins.h
+++ b/clang/include/clang/Basic/Builtins.h
@@ -309,7 +309,10 @@ enum BuiltinTemplateKind : int {
   BTK__make_integer_seq,
 
   /// This names the __type_pack_element BuiltinTemplateDecl.
-  BTK__type_pack_element
+  BTK__type_pack_element,
+
+  /// This names the __common_type BuiltinTemplateDecl.
+  BTK__common_type,
 };
 
 } // end namespace clang
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3cb1aa935fe46..5c7945c4c5c58 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2282,6 +2282,10 @@ class Sema final : public SemaBase {
   /// Check to see if a given expression could have '.c_str()' called on it.
   bool hasCStrMethod(const Expr *E);
 
+  // Check whether a type member 'Type::Name' exists, and if yes, return the
+  // type. If there is no type, the QualType is null
+  QualType getTy

[clang] [analyzer][NFC] Add some docs for LazyCompoundValue (PR #97407)

2024-07-25 Thread Kristóf Umann via cfe-commits

https://github.com/Szelethus closed 
https://github.com/llvm/llvm-project/pull/97407
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Add some docs for LazyCompoundValue (PR #97407)

2024-07-25 Thread Kristóf Umann via cfe-commits

Szelethus wrote:

I decided to merge this. We are still miles ahead with these docs, and I don't 
wanna accidentally forget the PR.

https://github.com/llvm/llvm-project/pull/97407
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Aha!

https://bugs.llvm.org/show_bug.cgi?id=33767

We have a mixture of both `std::tm` and `::tm` in here, try switching to using 
`::tm` and see if that helps.

https://github.com/llvm/llvm-project/pull/99075
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-25 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

We could probably also add something like `-Xarch_device_ ` in 
lieu of `-Xopenmp-target= ` since the `=` format isn't really 
standard in this area.

https://github.com/llvm/llvm-project/pull/100152
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Donát Nagy via cfe-commits


@@ -923,12 +923,31 @@ SVal AnyCXXConstructorCall::getCXXThisVal() const {
   return UnknownVal();
 }
 
+static bool isWithinStdNamespace(const Decl *D) {

NagyDonat wrote:

Of course, feel free to leave it for a followup patch.

https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-25 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/100349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 90929dd - [analyzer] Don't invalidate the super region when a std object ctor runs (#100405)

2024-07-25 Thread via cfe-commits

Author: Balazs Benics
Date: 2024-07-25T13:43:47+02:00
New Revision: 90929dd97a8f2c00148bee676bf8b44bec063d9b

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

LOG: [analyzer] Don't invalidate the super region when a std object ctor runs 
(#100405)

CPP-5269

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/test/Analysis/call-invalidation.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp 
b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index 0e317ec765ec0..eba224b8ec01c 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -923,12 +923,31 @@ SVal AnyCXXConstructorCall::getCXXThisVal() const {
   return UnknownVal();
 }
 
+static bool isWithinStdNamespace(const Decl *D) {
+  const DeclContext *DC = D->getDeclContext();
+  while (DC) {
+if (const auto *NS = dyn_cast(DC);
+NS && NS->isStdNamespace())
+  return true;
+DC = DC->getParent();
+  }
+  return false;
+}
+
 void AnyCXXConstructorCall::getExtraInvalidatedValues(ValueList &Values,
RegionAndSymbolInvalidationTraits *ETraits) const {
   SVal V = getCXXThisVal();
   if (SymbolRef Sym = V.getAsSymbol(true))
 ETraits->setTrait(Sym,
   RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
+
+  // Standard classes don't reinterpret-cast and modify super regions.
+  const bool IsStdClassCtor = isWithinStdNamespace(getDecl());
+  if (const MemRegion *Obj = V.getAsRegion(); Obj && IsStdClassCtor) {
+ETraits->setTrait(
+Obj, RegionAndSymbolInvalidationTraits::TK_DoNotInvalidateSuperRegion);
+  }
+
   Values.push_back(V);
 }
 

diff  --git a/clang/test/Analysis/call-invalidation.cpp 
b/clang/test/Analysis/call-invalidation.cpp
index 727217f228b05..fb2b892b31a1f 100644
--- a/clang/test/Analysis/call-invalidation.cpp
+++ b/clang/test/Analysis/call-invalidation.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
-analyzer-config eagerly-assume=false %s
 
+template  void clang_analyzer_dump(T);
 void clang_analyzer_eval(bool);
 
 void usePointer(int * const *);
@@ -165,3 +166,117 @@ void testMixedConstNonConstCalls() {
   useFirstNonConstSecondConst(&(s2.x), &(s2.y));
   clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
 }
+
+namespace std {
+class Opaque {
+public:
+  Opaque();
+  int nested_member;
+};
+} // namespace std
+
+struct StdWrappingOpaque {
+  std::Opaque o; // first member
+  int uninit;
+};
+struct StdWrappingOpaqueSwapped {
+  int uninit; // first member
+  std::Opaque o;
+};
+
+int testStdCtorDoesNotInvalidateParentObject() {
+  StdWrappingOpaque obj;
+  int x = obj.o.nested_member; // no-garbage: std::Opaque::ctor might 
initialized this
+  int y = obj.uninit; // FIXME: We should have a garbage read here. Read the 
details.
+  // As the first member ("obj.o") is invalidated, a conjured default binding 
is bound
+  // to the offset 0 within cluster "obj", and this masks every uninitialized 
fields
+  // that follows. We need a better store with extents to fix this.
+  return x + y;
+}
+
+int testStdCtorDoesNotInvalidateParentObjectSwapped() {
+  StdWrappingOpaqueSwapped obj;
+  int x = obj.o.nested_member; // no-garbage: std::Opaque::ctor might 
initialized this
+  int y = obj.uninit; // expected-warning {{Assigned value is garbage or 
undefined}}
+  return x + y;
+}
+
+class UserProvidedOpaque {
+public:
+  UserProvidedOpaque(); // might reinterpret_cast(this)
+  int nested_member;
+};
+
+struct WrappingUserProvidedOpaque {
+  UserProvidedOpaque o; // first member
+  int uninit;
+};
+struct WrappingUserProvidedOpaqueSwapped {
+  int uninit; // first member
+  UserProvidedOpaque o;
+};
+
+int testUserProvidedCtorInvalidatesParentObject() {
+  WrappingUserProvidedOpaque obj;
+  int x = obj.o.nested_member; // no-garbage: UserProvidedOpaque::ctor might 
initialized this
+  int y = obj.uninit; // no-garbage: UserProvidedOpaque::ctor might 
reinterpret_cast(this) and write to the "uninit" member.
+  return x + y;
+}
+
+int testUserProvidedCtorInvalidatesParentObjectSwapped() {
+  WrappingUserProvidedOpaqueSwapped obj;
+  int x = obj.o.nested_member; // no-garbage: same as above
+  int y = obj.uninit; // no-garbage: same as above
+  return x + y;
+}
+
+struct WrappingStdWrappingOpaqueOuterInits {
+  int first = 1;
+  std::Opaque second;
+  int third = 3;
+  WrappingStdWrappingOpaqueOuterInits() {
+clang_analyzer_dump(first); // expected-warning {{1 S32b}}
+clang_analyzer_dump(second.nested_member); // expected-warning {{derived_}}
+clang_analyzer_dump(third); // expected-warning {{3 S32b}}
+  }
+};
+
+struct WrappingUserProvidedOpaqueOuterInits {
+  int first = 1; // 

[clang] [analyzer] Don't invalidate the super region when a std object ctor runs (PR #100405)

2024-07-25 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/100405
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Interp] Visit `DecompositionDecl` and create a local variable (PR #100400)

2024-07-25 Thread via cfe-commits

https://github.com/yronglin closed 
https://github.com/llvm/llvm-project/pull/100400
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 534e2dd - [Clang][Interp] Visit `DecompositionDecl` and create a local variable (#100400)

2024-07-25 Thread via cfe-commits

Author: yronglin
Date: 2024-07-25T19:44:25+08:00
New Revision: 534e2dd29f252cc13b94312895d2f4b39b54b9d4

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

LOG: [Clang][Interp] Visit `DecompositionDecl` and create a local variable 
(#100400)

The following code should be well-formed:
```C++
float decompose_complex(_Complex float cf) {
  static _Complex float scf;
  auto &[sre, sim] = scf;
  // ok, this is references initialized by constant expressions all the way down
  static_assert(&sre == &__real scf);
  static_assert(&sim == &__imag scf);

  auto [re, im] = cf;
  return re*re + im*im;
}

```
We should visit `DecompositionDecl` and create a local variable but not
a create a dummy value directly.

-

Signed-off-by: yronglin 

Added: 


Modified: 
clang/lib/AST/Interp/Compiler.cpp
clang/test/SemaCXX/cxx1z-decomposition.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Compiler.cpp 
b/clang/lib/AST/Interp/Compiler.cpp
index df55d01b8b9d6..11ca7f210d2d5 100644
--- a/clang/lib/AST/Interp/Compiler.cpp
+++ b/clang/lib/AST/Interp/Compiler.cpp
@@ -5239,6 +5239,10 @@ bool Compiler::visitDeclRef(const ValueDecl *D, 
const Expr *E) {
   return false;
 };
 
+// DecompositionDecls are just proxies for us.
+if (isa(VD))
+  return revisit(VD);
+
 // Visit local const variables like normal.
 if ((VD->hasGlobalStorage() || VD->isLocalVarDecl() ||
  VD->isStaticDataMember()) &&

diff  --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index 305a9ac2ebc24..19c730303625e 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++17 -Wc++20-extensions -verify=expected %s
 // RUN: %clang_cc1 -std=c++20 -Wpre-c++20-compat -verify=expected %s
+// RUN: %clang_cc1 -std=c++20 -Wpre-c++20-compat 
-fexperimental-new-constant-interpreter -verify=expected %s
 
 void use_from_own_init() {
   auto [a] = a; // expected-error {{binding 'a' cannot appear in the 
initializer of its own decomposition declaration}}



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


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Rainer Orth via cfe-commits

rorth wrote:

> Aha!
> 
> https://bugs.llvm.org/show_bug.cgi?id=33767

Ah, old sins (from the GCC side no less) keep haunting me.

> We have a mixture of both `std::tm` and `::tm` in here, try switching to 
> using `::tm` and see if that helps.

Unfortunately not: I always get the undefined reference to the `std::tm const 
*` version, no matter what I tried.

https://github.com/llvm/llvm-project/pull/99075
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Improve support for explicit specializations of constrained member functions & member function templates (PR #88963)

2024-07-25 Thread Krystian Stasiowski via cfe-commits


@@ -10339,24 +10339,53 @@ Sema::CheckMemberSpecialization(NamedDecl *Member, 
LookupResult &Previous) {
   if (Previous.empty()) {
 // Nowhere to look anyway.
   } else if (FunctionDecl *Function = dyn_cast(Member)) {
+SmallVector Candidates;
+bool Ambiguous = false;
 for (LookupResult::iterator I = Previous.begin(), E = Previous.end();
I != E; ++I) {
-  NamedDecl *D = (*I)->getUnderlyingDecl();
-  if (CXXMethodDecl *Method = dyn_cast(D)) {
-QualType Adjusted = Function->getType();
-if (!hasExplicitCallingConv(Adjusted))
-  Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
-// This doesn't handle deduced return types, but both function
-// declarations should be undeduced at this point.
-if (Context.hasSameType(Adjusted, Method->getType())) {
-  FoundInstantiation = *I;
-  Instantiation = Method;
-  InstantiatedFrom = Method->getInstantiatedFromMemberFunction();
-  MSInfo = Method->getMemberSpecializationInfo();
-  break;
-}
+  CXXMethodDecl *Method =
+  dyn_cast((*I)->getUnderlyingDecl());
+  if (!Method)
+continue;
+  QualType Adjusted = Function->getType();
+  if (!hasExplicitCallingConv(Adjusted))
+Adjusted = adjustCCAndNoReturn(Adjusted, Method->getType());
+  // This doesn't handle deduced return types, but both function
+  // declarations should be undeduced at this point.
+  if (!Context.hasSameType(Adjusted, Method->getType()))
+continue;
+  if (ConstraintSatisfaction Satisfaction;
+  Method->getTrailingRequiresClause() &&
+  (CheckFunctionConstraints(Method, Satisfaction,
+/*UsageLoc=*/Member->getLocation(),
+/*ForOverloadResolution=*/true) ||
+   !Satisfaction.IsSatisfied))
+continue;
+  Candidates.push_back(Method);
+  FunctionDecl *MoreConstrained =
+  Instantiation ? getMoreConstrainedFunction(
+  Method, cast(Instantiation))
+: Method;
+  if (!MoreConstrained) {
+Ambiguous = true;
+continue;
+  }
+  if (MoreConstrained == Method) {
+Ambiguous = false;

sdkrystian wrote:

Whoops, good catch! I'll open a patch to fix this :)

https://github.com/llvm/llvm-project/pull/88963
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASTMatchers] Extend hasName matcher when matching templates (PR #100349)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> Allow users to match all record instantiations by using <> as a wildcard.

I think this will change the behavior of existing matchers, consider:
```
template 
struct S {
  Ty Val;
  void Call();
};

int main() {
  S<> s;
  s.Call(); // Currently matches only this

  S another;
  another.Call(); // Will now start to match this as well?
}
```
https://godbolt.org/z/Gr439c9v4

WDYT?

https://github.com/llvm/llvm-project/pull/100349
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-25 Thread Sergio Afonso via cfe-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/100152

>From cf26a318d3b49eb6217f29405cee9fd2c20f8e8a Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 23 Jul 2024 16:19:55 +0100
Subject: [PATCH 1/4] [Flang][Driver] Introduce -fopenmp-targets offloading
 option

This patch modifies the flang driver to introduce the `-fopenmp-targets` option
to the frontend compiler invocations corresponding to the OpenMP host device on
offloading-enabled compilations.

This option holds the list of offloading triples associated to the compilation
and is used by clang to determine whether offloading calls should be generated
for the host.
---
 clang/include/clang/Driver/Options.td|  2 +-
 clang/lib/Driver/ToolChains/Flang.cpp| 13 +
 flang/test/Driver/omp-driver-offload.f90 | 17 +
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 69269cf7537b0..4ef7c81fbd9e4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3530,7 +3530,7 @@ def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, 
Group,
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>, Visibility<[ClangOption, CC1Option]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">,
-  Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option, FlangOption]>,
+  Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option, FlangOption, 
FC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index c4f2375c64034..b0a3528dce05d 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Driver/Options.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -492,6 +493,18 @@ void Flang::addOffloadOptions(Compilation &C, const 
InputInfoList &Inputs,
 if (Args.hasArg(options::OPT_nogpulib))
   CmdArgs.push_back("-nogpulib");
   }
+
+  // For all the host OpenMP offloading compile jobs we need to pass the 
targets
+  // information using -fopenmp-targets= option.
+  if (JA.isHostOffloading(Action::OFK_OpenMP)) {
+SmallString<128> Targets("-fopenmp-targets=");
+
+SmallVector Triples;
+auto TCRange = C.getOffloadToolChains();
+std::transform(TCRange.first, TCRange.second, std::back_inserter(Triples),
+   [](auto TC) { return TC.second->getTripleString(); });
+CmdArgs.push_back(Args.MakeArgString(Targets + llvm::join(Triples, ",")));
+  }
 }
 
 static void addFloatingPointOptions(const Driver &D, const ArgList &Args,
diff --git a/flang/test/Driver/omp-driver-offload.f90 
b/flang/test/Driver/omp-driver-offload.f90
index 6fb4f4ca1..70fb8c7298e77 100644
--- a/flang/test/Driver/omp-driver-offload.f90
+++ b/flang/test/Driver/omp-driver-offload.f90
@@ -227,3 +227,20 @@
 ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"
 ! FORCE-USM-OFFLOAD-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"amdgcn-amd-amdhsa"
 ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm"
+
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: | FileCheck %s --check-prefix=OFFLOAD-TARGETS
+
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp --offload-arch=gfx90a \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN: | FileCheck %s --check-prefix=OFFLOAD-TARGETS
+
+! OFFLOAD-TARGETS: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
+! OFFLOAD-TARGETS-SAME: "-fopenmp-targets=amdgcn-amd-amdhsa"
+! OFFLOAD-TARGETS-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"amdgcn-amd-amdhsa"
+! OFFLOAD-TARGETS-NOT: -fopenmp-targets
+! OFFLOAD-TARGETS: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu"
+! OFFLOAD-TARGETS-SAME: "-fopenmp-targets=amdgcn-amd-amdhsa"

>From a5d5c988044c3182fb51662f486e1b79820e29f8 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Wed, 24 Jul 2024 11:29:19 +0100
Subject: [PATCH 2/4] Attempt to fix buildbot issue

---
 .../test/Driver/omp-driver-offload-amdgpu.f90  | 18 ++
 flang/test/Driver/omp-driver-offload.f90   | 11 +++
 2 files changed, 21 insertions(+), 8 deletions(-)
 create mode 100644 flang/test/Driver/omp-driver-offload-amdgpu.f90

diff --git a/flang/test/Driver/omp-driver-offload-amdgpu.f90 
b/flang/test/Driver/omp-driver-offload-amdgpu.f90
new file mode 100644
index 0..cf806d672f396
--- /dev/null
+++ b/flang/test/Dri

[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> > We have a mixture of both `std::tm` and `::tm` in here, try switching to 
> > using `::tm` and see if that helps.
> 
> Unfortunately not: I always get the undefined reference to the `std::tm const 
> *` version, no matter what I tried.

Drat!

If you dump the symbols from the STL shared library on the system, is there one 
for `time_put` at all? If so, what is the mangled symbol it exports?

(As a perhaps terrible idea, could we use the `alias` attribute on a 
redeclaration to try to force to link against the correct mangling for Solaris 
only?)

https://github.com/llvm/llvm-project/pull/99075
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)

2024-07-25 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman approved this pull request.

LGTM! Thank you for the fix!

https://github.com/llvm/llvm-project/pull/99308
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)

2024-07-25 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

@AaronBallman If no further feedback is needed, could you please proceed with 
the merge? Thanks

https://github.com/llvm/llvm-project/pull/99308
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> @AaronBallman If no further feedback is needed, could you please proceed with 
> the merge? Thanks

Can do! Btw, you should feel free to obtain commit privileges yourself if you'd 
like: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

https://github.com/llvm/llvm-project/pull/99308
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f916cb6 - [Clang] fix assertion failure in invalid delete operator declaration check (#99308)

2024-07-25 Thread via cfe-commits

Author: Oleksandr T.
Date: 2024-07-25T08:08:18-04:00
New Revision: f916cb6184fb04b27ae7b867edcfd162c3a49694

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

LOG: [Clang] fix assertion failure in invalid delete operator declaration check 
(#99308)

Fixes #96191

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/cxx2a-destroying-delete.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0b79e952b48af..9f5ee9c82ab0a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -150,6 +150,7 @@ Bug Fixes to C++ Support
 
 
 - Fixed a crash when an expression with a dependent ``__typeof__`` type is 
used as the operand of a unary operator. (#GH97646)
+- Fixed a failed assertion when checking invalid delete operator declaration. 
(#GH96191)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 14d1f395af90e..51c4a36808fce 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -3806,6 +3806,9 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool 
UseGlobal,
  Overaligned, DeleteName);
 }
 
+if (OperatorDelete->isInvalidDecl())
+  return ExprError();
+
 MarkFunctionReferenced(StartLoc, OperatorDelete);
 
 // Check access and ambiguity of destructor if we're going to call it.

diff  --git a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp 
b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
index 349e6e9538a4c..25b985ef11d15 100644
--- a/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
+++ b/clang/test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -187,3 +187,12 @@ namespace delete_from_new {
 #endif
   }
 }
+
+namespace GH96191 {
+  struct S {};
+  struct T {
+void operator delete(S) { } // expected-error {{first parameter of 
'operator delete' must have type 'void *'}}
+  };
+
+  void foo(T *t) { delete t; }
+}



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


[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)

2024-07-25 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman closed 
https://github.com/llvm/llvm-project/pull/99308
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)

2024-07-25 Thread Oleksandr T. via cfe-commits

a-tarasyuk wrote:

@AaronBallman Thanks

https://github.com/llvm/llvm-project/pull/99308
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [libcxx] [Clang] Add __common_type builtin (PR #99473)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Should we prefix this with `__builtin_` as mentioned in 
https://github.com/llvm/llvm-project/issues/98310#issuecomment-2221105713 ?

https://github.com/llvm/llvm-project/pull/99473
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Rainer Orth via cfe-commits

rorth wrote:

> If you dump the symbols from the STL shared library on the system, is there 
> one for `time_put` at all? If so, what is the mangled symbol it exports?

While the source requires
```
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_

std::time_put > 
>::put(std::ostreambuf_iterator >, std::ios_base&, 
char, std::tm const*, char const*, char const*) const
```
`libstdc++.so.6` only provides
```
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPK2tmPKcSB_

std::time_put > 
>::put(std::ostreambuf_iterator >, std::ios_base&, 
char, tm const*, char const*, char const*) const
```
i.e. `tm const *` instead of `std::tm const *`.
> 
> (As a perhaps terrible idea, could we use the `alias` attribute on a 
> redeclaration to try to force to link against the correct mangling for 
> Solaris only?)

A hack along the lines of
```
asm("_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPKSt2tmPKcSB_
 = 
_ZNKSt8time_putIcSt19ostreambuf_iteratorIcSt11char_traitsIcEEE3putES3_RSt8ios_basecPK2tmPKcSB_");
```
at least allows `clang` to link.

https://github.com/llvm/llvm-project/pull/99075
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] fix assertion failure in invalid delete operator declaration check (PR #99308)

2024-07-25 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-hip-vega20` running 
on `hip-vega20-0` while building `clang` at step 3 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/123/builds/2579

Here is the relevant piece of the build log for the reference:
```
Step 3 (annotate) failure: 
'../llvm-zorg/zorg/buildbot/builders/annotated/hip-build.sh --jobs=' (failure)
...
[36/38] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 
-DNDEBUG  
External/HIP/CMakeFiles/InOneWeekend-hip-6.0.2.dir/workload/ray-tracing/InOneWeekend/main.cc.o
 -o External/HIP/InOneWeekend-hip-6.0.2  
--rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt 
-unwindlib=libgcc -frtlib-add-rpath && cd 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && 
/usr/local/bin/cmake -E create_symlink 
/buildbot/llvm-test-suite/External/HIP/InOneWeekend.reference_output 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend.reference_output-hip-6.0.2
[37/38] /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -DNDEBUG  -O3 
-DNDEBUG   -w -Werror=date-time --rocm-path=/buildbot/Externals/hip/rocm-6.0.2 
--offload-arch=gfx908 --offload-arch=gfx90a --offload-arch=gfx1030 
--offload-arch=gfx1100 -xhip -mfma -MD -MT 
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o
 -MF 
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o.d
 -o 
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o
 -c 
/buildbot/llvm-test-suite/External/HIP/workload/ray-tracing/TheNextWeek/main.cc
[38/38] : && /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/clang++ -O3 
-DNDEBUG  
External/HIP/CMakeFiles/TheNextWeek-hip-6.0.2.dir/workload/ray-tracing/TheNextWeek/main.cc.o
 -o External/HIP/TheNextWeek-hip-6.0.2  
--rocm-path=/buildbot/Externals/hip/rocm-6.0.2 --hip-link -rtlib=compiler-rt 
-unwindlib=libgcc -frtlib-add-rpath && cd 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && 
/usr/local/bin/cmake -E create_symlink 
/buildbot/llvm-test-suite/External/HIP/TheNextWeek.reference_output 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/TheNextWeek.reference_output-hip-6.0.2
+ build_step 'Testing HIP test-suite'
+ echo '@@@BUILD_STEP Testing HIP test-suite@@@'
+ ninja -v check-hip-simple
@@@BUILD_STEP Testing HIP test-suite@@@
[0/1] cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP 
&& /buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv 
empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test 
InOneWeekend-hip-6.0.2.test TheNextWeek-hip-6.0.2.test blender.test
-- Testing: 6 tests, 6 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 
FAIL: test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test (4 of 6)
 TEST 'test-suite :: 
External/HIP/InOneWeekend-hip-6.0.2.test' FAILED 

/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/timeit-target 
--timeout 7200 --limit-core 0 --limit-cpu 7200 --limit-file-size 209715200 
--limit-rss-size 838860800 --append-exitstatus --redirect-output 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out
 --redirect-input /dev/null --summary 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.time
 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/InOneWeekend-hip-6.0.2
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP ; 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out
 InOneWeekend.reference_output-hip-6.0.2

+ cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP
+ /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target 
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP/Output/InOneWeekend-hip-6.0.2.test.out
 InOneWeekend.reference_output-hip-6.0.2
/buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/tools/fpcmp-target: 
Comparison failed, textual difference between 'M' and 'i'


/usr/bin/strip: /bin/bash.stripped: Bad file descriptor
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

Failed Tests (1):
  test-suite :: External/HIP/InOneWeekend-hip-6.0.2.test


Testing Time: 387.32s

Total Discovered Tests: 6
  Passed: 5 (83.33%)
  Failed: 1 (16.67%)
FAILED: External/HIP/CMakeFiles/check-hip-simple-hip-6.0.2 
cd /buildbot/hip-vega20-0/clang-hip-vega20/test-suite-build/External/HIP && 
/buildbot/hip-vega20-0/clang-hip-vega20/llvm/bin/llvm-lit -sv 
empty-hip-6.0.2.test with-fopenmp-hip-6.0.2.test saxpy-hip-6.0.2.test 
InOneWeekend-hip-6.0.2.test TheNextWeek-hip

[clang] [clang] replaced the usage of `asctime` with `std::put_time` (PR #99075)

2024-07-25 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Blech, thank you for trying! I guess that unless there's some way to hide this 
ugliness in the cmake scripts or someone else has better ideas to try, the 
`asm` aliasing (on Solaris only) may be our best path forward.

https://github.com/llvm/llvm-project/pull/99075
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix confusing diagnositcs related to explicit this parameters (PR #100351)

2024-07-25 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/100351

>From 4e0845195d6593b907bbf65d436ededee9c2aacd Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Tue, 23 Jul 2024 11:04:06 -0400
Subject: [PATCH] Fixed confusing diagnostics / add release notes

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaOverload.cpp| 2 +-
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ac1de0db9ce48..81624902c4f43 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -120,6 +120,8 @@ Improvements to Clang's diagnostics
   template  int i; // error: non-static data member 'i' cannot 
be declared as a template
  };
 
+- Clang now has improved diagnostics for functions with explicit 'this' 
parameters. Fixes #GH97878
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a8d250fbabfed..ac90ccd5643c1 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -11149,7 +11149,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
   if (isa(Fn) && !isa(Fn)) {
 if (I == 0)
   isObjectArgument = true;
-else
+else if (!Fn->hasCXXExplicitFunctionObjectParameter())
   I--;
   }
 
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 5cbc1f735383b..f5cae2ecb5f08 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -959,3 +959,10 @@ void f();
 };
 void a::f(this auto) {} // expected-error {{an explicit object parameter 
cannot appear in a non-member function}}
 }
+
+struct R {
+  void f(this auto &&self, int &&r_value_ref) {} // expected-note {{candidate 
function template not viable: expects an rvalue for 2nd argument}}
+  void g(int &&r_value_ref) {
+   f(r_value_ref); // expected-error {{no matching member function for 
call to 'f'}}
+  }
+};

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


[clang] [clang][Sema] Refine unused-member-function diagnostic message for constructors (PR #84515)

2024-07-25 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

Thank you for the diagnostic improvement!

https://github.com/llvm/llvm-project/pull/84515
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Refine unused-member-function diagnostic message for constructors (PR #84515)

2024-07-25 Thread Aaron Ballman via cfe-commits


@@ -76,10 +76,33 @@ struct S {
   struct SVS : public VS {
 void vm() { }
   };
+
+  struct CS {

AaronBallman wrote:

When switching the diagnostic approach, be sure to add test coverage for unused 
copy/move constructors, copy/move assignment, and destructors (you can get an 
unused destructor if you only use `new` to allocate the class rather than stack 
allocate it).

https://github.com/llvm/llvm-project/pull/84515
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Refine unused-member-function diagnostic message for constructors (PR #84515)

2024-07-25 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman edited 
https://github.com/llvm/llvm-project/pull/84515
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Sema] Refine unused-member-function diagnostic message for constructors (PR #84515)

2024-07-25 Thread Aaron Ballman via cfe-commits


@@ -402,7 +402,7 @@ def warn_unused_function : Warning<"unused function %0">,
   InGroup, DefaultIgnore;
 def warn_unused_template : Warning<"unused %select{function|variable}0 
template %1">,
   InGroup, DefaultIgnore;
-def warn_unused_member_function : Warning<"unused member function %0">,
+def warn_unused_member_function : Warning<"unused %select{constructor|member 
function %1}0">,

AaronBallman wrote:

I would recommend using `%sub{select_special_member_kind}1` instead of manually 
spelling out constructor; see `note_member_synthesized_at` for an example of it 
being used.

https://github.com/llvm/llvm-project/pull/84515
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >