[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-07-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 539409.
v.g.vassilev marked 7 inline comments as done.
v.g.vassilev added a comment.

Address most of the comments. I will need some help with the 
`Modules/pr60085.cppm` failure. I suspect we pass to CodeGen some instantiation 
by iterator index and that does not work as the instantiations are lazily 
triggered upon use now.


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

https://reviews.llvm.org/D41416

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/cxx-templates.cpp
  clang/test/Modules/odr_hash.cpp

Index: clang/test/Modules/odr_hash.cpp
===
--- clang/test/Modules/odr_hash.cpp
+++ clang/test/Modules/odr_hash.cpp
@@ -2902,7 +2902,7 @@
 #else
 S5 s5;
 // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 'SecondModule' is not present in definition of 'PointersAndReferences::S5' in module 'FirstModule'}}
-// expected-note@first.h:* {{declaration of 'x' does not match}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
 #endif
 
 #if defined(FIRST)
@@ -3839,7 +3839,7 @@
 #else
 Invalid::L2<1>::L3<1> invalid;
 // expected-error@second.h:* {{'Types::InjectedClassName::Invalid::L2::L3::x' from module 'SecondModule' is not present in definition of 'L3<>' in module 'FirstModule'}}
-// expected-note@first.h:* {{declaration of 'x' does not match}}
+// expected-note@second.h:* {{declaration of 'x' does not match}}
 Valid::L2<1>::L3<1> valid;
 #endif
 }  // namespace InjectedClassName
Index: clang/test/Modules/cxx-templates.cpp
===
--- clang/test/Modules/cxx-templates.cpp
+++ clang/test/Modules/cxx-templates.cpp
@@ -251,7 +251,7 @@
 
 // CHECK-DUMP:  ClassTemplateDecl {{.*}} <{{.*[/\\]}}cxx-templates-common.h:1:1, {{.*}}>  col:{{.*}} in cxx_templates_common SomeTemplate
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
-// CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
+// CHECK-DUMP-NEXT: TemplateArgument type 'char[1]'
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition
 // CHECK-DUMP-NEXT: DefinitionData
 // CHECK-DUMP-NEXT:   DefaultConstructor
@@ -260,9 +260,9 @@
 // CHECK-DUMP-NEXT:   CopyAssignment
 // CHECK-DUMP-NEXT:   MoveAssignment
 // CHECK-DUMP-NEXT:   Destructor
-// CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
-// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
 // CHECK-DUMP-NEXT: TemplateArgument type 'char[1]'
+// CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} prev {{.*}} SomeTemplate
+// CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
 // CHECK-DUMP:ClassTemplateSpecializationDecl {{.*}} SomeTemplate definition
 // CHECK-DUMP-NEXT: DefinitionData
 // CHECK-DUMP-NEXT:   DefaultConstructor
@@ -271,4 +271,4 @@
 // CHECK-DUMP-NEXT:   CopyAssignment
 // CHECK-DUMP-NEXT:   MoveAssignment
 // CHECK-DUMP-NEXT:   Destructor
-// CHECK-DUMP-NEXT: TemplateArgument type 'char[1]'
+// CHECK-DUMP-NEXT: TemplateArgument type 'char[2]'
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -177,11 +177,12 @@
   Record.AddSourceLocation(typeParams->getRAngleLoc());
 }
 
-/// Add to the record the first declaration from each module file that
-/// provides a declaration of D. The intent is to provide a sufficient
-/// set such that reloading this set will load all current redeclarations.
-void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
-  llvm::MapVector Firsts;
+/// Collect the first declaration from each module file that provides a
+/// declaration of D.
+void CollectFirstDeclFromEachModule(
+const Decl *D, bool IncludeLocal,
+llvm::MapVector &Firsts) {
+
   // FIXME: We can skip entries that we know are implied by others.
   for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
 if (R->isFromASTFile())
@@ -189,10 +190,49 @@
 else if (IncludeLocal)
   Firsts[nullptr] = R;
   }
