[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-07-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:5019
 if (SS->getCond()->isValueDependent()) {
   if (!EvaluateDependentExpr(SS->getCond(), Info))
 return ESR_Failed;

Please don't forget to remove this `if` and make the return unconditional as 
reinforced by @hokein comment above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153296

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


[PATCH] D154520: [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Alex Brachet via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68f5d1be3d8f: [UTC] Adapt version matcher to glob 
CLANG_VENDOR (authored by hnrklssn, committed by abrachet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154520

Files:
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -1571,17 +1571,16 @@
 ]
 
 
-# The capture group is kept as is, followed by a {{.*}} glob
 METADATA_FILTERS = [
-r"(\w+ version )[\d.]+(?: \([^)]+\))?",
-r'(!DIFile\(filename: ".+", directory: )".+"',
+(r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", r"{{.*}}\2{{.*}}"), 
# preface with glob also, to capture optional CLANG_VENDOR
+(r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),
 ]
-METADATA_FILTERS_RE = [re.compile(s) for s in METADATA_FILTERS]
+METADATA_FILTERS_RE = [(re.compile(f),r) for (f,r) in METADATA_FILTERS]
 
 
 def filter_unstable_metadata(line):
-for f in METADATA_FILTERS_RE:
-line = f.sub(r"\1{{.*}}", line)
+for (f,replacement) in METADATA_FILTERS_RE:
+line = f.sub(replacement, line)
 return line
 
 
Index: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
===
--- 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
+++ 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
@@ -243,7 +243,7 @@
 !61 = !{!"branch_weights", i32 1, i32 1048575}
 !62 = distinct !DIAssignID()
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META7:![0-9]+]] = distinct !DISubprogram(name: "foo", scope: 
[[META1]], file: [[META1]], line: 1, type: [[META8:![0-9]+]], scopeLine: 1, 
flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition 
| DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META12:![0-9]+]])
Index: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
===
--- 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
+++ 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
@@ -250,13 +250,13 @@
 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(argmem: readwrite) }
 ; CHECK: attributes #[[ATTR3]] = { nounwind }
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META3:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
 ; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; CHECK: [[META5:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-; CHECK: [[META6:![0-9]+]] = !{!"clang version {{.*}}"}
+; CHECK: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 ; CHECK: [[DBG7]] = distinct !DISubprogram(name: "foo", scope: [[META1]], 

[clang] 68f5d1b - [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Alex Brachet via cfe-commits

Author: Henrik G. Olsson
Date: 2023-07-05T17:10:47Z
New Revision: 68f5d1be3d8f9b2ee2f25098203b24a32057b4e6

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

LOG: [UTC] Adapt version matcher to glob CLANG_VENDOR

Both the pattern for finding the clang version metadata, and the emitted
checker, are now more robust, to handle a vendor prefix.

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

Added: 


Modified: 

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
index 66959811660d65..6ec61165377512 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
@@ -247,12 +247,12 @@ void foo(void) {
 //.
 // OMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // OMP: [[META1:![0-9]+]] = !{i32 7, !"openmp", i32 51}
-// OMP: [[META2:![0-9]+]] = !{!"clang version {{.*}}"}
+// OMP: [[META2:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // OMP: [[META3:![0-9]+]] = !{[[META4:![0-9]+]]}
 // OMP: [[META4]] = !{i64 2, i64 -1, i64 -1, i1 true}
 //.
 // NOOMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-// NOOMP: [[META1:![0-9]+]] = !{!"clang version {{.*}}"}
+// NOOMP: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // NOOMP: [[LOOP2]] = distinct !{[[LOOP2]], [[META3:![0-9]+]]}
 // NOOMP: [[META3]] = !{!"llvm.loop.mustprogress"}
 // NOOMP: [[LOOP4]] = distinct !{[[LOOP4]], [[META3]]}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
index 219e5ceee6c784..1b0074023a60cb 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
@@ -118,12 +118,12 @@ void foo(void) {
 //.
 // OMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // OMP: [[META1:![0-9]+]] = !{i32 7, !"openmp", i32 51}
-// OMP: [[META2:![0-9]+]] = !{!"clang version {{.*}}"}
+// OMP: [[META2:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // OMP: [[META3:![0-9]+]] = !{[[META4:![0-9]+]]}
 // OMP: [[META4]] = !{i64 2, i64 -1, i64 -1, i1 true}
 //.
 // NOOMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-// NOOMP: [[META1:![0-9]+]] = !{!"clang version {{.*}}"}
+// NOOMP: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // NOOMP: [[LOOP2]] = distinct !{[[LOOP2]], [[META3:![0-9]+]]}
 // NOOMP: [[META3]] = !{!"llvm.loop.mustprogress"}
 // NOOMP: [[LOOP4]] = distinct !{[[LOOP4]], [[META3]]}

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
 
b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
index a867c34090123d..ea35ec593720e7 100644
--- 
a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
+++ 
b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
@@ -250,13 +250,13 @@ attributes #3 = { nounwind }
 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(argmem: readwrite) }
 ; CHECK: attributes #[[ATTR3]] = { nounwind }
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META3:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
 ; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; 

[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

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



Comment at: clang/lib/Format/BreakableToken.cpp:199
 
+if (EscapeSequence && Advance == 2) {
+  switch (Text[1]) {

sstwcw wrote:
> MyDeveloperDay wrote:
> > Can we add a unit test for escape sequences > \X which I assume this handles
> There are already tests that verify that the string does not get broken 
> inside an escape sequence in `BreaksWideAndNSStringLiterals` and 
> `DoNotBreakStringLiteralsInEscapeSequence`.  And escape sequences longer than 
> 1 character following the backslash should not begin with one of these 
> letters.  So I don't see what tests I should add.
I was thinking about your tests having a test case which shows it shouldn't 
break, in case someone add case 'x' into your code, i.e. asserting the 
negative. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[PATCH] D86993: Document Clang's expectations of the C standard library.

2023-07-05 Thread Ralf via Phabricator via cfe-commits
RalfJung added a comment.

The first point is important for LLVM's own memcpy/memmove intrinsics, which 
are documented as NOPs on size 0 (and e.g. Rust relies on that).

`memset` should be added to that list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86993

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


[PATCH] D154520: [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn added a comment.

In D154520#4474216 , @abrachet wrote:

> That works. Thanks a lot, @hnrklssn

No problem! I’m no longer at the computer, so feel free to land the commit if 
you need it before tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154520

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


[PATCH] D86993: Document Clang's expectations of the C standard library.

2023-07-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I agree with Aaron that it would be better to change the C standard if we can.  
I don't know how important the first bullet is; IIRC it enables some useful 
middle-end transformation.  I know the second is useful in the frontend so that 
we don't have to do explicit pointer equality checks around aggregate 
assignments, although in many cases we'd be able to avoid that because e.g. we 
know that one of the operands is a temporary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86993

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


[PATCH] D154502: [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-05 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

Unfortunately my fix then broke builds using MSVC. Hopefully fixed for real in 
https://reviews.llvm.org/rG25784cd6a962.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154502

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


[PATCH] D153273: [analyzer] Rework support for CFGScopeBegin, CFGScopeEnd, CFGLifetime elements

2023-07-05 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D153273#4471672 , @steakhal wrote:

> I'd appreciate some review on this, given that a lot of you would be affected 
> by the changes of CFG.
> By changes I mean, fixes for goto statements, properly calling destructors 
> and stuff.
>
> It's already in production for our CSA fork, and the results look good.
>
> **In two weeks we plan to land this unless anyone objects.**

Thanks! We're planning to take a look in the next few days.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153273

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


[clang] 25784cd - Fix compile error in UnresolvedSetTest.cpp, again

2023-07-05 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-07-05T17:54:50+01:00
New Revision: 25784cd6a962ac59e7bde07761fc3ba450da6628

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

LOG: Fix compile error in UnresolvedSetTest.cpp, again

My previous fix used a gcc-style attribute, but not all compilers will accept
that. Instead use [[maybe_unused]], which is what we use elsewhere for this
kind of thing.

Added: 


Modified: 
clang/unittests/AST/UnresolvedSetTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/UnresolvedSetTest.cpp 
b/clang/unittests/AST/UnresolvedSetTest.cpp
index 147c42e1fb0884..ada857e0e38260 100644
--- a/clang/unittests/AST/UnresolvedSetTest.cpp
+++ b/clang/unittests/AST/UnresolvedSetTest.cpp
@@ -5,7 +5,7 @@ namespace clang {
 class NamedDecl {
   // DeclAccessPair assumes that NamedDecl is at least 4-byte aligned, so we
   // we need to have a dummy value to make this dummy NamedDecl also be 
aligned.
-  int dummy __attribute__((unused));
+  [[maybe_unused]] int dummy;
 
 public:
   NamedDecl() {}



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


[PATCH] D153205: [clang-format] Support block indenting array/struct list initializers

2023-07-05 Thread Gedare Bloom via Phabricator via cfe-commits
gedare requested review of this revision.
gedare marked 8 inline comments as done.
gedare added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:365-367
+   (Current.is(tok::r_brace) && Style.Cpp11BracedListStyle &&
+Current.MatchingParen->isOneOf(BK_BracedInit, BK_ListInit) &&
+Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent))) {

owenpan wrote:
> And `isBlockIndentedInitRBrace()` returns true only if the matching `l_brace` 
> is of `BK_BracedInit` or preceded by an `=`.
yes, this works nicely. thanks for spotting it. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153205: [clang-format] Support block indenting array/struct list initializers

2023-07-05 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 537402.
gedare added a comment.

Regenerate docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4929,7 +4929,7 @@
"  \"\"};\n",
Style);
   // Designated initializers.
-  verifyFormat("int LongVariable[1] = {\n"
+  verifyFormat("int LongVariable[2] = {\n"
"  [0] = 1000, [1] = 2000};",
Style);
   verifyFormat("SomeStruct s{\n"
@@ -5039,7 +5039,7 @@
"bar,\n"
"  },\n"
"  SomeArrayT{},\n"
-   "}\n",
+   "};",
Style);
   verifyFormat("SomeArrayT a[3] = {\n"
"  {foo},\n"
@@ -5056,7 +5056,7 @@
"},\n"
"  },\n"
"  {baz},\n"
-   "}\n",
+   "};",
Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
@@ -25494,6 +25494,155 @@
Style);
 }
 
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentInitializers) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  // Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "1000, 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "\"\", \"\",\n"
+   "\"\"\n"
+   "};",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[2] = {\n"
+   "[0] = 1000, [1] = 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   ".foo = \"x\",\n"
+   ".bar = \"y\",\n"
+   ".baz = \"z\"\n"
+   "};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   "   \"x\",\n"
+   "   \"y\",\n"
+   "   \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Assignment operand initialization.
+  verifyFormat("s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Returned object initialization.
+  verifyFormat("return {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Initializer list.

[PATCH] D153205: [clang-format] Add new block type ListInit

2023-07-05 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 537399.
gedare added a comment.

Address comments from owenpan.

Do not add the new block type, and instead check explicitly for the equal sign
before an opening right brace.


Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

Your review contains a change to ClangFormatStyleOptions.rst but not a change 
to clang/include/clang/Format/Format.h

ClangFormatStyleOptions.rst is auto generated from Format.h via 
clang/docs/tools/dump_format_style.py,  please run this to regenerate the .rst

You can validate that the rst is valid by running.

  ./docs/tools/dump_format_style.py
  mkdir -p html
  /usr/bin/sphinx-build -n ./docs ./html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4929,7 +4929,7 @@
"  \"\"};\n",
Style);
   // Designated initializers.
-  verifyFormat("int LongVariable[1] = {\n"
+  verifyFormat("int LongVariable[2] = {\n"
"  [0] = 1000, [1] = 2000};",
Style);
   verifyFormat("SomeStruct s{\n"
@@ -5039,7 +5039,7 @@
"bar,\n"
"  },\n"
"  SomeArrayT{},\n"
-   "}\n",
+   "};",
Style);
   verifyFormat("SomeArrayT a[3] = {\n"
"  {foo},\n"
@@ -5056,7 +5056,7 @@
"},\n"
"  },\n"
"  {baz},\n"
-   "}\n",
+   "};",
Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
@@ -25494,6 +25494,155 @@
Style);
 }
 
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentInitializers) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  // Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "1000, 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "\"\", \"\",\n"
+   "\"\"\n"
+   "};",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[2] = {\n"
+   "[0] = 1000, [1] = 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   ".foo = \"x\",\n"
+   ".bar = \"y\",\n"
+   ".baz = \"z\"\n"
+   "};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   "   \"x\",\n"
+   "   \"y\",\n"
+   "   \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "

[PATCH] D154502: [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-05 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

The test I added here caused failures in buildbots that build with -Wall 
-Werror, fixed in https://reviews.llvm.org/rG258322105892.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154502

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


[PATCH] D154520: [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Alex Brachet via Phabricator via cfe-commits
abrachet accepted this revision.
abrachet added a comment.
This revision is now accepted and ready to land.

That works. Thanks a lot, @hnrklssn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154520

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


[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-05 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/test/SemaCXX/paren-list-agg-init.cpp:276-285
+namespace gh62863 {
+int (&)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[1] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[2] = static_cast(42); // expected-error {{reference to 
type 'int[2]' could not bind to an rvalue of type 'int[1]'}}
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}

aaron.ballman wrote:
> I'd like to see test coverage for:
> ```
> int (&)[] = (int[])(42);
> int (&)[1] = (int[])(42);
> int (&)[2] = (int[])(42);
> int (&)[3] = (int[3])(42);
> ```
> where we're using a C-style cast, because: http://eel.is/c++draft/expr.cast#4
Thank you for the review!

Just to double check, so it says:

> The conversions performed by ... *all named casts* can be performed using the 
> cast notation of explicit type conversion.

Does that mean the c-style cast should produce the same thing? And, 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1975r0.html doesn't 
say anything about c-style casts because it is assumed that it should be able 
to do anything that `static_cast` can do?

gcc doesn't agree https://godbolt.org/z/Pfq8frdn9 . The funny thing is that the 
original bug report seems to be using some kind of gcc test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[clang] 2583221 - Fix compile error in UnresolvedSetTest.cpp with -Wall

2023-07-05 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-07-05T17:39:59+01:00
New Revision: 258322105892bd895a89ccbe89487885581f5a47

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

LOG: Fix compile error in UnresolvedSetTest.cpp with -Wall

A stage 2 buildbot that compiles with -Wall -Werror is showing a failure because
a dummy value is unused. Use the unused attribute to suppress the warning, and
add a comment about why we have this value.

Added: 


Modified: 
clang/unittests/AST/UnresolvedSetTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/UnresolvedSetTest.cpp 
b/clang/unittests/AST/UnresolvedSetTest.cpp
index 6c4d6db9092321..147c42e1fb0884 100644
--- a/clang/unittests/AST/UnresolvedSetTest.cpp
+++ b/clang/unittests/AST/UnresolvedSetTest.cpp
@@ -3,7 +3,9 @@
 
 namespace clang {
 class NamedDecl {
-  int dummy;
+  // DeclAccessPair assumes that NamedDecl is at least 4-byte aligned, so we
+  // we need to have a dummy value to make this dummy NamedDecl also be 
aligned.
+  int dummy __attribute__((unused));
 
 public:
   NamedDecl() {}



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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-07-05 Thread Galen Elias via Phabricator via cfe-commits
galenelias updated this revision to Diff 537383.
galenelias edited the summary of this revision.
galenelias added a comment.

I re-wrote the alignment to stop using AlignTokens so that I can now handle all 
the edge cases that came up.  Specifically:

- Allowing empty case labels (implicit fall through) to not break the 
alignment, but only if they are sandwiched by short case statements.
- Don't align the colon of a non-short case label that follows short case 
labels when using 'AlignCaseColons=true'.
- Empty case labels will also now push out the alignment of the statements when 
using AlignCaseColons=false.

Also, this now avoids having to add the `IgnoreNestedScopes` parameter to 
`AlignTokens` which didn't feel great.

I refactored `AlignMacroSequence` so I could re-use the core aligning method, 
since it's the same logic I need, but I removed some of the dead code just to 
simplify things along the way.  But even with that, this version is quite a bit 
more code (~100 lines vs. ~30 lines).


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

https://reviews.llvm.org/D151761

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19244,6 +19244,255 @@
BracedAlign);
 }
 
+TEST_F(FormatTest, AlignConsecutiveShortCaseStatements) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AllowShortCaseLabelsOnASingleLine = true;
+  Alignment.AlignConsecutiveShortCaseStatements.Enabled = true;
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:   return \"default\";\n"
+   "}",
+   Alignment);
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "  return \"warning\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements push out the alignment, but non-short case labels don't.
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::critical:\n"
+   "case log::warning:\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::extra_severe:\n" 
+   "  // comment\n"
+   "  return \"extra_severe\";\n"
+   "}",
+   Alignment);
+
+  // Verify comments and empty lines break the alignment.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   Alignment);
+
+  // Empty case statements don't break the alignment, and potentially push it out
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "case log::critical:\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Implicit fallthrough cases can be aligned with either a comment or
+  // [[fallthrough]]
+  verifyFormat("switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:  // fallthrough\n"
+   "case log::error:return \"error\";\n"
+   "case log::critical: /*fallthrough*/\n"
+   "case log::severe:   return \"severe\";\n"
+   "case log::diag: [[fallthrough]];\n"
+   "default:return \"default\";\n"
+   "}",
+   Alignment);
+
+  // Verify trailing comment that needs a reflow also gets aligned properly.
+  

[PATCH] D154520: [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn created this revision.
hnrklssn added reviewers: nikic, abrachet.
Herald added subscribers: StephenFan, arichardson.
Herald added a project: All.
hnrklssn requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Both the pattern for finding the clang version metadata, and the emitted
checker, are now more robust, to handle a vendor prefix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154520

Files:
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/utils/UpdateTestChecks/common.py


Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -1571,17 +1571,16 @@
 ]
 
 
-# The capture group is kept as is, followed by a {{.*}} glob
 METADATA_FILTERS = [
-r"(\w+ version )[\d.]+(?: \([^)]+\))?",
-r'(!DIFile\(filename: ".+", directory: )".+"',
+(r"(?<=\")(\w+ )?(\w+ version )[\d.]+(?: \([^)]+\))?", r"{{.*}}\2{{.*}}"), 
# preface with glob also, to capture optional CLANG_VENDOR
+(r'(!DIFile\(filename: ".+", directory: )".+"', r"\1{{.*}}"),
 ]
-METADATA_FILTERS_RE = [re.compile(s) for s in METADATA_FILTERS]
+METADATA_FILTERS_RE = [(re.compile(f),r) for (f,r) in METADATA_FILTERS]
 
 
 def filter_unstable_metadata(line):
-for f in METADATA_FILTERS_RE:
-line = f.sub(r"\1{{.*}}", line)
+for (f,replacement) in METADATA_FILTERS_RE:
+line = f.sub(replacement, line)
 return line
 
 
Index: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
===
--- 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
+++ 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
@@ -243,7 +243,7 @@
 !61 = !{!"branch_weights", i32 1, i32 1048575}
 !62 = distinct !DIAssignID()
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META7:![0-9]+]] = distinct !DISubprogram(name: "foo", scope: 
[[META1]], file: [[META1]], line: 1, type: [[META8:![0-9]+]], scopeLine: 1, 
flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition 
| DISPFlagOptimized, unit: [[META0]], retainedNodes: [[META12:![0-9]+]])
Index: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
===
--- 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
+++ 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
@@ -250,13 +250,13 @@
 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(argmem: readwrite) }
 ; CHECK: attributes #[[ATTR3]] = { nounwind }
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META3:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
 ; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; CHECK: [[META5:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-; CHECK: [[META6:![0-9]+]] = !{!"clang version {{.*}}"}
+; CHECK: [[META6:![0-9]+]] = 

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-07-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a subscriber: hubert.reinterpretcast.
cor3ntin added a comment.

Some tests with lldb

  (lldb) b main
  Breakpoint 1: where = placeholder`main + 4 at debug_placeholder.cpp:2:9, 
address = 0x5134
  (lldb) run
  Process 4044833 launched: 
'/home/cor3ntin/dev/compilers/LLVM/build-release/placeholder' (x86_64)
  Process 4044833 stopped
  * thread #1, name = 'placeholder', stop reason = breakpoint 1.1
  frame #0: 0x5134 placeholder`main at debug_placeholder.cpp:2:9
 1int main() {
  -> 2int _ = 0;
 3int _ = 0;
 4int _ = 0;
 5{
 6int _ = 0;
 7int _ = 0;
  (lldb) step
  Process 4044833 stopped
  * thread #1, name = 'placeholder', stop reason = step in
  frame #0: 0x513b placeholder`main at debug_placeholder.cpp:3:9
 1int main() {
 2int _ = 0;
  -> 3int _ = 0;
 4int _ = 0;
 5{
 6int _ = 0;
 7int _ = 0;
  (lldb) step
  Process 4044833 stopped
  * thread #1, name = 'placeholder', stop reason = step in
  frame #0: 0x5142 placeholder`main at debug_placeholder.cpp:4:9
 1int main() {
 2int _ = 0;
 3int _ = 0;
  -> 4int _ = 0;
 5{
 6int _ = 0;
 7int _ = 0;
  (lldb) frame variable
  (int) _ = 0
  (int) _ = 0
  (int) _ = 0
  (lldb) step
  Process 4044833 stopped
  * thread #1, name = 'placeholder', stop reason = step in
  frame #0: 0x5149 placeholder`main at 
debug_placeholder.cpp:6:13
 3int _ = 0;
 4int _ = 0;
 5{
  -> 6int _ = 0;
 7int _ = 0;
 8}
 9}
  (lldb) step
  Process 4044833 stopped
  * thread #1, name = 'placeholder', stop reason = step in
  frame #0: 0x5150 placeholder`main at 
debug_placeholder.cpp:7:13
 4int _ = 0;
 5{
 6int _ = 0;
  -> 7int _ = 0;
 8}
 9}
  (lldb) frame variable
  (int) _ = 0
  (int) _ = 0
  (int) _ = 0
  (int) _ = 0
  (int) _ = 32767
  (lldb) 

Seems to work well enough @hubert.reinterpretcast


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D153600: Implement -frecord-command-line for XCOFF

2023-07-05 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 537377.
Jake-Egan added a comment.

Rerun CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153600

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/AsmPrinter.h
  llvm/include/llvm/MC/MCStreamer.h
  llvm/include/llvm/MC/MCXCOFFStreamer.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll

Index: llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-command-line-metadata.ll
@@ -0,0 +1,23 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefix=ASM %s
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | \
+; RUN: FileCheck --check-prefix=ASM %s
+
+; RUN: not --crash llc -mtriple powerpc-ibm-aix-xcoff -filetype=obj  < %s 2>&1 | \
+; RUN: FileCheck --check-prefix=OBJ %s
+; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj  < %s 2>&1 | \
+; RUN: FileCheck --check-prefix=OBJ %s
+
+; Verify that llvm.commandline metadata is emitted to .info sections and that the
+; metadata is padded if necessary.
+
+; OBJ: LLVM ERROR: emitXCOFFCInfoSym is not implemented yet on object generation path
+
+; ASM: .info ".GCC.command.line", 0x003a,
+; ASM: .info , 0x40282329, 0x6f707420, 0x636c616e, 0x67202d63, 0x6f6d6d61, 0x6e64202d
+; ASM: .info , 0x6c696e65, 0x0a004028, 0x23296f70, 0x7420736f, 0x6d657468, 0x696e6720
+; ASM: .info , 0x656c7365, 0x20313233, 0x0a00
+
+!llvm.commandline = !{!0, !1}
+!0 = !{!"clang -command -line"}
+!1 = !{!"something else 123"}
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -290,6 +290,8 @@
   bool doFinalization(Module ) override;
 
   void emitTTypeReference(const GlobalValue *GV, unsigned Encoding) override;
+
+  void emitModuleCommandLines(Module ) override;
 };
 
 } // end anonymous namespace
@@ -2954,6 +2956,26 @@
   return new PPCLinuxAsmPrinter(tm, std::move(Streamer));
 }
 
+void PPCAIXAsmPrinter::emitModuleCommandLines(Module ) {
+  const NamedMDNode *NMD = M.getNamedMetadata("llvm.commandline");
+  if (!NMD || !NMD->getNumOperands())
+return;
+
+  std::string S;
+  raw_string_ostream RSOS(S);
+  for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
+const MDNode *N = NMD->getOperand(i);
+assert(N->getNumOperands() == 1 &&
+   "llvm.commandline metadata entry can have only one operand");
+const MDString *MDS = cast(N->getOperand(0));
+// Add "@(#)" to support retrieving the command line information with the
+// AIX "what" command
+RSOS << "@(#)opt " << MDS->getString() << "\n";
+RSOS.write('\0');
+  }
+  OutStreamer->emitXCOFFCInfoSym(".GCC.command.line", RSOS.str());
+}
+
 // Force static initialization.
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter() {
   TargetRegistry::RegisterAsmPrinter(getThePPC32Target(),
Index: llvm/lib/MC/MCStreamer.cpp
===
--- llvm/lib/MC/MCStreamer.cpp
+++ llvm/lib/MC/MCStreamer.cpp
@@ -1208,6 +1208,11 @@
  "XCOFF targets");
 }
 
+void MCStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
+  llvm_unreachable("emitXCOFFCInfoSym is only supported on"
+   "XCOFF targets");
+}
+
 void MCStreamer::emitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
 void MCStreamer::emitELFSymverDirective(const MCSymbol *OriginalSym,
 StringRef Name, bool KeepOriginalSym) {}
Index: llvm/lib/MC/MCAsmStreamer.cpp
===
--- llvm/lib/MC/MCAsmStreamer.cpp
+++ llvm/lib/MC/MCAsmStreamer.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/Path.h"
+#include 
 #include 
 
 using namespace llvm;
@@ -200,6 +201,7 @@
 const MCSymbol *Trap,
 unsigned Lang, unsigned Reason,
 unsigned FunctionSize, bool hasDebug) override;
+  void emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) override;
 
   void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
   void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
@@ -966,6 +968,66 @@
   EmitEOL();
 }
 
+void MCAsmStreamer::emitXCOFFCInfoSym(StringRef Name, StringRef Metadata) {
+  const char *InfoDirective = "\t.info ";
+  const char *Separator = ", ";
+  constexpr int WordSize = sizeof(uint32_t);
+
+  // Start by emitting the .info pseudo-op and C_INFO 

[PATCH] D144135: [clang-tidy] Add performance-enum-size check

2023-07-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL marked an inline comment as done.
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp:127-128
+
+  diag(MatchedDecl->getLocation(), "enum %0 derive from %1 of size %2 bytes, "
+   "derive from '%3' to reduce it size to %4")
+  << MatchedDecl << MatchedDecl->getIntegerType() << Size << NewType.first

unterumarmung wrote:
> I find the enum's type derivation message to be a bit unintuitive. It would 
> slightly improve the user experience if the error message provided clearer 
> information, like stating "enum %0 has a base type of %1..." or "the base 
> type of enum %0 appears excessive for its value set...". However, please 
> remember that these are merely personal thoughts, and as a non-contributor, 
> my suggestions are not obligatory.
Hmm, ok, I think I can change it to utilize a "base type" instead of "derive" 
and something like "appears excessive for its value set.".



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance/enum-size.rst:62
+Requires C++11 or above.
+Does not provide auto-fixes.
+

unterumarmung wrote:
> Why not? 
Problem is mainly with forward declarations, and a fact that some of these 
changes may be unnecessary from a domain point of view. I would prefer users to 
change enum sizes on their own risk. And I didn't wanted to add this at the 
beginning, in future maybe.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144135

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: dblaikie, echristo.
aaron.ballman added a comment.

CCing David and Eric -- do you see any concerns regarding debug information for 
these changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536

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


[PATCH] D144135: [clang-tidy] Add performance-enum-size check

2023-07-05 Thread Daniil Dudkin via Phabricator via cfe-commits
unterumarmung added inline comments.



Comment at: clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp:127-128
+
+  diag(MatchedDecl->getLocation(), "enum %0 derive from %1 of size %2 bytes, "
+   "derive from '%3' to reduce it size to %4")
+  << MatchedDecl << MatchedDecl->getIntegerType() << Size << NewType.first

I find the enum's type derivation message to be a bit unintuitive. It would 
slightly improve the user experience if the error message provided clearer 
information, like stating "enum %0 has a base type of %1..." or "the base type 
of enum %0 appears excessive for its value set...". However, please remember 
that these are merely personal thoughts, and as a non-contributor, my 
suggestions are not obligatory.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance/enum-size.rst:62
+Requires C++11 or above.
+Does not provide auto-fixes.
+

Why not? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144135

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


[PATCH] D153579: [clang-format] Fix RAS reference alignment when PAS is left or middle

2023-07-05 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 537363.
gedare edited the summary of this revision.
gedare added a comment.

Use suggested shorter logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153579

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2189,6 +2189,15 @@
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
 
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("Const unsigned int * c;\n"
+   "const unsigned int * d;\n"
+   "Const unsigned int  \n"
+   "const unsigned int  \n"
+   "const unsigned &\n"
+   "Const unsigned   h;",
+   Style);
+
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
   // verifyFormat("int Add2(BTree * , char * szToAdd)", Style);
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -453,12 +453,24 @@
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;
 
 // If PointerAlignment is PAS_Right, keep *s or  next to the token
-if (Style.PointerAlignment == FormatStyle::PAS_Right &&
+if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
+ Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
 Changes[i].Spaces != 0) {
+  const bool ReferenceNotRightAligned =
+  Style.ReferenceAlignment != FormatStyle::RAS_Right &&
+  Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
   for (int Previous = i - 1;
Previous >= 0 &&
Changes[Previous].Tok->getType() == TT_PointerOrReference;
--Previous) {
+assert(
+Changes[Previous].Tok->isOneOf(tok::star, tok::amp, tok::ampamp));
+if (Changes[Previous].Tok->isNot(tok::star)) {
+  if (ReferenceNotRightAligned)
+continue;
+} else if (Style.PointerAlignment != FormatStyle::PAS_Right) {
+  continue;
+}
 Changes[Previous + 1].Spaces -= Shift;
 Changes[Previous].Spaces += Shift;
 Changes[Previous].StartOfTokenColumn += Shift;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2189,6 +2189,15 @@
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
 
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("Const unsigned int * c;\n"
+   "const unsigned int * d;\n"
+   "Const unsigned int  \n"
+   "const unsigned int  \n"
+   "const unsigned &\n"
+   "Const unsigned   h;",
+   Style);
+
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
   // verifyFormat("int Add2(BTree * , char * szToAdd)", Style);
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -453,12 +453,24 @@
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;
 
 // If PointerAlignment is PAS_Right, keep *s or  next to the token
-if (Style.PointerAlignment == FormatStyle::PAS_Right &&
+if ((Style.PointerAlignment == FormatStyle::PAS_Right ||
+ Style.ReferenceAlignment == FormatStyle::RAS_Right) &&
 Changes[i].Spaces != 0) {
+  const bool ReferenceNotRightAligned =
+  Style.ReferenceAlignment != FormatStyle::RAS_Right &&
+  Style.ReferenceAlignment != FormatStyle::RAS_Pointer;
   for (int Previous = i - 1;
Previous >= 0 &&
Changes[Previous].Tok->getType() == TT_PointerOrReference;
--Previous) {
+assert(
+Changes[Previous].Tok->isOneOf(tok::star, tok::amp, tok::ampamp));
+if (Changes[Previous].Tok->isNot(tok::star)) {
+  if (ReferenceNotRightAligned)
+continue;
+} else if (Style.PointerAlignment != FormatStyle::PAS_Right) {
+  continue;
+}
 Changes[Previous + 1].Spaces -= Shift;
 Changes[Previous].Spaces += Shift;
 Changes[Previous].StartOfTokenColumn += Shift;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D153585: [clang-format] Fix align consecutive declarations over function pointers

2023-07-05 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 537359.
gedare added a comment.

Merge the two if statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153585

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2059,6 +2059,8 @@
"const unsigned int *d;\n"
"Const unsigned int \n"
"const unsigned int \n"
+   "int*f1(int *a, int , int &);\n"
+   "double *(*f2)(int *a, double &);\n"
"const unsigned&\n"
"Const unsigned  h;",
Style);
@@ -2104,6 +2106,8 @@
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int* a, int& b, int&& c);\n"
+   "double* (*f2)(int* a, double&& b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2129,6 +2133,8 @@
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int *a, int& b, int&& c);\n"
+   "double *(*f2)(int *a, double&& b);\n"
"const unsigned  g;\n"
"Const unsigned  h;",
Style);
@@ -2169,6 +2175,8 @@
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
"const unsigned int & f;\n"
+   "int* f1(int* a, int & b, int && c);\n"
+   "double*  (*f2)(int* a, double && b);\n"
"const unsigned &&g;\n"
"Const unsigned   h;",
Style);
@@ -2189,6 +2197,17 @@
   verifyFormat("for (int a = 0, b = 0; const Foo * c : {1, 2, 3})", Style);
   verifyFormat("for (int a = 0, b++; const Foo * c : {1, 2, 3})", Style);
 
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+  verifyFormat("Const unsigned int * c;\n"
+   "const unsigned int * d;\n"
+   "Const unsigned int  \n"
+   "const unsigned int  \n"
+   "int *f1(int * a, int , int &);\n"
+   "double * (*f2)(int * a, double &);\n"
+   "const unsigned &\n"
+   "Const unsigned   h;",
+   Style);
+
   // FIXME: we don't handle this yet, so output may be arbitrary until it's
   // specifically handled
   // verifyFormat("int Add2(BTree * , char * szToAdd)", Style);
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -866,7 +866,7 @@
   AlignTokens(
   Style,
   [](Change const ) {
-if (C.Tok->is(TT_FunctionDeclarationName))
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, TT_FunctionTypeLParen))
   return true;
 if (C.Tok->isNot(TT_StartOfName))
   return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2059,6 +2059,8 @@
"const unsigned int *d;\n"
"Const unsigned int \n"
"const unsigned int \n"
+   "int*f1(int *a, int , int &);\n"
+   "double *(*f2)(int *a, double &);\n"
"const unsigned&\n"
"Const unsigned  h;",
Style);
@@ -2104,6 +2106,8 @@
"const unsigned int* d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int* a, int& b, int&& c);\n"
+   "double* (*f2)(int* a, double&& b);\n"
"const unsigned&&g;\n"
"Const unsigned  h;",
Style);
@@ -2129,6 +2133,8 @@
"const unsigned int *d;\n"
"Const unsigned int& e;\n"
"const unsigned int& f;\n"
+   "int*f1(int *a, int& b, int&& c);\n"
+   "double *(*f2)(int *a, double&& b);\n"
"const unsigned  g;\n"
"Const unsigned  h;",
Style);
@@ -2169,6 +2175,8 @@
"const unsigned int*  d;\n"
"Const unsigned int & e;\n"
"const unsigned int & f;\n"
+   "int* f1(int* a, 

[PATCH] D154502: [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-05 Thread John Brawn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4ade8b7ed997: [AST] Fix bug in UnresolvedSet::erase of last 
element (authored by john.brawn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154502

Files:
  clang/include/clang/AST/UnresolvedSet.h
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/UnresolvedSetTest.cpp

Index: clang/unittests/AST/UnresolvedSetTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/UnresolvedSetTest.cpp
@@ -0,0 +1,115 @@
+#include "clang/AST/UnresolvedSet.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+class NamedDecl {
+  int dummy;
+
+public:
+  NamedDecl() {}
+};
+} // namespace clang
+
+using namespace clang;
+
+class UnresolvedSetTest : public ::testing::Test {
+protected:
+  NamedDecl n0, n1, n2, n3;
+  UnresolvedSet<2> set;
+
+  void SetUp() override {
+set.addDecl();
+set.addDecl();
+set.addDecl();
+set.addDecl();
+  }
+};
+
+TEST_F(UnresolvedSetTest, Size) { EXPECT_EQ(set.size(), 4u); }
+
+TEST_F(UnresolvedSetTest, ArrayOperator) {
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+  EXPECT_EQ(set[3].getDecl(), );
+}
+
+TEST_F(UnresolvedSetTest, EraseIntegerFromStart) {
+  set.erase(0);
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIntegerFromEnd) {
+  set.erase(3);
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(2);
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(1);
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIteratorFromStart) {
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIteratorFromEnd) {
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 0u);
+}
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -35,6 +35,7 @@
   StructuralEquivalenceTest.cpp
   TemplateNameTest.cpp
   TypePrinterTest.cpp
+  UnresolvedSetTest.cpp
   )
 
 clang_target_link_libraries(ASTTests
Index: clang/include/clang/AST/UnresolvedSet.h
===
--- clang/include/clang/AST/UnresolvedSet.h
+++ clang/include/clang/AST/UnresolvedSet.h
@@ -114,9 +114,17 @@
 I.I->set(New, AS);
   }
 
-  void erase(unsigned I) { decls()[I] = decls().pop_back_val(); }
+  void erase(unsigned I) {
+auto val = decls().pop_back_val();
+if (I < size())
+  decls()[I] = val;
+  }
 
-  void erase(iterator I) { *I.I = decls().pop_back_val(); }
+  void erase(iterator I) {
+auto val = decls().pop_back_val();
+if (I != end())
+  *I.I = val;
+  }
 
   void setAccess(iterator I, AccessSpecifier AS) { I.I->setAccess(AS); }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4ade8b7 - [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-05 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-07-05T16:02:40+01:00
New Revision: 4ade8b7ed9976303b23cff3525223826e65b46e7

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

LOG: [AST] Fix bug in UnresolvedSet::erase of last element

UnresolvedSet::erase works by popping the last element then replacing
the element to be erased with that element. When the element to be
erased is itself the last element this leads to writing past the end
of the set, causing an assertion failure.

Fix this by making erase of the last element just pop that element.

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

Added: 
clang/unittests/AST/UnresolvedSetTest.cpp

Modified: 
clang/include/clang/AST/UnresolvedSet.h
clang/unittests/AST/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/AST/UnresolvedSet.h 
b/clang/include/clang/AST/UnresolvedSet.h
index 17b47f6ab96bee..ee31be969b6e35 100644
--- a/clang/include/clang/AST/UnresolvedSet.h
+++ b/clang/include/clang/AST/UnresolvedSet.h
@@ -114,9 +114,17 @@ class UnresolvedSetImpl {
 I.I->set(New, AS);
   }
 
-  void erase(unsigned I) { decls()[I] = decls().pop_back_val(); }
+  void erase(unsigned I) {
+auto val = decls().pop_back_val();
+if (I < size())
+  decls()[I] = val;
+  }
 
-  void erase(iterator I) { *I.I = decls().pop_back_val(); }
+  void erase(iterator I) {
+auto val = decls().pop_back_val();
+if (I != end())
+  *I.I = val;
+  }
 
   void setAccess(iterator I, AccessSpecifier AS) { I.I->setAccess(AS); }
 

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index b664b64070328e..12484be9206e23 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -35,6 +35,7 @@ add_clang_unittest(ASTTests
   StructuralEquivalenceTest.cpp
   TemplateNameTest.cpp
   TypePrinterTest.cpp
+  UnresolvedSetTest.cpp
   )
 
 clang_target_link_libraries(ASTTests

diff  --git a/clang/unittests/AST/UnresolvedSetTest.cpp 
b/clang/unittests/AST/UnresolvedSetTest.cpp
new file mode 100644
index 00..6c4d6db9092321
--- /dev/null
+++ b/clang/unittests/AST/UnresolvedSetTest.cpp
@@ -0,0 +1,115 @@
+#include "clang/AST/UnresolvedSet.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+class NamedDecl {
+  int dummy;
+
+public:
+  NamedDecl() {}
+};
+} // namespace clang
+
+using namespace clang;
+
+class UnresolvedSetTest : public ::testing::Test {
+protected:
+  NamedDecl n0, n1, n2, n3;
+  UnresolvedSet<2> set;
+
+  void SetUp() override {
+set.addDecl();
+set.addDecl();
+set.addDecl();
+set.addDecl();
+  }
+};
+
+TEST_F(UnresolvedSetTest, Size) { EXPECT_EQ(set.size(), 4u); }
+
+TEST_F(UnresolvedSetTest, ArrayOperator) {
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+  EXPECT_EQ(set[3].getDecl(), );
+}
+
+TEST_F(UnresolvedSetTest, EraseIntegerFromStart) {
+  set.erase(0);
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIntegerFromEnd) {
+  set.erase(3);
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(2);
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(1);
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIteratorFromStart) {
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIteratorFromEnd) {
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 0u);
+}




