[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


[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 &Name = "") {
-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 &Name = "") {
-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 &Name = "") {
-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 
&CallInfo,
 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 = getConte

[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


[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


[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(&mu1);
+}
+
 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(&mu1);// expected-warning {{releasing mutex 'mu1' that was not held}}
 
+
+  {
+mutex_exclusive_lock(&mu1);
+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] 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 &c = n; // expected-error {{declaration of 'n' must be imported}}
-// expected-note@* {{declaration here is not visible}}
+int &c = 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] 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] 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(&arr);
  }


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


[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 &CtxTS = 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] 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> &BV, Value *Fmt) {
-  StringRef Str;
-  if (!getConstantStringInfo(Fmt, Str) || Str.empty())
-return;
-
+static void locateCStrings(SparseBitVector<8> &BV, 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<> &Builder,
-  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<> &Builder, ArrayRef Args, Value *Fmt,
+bool isConstFmtStr, SparseBitVector<8> &SpecIsCString,
+SmallVectorImpl &StringContents, Value *&ArgSize) {
+  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

[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 &S, 
const ParsedAttr &Attr,
 /// match one of the standard Neon vector types.
 static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
  Sema &S, 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 &CurType, 
const ParsedAttr &Attr,
   }
   // 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 &CurType, 
const ParsedAttr &Attr,
 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] 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 &CurType, const ParsedAttr &Attr,
  Sema &S, 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;
+// expe

[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] 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 &Cfg = 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] 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 
> 

[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] 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" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,+zicsr,+zifencei,-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,-v,-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,-zve32f,-

[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] 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, &Invalid);
@@ -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] 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&to=97f1c0cde42ba85eaa67cbe89bec8fe45b801f21&stat=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(&F.getEntryBlock());
 
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 &Dead);
 
-  using ToShrinkSet = SetVector,
-SmallPtrSet>;
+  using ToShrinkSet = SmallSetVector;
 
   /// Helper for eliminateDeadDefs.
   void eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink);
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 ar

[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] 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] 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] 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


