[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-05 Thread Ben Shi via cfe-commits

benshi001 wrote:

> For now only the pre-condition is added, the `evalFflush` function is missing.

I have also added `evalFflush`.

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


[clang] [Sema] Warning for _Float16 passed to format specifier '%f' (PR #74439)

2023-12-05 Thread Haocong Lu via cfe-commits

Luhaocong wrote:

> Should this only apply in C23 mode? Standard behavior until C23 is that 
> `_Float16` promotes to `double`. What about C++?

It seems clang never support default argument promotions for _Float16, as 
described in 
https://github.com/llvm/llvm-project/blob/main/clang/docs/LanguageExtensions.rst#id68
 five years ago. Is there any demand to support this in old C/C++ standard?

And I try case with -std=c99 (https://godbolt.org/z/xqx8e6oh5) and -std=c++11 
(https://godbolt.org/z/Mrn779Tdq) , GCC give a warning at both.

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


[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

2023-12-05 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/74296

>From 65ce18117f99056aafcf58151b64f4243f4d5e26 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 4 Dec 2023 15:51:20 +0800
Subject: [PATCH 1/2] [clang][analyzer] Support `fflush` in the StreamChecker

---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp| 16 
 .../Analysis/Inputs/system-header-simulator.h|  1 +
 clang/test/Analysis/stream-error.c   |  9 +
 3 files changed, 26 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 925fc90e35543..2c725c01dc285 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -266,6 +266,7 @@ class StreamChecker : public CheckerStreamArgNo)
+   ->isNullPointerConstant(C.getASTContext(),
+   Expr::NPC_ValueDependentIsNotNull)) {
+ProgramStateRef State = C.getState();
+if (State = ensureStreamOpened(getStreamArg(Desc, Call), C, State))
+  C.addTransition(State);
+  }
+}
+
 ProgramStateRef
 StreamChecker::ensureStreamNonNull(SVal StreamVal, const Expr *StreamE,
CheckerContext ,
diff --git a/clang/test/Analysis/Inputs/system-header-simulator.h 
b/clang/test/Analysis/Inputs/system-header-simulator.h
index 7089bd8bfc9d9..409a969a0d4cc 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator.h
@@ -61,6 +61,7 @@ void clearerr(FILE *stream);
 int feof(FILE *stream);
 int ferror(FILE *stream);
 int fileno(FILE *stream);
+int fflush(FILE *stream);
 
 size_t strlen(const char *);
 
diff --git a/clang/test/Analysis/stream-error.c 
b/clang/test/Analysis/stream-error.c
index c8332bcbfa8ca..aa5b6be851773 100644
--- a/clang/test/Analysis/stream-error.c
+++ b/clang/test/Analysis/stream-error.c
@@ -299,6 +299,15 @@ void error_fseek_0(void) {
   fclose(F);
 }
 
+void error_fflush(void) {
+  FILE *F = tmpfile();
+  if (!F)
+return;
+  fclose(F);
+  fflush(F);// expected-warning {{Stream might be already closed}}
+  fflush(NULL); // no-warning
+}
+
 void error_indeterminate(void) {
   FILE *F = fopen("file", "r+");
   if (!F)

>From dcb766b468a2f29df30451f8f196d7a2371fd038 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Wed, 6 Dec 2023 15:47:35 +0800
Subject: [PATCH 2/2] [clang][analyzer] Support `fflush` in the StreamChecker

---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 49 ---
 clang/test/Analysis/stream-error.c| 12 +++--
 2 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 2c725c01dc285..a368619fd37d2 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -266,7 +266,8 @@ class StreamChecker : public CheckerStreamArgNo)
-   ->isNullPointerConstant(C.getASTContext(),
-   Expr::NPC_ValueDependentIsNotNull)) {
-ProgramStateRef State = C.getState();
-if (State = ensureStreamOpened(getStreamArg(Desc, Call), C, State))
+  ProgramStateRef State = C.getState();
+  SVal StreamVal = getStreamArg(Desc, Call);
+  std::optional Stream = StreamVal.getAs();
+  if (!Stream)
+return;
+
+  ConstraintManager::ProgramStatePair SP =
+  C.getConstraintManager().assumeDual(State, *Stream);
+  if (State = SP.first)
+if (State = ensureStreamOpened(StreamVal, C, State))
   C.addTransition(State);
+}
+
+void StreamChecker::evalFflush(const FnDescription *Desc, const CallEvent 
,
+   CheckerContext ) const {
+  ProgramStateRef State = C.getState();
+
+  // We will check the result even if the input is `NULL`,
+  // but do nothing if the input state is unknown.
+  SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
+  if (StreamSym) {
+const StreamState *OldSS = State->get(StreamSym);
+if (!OldSS)
+  return;
+assertStreamStateOpened(OldSS);
   }
+
+  const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  // `fflush` returns 0 on success, otherwise returns EOF.
+  ProgramStateRef StateNotFailed = bindInt(0, State, C, CE);
+  ProgramStateRef StateFailed = bindInt(*EofVal, State, C, CE);
+
+  // This function does not affect the stream state.
+  // Still we add success and failure state with the appropriate return value.
+  C.addTransition(StateNotFailed);
+  C.addTransition(StateFailed);
 }
 
 ProgramStateRef
diff --git a/clang/test/Analysis/stream-error.c 
b/clang/test/Analysis/stream-error.c
index aa5b6be851773..94787874cf839 100644
--- a/clang/test/Analysis/stream-error.c
+++ b/clang/test/Analysis/stream-error.c
@@ -301,11 +301,17 @@ void error_fseek_0(void) {
 
 void error_fflush(void) {
   FILE 

[clang] [clang-format][NFC] Refactor getting first/last non-comment of line (PR #74570)

2023-12-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes



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


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.h (+5) 
- (modified) clang/lib/Format/UnwrappedLineFormatter.cpp (+6-13) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.h 
b/clang/lib/Format/TokenAnnotator.h
index 58e2cf79f488f..05a6daa87d803 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/lib/Format/TokenAnnotator.h
@@ -156,6 +156,11 @@ class AnnotatedLine {
 return First->is(tok::comment) ? First->getNextNonComment() : First;
   }
 
+  FormatToken *getLastNonComment() const {
+assert(Last);
+return Last->is(tok::comment) ? Last->getPreviousNonComment() : Last;
+  }
+
   FormatToken *First;
   FormatToken *Last;
 
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 40730cd53529e..b4930c2e4621d 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -346,14 +346,10 @@ class LineJoiner {
 return false;
 
   // Check if the found line starts a record.
-  const FormatToken *LastNonComment = Line->Last;
+  const auto *LastNonComment = Line->getLastNonComment();
+  // There must be another token (usually `{`), because we chose a
+  // non-PPDirective and non-comment line that has a smaller level.
   assert(LastNonComment);
-  if (LastNonComment->is(tok::comment)) {
-LastNonComment = LastNonComment->getPreviousNonComment();
-// There must be another token (usually `{`), because we chose a
-// non-PPDirective and non-comment line that has a smaller level.
-assert(LastNonComment);
-  }
   return isRecordLBrace(*LastNonComment);
 }
   }
@@ -363,12 +359,9 @@ class LineJoiner {
 
 bool MergeShortFunctions = ShouldMergeShortFunctions();
 
-const FormatToken *FirstNonComment = TheLine->First;
-if (FirstNonComment->is(tok::comment)) {
-  FirstNonComment = FirstNonComment->getNextNonComment();
-  if (!FirstNonComment)
-return 0;
-}
+const auto *FirstNonComment = TheLine->getFirstNonComment();
+if (!FirstNonComment)
+  return 0;
 // FIXME: There are probably cases where we should use FirstNonComment
 // instead of TheLine->First.
 

``




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


[clang] [clang-format][NFC] Refactor getting first/last non-comment of line (PR #74570)

2023-12-05 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/74570

None

>From a37925ae51d95e91d32ec50bc39a9b6e5b13c571 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 5 Dec 2023 23:31:28 -0800
Subject: [PATCH] [clang-format][NFC] Refactor getting first/last non-comment
 of line

---
 clang/lib/Format/TokenAnnotator.h   |  5 +
 clang/lib/Format/UnwrappedLineFormatter.cpp | 19 ++-
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.h 
b/clang/lib/Format/TokenAnnotator.h
index 58e2cf79f488f..05a6daa87d803 100644
--- a/clang/lib/Format/TokenAnnotator.h
+++ b/clang/lib/Format/TokenAnnotator.h
@@ -156,6 +156,11 @@ class AnnotatedLine {
 return First->is(tok::comment) ? First->getNextNonComment() : First;
   }
 
+  FormatToken *getLastNonComment() const {
+assert(Last);
+return Last->is(tok::comment) ? Last->getPreviousNonComment() : Last;
+  }
+
   FormatToken *First;
   FormatToken *Last;
 
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 40730cd53529e..b4930c2e4621d 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -346,14 +346,10 @@ class LineJoiner {
 return false;
 
   // Check if the found line starts a record.
-  const FormatToken *LastNonComment = Line->Last;
+  const auto *LastNonComment = Line->getLastNonComment();
+  // There must be another token (usually `{`), because we chose a
+  // non-PPDirective and non-comment line that has a smaller level.
   assert(LastNonComment);
-  if (LastNonComment->is(tok::comment)) {
-LastNonComment = LastNonComment->getPreviousNonComment();
-// There must be another token (usually `{`), because we chose a
-// non-PPDirective and non-comment line that has a smaller level.
-assert(LastNonComment);
-  }
   return isRecordLBrace(*LastNonComment);
 }
   }
@@ -363,12 +359,9 @@ class LineJoiner {
 
 bool MergeShortFunctions = ShouldMergeShortFunctions();
 
-const FormatToken *FirstNonComment = TheLine->First;
-if (FirstNonComment->is(tok::comment)) {
-  FirstNonComment = FirstNonComment->getNextNonComment();
-  if (!FirstNonComment)
-return 0;
-}
+const auto *FirstNonComment = TheLine->getFirstNonComment();
+if (!FirstNonComment)
+  return 0;
 // FIXME: There are probably cases where we should use FirstNonComment
 // instead of TheLine->First.
 

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


[libc] [compiler-rt] [lldb] [llvm] [lld] [libcxx] [flang] [clang-tools-extra] [libunwind] [mlir] [clang] [IRPGO][ValueProfile] Instrument virtual table address that could be used to do virtual table a

2023-12-05 Thread Mingming Liu via cfe-commits

minglotus-6 wrote:

Three tests failed on the windows build-bot 
(https://buildkite.com/llvm-project/github-pull-requests/builds/20392#018c3c8d-d4fd-41f7-b456-b1a4ded6dc61).
 Two (Transforms/PGOProfile/vtable_profile.ll and 
tools/llvm-profdata/vtable-value-prof-basic.test) of these three passed in my 
local check and one (tools/llvm-profdata/nocompress.test) turns out not 
supported (`requires !zlib`) in my local build

I added `require zlib` for the first two, and updated the 3rd test under 
`-DLLVM_ENABLE_ZLIB=0`. 

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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Bill Wendling via cfe-commits

bwendling wrote:

Okay. I should have fixed that issue.

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


[clang] [libc] [llvm] [clang-tools-extra] [compiler-rt] [flang] [clang] Exclude non-template classes when checking if constraint refers to containing template arguments (PR #74265)

2023-12-05 Thread via cfe-commits

https://github.com/antangelo updated 
https://github.com/llvm/llvm-project/pull/74265

>From a8e841657b9816a78f6eb1520c8513454fe0008b Mon Sep 17 00:00:00 2001
From: Antonio Abbatangelo 
Date: Tue, 28 Nov 2023 21:19:13 -0500
Subject: [PATCH 1/2] [clang] Exclude non-template classes when checking if
 constraint refers to containing template arguments

---
 clang/docs/ReleaseNotes.rst |  3 +++
 clang/lib/Sema/SemaTemplate.cpp |  2 ++
 clang/test/SemaTemplate/GH71595.cpp | 34 +
 3 files changed, 39 insertions(+)
 create mode 100644 clang/test/SemaTemplate/GH71595.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c7a948fd3fae5..852b908dd1594 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -651,6 +651,9 @@ Bug Fixes in This Version
 - Fixed false positive error emitted by clang when performing qualified name
   lookup and the current class instantiation has dependent bases.
   Fixes (`#13826 `_)
+- Fix a ``clang-17`` regression where a templated friend with constraints is 
not 
+  properly applied when its parameters reference an enclosing non-template 
class.
+  Fixes (`#71595 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 09bbf14d39af5..aec802b289a2d 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1714,6 +1714,8 @@ class ConstraintRefersToContainingTemplateChecker
   // Friend, likely because it was referred to without its template arguments.
   void CheckIfContainingRecord(const CXXRecordDecl *CheckingRD) {
 CheckingRD = CheckingRD->getMostRecentDecl();
+if (!CheckingRD->isTemplated())
+  return;
 
 for (const DeclContext *DC = Friend->getLexicalDeclContext();
  DC && !DC->isFileContext(); DC = DC->getParent())
diff --git a/clang/test/SemaTemplate/GH71595.cpp 
b/clang/test/SemaTemplate/GH71595.cpp
new file mode 100644
index 0..7d34d1bf054e4
--- /dev/null
+++ b/clang/test/SemaTemplate/GH71595.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template
+concept C = true;
+
+class non_temp {
+template T>
+friend void f();
+
+non_temp();
+};
+
+template T>
+void f() {
+auto v = non_temp();
+}
+
+template
+class temp {
+template T>
+friend void g();
+
+temp(); // expected-note {{implicitly declared private here}}
+};
+
+template> T>
+void g() {
+auto v = temp(); // expected-error {{calling a private constructor of 
class 'temp'}}
+}
+
+void h() {
+f();
+g(); // expected-note {{in instantiation of function template 
specialization 'g' requested here}}
+}

>From 7c27cd73781b64855b652ff18cd0fc3a0fb3dfac Mon Sep 17 00:00:00 2001
From: Antonio Abbatangelo 
Date: Sun, 3 Dec 2023 20:22:31 -0500
Subject: [PATCH 2/2] Fix trailing whitespace in release notes

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 852b908dd1594..b7ebd17051be4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -651,7 +651,7 @@ Bug Fixes in This Version
 - Fixed false positive error emitted by clang when performing qualified name
   lookup and the current class instantiation has dependent bases.
   Fixes (`#13826 `_)
-- Fix a ``clang-17`` regression where a templated friend with constraints is 
not 
+- Fix a ``clang-17`` regression where a templated friend with constraints is 
not
   properly applied when its parameters reference an enclosing non-template 
class.
   Fixes (`#71595 `_)
 

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2023-12-05 Thread via cfe-commits

cor3ntin wrote:

Can you add a release note indicating 
https://github.com/llvm/llvm-project/issues/74016 was fixed?
Otherwise LGTM.

If you wanted to make a follow up {R to rename `isPure` to `isPureVirtual`, i 
think that might be helpful (to avoid confusion with the `gnu::pure` attribute)

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


[llvm] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-05 Thread Mingming Liu via cfe-commits

minglotus-6 wrote:

Using the same added ICP test,  profile matching on local-linkage 
`_ZL7callee0v` using `clang++ -v -fuse-ld=lld -O2 
-fprofile-use=thinlto_icall_prom.profdata ` , as 
[this](https://gist.github.com/minglotus-6/11817ba645c6b12cd7116f41bfb1185e) 
pgo-instr-use output shows.

However, when trying to follow the counter matching [code 
path](https://github.com/llvm/llvm-project/blob/df7545e4be5cb65ef3ddd278119c0b8b2f37b0ec/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp#L1337),
 I came across another 
place(https://github.com/llvm/llvm-project/blob/df7545e4be5cb65ef3ddd278119c0b8b2f37b0ec/llvm/lib/ProfileData/InstrProfReader.cpp#L1019)
 that might have something to do with colon/semicolon delimiter inside itanium 
remapper 
(https://github.com/llvm/llvm-project/blob/df7545e4be5cb65ef3ddd278119c0b8b2f37b0ec/llvm/lib/ProfileData/InstrProfReader.cpp#L1055).
 I'm wondering if this needs an update (with updated regression test)? 
@david-xl @xur-llvm who might have more context.


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


[mlir] [flang] [llvm] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [mlir] Fix a zero stride canonicalizer crash (PR #74200)

2023-12-05 Thread Rik Huijzer via cfe-commits

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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Bill Wendling via cfe-commits

bwendling wrote:

Could you add the .c and .sh files? I'll try to recreate it on my end though.

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


[llvm] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-05 Thread Mingming Liu via cfe-commits


@@ -300,12 +316,8 @@ getIRPGONameForGlobalObject(const GlobalObject ,
 GlobalValue::LinkageTypes Linkage,
 StringRef FileName) {
   SmallString<64> Name;
-  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
-Name.append(FileName.empty() ? "" : FileName);
-Name.append(";");
-  }
   Mangler().getNameWithPrefix(Name, , /*CannotUsePrivateLabel=*/true);

minglotus-6 wrote:

Thanks for giving the thumb-up Ellis! Just created 
https://github.com/llvm/llvm-project/issues/74565. 

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


[clang] [Driver] Add riscv64-suse-linux triple (PR #74513)

2023-12-05 Thread Fangrui Song via cfe-commits

MaskRay wrote:

Sorry for causing you trouble but I think removing special cases from these 
`static const char *const XXXTriples[]` is intentional and we shall not add 
special cases for vendors. See 
https://github.com/llvm/llvm-project/issues/72256#issuecomment-1842148887

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


[clang] [clang] Strict aliasing warning ala GCC [PR50066] (PR #74155)

2023-12-05 Thread Fangrui Song via cfe-commits

MaskRay wrote:

Add @shafik who authors 
https://gist.github.com/shafik/848ae25ee209f698763cffee272a58f8 ("Although 
clang allows these flags it apparently does not actually implement the 
warnings")

> [*] I implemented what turned into GCC's level=1 way back when.

Cool!

FWIW the GCC doc is 
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wstrict-aliasing_003dn
It says for Level 3 "If optimization is enabled, it also runs in the back end, 
where it deals with multiple statement cases using flow-sensitive points-to 
information."

Do you know how it works? Any example?


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


[clang] [clang] Strict aliasing warning ala GCC [PR50066] (PR #74155)

2023-12-05 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,192 @@
+// RUN: %clang_cc1 %s -O0 -Wstrict-aliasing -S -o %t -verify=quiet
+// RUN: %clang_cc1 %s -O2 -Wstrict-aliasing=0 -S -o %t -verify=quiet
+// RUN: %clang_cc1 %s -O2 -Wno-strict-aliasing -S -o %t -verify=quiet
+// RUN: %clang_cc1 %s -O2 -Wstrict-aliasing=1 -S -o %t 
-verify=level1,level12,level123
+// RUN: %clang_cc1 %s -O2 -Wstrict-aliasing=2 -S -o %t 
-verify=level2,level23,level12,level123
+// RUN: %clang_cc1 %s -O2 -Wstrict-aliasing=3 -S -o %t -verify=level23,level123
+// RUN: %clang_cc1 %s -O2 -Wstrict-aliasing -S -o %t -verify=level23,level123
+// RUN: %clang_cc1 %s -O2 -S -o %t -verify=level23,level123
+
+// quiet-no-diagnostics
+
+#if _LP64
+// These names make more sense on an ilp32 machine
+typedef long INT;
+typedef long long LONG;
+typedef unsigned long UINT;
+#else
+typedef int INT;
+typedef long LONG;
+typedef unsigned int UINT;
+#endif
+typedef short SHORT;
+
+INT ScalarINT;
+INT Ary[2];
+struct {int m;} Struct;
+
+_Complex int CPLx;
+
+void ByVal(long long);
+void ByPtr(void *);
+
+void VarPtr(INT *Ptr) {
+  // GCC: 1
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByPtr((LONG *)(Ptr));
+  // level1-note@-1{{not alias compatible}}
+
+  // GCC:
+  ByPtr((LONG *)((void *)(Ptr)));
+
+  // GCC: 1
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)(Ptr));
+  // level1-note@-1{{not alias compatible}}
+}
+
+void Object() {
+  // GCC: 1, 2
+  // level2-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByPtr((LONG *)());
+  // level12-note@-1{{not alias compatible}}
+
+  // GCC:
+  ByPtr((LONG *)((void *)()));
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)());
+  // level123-note@-1{{not alias compatible}}
+}
+
+// Level 1, 2, 3 - 1, 2, 3
+void DetectedVariants() {
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)([1]));
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)());
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)(&()->m));
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)(&__real__(CPLx)));
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*(LONG *)(&__imag__(CPLx)));
+  // level123-note@-1{{not alias compatible}}
+}
+
+void Ok() {
+  // GCC:
+  ByPtr((UINT *)());
+  // GCC:
+  ByPtr((UINT *)((void *)()));
+  // GCC:
+  ByVal(*(UINT *)());
+}
+
+// Level 1, 2, 3 - 1, 2, 3
+void Parens() {
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*((LONG *)((&(ScalarINT);
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ByVal(*((LONG *)((&(Ary[1]);
+  // level123-note@-1{{not alias compatible}}
+}
+
+// Clang models may_alias as a decl attribute, not a type attribute.
+
+typedef int MA __attribute__((may_alias));
+
+void Frob(MA *a) {
+  ByPtr((short *)(a));
+  ByVal(*(short *)(a));
+}
+
+struct Inner { int m; };
+struct Outer1 { struct Inner i; };
+struct Outer2 { struct Outer1 o; };
+struct Inner i;
+struct Outer2 o;
+
+void ByValInner (struct Inner);
+void ByValOuter2 (struct Outer2);
+
+void Inherit() {
+  // Check we see through multiple levels
+  int in;
+
+  ByValOuter2(*(struct Outer2 *));
+  ByValOuter2(*(struct Outer2 *));
+  ByValInner(*(struct Inner *));
+  ByValInner(*(struct Inner *));
+  ByVal(*(int *));
+}
+
+// PR 50066
+typedef unsigned char uchar;
+
+void Double(double);
+
+int main() {
+  double d = 2.34;
+  int i[2];
+  Double(d);
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  *(long long *)i =
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  *(long long *)
+  // level123-note@-1{{not alias compatible}}
+
+  // GCC: 1, 2, 3
+  // level23-warning@+2{{type-punned pointer breaks}}
+  // level1-warning@+1{{type-punned pointer might break}}
+  ((int *))[0] = i[0];
+  // level123-note@-1{{not 

[clang] [clang] Add separate C++23 extension flag for attrs on lambda (PR #74553)

2023-12-05 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 updated https://github.com/llvm/llvm-project/pull/74553

>From 9be87da42e48895cf23d90a3ed735b7a36b1ccb3 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 6 Dec 2023 04:51:45 +0100
Subject: [PATCH 1/2] [clang] Add separate C++23 extension flag for attrs on
 lambda

---
 clang/include/clang/Basic/DiagnosticGroups.td   |  4 +++-
 clang/include/clang/Basic/DiagnosticParseKinds.td   |  2 +-
 clang/test/SemaCXX/coro-lifetimebound.cpp   | 10 ++
 clang/test/SemaCXX/coro-return-type-and-wrapper.cpp |  9 ++---
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf7426..81443fb16a1f3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1126,6 +1126,8 @@ def FutureAttrs : 
DiagGroup<"future-attribute-extensions", [CXX14Attrs,
 CXX17Attrs,
 CXX20Attrs]>;
 
+def CXX23AttrsOnLambda : DiagGroup<"c++23-attrs-on-lambda">;
+
 // A warning group for warnings about using C++11 features as extensions in
 // earlier C++ versions.
 def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, 
CXX11InlineNamespace,
@@ -1145,7 +1147,7 @@ def CXX20 : DiagGroup<"c++20-extensions", 
[CXX20Designator, CXX20Attrs]>;
 
 // A warning group for warnings about using C++23 features as extensions in
 // earlier C++ versions.
-def CXX23 : DiagGroup<"c++23-extensions">;
+def CXX23 : DiagGroup<"c++23-extensions", [CXX23AttrsOnLambda]>;
 
 // A warning group for warnings about using C++26 features as extensions in
 // earlier C++ versions.
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 21fe6066d5876..bc7bd7589ef14 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1035,7 +1035,7 @@ def err_capture_default_first : Error<
   "capture default must be first">;
 def ext_decl_attrs_on_lambda : ExtWarn<
   "%select{an attribute specifier sequence|%0}1 in this position "
-  "is a C++23 extension">, InGroup;
+  "is a C++23 extension">, InGroup;
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
diff --git a/clang/test/SemaCXX/coro-lifetimebound.cpp 
b/clang/test/SemaCXX/coro-lifetimebound.cpp
index d3e2d673ebb3c..ec8997036feb4 100644
--- a/clang/test/SemaCXX/coro-lifetimebound.cpp
+++ b/clang/test/SemaCXX/coro-lifetimebound.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-error=unreachable-code -Wno-unused
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-error=unreachable-code -Wno-unused 
-Wno-c++23-attrs-on-lambda
 
 #include "Inputs/std-coroutine.h"
 
@@ -64,14 +64,8 @@ Co bar_coro(const int , int c) {
   : bar_coro(0, 1); // expected-warning {{returning address of local 
temporary object}}
 }
 
-#define CORO_WRAPPER \
-  _Pragma("clang diagnostic push") \
-  _Pragma("clang diagnostic ignored \"-Wc++23-extensions\"") \
-  [[clang::coro_wrapper]] \
-  _Pragma("clang diagnostic pop")
-
 void lambdas() {
-  auto unsafe_lambda = [] CORO_WRAPPER (int b) {
+  auto unsafe_lambda = [] [[clang::coro_wrapper]] (int b) {
 return foo_coro(b); // expected-warning {{address of stack memory 
associated with parameter}}
   };
   auto coro_lambda = [] (const int&) -> Co {
diff --git a/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp 
b/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
index 5f8076f1c782a..d52d1e4cea399 100644
--- a/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
+++ b/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-c++23-attrs-on-lambda
 #include "Inputs/std-coroutine.h"
 
 using std::suspend_always;
@@ -45,11 +45,6 @@ Co non_marked_wrapper(int b) { return foo_coro(b); }
 } // namespace using_decl
 
 namespace lambdas {
-#define CORO_WRAPPER \
-  _Pragma("clang diagnostic push") \
-  _Pragma("clang diagnostic ignored \"-Wc++23-extensions\"") \
-  [[clang::coro_wrapper]] \
-  _Pragma("clang diagnostic pop")
 
 void foo() {
   auto coro_lambda = []() -> Gen {
@@ -59,7 +54,7 @@ void foo() {
   auto not_allowed_wrapper = []() -> Gen {
 return foo_coro(1);
   };
-  auto allowed_wrapper = [] CORO_WRAPPER() -> Gen {
+  auto allowed_wrapper = [] [[clang::coro_wrapper]] () -> Gen {
 return foo_coro(1);
   };
 }

>From 14532988c00fc0ce6530a05a899abbc3976bd374 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 6 Dec 2023 

[clang] [clang] Add separate C++23 extension flag for attrs on lambda (PR #74553)

2023-12-05 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Utkarsh Saxena (usx95)


Changes



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


4 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticGroups.td (+3-1) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+1-1) 
- (modified) clang/test/SemaCXX/coro-lifetimebound.cpp (+2-8) 
- (modified) clang/test/SemaCXX/coro-return-type-and-wrapper.cpp (+2-7) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf7426..81443fb16a1f3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1126,6 +1126,8 @@ def FutureAttrs : 
DiagGroup<"future-attribute-extensions", [CXX14Attrs,
 CXX17Attrs,
 CXX20Attrs]>;
 
+def CXX23AttrsOnLambda : DiagGroup<"c++23-attrs-on-lambda">;
+
 // A warning group for warnings about using C++11 features as extensions in
 // earlier C++ versions.
 def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, 
CXX11InlineNamespace,
@@ -1145,7 +1147,7 @@ def CXX20 : DiagGroup<"c++20-extensions", 
[CXX20Designator, CXX20Attrs]>;
 
 // A warning group for warnings about using C++23 features as extensions in
 // earlier C++ versions.
-def CXX23 : DiagGroup<"c++23-extensions">;
+def CXX23 : DiagGroup<"c++23-extensions", [CXX23AttrsOnLambda]>;
 
 // A warning group for warnings about using C++26 features as extensions in
 // earlier C++ versions.
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 21fe6066d5876..bc7bd7589ef14 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1035,7 +1035,7 @@ def err_capture_default_first : Error<
   "capture default must be first">;
 def ext_decl_attrs_on_lambda : ExtWarn<
   "%select{an attribute specifier sequence|%0}1 in this position "
-  "is a C++23 extension">, InGroup;
+  "is a C++23 extension">, InGroup;
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
diff --git a/clang/test/SemaCXX/coro-lifetimebound.cpp 
b/clang/test/SemaCXX/coro-lifetimebound.cpp
index d3e2d673ebb3c..ec8997036feb4 100644
--- a/clang/test/SemaCXX/coro-lifetimebound.cpp
+++ b/clang/test/SemaCXX/coro-lifetimebound.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-error=unreachable-code -Wno-unused
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-error=unreachable-code -Wno-unused 
-Wno-c++23-attrs-on-lambda
 
 #include "Inputs/std-coroutine.h"
 
@@ -64,14 +64,8 @@ Co bar_coro(const int , int c) {
   : bar_coro(0, 1); // expected-warning {{returning address of local 
temporary object}}
 }
 
-#define CORO_WRAPPER \
-  _Pragma("clang diagnostic push") \
-  _Pragma("clang diagnostic ignored \"-Wc++23-extensions\"") \
-  [[clang::coro_wrapper]] \
-  _Pragma("clang diagnostic pop")
-
 void lambdas() {
-  auto unsafe_lambda = [] CORO_WRAPPER (int b) {
+  auto unsafe_lambda = [] [[clang::coro_wrapper]] (int b) {
 return foo_coro(b); // expected-warning {{address of stack memory 
associated with parameter}}
   };
   auto coro_lambda = [] (const int&) -> Co {
diff --git a/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp 
b/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
index 5f8076f1c782a..d52d1e4cea399 100644
--- a/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
+++ b/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-c++23-attrs-on-lambda
 #include "Inputs/std-coroutine.h"
 
 using std::suspend_always;
@@ -45,11 +45,6 @@ Co non_marked_wrapper(int b) { return foo_coro(b); }
 } // namespace using_decl
 
 namespace lambdas {
-#define CORO_WRAPPER \
-  _Pragma("clang diagnostic push") \
-  _Pragma("clang diagnostic ignored \"-Wc++23-extensions\"") \
-  [[clang::coro_wrapper]] \
-  _Pragma("clang diagnostic pop")
 
 void foo() {
   auto coro_lambda = []() -> Gen {
@@ -59,7 +54,7 @@ void foo() {
   auto not_allowed_wrapper = []() -> Gen {
 return foo_coro(1);
   };
-  auto allowed_wrapper = [] CORO_WRAPPER() -> Gen {
+  auto allowed_wrapper = [] [[clang::coro_wrapper]] () -> Gen {
 return foo_coro(1);
   };
 }

``




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


[llvm] [clang-tools-extra] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Fangrui Song via cfe-commits


@@ -1,14 +1,49 @@
-; RUN: llvm-as < %s -o - | llc -filetype=asm | FileCheck %s
+; RUN: llc -filetype=asm -mtriple=x86_64-unknown-linux-gnu %s -o - | FileCheck 
%s --check-prefixes=ELF

MaskRay wrote:

omit `-filetype=asm`

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


[clang] [clang] Add separate C++23 extension flag for attrs on lambda (PR #74553)

2023-12-05 Thread Utkarsh Saxena via cfe-commits

https://github.com/usx95 created https://github.com/llvm/llvm-project/pull/74553

None

>From 9be87da42e48895cf23d90a3ed735b7a36b1ccb3 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 6 Dec 2023 04:51:45 +0100
Subject: [PATCH] [clang] Add separate C++23 extension flag for attrs on lambda

---
 clang/include/clang/Basic/DiagnosticGroups.td   |  4 +++-
 clang/include/clang/Basic/DiagnosticParseKinds.td   |  2 +-
 clang/test/SemaCXX/coro-lifetimebound.cpp   | 10 ++
 clang/test/SemaCXX/coro-return-type-and-wrapper.cpp |  9 ++---
 4 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff028bbbf7426..81443fb16a1f3 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1126,6 +1126,8 @@ def FutureAttrs : 
DiagGroup<"future-attribute-extensions", [CXX14Attrs,
 CXX17Attrs,
 CXX20Attrs]>;
 
+def CXX23AttrsOnLambda : DiagGroup<"c++23-attrs-on-lambda">;
+
 // A warning group for warnings about using C++11 features as extensions in
 // earlier C++ versions.
 def CXX11 : DiagGroup<"c++11-extensions", [CXX11ExtraSemi, 
CXX11InlineNamespace,
@@ -1145,7 +1147,7 @@ def CXX20 : DiagGroup<"c++20-extensions", 
[CXX20Designator, CXX20Attrs]>;
 
 // A warning group for warnings about using C++23 features as extensions in
 // earlier C++ versions.
-def CXX23 : DiagGroup<"c++23-extensions">;
+def CXX23 : DiagGroup<"c++23-extensions", [CXX23AttrsOnLambda]>;
 
 // A warning group for warnings about using C++26 features as extensions in
 // earlier C++ versions.
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 21fe6066d5876..bc7bd7589ef14 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1035,7 +1035,7 @@ def err_capture_default_first : Error<
   "capture default must be first">;
 def ext_decl_attrs_on_lambda : ExtWarn<
   "%select{an attribute specifier sequence|%0}1 in this position "
-  "is a C++23 extension">, InGroup;
+  "is a C++23 extension">, InGroup;
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
diff --git a/clang/test/SemaCXX/coro-lifetimebound.cpp 
b/clang/test/SemaCXX/coro-lifetimebound.cpp
index d3e2d673ebb3c..ec8997036feb4 100644
--- a/clang/test/SemaCXX/coro-lifetimebound.cpp
+++ b/clang/test/SemaCXX/coro-lifetimebound.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-error=unreachable-code -Wno-unused
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-error=unreachable-code -Wno-unused 
-Wno-c++23-attrs-on-lambda
 
 #include "Inputs/std-coroutine.h"
 
@@ -64,14 +64,8 @@ Co bar_coro(const int , int c) {
   : bar_coro(0, 1); // expected-warning {{returning address of local 
temporary object}}
 }
 
-#define CORO_WRAPPER \
-  _Pragma("clang diagnostic push") \
-  _Pragma("clang diagnostic ignored \"-Wc++23-extensions\"") \
-  [[clang::coro_wrapper]] \
-  _Pragma("clang diagnostic pop")
-
 void lambdas() {
-  auto unsafe_lambda = [] CORO_WRAPPER (int b) {
+  auto unsafe_lambda = [] [[clang::coro_wrapper]] (int b) {
 return foo_coro(b); // expected-warning {{address of stack memory 
associated with parameter}}
   };
   auto coro_lambda = [] (const int&) -> Co {
diff --git a/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp 
b/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
index 5f8076f1c782a..d52d1e4cea399 100644
--- a/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
+++ b/clang/test/SemaCXX/coro-return-type-and-wrapper.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only 
-verify -Wall -Wextra -Wno-c++23-attrs-on-lambda
 #include "Inputs/std-coroutine.h"
 
 using std::suspend_always;
@@ -45,11 +45,6 @@ Co non_marked_wrapper(int b) { return foo_coro(b); }
 } // namespace using_decl
 
 namespace lambdas {
-#define CORO_WRAPPER \
-  _Pragma("clang diagnostic push") \
-  _Pragma("clang diagnostic ignored \"-Wc++23-extensions\"") \
-  [[clang::coro_wrapper]] \
-  _Pragma("clang diagnostic pop")
 
 void foo() {
   auto coro_lambda = []() -> Gen {
@@ -59,7 +54,7 @@ void foo() {
   auto not_allowed_wrapper = []() -> Gen {
 return foo_coro(1);
   };
-  auto allowed_wrapper = [] CORO_WRAPPER() -> Gen {
+  auto allowed_wrapper = [] [[clang::coro_wrapper]] () -> Gen {
 return foo_coro(1);
   };
 }

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang-tools-extra] [llvm] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Fangrui Song via cfe-commits


@@ -0,0 +1,72 @@
+; RUN: llc -mtriple=arm64-unknown-linux-gnu %s -filetype=asm -o - | FileCheck 
%s --check-prefixes=ELF

MaskRay wrote:

Omit `-filetype=asm` (convention).

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


[clang-tools-extra] [llvm] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Fangrui Song via cfe-commits


@@ -1809,6 +1814,255 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
+void AArch64AsmPrinter::emitGlobalIFunc(Module , const GlobalIFunc ) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);
+
+  // On Darwin platforms, emit a manually-constructed .symbol_resolver that
+  // implements the symbol resolution duties of the IFunc.
+  //
+  // Normally, this would be handled by linker magic, but unfortunately there
+  // are a few limitations in ld64 and ld-prime's implementation of
+  // .symbol_resolver that mean we can't always use them:
+  //
+  //*  resolvers cannot be the target of an alias
+  //*  resolvers cannot have private linkage
+  //*  resolvers cannot have linkonce linkage
+  //*  resolvers cannot appear in executables
+  //*  resolvers cannot appear in bundles
+  //
+  // This works around that by emitting a close approximation of what the 
linker
+  // would have done.
+
+  auto EmitLinkage = [&](MCSymbol *Sym) {
+if (GI.hasExternalLinkage() || !MAI->getWeakRefDirective())

MaskRay wrote:

`MAI->getWeakRefDirective()` is always true for Mach-O.

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


[flang] [mlir] [llvm] [compiler-rt] [libcxx] [clang-tools-extra] [clang] [libc] [mlir][gpu] Support dynamic_shared_memory Op with vector dialect (PR #74475)

2023-12-05 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph approved this pull request.


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


[clang] ANDROID: AArch64: Change default max-page-size from 4k to 16k (PR #70251)

2023-12-05 Thread via cfe-commits

pirama-arumuga-nainar wrote:

cc: @nico

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


[clang-tools-extra] [clang] [llvm] [XCOFF][obj2yaml] support parsing auxiliary symbols for XCOFF (PR #70642)

2023-12-05 Thread via cfe-commits


@@ -106,6 +126,210 @@ Error XCOFFDumper::dumpSections(ArrayRef Sections) {
   return Error::success();
 }
 
+Error XCOFFDumper::dumpFileAuxSym(XCOFFYAML::Symbol ,
+  const XCOFFSymbolRef ) {
+  for (uint8_t I = 1; I <= Sym.NumberOfAuxEntries; ++I) {
+uintptr_t AuxAddress = XCOFFObjectFile::getAdvancedSymbolEntryAddress(
+SymbolEntRef.getEntryAddress(), I);
+const XCOFFFileAuxEnt *FileAuxEntPtr =
+getAuxEntPtr(AuxAddress);
+auto FileNameOrError = Obj.getCFileName(FileAuxEntPtr);
+if (!FileNameOrError)
+  return FileNameOrError.takeError();
+
+XCOFFYAML::FileAuxEnt FileAuxSym;
+FileAuxSym.FileNameOrString = FileNameOrError.get();
+FileAuxSym.FileStringType = FileAuxEntPtr->Type;
+Sym.AuxEntries.push_back(

EsmeYi wrote:

Thanks!
The aux type is not in the XCOFF32 object, but it is needed in YAML to help 
yaml2obj create the identical object.

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


[compiler-rt] [clang] [llvm] [flang] [libc] [clang-tools-extra] [clang-format] Add "three dot" diff option to git-clang-format (PR #74230)

2023-12-05 Thread Aiden Grossman via cfe-commits

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


[clang] aeaae53 - [clang-format] Add "three dot" diff option to git-clang-format (#74230)

2023-12-05 Thread via cfe-commits

Author: Aiden Grossman
Date: 2023-12-05T19:19:21-08:00
New Revision: aeaae5311b8d4bbcfe7ef5cff722ea36b038c0ad

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

LOG: [clang-format] Add "three dot" diff option to git-clang-format (#74230)

This patch adds in the ability to do a "three dot" git-clang-format
between two commits. This looks at the diff between the second commit
and the common merge base rather than comparing at the point of the
specified commits. This is needed to improve the reliability of the LLVM
code formatting CI action which currently breaks in some cases where
files have been modified in the upstream tree and when the person
created their branch, leaving phantom formatting diffs that weren't
touched by the PR author.

Part of a fix for #73873

Added: 


Modified: 
clang/tools/clang-format/git-clang-format

Removed: 




diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index f7b25b7deae2b..d33fd478d77fd 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -132,6 +132,10 @@ def main():
  help='passed to clang-format'),
   p.add_argument('-v', '--verbose', action='count', default=0,
  help='print extra information')
+  p.add_argument('--
diff _from_common_commit', action='store_true',
+ help=('
diff  from the last common commit for commits in '
+  'separate branches rather than the exact point of the '
+  'commits'))
   # We gather all the remaining positional arguments into 'args' since we need
   # to use some heuristics to determine whether or not  was present.
   # However, to print pretty messages, we make use of metavar and help.
@@ -145,19 +149,23 @@ def main():
   del opts.quiet
 
   commits, files = interpret_args(opts.args, dash_dash, opts.commit)
-  if len(commits) > 1:
+  if len(commits) > 2:
+die('at most two commits allowed; %d given' % len(commits))
+  if len(commits) == 2:
 if opts.staged:
   die('--staged is not allowed when two commits are given')
 if not opts.
diff :
   die('--
diff  is required when two commits are given')
-  else:
-if len(commits) > 2:
-  die('at most two commits allowed; %d given' % len(commits))
+  elif opts.
diff _from_common_commit:
+die('--
diff _from_common_commit is only allowed when two commits are given')
 
   if os.path.dirname(opts.binary):
 opts.binary = os.path.abspath(opts.binary)
 
-  changed_lines = compute_
diff _and_extract_lines(commits, files, opts.staged)
+  changed_lines = compute_
diff _and_extract_lines(commits,
+ files,
+ opts.staged,
+ opts.
diff _from_common_commit)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -305,9 +313,9 @@ def get_object_type(value):
   return convert_string(stdout.strip())
 
 
-def compute_
diff _and_extract_lines(commits, files, staged):
+def compute_
diff _and_extract_lines(commits, files, staged, 
diff _common_commit):
   """Calls compute_
diff () followed by extract_lines()."""
-  
diff _process = compute_
diff (commits, files, staged)
+  
diff _process = compute_
diff (commits, files, staged, 
diff _common_commit)
   changed_lines = extract_lines(
diff _process.stdout)
   
diff _process.stdout.close()
   
diff _process.wait()
@@ -317,7 +325,7 @@ def compute_
diff _and_extract_lines(commits, files, staged):
   return changed_lines
 
 
-def compute_
diff (commits, files, staged):
+def compute_
diff (commits, files, staged, 
diff _common_commit):
   """Return a subprocess object producing the 
diff  from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
@@ -327,10 +335,13 @@ def compute_
diff (commits, files, staged):
   Zero context lines are used in the patch."""
   git_tool = '
diff -index'
   extra_args = []
-  if len(commits) > 1:
+  if len(commits) == 2:
 git_tool = '
diff -tree'
+if 
diff _common_commit:
+  commits = [f'{commits[0]}...{commits[1]}']
   elif staged:
 extra_args += ['--cached']
+
   cmd = ['git', git_tool, '-p', '-U0'] + extra_args + commits + ['--']
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)



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


[compiler-rt] [lld] [openmp] [libcxx] [mlir] [clang] [lldb] [llvm] [flang] [libc] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Mehdi Amini via cfe-commits

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


[compiler-rt] [lld] [openmp] [libcxx] [mlir] [clang] [lldb] [llvm] [flang] [libc] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Mehdi Amini via cfe-commits


@@ -61,6 +63,7 @@ registerAllGPUToLLVMIRTranslations(DialectRegistry ) 
{
   registerLLVMDialectTranslation(registry);
   registerNVVMDialectTranslation(registry);
   registerROCDLDialectTranslation(registry);
+  registerSPIRVDialectTranslation(registry);

joker-eph wrote:

> The PR has been open for a while and blocking other work that depends on it. 
> Would be great if you can approve soon.

Well, we were waiting on the test that you just added today!

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


[compiler-rt] [lld] [openmp] [libcxx] [mlir] [clang] [lldb] [llvm] [flang] [libc] [clang-tools-extra] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Mehdi Amini via cfe-commits


@@ -0,0 +1,31 @@
+//===- SPIRVToLLVMIRTranslation.cpp - Translate SPIRV to LLVM IR 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a translation between the MLIR SPIRV dialect and
+// LLVM IR.
+//
+//===--===//
+
+#include "mlir/Target/LLVMIR/Dialect/SPIRV/SPIRVToLLVMIRTranslation.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/IR/BuiltinAttributes.h"
+#include "mlir/IR/Operation.h"
+#include "mlir/Target/LLVMIR/ModuleTranslation.h"
+
+using namespace mlir;
+using namespace mlir::LLVM;
+
+void mlir::registerSPIRVDialectTranslation(DialectRegistry ) {
+  registry.insert();

joker-eph wrote:

It does not make sense to me to have an API called 
"registerSPIRVDialectTranslation" that itself registers a dialect and no 
translation actually.

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


[compiler-rt] [libcxx] [mlir] [clang] [llvm] [flang] [clang-tools-extra] [mlir] Fix a zero stride canonicalizer crash (PR #74200)

2023-12-05 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph approved this pull request.

Thanks!

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


[clang] [llvm] [Sema] Implement support for -Wformat-signedness (PR #74440)

2023-12-05 Thread Yingchi Long via cfe-commits

https://github.com/inclyc commented:

Also please add release notes to let users know what has been changed :)

See: `clang/docs/ReleaseNotes.rst`

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


[clang] [llvm] [Sema] Implement support for -Wformat-signedness (PR #74440)

2023-12-05 Thread Yingchi Long via cfe-commits


@@ -918,6 +918,9 @@ def Wdeprecated : Flag<["-"], "Wdeprecated">, 
Group,
   HelpText<"Enable warnings for deprecated constructs and define 
__DEPRECATED">;
 def Wno_deprecated : Flag<["-"], "Wno-deprecated">, Group,
   Visibility<[ClangOption, CC1Option]>;
+def Wformat_signedness : Flag<["-"], "Wformat-signedness">,

inclyc wrote:

I agree with @hazohelet 

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


[clang] [llvm] [Sema] Implement support for -Wformat-signedness (PR #74440)

2023-12-05 Thread Yingchi Long via cfe-commits


@@ -0,0 +1,107 @@
+// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify -Wformat -Wformat-signedness 
%s
+
+int printf(const char *restrict format, ...);
+int scanf(const char * restrict, ...);
+
+void test_printf_bool(_Bool x)
+{
+printf("%d", x); // no-warning
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type '_Bool'}}
+printf("%x", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type '_Bool'}}
+}
+
+void test_printf_char(char x)
+{
+printf("%c", x); // no-warning
+}
+
+void test_printf_unsigned_char(unsigned char x)
+{
+printf("%c", x); // no-warning
+}
+
+void test_printf_int(int x)
+{
+printf("%d", x); // no-warning
+printf("%u", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}
+printf("%x", x); // expected-warning{{format specifies type 'unsigned int' 
but the argument has type 'int'}}

inclyc wrote:

will this be a little pedantic?

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


[clang] [llvm] [Sema] Implement support for -Wformat-signedness (PR #74440)

2023-12-05 Thread Yingchi Long via cfe-commits


@@ -11815,6 +11815,18 @@ isArithmeticArgumentPromotion(Sema , const 
ImplicitCastExpr *ICE) {
  S.Context.getFloatingTypeOrder(From, To) < 0;
 }
 
+static clang::analyze_format_string::ArgType::MatchKind

inclyc wrote:

```suggestion
static analyze_format_string::ArgType::MatchKind
```

Maybe we can remove this namespace?

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


[clang] [llvm] [clang][RISCV] Change default abi when only have f extension but no d extension (PR #73489)

2023-12-05 Thread Fangrui Song via cfe-commits

MaskRay wrote:

> when only have f extension but no d extension

This can be simplified to "w/ f extension but w/o d extension"

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


[clang] [llvm] [clang][RISCV] Change default abi when only have f extension but no d extension (PR #73489)

2023-12-05 Thread Fangrui Song via cfe-commits

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


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


[clang] [llvm] [clang][RISCV] Change default abi when only have f extension but no d extension (PR #73489)

2023-12-05 Thread Fangrui Song via cfe-commits


@@ -1,4 +1,4 @@
-// Check target CPUs are correctly passed.
+·// Check target CPUs are correctly passed.

MaskRay wrote:

Stray `.`? Please fix

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


[clang] [clang][analyzer][NFC] Supplement comments in `evalFtell` of StreamChecker (PR #74291)

2023-12-05 Thread Ben Shi via cfe-commits

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


[clang] 4699789 - [clang][analyzer][NFC] Supplement comments in `evalFtell` of StreamChecker (#74291)

2023-12-05 Thread via cfe-commits

Author: Ben Shi
Date: 2023-12-06T10:26:30+08:00
New Revision: 4699789249e6945c46cdbecd1fee493cbe553c66

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

LOG: [clang][analyzer][NFC] Supplement comments in `evalFtell` of StreamChecker 
(#74291)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index a4799b5f762ca..925fc90e35543 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -1072,6 +1072,9 @@ void StreamChecker::evalFtell(const FnDescription *Desc, 
const CallEvent ,
   ProgramStateRef StateFailed = State->BindExpr(
   CE, C.getLocationContext(), SVB.makeIntVal(-1, 
C.getASTContext().LongTy));
 
+  // This function does not affect the stream state.
+  // Still we add success and failure state with the appropriate return value.
+  // StdLibraryFunctionsChecker can change these states (set the 'errno' 
state).
   C.addTransition(StateNotFailed);
   C.addTransition(StateFailed);
 }



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


[clang] [compiler-rt] [llvm] [clang-tools-extra] [flang] [libc] [clang-format] Add "three dot" diff option to git-clang-format (PR #74230)

2023-12-05 Thread Owen Pan via cfe-commits

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


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


[clang] 8a68671 - [Driver, AArch64] Ensure -arch logic is Darwin-specific

2023-12-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-12-05T18:10:39-08:00
New Revision: 8a686716e360157ad5726560cc5ea61be647893c

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

LOG: [Driver,AArch64] Ensure -arch logic is Darwin-specific

`-arch` is a Darwin-specific option that is ignored for other targets
and not known by GCC. It leads to an error for non-Darwin OSes for
non-AArch64 architectures. Ensure that it leads to an error for AArch64
non-Darwin OSes as well.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/arm-arch-darwin.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 1f77c98705174..097258b169244 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -57,9 +57,8 @@ std::string aarch64::getAArch64TargetCPU(const ArgList ,
   if (Triple.isArm64e())
 return "apple-a12";
 
-  // Make sure we pick the appropriate Apple CPU if -arch is used or when
-  // targetting a Darwin OS.
-  if (Args.getLastArg(options::OPT_arch) || Triple.isOSDarwin())
+  // Make sure we pick the appropriate Apple CPU when targetting a Darwin OS.
+  if (Triple.isOSDarwin())
 return Triple.getArch() == llvm::Triple::aarch64_32 ? "apple-s4"
 : "apple-a7";
 
@@ -274,7 +273,7 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 success = getAArch64ArchFeaturesFromMarch(D, A->getValue(), Args, 
Features);
   else if ((A = Args.getLastArg(options::OPT_mcpu_EQ)))
 success = getAArch64ArchFeaturesFromMcpu(D, A->getValue(), Args, Features);
-  else if (Args.hasArg(options::OPT_arch) || isCPUDeterminedByTriple(Triple))
+  else if (isCPUDeterminedByTriple(Triple))
 success = getAArch64ArchFeaturesFromMcpu(
 D, getAArch64TargetCPU(Args, Triple, A), Args, Features);
   else
@@ -287,8 +286,7 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   else if (success && (A = Args.getLastArg(options::OPT_mcpu_EQ)))
 success =
 getAArch64MicroArchFeaturesFromMcpu(D, A->getValue(), Args, Features);
-  else if (success &&
-   (Args.hasArg(options::OPT_arch) || isCPUDeterminedByTriple(Triple)))
+  else if (success && isCPUDeterminedByTriple(Triple))
 success = getAArch64MicroArchFeaturesFromMcpu(
 D, getAArch64TargetCPU(Args, Triple, A), Args, Features);
 

diff  --git a/clang/test/Driver/arm-arch-darwin.c 
b/clang/test/Driver/arm-arch-darwin.c
index c523622964738..f6d3f88a3f8d1 100644
--- a/clang/test/Driver/arm-arch-darwin.c
+++ b/clang/test/Driver/arm-arch-darwin.c
@@ -5,3 +5,6 @@
 /// -arch is unsupported for non-Darwin targets.
 // RUN: not %clang --target=armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 
2>&1 | FileCheck -check-prefix=ERR %s
 // ERR: unsupported option '-arch' for target 'armv7m'
+
+// RUN: not %clang --target=aarch64-linux-gnu -arch arm64 -### -c %s 2>&1 | 
FileCheck -check-prefix=ERR2 %s
+// ERR2: unsupported option '-arch' for target 'aarch64-linux-gnu'



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


[clang] [compiler-rt] [llvm] [clang-tools-extra] [flang] [libc] [clang-format] Add "three dot" diff option to git-clang-format (PR #74230)

2023-12-05 Thread Owen Pan via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/74230

>From ae4097b53b90e31802be0be5c8a81fb74c81efc9 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 2 Dec 2023 23:46:58 -0800
Subject: [PATCH 1/3] [clang-format] Add "three dot" diff option to
 git-clang-format

This patch adds in the ability to do a "three dot" git-clang-format
between two commits. This looks at the diff between the second commit
and the common merge base rather than comparing at the point of the
specified commits. This is needed to improve the reliability of the LLVM
code formatting CI action which currently breaks in some cases where
files have been modified in the upstream tree and when the person
created their branch, leaving phantom formatting diffs that weren't
touched by the PR author.

Part of a fix for #73873
---
 clang/tools/clang-format/git-clang-format | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 6e827e17b4ee2..4fe4671482e3f 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -132,6 +132,10 @@ def main():
  help='passed to clang-format'),
   p.add_argument('-v', '--verbose', action='count', default=0,
  help='print extra information')
+  p.add_argument('--diff_from_common_commit', action='store_true',
+ help=('diff from the last common commit for commits in '
+  'separate branches rather than the exact point of the '
+  'commits'))
   # We gather all the remaining positional arguments into 'args' since we need
   # to use some heuristics to determine whether or not  was present.
   # However, to print pretty messages, we make use of metavar and help.
@@ -154,7 +158,10 @@ def main():
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
   opts.binary=os.path.abspath(opts.binary)
-  changed_lines = compute_diff_and_extract_lines(commits, files, opts.staged)
+  changed_lines = compute_diff_and_extract_lines(commits,
+ files,
+ opts.staged,
+ opts.diff_from_common_commit)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -302,9 +309,9 @@ def get_object_type(value):
   return convert_string(stdout.strip())
 
 
-def compute_diff_and_extract_lines(commits, files, staged):
+def compute_diff_and_extract_lines(commits, files, staged, diff_common_commit):
   """Calls compute_diff() followed by extract_lines()."""
-  diff_process = compute_diff(commits, files, staged)
+  diff_process = compute_diff(commits, files, staged, diff_common_commit)
   changed_lines = extract_lines(diff_process.stdout)
   diff_process.stdout.close()
   diff_process.wait()
@@ -314,7 +321,7 @@ def compute_diff_and_extract_lines(commits, files, staged):
   return changed_lines
 
 
-def compute_diff(commits, files, staged):
+def compute_diff(commits, files, staged, diff_common_commit):
   """Return a subprocess object producing the diff from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
@@ -328,6 +335,10 @@ def compute_diff(commits, files, staged):
 git_tool = 'diff-tree'
   elif staged:
 extra_args += ['--cached']
+
+  if len(commits) > 1 and diff_common_commit:
+commits = [f'{commits[0]}...{commits[1]}']
+
   cmd = ['git', git_tool, '-p', '-U0'] + extra_args + commits + ['--']
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

>From 4584ebc58337f04290a5c753f585426c8c6f739f Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sun, 3 Dec 2023 13:08:16 -0800
Subject: [PATCH 2/3] Add early exit when flag is specified with invalid
 parameters

---
 clang/tools/clang-format/git-clang-format | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 4fe4671482e3f..51ae8739bee0e 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -157,6 +157,8 @@ def main():
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
+  if len(commits) < 2 and opts.diff_from_common_commit:
+die('--diff_from_common_commit is only allowed when two commits are given')
   opts.binary=os.path.abspath(opts.binary)
   changed_lines = compute_diff_and_extract_lines(commits,
  files,

>From a8b385070845ba20f63f1e0c6835ff9bc609548f Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Tue, 5 Dec 2023 17:42:12 -0800
Subject: [PATCH 3/3] Address reviewer feedback

---
 

[clang] 7a49c30 - [Driver,test] Remove invalid -arch for non-Darwin AArch64 OSes

2023-12-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-12-05T18:07:22-08:00
New Revision: 7a49c30b830471c39d09d71a6a617f2a7f3e711c

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

LOG: [Driver,test] Remove invalid -arch for non-Darwin AArch64 OSes

See also #74365. clang/lib/Driver/ToolChains/Arch/AArch64.cpp
inappropriately claims OPT_arch, which will be removed by the follow-up
change.

Added: 


Modified: 
clang/test/Driver/aarch64-thread-pointer.c
clang/test/Headers/arm-neon-header.c

Removed: 




diff  --git a/clang/test/Driver/aarch64-thread-pointer.c 
b/clang/test/Driver/aarch64-thread-pointer.c
index 6a5d4ba0852ed..b1c6df4ac5e5d 100644
--- a/clang/test/Driver/aarch64-thread-pointer.c
+++ b/clang/test/Driver/aarch64-thread-pointer.c
@@ -1,45 +1,45 @@
 // Test of the AArch64 values of -mtp=, checking that each one maps to
 // the right target features.
 
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a 2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL0 %s
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=el0 2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=el0 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL0 %s
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=tpidr_el0 
2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=tpidr_el0 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL0 %s
 // ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidrro-el0"
 // ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidr-el1"
 // ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidr-el2"
 // ARMv8_THREAD_POINTER_EL0-NOT: "-target-feature" "+tpidr-el3"
 
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=tpidrro_el0 
2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=tpidrro_el0 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_ROEL0 %s
 // ARMv8_THREAD_POINTER_ROEL0: "-target-feature" "+tpidrro-el0"
 // ARMv8_THREAD_POINTER_ROEL0-NOT: "-target-feature" "+tpidr-el1"
 // ARMv8_THREAD_POINTER_ROEL0-NOT: "-target-feature" "+tpidr-el2"
 // ARMv8_THREAD_POINTER_ROEL0-NOT: "-target-feature" "+tpidr-el3"
 
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=el1 2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=el1 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL1 %s
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=tpidr_el1 
2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=tpidr_el1 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL1 %s
 // ARMv8_THREAD_POINTER_EL1-NOT: "-target-feature" "+tpidrro-el0"
 // ARMv8_THREAD_POINTER_EL1: "-target-feature" "+tpidr-el1"
 // ARMv8_THREAD_POINTER_EL1-NOT: "-target-feature" "+tpidr-el2"
 // ARMv8_THREAD_POINTER_EL1-NOT: "-target-feature" "+tpidr-el3"
 
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=el2 2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=el2 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL2 %s
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=tpidr_el2 
2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=tpidr_el2 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL2 %s
 // ARMv8_THREAD_POINTER_EL2-NOT: "-target-feature" "+tpidrro-el0"
 // ARMv8_THREAD_POINTER_EL2-NOT: "-target-feature" "+tpidr-el1"
 // ARMv8_THREAD_POINTER_EL2: "-target-feature" "+tpidr-el2"
 // ARMv8_THREAD_POINTER_EL2-NOT: "-target-feature" "+tpidr-el3"
 
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=el3 2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=el3 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL3 %s
-// RUN: %clang --target=aarch64-linux -### -S %s -arch armv8a -mtp=tpidr_el3 
2>&1 | \
+// RUN: %clang --target=aarch64-linux -### -S %s -mtp=tpidr_el3 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv8_THREAD_POINTER_EL3 %s
 // ARMv8_THREAD_POINTER_EL3-NOT: "-target-feature" "+tpidrro-el0"
 // ARMv8_THREAD_POINTER_EL3-NOT: "-target-feature" "+tpidr-el1"

diff  --git a/clang/test/Headers/arm-neon-header.c 
b/clang/test/Headers/arm-neon-header.c
index 7e98d03dfc191..89bd5aaa25420 100644
--- a/clang/test/Headers/arm-neon-header.c
+++ b/clang/test/Headers/arm-neon-header.c
@@ -22,7 +22,7 @@
 
 // RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64-none-elf -march=armv8.2-a+fp16fml+crypto+dotprod -std=c11 -xc 
--sysroot=%S/Inputs -flax-vector-conversions=none %s
 // RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding 
--target=aarch64_be-none-elf 

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Nathan Chancellor via cfe-commits

nathanchance wrote:

For what it's worth, I see a new crash on the latest version of this PR, in 
case it is not known.

```
$ make -skj"$(nproc)" ARCH=arm64 LLVM=1 mrproper allmodconfig 
net/ipv4/udp_tunnel_nic.o
clang: /home/nathan/cbl/src/llvm-project/llvm/lib/IR/Instructions.cpp:3342: 
static CastInst *llvm::CastInst::Create(Instruction::CastOps, Value *, Type *, 
const Twine &, Instruction *): Assertion `castIsValid(op, S, Ty) && "Invalid 
cast!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: /mnt/nvme/tmp/build/llvm-bisect/final/bin/clang 
--target=aarch64-linux-gnu -fintegrated-as -Werror=unknown-warning-option 
-Werror=ignored-optimization-argument -Werror=option-ignored 
-Werror=unused-command-line-argument -mlittle-endian -fmacro-prefix-map== 
-std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE 
-fno-strict-aliasing -mgeneral-regs-only -Wno-psabi 
-fasynchronous-unwind-tables -mbranch-protection=pac-ret+bti -ffixed-x18 
-fno-delete-null-pointer-checks -O2 -fstack-protector-strong 
-fno-omit-frame-pointer -fno-optimize-sibling-calls 
-ftrivial-auto-var-init=pattern -fno-stack-clash-protection 
-fzero-call-used-regs=used-gpr -fpatchable-function-entry=2 -fsanitize=kcfi 
-falign-functions=64 -fstrict-flex-arrays=3 -fno-strict-overflow 
-fno-stack-check -Wall -Wundef -Werror=implicit-function-declaration 
-Werror=implicit-int -Werror=return-type -Werror=strict-prototypes 
-Wno-format-security -Wno-trigraphs -Wno-frame-address 
-Wno-address-of-packed-member -Wframe-larger-than=2048 -Wno-gnu 
-Wno-unused-but-set-variable -Wno-unused-const-variable -Wvla -Wno-pointer-sign 
-Wcast-function-type -Wimplicit-fallthrough -Werror=date-time 
-Werror=incompatible-pointer-types -Wenum-conversion 
-Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-format-overflow 
-Wno-format-truncation -Wno-pointer-to-enum-cast 
-Wno-tautological-constant-out-of-range-compare -Wno-unaligned-access 
-Wno-cast-function-type-strict -Wno-missing-field-initializers -Wno-type-limits 
-Wno-shift-negative-value -Wno-initializer-overrides -Wno-sign-compare 
-frandomize-layout-seed-file=./scripts/basic/randstruct.seed 
-mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 
-mstack-protector-guard-offset=10432 -fsanitize=array-bounds -fsanitize=shift 
-fsanitize=unreachable -fsanitize=bool -fsanitize=enum 
-fsanitize-coverage=trace-pc -fsanitize-coverage=trace-cmp -fsanitize=thread 
-fno-optimize-sibling-calls -mllvm -tsan-compound-read-before-write=1 -mllvm 
-tsan-distinguish-volatile=1 -Werror -Wa,-march=armv8.5-a -nostdinc 
-Iarch/arm64/include -I./arch/arm64/include/generated -Iinclude -I./include 
-Iarch/arm64/include/uapi -I./arch/arm64/include/generated/uapi -Iinclude/uapi 
-I./include/generated/uapi -include include/linux/compiler-version.h -include 
include/linux/kconfig.h -include include/linux/compiler_types.h -D__KERNEL__ 
-DCC_USING_PATCHABLE_FUNCTION_ENTRY -DKASAN_SHADOW_SCALE_SHIFT= 
-DCONFIG_CC_HAS_K_CONSTRAINT=1 -DARM64_ASM_ARCH=\"armv8.5-a\" 
-DKASAN_SHADOW_SCALE_SHIFT= -DRANDSTRUCT -I net/ipv4 -I ./net/ipv4 -DMODULE 
-DKBUILD_BASENAME=\"udp_tunnel_nic\" -DKBUILD_MODNAME=\"udp_tunnel\" 
-D__KBUILD_MODNAME=kmod_udp_tunnel -c -Wp,-MMD,net/ipv4/.udp_tunnel_nic.o.d 
-fcolor-diagnostics -o net/ipv4/udp_tunnel_nic.o net/ipv4/udp_tunnel_nic.c
1.   parser at end of file
2.  Per-file LLVM IR generation
3.  net/ipv4/udp_tunnel_nic.c:345:1: Generating code for declaration 
'udp_tunnel_nic_has_collision'
4.  net/ipv4/udp_tunnel_nic.c:353:51: LLVM IR generation of compound 
statement ('{}')
 #0 0x5574960f5698 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4153698)
 #1 0x5574960f32ce llvm::sys::RunSignalHandlers() 
(/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x41512ce)
 #2 0x557496077e26 CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
 #3 0x7f1682eaf710 (/usr/lib/libc.so.6+0x3e710)
 #4 0x7f1682eff83c (/usr/lib/libc.so.6+0x8e83c)
 #5 0x7f1682eaf668 gsignal (/usr/lib/libc.so.6+0x3e668)
 #6 0x7f1682e974b8 abort (/usr/lib/libc.so.6+0x264b8)
 #7 0x7f1682e973dc (/usr/lib/libc.so.6+0x263dc)
 #8 0x7f1682ea7d26 (/usr/lib/libc.so.6+0x36d26)
 #9 0x557495c1c9d3 llvm::CastInst::Create(llvm::Instruction::CastOps, 
llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*) 
(/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x3c7a9d3)
#10 0x557494d032f2 llvm::IRBuilderBase::CreateIntCast(llvm::Value*, 
llvm::Type*, bool, llvm::Twine const&) AArch64TargetTransformInfo.cpp:0:0
#11 0x557496437dbf 
clang::CodeGen::CodeGenFunction::EmitBoundsCheck(clang::Expr const*, 
clang::Expr const*, llvm::Value*, clang::QualType, bool) 
(/mnt/nvme/tmp/build/llvm-bisect/final/bin/clang+0x4495dbf)
#12 0x55749644c893 

[clang] [clang] Add per-global code model attribute (PR #72078)

2023-12-05 Thread via cfe-commits


@@ -57,6 +57,16 @@ global variable or function should be in after translation.
   let Heading = "section, __declspec(allocate)";
 }
 
+def CodeModelDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``model`` attribute allows you to use a different code model for

heiher wrote:

Done. Thanks

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


[clang] [clang] Add per-global code model attribute (PR #72078)

2023-12-05 Thread via cfe-commits

https://github.com/heiher updated 
https://github.com/llvm/llvm-project/pull/72078

>From e3863873ab817dacf8680763bb42d91f005fe5ea Mon Sep 17 00:00:00 2001
From: WANG Rui 
Date: Fri, 10 Nov 2023 21:07:48 -0600
Subject: [PATCH 1/4] [clang] Add per-global code model attribute

This patch adds a per-global code model attribute, which can override
the target's code model to access global variables.

Currently, the code model attribute is only supported on LoongArch.
This patch also maps GCC's code model names to LLVM's, which allows
for better compatibility between the two compilers.

Suggested-by: Arthur Eubanks 
Signed-off-by: WANG Rui 
Link: 
https://discourse.llvm.org/t/how-to-best-implement-code-model-overriding-for-certain-values/71816
Link: https://discourse.llvm.org/t/rfc-add-per-global-code-model-attribute/74944
---
 clang/include/clang/Basic/Attr.td |  8 +
 clang/include/clang/Basic/AttrDocs.td |  9 ++
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/lib/CodeGen/CodeGenModule.cpp   | 13 
 clang/lib/Sema/SemaDeclAttr.cpp   | 30 +++
 clang/test/CodeGen/LoongArch/attributes.c | 10 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 clang/test/Sema/loongarch-attr-model.c| 13 
 8 files changed, 86 insertions(+)
 create mode 100644 clang/test/CodeGen/LoongArch/attributes.c
 create mode 100644 clang/test/Sema/loongarch-attr-model.c

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 1800f584c7e10..d5b5717f3d77c 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2718,6 +2718,14 @@ def PragmaClangTextSection : InheritableAttr {
   let Documentation = [InternalOnly];
 }
 
+def CodeModel : InheritableAttr {
+  let Spellings = [GCC<"model">];
+  let Args = [StringArgument<"Model">];
+  let Subjects =
+  SubjectList<[ GlobalVar ], ErrorDiag>;
+  let Documentation = [CodeModelDocs];
+}
+
 def Sentinel : InheritableAttr {
   let Spellings = [GCC<"sentinel">];
   let Args = [DefaultIntArgument<"Sentinel", 0>,
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b45ec6bbb8d37..1d37c2da6bec0 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -57,6 +57,15 @@ global variable or function should be in after translation.
   let Heading = "section, __declspec(allocate)";
 }
 
+def CodeModelDocs : Documentation {
+  let Category = DocCatVariable;
+  let Content = [{
+The ``model`` attribute allows you to specify a specific code model a
+global variable should be in after translation.
+  }];
+  let Heading = "model";
+}
+
 def UsedDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6dfb2d7195203..d438fdde9ac7e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3408,6 +3408,8 @@ def warn_objc_redundant_literal_use : Warning<
 def err_attr_tlsmodel_arg : Error<"tls_model must be \"global-dynamic\", "
   "\"local-dynamic\", \"initial-exec\" or \"local-exec\"">;
 
+def err_attr_codemodel_arg : Error<"code_model '%0' is not yet supported on 
this target">;
+
 def err_aix_attr_unsupported_tls_model : Error<"TLS model '%0' is not yet 
supported on AIX">;
 
 def err_tls_var_aligned_over_maximum : Error<
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dea58a7ff4146..1f49721e79ddc 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4841,6 +4841,19 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef 
MangledName, llvm::Type *Ty,
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
   GV->setSection(".cp.rodata");
 
+// Handle code model attribute
+if (D->hasAttr()) {
+  if (const CodeModelAttr *CMA = D->getAttr()) {
+auto CM = llvm::StringSwitch(CMA->getModel())
+  .Case("tiny", llvm::CodeModel::Tiny)
+  .Case("kernel", llvm::CodeModel::Kernel)
+  .Case("medium", llvm::CodeModel::Medium)
+  .Case("large", llvm::CodeModel::Large)
+  .Default(llvm::CodeModel::Small);
+GV->setCodeModel(CM);
+  }
+}
+
 // Check if we a have a const declaration with an initializer, we may be
 // able to emit it as available_externally to expose it's value to the
 // optimizer.
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 87c78d742d0ff..64aa242dbb04f 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3369,6 +3369,33 @@ static void handleSectionAttr(Sema , Decl *D, const 
ParsedAttr ) {
   }
 }
 
+static void handleCodeModelAttr(Sema 

[clang] [clang-format] Add "three dot" diff option to git-clang-format (PR #74230)

2023-12-05 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/74230

>From ae4097b53b90e31802be0be5c8a81fb74c81efc9 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 2 Dec 2023 23:46:58 -0800
Subject: [PATCH 1/3] [clang-format] Add "three dot" diff option to
 git-clang-format

This patch adds in the ability to do a "three dot" git-clang-format
between two commits. This looks at the diff between the second commit
and the common merge base rather than comparing at the point of the
specified commits. This is needed to improve the reliability of the LLVM
code formatting CI action which currently breaks in some cases where
files have been modified in the upstream tree and when the person
created their branch, leaving phantom formatting diffs that weren't
touched by the PR author.

Part of a fix for #73873
---
 clang/tools/clang-format/git-clang-format | 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 6e827e17b4ee2..4fe4671482e3f 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -132,6 +132,10 @@ def main():
  help='passed to clang-format'),
   p.add_argument('-v', '--verbose', action='count', default=0,
  help='print extra information')
+  p.add_argument('--diff_from_common_commit', action='store_true',
+ help=('diff from the last common commit for commits in '
+  'separate branches rather than the exact point of the '
+  'commits'))
   # We gather all the remaining positional arguments into 'args' since we need
   # to use some heuristics to determine whether or not  was present.
   # However, to print pretty messages, we make use of metavar and help.
@@ -154,7 +158,10 @@ def main():
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
   opts.binary=os.path.abspath(opts.binary)
-  changed_lines = compute_diff_and_extract_lines(commits, files, opts.staged)
+  changed_lines = compute_diff_and_extract_lines(commits,
+ files,
+ opts.staged,
+ opts.diff_from_common_commit)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)
   filter_by_extension(changed_lines, opts.extensions.lower().split(','))
@@ -302,9 +309,9 @@ def get_object_type(value):
   return convert_string(stdout.strip())
 
 
-def compute_diff_and_extract_lines(commits, files, staged):
+def compute_diff_and_extract_lines(commits, files, staged, diff_common_commit):
   """Calls compute_diff() followed by extract_lines()."""
-  diff_process = compute_diff(commits, files, staged)
+  diff_process = compute_diff(commits, files, staged, diff_common_commit)
   changed_lines = extract_lines(diff_process.stdout)
   diff_process.stdout.close()
   diff_process.wait()
@@ -314,7 +321,7 @@ def compute_diff_and_extract_lines(commits, files, staged):
   return changed_lines
 
 
-def compute_diff(commits, files, staged):
+def compute_diff(commits, files, staged, diff_common_commit):
   """Return a subprocess object producing the diff from `commits`.
 
   The return value's `stdin` file object will produce a patch with the
@@ -328,6 +335,10 @@ def compute_diff(commits, files, staged):
 git_tool = 'diff-tree'
   elif staged:
 extra_args += ['--cached']
+
+  if len(commits) > 1 and diff_common_commit:
+commits = [f'{commits[0]}...{commits[1]}']
+
   cmd = ['git', git_tool, '-p', '-U0'] + extra_args + commits + ['--']
   cmd.extend(files)
   p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)

>From 4584ebc58337f04290a5c753f585426c8c6f739f Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sun, 3 Dec 2023 13:08:16 -0800
Subject: [PATCH 2/3] Add early exit when flag is specified with invalid
 parameters

---
 clang/tools/clang-format/git-clang-format | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 4fe4671482e3f..51ae8739bee0e 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -157,6 +157,8 @@ def main():
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
+  if len(commits) < 2 and opts.diff_from_common_commit:
+die('--diff_from_common_commit is only allowed when two commits are given')
   opts.binary=os.path.abspath(opts.binary)
   changed_lines = compute_diff_and_extract_lines(commits,
  files,

>From a8b385070845ba20f63f1e0c6835ff9bc609548f Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Tue, 5 Dec 2023 17:42:12 -0800
Subject: [PATCH 3/3] Address reviewer feedback

---
 

[clang] [clang] Enhance handling of Apple-specific '-arch'/'-target' option values (PR #72821)

2023-12-05 Thread Daniil Kovalev via cfe-commits

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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-05 Thread Daniil Kovalev via cfe-commits

kovdan01 wrote:

OK, thanks for such a detailed explanation! Closing 
https://github.com/llvm/llvm-project/pull/72821 as not needed.

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


[llvm] [clang] [clang-tools-extra] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Jon Roelofs via cfe-commits


@@ -1809,6 +1814,255 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
+void AArch64AsmPrinter::emitGlobalIFunc(Module , const GlobalIFunc ) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);

jroelofs wrote:

Sounds good, I like that.

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


[llvm] [clang] Remove experimental from Vector Crypto extensions (PR #69000)

2023-12-05 Thread Brandon Wu via cfe-commits

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


[llvm] [clang] Remove experimental from Vector Crypto extensions (PR #69000)

2023-12-05 Thread Brandon Wu via cfe-commits

4vtomat wrote:

moved to the new [one](https://github.com/llvm/llvm-project/pull/74213)

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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-05 Thread Fangrui Song via cfe-commits

MaskRay wrote:

When the target triple is aarch64 and `-arch ` is specified, e.g. 
`--target=aarch64 -arch arm64e`, there is currently no warning/error, because 
`clang/lib/Driver/ToolChains/Arch/AArch64.cpp` claims `OPT_arch` in quite a few 
places.
We can safely remove these references now that https://reviews.llvm.org/D55731 
has checked `isOSDarwin` (which covers macOS/iOS/watchOS/DriverKit).

> Are we supposed to pass -target to clang in addition to -arch if we want to 
> be sure to compile with Apple's triple?

If the default target triple is not Apple's triple, `--target=` is required. 
`clang -arch arm64` without `--target=` does not work.
This is the desired behavior.

> It might be reasonable, but in such case many tests which use -arch without 
> -target actually might run with undesired non-Apple triple - I find such 
> behavior a bit misleading. Is this "by design"?

These tests need to be fixed to specify `--target=` if it may run on a 
non-Apple target.
It's possible that `-arch ` is redundant with `--target=`.


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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-05 Thread Daniil Kovalev via cfe-commits

kovdan01 wrote:

@MaskRay Unfortunately, the case I was initially trying to fix still has a 
problem after applying this patch. Consider 
`LLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-musl`. In such a case, running `clang 
-arch arm64e -c test.c -###` will show us `"-triple" 
"aarch64-unknown-linux-musl"`. As far as I understood from the comment 
https://github.com/llvm/llvm-project/pull/72821#issuecomment-1839435929, a 
warning `-Wunused-command-line-argument` should be emitted - but it is not 
(this does not change even if we really compile to the object file instead of 
just printing cli args with `-###`).

Are we supposed to pass `-target` to clang in addition to `-arch` if we want to 
be sure to compile with Apple's triple? It might be reasonable, but in such 
case many tests which use `-arch` without `-target` actually might run with 
undesired non-Apple triple - I find such behavior a bit misleading. Is this "by 
design"?

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


[compiler-rt] [llvm] [flang] [mlir] [libcxx] [clang-tools-extra] [clang] [mlir] Fix a zero stride canonicalizer crash (PR #74200)

2023-12-05 Thread Kai Sasaki via cfe-commits

Lewuathe wrote:

@joker-eph Thank you. That gets clearer to me!

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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Bill Wendling via cfe-commits

bwendling wrote:

The `__bdos` stuff is only a subset of the bounds checking code so we should 
focus on that.

It's still messier than that, since it's not always going to be a pointer 
directly to the FAM (e.g. p->a.b.c.array[index]), but I'll give it a shot. I 
don't think it's going to be any less convoluted.

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


[llvm] [clang] [clang-tools-extra] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Ahmed Bougacha via cfe-commits

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


[clang] [clang-tools-extra] [llvm] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Ahmed Bougacha via cfe-commits


@@ -1809,6 +1814,255 @@ void AArch64AsmPrinter::emitInstruction(const 
MachineInstr *MI) {
   EmitToStreamer(*OutStreamer, TmpInst);
 }
 
+void AArch64AsmPrinter::emitGlobalIFunc(Module , const GlobalIFunc ) {
+  if (!TM.getTargetTriple().isOSBinFormatMachO())
+return AsmPrinter::emitGlobalIFunc(M, GI);

ahmedbougacha wrote:

How about having all the lazy/stub symbol machinery in AsmPrinter proper, and 
only having target-specific "emit macho stub/helper body" overridable hooks?
I ask because I wondered "when would you have `!MAI->getWeakRefDirective()` for 
macho?" and noticed that's from the base anyway.  I imagine moving this 
wouldn't change that, because this'd still be in a macho-specific bit there.  
But at least if the ELF base changes, the macho version would be right there 
next to it ;)  WDYT?

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


[llvm] [clang] [clang-tools-extra] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Ahmed Bougacha via cfe-commits


@@ -144,7 +144,12 @@ bool CallLowering::lowerCall(MachineIRBuilder , 
const CallBase ,
   // Try looking through a bitcast from one function type to another.
   // Commonly happens with calls to objc_msgSend().
   const Value *CalleeV = CB.getCalledOperand()->stripPointerCasts();
-  if (const Function *F = dyn_cast(CalleeV))
+  if (const GlobalIFunc *IF = dyn_cast(CalleeV);
+  IF && MF.getTarget().getTargetTriple().isOSBinFormatMachO()) {

ahmedbougacha wrote:

Heh, I did a double-take on the nesting; maybe embrace the dumber 
`isa<>`/`cast<>`? ;)

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


[clang] [llvm] [clang-tools-extra] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Ahmed Bougacha via cfe-commits


@@ -882,8 +882,11 @@ class AsmPrinter : public MachineFunctionPass {
 
   GCMetadataPrinter *getOrCreateGCPrinter(GCStrategy );
   void emitGlobalAlias(Module , const GlobalAlias );
-  void emitGlobalIFunc(Module , const GlobalIFunc );
 
+protected:
+  virtual void emitGlobalIFunc(Module , const GlobalIFunc );

ahmedbougacha wrote:

Probably deserves to be with `emitGlobalVariable` or "overridable hooks" above? 
 (but maybe the hooks can be finer-grained, see later comment)

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


[clang-tools-extra] bb0f162 - [clang][tidy] Fix build failure after 07157db

2023-12-05 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-12-05T15:52:57-08:00
New Revision: bb0f162b3acfab3146807ab1e01946596d9921f9

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

LOG: [clang][tidy] Fix build failure after 07157db

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index baee1d205813b..565f044778c94 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -148,7 +148,7 @@ class ErrorReporter {
 tooling::Replacement R(FixAbsoluteFilePath, Repl.getOffset(),
Repl.getLength(), 
Repl.getReplacementText());
 auto  = FileReplacements[R.getFilePath()];
-Replacements  = Entry.Replacements;
+Replacements  = Entry.Replaces;
 llvm::Error Err = Replacements.add(R);
 if (Err) {
   // FIXME: Implement better conflict handling.
@@ -216,7 +216,7 @@ class ErrorReporter {
 }
 llvm::Expected Replacements =
 format::cleanupAroundReplacements(
-Code, FileAndReplacements.second.Replacements, *Style);
+Code, FileAndReplacements.second.Replaces, *Style);
 if (!Replacements) {
   llvm::errs() << llvm::toString(Replacements.takeError()) << "\n";
   continue;
@@ -303,7 +303,7 @@ class ErrorReporter {
 
   struct ReplacementsWithBuildDir {
 StringRef BuildDir;
-Replacements Replacements;
+Replacements Replaces;
   };
 
   FileManager Files;



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


[clang] [Clang] Emit TBAA info for enums in C (PR #73326)

2023-12-05 Thread John McCall via cfe-commits

rjmccall wrote:

This seems conservatively correct, yeah.  My reading is that we could also use 
the underlying type as a parent type for the TBAA metadata: enums are 
compatible with their underlying type, but two enums with the same underlying 
type are not compatible with each other.  But this rule should also work.

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


[clang] [clang-tools-extra] [clang][tidy] Ensure rewriter has the correct CWD (PR #67839)

2023-12-05 Thread Jan Svoboda via cfe-commits

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


[clang] 07157db - [clang][tidy] Ensure rewriter has the correct CWD (#67839)

2023-12-05 Thread via cfe-commits

Author: Jan Svoboda
Date: 2023-12-05T15:35:55-08:00
New Revision: 07157db81d4421ced9fcf9a2002255c2a3a80d49

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

LOG: [clang][tidy] Ensure rewriter has the correct CWD (#67839)

This patch replaces use of the deprecated `FileEntry::getName()` with
`FileEntryRef::getName()`. This means the code now uses the path that
was used to register file entry in `SourceManager` instead of the
absolute path that happened to be used in the last call to
`FileManager::getFile()` some place else.

This caused some test failures due to the fact that some paths can be
relative and thus rely on the VFS CWD. The CWD can change for each TU,
so when we run `clang-tidy` on a compilation database and try to perform
all the replacements at the end, relative paths won't resolve the same.
This patch takes care to reinstate the correct CWD and make the path
reported by `FileEntryRef` absolute before passing it to
`llvm::writeToOutput()`.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/compilation-database/template.json

clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
clang/lib/Rewrite/Rewriter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 4b1a67b6dd98a..baee1d205813b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -147,7 +147,8 @@ class ErrorReporter {
 Files.makeAbsolutePath(FixAbsoluteFilePath);
 tooling::Replacement R(FixAbsoluteFilePath, Repl.getOffset(),
Repl.getLength(), 
Repl.getReplacementText());
-Replacements  = FileReplacements[R.getFilePath()];
+auto  = FileReplacements[R.getFilePath()];
+Replacements  = Entry.Replacements;
 llvm::Error Err = Replacements.add(R);
 if (Err) {
   // FIXME: Implement better conflict handling.
@@ -174,6 +175,7 @@ class ErrorReporter {
 }
 FixLoc = getLocation(FixAbsoluteFilePath, Repl.getOffset());
 FixLocations.push_back(std::make_pair(FixLoc, CanBeApplied));
+Entry.BuildDir = Error.BuildDirectory;
   }
 }
   }
@@ -189,9 +191,14 @@ class ErrorReporter {
 
   void finish() {
 if (TotalFixes > 0) {
-  Rewriter Rewrite(SourceMgr, LangOpts);
+  auto  = Files.getVirtualFileSystem();
+  auto OriginalCWD = VFS.getCurrentWorkingDirectory();
+  bool AnyNotWritten = false;
+
   for (const auto  : FileReplacements) {
+Rewriter Rewrite(SourceMgr, LangOpts);
 StringRef File = FileAndReplacements.first();
+VFS.setCurrentWorkingDirectory(FileAndReplacements.second.BuildDir);
 llvm::ErrorOr> Buffer =
 SourceMgr.getFileManager().getBufferForFile(File);
 if (!Buffer) {
@@ -208,8 +215,8 @@ class ErrorReporter {
   continue;
 }
 llvm::Expected Replacements =
-format::cleanupAroundReplacements(Code, FileAndReplacements.second,
-  *Style);
+format::cleanupAroundReplacements(
+Code, FileAndReplacements.second.Replacements, *Style);
 if (!Replacements) {
   llvm::errs() << llvm::toString(Replacements.takeError()) << "\n";
   continue;
@@ -226,13 +233,18 @@ class ErrorReporter {
 if (!tooling::applyAllReplacements(Replacements.get(), Rewrite)) {
   llvm::errs() << "Can't apply replacements for file " << File << "\n";
 }
+AnyNotWritten &= Rewrite.overwriteChangedFiles();
   }
-  if (Rewrite.overwriteChangedFiles()) {
+
+  if (AnyNotWritten) {
 llvm::errs() << "clang-tidy failed to apply suggested fixes.\n";
   } else {
 llvm::errs() << "clang-tidy applied " << AppliedFixes << " of "
  << TotalFixes << " suggested fixes.\n";
   }
+
+  if (OriginalCWD)
+VFS.setCurrentWorkingDirectory(*OriginalCWD);
 }
   }
 
@@ -289,13 +301,18 @@ class ErrorReporter {
 return CharSourceRange::getCharRange(BeginLoc, EndLoc);
   }
 
+  struct ReplacementsWithBuildDir {
+StringRef BuildDir;
+Replacements Replacements;
+  };
+
   FileManager Files;
   LangOptions LangOpts; // FIXME: use langopts from each original file
   IntrusiveRefCntPtr DiagOpts;
   DiagnosticConsumer *DiagPrinter;
   DiagnosticsEngine Diags;
   SourceManager SourceMgr;
-  llvm::StringMap FileReplacements;
+  llvm::StringMap FileReplacements;
   ClangTidyContext 
   FixBehaviour ApplyFixes;
   unsigned TotalFixes = 0U;

diff  

[clang-tools-extra] [clang] [clang][tidy] Ensure rewriter has the correct CWD (PR #67839)

2023-12-05 Thread Jan Svoboda via cfe-commits

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


[flang] [clang-tools-extra] [compiler-rt] [libcxx] [lld] [llvm] [clang] [libc] [lldb] [Clang] Fix linker error for function multiversioning (PR #71706)

2023-12-05 Thread via cfe-commits

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


[clang] cee5b87 - [Clang] Fix linker error for function multiversioning (#71706)

2023-12-05 Thread via cfe-commits

Author: elizabethandrews
Date: 2023-12-05T18:11:53-05:00
New Revision: cee5b8777fa98312b05bf8aa81554910a8f867c5

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

LOG: [Clang]  Fix linker error for function multiversioning (#71706)

Currently target_clones attribute results in a linker error when there
are no multi-versioned function declarations in the calling TU.

In the calling TU, the call is generated with the ‘normal’ assembly
name. This does not match any of the versions or the ifunc, since
version mangling includes a .versionstring, and the ifunc includes
.ifunc suffix. The linker error is not seen with GCC since the mangling
for the ifunc symbol in GCC is the ‘normal’ assembly name for function
i.e. no ifunc suffix.

This PR removes the .ifunc suffix to match GCC. It also adds alias with
the .ifunc suffix so as to ensure backward compatibility.

The changes exclude aarch64 target because the mangling for default
versions on aarch64 does not include a .default suffix and is the
'normal' assembly name, unlike other targets. It is not clear to me what
the correct behavior for this target is.

Old Phabricator review - https://reviews.llvm.org/D158666

-

Co-authored-by: Tom Honermann 

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-target-clones.c
clang/test/CodeGenCXX/attr-target-clones.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 828dd10e3d6db..89ea2f0930cec 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -651,6 +651,9 @@ Bug Fixes in This Version
 - Fixed false positive error emitted by clang when performing qualified name
   lookup and the current class instantiation has dependent bases.
   Fixes (`#13826 `_)
+- Fix the name of the ifunc symbol emitted for multiversion functions declared 
with the
+  ``target_clones`` attribute. This addresses a linker error that would 
otherwise occur
+  when these functions are referenced from other TUs.
 - Fixes compile error that double colon operator cannot resolve macro with 
parentheses.
   Fixes (`#64467 `_)
 - Clang's ``-Wchar-subscripts`` no longer warns on chars whose values are 
known non-negative constants.

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 53c3dff19fc9b..bbe4de94cbabe 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2552,6 +2552,13 @@ example, the following will emit 4 versions of the 
function:
 __attribute__((target_clones("arch=atom,avx2","arch=ivybridge","default")))
 void foo() {}
 
+For targets that support the GNU indirect function (IFUNC) feature, dispatch
+is performed by emitting an indirect function that is resolved to the 
appropriate
+target clone at load time. The indirect function is given the name the
+multiversioned function would have if it had been declared without the 
attribute.
+For backward compatibility with earlier Clang releases, a function alias with 
an
+``.ifunc`` suffix is also emitted. The  ``.ifunc`` suffixed symbol is a 
deprecated
+feature and support for it may be removed in the future.
 }];
 }
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dea58a7ff4146..6a20723bf2bca 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4178,8 +4178,29 @@ void CodeGenModule::emitMultiVersionFunctions() {
 }
 
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
-if (auto *IFunc = dyn_cast(ResolverConstant))
+if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
+  // In Aarch64, default versions of multiversioned functions are mangled 
to
+  // their 'normal' assembly name. This deviates from other targets which
+  // append a '.default' string. As a result we need to continue appending
+  // .ifunc in Aarch64.
+  // FIXME: Should Aarch64 mangling for 'default' multiversion function and
+  // in turn ifunc function match that of other targets?
+  if (FD->isTargetClonesMultiVersion() &&
+  !getTarget().getTriple().isAArch64()) {
+const CGFunctionInfo  = getTypes().arrangeGlobalDeclaration(GD);
+llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
+std::string MangledName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+// In prior versions of Clang, the mangling for ifuncs incorrectly
+// 

[llvm] [clang] [clang] NFC: Deprecate `FileEntry::getName()` (PR #68157)

2023-12-05 Thread Jan Svoboda via cfe-commits


@@ -157,6 +157,25 @@
 #define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
 #endif
 
+// clang-format off
+#if defined(__clang__) || defined(__GNUC__)
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_BEGIN 
\

jansvoboda11 wrote:

Maybe we could have a more generic macro?

```c++
#define DO_PRAGMA(x) _Pragma(#x)
#if defined(__clang__) || defined(__GNUC__)
#define LLVM_DISABLE_WARNING_BEGIN(GCC_FLAG, MSVC_NUMBER) \
  DO_PRAGMA(GCC diagnostic push)  \
  DO_PRAGMA(GCC diagnostic ignored "-W" GCC_FLAG)
#define LLVM_DISABLE_WARNING_END  \
  DO_PRAGMA(GCC diagnostic pop)
#elif defined(_MSC_VER)
#define LLVM_DISABLE_WARNING_BEGIN(GCC_FLAG, MSVC_NUMBER) \
  DO_PRAGMA(warning(push))\
  DO_PRAGMA(warning(disable: MSVC_NUMBER))
#define LLVM_DISABLE_WARNING_END  \
  DO_PRAGMA(warning(pop))
#else
#define LLVM_DISABLE_WARNING_BEGIN(GCC_FLAG, MSVC_NUMBER)
#define LLVM_DISABLE_WARNING_END
#endif

LLVM_DISABLE_WARNING_BEGIN("deprecated-declarations", 4996)
EXPECT_EQ("dir/f2.cpp", F2->getFileEntry().getName());
LLVM_DISABLE_WARNING_END
```

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


[clang] [clang-tools-extra] [lldb] [llvm] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)

2023-12-05 Thread Adrian Prantl via cfe-commits

adrian-prantl wrote:

SGTM, maybe wait one more day for @JDevlieghere to chime in.

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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Trying to discuss both __bdos and the array bounds sanitizer changes in the 
same review is making things confusing to discuss.  It seems like they have 
significant differences.

For array bounds sanitizer, take your example:

```
struct s {
  struct s *p;
  int count;
  int array[] __attribute__((count));
};

int foo(struct s *p, int index) {
  return p->p->p->array[index];
}
```

When we visit the ArraySubscriptExpr, without sanitization, we call EmitLValue 
on `p->p->p->array`.  My proposal is that, when we're doing sanitization, we 
don't do that.  Instead, we call EmitPointerWithAlignment on `p->p->p`, then 
use the returned pointer to load `count` and index to `array`.

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


[clang-tools-extra] [clang-tidy] Add check hicpp-ignored-remove-result (PR #73119)

2023-12-05 Thread Björn Svensson via cfe-commits

bjosv wrote:

Updated the check to be derived from the original check instead of an alias.

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


[clang-tools-extra] [clang-tidy] Add check hicpp-ignored-remove-result (PR #73119)

2023-12-05 Thread Björn Svensson via cfe-commits

https://github.com/bjosv updated https://github.com/llvm/llvm-project/pull/73119

From 91cf412abcfd231ab399c3e44c6a9bc14109537c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= 
Date: Tue, 21 Nov 2023 23:30:07 +0100
Subject: [PATCH 1/3] [clang-tidy] Add check hicpp-ignored-remove-result

This check implements the rule 17.5.1 of the HICPP standard
which states:

- Do not ignore the result of std::remove, std::remove_if or std::unique

  The mutating algorithms std::remove, std::remove_if and both overloads of
  std::unique operate by swapping or moving elements of the range they are
  operating over. On completion, they return an iterator to the last valid 
element.
  In the majority of cases the correct behavior is to use this result as the
  first operand in a call to std::erase.

Suppressing issues by casting to `void` is enabled by default, but can be
disabled by setting `AllowCastToVoid` option to `false`.
---
 .../clang-tidy/hicpp/HICPPTidyModule.cpp  | 20 
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 ++
 .../checks/hicpp/ignored-remove-result.rst| 20 
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../checkers/hicpp/ignored-remove-result.cpp  | 47 +++
 5 files changed, 92 insertions(+)
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/hicpp/ignored-remove-result.cpp

diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp 
b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
index 3749796877120e..09d15ccab3f29c 100644
--- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -10,6 +10,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "../bugprone/UndelegatedConstructorCheck.h"
+#include "../bugprone/UnusedReturnValueCheck.h"
 #include "../bugprone/UseAfterMoveCheck.h"
 #include "../cppcoreguidelines/AvoidGotoCheck.h"
 #include "../cppcoreguidelines/NoMallocCheck.h"
@@ -41,6 +42,15 @@
 #include "NoAssemblerCheck.h"
 #include "SignedBitwiseCheck.h"
 
+namespace {
+
+// Checked functions for hicpp-ignored-remove-result.
+const llvm::StringRef CheckedFunctions = "::std::remove;"
+ "::std::remove_if;"
+ "::std::unique;";
+
+} // namespace
+
 namespace clang::tidy {
 namespace hicpp {
 
@@ -64,6 +74,8 @@ class HICPPModule : public ClangTidyModule {
 "hicpp-explicit-conversions");
 CheckFactories.registerCheck(
 "hicpp-function-size");
+CheckFactories.registerCheck(
+"hicpp-ignored-remove-result");
 CheckFactories.registerCheck(
 "hicpp-named-parameter");
 CheckFactories.registerCheck(
@@ -107,6 +119,14 @@ class HICPPModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "hicpp-vararg");
   }
+
+  ClangTidyOptions getModuleOptions() override {
+ClangTidyOptions Options;
+ClangTidyOptions::OptionMap  = Options.CheckOptions;
+Opts["hicpp-ignored-remove-result.CheckedFunctions"] = CheckedFunctions;
+Opts["hicpp-ignored-remove-result.AllowCastToVoid"] = "true";
+return Options;
+  }
 };
 
 // Register the HICPPModule using this statically initialized variable.
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d5f49dc062545..c940025df1c63c 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -205,6 +205,10 @@ New check aliases
   ` to 
:doc:`modernize-macro-to-enum
   ` was added.
 
+- New alias :doc:`hicpp-ignored-remove-result
+  ` to 
:doc:`bugprone-unused-return-value
+  ` was added.
+
 Changes in existing checks
 ^^
 
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst 
b/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
new file mode 100644
index 00..4b6188b886db12
--- /dev/null
+++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp/ignored-remove-result.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - hicpp-ignored-remove-result
+
+hicpp-ignored-remove-result
+===
+
+Ensure that the result of ``std::remove``, ``std::remove_if`` and 
``std::unique``
+are not ignored according to
+`rule 17.5.1 
`_.
+
+The mutating algorithms ``std::remove``, ``std::remove_if`` and both overloads
+of ``std::unique`` operate by swapping or moving elements of the range they are
+operating over. On completion, they return an iterator to the last valid
+element. In the majority of cases the correct behavior is to use this result as
+the first operand in a call to std::erase.
+
+This check is an alias of check :doc:`bugprone-unused-return-value 

[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Bill Wendling via cfe-commits

bwendling wrote:

> I mean, the base case should be "return nullptr", and you should only 
> explicitly list out expressions you know we need to handle. We shouldn't need 
> to explicitly mention VisitUnaryPostDec etc.

The expression can be arbitrarily complex. For instance this:

```
struct s {
  struct s *p;
  int count;
  int array[] __attribute__((count));
};

int foo(struct s *p, int index) {
  return p->p->p->array[index];
}

struct q {
  struct s *ptr[20];
};

int bar(struct q *f, int idx1, int index) {
  return f->ptr[idx1]->p->array[index];
}
```

and so on. If all I was dealing with were 
`ArraySubscriptExpr(MemberExpr(DeclRefExpr), ArrayIndex)`, I wouldn't have to 
jump through hoops to deal with these horrors.

In `ArraySubscriptExpr`, I don't even have the luxury of knowing what all of 
the elements in the expression are, since it could be on an arbitrary recursive 
level.

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


[clang-tools-extra] [llvm] [clang] [llvm] Support IFuncs on Darwin platforms (PR #73686)

2023-12-05 Thread Jon Roelofs via cfe-commits

jroelofs wrote:

ping

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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

> > And ideally, the recursive visit should list those expressions explicitly, 
> > instead aborting on ones we know are bad.
> 
> I'm sorry, I don't understand what you're talking about here. The whole point 
> of the recursive visit is to find a suitable base pointer. If we run across 
> any undesirable expressions (e.g. pointer arithmetic) then we return 
> `nullptr` to signify this. What do you mean we should list those expressions 
> explicitly?

I mean, the base case should be "return nullptr", and you should only 
explicitly list out expressions you know we need to handle.  We shouldn't need 
to explicitly mention VisitUnaryPostDec etc.

> > So you don't recurse; you just look for that exact AST structure.
> 
> The information about what LValue was generated for that base pointer is no 
> longer available to us.

No, I mean, you do the check before you emit the lvalue for the base.  So in 
`ArraySubscriptExpr(MemberExpr(StructBase), ArrayIndex)`, instead of calling 
EmitLValue on `MemberExpr(StructBase)` like we normally would, you call 
EmitLValue on StructBase.  So we have the LValue.  Then we do the indexing 
corresponding to the MemberExpr explicitly.  So you don't care what 
`StructBase` refers to, and you don't need a map to look up expressions.

For __builtin_dynamic_object_size, my understanding is that this approach 
doesn't work because the argument isn't actually supposed to be evaluated.  So 
we need a different approach that looks for specific constructs we want to 
allow.  And then we need a mini-codegen that specifically handles those 
constructs (or a mini-verifier that ensures when we call generic codegen, we 
don't have side-effects, but that's harder to get right).  And this is where 
you need the full recursive visit.

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


[clang-tools-extra] [lldb] [llvm] [clang] [lldb][test] Apply @expectedFailureAll/@skipIf early for debug_info tests (PR #73067)

2023-12-05 Thread Jordan Rupprecht via cfe-commits

rupprecht wrote:

> Is this a performance optimization or a function al change?

Neither. This should only affect tests, and the set of tests we skip/mark as 
xfail should not change, we just generally know about it earlier in the test 
setup.

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


[clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)

2023-12-05 Thread Shafik Yaghmour via cfe-commits

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

LGTM w/ minor comments

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


[clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)

2023-12-05 Thread Shafik Yaghmour via cfe-commits


@@ -8395,10 +8395,11 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl 
*ShadowedDecl,
 
   unsigned WarningDiag = diag::warn_decl_shadow;
   SourceLocation CaptureLoc;
-  if (isa(D) && isa(ShadowedDecl) && NewDC &&
-  isa(NewDC)) {
+  if (isa(D) && NewDC && isa(NewDC)) {
 if (const auto *RD = dyn_cast(NewDC->getParent())) {
   if (RD->isLambda() && OldDC->Encloses(NewDC->getLexicalParent())) {
+if (!isa(ShadowedDecl))

shafik wrote:

Maybe a comment here along the lines of "if it is not VarDecl then it can not 
shadow" I am not sure if that implies it must be a capture but I think it does.

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


[clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)

2023-12-05 Thread Shafik Yaghmour via cfe-commits

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


[clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)

2023-12-05 Thread Shafik Yaghmour via cfe-commits


@@ -179,3 +179,21 @@ void f() {
 #endif
 }
 }
+
+namespace GH71976 {
+struct A {
+  int b = 5;
+  int foo() {
+return [b = b]() { return b; }();

shafik wrote:

```suggestion
return [b = b]() { return b; }(); // no diagnostic, init-capture does not 
shadow b
```

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


[clang] [clang] Avoid -Wshadow warning when init-capture named same as class field (PR #74512)

2023-12-05 Thread Shafik Yaghmour via cfe-commits


@@ -179,3 +179,21 @@ void f() {
 #endif
 }
 }
+
+namespace GH71976 {
+struct A {
+  int b = 5;
+  int foo() {
+return [b = b]() { return b; }();
+  }
+};
+
+struct B {
+  int a;
+  void foo() {
+auto b = [a = this->a] {

shafik wrote:

```suggestion
auto b = [a = this->a] { // no diagnostic, init-capture does not shadow a
```

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


[clang] [libc] [compiler-rt] [libcxx] [lld] [mlir] [clang-tools-extra] [llvm] [flang] [openmp] [lldb] [MLIR] Enable GPU Dialect to SYCL runtime integration (PR #71430)

2023-12-05 Thread Fabian Mora via cfe-commits

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2023-12-05 Thread Charalampos Mitrodimas via cfe-commits

https://github.com/charmitro updated 
https://github.com/llvm/llvm-project/pull/74510

>From 5582cfacf106a7c00912fcef0d116d6fa58e064b Mon Sep 17 00:00:00 2001
From: Charalampos Mitrodimas 
Date: Tue, 5 Dec 2023 11:46:56 +0200
Subject: [PATCH] [clang] Disable missing definition warning on pure virtual
 functions

Warning '-Wundefined-func-template' incorrectly indicates that no
definition is available for a pure virtual function. However, a
definition is not needed for a pure virtual function.

Fixes #74016

Signed-off-by: Charalampos Mitrodimas 
---
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  3 +-
 .../instantiate-pure-virtual-function.cpp | 48 +++
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d768bb72e07c0..a034de0697b2b 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4952,7 +4952,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
   if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
-  !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) {
+  !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc()) &&
+  !Function->isPure()) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
diff --git a/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp 
b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
new file mode 100644
index 0..09164e8a79f96
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wundefined-func-template %s
+
+namespace GH74016 {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+virtual constexpr void bar(unsigned int) = 0;
+  };
+
+  template  class D : public B {
+  public:
+constexpr void bar(unsigned int) override {}
+  };
+
+  void test() {
+auto t = D();
+t.foo(0);
+  }
+};
+
+namespace non_pure_virtual_function {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+
+virtual constexpr void bar(unsigned int); // expected-warning {{inline 
function 'non_pure_virtual_function::B::bar' is not defined}}
+// expected-note@-1 {{forward declaration of template entity is here}}
+// expected-note@-2 {{forward declaration of template entity is here}}
+// expected-note@-3 {{forward declaration of template entity is here}}
+  };
+
+  template  class D : public B { // expected-warning 
{{instantiation of function 'non_pure_virtual_function::B::bar' required 
here, but no definition is available}}
+// expected-warning@-1 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-warning@-2 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-note@-3 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-4 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-5 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-6 {{used here}}
+
+  public:
+constexpr void bar(unsigned int) override { }
+  };
+
+  void test() {
+auto t = D();
+t.foo(0);
+  }
+};

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2023-12-05 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff d6fbd96e5eaf3e8acbf1b43dce7a311352907567 
1140e0094137614ad9917276f5324cbea4f2e0f9 -- 
clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5611bb6f5b..a034de0697 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4953,7 +4953,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 } else if (TSK == TSK_ImplicitInstantiation) {
   if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
   !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc()) &&
-   !Function->isPure()) {
+  !Function->isPure()) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);

``




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


[clang] [clang] Exclude non-template classes when checking if constraint refers to containing template arguments (PR #74265)

2023-12-05 Thread via cfe-commits


@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template
+concept C = true;
+
+class non_temp {
+template T>
+friend void f();
+
+non_temp();
+};
+
+template T>
+void f() {
+auto v = non_temp();
+}
+
+template
+class temp {
+template T>
+friend void g();

antangelo wrote:

Do you want me to address this as part of this patch or as a followup?

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2023-12-05 Thread Charalampos Mitrodimas via cfe-commits

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2023-12-05 Thread Charalampos Mitrodimas via cfe-commits


@@ -4952,7 +4952,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
   if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
-  !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) {
+  !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc()) &&
+  !Function->isVirtualAsWritten() && !Function->isPure()) {

charmitro wrote:

After double-checking this, I think we should just check for `isPure()` and 
don't bother checking for `isVirtualAsWritten()` at all since non-virtual 
functions cannot be pure. Also, for reference,

https://github.com/llvm/llvm-project/blob/d6fbd96e5eaf3e8acbf1b43dce7a311352907567/clang/include/clang/AST/Decl.h#L2293-L2295

Code updated to match this. Also a test-case added to verify that non-pure 
virtual functions still get diagnosed.

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


[clang] [clang] Disable missing definition warning on pure virtual functions (PR #74510)

2023-12-05 Thread Charalampos Mitrodimas via cfe-commits

https://github.com/charmitro updated 
https://github.com/llvm/llvm-project/pull/74510

>From 1140e0094137614ad9917276f5324cbea4f2e0f9 Mon Sep 17 00:00:00 2001
From: Charalampos Mitrodimas 
Date: Tue, 5 Dec 2023 11:46:56 +0200
Subject: [PATCH] [clang] Disable missing definition warning on pure virtual
 functions

Warning '-Wundefined-func-template' incorrectly indicates that no
definition is available for a pure virtual function. However, a
definition is not needed for a pure virtual function.

Fixes #74016

Signed-off-by: Charalampos Mitrodimas 
---
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  3 +-
 .../instantiate-pure-virtual-function.cpp | 48 +++
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 
clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d768bb72e07c0..5611bb6f5b018 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4952,7 +4952,8 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 std::make_pair(Function, PointOfInstantiation));
 } else if (TSK == TSK_ImplicitInstantiation) {
   if (AtEndOfTU && !getDiagnostics().hasErrorOccurred() &&
-  !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc())) {
+  !getSourceManager().isInSystemHeader(PatternDecl->getBeginLoc()) &&
+   !Function->isPure()) {
 Diag(PointOfInstantiation, diag::warn_func_template_missing)
   << Function;
 Diag(PatternDecl->getLocation(), diag::note_forward_template_decl);
diff --git a/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp 
b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
new file mode 100644
index 0..09164e8a79f96
--- /dev/null
+++ b/clang/test/SemaTemplate/instantiate-pure-virtual-function.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wundefined-func-template %s
+
+namespace GH74016 {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+virtual constexpr void bar(unsigned int) = 0;
+  };
+
+  template  class D : public B {
+  public:
+constexpr void bar(unsigned int) override {}
+  };
+
+  void test() {
+auto t = D();
+t.foo(0);
+  }
+};
+
+namespace non_pure_virtual_function {
+  template  class B {
+  public:
+constexpr void foo(const T &) { bar(1); }
+
+virtual constexpr void bar(unsigned int); // expected-warning {{inline 
function 'non_pure_virtual_function::B::bar' is not defined}}
+// expected-note@-1 {{forward declaration of template entity is here}}
+// expected-note@-2 {{forward declaration of template entity is here}}
+// expected-note@-3 {{forward declaration of template entity is here}}
+  };
+
+  template  class D : public B { // expected-warning 
{{instantiation of function 'non_pure_virtual_function::B::bar' required 
here, but no definition is available}}
+// expected-warning@-1 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-warning@-2 {{instantiation of function 
'non_pure_virtual_function::B::bar' required here, but no definition is 
available}}
+// expected-note@-3 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-4 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-5 {{add an explicit instantiation declaration to suppress 
this warning if 'non_pure_virtual_function::B::bar' is explicitly 
instantiated in another translation unit}}
+// expected-note@-6 {{used here}}
+
+  public:
+constexpr void bar(unsigned int) override { }
+  };
+
+  void test() {
+auto t = D();
+t.foo(0);
+  }
+};

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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Bill Wendling via cfe-commits

bwendling wrote:

> And ideally, the recursive visit should list those expressions explicitly, 
> instead aborting on ones we know are bad.

I'm sorry, I don't understand what you're talking about here. The whole point 
of the recursive visit is to find a suitable base pointer. If we run across any 
undesirable expressions (e.g. pointer arithmetic) then we return `nullptr` to 
signify this. What do you mean we should list those expressions explicitly?

> So you don't recurse; you just look for that exact AST structure.

Looking for the exact AST structure is what I'm trying to accomplish with 
`ExprLValueMap`. Even in `EmitArraySubscriptExpr`, I'll still have to crawl up 
the `MemberExpr` to find a suitable base pointer for accessing the `counted_by` 
field. The information about what LValue was generated for that base pointer is 
no longer available to us. It's not so bad if the base pointer is a simple 
`DeclRefExpr`, but if it's a `MemberExpr`, things get more complicated. If I 
can verify that the `MemberExpr` has no side-effects, then I can call the 
`EmitMemberExpr` method. This will most likely duplicate code, but not a huge 
deal. However, if I *can* reusing the `LValue` from the base `MemberExpr` with 
side-effects, then I can still emit the `counted_by` check, since I won't be 
re-generating the side-effects.

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


[llvm] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-05 Thread Mingming Liu via cfe-commits

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


[flang] [clang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-05 Thread Andrzej Warzyński via cfe-commits

banach-space wrote:

> Are you going to add an entry to the [Release 
> Notes](https://github.com/llvm/llvm-project/blob/main/flang/docs/ReleaseNotes.md)?

Once this change lands, yes.

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


[clang] [llvm] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-05 Thread Mingming Liu via cfe-commits

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


[clang] [llvm] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-05 Thread Mingming Liu via cfe-commits


@@ -300,12 +316,8 @@ getIRPGONameForGlobalObject(const GlobalObject ,
 GlobalValue::LinkageTypes Linkage,
 StringRef FileName) {
   SmallString<64> Name;
-  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
-Name.append(FileName.empty() ? "" : FileName);
-Name.append(";");
-  }
   Mangler().getNameWithPrefix(Name, , /*CannotUsePrivateLabel=*/true);

minglotus-6 wrote:

>  I think it makes more sense to use linkage-names for IRPGO, -order_file, and 
> ThinLTO. -order_file is used in the linker when it only knows linkage-names, 
> so I don't think it makes sense to feed it mangled names.

Thanks for the input.  (not to bikeshed but) I think for the purpose of 
computing global identifier, unique names should suffice. Clang-FE mangled 
names are unique so sounds fine.

Using linkage-name would be a non-trivial change, given the static 
`getGlobalIdentifier` takes a stringified name currently, and using 
linkage-name means requiring compatible change in each callsite (e.g., if the 
caller context doesn't have `GlobalValue` but just stringified names in the 
bitcode, make sure linkage-name exists in the bitcode, 
[this](https://github.com/llvm/llvm-project/blob/d6fbd96e5eaf3e8acbf1b43dce7a311352907567/llvm/lib/Bitcode/Reader/BitcodeReader.cpp#L6763)
 seems one example). An alternative fixup is to store the MD5 of 
`[filename;]linkage-name` (this is what's currently stored in this 
[field](https://github.com/llvm/llvm-project/blob/0f45e45847a5f2969b8021c787a566531fc96473/compiler-rt/include/profile/InstrProfData.inc#L72-L74))
 and the MD5 of `[filename:]mangled-name` (the original hash before D156569) in 
the raw profiles, so `llvm-profdata` could choose properly (former for ordering 
and latter for ICP)

Would you mind if I create a Github issue to track how to fix other potential 
cases and assign it to you ? This PR would solve the colon and semicolon 
difference.

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


[clang] [flang] [llvm] [clang-tools-extra] [mlir] [lldb] [compiler-rt] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-05 Thread Zequan Wu via cfe-commits


@@ -702,6 +708,8 @@ serializeValueProfDataFrom(ValueProfRecordClosure *Closure,
 #define INSTR_PROF_COVMAP_COMMON __llvm_covmap
 #define INSTR_PROF_COVFUN_COMMON __llvm_covfun
 #define INSTR_PROF_ORDERFILE_COMMON __llvm_orderfile

ZequanWu wrote:

Done.

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


[mlir] [llvm] [lldb] [flang] [clang] [compiler-rt] [clang-tools-extra] [Profile] Add binary profile correlation for code coverage. (PR #69493)

2023-12-05 Thread Zequan Wu via cfe-commits

ZequanWu wrote:

> Can you break up all the changes to tests that replace 
> `-debug-info-correlate` with `--profile-correlate=debug-info` into a separate 
> PR to reduce the size of this PR?

Done.

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


[libc] [flang] [clang] [compiler-rt] [libcxx] [llvm] Ensure `lli --force-interpreter` disables the OrcJIT too (PR #73717)

2023-12-05 Thread Nate Voorhies via cfe-commits

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


[clang-tools-extra] [lld] [compiler-rt] [libcxx] [clang] [llvm] [lldb] [libc] [flang] [Clang] Fix linker error for function multiversioning (PR #71706)

2023-12-05 Thread via cfe-commits

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


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


[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

2023-12-05 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

If you do need a map for something, I'd prefer to make it as narrow as 
possible.  For example, I can imagine you could need to specifically look up 
the corresponding allocation for a CompoundLiteralExpr; that might make sense.  
I don't think we should need to look up arbitrary lvalues.  For 
__builtin_dynamic_object_size, we should support a limited set of expressions 
as the base.  (And ideally, the recursive visit should list those expressions 
explicitly, instead aborting on ones we know are bad.)

> But if I placed some code in EmitArraySubscriptExpr, I'm guessing your 
> suggestion is more-or-less this:

Not sure it goes at the end. But to restate more explicitly, if you have 
something like ArraySubscriptExpr(MemberExpr(StructBase), ArrayIndex), you emit 
StructBase, then you emit the addresses of the array member and the counted_by 
member, then you use that to emit a bounds-checked array access.  So you don't 
recurse; you just look for that exact AST structure.

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


[clang-tools-extra] [clang] [clang][tidy] Ensure rewriter has the correct CWD (PR #67839)

2023-12-05 Thread Piotr Zegar via cfe-commits

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

LGTM

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


  1   2   3   4   5   >