[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

2023-07-05 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

It won't break the string inside an escape sequence.  But escape sequences like 
`\040`, `\x20`, and `\u0020` don't get recognized as whitespace.




Comment at: clang/lib/Format/BreakableToken.cpp:199
 
+if (EscapeSequence && Advance == 2) {
+  switch (Text[1]) {

MyDeveloperDay wrote:
> Can we add a unit test for escape sequences > \X which I assume this handles
There are already tests that verify that the string does not get broken inside 
an escape sequence in `BreaksWideAndNSStringLiterals` and 
`DoNotBreakStringLiteralsInEscapeSequence`.  And escape sequences longer than 1 
character following the backslash should not begin with one of these letters.  
So I don't see what tests I should add.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[PATCH] D105759: Implement P2361 Unevaluated string literals

2023-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: clang-vendors.
aaron.ballman added a comment.

In D105759#4457041 , @cor3ntin wrote:

> In D105759#4456864 , @aaron.ballman 
> wrote:
>
>> I don't think it's correct to assume that all string arguments to attributes 
>> are unevaluated, but it is hard to tell where to draw the line sometimes. 
>> Backing up a step, as I understand P2361 , 
>> an unevaluated string is one which is not converted into the execution 
>> character set (effectively). Is that correct? If so, then as an example, 
>> `[[clang::annotate()]]` should almost certainly be using an evaluated string 
>> because the argument is passed down to LLVM IR and is used in ways we cannot 
>> predict. What's more, an unevaluated string cannot have some kinds of escape 
>> characters (numeric and conditional escape sequences) and those are 
>> currently allowed by `clang::annotate` and could potentially be used by a 
>> backend plugin.
>>
>> I think other attributes may have similar issues. For example, the `alias` 
>> attribute is a bit of a question mark for me -- that takes a string literal 
>> representing an external identifier that is looked up. I'm not certain 
>> whether that should be in the execution character set or not, but we do 
>> support escape sequences for it: https://godbolt.org/z/v65Yd7a68
>>
>> I think we need to track evaluated vs not on the argument level so that the 
>> attributes in Attr.td can decide which form to use. I think we should 
>> default to "evaluated" for any attribute we're on the fence about because 
>> that's the current behavior they get today (so we should avoid regressions).
>
> I really don't think it makes sense to have both "unevaluated" and 
> "evaluated" arguments.
> We chatted offline and we struggle to find places where escape sequences are 
> used, or examples of attributes intended to be in the execution character set.

In general I agree, but the one scenario that I keep coming back to are 
attributes like `diagnose_if` where they take an expression we're evaluating at 
compile time (condition expression) and a string literal that's not evaluated 
(warning vs error, diagnostic message itself). But I think the "evaluating at 
compile time" is part of why I don't think we intend the attribute to be 
considering the execution character set.

> My suggestion would be to land the non-attributes changes now, and the 
> attributes bits in early clang 18.

I think we're almost safe enough to make the attribute changes in Clang 17 so 
that no attribute uses an evaluated argument, but given that there's less than 
a month before we make the 17 branch, I think it's probably a good idea to make 
these changes after the branch point so folks have longer to react. Adding 
`clang-vendors` to the review for awareness of the potential for a breaking 
change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105759

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


[clang] 1077a34 - [Clang] Fix handling of using declarations in for loop init statements.

2023-07-05 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-07-05T16:20:53+02:00
New Revision: 1077a343911127452615c6f5441c121de06be6d5

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

LOG: [Clang] Fix handling of using declarations in for loop init statements.

The type was never saved, and therefore never transformed
in dependent contexts.

Reviewed By: aaron.ballman, #clang-language-wg

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

Added: 
clang/test/SemaCXX/cxx23-init-statement.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseStmt.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 022d51b525c04c..79550f79cc36b5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -635,6 +635,9 @@ Bug Fixes to C++ Support
 - Allow abstract parameter and return types in functions that are
   either deleted or not defined.
   (`#63012 `_)
+- Fix handling of using-declarations in the init statements of for
+  loop declarations.
+  (`#63627 `_)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 43ff808e296b54..2346470dbdb73d 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -2054,15 +2054,15 @@ StmtResult Parser::ParseForStatement(SourceLocation 
*TrailingElseLoc) {
   Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
 }
 DeclGroupPtrTy DG;
+SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
 if (Tok.is(tok::kw_using)) {
   DG = ParseAliasDeclarationInInitStatement(DeclaratorContext::ForInit,
 attrs);
+  FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
 } else {
   // In C++0x, "for (T NS:a" might not be a typo for ::
   bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
   ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);
-
-  SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
   ParsedAttributes DeclSpecAttrs(AttrFactory);
   DG = ParseSimpleDeclaration(
   DeclaratorContext::ForInit, DeclEnd, attrs, DeclSpecAttrs, false,

diff  --git a/clang/test/SemaCXX/cxx23-init-statement.cpp 
b/clang/test/SemaCXX/cxx23-init-statement.cpp
new file mode 100644
index 00..bf99a53df15e14
--- /dev/null
+++ b/clang/test/SemaCXX/cxx23-init-statement.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 %s
+
+namespace GH63627 {
+template
+void ok() {
+  if  (using U = decltype([]{ return 42;}); true) {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); [[maybe_unused]] auto x : "abc") {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); false; ) {
+  static_assert(U{}() == 42);
+  }
+}
+
+template
+void err() {
+  if  (using U = decltype([]{}.foo); true) {}  // expected-error {{no member 
named 'foo'}}
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member 
named 'foo'}}
+   [[maybe_unused]] auto x : "abc") { }
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member 
named 'foo'}}
+   false ; ) { }
+};
+
+void test() {
+  ok();
+  err(); // expected-note {{in instantiation of function template 
specialization 'GH63627::err'}}
+}
+
+}



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


[PATCH] D154492: [Clang] Fix handling of using declarations in for loop init statements.

2023-07-05 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1077a3439111: [Clang] Fix handling of using declarations in 
for loop init statements. (authored by cor3ntin).