+}
+
+/// Add to the record the first declaration from each module file that
+/// provides a declaration of D. The intent is to provide a sufficient
+/// set such that reloading this set will load all current redeclarations.
+void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
+  llvm::MapVector Firsts;
+  CollectFirstDeclFromEachModule(D, Incl

[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-07-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/AST/DeclTemplate.cpp:337
+void RedeclarableTemplateDecl::loadLazySpecializationsImpl(
+ bool OnlyPartial/*=false*/) const 
{
   // Grab the most recent declaration to ensure we've loaded any lazy

shafik wrote:
> `/*=false*/` is this left over code that was meant to be removed?
That was not my intent. I added `/*=false*/` to keep track of the the actual 
default argument.

However, you are right, we are not using it without passing the correct 
argument. I will drop the default arg.



Comment at: clang/lib/AST/DeclTemplate.cpp:366
+  Args,
+  TemplateParameterList 
*TPL) const {
+  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();

Hahnfeld wrote:
> ChuanqiXu wrote:
> > TPL here looks not used.
> This is required because of the argument forwarding from 
> `findSpecializationImpl` below...
Are you suggesting to make this replacement: `TPL` -> `/*TPL*/`?


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

https://reviews.llvm.org/D41416

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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-07-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/test/Modules/odr_hash.cpp:2905
 // expected-error@second.h:* {{'PointersAndReferences::S5::x' from module 
'SecondModule' is not present in definition of 'PointersAndReferences::S5' in 
module 'FirstModule'}}
-// expected-note@first.h:* {{declaration of 'x' does not match}}
 #endif

I realize that change is probably incorrect since we want to show both places 
where things differ.


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

https://reviews.llvm.org/D41416

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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-07-12 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

> I will need some help with the Modules/pr60085.cppm failure.

I am looking at https://reviews.llvm.org/D154914 so maybe I can't look this 
deeply now. If there are concrete and small issues, maybe I can try to take a 
look. Hope this helps.




Comment at: clang/lib/AST/DeclTemplate.cpp:366
+  Args,
+  TemplateParameterList 
*TPL) const {
+  CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr();

v.g.vassilev wrote:
> Hahnfeld wrote:
> > ChuanqiXu wrote:
> > > TPL here looks not used.
> > This is required because of the argument forwarding from 
> > `findSpecializationImpl` below...
> Are you suggesting to make this replacement: `TPL` -> `/*TPL*/`?
I am not sure. I'm just wondering if there will be a static checker emits 
warnings for unused arguments.


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

https://reviews.llvm.org/D41416

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


[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539413.
eopXD added a comment.

Change:

- Rebase to latest main
- let `hasPostISelHook = 1` for PseudoVFADD to trigger code under 
`AdjustInstrPostInstrSelection`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfadd-out-of-range.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll
  llvm/test/CodeGen/RISCV/rvv/combine-vmv.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fmf.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[PATCH] D154983: [clang-extdef-mapping] register necessary targest for ms-style asm block

2023-07-12 Thread Tobias Hieta via Phabricator via cfe-commits
thieta added a comment.

Yes, I can do that, but I rather wait for @balazske to also approve this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154983

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-07-12 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat marked 2 inline comments as done.
4vtomat added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:2378
+
+multiclass RVVOutBuiltinSetP {

craig.topper wrote:
> What does `P` in this name mean? Is this because they use OP_P as their 
> opcode? If so I don't think that should be part of how we name intrinsics.
Sure, I will rename by appending Zvk suffix for clarifying it's meaning~



Comment at: clang/include/clang/Basic/riscv_vector.td:2381
+  if HasVV then {
+defvar suffix = !if(!or(HasVS, !eq(NAME, "vsm4r")), "vv", "v");
+// We don't need suffix in Zvkb extension since it's consider as normal

michaelmaitland wrote:
> Why do we check `HasVS` when assigning suffix `vv`? I would have expected we 
> use `HasVV`. In addition, why do we need to check `!eq(NAME, "vsm4r")` 
> instead of setting the `HasVV` for that instruction?
We check `HasVS` when assigning suffix `vv` because when the instruction has 
both `VV` and `VS` version, it uses double `v` as suffix, but if it just has 
`VS` version, it will use single `v` as suffix, that's why we check if it also 
has `VS` version in `HasVV` statement.
As per spec, the instruction name is vsm4r.v(single v), so it's an exception 
for `HasVV` case.



Comment at: clang/include/clang/Basic/riscv_vector.td:2400
+// mnemonics into its intrinsic function name.
+defvar suffix = !if(!eq(NAME, "vgmul"), "vv", "vs");
+defvar name = NAME # !if(!or(IsZvkb, !or(!eq(NAME, "vaesz"),

michaelmaitland wrote:
> Why not set `HasVS=1` and `HasVV=0` for `vaesz` instead of checking 
> `!if(!eq(NAME, "vgmul"),...`?
> 
> Also, do you mean to be discussing `vaesz` in the comment but use `vgmul` 
> below?
The reason we set these condition to check `vaesz` and `vgmul` is because they 
are exceptions.
They don't need suffix in their overloaded name since they only have one 
version.
`HasVS=1` and `HasVV=0` is not enough to determine this situation.



Comment at: clang/include/clang/Basic/riscv_vector.td:2423
+  defm vandn   : RVVIntBinBuiltinSet;
+  defm vbrev   : RVVOutBuiltinSetP<1, 0, 1, "csil", 1>;
+  defm vbrev8  : RVVOutBuiltinSetP<1, 0, 1, "csil", 1>;

craig.topper wrote:
> I think I'd prefer to see the Zvbb instructions use their own class and not 
> try to make `RVVOutBuiltinSetP` handle them and instructions that set HasVS.
It's a good idea, it will be much clearer and reduce the code size, thanks!



Comment at: clang/include/clang/Basic/riscv_vector.td:2449
+  let UnMaskedPolicyScheme = HasPassthruOperand in
+  defm vaeskf1 : RVVOutOp1BuiltinSet<"vaeskf1", "i", [["vi", "Uv", "UvUvUe"]]>;
+  defm vaeskf2 : RVVOutOp1BuiltinSetP<0>;

craig.topper wrote:
> I think the `Ue` needs a `K` since its required to be a constant? Also need 
> to update SemaChecking to verify the valid range.
> 
> I'm not sure whether we should use `Ue` or 'z' for constants.
I'm not sure what's the difference between `e` and `z`, but seems both of them 
works fine.
However K is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[clang] 6d9fcc2 - [clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output

2023-07-12 Thread Dmitry Polukhin via cfe-commits

Author: Dmitry Polukhin
Date: 2023-07-12T00:57:41-07:00
New Revision: 6d9fcc2ad874e4ee9b94eef4b85ffece18e501b1

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

LOG: [clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output

The crash happens in clang::driver::tools::SplitDebugName when Output is
InputInfo::Nothing. It doesn't happen with standalone clang driver because
output is created in Driver::BuildJobsForActionNoCache.

Example backtrace:
```
* thread #1, name = 'clangd', stop reason = hit program assert
  * frame #0: 0x75c4eacf libc.so.6`raise + 271
frame #1: 0x75c21ea5 libc.so.6`abort + 295
frame #2: 0x75c21d79 libc.so.6`__assert_fail_base.cold.0 + 15
frame #3: 0x75c47426 libc.so.6`__assert_fail + 70
frame #4: 0x5dc0923c 
clangd`clang::driver::InputInfo::getFilename(this=0x7fff9398) const at 
InputInfo.h:84:5
frame #5: 0x5dcd0d8d 
clangd`clang::driver::tools::SplitDebugName(JA=0x5f6c6a50, 
Args=0x5f6d0b80, Input=0x7fff9678, Output=0x7fff9398) 
at CommonArgs.cpp:1275:40
frame #6: 0x5dc955a5 
clangd`clang::driver::tools::Clang::ConstructJob(this=0x5f6c69d0, 
C=0x5f6c64a0, JA=0x5f6c6a50, Output=0x7fff9398, 
Inputs=0x7fff9668, Args=0x5f6d0b80, 
LinkingOutput=0x) const at Clang.cpp:5690:33
frame #7: 0x5dbf6b54 
clangd`clang::driver::Driver::BuildJobsForActionNoCache(this=0x7fffb5e0,
 C=0x5f6c64a0, A=0x5f6c6a50, TC=0x5f6c4be0, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=1, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5618:10
frame #8: 0x5dbf4ef0 
clangd`clang::driver::Driver::BuildJobsForAction(this=0x7fffb5e0, 
C=0x5f6c64a0, A=0x5f6c6a50, TC=0x5f6c4be0, 
BoundArch=(Data = 0x, Length = 0), AtTopLevel=true, 
MultipleArchs=false, LinkingOutput=0x, CachedResults=size=1, 
TargetDeviceOffloadKind=OFK_None) const at Driver.cpp:5306:26
frame #9: 0x5dbeb590 
clangd`clang::driver::Driver::BuildJobs(this=0x7fffb5e0, 
C=0x5f6c64a0) const at Driver.cpp:4844:5
frame #10: 0x5dbe6b0f 
clangd`clang::driver::Driver::BuildCompilation(this=0x7fffb5e0, 
ArgList=ArrayRef @ 0x7fffb268) at Driver.cpp:1496:3
frame #11: 0x5b0cc0d9 
clangd`clang::createInvocation(ArgList=ArrayRef @ 
0x7fffbb38, Opts=CreateInvocationOptions @ 0x7fffbb90) at 
CreateInvocationFromCommandLine.cpp:53:52
frame #12: 0x5b378e7b 
clangd`clang::clangd::buildCompilerInvocation(Inputs=0x7fffca58, 
D=0x7fffc158, CC1Args=size=0) at Compiler.cpp:116:44
frame #13: 0x5895a6c8 clangd`clang::clangd::(anonymous 
namespace)::Checker::buildInvocation(this=0x7fffc760, 
TFS=0x7fffe570, Contents= Has Value=false ) at Check.cpp:212:9
frame #14: 0x58959cec clangd`clang::clangd::check(File=(Data = 
"build/test.cpp", Length = 64), TFS=0x7fffe570, 
Opts=0x7fffe600) at Check.cpp:486:34
frame #15: 0x5892164a clangd`main(argc=4, argv=0x7fffecd8) 
at ClangdMain.cpp:993:12
frame #16: 0x75c3ad85 libc.so.6`__libc_start_main + 229
frame #17: 0x585bbe9e clangd`_start + 46
```

Test Plan: ninja ClangDriverTests && 
tools/clang/unittests/Driver/ClangDriverTests

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/unittests/Driver/ToolChainTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 3dcbd5b8deb8d7..649d7ddcf8997a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1274,7 +1274,7 @@ const char *tools::SplitDebugName(const JobAction &JA, 
const ArgList &Args,
 F += ".dwo";
   };
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
-if (StringRef(A->getValue()) == "single")
+if (StringRef(A->getValue()) == "single" && Output.isFilename())
   return Args.MakeArgString(Output.getFilename());
 
   SmallString<128> T;

diff  --git a/clang/unittests/Driver/ToolChainTest.cpp 
b/clang/unittests/Driver/ToolChainTest.cpp
index 4ddeadac2103f4..8d3853a7b4a6de 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -367,6 +367,16 @@ TEST(ToolChainTest, PostCallback) {
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(CompilerInvocation, SplitSwarfSingleCr

[PATCH] D154602: [clang][clangd] Don't crash/assert on -gsplit-dwarf=single without output

2023-07-12 Thread Dmitry Polukhin 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 rG6d9fcc2ad874: [clang][clangd] Don't crash/assert on 
-gsplit-dwarf=single without output (authored by DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154602

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -367,6 +367,16 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(CompilerInvocation, SplitSwarfSingleCrash) {
+  static constexpr const char *Args[] = {
+  "clang", "--target=arm-linux-gnueabi",
+  "-gdwarf-4", "-gsplit-dwarf=single",
+  "-c","foo.cpp"};
+  CreateInvocationOptions CIOpts;
+  std::unique_ptr CI = createInvocation(Args, CIOpts);
+  EXPECT_TRUE(CI); // no-crash
+}
+
 TEST(GetDriverMode, PrefersLastDriverMode) {
   static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
  "--driver-mode=bar", "foo.cpp"};
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1274,7 +1274,7 @@
 F += ".dwo";
   };
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
-if (StringRef(A->getValue()) == "single")
+if (StringRef(A->getValue()) == "single" && Output.isFilename())
   return Args.MakeArgString(Output.getFilename());
 
   SmallString<128> T;


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -367,6 +367,16 @@
   EXPECT_TRUE(CallbackHasCalled);
 }
 
+TEST(CompilerInvocation, SplitSwarfSingleCrash) {
+  static constexpr const char *Args[] = {
+  "clang", "--target=arm-linux-gnueabi",
+  "-gdwarf-4", "-gsplit-dwarf=single",
+  "-c","foo.cpp"};
+  CreateInvocationOptions CIOpts;
+  std::unique_ptr CI = createInvocation(Args, CIOpts);
+  EXPECT_TRUE(CI); // no-crash
+}
+
 TEST(GetDriverMode, PrefersLastDriverMode) {
   static constexpr const char *Args[] = {"clang-cl", "--driver-mode=foo",
  "--driver-mode=bar", "foo.cpp"};
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1274,7 +1274,7 @@
 F += ".dwo";
   };
   if (Arg *A = Args.getLastArg(options::OPT_gsplit_dwarf_EQ))
-if (StringRef(A->getValue()) == "single")
+if (StringRef(A->getValue()) == "single" && Output.isFilename())
   return Args.MakeArgString(Output.getFilename());
 
   SmallString<128> T;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16286: [clang-tidy] Readability check for redundant parenthesis in return expression.

2023-07-12 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.
Herald added a subscriber: carlosgalvezp.

clang-format can remove some types of redundant parens now. See D154484 
.


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

https://reviews.llvm.org/D16286

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


[PATCH] D4784: [clang-tidy] Add check for possibly incomplete switch statements

2023-07-12 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL requested changes to this revision.
PiotrZSL added a comment.
This revision now requires changes to proceed.

Missing documentation for check.
Once you ready with update, please switch review into ready for review.




Comment at: clang-tools-extra/clang-tidy/misc/IncompleteSwitchCheck.cpp:19
+  Finder->addMatcher(
+  switchStmt(has(implicitCastExpr().bind("cast")),
+ unless(hasAncestor(switchStmt(has(defaultStmt())

no need to check casts, just check if its not enum... or check if its integer 
(validate type of expression).
and use IgnoreUnlessSpelledInSource to exclude implicit code (like other checks)



Comment at: clang-tools-extra/clang-tidy/misc/IncompleteSwitchCheck.cpp:20
+  switchStmt(has(implicitCastExpr().bind("cast")),
+ unless(hasAncestor(switchStmt(has(defaultStmt())
+  .bind("switch"),

so switch in switch is allowed ? why 



Comment at: clang-tools-extra/clang-tidy/misc/IncompleteSwitchCheck.cpp:31
+
+  const auto *s = Result.Nodes.getNodeAs("switch");
+  diag(s->getSwitchLoc(), "switching on non-enum value without "

put some meaningful names of variables according to LLVM standard



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:222
 
+- New :doc:`misc-incomplete-switch
+  ` check.

name is to generic. maybe misc-switch-missing-default-case or something 
similar, maybe it should be readability module or bugprone ? Still misc could 
be not bad trade-off.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:225
+
+  Detects incomplete switch statements without a default case.
+

put info about non enum, for enums we got compiler warnings already



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc/incomplete-switch.cpp:1
+// RUN: clang-tidy --checks='-*,misc-incomplete-switch' %s -- | FileCheck 
-implicit-check-not="{{warning|error}}:" %s
+

Check currently use different run command. Base on new one.


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

https://reviews.llvm.org/D4784

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


[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

2023-07-12 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:16413
+APSInt C = Char.getInt();
+Result.push_back(static_cast(C.getExtValue()));
+if (!HandleLValueArrayAdjustment(Info, PtrExpression, String, CharTy, 1))

aaron.ballman wrote:
> barannikov88 wrote:
> > This relies on host's CHAR_BIT >= target's CHAR_BIT, which isn't true for 
> > my target. Could you add an assertion?
> > 
> Wouldn't adding the assertion cause you problems then? (FWIW, we only support 
> `CHAR_BIT == 8` currently.)
It will, the assertion will help find this place.
There are several places where it is asserted, and this was very helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

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


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-07-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 3 inline comments as done.
balazske added inline comments.



Comment at: clang/test/Analysis/stream-note.c:61-62
   FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F1)

steakhal wrote:
> Why are these notes doubled?
There are 2 cases of resource leak reported (for `F1` and `F2`) and a note tag 
is there for both of these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D154628: [1/8][RISCV] Add rounding mode control variant for vfsub, vfrsub

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539426.
eopXD marked 2 inline comments as done.
eopXD added a comment.

Change:

- Rebase upon latest main and latest parent revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154628

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfrsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfrsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfrsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfsub.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfrsub.ll
  llvm/test/CodeGen/RISCV/rvv/vfsub.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll

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


[PATCH] D151730: [RISCV] Support target attribute for function

2023-07-12 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 539428.
BeMg added a comment.

1. simplify riscv-func-attr-target.ll
2. handle corner case in parseTargetAttr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151730

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/RISCV/riscv-func-attr-target.c
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll

Index: llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/riscv-func-attr-target.ll
@@ -0,0 +1,46 @@
+; RUN: llc -mtriple=riscv64 -mattr=+a,+d,+f,+m -verify-machineinstrs < %s | FileCheck %s
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test1() "target-features"="+a,+d,+f,+m,+c,+v,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b" {
+; CHECK-LABEL: test1
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test2() "target-features"="+a,+d,+f,+m,+c,+zifencei" {
+; CHECK-LABEL: test2
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test3() "target-features"="+a,+d,+f,+m,+v,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b" {
+; CHECK-LABEL: test3
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +experimental-zihintntl, +zifencei
+define void @test4() "target-features"="+a,+d,+f,+m,+experimental-zihintntl,+zifencei" {
+; CHECK-LABEL: test4
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +zifencei
+define void @test5() "target-features"="+a,+d,+f,+m,+zifencei" {
+; CHECK-LABEL: test5
+; CHECL: .option pop
+entry:
+  ret void
+}
Index: llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
===
--- llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
+++ llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
@@ -36,6 +36,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 
@@ -46,6 +47,10 @@
 STATISTIC(RISCVNumInstrsCompressed,
   "Number of RISC-V Compressed instructions emitted");
 
+namespace llvm {
+extern const SubtargetFeatureKV RISCVFeatureKV[RISCV::NumSubtargetFeatures];
+} // namespace llvm
+
 namespace {
 class RISCVAsmPrinter : public AsmPrinter {
   const RISCVSubtarget *STI;
@@ -83,6 +88,8 @@
   void emitEndOfAsmFile(Module &M) override;
 
   void emitFunctionEntryLabel() override;
+  void emitDirectiveOptionArch();
+  bool isSameAttribute();
 
 private:
   void emitAttributes();
@@ -238,11 +245,43 @@
   return false;
 }
 
+void RISCVAsmPrinter::emitDirectiveOptionArch() {
+  RISCVTargetStreamer &RTS =
+  static_cast(*OutStreamer->getTargetStreamer());
+  SmallVector NeedEmitStdOptionArgs;
+  const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
+  for (const auto &Feature : RISCVFeatureKV) {
+if (!llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature.Key))
+  continue;
+if (STI->hasFeature(Feature.Value) && !MCSTI.hasFeature(Feature.Value))
+  NeedEmitStdOptionArgs.emplace_back(RISCVOptionArchArgType::Plus,
+ Feature.Key);
+if (!STI->hasFeature(Feature.Value) && MCSTI.hasFeature(Feature.Value))
+  NeedEmitStdOptionArgs.emplace_back(RISCVOptionArchArgType::Minus,
+ Feature.Key);
+  }
+  RTS.emitDirectiveOptionArch(NeedEmitStdOptionArgs);
+}
+
+bool RISCVAsmPrinter::isSameAttribute() {
+  const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
+  return MCSTI.getFeatureBits() == STI->getFeatureBits();
+}
+
 bool RISCVAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   STI = &MF.getSubtarget();
+  RISCVTargetStreamer &RTS =
+  static_cast(*OutStreamer->getTargetStreamer());
+  if (!isSameAttribute()) {
+RTS.emitDirectiveOptionPush();
+emitDirectiveOptionArch();
+  }
 
   SetupMachineFunction(MF);
   emitFunctionBody();
+
+  if (!isSameAttribute())
+RTS.emitDirectiveOptionPop();
   return false;
 }
 
Index: clang/test/CodeGen/RISCV/riscv-func-attr-target.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-func-attr-target.c
@@ -0,0 +1,152 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zifencei

[clang-tools-extra] a20d57e - [clangd] Fix builds with LLVM_LINK_LLVM_DYLIB=ON

2023-07-12 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-07-12T11:59:48+03:00
New Revision: a20d57e83441a69fa2bab86593b18cc0402095d2

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

LOG: [clangd] Fix builds with LLVM_LINK_LLVM_DYLIB=ON

This was broken by 56ac9d46a7c1468d587ccec02a781e52d0bb298a.

Added: 


Modified: 
clang-tools-extra/clangd/tool/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/tool/CMakeLists.txt 
b/clang-tools-extra/clangd/tool/CMakeLists.txt
index 223bd7c606f7d1..ddf9c2488819e2 100644
--- a/clang-tools-extra/clangd/tool/CMakeLists.txt
+++ b/clang-tools-extra/clangd/tool/CMakeLists.txt
@@ -32,14 +32,19 @@ clang_target_link_libraries(clangdMain
   clangToolingCore
   clangToolingRefactoring
   clangToolingSyntax
+  )
+
+target_link_libraries(clangdMain
+  PRIVATE
   clangTidy
+
   clangDaemon
   clangdRemoteIndex
   clangdSupport
   ${CLANGD_XPC_LIBS}
   )
 
-clang_target_link_libraries(clangd
+target_link_libraries(clangd
   PRIVATE
   clangdMain
   )



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


[PATCH] D145302: [clangd] Add library for clangd main function

2023-07-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D145302#4491973 , @glandium wrote:

> This broke building with `-DLLVM_LINK_LLVM_DYLIB=ON`:

I also ran into this; I pushed a fix in 
a20d57e83441a69fa2bab86593b18cc0402095d2 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145302

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


[PATCH] D154629: [2/8][RISCV] Add rounding mode control variant for vfwadd, vfwsub

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539430.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154629

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwsub-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/regalloc-last-chance-recoloring-failure.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfwadd.ll
  llvm/test/CodeGen/RISCV/rvv/vfwadd.w.ll
  llvm/test/CodeGen/RISCV/rvv/vfwsub.ll
  llvm/test/CodeGen/RISCV/rvv/vfwsub.w.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[PATCH] D154983: [clang-extdef-mapping] register necessary targest for ms-style asm block

2023-07-12 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

Thanks! @thieta


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154983

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


[PATCH] D154631: [3/8][RISCV] Add rounding mode control variant for vfmul, vfdiv, vfrdiv, vfwmul

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539434.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154631

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfrdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfrdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfrdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfdiv-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfmul-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfrdiv-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwmul-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/regalloc-last-chance-recoloring-failure.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/pass-fast-math-flags-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfdiv.ll
  llvm/test/CodeGen/RISCV/rvv/vfmul.ll
  llvm/test/CodeGen/RISCV/rvv/vfrdiv.ll
  llvm/test/CodeGen/RISCV/rvv/vfwmul.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll

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


[PATCH] D154357: [Driver] Recognize powerpc-unknown-eabi as a bare-metal toolchain

2023-07-12 Thread Christian Walther via Phabricator via cfe-commits
cwalther added a comment.

I am unable to provoke any problem with my tests by putting various things in 
`/usr/lib/gcc/`, and I also can’t find any code that would go looking there on 
the code path that is exercised by these tests. Can you give me a hint where 
that code is, so I can try harder to provoke it? Is it outside of 
`Generic_GCC::GCCInstallationDetector`? `GCCInstallationDetector` is not used 
on the code path taken for `--target=powerpc[64][le]-unknown-eabi` (after my 
patch), as far as I can tell. It’s only used by `Generic_GCC` and subclasses, 
getting away from which is the whole point of my patch.

Or are you suggesting the addition of --sysroot just to prevent potential 
future problems?


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

https://reviews.llvm.org/D154357

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


[PATCH] D154632: [4/8][RISCV] Add rounding mode control variant for vfmacc, vfnmacc, vfmsac, vfnmsac, vfmadd, vfnmadd, vfmsub, vfnmsub

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539439.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154632

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfmacc-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfmadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfmsac-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfmsub-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfnmacc-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfnmadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfnmsac-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfnmsub-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-ta.ll
  llvm/test/CodeGen/RISCV/rvv/vfmacc.ll
  llvm/test/CodeGen/RISCV/rvv/vfmadd.ll
  llvm/test/CodeGen/RISCV/rvv/vfmsac.ll
  llvm/test/CodeGen/RISCV/rvv/vfmsub.ll
  llvm/test/CodeGen/RISCV/rvv/vfnmacc.ll
  llvm/test/CodeGen/RISCV/rvv/vfnmadd.ll
  llvm/test/CodeGen/RISCV/rvv/vfnmsac.ll
  llvm/test/CodeGen/RISCV/rvv/vfnmsub.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll

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


[PATCH] D145302: [clangd] Add library for clangd main function

2023-07-12 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko added a comment.

In D145302#4492595 , @mstorsjo wrote:

> In D145302#4491973 , @glandium 
> wrote:
>
>> This broke building with `-DLLVM_LINK_LLVM_DYLIB=ON`:
>
> I also ran into this; I pushed a fix in 
> a20d57e83441a69fa2bab86593b18cc0402095d2 
> .

Thank for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145302

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


[PATCH] D154633: [5/8][RISCV] Add rounding mode control variant for vfwmacc, vfwnmacc, vfwmsac, vfwnmsac

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539443.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154633

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwmacc-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwmsac-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwnmacc-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwnmsac-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-ta.ll
  llvm/test/CodeGen/RISCV/rvv/vfwmacc.ll
  llvm/test/CodeGen/RISCV/rvv/vfwmsac.ll
  llvm/test/CodeGen/RISCV/rvv/vfwnmacc.ll
  llvm/test/CodeGen/RISCV/rvv/vfwnmsac.ll

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


[PATCH] D154634: [6/8][RISCV] Add rounding mode control variant for vfsqrt, vfrec7

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539447.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154634

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfrec7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfsqrt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfrec7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfsqrt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrec7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsqrt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfrec7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfrec7-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfsqrt-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfrec7.ll
  llvm/test/CodeGen/RISCV/rvv/vfsqrt.ll

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


[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-07-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a reviewer: aaron.ballman.
v.g.vassilev added a subscriber: aaron.ballman.
v.g.vassilev added a comment.

@capfredf this seems to be heading in a good direction. Please find another 
round of comments.

@aaron.ballman, I could not find a person that's active in that area. Could you 
help with finding reviewers for this type of patch?




Comment at: clang/include/clang/Interpreter/Interpreter.h:117
   ASTContext &getASTContext();
+  void CodeComplete(llvm::StringRef Input, size_t Col, size_t Line = 1);
   const CompilerInstance *getCompilerInstance() const;

I could not find where this interface was used. If it is unused, let'd drop it.



Comment at: clang/include/clang/Sema/Sema.h:13324
+/// Code completion occurs at top-level in a REPL session
+PCC_ReplTopLevel,
   };





Comment at: clang/lib/Interpreter/IncrementalParser.cpp:338
+  //   return;
+  // }
+  if (FE) {

Seems that we have stray debug fragments? Can you remove them?



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:376
   // Create FileID for the current buffer.
-  FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, /*LoadedID=*/0,
-   /*LoadedOffset=*/0, NewLoc);
+  // FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, 
/*LoadedID=*/0,
+  //  /*LoadedOffset=*/0, NewLoc);

Why we had to comment out this line?



Comment at: clang/lib/Interpreter/Interpreter.cpp:248
+  auto *CConsumer = new ReplCompletionConsumer(CompResults);
+  CI->setCodeCompletionConsumer(CConsumer);
+  IncrParser = std::make_unique(

IIUC, `setCodeCompletionConsumer` takes the ownership of `CConsumer`. I'd 
suggest to drop `CConsumer` member.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


[PATCH] D154983: [clang-extdef-mapping] register necessary targest for ms-style asm block

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

I do not have the knowledge to approve this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154983

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


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

2023-07-12 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev commandeered this revision.
v.g.vassilev edited reviewers, added: junaire; removed: v.g.vassilev.
v.g.vassilev added a comment.

Jun has moved on in his career and I'd like to take responsibility for this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146809

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


[PATCH] D138373: [clang-format] Don't eat two semicolons after namespace

2023-07-12 Thread Björn Schäpers via Phabricator via cfe-commits
Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138373

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


[PATCH] D140727: [XRay] Add initial support for loongarch64

2023-07-12 Thread Limin Zhang via Phabricator via cfe-commits
Ami-zhang added inline comments.



Comment at: compiler-rt/lib/xray/xray_loongarch64.cpp:30
+// are 2RI12-type and 2RI16-type.
+inline static uint32_t
+encodeInstruction2RIx(uint32_t Opcode, uint32_t Rd, uint32_t Rj,

MaskRay wrote:
> Early xray code unfortunately does not respect the conventional style that 
> well.
> The usual order is `static inline`
Done, adjusted to `static inline`.



Comment at: compiler-rt/lib/xray/xray_trampoline_loongarch64.S:20
+  .type __xray_FunctionEntry,@function
+__xray_FunctionEntry:
+  .cfi_startproc

MaskRay wrote:
> The symbol needs to be hidden and consider using some macros. See 
> xray_trampoline_AArch64.S
> 
Ok, I have modified them.
Thanks for your suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140727

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


[PATCH] D140727: [XRay] Add initial support for loongarch64

2023-07-12 Thread Limin Zhang via Phabricator via cfe-commits
Ami-zhang updated this revision to Diff 539465.
Ami-zhang added a comment.

Hide some symbols and using some macros in asm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140727

Files:
  clang/lib/Driver/XRayArgs.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/xray/CMakeLists.txt
  compiler-rt/lib/xray/xray_interface.cpp
  compiler-rt/lib/xray/xray_loongarch64.cpp
  compiler-rt/lib/xray/xray_trampoline_loongarch64.S
  compiler-rt/lib/xray/xray_tsc.h
  compiler-rt/test/xray/TestCases/Posix/c-test.cpp
  compiler-rt/test/xray/TestCases/Posix/fdr-thread-order.cpp
  llvm/lib/CodeGen/XRayInstrumentation.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchSubtarget.h
  llvm/lib/XRay/InstrumentationMap.cpp
  llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll

Index: llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll
@@ -0,0 +1,56 @@
+; RUN: llc --mtriple=loongarch64 %s -o - | FileCheck %s
+; RUN: llc --mtriple=loongarch64 -filetype=obj %s -o %t
+; RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=RELOC
+
+define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK-LABEL: foo:
+; CHECK-LABEL: .Lfunc_begin0:
+; CHECK:   .p2align 2
+; CHECK-LABEL: .Lxray_sled_begin0:
+; CHECK-NEXT:  b .Lxray_sled_end0
+; CHECK-COUNT-11:  nop
+; CHECK-LABEL: .Lxray_sled_end0:
+  ret i32 0
+; CHECK-LABEL: .Lxray_sled_begin1:
+; CHECK-NEXT:  b .Lxray_sled_end1
+; CHECK-COUNT-11:  nop
+; CHECK-NEXT: .Lxray_sled_end1:
+; CHECK-NEXT:  ret
+; CHECK-NEXT: .Lfunc_end0:
+}
+
+; CHECK-LABEL: .section xray_instr_map
+; CHECK-NEXT: .Lxray_sleds_start0:
+; CHECK-NEXT: .Ltmp0:
+; CHECK-NEXT: .dword .Lxray_sled_begin0-.Ltmp0
+; CHECK-NEXT: .dword .Lfunc_begin0-(.Ltmp0+8)
+; CHECK-NEXT: .byte 0x00
+; CHECK-NEXT: .byte 0x01
+; CHECK-NEXT: .byte 0x02
+; CHECK-NEXT: .space 13
+; CHECK-NEXT: .Ltmp1:
+; CHECK-NEXT: .dword .Lxray_sled_begin1-.Ltmp1
+; CHECK-NEXT: .dword .Lfunc_begin0-(.Ltmp1+8)
+; CHECK-NEXT: .byte 0x01
+; CHECK-NEXT: .byte 0x01
+; CHECK-NEXT: .byte 0x02
+; CHECK-NEXT: .space 13
+; CHECK-NEXT: .Lxray_sleds_end0:
+
+; CHECK-LABEL:  .section xray_fn_idx
+; CHECK-LABEL:  .Lxray_fn_idx0:
+; CHECK:  .dword .Lxray_sleds_start0-.Lxray_fn_idx0
+; CHECK-NEXT: .dword 2
+
+; RELOC:  Section ([[#]]) .relaxray_instr_map {
+; RELOC-NEXT:   0x0 R_LARCH_64_PCREL .text 0x0
+; RELOC-NEXT:   0x8 R_LARCH_64_PCREL .text 0x0
+; RELOC-NEXT:   0x20 R_LARCH_64_PCREL .text 0x34
+; RELOC-NEXT:   0x28 R_LARCH_64_PCREL .text 0x0
+; RELOC-NEXT: }
+; RELOC-NEXT: Section ([[#]]) .relaxray_fn_idx {
+; RELOC-NEXT:   0x0 R_LARCH_64_PCREL xray_instr_map 0x0
+; RELOC-NEXT: }
+; RELOC-NEXT: Section ([[#]]) .rela.eh_frame {
+; RELOC-NEXT:   0x1C R_LARCH_32_PCREL .text 0x0
+; RELOC-NEXT: }
Index: llvm/lib/XRay/InstrumentationMap.cpp
===
--- llvm/lib/XRay/InstrumentationMap.cpp
+++ llvm/lib/XRay/InstrumentationMap.cpp
@@ -60,6 +60,7 @@
   // Find the section named "xray_instr_map".
   if ((!ObjFile.getBinary()->isELF() && !ObjFile.getBinary()->isMachO()) ||
   !(ObjFile.getBinary()->getArch() == Triple::x86_64 ||
+ObjFile.getBinary()->getArch() == Triple::loongarch64 ||
 ObjFile.getBinary()->getArch() == Triple::ppc64le ||
 ObjFile.getBinary()->getArch() == Triple::arm ||
 ObjFile.getBinary()->getArch() == Triple::aarch64))
Index: llvm/lib/Target/LoongArch/LoongArchSubtarget.h
===
--- llvm/lib/Target/LoongArch/LoongArchSubtarget.h
+++ llvm/lib/Target/LoongArch/LoongArchSubtarget.h
@@ -96,6 +96,7 @@
   MVT getGRLenVT() const { return GRLenVT; }
   unsigned getGRLen() const { return GRLen; }
   LoongArchABI::ABI getTargetABI() const { return TargetABI; }
+  bool isXRaySupported() const override { return is64Bit(); }
 };
 } // end namespace llvm
 
Index: llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
===
--- llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
+++ llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
@@ -42,6 +42,9 @@
  const char *ExtraCode, raw_ostream &OS) override;
 
   void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
+  void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
+  void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
+  void emitSled(const MachineInstr &MI, SledKind Kind);
 
   // tblgen'erated function.
   bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
Index: llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
===

[PATCH] D145228: [clangd] Add clangd headers to install targets

2023-07-12 Thread Ivan Murashko via Phabricator via cfe-commits
ivanmurashko abandoned this revision.
ivanmurashko added a comment.

The diff is not required after https://reviews.llvm.org/D145302 deployed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145228

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


[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

2023-07-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 539467.
cor3ntin marked an inline comment as done.
cor3ntin added a comment.

- Rename EvaluateCharPointerAsString => EvaluateCharRangeAsString
- Improve diag messages
- Form an overload set to diagnose invalid overloads
- Add more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   User-generated static_assert messages
   https://wg21.link/P2741R3";>P2741R3
-  No
+  Clang 17
  
  
   Placeholder variables with no name
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (StringLiteral *Message = D->getMessage())
+  if (auto *Message = dyn_cast(D->getMessage()))
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -0,0 +1,229 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only %s -verify
+
+static_assert(true, "");
+static_assert(true, 0); // expected-error {{the message in a static assertion must be a string literal or an object with 'data()' and 'size()' member functions}}
+struct Empty{};
+static_assert(true, Empty{}); // expected-error {{the message object in this static assertion is missing 'data()' and 'size()' member functions}}
+struct NoData {
+unsigned long size() const;
+};
+struct NoSize {
+const char* data() const;
+};
+static_assert(true, NoData{}); // expected-error {{the message object in this static assertion is missing a 'data()' member function}}
+static_assert(true, NoSize{}); // expected-error {{the message object in this static assertion is missing a 'size()' member function}}
+
+struct InvalidSize {
+const char* size() const;
+const char* data() const;
+};
+static_assert(true, InvalidSize{}); // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}} \
+// expected-error {{value of type 'const char *' is not implicitly convertible to 'unsigned long'}}
+struct InvalidData {
+unsigned long size() const;
+unsigned long data() const;
+};
+static_assert(true, InvalidData{}); // expected-error {{the message in a static assertion must have a 'data()' member function returning an object convertible to 'const char*'}} \
+// expected-error {{value of type 'unsigned long' is not implicitly convertible to 'const char *'}}
+
+struct NonConstexprSize {
+unsigned long size() const; // expected-note {{declared here}}
+constexpr const char* data() const;
+};
+
+static_assert(true, NonConstexprSize{});
+static_assert(false, NonConstexprSize{}); // expected-error {{the message in a static assertion must be produced by a constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'size' cannot be used in a constant expression}}
+
+struct NonConstexprData {
+constexpr unsigned long size() const {
+return 32;
+}
+const char* data() const;  // expected-note {{declared here}}
+};
+
+static_assert(true, NonConstexprData{});
+static_assert(false, NonConstexprData{}); // expected-error {{the message in a static assertion must be produced by a constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'data' cannot be used in a constant expression}}
+
+struct string_view {
+int S;
+const char* D;
+constexpr string_

[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-07-12 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, rsmith, cor3ntin, erichkeane, tbaeder.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added projects: clang, libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This patch makes clang diagnose extensive cases of `consteval if` and 
`is_constant_evaluated` usage that are tautologically true or false.
This introduces a new `Sema::ExpressionEvaluationContext` kind that means the 
immediate appearance of `if consteval` or `is_constant_evaluated` are 
tautologically false(e.g. inside `if !consteval {}` block or 
non-constexpr-qualified function definition body)
This patch also pushes new expression evaluation context when parsing the 
condition of `if constexpr` and initializer of variables so that Sema can be 
aware that the use of `consteval if` and `is_consteval` are tautologically true 
in `if constexpr` condition and `constexpr` variable initializers.
BEFORE this patch, the warning for `is_constant_evaluated` was emitted from 
constant evaluator. This patch moves the warning logic to Sema in order to 
diagnose tautological use of `is_constant_evaluated` in the same way as 
`consteval if`.

Fixes https://github.com/llvm/llvm-project/issues/43760
Fixes https://github.com/llvm/llvm-project/issues/51567


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155064

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/AST/Interp/builtins.cpp
  clang/test/AST/Interp/if.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp
  clang/test/CXX/expr/expr.const/p6-2a.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p3.cpp
  clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p4.cpp
  clang/test/Parser/pragma-fenv_access.c
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/cxx2b-consteval-if.cpp
  clang/test/SemaCXX/ext-int.cpp
  clang/test/SemaCXX/warn-constant-evaluated-constexpr.cpp
  clang/test/SemaCXX/warn-tautological-meta-constant.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/unittests/Support/TimeProfilerTest.cpp
  
libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
  
libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp

Index: libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp
===
--- libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp
+++ libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.verify.cpp
@@ -24,7 +24,7 @@
 #else
   // expected-error-re@+1 (static_assert|static assertion)}} failed}}
   static_assert(!std::is_constant_evaluated(), "");
-  // expected-warning@-1 0-1 {{'std::is_constant_evaluated' will always evaluate to 'true' in a manifestly constant-evaluated expression}}
+  // expected-warning@-1 0-1 {{'std::is_constant_evaluated' will always evaluate to true in this context}}
 #endif
   return 0;
 }
Index: libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
===
--- libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
+++ libcxx/test/std/algorithms/alg.modifying.operations/alg.copy/ranges.copy.segmented.pass.cpp
@@ -93,12 +93,10 @@
 }
 
 int main(int, char**) {
-  if (!std::is_constant_evaluated()) {
-test_containers, std::deque>();
-test_containers, std::vector>();
-test_containers, std::deque>();
-test_containers, std::vector>();
-  }
+  test_containers, std::deque>();
+  test_containers, std::vector>();
+  test_containers, std::deque>();
+  test_containers, std::vector>();
 
   types::for_each(types::forward_iterator_list{}, [] {
 test_join_view();
Index: clang/unittests/Support/TimeProfilerTest.cpp
===
--- clang/unittests/Support/TimeProfilerTest.cpp
+++ clang/unittests/Support/TimeProfilerTest.cpp
@@ -188,7 +188,6 @@
 | EvaluateAsBooleanCondition ()
 | | EvaluateAsRValue ()
 | EvaluateAsInitializer (slow_value)
-| EvaluateAsConstantExpr ()
 | EvaluateAsConstantExpr ()
 | EvaluateAsRValue ()
 | EvaluateAsInitializer (slow_init_list)
Index: clang/test/SemaTemplate/

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

2023-07-12 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 539470.
tomasz-kaminski-sonarsource marked 3 inline comments as done.
tomasz-kaminski-sonarsource added a comment.

Apply review suggestion and replaced make_scope_exit with SaveAndRestore that 
was already used
in file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153273

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/lifetime-cfg-output.cpp
  clang/test/Analysis/no-exit-cfg.c
  clang/test/Analysis/nonreturn-destructors-cfg-output.cpp
  clang/test/Analysis/scopes-cfg-output.cpp

Index: clang/test/Analysis/scopes-cfg-output.cpp
===
--- clang/test/Analysis/scopes-cfg-output.cpp
+++ clang/test/Analysis/scopes-cfg-output.cpp
@@ -674,30 +674,30 @@
   A f;
 }
 
-// CHECK:  [B8 (ENTRY)]
+// CHECK:  [B9 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B7
 // CHECK:  [B1]
 // CHECK-NEXT:  l1:
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B1.2], A)
 // CHECK-NEXT:   2: A c;
 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   5: [B6.3].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B6.2].~A() (Implicit destructor)
 // CHECK-NEXT:   6: [B7.3].~A() (Implicit destructor)
 // CHECK-NEXT:   7: CFGScopeEnd(a)
 // CHECK-NEXT:   Preds (2): B2 B3
 // CHECK-NEXT:   Succs (1): B0
 // CHECK:  [B2]
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B2.2], A)
-// CHECK-NEXT:   2: A b;
+// CHECK-NEXT:   2: A nb;
 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   5: CFGScopeEnd(a)
+// CHECK-NEXT:   4: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(na)
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
 // CHECK:  [B3]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: CFGScopeEnd(a)
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
 // CHECK-NEXT:   T: goto l1;
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
@@ -708,33 +708,35 @@
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (2): B3 B2
 // CHECK:  [B5]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   3: [B6.3].~A() (Implicit destructor)
-// CHECK-NEXT:   4: CFGScopeEnd(cb)
-// CHECK-NEXT:   T: goto l0;
 // CHECK-NEXT:   Preds (1): B6
-// CHECK-NEXT:   Succs (1): B6
+// CHECK-NEXT:   Succs (1): B8
 // CHECK:  [B6]
 // CHECK-NEXT:  l0:
-// CHECK-NEXT:   1: CFGScopeBegin(cb)
-// CHECK-NEXT:   2:  (CXXConstructExpr, [B6.3], A)
-// CHECK-NEXT:   3: A cb;
-// CHECK-NEXT:   4:  (CXXConstructExpr, [B6.5], A)
-// CHECK-NEXT:   5: A b;
-// CHECK-NEXT:   6: CFGScopeBegin(a)
-// CHECK-NEXT:   7:  (CXXConstructExpr, [B6.8], A)
-// CHECK-NEXT:   8: A a;
-// CHECK-NEXT:   9: UV
-// CHECK-NEXT:  10: [B6.9] (ImplicitCastExpr, LValueToRValue, _Bool)
-// CHECK-NEXT:   T: if [B6.10]
-// CHECK-NEXT:   Preds (2): B7 B5
+// CHECK-NEXT:   1:  (CXXConstructExpr, [B6.2], A)
+// CHECK-NEXT:   2: A cb;
+// CHECK-NEXT:   3:  (CXXConstructExpr, [B6.4], A)
+// CHECK-NEXT:   4: A b;
+// CHECK-NEXT:   5: CFGScopeBegin(na)
+// CHECK-NEXT:   6:  (CXXConstructExpr, [B6.7], A)
+// CHECK-NEXT:   7: A na;
+// CHECK-NEXT:   8: UV
+// CHECK-NEXT:   9: [B6.8] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK-NEXT:   T: if [B6.9]
+// CHECK-NEXT:   Preds (2): B7 B8
 // CHECK-NEXT:   Succs (2): B5 B4
 // CHECK:  [B7]
 // CHECK-NEXT:   1: CFGScopeBegin(a)
 // CHECK-NEXT:   2:  (CXXConstructExpr, [B7.3], A)
 // CHECK-NEXT:   3: A a;
-// CHECK-NEXT:   Preds (1): B8
+// CHECK-NEXT:   Preds (1): B9
+// CHECK-NEXT:   Succs (1): B6
+// CHECK:  [B8]
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
+// CHECK-NEXT:   3: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.2].~A() (Implicit destructor)
+// CHECK-NEXT:   T: goto l0;
+// CHECK-NEXT:   Preds (1): B5
 // CHECK-NEXT:   Succs (1): B6
 // CHECK:  [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
@@ -743,10 +745,10 @@
 l0:
   A cb;
   A b;
-  { A a;
+  { A na;
 if (UV) goto l0;
 if (UV) goto l1;
-A b;
+A nb;
   }
 l1:
   A c;
@@ -1168,3 +1170,184 @@
 }
   }
 }
+
+// CHECK:   [B4 (ENTRY)]
+// CHECK-NEXT:Succs (1): B3
+// CHECK:   [B1]
+// CHECK-NEXT:   label:
+// CHECK-NEXT:1: CFGScopeEnd(n2t)
+// CHECK-NEXT:2: CFGScopeEnd(n1t)
+// CHECK-NEXT:3: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:4: CFGScopeEnd(a)
+// CHECK-NEXT:Preds (2): B2 B3
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B2]
+// CHECK-NEXT:1: [B3.9].~A() (Implicit destructor)
+// 

[clang] 1116ed2 - [clang-format] Correctly count a tab's width in a comment

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

Author: Björn Schäpers
Date: 2023-07-12T12:23:19+02:00
New Revision: 1116ed2beb1cd62a4b450efead481009af19df62

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

LOG: [clang-format] Correctly count a tab's width in a comment

It worked only correct for a tab as the first char.

Fixes https://github.com/llvm/llvm-project/issues/56769

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

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index 16df187eadbf57..af1e0748fafa97 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -82,9 +82,9 @@ getCommentSplit(StringRef Text, unsigned ContentStartColumn,
NumChars < MaxSplit && MaxSplitBytes < Text.size();) {
 unsigned BytesInChar =
 encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding);
-NumChars +=
-encoding::columnWidthWithTabs(Text.substr(MaxSplitBytes, BytesInChar),
-  ContentStartColumn, TabWidth, Encoding);
+NumChars += encoding::columnWidthWithTabs(
+Text.substr(MaxSplitBytes, BytesInChar), ContentStartColumn + NumChars,
+TabWidth, Encoding);
 MaxSplitBytes += BytesInChar;
   }
 

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index b0ba00caeeb442..a5fcf60cc59e76 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -652,6 +652,11 @@ TEST_F(FormatTestComments, SplitsLongCxxComments) {
 "//: one line",
 format("//: A comment that doesn't fit on one line",
getLLVMStyleWithColumns(20)));
+
+  verifyFormat(
+  "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth()\n"
+  "//* 0.2)",
+  "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth() * 0.2)");
 }
 
 TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {



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


[clang] ce7356f - [clang-format] Don't eat two semicolons after namespace

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

Author: Björn Schäpers
Date: 2023-07-12T12:23:20+02:00
New Revision: ce7356f08194083c205b92e77d1a4cd515a2a5b8

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

LOG: [clang-format] Don't eat two semicolons after namespace

Remove the double check, move the comment.

This changes behavior, but I think for the better. Despite the comment
my personal opinion would be to not even gracefully handle the one
semicolon, it shouldn't be there.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 737ba52a1fb1b4..0ef2b1c3a46293 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2970,15 +2970,12 @@ void UnwrappedLineParser::parseNamespace() {
 if (ManageWhitesmithsBraces)
   ++Line->Level;
 
+// Munch the semicolon after a namespace. This is more common than one 
would
+// think. Putting the semicolon into its own line is very ugly.
 parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/true,
/*KeepBraces=*/true, /*IfKind=*/nullptr,
ManageWhitesmithsBraces);
 
-// Munch the semicolon after a namespace. This is more common than one 
would
-// think. Putting the semicolon into its own line is very ugly.
-if (FormatTok->is(tok::semi))
-  nextToken();
-
 addUnwrappedLine(AddLevels > 0 ? LineLevel::Remove : LineLevel::Keep);
 
 if (ManageWhitesmithsBraces)



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


[PATCH] D138402: [clang-format] Correctly count a tab's width in a comment

2023-07-12 Thread Björn Schäpers 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 rG1116ed2beb1c: [clang-format] Correctly count a tab's 
width in a comment (authored by HazardyKnusperkeks).

Changed prior to commit:
  https://reviews.llvm.org/D138402?vs=480597&id=539471#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138402

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestComments.cpp


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -652,6 +652,11 @@
 "//: one line",
 format("//: A comment that doesn't fit on one line",
getLLVMStyleWithColumns(20)));
+
+  verifyFormat(
+  "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth()\n"
+  "//* 0.2)",
+  "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth() * 0.2)");
 }
 
 TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -82,9 +82,9 @@
NumChars < MaxSplit && MaxSplitBytes < Text.size();) {
 unsigned BytesInChar =
 encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding);
-NumChars +=
-encoding::columnWidthWithTabs(Text.substr(MaxSplitBytes, BytesInChar),
-  ContentStartColumn, TabWidth, Encoding);
+NumChars += encoding::columnWidthWithTabs(
+Text.substr(MaxSplitBytes, BytesInChar), ContentStartColumn + NumChars,
+TabWidth, Encoding);
 MaxSplitBytes += BytesInChar;
   }
 


Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -652,6 +652,11 @@
 "//: one line",
 format("//: A comment that doesn't fit on one line",
getLLVMStyleWithColumns(20)));
+
+  verifyFormat(
+  "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth()\n"
+  "//* 0.2)",
+  "//\t\t\t\tofMap(message.velocity, 0, 127, 0, ofGetWidth() * 0.2)");
 }
 
 TEST_F(FormatTestComments, PreservesHangingIndentInCxxComments) {
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -82,9 +82,9 @@
NumChars < MaxSplit && MaxSplitBytes < Text.size();) {
 unsigned BytesInChar =
 encoding::getCodePointNumBytes(Text[MaxSplitBytes], Encoding);
-NumChars +=
-encoding::columnWidthWithTabs(Text.substr(MaxSplitBytes, BytesInChar),
-  ContentStartColumn, TabWidth, Encoding);
+NumChars += encoding::columnWidthWithTabs(
+Text.substr(MaxSplitBytes, BytesInChar), ContentStartColumn + NumChars,
+TabWidth, Encoding);
 MaxSplitBytes += BytesInChar;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138373: [clang-format] Don't eat two semicolons after namespace

2023-07-12 Thread Björn Schäpers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
HazardyKnusperkeks marked an inline comment as done.
Closed by commit rGce7356f08194: [clang-format] Don't eat two semicolons 
after namespace (authored by HazardyKnusperkeks).

Changed prior to commit:
  https://reviews.llvm.org/D138373?vs=476724&id=539472#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138373

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2970,15 +2970,12 @@
 if (ManageWhitesmithsBraces)
   ++Line->Level;
 
+// Munch the semicolon after a namespace. This is more common than one 
would
+// think. Putting the semicolon into its own line is very ugly.
 parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/true,
/*KeepBraces=*/true, /*IfKind=*/nullptr,
ManageWhitesmithsBraces);
 
-// Munch the semicolon after a namespace. This is more common than one 
would
-// think. Putting the semicolon into its own line is very ugly.
-if (FormatTok->is(tok::semi))
-  nextToken();
-
 addUnwrappedLine(AddLevels > 0 ? LineLevel::Remove : LineLevel::Keep);
 
 if (ManageWhitesmithsBraces)


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2970,15 +2970,12 @@
 if (ManageWhitesmithsBraces)
   ++Line->Level;
 
+// Munch the semicolon after a namespace. This is more common than one would
+// think. Putting the semicolon into its own line is very ugly.
 parseBlock(/*MustBeDeclaration=*/true, AddLevels, /*MunchSemi=*/true,
/*KeepBraces=*/true, /*IfKind=*/nullptr,
ManageWhitesmithsBraces);
 
-// Munch the semicolon after a namespace. This is more common than one would
-// think. Putting the semicolon into its own line is very ugly.
-if (FormatTok->is(tok::semi))
-  nextToken();
-
 addUnwrappedLine(AddLevels > 0 ? LineLevel::Remove : LineLevel::Keep);
 
 if (ManageWhitesmithsBraces)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

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



Comment at: clang/lib/AST/ExprConstant.cpp:16417-16418
+  }
+  if (!Scope.destroy())
+return false;
+

aaron.ballman wrote:
> Rather than use an RAII object and destroy it manually, let's use `{}` to 
> scope the RAII object appropriately.
This seems to be the way to use this interface - mostly because destroy can 
fail and we want to detect that



Comment at: clang/lib/AST/ExprConstant.cpp:16413
+APSInt C = Char.getInt();
+Result.push_back(static_cast(C.getExtValue()));
+if (!HandleLValueArrayAdjustment(Info, PtrExpression, String, CharTy, 1))

aaron.ballman wrote:
> barannikov88 wrote:
> > This relies on host's CHAR_BIT >= target's CHAR_BIT, which isn't true for 
> > my target. Could you add an assertion?
> > 
> Wouldn't adding the assertion cause you problems then? (FWIW, we only support 
> `CHAR_BIT == 8` currently.)
I replied to that in one of the comment i made on the review, but CHAR_BIT is 
not relevant there.
This cast is valid as long as `C` carries some kind of UTF-8 code unit - even 
if that code unit was 0 extended to fill an arbitrary long storage.
This would only be problematic if somehow the literal encoding of narrow 
literal was a wide encoding like UTF-16 or dec-kanji?
The assertion we would want is "does the literal encoding has codepoints 
greater than the size of char", which is not something we are going to get.

That being said I realized while replying that there is a bug there: it should 
cast to unsigned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

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


[PATCH] D154635: [7/8][RISCV] Add rounding mode control variant for conversion intrinsics between floating-point and integer

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539473.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154635

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfncvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfncvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfncvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfncvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfcvt-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfncvt-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwcvt-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/half-round-conv.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-f-x.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-f-xu.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-x-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfcvt-xu-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-x.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-f-xu.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-x-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfncvt-xu-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-f-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-f-x.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-f-xu.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-x-f.ll
  llvm/test/CodeGen/RISCV/rvv/vfwcvt-xu-f.ll

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


[PATCH] D154636: [8/8][RISCV] Add rounding mode control variant for vfredosum, vfredusum, vfwredosum, vfwredusum

2023-07-12 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 539478.
eopXD added a comment.

Change:

- Rebase upon latest main and updated parent revisions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154636

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfwredusum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfredosum-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfredusum-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwredosum-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfwredusum-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/unmasked-ta.ll
  llvm/test/CodeGen/RISCV/rvv/vfredosum.ll
  llvm/test/CodeGen/RISCV/rvv/vfredusum.ll
  llvm/test/CodeGen/RISCV/rvv/vfwredosum.ll
  llvm/test/CodeGen/RISCV/rvv/vfwredusum.ll

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


[PATCH] D154963: [Format][Tooling] Fix HeaderIncludes::insert not respect the main-file header.

2023-07-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 539481.
hokein marked 2 inline comments as done.
hokein added a comment.
Herald added a subscriber: arphaman.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154963

Files:
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Tooling/HeaderIncludesTest.cpp

Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -143,6 +143,19 @@
   EXPECT_NE(Expected, insert(Code, "")) << "Not main header";
 }
 
+TEST_F(HeaderIncludesTest, InsertMainHeader) {
+  Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
+  .IncludeStyle;
+  FileName = "fix.cpp";
+  EXPECT_EQ(R"cpp(#include "fix.h"
+#include "a.h")cpp", insert("#include \"a.h\"", "\"fix.h\""));
+
+  // Respect the original main-file header.
+  EXPECT_EQ(R"cpp(#include "z/fix.h"
+#include "a/fix.h"
+)cpp", insert("#include \"z/fix.h\"", "\"a/fix.h\""));
+}
+
 TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
   std::string Code = "#include \n"
  "\n"
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -276,6 +276,7 @@
   MaxInsertOffset(MinInsertOffset +
   getMaxHeaderInsertionOffset(
   FileName, Code.drop_front(MinInsertOffset), Style)),
+  MainIncludeFound(false),
   Categories(Style, FileName) {
   // Add 0 for main header and INT_MAX for headers that are not in any
   // category.
@@ -335,7 +336,9 @@
   // Only record the offset of current #include if we can insert after it.
   if (CurInclude.R.getOffset() <= MaxInsertOffset) {
 int Priority = Categories.getIncludePriority(
-CurInclude.Name, /*CheckMainHeader=*/FirstIncludeOffset < 0);
+CurInclude.Name, /*CheckMainHeader=*/!MainIncludeFound);
+if (Priority == 0)
+  MainIncludeFound = true;
 CategoryEndOffsets[Priority] = NextLineOffset;
 IncludesByPriority[Priority].push_back(&CurInclude);
 if (FirstIncludeOffset < 0)
@@ -362,7 +365,9 @@
   std::string(llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName));
   StringRef QuotedName = Quoted;
   int Priority = Categories.getIncludePriority(
-  QuotedName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
+  QuotedName, /*CheckMainHeader=*/!MainIncludeFound);
+  if (Priority == 0)
+MainIncludeFound = true;
   auto CatOffset = CategoryEndOffsets.find(Priority);
   assert(CatOffset != CategoryEndOffsets.end());
   unsigned InsertOffset = CatOffset->second; // Fall back offset
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -128,6 +128,7 @@
   // inserting new #includes into the actual code section (e.g. after a
   // declaration).
   unsigned MaxInsertOffset;
+  mutable bool MainIncludeFound;
   IncludeCategoryManager Categories;
   // Record the offset of the end of the last include in each category.
   std::unordered_map CategoryEndOffsets;
Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -311,12 +311,9 @@
   Results = {};
   Results.Missing.push_back("\"d.h\"");
   Code = R"cpp(#include "a.h")cpp";
-  // FIXME: this isn't correct, the main-file header d.h should be added before
-  // a.h.
   EXPECT_EQ(fixIncludes(Results, "d.cc", Code, format::getLLVMStyle()),
-R"cpp(#include "a.h"
-#include "d.h"
-)cpp");
+R"cpp(#include "d.h"
+#include "a.h")cpp");
 }
 
 MATCHER_P3(expandedAt, FileID, Offset, SM, "") {
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -214,7 +214,7 @@
 })cpp");
 
   TestTU TU;
-  TU.Filename = "foo.cpp";
+  TU.Filename = "main.cpp";
   TU.AdditionalFiles["a.h"] = guard("#include \"b.h\"");
   TU.AdditionalFiles["b.h"] = guard("void b();");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin

[clang] 227012c - [OpenMP] Migrate device code privatisation from Clang CodeGen to OMPIRBuilder

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

Author: Akash Banerjee
Date: 2023-07-12T12:03:28+01:00
New Revision: 227012cbd71f7f55c9f28f561a069628a964a97a

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

LOG: [OpenMP] Migrate device code privatisation from Clang CodeGen to 
OMPIRBuilder

This patch migrates the UseDevicePtr and UseDeviceAddr clause related code for 
handling privatisation from Clang codegen to the OMPIRBuilder

Depends on D150860

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index e5952bf436df93..a52ec8909b12ac 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6819,6 +6819,7 @@ class MappableExprsHandler {
 const Expr *getMapExpr() const { return MapExpr; }
   };
 
+  using DeviceInfoTy = llvm::OpenMPIRBuilder::DeviceInfoTy;
   using MapBaseValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
   using MapValuesArrayTy = llvm::OpenMPIRBuilder::MapValuesArrayTy;
   using MapFlagsArrayTy = llvm::OpenMPIRBuilder::MapFlagsArrayTy;
@@ -7589,6 +7590,7 @@ class MappableExprsHandler {
 CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
 CombinedInfo.BasePointers.push_back(BP.getPointer());
 CombinedInfo.DevicePtrDecls.push_back(nullptr);
+CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
 CombinedInfo.Pointers.push_back(LB.getPointer());
 CombinedInfo.Sizes.push_back(CGF.Builder.CreateIntCast(
 Size, CGF.Int64Ty, /*isSigned=*/true));
@@ -7601,6 +7603,7 @@ class MappableExprsHandler {
   CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
   CombinedInfo.BasePointers.push_back(BP.getPointer());
   CombinedInfo.DevicePtrDecls.push_back(nullptr);
+  CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
   CombinedInfo.Pointers.push_back(LB.getPointer());
   Size = CGF.Builder.CreatePtrDiff(
   CGF.Int8Ty, CGF.Builder.CreateConstGEP(HB, 1).getPointer(),
@@ -7619,6 +7622,7 @@ class MappableExprsHandler {
   CombinedInfo.Exprs.emplace_back(MapDecl, MapExpr);
   CombinedInfo.BasePointers.push_back(BP.getPointer());
   CombinedInfo.DevicePtrDecls.push_back(nullptr);
+  CombinedInfo.DevicePointers.push_back(DeviceInfoTy::None);
   CombinedInfo.Pointers.push_back(LB.getPointer());
   CombinedInfo.Sizes.push_back(
   CGF.Builder.CreateIntCast(Size, CGF.Int64Ty, /*isSigned=*/true));
@@ -8119,10 +8123,12 @@ class MappableExprsHandler {
 
 auto &&UseDeviceDataCombinedInfoGen =
 [&UseDeviceDataCombinedInfo](const ValueDecl *VD, llvm::Value *Ptr,
- CodeGenFunction &CGF) {
+ CodeGenFunction &CGF, bool IsDevAddr) {
   UseDeviceDataCombinedInfo.Exprs.push_back(VD);
   UseDeviceDataCombinedInfo.BasePointers.emplace_back(Ptr);
   UseDeviceDataCombinedInfo.DevicePtrDecls.emplace_back(VD);
+  UseDeviceDataCombinedInfo.DevicePointers.emplace_back(
+  IsDevAddr ? DeviceInfoTy::Address : DeviceInfoTy::Pointer);
   UseDeviceDataCombinedInfo.Pointers.push_back(Ptr);
   UseDeviceDataCombinedInfo.Sizes.push_back(
   llvm::Constant::getNullValue(CGF.Int64Ty));
@@ -8162,7 +8168,7 @@ class MappableExprsHandler {
 } else {
   Ptr = CGF.EmitLoadOfScalar(CGF.EmitLValue(IE), IE->getExprLoc());
 }
-UseDeviceDataCombinedInfoGen(VD, Ptr, CGF);
+UseDeviceDataCombinedInfoGen(VD, Ptr, CGF, IsDevAddr);
   }
 };
 
@@ -8189,6 +8195,7 @@ class MappableExprsHandler {
   // item.
   if (CI != Data.end()) {
 if (IsDevAddr) {
+  CI->ForDeviceAddr = IsDevAddr;
   CI->ReturnDevicePointer = true;
   Found = true;
   break;
@@ -8201,6 +8208,7 @@ class MappableExprsHandler {
   PrevCI == CI->Components.rend() ||
   isa(PrevCI->getAssociatedExpression()) || !VarD 
||
   VarD->hasLocalStorage()) {
+CI->ForDeviceAddr = IsDevAddr;
 CI->ReturnDevicePointer = true;
 Found = true;
 break;
@@ -8292,6 +8300,8 @@ class M

[PATCH] D152554: [OpenMP] Migrate device code privatisation from Clang CodeGen to OMPIRBuilder

2023-07-12 Thread Akash Banerjee 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 rG227012cbd71f: [OpenMP] Migrate device code privatisation 
from Clang CodeGen to OMPIRBuilder (authored by TIFitis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152554

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4166,7 +4166,7 @@
 omp::RuntimeFunction *MapperFunc,
 function_ref
 BodyGenCB,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB, Value *SrcLocInfo) {
   if (!updateToLocation(Loc))
 return InsertPointTy();
@@ -4213,6 +4213,14 @@
 
   Builder.CreateCall(BeginMapperFunc, OffloadingArgs);
 
+  for (auto DeviceMap : Info.DevicePtrInfoMap) {
+if (isa(DeviceMap.second.second)) {
+  auto *LI =
+  Builder.CreateLoad(Builder.getPtrTy(), DeviceMap.second.first);
+  Builder.CreateStore(LI, DeviceMap.second.second);
+}
+  }
+
   // If device pointer privatization is required, emit the body of the
   // region here. It will have to be duplicated: with and without
   // privatization.
@@ -4628,7 +4636,7 @@
 void OpenMPIRBuilder::emitOffloadingArrays(
 InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
 TargetDataInfo &Info, bool IsNonContiguous,
-function_ref DeviceAddrCB,
+function_ref DeviceAddrCB,
 function_ref CustomMapperCB) {
 
   // Reset the array information.
@@ -4766,9 +4774,21 @@
 BPVal, BP, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
 
 if (Info.requiresDevicePointerInfo()) {
-  assert(DeviceAddrCB &&
- "DeviceAddrCB missing for DevicePtr code generation");
-  DeviceAddrCB(I, BP, BPVal);
+  if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Pointer) {
+CodeGenIP = Builder.saveIP();
+Builder.restoreIP(AllocaIP);
+Info.DevicePtrInfoMap[BPVal] = {
+BP, Builder.CreateAlloca(Builder.getPtrTy())};
+Builder.restoreIP(CodeGenIP);
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, Info.DevicePtrInfoMap[BPVal].second);
+  } else if (CombinedInfo.DevicePointers[I] == DeviceInfoTy::Address) {
+Info.DevicePtrInfoMap[BPVal] = {BP, BP};
+assert(DeviceAddrCB &&
+   "DeviceAddrCB missing for DevicePtr code generation");
+DeviceAddrCB(I, BP);
+  }
 }
 
 Value *PVal = CombinedInfo.Pointers[I];
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -1610,6 +1610,9 @@
   public:
 TargetDataRTArgs RTArgs;
 
+SmallMapVector, 4>
+DevicePtrInfoMap;
+
 /// Indicate whether any user-defined mapper exists.
 bool HasMapper = false;
 /// The total number of pointers passed to the runtime library.
@@ -1636,7 +1639,9 @@
 bool separateBeginEndCalls() { return SeparateBeginEndCalls; }
   };
 
+  enum class DeviceInfoTy { None, Pointer, Address };
   using MapValuesArrayTy = SmallVector;
+  using MapDeviceInfoArrayTy = SmallVector;
   using MapFlagsArrayTy = SmallVector;
   using MapNamesArrayTy = SmallVector;
   using MapDimArrayTy = SmallVector;
@@ -1655,6 +1660,7 @@
 };
 MapValuesArrayTy BasePointers;
 MapValuesArrayTy Pointers;
+MapDeviceInfoArrayTy DevicePointers;
 MapValuesArrayTy Sizes;
 MapFlagsArrayTy Types;
 MapNamesArrayTy Names;
@@ -1665,6 +1671,8 @@
   BasePointers.append(CurInfo.BasePointers.begin(),
   CurInfo.BasePointers.end());
   Pointers.append(CurInfo.Pointers.begin(), CurInfo.Pointers.end());
+  DevicePointers.append(CurInfo.DevicePointers.begin(),
+CurInfo.DevicePointers.end());
   Sizes.append(CurInfo.Sizes.begin(), CurInfo.Sizes.end());
   Types.append(CurInfo.Types.begin(), CurInfo.Types.end());
   Names.append(CurInfo.Names.begin(), CurInfo.Names.end());
@@ -1723,7 +1731,7 @@
   void emitOffloadingArrays(
   InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
   TargetDataInfo &Info, bool IsNonContiguous = false,
-  function_ref DeviceAddrCB = nullptr,
+ 

[PATCH] D155067: [clang][dataflow] Strengthen flow condition assertions.

2023-07-12 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Instead of asserting merely that the flow condition doesn't imply that a
variable is true, make the stronger assertion that the flow condition implies
that the variable is false.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155067

Files:
  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
@@ -3530,7 +3530,7 @@
 EXPECT_TRUE(EnvThen.flowConditionImplies(BarValThen));
 
 auto &BarValElse = *cast(EnvElse.getValue(*BarDecl));
-EXPECT_FALSE(EnvElse.flowConditionImplies(BarValElse));
+EXPECT_TRUE(EnvElse.flowConditionImplies(EnvElse.makeNot(BarValElse)));
   });
 }
 
@@ -3561,7 +3561,7 @@
 ASSERT_THAT(BarDecl, NotNull());
 
 auto &BarValThen = *cast(EnvThen.getValue(*BarDecl));
-EXPECT_FALSE(EnvThen.flowConditionImplies(BarValThen));
+EXPECT_TRUE(EnvThen.flowConditionImplies(EnvThen.makeNot(BarValThen)));
 
 auto &BarValElse = *cast(EnvElse.getValue(*BarDecl));
 EXPECT_TRUE(EnvElse.flowConditionImplies(BarValElse));


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3530,7 +3530,7 @@
 EXPECT_TRUE(EnvThen.flowConditionImplies(BarValThen));
 
 auto &BarValElse = *cast(EnvElse.getValue(*BarDecl));
-EXPECT_FALSE(EnvElse.flowConditionImplies(BarValElse));
+EXPECT_TRUE(EnvElse.flowConditionImplies(EnvElse.makeNot(BarValElse)));
   });
 }
 
@@ -3561,7 +3561,7 @@
 ASSERT_THAT(BarDecl, NotNull());
 
 auto &BarValThen = *cast(EnvThen.getValue(*BarDecl));
-EXPECT_FALSE(EnvThen.flowConditionImplies(BarValThen));
+EXPECT_TRUE(EnvThen.flowConditionImplies(EnvThen.makeNot(BarValThen)));
 
 auto &BarValElse = *cast(EnvElse.getValue(*BarDecl));
 EXPECT_TRUE(EnvElse.flowConditionImplies(BarValElse));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154963: [Format][Tooling] Fix HeaderIncludes::insert not respect the main-file header.

2023-07-12 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:369-370
+  QuotedName, /*CheckMainHeader=*/!MainIncludeFound);
+  if (Priority == 0)
+MainIncludeFound = true;
   auto CatOffset = CategoryEndOffsets.find(Priority);

sorry if I was unclear in the previous comment. but i was trying to say we 
should only consider includes we've encountered during the initial scan.

getting different results depending on the order of insertions being performed 
is likely gonna cause confusion elsewhere (e.g. depending on the first 
diagnostic you've in clangd, you'll get different order of includes). hence, 
let's keep this function stateless (which also gets rid of the concerns around 
mutable)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154963

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


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-12 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 539493.
yronglin added a comment.

Address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Stmt.h
  clang/test/SemaCXX/builtin-dump-struct.cpp


Index: clang/test/SemaCXX/builtin-dump-struct.cpp
===
--- clang/test/SemaCXX/builtin-dump-struct.cpp
+++ clang/test/SemaCXX/builtin-dump-struct.cpp
@@ -159,3 +159,28 @@
 // expected-note@#Format {{no known 
conversion from 'int' to 'ConstexprString &' for 1st argument}}
 }
 #endif
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow. This
+// would previously cause a crash.
+struct t1 {
+  int v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, 
v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, 
v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, 
v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, 
v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, 
v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, 
v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+struct t2 {
+  t1 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, 
v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, 
v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, 
v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, 
v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, 
v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+int printf(const char *, ...);
+void f1(t2 w) { __builtin_dump_struct(&w, printf); }
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -593,10 +593,8 @@
 
 unsigned : NumExprBits;
 
-// These don't need to be particularly wide, because they're
-// strictly limited by the forms of expressions we permit.
-unsigned NumSubExprs : 8;
-unsigned ResultIndex : 32 - 8 - NumExprBits;
+unsigned NumSubExprs : 16;
+unsigned ResultIndex : 16;
   };
 
   class SourceLocExprBitfields {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -591,6 +591,8 @@
   (`#38717 _`).
 - Fix an assertion when using ``\u0024`` (``$``) as an identifier, by 
disallowing
   that construct (`#62133 
_`).
+- Fix crash caused by PseudoObjectExprBitfields: NumSubExprs overflow.
+  (`#63169 _`)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/builtin-dump-struct.cpp
===
--- clang/test/SemaCXX/builtin-dump-struct.cpp
+++ clang/test/SemaCXX/builtin-dump-struct.cpp
@@ -159,3 +159,28 @@
 // expected-note@#Format {{no known conversion from 'int' to 'ConstexprString &' for 1st argument}}
 }
 #endif
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow. This
+// would previously cause a crash.
+struct t1 {
+  int v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+struct t2 {
+  t1 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+int printf(const char *, ...);
+void f1(t2 w) { __builtin_dump_struct(&w, printf); }
Index: clang/include/clang/AST/Stmt.h
===

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

2023-07-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/Analysis/CFG.cpp:1819-1826
+  for (std::size_t idx = 1, count = LocalScopeEndMarkers.size(); idx < count;
+   ++idx) {
+LocalScope::const_iterator B = LocalScopeEndMarkers[idx];
+LocalScope::const_iterator E = LocalScopeEndMarkers[idx - 1];
+if (!B.inSameLocalScope(E))
+  addScopeExitHandling(B, E, S);
+addAutomaticObjDestruction(B, E, S);

How about using a "pairwise"  range here?
I believe, we don't have that just yet, but we can use `zip` instead.



Comment at: clang/lib/Analysis/CFG.cpp:1844-1846
+  for (LocalScope::const_iterator I = B; I != E; ++I)
+if (!hasTrivialDestructor(*I))
+  DeclsNonTrivial.push_back(*I);

We could use `llvm::make_range(B, E)` here, I believe.



Comment at: clang/lib/Analysis/CFG.cpp:1901-1903
+  for (LocalScope::const_iterator I = B; I != E; ++I)
 if (hasTrivialDestructor(*I))
   DeclsTrivial.push_back(*I);

Ranges here too.



Comment at: clang/lib/Analysis/CFG.cpp:1936-1938
+for (LocalScope::const_iterator I = DstPos; I != BasePos; ++I)
+  if (I.pointsToFirstDeclaredVar())
+appendScopeBegin(Block, *I, S);

Probably, we could also use a `llvm::make_range(DstPos, BasePos)` here, but I'm 
not sure if that's more readable or not.


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


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-12 Thread Yurong via Phabricator via cfe-commits
yronglin marked an inline comment as done.
yronglin added inline comments.



Comment at: clang/include/clang/AST/Stmt.h:603
 
-// These don't need to be particularly wide, because they're
-// strictly limited by the forms of expressions we permit.
-unsigned NumSubExprs : 8;
-unsigned ResultIndex : 32 - 8 - NumExprBits;
+// Whether the PseudoObjectExpr has result.
+unsigned HasResult : 1;

rjmccall wrote:
> aaron.ballman wrote:
> > 
> Please remove the comment, which is incorrect.  Otherwise, I think this is 
> fine.
Thanks, removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

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


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-12 Thread Yurong via Phabricator via cfe-commits
yronglin marked an inline comment as done.
yronglin added a comment.

Thanks for your review! @aaron.ballman @rjmccall


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

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


[PATCH] D153701: [WIP][Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

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



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8901-8914
+  // [P2718R0] Lifetime extension in range-based for loops.
+  //
+  // 6.7.7 [class.temporary] p5:
+  // There are four contexts in which temporaries are destroyed at a different
+  // point than the end of the full-expression.
+  //
+  // 6.7.7 [class.temporary] p6:

hubert.reinterpretcast wrote:
> yronglin wrote:
> > rsmith wrote:
> > > This isn't the right way to model the behavior here -- the presence or 
> > > absence of an `ExprWithCleanups` is just a convenience to tell consumers 
> > > of the AST whether they should expect to see cleanups later or not, and 
> > > doesn't carry an implication of affecting the actual temporary lifetimes 
> > > and storage durations.
> > > 
> > > The outcome that we should be aiming to reach is that all 
> > > `MaterializeTemporaryExpr`s created as part of processing the 
> > > for-range-initializer are marked as being lifetime-extended by the 
> > > for-range variable. Probably the simplest way to handle that would be to 
> > > track the current enclosing for-range-initializer variable in the 
> > > `ExpressionEvaluationContextRecord`, and whenever a 
> > > `MaterializeTemporaryExpr` is created, if there is a current enclosing 
> > > for-range-initializer, mark that `MaterializeTemporaryExpr` as being 
> > > lifetime-extended by it.
> > Awesome! Thanks a lot for your advice, this is very helpful! I want to take 
> > a longer look at it.
> As mentioned in D139586, `CXXDefaultArgExpr`s may need additional handling. 
> Similarly for `CXXDefaultInitExpr`s.
Thanks for your tips! I have a question that what's the correct way to extent 
the lifetime of `CXXBindTemporaryExpr`? Can I just `materialize` the temporary? 
It may replaced by `MaterializeTemporaryExpr`, and then I can mark it as being 
lifetime-extended by the for-range variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D154290: [Clang] Implement P2741R3 - user-generated static_assert messages

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

Add tests for deleted methods and methods whose constraints are not satisfied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154290

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ODRDiagsEmitter.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/static-assert-cxx26.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -145,7 +145,7 @@
  
   User-generated static_assert messages
   https://wg21.link/P2741R3";>P2741R3
-  No
+  Clang 17
  
  
   Placeholder variables with no name
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (StringLiteral *Message = D->getMessage())
+  if (auto *Message = dyn_cast(D->getMessage()))
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
Index: clang/test/SemaCXX/static-assert-cxx26.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/static-assert-cxx26.cpp
@@ -0,0 +1,240 @@
+// RUN: %clang_cc1 -std=c++2c -fsyntax-only %s -verify
+
+static_assert(true, "");
+static_assert(true, 0); // expected-error {{the message in a static assertion must be a string literal or an object with 'data()' and 'size()' member functions}}
+struct Empty{};
+static_assert(true, Empty{}); // expected-error {{the message object in this static assertion is missing 'data()' and 'size()' member functions}}
+struct NoData {
+unsigned long size() const;
+};
+struct NoSize {
+const char* data() const;
+};
+static_assert(true, NoData{}); // expected-error {{the message object in this static assertion is missing a 'data()' member function}}
+static_assert(true, NoSize{}); // expected-error {{the message object in this static assertion is missing a 'size()' member function}}
+
+struct InvalidSize {
+const char* size() const;
+const char* data() const;
+};
+static_assert(true, InvalidSize{}); // expected-error {{the message in a static assertion must have a 'size()' member function returning an object convertible to 'std::size_t'}} \
+// expected-error {{value of type 'const char *' is not implicitly convertible to 'unsigned long'}}
+struct InvalidData {
+unsigned long size() const;
+unsigned long data() const;
+};
+static_assert(true, InvalidData{}); // expected-error {{the message in a static assertion must have a 'data()' member function returning an object convertible to 'const char*'}} \
+// expected-error {{value of type 'unsigned long' is not implicitly convertible to 'const char *'}}
+
+struct NonConstexprSize {
+unsigned long size() const; // expected-note {{declared here}}
+constexpr const char* data() const;
+};
+
+static_assert(true, NonConstexprSize{});
+static_assert(false, NonConstexprSize{}); // expected-error {{the message in a static assertion must be produced by a constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'size' cannot be used in a constant expression}}
+
+struct NonConstexprData {
+constexpr unsigned long size() const {
+return 32;
+}
+const char* data() const;  // expected-note {{declared here}}
+};
+
+static_assert(true, NonConstexprData{});
+static_assert(false, NonConstexprData{}); // expected-error {{the message in a static assertion must be produced by a constant expression}} \
+  // expected-error {{static assertion failed}} \
+  // expected-note  {{non-constexpr function 'data' cannot be used in a constant expression}}
+
+struct string_view {
+int S;
+const char* D;
+constexpr string_view(const char* Str) : S(__builtin_strlen(Str)), D(Str) {}
+constexpr string_view(int Size, const char* Str) : S(Size),

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

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

Ping.


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] D153701: [WIP][Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

2023-07-12 Thread Yurong via Phabricator via cfe-commits
yronglin marked an inline comment as done.
yronglin added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8901-8914
+  // [P2718R0] Lifetime extension in range-based for loops.
+  //
+  // 6.7.7 [class.temporary] p5:
+  // There are four contexts in which temporaries are destroyed at a different
+  // point than the end of the full-expression.
+  //
+  // 6.7.7 [class.temporary] p6:

yronglin wrote:
> hubert.reinterpretcast wrote:
> > yronglin wrote:
> > > rsmith wrote:
> > > > This isn't the right way to model the behavior here -- the presence or 
> > > > absence of an `ExprWithCleanups` is just a convenience to tell 
> > > > consumers of the AST whether they should expect to see cleanups later 
> > > > or not, and doesn't carry an implication of affecting the actual 
> > > > temporary lifetimes and storage durations.
> > > > 
> > > > The outcome that we should be aiming to reach is that all 
> > > > `MaterializeTemporaryExpr`s created as part of processing the 
> > > > for-range-initializer are marked as being lifetime-extended by the 
> > > > for-range variable. Probably the simplest way to handle that would be 
> > > > to track the current enclosing for-range-initializer variable in the 
> > > > `ExpressionEvaluationContextRecord`, and whenever a 
> > > > `MaterializeTemporaryExpr` is created, if there is a current enclosing 
> > > > for-range-initializer, mark that `MaterializeTemporaryExpr` as being 
> > > > lifetime-extended by it.
> > > Awesome! Thanks a lot for your advice, this is very helpful! I want to 
> > > take a longer look at it.
> > As mentioned in D139586, `CXXDefaultArgExpr`s may need additional handling. 
> > Similarly for `CXXDefaultInitExpr`s.
> Thanks for your tips! I have a question that what's the correct way to extent 
> the lifetime of `CXXBindTemporaryExpr`? Can I just `materialize` the 
> temporary? It may replaced by `MaterializeTemporaryExpr`, and then I can mark 
> it as being lifetime-extended by the for-range variable.
Eg.
```
void f() {
  int v[] = {42, 17, 13};
  Mutex m;
  for (int x : static_cast(LockGuard(m)), v) // lock released in C++ 2020
  {
LockGuard guard(m); // OK in C++ 2020, now deadlocks
  }
}
```
```
BinaryOperator 0x135036220 'int[3]' lvalue ','
|-CXXStaticCastExpr 0x1350361d0 'void' static_cast 
| `-CXXFunctionalCastExpr 0x135036198 'LockGuard':'struct LockGuard' functional 
cast to LockGuard 
|   `-CXXBindTemporaryExpr 0x135036178 'LockGuard':'struct LockGuard' 
(CXXTemporary 0x135036178)
| `-CXXConstructExpr 0x135036140 'LockGuard':'struct LockGuard' 'void 
(Mutex &)'
|   `-DeclRefExpr 0x135035e18 'Mutex':'class Mutex' lvalue Var 0x135035b40 
'm' 'Mutex':'class Mutex'
`-DeclRefExpr 0x135036200 'int[3]' lvalue Var 0x135035928 'v' 'int[3]'
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

___
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-12 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource added inline comments.



Comment at: clang/lib/Analysis/CFG.cpp:1936-1938
+for (LocalScope::const_iterator I = DstPos; I != BasePos; ++I)
+  if (I.pointsToFirstDeclaredVar())
+appendScopeBegin(Block, *I, S);

steakhal wrote:
> Probably, we could also use a `llvm::make_range(DstPos, BasePos)` here, but 
> I'm not sure if that's more readable or not.
We need to call iterator member function `I` here, so we cannot replace it with 
the range.



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


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

2023-07-12 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 539502.
Fznamznon added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.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
@@ -273,7 +273,6 @@
 // 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;
@@ -294,3 +293,23 @@
 }
 
 }
+
+namespace gh62863 {
+int (&&arr)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&&arr1)[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 (&&arr2)[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}}
+int (&&arr3)[3] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a 
parenthesized list of values is a C++20 extension}}
+
+int (&&arr4)[] = (int[])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&&arr5)[1] = (int[])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&&arr6)[2] = (int[])(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}}
+int (&&arr7)[3] = (int[3])(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a 
parenthesized list of values is a C++20 extension}}
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8853,6 +8853,18 @@
   }
 }
   }
