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

2023-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Aiden Grossman (boomanaiden154)


Changes

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

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


1 Files Affected:

- (modified) clang/tools/clang-format/git-clang-format (+15-4) 


``diff
diff --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 0f33b5339ec14..1f5d9a9bbf676 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.
@@ -153,7 +157,10 @@ def main():
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  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(','))
@@ -301,9 +308,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()
@@ -313,7 +320,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,6 +334,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)

``




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] [clang-format] Add "three dot" diff option to git-clang-format (PR #74230)

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

https://github.com/boomanaiden154 created 
https://github.com/llvm/llvm-project/pull/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

>From 60032c548da7fa5bdf7033cf3bc8f8589dc1d13a Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 2 Dec 2023 23:46:58 -0800
Subject: [PATCH] [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 0f33b5339ec14..1f5d9a9bbf676 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.
@@ -153,7 +157,10 @@ def main():
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  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(','))
@@ -301,9 +308,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()
@@ -313,7 +320,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,6 +334,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)

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


[clang-tools-extra] [clangd] Carefully handle PseudoObjectExprs for inlay hints (PR #71366)

2023-12-02 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] 0fc69b1 - [clangd] Carefully handle PseudoObjectExprs for inlay hints (#71366)

2023-12-02 Thread via cfe-commits

Author: Younan Zhang
Date: 2023-12-03T02:27:45-05:00
New Revision: 0fc69b1402d75704744c73e15d278dcc8f437f0e

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

LOG: [clangd] Carefully handle PseudoObjectExprs for inlay hints (#71366)

Not all subexpressions for a PseudoObjectExpr are interesting, and they
probably mess up inlay hints.

Fixes https://github.com/clangd/clangd/issues/1813.

Added: 


Modified: 
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index 3da047f954213..b540c273cbd59 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -589,6 +589,31 @@ class InlayHintVisitor : public 
RecursiveASTVisitor {
 return true;
   }
 
+  // Carefully recurse into PseudoObjectExprs, which typically incorporate
+  // a syntactic expression and several semantic expressions.
+  bool TraversePseudoObjectExpr(PseudoObjectExpr *E) {
+Expr *SyntacticExpr = E->getSyntacticForm();
+if (isa(SyntacticExpr))
+  // Since the counterpart semantics usually get the identical source
+  // locations as the syntactic one, visiting those would end up presenting
+  // confusing hints e.g., __builtin_dump_struct.
+  // Thus, only traverse the syntactic forms if this is written as a
+  // CallExpr. This leaves the door open in case the arguments in the
+  // syntactic form could possibly get parameter names.
+  return 
RecursiveASTVisitor::TraverseStmt(SyntacticExpr);
+// We don't want the hints for some of the MS property extensions.
+// e.g.
+// struct S {
+//   __declspec(property(get=GetX, put=PutX)) int x[];
+//   void PutX(int y);
+//   void Work(int y) { x = y; } // Bad: `x = y: y`.
+// };
+if (isa(SyntacticExpr))
+  return true;
+// FIXME: Handle other forms of a pseudo object expression.
+return RecursiveASTVisitor::TraversePseudoObjectExpr(E);
+  }
+
   bool VisitCallExpr(CallExpr *E) {
 if (!Cfg.InlayHints.Parameters)
   return true;

diff  --git a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp 
b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
index 20c1cdd985dbc..6e91053632e00 100644
--- a/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ b/clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1709,7 +1709,8 @@ TEST(DesignatorHints, NoCrash) {
 void test() {
   Foo f{A(), $b[[1]]};
 }
-  )cpp", ExpectedHint{".b=", "b"});
+  )cpp",
+ExpectedHint{".b=", "b"});
 }
 
 TEST(InlayHints, RestrictRange) {
@@ -1724,6 +1725,38 @@ TEST(InlayHints, RestrictRange) {
   ElementsAre(labelIs(": int"), labelIs(": char")));
 }
 