[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 &C, 
const JobAction &JA,
 
   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 &C, 
const JobAction &JA,
  /*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] 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"
 

[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] 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 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] 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


[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] 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] 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 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 update

[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] 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, &V, 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] 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] 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] 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] 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(&arr);
>   }

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] 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] 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 &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
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 &AST, 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 &AST,
   const llvm::DenseSet &ReferencedFiles,
@@ -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 &Diag : 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 &Diag : MissingIncludeDiags) {
 assert(Diag.Fixes.size() == 1 && "Expected exactly one fix.");
-for (const auto& Edit : Diag.Fixes.front().Edits) {
+for (const auto &Edit : 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 &RemoveAllUnused, const Fix &AddAllMissing) {
   Fix FixAll;
   FixAll.Message = "fix all includes";
 
@@ -526,22 +512,23 @@
   for (const auto &F : AddAllMissing.Edits)
 FixAll.Edits.push_back(F);
 
-  for (const auto& A : RemoveAllUnused.Annotations)
+  for (const auto &A : RemoveAllUnused.Annotations)
 FixAll.Annotations.push_back(A);
-  for (const auto& A : AddAllMissing.Annotations)
+  for (const auto &A : AddAllMissing.Annotations)
 FixAll.Annotations.push_back(A);
   return FixAll;
 }
 
-std::vector generateIncludeCleanerDiagnostic(
-ParsedAST &AST, const IncludeCleanerFindings &Findings,
-llvm::StringRef Code) {
+std::vector
+generateIncludeCleanerDiagnostic(ParsedAST &AST,
+ const IncludeCleanerFindings &Findings,
+ 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 =
+  generateM

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

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] 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 &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
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 &AST, 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 &AST,
   const llvm::DenseSet &ReferencedFiles,
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 &SM,
 const llvm::ArrayRef Includes);
 
-/// Determines the header spelling of an include-cleaner header
-/// representation. The spelling contains the ""<> characters.
-std::string spellHeader(ParsedAST &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider);
-
 std::vector
 collectMacroReferences(ParsedAST &AST);
 
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 &AST, const FileEntry *MainFile,
-include_cleaner::Header Provider) {
-  if (Provider.kind() == include_cleaner::Header::Physical) {
-if (auto CanonicalPath =
-getCanonicalPath(Provider.physical()->getLastRef(),
- AST.getSourceManager().getFileManage

[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] 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] 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] 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] 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] 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 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] 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] 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] 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] 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] 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] 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] 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] 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 &S, CodePtr OpPC, const Pointer &This) {
   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 &S, 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] 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] D152551: [clang] Remove dead parameter of CGBuilderTy::CreateElementBitCast (NFC)

2023-06-09 Thread Youngsuk Kim via Phabricator via cfe-commits
JOE1994 created this revision.
Herald added a project: All.
JOE1994 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove the 'Name' parameter of `CreateElementBitcast()`, which is
unused.

Depends on D152321 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152551

Files:
  clang/lib/CodeGen/CGBlocks.cpp
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7668,7 +7668,7 @@
 Address(CGF.Builder.CreateLoad(OverflowArgAreaPtr, "overflow_arg_area"),
 CGF.Int8Ty, TyInfo.Align);
 Address MemAddr =
-CGF.Builder.CreateElementBitCast(OverflowArgArea, DirectTy, "mem_addr");
+CGF.Builder.CreateElementBitCast(OverflowArgArea, DirectTy);
 
 // Update overflow_arg_area_ptr pointer
 llvm::Value *NewOverflowArgArea = CGF.Builder.CreateGEP(
@@ -7726,7 +7726,7 @@
   CGF.Builder.CreateGEP(CGF.Int8Ty, RegSaveArea, RegOffset, "raw_reg_addr"),
   CGF.Int8Ty, PaddedSize);
   Address RegAddr =
-  CGF.Builder.CreateElementBitCast(RawRegAddr, DirectTy, "reg_addr");
+  CGF.Builder.CreateElementBitCast(RawRegAddr, DirectTy);
 
   // Update the register count
   llvm::Value *One = llvm::ConstantInt::get(IndexTy, 1);
@@ -7747,7 +7747,7 @@
   Address RawMemAddr =
   CGF.Builder.CreateConstByteGEP(OverflowArgArea, Padding, "raw_mem_addr");
   Address MemAddr =
-CGF.Builder.CreateElementBitCast(RawMemAddr, DirectTy, "mem_addr");
+CGF.Builder.CreateElementBitCast(RawMemAddr, DirectTy);
 
   // Update overflow_arg_area_ptr pointer
   llvm::Value *NewOverflowArgArea =
@@ -8856,7 +8856,7 @@
   // FIXME: Need to handle alignment
   llvm::Type *BP = CGF.Int8PtrTy;
   CGBuilderTy &Builder = CGF.Builder;
-  Address VAListAddrAsBPP = Builder.CreateElementBitCast(VAListAddr, BP, "ap");
+  Address VAListAddrAsBPP = Builder.CreateElementBitCast(VAListAddr, BP);
   llvm::Value *Addr = Builder.CreateLoad(VAListAddrAsBPP, "ap.cur");
   // Handle address alignment for type alignment > 32 bits
   uint64_t TyAlign = CGF.getContext().getTypeAlign(Ty) / 8;
@@ -9981,7 +9981,7 @@
   case ABIArgInfo::Indirect:
   case ABIArgInfo::IndirectAliased:
 Stride = SlotSize;
-ArgAddr = Builder.CreateElementBitCast(Addr, ArgPtrTy, "indirect");
+ArgAddr = Builder.CreateElementBitCast(Addr, ArgPtrTy);
 ArgAddr = Address(Builder.CreateLoad(ArgAddr, "indirect.arg"), ArgTy,
   TypeInfo.Align);
 break;
@@ -9994,7 +9994,7 @@
   Address NextPtr = Builder.CreateConstInBoundsByteGEP(Addr, Stride, "ap.next");
   Builder.CreateStore(NextPtr.getPointer(), VAListAddr);
 
-  return Builder.CreateElementBitCast(ArgAddr, ArgTy, "arg.addr");
+  return Builder.CreateElementBitCast(ArgAddr, ArgTy);
 }
 
 void SparcV9ABIInfo::computeInfo(CGFunctionInfo &FI) const {
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1279,7 +1279,7 @@
 void MicrosoftCXXABI::EmitVBPtrStores(CodeGenFunction &CGF,
   const CXXRecordDecl *RD) {
   Address This = getThisAddress(CGF);
-  This = CGF.Builder.CreateElementBitCast(This, CGM.Int8Ty, "this.int8");
+  This = CGF.Builder.CreateElementBitCast(This, CGM.Int8Ty);
   const ASTContext &Context = getContext();
   const ASTRecordLayout &Layout = Context.getASTRecordLayout(RD);
 
@@ -1296,8 +1296,7 @@
 Address VBPtr = CGF.Builder.CreateConstInBoundsByteGEP(This, Offs);
 llvm::Value *GVPtr =
 CGF.Builder.CreateConstInBoundsGEP2_32(GV->getValueType(), GV, 0, 0);
-VBPtr = CGF.Builder.CreateElementBitCast(VBPtr, GVPtr->getType(),
-  "vbptr." + VBT->ObjectWithVPtr->getName());
+VBPtr = CGF.Builder.CreateElementBitCast(VBPtr, GVPtr->getType());
 CGF.Builder.CreateStore(GVPtr, VBPtr);
   }
 }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1936,7 +1936,7 @@
 = llvm::ConstantInt::get(CGF.IntPtrTy, baseSize.getQuantity());
 
   Address begin =
-Builder.CreateElementBitCast(dest, CGF.Int8Ty, "vla.begin");
+Builder.CreateElementBitCast(dest, CGF.Int8Ty);
   llvm::Value *end = Builder.CreateInBoundsGEP(
   begin.getElementType(), begin.getPointer(), sizeInChars, "vla.end");
 
@@ -2142,7 +2142,7

[clang] 5548843 - [Driver] Mark many target-specific driver-only options as TargetSpecific

2023-06-09 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-06-09T09:26:37-07:00
New Revision: 5548843d692a92a7840f14002debc3cebcb3cdc3

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

LOG: [Driver] Mark many target-specific driver-only options as TargetSpecific

so that they get an error on other targets. This change uses let statements to
apply `Flags = [TargetSpecific]` to options (mostly -m*) without specifying 
`Flags`.
Follow-up to D151590.

For some options, e.g. -mdefault-build-attributes (D31813), -mbranch-likely
(D38168), -mfpu=/-mabi= (6890b9b71e525020ab58d436336664beede71575), a warning
seems desired in at least certain cases. This is not the best practice, but this
change works around them by not applying `Flags = [TargetSpecific]`.

(
For Intel CPU errata -malign-branch= family options, we also drop the unneeded
NotXarchOption flag. This flag reports an error if the option is used with
-Xarch_*. This error reporting does not seem very useful.
)

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/munaligned-access-unused.c
clang/test/Driver/x86-malign-branch.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0a17de56c74de..0af3b7f12fd8f 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -251,6 +251,10 @@ def flang_ignored_w_Group : OptionGroup<"">,
 def clang_ignored_legacy_options_Group : OptionGroup<"">,
   Group, Flags<[Ignored]>;
 
+def LongDouble_Group : OptionGroup<"">, Group,
+  DocName<"Long double flags">,
+  DocBrief<[{Selects the long double implementation}]>;
+
 // Retired with clang-5.0
 def : Flag<["-"], "fslp-vectorize-aggressive">, 
Group;
 def : Flag<["-"], "fno-slp-vectorize-aggressive">, 
Group;
@@ -3492,36 +3496,39 @@ def mno_iamcu : Flag<["-"], "mno-iamcu">, 
Group, Flags<[NoXarchOption,
 def malign_functions_EQ : Joined<["-"], "malign-functions=">, 
Group;
 def malign_loops_EQ : Joined<["-"], "malign-loops=">, 
Group;
 def malign_jumps_EQ : Joined<["-"], "malign-jumps=">, 
Group;
-def malign_branch_EQ : CommaJoined<["-"], "malign-branch=">, Group, 
Flags<[NoXarchOption]>,
+
+let Flags = [TargetSpecific] in {
+def malign_branch_EQ : CommaJoined<["-"], "malign-branch=">, Group,
   HelpText<"Specify types of branches to align">;
-def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group, Flags<[NoXarchOption]>,
+def malign_branch_boundary_EQ : Joined<["-"], "malign-branch-boundary=">, 
Group,
   HelpText<"Specify the boundary's size to align branches">;
-def mpad_max_prefix_size_EQ : Joined<["-"], "mpad-max-prefix-size=">, 
Group, Flags<[NoXarchOption]>,
+def mpad_max_prefix_size_EQ : Joined<["-"], "mpad-max-prefix-size=">, 
Group,
   HelpText<"Specify maximum number of prefixes to use for padding">;
-def mbranches_within_32B_boundaries : Flag<["-"], 
"mbranches-within-32B-boundaries">, Flags<[NoXarchOption]>, Group,
+def mbranches_within_32B_boundaries : Flag<["-"], 
"mbranches-within-32B-boundaries">, Group,
   HelpText<"Align selected branches (fused, jcc, jmp) within 32-byte 
boundary">;
 def mfancy_math_387 : Flag<["-"], "mfancy-math-387">, 
Group;
 def mlong_calls : Flag<["-"], "mlong-calls">, Group,
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
+} // let Flags = [TargetSpecific]
 def mdouble_EQ : Joined<["-"], "mdouble=">, Group,
   MetaVarName<", Values<"32,64">, Flags<[CC1Option]>,
   HelpText<"Force double to be  bits">,
   MarshallingInfoInt, "0">;
-def LongDouble_Group : OptionGroup<"">, Group,
-  DocName<"Long double flags">,
-  DocBrief<[{Selects the long double implementation}]>;
 def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
 def mlong_double_80 : Flag<["-"], "mlong-double-80">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 80 bits, padded to 128 bits for storage">;
 def mlong_double_128 : Flag<["-"], "mlong-double-128">, 
Group, Flags<[CC1Option]>,
   HelpText<"Force long double to be 128 bits">;
+let Flags = [TargetSpecific] in {
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
+} // let Flags = [TargetSpecific]
 def mexecute_only : Flag<["-"], "mexecute-only">, Group,
   HelpText<"Disallow generation of data access to code sections (ARM only)">;
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
   HelpText<"Allow generation of data access to code sections (ARM only)">;
+let Flags = [TargetSpecific] in {
 def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft,cp15,el0,el1,el2,el3">,
   HelpText<"Thread pointer access method (AArch32/AAr

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

The point of this patch was to show a regression. I'm not trying to fix 
anything per se. I'd like https://reviews.llvm.org/D151954  and anything that 
depends on it reverted, since it breaks `clang-format`. My understanding was 
that @owenpan was reluctant to revert since they couldn't reproduce the issue, 
but now that they can, I don't see why this can't go in (with a modified 
summary) after the revert (or as part of it).

I can of course revert those patches here, but it didn't make sense to me to do 
that, since it wouldn't show the regression.


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

In D144999#4408248 , @Michael137 
wrote:

> Looks like the latest reland of this patch 
> (`e60b30d5e3878e7d91f8872ec4c4dca00d4a2dfc`) 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`.
>
> AFAICT, it also broke following LLDB test 
> (https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-as/263/execution/node/65/log/):
>
>   Failed Tests (1):
> lldb-api :: functionalities/step-avoids-no-debug/TestStepNoDebug.py
>
> Let me know if you need help reproducing this

Mind taking a look or reverting the patch until the tests pass?


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] D152554: [OpenMP] Migrate deviice code privatization from Clang CodeGen to OMPIRBuilder

2023-06-09 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis created this revision.
TIFitis added reviewers: jsjodin, jdoerfert, kiranktp.
Herald added subscribers: sunshaoce, guansong, hiraditya, yaxunl.
Herald added a project: All.
TIFitis requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jplehr, sstefan1.
Herald added projects: clang, LLVM.

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

Depends on D150860 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152554

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

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

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

2023-06-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1279
+  if (isa(E))
+return nullptr;
+

This needs a comment explaining why we're bailing out here.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1664
 
   // FIXME: Implement C++11 [basic.start.init]p2: if the initializer of a
   // reference is a constant expression, and the reference binds to a 
temporary,

You can probably delete this FIXME comment.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1670
   // desired value of the referee.
-  if (destType->isReferenceType())
-return nullptr;
+  if (!destType->isLValueReferenceType()) {
+QualType nonMemoryDestType = getNonMemoryType(CGM, destType);

Why are you changing this to "isLValueReferenceType"?  I think rvalue 
references need to be handled basically the same way as lvalue references.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

___
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 Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

Please use clang-format on the modified lines.




Comment at: clang/lib/CodeGen/CGBuilder.h:170
   Address CreateElementBitCast(Address Addr, llvm::Type *Ty,
const llvm::Twine &Name = "") {
+return Address(Addr.getPointer(), Ty,

The argument can be removed.

Idea for a follow-up: I would also consider removing this method because it 
does not do what its name says.
Maybe replace it with `Address::withElementType` analagous to 
`Address::withPointer` / `Address::withAlignment`?




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:9351
   // Implement the index operand if not omitted.
   if (Ops.size() > 3) {
 BasePtr = Builder.CreateGEP(MemoryTy, BasePtr, Ops[2]);

Braces are now redundant.



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:238-240
   CharPtrTy = llvm::PointerType::getUnqual(Types.ConvertType(Ctx.CharTy));
   VoidPtrTy = cast(Types.ConvertType(Ctx.VoidPtrTy));
+  VoidPtrPtrTy = llvm::PointerType::get(CGM.getLLVMContext(), 0);

These are all the same types. Replace the variables with single `PtrTy`?




Comment at: clang/lib/CodeGen/CGCUDANV.cpp:272
   auto *RegisterGlobalsFnTy = getRegisterGlobalsFnTy();
-  llvm::Type *Params[] = {RegisterGlobalsFnTy->getPointerTo(), VoidPtrTy,
-  VoidPtrTy, CallbackFnTy->getPointerTo()};
+  llvm::Type *Params[] = {llvm::PointerType::getUnqual(RegisterGlobalsFnTy), 
VoidPtrTy,
+  VoidPtrTy, llvm::PointerType::get(Context, 0)};

Pass Context



Comment at: clang/lib/CodeGen/CGCUDANV.cpp:540
   VoidPtrPtrTy, CharPtrTy, CharPtrTy, CharPtrTy, IntTy,
-  VoidPtrTy,VoidPtrTy, VoidPtrTy, VoidPtrTy, IntTy->getPointerTo()};
+  VoidPtrTy,VoidPtrTy, VoidPtrTy, VoidPtrTy, 
llvm::PointerType::getUnqual(IntTy)};
   llvm::FunctionCallee RegisterFunc = CGM.CreateRuntimeFunction(

Pass Context



Comment at: clang/lib/CodeGen/CGCXX.cpp:175
   // Create the alias with no name.
+  llvm::Type *AliasValueType = getTypes().GetFunctionType(AliasDecl);
   auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",

This looks wrong. It used to be `GetFunctionType(TargetDecl)`.




Comment at: clang/lib/CodeGen/CGCXX.cpp:184
   if (Entry) {
-assert(Entry->getType() == AliasType &&
+assert(Entry->getValueType() == AliasValueType &&
+   Entry->getAddressSpace() == Alias->getAddressSpace() &&

What's the reason for this change?



Comment at: clang/lib/CodeGen/CGException.cpp:2117
+  llvm::Type *PtrTy = llvm::PointerType::get(getLLVMContext(), 0);
+  llvm::Type *PtrsTy = llvm::StructType::get(PtrTy, CGM.VoidPtrTy);
+  llvm::Value *Rec = Builder.CreateStructGEP(PtrsTy, SEHInfo, 0);

I guess this was intended to be named `RecordTy`.




Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1945-1949
   if (TypeInfoLValue TI = base.dyn_cast()) {
-llvm::Type *StdTypeInfoPtrTy =
-CGM.getTypes().ConvertType(base.getTypeInfoType())->getPointerTo();
 llvm::Constant *TypeInfo =
 CGM.GetAddrOfRTTIDescriptor(QualType(TI.getType(), 0));
-if (TypeInfo->getType() != StdTypeInfoPtrTy)
-  TypeInfo = llvm::ConstantExpr::getBitCast(TypeInfo, StdTypeInfoPtrTy);
 return TypeInfo;
   }





Comment at: clang/lib/CodeGen/CGObjCRuntime.cpp:373
 llvm::PointerType *signatureType =
-  CGM.getTypes().GetFunctionType(signature)->getPointerTo(ProgramAS);
+  llvm::PointerType::get(CGM.getTypes().GetFunctionType(signature),
+ ProgramAS);

Pass context here



Comment at: clang/lib/CodeGen/CGObjCRuntime.cpp:388
   llvm::PointerType *signatureType =
-CGM.getTypes().GetFunctionType(argsInfo)->getPointerTo(ProgramAS);
+llvm::PointerType::get(CGM.getTypes().GetFunctionType(argsInfo),
+   ProgramAS);

Pass context here.
Can also be moved above `if`.




Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:816-818
   llvm::Value *Addr = Builder.CreateInBoundsGEP(
   Base.getElementType(), Base.getPointer(), MemPtr, "memptr.offset");
+  return Addr;





Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:1924-1927
   llvm::Value *Load = CGF.Builder.CreateCall(
   CGM.getIntrinsic(llvm::Intrinsic::load_relative, {CGM.Int32Ty}),
   {VTable, llvm::ConstantInt::get(CGM.Int32Ty, 4 * VTableIndex)});
+  VFuncLoad = Load;





Comment at: clang/lib/CodeGen/ItaniumCXXABI.cpp:2552-2554
   auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0;
-  auto AddrInt8PtrTy =
-  AddrAS ? CGF.Int8Ty->getPointerTo(AddrAS) : CGF.

[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#4409149 , @Michael137 
wrote:

> In D144999#4408248 , @Michael137 
> wrote:
>
>> Looks like the latest reland of this patch 
>> (`e60b30d5e3878e7d91f8872ec4c4dca00d4a2dfc`) 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`.
>>
>> AFAICT, it also broke following LLDB test 
>> (https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake-as/263/execution/node/65/log/):
>>
>>   Failed Tests (1):
>> lldb-api :: functionalities/step-avoids-no-debug/TestStepNoDebug.py
>>
>> Let me know if you need help reproducing this
>
> Mind taking a look or reverting the patch until the tests pass?

Yes - having a look now - wasn't able to repro the test failure before because 
the build broke at HEAD:

  /mnt/ssd/repo/llvm-project/llvm/include/llvm/CodeGen/RDFRegisters.h: In 
member function ‘constexpr size_t llvm::rdf::RegisterRef::hash() const’:
  /mnt/ssd/repo/llvm-project/llvm/include/llvm/CodeGen/RDFRegisters.h:92:35: 
error: call to non-‘constexpr’ function ‘std::size_t std::hash::operator()(unsigned int) const’
 92 | return std::hash{}(Reg) ^
|~~~^


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] D152554: [OpenMP] Migrate deviice code privatization from Clang CodeGen to OMPIRBuilder

2023-06-09 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:7170-7234
+const llvm::Value *DevPtr = nullptr;
 
 // In order to identify the right initializer we need to match the
 // declaration used by the mapping logic. In some cases we may get
 // OMPCapturedExprDecl that refers to the original declaration.
-const ValueDecl *MatchingVD = OrigVD;
-if (const auto *OED = dyn_cast(MatchingVD)) {
+if (const auto *OED = dyn_cast(OrigVD)) {
   // OMPCapturedExprDecl are used to privative fields of the current

Currently clang maintains a map between Clang::ValueDecl and corresponding 
address in Info.CaptureDeviceAddrMap.

Please see the EmitOMPUseDeviceAddrClause function just below this to see how 
it does so.

I would however like to get rid of this map as it allows us to then get rid of 
another map in the MapInfosTy and a clang specific callback for maintaining 
these maps..

This map is only used to retain the mapping between a ValueDecl inside a map 
clause to its corresponding llvm address.

The highlighted code here tries to retrieve this llvm address back from the 
ValueDecl without using the map, but as you can it is a very hacky way of doing 
so. But my intuition says that there must be a much simpler method of 
retrieving this address as Clang must be storing it in some way in order for it 
to generate code.

It would be great if someone with more experience in Clang codegen could help 
me achieve this. 

Also I am aware that I am probably doing a very poor job at explaining this. 
Please let me know if you have any questions or would like me to try and 
explain it with more clarity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152554

___
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 updated this revision to Diff 52.
paulkirth added a comment.

Revert patches introducing regression & add unit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152473

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/test/Format/overlapping-lines.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12856,22 +12856,6 @@
"  void f() {}\n"
"};\n",
Style);
-  verifyFormat("struct foo {\n"
-   "#ifdef FOO\n"
-   "#else\n"
-   "private:\n"
-   "\n"
-   "#endif\n"
-   "};",
-   "struct foo {\n"
-   "#ifdef FOO\n"
-   "#else\n"
-   "private:\n"
-   "\n"
-   "\n"
-   "#endif\n"
-   "};",
-   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"
@@ -25744,15 +25728,6 @@
   verifyFormat("int i;\n", "int i;", Style);
 }
 
-TEST_F(FormatTest, KeepEmptyLinesAtEOF) {
-  FormatStyle Style = getLLVMStyle();
-  Style.KeepEmptyLinesAtEOF = true;
-
-  const StringRef Code{"int i;\n\n"};
-  verifyFormat(Code, Code, Style);
-  verifyFormat(Code, "int i;\n\n\n", Style);
-}
-
 TEST_F(FormatTest, SpaceAfterUDL) {
   verifyFormat("auto c = (4s).count();");
   verifyFormat("auto x = 5s .count() == 5;");
@@ -25765,6 +25740,18 @@
"}");
 }
 
+TEST_F(FormatTest, PreprocessorOverlappingRegions) {
+  verifyFormat("#ifdef\n\n"
+   "#else\n"
+   "#endif\n",
+   "#ifdef \n"
+   "\n"
+   "\n"
+   "#else \n"
+   "#endif \n",
+   getGoogleStyle());
+}
+
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -167,7 +167,6 @@
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(InsertBraces);
   CHECK_PARSE_BOOL(InsertNewlineAtEOF);
-  CHECK_PARSE_BOOL(KeepEmptyLinesAtEOF);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/test/Format/overlapping-lines.cpp
===
--- /dev/null
+++ clang/test/Format/overlapping-lines.cpp
@@ -0,0 +1,8 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format --style=Google 2>&1 | FileCheck %s 
+// CHECK-NOT: The new replacement overlaps with an existing replacement.
+
+#ifdef 
+
+
+#else 
+#endif 
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,12 +1418,19 @@
   return Penalty;
 }
 
-static auto newlinesBeforeLine(const AnnotatedLine &Line,
-   const AnnotatedLine *PreviousLine,
-   const AnnotatedLine *PrevPrevLine,
-   const SmallVectorImpl &Lines,
-   const FormatStyle &Style) {
-  const auto &RootToken = *Line.First;
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const AnnotatedLine *PrevPrevLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
+  FormatToken &RootToken = *Line.First;
+  if (RootToken.is(tok::eof)) {
+unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
+unsigned TokenIndent = Newlines ? NewlineIndent : 0;
+Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
+   TokenIndent);
+return;
+  }
   unsigned Newlines =
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
@@ -1503,29 +1510,6 @@
 }
   }
 
-  return Newlines;
-}
-
-void UnwrappedLineFormatter::formatFirstToken(
-const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
-const AnnotatedLine *PrevPrevLine,
-const SmallVectorImpl &Lines, unsigned Indent,
-unsigned NewlineIndent) {
-  FormatToken &RootToken = *Line.First;
-  if (RootToken.is(tok::eof)) {
-unsigned Newlines =
-std::min(RootToken.Newl

[PATCH] D151587: [clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

2023-06-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1279
+  if (isa(E))
+return nullptr;
+

efriedma wrote:
> This needs a comment explaining why we're bailing out here.
We might need to do a recursive visit still, to handle the cases noted at 
https://en.cppreference.com/w/cpp/language/reference_initialization#Lifetime_of_a_temporary
 .  Not constructors, but other things.  I think we don't have existing 
testcases, but for example `typedef int x[2]; struct Z { int &&x, y; }; Z z = { 
x{1,2}[0], z.x=10 };`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151587

___
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 updated this revision to Diff 530004.
paulkirth edited the summary of this revision.
paulkirth added reverted changes: rGd2627cf88d25: [clang-format] Add the 
KeepEmptyLinesAtEOF option, rG4b9764959dc4: [clang-format] Fix overlapping 
replacements before PPDirectives, D152305: [clang-format] Add the 
KeepEmptyLinesAtEOF option, D151954: [clang-format] Fix overlapping whitespace 
replacements before PPDirective.
paulkirth added a comment.

Rebase and update summary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152473

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/test/Format/overlapping-lines.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12856,22 +12856,6 @@
"  void f() {}\n"
"};\n",
Style);
-  verifyFormat("struct foo {\n"
-   "#ifdef FOO\n"
-   "#else\n"
-   "private:\n"
-   "\n"
-   "#endif\n"
-   "};",
-   "struct foo {\n"
-   "#ifdef FOO\n"
-   "#else\n"
-   "private:\n"
-   "\n"
-   "\n"
-   "#endif\n"
-   "};",
-   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"
@@ -25744,15 +25728,6 @@
   verifyFormat("int i;\n", "int i;", Style);
 }
 
-TEST_F(FormatTest, KeepEmptyLinesAtEOF) {
-  FormatStyle Style = getLLVMStyle();
-  Style.KeepEmptyLinesAtEOF = true;
-
-  const StringRef Code{"int i;\n\n"};
-  verifyFormat(Code, Code, Style);
-  verifyFormat(Code, "int i;\n\n\n", Style);
-}
-
 TEST_F(FormatTest, SpaceAfterUDL) {
   verifyFormat("auto c = (4s).count();");
   verifyFormat("auto x = 5s .count() == 5;");
@@ -25765,6 +25740,18 @@
"}");
 }
 
+TEST_F(FormatTest, PreprocessorOverlappingRegions) {
+  verifyFormat("#ifdef\n\n"
+   "#else\n"
+   "#endif\n",
+   "#ifdef \n"
+   "\n"
+   "\n"
+   "#else \n"
+   "#endif \n",
+   getGoogleStyle());
+}
+
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -167,7 +167,6 @@
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(InsertBraces);
   CHECK_PARSE_BOOL(InsertNewlineAtEOF);
-  CHECK_PARSE_BOOL(KeepEmptyLinesAtEOF);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/test/Format/overlapping-lines.cpp
===
--- /dev/null
+++ clang/test/Format/overlapping-lines.cpp
@@ -0,0 +1,8 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format --style=Google 2>&1 | FileCheck %s 
+// CHECK-NOT: The new replacement overlaps with an existing replacement.
+
+#ifdef 
+
+
+#else 
+#endif 
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,12 +1418,19 @@
   return Penalty;
 }
 
-static auto newlinesBeforeLine(const AnnotatedLine &Line,
-   const AnnotatedLine *PreviousLine,
-   const AnnotatedLine *PrevPrevLine,
-   const SmallVectorImpl &Lines,
-   const FormatStyle &Style) {
-  const auto &RootToken = *Line.First;
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const AnnotatedLine *PrevPrevLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
+  FormatToken &RootToken = *Line.First;
+  if (RootToken.is(tok::eof)) {
+unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
+unsigned TokenIndent = Newlines ? NewlineIndent : 0;
+Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
+   TokenIndent);
+return;
+  }
   unsigned Newlines =
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
@@ -1503,29 +1510,6 @@
 }
   }
 
-  return Newlines;
-}
-
-void UnwrappedLineF

[PATCH] D152561: [AST] Always set dependent-type for the CallExpr for error-recovery in C.

2023-06-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added reviewers: aaron.ballman, sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang.

When build CallExpr for error-recovery where we have any dependent
child nodes), we should set a dependent type for CallExpr to avoid
running into some unexpected following semantic analysis.

This also aligns with the C++ behavior.

This fixes the symptom crashes: 
https://github.com/llvm/llvm-project/issues/50244


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152561

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' 
contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7201,13 +7201,8 @@
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) 
&&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -93,7 +93,7 @@
   (*__builtin_classify_type)(1);
 
   extern void ext();
-  // CHECK: CallExpr {{.*}} 'void' contains-errors
+  // CHECK: CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-DeclRefExpr {{.*}} 'ext'
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
@@ -117,3 +117,12 @@
   // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
   if (__builtin_va_arg(undef, int) << 1);
 }
+
+void test6_GH50244() {
+  double array[16];
+  // CHECK:  UnaryExprOrTypeTraitExpr {{.*}} 'unsigned long' contains-errors sizeof
+  // CHECK-NEXT: `-CallExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   |-DeclRefExpr {{.*}} 'int ()'
+  // CHECK-NEXT:   `-RecoveryExpr {{.*}} ''
+  sizeof array / sizeof foo(undef);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7201,13 +7201,8 @@
 llvm::any_of(ArgExprs,
  [](clang::Expr *E) { return E->containsErrors(); })) &&
"should only occur in error-recovery path.");
-QualType ReturnType =
-llvm::isa_and_nonnull(NDecl)
-? cast(NDecl)->getCallResultType()
-: Context.DependentTy;
-return CallExpr::Create(Context, Fn, ArgExprs, ReturnType,
-Expr::getValueKindForType(ReturnType), RParenLoc,
-CurFPFeatureOverrides());
+return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
+VK_PRValue, RParenLoc, CurFPFeatureOverrides());
   }
   return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
ExecConfig, IsExecConfig);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149872: [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

2023-06-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

If this passes all our tests, it looks fine. A few nits below, try to address 
if possible.




Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4427
+  M.getContext(), ArrayRef({Int64Ty, Int64Ty, Int64Ty}),
+  "struct.descriptor_dim");
+

If it helps, you can define the struct type in OMPKind.td, I think that's the 
name.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4487
+
+  if (Info.NumberOfPtrs) {
+Builder.restoreIP(AllocaIP);

Can we do an early exit here?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4562
+Info.RTArgs.SizesArray = SizesArrayGbl;
+  }
+  Builder.restoreIP(CodeGenIP);

Generally try to have the "short" branch first, especially one liners.
People have forgotten the condition when they get here.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4618
+  if (Info.requiresDevicePointerInfo()) {
+assert(DeviceAddrCB);
+DeviceAddrCB(I, BP, BPVal);

Add a message to all asserts, please.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

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


[PATCH] D146557: [MLIR][OpenMP] Refactoring createTargetData in OMPIRBuilder

2023-06-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:1365
+  // possible, or else at the end of the function.
+  void EmitBlock(BasicBlock *BB, Function *CurFn, bool IsFinished = false);
+

why are these capitalized?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4085
+omp::RuntimeFunction *MapperFunc,
+function_ref
+BodyGenCB) {

Can we not use an `int` for some "type". The 1 and 2 below are magic, use an 
enum and descriptive words.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4105
+// Emit the number of elements in the offloading arrays.
+llvm::Value *PointerNum = Builder.getInt32(Info.NumberOfPtrs);
 

No llvm::. Also elsewhere.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4727
+  Builder.ClearInsertionPoint();
+}
+

This function doesn't make sense to me. For one, I don't know what a "unreal 
block" is. Nor would I have expected a block with terminator to be silently not 
touched. It might just be a documentation issue (in the header). I would avoid 
duplicating the comment here again.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:4785
+  EmitBlock(ContBlock, CurFn, /*IsFinished=*/true);
+}
+