Changed prior to commit:
  https://reviews.llvm.org/D154492?vs=537290=537351#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154492

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseStmt.cpp
  clang/test/SemaCXX/cxx23-init-statement.cpp


Index: clang/test/SemaCXX/cxx23-init-statement.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx23-init-statement.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 %s
+
+namespace GH63627 {
+template
+void ok() {
+  if  (using U = decltype([]{ return 42;}); true) {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); [[maybe_unused]] auto x : "abc") {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); false; ) {
+  static_assert(U{}() == 42);
+  }
+}
+
+template
+void err() {
+  if  (using U = decltype([]{}.foo); true) {}  // expected-error {{no member 
named 'foo'}}
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member 
named 'foo'}}
+   [[maybe_unused]] auto x : "abc") { }
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member 
named 'foo'}}
+   false ; ) { }
+};
+
+void test() {
+  ok();
+  err(); // expected-note {{in instantiation of function template 
specialization 'GH63627::err'}}
+}
+
+}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2054,15 +2054,15 @@
   Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
 }
 DeclGroupPtrTy DG;
+SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
 if (Tok.is(tok::kw_using)) {
   DG = ParseAliasDeclarationInInitStatement(DeclaratorContext::ForInit,
 attrs);
+  FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
 } else {
   // In C++0x, "for (T NS:a" might not be a typo for ::
   bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
   ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);