+  if (isa(E)) {
+QualType DestType = E->getType();
+if (const auto *IAT = Context.getAsIncompleteArrayType(DestType)) {
+  // C++20 [expr.static.cast]p.4: ... If T is “array of unknown bound of 
U”,
+  // this direct-initialization defines the type of the expression as U[1]
+  QualType ResultType = Context.getConstantArrayType(
+  IAT->getElementType(),
+  llvm::APInt(Context.getTypeSize(Context.getSizeType()), 1),
+  /*SizeExpr=*/nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0);
+  E->setType(ResultType);
+}
+  }
 }
 
 QualType Sema::getCompletedType(Expr *E) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -591,6 +591,8 @@
   (`#38717 _`).
 - Fix an assertion when using ``\u0024`` (``$``) as an identifier, by 
disallowing
   that construct (`#62133 
_`).
+- Fixed `static_cast` to array of unknown bound.
+  (`#62863 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


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
@@ -273,7 +273,6 @@
 // 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;
@@ -294,3 +293,23 @@
 }
 
 }
+
+namespace gh62863 {
+int (&&arr)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a parenthesized list of values is a C++20 extension}}
+int (&&arr1)[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 (&&arr2)[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}}
+int (&&arr3)[3] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[3]' from a parenthesized list of values is a C++20 extension}}
+
+int (&&arr4)[] = (

[PATCH] D154716: [SemaCXX] Fix bug where unexpanded lambda captures where assumed to be expanded

2023-07-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

This looks reasonable to me.
But can you add an entry into clang/docs/ReleaseNotes.rst?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154716

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


[PATCH] D153701: [WIP][Clang] Implement P2718R0 "Lifetime extension in range-based for loops"

2023-07-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin requested changes to this revision.
cor3ntin added a comment.
This revision now requires changes to proceed.

Marking that as needing revision while the author explores the direction 
outlined by Richard :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D154963: [Format][Tooling] Fix HeaderIncludes::insert not respect the main-file header.

2023-07-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 539506.
hokein added a comment.

Make the MainFileFound stateless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154963

Files:
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Tooling/HeaderIncludesTest.cpp

Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -143,6 +143,19 @@
   EXPECT_NE(Expected, insert(Code, "")) << "Not main header";
 }
 
+TEST_F(HeaderIncludesTest, InsertMainHeader) {
+  Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
+  .IncludeStyle;
+  FileName = "fix.cpp";
+  EXPECT_EQ(R"cpp(#include "fix.h"
+#include "a.h")cpp", insert("#include \"a.h\"", "\"fix.h\""));
+
+  // Respect the original main-file header.
+  EXPECT_EQ(R"cpp(#include "z/fix.h"
+#include "a/fix.h"
+)cpp", insert("#include \"z/fix.h\"", "\"a/fix.h\""));
+}
+
 TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
   std::string Code = "#include \n"
  "\n"
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -276,6 +276,7 @@
   MaxInsertOffset(MinInsertOffset +
   getMaxHeaderInsertionOffset(
   FileName, Code.drop_front(MinInsertOffset), Style)),
+  MainIncludeFound(false),
   Categories(Style, FileName) {
   // Add 0 for main header and INT_MAX for headers that are not in any
   // category.
@@ -335,7 +336,9 @@
   // Only record the offset of current #include if we can insert after it.
   if (CurInclude.R.getOffset() <= MaxInsertOffset) {
 int Priority = Categories.getIncludePriority(
-CurInclude.Name, /*CheckMainHeader=*/FirstIncludeOffset < 0);
+CurInclude.Name, /*CheckMainHeader=*/!MainIncludeFound);
+if (Priority == 0)
+  MainIncludeFound = true;
 CategoryEndOffsets[Priority] = NextLineOffset;
 IncludesByPriority[Priority].push_back(&CurInclude);
 if (FirstIncludeOffset < 0)
@@ -362,7 +365,7 @@
   std::string(llvm::formatv(IsAngled ? "<{0}>" : "\"{0}\"", IncludeName));
   StringRef QuotedName = Quoted;
   int Priority = Categories.getIncludePriority(
-  QuotedName, /*CheckMainHeader=*/FirstIncludeOffset < 0);
+  QuotedName, /*CheckMainHeader=*/!MainIncludeFound);
   auto CatOffset = CategoryEndOffsets.find(Priority);
   assert(CatOffset != CategoryEndOffsets.end());
   unsigned InsertOffset = CatOffset->second; // Fall back offset
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -128,6 +128,8 @@
   // inserting new #includes into the actual code section (e.g. after a
   // declaration).
   unsigned MaxInsertOffset;
+  // True if we find the main-file header in the Code.
+  bool MainIncludeFound;
   IncludeCategoryManager Categories;
   // Record the offset of the end of the last include in each category.
   std::unordered_map CategoryEndOffsets;
Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -311,12 +311,9 @@
   Results = {};
   Results.Missing.push_back("\"d.h\"");
   Code = R"cpp(#include "a.h")cpp";
-  // FIXME: this isn't correct, the main-file header d.h should be added before
-  // a.h.
   EXPECT_EQ(fixIncludes(Results, "d.cc", Code, format::getLLVMStyle()),
-R"cpp(#include "a.h"
-#include "d.h"
-)cpp");
+R"cpp(#include "d.h"
+#include "a.h")cpp");
 }
 
 MATCHER_P3(expandedAt, FileID, Offset, SM, "") {
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -214,7 +214,7 @@
 })cpp");
 
   TestTU TU;
-  TU.Filename = "foo.cpp";
+  TU.Filename = "main.cpp";
   TU.AdditionalFiles["a.h"] = guard("#include \"b.h\"");
   TU.AdditionalFiles["b.h"] = guard("void b();");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154761: [clang][Interp] Diagnose callsite for implicit functions

2023-07-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin 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/D154761/new/

https://reviews.llvm.org/D154761

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


[PATCH] D154963: [Format][Tooling] Fix HeaderIncludes::insert not respect the main-file header.

2023-07-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:369-370
+  QuotedName, /*CheckMainHeader=*/!MainIncludeFound);
+  if (Priority == 0)
+MainIncludeFound = true;
   auto CatOffset = CategoryEndOffsets.find(Priority);

kadircet wrote:
> sorry if I was unclear in the previous comment. but i was trying to say we 
> should only consider includes we've encountered during the initial scan.
> 
> getting different results depending on the order of insertions being 
> performed is likely gonna cause confusion elsewhere (e.g. depending on the 
> first diagnostic you've in clangd, you'll get different order of includes). 
> hence, let's keep this function stateless (which also gets rid of the 
> concerns around mutable)
sorry for misunderstanding your comment. Make it stateless looks like a good 
idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154963

___
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-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: hubert.reinterpretcast.
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/paren-list-agg-init.cpp:276-285
+namespace gh62863 {
+int (&&arr)[] = static_cast(42);
+// beforecxx20-warning@-1 {{aggregate initialization of type 'int[1]' from a 
parenthesized list of values is a C++20 extension}}
+int (&&arr1)[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 (&&arrr2)[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}}

Fznamznon wrote:
> aaron.ballman wrote:
> > I'd like to see test coverage for:
> > ```
> > int (&&arr)[] = (int[])(42);
> > int (&&arr1)[1] = (int[])(42);
> > int (&&arrr2)[2] = (int[])(42);
> > int (&&arr3)[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.
> 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?

Correct

> 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.

MSVC and ICC both agree though, so I lean towards us being on the right path in 
allowing those casts. @hubert.reinterpretcast  -- do you have thoughts?


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] D153589: [NFC] Initialize pointer fields and remove a needless null check.

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

Can you mark this change as closed?
If you'd put "Differential Revision: https://reviews.llvm.org/D153589"; in your 
commit message this would have happened automatically.


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

https://reviews.llvm.org/D153589

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


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-07-12 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks for working on this!
I left some comments, i hope it helps!




Comment at: clang/include/clang/Sema/Sema.h:1277
+/// as PotentiallyEvaluated.
+RuntimeEvaluated
   };