CFG Utils have helpers for these things. Do we not use them on purpose?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146557

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


[PATCH] D149548: [IR] Update to use new shufflevector semantics

2023-06-09 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added a comment.

In D149548#4405173 , @qiucf wrote:

> Why this changes IR output of following case?
>
>   // RUN: clang vecpromote.c -S -o - -O0 -target s390x-linux-gnu -fzvector 
> -emit-llvm
>   #include 
>   
>   vector int si;
>   int g;
>   int i;
>   
>   void foo() {
> si = vec_promote(g, i);
>   }
>   
>   // store <4 x i32> undef, ptr %__vec.i, align 16, !noalias !6  ; this undef 
> becomes poison after this patch
>   // %2 = load i32, ptr %__scalar.addr.i, align 4, !noalias !6
>   // %3 = load i32, ptr %__index.addr.i, align 4, !noalias !6
>   // %4 = load <4 x i32>, ptr %__vec.i, align 16, !noalias !6
>   // %vecins.i = insertelement <4 x i32> %4, i32 %2, i32 %and.i

I think it's because vec_promote is implemented in clang using a shufflevector 
with an undefined mask (-1). 
ConstantFold sees that we have a fully undefined mask and it folds the 
shufflevector to poison.(previously undef)
My concern : is it Ok to have the undefined values of the vector be poison or 
was the undef used to abide to some specific semantics?
Hope this makes sense.

