[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-06-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

lgtm with nit




Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:280
+} else {
+  auto AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType());
+  if (AllocSize <= 8)

BufSize += std::max(getTypeAllocSize(), 8)



Comment at: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp:369
+if (DL.getTypeAllocSize(Ty) < 8) {
+  return Builder.CreateFPExt(Arg, Builder.getDoubleTy());
+}

maybe add a constrained fp run line to a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

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


[PATCH] D152548: [Clang][Interp] Diagnose uninitialized ctor of global record arrays

2023-06-09 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, tbaeder, shafik.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

This patch adds a check for uninitialized subobjects of global variables that 
are record arrays.
e.g. `constexpr Foo f[2];`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152548

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp


Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -138,14 +138,43 @@
 namespace UninitializedFields {
   class A {
   public:
-int a; // expected-note 3{{subobject declared here}} \
-   // ref-note 3{{subobject declared here}}
+int a; // expected-note 4{{subobject declared here}} \
+   // ref-note 4{{subobject declared here}}
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant 
expression}} \
  // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} 
\
  // ref-note {{subobject 'a' is not initialized}}
+  constexpr A aarr[2]; // expected-error {{must be initialized by a constant 
expression}} \
+   // expected-note {{subobject 'a' is not initialized}} \
+   // ref-error {{must be initialized by a constant 
expression}} \
+   // ref-note {{subobject 'a' is not initialized}}
+  class F {
+public:
+  int f;// expected-note 3{{subobject declared here}} \
+// ref-note 3{{subobject declared here}}
+
+  constexpr F() {}
+  constexpr F(bool b) {
+if (b)
+  f = 42;
+  }
+  };
+
+  constexpr F foo[2] = {true};// expected-error {{must be initialized by a 
constant expression}} \
+ // expected-note {{subobject 'f' is not initialized}} \
+ // ref-error {{must be initialized by a constant 
expression}} \
+ // ref-note {{subobject 'f' is not initialized}}
+  constexpr F foo2[3] = {true, false, true};// expected-error {{must be 
initialized by a constant expression}} \
+ // expected-note {{subobject 'f' is not initialized}} \
+ // ref-error {{must be initialized by a constant 
expression}} \
+ // ref-note {{subobject 'f' is not initialized}}
+  constexpr F foo3[3] = {true, true, F()};// expected-error {{must be 
initialized by a constant expression}} \
+ // expected-note {{subobject 'f' is not initialized}} \
+ // ref-error {{must be initialized by a constant 
expression}} \
+ // ref-note {{subobject 'f' is not initialized}}
+
 
 
   class Base {
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -455,8 +455,11 @@
 
 bool CheckCtorCall(InterpState , CodePtr OpPC, const Pointer ) {
   assert(!This.isZero());
-  const Record *R = This.getRecord();
-  return CheckFieldsInitialized(S, OpPC, This, R);
+  if (const Record *R = This.getRecord())
+return CheckFieldsInitialized(S, OpPC, This, R);
+  const auto *CAT =
+  cast(This.getType()->getAsArrayTypeUnsafe());
+  return CheckArrayInitialized(S, OpPC, This, CAT);
 }
 
 bool CheckFloatResult(InterpState , CodePtr OpPC, APFloat::opStatus Status) {
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -164,7 +164,8 @@
 if (!visitInitializer(Init))
   return false;
 
-if (Init->getType()->isRecordType() && !this->emitCheckGlobalCtor(Init))
+if ((Init->getType()->isArrayType() || Init->getType()->isRecordType()) &&
+!this->emitCheckGlobalCtor(Init))
   return false;
 
 return this->emitPopPtr(Init);


Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -138,14 +138,43 @@
 namespace UninitializedFields {
   class A {
   public:
-int a; // expected-note 3{{subobject declared here}} \
-   // ref-note 3{{subobject declared here}}
+int a; // expected-note 4{{subobject declared here}} \
+   // ref-note 4{{subobject declared here}}
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant expression}} \
  // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} \
  // 

[PATCH] D152547: [clang][NFC] Drop alignment in builtin-nondeterministic-value test

2023-06-09 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito created this revision.
ManuelJBrito added reviewers: zixuan-wu, erichkeane.
Herald added a subscriber: mgrang.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Drop alignment to allow tests to run in different platforms.
Following @zixuan-wu 's request in D142388 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152547

Files:
  clang/test/CodeGen/builtins-nondeterministic-value.c


Index: clang/test/CodeGen/builtins-nondeterministic-value.c
===
--- clang/test/CodeGen/builtins-nondeterministic-value.c
+++ clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32, align
+// CHECK: store i32 [[X:%.*]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float, align
+// CHECK: store float [[X:%.*]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double, align
+// CHECK: store double [[X:%.*]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8, align
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);


Index: clang/test/CodeGen/builtins-nondeterministic-value.c
===
--- clang/test/CodeGen/builtins-nondeterministic-value.c
+++ clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32, align
+// CHECK: store i32 [[X:%.*]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float, align
+// CHECK: store float [[X:%.*]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double, align
+// CHECK: store double [[X:%.*]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8, align
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]], align
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143984: [DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)

2023-06-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

When we migrated to github we gained higher fidelity for attributing authors 
(we can now commit on someone's behalf but have the commit author properly 
recorded as the real author - we couldn't do that back on Subversion) - but I 
think it's meant that fail-mail from bots goes to that author, and not to the 
committer. Ideally it'd go to both - so, as it stands now, being a 
commiter-but-not-author is tricky, because you don't get the feedback on the 
commit you made. You might watch buildbots manually, or at least bhe responsive 
to other people complaining on the reviews like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143984

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


[PATCH] D152447: [Clang] Remove -no-opaque-pointers cc1 flag

2023-06-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added subscribers: t.p.northover, dblaikie.
dblaikie added a comment.

(I hope this doesn't come off as condescending/patronizing, I mean it quite 
genuinely)

A deep thanks to everyone who worked on this, especially @aeubanks and @nikic, 
and @t.p.northover - it's been a long project and I really appreciate you folks 
picking up where I stalled out years ago/paying down the technical debt I 
created (which I'm sorry about).
Starting with 
https://lists.llvm.org/pipermail/llvm-dev/2015-February/081822.html and the 
first change, I think, was D7655 , so... 8 
years, 4 months? Glad it's come along.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152447

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


[PATCH] D142388: [clang] Add builtin_nondeterministic_value

2023-06-09 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added inline comments.



Comment at: clang/test/CodeGen/builtins-nondeterministic-value.c:26
+// CHECK-LABEL: entry
+// CHECK: [[A:%.*]] = alloca double, align 8
+// CHECK: store double [[X:%.*]], ptr [[A]], align 8

zixuan-wu wrote:
> hi, @ManuelJBrito , because double is 4 alignment in CSKY target, could you 
> please update this with capture match pattern which makes it more adaptable?
Hi, I'll make a patch dropping the alignment since it's not relevant for what 
we are testing here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142388

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


[PATCH] D152443: Add SpaceAfterOperatorKeyword & SpaceAfterOperatorKeywordInCall style options for clang-format

2023-06-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D152443#4407438 , @KitsuneAlex 
wrote:

> I had some issues with Git there because i messed up a merge, so the diff was 
> bad. Here's the proper diff.



> NOTE: Clang-Format Team Automated Review Comment

keep you honest right!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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


[PATCH] D152443: Add SpaceAfterOperatorKeyword & SpaceAfterOperatorKeywordInCall style options for clang-format

2023-06-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:4709
+
+**SpaceAfterOperatorKeyword** (``Boolean``) :versionbadge:`clang-format 17` 
:ref:`¶ `
+  If ``true``, a space will be inserted after the 'operator' keyword.

could we use something like `SpaceAfterOperatorDeclaration` to differentiate



Comment at: clang/docs/ClangFormatStyleOptions.rst:4719
+
+**SpaceAfterOperatorKeywordInCall** (``Boolean``) :versionbadge:`clang-format 
17` :ref:`¶ `
+  If ``true``, a space will be inserted after the 'operator' keyword in a call 
expression.

I'm not going to lie I'm not a fan of `SpaceAfterOperatorKeywordInCall` as an 
option name, any other suggestions for a name?



Comment at: clang/lib/Format/TokenAnnotator.cpp:3762
   }
+
   // co_await (x), co_yield (x), co_return (x)

kind of unrelated change?



Comment at: clang/unittests/Format/FormatTest.cpp:22916
+  Style.SpaceAfterOperatorKeywordInCall = true;
+  verifyFormat("foo.operator ==();", Style);
+  verifyFormat("foo.Foo::operator ==();", Style);

I assume I could have `foo->operator ==();`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152443

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-06-09 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D150226#4408563 , @erichkeane 
wrote:

> In D150226#4408381 , @aaron.ballman 
> wrote:
>
>> In D150226#4404808 , @rupprecht 
>> wrote:
>>
>>> I suppose including this warning in `ShowInSystemHeader` with your diff 
>>> above would be a good first step anyway, right? If we're about to make it a 
>>> hard error anyway, then making it a `ShowInSystemHeader` error first would 
>>> ease that transition.
>>
>> Yes and no.
>>
>> If we're going to turn something into a hard error, letting folks 
>> implementing system headers know about it is important, so from that 
>> perspective, it makes sense to enable the diagnostic in system headers. 
>> However, *users* have no choice in their system headers (oftentimes) which 
>> makes the diagnostic unactionable for them as they're not going to (and 
>> shouldn't have to) modify system headers, so from that perspective, enabling 
>> the diagnostic in a system header introduces friction.
>>
>> If this diagnostic is showing up in system headers, I think we would likely 
>> need to consider adding a compatibility hack to allow Clang to still consume 
>> that system header while erroring when outside of that system header (we've 
>> done this before to keep STL implementations working, for example). Between 
>> this need and the friction it causes users to have an unactionable 
>> diagnostic, I think we probably should not enable `ShowInSystemHeader`.
>
> It seems to me that if our concern is breaking system headers, we need to do 
> that with better testing.  Some sort of 'diagnostic group' for "This is going 
> to become an error *SOON*" mixed with us/vendors running that on platforms we 
> consider significant enough to not break.  But just diagnosing on arbitrary 
> users with no choice on how to fix the headers doesn't seem appropriate.

I think that's the request here: 
https://github.com/llvm/llvm-project/issues/63180 - some way, initially, to 
opt-in to such a diagnostic group or mechanism (like "enable this warning in 
system headers") to assess how big the migration effort is/report back on 
whether it's necessary to implement a compatibility hack or whether things will 
be able to be cleaned up. (such a thing could be opt-in at first, vendors etc 
could use that to assess the fallout - if the answer is "we think we can clean 
this up" and folks plan some timeline, they reckon they're ready, then you 
switch to that feature being enabled by default (because we think we can make 
it an error - but there's always surprises, so shipping it as an 
error-by-default-but-with-a-way-to-opt-out is better than shipping it as a hard 
error that catches users by surprise) - then if there's no major fallout, 
remove the ability to opt-out)


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

https://reviews.llvm.org/D150226

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


[PATCH] D152321: [clang] Replace use of Type::getPointerTo() (NFC)

2023-06-09 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 added inline comments.



Comment at: clang/lib/CodeGen/CGBuilder.h:172
+auto *PtrTy = llvm::PointerType::get(Ty, Addr.getAddressSpace());
 return Address(CreateBitCast(Addr.getPointer(), PtrTy, Name), Ty,
Addr.getAlignment(), Addr.isKnownNonNull());

nikic wrote:
> JOE1994 wrote:
> > nikic wrote:
> > > Can remove this bit cast.
> > Wouldn't removing the bitcast cause behavior change for uses of 
> > `CreateElementBitCast` that supply a `Name` that is not `""`?
> This will never actually create an instruction, so the name is already 
> ignored now. It would make sense to remove the parameter altogether.
Thank you for the clarification.

I've updated the revision to get rid of the bitcast.

I'll prepare a separate commit that gets rid of the `Name` parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152321

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


[PATCH] D152473: [clang-format] Add test case for issue 63170

2023-06-09 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I presume the test fail, we don't check in tests that just fail without a fix, 
or the build would be stale.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152473

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


[PATCH] D152321: [clang] Replace use of Type::getPointerTo() (NFC)

2023-06-09 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 updated this revision to Diff 529976.
JOE1994 added a comment.

- Update uses of `PointerType::get(Ty)` & `PointerType::getUnqual` to be in 
overloaded form of `PointerType::get` that takes LLVMContext&

- Remove more unnecessary bitcasts which were previously overlooked.

- Remove pointee type info from Type variable names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152321

Files:
  clang/lib/CodeGen/Address.h
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCXX.cpp
  clang/lib/CodeGen/CGCXXABI.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGObjCRuntime.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -402,7 +402,7 @@
   llvm::Type *DirectTy = CGF.ConvertTypeForMem(ValueTy), *ElementTy = DirectTy;
   if (IsIndirect) {
 unsigned AllocaAS = CGF.CGM.getDataLayout().getAllocaAddrSpace();
-DirectTy = DirectTy->getPointerTo(AllocaAS);
+DirectTy = llvm::PointerType::get(CGF.getLLVMContext(), AllocaAS);
   }
 
   Address Addr = emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize,
@@ -2042,7 +2042,7 @@
   Info = ABIArgInfo::getInAlloca(FrameFields.size(), IsIndirect);
   llvm::Type *LLTy = CGT.ConvertTypeForMem(Type);
   if (IsIndirect)
-LLTy = LLTy->getPointerTo(0);
+LLTy = llvm::PointerType::get(getVMContext(), 0);
   FrameFields.push_back(LLTy);
   StackOffset += IsIndirect ? WordSize : getContext().getTypeSizeInChars(Type);
 
@@ -4851,7 +4851,7 @@
   Builder.CreateCondBr(CC, UsingRegs, UsingOverflow);
 
   llvm::Type *DirectTy = CGF.ConvertType(Ty), *ElementTy = DirectTy;
-  if (isIndirect) DirectTy = DirectTy->getPointerTo(0);
+  if (isIndirect) DirectTy = llvm::PointerType::get(CGF.getLLVMContext(), 0);
 
   // Case 1: consume registers.
   Address RegAddr = Address::invalid();
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -584,9 +584,6 @@
   auto *RD =
   cast(MPT->getClass()->castAs()->getDecl());
 
-  llvm::FunctionType *FTy = CGM.getTypes().GetFunctionType(
-  CGM.getTypes().arrangeCXXMethodType(RD, FPT, /*FD=*/nullptr));
-
   llvm::Constant *ptrdiff_1 = llvm::ConstantInt::get(CGM.PtrDiffTy, 1);
 
   llvm::BasicBlock *FnVirtual = CGF.createBasicBlock("memptr.virtual");
@@ -687,8 +684,6 @@
   {VFPAddr, llvm::ConstantInt::get(CGM.Int32Ty, 0), TypeId});
   CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);
   VirtualFn = Builder.CreateExtractValue(CheckedLoad, 0);