I think I'd prefer a boolean for that, `ExpressionEvaluationContext` somewhat 
matches standard definitions.
I think we might mostly be able to reuse PotentiallyEvaluatedIfUsed | 
PotentiallyEvaluated.

RuntimeEvaluated is anything that does not have a parent context that is 
constant evaluated/immediate/unevaluated. Maybe you could try to make a 
function for that?



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3208-3211
 ExprResult Parser::ParseCXXMemberInitializer(Decl *D, bool IsFunction,
+ bool IsConstexpr,
  SourceLocation &EqualLoc) {
   assert(Tok.isOneOf(tok::equal, tok::l_brace) &&

I think I'd prefer casting D to a VarDecl rather than adding a parameter



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3214-3221
   EnterExpressionEvaluationContext Context(
   Actions,
   isa_and_present(D)
   ? Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed
   : Sema::ExpressionEvaluationContext::PotentiallyEvaluated,
   D);
+  Actions.ExprEvalContexts.back().InConstantEvaluated =

Maybe we should instead say that a constexpr FieldDecl is ConstantEvaluated ?
`InConstantEvaluated` in general seems redundant



Comment at: clang/lib/Parse/ParseExpr.cpp:240
   Actions, Sema::ExpressionEvaluationContext::Unevaluated);
+  Actions.ExprEvalContexts.back().InConstantEvaluated = true;
   ExprResult LHS(ParseCastExpression(AnyCastExpr));

I'd rather either get rid of `InConstantEvaluated`, or at least consider 
UnevaluatedContext as ConstantEvaluated everywhere (ie by changing 
DiagnoseTautologicalIsConstantEvaluated)



Comment at: clang/lib/Parse/ParseStmt.cpp:1513-1516
+EnterExpressionEvaluationContext Consteval(
+Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
+/*LambdaContextDecl=*/nullptr,
+Sema::ExpressionEvaluationContextRecord::EK_Other, IsConstexpr);

This seems wrong, the condition of a if statement is not constant evaluated.



Comment at: clang/lib/Sema/SemaDecl.cpp:15241-15252
+  if (!isLambdaCallOperator(FD)) {
 // [expr.const]/p14.1
 // An expression or conversion is in an immediate function context if it is
 // potentially evaluated and either: its innermost enclosing non-block 
scope
 // is a function parameter scope of an immediate function.
+
 PushExpressionEvaluationContext(

There are a bunch of white spaces only changes there



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:17962-18006
-/// Determine whether the given declaration is a global variable or
-/// static data member.
-static bool isNonlocalVariable(const Decl *D) {
-  if (const VarDecl *Var = dyn_cast_or_null(D))
-return Var->hasGlobalStorage();
-
-  return false;

Can you explain the changes to this file? they seems to affect test cases 
unrelated to the goal of this PR



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:1964
   void f() {
-constexpr int &n = n; // expected-error {{constant expression}} 
expected-note {{use of reference outside its lifetime}} expected-warning {{not 
yet bound to a value}}
 constexpr int m = m; // expected-error {{constant expression}} 
expected-note {{read of object outside its lifetime}}

This change does not seem correct


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155064

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


[PATCH] D155074: [clang][dataflow] Add a test for not explicitly initialized fields in aggregate initialization.

2023-07-12 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a project: All.
mboehme 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/D155074

Files:
  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
@@ -2940,6 +2940,39 @@
   });
 }
 
+TEST(TransferTest, AggregateInitialization_NotExplicitlyInitializedField) {
+  std::string Code = R"(
+struct S {
+  int i1;
+  int i2;
+};
+
+void target(int i) {
+  S s = { i };
+  /*[[p]]*/
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *I1FieldDecl = findValueDecl(ASTCtx, "i1");
+const ValueDecl *I2FieldDecl = findValueDecl(ASTCtx, "i2");
+
+auto &SLoc = getLocForDecl(ASTCtx, Env, "s");
+
+auto &IValue = getValueForDecl(ASTCtx, Env, "i");
+auto &I1Value =
+*cast(getFieldValue(&SLoc, *I1FieldDecl, Env));
+EXPECT_EQ(&I1Value, &IValue);
+auto &I2Value =
+*cast(getFieldValue(&SLoc, *I2FieldDecl, Env));
+EXPECT_NE(&I2Value, &IValue);
+  });
+}
+
 TEST(TransferTest, AssignToUnionMember) {
   std::string Code = R"(
 union A {


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2940,6 +2940,39 @@
   });
 }
 