> I see no PowerPC related case changes. Maybe adding SystemZ folks for 
> comments @uweigand @jonpa

My bad I pinged the wrong people, thanks for adding SystemZ folks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149548

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


[PATCH] D152561: [AST] Always set dependent-type for the CallExpr for error-recovery in C.

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, though please add a release note about the fix. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152561

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


[PATCH] D152412: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses

2023-06-09 Thread Duo Wang via Phabricator via cfe-commits
dwang added a comment.

@vitalybuka Thanks for the quick review!

I need help landing this since I do not have commit permission.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152412

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


[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:1560
+  // is the furthest we might go up in the hierarchy.
+  ThisPtr = ThisPtr.getDeclPtr();
+}

tbaeder wrote:
> I think this test case was from the function pointer review, but this fixes:
> ```
> struct S {
>   virtual constexpr int func() const { return 1; }
> };
> 
> struct Middle : S {
>   constexpr Middle(int i) : i(i) {}
>   int i;
> };
> 
> struct Other {
>   constexpr Other(int k) : k(k) {}
>   int k;
> };
> 
> struct S2 : Middle, Other {
>   int j;
>   constexpr S2(int i, int j, int k) : Middle(i), Other(k), j(j) {}
>   virtual constexpr int func() const { return i + j + k  + S::func(); }
> };
> 
> 
> constexpr S s;
> constexpr decltype(&S::func) foo = &S::func;
> constexpr S2 s2(1, 2, 3);
> constexpr int value3 = (s2.*foo)();
> ```
> 
> even I am confused by all of this now, so the comment might not be the 
> clearest :)
> 
> (I did not add that test case since it needs other changes in`classify()` and 
> `VisitBinaryOperator()`, but can do that in a follow-up commit.)
Please do add the example in a follow-up.