-  VirtualFn = Builder.CreateBitCast(VirtualFn, FTy->getPointerTo(),
-"memptr.virtualfn");
 } else {
   // When not doing VFE, emit a normal load, as it allows more
   // optimisations than type.checked.load.
@@ -709,14 +704,11 @@
 CGM.getIntrinsic(llvm::Intrinsic::load_relative,
  {VTableOffset->getType()}),
 {VTable, VTableOffset});
-VirtualFn = CGF.Builder.CreateBitCast(VirtualFn, FTy->getPointerTo());
   } else {
 llvm::Value *VFPAddr =
 CGF.Builder.CreateGEP(CGF.Int8Ty, VTable, VTableOffset);
-VFPAddr = CGF.Builder.CreateBitCast(
-VFPAddr, FTy->getPointerTo()->getPointerTo());
 VirtualFn = CGF.Builder.CreateAlignedLoad(
-FTy->getPointerTo(), VFPAddr, CGF.getPointerAlign(),
+llvm::PointerType::get(CGF.getLLVMContext(), 0), VFPAddr, CGF.getPointerAlign(),
 "memptr.virtualfn");
   }
 }
@@ -758,7 +750,7 @@
   // function pointer.
   CGF.EmitBlock(FnNonVirtual);
   llvm::Value *NonVirtualFn =
-Builder.CreateIntToPtr(FnAsInt, FTy->getPointerTo(), "memptr.nonvirtualfn");
+Builder.CreateIntToPtr(FnAsInt, llvm::PointerType::get(CGF.getLLVMContext(), 0), "memptr.nonvirtualfn");
 
   // Check the function pointer if CFI on member function pointers is enabled.
   if (ShouldEmitCFICheck) {
@@ -799,7 +791,8 @@
 
   // We're done.
   CGF.EmitBlock(FnEnd);
-  llvm::PHINode *CalleePtr = Builder.CreatePHI(FTy->getPointerTo(), 2);
+  llvm::PHINode *CalleePtr =
+Builder.CreatePHI(llvm::PointerType::get(CGF.getLLVMContext(), 0), 2);
   CalleePtr->addIncoming(VirtualFn, FnVirtual);
   CalleePtr->addIncoming(NonVirtualFn, FnNonVirtual);
 
@@ -822,12 +815,7 @@
   // Apply the offset, 

[PATCH] D150358: [clang][Interp] Remove args from called functions in more cases

2023-06-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a subscriber: MaskRay.
tbaeder added inline comments.



Comment at: clang/test/AST/Interp/functions.cpp:262
+namespace CallWithArgs {
+  /// This used to call problems during checkPotentialConstantExpression() 
runs.
+  constexpr void g(int a) {}

aaron.ballman wrote:
> 
Question regarding this: IIRC it was @MaskRay who once told me to use `///` 
comments for everything that's not a `RUN` or `expected` line. If you look 
further up, I think I stuck to that (mostly). Should I continue doing that or 
not?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150358

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


[PATCH] D152522: [NFC][SetVector] Update some usages of SetVector to SmallSetVector

2023-06-09 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic 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/D152522/new/

https://reviews.llvm.org/D152522

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


[PATCH] D152525: [clang][Diagnostics] Don't expand label fixit to the next line

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

As far as the fixit goes, I guess the previous version was better, since it 
didn't leave an empty line behind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152525

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


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

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

Yes, FWIW I looked into this again last week and noticed a few unsolved 
problems as well. I'll post a comment once I consider it ready for actual 
review.


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

https://reviews.llvm.org/D144943

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


[PATCH] D152542: [clangd] Use include_cleaner spelling strategies in clangd.

2023-06-09 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 529974.
VitaNuo added a comment.

Remove unrelated formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152542

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -74,11 +74,6 @@
 convertIncludes(const SourceManager ,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST , const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST );
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -198,8 +198,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -334,22 +335,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST , const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManager())) {
-  std::string SpelledHeader =
-  llvm::cantFail(URI::includeSpelling(URI::create(*CanonicalPath)));
-  if (!SpelledHeader.empty())
-return SpelledHeader;
-}
-  }
-  return include_cleaner::spellHeader(
-  {Provider, AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
-}
-
 std::vector
 getUnused(ParsedAST ,
   const llvm::DenseSet ,
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -18,6 +18,7 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "clang-include-cleaner/Analysis.h"
+#include "clang-include-cleaner/IncludeSpeller.h"
 #include "clang-include-cleaner/Types.h"
 #include "index/SymbolCollector.h"
 #include "support/Logger.h"
@@ -1223,7 +1224,9 @@
 // on local variables, etc.
 return;
 
-  HI.Provider = spellHeader(AST, SM.getFileEntryForID(SM.getMainFileID()), H);
+  HI.Provider = include_cleaner::spellHeader(
+  {H, AST.getPreprocessor().getHeaderSearchInfo(),
+   SM.getFileEntryForID(SM.getMainFileID())});
 }
 
 // FIXME: similar functions are present in FindHeaders.cpp (symbolName)


Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -74,11 +74,6 @@
 convertIncludes(const SourceManager ,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST , const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST );
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -198,8 +198,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -334,22 +335,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST , const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManager())) {
-  std::string SpelledHeader =
-  

[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-06-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I'll make `-munaligned-access` `TargetSpecific` (D151590 
) to report errors for unsupported targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D152473: [clang-format] Add test case for issue 63170

2023-06-09 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

In D152473#4407832 , @owenpan wrote:

> Can you add the test to clang/unittests/Format/FormatTest.cpp instead? Please 
> also include the full diff. See 
> https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface.

I can try to add this to unit tests, but I used arcanist so this is the full 
context, since I only made a lit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152473

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


[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-06-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> [1]: 
> https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cpu.h#L77
> [2]: 
> https://github.com/torvalds/linux/blob/master/arch/loongarch/kernel/proc.c#L75

`master` will point to different commits. It'd be better to use a specific 
commit for future patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D152542: [clangd] Use include_cleaner spelling strategies in clangd.

2023-06-09 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152542

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h

Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -74,11 +74,6 @@
 convertIncludes(const SourceManager ,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST , const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST );
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -198,8 +198,9 @@
   continue;
 }
 
-std::string Spelling =
-spellHeader(AST, MainFile, SymbolWithMissingInclude.Providers.front());
+std::string Spelling = include_cleaner::spellHeader(
+{SymbolWithMissingInclude.Providers.front(),
+ AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
 
 llvm::StringRef HeaderRef{Spelling};
 bool Angled = HeaderRef.starts_with("<");
@@ -334,22 +335,6 @@
   return ConvertedIncludes;
 }
 
-std::string spellHeader(ParsedAST , const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManager())) {
-  std::string SpelledHeader =
-  llvm::cantFail(URI::includeSpelling(URI::create(*CanonicalPath)));
-  if (!SpelledHeader.empty())
-return SpelledHeader;
-}
-  }
-  return include_cleaner::spellHeader(
-  {Provider, AST.getPreprocessor().getHeaderSearchInfo(), MainFile});
-}
-
 std::vector
 getUnused(ParsedAST ,
   const llvm::DenseSet ,
@@ -459,7 +444,8 @@
   return {std::move(UnusedIncludes), std::move(MissingIncludes)};
 }
 
-std::optional removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes) {
+std::optional
+removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes) {
   if (UnusedIncludes.empty())
 return std::nullopt;
 
@@ -468,8 +454,8 @@
   for (const auto  : UnusedIncludes) {
 assert(Diag.Fixes.size() == 1 && "Expected exactly one fix.");
 RemoveAll.Edits.insert(RemoveAll.Edits.end(),
- Diag.Fixes.front().Edits.begin(),
- Diag.Fixes.front().Edits.end());
+   Diag.Fixes.front().Edits.begin(),
+   Diag.Fixes.front().Edits.end());
   }
 
   // TODO(hokein): emit a suitable text for the label.
@@ -497,7 +483,7 @@
   llvm::StringMap Edits;
   for (const auto  : MissingIncludeDiags) {
 assert(Diag.Fixes.size() == 1 && "Expected exactly one fix.");
-for (const auto& Edit : Diag.Fixes.front().Edits) {
+for (const auto  : Diag.Fixes.front().Edits) {
   Edits.try_emplace(Edit.newText, Edit);
 }
   }
@@ -517,7 +503,7 @@
   }
   return AddAllMissing;
 }