-
-  SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
   ParsedAttributes DeclSpecAttrs(AttrFactory);
   DG = ParseSimpleDeclaration(
   DeclaratorContext::ForInit, DeclEnd, attrs, DeclSpecAttrs, false,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -635,6 +635,9 @@
 - Allow abstract parameter and return types in functions that are
   either deleted or not defined.
   (`#63012 `_)
+- Fix handling of using-declarations in the init statements of for
+  loop declarations.
+  (`#63627 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/cxx23-init-statement.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx23-init-statement.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++23 %s
+
+namespace GH63627 {
+template
+void ok() {
+  if  (using U = decltype([]{ return 42;}); true) {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); [[maybe_unused]] auto x : "abc") {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); false; ) {
+  static_assert(U{}() == 42);
+  }
+}
+
+template
+void err() {
+  if  (using U = decltype([]{}.foo); true) {}  // expected-error {{no member named 'foo'}}
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member named 'foo'}}
+   [[maybe_unused]] auto x : "abc") { }
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member named 'foo'}}
+   false ; ) { }
+};
+
+void test() {
+  ok();
+  err(); // expected-note {{in instantiation of function template specialization 'GH63627::err'}}
+}
+
+}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2054,15 +2054,15 @@
   Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
 }
 DeclGroupPtrTy DG;
+SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
 if (Tok.is(tok::kw_using)) {
   DG = ParseAliasDeclarationInInitStatement(DeclaratorContext::ForInit,
 attrs);
+  FirstPart = 

[PATCH] D154492: [Clang] Fix handling of using declarations in for loop init statements.

2023-07-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/test/SemaCXX/cxx23-init-statement.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 -Wall %s
+

aaron.ballman wrote:
> This should suffice, yes?
Yep!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154492

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


[PATCH] D153695: [clang][Interp] Fix passing parameters of composite type

2023-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with debugging code removed and comments cleaned up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153695

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


[PATCH] D154492: [Clang] Fix handling of using declarations in for loop init statements.

2023-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/test/SemaCXX/cxx23-init-statement.cpp:1
+// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 -Wall %s
+

This should suffice, yes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154492

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


[clang] 07630da - Minor change to clang test

2023-07-05 Thread Akash Banerjee via cfe-commits

Author: Akash Banerjee
Date: 2023-07-05T14:56:45+01:00
New Revision: 07630da36a31596594a1ba3b9f000dc57d5382f3

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

LOG: Minor change to clang test

Fix clang test error cuased by commit 4a49226537abafc9b372ba8ef61d14a817a5226a. 
Minor change in order of globals.

Added: 


Modified: 
clang/test/OpenMP/target_data_map_codegen_hold.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_data_map_codegen_hold.cpp 
b/clang/test/OpenMP/target_data_map_codegen_hold.cpp
index 5f4e50eaf0e300..73df250e098d65 100644
--- a/clang/test/OpenMP/target_data_map_codegen_hold.cpp
+++ b/clang/test/OpenMP/target_data_map_codegen_hold.cpp
@@ -53,10 +53,10 @@ struct S2 {
 //   MEMBER_OF_7 = 0x7
 
 //.
-// CHECK-PPC64LE: @.offload_sizes = private unnamed_addr constant [1 x i64] 
[i64 20]
-// CHECK-PPC64LE: @.offload_maptypes = private unnamed_addr constant [1 x i64] 
[i64 8193]
 // CHECK-PPC64LE: @0 = private unnamed_addr constant [23 x i8] c"
 // CHECK-PPC64LE: @1 = private unnamed_addr constant %struct.ident_t { i32 0, 
i32 2, i32 0, i32 22, ptr @0 }, align 8
+// CHECK-PPC64LE: @.offload_sizes = private unnamed_addr constant [1 x i64] 
[i64 20]
+// CHECK-PPC64LE: @.offload_maptypes = private unnamed_addr constant [1 x i64] 
[i64 8193]
 // CHECK-PPC64LE: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] 
[i64 20]
 // CHECK-PPC64LE: @.offload_maptypes.2 = private unnamed_addr constant [1 x 
i64] [i64 9221]
 // CHECK-PPC64LE: @.offload_sizes.3 = private unnamed_addr constant [1 x i64] 
[i64 4]
@@ -64,10 +64,10 @@ struct S2 {
 // CHECK-PPC64LE: @.offload_sizes.5 = private unnamed_addr constant [11 x i64] 
[i64 0, i64 4, i64 8, i64 8, i64 4, i64 4, i64 0, i64 4, i64 8, i64 8, i64 4]
 // CHECK-PPC64LE: @.offload_maptypes.6 = private unnamed_addr constant [11 x 
i64] [i64 8192, i64 281474976718851, i64 281474976718864, i64 8208, i64 8211, 
i64 3, i64 8192, i64 1970324836982787, i64 1970324836982800, i64 8208, i64 8211]
 //.
-// CHECK-I386: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 
20]
-// CHECK-I386: @.offload_maptypes = private unnamed_addr constant [1 x i64] 
[i64 8193]
 // CHECK-I386: @0 = private unnamed_addr constant [23 x i8] c"
 // CHECK-I386: @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 
2, i32 0, i32 22, ptr @0 }, align 8
+// CHECK-I386: @.offload_sizes = private unnamed_addr constant [1 x i64] [i64 
20]
+// CHECK-I386: @.offload_maptypes = private unnamed_addr constant [1 x i64] 
[i64 8193]
 // CHECK-I386: @.offload_sizes.1 = private unnamed_addr constant [1 x i64] 
[i64 20]
 // CHECK-I386: @.offload_maptypes.2 = private unnamed_addr constant [1 x i64] 
[i64 9221]
 // CHECK-I386: @.offload_sizes.3 = private unnamed_addr constant [1 x i64] 
[i64 4]



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


[PATCH] D154509: [clang][analyzer] StdLibraryFunctionsChecker: Allow NULL buffer in `fread` and `fwrite` if size is zero.

2023-07-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, gamesh411, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a reviewer: NoQ.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154509

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -184,6 +184,44 @@
 // bugpath-warning{{The 1st argument to 'fread' is NULL but should not be NULL}} \
 // bugpath-note{{The 1st argument to 'fread' is NULL but should not be NULL}}
 }
+
+int __not_null_buffer(void *, int, int);
+
+void test_notnull_buffer_1(void *buf) {
+  __not_null_buffer(buf, 0, 1);
+  clang_analyzer_eval(buf != 0); // \
+  // report-warning{{TRUE}} \
+  // bugpath-warning{{TRUE}} \
+  // report-warning{{FALSE}} \
+  // bugpath-warning{{FALSE}} \
+  // bugpath-note{{TRUE}} \
+  // bugpath-note{{FALSE}} \
+  // bugpath-note{{Assuming 'buf' is equal to null}} \
+  // bugpath-note{{Assuming 'buf' is not equal to null}}
+}
+
+void test_notnull_buffer_2(void *buf) {
+  __not_null_buffer(buf, 1, 0);
+  clang_analyzer_eval(buf != 0); // \
+  // report-warning{{TRUE}} \
+  // bugpath-warning{{TRUE}} \
+  // report-warning{{FALSE}} \
+  // bugpath-warning{{FALSE}} \
+  // bugpath-note{{TRUE}} \
+  // bugpath-note{{FALSE}} \
+  // bugpath-note{{Assuming 'buf' is equal to null}} \
+  // bugpath-note{{Assuming 'buf' is not equal to null}}
+}
+
+void test_notnull_buffer_3(void *buf) {
+  __not_null_buffer(buf, 1, 1);
+  clang_analyzer_eval(buf != 0); // \
+  // report-warning{{TRUE}} \
+  // bugpath-warning{{TRUE}} \
+  // bugpath-note{{TRUE}} \
+  // bugpath-note{{'buf' is not equal to null}}
+}
+
 void test_no_node_after_bug(FILE *fp, size_t size, size_t n, void *buf) {
   if (fp) // \
   // bugpath-note{{Assuming 'fp' is null}} \
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -402,6 +402,53 @@
 }
   };
 
+  /// Check null or non-null-ness of an argument that is of pointer type.
+  /// The argument is meant to be a buffer that has a size constraint, and it
+  /// is allowed to have a NULL value if the size is 0. The size can depend on
+  /// 1 or 2 additional arguments, if one of these is 0 the buffer is allowed to
+  /// be NULL. This is useful for functions like `fread` which have this special
+  /// property.
+  class NotNullBufferConstraint : public ValueConstraint {
+using ValueConstraint::ValueConstraint;
+ArgNo SizeArg1N;
+std::optional SizeArg2N;
+// This variable has a role when we negate the constraint.
+bool CannotBeNull = true;
+
+  public:
+NotNullBufferConstraint(ArgNo ArgN, ArgNo SizeArg1N,
+std::optional SizeArg2N,
+bool CannotBeNull = true)
+: ValueConstraint(ArgN), SizeArg1N(SizeArg1N), SizeArg2N(SizeArg2N),
+  CannotBeNull(CannotBeNull) {}
+
+ProgramStateRef apply(ProgramStateRef State, const CallEvent ,
+  const Summary ,
+  CheckerContext ) const override;
+
+void describe(DescriptionKind DK, const CallEvent ,
+  ProgramStateRef State, const Summary ,
+  llvm::raw_ostream ) const override;
+
+bool describeArgumentValue(const CallEvent , ProgramStateRef State,
+   const Summary ,
+   llvm::raw_ostream ) const override;
+
+ValueConstraintPtr negate() const override {
+  NotNullBufferConstraint Tmp(*this);
+  Tmp.CannotBeNull = !this->CannotBeNull;
+  return std::make_shared(Tmp);
+}
+
+  protected:
+bool checkSpecificValidity(const FunctionDecl *FD) const override {
+  const bool ValidArg = getArgType(FD, ArgN)->isPointerType();
+  assert(ValidArg &&
+ "This constraint should be applied only on a pointer type");
+  return ValidArg;
+}
+  };
+
   // Represents a buffer argument with an additional size constraint. The
   // constraint may be a concrete value, or a symbolic value in an argument.
   // Example 1. Concrete value as the minimum buffer size.
@@ -1141,6 +1188,54 @@
   return true;
 }
 
+ProgramStateRef 

[PATCH] D153881: Create diagnostic group for definition deprecation warning

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

In D153881#4468597 , @nuriamari wrote:

> In D153881#4467127 , @aaron.ballman 
> wrote:
>
>> I think it's a bit odd that we'd leave `const` under `-Wdeprecated` but 
>> separate `constexpr` out into its own warning flag, but I'm also not opposed.
>
> Would moving both const and constexpr into their own warning flag work? I 
> don't really see cases where you'd want to disable only one or the other.

I think that would work better, yes.

>> Can you explain the need a bit more though? I think our belief was that 
>> silencing this diagnostic was pretty trivial (delete the line in question), 
>> so we wouldn't need a separate diagnostic group for it.
>
> In our case we have libraries that are consumed both with say C++14 and 
> C++17, so we can't just delete them, we've needed to add a standard version 
> check. Admittedly not a huge change either, but we ran into many occurrences 
> of this warning trying to adopt the latest Clang. I suppose I don't see the 
> downside of a little more granular control.

Ah, I see now, thank you. Backcompat would be harder without this kind of 
granular control, so I'm okay with this direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153881

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


[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 537346.
balazske added a comment.

Added AT_FDCWD `openat` test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/Inputs/std-c-library-functions-POSIX.h
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -316,6 +316,7 @@
   // bugpath-note{{The 1st argument to 'linkat' is -22 but should be a valid file descriptor or AT_FDCWD}}
 
   // no warning for these functions if the AT_FDCWD value is used
+  (void)openat(AT_FDCWD, "path", 0);
   (void)linkat(AT_FDCWD, "from", AT_FDCWD, "to", 0);
   (void)faccessat(AT_FDCWD, "path", 0, 0);
   (void)symlinkat("oldpath", AT_FDCWD, "newpath");
Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -1,3 +1,12 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctions \
+// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -analyzer-config alpha.unix.StdCLibraryFunctions:DisplayLoadedSummaries=true \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-config eagerly-assume=false \
+// RUN:   -triple i686-unknown-linux -verify
+
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=alpha.unix.StdCLibraryFunctions \
@@ -15,6 +24,8 @@
 // CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: long a64l(const char *str64)
 // CHECK: Loaded summary for: char *l64a(long value)
+// CHECK: Loaded summary for: int open(const char *path, int oflag, ...)
+// CHECK: Loaded summary for: int openat(int fd, const char *path, int oflag, ...)
 // CHECK: Loaded summary for: int access(const char *pathname, int amode)
 // CHECK: Loaded summary for: int faccessat(int dirfd, const char *pathname, int mode, int flags)
 // CHECK: Loaded summary for: int dup(int fildes)
@@ -82,6 +93,7 @@
 // CHECK: Loaded summary for: int execv(const char *path, char *const argv[])
 // CHECK: Loaded summary for: int execvp(const char *file, char *const argv[])
 // CHECK: Loaded summary for: int getopt(int argc, char *const argv[], const char *optstring)
+// CHECK: Loaded summary for: int socket(int domain, int type, int protocol)
 // CHECK: Loaded summary for: int accept(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
 // CHECK: Loaded summary for: int bind(int socket, __CONST_SOCKADDR_ARG address, socklen_t address_len)
 // CHECK: Loaded summary for: int getpeername(int socket, __SOCKADDR_ARG address, socklen_t *restrict address_len)
@@ -97,6 +109,7 @@
 // CHECK: Loaded summary for: int getsockopt(int socket, int level, int option_name, void *restrict option_value, socklen_t *restrict option_len)
 // CHECK: Loaded summary for: ssize_t send(int sockfd, const void *buf, size_t len, int flags)
 // CHECK: Loaded summary for: int socketpair(int domain, int type, int protocol, int sv[2])
+// CHECK: Loaded summary for: int shutdown(int socket, int how)
 // CHECK: Loaded summary for: int getnameinfo(const struct sockaddr *restrict sa, socklen_t salen, char *restrict node, socklen_t nodelen, char *restrict service, socklen_t servicelen, int flags)
 // CHECK: Loaded summary for: int utime(const char *filename, struct utimbuf *buf)
 // CHECK: Loaded summary for: int futimens(int fd, const struct timespec times[2])
@@ -128,8 +141,12 @@
 
 #include "Inputs/std-c-library-functions-POSIX.h"
 
-// Must have at least one call expression to initialize the summary map.
-int bar(void);
-void foo(void) {
-  bar();
+void test_open(void) {
+  open(0, 0); // \
+  // expected-warning{{The 1st argument to 'open' is NULL but should not be NULL}}
+}
+
+void test_open_additional_arg(void) {
+  open(0, 0, 0); // \
+  // expected-warning{{The 1st argument to 'open' is NULL but should not be NULL}}
 }
Index: clang/test/Analysis/Inputs/std-c-library-functions-POSIX.h
===
--- clang/test/Analysis/Inputs/std-c-library-functions-POSIX.h
+++ clang/test/Analysis/Inputs/std-c-library-functions-POSIX.h
@@ -47,6 +47,8 @@
 int fileno(FILE *stream);
 long a64l(const char *str64);
 char *l64a(long value);
+int open(const char *path, int oflag, ...);
+int openat(int fd, const char *path, int oflag, ...);
 int access(const char 

[PATCH] D154502: [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-05 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154502

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


[PATCH] D154486: [Clang] Fix a crash when trying to initialize an invalid aggregate.

2023-07-05 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1bc7f3fb9367: [Clang] Fix a crash when trying to initialize 
an invalid aggregate. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154486

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,25 @@
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct 
member}}
+  static const auto y = 1;
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' 
from a parenthesized list of values is a C++20 extension}}
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@
 }
   }
 
+  Expr *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-  CurInit.get());
+  cast(Entity.getDecl()), Init);
 
   // Check for std::move on construction.
-  if (const Expr *E = CurInit.get()) {
-CheckMoveOnConstruction(S, E,
-Entity.getKind() == InitializedEntity::EK_Result);
-  }
+  CheckMoveOnConstruction(S, Init,
+  Entity.getKind() == InitializedEntity::EK_Result);
 
-  return CurInit;
+  return Init;
 }
 
 /// Somewhere within T there is an uninitialized reference subobject.


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,25 @@
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct member}}
+  static const auto y = 1;
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' from a parenthesized list of values is a C++20 extension}}
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@
 }
   }
 
+  Expr *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-  CurInit.get());
+  cast(Entity.getDecl()), Init);
 
   // Check for std::move on construction.
-  if (const Expr *E = CurInit.get()) {
-CheckMoveOnConstruction(S, E,
-Entity.getKind() == InitializedEntity::EK_Result);
-  }
+  CheckMoveOnConstruction(S, Init,
+  Entity.getKind() 

[clang] 1bc7f3f - [Clang] Fix a crash when trying to initialize an invalid aggregate.

2023-07-05 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-07-05T15:45:46+02:00
New Revision: 1bc7f3fb936724dd7a2d0b5ac91f773d3168a5f0

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

LOG: [Clang] Fix a crash when trying to initialize an invalid aggregate.

We did not return an error when failing to producing
a valid expression when performing the initialization of
an aggregate initialized with a parenthesized list of expressions.

This is a regression introduced in Clang 17.

Fixes #63278

Reviewed By: aaron.ballman, #clang-language-wg

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

Added: 


Modified: 
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b893d358dfe790..6db211a20e311f 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@ ExprResult InitializationSequence::Perform(Sema ,
 }
   }
 
+  Expr *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@ ExprResult InitializationSequence::Perform(Sema ,
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-  CurInit.get());
+  cast(Entity.getDecl()), Init);
 
   // Check for std::move on construction.
-  if (const Expr *E = CurInit.get()) {
-CheckMoveOnConstruction(S, E,
-Entity.getKind() == InitializedEntity::EK_Result);
-  }
+  CheckMoveOnConstruction(S, Init,
+  Entity.getKind() == InitializedEntity::EK_Result);
 
-  return CurInit;
+  return Init;
 }
 
 /// Somewhere within T there is an uninitialized reference subobject.

diff  --git a/clang/test/SemaCXX/paren-list-agg-init.cpp 
b/clang/test/SemaCXX/paren-list-agg-init.cpp
index 042ce3b3ddce2c..88d9b95c0e4be4 100644
--- a/clang/test/SemaCXX/paren-list-agg-init.cpp
+++ b/clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,25 @@ auto a = new A('a', {1.1});
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct 
member}}
+  static const auto y = 1;
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' 
from a parenthesized list of values is a C++20 extension}}
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}



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


[PATCH] D154349: [include-cleaner] Add a signal to down-rank exporting headers

2023-07-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5933d265b72a: [include-cleaner] Add a signal to down-rank 
exporting headers (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154349

Files:
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/TypesInternal.h
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp
@@ -8,17 +8,21 @@
 
 #include "AnalysisInternal.h"
 #include "TypesInternal.h"
+#include "clang-include-cleaner/Analysis.h"
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Frontend/FrontendActions.h"
 #include "clang/Testing/TestAST.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 
 namespace clang::include_cleaner {
@@ -253,11 +257,11 @@
   EXPECT_THAT(
   findHeaders("private.inc"),
   UnorderedElementsAre(
-  HintedHeader(physicalHeader("private.inc"), Hints::None),
+  HintedHeader(physicalHeader("private.inc"), Hints::OriginHeader),
   HintedHeader(physicalHeader("public.h"), Hints::PublicHeader)));
   EXPECT_THAT(findHeaders("private.h"),
-  UnorderedElementsAre(
-  HintedHeader(physicalHeader("private.h"), Hints::None)));
+  UnorderedElementsAre(HintedHeader(physicalHeader("private.h"),
+Hints::OriginHeader)));
 }
 
 TEST_F(FindHeadersTest, PreferredHeaderHint) {
@@ -269,11 +273,12 @@
   )cpp");
   buildAST();
   // Headers explicitly marked should've preferred signal.
-  EXPECT_THAT(findHeaders("private.h"),
-  UnorderedElementsAre(
-  HintedHeader(physicalHeader("private.h"), Hints::None),
-  HintedHeader(Header("\"public.h\""),
-   Hints::PreferredHeader | Hints::PublicHeader)));
+  EXPECT_THAT(
+  findHeaders("private.h"),
+  UnorderedElementsAre(
+  HintedHeader(physicalHeader("private.h"), Hints::OriginHeader),
+  HintedHeader(Header("\"public.h\""),
+   Hints::PreferredHeader | Hints::PublicHeader)));
 }
 
 class HeadersForSymbolTest : public FindHeadersTest {
@@ -339,11 +344,12 @@
 }
 
 TEST_F(HeadersForSymbolTest, Ranking) {
-  // Sorting is done over (canonical, public, complete) triplet.
+  // Sorting is done over (canonical, public, complete, origin)-tuple.
   Inputs.Code = R"cpp(
 #include "private.h"
 #include "public.h"
 #include "public_complete.h"
+#include "exporter.h"
   )cpp";
   Inputs.ExtraFiles["public.h"] = guard(R"cpp(
 struct foo;
@@ -352,11 +358,15 @@
 // IWYU pragma: private, include "canonical.h"
 struct foo;
   )cpp");
+  Inputs.ExtraFiles["exporter.h"] = guard(R"cpp(
+  #include "private.h" // IWYU pragma: export
+  )cpp");
   Inputs.ExtraFiles["public_complete.h"] = guard("struct foo {};");
   buildAST();
   EXPECT_THAT(headersForFoo(), ElementsAre(Header("\"canonical.h\""),
physicalHeader("public_complete.h"),
physicalHeader("public.h"),
+   physicalHeader("exporter.h"),
physicalHeader("private.h")));
 }
 
@@ -424,6 +434,24 @@
physicalHeader("private.h")));
 }
 
+TEST_F(HeadersForSymbolTest, ExporterIsDownRanked) {
+  Inputs.Code = R"cpp(
+#include "exporter.h"
+#include "zoo.h"
+  )cpp";
+  // Deliberately named as zoo to make sure it doesn't get name-match boost and
+  // also gets lexicographically bigger order than "exporter".
+  Inputs.ExtraFiles["zoo.h"] = guard(R"cpp(
+struct foo {};
+  )cpp");
+  Inputs.ExtraFiles["exporter.h"] = guard(R"cpp(
+#include "zoo.h" // IWYU pragma: export
+  )cpp");
+  buildAST();
+  EXPECT_THAT(headersForFoo(), ElementsAre(physicalHeader("zoo.h"),
+   physicalHeader("exporter.h")));
+}
+
 TEST_F(HeadersForSymbolTest, PreferPublicOverNameMatchOnPrivate) {
   Inputs.Code = R"cpp(
 #include "foo.h"
@@ -496,6 +524,5 @@
tooling::stdlib::Header::named("")));
 }
 
-
 } // namespace
 } // 

[clang-tools-extra] 5933d26 - [include-cleaner] Add a signal to down-rank exporting headers

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

Author: Kadir Cetinkaya
Date: 2023-07-05T15:37:17+02:00
New Revision: 5933d265b72a8e9aade5edd68998a00dc4fbb359

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

LOG: [include-cleaner] Add a signal to down-rank exporting headers

Currently exporter can have same relevance signals as the origin header
when name match signals don't trigger.
This patch introduces a tie braker signal to boost origin headers in
such cases, this is deliberately introduced with lower significance than
public-ness to make sure we still prefer a public-exporter instead of a
private-origin header.

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/lib/TypesInternal.h
clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
clang-tools-extra/include-cleaner/unittests/FindHeadersTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp 
b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index 1eff19cb5b..a1d9d3b5fb2154 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -96,7 +96,7 @@ 
hintedHeadersForStdHeaders(llvm::ArrayRef Headers,
const SourceManager , const PragmaIncludes *PI) {
   llvm::SmallVector> Results;
   for (const auto  : Headers) {
-Results.emplace_back(H, Hints::PublicHeader);
+Results.emplace_back(H, Hints::PublicHeader | Hints::OriginHeader);
 if (!PI)
   continue;
 for (const auto *Export : PI->getExporters(H, SM.getFileManager()))
@@ -186,10 +186,12 @@ llvm::SmallVector> findHeaders(const 
SymbolLocation ,
 if (!FE)
   return {};
 if (!PI)
-  return {{FE, Hints::PublicHeader}};
+  return {{FE, Hints::PublicHeader | Hints::OriginHeader}};
+bool IsOrigin = true;
 while (FE) {
-  Hints CurrentHints = isPublicHeader(FE, *PI);
-  Results.emplace_back(FE, CurrentHints);
+  Results.emplace_back(FE,
+   isPublicHeader(FE, *PI) |
+   (IsOrigin ? Hints::OriginHeader : Hints::None));
   // FIXME: compute transitive exporter headers.
   for (const auto *Export : PI->getExporters(FE, SM.getFileManager()))
 Results.emplace_back(Export, isPublicHeader(Export, *PI));
@@ -205,6 +207,7 @@ llvm::SmallVector> findHeaders(const 
SymbolLocation ,
   // Walkup the include stack for non self-contained headers.
   FID = SM.getDecomposedIncludedLoc(FID).first;
   FE = SM.getFileEntryForID(FID);
+  IsOrigin = false;
 }
 return Results;
   }

diff  --git a/clang-tools-extra/include-cleaner/lib/TypesInternal.h 
b/clang-tools-extra/include-cleaner/lib/TypesInternal.h
index 09a3933577a94f..e9f8689e8647e0 100644
--- a/clang-tools-extra/include-cleaner/lib/TypesInternal.h
+++ b/clang-tools-extra/include-cleaner/lib/TypesInternal.h
@@ -63,17 +63,20 @@ llvm::raw_ostream <<(llvm::raw_ostream &, const 
SymbolLocation &);
 /// Hints are sorted in ascending order of relevance.
 enum class Hints : uint8_t {
   None = 0x00,
+  /// Symbol is directly originating from this header, rather than being
+  /// exported or included transitively.
+  OriginHeader = 1 << 0,
   /// Provides a generally-usable definition for the symbol. (a function decl,
   /// or class definition and not a forward declaration of a template).
-  CompleteSymbol = 1 << 0,
+  CompleteSymbol = 1 << 1,
   /// Symbol is provided by a public file. Only absent in the cases where file
   /// is explicitly marked as such, non self-contained or IWYU private
   /// pragmas.
-  PublicHeader = 1 << 1,
+  PublicHeader = 1 << 2,
   /// Header providing the symbol is explicitly marked as preferred, with an
   /// IWYU private pragma that points at this provider or header and symbol has
   /// ~the same name.
-  PreferredHeader = 1 << 2,
+  PreferredHeader = 1 << 3,
   LLVM_MARK_AS_BITMASK_ENUM(PreferredHeader),
 };
 LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
@@ -86,6 +89,11 @@ template  struct Hinted : public T {
   bool operator<(const Hinted ) const {
 return static_cast(Hint) < static_cast(Other.Hint);
   }
+
+  friend llvm::raw_ostream <<(llvm::raw_ostream ,
+   const Hinted ) {
+return OS << static_cast(H.Hint) << " - " << static_cast(H);
+  }
 };
 
 } // namespace clang::include_cleaner

diff  --git a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
index 5b5f77b5fdea80..b6521d56bcff44 100644
--- a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp

[PATCH] D154349: [include-cleaner] Add a signal to down-rank exporting headers

2023-07-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154349

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


[PATCH] D154486: [Clang] Fix a crash when trying to initialize an invalid aggregate.

2023-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154486

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


[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Results from the last run (the same applies as before, the run postfix `_3` 
must be selected at top right corner):

| memcached_1.6.8_stdclf_notetag_interesting_test_3  | Reports 

  |
| tmux_2.6_stdclf_notetag_interesting_test_3 | Reports 

 |
| curl_curl-7_66_0_stdclf_notetag_interesting_test_3 | Reports 

 |
| twin_v0.8.1_stdclf_notetag_interesting_test_3  | Reports 

  |
| vim_v8.2.1920_stdclf_notetag_interesting_test_3| Reports 

|
| openssl_openssl-3.0.0-alpha7_stdclf_notetag_interesting_test_3 | Reports 

 |
| sqlite_version-3.33.0_stdclf_notetag_interesting_test_3| Reports 

|
| ffmpeg_n4.3.1_stdclf_notetag_interesting_test_3| Reports 

|
| postgres_REL_13_0_stdclf_notetag_interesting_test_3| Reports 

|
| xerces_v3.2.3_stdclf_notetag_interesting_test_3| Reports 

|
| bitcoin_v0.20.1_stdclf_notetag_interesting_test_3  | Reports 

  |


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

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


[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: clang-language-wg, cor3ntin.
aaron.ballman added a comment.

Thank you for working on this!




Comment at: clang/lib/Sema/SemaCast.cpp:1269-1272
+ResultType = Self.Context.getConstantArrayType(
+IAT->getElementType(),
+llvm::APInt(Self.Context.getTypeSize(Self.Context.getSizeType()), 1),
+/*SizeExpr=*/nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0);

This seems incorrect to me -- I think the `CastOperation` should be created 
with the correct result type to begin with. What you are citing is a note, but 
the actual wording that specifies that note is: 
https://eel.is/c++draft/dcl.init#general-16.5 so I think the fix approach is 
somewhat correct but the code lives in the wrong place, this should be closer 
to the initialization code I think.



Comment at: clang/test/SemaCXX/paren-list-agg-init.cpp:276-285
+namespace gh62863 {
+int (&)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[1] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&)[2] = static_cast(42); // expected-error {{reference to 
type 'int[2]' could not bind to an rvalue of type 'int[1]'}}
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}

I'd like to see test coverage for:
```
int (&)[] = (int[])(42);
int (&)[1] = (int[])(42);
int (&)[2] = (int[])(42);
int (&)[3] = (int[3])(42);
```
where we're using a C-style cast, because: http://eel.is/c++draft/expr.cast#4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2023-07-05 Thread Guillot Tony via Phabricator via cfe-commits
to268 updated this revision to Diff 537331.
to268 added a comment.

I have fixed the misleading diagnostic with auto array declarations.
The diagnostics now says that `'auto' is not allowed in array declarations`.

I am not sure with the way i have currently implemented it in ` SemaDecl.cpp`, 
maybe it can be done in a cleaner way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1190,12 +1190,12 @@
 
   Underspecified object definitions
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3006.htm;>N3006
-  Unknown
+  Unknown
 
 
   Type inference for object declarations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm;>N3007
-  No
+  Clang 17
 
 
   constexpr for object definitions
Index: clang/test/Sema/c2x-auto.c
===
--- /dev/null
+++ clang/test/Sema/c2x-auto.c
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -std=c2x -verify -pedantic -Wno-comments %s
+
+void test_basic_types(void) {
+  auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
+  auto auto_int = 4;
+  auto auto_long = 4UL;
+
+  _Static_assert(_Generic(auto_int, int : 1));
+  _Static_assert(_Generic(auto_long, unsigned long : 1));
+}
+
+void test_sizeof_typeof(void) {
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  typeof(auto) tpof = 4;  // expected-error {{expected expression}}
+}
+
+void test_casts(void) {
+  auto int_cast = (int)(4 + 3);
+  auto double_cast = (double)(1 / 3);
+  auto long_cast = (long)(4UL + 3UL);
+  auto auto_cast = (auto)(4 + 3); // expected-error {{expected expression}}
+
+  _Static_assert(_Generic(int_cast, int : 1));
+  _Static_assert(_Generic(double_cast, double : 1));
+  _Static_assert(_Generic(long_cast, long : 1));
+}
+
+void test_compound_literral(void) {
+  auto int_cl = (int){13};
+  auto double_cl = (double){2.5};
+  auto array[] = { 1, 2, 3 }; // expected-error {{cannot use 'auto' with initializer list in C}}
+
+  auto auto_cl = (auto){13};  // expected-error {{expected expression}}
+
+  _Static_assert(_Generic(int_cl, int : 1));
+  _Static_assert(_Generic(double_cl, double : 1));
+}
+
+void test_array_pointers(void) {
+  double array[3] = { 0 };
+  auto a = array;
+  auto b = 
+
+  _Static_assert(_Generic(array, double * : 1));
+  _Static_assert(_Generic(a, double * : 1));
+  _Static_assert(_Generic(b, double (*)[3] : 1));
+}
+
+void test_typeof() {
+  int typeof_target();
+  auto result = (typeof(typeof_target())){12};
+
+  _Static_assert(_Generic(result, int : 1));
+}
+
+void test_qualifiers(const int y) {
+  const auto a = 12;
+  auto b = y;
+  static auto c = 1UL;
+  int* pa =  // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}
+  const int* pb = 
+  int* pc =  // expected-warning {{incompatible pointer types initializing 'int *' with an expression of type 'unsigned long *'}}
+
+  _Static_assert(_Generic(a, int : 1));
+  _Static_assert(_Generic(b, int : 1));
+  _Static_assert(_Generic(c, unsigned long : 1));
+  _Static_assert(_Generic(pa, int * : 1));
+  _Static_assert(_Generic(pb, const int * : 1));
+  _Static_assert(_Generic(pc, int * : 1));
+}
+
+void test_strings(void) {
+  auto str = "this is a string";
+  auto str2[] = "this is a string";
+  auto (str3) = "this is a string";
+  auto (((str4))) = "this is a string";
+
+  _Static_assert(_Generic(str, char * : 1));
+  _Static_assert(_Generic(str2, char * : 1));
+  _Static_assert(_Generic(str3, char * : 1));
+  _Static_assert(_Generic(str4, char * : 1));
+}
+
+void test_pointers(void) {
+  auto a = 12;
+  auto *ptr =  // expected-warning {{explicit declaration of 'auto' pointers is a Clang extension}}
+  auto *str = "this is a string"; // expected-warning {{explicit declaration of 'auto' pointers is a Clang extension}}
+  const auto *str2 = "this is a string";  // expected-warning {{explicit declaration of 'auto' pointers is a Clang extension}}
+  auto *b =// expected-warning {{explicit declaration of 'auto' pointers is a Clang extension}}
+  *b = // expected-error {{incompatible pointer to integer conversion assigning to 'int' from 'int *'; remove &}}
+  auto nptr = nullptr;
+
+  

[clang] 4a49226 - [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

2023-07-05 Thread Akash Banerjee via cfe-commits

Author: Akash Banerjee
Date: 2023-07-05T14:03:54+01:00
New Revision: 4a49226537abafc9b372ba8ef61d14a817a5226a

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

LOG: [OpenMP] Change clang emitTargetDataCalls to use OMPIRBuilder

This patch changes the emitTargetDataCalls function in clang to make use of the 
OpenMPIRBuilder::createTargetData function for Target Data directive code gen.
Reapplying commit 0d8d718171192301f2beb10bd08ce62e70281a5e after fixing 
libomptarget test failure related to debug info.

Depends on D146557

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_data_codegen.cpp
clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 188b21e3a88949..180f3265ab1938 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -9026,14 +9026,14 @@ static void emitOffloadingArrays(
   InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
   CGF.Builder.GetInsertPoint());
 
-  auto fillInfoMap = [&](MappableExprsHandler::MappingExprInfo ) {
+  auto FillInfoMap = [&](MappableExprsHandler::MappingExprInfo ) {
 return emitMappingInformation(CGF, OMPBuilder, MapExpr);
   };
   if (CGM.getCodeGenOpts().getDebugInfo() !=
   llvm::codegenoptions::NoDebugInfo) {
 CombinedInfo.Names.resize(CombinedInfo.Exprs.size());
 llvm::transform(CombinedInfo.Exprs, CombinedInfo.Names.begin(),
-fillInfoMap);
+FillInfoMap);
   }
 
   auto DeviceAddrCB = [&](unsigned int I, llvm::Value *BP, llvm::Value *BPVal) 
{
@@ -10379,140 +10379,97 @@ void CGOpenMPRuntime::emitTargetDataCalls(
   // off.
   PrePostActionTy NoPrivAction;
 
-  // Generate the code for the opening of the data environment. Capture all the
-  // arguments of the runtime call by reference because they are used in the
-  // closing of the region.
-  auto & = [this, , Device, ,
- ](CodeGenFunction , PrePostActionTy &) {
-// Fill up the arrays with all the mapped variables.
-MappableExprsHandler::MapCombinedInfoTy CombinedInfo;
+  using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+  InsertPointTy AllocaIP(CGF.AllocaInsertPt->getParent(),
+ CGF.AllocaInsertPt->getIterator());
+  InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
+  CGF.Builder.GetInsertPoint());
+  llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
+
+  llvm::Value *IfCondVal = nullptr;
+  if (IfCond)
+IfCondVal = CGF.EvaluateExprAsBool(IfCond);
+
+  // Emit device ID if any.
+  llvm::Value *DeviceID = nullptr;
+  if (Device) {
+DeviceID = CGF.Builder.CreateIntCast(CGF.EmitScalarExpr(Device),
+ CGF.Int64Ty, /*isSigned=*/true);
+  } else {
+DeviceID = CGF.Builder.getInt64(OMP_DEVICEID_UNDEF);
+  }
 
+  // Fill up the arrays with all the mapped variables.
+  MappableExprsHandler::MapCombinedInfoTy CombinedInfo;
+  auto GenMapInfoCB =
+  [&](InsertPointTy CodeGenIP) -> llvm::OpenMPIRBuilder::MapInfosTy & {
+CGF.Builder.restoreIP(CodeGenIP);
 // Get map clause information.
 MappableExprsHandler MEHandler(D, CGF);
 MEHandler.generateAllInfo(CombinedInfo);
 
-// Fill up the arrays and create the arguments.
-emitOffloadingArrays(CGF, CombinedInfo, Info, OMPBuilder,
- /*IsNonContiguous=*/true);
-
-llvm::OpenMPIRBuilder::TargetDataRTArgs RTArgs;
-bool EmitDebug = CGF.CGM.getCodeGenOpts().getDebugInfo() !=
- llvm::codegenoptions::NoDebugInfo;
-OMPBuilder.emitOffloadingArraysArgument(CGF.Builder, RTArgs, Info,
-EmitDebug);
-
-// Emit device ID if any.
-llvm::Value *DeviceID = nullptr;
-if (Device) {
-  DeviceID = CGF.Builder.CreateIntCast(CGF.EmitScalarExpr(Device),
-   CGF.Int64Ty, /*isSigned=*/true);
-} else {
-  DeviceID = CGF.Builder.getInt64(OMP_DEVICEID_UNDEF);
+auto FillInfoMap = [&](MappableExprsHandler::MappingExprInfo ) {
+  return emitMappingInformation(CGF, OMPBuilder, MapExpr);
+};
+if (CGM.getCodeGenOpts().getDebugInfo() !=
+llvm::codegenoptions::NoDebugInfo) {
+  CombinedInfo.Names.resize(CombinedInfo.Exprs.size());
+  llvm::transform(CombinedInfo.Exprs, CombinedInfo.Names.begin(),
+  

[PATCH] D86993: Document Clang's expectations of the C standard library.

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

In D86993#4471912 , @RalfJung wrote:

> What is the status of this patch? It has not been committed as far as I can 
> tell.

Correct, it's not been committed yet. we're still discussing (though that's 
obviously stalled out a bit).

> I was looking into this coming from Rust, where we do worry a bit about LLVM 
> calling `memcpy`, `memmove` or `memset` in ways that are not allowed by the C 
> standard. This here would at least give us something to point to, though it 
> doesn't answer the question "which C standard libraries have officially 
> committed to guaranteeing these properties". Since this affects all compilers 
> using LLVM, not just Clang, should this be put somewhere in the LLVM docs?

I think it makes sense to document this both from the Clang perspective and 
from the LLVM perspective, as they're somewhat different. Clang strives to be a 
conforming C and C++ implementation, so our conformance requirements are 
different than LLVM, which aims to be a backend for more general use than just 
C and C++. For example, Clang needs to talk about freestanding and that's not 
really something LLVM needs to talk about as such.

I continue to think it's a mistake for us to document that Clang will not work 
with a conforming C standard library implementation unless we're filing issues 
with WG14 to alert them to the reasons why. If there's a DR filed with the 
committee, that gives us something to point our users to as justification. 
Otherwise, our users will correctly put these bugs at our feet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86993

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


[PATCH] D154486: [Clang] Fix a crash when trying to initialize an invalid aggregate.

2023-07-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 537319.
cor3ntin added a comment.

Address Aaron's Feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154486

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/paren-list-agg-init.cpp


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,25 @@
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct 
member}}
+  static const auto y = 1;
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' 
from a parenthesized list of values is a C++20 extension}}
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@
 }
   }
 
+  Expr *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-  CurInit.get());
+  cast(Entity.getDecl()), Init);
 
   // Check for std::move on construction.
-  if (const Expr *E = CurInit.get()) {
-CheckMoveOnConstruction(S, E,
-Entity.getKind() == InitializedEntity::EK_Result);
-  }
+  CheckMoveOnConstruction(S, Init,
+  Entity.getKind() == InitializedEntity::EK_Result);
 
-  return CurInit;
+  return Init;
 }
 
 /// Somewhere within T there is an uninitialized reference subobject.


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,25 @@
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct member}}
+  static const auto y = 1;
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' from a parenthesized list of values is a C++20 extension}}
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@
 }
   }
 
+  Expr *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-  CurInit.get());
+  cast(Entity.getDecl()), Init);
 
   // Check for std::move on construction.
-  if (const Expr *E = CurInit.get()) {
-CheckMoveOnConstruction(S, E,
-Entity.getKind() == InitializedEntity::EK_Result);
-  }
+  CheckMoveOnConstruction(S, Init,
+  Entity.getKind() == InitializedEntity::EK_Result);
 
-  return CurInit;
+  return Init;
 }
 
 /// Somewhere within T there is an uninitialized reference subobject.

[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-05 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: dexonsmith, rsmith, rjmccall.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When a function is declared in the same scope as a class with the same name 
then the function hides that class. Currently this is done by a single check 
after the main loop in LookupResult::resolveKind, but this can give the wrong 
result when we have a using declaration in multiple namespace scopes in two 
different ways:

- When the using declaration is hidden in one namespace but not the other we 
can end up considering only the hidden one when deciding if the result is 
ambiguous, causing an incorrect "not ambiguous" result.
- When two classes with the same name in different namespace scopes are both 
hidden by using declarations this can result in incorrectly deciding the result 
is ambiguous. There's currently a comment saying this is expected, but I don't 
think that's correct.

Solve this by having a separate loop before the main loop to eliminate classes 
that have been hidden by functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154503

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaCXX/using-hiding.cpp

Index: clang/test/SemaCXX/using-hiding.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/using-hiding.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace A {
+  class X { }; // expected-note{{candidate found by name lookup is 'A::X'}}
+}
+namespace B {
+  void X(int); // expected-note{{candidate found by name lookup is 'B::X'}}
+}
+
+// Using directive doesn't cause A::X to be hidden, so X is ambiguous.
+namespace Test1 {
+  using namespace A;
+  using namespace B;
+
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// Using declaration causes A::X to be hidden, so X is not ambiguous.
+namespace Test2 {
+  using A::X;
+  using B::X;
+
+  void f() {
+X(1);
+  }
+}
+
+// Behaviour here should be the same as including A and B directly.
+namespace Test3 {
+  namespace C {
+using A::X; // expected-note{{candidate found by name lookup is 'Test3::C::X'}}
+  }
+  namespace D {
+using B::X; // expected-note{{candidate found by name lookup is 'Test3::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// using B::X inside C should hide using A::X in C but not D, so the result is ambiguous.
+namespace Test4 {
+  namespace C {
+using A::X;
+using B::X; // expected-note{{candidate found by name lookup is 'Test4::C::X'}}
+  }
+  namespace D {
+using A::X; // expected-note{{candidate found by name lookup is 'Test4::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
+
+// A::X hidden in both C and D, so the result is not ambiguous.
+namespace Test5 {
+  namespace C {
+using A::X;
+using B::X;
+  }
+  namespace D {
+using A::X;
+using B::X;
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1);
+  }
+}
+
+// D declares a different class X, but it's hidden so the result is not ambiguous.
+namespace Test6 {
+  namespace C {
+using A::X;
+using B::X;
+  }
+  namespace D {
+class X { };
+using B::X;
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1);
+  }
+}
+
+// X inside C should hide X in C but not D.
+namespace Test7 {
+  namespace C {
+class X;
+void X(int); // expected-note{{candidate found by name lookup is 'Test7::C::X'}}
+  }
+  namespace D {
+class X; // expected-note{{candidate found by name lookup is 'Test7::D::X'}}
+  }
+  using namespace C;
+  using namespace D;
+  void f() {
+X(1); // expected-error{{reference to 'X' is ambiguous}}
+  }
+}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -504,6 +504,43 @@
   // Don't do any extra resolution if we've already resolved as ambiguous.
   if (ResultKind == Ambiguous) return;
 
+  // C++ [basic.scope.hiding]p2:
+  //   A class name or enumeration name can be hidden by the name of
+  //   an object, function, or enumerator declared in the same
+  //   scope. If a class or enumeration name and an object, function,
+  //   or enumerator are declared in the same scope (in any order)
+  //   with the same name, the class or enumeration name is hidden
+  //   wherever the object, function, or enumerator name is visible.
+  if (HideTags) {
+// First collect all decls that can hide others and those that can be hidden
+std::set CanHideOther, CanBeHidden;
+for (unsigned I = 0; I < N; ++I) {
+  const NamedDecl *D = 

[PATCH] D154486: [Clang] Fix a crash when trying to initialize an invalid aggregate.

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

Precommit CI found issues with the newly added test that should be addressed.




Comment at: clang/docs/ReleaseNotes.rst:633-634
   (`#63012 `_)
+- Fix a crash when trying to parentheses-initialize an invalid aggregate.
+  (`#63278 `_)
 

This is a new regression introduced in Clang 17, so I don't think we need a 
release note, right?



Comment at: clang/lib/Sema/SemaInit.cpp:9390
 
+  auto *Init = CurInit.get();
+  if (!Init)

Please spell out the type (and make it a const pointer if possible).



Comment at: clang/test/SemaCXX/paren-list-agg-init.cpp:281
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct 
member}}
+};