+TEST(TransferTest, AggregateInitialization_NotExplicitlyInitializedField) {
+  std::string Code = R"(
+struct S {
+  int i1;
+  int i2;
+};
+
+void target(int i) {
+  S s = { i };
+  /*[[p]]*/
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const ValueDecl *I1FieldDecl = findValueDecl(ASTCtx, "i1");
+const ValueDecl *I2FieldDecl = findValueDecl(ASTCtx, "i2");
+
+auto &SLoc = getLocForDecl(ASTCtx, Env, "s");
+
+auto &IValue = getValueForDecl(ASTCtx, Env, "i");
+auto &I1Value =
+*cast(getFieldValue(&SLoc, *I1FieldDecl, Env));
+EXPECT_EQ(&I1Value, &IValue);
+auto &I2Value =
+*cast(getFieldValue(&SLoc, *I2FieldDecl, Env));
+EXPECT_NE(&I2Value, &IValue);
+  });
+}
+
 TEST(TransferTest, AssignToUnionMember) {
   std::string Code = R"(
 union A {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D155075: [clang][dataflow] Add `DataflowEnvironment::createObject()`.

2023-07-12 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

This consolidates the code used in various places to initialize objects (usually
for variables) into one central location.

It will also help reduce the number of changes needed when we make the upcoming
API changes to `AggregateStorageLocation` and `StructValue`.

Depends On D155074 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155075

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp

Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -208,62 +208,15 @@
 if (D.hasGlobalStorage())
   return;
 
-if (D.getType()->isReferenceType()) {
-  // If this is the holding variable for a `BindingDecl`, we may already
-  // have a storage location set up -- so check. (See also explanation below
-  // where we process the `BindingDecl`.)
-  if (Env.getStorageLocation(D) == nullptr) {
-const Expr *InitExpr = D.getInit();
-assert(InitExpr != nullptr);
-if (auto *InitExprLoc =
-Env.getStorageLocation(*InitExpr, SkipPast::Reference)) {
-  Env.setStorageLocation(D, *InitExprLoc);
-} else {
-  // Even though we have an initializer, we might not get an
-  // InitExprLoc, for example if the InitExpr is a CallExpr for which we
-  // don't have a function body. In this case, we just invent a storage
-  // location and value -- it's the best we can do.
-  StorageLocation &Loc =
-  Env.createStorageLocation(D.getType().getNonReferenceType());
-  Env.setStorageLocation(D, Loc);
-  if (Value *Val = Env.createValue(D.getType().getNonReferenceType()))
-Env.setValue(Loc, *Val);
-}
-  }
-} else {
-  // Not a reference type.
+// If this is the holding variable for a `BindingDecl`, we may already
+// have a storage location set up -- so check. (See also explanation below
+// where we process the `BindingDecl`.)
+if (D.getType()->isReferenceType() && Env.getStorageLocation(D) != nullptr)
+  return;
 
-  assert(Env.getStorageLocation(D) == nullptr);
-  StorageLocation &Loc = Env.createStorageLocation(D);
-  Env.setStorageLocation(D, Loc);
+assert(Env.getStorageLocation(D) == nullptr);
 
-  const Expr *InitExpr = D.getInit();
-  if (InitExpr == nullptr) {
-// No initializer expression - associate `Loc` with a new value.
-if (Value *Val = Env.createValue(D.getType()))
-  Env.setValue(Loc, *Val);
-return;
-  }
-
-  if (auto *InitExprVal = Env.getValueStrict(*InitExpr))
-Env.setValue(Loc, *InitExprVal);
-
-  if (Env.getValue(Loc) == nullptr) {
-// We arrive here in (the few) cases where an expression is
-// intentionally "uninterpreted". There are two ways to handle this
-// situation: propagate the status, so that uninterpreted initializers
-// result in uninterpreted variables, or provide a default value. We
-// choose the latter so that later refinements of the variable can be
-// used for reasoning about the surrounding code.
-//
-// FIXME. If and when we interpret all language cases, change this to
-// assert that `InitExpr` is interpreted, rather than supplying a
-// default value (assuming we don't update the environment API to return
-// references).
-if (Value *Val = Env.createValue(D.getType()))
-  Env.setValue(Loc, *Val);
-  }
-}
+Env.setStorageLocation(D, Env.createObject(D));
 
 // `DecompositionDecl` must be handled after we've interpreted the loc
 // itself, because the binding expression refers back to the
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -256,10 +256,8 @@
   for (const VarDecl *D : Vars) {
 if (getStorageLocation(*D) != nullptr)
   continue;
-auto &Loc = createStorageLocation(D->getType().getNonReferenceType());
-setStorageLocation(*D, Loc);
-if (auto *Val = createValue(D->getType().getNonReferenceType()))
-  setValue(Loc, *Val);
+
+setStorageLocation(*D, createObject(*D));
   }
 
   for (const FunctionDecl *FD : Func

[clang] 2a3322b - [clang] Create a buildkite-pipeline.yml file for clang

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

Author: Nikolas Klauser
Date: 2023-07-12T08:33:22-04:00
New Revision: 2a3322bab069166dd0da8474534d0b8dad25b949

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

LOG: [clang] Create a buildkite-pipeline.yml file for clang

This moves the formatting job to a shell script, which should also fix
the clang pre-commit CI.

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

Added: 
clang/utils/ci/buildkite-pipeline.yml
clang/utils/ci/run-buildbot

Modified: 
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
libcxx/utils/ci/generate-buildkite-pipeline

Removed: 
libcxx/utils/ci/buildkite-pipeline-clang.yml



diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index b0c1014e3c975e..531115efa64f94 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -114,7 +114,7 @@ Atom DataflowAnalysisContext::forkFlowCondition(Atom Token) 
{
   return ForkToken;
 }
 
-Atom 
+Atom
 DataflowAnalysisContext::joinFlowConditions(Atom FirstToken,
 Atom SecondToken) {
   Atom Token = arena().makeFlowConditionToken();

diff  --git a/libcxx/utils/ci/buildkite-pipeline-clang.yml 
b/clang/utils/ci/buildkite-pipeline.yml
similarity index 61%
rename from libcxx/utils/ci/buildkite-pipeline-clang.yml
rename to clang/utils/ci/buildkite-pipeline.yml
index 58cea64b0d2581..3bc4f23f8763cd 100644
--- a/libcxx/utils/ci/buildkite-pipeline-clang.yml
+++ b/clang/utils/ci/buildkite-pipeline.yml
@@ -19,7 +19,7 @@ env:
 steps:
   - label: "Format"
 commands:
-  - "! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs || 
false"
+  - "clang/utils/ci/run-buildbot check-format"
 
 agents:
   queue: "libcxx-builders"
@@ -34,15 +34,7 @@ steps:
 
   - label: "Building clang"
 commands:
-  - "mkdir install"
-  # We use Release here to avoid including debug information. Otherwise, 
the clang binary is very large, which
-  # is problematic because we need to upload the artifacts for other jobs 
to use. This may seem like nothing,
-  # but with the number of jobs we run daily, this can result in thousands 
of GB of network I/O.
-  - "cmake -S llvm -B build -G Ninja 
-DCMAKE_CXX_COMPILER_LAUNCHER=\"ccache\" -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=install -DLLVM_ENABLE_PROJECTS=\"clang;compiler-rt\""
-  - "ninja -C build install-clang install-clang-resource-headers"
-  - "ccache -s"
-  - "tar -cJvf install.tar.xz install/"
-  - "buildkite-agent artifact upload --debug install.tar.xz"
+  - "clang/utils/ci/run-buildbot build-clang"
 env:
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
@@ -59,12 +51,7 @@ steps:
 
   - label: "C++03"
 commands:
-  - "buildkite-agent artifact download install.tar.xz ."
-  - "tar -xvf install.tar.xz"
-  - "export CC=$(pwd)/install/bin/clang"
-  - "export CXX=$(pwd)/install/bin/clang++"
-  - "chmod +x install/bin/clang install/bin/clang++"
-  - "libcxx/utils/ci/run-buildbot generic-cxx03"
+  - "clang/utils/ci/run-buildbot generic-cxx03"
 artifact_paths:
   - "**/test-results.xml"
   - "**/crash_diagnostics/*"
@@ -82,12 +69,7 @@ steps:
 
   - label: "C++26"
 commands:
-  - "buildkite-agent artifact download install.tar.xz ."
-  - "tar -xvf install.tar.xz"
-  - "export CC=$(pwd)/install/bin/clang"
-  - "export CXX=$(pwd)/install/bin/clang++"
-  - "chmod +x install/bin/clang install/bin/clang++"
-  - "libcxx/utils/ci/run-buildbot generic-cxx26"
+  - "clang/utils/ci/run-buildbot generic-cxx26"
 artifact_paths:
   - "**/test-results.xml"
   - "**/crash_diagnostics/*"
@@ -105,12 +87,7 @@ steps:
 
   - label: "Modules"
 commands:
-  - "buildkite-agent artifact download install.tar.xz ."
-  - "tar -xvf install.tar.xz"
-  - "export CC=$(pwd)/install/bin/clang"
-  - "export CXX=$(pwd)/install/bin/clang++"
-  - "chmod +x install/bin/clang install/bin/clang++"
-  - "libcxx/utils/ci/run-buildbot generic-modules"
+  - "clang/utils/ci/run-buildbot generic-modules"
 artifact_paths:
   - "**/test-results.xml"
   - "**/crash_diagnostics/*"

diff  --git a/clang/utils/ci/run-buildbot b/clang/utils/ci/run-buildbot
new file mode 100755
index 00..ef3909a5babc9d
--- /dev/null
+++ b/clang/utils/ci/run-buildbot
@@ -0,0 +1,128 @@
+#!/usr/bin/env bash
+#===--===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.

[PATCH] D153920: [clang] Move the clang formatting job to run-buildbot to fix the CI

2023-07-12 Thread Louis Dionne 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 rG2a3322bab069: [clang] Create a buildkite-pipeline.yml file 
for clang (authored by philnik, committed by ldionne).

Changed prior to commit:
  https://reviews.llvm.org/D153920?vs=539183&id=539515#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153920

Files:
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/utils/ci/buildkite-pipeline.yml
  clang/utils/ci/run-buildbot
  libcxx/utils/ci/buildkite-pipeline-clang.yml
  libcxx/utils/ci/generate-buildkite-pipeline

Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -20,7 +20,7 @@
 fi
 
 if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat libcxx/utils/ci/buildkite-pipeline-clang.yml
+  cat clang/utils/ci/buildkite-pipeline.yml
 else
   cat libcxx/utils/ci/buildkite-pipeline.yml
 fi
Index: clang/utils/ci/run-buildbot
===
--- /dev/null
+++ clang/utils/ci/run-buildbot
@@ -0,0 +1,128 @@
+#!/usr/bin/env bash
+#===--===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===--===##
+
+set -ex
+set -o pipefail
+unset LANG
+unset LC_ALL
+unset LC_COLLATE
+
+PROGNAME="$(basename "${0}")"
+
+function usage() {
+cat <
+
+[-h|--help] Display this help and exit.
+
+--llvm-rootPath to the root of the LLVM monorepo. By default, we try
+to figure it out based on the current working directory.
+
+--build-dirThe directory to use for building the library. By default,
+this is '/build/'.
+EOF
+}
+
+if [[ $# == 0 ]]; then
+   usage
+   exit 0
+fi
+
+while [[ $# -gt 0 ]]; do
+case ${1} in
+-h|--help)
+usage
+exit 0
+;;
+--llvm-root)
+MONOREPO_ROOT="${2}"
+shift; shift
+;;
+--build-dir)
+BUILD_DIR="${2}"
+shift; shift
+;;
+*)
+BUILDER="${1}"
+shift
+;;
+esac
+done
+
+MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
+BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build/${BUILDER}}"
+INSTALL_DIR="${BUILD_DIR}/install"
+
+# Print the version of a few tools to aid diagnostics in some cases
+cmake --version
+ninja --version
+
+case "${BUILDER}" in
+check-format)
+! grep -rnI '[[:blank:]]$' clang/lib clang/include clang/docs
+;;
+build-clang)
+mkdir install
+# We use Release here to avoid including debug information. Otherwise, the
+# clang binary is very large, which is problematic because we need to upload
+# the artifacts for other jobs to use. This may seem like nothing, but with
+# the number of jobs we run daily, this can result in thousands of GB of
+# network I/O.
+cmake  \
+-S llvm\
+-B build   \
+-G Ninja   \
+-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \
+-DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_INSTALL_PREFIX=install \
+-DLLVM_ENABLE_PROJECTS="clang;compiler-rt" \
+
+ninja -C build install-clang install-clang-resource-headers
+ccache -s
+tar -cJvf install.tar.xz install/
+buildkite-agent artifact upload --debug install.tar.xz
+;;
+generic-cxx03)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export CXX=$(pwd)/install/bin/clang++
+chmod +x install/bin/clang install/bin/clang++
+libcxx/utils/ci/run-buildbot generic-cxx03
+;;
+generic-cxx26)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export CXX=$(pwd)/install/bin/clang++
+chmod +x install/bin/clang install/bin/clang++
+libcxx/utils/ci/run-buildbot generic-cxx26
+;;
+generic-modules)
+buildkite-agent artifact download install.tar.xz .
+tar -xvf install.tar.xz
+export CC=$(pwd)/install/bin/clang
+export

[PATCH] D155078: [ci] Make libc++ and Clang CI scripts independent

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 539526.
ldionne added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Touch a file inside Clang to test the triggering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155078