Comment at: clang/test/AST/Interp/records.cpp:650
+};
+#endif

We should also have test cases for calling virtual functions from within a 
constructor and a destructor, as that has special semantics. e.g., 
https://godbolt.org/z/snaj1zfM5


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

https://reviews.llvm.org/D142630

___
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 Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D152443#4407331 , @KitsuneAlex 
wrote:

> Applied all suggested changes and added a suiting option for aformentioned 
> edge-case for call expressions.
> Also added the missing release notes to the apropriate section.

Please mark comments as done, if you think they are done.




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.

MyDeveloperDay wrote:
> could we use something like `SpaceAfterOperatorDeclaration` to differentiate
But it also applies to the definition?

Keyword seems to be wrong too, if we have a second option for the calls...

I currently have no recommendations for the naming.



Comment at: clang/lib/Format/TokenAnnotator.cpp:4206
+  if (Left.Previous &&
+  Left.Previous->isOneOf(tok::coloncolon, tok::period)) {
+return Style.SpaceAfterOperatorKeywordInCall ||

`bool Foo::operator==() = default;`?

Please add a test. :)



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

Can you add an empty line, so that the 2 blocks are visually separated?



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

MyDeveloperDay wrote:
> I assume I could have `foo->operator ==();`
Of course you can. :)


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


[clang] b03abbb - [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses

2023-06-09 Thread Vitaly Buka via cfe-commits

Author: Wang
Date: 2023-06-09T11:28:14-07:00
New Revision: b03abbb537e5403ab32f97e2ffcebafe4a92720d

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

LOG: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init 
statements and condition variables in switch clauses

[VarBypassDetector.cpp](https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/VarBypassDetector.cpp)
 lacks test coverage for handling init statements and condition variables in 
switch clauses, as is shown in:
https://lab.llvm.org/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/CodeGen/VarBypassDetector.cpp.html#L70
This patch adds test coverage for uncovered lines.

Reviewed By: vitalybuka

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

Added: 
clang/test/CodeGen/lifetime3.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/lifetime3.cpp 
b/clang/test/CodeGen/lifetime3.cpp
new file mode 100644
index 0..37ed5f1938111
--- /dev/null
+++ b/clang/test/CodeGen/lifetime3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s  | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s   | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK 
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @no_switch_bypass
+extern "C" void no_switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1: {
+// O2: call void @llvm.lifetime.start.p0(i64 1,
+// O2: call void @llvm.lifetime.end.p0(i64 1,
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: call void @llvm.lifetime.start.p0(i64 5,
+// O2: call void @llvm.lifetime.end.p0(i64 5,
+char y[5];
+bar(y, 5);
+break;
+  }
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+}
+
+// CHECK-LABEL: @switch_bypass
+extern "C" void switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1:
+n = n;
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}



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