-Fix fixAll(const Fix& RemoveAllUnused, const Fix& AddAllMissing) {
+Fix fixAll(const Fix , const Fix ) {
   Fix FixAll;
   FixAll.Message = "fix all includes";
 
@@ -526,22 +512,23 @@
   for (const auto  : AddAllMissing.Edits)
 FixAll.Edits.push_back(F);
 
-  for (const auto& A : RemoveAllUnused.Annotations)
+  for (const auto  : RemoveAllUnused.Annotations)
 FixAll.Annotations.push_back(A);
-  for (const auto& A : AddAllMissing.Annotations)
+  for (const auto  : AddAllMissing.Annotations)
 FixAll.Annotations.push_back(A);
   return FixAll;
 }
 
-std::vector generateIncludeCleanerDiagnostic(
-ParsedAST , const IncludeCleanerFindings ,
-llvm::StringRef Code) {
+std::vector
+generateIncludeCleanerDiagnostic(ParsedAST ,
+ const IncludeCleanerFindings ,
+ llvm::StringRef Code) {
   std::vector UnusedIncludes = generateUnusedIncludeDiagnostics(
   AST.tuPath(), Findings.UnusedIncludes, Code);
   std::optional RemoveAllUnused = removeAllUnusedIncludes(UnusedIncludes);
 
-  std::vector MissingIncludeDiags = generateMissingIncludeDiagnostics(
-  AST, Findings.MissingIncludes, Code);
+  std::vector MissingIncludeDiags =
+  generateMissingIncludeDiagnostics(AST, Findings.MissingIncludes, Code);
   std::optional AddAllMissing = 

[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

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

In D152436#4408301 , @steakhal wrote:

> In D152436#4405558 , @balazske 
> wrote:
>
>> These are reports that could be improved:
>> link 
>> 
>> In this case function `fileno` returns -1 because of failure, but this is 
>> not indicated in a `NoteTag`. This is a correct result, only the note is 
>> missing. This problem can be solved if a note is displayed on every branch 
>> ("case") of the standard C functions. But this leads to many notes at 
>> un-interesting places. If the note is displayed only at "interesting" values 
>> another difficulty shows up: The note disappears from places where it should 
>> be shown because the "interestingness" is not set, for example at conditions 
>> of `if` statement. So the solution may require more work. This case with 
>> function `fileno` occurs 13 times in all the tested projects.
>
> Could you elaborate on what do you mean by "The note disappears from places 
> where it should be shown because the "interestingness" is not set, for 
> example at conditions of `if` statement.".  A short example would do the job 
> I think.
>
> I looked at the TPs, and if the violation was introduced by an assumption 
> (instead of an assignment), then it's really hard to spot which assumption is 
> important for the bug.
> I wonder if we could add the `TrackConstraintBRVisitor` to the bugreport to 
> "highlight" that particular assumption/place.

The question is first if this problem must be fixed before the checker comes 
out of alpha state. If yes I try to make another patch with this fix. I tried 
this previously but do not remember exactly what the problem was.




Comment at: clang/docs/analyzer/checkers.rst:922
+
+unix.StdCLibraryFunctions (C)
+"

This is applicable to C++ too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-09 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

In D144999#4407934 , @t.p.northover 
wrote:

> I don't think this handles the no-personality case properly. For example this 
> code leads to a DWARF entry now:
>
>   void bar(int *) noexcept;
>   void foo() {
> int arr;
> bar();
>   }

Thanks! Sent the fix in D152540 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D150661: [clang][Interp] Allow evaluating standalone composite expressions

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

LGTM, but you should change the summary to `Allow evaluating standalone complex 
expressions` when landing.


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

https://reviews.llvm.org/D150661

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


[PATCH] D149133: [clang][Interp] BaseToDerived casts

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

LGTM!


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

https://reviews.llvm.org/D149133

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


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

2023-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Making it clear that there's more work here.


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

https://reviews.llvm.org/D144943

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


[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

2023-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

There's still quite a few unaddressed comments, FWIW.




Comment at: clang/lib/AST/Interp/Boolean.h:113
+
+  void bitcastToMemory(std::byte *Buff) { std::memcpy(Buff, , sizeof(V)); }
+




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

https://reviews.llvm.org/D144943

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


[PATCH] D150358: [clang][Interp] Remove args from called functions in more cases

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

LGTM




Comment at: clang/test/AST/Interp/functions.cpp:262
+namespace CallWithArgs {
+  /// This used to call problems during checkPotentialConstantExpression() 
runs.
+  constexpr void g(int a) {}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150358

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


[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-09 Thread Aaron Ballman 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 rG7fbc9de45536: [libclang] Add CXBinaryOperatorKind and 
CXUnaryOperatorKind (authored by MineGame159, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150910

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OperationKinds.def
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/libclang.map
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1138,6 +1138,40 @@
 "class ns1::Class1");
 }
 
+TEST_F(LibclangParseTest, BinaryOperator) {
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { return 5 + 9; }");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
+   0, TUFlags);
+
+  Traverse([](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_BinaryOperator) {
+  EXPECT_EQ(clang_getCursorBinaryOperatorKind(cursor),
+CXBinaryOperator_Add);
+  return CXChildVisit_Break;
+}
+
+return CXChildVisit_Recurse;
+  });
+}
+
+TEST_F(LibclangParseTest, UnaryOperator) {
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { int a = 5; return a++; }");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
+   0, TUFlags);
+
+  Traverse([](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_UnaryOperator) {
+  EXPECT_EQ(clang_getCursorUnaryOperatorKind(cursor),
+CXUnaryOperator_PostInc);
+  return CXChildVisit_Break;
+}
+
+return CXChildVisit_Recurse;
+  });
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -422,6 +422,10 @@
   global:
 clang_CXXMethod_isExplicit;
 clang_createIndexWithOptions;
+clang_getBinaryOperatorKindSpelling;
+clang_getCursorBinaryOperatorKind;
+clang_getUnaryOperatorKindSpelling;
+clang_getCursorUnaryOperatorKind;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -23,8 +23,11 @@
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjCCommon.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/OpenMPClause.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticCategories.h"
@@ -9604,3 +9607,38 @@
 OS << "--\n";
   }
 }
+
+CXString clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind) {
+  return cxstring::createRef(
+  BinaryOperator::getOpcodeStr(static_cast(kind - 1)));
+}
+
+enum CXBinaryOperatorKind clang_getCursorBinaryOperatorKind(CXCursor cursor) {
+  if (clang_isExpression(cursor.kind)) {
+const Expr *expr = getCursorExpr(cursor);
+
+if (const auto *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+
+if (const auto *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+  }
+
+  return CXBinaryOperator_Invalid;
+}
+
+CXString clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind) {
+  return cxstring::createRef(
+  UnaryOperator::getOpcodeStr(static_cast(kind - 1)));
+}
+
+enum CXUnaryOperatorKind clang_getCursorUnaryOperatorKind(CXCursor cursor) {
+  if (clang_isExpression(cursor.kind)) {
+const Expr *expr = getCursorExpr(cursor);
+
+if (const auto *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+  }
+
+  return CXUnaryOperator_Invalid;
+}
Index: clang/include/clang/AST/OperationKinds.def
===
--- clang/include/clang/AST/OperationKinds.def
+++ clang/include/clang/AST/OperationKinds.def
@@ -362,8 +362,8 @@
 
 //===- Binary Operations  -===//
 // Operators listed in order of precedence.
-// Note that additions to this should also update the StmtVisitor class and
-// BinaryOperator::getOverloadedOperator.
+// Note that additions to this should also 

[clang] 7fbc9de - [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind

2023-06-09 Thread Aaron Ballman via cfe-commits

Author: MineGame159
Date: 2023-06-09T10:01:43-04:00
New Revision: 7fbc9de4553666a189b0529ca04e1d9966c0d4f8

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

LOG: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind

Adds 2 new functions to the C libclang api for retrieving operator
kinds for binary and unary operators from cursors. Also adds 2
functions for retrieving the spelling of the new enums.

Fixes https://github.com/llvm/llvm-project/issues/29138
Differential Revision: https://reviews.llvm.org/D150910

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang-c/Index.h
clang/include/clang/AST/OperationKinds.def
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/libclang.map
clang/unittests/libclang/LibclangTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e3dd7910e7a9e..acd8c4d622a89 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -728,6 +728,9 @@ libclang
   has an evaluable bit width. Fixes undefined behavior when called on a
   bit-field whose width depends on a template parameter.
 
+- Added ``CXBinaryOperatorKind`` and ``CXUnaryOperatorKind``.
+  (`#29138 `_)
+
 Static Analyzer
 ---
 - Fix incorrect alignment attribute on the this parameter of certain

diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 29c53c0382abe..601b91f67d658 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -6510,6 +6510,144 @@ typedef enum CXVisitorResult (*CXFieldVisitor)(CXCursor 
C,
 CINDEX_LINKAGE unsigned clang_Type_visitFields(CXType T, CXFieldVisitor 
visitor,
CXClientData client_data);
 
+/**
+ * Describes the kind of binary operators.
+ */
+enum CXBinaryOperatorKind {
+  /** This value describes cursors which are not binary operators. */
+  CXBinaryOperator_Invalid,
+  /** C++ Pointer - to - member operator. */
+  CXBinaryOperator_PtrMemD,
+  /** C++ Pointer - to - member operator. */
+  CXBinaryOperator_PtrMemI,
+  /** Multiplication operator. */
+  CXBinaryOperator_Mul,
+  /** Division operator. */
+  CXBinaryOperator_Div,
+  /** Remainder operator. */
+  CXBinaryOperator_Rem,
+  /** Addition operator. */
+  CXBinaryOperator_Add,
+  /** Subtraction operator. */
+  CXBinaryOperator_Sub,
+  /** Bitwise shift left operator. */
+  CXBinaryOperator_Shl,
+  /** Bitwise shift right operator. */
+  CXBinaryOperator_Shr,
+  /** C++ three-way comparison (spaceship) operator. */
+  CXBinaryOperator_Cmp,
+  /** Less than operator. */
+  CXBinaryOperator_LT,
+  /** Greater than operator. */
+  CXBinaryOperator_GT,
+  /** Less or equal operator. */
+  CXBinaryOperator_LE,
+  /** Greater or equal operator. */
+  CXBinaryOperator_GE,
+  /** Equal operator. */
+  CXBinaryOperator_EQ,
+  /** Not equal operator. */
+  CXBinaryOperator_NE,
+  /** Bitwise AND operator. */
+  CXBinaryOperator_And,
+  /** Bitwise XOR operator. */
+  CXBinaryOperator_Xor,
+  /** Bitwise OR operator. */
+  CXBinaryOperator_Or,
+  /** Logical AND operator. */
+  CXBinaryOperator_LAnd,
+  /** Logical OR operator. */
+  CXBinaryOperator_LOr,
+  /** Assignment operator. */
+  CXBinaryOperator_Assign,
+  /** Multiplication assignment operator. */
+  CXBinaryOperator_MulAssign,
+  /** Division assignment operator. */
+  CXBinaryOperator_DivAssign,
+  /** Remainder assignment operator. */
+  CXBinaryOperator_RemAssign,
+  /** Addition assignment operator. */
+  CXBinaryOperator_AddAssign,
+  /** Subtraction assignment operator. */
+  CXBinaryOperator_SubAssign,
+  /** Bitwise shift left assignment operator. */
+  CXBinaryOperator_ShlAssign,
+  /** Bitwise shift right assignment operator. */
+  CXBinaryOperator_ShrAssign,
+  /** Bitwise AND assignment operator. */
+  CXBinaryOperator_AndAssign,
+  /** Bitwise XOR assignment operator. */
+  CXBinaryOperator_XorAssign,
+  /** Bitwise OR assignment operator. */
+  CXBinaryOperator_OrAssign,
+  /** Comma operator. */
+  CXBinaryOperator_Comma
+};
+
+/**
+ * Retrieve the spelling of a given CXBinaryOperatorKind.
+ */
+CINDEX_LINKAGE CXString
+clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind);
+
+/**
+ * Retrieve the binary operator kind of this cursor.
+ *
+ * If this cursor is not a binary operator then returns Invalid.
+ */
+CINDEX_LINKAGE enum CXBinaryOperatorKind
+clang_getCursorBinaryOperatorKind(CXCursor cursor);
+
+/**
+ * Describes the kind of unary operators.
+ */
+enum CXUnaryOperatorKind {
+  /** This value describes cursors which are not unary operators. */
+  CXUnaryOperator_Invalid,
+  /** Postfix increment operator. */
+  CXUnaryOperator_PostInc,
+  /** Postfix 

[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-09 Thread MineGame159 via Phabricator via cfe-commits
MineGame159 added a comment.

In D150910#4408585 , @aaron.ballman 
wrote:

> LGTM! Do you need me to commit on your behalf? If so, what name and email 
> address would you like me to use for patch attribution?

Yeah, this is my first contribution, thanks. My name can be `MineGame159` and 
email `petulk...@gmail.com`.


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

https://reviews.llvm.org/D150910

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


[clang] 644917b - Remove unnecessary metadata check in test

2023-06-09 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2023-06-09T06:41:22-07:00
New Revision: 644917bb7c05d330b3dfa75ccd50414f9b9cd8ee

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

LOG: Remove unnecessary metadata check in test

Added: 


Modified: 
clang/test/CodeGenObjC/arc.m

Removed: 




diff  --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m
index 05a3a647b818a..997bbc3f6b1ee 100644
--- a/clang/test/CodeGenObjC/arc.m
+++ b/clang/test/CodeGenObjC/arc.m
@@ -1414,14 +1414,14 @@ void test71(void) {
 // CHECK: %[[ARRAYDESTROY_ELEMENTPAST:.*]] = phi ptr [ %[[V7]], %{{.*}} ], [ 
%[[ARRAYDESTROY_ELEMENT:.*]], %{{.*}} ]
 // CHECK: %[[ARRAYDESTROY_ELEMENT]] = getelementptr inbounds ptr, ptr 
%[[ARRAYDESTROY_ELEMENTPAST]], i64 -1
 // CHECK: %[[V8:.*]] = load ptr, ptr %[[ARRAYDESTROY_ELEMENT]], align 8
-// CHECK: call void @llvm.objc.release(ptr %[[V8]]) #2, 
!clang.imprecise_release !10
+// CHECK: call void @llvm.objc.release(ptr %[[V8]]) #2, 
!clang.imprecise_release
 
 // CHECK-NOT: call void @llvm.objc.release
 
 // CHECK: %[[V10:.*]] = load ptr, ptr %[[B_ADDR]], align 8
-// CHECK: call void @llvm.objc.release(ptr %[[V10]]) #2, 
!clang.imprecise_release !10
+// CHECK: call void @llvm.objc.release(ptr %[[V10]]) #2, 
!clang.imprecise_release
 // CHECK: %[[V11:.*]] = load ptr, ptr %[[A_ADDR]], align 8
-// CHECK: call void @llvm.objc.release(ptr %[[V11]]) #2, 
!clang.imprecise_release !10
+// CHECK: call void @llvm.objc.release(ptr %[[V11]]) #2, 
!clang.imprecise_release
 
 void test72(id a, id b) {
   __strong id t[] = (__strong id[]){a, b};



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


[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-06-09 Thread Sebastian Neubauer via Phabricator via cfe-commits
sebastian-ne added inline comments.



Comment at: cmake/Modules/GetClangResourceDir.cmake:15
+  else()
+string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION})
+set(ret_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR})

This fails in our downstream project.
We use add_subdirectory() to include LLVM and our parent project already sets 
PACKAGE_VERSION to something that is not the LLVM version.

Parsing PACKAGE_VERSION only if CLANG_VERSION_MAJOR is not already known seems 
to work:
```
if (NOT CLANG_VERSION_MAJOR)
  string(REGEX MATCH "^[0-9]+" CLANG_VERSION_MAJOR ${PACKAGE_VERSION})
endif()
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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


[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

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

LGTM! Do you need me to commit on your behalf? If so, what name and email 
address would you like me to use for patch attribution?


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

https://reviews.llvm.org/D150910

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-06-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D150226#4408381 , @aaron.ballman 
wrote:

> In D150226#4404808 , @rupprecht 
> wrote:
>
>> I suppose including this warning in `ShowInSystemHeader` with your diff 
>> above would be a good first step anyway, right? If we're about to make it a 
>> hard error anyway, then making it a `ShowInSystemHeader` error first would 
>> ease that transition.
>
> Yes and no.
>
> If we're going to turn something into a hard error, letting folks 
> implementing system headers know about it is important, so from that 
> perspective, it makes sense to enable the diagnostic in system headers. 
> However, *users* have no choice in their system headers (oftentimes) which 
> makes the diagnostic unactionable for them as they're not going to (and 
> shouldn't have to) modify system headers, so from that perspective, enabling 
> the diagnostic in a system header introduces friction.
>
> If this diagnostic is showing up in system headers, I think we would likely 
> need to consider adding a compatibility hack to allow Clang to still consume 
> that system header while erroring when outside of that system header (we've 
> done this before to keep STL implementations working, for example). Between 
> this need and the friction it causes users to have an unactionable 
> diagnostic, I think we probably should not enable `ShowInSystemHeader`.

It seems to me that if our concern is breaking system headers, we need to do 
that with better testing.  Some sort of 'diagnostic group' for "This is going 
to become an error *SOON*" mixed with us/vendors running that on platforms we 
consider significant enough to not break.  But just diagnosing on arbitrary 
users with no choice on how to fix the headers doesn't seem appropriate.


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

https://reviews.llvm.org/D150226

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


[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-09 Thread MineGame159 via Phabricator via cfe-commits
MineGame159 updated this revision to Diff 529938.

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

https://reviews.llvm.org/D150910

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/OperationKinds.def
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/libclang.map
  clang/unittests/libclang/LibclangTest.cpp

Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1138,6 +1138,40 @@
 "class ns1::Class1");
 }
 
+TEST_F(LibclangParseTest, BinaryOperator) {
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { return 5 + 9; }");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
+   0, TUFlags);
+
+  Traverse([](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_BinaryOperator) {
+  EXPECT_EQ(clang_getCursorBinaryOperatorKind(cursor),
+CXBinaryOperator_Add);
+  return CXChildVisit_Break;
+}
+
+return CXChildVisit_Recurse;
+  });
+}
+
+TEST_F(LibclangParseTest, UnaryOperator) {
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { int a = 5; return a++; }");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, nullptr,
+   0, TUFlags);
+
+  Traverse([](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_UnaryOperator) {
+  EXPECT_EQ(clang_getCursorUnaryOperatorKind(cursor),
+CXUnaryOperator_PostInc);
+  return CXChildVisit_Break;
+}
+
+return CXChildVisit_Recurse;
+  });
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -422,6 +422,10 @@
   global:
 clang_CXXMethod_isExplicit;
 clang_createIndexWithOptions;
+clang_getBinaryOperatorKindSpelling;
+clang_getCursorBinaryOperatorKind;
+clang_getUnaryOperatorKindSpelling;
+clang_getCursorUnaryOperatorKind;
 };
 
 # Example of how to add a new symbol version entry.  If you do add a new symbol
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -23,8 +23,11 @@
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/DeclObjCCommon.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/OpenMPClause.h"
+#include "clang/AST/OperationKinds.h"
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticCategories.h"
@@ -9604,3 +9607,38 @@
 OS << "--\n";
   }
 }
+
+CXString clang_getBinaryOperatorKindSpelling(enum CXBinaryOperatorKind kind) {
+  return cxstring::createRef(
+  BinaryOperator::getOpcodeStr(static_cast(kind - 1)));
+}
+
+enum CXBinaryOperatorKind clang_getCursorBinaryOperatorKind(CXCursor cursor) {
+  if (clang_isExpression(cursor.kind)) {
+const Expr *expr = getCursorExpr(cursor);
+
+if (const auto *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+
+if (const auto *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+  }
+
+  return CXBinaryOperator_Invalid;
+}
+
+CXString clang_getUnaryOperatorKindSpelling(enum CXUnaryOperatorKind kind) {
+  return cxstring::createRef(
+  UnaryOperator::getOpcodeStr(static_cast(kind - 1)));
+}
+
+enum CXUnaryOperatorKind clang_getCursorUnaryOperatorKind(CXCursor cursor) {
+  if (clang_isExpression(cursor.kind)) {
+const Expr *expr = getCursorExpr(cursor);
+
+if (const auto *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+  }
+
+  return CXUnaryOperator_Invalid;
+}
Index: clang/include/clang/AST/OperationKinds.def
===
--- clang/include/clang/AST/OperationKinds.def
+++ clang/include/clang/AST/OperationKinds.def
@@ -362,8 +362,8 @@
 
 //===- Binary Operations  -===//
 // Operators listed in order of precedence.
-// Note that additions to this should also update the StmtVisitor class and
-// BinaryOperator::getOverloadedOperator.
+// Note that additions to this should also update the StmtVisitor class,
+// BinaryOperator::getOverloadedOperator and CXBinaryOperatorKind enum.
 
 // [C++ 5.5] Pointer-to-member operators.
 BINARY_OPERATION(PtrMemD, ".*")
@@ -415,8 +415,8 @@
 
 
 //===- Unary Operations 

[PATCH] D152207: [HIP] Instruct lld to go through all archives

2023-06-09 Thread Siu Chi Chan 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 rGf1aee32f1c85: [HIP] Instruct lld to go through all archives 
(authored by scchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152207

Files:
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc-static-lib.hip


Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -80,7 +80,9 @@
 // CHECK-NOT: ".*llc"
 // CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-plugin-opt=mcpu=gfx900"
+// CHECK-SAME: "--whole-archive"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK-SAME: "--no-whole-archive"
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -126,18 +126,22 @@
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // LINK-SAME: "-plugin-opt=mcpu=gfx803"
+// LINK-SAME: "--whole-archive"
 // LLD-TMP-SAME: "-o" "[[IMG_DEV1:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx803]]"
 // LINK-SAME "[[A_BC1]]" "[[B_BC1]]"
+// LINK-SAME: "--no-whole-archive"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // LINK-SAME: "-plugin-opt=mcpu=gfx900"
+// LINK-SAME: "--whole-archive"
 // LLD-TMP-SAME: "-o" "[[IMG_DEV2:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx900]]"
 // LINK-SAME "[[A_BC2]]" "[[B_BC2]]"
+// LINK-SAME: "--no-whole-archive"
 
 // LINK-BUNDLE: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-BUNDLE-SAME: 
"-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -152,6 +152,18 @@
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
+  // Given that host and device linking happen in separate processes, the 
device
+  // linker doesn't always have the visibility as to which device symbols are
+  // needed by a program, especially for the device symbol dependencies that 
are
+  // introduced through the host symbol resolution.
+  // For example: host_A() (A.obj) --> host_B(B.obj) --> device_kernel_B()
+  // (B.obj) In this case, the device linker doesn't know that A.obj actually
+  // depends on the kernel functions in B.obj.  When linking to static device
+  // library, the device linker may drop some of the device global symbols if
+  // they aren't referenced.  As a workaround, we are adding to the
+  // --whole-archive flag such that all global symbols would be linked in.
+  LldArgs.push_back("--whole-archive");
+
   for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker)) {
 LldArgs.push_back(Arg->getValue(1));
 Arg->claim();
@@ -169,6 +181,8 @@
  /*IsBitCodeSDL=*/true,
  /*PostClangLink=*/false);
 
+  LldArgs.push_back("--no-whole-archive");
+
   const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
   C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
  Lld, LldArgs, Inputs, Output));


Index: clang/test/Driver/hip-toolchain-rdc-static-lib.hip
===
--- clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -80,7 +80,9 @@
 // CHECK-NOT: ".*llc"
 // CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-plugin-opt=mcpu=gfx900"
+// CHECK-SAME: "--whole-archive"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK-SAME: "--no-whole-archive"
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -126,18 +126,22 @@
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // LINK-SAME: "-plugin-opt=mcpu=gfx803"
+// LINK-SAME: "--whole-archive"
 

[clang] f1aee32 - [HIP] Instruct lld to go through all archives

2023-06-09 Thread Siu Chi Chan via cfe-commits

Author: Siu Chi Chan
Date: 2023-06-09T08:50:44-04:00
New Revision: f1aee32f1c85aa476bce70ec110284011c6df354

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

LOG: [HIP] Instruct lld to go through all archives

Add the --whole-archive flag when linking HIP programs to instruct lld
to go through every archive library to link in all the kernel functions
(entry pointers to the GPU program); otherwise, lld may skip some
library files if there are no more symbols that need to be resolved.

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

Change-Id: I084d3d606f9cee646f9adc65f4b648c9bcb252e6

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc-static-lib.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp 
b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index 3131c8ed24639..a9afa5858b1bd 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -152,6 +152,18 @@ void AMDGCN::Linker::constructLldCommand(Compilation , 
const JobAction ,
 
   addLinkerCompressDebugSectionsOption(TC, Args, LldArgs);
 
+  // Given that host and device linking happen in separate processes, the 
device
+  // linker doesn't always have the visibility as to which device symbols are
+  // needed by a program, especially for the device symbol dependencies that 
are
+  // introduced through the host symbol resolution.
+  // For example: host_A() (A.obj) --> host_B(B.obj) --> device_kernel_B()
+  // (B.obj) In this case, the device linker doesn't know that A.obj actually
+  // depends on the kernel functions in B.obj.  When linking to static device
+  // library, the device linker may drop some of the device global symbols if
+  // they aren't referenced.  As a workaround, we are adding to the
+  // --whole-archive flag such that all global symbols would be linked in.
+  LldArgs.push_back("--whole-archive");
+
   for (auto *Arg : Args.filtered(options::OPT_Xoffload_linker)) {
 LldArgs.push_back(Arg->getValue(1));
 Arg->claim();
@@ -169,6 +181,8 @@ void AMDGCN::Linker::constructLldCommand(Compilation , 
const JobAction ,
  /*IsBitCodeSDL=*/true,
  /*PostClangLink=*/false);
 
+  LldArgs.push_back("--no-whole-archive");
+
   const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
   C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
  Lld, LldArgs, Inputs, Output));

diff  --git a/clang/test/Driver/hip-toolchain-rdc-separate.hip 
b/clang/test/Driver/hip-toolchain-rdc-separate.hip
index 4782434df4f80..286acfdb6d066 100644
--- a/clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -126,18 +126,22 @@
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // LINK-SAME: "-plugin-opt=mcpu=gfx803"
+// LINK-SAME: "--whole-archive"
 // LLD-TMP-SAME: "-o" "[[IMG_DEV1:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx803]]"
 // LINK-SAME "[[A_BC1]]" "[[B_BC1]]"
+// LINK-SAME: "--no-whole-archive"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // LINK-SAME: "-plugin-opt=mcpu=gfx900"
+// LINK-SAME: "--whole-archive"
 // LLD-TMP-SAME: "-o" "[[IMG_DEV2:.*.out]]"
 // LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx900]]"
 // LINK-SAME "[[A_BC2]]" "[[B_BC2]]"
+// LINK-SAME: "--no-whole-archive"
 
 // LINK-BUNDLE: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-BUNDLE-SAME: 
"-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"

diff  --git a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip 
b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
index 66eac74876cfc..20fd2fb29c1e9 100644
--- a/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
+++ b/clang/test/Driver/hip-toolchain-rdc-static-lib.hip
@@ -80,7 +80,9 @@
 // CHECK-NOT: ".*llc"
 // CHECK: [[LLD]] {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
 // CHECK-SAME: "-plugin-opt=mcpu=gfx900"
+// CHECK-SAME: "--whole-archive"
 // CHECK-SAME: "-o" "[[IMG_DEV2:.*out]]" [[A_BC2]] [[B_BC2]]
+// CHECK-SAME: "--no-whole-archive"
 
 // combine images generated into hip fat binary object
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"



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


[PATCH] D151197: [Clang][SVE2p1] Add svpsel builtins

2023-06-09 Thread hassnaaHamdi via Phabricator via cfe-commits
hassnaa-arm added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9633-9635
+bool IsSVCount = isa(Ops[0]->getType());
+assert(((!IsSVCount || cast(Ops[0]->getType())->getName() ==
+   "aarch64.svcount")) &&

hassnaa-arm wrote:
> for the case of sve::BI__builtin_sve_svpsel_lane_b8, 
> what is the expected value of IsSVCount ? and how the assertion statement 
> didn't assert for the check of :
> (cast(Ops[0]->getType())->getName() ==
>"aarch64.svcount"))
> how is the parameter type considered as aarch64.svcount ?
Hi Carol,
I understood that part, ignore my comment.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9642
+Function *CastToSVCountF =
+CGM.getIntrinsic(Intrinsic::aarch64_sve_convert_from_svbool, 
SVCountTy);
+

hassnaa-arm wrote:
> Isn't the type of 'SVCountTy' = 'aarch64.svcount' as a result of the 
> statement at line 9637 ?
> So why do we need to aarch64_sve_convert_from_svbool while it's not svbool.
> Am I missing something ?
I understood that part, please ignore my comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151197

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


[PATCH] D152525: [clang][Diagnostics] Don't expand label fixit to the next line

2023-06-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, cjdb.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  Now that we print >1 line of code snippet, we printed another line of
  code for now reason, because the source range we created for the fixit
  expanded to the next line, if the next token was there. Don't do that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152525

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/FixIt/fixit-newline-style.c


Index: clang/test/FixIt/fixit-newline-style.c
===
--- clang/test/FixIt/fixit-newline-style.c
+++ clang/test/FixIt/fixit-newline-style.c
@@ -5,6 +5,7 @@
 // CHECK: warning: unused label 'ddd'
 // CHECK-NEXT: {{^  ddd:}}
 // CHECK-NEXT: {{^  \^~~~$}}
+// CHECK-NOT: {{^  ;}}
 void f(void) {
   ddd:
   ;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2096,7 +2096,7 @@
   if (isa(D)) {
 SourceLocation AfterColon = Lexer::findLocationAfterToken(
 D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
-true);
+/*SkipTrailingWhitespaceAndNewline=*/false);
 if (AfterColon.isInvalid())
   return;
 Hint = FixItHint::CreateRemoval(


Index: clang/test/FixIt/fixit-newline-style.c
===
--- clang/test/FixIt/fixit-newline-style.c
+++ clang/test/FixIt/fixit-newline-style.c
@@ -5,6 +5,7 @@
 // CHECK: warning: unused label 'ddd'
 // CHECK-NEXT: {{^  ddd:}}
 // CHECK-NEXT: {{^  \^~~~$}}
+// CHECK-NOT: {{^  ;}}
 void f(void) {
   ddd:
   ;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2096,7 +2096,7 @@
   if (isa(D)) {
 SourceLocation AfterColon = Lexer::findLocationAfterToken(
 D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
-true);
+/*SkipTrailingWhitespaceAndNewline=*/false);
 if (AfterColon.isInvalid())
   return;
 Hint = FixItHint::CreateRemoval(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150910: [libclang] Add CXBinaryOperatorKind and CXUnaryOperatorKind (implements 29138)

2023-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D150910#4406296 , @MineGame159 
wrote:

> I have added the new functions into the file and now it successfully compiles 
> the test. (but fails when running it - EDIT: guess I broke my dev env somehow)
>
> Also checked and made sure that `CINDEX_VERSION_MINOR` was already 
> incremented in LLVM 17.
> Another thing I am not sure is which naming convention I should be using. 
> Some functions in the C api use `clang_getCursorBinaryOperatorKind` and 
> others `clang_Cursor_getBinaryOperatorKind`.

The style you're using currently is fine.




Comment at: clang/docs/ReleaseNotes.rst:720
 
+- Add ``CXBinaryOperatorKind`` and ``CXUnaryOperatorKind``.
+  (`#29138 `_)





Comment at: clang/tools/libclang/CIndex.cpp:9620-9624
+if (const BinaryOperator *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);
+
+if (const CXXRewrittenBinaryOperator *op =
+dyn_cast(expr))

Sorry, I was unclear before. :-) Our style guide is to not use `auto` unless 
the type is spelled out explicitly in the RHS of the assignment (basically, use 
`auto` when it lets you avoid repeating the type name). So these uses with 
`dyn_cast` (and friends) should use `auto`, while a call like `getCursorExpr()` 
should spell out the type explicitly.



Comment at: clang/tools/libclang/CIndex.cpp:9640
+
+if (const UnaryOperator *op = dyn_cast(expr))
+  return static_cast(op->getOpcode() + 1);





Comment at: clang/unittests/libclang/LibclangTest.cpp:1143
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { return 5 + 9; };");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, 
nullptr,





Comment at: clang/unittests/libclang/LibclangTest.cpp:1160
+  std::string Main = "main.cpp";
+  WriteFile(Main, "int foo() { int a = 5; return a++; };");
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, 
nullptr,




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

https://reviews.llvm.org/D150910

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


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

2023-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D150226#4404808 , @rupprecht wrote:

> I suppose including this warning in `ShowInSystemHeader` with your diff above 
> would be a good first step anyway, right? If we're about to make it a hard 
> error anyway, then making it a `ShowInSystemHeader` error first would ease 
> that transition.

Yes and no.

If we're going to turn something into a hard error, letting folks implementing 
system headers know about it is important, so from that perspective, it makes 
sense to enable the diagnostic in system headers. However, *users* have no 
choice in their system headers (oftentimes) which makes the diagnostic 
unactionable for them as they're not going to (and shouldn't have to) modify 
system headers, so from that perspective, enabling the diagnostic in a system 
header introduces friction.

If this diagnostic is showing up in system headers, I think we would likely 
need to consider adding a compatibility hack to allow Clang to still consume 
that system header while erroring when outside of that system header (we've 
done this before to keep STL implementations working, for example). Between 
this need and the friction it causes users to have an unactionable diagnostic, 
I think we probably should not enable `ShowInSystemHeader`.


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

https://reviews.llvm.org/D150226

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


[PATCH] D152522: [NFC][SetVector] Update some usages of SetVector to SmallSetVector

2023-06-09 Thread Dhruv Chawla via Phabricator via cfe-commits
0xdc03 created this revision.
0xdc03 added a reviewer: nikic.
Herald added subscribers: ChuanqiXu, StephenFan, haicheng, hiraditya, MatzeB.
Herald added a project: All.
0xdc03 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch is a continuation of D152497 . It 
updates usages of SetVector
that were found in llvm/ and clang/ which were originally specifying either
SmallPtrSet or SmallVector to just using SmallSetVector, as the overhead
of SetVector is reduced with D152497 .

This also helps clean up the code a fair bit, and gives a decent speed
boost at -O0 (~0.2%):
https://llvm-compile-time-tracker.com/compare.php?from=9ffdabecabcddde298ff313f5353f9e06590af62=97f1c0cde42ba85eaa67cbe89bec8fe45b801f21=instructions%3Au


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152522

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  llvm/include/llvm/ADT/GenericCycleInfo.h
  llvm/include/llvm/CodeGen/LiveRangeEdit.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/lib/Analysis/InlineCost.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h

Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -318,9 +318,7 @@
 
   /// This is a collection of subprogram MDNodes that are processed to
   /// create DIEs.
-  SetVector,
-SmallPtrSet>
-  ProcessedSPNodes;
+  SmallSetVector ProcessedSPNodes;
 
   /// If nonnull, stores the current machine function we're processing.
   const MachineFunction *CurFn = nullptr;
Index: llvm/lib/Analysis/InlineCost.cpp
===
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -2680,9 +2680,7 @@
   // basic blocks in a breadth-first order as we insert live successors. To
   // accomplish this, prioritizing for small iterations because we exit after
   // crossing our threshold, we use a small-size optimized SetVector.
-  typedef SetVector,
-SmallPtrSet>
-  BBSetVector;
+  typedef SmallSetVector BBSetVector;
   BBSetVector BBWorklist;
   BBWorklist.insert(());
 
Index: llvm/include/llvm/Transforms/Scalar/SROA.h
===
--- llvm/include/llvm/Transforms/Scalar/SROA.h
+++ llvm/include/llvm/Transforms/Scalar/SROA.h
@@ -105,7 +105,7 @@
   /// directly promoted. Finally, each time we rewrite a use of an alloca other
   /// the one being actively rewritten, we add it back onto the list if not
   /// already present to ensure it is re-visited.
-  SetVector> Worklist;
+  SmallSetVector Worklist;
 
   /// A collection of instructions to delete.
   /// We try to batch deletions to simplify code and make things a bit more
@@ -120,7 +120,7 @@
   ///
   /// Note that we have to be very careful to clear allocas out of this list in
   /// the event they are deleted.
-  SetVector> PostPromotionWorklist;
+  SmallSetVector PostPromotionWorklist;
 
   /// A collection of alloca instructions we can directly promote.
   std::vector PromotableAllocas;
@@ -130,7 +130,7 @@
   /// All of these PHIs have been checked for the safety of speculation and by
   /// being speculated will allow promoting allocas currently in the promotable
   /// queue.
-  SetVector> SpeculatablePHIs;
+  SmallSetVector SpeculatablePHIs;
 
   /// A worklist of select instructions to rewrite prior to promoting
   /// allocas.
Index: llvm/include/llvm/CodeGen/LiveRangeEdit.h
===
--- llvm/include/llvm/CodeGen/LiveRangeEdit.h
+++ llvm/include/llvm/CodeGen/LiveRangeEdit.h
@@ -97,8 +97,7 @@
   /// a load, eliminate the register by folding the def into the use.
   bool foldAsLoad(LiveInterval *LI, SmallVectorImpl );
 
-  using ToShrinkSet = SetVector,
-SmallPtrSet>;
+  using ToShrinkSet = SmallSetVector;
 
   /// Helper for eliminateDeadDefs.
   void eliminateDeadDef(MachineInstr *MI, ToShrinkSet );
Index: llvm/include/llvm/ADT/GenericCycleInfo.h
===
--- llvm/include/llvm/ADT/GenericCycleInfo.h
+++ llvm/include/llvm/ADT/GenericCycleInfo.h
@@ -28,10 +28,10 @@
 #ifndef LLVM_ADT_GENERICCYCLEINFO_H
 #define LLVM_ADT_GENERICCYCLEINFO_H
 
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/GenericSSAContext.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/SetVector.h"
-#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -64,7 +64,7 @@
   /// Basic blocks that are contained in the cycle, including entry blocks,
   /// and including blocks that are part of a child cycle.
   using 

[PATCH] D152520: [clangd] Unify printing policy for type hints

2023-06-09 Thread Younan Zhang via Phabricator via cfe-commits
zyounan created this revision.
zyounan added a reviewer: nridge.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
zyounan published this revision for review.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

(This patch addresses the comment from 
https://reviews.llvm.org/D151785#4402460.)

Previously, we used a special printing policy that enabled `PrintCanonicalTypes`
to print type hints for structure bindings. This was intended to
eliminate type aliases like `tuple_element::type`. However, this also
caused TypePrinter to print default template arguments, which could
result in losing the ability to see types like `std::basic_string`
if the fully expanded template-id exceeded the default inlay hint threshold.

Simply getting the canonical type at the call site could help us get rid of
the side effect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152520

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


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1347,8 +1347,11 @@
 struct A {};
 A foo();
 auto $var[[var]] = foo();
+A bar[1];
+auto [$binding[[value]]] = bar;
   )cpp",
-  ExpectedHint{": A", "var"});
+  ExpectedHint{": A", "var"},
+  ExpectedHint{": A", "binding"});
 }
 
 TEST(TypeHints, Deduplication) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -198,8 +198,7 @@
 Cfg(Cfg), RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