Files:
  .ci/generate-buildkite-pipeline-premerge
  .ci/generate-buildkite-pipeline-scheduled
  clang/foo
  libcxx/utils/ci/buildkite-pipeline-premerge.sh
  libcxx/utils/ci/buildkite-pipeline-snapshot.sh
  libcxx/utils/ci/generate-buildkite-pipeline

Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -9,18 +9,9 @@
 
 #
 # This script generates the appropriate libc++ CI pipeline based on which project(s) were changed.
+# TODO: Remove this once the libcxx CI pipeline uploads the buildkite-pipeline.yml file directly.
 #
 
 if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then
-  LIBCXX_CHANGED=true
-fi
-
-if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
-  CLANG_CHANGED=true
-fi
-
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat clang/utils/ci/buildkite-pipeline.yml
-else
   cat libcxx/utils/ci/buildkite-pipeline.yml
 fi
Index: libcxx/utils/ci/buildkite-pipeline-snapshot.sh
===
--- libcxx/utils/ci/buildkite-pipeline-snapshot.sh
+++ libcxx/utils/ci/buildkite-pipeline-snapshot.sh
@@ -7,18 +7,5 @@
 #
 #===--===##
 
-#
-# This file generates a Buildkite pipeline that triggers the libc++ CI jobs.
-# See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format.
-#
-# Invoked by CI on full builds.
-#
-
-cat 

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

2023-07-12 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource updated this revision to Diff 539529.
tomasz-kaminski-sonarsource marked 5 inline comments as done.
tomasz-kaminski-sonarsource added a comment.

Switched to ranges when applicable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153273

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/lifetime-cfg-output.cpp
  clang/test/Analysis/no-exit-cfg.c
  clang/test/Analysis/nonreturn-destructors-cfg-output.cpp
  clang/test/Analysis/scopes-cfg-output.cpp

Index: clang/test/Analysis/scopes-cfg-output.cpp
===
--- clang/test/Analysis/scopes-cfg-output.cpp
+++ clang/test/Analysis/scopes-cfg-output.cpp
@@ -674,30 +674,30 @@
   A f;
 }
 
-// CHECK:  [B8 (ENTRY)]
+// CHECK:  [B9 (ENTRY)]
 // CHECK-NEXT:   Succs (1): B7
 // CHECK:  [B1]
 // CHECK-NEXT:  l1:
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B1.2], A)
 // CHECK-NEXT:   2: A c;
 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   5: [B6.3].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   5: [B6.2].~A() (Implicit destructor)
 // CHECK-NEXT:   6: [B7.3].~A() (Implicit destructor)
 // CHECK-NEXT:   7: CFGScopeEnd(a)
 // CHECK-NEXT:   Preds (2): B2 B3
 // CHECK-NEXT:   Succs (1): B0
 // CHECK:  [B2]
 // CHECK-NEXT:   1:  (CXXConstructExpr, [B2.2], A)
-// CHECK-NEXT:   2: A b;
+// CHECK-NEXT:   2: A nb;
 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
-// CHECK-NEXT:   4: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   5: CFGScopeEnd(a)
+// CHECK-NEXT:   4: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   5: CFGScopeEnd(na)
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
 // CHECK:  [B3]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: CFGScopeEnd(a)
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
 // CHECK-NEXT:   T: goto l1;
 // CHECK-NEXT:   Preds (1): B4
 // CHECK-NEXT:   Succs (1): B1
@@ -708,33 +708,35 @@
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (2): B3 B2
 // CHECK:  [B5]
-// CHECK-NEXT:   1: [B6.8].~A() (Implicit destructor)
-// CHECK-NEXT:   2: [B6.5].~A() (Implicit destructor)
-// CHECK-NEXT:   3: [B6.3].~A() (Implicit destructor)
-// CHECK-NEXT:   4: CFGScopeEnd(cb)
-// CHECK-NEXT:   T: goto l0;
 // CHECK-NEXT:   Preds (1): B6
-// CHECK-NEXT:   Succs (1): B6
+// CHECK-NEXT:   Succs (1): B8
 // CHECK:  [B6]
 // CHECK-NEXT:  l0:
-// CHECK-NEXT:   1: CFGScopeBegin(cb)
-// CHECK-NEXT:   2:  (CXXConstructExpr, [B6.3], A)
-// CHECK-NEXT:   3: A cb;
-// CHECK-NEXT:   4:  (CXXConstructExpr, [B6.5], A)
-// CHECK-NEXT:   5: A b;
-// CHECK-NEXT:   6: CFGScopeBegin(a)
-// CHECK-NEXT:   7:  (CXXConstructExpr, [B6.8], A)
-// CHECK-NEXT:   8: A a;
-// CHECK-NEXT:   9: UV
-// CHECK-NEXT:  10: [B6.9] (ImplicitCastExpr, LValueToRValue, _Bool)
-// CHECK-NEXT:   T: if [B6.10]
-// CHECK-NEXT:   Preds (2): B7 B5
+// CHECK-NEXT:   1:  (CXXConstructExpr, [B6.2], A)
+// CHECK-NEXT:   2: A cb;
+// CHECK-NEXT:   3:  (CXXConstructExpr, [B6.4], A)
+// CHECK-NEXT:   4: A b;
+// CHECK-NEXT:   5: CFGScopeBegin(na)
+// CHECK-NEXT:   6:  (CXXConstructExpr, [B6.7], A)
+// CHECK-NEXT:   7: A na;
+// CHECK-NEXT:   8: UV
+// CHECK-NEXT:   9: [B6.8] (ImplicitCastExpr, LValueToRValue, _Bool)
+// CHECK-NEXT:   T: if [B6.9]
+// CHECK-NEXT:   Preds (2): B7 B8
 // CHECK-NEXT:   Succs (2): B5 B4
 // CHECK:  [B7]
 // CHECK-NEXT:   1: CFGScopeBegin(a)
 // CHECK-NEXT:   2:  (CXXConstructExpr, [B7.3], A)
 // CHECK-NEXT:   3: A a;
-// CHECK-NEXT:   Preds (1): B8
+// CHECK-NEXT:   Preds (1): B9
+// CHECK-NEXT:   Succs (1): B6
+// CHECK:  [B8]
+// CHECK-NEXT:   1: [B6.7].~A() (Implicit destructor)
+// CHECK-NEXT:   2: CFGScopeEnd(na)
+// CHECK-NEXT:   3: [B6.4].~A() (Implicit destructor)
+// CHECK-NEXT:   4: [B6.2].~A() (Implicit destructor)
+// CHECK-NEXT:   T: goto l0;
+// CHECK-NEXT:   Preds (1): B5
 // CHECK-NEXT:   Succs (1): B6
 // CHECK:  [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
@@ -743,10 +745,10 @@
 l0:
   A cb;
   A b;
-  { A a;
+  { A na;
 if (UV) goto l0;
 if (UV) goto l1;
-A b;
+A nb;
   }
 l1:
   A c;
@@ -1168,3 +1170,184 @@
 }
   }
 }
+
+// CHECK:   [B4 (ENTRY)]
+// CHECK-NEXT:Succs (1): B3
+// CHECK:   [B1]
+// CHECK-NEXT:   label:
+// CHECK-NEXT:1: CFGScopeEnd(n2t)
+// CHECK-NEXT:2: CFGScopeEnd(n1t)
+// CHECK-NEXT:3: [B3.3].~A() (Implicit destructor)
+// CHECK-NEXT:4: CFGScopeEnd(a)
+// CHECK-NEXT:Preds (2): B2 B3
+// CHECK-NEXT:Succs (1): B0
+// CHECK:   [B2]
+// CHECK-NEXT:1: [B3.9].~A() (Implicit destructor)
+// CHECK-NEXT:2: CFGScopeEnd(n2s)
+// CHECK-NEXT:3: [B3.6].~A() 

[PATCH] D138042: [libc++] Trigger both Clang and libc++ CI when there are changes to both

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne abandoned this revision.
ldionne added a comment.

This will be superseded by D155078 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138042

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


[PATCH] D141423: Trigger the Clang/libc++ CI pipeline even when libc++ has been modified

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne abandoned this revision.
ldionne added a comment.

Superseded by D155078 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141423

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


[PATCH] D155081: Specify the developer policy around links to external resources

2023-07-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rnk, lattner, doug.gregor, probinson, ldionne, 
arsenm, mehdi_amini.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

This specifies the developer policy on adding links in source & test files and 
commit messages, related to discussion at: 
https://discourse.llvm.org/t/code-review-reminder-about-links-in-code-commit-messages/71847

The intent is to discourage adding links to resources that are not available to 
the community as a whole (dead links, links to internal documentation, links to 
internal bug trackers, etc) from source and test files, while still allowing 
such links to appear in other contexts as needed. It suggests to instead add 
sufficient context in the surrounding comments to make such links unnecessary.

It also clarifies that these links can appear in commit messages as metadata 
(similar to how we already have Differential Revision and Fixes metadata with 
links).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155081

Files:
  llvm/docs/DeveloperPolicy.rst


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -201,6 +201,11 @@
   entire failing program into ``llvm/test`` as this creates a *time-to-test*
   burden on all developers. Please keep them short.
 
+* Avoid adding links to resources that are not available to the entire
+  community, such as links to private bug trackers, internal corporate
+  documentation, etc. Instead, add sufficient comments to the test to provide
+  the context behind such links.
+
 Note that llvm/test and clang/test are designed for regression and small 
feature
 tests only. More extensive test cases (e.g., entire applications, benchmarks,
 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
@@ -256,6 +261,11 @@
the change (more invasive changes require more testing). A reasonable subset
might be something like "``llvm-test/MultiSource/Benchmarks``".
 
+#. Ensure that links in source code and test files are to publicly available
+   resources and are used primarily to add additional information rather than
+   to supply critical context. The surrounding comments should be sufficient
+   to provide the context behind such links.
+
 Additionally, the committer is responsible for addressing any problems found in
 the future that the change is responsible for.  For example:
 
@@ -336,8 +346,6 @@
   code snippets and gory details should be left to bug comments, web
   review or the mailing list.
 
-* If the patch fixes a bug in GitHub Issues, please include the PR# in the 
message.
-
 * Text formatting and spelling should follow the same rules as documentation
   and in-code comments, ex. capitalization, full stop, etc.
 
@@ -346,8 +354,14 @@
   related commit. This could be as simple as "Revert commit  because it
   caused PR#".
 
-* If the patch has been reviewed, add a link to its review page, as shown
+* It is acceptable to add metadata to the commit message to automate processes.
+  If the patch fixes a bug in GitHub Issues, we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a
+  link to its review page, as shown
   `here `_.
+  Other kinds of metadata are also acceptable, including links to resources
+  that are not available to the entire community.
 
 For minor violations of these recommendations, the community normally favors
 reminding the contributor of this policy over reverting. Minor corrections and


Index: llvm/docs/DeveloperPolicy.rst
===
--- llvm/docs/DeveloperPolicy.rst
+++ llvm/docs/DeveloperPolicy.rst
@@ -201,6 +201,11 @@
   entire failing program into ``llvm/test`` as this creates a *time-to-test*
   burden on all developers. Please keep them short.
 
+* Avoid adding links to resources that are not available to the entire
+  community, such as links to private bug trackers, internal corporate
+  documentation, etc. Instead, add sufficient comments to the test to provide
+  the context behind such links.
+
 Note that llvm/test and clang/test are designed for regression and small feature
 tests only. More extensive test cases (e.g., entire applications, benchmarks,
 etc) should be added to the ``llvm-test`` test suite.  The llvm-test suite is
@@ -256,6 +261,11 @@
the change (more invasive changes require more testing). A reasonable subset
might be something like "``llvm-test/MultiSource/Benchmarks``".
 
+#. Ensure that links in source code and test files are to publicly available
+   resources and are used primarily to add additional information 

[PATCH] D155078: [ci] Make libc++ and Clang CI scripts independent

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 539534.
ldionne added a comment.

Poke CI after fixing pipeline settings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155078

Files:
  .ci/generate-buildkite-pipeline-premerge
  .ci/generate-buildkite-pipeline-scheduled
  clang/foo
  libcxx/utils/ci/buildkite-pipeline-premerge.sh
  libcxx/utils/ci/buildkite-pipeline-snapshot.sh
  libcxx/utils/ci/generate-buildkite-pipeline

Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -9,18 +9,9 @@
 
 #
 # This script generates the appropriate libc++ CI pipeline based on which project(s) were changed.
+# TODO: Remove this once the libcxx CI pipeline uploads the buildkite-pipeline.yml file directly.
 #
 
 if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then
-  LIBCXX_CHANGED=true
-fi
-
-if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
-  CLANG_CHANGED=true
-fi
-
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat clang/utils/ci/buildkite-pipeline.yml
-else
   cat libcxx/utils/ci/buildkite-pipeline.yml
 fi
Index: libcxx/utils/ci/buildkite-pipeline-snapshot.sh
===
--- libcxx/utils/ci/buildkite-pipeline-snapshot.sh
+++ libcxx/utils/ci/buildkite-pipeline-snapshot.sh
@@ -7,18 +7,5 @@
 #
 #===--===##
 
-#
-# This file generates a Buildkite pipeline that triggers the libc++ CI jobs.
-# See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format.
-#
-# Invoked by CI on full builds.
-#
-
-cat 

[PATCH] D155081: Specify the developer policy around links to external resources

2023-07-12 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/docs/DeveloperPolicy.rst:359
+  If the patch fixes a bug in GitHub Issues, we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a

I haven't quite figured out what the exact syntaxes which are automatically 
recognized. It seems to recognize "Fixes #Nxyz"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155081

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


[clang] fb9a741 - [CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions

2023-07-12 Thread Chris Bowler via cfe-commits

Author: Alex Gatea
Date: 2023-07-12T09:29:11-04:00
New Revision: fb9a74122ef7730ae9839c63c4b7e9a78549d8e6

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

LOG: [CodeGen][NFCI] Avoid calls to setTargetAttributes on definitions

Avoid duplicate calls to setTargetAttributes on global variable definitions.

Differential: https://reviews.llvm.org/D153903

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 13b49eb577a703..d8a45e4dcb3064 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4765,7 +4765,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef 
MangledName, llvm::Type *Ty,
 }
   }
 