Probably worth it to add a `static auto y = 1;` case as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154486

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


[PATCH] D154502: [AST] Fix bug in UnresolvedSet::erase of last element

2023-07-05 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: dexonsmith, rsmith, rjmccall.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

UnresolvedSet::erase works by popping the last element then replacing the 
element to be erased with that element. When the element to be erased is itself 
the last element this leads to writing past the end of the set, causing an 
assertion failure.

Fix this by making erase of the last element just pop that element.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154502

Files:
  clang/include/clang/AST/UnresolvedSet.h
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/UnresolvedSetTest.cpp

Index: clang/unittests/AST/UnresolvedSetTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/UnresolvedSetTest.cpp
@@ -0,0 +1,115 @@
+#include "clang/AST/UnresolvedSet.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+class NamedDecl {
+  int dummy;
+
+public:
+  NamedDecl() {}
+};
+} // namespace clang
+
+using namespace clang;
+
+class UnresolvedSetTest : public ::testing::Test {
+protected:
+  NamedDecl n0, n1, n2, n3;
+  UnresolvedSet<2> set;
+
+  void SetUp() override {
+set.addDecl();
+set.addDecl();
+set.addDecl();
+set.addDecl();
+  }
+};
+
+TEST_F(UnresolvedSetTest, Size) { EXPECT_EQ(set.size(), 4u); }
+
+TEST_F(UnresolvedSetTest, ArrayOperator) {
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+  EXPECT_EQ(set[3].getDecl(), );
+}
+
+TEST_F(UnresolvedSetTest, EraseIntegerFromStart) {
+  set.erase(0);
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIntegerFromEnd) {
+  set.erase(3);
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(2);
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(1);
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(0);
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIteratorFromStart) {
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(set.begin());
+  EXPECT_EQ(set.size(), 0u);
+}
+
+TEST_F(UnresolvedSetTest, EraseIteratorFromEnd) {
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 3u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+  EXPECT_EQ(set[2].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 2u);
+  EXPECT_EQ(set[0].getDecl(), );
+  EXPECT_EQ(set[1].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 1u);
+  EXPECT_EQ(set[0].getDecl(), );
+
+  set.erase(--set.end());
+  EXPECT_EQ(set.size(), 0u);
+}
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -35,6 +35,7 @@
   StructuralEquivalenceTest.cpp
   TemplateNameTest.cpp
   TypePrinterTest.cpp
+  UnresolvedSetTest.cpp
   )
 
 clang_target_link_libraries(ASTTests
Index: clang/include/clang/AST/UnresolvedSet.h
===
--- clang/include/clang/AST/UnresolvedSet.h
+++ clang/include/clang/AST/UnresolvedSet.h
@@ -114,9 +114,17 @@
 I.I->set(New, AS);
   }
 
-  void erase(unsigned I) { decls()[I] = decls().pop_back_val(); }
+  void erase(unsigned I) {
+auto val = decls().pop_back_val();
+if (I < size())
+  decls()[I] = val;
+  }
 
-  void erase(iterator I) { *I.I = decls().pop_back_val(); }
+  void erase(iterator I) {
+auto val = decls().pop_back_val();
+if (I != end())
+  *I.I = val;
+  }
 
   void setAccess(iterator I, AccessSpecifier AS) { I.I->setAccess(AS); }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154493: [X86] Support some Intel CPUs for cpu_specific/dispatch feature