-TypeHintPolicy(this->AST.getPrintingPolicy()),
-StructuredBindingPolicy(this->AST.getPrintingPolicy()) {
+TypeHintPolicy(this->AST.getPrintingPolicy()) {
 bool Invalid = false;
 llvm::StringRef Buf =
 AST.getSourceManager().getBufferData(MainFileID, );
@@ -209,14 +208,8 @@
 TypeHintPolicy.AnonymousTagLocations =
 false; // do not print lambda locations
 
-// For structured bindings, print canonical types. This is important 
because
-// for bindings that use the tuple_element protocol, the non-canonical 
types
-// would be "tuple_element::type".
-// For "auto", we often prefer sugared types.
 // Not setting PrintCanonicalTypes for "auto" allows
 // SuppressDefaultTemplateArgs (set by default) to have an effect.
-StructuredBindingPolicy = TypeHintPolicy;
-StructuredBindingPolicy.PrintCanonicalTypes = true;
   }
 
   bool VisitTypeLoc(TypeLoc TL) {
@@ -298,8 +291,12 @@
 // but show hints for the individual bindings.
 if (auto *DD = dyn_cast(D)) {
   for (auto *Binding : DD->bindings()) {
-addTypeHint(Binding->getLocation(), Binding->getType(), /*Prefix=*/": 
",
-StructuredBindingPolicy);
+// For structured bindings, print canonical types. This is important
+// because for bindings that use the tuple_element protocol, the
+// non-canonical types would be "tuple_element::type".
+if (auto Type = Binding->getType(); !Type.isNull())
+  addTypeHint(Binding->getLocation(), Type.getCanonicalType(),
+  /*Prefix=*/": ", TypeHintPolicy);
   }
   return true;
 }
@@ -707,14 +704,7 @@
   FileID MainFileID;
   StringRef MainFileBuf;
   const HeuristicResolver *Resolver;
-  // We want to suppress default template arguments, but otherwise print
-  // canonical types. Unfortunately, they're conflicting policies so we can't
-  // have both. For regular types, suppressing template arguments is more
-  // important, whereas printing canonical types is crucial for structured
-  // bindings, so we use two separate policies. (See the constructor where
-  // the policies are initialized for more details.)
   PrintingPolicy TypeHintPolicy;
-  PrintingPolicy StructuredBindingPolicy;
 };
 
 } // namespace


Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -1347,8 +1347,11 @@
 struct A {};
 A foo();
 auto $var[[var]] = foo();