+TEST(ParameterHints, PseudoObjectExpr) {
+  Annotations Code(R"cpp(
+struct S {
+  __declspec(property(get=GetX, put=PutX)) int x[];
+  int GetX(int y, int z) { return 42 + y; }
+  void PutX(int) { }
+
+  // This is a PseudoObjectExpression whose syntactic form is a binary
+  // operator.
+  void Work(int y) { x = y; } // Not `x = y: y`.
+};
+
+int printf(const char *Format, ...);
+
+int main() {
+  S s;
+  __builtin_dump_struct(, printf); // Not `Format: 
__builtin_dump_struct()`
+  printf($Param[["Hello, %d"]], 42); // Normal calls are not affected.
+  // This builds a PseudoObjectExpr, but here it's useful for showing the
+  // arguments from the semantic form.
+  return s.x[ $one[[1]] ][ $two[[2]] ]; // `x[y: 1][z: 2]`
+}
+  )cpp");
+  auto TU = TestTU::withCode(Code.code());
+  TU.ExtraArgs.push_back("-fms-extensions");
+  auto AST = TU.build();
+  EXPECT_THAT(inlayHints(AST, std::nullopt),
+  ElementsAre(HintMatcher(ExpectedHint{"Format: ", "Param"}, Code),
+  HintMatcher(ExpectedHint{"y: ", "one"}, Code),
+  HintMatcher(ExpectedHint{"z: ", "two"}, Code)));
+}
+
 TEST(ParameterHints, ArgPacksAndConstructors) {
   assertParameterHints(
   R"cpp(



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


[clang-tools-extra] [clangd] Carefully handle PseudoObjectExprs for inlay hints (PR #71366)

2023-12-02 Thread Nathan Ridge via cfe-commits

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

LGTM, thank you!

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


[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread Thomas Schenker via cfe-commits

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


[flang] [libcxx] [clang] [compiler-rt] [clang-tools-extra] [llvm] [Clang][Sema] Fix qualifier restriction of overriden methods (PR #71696)

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


@@ -18469,9 +18469,22 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
 
 
   // The new class type must have the same or less qualifiers as the old type.
-  if (NewClassTy.isMoreQualifiedThan(OldClassTy)) {
+  if (!OldClassTy.isAtLeastAsQualifiedAs(NewClassTy)) {

shafik wrote:

and also add a release note.

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


[flang] [libcxx] [clang] [compiler-rt] [clang-tools-extra] [llvm] [Clang][Sema] Fix qualifier restriction of overriden methods (PR #71696)

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


@@ -18469,9 +18469,22 @@ bool Sema::CheckOverridingFunctionReturnType(const 
CXXMethodDecl *New,
 
 
   // The new class type must have the same or less qualifiers as the old type.
-  if (NewClassTy.isMoreQualifiedThan(OldClassTy)) {
+  if (!OldClassTy.isAtLeastAsQualifiedAs(NewClassTy)) {

shafik wrote:

In the comment right above we can add a standard reference see: 
https://eel.is/c++draft/class.virtual#8

e.g.

```cpp
// C++ [class.virtual]p8:
//   The return type of an overriding function shall be either identical to the 
return type of the overridden function or [covariant]
```

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


[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread Thomas Schenker via cfe-commits

https://github.com/schenker updated 
https://github.com/llvm/llvm-project/pull/74215

>From e6afca50ae820ec2e8cc2d53fa68d09f5cd3b1ed Mon Sep 17 00:00:00 2001
From: Thomas Schenker 
Date: Sat, 2 Dec 2023 11:10:26 +0100
Subject: [PATCH 1/2] [clang-tidy] readability-container-contains literal
 suffixes

Before this PR, readability-container-contains fixits did not handle
integer literal suffixes correctly. It e.g. changed
```
  MyMap.count(2) != 0U;
```
into
```
  MyMap.contains(2)U;
```

With this PR, it correctly changes it to
```
  MyMap.contains(2);
```
---
 .../readability/ContainerContainsCheck.cpp|  4 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 +++
 .../readability/container-contains.cpp| 31 +++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
index 970ed8b83e0a7..dbb50a060e596 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -131,8 +131,8 @@ void ContainerContainsCheck::check(const 
MatchFinder::MatchResult ) {
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(ComparisonBegin, CallBegin),
   Negated ? "!" : "");
-  Diag << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
-  CallEnd.getLocWithOffset(1), ComparisonEnd.getLocWithOffset(1)));
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  CallEnd.getLocWithOffset(1), ComparisonEnd));
 }
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d5f49dc06254..bdc44d6e4c14e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -399,6 +399,10 @@ Changes in existing checks
   ` diagnositics to
   highlight the const location
 
+- Improved :doc:`readability-container-contains
+  ` to correctly handle
+  interger literals with suffixes in fixits.
+
 - Improved :doc:`readability-container-size-empty
   ` check to
   detect comparison between string and empty string literals and support
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
index 05a4ebc9c8a17..0ecb61b2e7df0 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -175,6 +175,37 @@ int nonRewrittenCount(std::multimap ) {
   return C1 + C2 + C3 + C4;
 }
 
+// Check different integer literal suffixes
+int testDifferentIntegerLiteralSuffixes(std::map ) {
+
+  auto C1 = MyMap.count(2) != 0U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C1 = MyMap.contains(2);
+  auto C2 = MyMap.count(2) != 0UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = MyMap.contains(2);
+  auto C3 = 0U != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = 0UL != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(2);
+  auto C5 = MyMap.count(2) < 1U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(2);
+  auto C6 = MyMap.count(2) < 1UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C6 = !MyMap.contains(2);
+  auto C7 = 1U > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C7 = !MyMap.contains(2);
+  auto C8 = 1UL > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C8 = !MyMap.contains(2);
+
+  return C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8;
+}
+
 // We don't want to rewrite if the `contains` call is from a macro expansion
 int testMacroExpansion(std::unordered_set ) {
 #define COUNT_ONES(SET) SET.count(1)

>From 61af3ce59ced216bece6ed22ef764aa99a1362f3 Mon Sep 17 00:00:00 2001
From: Thomas Schenker 
Date: Sun, 3 Dec 2023 07:43:09 +0100
Subject: [PATCH 2/2] fix typo

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

diff --git 

[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

https://lab.llvm.org/buildbot/#/builders/123/builds/23364 stage 1 checks run 
successfully. You can close this PR as superseded by 
19bef888a8c7c58bdf94d377fc485e050efb

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Thank you for looking into this!

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

It was my commit that broke bots, so it is only appropriate to tag me on this.
I committed a different fix just now 19bef888a8c7c58bdf94d377fc485e050efb

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


[clang] 19bef88 - [clang][NFC] Adjust expected directives in DR tests further

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-03T09:02:58+03:00
New Revision: 19bef888a8c7c58bdf94d377fc485e050efb

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

LOG: [clang][NFC] Adjust expected directives in DR tests further

This is a follow-up to 96070e1e4c13f53c2cef8178d64e206162923f54, where long 
long case was hidden by a different error.

Addresses bot failures:
https://lab.llvm.org/buildbot/#/builders/123/builds/23355

Added: 


Modified: 
clang/test/CXX/drs/dr2xx.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 4dd6d7599f2a0..bc862e26ff667 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1298,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
+  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned (long 
long|long|int)' is ambiguous
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }



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


[libcxx] [flang] [lldb] [compiler-rt] [llvm] [libc] [clang] [lld] Work around GCC test failure that is caused by enabling optimizations. (PR #73998)

2023-12-02 Thread via cfe-commits

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Sizov Nikita via cfe-commits

https://github.com/snikitav updated 
https://github.com/llvm/llvm-project/pull/74223

>From 41bae56752441a2b2e23ff04e3f0a03ef0d95743 Mon Sep 17 00:00:00 2001
From: Sizov Nikita 
Date: Sun, 3 Dec 2023 06:56:08 +0300
Subject: [PATCH] Fix crash for windows clang unittest

---
 clang/test/CXX/drs/dr2xx.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 4dd6d7599f2a0..582993ba7fe71 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1298,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
+  // since-cxx14-error-re@#dr299-q {{conversion from 'T' to 'unsigned 
{{(long|int)}}' is ambiguous}}
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Sizov Nikita via cfe-commits

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Sizov Nikita via cfe-commits

https://github.com/snikitav updated 
https://github.com/llvm/llvm-project/pull/74223

>From 661c42716c494bb27449c2dd81e03cf0945f1cf1 Mon Sep 17 00:00:00 2001
From: Sizov Nikita 
Date: Sun, 3 Dec 2023 06:56:08 +0300
Subject: [PATCH] Fix crash for windows clang unittest

---
 clang/test/CXX/drs/dr2xx.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 4dd6d7599f2a..4167b4363648 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1298,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
+  // since-cxx14-error-re@#dr299-q {{conversion from 'T' to 'unsigned 
{{long|int}}' is ambiguous}}
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Sizov Nikita via cfe-commits

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Sizov Nikita via cfe-commits

snikitav wrote:

@Endilll Im'sorry, not sure what to do in this situation, but I think current 
master CI is broken and my patch might fix it. Is it ok to tag you or other 
people, or should I wait for autoassigned reviewers?

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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sizov Nikita (snikitav)


Changes

Currently windows build fails with:

```
# | error: 'cxx98-14-error' diagnostics expected but not seen: 
# |   File C:\ws\src\clang\test\CXX\drs\dr2xx.cpp Line 1297 (directive at 
C:\ws\src\clang\test\CXX\drs\dr2xx.cpp:1301): {{conversion from 'T' to 
'unsigned (long|int)' is ambiguous}}
```

Obviously, there is an excessive pair of brackets

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


1 Files Affected:

- (modified) clang/test/CXX/drs/dr2xx.cpp (+1-1) 


``diff
diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 4dd6d7599f2a0..170753e5efce4 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1298,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
+  // since-cxx14-error-re@#dr299-q {{conversion from 'T' to 'unsigned 
(long|int)' is ambiguous}}
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }

``




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


[clang] Fix dr2xx clang test (PR #74223)

2023-12-02 Thread Sizov Nikita via cfe-commits

https://github.com/snikitav created 
https://github.com/llvm/llvm-project/pull/74223

Currently windows build fails with:

```
# | error: 'cxx98-14-error' diagnostics expected but not seen: 
# |   File C:\ws\src\clang\test\CXX\drs\dr2xx.cpp Line 1297 (directive at 
C:\ws\src\clang\test\CXX\drs\dr2xx.cpp:1301): {{conversion from 'T' to 
'unsigned (long|int)' is ambiguous}}
```

Obviously, there is an excessive pair of brackets

>From 17cb937a233290627ea90778a0fafb968f03091b Mon Sep 17 00:00:00 2001
From: Sizov Nikita 
Date: Sun, 3 Dec 2023 06:56:08 +0300
Subject: [PATCH] Fix crash for windows clang unittest

---
 clang/test/CXX/drs/dr2xx.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 4dd6d7599f2a0..170753e5efce4 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1298,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
+  // since-cxx14-error-re@#dr299-q {{conversion from 'T' to 'unsigned 
(long|int)' is ambiguous}}
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }

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


[llvm] [clang] Missing opt with ctlz and shifts of power of 2 constants (#41333) (PR #74175)

2023-12-02 Thread Sizov Nikita via cfe-commits

https://github.com/snikitav updated 
https://github.com/llvm/llvm-project/pull/74175

>From cb2bdf4a4cb9db2262920a0a474e2024e7a1406a Mon Sep 17 00:00:00 2001
From: Sizov Nikita 
Date: Sat, 2 Dec 2023 04:53:32 +0300
Subject: [PATCH] Missing opt with ctlz and shifts of power of 2 constants
 (#41333)

---
 clang/test/CXX/drs/dr2xx.cpp  |   2 +-
 .../InstCombine/InstCombineCalls.cpp  |  33 +++
 .../InstCombine/ctlz-cttz-shifts.ll   | 243 ++
 3 files changed, 277 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Transforms/InstCombine/ctlz-cttz-shifts.ll

diff --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 4dd6d7599f2a0..170753e5efce4 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1298,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
+  // since-cxx14-error-re@#dr299-q {{conversion from 'T' to 'unsigned 
(long|int)' is ambiguous}}
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index a991f0906052a..f6322b3f4f415 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -514,6 +514,8 @@ static Instruction *foldCttzCtlz(IntrinsicInst , 
InstCombinerImpl ) {
 return IC.replaceInstUsesWith(II, ConstantInt::getNullValue(II.getType()));
   }
 
+  Constant *C;
+
   if (IsTZ) {
 // cttz(-x) -> cttz(x)
 if (match(Op0, m_Neg(m_Value(X
@@ -549,6 +551,37 @@ static Instruction *foldCttzCtlz(IntrinsicInst , 
InstCombinerImpl ) {
 
 if (match(Op0, m_Intrinsic(m_Value(X
   return IC.replaceOperand(II, 0, X);
+
+// cttz(shl(%const, %val), 1) --> add(cttz(%const, 1), %val)
+if (match(Op0, m_Shl(m_Constant(C), m_Value(X))) && match(Op1, m_One())) {
+  Value *ConstCttz =
+  IC.Builder.CreateBinaryIntrinsic(Intrinsic::cttz, C, Op1);
+  return BinaryOperator::CreateAdd(ConstCttz, X);
+}
+
+// cttz(lshr exact (%const, %val), 0) --> sub(cttz(%const, 0), %val)
+if (match(Op0, m_Exact(m_LShr(m_Constant(C), m_Value(X) {
+  Value *ConstCttz =
+  IC.Builder.CreateBinaryIntrinsic(Intrinsic::cttz, C, Op1);
+  return BinaryOperator::CreateSub(ConstCttz, X);
+}
+  } else {
+// ctlz(lshr(%const, %val), 1) --> add(ctlz(%const, 1), %val)
+if (match(Op0, m_LShr(m_Constant(C), m_Value(X))) && match(Op1, m_One())) {
+  Value *ConstCtlz =
+  IC.Builder.CreateBinaryIntrinsic(Intrinsic::ctlz, C, Op1);
+  return BinaryOperator::CreateAdd(ConstCtlz, X);
+}
+
+// ctlz(shl nuw (%const, %val), 0) |
+// ctlz(shl nsw (%const, %val), 0) |--> sub(ctlz(%const, 0), %val)
+// ctlz(shl nuw nsw (%const, %val), 0) |
+if (match(Op0, m_NUWShl(m_Constant(C), m_Value(X))) ||
+match(Op0, m_NSWShl(m_Constant(C), m_Value(X {
+  Value *ConstCtlz =
+  IC.Builder.CreateBinaryIntrinsic(Intrinsic::ctlz, C, Op1);
+  return BinaryOperator::CreateSub(ConstCtlz, X);
+}
   }
 
   KnownBits Known = IC.computeKnownBits(Op0, 0, );
diff --git a/llvm/test/Transforms/InstCombine/ctlz-cttz-shifts.ll 
b/llvm/test/Transforms/InstCombine/ctlz-cttz-shifts.ll
new file mode 100644
index 0..5abe5ab6c9310
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/ctlz-cttz-shifts.ll
@@ -0,0 +1,243 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 4
+; RUN: opt -passes=instcombine -S < %s | FileCheck %s
+
+declare i32 @llvm.ctlz.i32(i32, i1)
+declare i32 @llvm.cttz.i32(i32, i1)
+declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1)
+declare <2 x i32> @llvm.cttz.v2i32(<2 x i32>, i1)
+
+define i32 @lshr_ctlz_true(i32) {
+; CHECK-LABEL: define i32 @lshr_ctlz_true(
+; CHECK-SAME: i32 [[TMP0:%.*]]) {
+; CHECK-NEXT:[[CTLZ:%.*]] = add i32 [[TMP0]], 9
+; CHECK-NEXT:ret i32 [[CTLZ]]
+;
+  %lshr = lshr i32 8387584, %0
+  %ctlz = call i32 @llvm.ctlz.i32(i32 %lshr, i1 true)
+  ret i32 %ctlz
+}
+
+define i32 @shl_nuw_ctlz_false(i32) {
+; CHECK-LABEL: define i32 @shl_nuw_ctlz_false(
+; CHECK-SAME: i32 [[TMP0:%.*]]) {
+; CHECK-NEXT:[[CTLZ:%.*]] = sub i32 9, [[TMP0]]
+; CHECK-NEXT:ret i32 [[CTLZ]]
+;
+  %shl = shl nuw i32 8387584, %0
+  %ctlz = call i32 @llvm.ctlz.i32(i32 %shl, i1 false)
+  ret i32 %ctlz
+}
+
+define i32 @shl_nsw_ctlz_false(i32) {
+; CHECK-LABEL: define i32 

[clang] [clang] assert fail when number of arguments in pack exceed implement… (PR #74220)

2023-12-02 Thread via cfe-commits

wheatman wrote:

This is designed to detect bugs like 
https://github.com/llvm/llvm-project/issues/71888 with an assert instead of 
silently changing the meaning of the code.

an example of the code which the assert will trigger on is 
```
#include 
#include 


template 
  constexpr auto static make_helper(std::index_sequence) {
return std::array{I...};
  }

int main(int argc, char *argv[]) {
  static constexpr auto foos = 
make_helper(std::make_index_sequence<1UL << 16>{});
  return foos[argc];
}
```

Before this would lead to an error like 
```
:8:42: error: initializer for aggregate with no elements requires 
explicit braces
8 | return std::array{I...};
```
since it thinks the pack has zero size, but finds elements in there
https://godbolt.org/z/9qYhcKKqe

afterwards it fails with the assert and backtrace like

```
clang-17: /home/wheatman/llvm-project/clang/lib/AST/ExprCXX.cpp:1684: 
clang::SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(clang::QualType,
 clang::ExprValueKind, clang::SourceLocation, const clang::TemplateArgument &, 
clang::Decl *, unsigned int): Assertion `NumArguments == ArgPack.pack_size() && 
"number of arguments in a pack exceeded implementation limit"' 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: /home/wheatman/llvm-project/build/bin/clang-17 -cc1 
-triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -dumpdir a- 
-disable-free -clear-ast-before-backend -main-file-name crash4.cpp 
-mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all 
-fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases 
-funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb 
-fdebug-compilation-dir=/home/wheatman/llvm-project 
-fcoverage-compilation-dir=/home/wheatman/llvm-project -resource-dir 
/home/wheatman/llvm-project/build/lib/clang/18 -internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11 -internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/x86_64-linux-gnu/c++/11 
-internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/backward 
-internal-isystem /home/wheatman/llvm-project/build/lib/clang/18/include 
-internal-isystem /usr/local/include -internal-isystem 
/usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include 
-internal-externc-isystem /usr/include/x86_64-linux-gnu 
-internal-externc-isystem /include -internal-externc-isystem /usr/include 
-std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 
-fno-implicit-modules -fcxx-exceptions -fexceptions -faddrsig 
-D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/crash4-ef5f78.o -x c++ crash4.cpp
1.  crash4.cpp:12:56: current parser token ')'
2.  crash4.cpp:10:34: parsing function body 'main'
3.  crash4.cpp:10:34: in compound statement ('{}')
4.  crash4.cpp:6:23: instantiating function definition 'make_helper<0UL, 
..., 65535UL>'
 #0 0x55a1ae8d23ad llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/wheatman/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x55a1ae8d289b PrintStackTraceSignalHandler(void*) 
/home/wheatman/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x55a1ae8d08c6 llvm::sys::RunSignalHandlers() 
/home/wheatman/llvm-project/llvm/lib/Support/Signals.cpp:105:5
 #3 0x55a1ae8d30b5 SignalHandler(int) 
/home/wheatman/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x7fe812eda520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x7fe812f2e9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x7fe812f2e9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x7fe812f2e9fc pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x7fe812eda476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x7fe812ec07f3 abort ./stdlib/abort.c:81:7
#10 0x7fe812ec071b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#11 0x7fe812ed1e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#12 0x55a1b4c6ec4f 
clang::SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(clang::QualType,
 clang::ExprValueKind, clang::SourceLocation, clang::TemplateArgument const&, 
clang::Decl*, unsigned int) 
/home/wheatman/llvm-project/clang/lib/AST/ExprCXX.cpp:0:3
#13 0x55a1b3e348db (anonymous 
namespace)::TemplateInstantiator::TransformTemplateParmRefExpr(clang::DeclRefExpr*,
 clang::NonTypeTemplateParmDecl*) 
/home/wheatman/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:1866:36
#14 0x55a1b3e2378a (anonymous 
namespace)::TemplateInstantiator::TransformDeclRefExpr(clang::DeclRefExpr*) 
/home/wheatman/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:2130:14
#15 0x55a1b3e14af6 clang::TreeTransform<(anonymous 
namespace)::TemplateInstantiator>::TransformExpr(clang::Expr*) 

[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread via cfe-commits


@@ -399,6 +399,10 @@ Changes in existing checks
   ` diagnositics to
   highlight the const location
 
+- Improved :doc:`readability-container-contains
+  ` to correctly handle
+  interger literals with suffixes in fixits.

EugeneZelenko wrote:

`fix-its`.

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


[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread via cfe-commits

https://github.com/EugeneZelenko requested changes to this pull request.


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


[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread via cfe-commits

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


[clang] [clang] assert fail when number of arguments in pack exceed implement… (PR #74220)

2023-12-02 Thread via cfe-commits

https://github.com/wheatman updated 
https://github.com/llvm/llvm-project/pull/74220

>From 86e187f7f13c5cbb0d1afb9ebbe9c0e7022269a6 Mon Sep 17 00:00:00 2001
From: Brian Wheatman 
Date: Sat, 2 Dec 2023 22:17:24 -0500
Subject: [PATCH] [clang] assert fail when number of arguments in pack exceed
 implementation limit

---
 clang/lib/AST/ExprCXX.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 83af7998f6833..2509a6ddadd19 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1681,6 +1681,8 @@ 
SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
   AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
   NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) {
   assert(AssociatedDecl != nullptr);
+  assert(NumArguments == ArgPack.pack_size() &&
+ "number of arguments in a pack exceeded implementation limit");
   setDependence(ExprDependence::TypeValueInstantiation |
 ExprDependence::UnexpandedPack);
 }

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


[clang] [clang] assert fail when number of arguments in pack exceed implement… (PR #74220)

2023-12-02 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 38f75d606f94e6b552fd74d487b061a1f8f907fa 
8990877d381639d8498630fd4e9b30732ab893d6 -- clang/lib/AST/ExprCXX.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 5798321ea5..2509a6ddad 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1681,7 +1681,8 @@ 
SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
   AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
   NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) {
   assert(AssociatedDecl != nullptr);
-  assert(NumArguments == ArgPack.pack_size() && "number of arguments in a pack 
exceeded implementation limit");
+  assert(NumArguments == ArgPack.pack_size() &&
+ "number of arguments in a pack exceeded implementation limit");
   setDependence(ExprDependence::TypeValueInstantiation |
 ExprDependence::UnexpandedPack);
 }

``




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


[clang] [clang] assert fail when number of arguments in pack exceed implement… (PR #74220)

2023-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (wheatman)


Changes

…ation limit

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


1 Files Affected:

- (modified) clang/lib/AST/ExprCXX.cpp (+1) 


``diff
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 83af7998f6833..5798321ea59f3 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1681,6 +1681,7 @@ 
SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
   AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
   NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) {
   assert(AssociatedDecl != nullptr);
+  assert(NumArguments == ArgPack.pack_size() && "number of arguments in a pack 
exceeded implementation limit");
   setDependence(ExprDependence::TypeValueInstantiation |
 ExprDependence::UnexpandedPack);
 }

``




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


[clang] [clang] assert fail when number of arguments in pack exceed implement… (PR #74220)

2023-12-02 Thread via cfe-commits

https://github.com/wheatman created 
https://github.com/llvm/llvm-project/pull/74220

…ation limit

>From 8990877d381639d8498630fd4e9b30732ab893d6 Mon Sep 17 00:00:00 2001
From: Brian Wheatman 
Date: Sat, 2 Dec 2023 22:17:24 -0500
Subject: [PATCH] [clang] assert fail when number of arguments in pack exceed
 implementation limit

---
 clang/lib/AST/ExprCXX.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 83af7998f6833..5798321ea59f3 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1681,6 +1681,7 @@ 
SubstNonTypeTemplateParmPackExpr::SubstNonTypeTemplateParmPackExpr(
   AssociatedDecl(AssociatedDecl), Arguments(ArgPack.pack_begin()),
   NumArguments(ArgPack.pack_size()), Index(Index), NameLoc(NameLoc) {
   assert(AssociatedDecl != nullptr);
+  assert(NumArguments == ArgPack.pack_size() && "number of arguments in a pack 
exceeded implementation limit");
   setDependence(ExprDependence::TypeValueInstantiation |
 ExprDependence::UnexpandedPack);
 }

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


[flang] [libc] [libcxx] [lld] [lldb] [compiler-rt] [clang] [llvm] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-02 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/74000

>From 672b71cc1003533460a82f06b7d24fbdc02ffd58 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Thu, 30 Nov 2023 14:44:07 -0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../lib/hwasan/hwasan_interceptors.cpp|  8 ++---
 .../test/hwasan/TestCases/memset-recover.cpp  | 32 +++
 2 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100644 compiler-rt/test/hwasan/TestCases/memset-recover.cpp

diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp 
b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index d9237cf9b8e3b..ee7166c942bbe 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -36,10 +36,10 @@ struct HWAsanInterceptorContext {
   const char *interceptor_name;
 };
 
-#  define ACCESS_MEMORY_RANGE(ctx, offset, size, access)\
-do {\
-  __hwasan::CheckAddressSized((uptr)offset, \
-  size);\
+#  define ACCESS_MEMORY_RANGE(ctx, offset, size, access)  \
+do {  \
+  __hwasan::CheckAddressSized((uptr)offset, \
+size);\
 } while (0)
 
 #  define HWASAN_READ_RANGE(ctx, offset, size) \
diff --git a/compiler-rt/test/hwasan/TestCases/memset-recover.cpp 
b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
new file mode 100644
index 0..e29e7c412033e
--- /dev/null
+++ b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
@@ -0,0 +1,32 @@
+// RUN: %clangxx_hwasan %s -o %t
+// RUN: %env_hwasan_opts=halt_on_error=0 not %run %t 2>&1 | FileCheck %s 
--implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
+// RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s 
--implicit-check-not=RETURN_FROM_TEST
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+__attribute__((no_sanitize("hwaddress"))) void
+ForceCallInterceptor(void *p, int c, size_t size) {
+  memset(p, c, size) == nullptr;
+}
+
+int main(int argc, char **argv) {
+  __hwasan_enable_allocator_tagging();
+  char a[] = {static_cast(argc), 2, 3, 4};
+  int size = sizeof(a);
+  char *volatile p = (char *)malloc(size);
+  void *volatile p2 = p;
+  for (int i = 0; p2 == p; p2 = __hwasan_tag_pointer(p, ++i)) {
+  }
+  ForceCallInterceptor(p2, 0, size);
+  free(p);
+  fprintf(stderr,  "RETURN_FROM_TEST\n");
+  return 0;
+  // CHECK: HWAddressSanitizer: tag-mismatch on address
+  // CHECK: WRITE of size 4
+  // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main 
{{.*}}memset-recover.cpp:[[@LINE-28]]
+  // RECOVER: RETURN_FROM_TEST
+}

>From 34550bbb8168aeae0e74b29d85ab92fdea50a9bd Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Thu, 30 Nov 2023 14:45:22 -0800
Subject: [PATCH 2/3] format

Created using spr 1.3.4
---
 compiler-rt/test/hwasan/TestCases/memset-recover.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/test/hwasan/TestCases/memset-recover.cpp 
b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
index e29e7c412033e..093a0179347be 100644
--- a/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
+++ b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
@@ -3,10 +3,10 @@
 // RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s 
--implicit-check-not=RETURN_FROM_TEST
 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 __attribute__((no_sanitize("hwaddress"))) void
 ForceCallInterceptor(void *p, int c, size_t size) {
@@ -23,7 +23,7 @@ int main(int argc, char **argv) {
   }
   ForceCallInterceptor(p2, 0, size);
   free(p);
-  fprintf(stderr,  "RETURN_FROM_TEST\n");
+  fprintf(stderr, "RETURN_FROM_TEST\n");
   return 0;
   // CHECK: HWAddressSanitizer: tag-mismatch on address
   // CHECK: WRITE of size 4

>From 76e1e45922e6709392fb82aac44bebe3dbc2ea63 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Sat, 2 Dec 2023 16:56:22 -0800
Subject: [PATCH 3/3] simplify

Created using spr 1.3.4
---
 compiler-rt/lib/hwasan/hwasan_interceptors.cpp | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp 
b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index 023cba9c8be2f..96df4dd0c24d7 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -74,10 +74,8 @@ struct HWAsanInterceptorContext {
 
 #  if HWASAN_WITH_INTERCEPTORS
 
-#define COMMON_SYSCALL_PRE_READ_RANGE(p, s) \
-  ACCESS_MEMORY_RANGE((uptr)p, (uptr)s, 

[clang] Remove warnings from -Wchar-subscripts for known positive constants (PR #69061)

2023-12-02 Thread via cfe-commits

https://github.com/wheatman updated 
https://github.com/llvm/llvm-project/pull/69061

>From 894e8623689abe615600d768ef4fbedea78ab799 Mon Sep 17 00:00:00 2001
From: Brian Wheatman 
Date: Sat, 14 Oct 2023 12:02:19 -0400
Subject: [PATCH] Remove warnings from -Wchar-subscripts for known positive
 constants

---
 clang/docs/ReleaseNotes.rst  |   2 +
 clang/lib/Sema/SemaExpr.cpp  |  11 ++-
 clang/test/Sema/warn-char-subscripts.c   |  25 ++
 clang/test/Sema/warn-char-subscripts.cpp | 103 +++
 4 files changed, 138 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/Sema/warn-char-subscripts.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c7a948fd3fae5..683d0026bb345 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -651,6 +651,8 @@ 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 `_)
+- Clang's ``-Wchar-subscripts`` no longer warns on chars whose values are 
known non-negative constants.
+  Fixes (`#18763 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d1b2b8084b8ff..d629be083d8c3 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6053,9 +6053,14 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, 
SourceLocation LLoc,
  << IndexExpr->getSourceRange());
 
   if ((IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_S) ||
-   IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U))
- && !IndexExpr->isTypeDependent())
-Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
+   IndexExpr->getType()->isSpecificBuiltinType(BuiltinType::Char_U)) &&
+  !IndexExpr->isTypeDependent()) {
+std::optional IntegerContantExpr =
+IndexExpr->getIntegerConstantExpr(getASTContext());
+if (!IntegerContantExpr.has_value() ||
+IntegerContantExpr.value().isNegative())
+  Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
+  }
 
   // C99 6.5.2.1p1: "shall have type "pointer to *object* type". Similarly,
   // C++ [expr.sub]p1: The type "T" shall be a completely-defined object
diff --git a/clang/test/Sema/warn-char-subscripts.c 
b/clang/test/Sema/warn-char-subscripts.c
index 2e72d90fa612a..0a012f68feae0 100644
--- a/clang/test/Sema/warn-char-subscripts.c
+++ b/clang/test/Sema/warn-char-subscripts.c
@@ -62,3 +62,28 @@ void t10(void) {
   UnsignedCharTy subscript = 0;
   int val = array[subscript]; // no warning for unsigned char
 }
+
+void t11(void) {
+  int array[256] = { 0 };
+  int val = array['a']; // no warning for char with known positive value
+}
+
+void t12(void) {
+  int array[256] = { 0 };
+  char b = 'a';
+  int val = array[b]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void t13(void) {
+  int array[256] = { 0 };
+  const char b = 'a';
+  int val = array[b]; // expected-warning{{array subscript is of type 'char'}}
+}
+
+void t14(void) {
+  int array[256] = { 0 }; // expected-note {{array 'array' declared here}}
+  const char b = -1;
+  // expected-warning@+2 {{array subscript is of type 'char'}}
+  // expected-warning@+1 {{array index -1 is before the beginning of the 
array}}
+  int val = array[b];
+}
diff --git a/clang/test/Sema/warn-char-subscripts.cpp 
b/clang/test/Sema/warn-char-subscripts.cpp
new file mode 100644
index 0..929fb372c5173
--- /dev/null
+++ b/clang/test/Sema/warn-char-subscripts.cpp
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -Wchar-subscripts -fsyntax-only -verify %s
+
+void t1(void) {
+  int array[1] = { 0 };
+  char subscript = 0;
+  int val = array[subscript]; // expected-warning{{array subscript is of type 
'char'}}
+}
+
+void t2(void) {
+  int array[1] = { 0 };
+  char subscript = 0;
+  int val = subscript[array]; // expected-warning{{array subscript is of type 
'char'}}
+}
+
+void t3(void) {
+  int *array = 0;
+  char subscript = 0;
+  int val = array[subscript]; // expected-warning{{array subscript is of type 
'char'}}
+}
+
+void t4(void) {
+  int *array = 0;
+  char subscript = 0;
+  int val = subscript[array]; // expected-warning{{array subscript is of type 
'char'}}
+}
+
+char returnsChar(void);
+void t5(void) {
+  int *array = 0;
+  int val = array[returnsChar()]; // expected-warning{{array subscript is of 
type 'char'}}
+}
+
+void t6(void) {
+  int array[1] = { 0 };
+  signed char subscript = 0;
+  int val = array[subscript]; // no warning for explicit signed char
+}
+
+void t7(void) {
+  int array[1] = { 0 };
+  unsigned char subscript = 0;
+  int val = array[subscript]; // no warning for unsigned char
+}
+
+typedef char CharTy;
+void t8(void) {
+  int array[1] 

[lld] [lldb] [llvm] [flang] [clang] [libc] [compiler-rt] [libcxx] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-02 Thread Vitaly Buka via cfe-commits

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


[lld] [lldb] [llvm] [flang] [clang] [libc] [compiler-rt] [libcxx] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-02 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

> [mmalcomson](/mmalcomson)



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


[llvm] [lld] [libcxx] [flang] [clang] [lldb] [libc] [compiler-rt] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-02 Thread Vitaly Buka via cfe-commits

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


[llvm] [lld] [libcxx] [flang] [clang] [lldb] [libc] [compiler-rt] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-02 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/74000

>From 672b71cc1003533460a82f06b7d24fbdc02ffd58 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Thu, 30 Nov 2023 14:44:07 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 .../lib/hwasan/hwasan_interceptors.cpp|  8 ++---
 .../test/hwasan/TestCases/memset-recover.cpp  | 32 +++
 2 files changed, 36 insertions(+), 4 deletions(-)
 create mode 100644 compiler-rt/test/hwasan/TestCases/memset-recover.cpp

diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp 
b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
index d9237cf9b8e3b..ee7166c942bbe 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
@@ -36,10 +36,10 @@ struct HWAsanInterceptorContext {
   const char *interceptor_name;
 };
 
-#  define ACCESS_MEMORY_RANGE(ctx, offset, size, access)\
-do {\
-  __hwasan::CheckAddressSized((uptr)offset, \
-  size);\
+#  define ACCESS_MEMORY_RANGE(ctx, offset, size, access)  \
+do {  \
+  __hwasan::CheckAddressSized((uptr)offset, \
+size);\
 } while (0)
 
 #  define HWASAN_READ_RANGE(ctx, offset, size) \
diff --git a/compiler-rt/test/hwasan/TestCases/memset-recover.cpp 
b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
new file mode 100644
index 0..e29e7c412033e
--- /dev/null
+++ b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
@@ -0,0 +1,32 @@
+// RUN: %clangxx_hwasan %s -o %t
+// RUN: %env_hwasan_opts=halt_on_error=0 not %run %t 2>&1 | FileCheck %s 
--implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
+// RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s 
--implicit-check-not=RETURN_FROM_TEST
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+__attribute__((no_sanitize("hwaddress"))) void
+ForceCallInterceptor(void *p, int c, size_t size) {
+  memset(p, c, size) == nullptr;
+}
+
+int main(int argc, char **argv) {
+  __hwasan_enable_allocator_tagging();
+  char a[] = {static_cast(argc), 2, 3, 4};
+  int size = sizeof(a);
+  char *volatile p = (char *)malloc(size);
+  void *volatile p2 = p;
+  for (int i = 0; p2 == p; p2 = __hwasan_tag_pointer(p, ++i)) {
+  }
+  ForceCallInterceptor(p2, 0, size);
+  free(p);
+  fprintf(stderr,  "RETURN_FROM_TEST\n");
+  return 0;
+  // CHECK: HWAddressSanitizer: tag-mismatch on address
+  // CHECK: WRITE of size 4
+  // CHECK: #{{[[:digit:]]+}} 0x{{[[:xdigit:]]+}} in main 
{{.*}}memset-recover.cpp:[[@LINE-28]]
+  // RECOVER: RETURN_FROM_TEST
+}

>From 34550bbb8168aeae0e74b29d85ab92fdea50a9bd Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Thu, 30 Nov 2023 14:45:22 -0800
Subject: [PATCH 2/2] format

Created using spr 1.3.4
---
 compiler-rt/test/hwasan/TestCases/memset-recover.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/compiler-rt/test/hwasan/TestCases/memset-recover.cpp 
b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
index e29e7c412033e..093a0179347be 100644
--- a/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
+++ b/compiler-rt/test/hwasan/TestCases/memset-recover.cpp
@@ -3,10 +3,10 @@
 // RUN: %env_hwasan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s 
--implicit-check-not=RETURN_FROM_TEST
 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 __attribute__((no_sanitize("hwaddress"))) void
 ForceCallInterceptor(void *p, int c, size_t size) {
@@ -23,7 +23,7 @@ int main(int argc, char **argv) {
   }
   ForceCallInterceptor(p2, 0, size);
   free(p);
-  fprintf(stderr,  "RETURN_FROM_TEST\n");
+  fprintf(stderr, "RETURN_FROM_TEST\n");
   return 0;
   // CHECK: HWAddressSanitizer: tag-mismatch on address
   // CHECK: WRITE of size 4

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


[clang] [lldb] [flang] [lld] [llvm] [libc] [compiler-rt] [libcxx] Work around GCC test failure that is caused by enabling optimizations. (PR #73998)

2023-12-02 Thread via cfe-commits

https://github.com/EricWF updated 
https://github.com/llvm/llvm-project/pull/73998

>From 2e7676bac9fb0c8694dd1ee635508ae4d4a6421d Mon Sep 17 00:00:00 2001
From: Eric Fiselier 
Date: Thu, 30 Nov 2023 17:23:37 -0500
Subject: [PATCH 1/3] Work around GCC test failure that is caused by enabling
 optimizations.

While trying to work around MSAN/TSAN build timeouts, we enabled
optimizations on some tests. This caused GCC to start complaining that
some values may be uninitialized. I believe GCC is wrong, but more
investigation is needed.

The values are initialized when the variable `__g` is either < 0 or >=
0. Which only leaves out NaN I believe, which is likely well into UB
   land anyway.

However, more investigation needed.
---
 .../rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp  | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
index 9ab8b6f427492..d0f6fbf0a1203 100644
--- 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
+++ 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -10,7 +10,11 @@
 
 // This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
 // spend less time waiting for this particular test to complete we compile 
with optimizations.
-// ADDITIONAL_COMPILE_FLAGS: -O1
+// ADDITIONAL_COMPILE_FLAGS(msan): -O1
+// ADDITIONAL_COMPILE_FLAGS(tsan): -O1
+
+// FIXME: This and other tests fail under GCC with optimizations enabled.
+// More investigation is needed, but it appears that  GCC is performing more 
constant folding.
 
 // 
 

>From d3a46c128fd597ca193c7f698f5fab3eb5784e66 Mon Sep 17 00:00:00 2001
From: eric 
Date: Sat, 2 Dec 2023 17:19:02 -0500
Subject: [PATCH 2/3] Re-add other slow test

---
 .../deque/deque.modifiers/insert_iter_iter.pass.cpp  | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
 
b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
index 946c2cfabf02b..b99c2b87cc5fe 100644
--- 
a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
+++ 
b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
@@ -9,6 +9,11 @@
 // REQUIRES: long_tests
 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
 
+// This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
+// spend less time waiting for this particular test to complete we compile 
with optimizations.
+// ADDITIONAL_COMPILE_FLAGS(msan): -O1
+// ADDITIONAL_COMPILE_FLAGS(tsan): -O1
+
 // 
 
 // template 

>From e50eb9e9a283d5f0b3cb73cd26507637ff0f1f40 Mon Sep 17 00:00:00 2001
From: eric 
Date: Sat, 2 Dec 2023 19:20:46 -0500
Subject: [PATCH 3/3] satisfy clang format

---
 .../rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
index bc586d3d68626..d0f6fbf0a1203 100644
--- 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
+++ 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -8,7 +8,6 @@
 //
 // REQUIRES: long_tests
 
-
 // This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
 // spend less time waiting for this particular test to complete we compile 
with optimizations.
 // ADDITIONAL_COMPILE_FLAGS(msan): -O1

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


[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread Thomas Schenker via cfe-commits

https://github.com/schenker updated 
https://github.com/llvm/llvm-project/pull/74215

>From e6afca50ae820ec2e8cc2d53fa68d09f5cd3b1ed Mon Sep 17 00:00:00 2001
From: Thomas Schenker 
Date: Sat, 2 Dec 2023 11:10:26 +0100
Subject: [PATCH] [clang-tidy] readability-container-contains literal suffixes

Before this PR, readability-container-contains fixits did not handle
integer literal suffixes correctly. It e.g. changed
```
  MyMap.count(2) != 0U;
```
into
```
  MyMap.contains(2)U;
```

With this PR, it correctly changes it to
```
  MyMap.contains(2);
```
---
 .../readability/ContainerContainsCheck.cpp|  4 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 +++
 .../readability/container-contains.cpp| 31 +++
 3 files changed, 37 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
index 970ed8b83e0a7..dbb50a060e596 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -131,8 +131,8 @@ void ContainerContainsCheck::check(const 
MatchFinder::MatchResult ) {
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(ComparisonBegin, CallBegin),
   Negated ? "!" : "");
-  Diag << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
-  CallEnd.getLocWithOffset(1), ComparisonEnd.getLocWithOffset(1)));
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  CallEnd.getLocWithOffset(1), ComparisonEnd));
 }
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d5f49dc06254..bdc44d6e4c14e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -399,6 +399,10 @@ Changes in existing checks
   ` diagnositics to
   highlight the const location
 
+- Improved :doc:`readability-container-contains
+  ` to correctly handle
+  interger literals with suffixes in fixits.
+
 - Improved :doc:`readability-container-size-empty
   ` check to
   detect comparison between string and empty string literals and support
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
index 05a4ebc9c8a17..0ecb61b2e7df0 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -175,6 +175,37 @@ int nonRewrittenCount(std::multimap ) {
   return C1 + C2 + C3 + C4;
 }
 
+// Check different integer literal suffixes
+int testDifferentIntegerLiteralSuffixes(std::map ) {
+
+  auto C1 = MyMap.count(2) != 0U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C1 = MyMap.contains(2);
+  auto C2 = MyMap.count(2) != 0UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = MyMap.contains(2);
+  auto C3 = 0U != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = 0UL != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(2);
+  auto C5 = MyMap.count(2) < 1U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(2);
+  auto C6 = MyMap.count(2) < 1UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C6 = !MyMap.contains(2);
+  auto C7 = 1U > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C7 = !MyMap.contains(2);
+  auto C8 = 1UL > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C8 = !MyMap.contains(2);
+
+  return C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8;
+}
+
 // We don't want to rewrite if the `contains` call is from a macro expansion
 int testMacroExpansion(std::unordered_set ) {
 #define COUNT_ONES(SET) SET.count(1)

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


[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread Thomas Schenker via cfe-commits

https://github.com/schenker updated 
https://github.com/llvm/llvm-project/pull/74215

>From f93185fe2346e7184c17ff35fb82ba0873e040a1 Mon Sep 17 00:00:00 2001
From: Thomas Schenker 
Date: Sat, 2 Dec 2023 11:10:26 +0100
Subject: [PATCH] [clang-tidy] readability-container-contains literal suffixes

Before this PR, readability-container-contains fixits did not handle
integer literal suffixes correctly. It e.g. changed
```
  MyMap.count(2) != 0U;
```
into
```
  MyMap.contains(2)U;
```

With this PR, it correctly changes it to
```
  MyMap.contains(2);
```
---
 .../readability/ContainerContainsCheck.cpp|  4 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 +++
 .../readability/container-contains.cpp| 32 +++
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
index 970ed8b83e0a7..dbb50a060e596 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -131,8 +131,8 @@ void ContainerContainsCheck::check(const 
MatchFinder::MatchResult ) {
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(ComparisonBegin, CallBegin),
   Negated ? "!" : "");
-  Diag << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
-  CallEnd.getLocWithOffset(1), ComparisonEnd.getLocWithOffset(1)));
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  CallEnd.getLocWithOffset(1), ComparisonEnd));
 }
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d5f49dc06254..bdc44d6e4c14e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -399,6 +399,10 @@ Changes in existing checks
   ` diagnositics to
   highlight the const location
 
+- Improved :doc:`readability-container-contains
+  ` to correctly handle
+  interger literals with suffixes in fixits.
+
 - Improved :doc:`readability-container-size-empty
   ` check to
   detect comparison between string and empty string literals and support
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
index 05a4ebc9c8a17..cecedbb2b3ea1 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -55,6 +55,7 @@ int testDifferentCheckTypes(std::map ) {
   auto C6 = MyMap.find(5) != MyMap.end();
   // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
   // CHECK-FIXES: auto C6 = MyMap.contains(5);
+
   return C1 + C2 + C3 + C4 + C5 + C6;
 }
 
@@ -175,6 +176,37 @@ int nonRewrittenCount(std::multimap ) {
   return C1 + C2 + C3 + C4;
 }
 
+// Check different integer literal suffixes
+int testDifferentIntegerLiteralSuffixes(std::map ) {
+
+  auto C1 = MyMap.count(2) != 0U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C1 = MyMap.contains(2);
+  auto C2 = MyMap.count(2) != 0UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = MyMap.contains(2);
+  auto C3 = 0U != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = 0UL != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(2);
+  auto C5 = MyMap.count(2) < 1U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(2);
+  auto C6 = MyMap.count(2) < 1UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C6 = !MyMap.contains(2);
+  auto C7 = 1U > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C7 = !MyMap.contains(2);
+  auto C8 = 1UL > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C8 = !MyMap.contains(2);
+
+  return C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8;
+}
+
 // We don't want to rewrite if the `contains` call is from a macro expansion
 int testMacroExpansion(std::unordered_set ) {
 #define 

[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Thomas Schenker (schenker)


Changes

Before this PR, readability-container-contains fixits did not handle integer 
literal suffixes correctly. It e.g. changed
```
  MyMap.count(2) != 0U;
```
into
```
  MyMap.contains(2)U;
```

With this PR, it correctly changes it to
```
  MyMap.contains(2);
```

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


3 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp (+2-2) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp 
(+36-1) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
index 970ed8b83e0a7..dbb50a060e596 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -131,8 +131,8 @@ void ContainerContainsCheck::check(const 
MatchFinder::MatchResult ) {
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(ComparisonBegin, CallBegin),
   Negated ? "!" : "");
-  Diag << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
-  CallEnd.getLocWithOffset(1), ComparisonEnd.getLocWithOffset(1)));
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  CallEnd.getLocWithOffset(1), ComparisonEnd));
 }
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d5f49dc06254..bdc44d6e4c14e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -399,6 +399,10 @@ Changes in existing checks
   ` diagnositics to
   highlight the const location
 
+- Improved :doc:`readability-container-contains
+  ` to correctly handle
+  interger literals with suffixes in fixits.
+
 - Improved :doc:`readability-container-size-empty
   ` check to
   detect comparison between string and empty string literals and support
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
index 05a4ebc9c8a17..8e5ec0089b21d 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -55,7 +55,11 @@ int testDifferentCheckTypes(std::map ) {
   auto C6 = MyMap.find(5) != MyMap.end();
   // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
   // CHECK-FIXES: auto C6 = MyMap.contains(5);
-  return C1 + C2 + C3 + C4 + C5 + C6;
+  auto C7 = 0 != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C7 = MyMap.contains(2);
+
+  return C1 + C2 + C3 + C4 + C5 + C6 + C7;
 }
 
 // Check that we detect various common ways to check for non-membership
@@ -175,6 +179,37 @@ int nonRewrittenCount(std::multimap ) {
   return C1 + C2 + C3 + C4;
 }
 
+// Check different integer literal suffixes
+int testDifferentIntegerLiteralSuffixes(std::map ) {
+
+  auto C1 = MyMap.count(2) != 0U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C1 = MyMap.contains(2);
+  auto C2 = MyMap.count(2) != 0UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = MyMap.contains(2);
+  auto C3 = 0U != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = 0UL != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(2);
+  auto C5 = MyMap.count(2) < 1U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(2);
+  auto C6 = MyMap.count(2) < 1UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C6 = !MyMap.contains(2);
+  auto C7 = 1U > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C7 = !MyMap.contains(2);
+  auto C8 = 1UL > MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // 

[clang-tools-extra] [clang-tidy] readability-container-contains literal suffixes (PR #74215)

2023-12-02 Thread Thomas Schenker via cfe-commits

https://github.com/schenker created 
https://github.com/llvm/llvm-project/pull/74215

Before this PR, readability-container-contains fixits did not handle integer 
literal suffixes correctly. It e.g. changed
```
  MyMap.count(2) != 0U;
```
into
```
  MyMap.contains(2)U;
```

With this PR, it correctly changes it to
```
  MyMap.contains(2);
```

>From 117b45abf919b264662de32c2e4014c6cd716bdf Mon Sep 17 00:00:00 2001
From: Thomas Schenker 
Date: Sat, 2 Dec 2023 11:10:26 +0100
Subject: [PATCH] [clang-tidy] readability-container-contains literal suffixes

Before this PR, readability-container-contains fixits did not handle
integer literal suffixes correctly. It e.g. changed
```
  MyMap.count(2) != 0U;
```
into
```
  MyMap.contains(2)U;
```

With this PR, it correctly changes it to
```
  MyMap.contains(2);
```
---
 .../readability/ContainerContainsCheck.cpp|  4 +-
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 ++
 .../readability/container-contains.cpp| 37 ++-
 3 files changed, 42 insertions(+), 3 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
index 970ed8b83e0a7..dbb50a060e596 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -131,8 +131,8 @@ void ContainerContainsCheck::check(const 
MatchFinder::MatchResult ) {
   Diag << FixItHint::CreateReplacement(
   CharSourceRange::getCharRange(ComparisonBegin, CallBegin),
   Negated ? "!" : "");
-  Diag << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
-  CallEnd.getLocWithOffset(1), ComparisonEnd.getLocWithOffset(1)));
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
+  CallEnd.getLocWithOffset(1), ComparisonEnd));
 }
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 6d5f49dc06254..bdc44d6e4c14e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -399,6 +399,10 @@ Changes in existing checks
   ` diagnositics to
   highlight the const location
 
+- Improved :doc:`readability-container-contains
+  ` to correctly handle
+  interger literals with suffixes in fixits.
+
 - Improved :doc:`readability-container-size-empty
   ` check to
   detect comparison between string and empty string literals and support
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
index 05a4ebc9c8a17..8e5ec0089b21d 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/container-contains.cpp
@@ -55,7 +55,11 @@ int testDifferentCheckTypes(std::map ) {
   auto C6 = MyMap.find(5) != MyMap.end();
   // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
   // CHECK-FIXES: auto C6 = MyMap.contains(5);
-  return C1 + C2 + C3 + C4 + C5 + C6;
+  auto C7 = 0 != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C7 = MyMap.contains(2);
+
+  return C1 + C2 + C3 + C4 + C5 + C6 + C7;
 }
 
 // Check that we detect various common ways to check for non-membership
@@ -175,6 +179,37 @@ int nonRewrittenCount(std::multimap ) {
   return C1 + C2 + C3 + C4;
 }
 
+// Check different integer literal suffixes
+int testDifferentIntegerLiteralSuffixes(std::map ) {
+
+  auto C1 = MyMap.count(2) != 0U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C1 = MyMap.contains(2);
+  auto C2 = MyMap.count(2) != 0UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C2 = MyMap.contains(2);
+  auto C3 = 0U != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C3 = MyMap.contains(2);
+  auto C4 = 0UL != MyMap.count(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C4 = MyMap.contains(2);
+  auto C5 = MyMap.count(2) < 1U;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C5 = !MyMap.contains(2);
+  auto C6 = MyMap.count(2) < 1UL;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use 'contains' to check for 
membership [readability-container-contains]
+  // CHECK-FIXES: auto C6 = !MyMap.contains(2);
+  auto C7 = 1U > 

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

2023-12-02 Thread Eric Biggers via cfe-commits

ebiggers wrote:

No activity here in a few weeks, so I've opened 
https://github.com/llvm/llvm-project/pull/74213 with an updated version of the 
change.

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] [RISCV] Remove experimental from Vector Crypto extensions (PR #74213)

2023-12-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-support

@llvm/pr-subscribers-llvm-analysis

Author: Eric Biggers (ebiggers)


Changes

This is an updated version of https://github.com/llvm/llvm-project/pull/69000, 
which hasn't had activity in a few weeks

---

Patch is 272.35 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74213.diff


200 Files Affected:

- (modified) clang/include/clang/Basic/riscv_vector.td (+9-9) 
- (modified) clang/include/clang/Support/RISCVVIntrinsicUtils.h (+3-2) 
- (modified) clang/lib/Basic/Targets/RISCV.cpp (+5) 
- (modified) clang/lib/Basic/Targets/RISCV.h (+1) 
- (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+4) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+4-4) 
- (modified) clang/lib/Sema/SemaRISCVVectorLookup.cpp (+10-9) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
 (+14-2) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
 (+10-7) 
- (modified) 

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

2023-12-02 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Eric Biggers (ebiggers)


Changes

This is an updated version of https://github.com/llvm/llvm-project/pull/69000, 
which hasn't had activity in a few weeks

---

Patch is 272.35 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74213.diff


200 Files Affected:

- (modified) clang/include/clang/Basic/riscv_vector.td (+9-9) 
- (modified) clang/include/clang/Support/RISCVVIntrinsicUtils.h (+3-2) 
- (modified) clang/lib/Basic/Targets/RISCV.cpp (+5) 
- (modified) clang/lib/Basic/Targets/RISCV.h (+1) 
- (modified) clang/lib/Driver/ToolChains/Arch/RISCV.cpp (+4) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+4-4) 
- (modified) clang/lib/Sema/SemaRISCVVectorLookup.cpp (+10-9) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
 (+14-2) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
 (+10-7) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
 (+10-8) 
- (modified) 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
 (+10-7) 
- (modified) 

[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-12-02 Thread David Li via cfe-commits

https://github.com/david-xl updated 
https://github.com/llvm/llvm-project/pull/73845

>From 4c0f907dc778e8cfd0e41008b8b2970a016201b0 Mon Sep 17 00:00:00 2001
From: David Li 
Date: Wed, 29 Nov 2023 11:56:31 -0800
Subject: [PATCH] Fix PGO documentation in user manual

---
 clang/docs/UsersManual.rst | 54 +++---
 1 file changed, 38 insertions(+), 16 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 2e658557b0e31..9d64195ee338e 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2348,9 +2348,10 @@ differences between the two:
 
 1. Profile data generated with one cannot be used by the other, and there is no
conversion tool that can convert one to the other. So, a profile generated
-   via ``-fprofile-instr-generate`` must be used with ``-fprofile-instr-use``.
-   Similarly, sampling profiles generated by external profilers must be
-   converted and used with ``-fprofile-sample-use``.
+   via ``-fprofile-generate`` or ``-fprofile-instr-generate`` must be used with
+   ``-fprofile-use`` or ``-fprofile-instr-use``.  Similarly, sampling profiles
+   generated by external profilers must be converted and used with 
``-fprofile-sample-use``
+   or ``-fauto-profile``.
 
 2. Instrumentation profile data can be used for code coverage analysis and
optimization.
@@ -2598,6 +2599,8 @@ Of those, 31,977 were spent inside the body of ``bar``. 
The last line
 of the profile (``2: 0``) corresponds to line 2 inside ``main``. No
 samples were collected there.
 
+.. _prof_instr:
+
 Profiling with Instrumentation
 ^^
 
@@ -2607,11 +2610,25 @@ overhead during the profiling, but it provides more 
detailed results than a
 sampling profiler. It also provides reproducible results, at least to the
 extent that the code behaves consistently across runs.
 
+Clang supports two types of instrumentation: frontend-based and IR-based.
+Frontend-based instrumentation can be enabled with the option 
``-fprofile-instr-generate``,
+and IR-based instrumentation can be enabled with the option 
``-fprofile-generate``.
+For best performance with PGO, IR-based instrumentation should be used. It has
+the benefits of lower instrumentation overhead, smaller raw profile size, and
+better runtime performance. Frontend-based instrumentation, on the other hand,
+has better source correlation, so it should be used with source line-based
+coverage testing.
+
+The flag ``-fcs-profile-generate`` also instruments programs using the same
+instrumentation method as ``-fprofile-generate``. However, it performs a
+post-inline late instrumentation and can produce context-sensitive profiles.
+
+
 Here are the steps for using profile guided optimization with
 instrumentation:
 
 1. Build an instrumented version of the code by compiling and linking with the
-   ``-fprofile-instr-generate`` option.
+   ``-fprofile-generate`` or ``-fprofile-instr-generate`` option.
 
.. code-block:: console
 
@@ -2674,8 +2691,8 @@ instrumentation:
Note that this step is necessary even when there is only one "raw" profile,
since the merge operation also changes the file format.
 
-4. Build the code again using the ``-fprofile-instr-use`` option to specify the
-   collected profile data.
+4. Build the code again using the ``-fprofile-use`` or ``-fprofile-instr-use``
+   option to specify the collected profile data.
 
.. code-block:: console
 
@@ -2685,13 +2702,10 @@ instrumentation:
profile. As you make changes to your code, clang may no longer be able to
use the profile data. It will warn you when this happens.
 
-Profile generation using an alternative instrumentation method can be
-controlled by the GCC-compatible flags ``-fprofile-generate`` and
-``-fprofile-use``. Although these flags are semantically equivalent to
-their GCC counterparts, they *do not* handle GCC-compatible profiles.
-They are only meant to implement GCC's semantics with respect to
-profile creation and use. Flag ``-fcs-profile-generate`` also instruments
-programs using the same instrumentation method as ``-fprofile-generate``.
+Note that ``-fprofile-use`` option is semantically equivalent to
+its GCC counterpart, it *does not* handle profile formats produced by GCC.
+Both ``-fprofile-use`` and ``-fprofile-instr-use`` accept profiles in the
+indexed format, regardeless whether it is produced by frontend or the IR pass.
 
 .. option:: -fprofile-generate[=]
 
@@ -4401,13 +4415,21 @@ Execute ``clang-cl /?`` to see a list of supported 
options:
   Instrument only functions from files where names 
don't match all the regexes separated by a semi-colon
   -fprofile-filter-files=
   Instrument only functions from files where names 
match any regex separated by a semi-colon
-  -fprofile-instr-generate=
-  Generate instrumented code to collect execution 
counts into 
+  

[compiler-rt] [lldb] [libc] [clang] [lld] [llvm] [libcxx] [flang] Work around GCC test failure that is caused by enabling optimizations. (PR #73998)

2023-12-02 Thread via cfe-commits

https://github.com/EricWF updated 
https://github.com/llvm/llvm-project/pull/73998

>From 2e7676bac9fb0c8694dd1ee635508ae4d4a6421d Mon Sep 17 00:00:00 2001
From: Eric Fiselier 
Date: Thu, 30 Nov 2023 17:23:37 -0500
Subject: [PATCH 1/2] Work around GCC test failure that is caused by enabling
 optimizations.

While trying to work around MSAN/TSAN build timeouts, we enabled
optimizations on some tests. This caused GCC to start complaining that
some values may be uninitialized. I believe GCC is wrong, but more
investigation is needed.

The values are initialized when the variable `__g` is either < 0 or >=
0. Which only leaves out NaN I believe, which is likely well into UB
   land anyway.

However, more investigation needed.
---
 .../rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp  | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
index 9ab8b6f427492..d0f6fbf0a1203 100644
--- 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
+++ 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -10,7 +10,11 @@
 
 // This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
 // spend less time waiting for this particular test to complete we compile 
with optimizations.
-// ADDITIONAL_COMPILE_FLAGS: -O1
+// ADDITIONAL_COMPILE_FLAGS(msan): -O1
+// ADDITIONAL_COMPILE_FLAGS(tsan): -O1
+
+// FIXME: This and other tests fail under GCC with optimizations enabled.
+// More investigation is needed, but it appears that  GCC is performing more 
constant folding.
 
 // 
 

>From d3a46c128fd597ca193c7f698f5fab3eb5784e66 Mon Sep 17 00:00:00 2001
From: eric 
Date: Sat, 2 Dec 2023 17:19:02 -0500
Subject: [PATCH 2/2] Re-add other slow test

---
 .../deque/deque.modifiers/insert_iter_iter.pass.cpp  | 5 +
 1 file changed, 5 insertions(+)

diff --git 
a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
 
b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
index 946c2cfabf02b..b99c2b87cc5fe 100644
--- 
a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
+++ 
b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
@@ -9,6 +9,11 @@
 // REQUIRES: long_tests
 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
 
+// This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
+// spend less time waiting for this particular test to complete we compile 
with optimizations.
+// ADDITIONAL_COMPILE_FLAGS(msan): -O1
+// ADDITIONAL_COMPILE_FLAGS(tsan): -O1
+
 // 
 
 // template 

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


[clang] [lld] [lldb] [llvm] [libc] [libcxx] [flang] [compiler-rt] Work around GCC test failure that is caused by enabling optimizations. (PR #73998)

2023-12-02 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 7ec4f6094e54911794c142b5d88496a220d807d6 
aaa004f3bd13743195865d5ab09f5ed81757b2a7 -- 
libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
``





View the diff from clang-format here.


``diff
diff --git 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
index bc586d3d68..d0f6fbf0a1 100644
--- 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
+++ 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -8,7 +8,6 @@
 //
 // REQUIRES: long_tests
 
-
 // This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
 // spend less time waiting for this particular test to complete we compile 
with optimizations.
 // ADDITIONAL_COMPILE_FLAGS(msan): -O1

``




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


[clang] [lld] [lldb] [llvm] [libc] [libcxx] [flang] [compiler-rt] Work around GCC test failure that is caused by enabling optimizations. (PR #73998)

2023-12-02 Thread via cfe-commits

https://github.com/EricWF updated 
https://github.com/llvm/llvm-project/pull/73998

>From 2e7676bac9fb0c8694dd1ee635508ae4d4a6421d Mon Sep 17 00:00:00 2001
From: Eric Fiselier 
Date: Thu, 30 Nov 2023 17:23:37 -0500
Subject: [PATCH] Work around GCC test failure that is caused by enabling
 optimizations.

While trying to work around MSAN/TSAN build timeouts, we enabled
optimizations on some tests. This caused GCC to start complaining that
some values may be uninitialized. I believe GCC is wrong, but more
investigation is needed.

The values are initialized when the variable `__g` is either < 0 or >=
0. Which only leaves out NaN I believe, which is likely well into UB
   land anyway.

However, more investigation needed.
---
 .../rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp  | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
index 9ab8b6f427492..d0f6fbf0a1203 100644
--- 
a/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
+++ 
b/libcxx/test/std/numerics/rand/rand.dist/rand.dist.bern/rand.dist.bern.negbin/eval.pass.cpp
@@ -10,7 +10,11 @@
 
 // This test is super slow, in particular with msan or tsan. In order to avoid 
timeouts and to
 // spend less time waiting for this particular test to complete we compile 
with optimizations.
-// ADDITIONAL_COMPILE_FLAGS: -O1
+// ADDITIONAL_COMPILE_FLAGS(msan): -O1
+// ADDITIONAL_COMPILE_FLAGS(tsan): -O1
+
+// FIXME: This and other tests fail under GCC with optimizations enabled.
+// More investigation is needed, but it appears that  GCC is performing more 
constant folding.
 
 // 
 

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


[clang] [llvm] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)

2023-12-02 Thread Craig Topper via cfe-commits

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


[clang] 96070e1 - [clang][NFC] Adjust expected directives in DR tests

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-03T00:21:53+03:00
New Revision: 96070e1e4c13f53c2cef8178d64e206162923f54

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

LOG: [clang][NFC] Adjust expected directives in DR tests

This is a follow-up to 0c06e8745f131d867c566f4d35a7a04e24b4a075, which 
accomodated expected directives for 32-bit ARM and Windows platforms.

Addressed bot failures:
https://lab.llvm.org/buildbot/#/builders/123/builds/23355
https://lab.llvm.org/buildbot/#/builders/245/builds/17458

Added: 


Modified: 
clang/test/CXX/drs/dr2xx.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index 72f69ba99ca7..4dd6d7599f2a 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -5,8 +5,10 @@
 // RUN: %clang_cc1 -std=c++20 %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions 
-fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++23 %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions 
-fcxx-exceptions -pedantic-errors
 
+// FIXME: diagnostic above is emitted only on Windows platforms
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t;
+// cxx98-error@-1 0-1 {{'long long' is a C++11 extension}}
 
 #if __cplusplus < 201103L
 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
@@ -1296,7 +1298,7 @@ namespace dr299 { // dr299: 2.8 c++11
   // cxx98-11-error@#dr299-q {{ambiguous conversion of array size expression 
of type 'T' to an integral or enumeration type}}
   //  cxx98-11-note@#dr299-int {{conversion to integral type 'int' declared 
here}}
   //  cxx98-11-note@#dr299-ushort {{conversion to integral type 'unsigned 
short' declared here}}
-  // since-cxx14-error@#dr299-q {{conversion from 'T' to 'unsigned long' is 
ambiguous}}
+  // since-cxx14-error-re@#dr299-q conversion from 'T' to 'unsigned 
(long|int)' is ambiguous
   //  since-cxx14-note@#dr299-int {{candidate function}}
   //  since-cxx14-note@#dr299-ushort {{candidate function}}
 }



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


[clang] [clang-format] Fix a bug in `git-clang-format --binary` (PR #74176)

2023-12-02 Thread Björn Schäpers via cfe-commits

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


https://github.com/llvm/llvm-project/pull/74176
___
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] [compiler-rt] [BPI] Reuse the AsmWriter's BB naming scheme in BranchProbabilityPrinterPass (PR #73593)

2023-12-02 Thread Mircea Trofin via cfe-commits

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


[clang] [clang-format] Add space in Verilog tagged unions (PR #71354)

2023-12-02 Thread via cfe-commits

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


[clang] b3e80d8 - [clang-format] Add space in Verilog tagged unions (#71354)

2023-12-02 Thread via cfe-commits

Author: sstwcw
Date: 2023-12-02T19:26:07Z
New Revision: b3e80d8ed251bfdad4a49fee19b8354eba407d1d

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

LOG: [clang-format] Add space in Verilog tagged unions (#71354)

In a tagged union expression, there should be a space between the field
name and the data. Previously, the tag could be recognized as part of a
dotted identifier or a struct literal, and the space would be omitted.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 86a68edc8abc0..eaccb5881ca30 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4721,8 +4721,15 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine ,
 Left.isOneOf(TT_VerilogDimensionedTypeName, Keywords.kw_function)) {
   return true;
 }
+// In a tagged union expression, there should be a space after the tag.
+if (Right.isOneOf(tok::period, Keywords.kw_apostrophe) &&
+Keywords.isVerilogIdentifier(Left) && Left.getPreviousNonComment() &&
+Left.getPreviousNonComment()->is(Keywords.kw_tagged)) {
+  return true;
+}
 // Don't add spaces between a casting type and the quote or repetition 
count
-// and the brace.
+// and the brace. The case of tagged union expressions is handled by the
+// previous rule.
 if ((Right.is(Keywords.kw_apostrophe) ||
  (Right.is(BK_BracedInit) && Right.is(tok::l_brace))) &&
 !(Left.isOneOf(Keywords.kw_assign, Keywords.kw_unique) ||

diff  --git a/clang/unittests/Format/FormatTestVerilog.cpp 
b/clang/unittests/Format/FormatTestVerilog.cpp
index 582887492f759..fcda05df18268 100644
--- a/clang/unittests/Format/FormatTestVerilog.cpp
+++ b/clang/unittests/Format/FormatTestVerilog.cpp
@@ -373,6 +373,11 @@ TEST_F(FormatTestVerilog, Case) {
"  arg);\n"
"endcase",
Style);
+
+  verifyFormat("case (v) matches\n"
+   "  tagged Valid .n:\n"
+   ";\n"
+   "endcase");
 }
 
 TEST_F(FormatTestVerilog, Coverage) {
@@ -1292,12 +1297,17 @@ TEST_F(FormatTestVerilog, StructLiteral) {
   verifyFormat("c = '{'{1, 1.0}, '{2, 2.0}};");
   verifyFormat("c = '{a: 0, b: 0.0};");
   verifyFormat("c = '{a: 0, b: 0.0, default: 0};");
+  verifyFormat("d = {int: 1, shortreal: 1.0};");
+  verifyFormat("c = '{default: 0};");
+
+  // The identifier before the quote can be either a tag or a type case.  There
+  // should be a space between the tag and the quote.
   verifyFormat("c = ab'{a: 0, b: 0.0};");
   verifyFormat("c = ab'{cd: cd'{1, 1.0}, ef: ef'{2, 2.0}};");
   verifyFormat("c = ab'{cd'{1, 1.0}, ef'{2, 2.0}};");
-  verifyFormat("d = {int: 1, shortreal: 1.0};");
   verifyFormat("d = ab'{int: 1, shortreal: 1.0};");
-  verifyFormat("c = '{default: 0};");
+  verifyFormat("x = tagged Add '{e1, 4, ed};");
+
   auto Style = getDefaultStyle();
   Style.SpacesInContainerLiterals = true;
   verifyFormat("c = '{a : 0, b : 0.0};", Style);



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


[clang] [clang][RISCVVEmitter] Remove no-op ptr-to-ptr bitcast (NFC) (PR #74179)

2023-12-02 Thread Youngsuk Kim via cfe-commits

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


[clang] c638161 - [clang][RISCVVEmitter] Remove no-op ptr-to-ptr bitcast (NFC) (#74179)

2023-12-02 Thread via cfe-commits

Author: Youngsuk Kim
Date: 2023-12-02T13:50:58-05:00
New Revision: c6381615ef9bc869a708ab8f786c4350f7e00ee7

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

LOG: [clang][RISCVVEmitter] Remove no-op ptr-to-ptr bitcast (NFC) (#74179)

Remove ptr-to-ptr bitcast which was added back in
939352b6ec31db4e8defe07856868438fbc5340d . With opaque pointers, the
bitcast is now redundant.

Opaque ptr cleanup effort.

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index cf731e8414a3b..1fb41805a0473 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -180,13 +180,10 @@ void emitCodeGenSwitchBody(const RVVIntrinsic *RVVI, 
raw_ostream ) {
 return;
   }
 
-  // Cast pointer operand of vector load intrinsic.
   for (const auto  : enumerate(RVVI->getInputTypes())) {
 if (I.value()->isPointer()) {
   assert(RVVI->getIntrinsicTypes().front() == -1 &&
  "RVVI should be vector load intrinsic.");
-  OS << "  Ops[" << I.index() << "] = Builder.CreateBitCast(Ops[";
-  OS << I.index() << "], ResultType->getPointerTo());\n";
 }
   }
 



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


[clang] 0c06e87 - [clang][NFC] Refactor expected directives in C++ DRs 200-299

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-02T21:25:54+03:00
New Revision: 0c06e8745f131d867c566f4d35a7a04e24b4a075

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

LOG: [clang][NFC] Refactor expected directives in C++ DRs 200-299

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

Added: 


Modified: 
clang/test/CXX/drs/dr2xx.cpp

Removed: 




diff  --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index bbebeb22cef2..72f69ba99ca7 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -1,12 +1,12 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++98 %s 
-verify=expected,cxx98,cxx98-11,cxx98-14,cxx98-17 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,since-cxx11,cxx98-11,cxx98-14,cxx98-17 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,since-cxx11,since-cxx14,cxx98-14,cxx98-17 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx17,cxx98-17 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 %s 
-verify=expected,since-cxx11,since-cxx14,since-cxx17 -fexceptions 
-fcxx-exceptions -pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
-typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
+typedef __SIZE_TYPE__ size_t;
 
 #if __cplusplus < 201103L
 #define fold(x) (__builtin_constant_p(x) ? (x) : (x))
@@ -16,7 +16,8 @@ typedef __SIZE_TYPE__ size_t; // expected-error 0-1 
{{extension}}
 
 namespace dr200 { // dr200: dup 214
   template  T f(int);
-  template  T f(U) = delete; // expected-error 
0-1{{extension}}
+  template  T f(U) = delete;
+  // cxx98-error@-1 {{deleted function definitions are a C++11 extension}}
 
   void g() {
 f(1);
@@ -36,9 +37,13 @@ namespace dr202 { // dr202: 3.1
 // FIXME (export) dr204: no
 
 namespace dr206 { // dr206: yes
-  struct S; // expected-note 2{{declaration}}
-  template struct Q { S s; }; // expected-error {{incomplete}}
-  template void f() { S s; } // expected-error {{incomplete}}
+  struct S; // #dr206-S
+  template struct Q { S s; };
+  // expected-error@-1 {{field has incomplete type 'S'}}
+  // expected-note@#dr206-S {{forward declaration of 'dr206::S'}}
+  template void f() { S s; }
+  // expected-error@-1 {{variable has incomplete type 'S'}}
+  // expected-note@#dr206-S {{forward declaration of 'dr206::S'}}
 }
 
 namespace dr207 { // dr207: yes
@@ -60,10 +65,12 @@ namespace dr207 { // dr207: yes
 
 namespace dr209 { // dr209: 3.2
   class A {
-void f(); // expected-note {{here}}
+void f(); // #dr209-A-f
   };
   class B {
-friend void A::f(); // expected-error {{private}}
+friend void A::f();
+// expected-error@-1 {{friend function 'f' is a private member of 
'dr209::A'}}
+// expected-note@#dr209-A-f {{implicitly declared private here}}
   };
 }
 
@@ -74,7 +81,8 @@ namespace dr211 { // dr211: yes
 A() try {
   throw 0;
 } catch (...) {
-  return; // expected-error {{return in the catch of a function try block 
of a constructor}}
+  return;
+  // expected-error@-1 {{return in the catch of a function try block of a 
constructor is illegal}}
 }
   };
 }
@@ -83,16 +91,19 @@ namespace dr213 { // dr213: yes
   template  struct A : T {
 void h(T t) {
   char  = f(t);
-  int  = g(t); // expected-error {{explicit qualification required to 
use member 'g' from dependent base class}}
+  int  = g(t);
+  // expected-error@-1 {{explicit qualification required to use member 'g' 
from dependent base class}}
+  // expected-note@#dr213-instantiation {{in instantiation of member 
function 'dr213::A::h' requested here}}
+  // expected-note@#dr213-B-g {{member is declared here}}
 }
   };
   struct B {
 int (B);
-int (B); // expected-note {{here}}
+int (B); // #dr213-B-g
   };
   char (B);
 
-  template void A::h(B); // expected-note {{instantiation}}
+  

[clang] 2f9c922 - [clang][NFC] Fill in historical data on when C++ DRs 200-299 were fixed

2023-12-02 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-02T21:25:00+03:00
New Revision: 2f9c922a12e9f15abe5f6b1a50d684414be47d26

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 200-299 were fixed

Added: 


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

Removed: 




diff  --git a/clang/test/CXX/drs/dr0xx.cpp b/clang/test/CXX/drs/dr0xx.cpp
index 768da0f8e6fa7..e5f675fb44898 100644
--- a/clang/test/CXX/drs/dr0xx.cpp
+++ b/clang/test/CXX/drs/dr0xx.cpp
@@ -59,7 +59,7 @@ namespace dr3 { // dr3: yes
   // expected-note@#dr3-f-T {{implicit instantiation first required here}}
 }
 
-namespace dr4 { // dr4: yes
+namespace dr4 { // dr4: 2.8
   extern "C" {
 static void dr4_f(int) {}
 static void dr4_f(float) {}
@@ -510,7 +510,7 @@ namespace dr33 { // dr33: 9
 // dr34: na
 // dr35: dup 178
 
-namespace dr36 { // dr36: yes
+namespace dr36 { // dr36: 2.8
 namespace example1 {
   namespace A {
 int i;

diff  --git a/clang/test/CXX/drs/dr1xx.cpp b/clang/test/CXX/drs/dr1xx.cpp
index 4465e7e0f1bfd..064ecace59067 100644
--- a/clang/test/CXX/drs/dr1xx.cpp
+++ b/clang/test/CXX/drs/dr1xx.cpp
@@ -436,17 +436,16 @@ namespace dr126 { // dr126: partial
   // since-cxx17-note@-2 {{use 'noexcept(false)' instead}}
 }
 
-namespace dr127 { // dr127: yes
+namespace dr127 { // dr127: 2.9
   __extension__ typedef __decltype(sizeof(0)) size_t;
   template struct A {
 A() { throw 0; }
 void *operator new(size_t, const char * = 0);
 void operator delete(void *, const char *) { T::error; } // 
#dr127-delete-const-char
 // expected-error@#dr127-delete-const-char {{type 'void' cannot be used 
prior to '::' because it has no members}}
-// expected-note@#dr127-p {{in instantiation of member function 
'dr127::A::operator delete' requested here}}
-
+//   expected-note@#dr127-p {{in instantiation of member function 
'dr127::A::operator delete' requested here}}
 // expected-error@#dr127-delete-const-char {{type 'int' cannot be used 
prior to '::' because it has no members}}
-// expected-note@#dr127-q {{in instantiation of member function 
'dr127::A::operator delete' requested here}}
+//   expected-note@#dr127-q {{in instantiation of member function 
'dr127::A::operator delete' requested here}}
 void operator delete(void *) { T::error; }
   };
   A *p = new A; // #dr127-p
@@ -944,7 +943,7 @@ namespace dr169 { // dr169: yes
   };
 }
 
-namespace { // dr171: yes
+namespace { // dr171: 3.4
   int dr171a;
 }
 int dr171b; // #dr171b-int
@@ -1113,7 +1112,7 @@ namespace dr181 { // dr181: yes
   }
 }
 
-namespace dr182 { // dr182: yes
+namespace dr182 { // dr182: 14
   template  struct C {
 void f();
 void g();

diff  --git a/clang/test/CXX/drs/dr2xx.cpp b/clang/test/CXX/drs/dr2xx.cpp
index c03b7b60bcb4f..bbebeb22cef23 100644
--- a/clang/test/CXX/drs/dr2xx.cpp
+++ b/clang/test/CXX/drs/dr2xx.cpp
@@ -25,7 +25,7 @@ namespace dr200 { // dr200: dup 214
 
 // dr201 FIXME: write codegen test
 
-namespace dr202 { // dr202: yes
+namespace dr202 { // dr202: 3.1
   template T f();
   template struct X {
 int arr[fold(g == ) ? 1 : -1];
@@ -58,7 +58,7 @@ namespace dr207 { // dr207: yes
 
 // dr208 FIXME: write codegen test
 
-namespace dr209 { // dr209: yes
+namespace dr209 { // dr209: 3.2
   class A {
 void f(); // expected-note {{here}}
   };
@@ -108,7 +108,7 @@ namespace dr214 { // dr214: yes
   }
 }
 
-namespace dr215 { // dr215: yes
+namespace dr215 { // dr215: 2.9
   template class X {
 friend void T::foo();
 int n;
@@ -198,7 +198,7 @@ namespace dr218 { // dr218: yes
 // dr219: na
 // dr220: na
 
-namespace dr221 { // dr221: yes
+namespace dr221 { // dr221: 3.6
   struct A { // expected-note 2-4{{candidate}}
 A =(int&); // expected-note 2{{candidate}}
 A +=(int&);
@@ -404,13 +404,13 @@ namespace dr228 { // dr228: yes
   };
 }
 
-namespace dr229 { // dr229: yes
+namespace dr229 { // dr229: 2.9
   template void f();
   template void f() {} // expected-error {{function template 
partial specialization}}
   template<> void f() {}
 }
 
-namespace dr230 { // dr230: yes
+namespace dr230 { // dr230: 3.0
   struct S {
 S() { f(); } // expected-warning {{call to pure virtual member function}}
 virtual void f() = 0; // expected-note {{declared here}}
@@ -430,7 +430,7 @@ namespace dr231 { // dr231: yes
 // dr234: na
 // dr235: na
 
-namespace dr236 { // dr236: yes
+namespace dr236 { // dr236: 3.2
   void *p = int();
 #if __cplusplus < 201103L
   // expected-warning@-2 {{null pointer}}
@@ -586,7 +586,7 @@ namespace dr245 { // dr245: yes
   };
 }
 
-namespace dr246 { // dr246: yes
+namespace dr246 { // dr246: 3.2
   struct S 

[clang] Fix documentation on PGO/coverage related options. (PR #73845)

2023-12-02 Thread Petr Hosek via cfe-commits

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


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


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

2023-12-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-mlir-memref

@llvm/pr-subscribers-mlir-tensor

Author: Rik Huijzer (rikhuijzer)


Changes

This PR fixes https://github.com/llvm/llvm-project/issues/73383 and is another 
shot at the refactoring proposed in 
https://github.com/llvm/llvm-project/pull/72885.

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


5 Files Affected:

- (modified) mlir/include/mlir/Dialect/Utils/StaticValueUtils.h (+27-3) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+6-11) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cpp (+7-10) 
- (modified) mlir/lib/Dialect/Utils/StaticValueUtils.cpp (+26-1) 
- (modified) mlir/test/Dialect/MemRef/canonicalize.mlir (+12) 


``diff
diff --git a/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h 
b/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
index 502ab93ddbfa7..a1853438ccf7f 100644
--- a/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
+++ b/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
@@ -139,12 +139,36 @@ SmallVector
 getValuesSortedByKey(ArrayRef keys, ArrayRef values,
  llvm::function_ref compare);
 
+/// Helper function to check whether the passed in `sizes` or `values` are
+/// valid. This can be used to re-check whether dimensions are still valid
+/// after constant folding the dynamic dimensions.
+bool hasValidSizesOffsets(SmallVector sizesOrOffsets);
+
+/// Helper function to check whether the passed in `strides` are valid. This
+/// can be used to re-check whether dimensions are still valid after constant
+/// folding the dynamic dimensions.
+bool hasValidStrides(SmallVector strides);
+
 /// Returns "success" when any of the elements in `ofrs` is a constant value. 
In
 /// that case the value is replaced by an attribute. Returns "failure" when no
-/// folding happened. If `onlyNonNegative` is set, only non-negative constant
-/// values are folded.
+/// folding happened. If `onlyNonNegative` and `onlyNonZero` are set, only
+/// non-negative and non-zero constant values are folded respectively.
 LogicalResult foldDynamicIndexList(SmallVectorImpl ,
-   bool onlyNonNegative = false);
+   bool onlyNonNegative = false,
+   bool onlyNonZero = false);
+
+/// Returns "success" when any of the elements in `OffsetsOrSizes` is a
+/// constant value. In that case the value is replaced by an attribute. Returns
+/// "failure" when no folding happened. Invalid values are not folded to avoid
+/// canonicalization crashes.
+LogicalResult
+foldDynamicOffsetSizeList(SmallVectorImpl );
+
+/// Returns "success" when any of the elements in `strides` is a constant
+/// value. In that case the value is replaced by an attribute. Returns
+/// "failure" when no folding happened. Invalid values are not folded to avoid
+/// canonicalization crashes.
+LogicalResult foldDynamicStrideList(SmallVectorImpl );
 
 /// Return the number of iterations for a loop with a lower bound `lb`, upper
 /// bound `ub` and step `step`.
diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp 
b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index dce96cca016ff..b2d52e400e52d 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -2581,17 +2581,12 @@ Type SubViewOp::inferResultType(MemRefType 
sourceMemRefType,
   dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
   dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
   dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
-
-  // If one of the offsets or sizes is invalid, fail the canonicalization.
-  // These checks also occur in the verifier, but they are needed here
-  // because some dynamic dimensions may have been constant folded.
-  for (int64_t offset : staticOffsets)
-if (offset < 0 && !ShapedType::isDynamic(offset))
-  return {};
-  for (int64_t size : staticSizes)
-if (size < 0 && !ShapedType::isDynamic(size))
-  return {};
-
+  if (!hasValidSizesOffsets(staticOffsets))
+return {};
+  if (!hasValidSizesOffsets(staticSizes))
+return {};
+  if (!hasValidStrides(staticStrides))
+return {};
   return SubViewOp::inferResultType(sourceMemRefType, staticOffsets,
 staticSizes, staticStrides);
 }
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp 
b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index 8970ea1c73b40..94b7b734f88fe 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -1446,13 +1446,8 @@ struct StaticTensorGenerate : public 
OpRewritePattern {
 SmallVector newShape;
 operandsAndShape(resultType, dynamicExtents, newOperands, newShape);
 
-for (int64_t newdim : newShape) {
-  // This check also occurs in the verifier, but we need it here too
-  // since intermediate passes may have replaced some dynamic dimensions
-  // by constants.
-  if 

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

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

https://github.com/rikhuijzer created 
https://github.com/llvm/llvm-project/pull/74200

This PR fixes https://github.com/llvm/llvm-project/issues/73383 and is another 
shot at the refactoring proposed in 
https://github.com/llvm/llvm-project/pull/72885.

>From 22928e7e5da508d8d9dc8d4b7e54f84cccadef06 Mon Sep 17 00:00:00 2001
From: Rik Huijzer 
Date: Mon, 20 Nov 2023 09:02:41 +0100
Subject: [PATCH 1/5] [mlir][tensor] Fix canon via `hasNegativeDimension`

---
 mlir/include/mlir/Dialect/Tensor/IR/Tensor.h |  6 ++
 mlir/lib/Dialect/Tensor/IR/TensorOps.cpp | 15 +++
 mlir/test/Dialect/Tensor/canonicalize.mlir   | 10 ++
 3 files changed, 31 insertions(+)

diff --git a/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h 
b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
index 06642adda42b3..0d027057b3a95 100644
--- a/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
+++ b/mlir/include/mlir/Dialect/Tensor/IR/Tensor.h
@@ -150,6 +150,12 @@ LogicalResult getOrCreateDestinations(OpBuilder , 
Location loc, Operation *op,
 /// Tests if types are the same when ignoring encoding on ranked tensors.
 bool isSameTypeWithoutEncoding(Type tp1, Type tp2);
 
+/// Helper function to check whether the dimensions are non-negative. This
+/// check also occurs in the verifier, but we need it at later stages too
+/// because the verifier ignores dynamic dimensions, but later stages might
+/// have constant folded those to (negative) constants.
+bool hasNegativeDimension(SmallVector shape);
+
 /// Function to control the folding of constant and extract slice.
 using ControlConstantExtractSliceFusionFn = 
std::function;
 
diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp 
b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
index e469815496e18..3297ef673ca2e 100644
--- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
+++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
@@ -125,6 +125,12 @@ bool tensor::isSameTypeWithoutEncoding(Type tp1, Type tp2) 
{
   return tp1 == tp2; // default implementation
 }
 
+bool tensor::hasNegativeDimension(SmallVector shape) {
+  return llvm::any_of(shape, [](int64_t dim) {
+return !ShapedType::isDynamic(dim) && dim < 0;
+  });
+}
+
 /// Compute the dropped dimensions of a rank-reducing tensor.extract_slice op 
or
 /// rank-extending tensor.insert_slice op.
 static llvm::SmallBitVector getDroppedDims(ArrayRef reducedShape,
@@ -1801,6 +1807,10 @@ RankedTensorType 
ExtractSliceOp::inferCanonicalRankReducedResultType(
   dispatchIndexOpFoldResults(offsets, dynamicOffsets, staticOffsets);
   dispatchIndexOpFoldResults(sizes, dynamicSizes, staticSizes);
   dispatchIndexOpFoldResults(strides, dynamicStrides, staticStrides);
+  if (hasNegativeDimension(staticOffsets))
+return {};
+  if (hasNegativeDimension(staticSizes))
+return {};
   return ExtractSliceOp::inferCanonicalRankReducedResultType(
   desiredResultRank, sourceRankedTensorType, staticOffsets, staticSizes,
   staticStrides);
@@ -2370,6 +2380,8 @@ class InsertSliceOpConstantArgumentFolder final
 auto sourceType = ExtractSliceOp::inferCanonicalRankReducedResultType(
 insertSliceOp.getSourceType().getRank(), insertSliceOp.getDestType(),
 mixedOffsets, mixedSizes, mixedStrides);
+if (!sourceType)
+  return failure();
 Value toInsert = insertSliceOp.getSource();
 if (sourceType != insertSliceOp.getSourceType()) {
   OpBuilder::InsertionGuard g(rewriter);
@@ -2500,6 +2512,8 @@ struct InsertSliceOpSourceCastInserter final
   getConstantIntValue(insertSliceOp.getMixedSizes()[i]))
 newSrcShape[i] = *constInt;
 }
+// if (hasNegativeDimension(newSrcShape))
+//  return failure();
 
 RankedTensorType newSrcType =
 RankedTensorType::get(newSrcShape, srcType.getElementType());
@@ -2521,6 +2535,7 @@ struct InsertSliceOpSourceCastInserter final
   rewriter.setInsertionPoint(insertSliceOp->getParentOp());
 Value cast = rewriter.create(
 insertSliceOp.getLoc(), newSrcType, insertSliceOp.getSource());
+
 rewriter.replaceOpWithNewOp(
 insertSliceOp, cast, insertSliceOp.getDest(),
 insertSliceOp.getMixedOffsets(), insertSliceOp.getMixedSizes(),
diff --git a/mlir/test/Dialect/Tensor/canonicalize.mlir 
b/mlir/test/Dialect/Tensor/canonicalize.mlir
index ea8c17640d7c1..88f27d3d36b04 100644
--- a/mlir/test/Dialect/Tensor/canonicalize.mlir
+++ b/mlir/test/Dialect/Tensor/canonicalize.mlir
@@ -1102,6 +1102,16 @@ func.func @no_fold_collapse_of_expand_empty_expr(%arg0: 
tensor<3x2x2xf32>)
 
 // -
 
+func.func @no_fold_extract_slice_negative_offset(%arg0: tensor<8xf32>) -> 
tensor {
+  %c-1 = arith.constant -1 : index
+  %e = tensor.extract_slice %arg0[1] [%c-1] [1] : tensor<8xf32> to 
tensor
+  return %e : tensor
+}
+// CHECK-LABEL: func @no_fold_extract_slice_negative_offset
+// CHECK: tensor.extract_slice
+
+// -
+
 func.func @reshape_splat_constant_int32() -> tensor<2x4x2xi32> {
   %c0 = arith.constant dense<42> : tensor<2x8xi32>
   %0 = 

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

2023-12-02 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan edited 
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-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Nathan Sidwell (urnathan)


Changes

This implements -Wstrict-aliasing(=[123])? along the same lines as GCC. It's 
not 100% the same for reasons expanded on below. The default is level 3, and I 
have verified that bootstrapping does not trigger any warnings (just like 
building with GCC).

As with GCC, higher levels result in fewer warnings, reducing the number of 
false positives at the cost of missing (some) potential cases. Unlike GCC, this 
is entirely in the FE, we do not propagate any checking into the IR (so there 
are cases GCC will detect we do not, I have not encountered any). GCC's 
documentation is not very specific about which cases are detected. I examined 
GCC's source code to reverse engineer the algorithm[*], and as can be seen from 
the testcases, noted GCC's behaviour.

The strict aliasing check relies on TBAA. LLVM's representation is semantically 
different to GCCs for structured types. I have tried to keep with the spirit of 
the warning.

The warning checks reinterpret_casts that are CK_BitCast or CK_LValueBitCast. 
It also checks C-style casts that are equivalent (to the extent available, as a 
C-style bitcast could be a well-formed static cast).

level=1 looks for reinterpret casts from T * to U * (or an lvalue of type T to 
U ), where T and U are not TBAA compatible.

level=2 requires the src expression be an lvalue something of known(ish) static 
type. I.e a variable, array dereference or member access.

level=3 requires level 2 and that the resultant pointer is actually referenced 
(lvalue-rvalue or lvalue written). Here we can do better than GCC, which 
doesn't represent this in the IR -- we merely get a dereference (and reference 
types are modeled as pointers with auto-dereference semantics). There is one 
exception to this, which is by-value aggregate arguments. These end up invoking 
a copy constructor (passing a reference of course), but are IMHO morally an 
rvalue -- so should trigger.

The warning hooks into clang's code-generator's TBAA machinery. For scalar 
types the TBAA is straight forwards, comparing LLVM's MDNode representaion. For 
record  union types we check if one of the types is (recursively) the same 
(or TBAA compatible) as the first direct base or a field(s) of the record at 
offset zero (i.e. the first member of a record, or any members of a union). 
This covers both C++ and C-Style inheritance. Also. the member maybe alias_any, 
or in ubiquitous-char's alias set, which is also permissible.

The warning is similar to the alignment check that 
CheckCompatibleReinterpretCast does, perhaps some merging could occur if this 
is accepted?

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

WIP: adjust tests

---

Patch is 77.54 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74155.diff


21 Files Affected:

- (modified) clang/include/clang/AST/ASTConsumer.h (+25) 
- (modified) clang/include/clang/Basic/DiagnosticGroups.td (-6) 
- (modified) clang/include/clang/Basic/DiagnosticOptions.h (+4) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+8) 
- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/include/clang/Sema/Sema.h (+11) 
- (modified) clang/lib/CodeGen/BackendConsumer.h (+1) 
- (modified) clang/lib/CodeGen/CodeGenAction.cpp (+4) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+1) 
- (modified) clang/lib/CodeGen/CodeGenTBAA.cpp (+134) 
- (modified) clang/lib/CodeGen/CodeGenTBAA.h (+4-1) 
- (modified) clang/lib/CodeGen/ModuleBuilder.cpp (+2) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+3) 
- (modified) clang/lib/Frontend/FrontendAction.cpp (+8) 
- (modified) clang/lib/Sema/SemaCast.cpp (+139) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+15-2) 
- (modified) clang/lib/Sema/SemaExprMember.cpp (+2) 
- (modified) clang/lib/Sema/SemaInit.cpp (+5) 
- (modified) clang/test/Misc/warning-flags-tree.c (-4) 
- (added) clang/test/Sema/strict-aliasing-warn.c (+192) 
- (added) clang/test/SemaCXX/strict-aliasing-warn.cpp (+1375) 


``diff
diff --git a/clang/include/clang/AST/ASTConsumer.h 
b/clang/include/clang/AST/ASTConsumer.h
index ebcd8059284d8..d5731ed6adf63 100644
--- a/clang/include/clang/AST/ASTConsumer.h
+++ b/clang/include/clang/AST/ASTConsumer.h
@@ -21,6 +21,7 @@ namespace clang {
   class DeclGroupRef;
   class ASTMutationListener;
   class ASTDeserializationListener; // layering violation because void* is ugly
+  class QualType;
   class SemaConsumer; // layering violation required for safe SemaConsumer
   class TagDecl;
   class VarDecl;
@@ -37,6 +38,27 @@ class ASTConsumer {
 
   friend class SemaConsumer;
 
+public:
+  /// Allow type-based aliasing information to be interrogated by the AST
+  /// producer (for diagnostics).
+  class TypeAliasing {
+  public:
+TypeAliasing() = default;
+virtual ~TypeAliasing(){};
+
+  public:
+enum 

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

2023-12-02 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan ready_for_review 
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] Avoid recalculating TBAA base type info (PR #73264)

2023-12-02 Thread Nathan Sidwell via cfe-commits

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


[clang] 1fa35f0 - [clang] Avoid recalculating TBAA base type info (#73264)

2023-12-02 Thread via cfe-commits

Author: Nathan Sidwell
Date: 2023-12-02T11:54:59-05:00
New Revision: 1fa35f0b5dc2f3427fbade0eaaca6e2d8c32caef

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

LOG: [clang] Avoid recalculating TBAA base type info (#73264)

As nullptr is a legitimate value, change the BaseTypeMetadataCache hash 
lookup/insertion to use find and
insert rather than the subscript operator. 

Also adjust getBaseTypeInfoHelper to do no insertion, but let getBaseTypeInfo 
do that.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenTBAA.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTBAA.cpp 
b/clang/lib/CodeGen/CodeGenTBAA.cpp
index 8705d3d65f1a5..5906b14dd93cf 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -342,7 +342,7 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type 
*Ty) {
   // field. Virtual bases are more complex and omitted, but avoid an
   // incomplete view for NewStructPathTBAA.
   if (CodeGenOpts.NewStructPathTBAA && CXXRD->getNumVBases() != 0)
-return BaseTypeMetadataCache[Ty] = nullptr;
+return nullptr;
   for (const CXXBaseSpecifier  : CXXRD->bases()) {
 if (B.isVirtual())
   continue;
@@ -354,7 +354,7 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type 
*Ty) {
  ? getBaseTypeInfo(BaseQTy)
  : getTypeInfo(BaseQTy);
 if (!TypeNode)
-  return BaseTypeMetadataCache[Ty] = nullptr;
+  return nullptr;
 uint64_t Offset = Layout.getBaseClassOffset(BaseRD).getQuantity();
 uint64_t Size =
 Context.getASTRecordLayout(BaseRD).getDataSize().getQuantity();
@@ -378,7 +378,7 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type 
*Ty) {
   llvm::MDNode *TypeNode = isValidBaseType(FieldQTy) ?
   getBaseTypeInfo(FieldQTy) : getTypeInfo(FieldQTy);
   if (!TypeNode)
-return BaseTypeMetadataCache[Ty] = nullptr;
+return nullptr;
 
   uint64_t BitOffset = Layout.getFieldOffset(Field->getFieldIndex());
   uint64_t Offset = Context.toCharUnitsFromBits(BitOffset).getQuantity();
@@ -418,14 +418,20 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(QualType QTy) {
 return nullptr;
 
   const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
-  if (llvm::MDNode *N = BaseTypeMetadataCache[Ty])
-return N;
 
-  // Note that the following helper call is allowed to add new nodes to the
-  // cache, which invalidates all its previously obtained iterators. So we
-  // first generate the node for the type and then add that node to the cache.
+  // nullptr is a valid value in the cache, so use find rather than []
+  auto I = BaseTypeMetadataCache.find(Ty);
+  if (I != BaseTypeMetadataCache.end())
+return I->second;
+
+  // First calculate the metadata, before recomputing the insertion point, as
+  // the helper can recursively call us.
   llvm::MDNode *TypeNode = getBaseTypeInfoHelper(Ty);
-  return BaseTypeMetadataCache[Ty] = TypeNode;
+  LLVM_ATTRIBUTE_UNUSED auto inserted =
+  BaseTypeMetadataCache.insert({Ty, TypeNode});
+  assert(inserted.second && "BaseType metadata was already inserted");
+
+  return TypeNode;
 }
 
 llvm::MDNode *CodeGenTBAA::getAccessTagInfo(TBAAAccessInfo Info) {



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


[clang] [llvm] [X86] Support CFE flags for APX features (PR #74199)

2023-12-02 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Shengchen Kan (KanRobert)


Changes

Positive options: -mapx-features=comma-separated-features
Negative options: -mno-apx-features=comma-separated-features

-m[no-]apx-features is designed to be able to control separate APX
features.

Besides, we also support the flag -m[no-]apxf, which can be used like an
alias of -m[no-]apx-features= all APX features covered by CPUID APX_F

Behaviour when positive and negative options are used together:

For boolean flags, the last one wins

-mapxf   -mno-apxf   - -mno-apxf
-mno-apxf   -mapxf   - -mapxf

For flags that take a set as arguments, it sets the mask by order of the
flags

-mapx-features=egpr,ndd  -mno-apx-features=egpr  -   -egpr,+ndd
-mapx-features=egpr  -mno-apx-features=egpr,ndd  -   -egpr,-ndd
-mno-apx-features=egpr  -mapx-features=egpr,ndd  -   +egpr,+ndd
-mno-apx-features=egpr,ndd  -mapx-features=egpr  -   -ndd,+egpr

The design is aligned with gcc
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628905.html


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


8 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+6) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+34) 
- (modified) clang/lib/Basic/Targets/X86.h (+6) 
- (modified) clang/lib/Driver/ToolChains/Arch/X86.cpp (+15) 
- (added) clang/test/Driver/apxf-target-features.c (+25) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+6) 
- (modified) llvm/lib/Target/X86/X86.td (+6) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+8) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 19d04e82aed4d..631c5ad1c015d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5999,6 +5999,12 @@ def mno_gather : Flag<["-"], "mno-gather">, 
Group,
  HelpText<"Disable generation of gather instructions in 
auto-vectorization(x86 only)">;
 def mno_scatter : Flag<["-"], "mno-scatter">, Group,
   HelpText<"Disable generation of scatter instructions in 
auto-vectorization(x86 only)">;
+def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, 
Group,
+HelpText<"Enable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
+def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, 
Group,
+HelpText<"Disable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
+def mapxf : Flag<["-"], "mapxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","cf"]>;
+def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","cf"]>;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 85d0697ad63ca..9392211aa6fdf 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -428,6 +428,18 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector ,
   HasX87 = true;
 } else if (Feature == "+fullbf16") {
   HasFullBFloat16 = true;
+} else if (Feature == "+egpr") {
+  HasEGPR = true;
+} else if (Feature == "+push2pop2") {
+  HasPush2Pop2 = true;
+} else if (Feature == "+ppx") {
+  HasPPX = true;
+} else if (Feature == "+ndd") {
+  HasNDD = true;
+} else if (Feature == "+ccmp") {
+  HasCCMP = true;
+} else if (Feature == "+cf") {
+  HasCF = true;
 }
 
 X86SSEEnum Level = llvm::StringSwitch(Feature)
@@ -927,6 +939,16 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__USERMSR__");
   if (HasCRC32)
 Builder.defineMacro("__CRC32__");
+  if (HasEGPR)
+Builder.defineMacro("__EGPR__");
+  if (HasPush2Pop2)
+Builder.defineMacro("__PUSH2POP2__");
+  if (HasNDD)
+Builder.defineMacro("__NDD__");
+  if (HasCCMP)
+Builder.defineMacro("__CCMP__");
+  if (HasCF)
+Builder.defineMacro("__CF__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1122,6 +1144,12 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) 
const {
   .Case("xsavec", true)
   .Case("xsaves", true)
   .Case("xsaveopt", true)
+  .Case("egpr", true)
+  .Case("push2pop2", true)
+  .Case("ppx", true)
+  .Case("ndd", true)
+  .Case("ccmp", true)
+  .Case("cf", true)
   .Default(false);
 }
 
@@ -1238,6 +1266,12 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
   .Case("xsaves", HasXSAVES)
   .Case("xsaveopt", HasXSAVEOPT)
   .Case("fullbf16", HasFullBFloat16)
+  .Case("egpr", HasEGPR)
+  .Case("push2pop2", HasPush2Pop2)
+  .Case("ppx", HasPPX)
+  .Case("ndd", HasNDD)
+  .Case("ccmp", HasCCMP)
+  .Case("cf", HasCF)
   .Default(false);
 }
 
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 99a64501d263c..0ab1c10833db2 100644
--- 

[llvm] [clang] [X86] Support CFE flags for APX features (PR #74199)

2023-12-02 Thread Shengchen Kan via cfe-commits

https://github.com/KanRobert created 
https://github.com/llvm/llvm-project/pull/74199

Positive options: -mapx-features=
Negative options: -mno-apx-features=

-m[no-]apx-features is designed to be able to control separate APX
features.

Besides, we also support the flag -m[no-]apxf, which can be used like an
alias of -m[no-]apx-features=< all APX features covered by CPUID APX_F>

Behaviour when positive and negative options are used together:

For boolean flags, the last one wins

-mapxf   -mno-apxf   -> -mno-apxf
-mno-apxf   -mapxf   -> -mapxf

For flags that take a set as arguments, it sets the mask by order of the
flags

-mapx-features=egpr,ndd  -mno-apx-features=egpr  ->   -egpr,+ndd
-mapx-features=egpr  -mno-apx-features=egpr,ndd  ->   -egpr,-ndd
-mno-apx-features=egpr  -mapx-features=egpr,ndd  ->   +egpr,+ndd
-mno-apx-features=egpr,ndd  -mapx-features=egpr  ->   -ndd,+egpr

The design is aligned with gcc
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628905.html


>From 246d6e2bc3f6fb60623b5d4c3f07b53c628ed88a Mon Sep 17 00:00:00 2001
From: Shengchen Kan 
Date: Sat, 2 Dec 2023 23:52:53 +0800
Subject: [PATCH] [X86] Support CFE flags for APX features

Positive options: -mapx-features=
Negative options: -mno-apx-features=

-m[no-]apx-features is designed to be able to control separate APX
features.

Besides, we also support the flag -m[no-]apxf, which can be used like an
alias of -m[no-]apx-features=< all APX features covered by CPUID APX_F>

Behaviour when positive and negative options are used together:

For boolean flags, the last one wins

-mapxf   -mno-apxf   -> -mno-apxf
-mno-apxf   -mapxf   -> -mapxf

For flags that take a set as arguments, it sets the mask by order of the
flags

-mapx-features=egpr,ndd  -mno-apx-features=egpr  ->   -egpr,+ndd
-mapx-features=egpr  -mno-apx-features=egpr,ndd  ->   -egpr,-ndd
-mno-apx-features=egpr  -mapx-features=egpr,ndd  ->   +egpr,+ndd
-mno-apx-features=egpr,ndd  -mapx-features=egpr  ->   -ndd,+egpr

The design is aligned with gcc
https://gcc.gnu.org/pipermail/gcc-patches/2023-August/628905.html
---
 clang/include/clang/Driver/Options.td |  6 
 clang/lib/Basic/Targets/X86.cpp   | 34 +++
 clang/lib/Basic/Targets/X86.h |  6 
 clang/lib/Driver/ToolChains/Arch/X86.cpp  | 15 
 clang/test/Driver/apxf-target-features.c  | 25 ++
 .../llvm/TargetParser/X86TargetParser.def |  6 
 llvm/lib/Target/X86/X86.td|  6 
 llvm/lib/TargetParser/X86TargetParser.cpp |  8 +
 8 files changed, 106 insertions(+)
 create mode 100644 clang/test/Driver/apxf-target-features.c

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 19d04e82aed4d..631c5ad1c015d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5999,6 +5999,12 @@ def mno_gather : Flag<["-"], "mno-gather">, 
Group,
  HelpText<"Disable generation of gather instructions in 
auto-vectorization(x86 only)">;
 def mno_scatter : Flag<["-"], "mno-scatter">, Group,
   HelpText<"Disable generation of scatter instructions in 
auto-vectorization(x86 only)">;
+def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, 
Group,
+HelpText<"Enable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
+def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, 
Group,
+HelpText<"Disable features of APX">, 
Values<"egpr,push2pop2,ppx,ndd,ccmp,cf">;
+def mapxf : Flag<["-"], "mapxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","cf"]>;
+def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","cf"]>;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 85d0697ad63ca..9392211aa6fdf 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -428,6 +428,18 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector ,
   HasX87 = true;
 } else if (Feature == "+fullbf16") {
   HasFullBFloat16 = true;
+} else if (Feature == "+egpr") {
+  HasEGPR = true;
+} else if (Feature == "+push2pop2") {
+  HasPush2Pop2 = true;
+} else if (Feature == "+ppx") {
+  HasPPX = true;
+} else if (Feature == "+ndd") {
+  HasNDD = true;
+} else if (Feature == "+ccmp") {
+  HasCCMP = true;
+} else if (Feature == "+cf") {
+  HasCF = true;
 }
 
 X86SSEEnum Level = llvm::StringSwitch(Feature)
@@ -927,6 +939,16 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__USERMSR__");
   if (HasCRC32)
 Builder.defineMacro("__CRC32__");
+  if (HasEGPR)
+Builder.defineMacro("__EGPR__");
+  if (HasPush2Pop2)
+Builder.defineMacro("__PUSH2POP2__");
+  if (HasNDD)
+Builder.defineMacro("__NDD__");
+  if (HasCCMP)
+

[clang] [Driver][LTO] Copy fix empty stats filename to AMDGPU, HIPAMD, MinGW (PR #74178)

2023-12-02 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

I think we should change signature of addLTOOptions. Instead of accepting a 
single InputInfo, it should accept InputInfoList. Then these ConstructJob 
members will pass Inputs to addLTOOptions, and addLTOOptions will pick the 
first file from it. This should be able to avoid repeated code.

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


[clang] [clang] Accept lambdas in C++03 as an extensions (PR #73376)

2023-12-02 Thread via cfe-commits

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


[clang] [clang] Accept lambdas in C++03 as an extensions (PR #73376)

2023-12-02 Thread Nikolas Klauser via cfe-commits


@@ -92,14 +94,14 @@ namespace ImplicitCapture {
 [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be 
implicitly captured in a lambda with no capture-default specified}} 
expected-note {{lambda expression begins here}} expected-note 2 {{capture 
'ref_i' by}} expected-note 2 {{default capture by}}
 
 static int j;
-int _j = j;
-[] { return ref_j; }; // ok
+int _j = j; // cxx03-fixme-note {{declared here}}
+[] { return ref_j; }; // cxx03-fixme-error {{variable 'ref_j' cannot be 
implicitly captured in a lambda with no capture-default specified}} 
cxx03-fixme-note 4 {{capture}} cxx03-fixme-note {{lambda expression begins 
here}}

philnik777 wrote:

Ah OK. So this diagnostic is actually correct, since an `int&` is not usable in 
a constant expression in C++03. Or am I misunderstanding more?

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


[clang] [clang] Accept lambdas in C++03 as an extensions (PR #73376)

2023-12-02 Thread via cfe-commits


@@ -92,14 +94,14 @@ namespace ImplicitCapture {
 [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be 
implicitly captured in a lambda with no capture-default specified}} 
expected-note {{lambda expression begins here}} expected-note 2 {{capture 
'ref_i' by}} expected-note 2 {{default capture by}}
 
 static int j;
-int _j = j;
-[] { return ref_j; }; // ok
+int _j = j; // cxx03-fixme-note {{declared here}}
+[] { return ref_j; }; // cxx03-fixme-error {{variable 'ref_j' cannot be 
implicitly captured in a lambda with no capture-default specified}} 
cxx03-fixme-note 4 {{capture}} cxx03-fixme-note {{lambda expression begins 
here}}

cor3ntin wrote:

`ref_j` is not odr-used because it is a reference whose initializer is itself a
usable in constant expressions (j is static and default initialized).

Because `ref_j` is not odr-used, it does not need to be captured.

https://eel.is/c++draft/expr.const#3
https://eel.is/c++draft/expr.const#4.3






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


[clang] [clang] Accept lambdas in C++03 as an extensions (PR #73376)

2023-12-02 Thread Nikolas Klauser via cfe-commits


@@ -92,14 +94,14 @@ namespace ImplicitCapture {
 [] { return ref_i; }; // expected-error {{variable 'ref_i' cannot be 
implicitly captured in a lambda with no capture-default specified}} 
expected-note {{lambda expression begins here}} expected-note 2 {{capture 
'ref_i' by}} expected-note 2 {{default capture by}}
 
 static int j;
-int _j = j;
-[] { return ref_j; }; // ok
+int _j = j; // cxx03-fixme-note {{declared here}}
+[] { return ref_j; }; // cxx03-fixme-error {{variable 'ref_j' cannot be 
implicitly captured in a lambda with no capture-default specified}} 
cxx03-fixme-note 4 {{capture}} cxx03-fixme-note {{lambda expression begins 
here}}

philnik777 wrote:

I don't really understand this failure. It would be great if someone could 
point me at the logic for allowing the capture of `ref_j`.

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


[clang] [clang] Fix crash when declaring invalid lambda member (PR #74110)

2023-12-02 Thread Nikolas Klauser via cfe-commits

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


[clang] [clang] Fix crash when declaring invalid lambda member (PR #74110)

2023-12-02 Thread Nikolas Klauser via cfe-commits

philnik777 wrote:

> The tests changes look mostly unrelated to this PR

They mostly are. I found this while trying to check C++03 with the test and 
noticed that C++11 also crashes, so I updated the test to also run in C++11.

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


[clang] [clang] Accept lambdas in C++03 as an extensions (PR #73376)

2023-12-02 Thread Nikolas Klauser via cfe-commits

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

>From 563f86bddc0ec59b63c6aeffee2342f027c09119 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Fri, 1 Dec 2023 18:16:36 +0100
Subject: [PATCH 1/2] [clang] Fix crash when declaring invalid lambda member

---
 clang/lib/AST/DeclCXX.cpp |  7 +++
 clang/test/SemaCXX/lambda-expressions.cpp | 16 +---
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index c944862fcefee..e9e62fea9fb37 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1526,10 +1526,9 @@ bool CXXRecordDecl::isGenericLambda() const {
 
 #ifndef NDEBUG
 static bool allLookupResultsAreTheSame(const DeclContext::lookup_result ) {
-  for (auto *D : R)
-if (!declaresSameEntity(D, R.front()))
-  return false;
-  return true;
+  return llvm::all_of(R, [&](NamedDecl *D) {
+return D->isInvalidDecl() || declaresSameEntity(D, R.front());
+  });
 }
 #endif
 
diff --git a/clang/test/SemaCXX/lambda-expressions.cpp 
b/clang/test/SemaCXX/lambda-expressions.cpp
index 1797eef320b86..1921d02b1a9cf 100644
--- a/clang/test/SemaCXX/lambda-expressions.cpp
+++ b/clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -std=c++11 -Wno-unused-value -fsyntax-only 
-verify=expected,expected-cxx14,cxx11 -fblocks %s
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify 
-verify=expected-cxx14 -fblocks %s
 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify -ast-dump -fblocks %s 
| FileCheck %s
 
@@ -558,8 +559,8 @@ struct B {
   int x;
   A a = [&] { int y = x; };
   A b = [&] { [&] { [&] { int y = x; }; }; };
-  A d = [&](auto param) { int y = x; };
-  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; };
+  A d = [&](auto param) { int y = x; }; // cxx11-error {{'auto' not allowed in 
lambda parameter}}
+  A e = [&](auto param) { [&] { [&](auto param2) { int y = x; }; }; }; // 
cxx11-error 2 {{'auto' not allowed in lambda parameter}}
 };
 
 B b;
@@ -589,6 +590,7 @@ struct S1 {
 void foo1() {
   auto s0 = S1{[name=]() {}}; // expected-error 2 {{expected expression}}
   auto s1 = S1{[name=name]() {}}; // expected-error {{use of undeclared 
identifier 'name'; did you mean 'name1'?}}
+  // cxx11-warning@-1 {{initialized lambda 
captures are a C++14 extension}}
 }
 }
 
@@ -604,7 +606,7 @@ namespace PR25627_dont_odr_use_local_consts {
 
 namespace ConversionOperatorDoesNotHaveDeducedReturnType {
   auto x = [](int){};
-  auto y = [](auto ) -> void { v.n = 0; };
+  auto y = [](auto ) -> void { v.n = 0; }; // cxx11-error {{'auto' not 
allowed in lambda parameter}} cxx11-note {{candidate function not viable}} 
cxx11-note {{conversion candidate}}
   using T = decltype(x);
   using U = decltype(y);
   using ExpectedTypeT = void (*)(int);
@@ -624,14 +626,14 @@ namespace ConversionOperatorDoesNotHaveDeducedReturnType {
 template
   friend constexpr U::operator ExpectedTypeU() const noexcept;
 #else
-friend auto T::operator()(int) const;
+friend auto T::operator()(int) const; // cxx11-error {{'auto' return 
without trailing return type; deduced return types are a C++14 extension}}
 friend T::operator ExpectedTypeT() const;
 
 template
-  friend void U::operator()(T&) const;
+  friend void U::operator()(T&) const; // cxx11-error {{friend declaration 
of 'operator()' does not match any declaration}}
 // FIXME: This should not match, as above.
 template
-  friend U::operator ExpectedTypeU() const;
+  friend U::operator ExpectedTypeU() const; // cxx11-error {{friend 
declaration of 'operator void (*)(type-parameter-0-0 &)' does not match any 
declaration}}
 #endif
 
   private:
@@ -639,7 +641,7 @@ namespace ConversionOperatorDoesNotHaveDeducedReturnType {
   };
 
   // Should be OK: lambda's call operator is a friend.
-  void use(X ) { y(x); }
+  void use(X ) { y(x); } // cxx11-error {{no matching function for call to 
object}}
 
   // This used to crash in return type deduction for the conversion opreator.
   struct A { int n; void f() { +[](decltype(n)) {}; } };

>From b566ad7128fac43d991d773eae60545ed49566e6 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sat, 25 Nov 2023 04:00:57 +0100
Subject: [PATCH 2/2] [clang] Accept lambdas in C++03 as an extensions

This is a fairly simple extension, but makes the life for people who
have to support C++03 a lot easier. As a nice bonus, this also improves
diagnostics, since lambdas are now properly recognized when parsing
C++03 code.
---
 clang/docs/LanguageExtensions.rst |  71 ++-
 .../clang/Basic/DiagnosticParseKinds.td   |   1 +
 clang/include/clang/Basic/Features.def|   1 +
 clang/lib/Parse/ParseExpr.cpp |   2 +-
 clang/lib/Parse/ParseExprCXX.cpp  |   9 +-
 clang/lib/Parse/ParseInit.cpp |   2 +-
 

[clang] [Clang] Remove NetBSD/i386 workaround for FP eval method with older versions (PR #74025)

2023-12-02 Thread Michał Górny via cfe-commits

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

Code LGTM but please add a note to the release notes, as was requested.

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


[libunwind] [llvm] [libcxx] [libc++] Allow running the test suite with optimizations (PR #68753)

2023-12-02 Thread Louis Dionne via cfe-commits

https://github.com/ldionne updated 
https://github.com/llvm/llvm-project/pull/68753

>From 5e53337f16aa446d6a2dc764d347ea37b22c3a56 Mon Sep 17 00:00:00 2001
From: Louis Dionne 
Date: Tue, 10 Oct 2023 16:35:11 -0700
Subject: [PATCH 1/5] [libc++] Allow running the test suite with optimizations

This patch adds a configuration of the libc++ test suite that enables
optimizations when building the tests. It also adds a new CI configuration
to exercise this on a regular basis. This is added in the context of [1],
which requires building with optimizations in order to hit the bug.

[1]: https://github.com/llvm/llvm-project/issues/68552
---
 .github/workflows/libcxx-build-and-test.yaml  |  2 +-
 .../caches/Generic-optimized-speed.cmake  |  4 +++
 .../support.dynamic/libcpp_deallocate.sh.cpp  | 17 +--
 .../path.member/path.assign/move.pass.cpp |  2 +-
 .../path.member/path.construct/move.pass.cpp  |  2 +-
 .../new.size.replace.indirect.pass.cpp|  3 +-
 .../new.size.replace.pass.cpp |  3 +-
 .../new.size_align.replace.indirect.pass.cpp  |  7 +++--
 ...ze_align_nothrow.replace.indirect.pass.cpp |  7 +++--
 .../new.size_align_nothrow.replace.pass.cpp   |  7 +++--
 ...new.size_nothrow.replace.indirect.pass.cpp |  3 +-
 .../new.size_nothrow.replace.pass.cpp |  3 +-
 .../new.size.replace.pass.cpp |  3 +-
 ...ze_align_nothrow.replace.indirect.pass.cpp |  7 +++--
 ...new.size_nothrow.replace.indirect.pass.cpp |  3 +-
 .../func.wrap.func.alg/swap.pass.cpp  | 16 +--
 .../func.wrap.func.con/F.pass.cpp |  2 +-
 .../func.wrap.func.con/copy_assign.pass.cpp   |  8 +++---
 .../func.wrap.func.con/copy_move.pass.cpp |  8 +++---
 .../nullptr_t_assign.pass.cpp |  2 +-
 .../func.wrap.func.mod/swap.pass.cpp  | 12 
 .../make_shared.pass.cpp  |  4 +--
 libcxx/test/support/count_new.h   |  5 
 libcxx/test/support/do_not_optimize.h | 28 +++
 libcxx/utils/ci/run-buildbot  |  5 
 libcxx/utils/libcxx/test/params.py| 28 ++-
 libunwind/test/libunwind_02.pass.cpp  | 26 +
 libunwind/test/unw_resume.pass.cpp|  2 +-
 libunwind/test/unwind_leaffunction.pass.cpp   | 20 +++--
 29 files changed, 169 insertions(+), 70 deletions(-)
 create mode 100644 libcxx/cmake/caches/Generic-optimized-speed.cmake
 create mode 100644 libcxx/test/support/do_not_optimize.h

diff --git a/.github/workflows/libcxx-build-and-test.yaml 
b/.github/workflows/libcxx-build-and-test.yaml
index 018f0e45a244..9c7adb808bcb 100644
--- a/.github/workflows/libcxx-build-and-test.yaml
+++ b/.github/workflows/libcxx-build-and-test.yaml
@@ -162,6 +162,7 @@ jobs:
   'generic-no-tzdb',
   'generic-no-unicode',
   'generic-no-wide-characters',
+  'generic-optimized-speed',
   'generic-static',
   'generic-with_llvm_unwinder',
   # TODO Find a better place for the benchmark and bootstrapping 
builds to live. They're either very expensive
@@ -209,4 +210,3 @@ jobs:
 **/CMakeError.log
 **/CMakeOutput.log
 **/crash_diagnostics/*
-  
diff --git a/libcxx/cmake/caches/Generic-optimized-speed.cmake 
b/libcxx/cmake/caches/Generic-optimized-speed.cmake
new file mode 100644
index ..577a5de9f34c
--- /dev/null
+++ b/libcxx/cmake/caches/Generic-optimized-speed.cmake
@@ -0,0 +1,4 @@
+set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(LIBCXX_TEST_PARAMS "optimization=speed" CACHE STRING "")
+set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
+set(LIBUNWIND_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "")
diff --git 
a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp 
b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
index fb56ce4518a7..6e6229b752a7 100644
--- 
a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ 
b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -34,6 +34,7 @@
 #include 
 #include 
 
+#include "do_not_optimize.h"
 #include "test_macros.h"
 
 TEST_DIAGNOSTIC_PUSH
@@ -187,13 +188,13 @@ void test_allocator_and_new_match() {
   stats.reset();
 #if defined(NO_SIZE) && defined(NO_ALIGN)
   {
-int* x = new int(42);
+int* x = support::do_not_optimize(new int(42));
 delete x;
 assert(stats.expect_plain());
   }
   stats.reset();
   {
-AlignedType* a = new AlignedType();
+AlignedType* a = support::do_not_optimize(new AlignedType());
 delete a;
 assert(stats.expect_plain());
   }
@@ -202,14 +203,14 @@ void test_allocator_and_new_match() {
   stats.reset();
 #if TEST_STD_VER >= 11
   {
-int* x = new int(42);
+int* x = support::do_not_optimize(new int(42));
 delete x;
 assert(stats.expect_plain());
   }
 #endif
   stats.reset();
   {
-   

[clang] 19e2174 - Revert "[Clang] Eagerly instantiate used constexpr function upon definition. (#73463)"

2023-12-02 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-12-02T13:35:27+01:00
New Revision: 19e2174d54356e1654583a65ff9cd38eccf797ee

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

LOG: Revert "[Clang] Eagerly instantiate used constexpr function upon 
definition. (#73463)"

This reverts commit 030047c432cac133738be68fa0974f70e69dd58d.

Breaks Qt and is inconsistent with GCC.

See the following issue for details:

Fixes #74069

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/ExternalSemaSource.h
clang/include/clang/Sema/MultiplexExternalSemaSource.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/Sema/MultiplexExternalSemaSource.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 
clang/test/PCH/instantiate-used-constexpr-function.cpp
clang/test/SemaTemplate/instantiate-used-constexpr-function.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 06796780f322..c7a948fd3fae 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -802,11 +802,6 @@ Bug Fixes to C++ Support
 - Fix crash when parsing nested requirement. Fixes:
   (`#73112 `_)
 
-- Clang now immediately instantiates function template specializations
-  at the end of the definition of the corresponding function template
-  when the definition appears after the first point of instantiation.
-  (`#73232 `_)
-
 Bug Fixes to AST Handling
 ^
 - Fixed an import failure of recursive friend class template.

diff  --git a/clang/include/clang/Sema/ExternalSemaSource.h 
b/clang/include/clang/Sema/ExternalSemaSource.h
index 8b41c5483458..22d1ee2df115 100644
--- a/clang/include/clang/Sema/ExternalSemaSource.h
+++ b/clang/include/clang/Sema/ExternalSemaSource.h
@@ -181,9 +181,6 @@ class ExternalSemaSource : public ExternalASTSource {
  SmallVectorImpl > ) {}
 
-  virtual void ReadPendingInstantiationsOfConstexprEntity(
-  const NamedDecl *D, llvm::SmallSetVector ){};
-
   /// Read the set of late parsed template functions for this source.
   ///
   /// The external source should insert its own late parsed template functions

diff  --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h 
b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 6054ef39e54f..2bf91cb5212c 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -319,9 +319,6 @@ class MultiplexExternalSemaSource : public 
ExternalSemaSource {
   void ReadPendingInstantiations(
  SmallVectorImpl >& Pending) 
override;
 
-  virtual void ReadPendingInstantiationsOfConstexprEntity(
-  const NamedDecl *D, llvm::SmallSetVector ) 
override;
-
   /// Read the set of late parsed template functions for this source.
   ///
   /// The external source should insert its own late parsed template functions

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 8b2ed6f7cd8c..e745c01ae0ae 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -59,7 +59,6 @@
 #include "clang/Sema/TypoCorrection.h"
 #include "clang/Sema/Weak.h"
 #include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallBitVector.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -10093,12 +10092,6 @@ class Sema final {
   /// but have not yet been performed.
   std::deque PendingInstantiations;
 
-  /// Track constexpr functions referenced before they are (lexically) defined.
-  /// The key is the pattern, associated with a list of specialisations that
-  /// need to be instantiated when the pattern is defined.
-  llvm::DenseMap>
-  PendingInstantiationsOfConstexprEntities;
-
   /// Queue of implicit template instantiations that cannot be performed
   /// eagerly.
   SmallVector LateParsedInstantiations;
@@ -10417,9 +10410,6 @@ class Sema final {
  bool Recursive = false,
  bool DefinitionRequired = false,
  bool AtEndOfTU = false);
-
-  void PerformPendingInstantiationsOfConstexprFunctions(FunctionDecl 
*Template);
-
   VarTemplateSpecializationDecl *BuildVarTemplateInstantiation(
   VarTemplateDecl *VarTemplate, VarDecl *FromVar,
   const TemplateArgumentList ,

diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 

[clang] [llvm] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)

2023-12-02 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [clang-fuzzer] Remove GCC 4.x pre GCC 4.9 workaround to silence warning (PR #73974)

2023-12-02 Thread Brad Smith via cfe-commits

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


[clang] 37da4e3 - [clang-fuzzer] Remove GCC 4.x pre GCC 4.9 workaround to silence warning (#73974)

2023-12-02 Thread via cfe-commits

Author: Brad Smith
Date: 2023-12-02T05:15:30-05:00
New Revision: 37da4e3d80d7136121e74e2b8d23afb14ae7ab69

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

LOG: [clang-fuzzer] Remove GCC 4.x pre GCC 4.9 workaround to silence warning 
(#73974)

The minimum GCC version was bumped up from 4.8 to 5.1 and then even newer
awhile ago so garbage collect the pre 4.9 workaround.

https://reviews.llvm.org/D66188

Added: 


Modified: 
clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp

Removed: 




diff  --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp 
b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
index 3d39d69e6c2b422..798b34b3ef0afd2 100644
--- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
+++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
@@ -185,23 +185,7 @@ static void CreateAndRunJITFunc(const std::string , 
CodeGenOptLevel OLvl) {
   EE->finalizeObject();
   EE->runStaticConstructorsDestructors(false);
 
-#if defined(__GNUC__) && !defined(__clang) &&  
\
-((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
-// Silence
-//
-//   warning: ISO C++ forbids casting between pointer-to-function and
-//   pointer-to-object [-Wpedantic]
-//
-// Since C++11 this casting is conditionally supported and GCC versions
-// starting from 4.9.0 don't warn about the cast.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wpedantic"
-#endif
   LLVMFunc f = reinterpret_cast(EE->getPointerToFunction(EntryFunc));
-#if defined(__GNUC__) && !defined(__clang) &&  
\
-((__GNUC__ == 4) && (__GNUC_MINOR__ < 9))
-#pragma GCC diagnostic pop
-#endif
 
   // Figure out if we are running the optimized func or the unoptimized func
   RunFuncOnInputs(f, (OLvl == CodeGenOptLevel::None) ? UnoptArrays : 
OptArrays);



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


[clang] [clang] Fix clang++ crash on assertions when compiling source (PR #70594)

2023-12-02 Thread Rajveer Singh Bharadwaj via cfe-commits

Rajveer100 wrote:

@cor3ntin 
Could you describe the format of the `release note` briefly so I can `amend` my 
`commit` accordingly?

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


[clang] [clang] Fix clang++ crash on assertions when compiling source (PR #70594)

2023-12-02 Thread Rajveer Singh Bharadwaj via cfe-commits

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


[clang] [clang-fuzzer] Remove GCC 4.x pre GCC 4.9 workaround to silence warning (PR #73974)

2023-12-02 Thread Nikita Popov via cfe-commits

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

LGTM

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