-  if (GV->isDeclaration()) {
+  if (D &&
+  D->isThisDeclarationADefinition(Context) == VarDecl::DeclarationOnly) {
 getTargetCodeGenInfo().setTargetAttributes(D, GV, *this);
 // External HIP managed variables needed to be recorded for transformation
 // in both device and host compilations.



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


[PATCH] D155081: Specify the developer policy around links to external resources

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



Comment at: llvm/docs/DeveloperPolicy.rst:359
+  If the patch fixes a bug in GitHub Issues, we encourage adding
+  "Fixes https://github.com/llvm/llvm-project/issues/12345"; to automate closing
+  the issue in GitHub. If the patch has been reviewed, we encourage adding a

arsenm wrote:
> I haven't quite figured out what the exact syntaxes which are automatically 
> recognized. It seems to recognize "Fixes #Nxyz"
Yup, it does support that form as well. I had heard more than once during code 
review that folks seem to prefer the full link because it's easier to click on 
that from the commit message than it is to navigate to the fix from the number 
alone. That seemed like a pretty good reason to recommend the full form, but I 
don't have strong opinions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155081

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


[PATCH] D155078: [ci] Make libc++ and Clang CI scripts independent

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Ok, this is ready to go. More context around this change:

I created a clang-specific CI pipeline 
(https://buildkite.com/llvm-project/clang-ci) and Clang CI jobs will now 
trigger inside that pipeline instead of inside the libc++ pipeline 
(https://buildkite.com/llvm-project/libcxx-ci). The problem this solves is that 
90% of the jobs of the libc++ CI pipelines are otherwise Clang jobs, which 
makes it nearly impossible for libc++ to figure out information about the jobs 
we're actually running.

- For now, this does not have any impact on the fact that Clang CI is still 
utilizing libc++ resources (although this is next on my list of things to 
address).
- This doesn't have any impact on whether we'll eventually want to move to 
Github Actions or some other CI system. This simply fixes the current system 
before the LLVM 17 release. In particular, I would like to avoid bikeshedding 
the location of the `generate-buildkite-pipeline` scripts under `.ci` -- it 
doesn't matter, I just wanted a neutral (non-libcxx-specific) location and that 
can be changed later once CI is out of constant-red.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155078

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


[clang] 91f886a - [FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by default.

2023-07-12 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2023-07-12T09:55:53-04:00
New Revision: 91f886a40d3fbabfc539c2bd8977a1ccb45aa450

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

LOG: [FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by 
default.

In D146869 @arsenm pointed out that the constrained intrinsics aren't
getting the strictfp attribute by default. They should be since they are
required to have it anyway.

TableGen did not know about this attribute until now. This patch adds
strictfp to TableGen, and it uses it on all of the constrained intrinsics.

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

Added: 
llvm/test/Assembler/fp-intrinsics-attr.ll

Modified: 
clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
llvm/include/llvm/IR/Intrinsics.td
llvm/test/Verifier/fp-intrinsics-pass.ll
llvm/utils/TableGen/CodeGenIntrinsics.cpp
llvm/utils/TableGen/CodeGenIntrinsics.h
llvm/utils/TableGen/IntrinsicEmitter.cpp

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl 
b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
index e7433787c89c88..605790164a7898 100644
--- a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
@@ -171,7 +171,7 @@ kernel void device_side_enqueue(global float *a, global 
float *b, int i) {
 // STRICTFP: attributes #[[ATTR0]] = { convergent noinline norecurse nounwind 
optnone strictfp "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="false" }
 // STRICTFP: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nounwind 
willreturn memory(argmem: readwrite) }
 // STRICTFP: attributes #[[ATTR2]] = { convergent noinline nounwind optnone 
strictfp "stack-protector-buffer-size"="8" }
-// STRICTFP: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync 
nounwind willreturn memory(inaccessiblemem: readwrite) }
+// STRICTFP: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync 
nounwind strictfp willreturn memory(inaccessiblemem: readwrite) }
 // STRICTFP: attributes #[[ATTR4]] = { convergent nounwind 
"stack-protector-buffer-size"="8" }
 // STRICTFP: attributes #[[ATTR5]] = { strictfp }
 //.

diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index 0779d1fd958f60..638a9fda29b15c 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1099,7 +1099,11 @@ def int_is_fpclass
 //===--- Constrained Floating Point Intrinsics 
===//
 //
 
-let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
+/// IntrStrictFP - The intrinsic is allowed to be used in an alternate
+/// floating point environment.
+def IntrStrictFP : IntrinsicProperty;
+
+let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn, IntrStrictFP] 
in {
   def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ 
llvm_anyfloat_ty ],
 [ LLVMMatchType<0>,
   LLVMMatchType<0>,

diff  --git a/llvm/test/Assembler/fp-intrinsics-attr.ll 
b/llvm/test/Assembler/fp-intrinsics-attr.ll
new file mode 100644
index 00..6546d1a275c99f
--- /dev/null
+++ b/llvm/test/Assembler/fp-intrinsics-attr.ll
@@ -0,0 +1,318 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; Test to verify that constrained intrinsics all have the strictfp attribute.
+; Ordering is from Intrinsics.td.
+
+define void @func(double %a, double %b, double %c, i32 %i) strictfp {
+; CHECK-LABEL: define void @func
+; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]], double [[C:%.*]], i32 
[[I:%.*]]) #[[ATTR0:[0-9]+]] {
+
+  %add = call double @llvm.experimental.constrained.fadd.f64(
+   double %a, double %b,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict")
+
+  %sub = call double @llvm.experimental.constrained.fsub.f64(
+   double %a, double %b,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict")
+
+  %mul = call double @llvm.experimental.constrained.fmul.f64(
+   double %a, double %b,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict")
+
+  %div = call double @llvm.experimental.constrained.fdiv.f64(
+   double %a, double %b,
+   

[PATCH] D154991: [FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by default.

2023-07-12 Thread Kevin P. Neal 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 rG91f886a40d3f: [FPEnv][TableGen] Add strictfp attribute to 
constrained intrinsics by default. (authored by kpn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154991

Files:
  clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
  llvm/include/llvm/IR/Intrinsics.td
  llvm/test/Assembler/fp-intrinsics-attr.ll
  llvm/test/Verifier/fp-intrinsics-pass.ll
  llvm/utils/TableGen/CodeGenIntrinsics.cpp
  llvm/utils/TableGen/CodeGenIntrinsics.h
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -388,6 +388,9 @@
   if (L->hasSideEffects != R->hasSideEffects)
 return R->hasSideEffects;
 
+  if (L->isStrictFP != R->isStrictFP)
+return R->isStrictFP;
+
   // Try to order by readonly/readnone attribute.
   uint32_t LK = L->ME.toIntValue();
   uint32_t RK = R->ME.toIntValue();
@@ -522,6 +525,8 @@
   OS << "  Attribute::get(C, Attribute::Convergent),\n";
 if (Intrinsic.isSpeculatable)
   OS << "  Attribute::get(C, Attribute::Speculatable),\n";
+if (Intrinsic.isStrictFP)
+  OS << "  Attribute::get(C, Attribute::StrictFP),\n";
 
 MemoryEffects ME = Intrinsic.ME;
 // TODO: IntrHasSideEffects should affect not only readnone intrinsics.
@@ -594,7 +599,8 @@
 Intrinsic.isNoReturn || Intrinsic.isNoCallback || Intrinsic.isNoSync ||
 Intrinsic.isNoFree || Intrinsic.isWillReturn || Intrinsic.isCold ||
 Intrinsic.isNoDuplicate || Intrinsic.isNoMerge ||
-Intrinsic.isConvergent || Intrinsic.isSpeculatable) {
+Intrinsic.isConvergent || Intrinsic.isSpeculatable ||
+Intrinsic.isStrictFP) {
   unsigned ID = UniqFnAttributes.find(&Intrinsic)->second;
   OS << "  AS[" << numAttrs++ << "] = {AttributeList::FunctionIndex, "
  << "getIntrinsicFnAttributeSet(C, " << ID << ")};\n";
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
===
--- llvm/utils/TableGen/CodeGenIntrinsics.h
+++ llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -103,6 +103,9 @@
   // True if the intrinsic is marked as speculatable.
   bool isSpeculatable;
 
+  // True if the intrinsic is marked as strictfp.
+  bool isStrictFP;
+
   enum ArgAttrKind {
 NoCapture,
 NoAlias,
Index: llvm/utils/TableGen/CodeGenIntrinsics.cpp
===
--- llvm/utils/TableGen/CodeGenIntrinsics.cpp
+++ llvm/utils/TableGen/CodeGenIntrinsics.cpp
@@ -74,6 +74,7 @@
   isConvergent = false;
   isSpeculatable = false;
   hasSideEffects = false;
+  isStrictFP = false;
 
   if (DefName.size() <= 4 || DefName.substr(0, 4) != "int_")
 PrintFatalError(DefLoc,
@@ -203,6 +204,8 @@
 isSpeculatable = true;
   else if (R->getName() == "IntrHasSideEffects")
 hasSideEffects = true;
+  else if (R->getName() == "IntrStrictFP")
+isStrictFP = true;
   else if (R->isSubClassOf("NoCapture")) {
 unsigned ArgNo = R->getValueAsInt("ArgNo");
 addArgAttribute(ArgNo, NoCapture);
Index: llvm/test/Verifier/fp-intrinsics-pass.ll
===
--- llvm/test/Verifier/fp-intrinsics-pass.ll
+++ llvm/test/Verifier/fp-intrinsics-pass.ll
@@ -1,7 +1,7 @@
 ; RUN: opt -passes=verify -S < %s 2>&1 | FileCheck %s
 
-declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #0
-declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #0
+declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
+declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
 
 ; Test that the verifier accepts legal code, and that the correct attributes are
 ; attached to the FP intrinsic. The attributes are checked at the bottom.
@@ -9,35 +9,34 @@
 ; CHECK: declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #[[ATTR]]
 ; Note: FP exceptions aren't usually caught through normal unwind mechanisms,
 ;   but we may want to revisit this for asynchronous exception handling.
-define double @f1(double %a, double %b) #0 {
+define double @f1(double %a, double %b) strictfp {
 ; CHECK-LABEL: define double @f1
-; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR1:[0-9]+]] {
+; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[STRICTFP:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[FADD:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[A]], double [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR1]]
+; CHECK-NEXT:[[FADD:%.*]] 

[PATCH] D154869: [Flang] [FlangRT] Implement FlangRT library as solution to Flang's runtime LLVM integration

2023-07-12 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 539545.
pscoro added a comment.

Small changes, flang-rt seems to work with the flang-new driver now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154869

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  flang-rt/CMakeLists.txt
  flang-rt/src/dummy.cpp
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/include/flang/Runtime/float128.h
  flang/lib/Decimal/CMakeLists.txt
  flang/runtime/CMakeLists.txt
  flang/test/CMakeLists.txt
  flang/test/Driver/linker-flags.f90
  flang/test/lit.cfg.py
  flang/tools/flang-driver/CMakeLists.txt
  lld/COFF/MinGW.cpp
  llvm/CMakeLists.txt
  llvm/projects/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -19,7 +19,7 @@
 
 # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
 # on libc++, so we put it after.
-set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp")
+set(LLVM_DEFAULT_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;flang-rt")
 set(LLVM_SUPPORTED_RUNTIMES "${LLVM_DEFAULT_RUNTIMES};llvm-libgcc")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
Index: llvm/projects/CMakeLists.txt
===
--- llvm/projects/CMakeLists.txt
+++ llvm/projects/CMakeLists.txt
@@ -6,6 +6,7 @@
   if(IS_DIRECTORY ${entry} AND EXISTS ${entry}/CMakeLists.txt)
 if((NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/compiler-rt) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/dragonegg) AND
+   (NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/flang-rt) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxx) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libcxxabi) AND
(NOT ${entry} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}/libunwind) AND
@@ -42,6 +43,8 @@
 add_llvm_external_project(dragonegg)
 add_llvm_external_project(openmp)
 
+add_llvm_external_project(flang-rt)
+
 if(LLVM_INCLUDE_TESTS)
   add_llvm_external_project(cross-project-tests)
 endif()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -149,7 +149,10 @@
 # As we migrate runtimes to using the bootstrapping build, the set of default runtimes
 # should grow as we remove those runtimes from LLVM_ENABLE_PROJECTS above.
 set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind")
-set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc")
+if ("flang" IN_LIST LLVM_ENABLE_PROJECTS)
+  set(LLVM_DEFAULT_RUNTIMES "libcxx;libcxxabi;libunwind;flang-rt")
+endif()
+set(LLVM_SUPPORTED_RUNTIMES "libc;libunwind;libcxxabi;pstl;libcxx;compiler-rt;openmp;llvm-libgcc;flang-rt")
 set(LLVM_ENABLE_RUNTIMES "" CACHE STRING
   "Semicolon-separated list of runtimes to build, or \"all\" (${LLVM_DEFAULT_RUNTIMES}). Supported runtimes are ${LLVM_SUPPORTED_RUNTIMES}.")
 if(LLVM_ENABLE_RUNTIMES STREQUAL "all")
Index: lld/COFF/MinGW.cpp
===
--- lld/COFF/MinGW.cpp
+++ lld/COFF/MinGW.cpp
@@ -50,8 +50,7 @@
   "libc++",
   "libc++abi",
   "libFortran_main",
-  "libFortranRuntime",
-  "libFortranDecimal",
+  "libflang-rt",
   "libunwind",
   "libmsvcrt",
   "libucrtbase",
Index: flang/tools/flang-driver/CMakeLists.txt
===
--- flang/tools/flang-driver/CMakeLists.txt
+++ flang/tools/flang-driver/CMakeLists.txt
@@ -19,8 +19,7 @@
   # These libraries are used in the linker invocation generated by the driver
   # (i.e. when constructing the linker job). Without them the driver would be
   # unable to generate executables.
-  FortranRuntime
-  FortranDecimal
+  flang-rt
   Fortran_main
 )
 
Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -153,19 +153,16 @@
 # the C++ runtime libraries. For this we need a C compiler. If for some reason
 # we don't have one, we can just disable the test.
 if config.cc:
-libruntime = os.path.join(config.flang_lib_dir, "libFortranRuntime.a")
-libdecimal = os.path.join(config.flang_lib_dir, "libFortranDecimal.a")
+libruntime = os.path.join(config.flang_lib_dir, "libflang-rt.a")
 include = os.path.join(config.flang_src_dir, "include")
 
 if (
 os.path.isfile(libruntime)
-and os.path.isfile(libdecimal)
 and os.path.isdir(include)
 ):
 config.available_features.add("c-compile

[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as` on AIX

2023-07-12 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 updated this revision to Diff 539544.
qiongsiwu1 added a comment.

Address test case review comments. Thanks so much @MaskRay for the feedback!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152924

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto-aix.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/test/tools/llvm-lto/aix.ll
  llvm/tools/llc/llc.cpp

Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -106,10 +106,6 @@
  "'none' means that all ELF features can be used, "
  "regardless of binutils support"));
 
-static cl::opt
-NoIntegratedAssembler("no-integrated-as", cl::Hidden,
-  cl::desc("Disable integrated assembler"));
-
 static cl::opt
 PreserveComments("preserve-as-comments", cl::Hidden,
  cl::desc("Preserve Comments in outputted assembly"),
@@ -517,7 +513,6 @@
 
 Options.BinutilsVersion =
 TargetMachine::parseBinutilsVersion(BinutilsVersion);
-Options.DisableIntegratedAS = NoIntegratedAssembler;
 Options.MCOptions.ShowMCEncoding = ShowMCEncoding;
 Options.MCOptions.AsmVerbose = AsmVerbose;
 Options.MCOptions.PreserveAsmComments = PreserveComments;
Index: llvm/test/tools/llvm-lto/aix.ll
===
--- llvm/test/tools/llvm-lto/aix.ll
+++ llvm/test/tools/llvm-lto/aix.ll
@@ -1,7 +1,11 @@
-; REQUIRES: system-aix
+; REQUIRES: powerpc-registered-target
+; RUN: rm -rf %t && mkdir %t && cd %t
 ; RUN: llvm-as < %s > %t1
 ; RUN: llvm-lto %t1 | FileCheck %s
 
+; Test system assembler.
+; RUN: %if system-aix %{ llvm-lto -no-integrated-as=1 %t1 | FileCheck %s %}
+
 target triple = "powerpc-ibm-aix"
 
 define i32 @main() {
@@ -9,4 +13,3 @@
   ret i32 42
 }
 ; CHECK: Wrote native object file
-
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -244,7 +244,7 @@
 
 bool LTOCodeGenerator::useAIXSystemAssembler() {
   const auto &Triple = TargetMach->getTargetTriple();
-  return Triple.isOSAIX();
+  return Triple.isOSAIX() && Config.Options.DisableIntegratedAS;
 }
 
 bool LTOCodeGenerator::runAIXSystemAssembler(SmallString<128> &AssemblyFile) {
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -81,6 +81,7 @@
 CGOPT(bool, StackRealign)
 CGOPT(std::string, TrapFuncName)
 CGOPT(bool, UseCtors)
+CGOPT(bool, DisableIntegratedAS)
 CGOPT(bool, RelaxELFRelocations)
 CGOPT_EXP(bool, DataSections)
 CGOPT_EXP(bool, FunctionSections)
@@ -487,6 +488,11 @@
   cl::init(false));
   CGBINDOPT(XCOFFReadOnlyPointers);
 
+  static cl::opt DisableIntegratedAS(
+  "no-integrated-as", cl::desc("Disable integrated assembler"),
+  cl::init(false));
+  CGBINDOPT(DisableIntegratedAS);
+
 #undef CGBINDOPT
 
   mc::RegisterMCTargetOptionsFlags();
@@ -540,6 +546,7 @@
   Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
   Options.StackSymbolOrdering = getStackSymbolOrdering();
   Options.UseInitArray = !getUseCtors();
+  Options.DisableIntegratedAS = getDisableIntegratedAS();
   Options.RelaxELFRelocations = getRelaxELFRelocations();
   Options.DataSections =
   getExplicitDataSections().value_or(TheTriple.hasDefaultDataSections());
Index: llvm/include/llvm/CodeGen/CommandFlags.h
===
--- llvm/include/llvm/CodeGen/CommandFlags.h
+++ llvm/include/llvm/CodeGen/CommandFlags.h
@@ -94,6 +94,8 @@
 
 bool getUseCtors();
 
+bool getDisableIntegratedAS();
+
 bool getRelaxELFRelocations();
 
 bool getDataSections();
Index: clang/test/Driver/lto-aix.c
===
--- clang/test/Driver/lto-aix.c
+++ clang/test/Driver/lto-aix.c
@@ -4,7 +4,7 @@
 //
 // LTOPATH: "-bplugin:{{.*}}libLTO.{{so|dll|dylib}}"
 // MCPUOPTLEVEL: "-bplugin_opt:-mcpu={{.*}}" "-bplugin_opt:-O3"
-//
+
 // More opt level option tests
 // RUN: %clang --target=powerpc-ibm-aix --sysroot %S/Inputs/aix_ppc_tree %s \
 // RUN:   -fuse-ld=ld -flto -O -### 2>&1 | FileCheck --check-prefix=O1 %s
@@ -26,7 +26,7 @@
 // O1: "-bplugin_opt:-O1"
 // O2: "-bplugin_opt:-O2"
 // O3: "-bplugin_opt:-O3"
-//
+
 // vec-extabi option
 // RUN: %clang --target=powerpc-ibm-aix --sysroot %S/Inputs/aix_ppc_tree %s \
 // RUN:   -fuse-ld=ld -flto -mabi=vec-extabi -### 2>&1 \
@@ -36,7 +36,7 @@
 //
 // VECEXTABI: "-bplugin_opt:-vec-extabi"
 // NOVECEXTABI-NOT: "-bplugin_opt:-vec-extabi"
-//
+
 // Test debugging options
 // RUN:

[PATCH] D155084: [analyzer] Fix crash in MoveChecker when it tries to report duplicate issue.

2023-07-12 Thread Tomasz Kamiński via Phabricator via cfe-commits
tomasz-kaminski-sonarsource created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
tomasz-kaminski-sonarsource requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The 'MoveChecker' was missing the check if the error node was
successfully generated (non-null value was returned). This happens
if duplicate of the report is emitted.

This patch contains NFC, where 'reportBug' is renamed to 'tryReportBug',
to better indicated conditional behavior of function.

Author: Arseniy Zaostrovnykh 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155084

Files:
  clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -213,8 +213,9 @@
 
   // Returns the exploded node against which the report was emitted.
   // The caller *must* add any further transitions against this node.
-  ExplodedNode *reportBug(const MemRegion *Region, const CXXRecordDecl *RD,
-  CheckerContext &C, MisuseKind MK) const;
+  // Returns nullptr and does not report if such node already exists.
+  ExplodedNode *tryToReportBug(const MemRegion *Region, const CXXRecordDecl 
*RD,
+   CheckerContext &C, MisuseKind MK) const;
 
   bool isInMoveSafeContext(const LocationContext *LC) const;
   bool isStateResetMethod(const CXXMethodDecl *MethodDec) const;
@@ -377,19 +378,20 @@
 return;
   }
 
-  ExplodedNode *N = reportBug(Region, RD, C, MK);
+  ExplodedNode *N = tryToReportBug(Region, RD, C, MK);
 
   // If the program has already crashed on this path, don't bother.
-  if (N->isSink())
+  if (!N || N->isSink())
 return;
 
   State = State->set(Region, RegionState::getReported());
   C.addTransition(State, N);
 }
 
-ExplodedNode *MoveChecker::reportBug(const MemRegion *Region,
- const CXXRecordDecl *RD, CheckerContext 
&C,
- MisuseKind MK) const {
+ExplodedNode *MoveChecker::tryToReportBug(const MemRegion *Region,
+  const CXXRecordDecl *RD,
+  CheckerContext &C,
+  MisuseKind MK) const {
   if (ExplodedNode *N = misuseCausesCrash(MK) ? C.generateErrorNode()
   : C.generateNonFatalErrorNode()) 
{
 // Uniqueing report to the same object.


Index: clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MoveChecker.cpp
@@ -213,8 +213,9 @@
 
   // Returns the exploded node against which the report was emitted.
   // The caller *must* add any further transitions against this node.
-  ExplodedNode *reportBug(const MemRegion *Region, const CXXRecordDecl *RD,
-  CheckerContext &C, MisuseKind MK) const;
+  // Returns nullptr and does not report if such node already exists.
+  ExplodedNode *tryToReportBug(const MemRegion *Region, const CXXRecordDecl *RD,
+   CheckerContext &C, MisuseKind MK) const;
 
   bool isInMoveSafeContext(const LocationContext *LC) const;
   bool isStateResetMethod(const CXXMethodDecl *MethodDec) const;
@@ -377,19 +378,20 @@
 return;
   }
 
-  ExplodedNode *N = reportBug(Region, RD, C, MK);
+  ExplodedNode *N = tryToReportBug(Region, RD, C, MK);
 
   // If the program has already crashed on this path, don't bother.
-  if (N->isSink())
+  if (!N || N->isSink())
 return;
 
   State = State->set(Region, RegionState::getReported());
   C.addTransition(State, N);
 }
 
-ExplodedNode *MoveChecker::reportBug(const MemRegion *Region,
- const CXXRecordDecl *RD, CheckerContext &C,
- MisuseKind MK) const {
+ExplodedNode *MoveChecker::tryToReportBug(const MemRegion *Region,
+  const CXXRecordDecl *RD,
+  CheckerContext &C,
+  MisuseKind MK) const {
   if (ExplodedNode *N = misuseCausesCrash(MK) ? C.generateErrorNode()
   : C.generateNonFatalErrorNode()) {
 // Uniqueing report to the same object.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-07-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/stream-note.c:61-62
   FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F1)

balazske wrote:
> steakhal wrote:
> > Why are these notes doubled?
> There are 2 cases of resource leak reported (for `F1` and `F2`) and a note 
> tag is there for both of these.
I still think we should only have a single note there given that `F2` is 
completely unrelated to the initialization of `F1`.
Do I miss something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D153612: [clang][analyzer] Add and change NoteTags in StdLibraryFunctionsChecker.

2023-07-12 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/test/Analysis/stream-note.c:61-62
   FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
+  // stdargs-note@-1 {{'fopen' is successful}}
+  // stdargs-note@-2 {{'fopen' is successful}}
   if (!F1)

steakhal wrote:
> balazske wrote:
> > steakhal wrote:
> > > Why are these notes doubled?
> > There are 2 cases of resource leak reported (for `F1` and `F2`) and a note 
> > tag is there for both of these.
> I still think we should only have a single note there given that `F2` is 
> completely unrelated to the initialization of `F1`.
> Do I miss something?
Oo, now I see. D153776 is supposed to fix limit the notes to be displayed only 
for the interesting values. nvm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153612

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


[PATCH] D155078: [ci] Make libc++ and Clang CI scripts independent

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 539553.
ldionne added a comment.

Poke CI after fixing Clang CI pipeline clone URL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155078

Files:
  .ci/generate-buildkite-pipeline-premerge
  .ci/generate-buildkite-pipeline-scheduled
  clang/foo
  libcxx/utils/ci/buildkite-pipeline-premerge.sh
  libcxx/utils/ci/buildkite-pipeline-snapshot.sh
  libcxx/utils/ci/generate-buildkite-pipeline

Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -9,18 +9,9 @@
 
 #
 # This script generates the appropriate libc++ CI pipeline based on which project(s) were changed.
+# TODO: Remove this once the libcxx CI pipeline uploads the buildkite-pipeline.yml file directly.
 #
 
 if git diff --name-only HEAD~1 | grep -q -E "^libcxx/|^libcxxabi/|^libunwind/|^runtimes/|^cmake/"; then
-  LIBCXX_CHANGED=true
-fi
-
-if git diff --name-only HEAD~1 | grep -q -E "^clang/"; then
-  CLANG_CHANGED=true
-fi
-
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
-  cat clang/utils/ci/buildkite-pipeline.yml
-else
   cat libcxx/utils/ci/buildkite-pipeline.yml
 fi
Index: libcxx/utils/ci/buildkite-pipeline-snapshot.sh
===
--- libcxx/utils/ci/buildkite-pipeline-snapshot.sh
+++ libcxx/utils/ci/buildkite-pipeline-snapshot.sh
@@ -7,18 +7,5 @@
 #
 #===--===##
 
-#
-# This file generates a Buildkite pipeline that triggers the libc++ CI jobs.
-# See https://buildkite.com/docs/agent/v3/cli-pipeline#pipeline-format.
-#
-# Invoked by CI on full builds.
-#
-
-cat 

[PATCH] D142569: [OpenMP] Introduce kernel environment

2023-07-12 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

How does a function find the corresponding kernel environment at runtime?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

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


[PATCH] D4784: [clang-tidy] Add check for possibly incomplete switch statements

2023-07-12 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 539558.
xgupta edited the summary of this revision.
xgupta added a comment.

Address some comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D4784

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/switch-missing-default-case.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/switch-missing-default-case.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/switch-missing-default-case.cpp
@@ -0,0 +1,27 @@
+// RUN: clang-tidy --checks='-*,misc-incomplete-switch' %s -- | FileCheck -implicit-check-not="{{warning|error}}:" %s
+
+void Positive() {
+  int i = 0;
+  // CHECK: [[@LINE+1]]:11: warning: switching on non-enum value without default case may not cover all cases [misc-incomplete-switch]
+  switch (i) {
+  case 0:
+break;
+  }
+}
+
+void Negative() {
+  enum E { eE1 };
+  E e = eE1;
+  switch (e) { // no-warning
+  case eE1:
+break;
+  }
+
+  int i = 0;
+  switch (i) { // no-warning
+  case 0:
+break;
+  default:
+break;
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -92,6 +92,7 @@
`bugprone-forwarding-reference-overload `_,
`bugprone-implicit-widening-of-multiplication-result `_, "Yes"
`bugprone-inaccurate-erase `_, "Yes"
+   `bugprone-switch-missing-default-case `_, "Yes"
`bugprone-incorrect-roundings `_,
`bugprone-infinite-loop `_,
`bugprone-integer-division `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -219,6 +219,11 @@
   Enforces consistent token representation for invoked binary, unary and
   overloaded operators in C++ code.
 
+- New :doc:`bugprone-switch-missing-default-case
+  ` check.
+
+  Detects incomplete switch statements without a default case.
+
 New check aliases
 ^
 
Index: clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.h
@@ -0,0 +1,29 @@
+//===--- SwitchMissingDefaultCaseCheck.h - clang-tidy ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWITCHMISSINGDEFAULTCASECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWITCHMISSINGDEFAULTCASECHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+
+namespace clang::tidy::bugprone {
+
+class SwitchMissingDefaultCaseCheck : public ClangTidyCheck {
+public:
+  SwitchMissingDefaultCaseCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace clang::tidy::bugprone
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SWITCHMISSINGDEFAULTCASECHECK_H
Index: clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
@@ -0,0 +1,36 @@
+//===--- SwitchMissingDefaultCaseCheck.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "SwitchMissingDefaultCaseCheck.h"
+#include "clang/AST/ASTContext.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void SwitchMissingDefaultCaseCheck::registerMatchers(
+ast_matchers::MatchFinder *Finder) {
+  Finder->addMatcher(
+  switchStmt(has(implici

[PATCH] D155078: [ci] Make libc++ and Clang CI scripts independent

2023-07-12 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

I like this a lot! LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155078

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


[PATCH] D154999: [clang-tidy] Add bugprone-std-forward-type-mismatch check

2023-07-12 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/std-forward-type-mismatch.rst:28
+is a mismatch between the type passed as an argument and the template 
parameter.
+

Excessive newline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154999

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


[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-07-12 Thread Fred Fu via Phabricator via cfe-commits
capfredf marked 5 inline comments as done.
capfredf added inline comments.



Comment at: clang/include/clang/Interpreter/Interpreter.h:117
   ASTContext &getASTContext();
+  void CodeComplete(llvm::StringRef Input, size_t Col, size_t Line = 1);
   const CompilerInstance *getCompilerInstance() const;

v.g.vassilev wrote:
> I could not find where this interface was used. If it is unused, let'd drop 
> it.
it is used at L86 of CodeCompletion.cpp



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:376
   // Create FileID for the current buffer.
-  FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, /*LoadedID=*/0,
-   /*LoadedOffset=*/0, NewLoc);
+  // FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, 
/*LoadedID=*/0,
+  //  /*LoadedOffset=*/0, NewLoc);

v.g.vassilev wrote:
> Why we had to comment out this line?
This is old code. `FID` is created in a different way. See below. 
I will remove the commented code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


[PATCH] D154784: [clang] Fix crash caused by PseudoObjectExprBitfields::NumSubExprs overflow

2023-07-12 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 539563.
yronglin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154784

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Stmt.h
  clang/test/SemaCXX/builtin-dump-struct.cpp


Index: clang/test/SemaCXX/builtin-dump-struct.cpp
===
--- clang/test/SemaCXX/builtin-dump-struct.cpp
+++ clang/test/SemaCXX/builtin-dump-struct.cpp
@@ -159,3 +159,28 @@
 // expected-note@#Format {{no known 
conversion from 'int' to 'ConstexprString &' for 1st argument}}
 }
 #endif
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow. This
+// would previously cause a crash.
+struct t1 {
+  int v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, 
v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, 
v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, 
v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, 
v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, 
v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, 
v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+struct t2 {
+  t1 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, 
v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, 
v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, 
v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, 
v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, 
v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+int printf(const char *, ...);
+void f1(t2 w) { __builtin_dump_struct(&w, printf); }
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -593,10 +593,8 @@
 
 unsigned : NumExprBits;
 
-// These don't need to be particularly wide, because they're
-// strictly limited by the forms of expressions we permit.
-unsigned NumSubExprs : 8;
-unsigned ResultIndex : 32 - 8 - NumExprBits;
+unsigned NumSubExprs : 16;
+unsigned ResultIndex : 16;
   };
 
   class SourceLocExprBitfields {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -591,6 +591,8 @@
   (`#38717 _`).
 - Fix an assertion when using ``\u0024`` (``$``) as an identifier, by 
disallowing
   that construct (`#62133 
_`).
+- Fix crash caused by PseudoObjectExprBitfields: NumSubExprs overflow.
+  (`#63169 _`)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/SemaCXX/builtin-dump-struct.cpp
===
--- clang/test/SemaCXX/builtin-dump-struct.cpp
+++ clang/test/SemaCXX/builtin-dump-struct.cpp
@@ -159,3 +159,28 @@
 // expected-note@#Format {{no known conversion from 'int' to 'ConstexprString &' for 1st argument}}
 }
 #endif
+
+// Check that PseudoObjectExprBitfields:NumSubExprs doesn't overflow. This
+// would previously cause a crash.
+struct t1 {
+  int v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+struct t2 {
+  t1 v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16,
+  v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+  v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46,
+  v47, v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61,
+  v62, v63, v64, v65, v66, v67, v68, v69, v70, v71, v72, v73, v74, v75, v76,
+  v77, v78, v79, v80, v81, v82, v83, v84, v85, v86, v87, v88, v89, v90, v91,
+  v92, v93, v94, v95, v96, v97, v98, v99;
+};
+
+int printf(const char *, ...);
+void f1(t2 w) { __builtin_dump_struct(&w, printf); }
Index: clang/include/clang/AST/Stmt.h

[PATCH] D155078: [ci] Make libc++ and Clang CI scripts independent

2023-07-12 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

See https://github.com/google/llvm-premerge-checks/pull/452 for the other side 
of this change. https://github.com/google/llvm-premerge-checks/pull/452 must 
land after this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155078

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


[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-07-12 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 539572.
capfredf marked 2 inline comments as done.
capfredf edited the summary of this revision.
capfredf added a comment.
Herald added a subscriber: arphaman.

- rename
- Do not export ReplCompletionConsumer
- remove commented code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Interpreter/CodeCompletion.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Interpreter/CodeCompletion.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp

Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -543,6 +543,7 @@
 case CodeCompletionContext::CCC_PreprocessorExpression:
 case CodeCompletionContext::CCC_PreprocessorDirective:
 case CodeCompletionContext::CCC_Attribute:
+case CodeCompletionContext::CCC_ReplTopLevel:
 case CodeCompletionContext::CCC_TypeQualifiers: {
   //Only Clang results should be accepted, so we'll set all of the other
   //context bits to 0 (i.e. the empty set)
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1851,7 +1851,7 @@
   case Sema::PCC_ObjCInstanceVariableList:
   case Sema::PCC_Expression:
   case Sema::PCC_Statement:
-  case Sema::PCC_ReplTopLevel:
+  case Sema::PCC_TopLevelStmtDecl:
   case Sema::PCC_ForInit:
   case Sema::PCC_Condition:
   case Sema::PCC_RecoveryInFunction:
@@ -1909,7 +1909,7 @@
   case Sema::PCC_Type:
   case Sema::PCC_ParenthesizedExpression:
   case Sema::PCC_LocalDeclarationSpecifiers:
-  case Sema::PCC_ReplTopLevel:
+  case Sema::PCC_TopLevelStmtDecl:
 return true;
 
   case Sema::PCC_Expression:
@@ -,7 +,7 @@
 break;
 
   case Sema::PCC_RecoveryInFunction:
-  case Sema::PCC_ReplTopLevel:
+  case Sema::PCC_TopLevelStmtDecl:
   case Sema::PCC_Statement: {
 if (SemaRef.getLangOpts().CPlusPlus11)
   AddUsingAliasResult(Builder, Results);
@@ -4212,7 +4212,7 @@
 
   case Sema::PCC_LocalDeclarationSpecifiers:
 return CodeCompletionContext::CCC_Type;
-  case Sema::PCC_ReplTopLevel:
+  case Sema::PCC_TopLevelStmtDecl:
 return CodeCompletionContext::CCC_ReplTopLevel;
   }
 
@@ -4354,7 +4354,7 @@
 break;
 
   case PCC_Statement:
-  case PCC_ReplTopLevel:
+  case PCC_TopLevelStmtDecl:
   case PCC_ParenthesizedExpression:
   case PCC_Expression:
   case PCC_ForInit:
@@ -4392,7 +4392,7 @@
   case PCC_ParenthesizedExpression:
   case PCC_Expression:
   case PCC_Statement:
-  case PCC_ReplTopLevel:
+  case PCC_TopLevelStmtDecl:
   case PCC_RecoveryInFunction:
 if (S->getFnParent())
   AddPrettyFunctionResults(getLangOpts(), Results);
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -928,7 +928,7 @@
 if (CurParsedObjCImpl) {
   PCC = Sema::PCC_ObjCImplementation;
 } else if (PP.isIncrementalProcessingEnabled()) {
-  PCC = Sema::PCC_ReplTopLevel;
+  PCC = Sema::PCC_TopLevelStmtDecl;
 } else {
   PCC = Sema::PCC_Namespace;
 };
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -239,12 +239,11 @@
 }
 
 Interpreter::Interpreter(std::unique_ptr CI, llvm::Error &Err,
- std::vector &CompResults,
+ CodeCompleteConsumer* CConsumer,
  const CompilerInstance *ParentCI) {
   llvm::ErrorAsOutParameter EAO(&Err);
   auto LLVMCtx = std::make_unique();
   TSCtx = std::make_unique(std::move(LLVMCtx));
-  auto *CConsumer = new ReplCompletionConsumer(CompResults);
   CI->setCodeCompletionConsumer(CConsumer);
   IncrParser = std::make_unique(
   *this, std::move(CI), *TSCtx->getContext(), Err, ParentCI);
@@ -304,7 +303,7 @@
 llvm::Expected>
 Interpreter::createForCodeCompletion(
 IncrementalCompilerBuilder &CB, const CompilerInstance *ParentCI,
-std::vector &CompResults) {
+CodeCompleteConsumer* CConsumer) {
   auto CI = CB.CreateCpp();
   if (auto Err = CI.takeError()) {
 return std::move(Err);
@@ -315,12 +314,9 @@
   (*CI)->getLangOpts().SpellChecking = false;
   (*CI)->getLangOpts().DelayedTemplateParsing = false;
 
-  auto &FrontendOpts = (*CI)->getFrontendOpts();
-  FrontendOpts.CodeCompleteOpts = getClangCompleteOpts();
-
   llvm::Error Err = llvm::Error::success();
   auto I

[PATCH] D154696: [Clang] Diagnose jumps into statement expressions

2023-07-12 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added subscribers: nickdesaulniers, nathanchance.
nathanchance added a comment.

This patch breaks building the Linux kernel for PowerPC, which uses `asm goto` 
with a local label in a statement expression for the WARN macro. It seems like 
something with the scoping is going wrong.

I have two reproducers. The first is manually reduced from the kernel sources:

  struct rb_node {
unsigned long __rb_parent_color;
struct rb_node *rb_right;
struct rb_node *rb_left;
  } __attribute__((aligned(sizeof(long;
  
  struct rb_root {
struct rb_node *rb_node;
  };
  struct kernfs_elem_dir {
struct rb_root children;
  };
  
  struct kernfs_node {
struct kernfs_elem_dir dir;
unsigned short  flags;
  };
  
  enum kernfs_node_flag {
KERNFS_ACTIVATED= 0x0010,
KERNFS_NS   = 0x0020,
KERNFS_HAS_SEQ_SHOW = 0x0040,
KERNFS_HAS_MMAP = 0x0080,
KERNFS_LOCKDEP  = 0x0100,
KERNFS_HIDDEN   = 0x0200,
KERNFS_SUICIDAL = 0x0400,
KERNFS_SUICIDED = 0x0800,
KERNFS_EMPTY_DIR= 0x1000,
KERNFS_HAS_RELEASE  = 0x2000,
KERNFS_REMOVING = 0x4000,
  };
  
  enum kernfs_node_type {
KERNFS_DIR  = 0x0001,
KERNFS_FILE = 0x0002,
KERNFS_LINK = 0x0004,
  };
  
  #define KERNFS_TYPE_MASK  0x000f
  
  struct bug_entry {
signed int bug_addr_disp;
signed int file_disp;
unsigned short line;
unsigned short flags;
  };
  
  static enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
  {
return kn->flags & KERNFS_TYPE_MASK;
  }
  
  void kernfs_enable_ns(struct kernfs_node *kn)
  {
({
int __ret_warn_on = !!(kernfs_type(kn) != KERNFS_DIR);
if (__builtin_expect(!!(__ret_warn_on), 0))
do {
__label__ __label_warn_on;
asm goto("1:"
 "twi 31, 0, 0"
 "\n"
 ".section __ex_table,\"a\";"
 " "
 ".balign 4;"
 " "
 ".long (1b) - . ;"
 " "
 ".long (%l[__label_warn_on]) - . ;"
 " "
 ".previous"
 " "
 ".section __bug_table,\"aw\"\n"
 "2:.4byte 1b - .\n"
 "  .4byte %0 - .\n"
 "  .short %1, %2\n"
 ".org 2b+%3\n"
 ".previous\n"
 :
 : "i"("include/linux/kernfs.h"),
   "i"(378),
   "i"((1 << 0) |
   ((1 << 1) | ((9) << 8))),
   "i"(sizeof(struct bug_entry))
 :
 : __label_warn_on);
do {
} while (0);
__builtin_unreachable();
  __label_warn_on:
break;
} while (0);
__builtin_expect(!!(__ret_warn_on), 0);
});
({
int __ret_warn_on = !!(!(
({
do {
__attribute__((
__noreturn__)) extern void
__compiletime_assert_244(void)
__attribute__((__error__(
"Unsupported access 
size for {READ,WRITE}_ONCE().")));
if (!((sizeof((&kn->dir.children)
  ->rb_node) ==
   sizeof(char) ||
   sizeof((&kn->dir.children)
  ->rb_node) ==
   sizeof(short) ||
   sizeof((&kn->dir.children)
  ->rb_node) ==
 

[PATCH] D155094: Refactoring and asserts in LevelIndentTracker. (NFC)

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

- adjustToUnmodifiedLine: The code does something only for non-PP-directives. 
This is now reflected by putting the if-check to the top. This also ensures 
that the assert() there is executed only if IndentForLevel is actually accessed.

- getIndent(): assert valud index into IndentForLevel.

- Added explanation regarding the intention of IndentForLevel.

This refactoring was split from https://reviews.llvm.org/D151047.
But both patches are independent of each other.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155094

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -88,13 +88,13 @@
   /// level to the same indent.
   /// Note that \c nextLine must have been called before this method.
   void adjustToUnmodifiedLine(const AnnotatedLine &Line) {
-unsigned LevelIndent = Line.First->OriginalColumn;
-if (static_cast(LevelIndent) - Offset >= 0)
-  LevelIndent -= Offset;
-assert(Line.Level < IndentForLevel.size());
-if ((!Line.First->is(tok::comment) || IndentForLevel[Line.Level] == -1) &&
-!Line.InPPDirective) {
-  IndentForLevel[Line.Level] = LevelIndent;
+if (!Line.InPPDirective) {
+  unsigned LevelIndent = Line.First->OriginalColumn;
+  if (static_cast(LevelIndent) - Offset >= 0)
+LevelIndent -= Offset;
+  assert(Line.Level < IndentForLevel.size());
+  if (Line.First->isNot(tok::comment) || IndentForLevel[Line.Level] == -1)
+IndentForLevel[Line.Level] = LevelIndent;
 }
   }
 
@@ -148,6 +148,7 @@
   /// at \p IndentForLevel[l], or a value < 0 if the indent for
   /// that level is unknown.
   unsigned getIndent(unsigned Level) const {
+assert(Level < IndentForLevel.size());
 if (IndentForLevel[Level] != -1)
   return IndentForLevel[Level];
 if (Level == 0)
@@ -159,7 +160,10 @@
   const AdditionalKeywords &Keywords;
   const unsigned AdditionalIndent;
 
-  /// The indent in characters for each level.
+  /// The indent in characters for each level. It remembers the indent of
+  /// previous lines (that are not PP directives) of equal or lower levels. 
This
+  /// is used to align formatted lines to the indent of previous non-formatted
+  /// lines. Think about the --lines parameter of clang-format.
   SmallVector IndentForLevel;
 
   /// Offset of the current line relative to the indent level.


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -88,13 +88,13 @@
   /// level to the same indent.
   /// Note that \c nextLine must have been called before this method.
   void adjustToUnmodifiedLine(const AnnotatedLine &Line) {
-unsigned LevelIndent = Line.First->OriginalColumn;
-if (static_cast(LevelIndent) - Offset >= 0)
-  LevelIndent -= Offset;
-assert(Line.Level < IndentForLevel.size());
-if ((!Line.First->is(tok::comment) || IndentForLevel[Line.Level] == -1) &&
-!Line.InPPDirective) {
-  IndentForLevel[Line.Level] = LevelIndent;
+if (!Line.InPPDirective) {
+  unsigned LevelIndent = Line.First->OriginalColumn;
+  if (static_cast(LevelIndent) - Offset >= 0)
+LevelIndent -= Offset;
+  assert(Line.Level < IndentForLevel.size());
+  if (Line.First->isNot(tok::comment) || IndentForLevel[Line.Level] == -1)
+IndentForLevel[Line.Level] = LevelIndent;
 }
   }
 
@@ -148,6 +148,7 @@
   /// at \p IndentForLevel[l], or a value < 0 if the indent for
   /// that level is unknown.
   unsigned getIndent(unsigned Level) const {
+assert(Level < IndentForLevel.size());
 if (IndentForLevel[Level] != -1)
   return IndentForLevel[Level];
 if (Level == 0)
@@ -159,7 +160,10 @@
   const AdditionalKeywords &Keywords;
   const unsigned AdditionalIndent;
 
-  /// The indent in characters for each level.
+  /// The indent in characters for each level. It remembers the indent of
+  /// previous lines (that are not PP directives) of equal or lower levels. This
+  /// is used to align formatted lines to the indent of previous non-formatted
+  /// lines. Think about the --lines parameter of clang-format.
   SmallVector IndentForLevel;
 
   /// Offset of the current line relative to the indent level.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154786: [Clang][Driver] Pass through the --be8 endian flag to linker in BareMetal driver For Arm.

2023-07-12 Thread Simi Pallipurath via Phabricator via cfe-commits
simpal01 updated this revision to Diff 539582.
simpal01 added a comment.

Addressing Review comment - Removing the variable IsBigEndian.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154786

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/baremetal.cpp

Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -15,7 +15,7 @@
 // CHECK-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECk-V6M-C-SAME: "-internal-isystem" "[[SYSROOT]]{{[/\\]+}}include"
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
-// CHECK-V6M-C-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-C-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
@@ -34,7 +34,7 @@
 // CHECK-ARMV7M-PER-TARGET: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-ARMV7M-PER-TARGET: "-isysroot" "[[SYSROOT:[^"]*]]"
 // CHECK-ARMV7M-PER-TARGET: "-x" "c++" "{{.*}}baremetal.cpp"
-// CHECK-ARMV7M-PER-TARGET: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-ARMV7M-PER-TARGET: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
 // CHECK-ARMV7M-PER-TARGET: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-ARMV7M-PER-TARGET: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}armv7m-vendor-none-eabi
 // CHECK-ARMV7M-PER-TARGET: "-lc" "-lm" "-lclang_rt.builtins"
@@ -42,7 +42,7 @@
 // RUN: %clangxx %s -### --target=armv6m-none-eabi 2>&1 \
 // RUN: --sysroot=%S/Inputs/baremetal_arm | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-V6M-DEFAULTCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-DEFAULTCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
 // CHECK-V6M-DEFAULTCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
@@ -53,7 +53,7 @@
 // CHECK-V6M-LIBCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-LIBCXX-NOT: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}{{[^v].*}}"
 // CHECK-V6M-LIBCXX-SAME: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
-// CHECK-V6M-LIBCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
 // CHECK-V6M-LIBCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
@@ -66,7 +66,7 @@
 // CHECK-V6M-LIBSTDCXX: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
 // CHECK-V6M-LIBSTDCXX-NOT: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBSTDCXX-SAME: "-internal-isystem" "{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
-// CHECK-V6M-LIBSTDCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-LIBSTDCXX: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
 // CHECK-V6M-LIBSTDCXX-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
@@ -77,7 +77,7 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
-// CHECK-V6M-NDL: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
+// CHECK-V6M-NDL: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "-EL"
 // CHECK-V6M-NDL-SAME: "-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-NDL-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 
@@ -117,6 +117,46 @@
 // RUN:   | FileCheck %s --check-prefix=CHECK-SYSROOT-INC
 // CHECK-SYSROOT-INC-NOT: "-internal-isystem" "include"
 
+// RUN: %clang -### %s --target=armebv7-none-eabi --sysroot=%S/Inputs/baremetal_arm 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7EB %s
+// CHECK-ARMV7EB: "{{.*}}ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic" "--be8" "-EB"
+
+// RUN: %clang -### %s --target=armv7-none-eabi -mbig-endian --sysroot=%S/Inputs/baremetal_arm 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7EB %s
+
+// RUN: %clang -### %s --target=armebv7-none-eabi -mbig-endian --sysroot=%S/Inputs/baremetal_arm 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARMV7EB %s
+
+// RUN: %clang -### %s --target=armv7-none-eabi --sysroot=%S/Inputs/bare

[PATCH] D154382: [ClangRepl] support code completion at a REPL

2023-07-12 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 539578.
capfredf edited the summary of this revision.
capfredf added a comment.

@v.g.vassilev I moved the ReplCodeCompletionConsumer class out of the header 
file, since it is not needed elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Interpreter/CodeCompletion.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/CodeCompletion.cpp
  clang/lib/Interpreter/ExternalSource.cpp
  clang/lib/Interpreter/ExternalSource.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,61 @@
+#include "clang/Interpreter/CodeCompletion.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "llvm/LineEditor/LineEditor.h"
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/Support/Error.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Completer = ReplListCompleter(CB, *Interp);
+  std::vector comps =
+  Completer(std::string("f"), 1);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0].TypedText, std::string("oo"));
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Completer = ReplListCompleter(CB, *Interp);
+  std::vector comps =
+  Completer(std::string("babanana"), 8);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Completer = ReplListCompleter(CB, *Interp);
+  std::vector comps =
+  Completer(std::string("app"), 3);
+  EXPECT_EQ((size_t)2, comps.size());
+}
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -543,6 +543,7 @@
 case CodeCompletionContext::CCC_PreprocessorExpression:
 case CodeCompletionContext::CCC_PreprocessorDirective:
 case CodeCompletionContext::CCC_Attribute:
+case CodeCompletionContext::CCC_ReplTopLevel:
 case CodeCompletionContext::CCC_TypeQualifiers: {
   //Only Clang results should be accepted, so we'll set all of the other
   //context bits to 0 (i.e. the empty set)
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -13,6 +13,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
+#include "clang/Interpreter/CodeCompletion.h"
 #include "clang/Interpreter/Interpreter.h"
 
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
@@ -155,8 +156,8 @@
 
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
-// FIXME: Add LE.setListCompleter
 std::string Input;
+LE.setListCompleter(clang::ReplListCompleter(CB, *Interp));
 while (std::optional Line 

[PATCH] D151047: [clang-format] Fix indentation for selective formatting.

2023-07-12 Thread Sedenion via Phabricator via cfe-commits
Sedeniono updated this revision to Diff 539583.
Sedeniono added a comment.

@owenpan Oh wow, you are right. Phabricator shows that there are two separate 
commits, under "Revision Contents" > "Commits", and their commit messages. But 
apparently there is no way to download some proper *.patch file that contains 
the meta data, only the total diff.

So, I uploaded a new diff here (D151047 ): It 
contains the bugfix. I will also edit the summary at the top with the 
corresponding commit message.

I have submitted the refactoring commit separately here: 
https://reviews.llvm.org/D155094

Note that both patches (D151047  and D155094 
) are fortunately independent of each other. 
I checked that both can be applied to the latest main branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151047

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestSelective.cpp

Index: clang/unittests/Format/FormatTestSelective.cpp
===
--- clang/unittests/Format/FormatTestSelective.cpp
+++ clang/unittests/Format/FormatTestSelective.cpp
@@ -528,6 +528,26 @@
 format("  int a;\n"
"void ff() {}",
11, 0));
+
+  // https://github.com/llvm/llvm-project/issues/59178
+  Style = getMozillaStyle();
+  EXPECT_EQ("int a()\n"
+"{\n"
+"return 0;\n"
+"}\n"
+"int b()\n"
+"{\n"
+"  return 42;\n"
+"}",
+format("int a()\n"
+   "{\n"
+   "return 0;\n"
+   "}\n"
+   "int b()\n"
+   "{\n"
+   "return 42;\n" // Format this line only
+   "}",
+   32, 0));
 }
 
 TEST_F(FormatTestSelective, UnderstandsTabs) {
@@ -617,6 +637,70 @@
  "namespace ns1 { namespace ns2 {\n"
  "}}";
   EXPECT_EQ(Code, format(Code, 0, 0));
+
+  Style = getLLVMStyle();
+  Style.FixNamespaceComments = false;
+  Code = "namespace ns {\n"
+ "#define REF(alias) alias alias_var;\n"
+ "}";
+  EXPECT_EQ(Code, format(Code, 51, 1));
+}
+
+TEST_F(FormatTestSelective, FormatMacroRegardlessOfPreviousIndent) {
+  // clang-format currently does not (or should not) take into account the
+  // indent of previous unformatted lines when formatting a PP directive.
+  // Technically speaking, LevelIndentTracker::IndentForLevel is only for non-PP
+  // lines. So these tests here check that the indent of previous non-PP lines
+  // do not affect the formatting. If this requirement changes, the tests here
+  // need to be adapted.
+  Style = getLLVMStyle();
+
+  Style.IndentPPDirectives = FormatStyle::PPDirectiveIndentStyle::PPDIS_None;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"#define some\n" // Formatted line
+"#endif\n"   // That this line is also formatted might be a bug.
+"}};", // Dito: Bug?
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
+
+  Style.IndentPPDirectives =
+  FormatStyle::PPDirectiveIndentStyle::PPDIS_BeforeHash;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"  #define some\n" // Formatted line
+" #endif\n"
+"}};",
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
+
+  Style.IndentPPDirectives =
+  FormatStyle::PPDirectiveIndentStyle::PPDIS_AfterHash;
+  EXPECT_EQ("  class Foo {\n"
+"void test() {\n"
+"#ifdef 1\n"
+"#  define some\n" // Formatted line
+"#endif\n" // That this line is also formatted might be a bug.
+"}};",
+format("  class Foo {\n"
+   "void test() {\n"
+   "#ifdef 1\n"
+   "#define some\n" // format this line
+   " #endif\n"
+   "}};",
+   75, 0));
 }
 
 } // end namespace
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/Unw

  1   2   3   >