+A bar[1];
+auto [$binding[[value]]] = bar;
   )cpp",
-  ExpectedHint{": A", "var"});
+  ExpectedHint{": A", "var"},
+  ExpectedHint{": A", "binding"});
 }
 
 TEST(TypeHints, Deduplication) {
Index: clang-tools-extra/clangd/InlayHints.cpp

[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

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

In D152436#4405558 , @balazske wrote:

> These are reports that could be improved:
> link 
> 
> In this case function `fileno` returns -1 because of failure, but this is not 
> indicated in a `NoteTag`. This is a correct result, only the note is missing. 
> This problem can be solved if a note is displayed on every branch ("case") of 
> the standard C functions. But this leads to many notes at un-interesting 
> places. If the note is displayed only at "interesting" values another 
> difficulty shows up: The note disappears from places where it should be shown 
> because the "interestingness" is not set, for example at conditions of `if` 
> statement. So the solution may require more work. This case with function 
> `fileno` occurs 13 times in all the tested projects.

Could you elaborate on what do you mean by "The note disappears from places 
where it should be shown because the "interestingness" is not set, for example 
at conditions of `if` statement.".  A short example would do the job I think.

I looked at the TPs, and if the violation was introduced by an assumption 
(instead of an assignment), then it's really hard to spot which assumption is 
important for the bug.
I wonder if we could add the `TrackConstraintBRVisitor` to the bugreport to 
"highlight" that particular assumption/place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

___
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-06-09 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 529906.
BeMg added a comment.

1. Update testcase
2. Remove supportsMultiVersioning for RISCV


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,81 @@
+; 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() #0 {
+; CHECK-LABEL: test1
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test2() #1 {
+; CHECK-LABEL: test2
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test3() #1 {
+; CHECK-LABEL: test3
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test4() #2 {
+; CHECK-LABEL: test4
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +experimental-zihintntl, +zifencei
+define void @test5() #3 {
+; CHECK-LABEL: test5
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +zifencei
+define void @test7() #4 {
+; CHECK-LABEL: test7
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +zifencei
+define void @test9() #6 {
+; CHECK-LABEL: test9
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+; CHECK: .option push
+; CHECK-NEXT: .optionarch,   +c, +v, +zifencei, +zve32f, +zve32x, +zve64d, +zve64f, +zve64x, +zvl128b, +zvl32b, +zvl64b
+define void @test10() #7 {
+; CHECK-LABEL: test10
+; CHECL: .option pop
+entry:
+  ret void
+}
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-e,-experimental-smaia,-experimental-ssaia,-experimental-zca,-experimental-zcb,-experimental-zcd,-experimental-zcf,-experimental-zcmp,-experimental-zcmt,-experimental-zfa,-experimental-zfbfmin,-experimental-zicond,-experimental-zihintntl,-experimental-ztso,-experimental-zvbb,-experimental-zvbc,-experimental-zvfbfmin,-experimental-zvfbfwma,-experimental-zvfh,-experimental-zvkg,-experimental-zvkn,-experimental-zvkned,-experimental-zvkng,-experimental-zvknha,-experimental-zvknhb,-experimental-zvks,-experimental-zvksed,-experimental-zvksg,-experimental-zvksh,-experimental-zvkt,-h,-save-restore,-svinval,-svnapot,-svpbmt,-xsfvcp,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zdinx,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zicbom,-zicbop,-zicboz,-zicntr,-zihintpause,-zihpm,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b" }
+attributes #1 = { noinline nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic-rv64" 

[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-09 Thread Michael Buch via Phabricator via cfe-commits
Michael137 added a comment.

Looks like the latest reland of this patch broke some debug-info 
`cross-project-tests` on the Arm64 macOS buildbots: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-as/263/execution/node/54/log/

  Failed Tests (2):
cross-project-tests :: debuginfo-tests/dexter-tests/optnone-fastmath.cpp
cross-project-tests :: 
debuginfo-tests/dexter-tests/optnone-struct-and-methods.cpp

You can run those tests by adding `cross-project-tests` to 
`LLVM_ENABLE_PROJECTS` and running `ninja check-debuginfo`.

Let me know if you need help reproducing this


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-09 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

> I am not sure about the exact requirements, this review can be a place for 
> discussion about what should be fixed (if any).

D52984  added the "Making your checker better" 
section to the dev manual: 
https://clang-analyzer.llvm.org/checker_dev_manual.html (nobody can be faulted 
for not finding this, aside from those that witnessed its creation, it has 
faded from the collective memory of the analyzer developers).

In D152436#4405558 , @balazske wrote:

> I could test the checker on these projects (CTU analysis was not used):
> memcached,tmux,curl,twin,vim,openssl,sqlite,ffmpeg,postgres,tinyxml2,libwebm,xerces,bitcoin,protobuf,qtbase,contour,acid
>
> These are reports that could be improved:
> link 
> 
> In this case function `fileno` returns -1 because of failure, but this is not 
> indicated in a `NoteTag`. This is a correct result, only the note is missing. 
> This problem can be solved if a note is displayed on every branch ("case") of 
> the standard C functions. But this leads to many notes at un-interesting 
> places. If the note is displayed only at "interesting" values another 
> difficulty shows up: The note disappears from places where it should be shown 
> because the "interestingness" is not set, for example at conditions of `if` 
> statement. So the solution may require more work. This case with function 
> `fileno` occurs 13 times in all the tested projects.

Yeah, this is a tough cookie... is it okay to find hide the -1 branch behind an 
off-by-default checker option for the time being?

> link 
> 
> The function `open` is not modeled in `StdCLibraryFunctionsChecker`, it 
> should not return less than -1 but this information is not included now.
> link 
> 
> `socket` can not return less than -1 but this function is not modeled 
> currently.

These should be a rather painless fix, right?

> link 
> 
> This looks wrong, `L` should not be 0 because `len` looks > 0 (see the macros 
> that set `len`). Probably the many bitwise operations cause the problem.
> link 
> 
> When `file_size` is 0 `status.ok()` is probably false that is not correctly 
> recognized (may work in CTU mode?).

Looks like something we can live with.

> link 
> 
> `fwrite` with 0 buffer and 0 size should not be an error, this is not checked 
> now.

Some discussion for that: D140387#inline-1360054 
. There is a FIXME in the code 
for it -- not sure how common this specific issue is, but we did stumble on it 
in an open source project... how painful would it be to fix this?

> These results look good:
> link 
> 
> link 
> 
> link 
> 
> link 
> 
> link 
> 

[PATCH] D149437: [clangd] Emit ChangeAnnotation label and description for include-cleaner diagnostics.

2023-06-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

thanks, mostly LG. I think we need to be a little careful when generating 
insertions for all the missing includes though.




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:169
 
-std::vector generateMissingIncludeDiagnostics(
+using MissingIncludeEdits = llvm::MapVector;
+MissingIncludeEdits generateMissingIncludeEdits(

what do we gain by preserving the insertion order here exactly?

in `generateMissingIncludeDiagnostics`, we already traverse using the order of 
`MissingIncludeDiagInfo`s and inside `addAllMissingIncludes` the order we 
preserved here (diagnostic order) doesn't really make much sense, we probably 
should generate fixes in the order of insertion location, or header spelling.

so what about just using a DenseMap ?



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:176
   const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID());
+  const Config  = Config::current();
 

nit: maybe inline into the call site



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:330
+  llvm::DenseMap>
+  HeaderToSymbols;

we might still have symbols with the same name (`ns1::Foo` vs `ns2::Foo`), 
they'll show up the same in the final annotation.

since we're already sorting by name, we might as well deduplicate after sorting 
and store just a SmallVector here



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:353
+ChangeAnnotationIdentifier ID = AddAllMissingID + std::to_string(I++);
+AddAllMissing.Edits.push_back(Edit);
+AddAllMissing.Edits.back().annotationId = ID;

we might generate multiple insertions to same location here e.g. insert `a.h` 
and `b.h` at the top of the file. 
[LSP](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textEditArray)
 says that order reported by the server will be preserved. hence we should 
actually make sure our edits are ordered by spelling.



Comment at: clang-tools-extra/clangd/IncludeCleaner.h:44
   }
+  include_cleaner::Header header() const {
+assert(!Providers.empty());

can you put definition out-of-line ?



Comment at: 
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h:71
 
+  std::string name() const;
+

// Unqualified name of the symbol


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149437

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


[PATCH] D152495: [Clang][SemaCXX] Add unused warning for variables declared in condition expressions

2023-06-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:2852
- "Should not use decl without marking it used!");
-
   if (ND->hasAttr()) {

Question for other reviewers: If we want to keep this assertion, would it 
instead make sense to mark the decl as used after emitting the diagnostic, in 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaDecl.cpp#L2154
 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152495

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


[PATCH] D152403: [Clang][CUDA] Disable diagnostics for neon attrs for GPU-side CUDA compilation

2023-06-09 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b0ea4874093: [Clang][CUDA] Disable diagnostics for neon 
attrs for GPU-side CUDA compilation (authored by alexander-shaposhnikov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152403

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCUDA/neon-attrs.cu


Index: clang/test/SemaCUDA/neon-attrs.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/neon-attrs.cu
@@ -0,0 +1,21 @@
+// CPU-side compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify=quiet %s
+
+// CPU-side compilation on ARM with neon disabled.
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on ARM (no errors expected).
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s
+
+// Regular C++ compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -x c++ 
-fsyntax-only -verify=quiet %s
+
+// Regular C++ compilation on ARM with neon disabled.
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -x c++ 
-fsyntax-only -verify %s
+
+// quiet-no-diagnostics
+typedef __attribute__((neon_vector_type(4))) float float32x4_t;
+// expected-error@-1 {{'neon_vector_type' attribute is not supported on 
targets missing 'neon' or 'mve'}}
+typedef unsigned char poly8_t;
+typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t;
+// expected-error@-1 {{'neon_polyvector_type' attribute is not supported on 
targets missing 'neon' or 'mve'}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8169,10 +8169,18 @@
 /// match one of the standard Neon vector types.
 static void HandleNeonVectorTypeAttr(QualType , const ParsedAttr ,
  Sema , VectorType::VectorKind VecKind) {
+  bool IsTargetCUDAAndHostARM = false;
+  if (S.getLangOpts().CUDAIsDevice) {
+const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
+IsTargetCUDAAndHostARM =
+AuxTI && (AuxTI->getTriple().isAArch64() || 
AuxTI->getTriple().isARM());
+  }
+
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!S.Context.getTargetInfo().hasFeature("neon") &&
-  !S.Context.getTargetInfo().hasFeature("mve")) {
+  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
+S.Context.getTargetInfo().hasFeature("mve") ||
+IsTargetCUDAAndHostARM)) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
 << Attr << "'neon' or 'mve'";
 Attr.setInvalid();
