[PATCH] D126365: [git-clang-format] Stop ignoring changes for files with space in path

2022-08-20 Thread Eitot via Phabricator via cfe-commits
Eitot added a comment.

In D126365#3565891 , @curdeius wrote:

> @Eitot, do you need help landing this?

I do need help. Could someone land this for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126365

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


[PATCH] D132275: [clang] Reset some attributed calling lambda

2022-08-20 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 454175.
vitalybuka added a comment.

fix for result slot


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132275

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp

Index: clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
===
--- clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
+++ clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
@@ -3,9 +3,9 @@
 // This code used to cause an assertion failure in EmitDelegateCallArg.
 
 // CHECK: define internal void @"?__invoke@@?0??test@@YAXXZ@CA@UTrivial@@@Z"(
-// CHECK: call void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(
+// CHECK: call void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(ptr align 1 undef,
 
-// CHECK: define internal void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(
+// CHECK: define internal void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(ptr align 1 %this,
 
 struct Trivial {
   int x;
@@ -16,3 +16,14 @@
 void test() {
   fnptr = [](Trivial a){ (void)a; };
 }
+
+// CHECK: define internal i32 @"?__invoke@@?0??test2@@YAXXZ@CA@H@Z"(
+// CHECK: call void @"??R@?0??test2@@YAXXZ@QEBA@H@Z"(ptr align 1 undef,
+
+// CHECK: define internal void @"??R@?0??test2@@YAXXZ@QEBA@H@Z"(ptr align 1 %this,
+
+Trivial (*fnptr2)(int);
+
+void test2() {
+  fnptr2 = [](int) -> Trivial { return {}; };
+}
\ No newline at end of file
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2219,7 +2219,8 @@
   void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
 
   void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
-  CallArgList &CallArgs);
+  CallArgList &CallArgs,
+  llvm::CallBase **CallOrInvoke);
   void EmitLambdaBlockInvokeBody();
   void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD);
   void EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD);
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -26,6 +26,7 @@
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "llvm/IR/Attributes.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
@@ -2894,8 +2895,8 @@
 }
 
 void CodeGenFunction::EmitForwardingCallToLambda(
-  const CXXMethodDecl *callOperator,
-  CallArgList &callArgs) {
+const CXXMethodDecl *callOperator, CallArgList &callArgs,
+llvm::CallBase **callOrInvoke) {
   // Get the address of the call operator.
   const CGFunctionInfo &calleeFnInfo =
 CGM.getTypes().arrangeCXXMethodDeclaration(callOperator);
@@ -2921,7 +2922,8 @@
 
   // Now emit our call.
   auto callee = CGCallee::forDirect(calleePtr, GlobalDecl(callOperator));
-  RValue RV = EmitCall(calleeFnInfo, callee, returnSlot, callArgs);
+  RValue RV =
+  EmitCall(calleeFnInfo, callee, returnSlot, callArgs, callOrInvoke);
 
   // If necessary, copy the returned value into the slot.
   if (!resultType->isVoidType() && returnSlot.isNull()) {
@@ -2960,7 +2962,7 @@
 
   assert(!Lambda->isGenericLambda() &&
 "generic lambda interconversion to block not implemented");
-  EmitForwardingCallToLambda(CallOp, CallArgs);
+  EmitForwardingCallToLambda(CallOp, CallArgs, nullptr);
 }
 
 void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) {
@@ -2990,7 +2992,23 @@
 assert(CorrespondingCallOpSpecialization);
 CallOp = cast(CorrespondingCallOpSpecialization);
   }
-  EmitForwardingCallToLambda(CallOp, CallArgs);
+  llvm::CallBase *CallOrInvoke = nullptr;
+  EmitForwardingCallToLambda(CallOp, CallArgs, &CallOrInvoke);
+
+  // ThisPtr is Undef, so we need to reset incompatible attributes.
+  const auto &ToRemove =
+  llvm::AttributeFuncs::getUBImplyingAttributes().addAttribute(
+  llvm::Attribute::NonNull);
+  CallOrInvoke->getParent()->getParent()->dump();
+  llvm::Function *F = CallOrInvoke->getCalledFunction();
+
+  for (llvm::Use &U : ThisPtr->uses()) {
+if (U.getUser() == CallOrInvoke && CallOrInvoke->isArgOperand(&U)) {
+  unsigned ArgNo = CallOrInvoke->getArgOperandNo(&U);
+  F->removeParamAttrs(ArgNo, ToRemove);
+  CallOrInvoke->removeParamAttrs(ArgNo, ToRemove);
+}
+  }
 }
 
 void CodeGenFunction::EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD) {
___
cfe-commi

[PATCH] D132275: [clang] Reset some attributed calling lambda

2022-08-20 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 454176.
vitalybuka added a comment.

remove dump


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132275

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp

Index: clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
===
--- clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
+++ clang/test/CodeGenCXX/lambda-to-function-pointer-conversion.cpp
@@ -3,9 +3,9 @@
 // This code used to cause an assertion failure in EmitDelegateCallArg.
 
 // CHECK: define internal void @"?__invoke@@?0??test@@YAXXZ@CA@UTrivial@@@Z"(
-// CHECK: call void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(
+// CHECK: call void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(ptr align 1 undef,
 
-// CHECK: define internal void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(
+// CHECK: define internal void @"??R@?0??test@@YAXXZ@QEBA@UTrivial@@@Z"(ptr align 1 %this,
 
 struct Trivial {
   int x;
@@ -16,3 +16,14 @@
 void test() {
   fnptr = [](Trivial a){ (void)a; };
 }
+
+// CHECK: define internal i32 @"?__invoke@@?0??test2@@YAXXZ@CA@H@Z"(
+// CHECK: call void @"??R@?0??test2@@YAXXZ@QEBA@H@Z"(ptr align 1 undef,
+
+// CHECK: define internal void @"??R@?0??test2@@YAXXZ@QEBA@H@Z"(ptr align 1 %this,
+
+Trivial (*fnptr2)(int);
+
+void test2() {
+  fnptr2 = [](int) -> Trivial { return {}; };
+}
\ No newline at end of file
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -2219,7 +2219,8 @@
   void EmitBlockWithFallThrough(llvm::BasicBlock *BB, const Stmt *S);
 
   void EmitForwardingCallToLambda(const CXXMethodDecl *LambdaCallOperator,
-  CallArgList &CallArgs);
+  CallArgList &CallArgs,
+  llvm::CallBase **CallOrInvoke);
   void EmitLambdaBlockInvokeBody();
   void EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD);
   void EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD);
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -26,6 +26,7 @@
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
+#include "llvm/IR/Attributes.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
@@ -2894,8 +2895,8 @@
 }
 
 void CodeGenFunction::EmitForwardingCallToLambda(
-  const CXXMethodDecl *callOperator,
-  CallArgList &callArgs) {
+const CXXMethodDecl *callOperator, CallArgList &callArgs,
+llvm::CallBase **callOrInvoke) {
   // Get the address of the call operator.
   const CGFunctionInfo &calleeFnInfo =
 CGM.getTypes().arrangeCXXMethodDeclaration(callOperator);
@@ -2921,7 +2922,8 @@
 
   // Now emit our call.
   auto callee = CGCallee::forDirect(calleePtr, GlobalDecl(callOperator));
-  RValue RV = EmitCall(calleeFnInfo, callee, returnSlot, callArgs);
+  RValue RV =
+  EmitCall(calleeFnInfo, callee, returnSlot, callArgs, callOrInvoke);
 
   // If necessary, copy the returned value into the slot.
   if (!resultType->isVoidType() && returnSlot.isNull()) {
@@ -2960,7 +2962,7 @@
 
   assert(!Lambda->isGenericLambda() &&
 "generic lambda interconversion to block not implemented");
-  EmitForwardingCallToLambda(CallOp, CallArgs);
+  EmitForwardingCallToLambda(CallOp, CallArgs, nullptr);
 }
 
 void CodeGenFunction::EmitLambdaDelegatingInvokeBody(const CXXMethodDecl *MD) {
@@ -2990,7 +2992,21 @@
 assert(CorrespondingCallOpSpecialization);
 CallOp = cast(CorrespondingCallOpSpecialization);
   }
-  EmitForwardingCallToLambda(CallOp, CallArgs);
+  llvm::CallBase *CallOrInvoke = nullptr;
+  EmitForwardingCallToLambda(CallOp, CallArgs, &CallOrInvoke);
+
+  // ThisPtr is Undef, so we need to reset incompatible attributes.
+  const auto &ToRemove =
+  llvm::AttributeFuncs::getUBImplyingAttributes().addAttribute(
+  llvm::Attribute::NonNull);
+  llvm::Function *F = CallOrInvoke->getCalledFunction();
+  for (llvm::Use &U : ThisPtr->uses()) {
+if (U.getUser() == CallOrInvoke && CallOrInvoke->isArgOperand(&U)) {
+  unsigned ArgNo = CallOrInvoke->getArgOperandNo(&U);
+  F->removeParamAttrs(ArgNo, ToRemove);
+  CallOrInvoke->removeParamAttrs(ArgNo, ToRemove);
+}
+  }
 }
 
 void CodeGenFunction::EmitLambdaStaticInvokeBody(const CXXMethodDecl *MD) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm

[PATCH] D130255: [Clang][LoongArch] Add initial LoongArch target and driver support

2022-08-20 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 454179.
SixWeining added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130255

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Arch/LoongArch.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/bin/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/include/.keep
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64d/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64f/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64s/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/crtbegin.o
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/bin/ld
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib/.keep
  
clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib64/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib/.keep
  clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib64/.keep
  clang/test/Driver/frame-pointer.c
  clang/test/Driver/loongarch-abi-error.c
  clang/test/Driver/loongarch-abi.c
  clang/test/Driver/loongarch-toolchain.c
  clang/test/Preprocessor/init-loongarch.c

Index: clang/test/Preprocessor/init-loongarch.c
===
--- /dev/null
+++ clang/test/Preprocessor/init-loongarch.c
@@ -0,0 +1,641 @@
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32 /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA32 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32-unknown-linux /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefixes=LA32,LA32-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch32 \
+// RUN: -fforce-enable-int128 /dev/null | FileCheck --match-full-lines \
+// RUN: --check-prefixes=LA32,LA32-INT128 %s
+
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64 /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefix=LA64 %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64-unknown-linux /dev/null \
+// RUN:   | FileCheck --match-full-lines --check-prefixes=LA64,LA64-LINUX %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=loongarch64 \
+// RUN: -fforce-enable-int128 /dev/null | FileCheck --match-full-lines \
+// RUN: --check-prefixes=LA64,LA64-INT128 %s
+
+ Note that common macros are tested in init.c, such as __VERSION__. So they're not listed here.
+
+// LA32: #define _ILP32 1
+// LA32: #define __ATOMIC_ACQUIRE 2
+// LA32-NEXT: #define __ATOMIC_ACQ_REL 4
+// LA32-NEXT: #define __ATOMIC_CONSUME 1
+// LA32-NEXT: #define __ATOMIC_RELAXED 0
+// LA32-NEXT: #define __ATOMIC_RELEASE 3
+// LA32-NEXT: #define __ATOMIC_SEQ_CST 5
+// LA32: #define __BIGGEST_ALIGNMENT__ 16
+// LA32: #define __BITINT_MAXWIDTH__ 128
+// LA32: #define __BOOL_WIDTH__ 8
+// LA32: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
+// LA32: #define __CHAR16_TYPE__ unsigned short
+// LA32: #define __CHAR32_TYPE__ unsigned int
+// LA32: #define __CHAR_BIT__ 8
+// LA32: #define __CLANG_ATOMIC_BOOL_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_CHAR_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_INT_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_LLONG_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_LONG_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_POINTER_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_SHORT_LOCK_FREE 1
+// LA32: #define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 1
+// LA32: #define __DBL_DECIMAL_DIG__ 17
+// LA32: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324
+// LA32: #define __DBL_DIG__ 15
+// LA32: #define __DBL_EPSILON__ 2.2204460492503131e-16
+// LA32: #define __DBL_HAS_DENORM__ 1
+// LA32: #define __DBL_HAS_INFINITY__ 1
+// LA32: #define __DBL_HAS_QUIET_NAN__ 1
+// LA32: #define __DBL_MANT_DIG__ 53
+// LA32: #define __DBL_MAX_10_EXP__ 308
+// LA32: #define __DBL_MAX_EXP__ 1024
+// LA32: #define __DBL_MAX__ 1.7976931348623157e+308
+// LA32: #define __DBL_MIN_10_EXP__ (-307)
+// LA32: #define __DBL_MIN_EXP__ (-1021

[PATCH] D132285: [LoongArch] Implement ABI lowering

2022-08-20 Thread Lu Weining via Phabricator via cfe-commits
SixWeining created this revision.
SixWeining added reviewers: xen0n, MaskRay, xry111, wangleiat.
Herald added subscribers: luke957, mstorsjo, StephenFan, luismarques, 
s.egerton, PkmX, simoncook, arichardson.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead.
Herald added a project: clang.

Reuse most of RISCV's implementation with several exceptions:

On RISCV, integer scalars passed in registers have signext/zeroext
when promoted, but are anyext if passed on the stack. This is defined
in early RISCV ABI specification. But after this change [1], integers
should also be signext/zeroext if passed on the stack. So I think
RISCV's ABI lowering should be updated [2].

In LoongArch ABI spec, we can see that integer scalars narrower than
GRLEN bits are zero/sign-extended no matter passed in registers or on
the stack.

There is another difference worth mentioning is that `char` is signed
by default on LoongArch while it is unsigned on RISCV.

This patch also adds `_BitInt` type support to LoongArch and handle it
in LoongArchABIInfo::classifyArgumentType.

[1] 
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/cec39a064ee0e5b0129973fffab7e3ad1710498f
[2] https://github.com/llvm/llvm-project/issues/57261

Depends on D130255 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132285

Files:
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/LoongArch/abi-lp64d.c
  clang/test/CodeGen/ext-int-cc.c
  clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp

Index: clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/LoongArch/abi-lp64d-struct-inherit.cpp
@@ -0,0 +1,95 @@
+// RUN: %clang_cc1 -triple loongarch64 -target-feature +f -target-feature +d -target-abi lp64d \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+/// Ensure that fields inherited from a parent struct are treated in the same
+/// way as fields directly in the child for the purposes of LoongArch ABI rules.
+
+struct parent1_int32_s {
+  int32_t i1;
+};
+
+struct child1_int32_s : parent1_int32_s {
+  int32_t i2;
+};
+
+// CHECK-LABEL: define{{.*}} i64 @_Z30int32_int32_struct_inheritance14child1_int32_s(i64 %a.coerce)
+struct child1_int32_s int32_int32_struct_inheritance(struct child1_int32_s a) {
+  return a;
+}
+
+struct parent2_int32_s {
+  int32_t i1;
+};
+
+struct child2_float_s : parent2_int32_s {
+  float f1;
+};
+
+// CHECK-LABEL: define{{.*}} { i32, float } @_Z30int32_float_struct_inheritance14child2_float_s(i32 %0, float %1)
+struct child2_float_s int32_float_struct_inheritance(struct child2_float_s a) {
+  return a;
+}
+
+struct parent3_float_s {
+  float f1;
+};
+
+struct child3_int64_s : parent3_float_s {
+  int64_t i1;
+};
+
+// CHECK-LABEL: define{{.*}} { float, i64 } @_Z30float_int64_struct_inheritance14child3_int64_s(float %0, i64 %1)
+struct child3_int64_s float_int64_struct_inheritance(struct child3_int64_s a) {
+  return a;
+}
+
+struct parent4_double_s {
+  double d1;
+};
+
+struct child4_double_s : parent4_double_s {
+  double d1;
+};
+
+// CHECK-LABEL: define{{.*}} { double, double } @_Z32double_double_struct_inheritance15child4_double_s(double %0, double %1)
+struct child4_double_s double_double_struct_inheritance(struct child4_double_s a) {
+  return a;
+}
+
+/// When virtual inheritance is used, the resulting struct isn't eligible for
+/// passing in registers.
+
+struct parent5_virtual_s {
+  int32_t i1;
+};
+
+struct child5_virtual_s : virtual parent5_virtual_s {
+  float f1;
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN16child5_virtual_sC1EOS_(ptr noundef nonnull align 8 dereferenceable(12) %this, ptr noundef nonnull align 8 dereferenceable(12) %0)
+struct child5_virtual_s int32_float_virtual_struct_inheritance(struct child5_virtual_s a) {
+  return a;
+}
+
+/// Check for correct lowering in the presence of diamond inheritance.
+
+struct parent6_float_s {
+  float f1;
+};
+
+struct child6a_s : parent6_float_s {
+};
+
+struct child6b_s : parent6_float_s {
+};
+
+struct grandchild_6_s : child6a_s, child6b_s {
+};
+
+// CHECK-LABEL: define{{.*}} { float, float } @_Z38float_float_diamond_struct_inheritance14grandchild_6_s(float %0, float %1)
+struct grandchild_6_s float_float_diamond_struct_inheritance(struct grandchild_6_s a) {
+  return a;
+}
Index: clang/test/CodeGen/ext-int-cc.c
===
--- clang/test/CodeGen/ext-int-cc.c
+++ clang/test/CodeGen/ext-int-cc.c
@@ -27,6 +27,8 @@
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple arm64_32-apple-ios -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=AARCH64
 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -triple arm64_32-apple-ios -target-abi darwin

[PATCH] D132286: [clang][Interp] Implement function calls

2022-08-20 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: erichkeane, aaron.ballman, shafik, tahonermann.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a `Call` op and use the existing infrastructure for parameters and return 
values.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132286

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/Function.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/functions.cpp

Index: clang/test/AST/Interp/functions.cpp
===
--- /dev/null
+++ clang/test/AST/Interp/functions.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++14 -verify %s
+// RUN: %clang_cc1 -std=c++14 -verify=ref %s
+
+// expected-no-diagnostics
+// ref-no-diagnostics
+
+template constexpr T identity(T t) { return t; }
+static_assert(identity(true), "");
+static_assert(identity(true), "");
+static_assert(!identity(false), "");
+
+
+constexpr int sub(int a, int b) {
+  return a - b;
+}
+static_assert(sub(5, 2) == 3, "");
+static_assert(sub(0, 5) == -5, "");
+
+constexpr int norm(int n) {
+  if (n >= 0) {
+return identity(n);
+  }
+  return -identity(n);
+}
+static_assert(norm(5) == norm(-5), "");
+
+constexpr int square(int n) {
+  return norm(n) * norm(n);
+}
+static_assert(square(2) == 4, "");
+
+constexpr int add_second(int a, int b, bool doAdd) {
+  if (doAdd)
+return a + b;
+  return a;
+}
+static_assert(add_second(10, 3, true) == 13, "");
+static_assert(add_second(300, -20, false) == 300, "");
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -82,6 +82,7 @@
 /// The macro implicitly exposes a type T in the scope of the inner block.
 #define TYPE_SWITCH_CASE(Name, B) \
   case Name: { using T = PrimConv::T; B; break; }
+
 #define TYPE_SWITCH(Expr, B)   \
   do { \
 switch (Expr) {\
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -42,7 +42,7 @@
 def ArgUint64 : ArgType { let Name = "uint64_t"; }
 def ArgBool : ArgType { let Name = "bool"; }
 
-def ArgFunction : ArgType { let Name = "Function *"; }
+def ArgFunction : ArgType { let Name = "const Function *"; }
 def ArgRecord : ArgType { let Name = "Record *"; }
 
 def ArgSema : ArgType { let Name = "const fltSemantics *"; }
@@ -153,6 +153,17 @@
 // [] -> EXIT
 def NoRet : Opcode {}
 
+
+def Call : Opcode {
+  let Args = [ArgFunction];
+  let Types = [AllTypeClass];
+  let ChangesPC = 1;
+  let CanReturn = 1;
+  let HasCustomEval = 1;
+  let HasGroup = 1;
+}
+
+
 //===--===//
 // Frame management
 //===--===//
Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -171,6 +171,7 @@
   auto Memory = std::make_unique(BlockSize);
   auto *B = new (Memory.get()) Block(Desc.second);
 
+  assert(Args);
   // Copy the initial value.
   TYPE_SWITCH(Desc.first, new (B->data()) T(stackRef(Off)));
 
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -53,6 +53,15 @@
   return true;
 }
 
+template ::T>
+static bool Call(InterpState &S, CodePtr &PC, APValue &Result,
+ const Function *Func) {
+  S.Current =
+  new InterpFrame(S, const_cast(Func), S.Current, PC, {});
+
+  return Interpret(S, Result);
+}
+
 static bool RetVoid(InterpState &S, CodePtr &PC, APValue &Result) {
   S.CallStackDepth--;
 
@@ -398,6 +407,7 @@
   S.Note(MD->getLocation(), diag::note_declared_at);
   return false;
 }
+
 bool Interpret(InterpState &S, APValue &Result) {
   assert(!S.Current->isRoot());
   CodePtr PC = S.Current->getPC();
Index: clang/lib/AST/Interp/Function.h
===
--- clang/lib/AST/Interp/Function.h
+++ clang/lib/AST/Interp/Function.h
@@ -62,7 +62,7 @@
 
   /// Returns the size of the function's local stack.
   unsigned getFrameSize() const { return FrameSize; }
-  /// Returns the size of 

[PATCH] D132285: [LoongArch] Implement ABI lowering

2022-08-20 Thread Xi Ruoyao via Phabricator via cfe-commits
xry111 added a comment.

Are cases like

  struct x { double a; __int128 : 0; double b;};
  double f(struct x x) { return x.a + x.b; }

handled properly?  AFAIK RISC-V clang currently does not handle it correctly:

https://godbolt.org/z/rvM99zbqc (GCC handles it properly)
https://godbolt.org/z/sWY5vs5ce (Clang does not handle it properly)

Note that we rectified the ABI to match the behavior of RISC-V GCC deliberately 
(https://gcc.gnu.org/r12-8294) but I didn't rewrite the document because the 
behavior is not easy to describe with my poor English.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132285

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


[PATCH] D132286: [clang][Interp] Implement function calls

2022-08-20 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.cpp:60
+  S.Current =
+  new InterpFrame(S, const_cast(Func), S.Current, PC, {});
+

This patch adds two `const_cast`s. They aren't strictly necessary, since the 
`InterpFrame` doesn't need to modify the function. I have a local NFC patch to 
add `const` to a few places to make this work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132286

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


[PATCH] D132285: [LoongArch] Implement ABI lowering

2022-08-20 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

In D132285#3736922 , @xry111 wrote:

> Are cases like
>
>   struct x { double a; __int128 : 0; double b;};
>   double f(struct x x) { return x.a + x.b; }
>
> handled properly?  AFAIK RISC-V clang currently does not handle it correctly:
>
> https://godbolt.org/z/rvM99zbqc (GCC handles it properly)
> https://godbolt.org/z/sWY5vs5ce (Clang does not handle it properly)
>
> Note that we rectified the ABI to match the behavior of RISC-V GCC 
> deliberately (https://gcc.gnu.org/r12-8294) but I didn't rewrite the document 
> because the behavior is not easy to describe with my poor English.

Thanks. Since current ABI doesn’t document the behavior of zero-bit fields so I 
pay less attention to this case. Let me check it later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132285

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


[PATCH] D132189: [clang-format] Don't put `noexcept` on empty line following constructor

2022-08-20 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 454191.
rymiel added a comment.

Extra tests, including token annotator tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132189

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -770,6 +770,19 @@
   EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsFunctionAnnotations) {
+  auto Tokens = annotate("template \n"
+ "DEPRECATED(\"Use NewClass::NewFunction instead.\")\n"
+ "string OldFunction(const string ¶meter) {}");
+  ASSERT_EQ(Tokens.size(), 20u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_FunctionAnnotationRParen);
+
+  Tokens = annotate("template \n"
+"A(T) noexcept;");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
   auto Annotate = [this](llvm::StringRef Code) {
 return annotate(Code, getLLVMStyle(FormatStyle::LK_Verilog));
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9525,6 +9525,15 @@
   verifyFormat("template  // T can be A, B or C.\n"
"struct C {};",
AlwaysBreak);
+  verifyFormat("template \n"
+   "C(T) noexcept;",
+   AlwaysBreak);
+  verifyFormat("template \n"
+   "ClassName(T) noexcept;",
+   AlwaysBreak);
+  verifyFormat("template \n"
+   "POOR_NAME(T) noexcept;",
+   AlwaysBreak);
   verifyFormat("template  class A {\n"
"public:\n"
"  E *f();\n"
@@ -9535,6 +9544,9 @@
   verifyFormat("template  class C {};", NeverBreak);
   verifyFormat("template  void f();", NeverBreak);
   verifyFormat("template  void f() {}", NeverBreak);
+  verifyFormat("template  C(T) noexcept;", NeverBreak);
+  verifyFormat("template  ClassName(T) noexcept;", NeverBreak);
+  verifyFormat("template  POOR_NAME(T) noexcept;", NeverBreak);
   verifyFormat("template \nvoid foo(aa "
") {}",
NeverBreak);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1922,7 +1922,7 @@
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
  tok::comma, tok::period, tok::arrow,
- tok::coloncolon)) {
+ tok::coloncolon, tok::kw_noexcept)) {
 if (FormatToken *AfterParen = Current.MatchingParen->Next) {
   // Make sure this isn't the return type of an Obj-C block declaration
   if (AfterParen->isNot(tok::caret)) {


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -770,6 +770,19 @@
   EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsFunctionAnnotations) {
+  auto Tokens = annotate("template \n"
+ "DEPRECATED(\"Use NewClass::NewFunction instead.\")\n"
+ "string OldFunction(const string ¶meter) {}");
+  ASSERT_EQ(Tokens.size(), 20u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_FunctionAnnotationRParen);
+
+  Tokens = annotate("template \n"
+"A(T) noexcept;");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::r_paren, TT_Unknown);
+}
+
 TEST_F(TokenAnnotatorTest, UnderstandsVerilogOperators) {
   auto Annotate = [this](llvm::StringRef Code) {
 return annotate(Code, getLLVMStyle(FormatStyle::LK_Verilog));
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9525,6 +9525,15 @@
   verifyFormat("template  // T can be A, B or C.\n"
"struct C {};",
AlwaysBreak);
+  verifyFormat("template \n"
+   "C(T) noexcept;",
+   AlwaysBreak);
+  verifyFormat("template \n"
+   "ClassName(T) noexcept;",
+   AlwaysBreak);
+  verifyFormat("template \n"
+  

[PATCH] D132289: [analyzer] Drop deprecated flags

2022-08-20 Thread Balázs Benics via Phabricator via cfe-commits
steakhal created this revision.
steakhal added reviewers: NoQ, martong, Szelethus, ASDenysPetrov, isuckatcs, 
balazske, xazax.hun, vabridgers.
Herald added subscribers: manas, dkrupp, donat.nagy, mikhail.ramalho, 
a.sidorin, rnkovacs, szepet, baloghadamsoftware, whisperity.
Herald added a project: All.
steakhal requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As proposed in D126215  
(ffe7950ebc62380c3afc7c71f454a1db3f6f5c76 
),
I'm dropping the `-analyzer-store` and
`-analyzer-opt-analyze-nested-blocks` clang frontend flags.
I'm also dropping the corresponding commandline handlers of `scanbuild`.

This behavior is planned to be part of `clang-16`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132289

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Analysis/deprecated-flags-and-options.cpp
  clang/tools/scan-build-py/lib/libscanbuild/analyze.py
  clang/tools/scan-build/bin/scan-build
  clang/tools/scan-build/libexec/ccc-analyzer

Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -466,9 +466,6 @@
 # Get the plugins to load.
 my $Plugins = $ENV{'CCC_ANALYZER_PLUGINS'};
 
-# Get the store model.
-my $StoreModel = $ENV{'CCC_ANALYZER_STORE_MODEL'};
-
 # Get the constraints engine.
 my $ConstraintsModel = $ENV{'CCC_ANALYZER_CONSTRAINTS_MODEL'};
 
@@ -729,10 +726,6 @@
   push @CmdArgs, '-x', $FileLang;
 }
 
-if (defined $StoreModel) {
-  push @AnalyzeArgs, "-analyzer-store=$StoreModel";
-}
-
 if (defined $ConstraintsModel) {
   push @AnalyzeArgs, "-analyzer-constraints=$ConstraintsModel";
 }
Index: clang/tools/scan-build/bin/scan-build
===
--- clang/tools/scan-build/bin/scan-build
+++ clang/tools/scan-build/bin/scan-build
@@ -61,7 +61,6 @@
   UseCC => undef,# C compiler to use for compilation.
   UseCXX => undef,   # C++ compiler to use for compilation.
   AnalyzerTarget => undef,
-  StoreModel => undef,
   ConstraintsModel => undef,
   InternalStats => undef,
   OutputFormat => "html",
@@ -977,8 +976,7 @@
 die "$var is undefined\n" if (!defined $var);
 $ENV{$var} = $EnvVars->{$var};
   }
-  foreach my $var ('CCC_ANALYZER_STORE_MODEL',
-   'CCC_ANALYZER_CONSTRAINTS_MODEL',
+  foreach my $var ('CCC_ANALYZER_CONSTRAINTS_MODEL',
'CCC_ANALYZER_INTERNAL_STATS',
'CCC_ANALYZER_OUTPUT_FORMAT',
'CCC_CC',
@@ -1704,12 +1702,6 @@
   next;
 }
 
-if ($arg eq "-store") {
-  shift @$Args;
-  $Options{StoreModel} = shift @$Args;
-  next;
-}
-
 if ($arg eq "-constraints") {
   shift @$Args;
   $Options{ConstraintsModel} = shift @$Args;
@@ -1958,7 +1950,6 @@
   'CCC_CC' => $Options{UseCC},
   'CCC_CXX' => $Options{UseCXX},
   'CCC_REPORT_FAILURES' => $Options{ReportFailures},
-  'CCC_ANALYZER_STORE_MODEL' => $Options{StoreModel},
   'CCC_ANALYZER_CONSTRAINTS_MODEL' => $Options{ConstraintsModel},
   'CCC_ANALYZER_INTERNAL_STATS' => $Options{InternalStats},
   'CCC_ANALYZER_OUTPUT_FORMAT' => $Options{OutputFormat},
Index: clang/tools/scan-build-py/lib/libscanbuild/analyze.py
===
--- clang/tools/scan-build-py/lib/libscanbuild/analyze.py
+++ clang/tools/scan-build-py/lib/libscanbuild/analyze.py
@@ -386,8 +386,6 @@
 
 result = []
 
-if args.store_model:
-result.append('-analyzer-store={0}'.format(args.store_model))
 if args.constraints_model:
 result.append('-analyzer-constraints={0}'.format(
 args.constraints_model))
Index: clang/test/Analysis/deprecated-flags-and-options.cpp
===
--- clang/test/Analysis/deprecated-flags-and-options.cpp
+++ clang/test/Analysis/deprecated-flags-and-options.cpp
@@ -1,18 +1,13 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core %s 2>&1 \
 // RUN: | FileCheck %s --check-prefixes=CHECK
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region %s 2>&1 \
-// RUN: | FileCheck %s --check-prefixes=CHECK,DEPRECATED-STORE
-// DEPRECATED-STORE: warning: analyzer option '-analyzer-store' is deprecated. This flag will be removed in clang-16, and passing this option will be an error.
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core -analyzer-store=region %s 2>&1 \
+// RUN: | FileCheck %s --check-prefixes=DEPRECATED-STORE
+// DEPRECATED-STORE: error: unknown argument: '-analyzer-store=region'
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-opt-analyze-

[PATCH] D132290: [clang-tidy] Skip unions in use-equals-default

2022-08-20 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: aaron.ballman, asoffer.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

For unions constructors with empty bodies behave differently (in comparison 
with structs/classes)
(e.g. https://godbolt.org/z/dqd4YGW7j)
and clang-tidy's fix might break the code in some cases : 
https://godbolt.org/z/GaT1bqGGb vs https://godbolt.org/z/4nGTqWvTM
This diff adjusts the check to skip unions for now (it seems to be a relatively 
rare case).

Test plan: ninja check-clang-tools


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132290

Files:
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
@@ -33,6 +33,17 @@
   ~NE() { f(); }
 };
 
+// Skip unions.
+union NU {
+  NU() {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: NU() {}
+  ~NU() {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: ~NU() {}
+  NE Field;
+};
+
 // Initializer or arguments.
 class IA {
 public:
Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
@@ -32,6 +32,20 @@
   int Field;
 };
 
+// Skip unions.
+union NU {
+  NU(const NU &Other) : Field(Other.Field) {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: NU(const NU &Other) :
+  NU &operator=(const NU &Other) {
+Field = Other.Field;
+return *this;
+  }
+  // CHECK-MESSAGES-NOT: :[[@LINE-4]]:7: warning: use '= default'
+  // CHECK-FIXES: NU &operator=(const NU &Other) {
+  IL Field;
+};
+
 // Wrong type.
 struct WT {
   WT(const IL &Other) {}
Index: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -218,11 +218,13 @@
 
 void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
   // Destructor.
-  Finder->addMatcher(cxxDestructorDecl(isDefinition()).bind(SpecialFunction),
+  
Finder->addMatcher(cxxDestructorDecl(unless(hasParent(recordDecl(isUnion(,
+   isDefinition())
+ .bind(SpecialFunction),
  this);
   Finder->addMatcher(
   cxxConstructorDecl(
-  isDefinition(),
+  unless(hasParent(recordDecl(isUnion(, isDefinition(),
   anyOf(
   // Default constructor.
   allOf(unless(hasAnyConstructorInitializer(isWritten())),
@@ -237,7 +239,8 @@
   this);
   // Copy-assignment operator.
   Finder->addMatcher(
-  cxxMethodDecl(isDefinition(), isCopyAssignmentOperator(),
+  cxxMethodDecl(unless(hasParent(recordDecl(isUnion(, isDefinition(),
+isCopyAssignmentOperator(),
 // isCopyAssignmentOperator() allows the parameter to be
 // passed by value, and in this case it cannot be
 // defaulted.


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp
@@ -33,6 +33,17 @@
   ~NE() { f(); }
 };
 
+// Skip unions.
+union NU {
+  NU() {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: NU() {}
+  ~NU() {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: ~NU() {}
+  NE Field;
+};
+
 // Initializer or arguments.
 class IA {
 public:
Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize

[PATCH] D132290: [clang-tidy] Skip unions in use-equals-default

2022-08-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp:221
   // Destructor.
-  Finder->addMatcher(cxxDestructorDecl(isDefinition()).bind(SpecialFunction),
+  
Finder->addMatcher(cxxDestructorDecl(unless(hasParent(recordDecl(isUnion(,
+   isDefinition())

It would be nice to explain why we skip unions.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132290

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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin created this revision.
Yoorkin added a reviewer: clang-tools-extra.
Yoorkin added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
Herald added a project: All.
Yoorkin requested review of this revision.
Herald added a subscriber: cfe-commits.

Hi, I have added a clang-tidy check which proposed in this issue 
.
The check can finds sprintf usage like:

  char buff[50];
  sprintf(buff,"Hello, %s!\n","world");

And suggest counted version function instead:

  warning: string to be written may exceeds the size of buffer; use snprintf 
instead [bugprone-sprintf-with-fixed-size-buffer]
sprintf(buff,"Hello, %s!\n","world");
^~~~
snprintf(buff, sizeof(buff), "Hello, %s!\n", "world")


https://reviews.llvm.org/D132294

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-sprintf-with-fixed-size-buffer %t
+
+#include 
+
+void f(){
+  char buff[80];
+  sprintf(buff, "Hello, %s!\n", "world");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer]
+  // CHECK-FIXES: snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
+}
+
+
+char sbuff[80];
+
+void f2(){
+  sprintf(sbuff, "Hello, %s!\n", "world");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer]
+  // CHECK-FIXES: snprintf(sbuff, sizeof(sbuff), "Hello, %s!\n", "world");
+}
+
+void f3(){
+char *dynamic_sized_buff = nullptr;
+sprintf(dynamic_sized_buff, "Hello, %s!\n", "world");
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -114,6 +114,7 @@
`bugprone-signed-char-misuse `_,
`bugprone-sizeof-container `_,
`bugprone-sizeof-expression `_,
+   `bugprone-sprintf-with-fixed-size-buffer `_, "Yes"
`bugprone-spuriously-wake-up-functions `_,
`bugprone-string-constructor `_, "Yes"
`bugprone-string-integer-assignment `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
@@ -0,0 +1,25 @@
+.. title:: clang-tidy - bugprone-sprintf-with-fixed-size-buffer
+
+bugprone-sprintf-with-fixed-size-buffer
+===
+
+The check finds usage of `sprintf`, which write output string into a fixed-size 
+array. It will suggest `snprintf` instead.
+
+It's a common idiom to have a fixed-size buffer of characters allocated on 
+the stack and then to printf into the buffer. It may be leading to errors if the 
+string to be written exceeds the size of the array pointed to by buffer.
+
+Example:
+.. code-block:: c++
+void f(){
+  char buff[80];
+  sprintf(buff, "Hello, %s!\n", "world");
+}
+
+Becomes:
+.. code-block:: c++
+void f(){
+  char buff[80];
+  snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
+}
\ No newline at end of file
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -99,6 +99,11 @@
 New checks
 ^^
 
+- New :doc:`bugprone-sprintf-with-fixed-size-buffer
+  ` check.
+
+  FIXME: add release notes.
+
 - New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
@@ -0,0 +1,35 @@
+//===--- SprintfWithFixedSizeBufferCheck.h - clang-tidy -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 wit

[PATCH] D132290: [clang-tidy] Skip unions in use-equals-default

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention changes in Release Notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132290

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


[PATCH] D128328: [C++20][Modules] Improve handing of Private Module Fragment diagnostics.

2022-08-20 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 454205.
iains marked an inline comment as done.
iains added a comment.

rebased, addressed remaing comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128328

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/Reachability-Private.cpp
  clang/test/Modules/cxx20-10-5-ex1.cpp

Index: clang/test/Modules/cxx20-10-5-ex1.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-10-5-ex1.cpp
@@ -0,0 +1,53 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \
+// RUN: -DBAD_FWD_DECL  -fsyntax-only -verify
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-5-ex1-interface.cpp \
+// RUN: -o A.pcm
+
+// RUN: %clang_cc1 -std=c++20 std-10-5-ex1-use.cpp  -fmodule-file=A.pcm \
+// RUN:-fsyntax-only -verify
+
+//--- std-10-5-ex1-interface.cpp
+
+export module A;
+#ifdef BAD_FWD_DECL
+export inline void fn_e(); // expected-error {{inline function not defined before the private module fragment}}
+   // expected-n...@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}
+#endif
+export inline void ok_fn() {}
+export inline void ok_fn2();
+#ifdef BAD_FWD_DECL
+inline void fn_m(); // expected-error {{inline function not defined before the private module fragment}}
+// expected-n...@std-10-5-ex1-interface.cpp:21 {{private module fragment begins here}}
+#endif
+static void fn_s();
+export struct X;
+export void g(X *x) {
+  fn_s();
+}
+export X *factory();
+void ok_fn2() {}
+
+module :private;
+struct X {};
+X *factory() {
+  return new X();
+}
+
+void fn_e() {}
+void fn_m() {}
+void fn_s() {}
+
+//--- std-10-5-ex1-use.cpp
+
+import A;
+
+void foo() {
+  X x; // expected-error 1+{{missing '#include'; 'X' must be defined before it is used}}
+   // expected-n...@std-10-5-ex1-interface.cpp:22 1+{{definition here is not reachable}}
+  X *p = factory();
+}
Index: clang/test/Modules/Reachability-Private.cpp
===
--- clang/test/Modules/Reachability-Private.cpp
+++ clang/test/Modules/Reachability-Private.cpp
@@ -4,18 +4,25 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: %clang_cc1 -std=c++20 %t/Private.cppm -emit-module-interface -o %t/Private.pcm
-// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
+// RUN: %clang_cc1 -std=c++20 %t/Private.cppm -emit-module-interface \
+// RUN: -o %t/Private.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp \
+// RUN: -DTEST_BADINLINE -verify -fsyntax-only
 
 //--- Private.cppm
 export module Private;
-inline void fn_m(); // OK, module-linkage inline function
+#ifdef TEST_BADINLINE
+inline void fn_m(); // expected-error {{un-exported inline function not defined before the private module fragment}}
+// expected-n...@private.cppm:13 {{private module fragment begins here}}
+#endif
 static void fn_s();
 export struct X;
 
 export void g(X *x) {
   fn_s(); // OK, call to static function in same translation unit
-  fn_m(); // OK, call to module-linkage inline function
+#ifdef TEST_BADINLINE
+  fn_m(); // fn_m is not OK.
+#endif
 }
 export X *factory(); // OK
 
@@ -30,10 +37,8 @@
 //--- Use.cpp
 import Private;
 void foo() {
-  X x; // expected-error {{definition of 'X' must be imported from module 'Private.' before it is required}}
-   // expected-error@-1 {{definition of 'X' must be imported from module 'Private.' before it is required}}
-   // expected-note@* {{definition here is not reachable}}
-   // expected-note@* {{definition here is not reachable}}
+  X x; // expected-error 1+{{missing '#include'; 'X' must be defined before it is used}}
+   // expected-n...@private.cppm:18 1+{{definition here is not reachable}}
   auto _ = factory();
   auto *__ = factory();
   X *___ = factory();
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -910,6 +910,17 @@
 diagExportedUnnamedDecl(*this, UnnamedDeclKind::Context, Child,
 BlockStart);
   }
+  if (auto *FD = dyn_cast(Child)) {
+// [dcl.inline]/7
+// If an inline function or variable that is attached to a named module
+// is declared in a definition domain, it shall be defined in that
+// domain.
+// So, if the current declaration does not have a definition, we must
+// check at the end of the TU (or when the PMF starts) to see that we
+   

[PATCH] D128328: [C++20][Modules] Improve handing of Private Module Fragment diagnostics.

2022-08-20 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked 2 inline comments as done.
iains added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1262
+if (auto *FDD = FD->getDefinition()) {
+  DefInPMF = FDD->getOwningModule()->isPrivateModule();
+  if (!DefInPMF)

ChuanqiXu wrote:
> nit:
(I added this one)
I wonder if we could try to reduce the number of asserts included by 
considering making a test-case to cover the condition that is of concern - 
since most devs build with assertions enabled, we should ensure that they are 
only covering some case we really cannot test directly.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128328

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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp:13
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+#include "clang/Lex/Lexer.h"

Unnecessary newline.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp:34
+const MatchFinder::MatchResult &Result) {
+  const DeclRefExpr *CA = Result.Nodes.getNodeAs("ConstantArray");
+  const CallExpr *Call = Result.Nodes.getNodeAs("sprintf");

`const auto *` could be used because type is spelled in same statement.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp:35
+  const DeclRefExpr *CA = Result.Nodes.getNodeAs("ConstantArray");
+  const CallExpr *Call = Result.Nodes.getNodeAs("sprintf");
+

Ditto.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h:29
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+

Please add `isLanguageVersionSupported` (C and C++).



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:105
+
+  FIXME: add release notes.
+

Please use first statement in documentation.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:6
+
+The check finds usage of `sprintf`, which write output string into a 
fixed-size 
+array. It will suggest `snprintf` instead.

Please omit `The check` and use double back-ticks for `sprintf` (language 
construct).



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:7
+The check finds usage of `sprintf`, which write output string into a 
fixed-size 
+array. It will suggest `snprintf` instead.
+

Ditto for `snprintf`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:14
+Example:
+.. code-block:: c++
+void f(){

Please separate with newline.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:21
+Becomes:
+.. code-block:: c++
+void f(){

Ditto.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:26
+}
\ No newline at end of file


Please fix.


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

https://reviews.llvm.org/D132294

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


[PATCH] D132295: [clang-format] Change heuristic for locating lambda template arguments

2022-08-20 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel created this revision.
rymiel added reviewers: HazardyKnusperkeks, owenpan, MyDeveloperDay, curdeius.
Herald added a project: All.
rymiel requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, the heuristic was simply to look for template argument-
specific keywords, such as `typename`, `class`, `template` and `auto`
that are preceded by a left angle bracket `<`.

This changes the heuristic to instead look for a left angle bracket `<`
preceded by a right square bracket `]`, since according to the C++
grammar, the template arguments must *directly* follow the introducer.
(This sort of check might just end up being *too* aggressive)

This patch also adds a bunch more token annotator tests for lambdas,
specifically for some of the stranger forms of lambdas now allowed as
of C++20 or soon-to-be-allowed as part of C++23.

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

This does NOT resolve the FIXME regarding explicit template lists, but
perhaps it gets closer


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132295

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -756,18 +756,85 @@
 
   Tokens = annotate("[]() -> auto {}");
   ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
   EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
   EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_LambdaLBrace);
 
   Tokens = annotate("[]() -> auto & {}");
   ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
   EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
   EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
 
   Tokens = annotate("[]() -> auto * {}");
   ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
   EXPECT_TOKEN(Tokens[4], tok::arrow, TT_LambdaArrow);
   EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[] {}");
+  ASSERT_EQ(Tokens.size(), 5u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[] noexcept {}");
+  ASSERT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[3], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[] -> auto {}");
+  ASSERT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::arrow, TT_LambdaArrow);
+  EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  () {}");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[8], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  {}");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  () {}");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  () {}");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  () {}");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[9], tok::l_brace, TT_LambdaLBrace);
+
+  Tokens = annotate("[]  {}");
+  ASSERT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::less, TT_TemplateOpener);
+  EXPECT_TOKEN(Tokens[7], tok::l_brace, TT_LambdaLBrace);
 }
 
 TEST_F(TokenA

[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 454212.
Ericson2314 added a comment.

Rebase; Include d3a1dbc4907b59690f9013cdb6221573ca4233f1 
 as 
requested

Thanks @thakis for letting me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

Files:
  bolt/runtime/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/caches/Android-stage2.cmake
  clang/cmake/caches/Android.cmake
  clang/cmake/modules/AddClang.cmake
  clang/cmake/modules/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  cmake/Modules/GNUInstallPackageDir.cmake
  compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/docs/BuildingCompilerRT.rst
  flang/CMakeLists.txt
  flang/cmake/modules/AddFlang.cmake
  flang/cmake/modules/CMakeLists.txt
  libc/CMakeLists.txt
  libc/lib/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/CMakeLists.txt
  lld/cmake/modules/AddLLD.cmake
  lld/cmake/modules/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/cmake/modules/LLDBStandalone.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/API/CMakeLists.txt
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/tools/intel-features/CMakeLists.txt
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddOCaml.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/CMake.rst
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/llvm-shlib/CMakeLists.txt
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
  llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  mlir/cmake/modules/AddMLIRPython.cmake
  mlir/cmake/modules/CMakeLists.txt
  mlir/test/CMakeLists.txt
  openmp/CMakeLists.txt
  openmp/README.rst
  polly/cmake/CMakeLists.txt
  polly/cmake/polly_macros.cmake
  polly/test/CMakeLists.txt
  pstl/CMakeLists.txt
  third-party/benchmark/src/CMakeLists.txt
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -67,8 +67,8 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "z10"
 
-/* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX ""
+/* Multilib basename for libdir. */
+#define CLANG_INSTALL_LIBDIR_BASENAME "lib"
 
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR ""
Index: third-party/benchmark/src/CMakeLists.txt
===
--- third-party/benchmark/src/CMakeLists.txt
+++ third-party/benchmark/src/CMakeLists.txt
@@ -79,7 +79,7 @@
 configure_package_config_file (
   ${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in
   ${project_config}
-  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
   NO_SET_AND_CHECK_MACRO
   NO_CHECK_REQUIRED_COMPONENTS_MACRO
 )
@@ -100,8 +100,8 @@
   install(
 TARGETS ${targets_to_export}
 EXPORT ${targets_export_name}
-ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -88,10 +88,10 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/Paral

[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h:29
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+

Eugene.Zelenko wrote:
> Please add `isLanguageVersionSupported` (C and C++).
can i just simply use 
```
  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.C99 || LangOpts.CPlusPlus11;
  }
```
I think the check should be supported after C99 and Cpp11 standards. But i 
don't know whether it return true when language version is c++20 or C11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132294

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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h:29
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+

Yoorkin wrote:
> Eugene.Zelenko wrote:
> > Please add `isLanguageVersionSupported` (C and C++).
> can i just simply use 
> ```
>   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override 
> {
> return LangOpts.C99 || LangOpts.CPlusPlus11;
>   }
> ```
> I think the check should be supported after C99 and Cpp11 standards. But i 
> don't know whether it return true when language version is c++20 or C11
`snprintf` is part of standard C library, so it could be used in early C and 
C++ standards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132294

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


[PATCH] D132300: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Ericson2314 added a reviewer: sebastian-ne.
Herald added a subscriber: mgorny.
Herald added a project: All.
Ericson2314 requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLDB, LLVM.

Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed.

This gets us ready for D130586 , in which 
`*_LIBDIR_SUFFIX` is
deprecated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132300

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -67,8 +67,8 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "z10"
 
-/* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX ""
+/* Multilib basename for libdir. */
+#define CLANG_INSTALL_LIBDIR_BASENAME "lib"
 
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR ""
Index: llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
===
--- llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
+++ llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
@@ -21,6 +21,7 @@
 "LLDB_ENABLE_PYTHON=",
 "LLDB_ENABLE_FBSDVMCORE=",
 "LLDB_EMBED_PYTHON_HOME=",
+"LLDB_INSTALL_LIBDIR_BASENAME=lib",
 "LLDB_GLOBAL_INIT_DIRECTORY=",
 
 "LLDB_PYTHON_HOME=",
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -18,6 +18,7 @@
 "CLANG_DEFAULT_OBJCOPY=objcopy",
 "CLANG_DEFAULT_OPENMP_RUNTIME=libomp",
 "CLANG_DEFAULT_UNWINDLIB=",
+"CLANG_INSTALL_LIBDIR_BASENAME=lib",
 "CLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_35",
 "CLANG_LIBDIR_SUFFIX=",
 "CLANG_RESOURCE_DIR=",
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -37,7 +37,8 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir = "/foo/bar/lib" LLDB_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING;
+  std::string path_to_clang_dir =
+  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir = "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_STRING;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -55,11 +55,11 @@
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
   // in $install_dir/lib{,64}/clang/$clang_version.
-  "lib" CLANG_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING,
+  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
-  // it there, so we use LLDB_LIBDIR_SUFFIX.
-  "lib" LLDB_LIBDIR_SUFFIX "/lldb/clang",
+  // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
+  LLDB_INSTALL_LIBDIR_BASENAME "/lldb/clang",
   };
 
   for (const auto &Suffix : kResourceDirSuffixes) {
Index: lldb/source/Host/linux/HostInfoLinux.cpp
===
--- lldb/source/Host/linux/HostInfoLinux.cpp
+++ lldb/source/Host/linux/HostInfoLinux.cpp
@@ -175,7 +175,7 @@
 }
 
 bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
-  FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins");
+  FileSpec temp_file("/usr/" LLDB_INSTALL_LIBDIR_BASENAME "/

[clang] fc4d3a1 - [clang] Use Any::has_value instead of Any::hasValue (NFC)

2022-08-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-20T08:40:18-07:00
New Revision: fc4d3a1109cde38d64583e21852f83e03aa92a73

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

LOG: [clang] Use Any::has_value instead of Any::hasValue (NFC)

Added: 


Modified: 
clang/unittests/Tooling/RefactoringTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/RefactoringTest.cpp 
b/clang/unittests/Tooling/RefactoringTest.cpp
index f0edff6052c9a..e38afc148a7b8 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -1294,7 +1294,7 @@ TEST_F(AtomicChangeTest, Metadata) {
 
 TEST_F(AtomicChangeTest, NoMetadata) {
   AtomicChange Change(Context.Sources, DefaultLoc);
-  EXPECT_FALSE(Change.getMetadata().hasValue());
+  EXPECT_FALSE(Change.getMetadata().has_value());
 }
 
 class ApplyAtomicChangesTest : public ::testing::Test {



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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 454226.
Yoorkin marked 10 inline comments as done.
Yoorkin added a comment.

I fixed them all


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

https://reviews.llvm.org/D132294

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-sprintf-with-fixed-size-buffer %t
+
+#include 
+
+void f(){
+  char buff[80];
+  sprintf(buff, "Hello, %s!\n", "world");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer]
+  // CHECK-FIXES: snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
+}
+
+
+char sbuff[80];
+
+void f2(){
+  sprintf(sbuff, "Hello, %s!\n", "world");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer]
+  // CHECK-FIXES: snprintf(sbuff, sizeof(sbuff), "Hello, %s!\n", "world");
+}
+
+void f3(){
+char *dynamic_sized_buff = nullptr;
+sprintf(dynamic_sized_buff, "Hello, %s!\n", "world");
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -114,6 +114,7 @@
`bugprone-signed-char-misuse `_,
`bugprone-sizeof-container `_,
`bugprone-sizeof-expression `_,
+   `bugprone-sprintf-with-fixed-size-buffer `_, "Yes"
`bugprone-spuriously-wake-up-functions `_,
`bugprone-string-constructor `_, "Yes"
`bugprone-string-integer-assignment `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - bugprone-sprintf-with-fixed-size-buffer
+
+bugprone-sprintf-with-fixed-size-buffer
+===
+
+Find usage of ``sprintf``, which write output string into a fixed-size array. It 
+will suggest ``snprintf`` instead.
+
+It's a common idiom to have a fixed-size buffer of characters allocated on 
+the stack and then to printf into the buffer. It may be leading to errors if the 
+string to be written exceeds the size of the array pointed to by buffer.
+
+Example:
+.. code-block:: c++
+
+void f(){
+  char buff[80];
+  sprintf(buff, "Hello, %s!\n", "world");
+}
+
+Becomes:
+.. code-block:: c++
+
+void f(){
+  char buff[80];
+  snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -99,6 +99,11 @@
 New checks
 ^^
 
+- New :doc:`bugprone-sprintf-with-fixed-size-buffer
+  ` check.
+
+  Find usage of ``sprintf``, which write output string into a fixed-size array.
+
 - New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
@@ -0,0 +1,38 @@
+//===--- SprintfWithFixedSizeBufferCheck.h - clang-tidy -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPRINTFWITHFIXEDSIZEBUFFERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPRINTFWITHFIXEDSIZEBUFFERCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Check if `sprintf` is called with a fixed size buffer. Replaced with counted
+/// version `snprintf`.
+/

[PATCH] D132295: [clang-format] Change heuristic for locating lambda template arguments

2022-08-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

can you add some format tests to show examples of how you think it should change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132295

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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst:6
+
+Find usage of ``sprintf``, which write output string into a fixed-size array. 
It 
+will suggest ``snprintf`` instead.

Should be `Finds`. Same in Release Notes.


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

https://reviews.llvm.org/D132294

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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread 方程 via Phabricator via cfe-commits
Yoorkin updated this revision to Diff 454228.
Yoorkin added a comment.

I fixed it. Thanks


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

https://reviews.llvm.org/D132294

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/sprintf-with-fixed-size-buffer.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-sprintf-with-fixed-size-buffer %t
+
+#include 
+
+void f(){
+  char buff[80];
+  sprintf(buff, "Hello, %s!\n", "world");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer]
+  // CHECK-FIXES: snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
+}
+
+
+char sbuff[80];
+
+void f2(){
+  sprintf(sbuff, "Hello, %s!\n", "world");
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: string to be written may exceeds the size of buffer; use snprintf instead [bugprone-sprintf-with-fixed-size-buffer]
+  // CHECK-FIXES: snprintf(sbuff, sizeof(sbuff), "Hello, %s!\n", "world");
+}
+
+void f3(){
+char *dynamic_sized_buff = nullptr;
+sprintf(dynamic_sized_buff, "Hello, %s!\n", "world");
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -114,6 +114,7 @@
`bugprone-signed-char-misuse `_,
`bugprone-sizeof-container `_,
`bugprone-sizeof-expression `_,
+   `bugprone-sprintf-with-fixed-size-buffer `_, "Yes"
`bugprone-spuriously-wake-up-functions `_,
`bugprone-string-constructor `_, "Yes"
`bugprone-string-integer-assignment `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/sprintf-with-fixed-size-buffer.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - bugprone-sprintf-with-fixed-size-buffer
+
+bugprone-sprintf-with-fixed-size-buffer
+===
+
+Finds usage of ``sprintf``, which write output string into a fixed-size array. It 
+will suggest ``snprintf`` instead.
+
+It's a common idiom to have a fixed-size buffer of characters allocated on 
+the stack and then to printf into the buffer. It may be leading to errors if the 
+string to be written exceeds the size of the array pointed to by buffer.
+
+Example:
+.. code-block:: c++
+
+void f(){
+  char buff[80];
+  sprintf(buff, "Hello, %s!\n", "world");
+}
+
+Becomes:
+.. code-block:: c++
+
+void f(){
+  char buff[80];
+  snprintf(buff, sizeof(buff), "Hello, %s!\n", "world");
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -99,6 +99,11 @@
 New checks
 ^^
 
+- New :doc:`bugprone-sprintf-with-fixed-size-buffer
+  ` check.
+
+  Finds usage of ``sprintf``, which write output string into a fixed-size array.
+
 - New :doc:`cppcoreguidelines-avoid-const-or-ref-data-members
   ` check.
 
Index: clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.h
@@ -0,0 +1,38 @@
+//===--- SprintfWithFixedSizeBufferCheck.h - clang-tidy -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPRINTFWITHFIXEDSIZEBUFFERCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SPRINTFWITHFIXEDSIZEBUFFERCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Check if `sprintf` is called with a fixed size buffer. Replaced with counted
+/// version `snprintf`.
+///
+/// For the user-facing documentati

[PATCH] D132256: [clang-format] Add DefinitionBlockSpacing option

2022-08-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

nice


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132256

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


[clang] 3adda39 - [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2022-08-20T12:52:21-04:00
New Revision: 3adda398cef7f56d024924158e7b17d65cbc565d

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

LOG: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

Use this instead of `*_LIBDIR_SUFFIX`, from which it is computed.

This gets us ready for D130586, in which `*_LIBDIR_SUFFIX` is
deprecated.

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/include/clang/Config/config.h.cmake
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
lldb/cmake/modules/LLDBGenerateConfig.cmake
lldb/include/lldb/Host/Config.h.cmake
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
lldb/unittests/Expression/ClangParserTest.cpp
llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 60f6c162a2d55..a6782db7b5809 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -871,6 +871,8 @@ if(CLANG_BUILT_STANDALONE)
   process_llvm_pass_plugins()
 endif()
 
+set(CLANG_INSTALL_LIBDIR_BASENAME "lib${CLANG_LIBDIR_SUFFIX}")
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)

diff  --git a/clang/include/clang/Config/config.h.cmake 
b/clang/include/clang/Config/config.h.cmake
index dfd2f757a185b..a4083827e43f8 100644
--- a/clang/include/clang/Config/config.h.cmake
+++ b/clang/include/clang/Config/config.h.cmake
@@ -53,8 +53,8 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}"
 
-/* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX "${CLANG_LIBDIR_SUFFIX}"
+/* Multilib basename for libdir. */
+#define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}"
 
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}"

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 05d00a50504c4..d00f08d15ae58 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -180,7 +180,7 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
 // path of the embedding binary, which for LLVM binaries will be in bin/.
 // ../lib gets us to lib/ in both cases.
 P = llvm::sys::path::parent_path(Dir);
-llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+llvm::sys::path::append(P, CLANG_INSTALL_LIBDIR_BASENAME, "clang",
 CLANG_VERSION_STRING);
   }
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 77ce0395cf3c1..c0aec33b082a5 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -502,7 +502,8 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const 
ArgList &Args,
 
 SmallString<1024> Plugin;
 llvm::sys::path::native(
-Twine(D.Dir) + "/../lib" CLANG_LIBDIR_SUFFIX "/LLVMgold" + Suffix,
+Twine(D.Dir) + "/../" CLANG_INSTALL_LIBDIR_BASENAME "/LLVMgold" +
+Suffix,
 Plugin);
 CmdArgs.push_back(Args.MakeArgString(Plugin));
   }
@@ -658,7 +659,7 @@ void tools::addOpenMPRuntimeSpecificRPath(const ToolChain 
&TC,
 // runtime
 SmallString<256> DefaultLibPath =
 llvm::sys::path::parent_path(TC.getDriver().Dir);
-llvm::sys::path::append(DefaultLibPath, Twine("lib") + 
CLANG_LIBDIR_SUFFIX);
+llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
 CmdArgs.push_back("-rpath");
 CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
   }
@@ -671,7 +672,7 @@ void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,
   // runtime.
   SmallString<256> DefaultLibPath =
   llvm::sys::path::parent_path(TC.getDriver().Dir);
-  llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+  llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
   CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath));
 }
 
@@ -1947,7 +1948,7 @@ void tools::AddStaticDeviceLibs(Compilation *C, const 
Tool *T,
 
   // Add path to lib-debug folders
   SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(D.Dir);
-  llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
+  llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
   LibraryPaths.emplace_back(DefaultLibPath.c_str

[PATCH] D132300: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3adda398cef7: [clang][lldb][cmake] Use new 
`*_INSTALL_LIBDIR_BASENAME` CPP macro (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132300

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
  llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h

Index: utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
===
--- utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
+++ utils/bazel/llvm-project-overlay/clang/include/clang/Config/config.h
@@ -67,8 +67,8 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "z10"
 
-/* Multilib suffix for libdir. */
-#define CLANG_LIBDIR_SUFFIX ""
+/* Multilib basename for libdir. */
+#define CLANG_INSTALL_LIBDIR_BASENAME "lib"
 
 /* Relative directory for resource files */
 #define CLANG_RESOURCE_DIR ""
Index: llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
===
--- llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
+++ llvm/utils/gn/secondary/lldb/include/lldb/Host/BUILD.gn
@@ -21,6 +21,7 @@
 "LLDB_ENABLE_PYTHON=",
 "LLDB_ENABLE_FBSDVMCORE=",
 "LLDB_EMBED_PYTHON_HOME=",
+"LLDB_INSTALL_LIBDIR_BASENAME=lib",
 "LLDB_GLOBAL_INIT_DIRECTORY=",
 
 "LLDB_PYTHON_HOME=",
Index: llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
+++ llvm/utils/gn/secondary/clang/include/clang/Config/BUILD.gn
@@ -18,6 +18,7 @@
 "CLANG_DEFAULT_OBJCOPY=objcopy",
 "CLANG_DEFAULT_OPENMP_RUNTIME=libomp",
 "CLANG_DEFAULT_UNWINDLIB=",
+"CLANG_INSTALL_LIBDIR_BASENAME=lib",
 "CLANG_OPENMP_NVPTX_DEFAULT_ARCH=sm_35",
 "CLANG_LIBDIR_SUFFIX=",
 "CLANG_RESOURCE_DIR=",
Index: lldb/unittests/Expression/ClangParserTest.cpp
===
--- lldb/unittests/Expression/ClangParserTest.cpp
+++ lldb/unittests/Expression/ClangParserTest.cpp
@@ -37,7 +37,8 @@
 TEST_F(ClangHostTest, ComputeClangResourceDirectory) {
 #if !defined(_WIN32)
   std::string path_to_liblldb = "/foo/bar/lib/";
-  std::string path_to_clang_dir = "/foo/bar/lib" LLDB_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING;
+  std::string path_to_clang_dir =
+  "/foo/bar/" LLDB_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING;
 #else
   std::string path_to_liblldb = "C:\\foo\\bar\\lib";
   std::string path_to_clang_dir = "C:\\foo\\bar\\lib\\clang\\" CLANG_VERSION_STRING;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
@@ -55,11 +55,11 @@
   static const llvm::StringRef kResourceDirSuffixes[] = {
   // LLVM.org's build of LLDB uses the clang resource directory placed
   // in $install_dir/lib{,64}/clang/$clang_version.
-  "lib" CLANG_LIBDIR_SUFFIX "/clang/" CLANG_VERSION_STRING,
+  CLANG_INSTALL_LIBDIR_BASENAME "/clang/" CLANG_VERSION_STRING,
   // swift-lldb uses the clang resource directory copied from swift, which
   // by default is placed in $install_dir/lib{,64}/lldb/clang. LLDB places
-  // it there, so we use LLDB_LIBDIR_SUFFIX.
-  "lib" LLDB_LIBDIR_SUFFIX "/lldb/clang",
+  // it there, so we use LLDB_INSTALL_LIBDIR_BASENAME.
+  LLDB_INSTALL_LIBDIR_BASENAME "/lldb/clang",
   };
 
   for (const auto &Suffix : kResourceDirSuffixes) {
Index: lldb/source/Host/linux/HostInfoLinux.cpp
===
--- lldb/source/Host/linux/HostInfoLinux.cpp
+++ lldb/source/Host/linux/HostInfoLinux.cpp
@@ -175,7 +175,7 @@
 }
 
 bool HostInfoLinux::ComputeSystemPluginsDirectory(FileSpec &file_spec) {
-  FileSpec temp_file("/usr/lib" LLDB_LIBDIR_SUFFIX "/lldb/plugins");
+  FileSpec temp_file("/usr/" LLDB_INSTALL_LIBDIR_BASENAME "/lldb/plugins");
   FileSystem::Instance().Resolve(temp_file);
   file_spec.SetD

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-08-20 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

This change breaks libc++'s modular build see build 
https://buildkite.com/llvm-project/libcxx-ci/builds/12991
Reverting this commit on top of yesterday's build (before your revert) fixes 
the issue.

libc++'s modular build uses Clang's pre-C++20 modules.

It can be reproduced building libc++ and running the following lit invocation
`${LIT} -Denable_modules=True 
libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp`

If you need assistance testing a new version of this patch on libc++ please let 
me know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D132300: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

`D130586` was approved; this is a subset; this had no test failures, so I just 
went ahead and landed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132300

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


[PATCH] D132189: [clang-format] Don't put `noexcept` on empty line following constructor

2022-08-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

This looks pretty good to me, but wait for @HazardyKnusperkeks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132189

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


[PATCH] D132131: [clang-format] Adds a formatter for aligning trailing comments over empty lines

2022-08-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:1602
   Style.AlignTrailingComments = false;
+  Style.AlignTrailingCommentsIgnoreEmptyLine = false;
   Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;

ditto remove



Comment at: clang/unittests/Format/FormatTest.cpp:26445
+   Style);
+}
+

I think it needs more tests than just include examples


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132131

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


[PATCH] D132300: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I fixed up the gn build after this in 804d4594cbe217ae817b6786b0e9965283f78aa2 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132300

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


[PATCH] D132300: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(ie if you revert that, it'd be appreciated if you could revert that in the 
same commit)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132300

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


[PATCH] D130308: [clang] extend getCommonSugaredType to merge sugar nodes

2022-08-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 454238.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130308

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1,2 +1,3 @@
 D111283
 D111509
+D130308
Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++20 -fenable-matrix -triple i686-pc-win32
 
 enum class N {};
 
@@ -38,3 +38,77 @@
 N t7 = X4() + Y4(); // expected-error {{rvalue of type 'B4'}}
 N t8 = X4() * Y4(); // expected-error {{rvalue of type 'B4'}}
 N t9 = X5() * Y5(); // expected-error {{rvalue of type 'A4 __attribute__((matrix_type(3, 3)))'}}
+
+template  struct S1 {
+  template  struct S2 {};
+};
+
+N t10 = 0 ? S1() : S1(); // expected-error {{from 'S1' (aka 'S1')}}
+N t11 = 0 ? S1::S2() : S1::S2(); // expected-error {{from 'S1::S2' (aka 'S2')}}
+
+template  using Al = S1;
+
+N t12 = 0 ? Al() : Al(); // expected-error {{from 'Al' (aka 'S1')}}
+
+#define AS1 __attribute__((address_space(1)))
+#define AS2 __attribute__((address_space(1)))
+using AS1X1 = AS1 B1;
+using AS1Y1 = AS1 B1;
+using AS2Y1 = AS2 B1;
+N t13 = 0 ? (AS1X1){} : (AS1Y1){}; // expected-error {{rvalue of type 'AS1 B1' (aka '__attribute__((address_space(1))) int')}}
+N t14 = 0 ? (AS1X1){} : (AS2Y1){}; // expected-error {{rvalue of type '__attribute__((address_space(1))) B1' (aka '__attribute__((address_space(1))) int')}}
+
+using FX1 = X1 ();
+using FY1 = Y1 ();
+N t15 = 0 ? (FX1*){} : (FY1*){}; // expected-error {{rvalue of type 'B1 (*)()' (aka 'int (*)()')}}
+
+struct SS1 {};
+using SB1 = SS1;
+using SX1 = SB1;
+using SY1 = SB1;
+
+using MFX1 = X1 SX1::*();
+using MFY1 = Y1 SY1::*();
+
+N t16 = 0 ? (MFX1*){} : (MFY1*){}; // expected-error {{rvalue of type 'B1 SB1::*(*)()'}}
+
+N t17 = 0 ? (FX1 SX1::*){} : (FY1 SY1::*){}; // expected-error {{rvalue of type 'B1 (SB1::*)() __attribute__((thiscall))'}}
+
+N t18 = 0 ? (__typeof(X1*)){} : (__typeof(Y1*)){}; // expected-error {{rvalue of type 'typeof(B1 *)' (aka 'int *')}}
+
+struct Enums {
+  enum X : B1;
+  enum Y : ::B1;
+};
+using EnumsB = Enums;
+using EnumsX = EnumsB;
+using EnumsY = EnumsB;
+
+N t19 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::Y)){};
+// expected-error@-1 {{rvalue of type 'B1' (aka 'int')}}
+
+N t20 = 0 ? (__underlying_type(EnumsX::X)){} : (__underlying_type(EnumsY::X)){};
+// expected-error@-1 {{rvalue of type '__underlying_type(Enums::X)' (aka 'int')}}
+
+using SBTF1 = SS1 [[clang::btf_type_tag("1")]];
+using SBTF2 = ::SS1 [[clang::btf_type_tag("1")]];
+using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
+
+N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 btf_type_tag(1)' (aka 'SS1')}}
+
+using QX = const SB1 *;
+using QY = const ::SB1 *;
+N t23 = 0 ? (QX){} : (QY){}; // expected-error {{rvalue of type 'const SB1 *' (aka 'const SS1 *')}}
+
+template  using Alias = short;
+N t24 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'Alias' (aka 'short')}}
+N t25 = 0 ? (Alias){} : (Alias){}; // expected-error {{rvalue of type 'short'}}
+
+template  concept C1 = true;
+template  concept C2 = true;
+C1 auto t26_1 = (SB1){};
+C1 auto t26_2 = (::SB1){};
+C2 auto t26_3 = (::SB1){};
+N t26 = 0 ? t26_1 : t26_2; // expected-error {{from 'SB1' (aka 'SS1')}}
+N t27 = 0 ? t26_1 : t26_3; // expected-error {{from 'SB1' (aka 'SS1')}}
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3848,13 +3848,11 @@
 //   - If A is an array type, the pointer type produced by the
 // array-to-pointer standard conversion (4.2) is used in place of
 // A for type deduction; otherwise,
-if (ArgType->isArrayType())
-  ArgType = S.Context.getArrayDecayedType(ArgType);
 //   - If A is a function type, the pointer type produced by the
 // function-to-pointer standard conversion (4.3) is used in place
 // of A for type deduction; otherwise,
-else if (ArgType->isFunctionType())
-  ArgType = S.Context.getPointerType(ArgType);
+if (ArgType->canDecayToPointerType())
+  ArgType = S.Context.getDecayedType(ArgType);
 else {
   // - If A is a cv-qualified type, the top level cv-qualifiers of A's
   //   type are ignored for type 

[PATCH] D130308: [clang] extend getCommonSugaredType to merge sugar nodes

2022-08-20 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked 5 inline comments as done.
mizvekov added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:12218
+CTN,
+NExpX && NExpY ? Optional(std::min(*NExpX, *NExpY)) : None);
+  }

davrec wrote:
> I'm not clear on how `NExpX` could not equal `NExpY` - could you add a test 
> which demonstrates this case?
It may not be needed in this patch, and it might in fact be related to a bug 
which I already solved in the main resugaring patch. I will double check later.



Comment at: clang/lib/AST/ASTContext.cpp:12767
+Ctx.getQualifiedType(Underlying),
+::getCommonDecl(EX->getOwnedTagDecl(), EY->getOwnedTagDecl()));
+  }

davrec wrote:
> mizvekov wrote:
> > davrec wrote:
> > > mizvekov wrote:
> > > > davrec wrote:
> > > > > This last argument should probably be omitted/nullptr passed, since
> > > > > # We probably won't encounter any owned tag decls in the types passed 
> > > > > to this function;
> > > > > # Even if we did, it would not necessarily be true that they both 
> > > > > have non-null owned tag decls, and I don't see any nullptr checks in 
> > > > > getCommonDecl; and
> > > > > # Even if we checked for nullptr there, and say passed the same 
> > > > > argument to X and Y so EX==EY, and that had an owned tag decl, it is 
> > > > > not clear to me it would be appropriate to construct a new type with 
> > > > > the same owned tag decl as another type.
> > > > 1. We can see, a one liner like this will do: `int e = true ? (struct 
> > > > S*)0 : (struct S*)0;`
> > > > 
> > > > Though normally in an example like the above, you would only see the 
> > > > owned decl on X, because when we get to Y the name has already been 
> > > > introduced into the scope.
> > > > 
> > > > I have an idea for a test case, but it's a bit convoluted:
> > > > 
> > > > This also introduces an OwnedTagDecl: `(struct S*)0`.
> > > > 
> > > > So with resugaring, if we resugar T, it might be possible to construct 
> > > > this situatiation. Given if it's appropriate to keep the OwnedTagDecl 
> > > > when resugaring, of course, which goes to 3)
> > > > 
> > > > 2. This is handled by `declaresSameEntity`, if either or both decls are 
> > > > null, we say they are not the same decl.
> > > > 
> > > > 3. That I am not sure. I see that this OwnedTagDecl is only used by the 
> > > > type printer, and it replaces printing the rest of the type by printing 
> > > > the OwnedDecl instead. So why do you think it would not be appropriate 
> > > > that the rebuilt type keeps this?
> > > (Re #3) Because I think the sense ownership is respected in how 
> > > ownedTagDecls are presently handled: at most one ElaboratedType owns a 
> > > particular TagDecl, *and* that type does not seem to be reused elsewhere 
> > > in the AST.  (This is relied on in https://reviews.llvm.org/D131685, 
> > > which was on my mind when I looked at this.)
> > > 
> > > E.g. consider this expansion of your example:
> > > ```
> > > auto e = true ? (struct S*)0 : (true ? (struct S*)0 : (struct S*)0);
> > > ```
> > > The first ElaboratedType has an ownedTagDecl; the second is a distinct 
> > > ElaboratedType without an ownedTagDecl, and the third equals the second.  
> > > 
> > > Now in practice what this means is that `getCommonDecl` when used on 
> > > binary expressions of this sort will always be nullptr, so no harm done.  
> > > But suppose it is called with X=Y=some ET with an ownedTagDecl (which is 
> > > the only time I believe we could see a non null getCommonDecl result 
> > > here).  Should the type that is returned have that same owned tag decl?  
> > > I think that would violate the sense of the original type "owning" that 
> > > decl that seems to be respected elsewhere in the AST.
> > > 
> > > Re type printing, I believe that ownedTagDecls only affects printing of 
> > > defined TagDecls like `struct S { int i; } x;` (which is what I was 
> > > mostly thinking re ownedTagDecls - I don't think we will see those here); 
> > > for undefined ones like `struct S x;`, printing should be unaffected 
> > > whether there is an ownedTagDecl or not.
> > > 
> > With type deduction this can happen:
> > 
> > ```
> > auto x = (struct S*)0; // it will also appear in the type of x
> > using t = decltype(x); // and now also in t
> > ```
> > 
> > With your second example, it can also happen:
> > 
> > ```
> > struct S { int i; } x;
> > int e = true ? &x : (struct S*)0;
> > ```
> > 
> > In those cases, the type node that owns the decl will be the same object, 
> > but that is only because of uniquing.
> > 
> > It may be possible that two different objects end up in this situation, if 
> > for example they come from different modules that got merged.
> > With type deduction this can happen:
> > ```
> > auto x = (struct S*)0; // it will also appear in the type of x
> > using t = decltype(x); // and now also in t
> > ```
> 
> My local clang is out of date - the type of `x` for 

[PATCH] D132300: [clang][lldb][cmake] Use new `*_INSTALL_LIBDIR_BASENAME` CPP macro

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

OK Thanks @thakis --- I was confused why the last GN fixup added but didn't 
remove lines. That clears it up!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132300

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


[PATCH] D132290: [clang-tidy] Skip unions in use-equals-default

2022-08-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default-copy.cpp:38
+  NU(const NU &Other) : Field(Other.Field) {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: NU(const NU &Other) :

These lines are redundant as FileCheck will report a failure for any line 
containing the word 'warning' that doesn't have a directive in the input file.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-equals-default.cpp:39
+  NU() {}
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:3: warning: use '= default'
+  // CHECK-FIXES: NU() {}

Same as above


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132290

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


[PATCH] D132294: [clang-tidy] Add check of sprintf with fixed size buffer

2022-08-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Why are we only targeting sprintf, vsprintf would also suffer from the same 
pitfalls.
Is there any hard reason that this check always suggests `snprintf` instead of 
`sprintf_s`, maybe have that dynamically controlled with an option.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/SprintfWithFixedSizeBufferCheck.cpp:36
+
+  std::string ReplacementText = "snprintf(";
+  auto arg = Call->getArgs();

Prefer small little edits instead of one big replacement.
So create a fix it that turns `sprintf` into `snprintf`, then create a fix it 
that inserts `, sizeof(Buff)` after the first argument.


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

https://reviews.llvm.org/D132294

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


[PATCH] D128861: [clang-tidy] add cppcoreguidelines-symmetric-binary-operator

2022-08-20 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti added a comment.

I've got everything done locally, but I'm waiting on the decision on the bitset 
to update the diff, including some minor additional updates I will list then.




Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/SymmetricBinaryOperatorCheck.cpp:56
+bool isComparisonOperator(OverloadedOperatorKind Kind) {
+  return llvm::is_contained(
+  std::initializer_list{

njames93 wrote:
> Could these not be represented as a bitset?
Yes. I changed this to use a bitset. While changing it I thought about the 
performance and came to these two solutions:
A) is straight forward but suffers from bad-ish code gen when doing -O0 (58 
instructions), on -O1 and up it's just 4 instructions.
```
bool isComparisonOperator(OverloadedOperatorKind Kind) {
  std::bitset BitSetCompOps{};
  BitSetCompOps.set(OO_Less);
  BitSetCompOps.set(OO_Greater);
  BitSetCompOps.set(OO_EqualEqual);
  BitSetCompOps.set(OO_ExclaimEqual);
  BitSetCompOps.set(OO_LessEqual);
  BitSetCompOps.set(OO_GreaterEqual);
  BitSetCompOps.set(OO_Spaceship);
  BitSetCompOps.set(OO_AmpAmp);
  BitSetCompOps.set(OO_PipePipe);
  return BitSetCompOps[Kind];
}
```

B) the same, but this emits much less code during -O0 (14 instructions) and for 
-O1 and up it's the same as A)
```
template 
constexpr size_t isComparisonOperatorGenerateBitset() {
  return ((static_cast(1U) << ComparisonKinds) | ...);
}

bool isComparisonOperator(OverloadedOperatorKind Kind) {
  constexpr static auto BitsetCompOps = isComparisonOperatorGenerateBitset<
  OO_Less, OO_Greater, OO_EqualEqual, OO_ExclaimEqual, OO_LessEqual,
  OO_GreaterEqual, OO_Spaceship, OO_AmpAmp, OO_PipePipe>();
  return BitsetCompOps & (static_cast(1U) << Kind);
}
```
See also https://godbolt.org/z/E9aeW67xb for both examples.
I think B) would be better, but I thought I'd ask before going with a parameter 
pack instead of the std::bitset.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/SymmetricBinaryOperatorCheck.cpp:84
+
+static Expected getNode(const BoundNodes &Nodes, StringRef ID) {
+  auto &NodesMap = Nodes.getMap();

njames93 wrote:
> Should there ever be a case where this returns an error. If not can this 
> assert instead and just return a DynTypedNode?
I got this bit from the Transformer lib implementation, but you're right, there 
are no paths in this check that call getNode with an unbound ID.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/SymmetricBinaryOperatorCheck.cpp:135-136
+};
+return invalidArgumentError(
+"constSpec invalid argument: not a CXXMethodDecl");
+  };

njames93 wrote:
> Is this error reachable? Again if not use unreachable.
> If it is reachable, is it possible to show a test case where this error is 
> expected and detected in the test?
Yes it's unreachable, constSpec get's only called on bound node "op" which is a 
CXXMethodDecl. Changed it to llvm_unreachable like the other unreachable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128861

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


[PATCH] D132316: [CMake] `${LLVM_BINARY_DIR}/lib(${LLVM_LIBDIR_SUFFIX})?` -> `${LLVM_LIBRARY_DIR}`

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Ericson2314 added reviewers: phosek, sebastian-ne, beanz.
Herald added subscribers: bzcheeseman, ayermolo, sdasgup3, wenzhicui, wrengr, 
cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, 
rriddle, mehdi_amini, pengfei, atanasyan, jrtc27, gbedwell, mgorny, nemanjai, 
sdardis.
Herald added a reviewer: bollu.
Herald added a reviewer: andreadb.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added projects: Flang, All.
Ericson2314 requested review of this revision.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits, yota9, 
stephenneuendorffer, nicolasvasilache, jdoerfert.
Herald added projects: clang, LLDB, MLIR, LLVM.

A simple sed, getting the versions with `LLVM_LIBDIR_SUFFIX` and the
ones without.

This decreases the usages of `LLVM_LIBDIR_SUFFIX`, preparing us for D130586 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132316

Files:
  bolt/lib/Target/AArch64/CMakeLists.txt
  bolt/lib/Target/X86/CMakeLists.txt
  bolt/unittests/Core/CMakeLists.txt
  clang/cmake/modules/CMakeLists.txt
  clang/lib/Tooling/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
  llvm/tools/llvm-shlib/CMakeLists.txt
  llvm/unittests/Target/ARM/CMakeLists.txt
  llvm/unittests/Target/DirectX/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/Mips/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt
  llvm/unittests/tools/llvm-mca/X86/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/test/CMakeLists.txt

Index: polly/test/CMakeLists.txt
===
--- polly/test/CMakeLists.txt
+++ polly/test/CMakeLists.txt
@@ -46,7 +46,7 @@
 
 set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
+set(LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}")
 if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
   set(POLLY_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 else()
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -12,7 +12,7 @@
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 if (CMAKE_CONFIGURATION_TYPES)
   set(POLLY_EXPORTS_FILE_NAME "PollyExports-$>.cmake")
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -15,7 +15,7 @@
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
 export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake)
Index: llvm/unittests/tools/llvm-mca/X86/CMakeLists.txt
===
--- llvm/unittests/tools/llvm-mca/X86/CMakeLists.txt
+++ llvm/unittests/tools/llvm-mca/X86/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_mca_unittest_includes(
   ${LLVM_MAIN_SRC_DIR}/lib/Target/X86
-  ${LLVM_BINARY_DIR}/lib/Target/X86
+  ${LLVM_LIBRARY_DIR}/Target/X86
   )
 
 add_llvm_mca_unittest_sources(
Index: llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt
===
--- llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt
+++ llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_exegesis_unittest_includes(
   ${LLVM_MAIN_SRC_DIR}/lib/Target/X86
-  ${LLVM_BINARY_DIR}/lib/Target/X86
+  ${LLVM_LIBRARY_DIR}/Target/X86
   ${LLVM_MAIN_SRC_DIR}/tool

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-08-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D126907#3737375 , @Mordante wrote:

> This change breaks libc++'s modular build see build 
> https://buildkite.com/llvm-project/libcxx-ci/builds/12991
> Reverting this commit on top of yesterday's build (before your revert) fixes 
> the issue.
>
> libc++'s modular build uses Clang's pre-C++20 modules.
>
> It can be reproduced building libc++ and running the following lit invocation
> `${LIT} -Denable_modules=True 
> libcxx/test/libcxx/ranges/range.adaptors/range.all/all.nodiscard.verify.cpp`
>
> If you need assistance testing a new version of this patch on libc++ please 
> let me know.

Is this not part of check-runtimes or check-cxx?  I ran both of those INCLUDING 
a modules-builds-all...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[libunwind] dad00da - [libunwind] Fixed a number of typos

2022-08-20 Thread Fangrui Song via cfe-commits

Author: Gabriel Ravier
Date: 2022-08-20T18:09:03-07:00
New Revision: dad00daa7a0a656640f7579c2c21933ef97a1978

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

LOG: [libunwind] Fixed a number of typos

I went over the output of the following mess of a command:

`(ulimit -m 200; ulimit -v 200; git ls-files -z | parallel --xargs -0 
cat | aspell list --mode=none --ignore-case | grep -E '^[A-Za-z][a-z]*$' | sort 
| uniq -c | sort -n | grep -vE '.{25}' | aspell pipe -W3 | grep : | cut -d' ' 
-f2 | less)`

and proceeded to spend a few days looking at it to find probable typos
and fixed a few hundred of them in all of the llvm project (note, the
ones I found are not anywhere near all of them, but it seems like a
good start).

Reviewed By: #libunwind, MaskRay

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

Added: 


Modified: 
libunwind/docs/conf.py
libunwind/include/mach-o/compact_unwind_encoding.h
libunwind/include/unwind.h
libunwind/src/DwarfInstructions.hpp
libunwind/src/DwarfParser.hpp
libunwind/src/Registers.hpp
libunwind/src/Unwind-EHABI.cpp
libunwind/src/Unwind-seh.cpp
libunwind/src/Unwind-sjlj.c
libunwind/src/UnwindCursor.hpp
libunwind/src/UnwindLevel1-gcc-ext.c
libunwind/src/UnwindLevel1.c
libunwind/src/UnwindRegistersRestore.S
libunwind/src/libunwind.cpp
libunwind/test/unwind_leaffunction.pass.cpp

Removed: 




diff  --git a/libunwind/docs/conf.py b/libunwind/docs/conf.py
index 3fe17d003c769..404bcb0685759 100644
--- a/libunwind/docs/conf.py
+++ b/libunwind/docs/conf.py
@@ -242,7 +242,7 @@
 #texinfo_show_urls = 'footnote'
 
 
-# FIXME: Define intersphinx configration.
+# FIXME: Define intersphinx configuration.
 intersphinx_mapping = {}
 
 

diff  --git a/libunwind/include/mach-o/compact_unwind_encoding.h 
b/libunwind/include/mach-o/compact_unwind_encoding.h
index 68d562eec438e..2dd857e45b496 100644
--- a/libunwind/include/mach-o/compact_unwind_encoding.h
+++ b/libunwind/include/mach-o/compact_unwind_encoding.h
@@ -33,7 +33,7 @@
 
 
 //
-// The compact unwind endoding is a 32-bit value which encoded in an
+// The compact unwind encoding is a 32-bit value which encoded in an
 // architecture specific way, which registers to restore from where, and how
 // to unwind out of the function.
 //
@@ -116,7 +116,7 @@ enum {
 //on the stack immediately after the return address.  The stack_size/4 is
 //encoded in the UNWIND_X86_FRAMELESS_STACK_SIZE (max stack size is 1024).
 //The number of registers saved is encoded in 
UNWIND_X86_FRAMELESS_STACK_REG_COUNT.
-//UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION constains which registers were
+//UNWIND_X86_FRAMELESS_STACK_REG_PERMUTATION contains which registers were
 //saved and their order.
 // UNWIND_X86_MODE_STACK_IND:
 //A "frameless" (EBP not used as frame pointer) function large constant 
@@ -250,7 +250,7 @@ enum {
 //on the stack immediately after the return address.  The stack_size/8 is
 //encoded in the UNWIND_X86_64_FRAMELESS_STACK_SIZE (max stack size is 
2048).
 //The number of registers saved is encoded in 
UNWIND_X86_64_FRAMELESS_STACK_REG_COUNT.
-//UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION constains which registers 
were
+//UNWIND_X86_64_FRAMELESS_STACK_REG_PERMUTATION contains which registers 
were
 //saved and their order.  
 // UNWIND_X86_64_MODE_STACK_IND:
 //A "frameless" (RBP not used as frame pointer) function large constant 

diff  --git a/libunwind/include/unwind.h b/libunwind/include/unwind.h
index 6557374fa9d31..26cdef22207ed 100644
--- a/libunwind/include/unwind.h
+++ b/libunwind/include/unwind.h
@@ -93,7 +93,7 @@ extern void _Unwind_SjLj_Unregister(_Unwind_FunctionContext_t 
fc);
 #endif
 
 //
-// The following are semi-suppoted extensions to the C++ ABI
+// The following are semi-supported extensions to the C++ ABI
 //
 
 //

diff  --git a/libunwind/src/DwarfInstructions.hpp 
b/libunwind/src/DwarfInstructions.hpp
index cee4ea53dab7a..77f13832d68fd 100644
--- a/libunwind/src/DwarfInstructions.hpp
+++ b/libunwind/src/DwarfInstructions.hpp
@@ -25,7 +25,7 @@
 namespace libunwind {
 
 
-/// DwarfInstructions maps abtract DWARF unwind instructions to a particular
+/// DwarfInstructions maps abstract DWARF unwind instructions to a particular
 /// architecture
 template 
 class DwarfInstructions {
@@ -241,7 +241,7 @@ int DwarfInstructions::stepWithDwarf(A &addressSpace, 
pint_t pc,
 return UNW_EBADREG;
 } else if (i == (int)cieInfo.returnAddressRegister) {
 // Leaf function keeps the return address in register and there is 
no
-// explicit intructions how to restore it.
+// explicit instructions how to restore it.
 returnA

[PATCH] D131533: [Flang][Driver] Enable PIC in the frontend

2022-08-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: flang/test/Driver/pic-flags.f90:69
+! CHECK-ROPI: "-mrelocation-model" "ropi"
+! CHECK-ROPI-NOT: -pic
+

I'd use `! CHECK-ROPI-NOT: "-pic`

otherwise there is a risk that the pattern matches a temporary file named 
`*-pic*`.


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

https://reviews.llvm.org/D131533

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


[PATCH] D132324: [RFC] Remove support for building C++ with `LLVM_ENABLE_PROJECTS`

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Ericson2314 added reviewers: ldionne, phosek.
Herald added subscribers: Enna1, arichardson, mgorny.
Herald added a project: All.
Ericson2314 requested review of this revision.
Herald added subscribers: llvm-commits, libcxx-commits, Sanitizers, 
cfe-commits, MaskRay.
Herald added projects: clang, Sanitizers, libc++, LLVM.
Herald added a reviewer: libc++.

This has been officially deprecated since D112724 
, meaning the
deprecation warning is present in released 14 and 15.

This makes me think that now, shortly after the 15 release is branched,
is a good time to pull the trigger.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132324

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  libcxx/utils/ci/buildkite-pipeline.yml
  libcxx/utils/ci/oss-fuzz.sh
  libcxx/utils/ci/run-buildbot
  llvm/CMakeLists.txt

Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -123,8 +123,9 @@
 endforeach()
 foreach(proj "libcxx" "libcxxabi" "libunwind")
   if (${proj} IN_LIST LLVM_ENABLE_PROJECTS)
-message(WARNING "Using LLVM_ENABLE_PROJECTS=${proj} is deprecated now, please use -DLLVM_ENABLE_RUNTIMES=${proj} or "
-"see the instructions at https://libcxx.llvm.org/BuildingLibcxx.html for building the runtimes.")
+message(FATAL_ERROR
+  "Using LLVM_ENABLE_PROJECTS=${proj} is incorrect. Please use -DLLVM_ENABLE_RUNTIMES=${proj} or "
+  "see the instructions at https://libcxx.llvm.org/BuildingLibcxx.html for building the runtimes.")
   endif()
 endforeach()
 
Index: libcxx/utils/ci/run-buildbot
===
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -510,21 +510,6 @@
-DLIBUNWIND_TEST_CONFIG="${MONOREPO_ROOT}/libunwind/test/lit.site.cfg.in"
 check-runtimes
 ;;
-legacy-project-build)
-clean
-
-echo "--- Generating CMake"
-${CMAKE} \
-  -S "${MONOREPO_ROOT}/llvm" \
-  -B "${BUILD_DIR}" \
-  -DLLVM_ENABLE_PROJECTS="libcxx;libunwind;libcxxabi" \
-  -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
-  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-  -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-  -DLLVM_LIT_ARGS="-sv --show-unsupported --xunit-xml-output test-results.xml --timeout=1500" \
-  -DLIBCXX_CXX_ABI=libcxxabi
-check-runtimes
-;;
 aarch64)
 clean
 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
Index: libcxx/utils/ci/oss-fuzz.sh
===
--- libcxx/utils/ci/oss-fuzz.sh
+++ libcxx/utils/ci/oss-fuzz.sh
@@ -13,7 +13,7 @@
 
 mkdir ${BUILD}
 cmake -S ${PWD} -B ${BUILD} \
-  -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
+  -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DCMAKE_INSTALL_PREFIX="${INSTALL}"
 cmake --build ${BUILD} --target install-cxx-headers
Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -321,20 +321,6 @@
 limit: 2
   timeout_in_minutes: 120
 
-- label: "Legacy LLVM_ENABLE_PROJECTS build"
-  command: "libcxx/utils/ci/run-buildbot legacy-project-build"
-  artifact_paths:
-- "**/test-results.xml"
-- "**/*.abilist"
-  agents:
-queue: "libcxx-builders"
-os: "linux"
-  retry:
-automatic:
-  - exit_status: -1  # Agent was lost
-limit: 2
-  timeout_in_minutes: 120
-
   # Tests with various build configurations.
   - label: "Static libraries"
 command: "libcxx/utils/ci/run-buildbot generic-static"
Index: compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
===
--- compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
+++ compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
@@ -102,7 +102,7 @@
   LIBCXX_FLAGS="${FLAGS} -Wno-macro-redefined"
   PROJECTS=
   if [[ ! -d $LLVM_SRC/projects/libcxxabi ]] ; then
-PROJECTS="-DLLVM_ENABLE_PROJECTS='libcxx;libcxxabi'"
+PROJECTS="-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi'"
   fi
   cmake -GNinja \
 ${PROJECTS} \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -307,13 +307,6 @@
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
-  // libc++.so in D.Dir+"/../lib/". Detect this path.
- 

[PATCH] D132324: [RFC] Remove support for building C++ with `LLVM_ENABLE_PROJECTS`

2022-08-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM




Comment at: 
compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh:103
   LIBCXX_FLAGS="${FLAGS} -Wno-macro-redefined"
   PROJECTS=
   if [[ ! -d $LLVM_SRC/projects/libcxxabi ]] ; then

I'd consider renaming this to `RUNTIMES`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132324

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


[PATCH] D132324: [RFC] Remove support for building C++ with `LLVM_ENABLE_PROJECTS`

2022-08-20 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 454271.
Ericson2314 added a comment.

Do the rename @phosek suggested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132324

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  libcxx/utils/ci/buildkite-pipeline.yml
  libcxx/utils/ci/oss-fuzz.sh
  libcxx/utils/ci/run-buildbot
  llvm/CMakeLists.txt

Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -123,8 +123,9 @@
 endforeach()
 foreach(proj "libcxx" "libcxxabi" "libunwind")
   if (${proj} IN_LIST LLVM_ENABLE_PROJECTS)
-message(WARNING "Using LLVM_ENABLE_PROJECTS=${proj} is deprecated now, please use -DLLVM_ENABLE_RUNTIMES=${proj} or "
-"see the instructions at https://libcxx.llvm.org/BuildingLibcxx.html for building the runtimes.")
+message(FATAL_ERROR
+  "Using LLVM_ENABLE_PROJECTS=${proj} is incorrect. Please use -DLLVM_ENABLE_RUNTIMES=${proj} or "
+  "see the instructions at https://libcxx.llvm.org/BuildingLibcxx.html for building the runtimes.")
   endif()
 endforeach()
 
Index: libcxx/utils/ci/run-buildbot
===
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -510,21 +510,6 @@
-DLIBUNWIND_TEST_CONFIG="${MONOREPO_ROOT}/libunwind/test/lit.site.cfg.in"
 check-runtimes
 ;;
-legacy-project-build)
-clean
-
-echo "--- Generating CMake"
-${CMAKE} \
-  -S "${MONOREPO_ROOT}/llvm" \
-  -B "${BUILD_DIR}" \
-  -DLLVM_ENABLE_PROJECTS="libcxx;libunwind;libcxxabi" \
-  -GNinja -DCMAKE_MAKE_PROGRAM="${NINJA}" \
-  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-  -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-  -DLLVM_LIT_ARGS="-sv --show-unsupported --xunit-xml-output test-results.xml --timeout=1500" \
-  -DLIBCXX_CXX_ABI=libcxxabi
-check-runtimes
-;;
 aarch64)
 clean
 generate-cmake -C "${MONOREPO_ROOT}/libcxx/cmake/caches/AArch64.cmake"
Index: libcxx/utils/ci/oss-fuzz.sh
===
--- libcxx/utils/ci/oss-fuzz.sh
+++ libcxx/utils/ci/oss-fuzz.sh
@@ -13,7 +13,7 @@
 
 mkdir ${BUILD}
 cmake -S ${PWD} -B ${BUILD} \
-  -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \
+  -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DCMAKE_INSTALL_PREFIX="${INSTALL}"
 cmake --build ${BUILD} --target install-cxx-headers
Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -321,20 +321,6 @@
 limit: 2
   timeout_in_minutes: 120
 
-- label: "Legacy LLVM_ENABLE_PROJECTS build"
-  command: "libcxx/utils/ci/run-buildbot legacy-project-build"
-  artifact_paths:
-- "**/test-results.xml"
-- "**/*.abilist"
-  agents:
-queue: "libcxx-builders"
-os: "linux"
-  retry:
-automatic:
-  - exit_status: -1  # Agent was lost
-limit: 2
-  timeout_in_minutes: 120
-
   # Tests with various build configurations.
   - label: "Static libraries"
 command: "libcxx/utils/ci/run-buildbot generic-static"
Index: compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
===
--- compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
+++ compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
@@ -100,12 +100,12 @@
   mkdir -p ${LIBCXX_BUILD}
   cd ${LIBCXX_BUILD}
   LIBCXX_FLAGS="${FLAGS} -Wno-macro-redefined"
-  PROJECTS=
+  RUNTIMES=
   if [[ ! -d $LLVM_SRC/projects/libcxxabi ]] ; then
-PROJECTS="-DLLVM_ENABLE_PROJECTS='libcxx;libcxxabi'"
+RUNTIMES="-DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi'"
   fi
   cmake -GNinja \
-${PROJECTS} \
+${RUNTIMES} \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_C_COMPILER=$CC \
 -DCMAKE_CXX_COMPILER=$CXX \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -307,13 +307,6 @@
 
   Generic_GCC::AddMultiarchPaths(D, SysRoot, OSLibDir, Paths);
 
-  // The deprecated -DLLVM_ENABLE_PROJECTS=libcxx configuration installs
-  // libc++.so in D.Dir+"/../lib/". Detect this path.
-  // TODO Remove once LLVM_ENABLE_PROJECTS=libcxx is unsupported.
-  if (StringRef(D.Dir).startswith(SysRoot) &&
-  D.getVFS().exists(D.Dir + "/../lib/libc++.so"))
-addPathIfExists(D, D.Dir + "/../lib", Paths);
-
   addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
   addPathIfExists(

[clang-tools-extra] 258531b - Remove redundant initialization of Optional (NFC)

2022-08-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-20T21:18:28-07:00
New Revision: 258531b7ac0d43fce84a008235c597f920a6af7e

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

LOG: Remove redundant initialization of Optional (NFC)

Added: 


Modified: 
bolt/lib/Core/BinaryContext.cpp
bolt/lib/Rewrite/DWARFRewriter.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
clang-tools-extra/clangd/Headers.cpp
clang/lib/Format/Format.cpp
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Lex/PPDirectives.cpp
lld/COFF/Driver.cpp
lldb/source/Core/DumpDataExtractor.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusNameParser.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp
lldb/source/Plugins/TraceExporter/common/TraceHTR.cpp
lldb/source/Target/Target.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Bitcode/Reader/BitcodeAnalyzer.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/lib/CodeGen/GlobalISel/Utils.cpp
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
llvm/lib/CodeGen/SelectOptimize.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
llvm/lib/IR/FPEnv.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/Remarks/RemarkLinker.cpp
llvm/lib/Support/Threading.cpp
llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
llvm/lib/Target/X86/X86DynAllocaExpander.cpp
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/lib/Transforms/IPO/SyntheticCountsPropagation.cpp
llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
llvm/lib/Transforms/Scalar/LoopFuse.cpp
llvm/lib/Transforms/Utils/LoopPeel.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
llvm/tools/llvm-objdump/llvm-objdump.cpp
llvm/tools/llvm-readobj/ELFDumper.cpp
llvm/utils/TableGen/CodeGenSchedule.cpp
llvm/utils/TableGen/GlobalISelEmitter.cpp
mlir/lib/Analysis/Presburger/IntegerRelation.cpp
mlir/lib/CAPI/Interfaces/Interfaces.cpp
mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp

Removed: 




diff  --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp
index 9260b86298659..a1689dc837bdb 100644
--- a/bolt/lib/Core/BinaryContext.cpp
+++ b/bolt/lib/Core/BinaryContext.cpp
@@ -1648,7 +1648,7 @@ void BinaryContext::preprocessDebugInfo() {
 
 uint16_t DwarfVersion = LineTable->Prologue.getVersion();
 if (DwarfVersion >= 5) {
-  Optional Checksum = None;
+  Optional Checksum;
   if (LineTable->Prologue.ContentTypes.HasMD5)
 Checksum = LineTable->Prologue.FileNames[0].Checksum;
   Optional Name =
@@ -1686,7 +1686,7 @@ void BinaryContext::preprocessDebugInfo() {
   if (Optional FName = dwarf::toString(FileNames[I].Name))
 FileName = *FName;
   assert(FileName != "");
-  Optional Checksum = None;
+  Optional Checksum;
   if (DwarfVersion >= 5 && LineTable->Prologue.ContentTypes.HasMD5)
 Checksum = LineTable->Prologue.FileNames[I].Checksum;
   cantFail(

diff  --git a/bolt/lib/Rewrite/DWARFRewriter.cpp 
b/bolt/lib/Rewrite/DWARFRewriter.cpp
index d1fd2b6eb5f7c..ee9b6d2d490d6 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -1890,8 +1890,8 @@ void DWARFRewriter::convertToRangesPatchDebugInfo(
 DWARFDie DIE, uint64_t RangesSectionOffset,
 SimpleBinaryPatcher &DebugInfoPatcher, uint64_t LowPCToUse,
 Optional RangesBase) {
-  Optional LowPCVal = None;
-  Optional HighPCVal = None;
+  Optional LowPCVal;
+  Optional HighPCVal;
   getRangeAttrData(DIE, LowPCVal, HighPCVal);
   uint64_t LowPCOffset = LowPCVal->Offset;
   uint64_t HighPCOffset = HighPCVal->Offset;

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
index 307559a403a9a..e54a4f35fd11b 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -79,7 +79,7 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult 
&Result) {
 return;
 
   QualType TypePtr = MatchedDecl->getType();
-  llvm::Optional InitializationString = llvm::None;
+  llvm::Optional InitializationString;
   bool AddMathInclude = false;
 
   if (TypePtr-

[clang] c5da37e - Use std::is_same_v instead of std::is_same (NFC)

2022-08-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-20T22:36:26-07:00
New Revision: c5da37e42d388947a40654b7011f2a820ec51601

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

LOG: Use std::is_same_v instead of std::is_same (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Context.h
clang-tools-extra/clangd/support/Function.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Type.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Tooling/Transformer/RewriteRule.h
clang/lib/AST/Type.cpp
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
lld/MachO/InputFiles.cpp
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/FunctionExtras.h
llvm/include/llvm/ADT/STLFunctionalExtras.h
llvm/include/llvm/ADT/Sequence.h
llvm/include/llvm/ADT/SmallVector.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/ADT/iterator.h
llvm/include/llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h
llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/ProfileData/MemProf.h
llvm/include/llvm/Support/AllocatorBase.h
llvm/include/llvm/Support/Casting.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/FormatProviders.h
llvm/include/llvm/Support/FormatVariadicDetails.h
llvm/include/llvm/Support/JSON.h
llvm/include/llvm/Support/TrailingObjects.h
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/Support/ItaniumManglingCanonicalizer.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/Scalar/NaryReassociate.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
mlir/include/mlir/TableGen/Class.h

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
index aac017c0725d4..aa86d82b837e5 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -409,7 +409,7 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
 return false;
 
   // A plain reference to a name (e.g. variable) isn't  worth extracting.
-  // FIXME: really? What if it's e.g. `std::is_same::value`?
+  // FIXME: really? What if it's e.g. `std::is_same_v`?
   if (llvm::isa(E))
 return false;
 

diff  --git a/clang-tools-extra/clangd/support/Context.h 
b/clang-tools-extra/clangd/support/Context.h
index a33a9ff8fffa7..f34fe5657a36f 100644
--- a/clang-tools-extra/clangd/support/Context.h
+++ b/clang-tools-extra/clangd/support/Context.h
@@ -157,7 +157,7 @@ class Context {
   };
 
   template  class TypedAnyStorage : public Context::AnyStorage {
-static_assert(std::is_same::type, T>::value,
+static_assert(std::is_same_v::type, T>,
   "Argument to TypedAnyStorage must be decayed");
 
   public:

diff  --git a/clang-tools-extra/clangd/support/Function.h 
b/clang-tools-extra/clangd/support/Function.h
index dc9216bc53753..2f0e7aace6379 100644
--- a/clang-tools-extra/clangd/support/Function.h
+++ b/clang-tools-extra/clangd/support/Function.h
@@ -93,7 +93,7 @@ template  class Event {
   }
 
 private:
-  static_assert(std::is_same::type, T>::value,
+  static_assert(std::is_same_v::type, T>,
 "use a plain type: event values are always passed by const&");
 
   std::recursive_mutex ListenersMu;

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d8efe663ce8ee..082e20d4e3b11 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1032,7 +1032,7 @@ class FullExpr : public Expr {
 class ConstantExpr final
 : public FullExpr,
   private llvm::TrailingObjects {
-  static_assert(std::is_same::value,
+  static_assert(std::is_same_v,
 "ConstantExpr assumes that llvm::APInt::WordType is uint64_t "
 "for tail-allocated storage");
   friend TrailingObjects;

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index ad9835e839a65..728d863ad6662 100644
--- a/clang/include/clang

[clang-tools-extra] c5da37e - Use std::is_same_v instead of std::is_same (NFC)

2022-08-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-20T22:36:26-07:00
New Revision: c5da37e42d388947a40654b7011f2a820ec51601

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

LOG: Use std::is_same_v instead of std::is_same (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Context.h
clang-tools-extra/clangd/support/Function.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Type.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Tooling/Transformer/RewriteRule.h
clang/lib/AST/Type.cpp
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
lld/MachO/InputFiles.cpp
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/FunctionExtras.h
llvm/include/llvm/ADT/STLFunctionalExtras.h
llvm/include/llvm/ADT/Sequence.h
llvm/include/llvm/ADT/SmallVector.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/ADT/iterator.h
llvm/include/llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h
llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/ProfileData/MemProf.h
llvm/include/llvm/Support/AllocatorBase.h
llvm/include/llvm/Support/Casting.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/FormatProviders.h
llvm/include/llvm/Support/FormatVariadicDetails.h
llvm/include/llvm/Support/JSON.h
llvm/include/llvm/Support/TrailingObjects.h
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/Support/ItaniumManglingCanonicalizer.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/Scalar/NaryReassociate.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
mlir/include/mlir/TableGen/Class.h

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
index aac017c0725d4..aa86d82b837e5 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -409,7 +409,7 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
 return false;
 
   // A plain reference to a name (e.g. variable) isn't  worth extracting.
-  // FIXME: really? What if it's e.g. `std::is_same::value`?
+  // FIXME: really? What if it's e.g. `std::is_same_v`?
   if (llvm::isa(E))
 return false;
 

diff  --git a/clang-tools-extra/clangd/support/Context.h 
b/clang-tools-extra/clangd/support/Context.h
index a33a9ff8fffa7..f34fe5657a36f 100644
--- a/clang-tools-extra/clangd/support/Context.h
+++ b/clang-tools-extra/clangd/support/Context.h
@@ -157,7 +157,7 @@ class Context {
   };
 
   template  class TypedAnyStorage : public Context::AnyStorage {
-static_assert(std::is_same::type, T>::value,
+static_assert(std::is_same_v::type, T>,
   "Argument to TypedAnyStorage must be decayed");
 
   public:

diff  --git a/clang-tools-extra/clangd/support/Function.h 
b/clang-tools-extra/clangd/support/Function.h
index dc9216bc53753..2f0e7aace6379 100644
--- a/clang-tools-extra/clangd/support/Function.h
+++ b/clang-tools-extra/clangd/support/Function.h
@@ -93,7 +93,7 @@ template  class Event {
   }
 
 private:
-  static_assert(std::is_same::type, T>::value,
+  static_assert(std::is_same_v::type, T>,
 "use a plain type: event values are always passed by const&");
 
   std::recursive_mutex ListenersMu;

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d8efe663ce8ee..082e20d4e3b11 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1032,7 +1032,7 @@ class FullExpr : public Expr {
 class ConstantExpr final
 : public FullExpr,
   private llvm::TrailingObjects {
-  static_assert(std::is_same::value,
+  static_assert(std::is_same_v,
 "ConstantExpr assumes that llvm::APInt::WordType is uint64_t "
 "for tail-allocated storage");
   friend TrailingObjects;

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index ad9835e839a65..728d863ad6662 100644
--- a/clang/include/clang

[clang] 8b1b0d1 - Revert "Use std::is_same_v instead of std::is_same (NFC)"

2022-08-20 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-08-20T23:00:39-07:00
New Revision: 8b1b0d1d81213d10e6add52d93d0afd71baf6a04

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

LOG: Revert "Use std::is_same_v instead of std::is_same (NFC)"

This reverts commit c5da37e42d388947a40654b7011f2a820ec51601.

This patch seems to break builds with some versions of MSVC.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Context.h
clang-tools-extra/clangd/support/Function.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/Type.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Tooling/Transformer/RewriteRule.h
clang/lib/AST/Type.cpp
clang/lib/Analysis/RetainSummaryManager.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
lld/MachO/InputFiles.cpp
llvm/include/llvm/ADT/APFloat.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/FunctionExtras.h
llvm/include/llvm/ADT/STLFunctionalExtras.h
llvm/include/llvm/ADT/Sequence.h
llvm/include/llvm/ADT/SmallVector.h
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/ADT/iterator.h
llvm/include/llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h
llvm/include/llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h
llvm/include/llvm/IR/Instruction.h
llvm/include/llvm/IR/PassManager.h
llvm/include/llvm/ProfileData/MemProf.h
llvm/include/llvm/Support/AllocatorBase.h
llvm/include/llvm/Support/Casting.h
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/FormatProviders.h
llvm/include/llvm/Support/FormatVariadicDetails.h
llvm/include/llvm/Support/JSON.h
llvm/include/llvm/Support/TrailingObjects.h
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/Support/ItaniumManglingCanonicalizer.cpp
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64AddressingModes.h
llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/Scalar/NaryReassociate.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/utils/TableGen/CodeGenDAGPatterns.h
mlir/include/mlir/TableGen/Class.h

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
index aa86d82b837e5..aac017c0725d4 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -409,7 +409,7 @@ bool eligibleForExtraction(const SelectionTree::Node *N) {
 return false;
 
   // A plain reference to a name (e.g. variable) isn't  worth extracting.
-  // FIXME: really? What if it's e.g. `std::is_same_v`?
+  // FIXME: really? What if it's e.g. `std::is_same::value`?
   if (llvm::isa(E))
 return false;
 

diff  --git a/clang-tools-extra/clangd/support/Context.h 
b/clang-tools-extra/clangd/support/Context.h
index f34fe5657a36f..a33a9ff8fffa7 100644
--- a/clang-tools-extra/clangd/support/Context.h
+++ b/clang-tools-extra/clangd/support/Context.h
@@ -157,7 +157,7 @@ class Context {
   };
 
   template  class TypedAnyStorage : public Context::AnyStorage {
-static_assert(std::is_same_v::type, T>,
+static_assert(std::is_same::type, T>::value,
   "Argument to TypedAnyStorage must be decayed");
 
   public:

diff  --git a/clang-tools-extra/clangd/support/Function.h 
b/clang-tools-extra/clangd/support/Function.h
index 2f0e7aace6379..dc9216bc53753 100644
--- a/clang-tools-extra/clangd/support/Function.h
+++ b/clang-tools-extra/clangd/support/Function.h
@@ -93,7 +93,7 @@ template  class Event {
   }
 
 private:
-  static_assert(std::is_same_v::type, T>,
+  static_assert(std::is_same::type, T>::value,
 "use a plain type: event values are always passed by const&");
 
   std::recursive_mutex ListenersMu;

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 082e20d4e3b11..d8efe663ce8ee 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1032,7 +1032,7 @@ class FullExpr : public Expr {
 class ConstantExpr final
 : public FullExpr,
   private llvm::TrailingObjects {
-  static_assert(std::is_same_v,
+  static_assert(std::is_same::value,
 "ConstantExpr assumes that llvm::APInt::WordType is uint64_t "
 "for tail-allocated storage");
   friend TrailingObjects;

diff  --git

[PATCH] D130181: [clang-tidy] Add readability-use-early-exits check

2022-08-20 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 454275.
njames93 added a comment.

Add NestedControlFlow options

This option can be used to silence diagnostics when there aren't any nested 
blocks inside the if statement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130181

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.cpp
  clang-tools-extra/clang-tidy/readability/UseEarlyExitsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/use-early-exits.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-braces.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-nested.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits-split.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/use-early-exits.cpp
@@ -0,0 +1,144 @@
+// RUN: %check_clang_tidy %s readability-use-early-exits %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 1}}"
+
+// Run the check with the braces around statements check also enabled, but
+// ShortStatementLines is set so that we shouldn't add braces.
+// RUN: %check_clang_tidy %s readability-use-early-exits,readability-braces-around-statements -format-style=llvm %t -- \
+// RUN:   -config="{CheckOptions: {readability-use-early-exits.LineCountThreshold: 1, \
+// RUN:readability-braces-around-statements.ShortStatementLines: 2}}"
+
+// Just to hit the threshold
+void padLines();
+
+void nomralFunc(int *A) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (A) {
+*A = 10;
+  }
+  //   CHECK-FIXES: if (!A)
+  //  CHECK-FIXES-NEXT: return;
+  //  CHECK-FIXES-NEXT: *A = 10;
+}
+
+void funcWithTrailing(int *B) {
+  // CHECK-MESSAGES: [[@LINE+1]]:3: warning: use early exit
+  if (B) {
+*B = 10;
+  }
+  return;
+  ;
+  //   CHECK-FIXES: if (!B)
+  //  CHECK-FIXES-NEXT: return;
+  //  CHECK-FIXES-NEXT: *B = 10;
+}
+
+void normal(int A, int B) {
+
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A == B) {
+  padLines();
+}
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A != B)
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: padLines();
+
+  // Eat continue and empty nulls
+  while (true) { // CHECK-MESSAGES: [[@LINE+1]]:5: warning: use early exit
+if (A != B) {
+  padLines();
+}
+continue;
+;
+continue;
+  }
+  //   CHECK-FIXES:  while (true) {
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: padLines();
+}
+
+void toShort(int A, int B) {
+  while (true) {
+if (A == B) 
+{ }
+  }
+}
+
+void hasElse(int A, int B) {
+  while (true) {
+if (A == B) {
+
+} else {
+}
+  }
+}
+
+void hasTrailingStmt(int A, int B) {
+  while (true) {
+if (A == B) {
+}
+padLines();
+  }
+}
+
+void nested(int A, int B) {
+  // if (A > B) {
+  // CHECK-MESSAGES: [[@LINE+6]]:5: warning: use early exit
+  // if (B < A) {
+  // CHECK-MESSAGES: [[@LINE+5]]:7: warning: use early exit
+  // if (A == B) {
+  // CHECK-MESSAGES: [[@LINE+4]]:9: warning: use early exit
+  while (true) { // Nested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  }
+}
+  } // EndLoop
+  //   CHECK-FIXES: while (true) { // Nested
+  //  CHECK-FIXES-NEXT: if (A <= B)
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: if (B >= A)
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: if (A == B)
+  //  CHECK-FIXES-NEXT:   continue;
+  //  CHECK-FIXES-NEXT: padLines();
+}
+
+void badNested(bool B) {
+  // Ensure check doesn't check for nested `if` if outer `if` has else.
+  while (true) {
+if (B) {
+  if (B) {
+  }
+} else {
+}
+  }
+}
+
+void semiNested(int A, int B) {
+  // CHECK-MESSAGES: [[@LINE+2]]:5: warning: use early exit
+  while (true) { // SemiNested
+if (A > B) {
+  if (B < A) {
+if (A != B) {
+  padLines();
+}
+  } else {
+  }
+}
+  }
+  //   CHECK-FIXES: while (true) { // SemiNested
+  //  CHECK-FIXES-NEXT:   if (A <= B)
+  //  CHECK-FIXES-NEXT: continue;
+  //  CHECK-FIXES-NEXT:   if (B < A) {
+  //  CHECK-FIXES-NEXT: if (A != B) {
+  //  CHECK-FIXES-NEXT:   padLines();
+  //  CHECK-FIXES-NEXT: }
+  //  CHECK-FIXES-NEXT: } else {
+  //  CHECK-FIXE