[PATCH] D152412: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses

2023-06-09 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb03abbb537e5: [clang/test/CodeGen] Add test coverage for 
VarBypassDetector handling init… (authored by dwang, committed by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152412

Files:
  clang/test/CodeGen/lifetime3.cpp


Index: clang/test/CodeGen/lifetime3.cpp
===
--- /dev/null
+++ clang/test/CodeGen/lifetime3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s  | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s   | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK 
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @no_switch_bypass
+extern "C" void no_switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1: {
+// O2: call void @llvm.lifetime.start.p0(i64 1,
+// O2: call void @llvm.lifetime.end.p0(i64 1,
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: call void @llvm.lifetime.start.p0(i64 5,
+// O2: call void @llvm.lifetime.end.p0(i64 5,
+char y[5];
+bar(y, 5);
+break;
+  }
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+}
+
+// CHECK-LABEL: @switch_bypass
+extern "C" void switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1:
+n = n;
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}


Index: clang/test/CodeGen/lifetime3.cpp
===
--- /dev/null
+++ clang/test/CodeGen/lifetime3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s  | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s   | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK 
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @no_switch_bypass
+extern "C" void no_switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1: {
+// O2: call void @llvm.lifetime.start.p0(i64 1,
+// O2: call void @llvm.lifetime.end.p0(i64 1,
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: call void @llvm.lifetime.start.p0(i64 5,
+// O2: call void @llvm.lifetime.end.p0(i64 5,
+char y[5];
+bar(y, 5);
+break;
+  }
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+}
+
+// CHECK-LABEL: @switch_bypass
+extern "C" void switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1:
+n = n;
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-06-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: beanz, clang-vendors.
aaron.ballman added a comment.

In D151683#4384017 , @erichkeane 
wrote:

> In D151683#4382408 , @philnik wrote:
>
>> No. I guess, since you are asking I should write one for this? Only for the 
>> removal of `-fdouble-square-bracket-attributes`, or also for back porting 
>> this?
>
> The RFC I would expect for "allow C/C++ style attributes as an extension in 
> previous modes".  This is a pretty significant feature to allow as an 
> extension, particularly since our two main alternative compilers (G++/MSVC) 
> don't have this as an extension. I'd be curious how the other C compilers do 
> this as well.

I think this does warrant an RFC because it impacts both C++ and C, but I'm 
hoping the RFC is uncontroversial. It's mostly to establish what the use cases 
are for needing the extension. The feature is conforming as an extension to 
both languages, and I don't know of any breakage that would come from enabling 
it by default. I'm not certain whether we want to remove the feature flag 
immediately or whether we'd like to give one release of warning about it being 
removed (I'll defer to whatever @MaskRay thinks is reasonable) -- that search 
is compelling for why it's safe to remove the option, but there's plenty of 
proprietary code which we don't know about, so it's possible the option is 
still used. I'd be especially curious to know if anyone is using 
`-fno-double-square-bracket-attributes` to disable the feature in a mode where 
it would otherwise be enabled. I'm adding the `clang-vendors` group as a 
subscriber as an early warning that removing the command line option could be a 
potentially breaking change.

In terms of implementation work, there's still some minor stuff to address. 
Also, please be sure to also add a release note about the changes, and a 
potentially breaking entry for removing the command line option (assuming we 
elect to go that route).




Comment at: clang/docs/LanguageExtensions.rst:1434
 Designated initializers (N494)  C99
   C89
 Array & element qualification (N2607)   C2x
   C89
+==  
= =

You need to add an entry here as well, as this also extends C.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:553
 def err_while_loop_outside_of_a_function : Error<
-  "while loop outside of a function">; 
+  "while loop outside of a function">;
 def err_brackets_go_after_unqualified_id : Error<

Spurious whitespace change.



Comment at: clang/include/clang/Driver/Options.td:3530
   Values<"none,cf,cf-nochecks">;
-def mcpu_EQ : Joined<["-"], "mcpu=">, Group, 
+def mcpu_EQ : Joined<["-"], "mcpu=">, Group,
   HelpText<"For a list of available CPUs for the target use '-mcpu=help'">;

Spurious whitespace change.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1196
   // Add include/gpu-none-libc/* to our system include path. This lets us 
use
-  // GPU-specific system headers first. 
+  // GPU-specific system headers first.
   // TODO: We need to find a way to make these headers compatible with the

Spurious whitespace change.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:4477
   SourceLocation OpenLoc = Tok.getLocation();
-  Diag(OpenLoc, diag::warn_cxx98_compat_attribute);
+  Diag(OpenLoc, getLangOpts().CPlusPlus11 ? diag::warn_cxx98_compat_attribute
+: getLangOpts().CPlusPlus ? diag::warn_ext_cxx11_attributes

Missing the same "not compatible with standards before C2x" warning as for C++ 
(might want to reword the C++ warning at the same time to fit the newer style)



Comment at: clang/test/OpenMP/assumes_messages_attr.c:57
 [[omp::directive(begin assumes ext_abc)]];
-

Spurious removal.



Comment at: clang/test/Parser/asm.c:14
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
-  asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 
'b'}} 
+  asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 
'b'}}
 

Spurious whitespace change



Comment at: clang/test/Parser/cxx-decl.cpp:316
 #if __cplusplus >= 201103L
-// expected-error@+3 {{expected}}
+// expected-error@+2 {{expected}}
 // expected-error@-3 {{expected ';' after top level declarator}}

Huh... I wasn't expecting to see a change here because there's no attribute 
nearby. Probably fine, but still a bit curious.



Comment at: clang/test/Parser/cxx-decl.cpp:322
 #endif
-

Spurious change.



Comm

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

2023-06-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek 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/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] 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.

P.S This might have the same root-cause with the previous comment and could be 
fixed by D152540  as well.
(not able to repro the failures yet - don't have arm64 readily available, will 
test it later this evening. but on linux x86-64 and macos x86-64, ninja 
check-debuginfo passed for me)


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] D152351: [clang] Add __builtin_isfpclass

2023-06-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 530041.
sepavloff added a comment.

Updated patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152351

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/isfpclass.c
  clang/test/Sema/builtins.c
  clang/test/Sema/constant-builtins-2.c
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/IRBuilder.cpp

Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -1375,6 +1375,14 @@
   return Fn;
 }
 
+Value *IRBuilderBase::createIsFPClass(Value *FPNum, unsigned Test) {
+  ConstantInt *TestV = getInt32(Test);
+  Module *M = BB->getParent()->getParent();
+  Function *FnIsFPClass =
+  Intrinsic::getDeclaration(M, Intrinsic::is_fpclass, {FPNum->getType()});
+  return CreateCall(FnIsFPClass, {FPNum, TestV});
+}
+
 CallInst *IRBuilderBase::CreateAlignmentAssumptionHelper(const DataLayout &DL,
  Value *PtrValue,
  Value *AlignValue,
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -2518,6 +2518,8 @@
  unsigned Index, unsigned FieldIndex,
  MDNode *DbgInfo);
 
+  Value *createIsFPClass(Value *FPNum, unsigned Test);
+
 private:
   /// Helper function that creates an assume intrinsic call that
   /// represents an alignment assumption on the provided pointer \p PtrValue
Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -124,6 +124,47 @@
 char isnormal_nan[!__builtin_isnormal(__builtin_nan("")) ? 1 : -1];
 char isnormal_snan   [!__builtin_isnormal(__builtin_nans("")) ? 1 : -1];
 