@@ -8180,8 +8188,8 @@
   }
   // Check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
-S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr
-  << 1;
+S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+<< Attr << 1;
 Attr.setInvalid();
 return;
   }
@@ -8191,7 +8199,8 @@
 return;
 
   // Only certain element types are supported for Neon vectors.
-  if (!isPermittedNeonBaseType(CurType, VecKind, S)) {
+  if (!isPermittedNeonBaseType(CurType, VecKind, S) &&
+  !IsTargetCUDAAndHostARM) {
 S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
 Attr.setInvalid();
 return;


Index: clang/test/SemaCUDA/neon-attrs.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/neon-attrs.cu
@@ -0,0 +1,21 @@
+// CPU-side compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify=quiet %s
+
+// CPU-side compilation on ARM with neon disabled.
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple nvptx64 -x cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on ARM (no errors expected).
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu -fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s
+
+// Regular C++ compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -x c++ -fsyntax-only -verify=quiet %s
+
+// Regular C++ compilation on ARM with neon disabled.
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -x c++ -fsyntax-only -verify %s
+
+// quiet-no-diagnostics
+typedef __attribute__((neon_vector_type(4))) float float32x4_t;
+// expected-error@-1 

[clang] 8b0ea48 - [Clang][CUDA] Disable diagnostics for neon attrs for GPU-side CUDA compilation

2023-06-09 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-06-09T09:27:01Z
New Revision: 8b0ea48740935d819618d8254fc45d98179b672c

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

LOG: [Clang][CUDA] Disable diagnostics for neon attrs for GPU-side CUDA 
compilation

Disable diagnostics for neon attributes for GPU-side CUDA compilation.

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D152403

Added: 
clang/test/SemaCUDA/neon-attrs.cu

Modified: 
clang/lib/Sema/SemaType.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 039082ecb29ba..2b2d17b469057 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8169,10 +8169,18 @@ static bool verifyValidIntegerConstantExpr(Sema , 
const ParsedAttr ,
 /// match one of the standard Neon vector types.
 static void HandleNeonVectorTypeAttr(QualType , const ParsedAttr ,
  Sema , VectorType::VectorKind VecKind) {
+  bool IsTargetCUDAAndHostARM = false;
+  if (S.getLangOpts().CUDAIsDevice) {
+const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
+IsTargetCUDAAndHostARM =
+AuxTI && (AuxTI->getTriple().isAArch64() || 
AuxTI->getTriple().isARM());
+  }
+
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!S.Context.getTargetInfo().hasFeature("neon") &&
-  !S.Context.getTargetInfo().hasFeature("mve")) {
+  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
+S.Context.getTargetInfo().hasFeature("mve") ||
+IsTargetCUDAAndHostARM)) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
 << Attr << "'neon' or 'mve'";
 Attr.setInvalid();
@@ -8180,8 +8188,8 @@ static void HandleNeonVectorTypeAttr(QualType , 
const ParsedAttr ,
   }
   // Check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
-S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments) << Attr
-  << 1;
+S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
+<< Attr << 1;
 Attr.setInvalid();
 return;
   }
@@ -8191,7 +8199,8 @@ static void HandleNeonVectorTypeAttr(QualType , 
const ParsedAttr ,
 return;
 
   // Only certain element types are supported for Neon vectors.
-  if (!isPermittedNeonBaseType(CurType, VecKind, S)) {
+  if (!isPermittedNeonBaseType(CurType, VecKind, S) &&
+  !IsTargetCUDAAndHostARM) {
 S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
 Attr.setInvalid();
 return;

diff  --git a/clang/test/SemaCUDA/neon-attrs.cu 
b/clang/test/SemaCUDA/neon-attrs.cu
new file mode 100644
index 0..a72b03f3bbbd7
--- /dev/null
+++ b/clang/test/SemaCUDA/neon-attrs.cu
@@ -0,0 +1,21 @@
+// CPU-side compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify=quiet %s
+
+// CPU-side compilation on ARM with neon disabled.
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify %s
+
+// GPU-side compilation on ARM (no errors expected).
+// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s
+
+// Regular C++ compilation on ARM with neon enabled (no errors expected).
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -x c++ 
-fsyntax-only -verify=quiet %s
+
+// Regular C++ compilation on ARM with neon disabled.
+// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -x c++ 
-fsyntax-only -verify %s
+
+// quiet-no-diagnostics
+typedef __attribute__((neon_vector_type(4))) float float32x4_t;
+// expected-error@-1 {{'neon_vector_type' attribute is not supported on 
targets missing 'neon' or 'mve'}}
+typedef unsigned char poly8_t;
+typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t;
+// expected-error@-1 {{'neon_polyvector_type' attribute is not supported on 
targets missing 'neon' or 'mve'}}



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