2023-07-05 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:333
   { {"pentium"}, CK_Pentium, ~0U, FeatureX87 | FeatureCMPXCHG8B, 'B', false },
   { {"pentium-mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX, '\0', false },
   { {"pentium_mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX, 'D', true },

add this as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154493

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


[PATCH] D153485: [dataflow] use true/false literals in formulas, rather than variables

2023-07-05 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71579569f439: [dataflow] use true/false literals in 
formulas, rather than variables (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D153485?vs=533439=537304#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153485

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2963,14 +2963,14 @@
 ASSERT_THAT(FooDecl, NotNull());
 
 const auto *FooVal =
-dyn_cast_or_null(Env.getValue(*FooDecl));
+dyn_cast_or_null(Env.getValue(*FooDecl));
 ASSERT_THAT(FooVal, NotNull());
 
 const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
 ASSERT_THAT(BarDecl, NotNull());
 
 const auto *BarVal =
-dyn_cast_or_null(Env.getValue(*BarDecl));
+dyn_cast_or_null(Env.getValue(*BarDecl));
 ASSERT_THAT(BarVal, NotNull());
 
 EXPECT_EQ(FooVal, (true));
@@ -3148,7 +3148,7 @@
 ASSERT_THAT(FooDecl, NotNull());
 
 const auto *FooVal =
-dyn_cast_or_null(Env.getValue(*FooDecl));
+dyn_cast_or_null(Env.getValue(*FooDecl));
 ASSERT_THAT(FooVal, NotNull());
 
 const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -457,6 +457,11 @@
 return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
+  // Returns a reference to a literal boolean value.
+  const Formula *literal(bool B) {
+return ::create(A, Formula::Literal, {}, B);
+  }
+
   // Creates a boolean conjunction.
   const Formula *conj(const Formula *LHS, const Formula *RHS) {
 return make(Formula::And, {LHS, RHS});
Index: clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
@@ -30,6 +30,12 @@
   EXPECT_THAT(llvm::to_string(*B), StrEq(Expected));
 }
 
+TEST(BoolValueDebugStringTest, Literal) {
+  ConstraintContext Ctx;
+  EXPECT_EQ("true", llvm::to_string(*Ctx.literal(true)));
+  EXPECT_EQ("false", llvm::to_string(*Ctx.literal(false)));
+}
+
 TEST(BoolValueDebugStringTest, Negation) {
   ConstraintContext Ctx;
   auto B = Ctx.neg(Ctx.atom());
@@ -91,16 +97,14 @@
 
 TEST(BoolValueDebugStringTest, ComplexBooleanWithSomeNames) {
   ConstraintContext Ctx;
-  auto True = Ctx.atom();
-  auto False = Ctx.atom();
-  auto V2 = Ctx.atom();
-  auto V3 = Ctx.atom();
+  auto X = Ctx.atom();
+  auto Y = Ctx.atom();
   Formula::AtomNames Names;
-  Names[True->getAtom()] = "true";
-  Names[False->getAtom()] = "false";
-  auto B = Ctx.disj(Ctx.conj(False, V2), Ctx.disj(True, V3));
+  Names[X->getAtom()] = "X";
+  Names[Y->getAtom()] = "Y";
+  auto B = Ctx.disj(Ctx.conj(Y, Ctx.atom()), Ctx.disj(X, Ctx.atom()));
 
-  auto Expected = R"(((false & V2) | (true | V3)))";
+  auto Expected = R"(((Y & V2) | (X | V3)))";
   std::string Actual;
   llvm::raw_string_ostream OS(Actual);
   B->print(OS, );
Index: clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
@@ -31,12 +31,6 @@
   EXPECT_NE(, );
 }
 
-TEST_F(ArenaTest, GetOrCreateConjunctionReturnsSameExprGivenSameArgs) {
-  auto  = A.makeAtomRef(A.makeAtom());
-  auto  = A.makeAnd(X, X);
-  EXPECT_EQ(, );
-}
-
 TEST_F(ArenaTest, GetOrCreateConjunctionReturnsSameExprOnSubsequentCalls) {
   auto  = A.makeAtomRef(A.makeAtom());
   auto  = A.makeAtomRef(A.makeAtom());
@@ -52,12 +46,6 @@
   EXPECT_NE(, );
 }
 
-TEST_F(ArenaTest, GetOrCreateDisjunctionReturnsSameExprGivenSameArgs) {
-  

[clang] 7157956 - [dataflow] use true/false literals in formulas, rather than variables

2023-07-05 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-07-05T14:06:48+02:00
New Revision: 71579569f4399d3cf6bc618dcd449b5388d749cc

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

LOG: [dataflow] use true/false literals in formulas, rather than variables

And simplify formulas containing true/false
It's unclear to me how useful this is, it does make formulas more
conveniently self-contained now (we can usefully print them without
carrying around the "true/false" labels)

(while here, simplify !!X to X, too)

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/Arena.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/Formula.h
clang/lib/Analysis/FlowSensitive/Arena.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/Formula.cpp
clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Arena.h 
b/clang/include/clang/Analysis/FlowSensitive/Arena.h
index 373697dc7379c5..8437caefeeda8f 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Arena.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Arena.h
@@ -19,7 +19,9 @@ namespace clang::dataflow {
 /// For example, `Value`, `StorageLocation`, `Atom`, and `Formula`.
 class Arena {
 public:
-  Arena() : True(makeAtom()), False(makeAtom()) {}
+  Arena()
+  : True(Formula::create(Alloc, Formula::Literal, {}, 1)),
+False(Formula::create(Alloc, Formula::Literal, {}, 0)) {}
   Arena(const Arena &) = delete;
   Arena =(const Arena &) = delete;
 
@@ -105,9 +107,7 @@ class Arena {
   const Formula (Atom A);
 
   /// Returns a formula for a literal true/false.
-  const Formula (bool Value) {
-return makeAtomRef(Value ? True : False);
-  }
+  const Formula (bool Value) { return Value ? True : False; }
 
   /// Returns a new atomic boolean variable, distinct from any other.
   Atom makeAtom() { return static_cast(NextAtom++); };
@@ -139,7 +139,7 @@ class Arena {
   llvm::DenseMap FormulaValues;
   unsigned NextAtom = 0;
 
-  Atom True, False;
+  const Formula , 
 };
 
 } // namespace clang::dataflow

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 116373dce15c81..b94485c99c9bad 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -467,9 +467,8 @@ class Environment {
 
   /// Returns a symbolic boolean value that models a boolean literal equal to
   /// `Value`
-  AtomicBoolValue (bool Value) const {
-return cast(
-arena().makeBoolValue(arena().makeLiteral(Value)));
+  BoolValue (bool Value) const {
+return arena().makeBoolValue(arena().makeLiteral(Value));
   }
 
   /// Returns an atomic boolean value.

diff  --git a/clang/include/clang/Analysis/FlowSensitive/Formula.h 
b/clang/include/clang/Analysis/FlowSensitive/Formula.h
index 0c7b1ecd02b17c..1d8cb6b3a8b1e6 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Formula.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Formula.h
@@ -54,7 +54,8 @@ class alignas(const Formula *) Formula {
 /// A reference to an atomic boolean variable.
 /// We name these e.g. "V3", where 3 == atom identity == Value.
 AtomRef,
-// FIXME: add const true/false rather than modeling them as variables
+/// Constant true or false.
+Literal,
 
 Not, /// True if its only operand is false
 
@@ -71,6 +72,11 @@ class alignas(const Formula *) Formula {
 return static_cast(Value);
   }
 
+  bool literal() const {
+assert(kind() == Literal);
+return static_cast(Value);
+  }
+
   ArrayRef operands() const {
 return ArrayRef(reinterpret_cast(this + 1),
 numOperands(kind()));
@@ -83,9 +89,9 @@ class alignas(const Formula *) Formula {
   void print(llvm::raw_ostream , const AtomNames * = nullptr) const;
 
   // Allocate Formulas using Arena rather than calling this function directly.
-  static Formula (llvm::BumpPtrAllocator , Kind K,
- ArrayRef Operands,
- unsigned Value = 0);
+  static const Formula (llvm::BumpPtrAllocator , Kind K,
+   ArrayRef Operands,
+   unsigned Value = 0);
 
 private:
   Formula() = default;
@@ -95,6 +101,7 @@ class 

[clang] 8a3fdf7 - [UTC] Add fallback support for specific metadata, and check their defs

2023-07-05 Thread Henrik G. Olsson via cfe-commits

Author: Henrik G. Olsson
Date: 2023-07-05T14:04:50+02:00
New Revision: 8a3fdf7b908978625e9a7e57fbb443e4e6f98976

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

LOG: [UTC] Add fallback support for specific metadata, and check their defs

This prevents update_cc_tests.py from emitting hard-coded identifiers
for metadata (global variable checkers still check hard-coded
identifiers). Instead it emits regex checkers that match even if the
identifiers change. Also adds a new mode for --check-globals: instead of
simply being on or off, it now has the options 'none', 'smart' and
'all', with 'none' and 'all' corresponding to the previous modes.

The 'smart' mode only emits checks for global definitions referenced
in the IR or other metadata that itself has a definition checker
emitted, making the rule transitive. It does not emit checks for
attribute sets, since that is better checked by --check-attributes. This
mode is made the new default. To make the change in default mode
backwards compatible a version bump is introduced (to v3), and the
default remains 'none' in v1 & v2.

This will result in metadata checks being emitted more often, so filters
are added to not check absolute file paths and compiler version git
hashes.

rdar://105239218

Added: 
clang/test/utils/update_cc_test_checks/Inputs/annotations.c
clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
clang/test/utils/update_cc_test_checks/annotations.test

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected

Modified: 

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
clang/test/utils/update_cc_test_checks/check-globals.test
clang/test/utils/update_cc_test_checks/generated-funcs.test

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_cc_test_checks.py
llvm/utils/update_test_checks.py

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/annotations.c 
b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c
new file mode 100644
index 00..f09b0f788e9b12
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
+
+int foo() {
+int x = x + 1;
+return x;
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
new file mode 100644
index 00..b4eb9b0091900c
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
@@ -0,0 +1,21 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: define dso_local i32 @foo
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[X:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 0, ptr [[X]], align 4, !annotation 
[[META2:![0-9]+]]
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP0]], 1
+// CHECK-NEXT:store i32 [[ADD]], ptr [[X]], align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X]], align 4
+// CHECK-NEXT:ret i32 [[TMP1]]
+//
+int foo() {
+int x = x + 1;
+return x;
+}
+//.
+// CHECK: [[META2]] = !{!"auto-init"}
+//.

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
 

[clang] 5e4ad81 - [dataflow] Replace most BoolValue subclasses with references to Formula (and AtomicBoolValue => Atom and BoolValue => Formula where appropriate)

2023-07-05 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-07-05T13:54:32+02:00
New Revision: 5e4ad816bf100b0325ed45ab1cfea18deb3ab3d1

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

LOG: [dataflow] Replace most BoolValue subclasses with references to Formula 
(and AtomicBoolValue => Atom and BoolValue => Formula where appropriate)

This properly frees the Value hierarchy from managing boolean formulas.

We still distinguish AtomicBoolValue; this type is used in client code.
However we expect to convert such uses to BoolValue (where the
distinction is not needed) or Atom (where atomic identity is intended),
and then fold AtomicBoolValue into FormulaBoolValue.

We also distinguish TopBoolValue; this has distinct rules for
widen/join/equivalence, and top-ness is not represented in Formula.
It'd be nice to find a cleaner representation (e.g. the absence of a
formula), but no immediate plans.

For now, BoolValues with the same Formula are deduplicated. This doesn't
seem desirable, as Values are mutable by their creators (properties).
We can probably drop this for FormulaBoolValue immediately (not in this
patch, to isolate changes). For AtomicBoolValue we first need to update
clients to stop using value pointers for atom identity.

The data structures around flow conditions are updated:
- flow condition tokens are Atom, rather than AtomicBoolValue*
- conditions are Formula, rather than BoolValue
Most APIs were changed directly, some with many clients had a
new version added and the existing one deprecated.

The factories for BoolValues in Environment keep their existing
signatures for now (e.g. makeOr(BoolValue, BoolValue) => BoolValue)
and are not deprecated. These have very many clients and finding the
most ergonomic API & migration path still needs some thought.

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/Arena.h
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/include/clang/Analysis/FlowSensitive/Value.h
clang/lib/Analysis/FlowSensitive/Arena.cpp
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
clang/unittests/Analysis/FlowSensitive/ValueTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Arena.h 
b/clang/include/clang/Analysis/FlowSensitive/Arena.h
index b6c62e76246254..373697dc7379c5 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Arena.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Arena.h
@@ -16,12 +16,10 @@
 namespace clang::dataflow {
 
 /// The Arena owns the objects that model data within an analysis.
-/// For example, `Value` and `StorageLocation`.
+/// For example, `Value`, `StorageLocation`, `Atom`, and `Formula`.
 class Arena {
 public:
-  Arena()
-  : TrueVal(create()),
-FalseVal(create()) {}
+  Arena() : True(makeAtom()), False(makeAtom()) {}
   Arena(const Arena &) = delete;
   Arena =(const Arena &) = delete;
 
@@ -57,33 +55,25 @@ class Arena {
 .get());
   }
 
-  /// Returns a boolean value that represents the conjunction of `LHS` and
-  /// `RHS`. Subsequent calls with the same arguments, regardless of their
-  /// order, will return the same result. If the given boolean values represent
-  /// the same value, the result will be the value itself.
-  BoolValue (BoolValue , BoolValue );
-
-  /// Returns a boolean value that represents the disjunction of `LHS` and
-  /// `RHS`. Subsequent calls with the same arguments, regardless of their
-  /// order, will return the same result. If the given boolean values represent
-  /// the same value, the result will be the value itself.
-  BoolValue (BoolValue , BoolValue );
-
-  /// Returns a boolean value that represents the negation of `Val`. Subsequent
-  /// calls with the same argument will return the same result.
-  BoolValue (BoolValue );
-
-  /// Returns a boolean value that represents `LHS => RHS`. Subsequent calls
-  /// with the same arguments, will return the same result. If the given 
boolean
-  /// values represent the same value, the result will be a value that
-  /// represents the true boolean literal.
-  BoolValue (BoolValue , BoolValue );
-
-  /// Returns a boolean value that represents `LHS <=> RHS`. Subsequent calls
-  /// with the same arguments, regardless of 

[PATCH] D153469: [dataflow] Replace most BoolValue subclasses with references to Formula (and AtomicBoolValue => Atom and BoolValue => Formula where appropriate)

2023-07-05 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG5e4ad816bf10: [dataflow] Replace most BoolValue subclasses 
with references to Formula (and… (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D153469?vs=533405=537301#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153469

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/ValueTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/ValueTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Analysis/FlowSensitive/Value.h"
+#include "clang/Analysis/FlowSensitive/Arena.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -39,17 +40,19 @@
 }
 
 TEST(ValueTest, TopsEquivalent) {
-  TopBoolValue V1;
-  TopBoolValue V2;
+  Arena A;
+  TopBoolValue V1(A.makeAtomRef(Atom(0)));
+  TopBoolValue V2(A.makeAtomRef(Atom(1)));
   EXPECT_TRUE(areEquivalentValues(V1, V2));
   EXPECT_TRUE(areEquivalentValues(V2, V1));
 }
 
 TEST(ValueTest, EquivalentValuesWithDifferentPropsEquivalent) {
-  TopBoolValue Prop1;
-  TopBoolValue Prop2;
-  TopBoolValue V1;
-  TopBoolValue V2;
+  Arena A;
+  TopBoolValue Prop1(A.makeAtomRef(Atom(0)));
+  TopBoolValue Prop2(A.makeAtomRef(Atom(1)));
+  TopBoolValue V1(A.makeAtomRef(Atom(2)));
+  TopBoolValue V2(A.makeAtomRef(Atom(3)));
   V1.setProperty("foo", Prop1);
   V2.setProperty("bar", Prop2);
   EXPECT_TRUE(areEquivalentValues(V1, V2));
@@ -57,9 +60,10 @@
 }
 
 TEST(ValueTest, DifferentKindsNotEquivalent) {
+  Arena A;
   auto L = ScalarStorageLocation(QualType());
   ReferenceValue V1(L);
-  TopBoolValue V2;
+  TopBoolValue V2(A.makeAtomRef(Atom(0)));
   EXPECT_FALSE(areEquivalentValues(V1, V2));
   EXPECT_FALSE(areEquivalentValues(V2, V1));
 }
Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3018,14 +3018,12 @@
   ASSERT_THAT(BazDecl, NotNull());
 
   const auto *BazVal =
-  dyn_cast_or_null(Env.getValue(*BazDecl));
+  dyn_cast_or_null(Env.getValue(*BazDecl));
   ASSERT_THAT(BazVal, NotNull());
-  EXPECT_EQ(>getLeftSubValue(), FooVal);
-
-  const auto *BazRightSubValVal =
-  cast(>getRightSubValue());
-  EXPECT_EQ(>getLeftSubValue(), BarVal);
-  EXPECT_EQ(>getRightSubValue(), QuxVal);
+  auto  = Env.arena();
+  EXPECT_EQ(>formula(),
+(FooVal->formula(),
+   A.makeOr(BarVal->formula(), QuxVal->formula(;
 });
   }
 
@@ -3068,15 +3066,12 @@
   ASSERT_THAT(BazDecl, NotNull());
 
   const auto *BazVal =
-  dyn_cast_or_null(Env.getValue(*BazDecl));
+  dyn_cast_or_null(Env.getValue(*BazDecl));
   ASSERT_THAT(BazVal, NotNull());
-
-  const auto *BazLeftSubValVal =
-  cast(>getLeftSubValue());
-  EXPECT_EQ(>getLeftSubValue(), FooVal);
-  EXPECT_EQ(>getRightSubValue(), QuxVal);
-
-  EXPECT_EQ(>getRightSubValue(), BarVal);
+  auto  = Env.arena();
+  EXPECT_EQ(>formula(),
+(A.makeAnd(FooVal->formula(), QuxVal->formula()),
+  BarVal->formula()));
 });
   }
 
@@ -3122,17 +3117,14 @@
   ASSERT_THAT(FooDecl, NotNull());
 
   const auto *FooVal =
-  dyn_cast_or_null(Env.getValue(*FooDecl));
+  dyn_cast_or_null(Env.getValue(*FooDecl));
   ASSERT_THAT(FooVal, NotNull());
-
-  const auto  =
-  cast(FooVal->getLeftSubValue());
-  const auto  =
-  

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-07-05 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 537299.
hnrklssn added a comment.

Update test cases after rebasing on ToT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

Files:
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  clang/test/utils/update_cc_test_checks/annotations.test
  clang/test/utils/update_cc_test_checks/check-globals.test
  clang/test/utils/update_cc_test_checks/generated-funcs.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -79,7 +79,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -195,7 +198,7 @@
 common.dump_input_lines(output_lines, ti, prefix_set, ";")
 
 args = ti.args
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -205,6 +208,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 
@@ -272,6 +276,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 has_checked_pre_function_globals = True
@@ -301,7 +306,7 @@
 continue
 is_in_function = is_in_function_start = True
 
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -311,6 +316,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 False,
+args.check_globals,
 )
 )
 if ti.args.gen_unused_prefix_body:
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -205,7 +205,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -436,7 +439,7 @@
 is_filtered=builder.is_filtered(),
 )
 
-if ti.args.check_globals:
+if ti.args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -444,8 +447,9 @@
 run_list,
 output_lines,
   

[PATCH] D153469: [dataflow] Replace most BoolValue subclasses with references to Formula (and AtomicBoolValue => Atom and BoolValue => Formula where appropriate)

2023-07-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/Arena.h:61
+  /// Passing in the same formula will result in the same BoolValue.
+  /// FIXME: This canonicalization isn't sound e.g. if we create two BoolValues
+  ///with the same formula but attach different properties.

gribozavr2 wrote:
> Per our offline conversation, do you still believe in this fixme?
No, I'm no longer convinced "unsound" is true.

However, I do think there's something to be fixed: if we really believe in it, 
we should be interning other types of values too (or have a clear idea about 
why bools are special).

And I think I still lean towards removing it: it looks like a 
power-vs-complexity tradeoff in the Value concept, and I suspect the historical 
reason to intern values was to intern formulas, not because we needed the power.

Reworded the fixme to say we should decide and be more consistent - text 
doesn't take a position on which way we should decide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153469

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


[PATCH] D154495: clang: Attach !fpmath metadata to __builtin_sqrt based on language flags

2023-07-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, Anastasia, jcranmer-intel, tra, jlebar, jhuber6.
Herald added a project: All.
arsenm requested review of this revision.
Herald added subscribers: jplehr, sstefan1, wdng.
Herald added a reviewer: jdoerfert.

OpenCL and HIP have -cl-fp32-correctly-rounded-divide-sqrt and
-fno-hip-correctly-rounded-divide-sqrt. The corresponding fpmath metadata
was only set on fdiv, and not sqrt. The backend is currently underutilizing
sqrt lowering options, and the responsibility is split between the libraries
and backend and this metadata is needed.

  

CUDA/NVCC has -prec-div and -prev-sqrt but clang doesn't appear to be
aiming for compatibility with those. Don't know if OpenMP has a similar
control.


https://reviews.llvm.org/D154495

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCUDA/correctly-rounded-div.cu
  clang/test/CodeGenOpenCL/fpmath.cl

Index: clang/test/CodeGenOpenCL/fpmath.cl
===
--- clang/test/CodeGenOpenCL/fpmath.cl
+++ clang/test/CodeGenOpenCL/fpmath.cl
@@ -21,6 +21,13 @@
   return a / b;
 }
 
+float spscalarsqrt(float a) {
+  // CHECK-LABEL: @spscalarsqrt
+  // NODIVOPT: call float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD:[0-9]+]]
+  // DIVOPT: call float @llvm.sqrt.f32(float %{{.+}}){{$}}
+  return __builtin_sqrtf(a);
+}
+
 #if __OPENCL_C_VERSION__ >=120
 void printf(constant char* fmt, ...);
 
@@ -34,11 +41,26 @@
 
 #ifndef NOFP64
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
+typedef __attribute__(( ext_vector_type(4) )) double double4;
+
 double dpscalardiv(double a, double b) {
   // CHECK: @dpscalardiv
   // CHECK-NOT: !fpmath
   return a / b;
 }
+
+double4 dpvectordiv(double4 a, double4 b) {
+  // CHECK: @dpvectordiv
+  // CHECK-NOT: !fpmath
+  return a / b;
+}
+
+double dpscalarsqrt(double a) {
+  // CHECK-LABEL: @dpscalarsqrt
+  // CHECK: call double @llvm.sqrt.f64(double %{{.+}}){{$}}
+  return __builtin_sqrt(a);
+}
+
 #endif
 
 // NODIVOPT: ![[MD]] = !{float 2.50e+00}
Index: clang/test/CodeGenCUDA/correctly-rounded-div.cu
===
--- clang/test/CodeGenCUDA/correctly-rounded-div.cu
+++ clang/test/CodeGenCUDA/correctly-rounded-div.cu
@@ -32,4 +32,18 @@
   return a / b;
 }
 
-// NCRDIV: ![[MD]] = !{float 2.50e+00}
+// COMMON-LABEL: @_Z12spscalarsqrt
+// NCRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD:[0-9]+]]
+// CRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}){{$}}
+__device__ float spscalarsqrt(float a) {
+  return __builtin_sqrtf(a);
+}
+
+// COMMON-LABEL: @_Z12dpscalarsqrt
+// COMMON: call contract double @llvm.sqrt.f64(double %{{.+}}){{$}}
+// COMMON-NOT: !fpmath
+__device__ double dpscalarsqrt(double a) {
+  return __builtin_sqrt(a);
+}
+
+// NCRSQRT: ![[MD]] = !{float 2.50e+00}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4688,6 +4688,10 @@
   /// point operation, expressed as the maximum relative error in ulp.
   void SetFPAccuracy(llvm::Value *Val, float Accuracy);
 
+  /// SetFPAccuracy - Set the minimum required accuracy of the given fdiv or
+  /// sqrt operation based on CodeGenOpts.
+  void SetSqrtOrDivFPAccuracy(llvm::Value *Val);
+
   /// Set the codegen fast-math flags.
   void SetFastMathFlags(FPOptions FPFeatures);
 
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -3478,21 +3478,7 @@
 llvm::Value *Val;
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, Ops.FPFeatures);
 Val = Builder.CreateFDiv(Ops.LHS, Ops.RHS, "div");
-if ((CGF.getLangOpts().OpenCL &&
- !CGF.CGM.getCodeGenOpts().OpenCLCorrectlyRoundedDivSqrt) ||
-(CGF.getLangOpts().HIP && CGF.getLangOpts().CUDAIsDevice &&
- !CGF.CGM.getCodeGenOpts().HIPCorrectlyRoundedDivSqrt)) {
-  // OpenCL v1.1 s7.4: minimum accuracy of single precision / is 2.5ulp
-  // OpenCL v1.2 s5.6.4.2: The -cl-fp32-correctly-rounded-divide-sqrt
-  // build option allows an application to specify that single precision
-  // floating-point divide (x/y and 1/x) and sqrt used in the program
-  // source are correctly rounded.
-  llvm::Type *ValTy = Val->getType();
-  if (ValTy->isFloatTy() ||
-  (isa(ValTy) &&
-   cast(ValTy)->getElementType()->isFloatTy()))
-CGF.SetFPAccuracy(Val, 2.5);
-}
+CGF.SetSqrtOrDivFPAccuracy(Val);
 return Val;
   }
   else if (Ops.isFixedPointOp())
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp

[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

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



Comment at: clang/lib/AST/ExprConstant.cpp:4921
+  // value is.
+  if (isa(E))
+return false;

hokein wrote:
> hokein wrote:
> > hokein wrote:
> > > yronglin wrote:
> > > > yronglin wrote:
> > > > > aaron.ballman wrote:
> > > > > > yronglin wrote:
> > > > > > > hokein wrote:
> > > > > > > > The constant evaluator is not aware of the "error" concept, it 
> > > > > > > > is only aware of value-dependent -- the general idea behind is 
> > > > > > > > that we treat the dependent-on-error and 
> > > > > > > > dependent-on-template-parameters cases the same, they are 
> > > > > > > > potentially constant (if we see an expression contains errors, 
> > > > > > > > it could be constant depending on how the error is resolved), 
> > > > > > > > this will give us nice recovery and avoid bogus following 
> > > > > > > > diagnostics.
> > > > > > > > 
> > > > > > > > So, a `RecoveryExpr` should not result in failure when checking 
> > > > > > > > for a potential constant expression.
> > > > > > > > 
> > > > > > > > I think the right fix is to remove the conditional check `if 
> > > > > > > > (!EvaluateDependentExpr(SS->getCond(), Info))` in 
> > > > > > > > `EvaluateSwitch`, and return `ESR_Failed` unconditionally (we 
> > > > > > > > don't know its value, any switch-case anwser will be wrong in 
> > > > > > > > some cases). We already do this for return-statment, 
> > > > > > > > do-statement etc.
> > > > > > > > 
> > > > > > > > 
> > > > > > > Do you mean?
> > > > > > > ```
> > > > > > > if (SS->getCond()->isValueDependent()) {
> > > > > > > EvaluateDependentExpr(SS->getCond(), Info);
> > > > > > > return ESR_Failed;
> > > > > > > }
> > > > > > > ```
> > > > > > > the general idea behind is that we treat the dependent-on-error 
> > > > > > > and dependent-on-template-parameters cases the same, they are 
> > > > > > > potentially constant (if we see an expression contains errors, it 
> > > > > > > could be constant depending on how the error is resolved), this 
> > > > > > > will give us nice recovery and avoid bogus following diagnostics.
> > > > > > 
> > > > > > I could use some further education on why this is the correct 
> > > > > > approach. For a dependent-on-template-parameters case, this makes 
> > > > > > sense -- either the template will be instantiated (at which point 
> > > > > > we'll know if it's a constant expression) or it won't be (at which 
> > > > > > point it's constant expression-ness doesn't matter). But for error 
> > > > > > recovery, we will *never* get a valid constant expression.
> > > > > > 
> > > > > > I worry about the performance overhead of continuing on with 
> > > > > > constant expression evaluation in the error case. We use these code 
> > > > > > paths not only to get a value but to say "is this a constant 
> > > > > > expression at all?".
> > > > > > 
> > > > > > I don't see why the fix should be localized to just the switch 
> > > > > > statement condition; it seems like *any* attempt to get a dependent 
> > > > > > value from an error recovery expression is a point at which we can 
> > > > > > definitively say "this is not a constant expression" and move on.
> > > > > I understand that continuing to perform constant evaluation when an 
> > > > > error occurs can bring more additional diagnostic information (such 
> > > > > as jumping to the default branch to continue calculation when the 
> > > > > condition expression evaluation of switch-statement fails), but the 
> > > > > additional diagnostic message that is emitted is in some cases 
> > > > > doesn't usually useful, and as Aaron said may affect performance of 
> > > > > clang. I don't have enough experience to make a tradeoff between the 
> > > > > two. BTW 
> > > > > https://github.com/llvm/llvm-project/blob/843ff7581408a02e852c0f1f7ebf176cabbc7527/clang/lib/Parse/ParseStmt.cpp#L1894-L1909
> > > > >  I don't quite understand why a RecoveryExpr is not created here, 
> > > > > which caused to the whole do statement disappears on the 
> > > > > AST(https://godbolt.org/z/PsPb31YKP), should we fix this? 
> > > > Thanks a lot for your comments! @aaron.ballman 
> > > > But for error recovery, we will *never* get a valid constant expression.
> > > 
> > > Yeah, this is true, and we don't evaluate these error-dependent 
> > > expressions.
> > > 
> > > I think the question here is that when we encounter an error-dependent 
> > > expression during a constant expression evaluation, do we want to bailout 
> > > the whole evaluation immediately, or just ignore the evaluation of this 
> > > error-dependent expression and continue to proceed when possible?
> > > 
> > > We choose 2) -- this was based on the discussion with @rsmith. This will 
> > > likely give us decent error-recovery and useful followup diagnostics.
> > > 
> > > Some concrete examples,
> > > 
> > > ```
> > > int abc();
> > > constexpr int f() { 
> > >   error(); 
> > >   // We emit a 

[PATCH] D154493: [X86] Support some Intel CPUs for cpu_specific/dispatch feature

2023-07-05 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154493

Files:
  clang/test/CodeGen/attr-cpuspecific-cpus.c
  llvm/lib/TargetParser/X86TargetParser.cpp

Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -333,48 +333,48 @@
   { {"pentium-mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX, '\0', false },
   { {"pentium_mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX, 'D', true },
   // i686-generation processors, P6 / Pentium M microarchitecture based.
-  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B, '\0', false },
+  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B, 'C', false },
   { {"pentium_pro"}, CK_PentiumPro, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B, 'C', true },
   { {"i686"}, CK_i686, ~0U, FeatureCMOV | FeatureX87 | FeatureCMPXCHG8B, '\0', false },
-  { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2, '\0', false },
+  { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2, 'E', false },
   { {"pentium_ii"}, CK_Pentium2, ~0U, FeaturesPentium2, 'E', true },
-  { {"pentium3"}, CK_Pentium3, ~0U, FeaturesPentium3, '\0', false },
-  { {"pentium3m"}, CK_Pentium3, ~0U, FeaturesPentium3, '\0', false },
+  { {"pentium3"}, CK_Pentium3, ~0U, FeaturesPentium3, 'H', false },
+  { {"pentium3m"}, CK_Pentium3, ~0U, FeaturesPentium3, 'H', false },
   { {"pentium_iii"}, CK_Pentium3, ~0U, FeaturesPentium3, 'H', true },
   { {"pentium_iii_no_xmm_regs"}, CK_Pentium3, ~0U, FeaturesPentium3, 'H', true },
   { {"pentium-m"}, CK_PentiumM, ~0U, FeaturesPentium4, '\0', false },
   { {"pentium_m"}, CK_PentiumM, ~0U, FeaturesPentium4, 'K', true },
   { {"c3-2"}, CK_C3_2, ~0U, FeaturesPentium3, '\0', false },
-  { {"yonah"}, CK_Yonah, ~0U, FeaturesPrescott, '\0', false },
+  { {"yonah"}, CK_Yonah, ~0U, FeaturesPrescott, 'L', false },
   // Netburst microarchitecture based processors.
-  { {"pentium4"}, CK_Pentium4, ~0U, FeaturesPentium4, '\0', false },
-  { {"pentium4m"}, CK_Pentium4, ~0U, FeaturesPentium4, '\0', false },
+  { {"pentium4"}, CK_Pentium4, ~0U, FeaturesPentium4, 'J', false },
+  { {"pentium4m"}, CK_Pentium4, ~0U, FeaturesPentium4, 'J', false },
   { {"pentium_4"}, CK_Pentium4, ~0U, FeaturesPentium4, 'J', true },
   { {"pentium_4_sse3"}, CK_Prescott, ~0U, FeaturesPrescott, 'L', true },
-  { {"prescott"}, CK_Prescott, ~0U, FeaturesPrescott, '\0', false },
-  { {"nocona"}, CK_Nocona, ~0U, FeaturesNocona, '\0', false },
+  { {"prescott"}, CK_Prescott, ~0U, FeaturesPrescott, 'L', false },
+  { {"nocona"}, CK_Nocona, ~0U, FeaturesNocona, 'L', false },
   // Core microarchitecture based processors.
-  { {"core2"}, CK_Core2, FEATURE_SSSE3, FeaturesCore2, '\0', false },
+  { {"core2"}, CK_Core2, FEATURE_SSSE3, FeaturesCore2, 'M', false },
   { {"core_2_duo_ssse3"}, CK_Core2, ~0U, FeaturesCore2, 'M', true },
-  { {"penryn"}, CK_Penryn, ~0U, FeaturesPenryn, '\0', false },
+  { {"penryn"}, CK_Penryn, ~0U, FeaturesPenryn, 'N', false },
   { {"core_2_duo_sse4_1"}, CK_Penryn, ~0U, FeaturesPenryn, 'N', true },
   // Atom processors
-  { {"bonnell"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell, '\0', false },
+  { {"bonnell"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell, 'O', false },
   { {"atom"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell, 'O', false },
-  { {"silvermont"}, CK_Silvermont, FEATURE_SSE4_2, FeaturesSilvermont, '\0', false },
-  { {"slm"}, CK_Silvermont, FEATURE_SSE4_2, FeaturesSilvermont, '\0', false },
+  { {"silvermont"}, CK_Silvermont, FEATURE_SSE4_2, FeaturesSilvermont, 'c', false },
+  { {"slm"}, CK_Silvermont, FEATURE_SSE4_2, FeaturesSilvermont, 'c', false },
   { {"atom_sse4_2"}, CK_Nehalem, FEATURE_SSE4_2, FeaturesNehalem, 'c', true },
   { {"atom_sse4_2_movbe"}, CK_Goldmont, FEATURE_SSE4_2, FeaturesGoldmont, 'd', true },
   { {"goldmont"}, CK_Goldmont, FEATURE_SSE4_2, FeaturesGoldmont, 'i', false },
   { {"goldmont-plus"}, CK_GoldmontPlus, FEATURE_SSE4_2, FeaturesGoldmontPlus, '\0', false },
-  { {"goldmont_plus"}, CK_GoldmontPlus, FEATURE_SSE4_2, FeaturesGoldmontPlus, '\0', true },
-  { {"tremont"}, CK_Tremont, FEATURE_SSE4_2, FeaturesTremont, '\0', false },
+  { {"goldmont_plus"}, CK_GoldmontPlus, FEATURE_SSE4_2, FeaturesGoldmontPlus, 'd', true },
+  { {"tremont"}, CK_Tremont, FEATURE_SSE4_2, FeaturesTremont, 'd', false },
   // Nehalem microarchitecture based processors.
-  { {"nehalem"}, CK_Nehalem, FEATURE_SSE4_2, FeaturesNehalem, '\0', false },
+  { {"nehalem"}, CK_Nehalem, FEATURE_SSE4_2, FeaturesNehalem, 'P', false },
   { {"core_i7_sse4_2"}, CK_Nehalem, FEATURE_SSE4_2, FeaturesNehalem, 'P', true },
-  { {"corei7"}, CK_Nehalem, 

[clang] 1c3ac8d - Reland "[dataflow] Add dedicated representation of boolean formulas"

2023-07-05 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-07-05T13:35:16+02:00
New Revision: 1c3ac8dfa16c42a631968aadd0396cfe7f7778e0

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

LOG: Reland "[dataflow] Add dedicated representation of boolean formulas"

This reverts commit 7a72ce98224be76d9328e65eee472381f7c8e7fe.

Test problems were due to unspecified order of function arg evaluation.

Added: 
clang/include/clang/Analysis/FlowSensitive/Formula.h
clang/lib/Analysis/FlowSensitive/Formula.cpp

Modified: 
clang/include/clang/Analysis/FlowSensitive/Arena.h
clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
clang/include/clang/Analysis/FlowSensitive/Solver.h
clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
clang/lib/Analysis/FlowSensitive/Arena.cpp
clang/lib/Analysis/FlowSensitive/CMakeLists.txt
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/Arena.h 
b/clang/include/clang/Analysis/FlowSensitive/Arena.h
index 83b4ddeec02564..b6c62e76246254 100644
--- a/clang/include/clang/Analysis/FlowSensitive/Arena.h
+++ b/clang/include/clang/Analysis/FlowSensitive/Arena.h
@@ -8,6 +8,7 @@
 #ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__ARENA_H
 #define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE__ARENA_H
 
+#include "clang/Analysis/FlowSensitive/Formula.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include 
@@ -104,7 +105,17 @@ class Arena {
 return create();
   }
 
+  /// Gets the boolean formula equivalent of a BoolValue.
+  /// Each unique Top values is translated to an Atom.
+  /// TODO: migrate to storing Formula directly in Values instead.
+  const Formula (const BoolValue &);
+
+  /// Returns a new atomic boolean variable, distinct from any other.
+  Atom makeAtom() { return static_cast(NextAtom++); };
+
 private:
+  llvm::BumpPtrAllocator Alloc;
+
   // Storage for the state of a program.
   std::vector> Locs;
   std::vector> Vals;
@@ -122,6 +133,9 @@ class Arena {
   llvm::DenseMap, BiconditionalValue *>
   BiconditionalVals;
 
+  llvm::DenseMap ValToFormula;
+  unsigned NextAtom = 0;
+
   AtomicBoolValue 
   AtomicBoolValue 
 };

diff  --git a/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h 
b/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
index 360786b02729f2..6b9f3681490af1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
@@ -19,7 +19,6 @@
 
 #include "clang/Analysis/FlowSensitive/Solver.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 
 namespace clang {
@@ -28,52 +27,9 @@ namespace dataflow {
 /// Returns a string representation of a value kind.
 llvm::StringRef debugString(Value::Kind Kind);
 
-/// Returns a string representation of a boolean assignment to true or false.
-llvm::StringRef debugString(Solver::Result::Assignment Assignment);
-
 /// Returns a string representation of the result status of a SAT check.
 llvm::StringRef debugString(Solver::Result::Status Status);
 
-/// Returns a string representation for the boolean value `B`.
-///
-/// Atomic booleans appearing in the boolean value `B` are assigned to labels
-/// either specified in `AtomNames` or created by default rules as B0, B1, ...
-///
-/// Requirements:
-///
-///   Names assigned to atoms should not be repeated in `AtomNames`.
-std::string debugString(
-const BoolValue ,
-llvm::DenseMap AtomNames = {{}});
-
-/// Returns a string representation for `Constraints` - a collection of boolean
-/// formulas.
-///
-/// Atomic booleans appearing in the boolean value `Constraints` are assigned 
to
-/// labels either specified in `AtomNames` or created by default rules as B0,
-/// B1, ...
-///
-/// Requirements:
-///
-///   Names assigned to atoms should not be repeated in `AtomNames`.
-std::string debugString(
-const llvm::ArrayRef Constraints,
-llvm::DenseMap AtomNames = {{}});
-
-/// Returns a string representation for `Constraints` - a collection of boolean
-/// formulas and the `Result` of satisfiability checking.
-///
-/// Atomic booleans appearing in `Constraints` and `Result` are assigned to
-/// labels either specified in `AtomNames` or created by default rules as B0,
-/// B1, ...
-///
-/// Requirements:

[PATCH] D154477: [include-cleaner] Ignore the layering-violation errors for the standalone tool

2023-07-05 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67e94c9dc8ff: [include-cleaner] Ignore the 
layering-violation errors for the standalone tool (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D154477?vs=537240=537292#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154477

Files:
  clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
  clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
  clang-tools-extra/include-cleaner/test/module.cpp
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -95,6 +95,15 @@
   RecordedPP PP;
   PragmaIncludes PI;
 
+  bool BeginInvocation(CompilerInstance ) override {
+// We only perform include-cleaner analysis. So we disable diagnostics that
+// won't affect our analysis to make the tool more robust against
+// in-development code.
+CI.getLangOpts().ModulesDeclUse = false;
+CI.getLangOpts().ModulesStrictDeclUse = false;
+return true;
+  }
+
   void ExecuteAction() override {
 auto  = getCompilerInstance().getPreprocessor();
 P.addPPCallbacks(PP.record(P));
Index: clang-tools-extra/include-cleaner/test/module.cpp
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/test/module.cpp
@@ -0,0 +1,7 @@
+// RUN: cp %s %t.cpp
+// RUN: clang-include-cleaner -edit %t.cpp -- -I%S/Inputs/modules 
-fimplicit-module-maps -fmodules-strict-decluse -fmodule-name=XA
+// RUN: FileCheck --match-full-lines --check-prefix=EDIT %s < %t.cpp
+
+// Verify the tool still works on compilable-but-layering-violation code.
+#include "a.h"
+// EDIT-NOT: {{^}}#include "a.h"{{$}}
Index: clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
@@ -0,0 +1,2 @@
+module XA {
+}
Index: clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
@@ -0,0 +1,2 @@
+#pragma once
+class A {};


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -95,6 +95,15 @@
   RecordedPP PP;
   PragmaIncludes PI;
 
+  bool BeginInvocation(CompilerInstance ) override {
+// We only perform include-cleaner analysis. So we disable diagnostics that
+// won't affect our analysis to make the tool more robust against
+// in-development code.
+CI.getLangOpts().ModulesDeclUse = false;
+CI.getLangOpts().ModulesStrictDeclUse = false;
+return true;
+  }
+
   void ExecuteAction() override {
 auto  = getCompilerInstance().getPreprocessor();
 P.addPPCallbacks(PP.record(P));
Index: clang-tools-extra/include-cleaner/test/module.cpp
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/test/module.cpp
@@ -0,0 +1,7 @@
+// RUN: cp %s %t.cpp
+// RUN: clang-include-cleaner -edit %t.cpp -- -I%S/Inputs/modules -fimplicit-module-maps -fmodules-strict-decluse -fmodule-name=XA
+// RUN: FileCheck --match-full-lines --check-prefix=EDIT %s < %t.cpp
+
+// Verify the tool still works on compilable-but-layering-violation code.
+#include "a.h"
+// EDIT-NOT: {{^}}#include "a.h"{{$}}
Index: clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
@@ -0,0 +1,2 @@
+module XA {
+}
Index: clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
===
--- /dev/null
+++ clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
@@ -0,0 +1,2 @@
+#pragma once
+class A {};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 67e94c9 - [include-cleaner] Ignore the layering-violation errors for the standalone tool

2023-07-05 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-07-05T13:30:26+02:00
New Revision: 67e94c9dc8ff7ac49f2557e02fdf375edd850d76

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

LOG: [include-cleaner] Ignore the layering-violation errors for the standalone 
tool

If the source code is compilable-but-layering-violation, we still want
the tool to be functional on it (rather than bailing out).

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

Added: 
clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
clang-tools-extra/include-cleaner/test/module.cpp

Modified: 
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/test/Inputs/modules/a.h 
b/clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
new file mode 100644
index 00..0b502e27d342bb
--- /dev/null
+++ b/clang-tools-extra/include-cleaner/test/Inputs/modules/a.h
@@ -0,0 +1,2 @@
+#pragma once
+class A {};

diff  --git a/clang-tools-extra/include-cleaner/test/Inputs/modules/module.map 
b/clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
new file mode 100644
index 00..510bfdbd1d83be
--- /dev/null
+++ b/clang-tools-extra/include-cleaner/test/Inputs/modules/module.map
@@ -0,0 +1,2 @@
+module XA {
+}

diff  --git a/clang-tools-extra/include-cleaner/test/module.cpp 
b/clang-tools-extra/include-cleaner/test/module.cpp
new file mode 100644
index 00..b344d16eefdf20
--- /dev/null
+++ b/clang-tools-extra/include-cleaner/test/module.cpp
@@ -0,0 +1,7 @@
+// RUN: cp %s %t.cpp
+// RUN: clang-include-cleaner -edit %t.cpp -- -I%S/Inputs/modules 
-fimplicit-module-maps -fmodules-strict-decluse -fmodule-name=XA
+// RUN: FileCheck --match-full-lines --check-prefix=EDIT %s < %t.cpp
+
+// Verify the tool still works on compilable-but-layering-violation code.
+#include "a.h"
+// EDIT-NOT: {{^}}#include "a.h"{{$}}

diff  --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 574023fda4968f..62febb488531af 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -95,6 +95,15 @@ class Action : public clang::ASTFrontendAction {
   RecordedPP PP;
   PragmaIncludes PI;
 
+  bool BeginInvocation(CompilerInstance ) override {
+// We only perform include-cleaner analysis. So we disable diagnostics that
+// won't affect our analysis to make the tool more robust against
+// in-development code.
+CI.getLangOpts().ModulesDeclUse = false;
+CI.getLangOpts().ModulesStrictDeclUse = false;
+return true;
+  }
+
   void ExecuteAction() override {
 auto  = getCompilerInstance().getPreprocessor();
 P.addPPCallbacks(PP.record(P));



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


[PATCH] D153001: [clang][ThreadSafety] Add __builtin_instance_member (WIP)

2023-07-05 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

We probably parse the attributes delayed in C++ but not in C. This probably 
also means you can't refer to later members in the attribute, so the mutex 
always needs to come first, right? Not sure if such a limitation is expected 
for C developers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153001

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


[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

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



Comment at: clang/lib/Format/BreakableToken.cpp:199
 
+if (EscapeSequence && Advance == 2) {
+  switch (Text[1]) {

Can we add a unit test for escape sequences > \X which I assume this handles


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[PATCH] D154091: [clang-format] Recognize escape sequences when breaking strings

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

What would happen for say unicode escapes?

  x = "XXXThis is a string \u0041 With stuff after";

would it break after the \u?

  x = "XXXThis is a string \u
  0041 With stuff after";


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154091

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


[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-07-05 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:4921
+  // value is.
+  if (isa(E))
+return false;

yronglin wrote:
> yronglin wrote:
> > aaron.ballman wrote:
> > > yronglin wrote:
> > > > hokein wrote:
> > > > > The constant evaluator is not aware of the "error" concept, it is 
> > > > > only aware of value-dependent -- the general idea behind is that we 
> > > > > treat the dependent-on-error and dependent-on-template-parameters 
> > > > > cases the same, they are potentially constant (if we see an 
> > > > > expression contains errors, it could be constant depending on how the 
> > > > > error is resolved), this will give us nice recovery and avoid bogus 
> > > > > following diagnostics.
> > > > > 
> > > > > So, a `RecoveryExpr` should not result in failure when checking for a 
> > > > > potential constant expression.
> > > > > 
> > > > > I think the right fix is to remove the conditional check `if 
> > > > > (!EvaluateDependentExpr(SS->getCond(), Info))` in `EvaluateSwitch`, 
> > > > > and return `ESR_Failed` unconditionally (we don't know its value, any 
> > > > > switch-case anwser will be wrong in some cases). We already do this 
> > > > > for return-statment, do-statement etc.
> > > > > 
> > > > > 
> > > > Do you mean?
> > > > ```
> > > > if (SS->getCond()->isValueDependent()) {
> > > > EvaluateDependentExpr(SS->getCond(), Info);
> > > > return ESR_Failed;
> > > > }
> > > > ```
> > > > the general idea behind is that we treat the dependent-on-error and 
> > > > dependent-on-template-parameters cases the same, they are potentially 
> > > > constant (if we see an expression contains errors, it could be constant 
> > > > depending on how the error is resolved), this will give us nice 
> > > > recovery and avoid bogus following diagnostics.
> > > 
> > > I could use some further education on why this is the correct approach. 
> > > For a dependent-on-template-parameters case, this makes sense -- either 
> > > the template will be instantiated (at which point we'll know if it's a 
> > > constant expression) or it won't be (at which point it's constant 
> > > expression-ness doesn't matter). But for error recovery, we will *never* 
> > > get a valid constant expression.
> > > 
> > > I worry about the performance overhead of continuing on with constant 
> > > expression evaluation in the error case. We use these code paths not only 
> > > to get a value but to say "is this a constant expression at all?".
> > > 
> > > I don't see why the fix should be localized to just the switch statement 
> > > condition; it seems like *any* attempt to get a dependent value from an 
> > > error recovery expression is a point at which we can definitively say 
> > > "this is not a constant expression" and move on.
> > I understand that continuing to perform constant evaluation when an error 
> > occurs can bring more additional diagnostic information (such as jumping to 
> > the default branch to continue calculation when the condition expression 
> > evaluation of switch-statement fails), but the additional diagnostic 
> > message that is emitted is in some cases doesn't usually useful, and as 
> > Aaron said may affect performance of clang. I don't have enough experience 
> > to make a tradeoff between the two. BTW 
> > https://github.com/llvm/llvm-project/blob/843ff7581408a02e852c0f1f7ebf176cabbc7527/clang/lib/Parse/ParseStmt.cpp#L1894-L1909
> >  I don't quite understand why a RecoveryExpr is not created here, which 
> > caused to the whole do statement disappears on the 
> > AST(https://godbolt.org/z/PsPb31YKP), should we fix this? 
> Thanks a lot for your comments! @aaron.ballman 
> But for error recovery, we will *never* get a valid constant expression.

Yeah, this is true, and we don't evaluate these error-dependent expressions.

I think the question here is that when we encounter an error-dependent 
expression during a constant expression evaluation, do we want to bailout the 
whole evaluation immediately, or just ignore the evaluation of this 
error-dependent expression and continue to proceed when possible?

We choose 2) -- this was based on the discussion with @rsmith. This will likely 
give us decent error-recovery and useful followup diagnostics.

Some concrete examples,

```
int abc();
constexpr int f() { 
  error(); 
  // We emit a diagnostic "Constexpr function never produces a constant 
expression, because abc() cannot be used in a constant expression"
  return abc(); 
}
```

```
// We prefer to treat the function f as a constexpr function even though it has 
an error expression. We will preserve more information in the AST, e.g. 
clangd's hover on the function call `f()` can give you the return value 1.

constexpr int f() {
   error();
   return 1;
}
```

> I worry about the performance overhead of continuing on with constant 
> expression evaluation in the error case. We use these code paths not only to 
> get a value but to say "is 

[PATCH] D154492: [Clang] Fix handling of using declarations in for loop init statements.

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

The type was never saved, and therefore never transformed
in dependent contexts.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154492

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Parse/ParseStmt.cpp
  clang/test/SemaCXX/cxx23-init-statement.cpp


Index: clang/test/SemaCXX/cxx23-init-statement.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx23-init-statement.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 -Wall %s
+
+namespace GH63627 {
+template
+void ok() {
+  if  (using U = decltype([]{ return 42;}); true) {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); [[maybe_unused]] auto x : "abc") {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); false; ) {
+  static_assert(U{}() == 42);
+  }
+}
+
+template
+void err() {
+  if  (using U = decltype([]{}.foo); true) {}  // expected-error {{no member 
named 'foo'}}
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member 
named 'foo'}}
+   [[maybe_unused]] auto x : "abc") { }
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member 
named 'foo'}}
+   false ; ) { }
+};
+
+void test() {
+  ok();
+  err(); // expected-note {{in instantiation of function template 
specialization 'GH63627::err'}}
+}
+
+}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2054,15 +2054,15 @@
   Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
 }
 DeclGroupPtrTy DG;
+SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
 if (Tok.is(tok::kw_using)) {
   DG = ParseAliasDeclarationInInitStatement(DeclaratorContext::ForInit,
 attrs);
+  FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
 } else {
   // In C++0x, "for (T NS:a" might not be a typo for ::
   bool MightBeForRangeStmt = getLangOpts().CPlusPlus;
   ColonProtectionRAIIObject ColonProtection(*this, MightBeForRangeStmt);
-
-  SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
   ParsedAttributes DeclSpecAttrs(AttrFactory);
   DG = ParseSimpleDeclaration(
   DeclaratorContext::ForInit, DeclEnd, attrs, DeclSpecAttrs, false,
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -630,6 +630,9 @@
 - Allow abstract parameter and return types in functions that are
   either deleted or not defined.
   (`#63012 `_)
+- Fix handling of using-declarations in the init statements of for
+  loop declarations.
+  (`#63627 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/cxx23-init-statement.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx23-init-statement.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 -Wall %s
+
+namespace GH63627 {
+template
+void ok() {
+  if  (using U = decltype([]{ return 42;}); true) {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); [[maybe_unused]] auto x : "abc") {
+  static_assert(U{}() == 42);
+  }
+  for (using U = decltype([]{ return 42;}); false; ) {
+  static_assert(U{}() == 42);
+  }
+}
+
+template
+void err() {
+  if  (using U = decltype([]{}.foo); true) {}  // expected-error {{no member named 'foo'}}
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member named 'foo'}}
+   [[maybe_unused]] auto x : "abc") { }
+
+  for (using U = decltype([]{}.foo);  // expected-error {{no member named 'foo'}}
+   false ; ) { }
+};
+
+void test() {
+  ok();
+  err(); // expected-note {{in instantiation of function template specialization 'GH63627::err'}}
+}
+
+}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -2054,15 +2054,15 @@
   Diag(Tok, diag::warn_gcc_variable_decl_in_for_loop);
 }
 DeclGroupPtrTy DG;
+SourceLocation DeclStart = Tok.getLocation(), DeclEnd;
 if (Tok.is(tok::kw_using)) {
   DG = ParseAliasDeclarationInInitStatement(DeclaratorContext::ForInit,
 attrs);
+  FirstPart = Actions.ActOnDeclStmt(DG, DeclStart, Tok.getLocation());
 } else {
   // In C++0x, "for (T NS:a" might not be a typo for ::
 

[PATCH] D152504: [clang][ThreadSafety] Analyze cleanup functions

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

Ping


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

https://reviews.llvm.org/D152504

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


[PATCH] D153001: [clang][ThreadSafety] Add __builtin_instance_member (WIP)

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153001

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


[PATCH] D154478: [analyzer][NFC] Use unique_ptrs for PathDiagnosticConsumers

2023-07-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal planned changes to this revision.
steakhal added a comment.

Hm, it seems like it broke some CSA unittests. I'll look into that once I have 
some time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154478

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


[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

A thousand times yes!




Comment at: clang/docs/ClangFormatStyleOptions.rst:4354
+
+  * ``RPS_None`` (in configuration: ``None``)
+Do not remove parentheses.

Should this be Leave, meaning "Don't touch anything?" vs None which could be 
confused with "No Parentheses"



Comment at: clang/docs/ClangFormatStyleOptions.rst:4363
+
+  * ``RPS_DoubleParentheses`` (in configuration: ``DoubleParentheses``)
+Replace double, triple, etc. parentheses with single parentheses.

Honestly I'm fine with this as it is but should this be? to describe what it 
will become?

e.g. "SingleParentheses"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154484

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-07-05 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

(The patch description could use an update...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D154467: [clang-format] Add Verilog suffixes to the scripts

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

What would happen for say unicode escapes?

  x = "XXXThis is a string \u0041 With stuff after";

would it break after the \u?

  x = "XXXThis is a string \u
  0041 With stuff after";


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154467

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


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-07-05 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 537286.
hnrklssn added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1.

Add unnamed global test case

Added cases in generated-funcs.c with --check-globals all, testing that named 
and unnamed globals are matched differently.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

Files:
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  clang/test/utils/update_cc_test_checks/annotations.test
  clang/test/utils/update_cc_test_checks/check-globals.test
  clang/test/utils/update_cc_test_checks/generated-funcs.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -79,7 +79,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -195,7 +198,7 @@
 common.dump_input_lines(output_lines, ti, prefix_set, ";")
 
 args = ti.args
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -205,6 +208,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 
@@ -272,6 +276,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 has_checked_pre_function_globals = True
@@ -301,7 +306,7 @@
 continue
 is_in_function = is_in_function_start = True
 
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -311,6 +316,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 False,
+args.check_globals,
 )
 )
 if ti.args.gen_unused_prefix_body:
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -205,7 +205,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -436,7 +439,7 @@
 is_filtered=builder.is_filtered(),
 )
 
-if ti.args.check_globals:
+if ti.args.check_globals != 'none':
 generated_prefixes.extend(
 

[PATCH] D154450: [clangd][c++20] Drop first template argument in code completion in some contexts.

2023-07-05 Thread Jens Massberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1af0e34477a3: [clangd][c++20] Drop first template argument 
in code completion in some… (authored by massberg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154450

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3961,26 +3961,54 @@
 template<$tparam^A U>
 int foo();
 
+template
+int bar(T t) requires $expr^A;
+
 template
-concept b = $other^A && $other^sizeof(T) % 2 == 0 || $other^A && sizeof(T) == 1;
+concept b = $expr^A && $expr^sizeof(T) % 2 == 0 || $expr^A && sizeof(T) == 1;
+
+$toplevel^A auto i = 19;
+
+template<$toplevel^A auto i> void constrainedNTTP();
 
-$other^A auto i = 19;
+// FIXME: The first parameter should be dropped in this case.
+void abbreviated($expr^A auto x) {}
   )cpp");
   TestTU TU;
   TU.Code = Code.code().str();
   TU.ExtraArgs = {"-std=c++20"};
 
-  std::vector Syms = {conceptSym("same_as")};
+  auto Sym = conceptSym("same_as");
+  Sym.Signature = "";
+  Sym.CompletionSnippetSuffix = "<${1:typename Tp}, ${2:typename Up}>";
+  std::vector Syms = {Sym};
   for (auto P : Code.points("tparam")) {
-ASSERT_THAT(completions(TU, P, Syms).Completions,
-AllOf(Contains(named("A")), Contains(named("same_as")),
-  Contains(named("class")), Contains(named("typename"
+ASSERT_THAT(
+completions(TU, P, Syms).Completions,
+AllOf(Contains(AllOf(named("A"), signature(""), snippetSuffix(""))),
+  Contains(AllOf(named("same_as"), signature(""),
+ snippetSuffix("<${2:typename Up}>"))),
+  Contains(named("class")), Contains(named("typename"
 << "Completing template parameter at position " << P;
   }
 
-  for (auto P : Code.points("other")) {
-EXPECT_THAT(completions(TU, P, Syms).Completions,
-AllOf(Contains(named("A")), Contains(named("same_as"
+  for (auto P : Code.points("toplevel")) {
+EXPECT_THAT(
+completions(TU, P, Syms).Completions,
+AllOf(Contains(AllOf(named("A"), signature(""), snippetSuffix(""))),
+  Contains(AllOf(named("same_as"), signature(""),
+ snippetSuffix("<${2:typename Up}>")
+<< "Completing 'requires' expression at position " << P;
+  }
+
+  for (auto P : Code.points("expr")) {
+EXPECT_THAT(
+completions(TU, P, Syms).Completions,
+AllOf(Contains(AllOf(named("A"), signature(""),
+ snippetSuffix("<${1:class T}>"))),
+  Contains(AllOf(
+  named("same_as"), signature(""),
+  snippetSuffix("<${1:typename Tp}, ${2:typename Up}>")
 << "Completing 'requires' expression at position " << P;
   }
 }
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -316,6 +316,15 @@
   }
 };
 
+// Remove the first template argument from Signature.
+// If Signature only contains a single argument an empty string is returned.
+std::string removeFirstTemplateArg(llvm::StringRef Signature) {
+  auto Rest = Signature.split(",").second;
+  if (Rest.empty())
+return "";
+  return ("<" + Rest.ltrim()).str();
+}
+
 // Assembles a code completion out of a bundle of >=1 completion candidates.
 // Many of the expensive strings are only computed at this point, once we know
 // the candidate bundle is going to be returned.
@@ -336,7 +345,7 @@
 EnableFunctionArgSnippets(Opts.EnableFunctionArgSnippets),
 IsUsingDeclaration(IsUsingDeclaration), NextTokenKind(NextTokenKind) {
 Completion.Deprecated = true; // cleared by any non-deprecated overload.
-add(C, SemaCCS);
+add(C, SemaCCS, ContextKind);
 if (C.SemaResult) {
   assert(ASTCtx);
   Completion.Origin |= SymbolOrigin::AST;
@@ -443,21 +452,40 @@
   });
   }
 
-  void add(const CompletionCandidate , CodeCompletionString *SemaCCS) {
+  void add(const CompletionCandidate , CodeCompletionString *SemaCCS,
+   CodeCompletionContext::Kind ContextKind) {
 assert(bool(C.SemaResult) == bool(SemaCCS));
 Bundled.emplace_back();
 BundledEntry  = Bundled.back();
+bool IsConcept = false;
 if (C.SemaResult) {
   getSignature(*SemaCCS, , , C.SemaResult->Kind,
C.SemaResult->CursorKind, );
   if (!C.SemaResult->FunctionCanBeCall)
 

[clang-tools-extra] 1af0e34 - [clangd][c++20] Drop first template argument in code completion in some contexts.

2023-07-05 Thread Jens Massberg via cfe-commits

Author: Jens Massberg
Date: 2023-07-05T12:04:24+02:00
New Revision: 1af0e34477a3b4a28a1c251e527c9f75f5cf69e1

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

LOG: [clangd][c++20] Drop first template argument in code completion in some 
contexts.

In case of a top level context the first template argument of a concept
should be dropped. Currently the indexer doesn't support different
signatures for different contexts (for an index entry always the default
`Symbol` context is used). Thus we add a hack which checks if we are in
a top level context and have a concept and in that case removes the
first argment of the signature and snippet suffix. If there is only a
single argument, the signature and snippet suffix are completly
removed. The check for the first argument is done by simply looking for
the first comma which should be sufficient in most cases.

Additionally extend test environment to support adding artificial index
entries with signature and completion snippet suffix.

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 70f2634aa7763e..68e12b2fb00167 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -316,6 +316,15 @@ struct ScoredBundleGreater {
   }
 };
 
+// Remove the first template argument from Signature.
+// If Signature only contains a single argument an empty string is returned.
+std::string removeFirstTemplateArg(llvm::StringRef Signature) {
+  auto Rest = Signature.split(",").second;
+  if (Rest.empty())
+return "";
+  return ("<" + Rest.ltrim()).str();
+}
+
 // Assembles a code completion out of a bundle of >=1 completion candidates.
 // Many of the expensive strings are only computed at this point, once we know
 // the candidate bundle is going to be returned.
@@ -336,7 +345,7 @@ struct CodeCompletionBuilder {
 EnableFunctionArgSnippets(Opts.EnableFunctionArgSnippets),
 IsUsingDeclaration(IsUsingDeclaration), NextTokenKind(NextTokenKind) {
 Completion.Deprecated = true; // cleared by any non-deprecated overload.
-add(C, SemaCCS);
+add(C, SemaCCS, ContextKind);
 if (C.SemaResult) {
   assert(ASTCtx);
   Completion.Origin |= SymbolOrigin::AST;
@@ -443,21 +452,40 @@ struct CodeCompletionBuilder {
   });
   }
 
-  void add(const CompletionCandidate , CodeCompletionString *SemaCCS) {
+  void add(const CompletionCandidate , CodeCompletionString *SemaCCS,
+   CodeCompletionContext::Kind ContextKind) {
 assert(bool(C.SemaResult) == bool(SemaCCS));
 Bundled.emplace_back();
 BundledEntry  = Bundled.back();
+bool IsConcept = false;
 if (C.SemaResult) {
   getSignature(*SemaCCS, , , 
C.SemaResult->Kind,
C.SemaResult->CursorKind, );
   if (!C.SemaResult->FunctionCanBeCall)
 S.SnippetSuffix.clear();
   S.ReturnType = getReturnType(*SemaCCS);
+  if (C.SemaResult->Kind == CodeCompletionResult::RK_Declaration)
+if (const auto *D = C.SemaResult->getDeclaration())
+  if (isa(D))
+IsConcept = true;
 } else if (C.IndexResult) {
   S.Signature = std::string(C.IndexResult->Signature);
   S.SnippetSuffix = std::string(C.IndexResult->CompletionSnippetSuffix);
   S.ReturnType = std::string(C.IndexResult->ReturnType);
+  if (C.IndexResult->SymInfo.Kind == index::SymbolKind::Concept)
+IsConcept = true;
 }
+
+/// When a concept is used as a type-constraint (e.g. `Iterator auto x`),
+/// and in some other contexts, its first type argument is not written.
+/// Drop the parameter from the signature.
+if (IsConcept && ContextKind == CodeCompletionContext::CCC_TopLevel) {
+  S.Signature = removeFirstTemplateArg(S.Signature);
+  // Dropping the first placeholder from the suffix will leave a $2
+  // with no $1.
+  S.SnippetSuffix = removeFirstTemplateArg(S.SnippetSuffix);
+}
+
 if (!Completion.Documentation) {
   auto SetDoc = [&](llvm::StringRef Doc) {
 if (!Doc.empty()) {
@@ -2020,7 +2048,7 @@ class CodeCompleteFlow {
 Item, SemaCCS, AccessibleScopes, *Inserter, FileName,
 CCContextKind, Opts, IsUsingDeclaration, 
NextTokenKind);
   else
-Builder->add(Item, SemaCCS);
+Builder->add(Item, SemaCCS, CCContextKind);
 }
 return Builder->build();
   }

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 

[PATCH] D154478: [analyzer][NFC] Use unique_ptrs for PathDiagnosticConsumers

2023-07-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154478

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


[PATCH] D153058: [clang][CFG] Support construction of a weak topological ordering of the CFG.

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



Comment at: clang/include/clang/Analysis/Analyses/IntervalPartition.h:56-64
+  template  struct NodeData {
+// The block from which the interval was constructed. It is either the
+// graph's entry block or has at least one predecessor outside the 
interval.
+const Node *Header;
+std::vector Nodes;
+  };
+  using IntervalData = std::variant, NodeData>;

Correct me if I'm wrong but I have the impression that `CFGInterval` might 
either contain only `CfgBlock`s or other `CfgInterval`s, but these might never 
be mixed. The current representation does allow such mixing. In case do not 
need that, I think it might be cleaner to make `CfgInterval` itself templated 
and remove the `std::variant`.



Comment at: clang/include/clang/Analysis/Analyses/IntervalPartition.h:101-103
+/// groups topologically. As a result, the blocks in a series of loops are
+/// ordered such that all nodes in loop `i` are earlier in the order than nodes
+/// in loop `j`. This ordering, when combined with widening, bounds the number

I wonder if we still want to somehow enforce that within a loop/interval the we 
visit nodes in the RPO order.



Comment at: clang/lib/Analysis/IntervalPartition.cpp:36
+bool inInterval(const Node *N, std::vector ) {
+  return std::find(Interval.begin(), Interval.end(), N) != Interval.end();
+}

We have some convenience wrappers in LLVM: 
https://llvm.org/doxygen/namespacellvm.html#a086e9fbdb06276db7753101a08a63adf



Comment at: clang/lib/Analysis/IntervalPartition.cpp:121
+Index.emplace(N, ID);
+  Graph.Intervals.emplace_back(ID, Header, std::move(Data.Nodes));
 }

ymandel wrote:
> xazax.hun wrote:
> > It would probably take for me some time to understand what is going on 
> > here, but I think this part might worth a comment. In particular, I have 
> > the impression that `Graph.Intervals` is the owner of all the intervals. 
> > But we use pointers to refer to these intervals. What would guarantee that 
> > those pointers are not being invalidated by this `emplace_back` operations?
> Excellent question, not least because I *wasn't* careful the first around and 
> indeed ran up against this as a memory bug. :) That's the reason I added IDs, 
> so that I could _avoid_ taking the addresses of elements until after we 
> finish growing the vector. See lines 148-165: after we finish building the 
> intervals, we go through and take addresses.
> 
> I can add comments to this effect, but perhaps the safe option is to use a 
> std::dequeue. What do you think?
Oh, thanks! I don't have a strong preference between a comment or a deque. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153058

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


[clang] 2e90370 - [Clang] Reset FP options before function instantiations

2023-07-05 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2023-07-05T16:34:19+07:00
New Revision: 2e903709de003dc6ae980197f4a0850a158dd9b8

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

LOG: [Clang] Reset FP options before function instantiations

This is recommit of 98390ccb80569e8fbb20e6c996b4b8cff87fbec6, reverted
in 82a3969d710f5fb7a2ee4c9afadb648653923fef, because it caused
https://github.com/llvm/llvm-project/issues/63542. Although the problem
described in the issue is independent of the reverted patch, fail of
PCH/late-parsed-instantiations.cpp indeed obseved on PowerPC and is
likely to be caused by wrong serialization of `LateParsedTemplate`
objects. In this patch the serialization is fixed.

Original commit message is below.

Previously function template instantiations occurred with FP options
that were in effect at the end of translation unit. It was a problem
for late template parsing as these FP options were used as attributes of
AST nodes and may result in crash. To fix it FP options are set to the
state of the point of template definition.

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

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/CodeGen/fp-template.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index eed23e5ba99c89..aa4fc8947cbe7d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -710,6 +710,12 @@ class Sema final {
 return result;
   }
 
+  void resetFPOptions(FPOptions FPO) {
+CurFPFeatures = FPO;
+FpPragmaStack.Stack.clear();
+FpPragmaStack.CurrentValue = FPO.getChangesFrom(FPOptions(LangOpts));
+  }
+
   // RAII object to push / pop sentinel slots for all MS #pragma stacks.
   // Actions should be performed only if we enter / exit a C++ method body.
   class PragmaStackSentinelRAII {
@@ -14028,6 +14034,8 @@ struct LateParsedTemplate {
   CachedTokens Toks;
   /// The template function declaration to be late parsed.
   Decl *D;
+  /// Floating-point options in the point of definition.
+  FPOptions FPO;
 };
 
 template <>

diff  --git a/clang/lib/Parse/ParseTemplate.cpp 
b/clang/lib/Parse/ParseTemplate.cpp
index d2e8a81ad521a9..776c66b436472e 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -1742,6 +1742,10 @@ void 
Parser::ParseLateTemplatedFuncDef(LateParsedTemplate ) {
   Actions.PushDeclContext(Actions.getCurScope(), DC);
   }
 
+  // Parsing should occur with empty FP pragma stack and FP options used in the
+  // point of the template definition.
+  Actions.resetFPOptions(LPT.FPO);
+
   assert(!LPT.Toks.empty() && "Empty body!");
 
   // Append the current token at the end of the new token stream so that it

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 7ef99b4bfcaf54..a1f0f5732b2b77 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -11377,6 +11377,7 @@ void Sema::MarkAsLateParsedTemplate(FunctionDecl *FD, 
Decl *FnD,
   // Take tokens to avoid allocations
   LPT->Toks.swap(Toks);
   LPT->D = FnD;
+  LPT->FPO = getCurFPFeatures();
   LateParsedTemplateMap.insert(std::make_pair(FD, std::move(LPT)));
 
   FD->setLateTemplateParsed(true);

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 78f718533bd55c..b989ff2a9c95c4 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8606,6 +8606,7 @@ void ASTReader::ReadLateParsedTemplates(
 
   auto LT = std::make_unique();
   LT->D = GetLocalDecl(*FMod, LateParsed[Idx++]);
+  LT->FPO = FPOptions::getFromOpaqueInt(LateParsed[Idx++]);
 
   ModuleFile *F = getOwningModuleFile(LT->D);
   assert(F && "No module");

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index e2dec17f7cae77..f4389ecd7629a1 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -4278,6 +4278,7 @@ void ASTWriter::WriteLateParsedTemplates(Sema ) {
 LateParsedTemplate  = *LPTMapEntry.second;
 AddDeclRef(FD, Record);
 AddDeclRef(LPT.D, Record);
+Record.push_back(LPT.FPO.getAsOpaqueInt());
 Record.push_back(LPT.Toks.size());
 
 for (const auto  : LPT.Toks) {

diff  --git a/clang/test/CodeGen/fp-template.cpp 
b/clang/test/CodeGen/fp-template.cpp
index 9e0fc0555e3365..e0ea8e4d12ad34 100644
--- a/clang/test/CodeGen/fp-template.cpp
+++ b/clang/test/CodeGen/fp-template.cpp
@@ -15,4 +15,40 @@ float func_01(float x, float y) {
 // CHECK-SAME:  (float 

[PATCH] D154486: [Clang] Fix a crash when trying to initialize an invalid aggregate.

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

We did not return an error when failing to producing
a valid expression when performing the initialization of
an aggregate initialized with a parenthesized list of expressions.

This is a regression introduced in Clang 17.

Fixes #63278


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154486

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


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,24 @@
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a 
parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct 
member}}
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1);
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@
 }
   }
 
+  auto *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-  CurInit.get());
+  cast(Entity.getDecl()), Init);
 
   // Check for std::move on construction.
-  if (const Expr *E = CurInit.get()) {
-CheckMoveOnConstruction(S, E,
-Entity.getKind() == InitializedEntity::EK_Result);
-  }
+  CheckMoveOnConstruction(S, Init,
+  Entity.getKind() == InitializedEntity::EK_Result);
 
-  return CurInit;
+  return Init;
 }
 
 /// Somewhere within T there is an uninitialized reference subobject.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -630,6 +630,8 @@
 - Allow abstract parameter and return types in functions that are
   either deleted or not defined.
   (`#63012 `_)
+- Fix a crash when trying to parentheses-initialize an invalid aggregate.
+  (`#63278 `_)
 
 Bug Fixes to AST Handling
 ^


Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -272,3 +272,24 @@
 // expected-warning@-1 {{braces around scalar init}}
 // beforecxx20-warning@-2 {{aggregate initialization of type 'A' from a parenthesized list of values is a C++20 extension}}
 }
+
+
+namespace GH63278 {
+struct S {
+  int a = 0;
+  int b {0};
+  auto x = 1; // expected-error {{'auto' not allowed in non-static struct member}}
+};
+
+int test() {
+  // used to crash
+  S a(0, 1);
+  S b(0);
+  S c(0, 0, 1);
+
+  S d {0, 1};
+  S e {0};
+  S f {0, 0, 1};
+}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -9387,10 +9387,13 @@
 }
   }
 
+  auto *Init = CurInit.get();
+  if (!Init)
+return ExprError();
+
   // Check whether the initializer has a shorter lifetime than the initialized
   // entity, and if not, either lifetime-extend or warn as appropriate.
-  if (auto *Init = CurInit.get())
-S.checkInitializerLifetime(Entity, Init);
+  S.checkInitializerLifetime(Entity, Init);
 
   // Diagnose non-fatal problems with the completed initialization.
   if (InitializedEntity::EntityKind EK = Entity.getKind();
@@ -9398,16 +9401,13 @@
EK == InitializedEntity::EK_ParenAggInitMember) &&
   cast(Entity.getDecl())->isBitField())
 S.CheckBitFieldInitialization(Kind.getLocation(),
-  cast(Entity.getDecl()),
-   

[PATCH] D151696: [X86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-07-05 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

Thank so much on all your comments/review to make this happen. Cheers~!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[clang] 7717c00 - [X86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-07-05 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-07-05T17:32:00+08:00
New Revision: 7717c0071d7ce9f4ca7b1417f677bb0380171621

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

LOG: [X86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

This refactor patch means to remove CPU_SPECIFIC* MACROs in X86TargetParser.def
and move those information into ProcInfo of X86TargetParser.cpp. Since these
two files both maintain a table with redundant info such as cpuname and its
features supported. CPU_SPECIFIC* MACROs define some different information. This
patch dealt with them in these ways when moving:
1.mangling
This is now moved to Mangling in ProcInfo and directly initialized at array of
Processors. CPUs don't support cpu_dispatch/specific are assigned '\0' as
mangling.
2.CPU alias
The alias cpu will also be initialized in array of Processors, its attributes
will be same as its alias target cpu. Same feature list, same mangling.
3.TUNE_NAME
Before my change, some cpu names support cpu_dispatch/specific are not
supported in X86.td, which means optimizer/backend doesn't recognize them. So
they use a different TUNE_NAME to generate in IR. In this patch, I added these
missing cpu support at X86.td by utilizing existing Features and XXXTunings, so
that each cpu name can directly use its own name as TUNE_NAME to be supported
by optimizer/backend.
4.Feature list
The feature list of one CPU maintained in X86TargetParser.def is not same as
the one in X86TargetParser.cpp. It only maintains part of features of one CPU
(features defined by X86_FEATURE_COMPAT). While X86TargetParser.cpp maintains
a complete one. This patch abandons the feature list maintained by CPU_SPECIFIC*
MACROs because assigning a CPU with a complete one doesn't affect the
functionality of cpu_dispatch/specific.
Except these four info, since some of CPUs supported by cpu_dispatch/specific
doesn's support clang options like -march, -mtune before, this patch also kept
this behavior still by adding another member OnlyForCPUDispatchSpecific in
ProcInfo.

Reviewed By: pengfei, RKSimon

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

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-cpuspecific-avx-abi.c
clang/test/CodeGen/attr-cpuspecific.c
llvm/include/llvm/TargetParser/X86TargetParser.def
llvm/include/llvm/TargetParser/X86TargetParser.h
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/X86TargetParser.cpp
llvm/test/CodeGen/X86/cpus-intel.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 3aa4b63a0004f6..08d2722a8e52c0 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1171,43 +1171,19 @@ unsigned 
X86TargetInfo::multiVersionSortPriority(StringRef Name) const {
 }
 
 bool X86TargetInfo::validateCPUSpecificCPUDispatch(StringRef Name) const {
-  return llvm::StringSwitch(Name)
-#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, true)
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, true)
-#include "llvm/TargetParser/X86TargetParser.def"
-  .Default(false);
-}
-
-static StringRef CPUSpecificCPUDispatchNameDealias(StringRef Name) {
-  return llvm::StringSwitch(Name)
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, NAME)
-#include "llvm/TargetParser/X86TargetParser.def"
-  .Default(Name);
+  return llvm::X86::validateCPUSpecificCPUDispatch(Name);
 }
 
 char X86TargetInfo::CPUSpecificManglingCharacter(StringRef Name) const {
-  return llvm::StringSwitch(CPUSpecificCPUDispatchNameDealias(Name))
-#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, MANGLING)
-#include "llvm/TargetParser/X86TargetParser.def"
-  .Default(0);
+  return llvm::X86::getCPUDispatchMangling(Name);
 }
 
 void X86TargetInfo::getCPUSpecificCPUDispatchFeatures(
 StringRef Name, llvm::SmallVectorImpl ) const {
-  StringRef WholeList =
-  llvm::StringSwitch(CPUSpecificCPUDispatchNameDealias(Name))
-#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, FEATURES)
-#include "llvm/TargetParser/X86TargetParser.def"
-  .Default("");
-  WholeList.split(Features, ',', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
-}
-
-StringRef X86TargetInfo::getCPUSpecificTuneName(StringRef Name) const {
-  return llvm::StringSwitch(Name)
-#define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, 
TUNE_NAME)
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, 
TUNE_NAME)
-#include "llvm/TargetParser/X86TargetParser.def"
-  .Default("");
+  SmallVector TargetCPUFeatures;
+  llvm::X86::getFeaturesForCPU(Name, TargetCPUFeatures, 

[PATCH] D151696: [X86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-07-05 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7717c0071d7c: [X86] Remove CPU_SPECIFIC* MACROs and add 
getCPUDispatchMangling (authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -6,16 +6,24 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i586 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i686 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentiumpro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -26,26 +34,39 @@
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=penryn 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o 

[PATCH] D154450: [clangd][c++20] Drop first template argument in code completion in some contexts.

2023-07-05 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:484
+  S.Signature = RemoveFirstTemplateArg(S.Signature);
+  S.SnippetSuffix = RemoveFirstTemplateArg(S.SnippetSuffix);
+}

massberg wrote:
> sammccall wrote:
> > maybe leave a comment:
> > 
> > // dropping the first placeholder from the suffix will leave a `$2` with no 
> > `$1`.
> > // However, editors appear to deal with this OK.
> > 
> > (assuming you've tested this in vscode)
> Yes I've tested it with vscode and it looks fine. Why is the numbering of the 
> parameters required?
The numbering defines the logical sequence, in practice which placeholder will 
be selected first, and the order that pressing `` will visit the others in.

I guess this could make sense when they're not parameters but some other 
snippet placeholders, but honestly this seems more confusing than useful, I'd 
prefer they were un-numbered and always LTR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154450

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


[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-05 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

Ping for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[PATCH] D154477: [include-cleaner] Ignore the layering-violation errors for the standalone tool

2023-07-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:99
+  bool BeginInvocation(CompilerInstance ) override {
+// Disable the clang-module-based layering-violation checks.
+// These checks emit errors for a compilable source code. We want the tool

maybe mention the general stance against diagnostics here?

```
We only want to perform include-cleaner analysis. So we disable diagnostics 
that won't affect our analysis to make the tool more robust against 
in-development code.

```

and then follow up with specific around disabling decluse


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154477

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


[PATCH] D154423: [clang][analyzer] Add all success/failure messages to StdLibraryFunctionsChecker.

2023-07-05 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

These code changes seem to be promising. Please upload results on the open 
source projects (like the ones that you uploaded previously), and I hope that 
after verifying those I we can finally merge this set of commits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154423

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


[PATCH] D154484: [clang-format] Add an option to remove redundant parentheses

2023-07-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, MyDeveloperDay.
owenpan requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154484

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25805,6 +25805,31 @@
getGoogleStyle());
 }
 
+TEST_F(FormatTest, RemoveParentheses) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.RemoveParentheses, FormatStyle::RPS_None);
+
+  verifyFormat("class __declspec((dllimport)) X {};", Style);
+  verifyFormat("return (0);", Style);
+
+  Style.RemoveParentheses = FormatStyle::RPS_DoubleParentheses;
+  verifyFormat("int x __attribute__ /**/ ((aligned(16))) = 0;", Style);
+  verifyFormat("class __declspec(dllimport) X {};",
+   "class __declspec((dllimport)) X {};", Style);
+  verifyFormat("return (0);", "return (((0)));", Style);
+
+  Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
+  verifyFormat("return 0;", "return (0);", Style);
+  verifyFormat("co_return 0;", "co_return ((0));", Style);
+  verifyFormat("return 0;", "return (((0)));", Style);
+
+  Style.ColumnLimit = 25;
+  verifyFormat("return (a + b) - (c + d);",
+   "return (((a + b)) -\n"
+   "((c + d)));",
+   Style);
+}
+
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -917,6 +917,13 @@
   LineEnding, FormatStyle::LE_CRLF);
   Style.LineEnding = DefaultLineEnding;
   CHECK_PARSE("UseCRLF: true", LineEnding, FormatStyle::LE_DeriveCRLF);
+
+  CHECK_PARSE("RemoveParentheses: DoubleParentheses", RemoveParentheses,
+  FormatStyle::RPS_DoubleParentheses);
+  CHECK_PARSE("RemoveParentheses: ReturnStatement", RemoveParentheses,
+  FormatStyle::RPS_ReturnStatement);
+  CHECK_PARSE("RemoveParentheses: None", RemoveParentheses,
+  FormatStyle::RPS_None);
 }
 
 TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2434,6 +2434,7 @@
 /// double ampersands. This applies for all nested scopes as well.
 void UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
   assert(FormatTok->is(tok::l_paren) && "'(' expected.");
+  auto *LeftParen = FormatTok;
   nextToken();
   do {
 switch (FormatTok->Tok.getKind()) {
@@ -2443,6 +2444,23 @@
 parseChildBlock();
   break;
 case tok::r_paren:
+  if (Style.RemoveParentheses > FormatStyle::RPS_None) {
+const auto *Prev = LeftParen->Previous;
+const auto *Next = Tokens->peekNextToken();
+const bool DoubleParens =
+Prev && Prev->is(tok::l_paren) && Next && Next->is(tok::r_paren);
+const auto *PrevPrev = Prev ? Prev->getPreviousNonComment() : nullptr;
+const bool AttributeParens =
+Style.isCpp() && PrevPrev && PrevPrev->is(tok::kw___attribute);
+const bool ReturnParens =
+Style.RemoveParentheses == FormatStyle::RPS_ReturnStatement &&
+Prev && Prev->isOneOf(tok::kw_return, tok::kw_co_return) && Next &&
+Next->is(tok::semi);
+if ((DoubleParens && !AttributeParens) || ReturnParens) {
+  LeftParen->Optional = true;
+  FormatTok->Optional = true;
+}
+  }
   nextToken();
   return;
 case tok::r_brace:
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -502,6 +502,15 @@
   }
 };
 
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO , FormatStyle::RemoveParenthesesStyle ) {
+IO.enumCase(Value, "None", FormatStyle::RPS_None);
+IO.enumCase(Value, "DoubleParentheses", FormatStyle::RPS_DoubleParentheses);
+IO.enumCase(Value, "ReturnStatement", FormatStyle::RPS_ReturnStatement);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits {
   static void enumeration(IO ,
@@ -989,6 +998,7 @@
 IO.mapOptional("ReferenceAlignment", Style.ReferenceAlignment);
 IO.mapOptional("ReflowComments", Style.ReflowComments);
 

[PATCH] D153340: [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

2023-07-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h:138
+  /// Returns the path (without surrounding quotes/brackets) for the header.
+  /// For physical headers, this is the resolved path.
+  llvm::StringRef resolvedPath() const;

i think name and the comment are somewhat confusing, what about:
```
/// Absolute path for the header, when it's a physical file. Otherwise just the 
spelling without surrounding quotes/brackets.
```



Comment at: clang-tools-extra/include-cleaner/lib/Analysis.cpp:82
+ Ref.RT == RefType::Explicit &&
+ (!HeaderFilter ||
+  !HeaderFilter(Providers.front().resolvedPath(

nit: rather than checking this at every use, might be easier to have something 
like:
```
if (!HeaderFilter)
  HeaderFilter = +[](llvm::StringRef) { return false; };
```



Comment at: clang-tools-extra/include-cleaner/test/tool.cpp:17
 
+//RUN: clang-include-cleaner -print=changes %s 
--ignore-headers="foobar\.h,foo\.h" -- -I%S/Inputs/ | FileCheck 
--match-full-lines --allow-empty --check-prefix=IGNORE %s
+// IGNORE-NOT: - "foobar.h"

hokein wrote:
> kadircet wrote:
> > can you ignore one but keep other?
> > 
> > it'd be useful to also test the regex behaviour
> this tests aims to test filtering logic for both missing-includes and 
> unused-includes cases.
> 
> added a new test.
we're still lacking a test for regex behaviour, maybe change next one to 
`foob.*\.h` ?



Comment at: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:212
+private:
+  llvm::function_ref HeaderFilter;
+};

nit: Drop `Path`



Comment at: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:231
+  }
+  return [FilterRegs](llvm::StringRef Path) {
+llvm::errs() << "Path: " << Path << "\n";

`FilterRegs=std::move(FilterRegs)` and drop the `shared_ptr`?



Comment at: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp:232
+  return [FilterRegs](llvm::StringRef Path) {
+llvm::errs() << "Path: " << Path << "\n";
+for (const auto  : *FilterRegs) {

looks like debugging artifact


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153340

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


[PATCH] D151696: [X86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-07-05 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.

LGTM - cheers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-07-05 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

In D153366#4471460 , @sammccall wrote:

> In D153366#4471320 , @TWeaver wrote:
>
>> My apologies but I've had to revert this change for now until the author can 
>> address the buildbot failures.
>
> Thanks for the revert, and sorry for the disruption - I expected to be around 
> to keep an eye on this, but was away.

No worries Sam, thanks for understanding! Good luck on the fix, let me know if 
you need any help 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

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


[PATCH] D154481: [analyzer] Remove deprecated analyzer-config options

2023-07-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

The option was deprecated in D138659 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154481

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


[PATCH] D154481: [analyzer] Remove deprecated analyzer-config options

2023-07-05 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

I'll mention this change in the Release Notes separately as we are getting 
closer and closer to branching off for the clang-17 release on 25th of July.
Read more here 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154481

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


<    1   2   3   >