+char isfpclass_inf_pos_0[__builtin_isfpclass(__builtin_inf(), 0x0200) ? 1 : -1]; // fcPosInf
+char isfpclass_inf_pos_1[!__builtin_isfpclass(__builtin_inff(), 0x0004) ? 1 : -1]; // fcNegInf
+char isfpclass_inf_pos_2[__builtin_isfpclass(__builtin_infl(), 0x0207) ? 1 : -1]; // fcSNan|fcQNan|fcNegInf|fcPosInf
+char isfpclass_inf_pos_3[!__builtin_isfpclass(__builtin_inf(), 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_pos_0[__builtin_isfpclass(1.0, 0x0100) ? 1 : -1]; // fcPosNormal
+char isfpclass_pos_1[!__builtin_isfpclass(1.0f, 0x0008) ? 1 : -1]; // fcNegNormal
+char isfpclass_pos_2[__builtin_isfpclass(1.0L, 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_pos_3[!__builtin_isfpclass(1.0, 0x0003) ? 1 : -1]; // fcSNan|fcQNan
+char isfpclass_pdenorm_0[__builtin_isfpclass(1.0e-40f, 0x0080) ? 1 : -1]; // fcPosSubnormal
+char isfpclass_pdenorm_1[__builtin_isfpclass(1.0e-310, 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_pdenorm_2[!__builtin_isfpclass(1.0e-40f, 0x003C) ? 1 : -1]; // fcNegative
+char isfpclass_pdenorm_3[!__builtin_isfpclass(1.0e-310, 0x0207) ? 1 : -1]; // ~fcFinite
+char isfpclass_pzero_0  [__builtin_isfpclass(0.0f, 0x0060) ? 1 : -1]; // fcZero
+char isfpclass_pzero_1  [__builtin_isfpclass(0.0, 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_pzero_2  [!__builtin_isfpclass(0.0L, 0x0020) ? 1 : -1]; // fcNegZero
+char isfpclass_pzero_3  [!__builtin_isfpclass(0.0, 0x0003) ? 1 : -1]; // fcNan
+char isfpclass_nzero_0  [__builtin_isfpclass(-0.0f, 0x0060) ? 1 : -1]; // fcZero
+char isfpclass_nzero_1  [__builtin_isfpclass(-0.0, 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_nzero_2  [!__builtin_isfpclass(-0.0L, 0x0040) ? 1 : -1]; // fcPosZero
+char isfpclass_nzero_3  [!__builtin_isfpclass(-0.0, 0x0003) ? 1 : -1]; // fcNan
+char isfpclass_ndenorm_0[__builtin_isfpclass(-1.0e-40f, 0x0010) ? 1 : -1]; // fcNegSubnormal
+char isfpclass_ndenorm_1[__builtin_isfpclass(-1.0e-310, 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_ndenorm_2[!__builtin_isfpclass(-1.0e-40f, 0x03C0) ? 1 : -1]; // fcPositive
+char isfpclass_ndenorm_3[!__builtin_isfpclass(-1.0e-310, 0x0207) ? 1 : -1]; // ~fcFinite
+char isfpclass_neg_0[__builtin_isfpclass(-1.0, 0x0008) ? 1 : -1]; // fcNegNormal
+char isfpclass_neg_1[!__builtin_isfpclass(-1.0f, 0x00100) ? 1 : -1]; // fcPosNormal
+char isfpclass_neg_2[__builtin_isfpclass(-1.0L, 0x01F8) ? 1 : -1]; // fcFinite
+char isfpclass_neg_3[!__builtin_isfpclass(-1.0, 0x0003) ? 1 : -1]; // fcSNan|fcQNan
+char isfpclass_inf_neg_0[__builtin_isfpclass(-__builtin_inf(), 0x0004) ? 1 : -1]; // fcNegInf
+char isfpclass_inf_neg_1[!__builtin_isfpclass(-__builtin_inff(), 0x0200) ? 1 : -1]; // fcPosInf
+char isf

[PATCH] D151834: Include math-errno with fast-math

2023-06-09 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 530040.
zahiraam marked 5 inline comments as done.

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

https://reviews.llvm.org/D151834

Files:
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/math-errno.c

Index: clang/test/CodeGen/math-errno.c
===
--- /dev/null
+++ clang/test/CodeGen/math-errno.c
@@ -0,0 +1,66 @@
+// -O2
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -ffp-contract=on -fno-rounding-math -O2 -emit-llvm -o - %s \
+// RUN: | FileCheck %s
+
+// -ffast-math
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -menable-no-infs -menable-no-nans -fapprox-func \
+// RUN: -funsafe-math-optimizations -fno-signed-zeros -mreassociate \
+// RUN: -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffast-math \
+// RUN: -ffinite-math-only -ffast-math -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix=FAST
+
+// -O0
+// RUN: %clang_cc1 -Wno-implicit-function-declaration  \
+// RUN: -ffp-contract=on -fno-rounding-math -O2 -emit-llvm -o - %s \
+// RUN: | FileCheck %s -check-prefix=NOOPT
+
+#pragma float_control(precise,on)
+float f1(float x) {
+  return sqrtf(x);
+}
+
+// CHECK-LABEL: define dso_local float @f1
+// CHECK: tail call float @sqrtf(float noundef {{.*}}) #[[ATTR4_O2:[0-9]+]]
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f1
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR3_FAST:[0-9]+]]
+//
+// NOOPT-LABEL: define dso_local float @f1
+// NOOPT: tail call float @sqrtf(float noundef {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
+
+
+#pragma float_control(precise,off)
+float f2(float x) {
+  return sqrtf(x);
+}
+
+// CHECK-LABEL: define dso_local float @f2
+// CHECK: tail call float @llvm.sqrt.f32(float {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f2
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR3_FAST]]
+
+// NOOPT-LABEL: define dso_local float @f2
+// NOOPT: tail call float @llvm.sqrt.f32(float {{.*}})
+
+
+__attribute__((optnone))
+float f3(float x) {
+  x = sqrtf(x);
+  return x;
+}
+
+// CHECK-LABEL: define dso_local float @f3
+// CHECK: call float @llvm.sqrt.f32(float {{.*}})
+
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f3
+// FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR4_FAST:[0-9]+]]
+
+// NOOPT-LABEL: define dso_local float @f3
+// NOOPT: call float @llvm.sqrt.f32(float {{.*}})
+
+// CHECK: [[ATTR4_O2]] = { nounwind willreturn memory(none) }
+// FAST: [[ATTR3_FAST]] =  { nounwind willreturn memory(none) }
+// NOOPT: [[ATTR4_NOOPT]] = { nounwind willreturn memory(none) }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1254,6 +1254,12 @@
   llvm::AttributeList &Attrs, unsigned &CallingConv,
   bool AttrOnCallSite, bool IsThunk);
 
+  /// Adjust Memory attribute to ensure that the BE gets the right attribute
+  // in order to generate the library call or the intrinsic for the function
+  // name 'Name'.
+  void AdjustMemoryAttribute(StringRef Name,
+ CGCalleeInfo CalleeInfo, llvm::AttributeList &Attrs);
+
   /// Adds attributes to F according to our CodeGenOptions and LangOptions, as
   /// though we had emitted it ourselves.  We remove any attributes on F that
   /// conflict with the attributes we add here.
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2216,6 +2216,17 @@
   return Mask;
 }
 
+void CodeGenModule::AdjustMemoryAttribute(StringRef Name,
+  CGCalleeInfo CalleeInfo,
+  llvm::AttributeList &Attrs) {
+  if (Attrs.getMemoryEffects().getModRef() == llvm::ModRefInfo::NoModRef) {
+Attrs = Attrs.removeFnAttribute(getLLVMContext(), llvm::Attribute::Memory);
+llvm::Attribute MemoryAttr = llvm::Attribute::getWithMemoryEffects(
+getLLVMContext(), llvm::MemoryEffects::writeOnly());
+Attrs = Attrs.addFnAttribute(getLLVMContext(), MemoryAttr);
+  }
+}
+
 /// Construct the IR attribute list of a function or call.
 ///
 /// When adding an attribute, please consider where it should be handled:
@@ -5463,11 +5474,17 @@
  /*AttrOnCallSite=*/true,
  /*IsThunk=*/false);
 
-  if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
+  if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDe

[PATCH] D151834: Include math-errno with fast-math

2023-06-09 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/include/clang/Basic/FPOptions.def:30
 OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, 
FPEvalMethod)
+OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
 #undef OPTION

andrew.w.kaylor wrote:
> Does this mean MathErrno is tracked in both LangOpts and FPOptions?
Yes. So that we can check that if it's overridden by a pragma or an attribute. 
I don't see another way.



Comment at: clang/test/CodeGen/math-errno.c:33
+
+__attribute__((optnone))
+float f4(float x) { 

andrew.w.kaylor wrote:
> Can you add a runline with -O0. That should prevent all instances of the 
> intrinsics, right?
Yes.



Comment at: clang/test/CodeGen/math-errno.c:49
+// FAST-LABEL: define dso_local nofpclass(nan inf) float @f4(float noundef 
nofpclass(nan inf) {{.*}})
+// FAST: call reassoc nnan ninf nsz arcp afn nofpclass(nan inf) float 
@sqrtf(float noundef nofpclass(nan inf) %0) #[[ATTR0:[0-9]+]]
+

andrew.w.kaylor wrote:
> I think the 'afn' flag here is a problem. The backend has no concept of 
> errno, so 'afn' will be treated as allowing the function to be replaced.
Added all the commands that are triggered by fast-math in the RUN line command. 


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

https://reviews.llvm.org/D151834

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


[PATCH] D152351: [clang] Add __builtin_isfpclass

2023-06-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Typo builting in commit message




Comment at: clang/docs/LanguageExtensions.rst:3418
+
+This function never raises floating-point exceptions.
+

Maybe also mention it doesn't canonicalize its input



Comment at: clang/test/CodeGen/isfpclass.c:54
+_Bool check_isfpclass_nan_f16(_Float16 x) {
+#pragma STDC FENV_ACCESS ON
+  return __builtin_isfpclass(x, 3 /*NaN*/);

Also tests without fenv access



Comment at: clang/test/CodeGen/isfpclass.c:56
+  return __builtin_isfpclass(x, 3 /*NaN*/);
+}

Test some vectors?



Comment at: clang/test/Sema/builtins.c:384
+  int x1 = __builtin_isfpclass(x, 1024); // expected-error {{argument value 
1024 is outside the valid range [0, 1023]}}
+  int x2 = __builtin_isfpclass(3, 3); // expected-error{{floating point 
classification requires argument of floating point type (passed in 'int')}}
+  int x3 = __builtin_isfpclass(x, 3, x); // expected-error{{too many arguments 
to function call, expected 2, have 3}}