[PATCH] D150427: [AMDGPU] Non hostcall printf support for HIP

2023-06-09 Thread Vikram Hegde via Phabricator via cfe-commits
vikramRH updated this revision to Diff 529865.
vikramRH added a comment.

Handled last set of review comments from @arsenm, would be willing to handle 
any new findings/concerns via additional patches


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150427

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenHIP/default-attributes.hip
  clang/test/CodeGenHIP/printf-kind-module-flag.hip
  clang/test/CodeGenHIP/printf_nonhostcall.cpp
  clang/test/CodeGenHIP/sanitize-undefined-null.hip
  clang/test/Driver/hip-options.hip
  llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp

Index: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
===
--- llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
+++ llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
@@ -17,6 +17,9 @@
 #include "llvm/Transforms/Utils/AMDGPUEmitPrintf.h"
 #include "llvm/ADT/SparseBitVector.h"
 #include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Support/DataExtractor.h"
+#include "llvm/Support/MD5.h"
+#include "llvm/Support/MathExtras.h"
 
 using namespace llvm;
 
@@ -179,11 +182,7 @@
 
 // Scan the format string to locate all specifiers, and mark the ones that
 // specify a string, i.e, the "%s" specifier with optional '*' characters.
-static void locateCStrings(SparseBitVector<8> , Value *Fmt) {
-  StringRef Str;
-  if (!getConstantStringInfo(Fmt, Str) || Str.empty())
-return;
-
+static void locateCStrings(SparseBitVector<8> , StringRef Str) {
   static const char ConvSpecifiers[] = "diouxXfFeEgGaAcspn";
   size_t SpecPos = 0;
   // Skip the first argument, the format string.
@@ -207,14 +206,322 @@
   }
 }
 