For any other float argument, 3 would accept implicit conversion. Do we just 
not do that for these type inferring intrinsics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152351

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


[PATCH] D152351: [clang] Add __builtin_isfpclass

2023-06-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked 8 inline comments as done.
sepavloff added a comment.

In D152351#4403904 , @aaron.ballman 
wrote:

> In D152351#4402785 , @arsenm wrote:
>
>> Also should get mentioned in the builtin docs and release notes
>
> +1, also, should there be named constants for the mask values?

I don't know where these constants could be placed.




Comment at: clang/test/CodeGen/isfpclass.c:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -O1 -emit-llvm %s -o - | 
FileCheck %s
+
+_Bool check_isfpclass_finite(float x) {

arsenm wrote:
>  Can you also add a half test, also vectors
Half is added. But vectors cannot, because in this case result is also a vector.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152351

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


[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-06-09 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/test/ParserHLSL/group_shared.hlsl:14
-// expected-error@+1 {{expected expression}}
 float groupshared [[]] i = 12;
 

aaron.ballman wrote:
> philnik wrote:
> > Should this also get an extension warning/should attributes be disabled for 
> > HLSL?
> CC @beanz 
> 
> I was wondering the same thing. :-)
By bug rather than design DXC allows C++ attribute syntax in some places for 
HLSL.

I'm totally fine with (and prefer) following the rest of the languages here and 
having HLSL in Clang always allow C++ attributes regardless of language version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


[PATCH] D152561: [AST] Always set dependent-type for the CallExpr for error-recovery in C.

2023-06-09 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

Thank you for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152561

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


[PATCH] D152351: [clang] Add __builtin_isfpclass

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

In D152351#4409725 , @sepavloff wrote:

> In D152351#4403904 , @aaron.ballman 
> wrote:
>
>> In D152351#4402785 , @arsenm wrote:
>>
>>> Also should get mentioned in the builtin docs and release notes
>>
>> +1, also, should there be named constants for the mask values?
>
> I don't know where these constants could be placed.

The preprocessor predefines a bunch of macros, so I was thinking along those 
same lines. e.g., 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Frontend/InitPreprocessor.cpp#L737


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152351

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


[PATCH] D152351: [clang] Add __builtin_isfpclass

2023-06-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/isfpclass.c:2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -O1 -emit-llvm %s -o - | 
FileCheck %s
+
+_Bool check_isfpclass_finite(float x) {

sepavloff wrote:
> arsenm wrote:
> >  Can you also add a half test, also vectors
> Half is added. But vectors cannot, because in this case result is also a 
> vector.
Could copy what __builtin_elementwise does. Should that be in this builtin, or 
should there be a separate __builtin_elementwise_isfpclass?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152351

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


[PATCH] D152570: [clang] Fix file mapping template arguments

2023-06-09 Thread Dan McGregor via Phabricator via cfe-commits
dankm created this revision.
Herald added a project: All.
dankm added a comment.
dankm updated this revision to Diff 530046.
dankm published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I still need to make a unit test for this. Should be more-or-less a cleaned up 
version of the testcase in https://github.com/llvm/llvm-project/issues/63219.


dankm added a comment.

Add release notes.


dankm added a comment.

Despite needing unit tests, I'd like some eyes on this change.


When expanding template arguments for pretty function printing,
such as for __PRETTY_FUNCTION__, apply macro-prefix-map remapping
for lambda names.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152570

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/Expr.cpp


Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -786,7 +786,21 @@
 Out << "static ";
 }
 
+class PrettyCallbacks final : public PrintingCallbacks {
+public:
+  PrettyCallbacks(const LangOptions &L) : LO(L) {}
+  std::string remapPath(StringRef Path) const override {
+SmallString<128> p(Path);
+LO.remapPathPrefix(p);
+return std::string(p);
+  }
+
+private:
+  const LangOptions &LO;
+};
 PrintingPolicy Policy(Context.getLangOpts());
+PrettyCallbacks PrettyCB(Context.getLangOpts());
+Policy.Callbacks = &PrettyCB;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -492,6 +492,8 @@
   (`See patch `_).
 - Fix crash when passing a value larger then 64 bits to the aligned attribute.
   (`#50534 `_).
+- Fix lambdas in template arguments ``-fmacro-prefix-map``
+  (`#63219 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -786,7 +786,21 @@
 Out << "static ";
 }
 
+class PrettyCallbacks final : public PrintingCallbacks {
+public:
+  PrettyCallbacks(const LangOptions &L) : LO(L) {}
+  std::string remapPath(StringRef Path) const override {
+SmallString<128> p(Path);
+LO.remapPathPrefix(p);
+return std::string(p);
+  }
+
+private:
+  const LangOptions &LO;
+};
 PrintingPolicy Policy(Context.getLangOpts());
+PrettyCallbacks PrettyCB(Context.getLangOpts());
+Policy.Callbacks = &PrettyCB;
 std::string Proto;
 llvm::raw_string_ostream POut(Proto);
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -492,6 +492,8 @@
   (`See patch `_).
 - Fix crash when passing a value larger then 64 bits to the aligned attribute.
   (`#50534 `_).
+- Fix lambdas in template arguments ``-fmacro-prefix-map``
+  (`#63219 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2023-06-09 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

@cor3ntin, sorry for failing to keep up with reviews; I know this has already 
been committed. I did spot a couple of typos should you feel inclined to 
address them.




Comment at: clang/lib/Lex/Lexer.cpp:2695
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;





Comment at: clang/lib/Lex/Lexer.cpp:2398
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D151683: [clang] Enable C++11-style attributes in all language modes

2023-06-09 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added inline comments.



Comment at: clang/test/Parser/cxx-decl.cpp:316
 #if __cplusplus >= 201103L
-// expected-error@+3 {{expected}}
+// expected-error@+2 {{expected}}
 // expected-error@-3 {{expected ';' after top level declarator}}

aaron.ballman wrote:
> Huh... I wasn't expecting to see a change here because there's no attribute 
> nearby. Probably fine, but still a bit curious.
This is probably because of the whitespace trim below.



Comment at: clang/test/ParserHLSL/group_shared.hlsl:14
-// expected-error@+1 {{expected expression}}
 float groupshared [[]] i = 12;
 

beanz wrote:
> aaron.ballman wrote:
> > philnik wrote:
> > > Should this also get an extension warning/should attributes be disabled 
> > > for HLSL?
> > CC @beanz 
> > 
> > I was wondering the same thing. :-)
> By bug rather than design DXC allows C++ attribute syntax in some places for 
> HLSL.
> 
> I'm totally fine with (and prefer) following the rest of the languages here 
> and having HLSL in Clang always allow C++ attributes regardless of language 
> version.
Would you like some sort of warning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151683

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


  1   2   >