-Value *llvm::emitAMDGPUPrintfCall(IRBuilder<> ,
-  ArrayRef Args) {
+// helper struct to package the string related data
+struct StringData {
+  StringRef Str;
+  Value *RealSize = nullptr;
+  Value *AlignedSize = nullptr;
+  bool IsConst = true;
+
+  StringData(StringRef ST, Value *RS, Value *AS, bool IC)
+  : Str(ST), RealSize(RS), AlignedSize(AS), IsConst(IC) {}
+};
+
+// Calculates frame size required for current printf expansion and allocates
+// space on printf buffer. Printf frame includes following contents
+// [ ControlDWord , format string/Hash , Arguments (each aligned to 8 byte) ]
+static Value *callBufferedPrintfStart(
+IRBuilder<> , ArrayRef Args, Value *Fmt,
+bool isConstFmtStr, SparseBitVector<8> ,
+SmallVectorImpl , Value *) {
+  Module *M = Builder.GetInsertBlock()->getModule();
+  Value *NonConstStrLen = nullptr;
+  Value *LenWithNull = nullptr;
+  Value *LenWithNullAligned = nullptr;
+  Value *TempAdd = nullptr;
+
+  // First 4 bytes to be reserved for control dword
+  size_t BufSize = 4;
+  if (isConstFmtStr)
+// First 8 bytes of MD5 hash
+BufSize += 8;
+  else {
+LenWithNull = getStrlenWithNull(Builder, Fmt);
+
+// Align the computed length to next 8 byte boundary
+TempAdd = Builder.CreateAdd(LenWithNull,
+ConstantInt::get(LenWithNull->getType(), 7U));
+NonConstStrLen = Builder.CreateAnd(
+TempAdd, ConstantInt::get(LenWithNull->getType(), ~7U));
+
+StringContents.push_back(
+StringData(StringRef(), LenWithNull, NonConstStrLen, false));
+  }
+
+  for (size_t i = 1; i < Args.size(); i++) {
+if (SpecIsCString.test(i)) {
+  StringRef ArgStr;
+  if (getConstantStringInfo(Args[i], ArgStr)) {
+auto alignedLen = alignTo(ArgStr.size() + 1, 8);
+StringContents.push_back(StringData(
+ArgStr,
+/*RealSize*/ nullptr, /*AlignedSize*/ nullptr, /*IsConst*/ true));
+BufSize += alignedLen;
+  } else {
+LenWithNull = getStrlenWithNull(Builder, Args[i]);
+
+// Align the computed length to next 8 byte boundary
+TempAdd = Builder.CreateAdd(
+LenWithNull, ConstantInt::get(LenWithNull->getType(), 7U));
+LenWithNullAligned = Builder.CreateAnd(
+TempAdd, ConstantInt::get(LenWithNull->getType(), ~7U));
+
+if (NonConstStrLen) {
+  auto Val = Builder.CreateAdd(LenWithNullAligned, NonConstStrLen,
+   "cumulativeAdd");
+  NonConstStrLen = Val;
+} else
+  NonConstStrLen = LenWithNullAligned;
+
+StringContents.push_back(
+StringData(StringRef(), LenWithNull, LenWithNullAligned, false));
+  }
+} else {
+  auto AllocSize = M->getDataLayout().getTypeAllocSize(Args[i]->getType());
+  if (AllocSize <= 8)
+// We end up expanding non string arguments to 8 bytes 
+// (args smaller than 8 bytes)
+

[clang] dcbbdbe - [NFC] remove duplciated unittests for modules

2023-06-09 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-06-09T17:19:32+08:00
New Revision: dcbbdbe3e50214b550383510ba05d059dc38496a

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

LOG: [NFC] remove duplciated unittests for modules

There was an overlook to duplicate the unittests for modules. This patch
removes one of this duplication.

Added: 


Modified: 
clang/unittests/AST/DeclTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/DeclTest.cpp 
b/clang/unittests/AST/DeclTest.cpp
index 0cc7f93153f43..463f35c1cd08b 100644
--- a/clang/unittests/AST/DeclTest.cpp
+++ b/clang/unittests/AST/DeclTest.cpp
@@ -240,23 +240,6 @@ TEST(Decl, ModuleAndInternalLinkage) {
 
   EXPECT_EQ(b->getFormalLinkage(), ModuleLinkage);
   EXPECT_EQ(g->getFormalLinkage(), ModuleLinkage);
-
-  AST = tooling::buildASTFromCodeWithArgs(
-  Code.code(), /*Args=*/{"-std=c++20"});
-  ASTContext  = AST->getASTContext();
-  a = selectFirst("a", match(varDecl(hasName("a")).bind("a"), CtxTS));
-  f = selectFirst(
-  "f", match(functionDecl(hasName("f")).bind("f"), CtxTS));
-
-  EXPECT_EQ(a->getFormalLinkage(), InternalLinkage);
-  EXPECT_EQ(f->getFormalLinkage(), InternalLinkage);
-
-  b = selectFirst("b", match(varDecl(hasName("b")).bind("b"), CtxTS));
-  g = selectFirst(
-  "g", match(functionDecl(hasName("g")).bind("g"), CtxTS));
-
-  EXPECT_EQ(b->getFormalLinkage(), ModuleLinkage);
-  EXPECT_EQ(g->getFormalLinkage(), ModuleLinkage);
 }
 
 TEST(Decl, GetNonTransparentDeclContext) {



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


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-06-09 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

about the comments that the patch seems to do multiple things;  I do not think 
we can fix the lookup without touching the typo-fixes since it uses the same 
underlying machinery - if we do not adjust the typo fixes, we will regress 
diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

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


[PATCH] D144999: [Clang][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-06-09 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added a comment.

I don't think this handles the no-personality case properly. For example this 
code leads to a DWARF entry now:

  void bar(int *) noexcept;
  void foo() {
int arr;
bar();
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D143587: [Docs] Multilib design

2023-06-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM




Comment at: clang/docs/Multilib.rst:231
+
+However, an exception is the normalization of -march.
+-march for Arm architectures contains a list of enabled and disabled extensions

Use backticks to render the flag name as code, same for the other instances in 
this paragraph.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143587

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


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-06-09 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 529852.
iains marked 2 inline comments as done.
iains added a comment.

rebased and adjusted for upstream changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145965

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/module/basic/basic.def.odr/p4.cppm
  clang/test/CXX/module/basic/basic.link/p2.cppm
  clang/test/CXX/module/module.import/p2.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/module/module.interface/p7.cpp
  clang/test/CXX/module/module.reach/ex1.cpp
  clang/test/CXX/module/module.reach/p2.cpp
  clang/test/CXX/module/module.reach/p5.cpp
  clang/test/Modules/Reachability-template-default-arg.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp
  clang/test/Modules/deduction-guide3.cppm
  clang/test/Modules/diagnose-missing-import.m

Index: clang/test/Modules/diagnose-missing-import.m
===
--- clang/test/Modules/diagnose-missing-import.m
+++ clang/test/Modules/diagnose-missing-import.m
@@ -6,9 +6,9 @@
 
 void foo(void) {
   XYZLogEvent(xyzRiskyCloseOpenParam, xyzRiskyCloseOpenParam); // expected-error {{call to undeclared function 'XYZLogEvent'; ISO C99 and later do not support implicit function declarations}} \
-  expected-error {{declaration of 'XYZLogEvent' must be imported}} \
-  expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 'NCI.A'}} \
-  expected-error {{declaration of 'xyzRiskyCloseOpenParam' must be imported from module 'NCI.A'}}
+  expected-error {{declaration of 'XYZLogEvent' is internal to 'NCI.A'}} \
+  expected-error {{declaration of 'xyzRiskyCloseOpenParam' is internal to 'NCI.A'}} \
+  expected-error {{declaration of 'xyzRiskyCloseOpenParam' is internal to 'NCI.A'}}
 }
 
 // expected-note@Inputs/diagnose-missing-import/a.h:5 {{declaration here is not visible}}
Index: clang/test/Modules/deduction-guide3.cppm
===
--- clang/test/Modules/deduction-guide3.cppm
+++ clang/test/Modules/deduction-guide3.cppm
@@ -19,8 +19,8 @@
 //--- Use.cpp
 import Templ;
 void func() {
-Templ t(5); // expected-error {{declaration of 'Templ' must be imported from module 'Templ' before it is required}}
+Templ t(5); // expected-error {{declaration of 'Templ' is private to module 'Templ'}}
 // expected-error@-1 {{unknown type name 'Templ'}}
-// expected-n...@templ.cppm:3 {{declaration here is not visible}}
+// expected-n...@templ.cppm:3 {{export the declaration to make it available}}
 }
 
Index: clang/test/Modules/cxx20-10-1-ex2.cpp
===
--- clang/test/Modules/cxx20-10-1-ex2.cpp
+++ clang/test/Modules/cxx20-10-1-ex2.cpp
@@ -54,8 +54,8 @@
 //--- std10-1-ex2-tu6.cpp
 import B;
 // error, n is module-local and this is not a module.
-int  = n; // expected-error {{declaration of 'n' must be imported}}
-// expected-note@* {{declaration here is not visible}}
+int  = n; // expected-error {{declaration of 'n' is private to module 'B'}}
+// expected-note@* {{export the declaration to make it available}}
 
 //--- std10-1-ex2-tu7.cpp
 // expected-no-diagnostics
Index: clang/test/Modules/Reachability-template-default-arg.cpp
===
--- clang/test/Modules/Reachability-template-default-arg.cpp
+++ clang/test/Modules/Reachability-template-default-arg.cpp
@@ -18,6 +18,6 @@
 import template_default_arg;
 void bar() {
   A<> a0;
-  A a1; // expected-error {{declaration of 't' must be imported from module 'template_default_arg' before it is required}}
-   // expected-note@* {{declaration here is not visible}}
+  A a1; // expected-error {{declaration of 't' is private to module 'template_default_arg'}}
+   // expected-note@* {{export the declaration to make it available}}
 }
Index: clang/test/CXX/module/module.reach/p5.cpp
===
--- clang/test/CXX/module/module.reach/p5.cpp
+++ clang/test/CXX/module/module.reach/p5.cpp
@@ -14,5 +14,5 @@
 export module B;
 import A;
 Y y; // OK, definition of X is reachable
-X x; // expected-error {{declaration of 'X' must be 

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

2023-06-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: NoQ, aaron.ballman, krememek, dergachev.a, MikeStump.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When a declaration has a cleanup function attached, add it to the CFG. This is 
basically a destructor on a per-declaration basis.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152504

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/Sema/warn-thread-safety-analysis.c

Index: clang/test/Sema/warn-thread-safety-analysis.c
===
--- clang/test/Sema/warn-thread-safety-analysis.c
+++ clang/test/Sema/warn-thread-safety-analysis.c
@@ -22,6 +22,7 @@
 #define SHARED_LOCKS_REQUIRED(...) \
   __attribute__ ((shared_locks_required(__VA_ARGS__)))
 #define NO_THREAD_SAFETY_ANALYSIS  __attribute__ ((no_thread_safety_analysis))
+#define CLEANUP(A) __attribute__ ((cleanup(A)))
 
 // Define the mutex struct.
 // Simplified only for test purpose.
@@ -72,6 +73,11 @@
   return *p;
 }
 
+void cleanup_int(int *unused) __attribute__((release_capability(mu1))) {
+  (void)unused;
+  mutex_exclusive_unlock();
+}
+
 int main(void) {
 
   Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu2'}} \
@@ -127,6 +133,15 @@
 // expected-note@-1{{mutex released here}}
   mutex_shared_unlock();// expected-warning {{releasing mutex 'mu1' that was not held}}
 
+
+  {
+mutex_exclusive_lock();
+int CLEANUP(cleanup_int) i;
+
+Bar_fun1(3);
+  }
+  Bar_fun1(4); // expected-warning {{calling function 'Bar_fun1' requires holding mutex 'mu1' exclusively}}
+
   return 0;
 }
 
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -1907,7 +1907,8 @@
 Decls.push_back(*I);
 
   for (VarDecl *VD : llvm::reverse(Decls)) {
-if (hasTrivialDestructor(VD)) {
+bool HasCleanupAttr = VD->hasAttr();
+if (hasTrivialDestructor(VD) && !HasCleanupAttr) {
   // If AddScopes is enabled and *I is a first variable in a scope, add a
   // ScopeEnd marker in a Block.
   if (BuildOpts.AddScopes && DeclsWithEndedScope.count(VD)) {
@@ -1925,7 +1926,8 @@
 }
 Ty = Context->getBaseElementType(Ty);
 
-if (Ty->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
+bool IsCXXRecordType = Ty->getAsCXXRecordDecl() != nullptr;
+if (IsCXXRecordType && Ty->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
   Block = createNoReturnBlock();
 else
   autoCreateBlock();
@@ -1933,7 +1935,28 @@
 // Add ScopeEnd just after automatic obj destructor.
 if (BuildOpts.AddScopes && DeclsWithEndedScope.count(VD))
   appendScopeEnd(Block, VD, S);
-appendAutomaticObjDtor(Block, VD, S);
+
+if (HasCleanupAttr) {
+  // Create a fake CallExpr for the cleanup function.
+  const CleanupAttr *CA = VD->getAttr();
+  FunctionDecl *FD = CA->getFunctionDecl();
+  assert(FD);
+  auto DRE =
+  DeclRefExpr::Create(*Context, {}, {}, VD, false, SourceLocation(),
+  VD->getType(), VK_PRValue);
+
+  auto F = DeclRefExpr::Create(*Context, {}, {}, FD, false,
+   SourceLocation(), FD->getType(), VK_LValue);
+
+  SmallVector Args;
+  Args.push_back(DRE);
+  auto A = CallExpr::Create(*Context, F, Args, FD->getType(), VK_PRValue,
+{}, FPOptionsOverride());
+  appendCall(Block, A);
+}
+
+if (IsCXXRecordType)
+  appendAutomaticObjDtor(Block, VD, S);
   }
 }
 
@@ -2090,7 +2113,8 @@
 return Scope;
 
   if (BuildOpts.AddImplicitDtors) {
-if (!hasTrivialDestructor(VD) || BuildOpts.AddScopes) {
+if (!hasTrivialDestructor(VD) || VD->hasAttr() ||
+BuildOpts.AddScopes) {
   // Add the variable to scope
   Scope = createOrReuseLocalScope(Scope);
   Scope->addVar(VD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152418: [clang] set python3 as required build dependency

2023-06-09 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG96962d5512fb: [clang] set python3 as required build 
dependency (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152418

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -82,10 +82,10 @@
   set( CMAKE_LIBRARY_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
-  if(LLVM_INCLUDE_TESTS)
-find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
-  COMPONENTS Interpreter)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
+  if(LLVM_INCLUDE_TESTS)
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
 AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX}


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -82,10 +82,10 @@
   set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
-  if(LLVM_INCLUDE_TESTS)
-find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
-  COMPONENTS Interpreter)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
+  if(LLVM_INCLUDE_TESTS)
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
 AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 96962d5 - [clang] set python3 as required build dependency

2023-06-09 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2023-06-09T07:52:48Z
New Revision: 96962d5512fbc6af0ada0f13e6be332c026529cb

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

LOG: [clang] set python3 as required build dependency

The required HTMLLogger include file needs python3 to run
resource_bundle.py to bundle all the html/css/js resources. However, if
user sets -DLLVM_INCLUDE_TESTS=OFF, CMake will not find python3 and the
resource bundler will never be executed. This patch set the python3 as a
required build dependency to fix this problem.

Patch By: Avimitin

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 8220a9dbfd4db..f7936d72e0882 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -82,10 +82,10 @@ if(CLANG_BUILT_STANDALONE)
   set( CMAKE_LIBRARY_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
-  if(LLVM_INCLUDE_TESTS)
-find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
-  COMPONENTS Interpreter)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
+  if(LLVM_INCLUDE_TESTS)
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
 AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX}



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


[clang] 2c44168 - [Clang] Remove typed pointer consistency assertions (NFC)

2023-06-09 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-06-09T09:45:43+02:00
New Revision: 2c44168381f0b06eb629cd093510a9fca6913066

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

LOG: [Clang] Remove typed pointer consistency assertions (NFC)

These are no-ops with opaque pointers.

Added: 


Modified: 
clang/lib/CodeGen/Address.h
clang/lib/CodeGen/CGBuilder.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGValue.h

Removed: 




diff  --git a/clang/lib/CodeGen/Address.h b/clang/lib/CodeGen/Address.h
index a45df7f8497e4..e020d95344ade 100644
--- a/clang/lib/CodeGen/Address.h
+++ b/clang/lib/CodeGen/Address.h
@@ -41,9 +41,6 @@ class Address {
 ElementType(ElementType), Alignment(Alignment) {
 assert(Pointer != nullptr && "Pointer cannot be null");
 assert(ElementType != nullptr && "Element type cannot be null");
-assert(llvm::cast(Pointer->getType())
-   ->isOpaqueOrPointeeTypeMatches(ElementType) &&
-   "Incorrect pointer element type");
   }
 
   static Address invalid() { return Address(nullptr); }

diff  --git a/clang/lib/CodeGen/CGBuilder.h b/clang/lib/CodeGen/CGBuilder.h
index f18d8be5ecd9d..902fd94570837 100644
--- a/clang/lib/CodeGen/CGBuilder.h
+++ b/clang/lib/CodeGen/CGBuilder.h
@@ -89,8 +89,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
   llvm::LoadInst *CreateAlignedLoad(llvm::Type *Ty, llvm::Value *Addr,
 CharUnits Align,
 const llvm::Twine  = "") {
-assert(llvm::cast(Addr->getType())
-   ->isOpaqueOrPointeeTypeMatches(Ty));
 return CreateAlignedLoad(Ty, Addr, Align.getAsAlign(), Name);
   }
 
@@ -120,15 +118,11 @@ class CGBuilderTy : public CGBuilderBaseTy {
   /// Emit a load from an i1 flag variable.
   llvm::LoadInst *CreateFlagLoad(llvm::Value *Addr,
  const llvm::Twine  = "") {
-assert(llvm::cast(Addr->getType())
-   ->isOpaqueOrPointeeTypeMatches(getInt1Ty()));
 return CreateAlignedLoad(getInt1Ty(), Addr, CharUnits::One(), Name);
   }
 
   /// Emit a store to an i1 flag variable.
   llvm::StoreInst *CreateFlagStore(bool Value, llvm::Value *Addr) {
-assert(llvm::cast(Addr->getType())
-   ->isOpaqueOrPointeeTypeMatches(getInt1Ty()));
 return CreateAlignedStore(getInt1(Value), Addr, CharUnits::One());
   }
 
@@ -157,9 +151,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
   using CGBuilderBaseTy::CreateAddrSpaceCast;
   Address CreateAddrSpaceCast(Address Addr, llvm::Type *Ty,
   const llvm::Twine  = "") {
-assert(cast(Ty)->isOpaqueOrPointeeTypeMatches(
-   Addr.getElementType()) &&
-   "Should not change the element type");
 return Addr.withPointer(CreateAddrSpaceCast(Addr.getPointer(), Ty, Name),
 Addr.isKnownNonNull());
   }

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index eb45e82fe8256..d39131828c066 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4912,25 +4912,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
 CGM, Loc, dyn_cast_or_null(CurCodeDecl), FD, CallArgs);
   }
 
-#ifndef NDEBUG
-  if (!(CallInfo.isVariadic() && CallInfo.getArgStruct())) {
-// For an inalloca varargs function, we don't expect CallInfo to match the
-// function pointer's type, because the inalloca struct a will have extra
-// fields in it for the varargs parameters.  Code later in this function
-// bitcasts the function pointer to the type derived from CallInfo.
-//
-// In other cases, we assert that the types match up (until pointers stop
-// having pointee types).
-if (Callee.isVirtual())
-  assert(IRFuncTy == Callee.getVirtualFunctionType());
-else {
-  llvm::PointerType *PtrTy =
-  
llvm::cast(Callee.getFunctionPointer()->getType());
-  assert(PtrTy->isOpaqueOrPointeeTypeMatches(IRFuncTy));
-}
-  }
-#endif
-
   // 1. Set up the arguments.
 
   // If we're using inalloca, insert the allocation after the stack save.

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index bbbe4749cdfb0..4c5d14e1e7028 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1405,9 +1405,6 @@ void 
CodeGenFunction::EmitAndRegisterVariableArrayDimensions(
 else {
   // Create an artificial VarDecl to generate debug info for.
   IdentifierInfo *NameIdent = VLAExprNames[NameIdx++];
-  assert(cast(VlaSize.NumElts->getType())
- ->isOpaqueOrPointeeTypeMatches(SizeTy) &&
- "Number of VLA elements must be SizeTy");
   auto QT = 

[PATCH] D152473: [clang-format] Add test case for issue 63170

2023-06-09 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

Can you add the test to clang/unittests/Format/FormatTest.cpp instead? Please 
also include the full diff. See 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152473

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


[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines as a driver option

2023-06-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 529832.

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

https://reviews.llvm.org/D152090

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/caret-diagnostics-max-lines.cpp
  clang/test/FixIt/fixit-function-call.cpp
  clang/test/Misc/caret-diags-multiline.cpp
  clang/test/Sema/caret-diags-complex-init.cpp

Index: clang/test/Sema/caret-diags-complex-init.cpp
===
--- clang/test/Sema/caret-diags-complex-init.cpp
+++ clang/test/Sema/caret-diags-complex-init.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace
+// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=5 %s 2>&1 | FileCheck %s -strict-whitespace
 
 
 //CHECK: {{.*}}: error: excess elements in scalar initializer
Index: clang/test/Misc/caret-diags-multiline.cpp
===
--- clang/test/Misc/caret-diags-multiline.cpp
+++ clang/test/Misc/caret-diags-multiline.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace
+// RUN: not %clang_cc1 -std=c++11 -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=5 -Wsometimes-uninitialized %s 2>&1 | FileCheck %s --strict-whitespace
 
 void line(int);
 
Index: clang/test/FixIt/fixit-function-call.cpp
===
--- clang/test/FixIt/fixit-function-call.cpp
+++ clang/test/FixIt/fixit-function-call.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> %t
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines=1 -x c++ %s 2> %t
 // RUN: FileCheck %s < %t
 // PR5941
 // END.
Index: clang/test/Driver/caret-diagnostics-max-lines.cpp
===
--- /dev/null
+++ clang/test/Driver/caret-diagnostics-max-lines.cpp
@@ -0,0 +1,13 @@
+//RUN: not %clang++ -fsyntax-only -fcaret-diagnostics-max-lines=2 %s 2>&1 | FileCheck %s -strict-whitespace
+
+
+static_assert(false &&
+// Comment
+true, "");
+
+// CHECK: error: static assertion failed due to requirement
+// CHECK-NEXT: {{^}}4 | static_assert(false &&{{$}}
+// CHECK-NEXT: {{^}}  |   {{$}}
+// CHECK-NEXT: {{^}}5 | // Comment
+// CHECK-NEXT: {{^}}  | ~~{{$}}
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6042,6 +6042,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_fmacro_backtrace_limit_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftemplate_backtrace_limit_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_fspell_checking_limit_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_fcaret_diagnostics_max_lines_EQ);
 
   // Pass -fmessage-length=.
   unsigned MessageLength = 0;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2297,6 +2297,11 @@
   Group, Flags<[NoXarchOption, CC1Option, CoreOption]>,
   HelpText<"Set the maximum number of entries to print in a macro expansion backtrace (0 = no limit)">,
   MarshallingInfoInt, "DiagnosticOptions::DefaultMacroBacktraceLimit">;
+def fcaret_diagnostics_max_lines_EQ :
+  Joined<["-"], "fcaret-diagnostics-max-lines=">,
+  Group, Flags<[NoXarchOption, CC1Option, CoreOption]>,
+  HelpText<"Set the maximum number of source lines to show in a caret diagnostic (0 = no limit).">,
+  MarshallingInfoInt, "DiagnosticOptions::DefaultSnippetLineLimit">;
 defm merge_all_constants : BoolFOption<"merge-all-constants",
   CodeGenOpts<"MergeAllConstants">, DefaultFalse,
   PosFlag, NegFlag,
@@ -5941,10 +5946,6 @@
 def ferror_limit : Separate<["-"], "ferror-limit">, MetaVarName<"">,
   HelpText<"Set the maximum number of errors to emit before stopping (0 = no limit).">,
   MarshallingInfoInt>;
-def fcaret_diagnostics_max_lines :
-  Separate<["-"], "fcaret-diagnostics-max-lines">, MetaVarName<"">,
-  HelpText<"Set the maximum number of source lines to show in a caret diagnostic">,
-  MarshallingInfoInt, "DiagnosticOptions::DefaultSnippetLineLimit">;
 def verify_EQ : CommaJoined<["-"], "verify=">,
   MetaVarName<"">,
   HelpText<"Verify diagnostic output using comment directives that start with"
Index: clang/docs/ReleaseNotes.rst

<    1   2