[clang] 572cc8d - Revert "[C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty"

2023-08-27 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-08-28T13:21:17+08:00
New Revision: 572cc8d38f938eb2769907c17137a10a408d9bfc

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

LOG: Revert "[C++20] [Coroutines] Mark await_suspend as noinline if the awaiter 
is not empty"

This reverts commit 9d9c25f81456aace2bec4b58498a420e650007d9.
This reverts commit 19ab2664ad3182ffa8fe3a95bb19765e4ae84653.
This reverts commit c4672454743e942f148a1aff1e809dae73e464f6.

As the issue https://github.com/llvm/llvm-project/issues/65018 shows,
the previous fix introduce a regression actually. So this commit reverts
the fix by our policies.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGCoroutine.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 
clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
clang/test/CodeGenCoroutines/pr56301.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6dc3c1c5fbcef8..767861df912998 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -174,13 +174,6 @@ Bug Fixes in This Version
   ``abs`` builtins.
   (`#45129 `_,
   `#45794 `_)
-- Fixed an issue where accesses to the local variables of a coroutine during
-  ``await_suspend`` could be misoptimized, including accesses to the awaiter
-  object itself.
-  (`#56301 `_)
-  The current solution may bring performance regressions if the awaiters have
-  non-static data members. See
-  `#64945 `_ for details.
 - Clang now prints unnamed members in diagnostic messages instead of giving an
   empty ''. Fixes
   (`#63759 `_)

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 8acb03cd5cfc4d..e323ddf8bedae9 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5527,34 +5527,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
 Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::AlwaysInline);
   }
 
-  // The await_suspend call performed by co_await is essentially asynchronous
-  // to the execution of the coroutine. Inlining it normally into an unsplit
-  // coroutine can cause miscompilation because the coroutine CFG misrepresents
-  // the true control flow of the program: things that happen in the
-  // await_suspend are not guaranteed to happen prior to the resumption of the
-  // coroutine, and things that happen after the resumption of the coroutine
-  // (including its exit and the potential deallocation of the coroutine frame)
-  // are not guaranteed to happen only after the end of await_suspend.
-  //
-  // The short-term solution to this problem is to mark the call as 
uninlinable.
-  // But we don't want to do this if the call is known to be trivial, which is
-  // very common.
-  //
-  // The long-term solution may introduce patterns like:
-  //
-  //  call @llvm.coro.await_suspend(ptr %awaiter, ptr %handle,
-  //ptr @awaitSuspendFn)
-  //
-  // Then it is much easier to perform the safety analysis in the middle end.
-  // If it is safe to inline the call to awaitSuspend, we can replace it in the
-  // CoroEarly pass. Otherwise we could replace it in the CoroSplit pass.
-  //
-  // If the `await_suspend()` function is marked as `always_inline` explicitly,
-  // we should give the user the right to control the codegen.
-  if (inSuspendBlock() && mayCoroHandleEscape() &&
-  !TargetDecl->hasAttr())
-Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoInline);
-
   // Disable inlining inside SEH __try blocks.
   if (isSEHTryScope()) {
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoInline);

diff  --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index 2614596312f63d..cf260570510176 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -139,36 +139,6 @@ static bool memberCallExpressionCanThrow(const Expr *E) {
   return true;
 }
 
-/// Return true when the coroutine handle may escape from the await-suspend
-/// (`awaiter.await_suspend(std::coroutine_handle)` expression).
-/// Return false only when the coroutine wouldn't escape in the await-suspend
-/// for sure.
-///
-/// While it is always safe to return true, return falses can bring better
-/// performances.
-///
-/// See https://github.com/llvm/llvm-project/issues/56301 and
-/// https://reviews.llvm.org/D157070 for the example and the full discussion.
-///
-/// FIXME: It will be much 

[PATCH] D158955: [Driver] Improve legibility of ld -z options on Solaris

2023-08-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158955

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


[PATCH] D158963: [CodeGen] Function multi-versioning: don't set comdat for internal linkage resolvers

2023-08-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: erichkeane, ilinpv, pengfei, RKSimon.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For function multi-versioning using the target and target_clones
function attributes, currently we incorrectly set comdat for internal
linkage functions. This is problematic for ELF linkers
as GRP_COMDAT deduplication will kick in even with STB_LOCAL signature
(https://groups.google.com/g/generic-abi/c/2X6mR-s2zoc
"GRP_COMDAT group with STB_LOCAL signature").

In short, two `__attribute((target_clones(...))) static void foo()`
in two translation units will be deduplicated. Fix this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158963

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-target-clones.c
  clang/test/CodeGen/attr-target-mv.c


Index: clang/test/CodeGen/attr-target-mv.c
===
--- clang/test/CodeGen/attr-target-mv.c
+++ clang/test/CodeGen/attr-target-mv.c
@@ -32,6 +32,13 @@
   return foo();
 }
 
+static int __attribute__((target("arch=meteorlake"))) foo_internal(void) 
{return 15;}
+static int __attribute__((target("default"))) foo_internal(void) { return 2; }
+
+int bar1(void) {
+  return foo_internal();
+}
+
 inline int __attribute__((target("sse4.2"))) foo_inline(void) { return 0; }
 inline int __attribute__((target("arch=sandybridge"))) foo_inline(void);
 inline int __attribute__((target("arch=ivybridge"))) foo_inline(void) {return 
1;}
@@ -128,6 +135,7 @@
 
 
 // LINUX: @foo.ifunc = weak_odr ifunc i32 (), ptr @foo.resolver
+// LINUX: @foo_internal.ifunc = internal ifunc i32 (), ptr 
@foo_internal.resolver
 // LINUX: @foo_inline.ifunc = weak_odr ifunc i32 (), ptr @foo_inline.resolver
 // LINUX: @foo_decls.ifunc = weak_odr ifunc void (), ptr @foo_decls.resolver
 // LINUX: @foo_multi.ifunc = weak_odr ifunc void (i32, double), ptr 
@foo_multi.resolver
@@ -254,6 +262,11 @@
 // WINDOWS: call i32 @foo.sse4.2
 // WINDOWS: call i32 @foo
 
+/// Internal linkage resolvers do not use comdat.
+// LINUX: define internal ptr @foo_internal.resolver() {
+
+// WINDOWS: define internal i32 @foo_internal.resolver() {
+
 // LINUX: define{{.*}} i32 @bar2()
 // LINUX: call i32 @foo_inline.ifunc()
 
Index: clang/test/CodeGen/attr-target-clones.c
===
--- clang/test/CodeGen/attr-target-clones.c
+++ clang/test/CodeGen/attr-target-clones.c
@@ -16,6 +16,7 @@
 // LINUX: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
 // LINUX: @__cpu_features2 = external dso_local global [3 x i32]
 
+// LINUX: @internal.ifunc = internal ifunc i32 (), ptr @internal.resolver
 // LINUX: @foo.ifunc = weak_odr ifunc i32 (), ptr @foo.resolver
 // LINUX: @foo_dupes.ifunc = weak_odr ifunc void (), ptr @foo_dupes.resolver
 // LINUX: @unused.ifunc = weak_odr ifunc void (), ptr @unused.resolver
@@ -23,6 +24,12 @@
 // LINUX: @foo_inline2.ifunc = weak_odr ifunc i32 (), ptr @foo_inline2.resolver
 // LINUX: @foo_used_no_defn.ifunc = weak_odr ifunc i32 (), ptr 
@foo_used_no_defn.resolver
 
+static int __attribute__((target_clones("sse4.2, default"))) internal(void) { 
return 0; }
+int use(void) { return internal(); }
+/// Internal linkage resolvers do not use comdat.
+// LINUX: define internal ptr @internal.resolver() {
+// WINDOWS: define internal i32 @internal() {
+
 int __attribute__((target_clones("sse4.2, default"))) foo(void) { return 0; }
 // LINUX: define {{.*}}i32 @foo.sse4.2.0()
 // LINUX: define {{.*}}i32 @foo.default.1()
@@ -192,7 +199,5 @@
 
 // CHECK: attributes #[[SSE42]] =
 // CHECK-SAME: 
"target-features"="+crc32,+cx8,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87"
-// CHECK: attributes #[[DEF]] =
-// Don't bother checking features, we verified it is the same as a normal 
function.
 // CHECK: attributes #[[SB]] =
 // CHECK-SAME: 
"target-features"="+avx,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+sahf,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave,+xsaveopt"
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -4059,7 +4059,7 @@
 
 ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
 
-if (supportsCOMDAT())
+if (!ResolverFunc->hasLocalLinkage() && supportsCOMDAT())
   ResolverFunc->setComdat(
   getModule().getOrInsertComdat(ResolverFunc->getName()));
 


Index: clang/test/CodeGen/attr-target-mv.c
===
--- clang/test/CodeGen/attr-target-mv.c
+++ clang/test/CodeGen/attr-target-mv.c
@@ -32,6 +32,13 @@
   return foo();
 }
 
+static int __attribute__((target("arch=meteorlake"))) foo_internal(void) {return 15;}
+static int __attribute__((target("default"))) 

[clang] 4198576 - [clang] - Add missing builtin name to AtomicExpr JSON dump

2023-08-27 Thread via cfe-commits

Author: serge-sans-paille
Date: 2023-08-28T06:34:57+02:00
New Revision: 4198576157bfd0d08c08b784220d6132b709ae2c

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

LOG: [clang] - Add missing builtin name to AtomicExpr JSON dump

As a side effect, introduce AtomicExpr::getOpAsString() to dump the
AtomicOp string representation.

This is a recommit with the ranges unchecked to cope with
platform-specific values.

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

Added: 
clang/test/AST/ast-dump-atomic-json.c

Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/JSONNodeDumper.h
clang/lib/AST/JSONNodeDumper.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 6737721e1ed1b2..8d1235be78a4ad 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -6480,6 +6480,15 @@ class AtomicExpr : public Expr {
   QualType getValueType() const;
 
   AtomicOp getOp() const { return Op; }
+  StringRef getOpAsString() const {
+switch (Op) {
+#define BUILTIN(ID, TYPE, ATTRS)
+#define ATOMIC_BUILTIN(ID, TYPE, ATTRS)
\
+  case AO##ID: 
\
+return #ID;
+#include "clang/Basic/Builtins.def"
+}
+  }
   unsigned getNumSubExprs() const { return NumSubExprs; }
 
   Expr **getSubExprs() { return reinterpret_cast(SubExprs); }

diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 0ce272df8df65b..4def5389137fa4 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -285,6 +285,7 @@ class JSONNodeDumper
   void VisitBinaryOperator(const BinaryOperator *BO);
   void VisitCompoundAssignOperator(const CompoundAssignOperator *CAO);
   void VisitMemberExpr(const MemberExpr *ME);
+  void VisitAtomicExpr(const AtomicExpr *AE);
   void VisitCXXNewExpr(const CXXNewExpr *NE);
   void VisitCXXDeleteExpr(const CXXDeleteExpr *DE);
   void VisitCXXThisExpr(const CXXThisExpr *TE);

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index 139dfce41e914c..e67c2c7e216dce 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1179,6 +1179,10 @@ void JSONNodeDumper::VisitBlockDecl(const BlockDecl *D) {
   attributeOnlyIfTrue("capturesThis", D->capturesCXXThis());
 }
 
+void JSONNodeDumper::VisitAtomicExpr(const AtomicExpr *AE) {
+  JOS.attribute("name", AE->getOpAsString());
+}
+
 void JSONNodeDumper::VisitObjCEncodeExpr(const ObjCEncodeExpr *OEE) {
   JOS.attribute("encodedType", createQualType(OEE->getEncodedType()));
 }

diff  --git a/clang/test/AST/ast-dump-atomic-json.c 
b/clang/test/AST/ast-dump-atomic-json.c
new file mode 100644
index 00..fa236cee25a1bd
--- /dev/null
+++ b/clang/test/AST/ast-dump-atomic-json.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux -Wno-unused-value -ast-dump=json %s 
| FileCheck %s
+
+int foo(int * ptr) {
+  return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
+}
+
+// NOTE: CHECK lines have *not* been autogenerated by gen_ast_dump_json_test.py
+// as its output is not portable for AtomicExpr across platforms. Instead rely
+// on loose CHECKS.
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "AtomicExpr",
+// CHECK:  "type": {
+// CHECK:   "qualType": "int"
+// CHECK:  },
+// CHECK:  "valueCategory": "prvalue",
+// CHECK:  "name": "__atomic_load_n",
+// CHECK:  "inner": [
+// CHECK:   {
+// CHECK:"id": "0x{{.*}}",
+// CHECK:"kind": "ImplicitCastExpr",
+// CHECK:},
+// CHECK:"type": {
+// CHECK: "qualType": "int *"
+// CHECK:},
+// CHECK:"valueCategory": "prvalue",
+// CHECK:"castKind": "LValueToRValue",
+// CHECK:"inner": [
+// CHECK: {
+// CHECK:  "id": "0x{{.*}}",
+// CHECK:  "kind": "DeclRefExpr",
+// CHECK:  },
+// CHECK:  "type": {
+// CHECK:   "qualType": "int *"
+// CHECK:  },
+// CHECK:  "valueCategory": "lvalue",
+// CHECK:  "referencedDecl": {
+// CHECK:   "id": "0x{{.*}}",
+// CHECK:   "kind": "ParmVarDecl",
+// CHECK:   "name": "ptr",
+// CHECK:   "type": {
+// CHECK:"qualType": "int *"
+// CHECK:   }
+// CHECK:  }
+// CHECK: }
+// CHECK:]
+// CHECK:   },
+// CHECK:   {
+// CHECK:"id": "0x{{.*}}",
+// CHECK:"kind": "IntegerLiteral",
+// CHECK:},
+// CHECK:"type": {
+// CHECK: "qualType": "int"
+// CHECK:},
+// CHECK:"valueCategory": "prvalue",
+// CHECK:"value": "5"
+// CHECK:   }
+// CHECK:  ]
+// CHECK: }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2023-08-27 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added a comment.

Gentle ping. Can I move forward and land this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[clang] 9d9c25f - [C++20] [Coroutines] Don't mark await_suspend as noinline if it is specified as always_inline already

2023-08-27 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-08-28T11:43:33+08:00
New Revision: 9d9c25f81456aace2bec4b58498a420e650007d9

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

LOG: [C++20] [Coroutines] Don't mark await_suspend as noinline if it is 
specified as always_inline already

Address https://github.com/llvm/llvm-project/issues/64933 and partially
https://github.com/llvm/llvm-project/issues/64945.

After c467245, we will add a noinline attribute to the await_suspend
member function of an awaiter if the awaiter has any non static member
functions.

Obviously, this decision will bring some performance regressions. And
people may complain about this while the long term solution may not be
available soon. In such cases, it is better to provide a solution for
the users who met the regression surprisingly.

Also it is natural to not prevent the inlining if the function is marked
as always_inline by the users already.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 68d77f7f68..8acb03cd5cfc4d 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5548,7 +5548,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   // Then it is much easier to perform the safety analysis in the middle end.
   // If it is safe to inline the call to awaitSuspend, we can replace it in the
   // CoroEarly pass. Otherwise we could replace it in the CoroSplit pass.
-  if (inSuspendBlock() && mayCoroHandleEscape())
+  //
+  // If the `await_suspend()` function is marked as `always_inline` explicitly,
+  // we should give the user the right to control the codegen.
+  if (inSuspendBlock() && mayCoroHandleEscape() &&
+  !TargetDecl->hasAttr())
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoInline);
 
   // Disable inlining inside SEH __try blocks.

diff  --git a/clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp 
b/clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
index f935e256d9db99..fe66d67e6e3557 100644
--- a/clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
+++ b/clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
@@ -67,6 +67,17 @@ StatefulAwaiter& operator co_await(Awaitable2) {
   return GlobalAwaiter;
 }
 
+struct AlwaysInlineStatefulAwaiter {
+void* value;
+bool await_ready() const noexcept { return false; }
+
+template 
+__attribute__((always_inline))
+void await_suspend(std::coroutine_handle h) noexcept {}
+
+void await_resume() noexcept {}
+};
+
 Task testing() {
 co_await std::suspend_always{};
 co_await StatefulAwaiter{};
@@ -85,6 +96,8 @@ Task testing() {
 
 co_await Awaitable{};
 co_await Awaitable2{};
+
+co_await AlwaysInlineStatefulAwaiter{};
 }
 
 // CHECK-LABEL: @_Z7testingv
@@ -135,6 +148,10 @@ Task testing() {
 // CHECK: call token @llvm.coro.save
 // CHECK: call void 
@_ZN15StatefulAwaiter13await_suspendIN4Task12promise_typeEEEvSt16coroutine_handleIT_E{{.*}}#[[NOINLINE_ATTR]]
 
+// Check `co_await AlwaysInlineStatefulAwaiter{};` to make sure user can force 
the await_suspend function to get inlined.
+// CHECK: call token @llvm.coro.save
+// CHECK: call void 
@_ZN27AlwaysInlineStatefulAwaiter13await_suspendIN4Task12promise_typeEEEvSt16coroutine_handleIT_E{{.*}}#[[NORMAL_ATTR]]
+
 // Check `co_await __promise__.final_suspend();`. We don't emit an blocker 
here since it is
 // empty.
 // CHECK: call token @llvm.coro.save



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


[PATCH] D133361: [BPF] Attribute btf_decl_tag("ctx") for structs

2023-08-27 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added inline comments.



Comment at: llvm/include/llvm/IR/Intrinsics.td:2432
   ImmArg>]>;
+def int_context_marker_bpf : DefaultAttrsIntrinsic<[llvm_ptr_ty],
+   [llvm_ptr_ty],

Is it possible to make this builtin as BPF specific one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133361

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


[PATCH] D158795: Fix AlignArrayOfStructures + Cpp11BracedListStyle=false

2023-08-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:20888
+   "  {  7, 5,\"!!\" }\n"
+   "};\n",
+   Style);

galenelias wrote:
> owenpan wrote:
> > galenelias wrote:
> > > owenpan wrote:
> > > > 
> > > This is consistent with basically every single adjacent test in this 
> > > function.  While I agree that this is unnecessary, in general I error on 
> > > the side of consistency with the surrounding tests.  I'll defer to the 
> > > maintainers, just wanted to make sure this is actually the preferred 
> > > change given the numerous adjacent tests with this form.
> > If you rebase your patch, you'll see that the trailing newlines in the 
> > surrounding tests have been removed. (Even if they had not been removed, we 
> > still wouldn't want new tests to have superfluous trailing newlines.)
> Thanks for the information, looks like I missed your cleanup change by a day. 
>  In general some code-bases favor consistency over some extra gunk, so I tend 
> to default to consistency, but good to know going forward.  I've rebased now.
Np!


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

https://reviews.llvm.org/D158795

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


[PATCH] D158920: Delete CloudABI support

2023-08-27 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

Looking for any feedback from the FreeBSD guys.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158920

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


[clang] 3823395 - [libclang] Modernize Location (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T16:13:55-07:00
New Revision: 3823395c9d715a1ed993eb13fc2bec97372f5655

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

LOG: [libclang] Modernize Location (NFC)

Added: 


Modified: 
clang/tools/libclang/CXLoadedDiagnostic.h

Removed: 




diff  --git a/clang/tools/libclang/CXLoadedDiagnostic.h 
b/clang/tools/libclang/CXLoadedDiagnostic.h
index 93995d7bb798c7..5ad9e1c32a92fa 100644
--- a/clang/tools/libclang/CXLoadedDiagnostic.h
+++ b/clang/tools/libclang/CXLoadedDiagnostic.h
@@ -71,11 +71,11 @@ class CXLoadedDiagnostic : public CXDiagnosticImpl {
 
   struct Location {
 CXFile file;
-unsigned line;
-unsigned column;
-unsigned offset;
+unsigned line = 0;
+unsigned column = 0;
+unsigned offset = 0;
 
-Location() : line(0), column(0), offset(0) {}
+Location() = default;
   };
   
   Location DiagLoc;



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


[clang] a8931a1 - [StaticAnalyzer] Modernize VforkChecker (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T16:13:53-07:00
New Revision: a8931a1ff76c74649dcdc8325e51a5cd0196839d

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

LOG: [StaticAnalyzer] Modernize VforkChecker (NFC)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
index 86a4e6fbcd6ac8..70e14b48a6efde 100644
--- a/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -46,7 +46,7 @@ class VforkChecker : public Checker> {
   mutable std::unique_ptr BT;
   mutable llvm::SmallSet VforkAllowlist;
-  mutable const IdentifierInfo *II_vfork;
+  mutable const IdentifierInfo *II_vfork = nullptr;
 
   static bool isChildProcess(const ProgramStateRef State);
 
@@ -58,7 +58,7 @@ class VforkChecker : public Checkerhttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8f1b718 - [StaticAnalyzer] Modernize ObjCSuperCallChecker (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T16:13:52-07:00
New Revision: 8f1b718bf9e5a8689250b07230d55cb4319806d6

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

LOG: [StaticAnalyzer] Modernize ObjCSuperCallChecker (NFC)

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
index fbbc32a40e8919..598b368e74d47a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCMissingSuperCallChecker.cpp
@@ -64,7 +64,7 @@ class FindSuperCallVisitor : public 
RecursiveASTVisitor {
 class ObjCSuperCallChecker : public Checker<
   check::ASTDecl > 
{
 public:
-  ObjCSuperCallChecker() : IsInitialized(false) {}
+  ObjCSuperCallChecker() = default;
 
   void checkASTDecl(const ObjCImplementationDecl *D, AnalysisManager ,
 BugReporter ) const;
@@ -75,7 +75,7 @@ class ObjCSuperCallChecker : public Checker<
   void fillSelectors(ASTContext , ArrayRef Sel,
  StringRef ClassName) const;
   mutable llvm::StringMap> SelectorsForClass;
-  mutable bool IsInitialized;
+  mutable bool IsInitialized = false;
 };
 
 }



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


[clang] e47189b - [CodeGen] Modernize BreakContinue (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T16:13:50-07:00
New Revision: e47189bfa9f2e08541c58d818a9da85d5c02f436

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

LOG: [CodeGen] Modernize BreakContinue (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenPGO.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenPGO.cpp 
b/clang/lib/CodeGen/CodeGenPGO.cpp
index b80317529b72b6..df6c76cde95f8d 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -376,9 +376,9 @@ struct ComputeRegionCounts : public 
ConstStmtVisitor {
 
   /// BreakContinueStack - Keep counts of breaks and continues inside loops.
   struct BreakContinue {
-uint64_t BreakCount;
-uint64_t ContinueCount;
-BreakContinue() : BreakCount(0), ContinueCount(0) {}
+uint64_t BreakCount = 0;
+uint64_t ContinueCount = 0;
+BreakContinue() = default;
   };
   SmallVector BreakContinueStack;
 



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


[clang] b32dfd9 - [ASTMatchers] Modernize TimeBucketRegion (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T16:13:48-07:00
New Revision: b32dfd98bfe78d06705f993d91a1110d2457c830

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

LOG: [ASTMatchers] Modernize TimeBucketRegion (NFC)

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index a27fac62bdef38..f9bd1354fa8dc4 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -979,7 +979,7 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
 
   class TimeBucketRegion {
   public:
-TimeBucketRegion() : Bucket(nullptr) {}
+TimeBucketRegion() = default;
 ~TimeBucketRegion() { setBucket(nullptr); }
 
 /// Start timing for \p NewBucket.
@@ -1002,7 +1002,7 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
 }
 
   private:
-llvm::TimeRecord *Bucket;
+llvm::TimeRecord *Bucket = nullptr;
   };
 
   /// Runs all the \p Matchers on \p Node.



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


[clang] ad183b9 - [Format] Modernize SpaceBeforeParensCustom (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T16:13:47-07:00
New Revision: ad183b927bfc9f0e558c00f1167add3e390b0c91

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

LOG: [Format] Modernize SpaceBeforeParensCustom (NFC)

Added: 


Modified: 
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index eb47715e71ca01..b641b313e32d98 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4021,35 +4021,35 @@ struct FormatStyle {
 ///true:  false:
 ///if (...) {} vs.if(...) {}
 /// \endcode
-bool AfterControlStatements;
+bool AfterControlStatements = false;
 /// If ``true``, put space between foreach macros and opening parentheses.
 /// \code
 ///true:  false:
 ///FOREACH (...)   vs.FOREACH(...)
 ///  
 /// \endcode
-bool AfterForeachMacros;
+bool AfterForeachMacros = false;
 /// If ``true``, put a space between function declaration name and opening
 /// parentheses.
 /// \code
 ///true:  false:
 ///void f ();  vs.void f();
 /// \endcode
-bool AfterFunctionDeclarationName;
+bool AfterFunctionDeclarationName = false;
 /// If ``true``, put a space between function definition name and opening
 /// parentheses.
 /// \code
 ///true:  false:
 ///void f () {}vs.void f() {}
 /// \endcode
-bool AfterFunctionDefinitionName;
+bool AfterFunctionDefinitionName = false;
 /// If ``true``, put space between if macros and opening parentheses.
 /// \code
 ///true:  false:
 ///IF (...)vs.IF(...)
 ///   
 /// \endcode
-bool AfterIfMacros;
+bool AfterIfMacros = false;
 /// If ``true``, put a space between operator overloading and opening
 /// parentheses.
 /// \code
@@ -4057,7 +4057,7 @@ struct FormatStyle {
 ///void operator++ (int a);vs.void operator++(int a);
 ///object.operator++ (10);object.operator++(10);
 /// \endcode
-bool AfterOverloadedOperator;
+bool AfterOverloadedOperator = false;
 /// If ``true``, put space between requires keyword in a requires clause 
and
 /// opening parentheses, if there is one.
 /// \code
@@ -4066,7 +4066,7 @@ struct FormatStyle {
 ///requires (A && B)requires(A && B)
 ///......
 /// \endcode
-bool AfterRequiresInClause;
+bool AfterRequiresInClause = false;
 /// If ``true``, put space between requires keyword in a requires 
expression
 /// and opening parentheses.
 /// \code
@@ -4076,7 +4076,7 @@ struct FormatStyle {
 ///  ......
 ///}  }
 /// \endcode
-bool AfterRequiresInExpression;
+bool AfterRequiresInExpression = false;
 /// If ``true``, put a space before opening parentheses only if the
 /// parentheses are not empty.
 /// \code
@@ -4084,14 +4084,9 @@ struct FormatStyle {
 ///void f (int a); vs.void f();
 ///f (a); f();
 /// \endcode
-bool BeforeNonEmptyParentheses;
+bool BeforeNonEmptyParentheses = false;
 
-SpaceBeforeParensCustom()
-: AfterControlStatements(false), AfterForeachMacros(false),
-  AfterFunctionDeclarationName(false),
-  AfterFunctionDefinitionName(false), AfterIfMacros(false),
-  AfterOverloadedOperator(false), AfterRequiresInClause(false),
-  AfterRequiresInExpression(false), BeforeNonEmptyParentheses(false) {}
+SpaceBeforeParensCustom() = default;
 
 bool operator==(const SpaceBeforeParensCustom ) const {
   return AfterControlStatements == Other.AfterControlStatements &&



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


[PATCH] D158920: Delete CloudABI support

2023-08-27 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 553815.
brad added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158920

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CloudABI.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Lex/InitHeaderSearch.cpp
  clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
  clang/test/Analysis/security-syntax-checks.m
  clang/test/Driver/cloudabi.c
  clang/test/Driver/cloudabi.cpp
  clang/test/Driver/frame-pointer-elim.c
  clang/test/Driver/fsanitize.c
  clang/test/Frontend/gnu-mcount.c
  clang/test/Preprocessor/init-arm.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/predefined-macros-no-warnings.c
  llvm/include/llvm/MC/MCELFObjectWriter.h
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/TargetParser/Triple.cpp
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
@@ -63,7 +63,6 @@
 "ToolChains/BareMetal.cpp",
 "ToolChains/CSKYToolChain.cpp",
 "ToolChains/Clang.cpp",
-"ToolChains/CloudABI.cpp",
 "ToolChains/CommonArgs.cpp",
 "ToolChains/CrossWindows.cpp",
 "ToolChains/Cuda.cpp",
Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -319,12 +319,6 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
-  T = Triple("x86_64-unknown-cloudabi");
-  EXPECT_EQ(Triple::x86_64, T.getArch());
-  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
-  EXPECT_EQ(Triple::CloudABI, T.getOS());
-  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
-
   T = Triple("x86_64-unknown-fuchsia");
   EXPECT_EQ(Triple::x86_64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -208,7 +208,6 @@
   case AMDHSA: return "amdhsa";
   case AMDPAL: return "amdpal";
   case CUDA: return "cuda";
-  case CloudABI: return "cloudabi";
   case Darwin: return "darwin";
   case DragonFly: return "dragonfly";
   case DriverKit: return "driverkit";
@@ -570,7 +569,6 @@
 
 static Triple::OSType parseOS(StringRef OSName) {
   return StringSwitch(OSName)
-.StartsWith("cloudabi", Triple::CloudABI)
 .StartsWith("darwin", Triple::Darwin)
 .StartsWith("dragonfly", Triple::DragonFly)
 .StartsWith("freebsd", Triple::FreeBSD)
Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -184,7 +184,6 @@
   enum OSType {
 UnknownOS,
 
-CloudABI,
 Darwin,
 DragonFly,
 FreeBSD,
Index: llvm/include/llvm/MC/MCELFObjectWriter.h
===
--- llvm/include/llvm/MC/MCELFObjectWriter.h
+++ llvm/include/llvm/MC/MCELFObjectWriter.h
@@ -71,8 +71,6 @@
 
   static uint8_t getOSABI(Triple::OSType OSType) {
 switch (OSType) {
-  case Triple::CloudABI:
-return ELF::ELFOSABI_CLOUDABI;
   case Triple::HermitCore:
 return ELF::ELFOSABI_STANDALONE;
   case Triple::PS4:
Index: clang/test/Preprocessor/predefined-macros-no-warnings.c
===
--- clang/test/Preprocessor/predefined-macros-no-warnings.c
+++ clang/test/Preprocessor/predefined-macros-no-warnings.c
@@ -10,7 +10,6 @@
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64_32-darwin
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64-darwin
-// RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64-cloudabi
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64-freebsd
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64-fuchsia
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64-linux
@@ -26,7 +25,6 @@
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple aarch64_be-netbsd
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple arm
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple 

[PATCH] D158946: Delete Ananas support

2023-08-27 Thread Brad Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a105105a621: Delete Ananas support (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158946

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/Ananas.h
  clang/test/Driver/ananas.c
  clang/test/Preprocessor/predefined-macros-no-warnings.c
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/TargetParser/Triple.cpp
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn
@@ -48,7 +48,6 @@
 "ToolChains/AMDGPU.cpp",
 "ToolChains/AMDGPUOpenMP.cpp",
 "ToolChains/AVR.cpp",
-"ToolChains/Ananas.cpp",
 "ToolChains/Arch/AArch64.cpp",
 "ToolChains/Arch/ARM.cpp",
 "ToolChains/Arch/CSKY.cpp",
Index: llvm/unittests/TargetParser/TripleTest.cpp
===
--- llvm/unittests/TargetParser/TripleTest.cpp
+++ llvm/unittests/TargetParser/TripleTest.cpp
@@ -319,12 +319,6 @@
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
   EXPECT_EQ(Triple::UnknownOS, T.getOS());
 
-  T = Triple("x86_64-unknown-ananas");
-  EXPECT_EQ(Triple::x86_64, T.getArch());
-  EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
-  EXPECT_EQ(Triple::Ananas, T.getOS());
-  EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
-
   T = Triple("x86_64-unknown-cloudabi");
   EXPECT_EQ(Triple::x86_64, T.getArch());
   EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -207,7 +207,6 @@
   case AIX: return "aix";
   case AMDHSA: return "amdhsa";
   case AMDPAL: return "amdpal";
-  case Ananas: return "ananas";
   case CUDA: return "cuda";
   case CloudABI: return "cloudabi";
   case Darwin: return "darwin";
@@ -571,7 +570,6 @@
 
 static Triple::OSType parseOS(StringRef OSName) {
   return StringSwitch(OSName)
-.StartsWith("ananas", Triple::Ananas)
 .StartsWith("cloudabi", Triple::CloudABI)
 .StartsWith("darwin", Triple::Darwin)
 .StartsWith("dragonfly", Triple::DragonFly)
Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -184,7 +184,6 @@
   enum OSType {
 UnknownOS,
 
-Ananas,
 CloudABI,
 Darwin,
 DragonFly,
Index: clang/test/Preprocessor/predefined-macros-no-warnings.c
===
--- clang/test/Preprocessor/predefined-macros-no-warnings.c
+++ clang/test/Preprocessor/predefined-macros-no-warnings.c
@@ -135,7 +135,6 @@
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple tcele
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686-darwin
-// RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686-ananas
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686-cloudabi
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686-linux
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686-linux-android
@@ -157,7 +156,6 @@
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple i686-hurd
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple x86_64
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple x86_64-darwin
-// RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple x86_64-ananas
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple x86_64-cloudabi
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple x86_64-linux
 // RUN: %clang_cc1 %s -Eonly -Wsystem-headers -Werror -triple x86_64-linux-android
Index: clang/test/Driver/ananas.c
===
--- clang/test/Driver/ananas.c
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: %clang --target=x86_64-unknown-ananas -static %s \
-// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-STATIC %s
-// CHECK-STATIC: ld{{.*}}" "-Bstatic"
-// CHECK-STATIC: crt0.o
-// CHECK-STATIC: crti.o
-// CHECK-STATIC: crtbegin.o
-// CHECK-STATIC: crtend.o
-// CHECK-STATIC: crtn.o
-
-// RUN: %clang --target=x86_64-unknown-ananas -shared %s \
-// 

[clang] 2a10510 - Delete Ananas support

2023-08-27 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-08-27T18:43:23-04:00
New Revision: 2a105105a621ffe75ddd09275309469c4cb548d4

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

LOG: Delete Ananas support

After looking at this further I think the Ananas support should be removed.

They stopped using Clang. There have never been any releases either; as in
source only, and the backend is not maintained.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/docs/tools/clang-formatted-files.txt
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/Driver.cpp
clang/test/Preprocessor/predefined-macros-no-warnings.c
llvm/include/llvm/TargetParser/Triple.h
llvm/lib/TargetParser/Triple.cpp
llvm/unittests/TargetParser/TripleTest.cpp
llvm/utils/gn/secondary/clang/lib/Driver/BUILD.gn

Removed: 
clang/lib/Driver/ToolChains/Ananas.cpp
clang/lib/Driver/ToolChains/Ananas.h
clang/test/Driver/ananas.c



diff  --git a/clang/docs/tools/clang-formatted-files.txt 
b/clang/docs/tools/clang-formatted-files.txt
index caab83f49bb812..994350c01f8925 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -397,7 +397,6 @@ clang/lib/Driver/ToolChains/AIX.cpp
 clang/lib/Driver/ToolChains/AIX.h
 clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
 clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
-clang/lib/Driver/ToolChains/Ananas.h
 clang/lib/Driver/ToolChains/AVR.cpp
 clang/lib/Driver/ToolChains/AVR.h
 clang/lib/Driver/ToolChains/CloudABI.cpp

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 86e8529c289147..d5d523de17ce49 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -541,8 +541,6 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple ,
   return std::make_unique(Triple, Opts);
 
 switch (os) {
-case llvm::Triple::Ananas:
-  return std::make_unique>(Triple, 
Opts);
 case llvm::Triple::CloudABI:
   return std::make_unique>(Triple,
 Opts);
@@ -605,8 +603,6 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple ,
   return std::make_unique(Triple, Opts);
 
 switch (os) {
-case llvm::Triple::Ananas:
-  return std::make_unique>(Triple, 
Opts);
 case llvm::Triple::CloudABI:
   return std::make_unique>(Triple,
 Opts);

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index d10740c8a92ec7..37e313b248dc13 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -50,20 +50,6 @@ class LLVM_LIBRARY_VISIBILITY CloudABITargetInfo : public 
OSTargetInfo {
   using OSTargetInfo::OSTargetInfo;
 };
 
-// Ananas target
-template 
-class LLVM_LIBRARY_VISIBILITY AnanasTargetInfo : public OSTargetInfo {
-protected:
-  void getOSDefines(const LangOptions , const llvm::Triple ,
-MacroBuilder ) const override {
-// Ananas defines
-Builder.defineMacro("__Ananas__");
-  }
-
-public:
-  using OSTargetInfo::OSTargetInfo;
-};
-
 void getDarwinDefines(MacroBuilder , const LangOptions ,
   const llvm::Triple , StringRef ,
   VersionTuple );

diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index c8778524a2b6ae..bdf24e771a5dd6 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -42,7 +42,6 @@ add_clang_library(clangDriver
   ToolChains/Arch/VE.cpp
   ToolChains/Arch/X86.cpp
   ToolChains/AIX.cpp
-  ToolChains/Ananas.cpp
   ToolChains/AMDGPU.cpp
   ToolChains/AMDGPUOpenMP.cpp
   ToolChains/AVR.cpp

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e02695e3f5572d..7b64ef4cc5db6e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -11,7 +11,6 @@
 #include "ToolChains/AMDGPU.h"
 #include "ToolChains/AMDGPUOpenMP.h"
 #include "ToolChains/AVR.h"
-#include "ToolChains/Ananas.h"
 #include "ToolChains/Arch/RISCV.h"
 #include "ToolChains/BareMetal.h"
 #include "ToolChains/CSKYToolChain.h"
@@ -6159,9 +6158,6 @@ const ToolChain ::getToolChain(const ArgList ,
 case llvm::Triple::Haiku:
   TC = std::make_unique(*this, Target, Args);
   break;
-case llvm::Triple::Ananas:
-  TC = std::make_unique(*this, Target, Args);
-  break;
 case llvm::Triple::CloudABI:
   TC = std::make_unique(*this, Target, Args);
   break;

diff  --git a/clang/lib/Driver/ToolChains/Ananas.cpp 
b/clang/lib/Driver/ToolChains/Ananas.cpp
deleted file mode 100644
index 

[PATCH] D158540: Improve error message for constexpr constructors of virtual base classes

2023-08-27 Thread Nouman Amir via Phabricator via cfe-commits
NoumanAmir657 added a comment.

@xgupta  It passed the test cases now


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

https://reviews.llvm.org/D158540

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


[PATCH] D158540: Improve error message for constexpr constructors of virtual base classes

2023-08-27 Thread Nouman Amir via Phabricator via cfe-commits
NoumanAmir657 updated this revision to Diff 553810.

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

https://reviews.llvm.org/D158540

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp
  clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
  clang/test/CXX/drs/dr13xx.cpp
  clang/test/CXX/drs/dr14xx.cpp
  clang/test/CXX/special/class.copy/p13-0x.cpp
  clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp

Index: clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
===
--- clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
+++ clang/test/SemaOpenCLCXX/addrspace-constructors.clcpp
@@ -54,5 +54,5 @@
 
 struct W {
   int w;
-  constexpr W() __constant = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
+  constexpr W() __constant = default; // expected-error {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}}
 };
Index: clang/test/CXX/special/class.copy/p13-0x.cpp
===
--- clang/test/CXX/special/class.copy/p13-0x.cpp
+++ clang/test/CXX/special/class.copy/p13-0x.cpp
@@ -125,7 +125,7 @@
 mutable A a;
   };
   struct C {
-constexpr C(const C &) = default; // expected-error {{not constexpr}}
+constexpr C(const C &) = default; // expected-error {{copy constructor cannot be 'constexpr' in a class or struct with virtual base classes}}
 A a;
   };
 }
Index: clang/test/CXX/drs/dr14xx.cpp
===
--- clang/test/CXX/drs/dr14xx.cpp
+++ clang/test/CXX/drs/dr14xx.cpp
@@ -129,19 +129,19 @@
 union A { constexpr A() = default; };
 union B { int n; constexpr B() = default; };
 #if __cplusplus <= 201703L
-// expected-error@-2 {{not constexpr}}
+// expected-error@-2 {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}}
 #endif
 union C { int n = 0; constexpr C() = default; };
 struct D { union {}; constexpr D() = default; }; // expected-error {{does not declare anything}}
 struct E { union { int n; }; constexpr E() = default; };
 #if __cplusplus <= 201703L
-// expected-error@-2 {{not constexpr}}
+// expected-error@-2 {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}}
 #endif
 struct F { union { int n = 0; }; constexpr F() = default; };
 
 struct G { union { int n = 0; }; union { int m; }; constexpr G() = default; };
 #if __cplusplus <= 201703L
-// expected-error@-2 {{not constexpr}}
+// expected-error@-2 {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}}
 #endif
 struct H {
   union {
Index: clang/test/CXX/drs/dr13xx.cpp
===
--- clang/test/CXX/drs/dr13xx.cpp
+++ clang/test/CXX/drs/dr13xx.cpp
@@ -328,10 +328,10 @@
 namespace dr1359 { // dr1359: 3.5
 #if __cplusplus >= 201103L
   union A { constexpr A() = default; };
-  union B { constexpr B() = default; int a; }; // expected-error {{not constexpr}} expected-note 2{{candidate}}
-  union C { constexpr C() = default; int a, b; }; // expected-error {{not constexpr}} expected-note 2{{candidate}}
+  union B { constexpr B() = default; int a; }; // expected-error {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}} expected-note 2{{candidate}}
+  union C { constexpr C() = default; int a, b; }; // expected-error {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}} expected-note 2{{candidate}}
   struct X { constexpr X() = default; union {}; }; // expected-error {{does not declare anything}}
-  struct Y { constexpr Y() = default; union { int a; }; }; // expected-error {{not constexpr}} expected-note 2{{candidate}}
+  struct Y { constexpr Y() = default; union { int a; }; }; // expected-error {{default constructor cannot be 'constexpr' in a class or struct with virtual base classes}} expected-note 2{{candidate}}
 
   constexpr A a = A();
   constexpr B b = B(); // expected-error {{no matching}}
Index: clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
===
--- clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
+++ clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp
@@ -3,7 +3,7 @@
 // An explicitly-defaulted function may be declared constexpr only if it would
 // have been implicitly declared as constexpr.
 struct S1 {
-  constexpr S1() = default; // expected-error {{defaulted definition of default constructor is not constexpr}}
+  constexpr S1() = default; // expected-error {{default constructor cannot be 'constexpr' in a class or struct with 

[PATCH] D158540: Improve error message for constexpr constructors of virtual base classes

2023-08-27 Thread Nouman Amir via Phabricator via cfe-commits
NoumanAmir657 added a comment.

I figured it out and changed the test files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158540

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


[PATCH] D158795: Fix AlignArrayOfStructures + Cpp11BracedListStyle=false

2023-08-27 Thread Galen Elias via Phabricator via cfe-commits
galenelias marked 4 inline comments as done.
galenelias added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:20888
+   "  {  7, 5,\"!!\" }\n"
+   "};\n",
+   Style);

owenpan wrote:
> galenelias wrote:
> > owenpan wrote:
> > > 
> > This is consistent with basically every single adjacent test in this 
> > function.  While I agree that this is unnecessary, in general I error on 
> > the side of consistency with the surrounding tests.  I'll defer to the 
> > maintainers, just wanted to make sure this is actually the preferred change 
> > given the numerous adjacent tests with this form.
> If you rebase your patch, you'll see that the trailing newlines in the 
> surrounding tests have been removed. (Even if they had not been removed, we 
> still wouldn't want new tests to have superfluous trailing newlines.)
Thanks for the information, looks like I missed your cleanup change by a day.  
In general some code-bases favor consistency over some extra gunk, so I tend to 
default to consistency, but good to know going forward.  I've rebased now.


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

https://reviews.llvm.org/D158795

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


[PATCH] D158795: Fix AlignArrayOfStructures + Cpp11BracedListStyle=false

2023-08-27 Thread Galen Elias via Phabricator via cfe-commits
galenelias updated this revision to Diff 553809.

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

https://reviews.llvm.org/D158795

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -20879,6 +20879,16 @@
"});",
Style);
 
+  Style.Cpp11BracedListStyle = false;
+  verifyFormat("struct test demo[] = {\n"
+   "  { 56,23, \"hello\" },\n"
+   "  { -1, 93463, \"world\" },\n"
+   "  {  7, 5,\"!!\" }\n"
+   "};",
+   Style);
+
+  Style.Cpp11BracedListStyle = true;
+
   Style.ColumnLimit = 0;
   EXPECT_EQ(
   "test demo[] = {\n"
@@ -2,6 +21121,15 @@
"});",
Style);
 
+  Style.Cpp11BracedListStyle = false;
+  verifyFormat("struct test demo[] = {\n"
+   "  { 56, 23,\"hello\" },\n"
+   "  { -1, 93463, \"world\" },\n"
+   "  { 7,  5, \"!!\"}\n"
+   "};",
+   Style);
+  Style.Cpp11BracedListStyle = true;
+
   Style.ColumnLimit = 0;
   EXPECT_EQ(
   "test demo[] = {\n"
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1226,6 +1226,7 @@
   if (!CellDescs.isRectangular())
 return;
 
+  const int BracePadding = Style.Cpp11BracedListStyle ? 0 : 1;
   auto  = CellDescs.Cells;
   // Now go through and fixup the spaces.
   auto *CellIter = Cells.begin();
@@ -1243,7 +1244,7 @@
   do {
 const FormatToken *Previous = Changes[Next->Index].Tok->Previous;
 if (Previous && Previous->isNot(TT_LineComment)) {
-  Changes[Next->Index].Spaces = 0;
+  Changes[Next->Index].Spaces = BracePadding;
   Changes[Next->Index].NewlinesBefore = 0;
 }
 Next = Next->NextColumnElement;
@@ -1276,7 +1277,7 @@
   NetWidth;
   if (Changes[CellIter->Index].NewlinesBefore == 0) {
 Changes[CellIter->Index].Spaces = (CellWidth - (ThisWidth + NetWidth));
-Changes[CellIter->Index].Spaces += (i > 0) ? 1 : 0;
+Changes[CellIter->Index].Spaces += (i > 0) ? 1 : BracePadding;
   }
   alignToStartOfCell(CellIter->Index, CellIter->EndIndex);
   for (const auto *Next = CellIter->NextColumnElement; Next;
@@ -1285,7 +1286,7 @@
 calculateCellWidth(Next->Index, Next->EndIndex, true) + NetWidth;
 if (Changes[Next->Index].NewlinesBefore == 0) {
   Changes[Next->Index].Spaces = (CellWidth - ThisWidth);
-  Changes[Next->Index].Spaces += (i > 0) ? 1 : 0;
+  Changes[Next->Index].Spaces += (i > 0) ? 1 : BracePadding;
 }
 alignToStartOfCell(Next->Index, Next->EndIndex);
   }
@@ -1299,12 +1300,13 @@
   if (!CellDescs.isRectangular())
 return;
 
+  const int BracePadding = Style.Cpp11BracedListStyle ? 0 : 1;
   auto  = CellDescs.Cells;
   // Now go through and fixup the spaces.
   auto *CellIter = Cells.begin();
   // The first cell needs to be against the left brace.
   if (Changes[CellIter->Index].NewlinesBefore == 0)
-Changes[CellIter->Index].Spaces = 0;
+Changes[CellIter->Index].Spaces = BracePadding;
   else
 Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces;
   ++CellIter;
@@ -1317,7 +1319,8 @@
 if (Changes[CellIter->Index].NewlinesBefore == 0) {
   Changes[CellIter->Index].Spaces =
   MaxNetWidth - ThisNetWidth +
-  (Changes[CellIter->Index].Tok->isNot(tok::r_brace) ? 1 : 0);
+  (Changes[CellIter->Index].Tok->isNot(tok::r_brace) ? 1
+ : BracePadding);
 }
 auto RowCount = 1U;
 auto Offset = std::distance(Cells.begin(), CellIter);
@@ -1331,7 +1334,7 @@
   if (Changes[Next->Index].NewlinesBefore == 0) {
 Changes[Next->Index].Spaces =
 MaxNetWidth - ThisNetWidth +
-(Changes[Next->Index].Tok->isNot(tok::r_brace) ? 1 : 0);
+(Changes[Next->Index].Tok->isNot(tok::r_brace) ? 1 : BracePadding);
   }
   ++RowCount;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158959: [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158959

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


[PATCH] D158959: [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Rainer Orth 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 rG03dff0d4acaf: [clang-tidy] Disambiguate calls to log 
(authored by ro).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158959

Files:
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
   break;
 case (BO_MulAssign):
-  Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+   log((double)ConstantValue);
   break;
 case (BO_DivAssign):
-  Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+   log((double)ConstantValue);
   break;
 default:
   // All other operators are not handled; assume large bounds.


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
   break;
 case (BO_MulAssign):
-  Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+   log((double)ConstantValue);
   break;
 case (BO_DivAssign):
-  Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+   log((double)ConstantValue);
   break;
 default:
   // All other operators are not handled; assume large bounds.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 03dff0d - [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2023-08-27T21:15:43+02:00
New Revision: 03dff0d4acafb61bbb3b765507de79c5e5b6681a

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

LOG: [clang-tidy] Disambiguate calls to log

c8644b18f570be9d26d83cdeeb2369cd3cbddaf1 

broke the Solaris/amd64 

and Solaris/sparcv9  
buildbots:

  FAILED: 
tools/clang/tools/extra/clang-tidy/altera/CMakeFiles/obj.clangTidyAlteraModule.dir/UnrollLoopsCheck.cpp.o
  [...]
  
/vol/llvm/src/llvm-project/dist/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:217:25:
 error: call to 'log' is ambiguous
217 |   Iterations = 1 + (log(EndValue) - log(InitValue)) / 
log(ConstantValue);
| ^~~
  /usr/include/iso/math_iso.h:60:15: note: candidate function
 60 | extern double log __P((double));
|   ^
  /usr/include/iso/math_iso.h:158:15: note: candidate function
158 | inline float log(float __X) { return __logf(__X); }
|  ^
  /usr/include/iso/math_iso.h:193:21: note: candidate function
193 | inline long double log(long double __X) { return __logl(__X); 
}
|^

Fixed by disambituating the calls with `double` casts.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 37eacf565f199d..532a43bad74127 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt 
*Statement,
   Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
   break;
 case (BO_MulAssign):
-  Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+   log((double)ConstantValue);
   break;
 case (BO_DivAssign):
-  Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+   log((double)ConstantValue);
   break;
 default:
   // All other operators are not handled; assume large bounds.



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


[clang] 24fcc0a - [clang] Remove redundant control flow statements (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T12:13:25-07:00
New Revision: 24fcc0a7c56f01246f89aa5a5cd7af568eab8152

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

LOG: [clang] Remove redundant control flow statements (NFC)

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Sema/SemaInit.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index e37d86cb6ba4ee..ae108a702c86aa 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -343,7 +343,6 @@ computeBlockInputState(const CFGBlock , 
AnalysisContext ) {
   }
 }
 Builder.addUnowned(*MaybePredState);
-continue;
   }
   return std::move(Builder).take();
 }

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 253ef8b75163ec..ac04b838602345 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -6385,7 +6385,6 @@ static void getNumThreads(CodeGenFunction , const 
CapturedStmt *CS,
   }
   if (isOpenMPSimdDirective(Dir->getDirectiveKind()))
 UpperBound = 1;
-  return;
 }
 
 const Expr *CGOpenMPRuntime::getNumThreadsExprForTargetDirective(
@@ -10015,8 +10014,6 @@ void 
CGOpenMPRuntime::registerTargetGlobalVariable(const VarDecl *VD,
 
   for (auto *ref : GeneratedRefs)
 CGM.addCompilerUsedGlobal(ref);
-
-  return;
 }
 
 bool CGOpenMPRuntime::emitTargetGlobal(GlobalDecl GD) {

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index d915d06ab2f1b8..93f05e2e47285e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5672,8 +5672,6 @@ static void TryOrBuildParenListInitialization(
diag::warn_cxx17_compat_aggregate_init_paren_list)
 << Kind.getLocation() << SR << ResultType;
   }
-
-  return;
 }
 
 /// Attempt a user-defined conversion between two types (C++ [dcl.init]),



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


[PATCH] D158959: [clang-tidy] Disambiguate calls to log

2023-08-27 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: PiotrZSL.
Herald added subscribers: carlosgalvezp, pengfei, zzheng, fedor.sergeev, 
xazax.hun, jyknight.
Herald added a reviewer: njames93.
Herald added a project: All.
ro requested review of this revision.
Herald added a project: clang-tools-extra.

c8644b18f570be9d26d83cdeeb2369cd3cbddaf1 
 broke the 
Solaris/amd64  and 
Solaris/sparcv9  
buildbots:

  FAILED: 
tools/clang/tools/extra/clang-tidy/altera/CMakeFiles/obj.clangTidyAlteraModule.dir/UnrollLoopsCheck.cpp.o
  [...]
  
/vol/llvm/src/llvm-project/dist/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp:217:25:
 error: call to 'log' is ambiguous 
217 |   Iterations = 1 + (log(EndValue) - log(InitValue)) / 
log(ConstantValue);
| ^~~
  /usr/include/iso/math_iso.h:60:15: note: candidate function
 60 | extern double log __P((double));
|   ^
  /usr/include/iso/math_iso.h:158:15: note: candidate function
158 | inline float log(float __X) { return __logf(__X); }
|  ^
  /usr/include/iso/math_iso.h:193:21: note: candidate function
193 | inline long double log(long double __X) { return __logl(__X); 
}
|^

Fixed by disambituating the calls with `double` casts.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.

Will commit shortly to unbreak the bots.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158959

Files:
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
   break;
 case (BO_MulAssign):
-  Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+   log((double)ConstantValue);
   break;
 case (BO_DivAssign):
-  Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+   log((double)ConstantValue);
   break;
 default:
   // All other operators are not handled; assume large bounds.


Index: clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
===
--- clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -214,10 +214,12 @@
   Iterations = ceil(float(InitValue - EndValue) / ConstantValue);
   break;
 case (BO_MulAssign):
-  Iterations = 1 + (log(EndValue) - log(InitValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)EndValue) - log((double)InitValue)) /
+   log((double)ConstantValue);
   break;
 case (BO_DivAssign):
-  Iterations = 1 + (log(InitValue) - log(EndValue)) / log(ConstantValue);
+  Iterations = 1 + (log((double)InitValue) - log((double)EndValue)) /
+   log((double)ConstantValue);
   break;
 default:
   // All other operators are not handled; assume large bounds.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158540: Improve error message for constexpr constructors of virtual base classes

2023-08-27 Thread Nouman Amir via Phabricator via cfe-commits
NoumanAmir657 added a comment.

How am I supposed to update tests? I am new to this. I get the files on which 
the tests fail but how do I update them


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158540

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


[PATCH] D158955: [Driver] Improve legibility of ld -z options on Solaris

2023-08-27 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: MaskRay.
ro added a project: clang.
Herald added subscribers: pengfei, fedor.sergeev, emaste.
Herald added a project: All.
ro requested review of this revision.

Following the lead of the Linux code, this patch passes the `ld -z` options as 
two separate args on Solaris, improving legibility.  For lack of a variadic 
`std::push_back`, `getAsNeededOption` had to be changed to `addAsNeededOption`, 
matching other `add*Options` functions, changing callers accordingly.  The 
additional args are also used in a WIP revision of the Solaris GNU ld patch 
D85309 , which will allow runtime selection of 
the linker to use.

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158955

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld-sanitizer.c
  clang/test/Driver/solaris-ld.c

Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -16,7 +16,7 @@
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
-// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
+// CHECK-LD-SPARC32-SAME: "-z" "ignore" "-latomic" "-z" "record"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
Index: clang/test/Driver/solaris-ld-sanitizer.c
===
--- clang/test/Driver/solaris-ld-sanitizer.c
+++ clang/test/Driver/solaris-ld-sanitizer.c
@@ -6,49 +6,49 @@
 // RUN: %clang --target=sparc-sun-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
-// CHECK-LD-SPARC32-NOT: -zrelax=transtls
+// CHECK-LD-SPARC32-NOT: "-z" "relax=transtls"
 
 /// Check sparc-sun-solaris2.11, 32bit
 // RUN: %clang -fsanitize=undefined --target=sparc-sun-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC32 %s
-// CHECK-LD-SPARC32-NOT: -zrelax=transtls
+// CHECK-LD-SPARC32-NOT: "-z" "relax=transtls"
 
 /// Check sparc-sun-solaris2.11, 64bit
 // RUN: %clang -m64 --target=sparc-sun-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
-// CHECK-LD-SPARC64-NOT: -zrelax=transtls
+// CHECK-LD-SPARC64-NOT: "-z" "relax=transtls"
 
 /// Check sparc-sun-solaris2.11, 64bit
 // RUN: %clang -m64 -fsanitize=undefined --target=sparc-sun-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-SPARC64 %s
-// CHECK-LD-SPARC64-NOT: -zrelax=transtls
+// CHECK-LD-SPARC64-NOT: "-z" "relax=transtls"
 
 /// Check i386-pc-solaris2.11, 32bit
 // RUN: %clang --target=i386-pc-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
-// CHECK-LD-X32-NOT: -zrelax=transtls
+// CHECK-LD-X32-NOT: "-z" "relax=transtls"
 
 /// Check i386-pc-solaris2.11, 32bit
 // RUN: %clang -fsanitize=undefined --target=i386-pc-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X32 %s
-// CHECK-LD-X32-NOT: -zrelax=transtls
+// CHECK-LD-X32-NOT: "-z" "relax=transtls"
 
 /// Check i386-pc-solaris2.11, 64bit
 // RUN: %clang -m64 --target=i386-pc-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64 %s
-// CHECK-LD-X64-NOT: -zrelax=transtls
+// CHECK-LD-X64-NOT: "-z" "relax=transtls"
 
 /// Check i386-pc-solaris2.11, 64bit
 // RUN: %clang -m64 -fsanitize=undefined --target=i386-pc-solaris2.11 %s -### 2>&1 \
 // RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_x86_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LD-X64-UBSAN %s
-// CHECK-LD-X64-UBSAN: -zrelax=transtls
+// CHECK-LD-X64-UBSAN: "-z" "relax=transtls"
 
 /// General tests that the ld -z now workaround is only applied on
 /// Solaris/i386 with shared libclang_rt.asan.. Note that we use sysroot to
@@ -58,10 +58,10 @@
 // RUN: %clang -fsanitize=address -shared-libasan 

[PATCH] D158953: [analyzer] MmapWriteExecChecker: use getAs instead of castAs

2023-08-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

Land it, whenever you wish. Thanks!
PS: usually we don't have a comment like that. The name of the function should 
give enough context, along with a // no-crash comment at the line where it was 
triggered in the past.
That usually just helps reviewers to understand the issue, but as I triaged 
this I'm aware what's going on.
In tricky situations.
I just let you know about these conventions, no need to adjust this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158953

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


[PATCH] D155769: [HIP][Clang][docs][RFC] Add documentation for C++ Parallel Algorithm Offload

2023-08-27 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 553800.
AlexVlx added a comment.

Add back clarification about RDC.


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

https://reviews.llvm.org/D155769

Files:
  clang/docs/HIPSupport.rst
  clang/docs/ReleaseNotes.rst

Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -279,6 +279,11 @@
 CUDA/HIP Language Changes
 ^
 
+- [HIP Only] add experimental support for offloading select C++ Algorithms,
+  which can be toggled via the ``-hipstdpar`` flag. This is available only for
+  the AMDGPU target at the moment. See the dedicated entry in the `HIP Language
+  support document for details `_
+
 CUDA Support
 
 
Index: clang/docs/HIPSupport.rst
===
--- clang/docs/HIPSupport.rst
+++ clang/docs/HIPSupport.rst
@@ -176,3 +176,391 @@
* - ``HIP_API_PER_THREAD_DEFAULT_STREAM``
  - Alias to ``__HIP_API_PER_THREAD_DEFAULT_STREAM__``. Deprecated.
 
+C++ Standard Parallelism Offload Support: Compiler And Runtime
+==
+
+Introduction
+
+
+This document describes the implementation of support for offloading the
+execution of standard C++ algorithms to accelerators that can be targeted via
+HIP. Furthermore, it enumerates restrictions on user defined code, as well as
+the interactions with runtimes.
+
+Algorithm Offload: What, Why, Where
+===
+
+C++17 introduced overloads
+`for most algorithms in the standard library `_
+which allow the user to specify a desired
+`execution policy `_.
+The `parallel_unsequenced_policy `_
+maps relatively well to the execution model of many accelerators, such as GPUs.
+This, coupled with the ubiquity of GPU accelerated algorithm libraries that
+implement most / all corresponding libraries in the standard library
+(e.g. `rocThrust `_), makes
+it feasible to provide seamless accelerator offload for supported algorithms,
+when an accelerated version exists. Thus, it becomes possible to easily access
+the computational resources of an accelerator, via a well specified, familiar,
+algorithmic interface, without having to delve into low-level hardware specific
+details. Putting it all together:
+
+- **What**: standard library algorithms, when invoked with the
+  ``parallel_unsequenced_policy``
+- **Why**: democratise accelerator programming, without loss of user familiarity
+- **Where**: any and all accelerators that can be targeted by Clang/LLVM via HIP
+
+Small Example
+=
+
+Given the following C++ code, which assumes the ``std`` namespace is included:
+
+.. code-block:: C++
+
+   bool has_the_answer(const vector& v) {
+ return find(execution::par_unseq, cbegin(v), cend(v), 42) != cend(v);
+   }
+
+if Clang is invoked with the ``-hipstdpar --offload-arch=foo`` flags, the call
+to ``find`` will be offloaded to an accelerator that is part of the ``foo``
+target family. If either ``foo`` or its runtime environment do not support
+transparent on-demand paging (such as e.g. that provided in Linux via
+`HMM `_), it is necessary to also include
+the ``--hipstdpar-interpose-alloc`` flag. If the accelerator specific algorithm
+library ``foo`` uses doesn't have an implementation of a particular algorithm,
+execution seamlessly falls back to the host CPU. It is legal to specify multiple
+``--offload-arch``s. All the flags we introduce, as well as a thorough view of
+various restrictions and their implications will be provided below.
+
+Implementation - General View
+=
+
+We built support for Algorithm Offload support atop the pre-existing HIP
+infrastructure. More specifically, when one requests offload via ``-hipstdpar``,
+compilation is switched to HIP compilation, as if ``-x hip`` was specified.
+Similarly, linking is also switched to HIP linking, as if ``--hip-link`` was
+specified. Note that these are implicit, and one should not assume that any
+interop with HIP specific language constructs is available e.g. ``__device__``
+annotations are neither necessary nor guaranteed to work.
+
+Since there are no language restriction mechanisms in place, it is necessary to
+relax HIP language specific semantic checks performed by the FE; they would
+identify otherwise valid, offloadable code, as invalid HIP code. Given that we
+know that the user intended only for certain algorithms to be offloaded, and
+encoded this by specifying the 

[PATCH] D155769: [HIP][Clang][docs][RFC] Add documentation for C++ Parallel Algorithm Offload

2023-08-27 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 553799.
AlexVlx edited reviewers, added: jhuber6; removed: tra, jdoerfert.
AlexVlx added a comment.
Herald added a reviewer: jdoerfert.

Fix typo, add release notes reflecting the HIP-only nature.


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

https://reviews.llvm.org/D155769

Files:
  clang/docs/HIPSupport.rst
  clang/docs/ReleaseNotes.rst

Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -279,6 +279,11 @@
 CUDA/HIP Language Changes
 ^
 
+- [HIP Only] add experimental support for offloading select C++ Algorithms,
+  which can be toggled via the ``-hipstdpar`` flag. This is available only for
+  the AMDGPU target at the moment. See the dedicated entry in the `HIP Language
+  support document for details `_
+
 CUDA Support
 
 
Index: clang/docs/HIPSupport.rst
===
--- clang/docs/HIPSupport.rst
+++ clang/docs/HIPSupport.rst
@@ -176,3 +176,387 @@
* - ``HIP_API_PER_THREAD_DEFAULT_STREAM``
  - Alias to ``__HIP_API_PER_THREAD_DEFAULT_STREAM__``. Deprecated.
 
+C++ Standard Parallelism Offload Support: Compiler And Runtime
+==
+
+Introduction
+
+
+This document describes the implementation of support for offloading the
+execution of standard C++ algorithms to accelerators that can be targeted via
+HIP. Furthermore, it enumerates restrictions on user defined code, as well as
+the interactions with runtimes.
+
+Algorithm Offload: What, Why, Where
+===
+
+C++17 introduced overloads
+`for most algorithms in the standard library `_
+which allow the user to specify a desired
+`execution policy `_.
+The `parallel_unsequenced_policy `_
+maps relatively well to the execution model of many accelerators, such as GPUs.
+This, coupled with the ubiquity of GPU accelerated algorithm libraries that
+implement most / all corresponding libraries in the standard library
+(e.g. `rocThrust `_), makes
+it feasible to provide seamless accelerator offload for supported algorithms,
+when an accelerated version exists. Thus, it becomes possible to easily access
+the computational resources of an accelerator, via a well specified, familiar,
+algorithmic interface, without having to delve into low-level hardware specific
+details. Putting it all together:
+
+- **What**: standard library algorithms, when invoked with the
+  ``parallel_unsequenced_policy``
+- **Why**: democratise accelerator programming, without loss of user familiarity
+- **Where**: any and all accelerators that can be targeted by Clang/LLVM via HIP
+
+Small Example
+=
+
+Given the following C++ code, which assumes the ``std`` namespace is included:
+
+.. code-block:: C++
+
+   bool has_the_answer(const vector& v) {
+ return find(execution::par_unseq, cbegin(v), cend(v), 42) != cend(v);
+   }
+
+if Clang is invoked with the ``-hipstdpar --offload-arch=foo`` flags, the call
+to ``find`` will be offloaded to an accelerator that is part of the ``foo``
+target family. If either ``foo`` or its runtime environment do not support
+transparent on-demand paging (such as e.g. that provided in Linux via
+`HMM `_), it is necessary to also include
+the ``--hipstdpar-interpose-alloc`` flag. If the accelerator specific algorithm
+library ``foo`` uses doesn't have an implementation of a particular algorithm,
+execution seamlessly falls back to the host CPU. It is legal to specify multiple
+``--offload-arch``s. All the flags we introduce, as well as a thorough view of
+various restrictions and their implications will be provided below.
+
+Implementation - General View
+=
+
+We built support for Algorithm Offload support atop the pre-existing HIP
+infrastructure. More specifically, when one requests offload via ``-hipstdpar``,
+compilation is switched to HIP compilation, as if ``-x hip`` was specified.
+Similarly, linking is also switched to HIP linking, as if ``--hip-link`` was
+specified. Note that these are implicit, and one should not assume that any
+interop with HIP specific language constructs is available e.g. ``__device__``
+annotations are neither necessary nor guaranteed to work.
+
+Since there are no language restriction mechanisms in place, it is necessary to
+relax HIP language specific semantic checks performed by the FE; they would
+identify otherwise valid, offloadable code, as invalid HIP code. Given that we
+know 

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

2023-08-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

Sorry that it took so long, I had to debug it and think a bit. This should do 
it:

  diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
  index 9d28325c1ea6..13e37ac2b56b 100644
  --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
  +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
  @@ -361,7 +361,7 @@ public:
   unsigned NumArgs = 0;
   
   // Function arguments
  -const Expr *const *FunArgs = nullptr;
  +llvm::PointerUnion FunArgs = nullptr;
   
   // is Self referred to with -> or .?
   bool SelfArrow = false;
  diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp 
b/clang/lib/Analysis/ThreadSafetyCommon.cpp
  index b8286cef396c..1eb48c0d5554 100644
  --- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
  +++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
  @@ -110,7 +110,8 @@ static StringRef ClassifyDiagnostic(QualType VDT) {
   /// \param D   The declaration to which the attribute is attached.
   /// \param DeclExp An expression involving the Decl to which the attribute
   ///is attached.  E.g. the call to a function.
  -/// \param SelfS-expression to substitute for a \ref CXXThisExpr.
  +/// \param SelfS-expression to substitute for a \ref CXXThisExpr in a 
call,
  +///or argument to a cleanup function.
   CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
  const NamedDecl *D,
  const Expr *DeclExp,
  @@ -144,7 +145,11 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const 
Expr *AttrExp,
   
 if (Self) {
   assert(!Ctx.SelfArg && "Ambiguous self argument");
  -Ctx.SelfArg = Self;
  +assert(isa(D) && "Self argument requires function");
  +if (isa(D))
  +  Ctx.SelfArg = Self;
  +else
  +  Ctx.FunArgs = Self;
   
   // If the attribute has no arguments, then assume the argument is "this".
   if (!AttrExp)
  @@ -312,8 +317,14 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const 
DeclRefExpr *DRE,
 ? (cast(D)->getCanonicalDecl() == Canonical)
 : (cast(D)->getCanonicalDecl() == Canonical)) {
   // Substitute call arguments for references to function parameters
  -assert(I < Ctx->NumArgs);
  -return translate(Ctx->FunArgs[I], Ctx->Prev);
  +if (const Expr *const *FunArgs =
  +Ctx->FunArgs.dyn_cast()) {
  +  assert(I < Ctx->NumArgs);
  +  return translate(FunArgs[I], Ctx->Prev);
  +} else {
  +  assert(I == 0);
  +  return Ctx->FunArgs.get();
  +}
 }
   }
   // Map the param back to the param of the original function declaration

The idea (which might be expressed in additional comments) is that until now we 
only had `Self` for `CXXMethodDecl`, but now we also have it for other 
`FunctionDecl`, in which case it is to be understood as the sole function 
argument.




Comment at: clang/lib/Analysis/ThreadSafety.cpp:1776
 /// \param D The callee declaration.
 /// \param Self  If \p Exp = nullptr, the implicit this argument.
 /// \param Loc   If \p Exp = nullptr, the location.

We should relax this like "the implicit this argument or the argument to an 
implicitly called cleanup function".



Comment at: clang/lib/Analysis/ThreadSafety.cpp:2436
+CF.getVarDecl()->getLocation());
+  break;
+}

tbaeder wrote:
> tbaeder wrote:
> > tbaeder wrote:
> > > aaronpuchert wrote:
> > > > aaronpuchert wrote:
> > > > > tbaeder wrote:
> > > > > > This handles the function call, but without the instance parameter. 
> > > > > > I was wondering how to best do that.
> > > > > Should you not simply pass 
> > > > > `SxBuilder.createVariable(CF.getVarDecl())` as third parameter in 
> > > > > analogy with the `AutomaticObjectDtor` case? It might also make sense 
> > > > > to copy the attribute check.
> > > > Can you write a test case that relies on passing the variable? Here is 
> > > > an idea:
> > > > ```
> > > > void unlock_scope(Mutex **mu) __attribute__((release_capability(*mu))) {
> > > >   mutex_exclusive_unlock(*mu);
> > > > }
> > > > 
> > > > Mutex* const CLEANUP(unlock_scope) scope = 
> > > > mutex_exclusive_lock(*scope);
> > > > // Unlock should happen automatically.
> > > > ```
> > > > I think this is mildly more interesting than the cleanup function with 
> > > > an unused parameter.
> > > > 
> > > > Unfortunately this is not quite as powerful as a scoped lock in C++, as 
> > > > we don't track the identity `scope == `. So `guarded_by` won't work 
> > > > with this. But we can at least see warnings on balanced 
> > > > locking/unlocking.
> > > > 
> > > > As for proper scoped locking, we could treat 

[PATCH] D158953: [analyzer] MmapWriteExecChecker: use getAs instead of castAs

2023-08-27 Thread Ding Fei via Phabricator via cfe-commits
danix800 updated this revision to Diff 553798.
danix800 added a comment.

Simplify testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158953

Files:
  clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  clang/test/Analysis/mmap-writeexec.c


Index: clang/test/Analysis/mmap-writeexec.c
===
--- clang/test/Analysis/mmap-writeexec.c
+++ clang/test/Analysis/mmap-writeexec.c
@@ -42,3 +42,9 @@
   int m = mprotect(p, 1024, PROT_WRITE | PROT_EXEC); // expected-warning{{Both 
PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory 
regions, which could be overwritten with malicious code}}
   (void)m;
 }
+
+// gh62285: no crash on non concrete arg 'prot'
+void *gh62285(void *addr, int prot)
+{
+  return mmap(addr, 1, prot, 1, 1, 1);
+}
Index: clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -48,8 +48,10 @@
  CheckerContext ) const {
   if (matchesAny(Call, MmapFn, MprotectFn)) {
 SVal ProtVal = Call.getArgSVal(2);
-auto ProtLoc = ProtVal.castAs();
-int64_t Prot = ProtLoc.getValue().getSExtValue();
+auto ProtLoc = ProtVal.getAs();
+if (!ProtLoc)
+  return;
+int64_t Prot = ProtLoc->getValue().getSExtValue();
 if (ProtExecOv != ProtExec)
   ProtExec = ProtExecOv;
 if (ProtReadOv != ProtRead)


Index: clang/test/Analysis/mmap-writeexec.c
===
--- clang/test/Analysis/mmap-writeexec.c
+++ clang/test/Analysis/mmap-writeexec.c
@@ -42,3 +42,9 @@
   int m = mprotect(p, 1024, PROT_WRITE | PROT_EXEC); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
   (void)m;
 }
+
+// gh62285: no crash on non concrete arg 'prot'
+void *gh62285(void *addr, int prot)
+{
+  return mmap(addr, 1, prot, 1, 1, 1);
+}
Index: clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -48,8 +48,10 @@
  CheckerContext ) const {
   if (matchesAny(Call, MmapFn, MprotectFn)) {
 SVal ProtVal = Call.getArgSVal(2);
-auto ProtLoc = ProtVal.castAs();
-int64_t Prot = ProtLoc.getValue().getSExtValue();
+auto ProtLoc = ProtVal.getAs();
+if (!ProtLoc)
+  return;
+int64_t Prot = ProtLoc->getValue().getSExtValue();
 if (ProtExecOv != ProtExec)
   ProtExec = ProtExecOv;
 if (ProtReadOv != ProtRead)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e7ee15e - [AST] Modernize MicrosoftNumberingContext (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T09:24:26-07:00
New Revision: e7ee15eebe3758c488716407fe93e3ec0446478f

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

LOG: [AST] Modernize MicrosoftNumberingContext (NFC)

Added: 


Modified: 
clang/lib/AST/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/lib/AST/MicrosoftCXXABI.cpp 
b/clang/lib/AST/MicrosoftCXXABI.cpp
index 263e263eba7c60..1c020c3ad4ad55 100644
--- a/clang/lib/AST/MicrosoftCXXABI.cpp
+++ b/clang/lib/AST/MicrosoftCXXABI.cpp
@@ -30,14 +30,12 @@ namespace {
 /// Typically these are things like static locals, lambdas, or blocks.
 class MicrosoftNumberingContext : public MangleNumberingContext {
   llvm::DenseMap ManglingNumbers;
-  unsigned LambdaManglingNumber;
-  unsigned StaticLocalNumber;
-  unsigned StaticThreadlocalNumber;
+  unsigned LambdaManglingNumber = 0;
+  unsigned StaticLocalNumber = 0;
+  unsigned StaticThreadlocalNumber = 0;
 
 public:
-  MicrosoftNumberingContext()
-  : LambdaManglingNumber(0), StaticLocalNumber(0),
-StaticThreadlocalNumber(0) {}
+  MicrosoftNumberingContext() = default;
 
   unsigned getManglingNumber(const CXXMethodDecl *CallOperator) override {
 return ++LambdaManglingNumber;



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


[clang] f6f6f19 - [CodeGen] Modernize InstrProfStats (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T09:24:29-07:00
New Revision: f6f6f1947da3fd088bd6f8b8d43a31d18ccd750f

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

LOG: [CodeGen] Modernize InstrProfStats (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index c22dd8486270a0..ce14a6cc55f6af 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -214,16 +214,14 @@ struct ObjCEntrypoints {
 
 /// This class records statistics on instrumentation based profiling.
 class InstrProfStats {
-  uint32_t VisitedInMainFile;
-  uint32_t MissingInMainFile;
-  uint32_t Visited;
-  uint32_t Missing;
-  uint32_t Mismatched;
+  uint32_t VisitedInMainFile = 0;
+  uint32_t MissingInMainFile = 0;
+  uint32_t Visited = 0;
+  uint32_t Missing = 0;
+  uint32_t Mismatched = 0;
 
 public:
-  InstrProfStats()
-  : VisitedInMainFile(0), MissingInMainFile(0), Visited(0), Missing(0),
-Mismatched(0) {}
+  InstrProfStats() = default;
   /// Record that we've visited a function and whether or not that function was
   /// in the main source file.
   void addVisited(bool MainFile) {



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


[clang] 5ab7c28 - [CodeGen] Modernize PeepholeProtection (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T09:24:28-07:00
New Revision: 5ab7c285fb7c7d80cc80fbef0d50125679ab8385

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

LOG: [CodeGen] Modernize PeepholeProtection (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 0741e3c40fcce6..215166f566ea65 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -1255,11 +1255,11 @@ class CodeGenFunction : public CodeGenTypeCache {
   /// destroyed by aggressive peephole optimizations that assume that
   /// all uses of a value have been realized in the IR.
   class PeepholeProtection {
-llvm::Instruction *Inst;
+llvm::Instruction *Inst = nullptr;
 friend class CodeGenFunction;
 
   public:
-PeepholeProtection() : Inst(nullptr) {}
+PeepholeProtection() = default;
   };
 
   /// A non-RAII class containing all the information about a bound



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


[clang] 7866c01 - [AST] Modernize EvalResult (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T09:24:24-07:00
New Revision: 7866c011f806928147fa084a073b0ded88144678

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

LOG: [AST] Modernize EvalResult (NFC)

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c6ab3758e99c1b..130cf23737f104 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12665,9 +12665,9 @@ namespace {
 class DataRecursiveIntBinOpEvaluator {
   struct EvalResult {
 APValue Val;
-bool Failed;
+bool Failed = false;
 
-EvalResult() : Failed(false) { }
+EvalResult() = default;
 
 void swap(EvalResult ) {
   Val.swap(RHS.Val);



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


[clang] e7eadbd - [ARCMigrate] Modernize PoolVarInfo (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T09:24:23-07:00
New Revision: e7eadbd04d32ce5699b1e32114929a68529b56be

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

LOG: [ARCMigrate] Modernize PoolVarInfo (NFC)

Added: 


Modified: 
clang/lib/ARCMigrate/TransAutoreleasePool.cpp

Removed: 




diff  --git a/clang/lib/ARCMigrate/TransAutoreleasePool.cpp 
b/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
index 47587d81850ab1..6d501228e712b2 100644
--- a/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
+++ b/clang/lib/ARCMigrate/TransAutoreleasePool.cpp
@@ -417,11 +417,11 @@ class AutoreleasePoolRewriter
   Selector DrainSel;
 
   struct PoolVarInfo {
-DeclStmt *Dcl;
+DeclStmt *Dcl = nullptr;
 ExprSet Refs;
 SmallVector Scopes;
 
-PoolVarInfo() : Dcl(nullptr) { }
+PoolVarInfo() = default;
   };
 
   std::map PoolVars;



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


[clang] 3d64b63 - [Sema] Modernize LambdaIntroducer (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T09:24:21-07:00
New Revision: 3d64b63673b6583d0e4c6daedc2005e765c878ec

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

LOG: [Sema] Modernize LambdaIntroducer (NFC)

Added: 


Modified: 
clang/include/clang/Sema/DeclSpec.h

Removed: 




diff  --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 4a5d7145803979..ff5e2e2e57366d 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -2769,11 +2769,10 @@ struct LambdaIntroducer {
 
   SourceRange Range;
   SourceLocation DefaultLoc;
-  LambdaCaptureDefault Default;
+  LambdaCaptureDefault Default = LCD_None;
   SmallVector Captures;
 
-  LambdaIntroducer()
-: Default(LCD_None) {}
+  LambdaIntroducer() = default;
 
   bool hasLambdaCapture() const {
 return Captures.size() > 0 || Default != LCD_None;



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


[PATCH] D158953: [analyzer] MmapWriteExecChecker: use getAs instead of castAs

2023-08-27 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

In D158953#4620125 , @steakhal wrote:

> Could you please simplify the test case?
> You could basically get rid of everything there, except for forwarding one 
> top level parameter as the proto argument to the mmap call.

No problem!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158953

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


[PATCH] D158953: [analyzer] MmapWriteExecChecker: use getAs instead of castAs

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

Could you please simplify the test case?
You could basically get rid of everything there, except for forwarding one top 
level parameter as the proto argument to the mmap call.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158953

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


[clang] f79bbef - [clang][NFC] Fix a few malformed links

2023-08-27 Thread via cfe-commits

Author: dingfei
Date: 2023-08-27T23:32:57+08:00
New Revision: f79bbefa82f26b3b12e8c7cb0c03721f379c104e

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

LOG: [clang][NFC] Fix a few malformed links

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1ed144cea09786..6dc3c1c5fbcef8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -149,7 +149,7 @@ Improvements to Clang's diagnostics
   (`#56035: `_).
 - Clang constexpr evaluator now diagnoses compound assignment operators against
   uninitialized variables as a read of uninitialized object.
-  (`#51536 _`)
+  (`#51536 `_)
 - Clang's ``-Wfortify-source`` now diagnoses ``snprintf`` call that is known to
   result in string truncation.
   (`#64871: `_).
@@ -163,10 +163,10 @@ Bug Fixes in This Version
   module may end up with members associated with the wrong declaration of the
   class, which can result in miscompiles in some cases.
 - Fix crash on use of a variadic overloaded operator.
-  (`#42535 _`)
+  (`#42535 `_)
 - Fix a hang on valid C code passing a function type as an argument to
   ``typeof`` to form a function declaration.
-  (`#64713 _`)
+  (`#64713 `_)
 - Clang now reports missing-field-initializers warning for missing designated
   initializers in C++.
   (`#56628 `_)
@@ -222,7 +222,7 @@ Bug Fixes to C++ Support
 - Expressions producing ``nullptr`` are correctly evaluated
   by the constant interpreter when appearing as the operand
   of a binary comparison.
-  (`#64923 _``)
+  (`#64923 `_)
 
 - Fix a crash when an immediate invocation is not a constant expression
   and appear in an implicit cast.



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


[clang] 7224749 - [clang] Use SmallDenseMap::contains (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T08:26:50-07:00
New Revision: 722474969e6be933948e5571cfd1511b4780a69b

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

LOG: [clang] Use SmallDenseMap::contains (NFC)

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index daa4b095eaa8ae..070246f099e2e9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -145,13 +145,12 @@ llvm::Constant 
*CodeGenModule::getBuiltinLibFunction(const FunctionDecl *FD,
 // PPC, after backend supports IEEE 128-bit style libcalls.
 if (getTriple().isPPC64() &&
 ().getLongDoubleFormat() == ::APFloat::IEEEquad() &&
-F128Builtins.find(BuiltinID) != F128Builtins.end())
+F128Builtins.contains(BuiltinID))
   Name = F128Builtins[BuiltinID];
 else if (getTriple().isOSAIX() &&
  ().getLongDoubleFormat() ==
  ::APFloat::IEEEdouble() &&
- AIXLongDouble64Builtins.find(BuiltinID) !=
- AIXLongDouble64Builtins.end())
+ AIXLongDouble64Builtins.contains(BuiltinID))
   Name = AIXLongDouble64Builtins[BuiltinID];
 else
   Name = Context.BuiltinInfo.getName(BuiltinID).substr(10);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index e7318880af8d3b..f1211260e71f18 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4173,7 +4173,7 @@ void LocalInstantiationScope::InstantiatedLocal(const 
Decl *D, Decl *Inst) {
 LocalInstantiationScope *Current = this;
 while (Current->CombineWithOuterScope && Current->Outer) {
   Current = Current->Outer;
-  assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
+  assert(!Current->LocalDecls.contains(D) &&
  "Instantiated local in inner and outer scopes");
 }
 #endif
@@ -4197,7 +4197,7 @@ void 
LocalInstantiationScope::MakeInstantiatedLocalArgPack(const Decl *D) {
   // This should be the first time we've been told about this decl.
   for (LocalInstantiationScope *Current = this;
Current && Current->CombineWithOuterScope; Current = Current->Outer)
-assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
+assert(!Current->LocalDecls.contains(D) &&
"Creating local pack after instantiation of local");
 #endif
 



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


[PATCH] D158953: [analyzer] MmapWriteExecChecker: use getAs instead of castAs

2023-08-27 Thread Ding Fei via Phabricator via cfe-commits
danix800 created this revision.
danix800 added a reviewer: steakhal.
danix800 added a project: clang.
Herald added subscribers: manas, ASDenysPetrov, martong, dkrupp, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
danix800 requested review of this revision.
Herald added a subscriber: cfe-commits.

MmapWriteExecChecker: use getAs instead of castAs

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158953

Files:
  clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
  clang/test/Analysis/mmap-writeexec.c


Index: clang/test/Analysis/mmap-writeexec.c
===
--- clang/test/Analysis/mmap-writeexec.c
+++ clang/test/Analysis/mmap-writeexec.c
@@ -42,3 +42,17 @@
   int m = mprotect(p, 1024, PROT_WRITE | PROT_EXEC); // expected-warning{{Both 
PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory 
regions, which could be overwritten with malicious code}}
   (void)m;
 }
+
+// gh62285: no crash on non concrete arg 'prot'
+typedef struct malloc_mmap_2
+{
+  int prot;
+} malloc_mmap_st_2;
+
+int gh62285(int cmd, void *arg2)
+{
+  malloc_mmap_st_2* args2 = arg2;
+  void *buf = ((void*)0);
+  buf = mmap((void*)0, 1, args2->prot, 1, 1, 1);
+  return 0;
+}
Index: clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -48,8 +48,10 @@
  CheckerContext ) const {
   if (matchesAny(Call, MmapFn, MprotectFn)) {
 SVal ProtVal = Call.getArgSVal(2);
-auto ProtLoc = ProtVal.castAs();
-int64_t Prot = ProtLoc.getValue().getSExtValue();
+auto ProtLoc = ProtVal.getAs();
+if (!ProtLoc)
+  return;
+int64_t Prot = ProtLoc->getValue().getSExtValue();
 if (ProtExecOv != ProtExec)
   ProtExec = ProtExecOv;
 if (ProtReadOv != ProtRead)


Index: clang/test/Analysis/mmap-writeexec.c
===
--- clang/test/Analysis/mmap-writeexec.c
+++ clang/test/Analysis/mmap-writeexec.c
@@ -42,3 +42,17 @@
   int m = mprotect(p, 1024, PROT_WRITE | PROT_EXEC); // expected-warning{{Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code}}
   (void)m;
 }
+
+// gh62285: no crash on non concrete arg 'prot'
+typedef struct malloc_mmap_2
+{
+  int prot;
+} malloc_mmap_st_2;
+
+int gh62285(int cmd, void *arg2)
+{
+  malloc_mmap_st_2* args2 = arg2;
+  void *buf = ((void*)0);
+  buf = mmap((void*)0, 1, args2->prot, 1, 1, 1);
+  return 0;
+}
Index: clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MmapWriteExecChecker.cpp
@@ -48,8 +48,10 @@
  CheckerContext ) const {
   if (matchesAny(Call, MmapFn, MprotectFn)) {
 SVal ProtVal = Call.getArgSVal(2);
-auto ProtLoc = ProtVal.castAs();
-int64_t Prot = ProtLoc.getValue().getSExtValue();
+auto ProtLoc = ProtVal.getAs();
+if (!ProtLoc)
+  return;
+int64_t Prot = ProtLoc->getValue().getSExtValue();
 if (ProtExecOv != ProtExec)
   ProtExec = ProtExecOv;
 if (ProtReadOv != ProtRead)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158540: Improve error message for constexpr constructors of virtual base classes

2023-08-27 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added reviewers: shafik, aaron.ballman.
xgupta added a comment.

Test case updates are missing due to which 7 test cases are failing on 
pre-merge check - 
https://buildkite.com/llvm-project/premerge-checks/builds/172995#018a2776-1461-4f98-b12d-bd0521352d50/6-14972.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158540

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


[clang-tools-extra] cbdc3e1 - [clang-tidy][NFC] Fix cppcoreguidelines-init-variables findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:03Z
New Revision: cbdc3e1bf9da09911ba353bcd20c6709bda43893

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

LOG: [clang-tidy][NFC] Fix cppcoreguidelines-init-variables findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/cert/StrToNumCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp
clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
clang-tools-extra/clang-tidy/misc/MisleadingIdentifier.cpp
clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
clang-tools-extra/clang-tidy/misc/NewDeleteOverloadsCheck.cpp
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
clang-tools-extra/clang-tidy/readability/MagicNumbersCheck.cpp
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp
clang-tools-extra/clang-tidy/utils/HeaderGuard.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 499144830eabea..47253570e91da6 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -133,7 +133,7 @@ class ErrorReporter {
   for (const FileByteRange  : Error.Message.Ranges)
 Diag << getRange(FBR);
   // FIXME: explore options to support interactive fix selection.
-  const llvm::StringMap *ChosenFix;
+  const llvm::StringMap *ChosenFix = nullptr;
   if (ApplyFixes != FB_NoFix &&
   (ChosenFix = getFixIt(Error, ApplyFixes == FB_FixNotes))) {
 for (const auto  : *ChosenFix) {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 8b261268449cf2..3e926236adb451 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -97,7 +97,7 @@ static std::optional getAsBool(StringRef Value,
 return Parsed;
   // To maintain backwards compatability, we support parsing numbers as
   // booleans, even though its not supported in YAML.
-  long long Number;
+  long long Number = 0;
   if (!Value.getAsInteger(10, Number))
 return Number != 0;
   return std::nullopt;

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
index 5688dc16d1106a..121892fd0daa9a 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationFactoryScaleCheck.cpp
@@ -159,7 +159,7 @@ void DurationFactoryScaleCheck::check(const 
MatchFinder::MatchResult ) {
 return;
 
   DurationScale Scale = *MaybeScale;
-  const Expr *Remainder;
+  const Expr *Remainder = nullptr;
   std::optional NewScale;
 
   // We next handle the cases of multiplication and division.

diff  --git a/clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp 

[clang-tools-extra] 857f532 - [clang-tidy][NFC] Fix clang-analyzer-optin.cplusplus.UninitializedObject findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:03Z
New Revision: 857f532fd5c9de92fe861374ad82e3a36beeb166

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

LOG: [clang-tidy][NFC] Fix clang-analyzer-optin.cplusplus.UninitializedObject 
findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
index 815c02a15492d1..7a9d04bfa8ba1b 100644
--- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
@@ -75,9 +75,9 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl 
*Ctor,
 /// the
 /// given constructor.
 bool hasExactlyOneUsageIn(const CXXConstructorDecl *Ctor) {
-  Count = 0;
+  Count = 0U;
   TraverseDecl(const_cast(Ctor));
-  return Count == 1;
+  return Count == 1U;
 }
 
   private:
@@ -88,7 +88,7 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl 
*Ctor,
   if (const ParmVarDecl *To = dyn_cast(D->getDecl())) {
 if (To == ParamDecl) {
   ++Count;
-  if (Count > 1) {
+  if (Count > 1U) {
 // No need to look further, used more than once.
 return false;
   }
@@ -98,7 +98,7 @@ static bool paramReferredExactlyOnce(const CXXConstructorDecl 
*Ctor,
 }
 
 const ParmVarDecl *ParamDecl;
-unsigned Count;
+unsigned Count = 0U;
   };
 
   return ExactlyOneUsageVisitor(ParamDecl).hasExactlyOneUsageIn(Ctor);



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


[clang-tools-extra] 9f82209 - [clang-tidy][NFC] Fix clang-analyzer-core.UndefinedBinaryOperatorResult findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:03Z
New Revision: 9f8220969cc8c52565d6f9b932e1934513e0c1bb

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

LOG: [clang-tidy][NFC] Fix clang-analyzer-core.UndefinedBinaryOperatorResult 
findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index e25708d4c05554..197fa812501601 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -171,7 +171,7 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt 
*Statement,
   const Stmt *Initializer = ForLoop->getInit();
   const Expr *Conditional = ForLoop->getCond();
   const Expr *Increment = ForLoop->getInc();
-  int InitValue;
+  int InitValue = 0;
   // If the loop variable value isn't known, we can't know the loop bounds.
   if (const auto *InitDeclStatement = dyn_cast(Initializer)) {
 if (const auto *VariableDecl =
@@ -183,12 +183,12 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt 
*Statement,
 }
   }
 
-  int EndValue;
+  int EndValue = 0;
   const auto *BinaryOp = cast(Conditional);
   if (!extractValue(EndValue, BinaryOp, Context))
 return true;
 
-  double Iterations;
+  double Iterations = 0.0;
 
   // If increment is unary and not one of ++, --, we can't know the loop 
bounds.
   if (const auto *Op = dyn_cast(Increment)) {



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


[clang-tools-extra] 26078f3 - [clang-tidy][NFC] Fix cppcoreguidelines-missing-std-forward findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:03Z
New Revision: 26078f33bdfa30f35bb880feb0c088b8bd2169c8

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

LOG: [clang-tidy][NFC] Fix cppcoreguidelines-missing-std-forward findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index e2c2dad6cf323e..7b02576a6093cb 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -479,7 +479,7 @@ struct MixData {
 return *this;
   }
 
-  template  MixData withCommonTypeTransformed(F &) const {
+  template  MixData withCommonTypeTransformed(const F ) const 
{
 if (CommonType.isNull())
   return *this;
 

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index 7af096053e9e27..855c4a2efc373e 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -31,7 +31,7 @@ AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
 // Iterate over all the fields in a record type, both direct and indirect (e.g.
 // if the record contains an anonymous struct).
 template 
-void forEachField(const RecordDecl , const T , Func &) {
+void forEachField(const RecordDecl , const T , const Func ) {
   for (const FieldDecl *F : Fields) {
 if (F->isAnonymousStructOrUnion()) {
   if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl())
@@ -44,7 +44,7 @@ void forEachField(const RecordDecl , const T , 
Func &) {
 
 template 
 void forEachFieldWithFilter(const RecordDecl , const T ,
-bool , Func &) {
+bool , const Func ) {
   for (const FieldDecl *F : Fields) {
 if (F->isAnonymousStructOrUnion()) {
   if (const CXXRecordDecl *R = F->getType()->getAsCXXRecordDecl()) {

diff  --git 
a/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
index a67b1cdc81f987..ccaa686f853234 100644
--- a/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/OperatorsRepresentationCheck.cpp
@@ -136,7 +136,7 @@ getRepresentation(const std::vector 
,
 
 template 
 static bool isAnyOperatorEnabled(const std::vector ,
- T &) {
+ const T ) {
   for (const auto &[traditional, alternative] : Operators) {
 if (!getRepresentation(Config, traditional, alternative).empty())
   return true;



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


[clang-tools-extra] 01c8bf6 - [clang-tidy][NFC] Fix llvm-else-after-return findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:02Z
New Revision: 01c8bf6fd4132831c971a764559e3d532f5129ae

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

LOG: [clang-tidy][NFC] Fix llvm-else-after-return findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 

clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
index 87e1b058027636..00dfa17a1ccf61 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
@@ -37,9 +37,8 @@ static SourceLocation findDefaultCaptureEnd(const LambdaExpr 
*Lambda,
 SourceLocation AddressofLoc = utils::lexer::findPreviousTokenKind(
 Capture.getLocation(), SourceMgr, Context.getLangOpts(), tok::amp);
 return AddressofLoc;
-  } else {
-return Capture.getLocation();
   }
+  return Capture.getLocation();
 }
   }
   return Lambda->getIntroducerRange().getEnd();

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
index da49d5610e229e..efcaffb45d9ad8 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
@@ -31,9 +31,8 @@ AST_MATCHER_P2(Stmt, argumentOf, bool, AllowPartialMove, 
StatementMatcher,
Ref) {
   if (AllowPartialMove) {
 return stmt(anyOf(Ref, hasDescendant(Ref))).matches(Node, Finder, Builder);
-  } else {
-return Ref.matches(Node, Finder, Builder);
   }
+  return Ref.matches(Node, Finder, Builder);
 }
 } // namespace
 

diff  --git a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp 
b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
index b7dcaf20169ebb..8c62fef6f3f3f9 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
@@ -62,7 +62,8 @@ static clang::CharSourceRange getReplaceRange(const 
ExplicitCastExpr *Expr) {
 return CharSourceRange::getCharRange(
 CastExpr->getLParenLoc(),
 CastExpr->getSubExprAsWritten()->getBeginLoc());
-  } else if (const auto *CastExpr = dyn_cast(Expr)) {
+  }
+  if (const auto *CastExpr = dyn_cast(Expr)) {
 return CharSourceRange::getCharRange(CastExpr->getBeginLoc(),
  CastExpr->getLParenLoc());
   } else

diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index 37aa26ded42407..bf340984bd3811 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -368,14 +368,14 @@ static std::optional 
getContainerExpr(const Expr *Call) {
   return ContainerCall{TheCall->getImplicitObjectArgument(),
Member->getMemberDecl()->getName(),
Member->isArrow(), CallKind};
-} else {
-  if (TheCall->getDirectCallee() == nullptr ||
-  !MemberNames.contains(TheCall->getDirectCallee()->getName()))
-return std::nullopt;
-  return ContainerCall{TheCall->getArg(0),
-   TheCall->getDirectCallee()->getName(), false,
-   CallKind};
 }
+if (TheCall->getDirectCallee() == nullptr ||
+!MemberNames.contains(TheCall->getDirectCallee()->getName()))
+  return std::nullopt;
+return ContainerCall{TheCall->getArg(0),
+ TheCall->getDirectCallee()->getName(), false,
+ CallKind};
+
   } else if (const auto *TheCall = dyn_cast_or_null(Dug)) {
 if (TheCall->getNumArgs() != 1)
   return std::nullopt;

diff  --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 75ebfbd381ad8f..310b5bf9affa15 100644
--- 

[clang-tools-extra] fe4bf68 - [clang-tidy][NFC] Fix readability-uppercase-literal-suffix findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:02Z
New Revision: fe4bf68c56e14dd474b62227a1aeb347b199bd1e

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

LOG: [clang-tidy][NFC] Fix readability-uppercase-literal-suffix findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp 
b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index bd317d0d264178..3d807c1d0f7aa2 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -29,7 +29,7 @@ static std::optional
 truncateIfIntegral(const FloatingLiteral ) {
   double Value = FloatLiteral.getValueAsApproximateDouble();
   if (std::fmod(Value, 1) == 0) {
-if (Value >= static_cast(1u << 31))
+if (Value >= static_cast(1U << 31))
   return std::nullopt;
 
 return llvm::APSInt::get(static_cast(Value));

diff  --git a/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
index cdd1984ab50cf7..b197c22dca410e 100644
--- a/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
@@ -484,7 +484,7 @@ void MacroToEnumCallbacks::fixEnumMacro(const MacroList 
) const {
   Check->diag(Begin, "replace macro with enum")
   << FixItHint::CreateInsertion(Begin, "enum {\n");
 
-  for (size_t I = 0u; I < MacroList.size(); ++I) {
+  for (size_t I = 0U; I < MacroList.size(); ++I) {
 const EnumMacro  = MacroList[I];
 SourceLocation DefineEnd =
 Macro.Directive->getMacroInfo()->getDefinitionLoc();

diff  --git a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
index 57e4c4863d3b70..7ec62f41aec019 100644
--- a/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp
@@ -105,7 +105,7 @@ RawStringLiteralCheck::RawStringLiteralCheck(StringRef Name,
 DisallowedChars.set(C);
 
   // Non-ASCII are disallowed too.
-  for (unsigned int C = 0x80u; C <= 0xFFu; ++C)
+  for (unsigned int C = 0x80U; C <= 0xFFU; ++C)
 DisallowedChars.set(static_cast(C));
 }
 

diff  --git 
a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
index 21e3bd08255d98..68e9dd4998473b 100644
--- a/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.cpp
@@ -27,8 +27,8 @@ NamespaceCommentCheck::NamespaceCommentCheck(StringRef Name,
   "^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
   "namespace( +(((inline )|([a-zA-Z0-9_:]))+))?\\.? *(\\*/)?$",
   llvm::Regex::IgnoreCase),
-  ShortNamespaceLines(Options.get("ShortNamespaceLines", 1u)),
-  SpacesBeforeComments(Options.get("SpacesBeforeComments", 1u)) {}
+  ShortNamespaceLines(Options.get("ShortNamespaceLines", 1U)),
+  SpacesBeforeComments(Options.get("SpacesBeforeComments", 1U)) {}
 
 void NamespaceCommentCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "ShortNamespaceLines", ShortNamespaceLines);

diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
index 78da016a0fb45f..0a8cf8668d3ca9 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -141,7 +141,7 @@ class ExceptionAnalyzer {
 
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
-  llvm::DenseMap FunctionCache{32u};
+  llvm::DenseMap FunctionCache{32U};
 };
 
 } // namespace clang::tidy::utils

diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.h 
b/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.h
index cf876599469387..ddfb796d9c5460 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.h
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.h
@@ -81,7 +81,7 @@ class ExceptionSpecAnalyzer {
   static DefaultableMemberKind
   getDefaultableMemberKind(const FunctionDecl *FuncDecl);
 
-  llvm::DenseMap FunctionCache{32u};

[clang-tools-extra] fc2a9ad - [clang-tidy][NFC] Fix modernize-use-auto findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T11:59:02Z
New Revision: fc2a9ad10e21bda3dafbb85d8317ef5e3e5f99a1

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

LOG: [clang-tidy][NFC] Fix modernize-use-auto findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp
clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index f532d3ea7a941c..cbf21a0e2ae344 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -107,7 +107,7 @@ void yamlize(IO , ClangTidyOptions::OptionMap , bool,
   } else {
 // We need custom logic here to support the old method of specifying check
 // options using a list of maps containing key and value keys.
-Input  = reinterpret_cast(IO);
+auto  = reinterpret_cast(IO);
 if (isa(I.getCurrentNode())) {
   MappingNormalization NOpts(IO,
   Val);
@@ -134,7 +134,7 @@ template <> void yamlize(IO , ChecksVariant , bool, 
EmptyContext ) {
   if (!IO.outputting()) {
 // Special case for reading from YAML
 // Must support reading from both a string or a list
-Input  = reinterpret_cast(IO);
+auto  = reinterpret_cast(IO);
 if (isa(I.getCurrentNode())) {
   Val.AsString = std::string();
   yamlize(IO, *Val.AsString, true, Ctx);

diff  --git a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
index 2a31d60961703f..d4b8c9e6d89422 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationAdditionCheck.cpp
@@ -29,9 +29,8 @@ void DurationAdditionCheck::registerMatchers(MatchFinder 
*Finder) {
 }
 
 void DurationAdditionCheck::check(const MatchFinder::MatchResult ) {
-  const BinaryOperator *Binop =
-  Result.Nodes.getNodeAs("binop");
-  const CallExpr *Call = Result.Nodes.getNodeAs("call");
+  const auto *Binop = Result.Nodes.getNodeAs("binop");
+  const auto *Call = Result.Nodes.getNodeAs("call");
 
   // Don't try to replace things inside of macro definitions.
   if (Binop->getExprLoc().isMacroID() || Binop->getExprLoc().isInvalid())

diff  --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
index 7effb8250ae76b..b36144d1912fce 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -86,8 +86,7 @@ void StringFindStartswithCheck::check(const 
MatchFinder::MatchResult ) {
   const Expr *Haystack = Result.Nodes.getNodeAs("findexpr")
  ->getImplicitObjectArgument();
   assert(Haystack != nullptr);
-  const CXXMethodDecl *FindFun =
-  Result.Nodes.getNodeAs("findfun");
+  const auto *FindFun = Result.Nodes.getNodeAs("findfun");
   assert(FindFun != nullptr);
 
   bool Rev = FindFun->getName().contains("rfind");

diff  --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index c3b47d41c46d64..cdaedd440959cc 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -110,7 +110,7 @@ void StructPackAlignCheck::check(const 
MatchFinder::MatchResult ) {
   }
 
   FixItHint FixIt;
-  AlignedAttr *Attribute = Struct->getAttr();
+  auto *Attribute = Struct->getAttr();
   std::string NewAlignQuantity = std::to_string((int)NewAlign.getQuantity());
   if (Attribute) {
 FixIt = FixItHint::CreateReplacement(

diff  --git 

[clang-tools-extra] 44b38fe - [clang-tidy][NFC] Fix bugprone-implicit-widening-of-multiplication-result findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:11Z
New Revision: 44b38fe86e9e74ebd0e6de9583e6456313d564ac

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

LOG: [clang-tidy][NFC] Fix bugprone-implicit-widening-of-multiplication-result 
findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index 0b7887ecfdfac6..c3b47d41c46d64 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -27,10 +27,10 @@ CharUnits
 StructPackAlignCheck::computeRecommendedAlignment(CharUnits MinByteSize) const 
{
   CharUnits NewAlign = CharUnits::fromQuantity(1);
   if (!MinByteSize.isPowerOfTwo()) {
-int MSB = (int)MinByteSize.getQuantity();
+CharUnits::QuantityType MSB = MinByteSize.getQuantity();
 for (; MSB > 0; MSB /= 2) {
-  NewAlign = NewAlign.alignTo(
-  CharUnits::fromQuantity(((int)NewAlign.getQuantity()) * 2));
+  NewAlign =
+  NewAlign.alignTo(CharUnits::fromQuantity(NewAlign.getQuantity() * 
2));
   // Abort if the computed alignment meets the maximum configured 
alignment.
   if (NewAlign.getQuantity() >= MaxConfiguredAlignment)
 break;



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


[clang-tools-extra] 9c857f2 - [clang-tidy][NFC] Fix modernize-raw-string-literal findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: 9c857f2151b48d3447828496295d076c3ec145e6

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

LOG: [clang-tidy][NFC] Fix modernize-raw-string-literal findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
index 14dfe963c9db3e..07ab34a07cd31d 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyProfiling.cpp
@@ -43,8 +43,8 @@ void 
ClangTidyProfiling::printUserFriendlyTable(llvm::raw_ostream ) {
 
 void ClangTidyProfiling::printAsJSON(llvm::raw_ostream ) {
   OS << "{\n";
-  OS << "\"file\": \"" << Storage->SourceFilename << "\",\n";
-  OS << "\"timestamp\": \"" << Storage->Timestamp << "\",\n";
+  OS << R"("file": ")" << Storage->SourceFilename << "\",\n";
+  OS << R"("timestamp": ")" << Storage->Timestamp << "\",\n";
   OS << "\"profile\": {\n";
   TG->printJSONValues(OS, "");
   OS << "\n}\n";

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index 1b1fbe97e9358e..ccc28efca68cda 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -483,7 +483,7 @@ static void insertNullTerminatorExpr(StringRef Name,
   (Twine('\n') + SpaceBeforeStmtStr +
exprToStr(Result.Nodes.getNodeAs(DestExprName), Result) + "[" +
exprToStr(Result.Nodes.getNodeAs(LengthExprName), Result) +
-   "] = " + ((Name[0] != 'w') ? "\'\\0\';" : "L\'\\0\';"))
+   "] = " + ((Name[0] != 'w') ? R"('\0';)" : R"(L'\0';)"))
   .str();
 
   const auto AddNullTerminatorExprFix = FixItHint::CreateInsertion(



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


[clang-tools-extra] 7142f73 - [clang-tidy][NFC] Fix modernize-type-traits findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:11Z
New Revision: 7142f731233a84255ca58327b857cf211a910837

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

LOG: [clang-tidy][NFC] Fix modernize-type-traits findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 17e9df96c39bec..39b9f9fa865b76 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -190,7 +190,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// If the corresponding key can't be parsed as a ``T``, emit a
 /// diagnostic and return ``std::nullopt``.
 template 
-std::enable_if_t::value, std::optional>
+std::enable_if_t, std::optional>
 get(StringRef LocalName) const {
   if (std::optional Value = get(LocalName)) {
 T Result{};
@@ -211,8 +211,8 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// If the corresponding key can't be parsed as a ``T``, emit a
 /// diagnostic and return \p Default.
 template 
-std::enable_if_t::value, T> get(StringRef LocalName,
-T Default) const {
+std::enable_if_t, T> get(StringRef LocalName,
+   T Default) const {
   return get(LocalName).value_or(Default);
 }
 
@@ -227,7 +227,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// If the corresponding key can't be parsed as a ``T``, emit a
 /// diagnostic and return ``std::nullopt``.
 template 
-std::enable_if_t::value, std::optional>
+std::enable_if_t, std::optional>
 getLocalOrGlobal(StringRef LocalName) const {
   std::optional ValueOr = get(LocalName);
   bool IsGlobal = false;
@@ -256,7 +256,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// If the corresponding key can't be parsed as a ``T``, emit a
 /// diagnostic and return \p Default.
 template 
-std::enable_if_t::value, T>
+std::enable_if_t, T>
 getLocalOrGlobal(StringRef LocalName, T Default) const {
   return getLocalOrGlobal(LocalName).value_or(Default);
 }
@@ -274,7 +274,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
 /// supply the mapping required to convert between ``T`` and a string.
 template 
-std::enable_if_t::value, std::optional>
+std::enable_if_t, std::optional>
 get(StringRef LocalName, bool IgnoreCase = false) const {
   if (std::optional ValueOr =
   getEnumInt(LocalName, typeEraseMapping(), false, IgnoreCase))
@@ -295,8 +295,8 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
 /// supply the mapping required to convert between ``T`` and a string.
 template 
-std::enable_if_t::value, T>
-get(StringRef LocalName, T Default, bool IgnoreCase = false) const {
+std::enable_if_t, T> get(StringRef LocalName, T Default,
+   bool IgnoreCase = false) const {
   return get(LocalName, IgnoreCase).value_or(Default);
 }
 
@@ -314,7 +314,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
 /// supply the mapping required to convert between ``T`` and a string.
 template 
-std::enable_if_t::value, std::optional>
+std::enable_if_t, std::optional>
 getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
   if (std::optional ValueOr =
   getEnumInt(LocalName, typeEraseMapping(), true, IgnoreCase))
@@ -336,7 +336,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
 /// supply the mapping required to convert between ``T`` and a string.
 template 
-std::enable_if_t::value, T>
+std::enable_if_t, T>
 getLocalOrGlobal(StringRef LocalName, T Default,
  bool IgnoreCase = false) const {
   return getLocalOrGlobal(LocalName, IgnoreCase).value_or(Default);
@@ -350,7 +350,7 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 /// Stores an option with the 

[clang-tools-extra] 24a7587 - [clang-tidy][NFC] Fix readability-make-member-function-const findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:11Z
New Revision: 24a7587b79648002ad47e4de425ad498fb863d60

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

LOG: [clang-tidy][NFC] Fix readability-make-member-function-const findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.h
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index ac458d4b5d35d9..0b7887ecfdfac6 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -24,7 +24,7 @@ void StructPackAlignCheck::registerMatchers(MatchFinder 
*Finder) {
 }
 
 CharUnits
-StructPackAlignCheck::computeRecommendedAlignment(CharUnits MinByteSize) {
+StructPackAlignCheck::computeRecommendedAlignment(CharUnits MinByteSize) const 
{
   CharUnits NewAlign = CharUnits::fromQuantity(1);
   if (!MinByteSize.isPowerOfTwo()) {
 int MSB = (int)MinByteSize.getQuantity();

diff  --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h 
b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
index f46d8e3b875a9b..5edfd40ef77bc6 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
@@ -29,7 +29,7 @@ class StructPackAlignCheck : public ClangTidyCheck {
 
 private:
   const unsigned MaxConfiguredAlignment;
-  CharUnits computeRecommendedAlignment(CharUnits MinByteSize);
+  CharUnits computeRecommendedAlignment(CharUnits MinByteSize) const;
 };
 
 } // namespace clang::tidy::altera

diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index 7bd12adacc4065..e25708d4c05554 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -246,7 +246,7 @@ bool UnrollLoopsCheck::extractValue(int , const 
BinaryOperator *Op,
 }
 
 bool UnrollLoopsCheck::exprHasLargeNumIterations(const Expr *Expression,
- const ASTContext *Context) {
+ const ASTContext *Context) 
const {
   Expr::EvalResult Result;
   if (Expression->EvaluateAsRValue(Result, *Context)) {
 if (!Result.Val.isInt())

diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
index e4bf7464c688ef..0d8306e8437b73 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
@@ -56,7 +56,7 @@ class UnrollLoopsCheck : public ClangTidyCheck {
   /// bound on the number of loops is greater than max_loop_iterations or not.
   /// If the expression is not evaluatable or not an integer, returns false.
   bool exprHasLargeNumIterations(const Expr *Expression,
- const ASTContext *Context);
+ const ASTContext *Context) const;
   /// Returns the type of unrolling, if any, associated with the given
   /// statement.
   enum UnrollType unrollType(const Stmt *Statement, ASTContext *Context);

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index ccc28efca68cda..44db5029fd9936 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -939,7 +939,7 @@ void NotNullTerminatedResultCheck::memchrFix(
 
 void NotNullTerminatedResultCheck::memmoveFix(
 StringRef Name, const MatchFinder::MatchResult ,
-DiagnosticBuilder ) {
+DiagnosticBuilder ) const {
   bool IsOverflows = isDestCapacityFix(Result, Diag);
 
   if (UseSafeFunctions && isKnownDest(Result)) {

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.h
index caed870cd1ca56..1eeead02b17ab4 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.h
+++ 

[clang-tools-extra] ec5f4be - [clang-tidy][NFC] Fix modernize-return-braced-init-list findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: ec5f4be4521c3b28d6bb14f34f39a87c36fe8c00

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

LOG: [clang-tidy][NFC] Fix modernize-return-braced-init-list findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/ClangTidyModule.cpp
clang-tools-extra/clang-tidy/GlobList.cpp
clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
clang-tools-extra/clang-tidy/google/FunctionNamingCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
clang-tools-extra/clang-tidy/utils/LexerUtils.h
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index ca48388e85a99e..99f137879d7f93 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -242,11 +242,11 @@ class ErrorReporter {
 private:
   SourceLocation getLocation(StringRef FilePath, unsigned Offset) {
 if (FilePath.empty())
-  return SourceLocation();
+  return {};
 
 auto File = SourceMgr.getFileManager().getFile(FilePath);
 if (!File)
-  return SourceLocation();
+  return {};
 
 FileID ID = SourceMgr.getOrCreateFileID(*File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 962f7dc32de3e6..30b4bfbe387795 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -212,11 +212,11 @@ class ClangTidyContext {
   using DiagLevelAndFormatString = std::pair;
   DiagLevelAndFormatString getDiagLevelAndFormatString(unsigned DiagnosticID,
SourceLocation Loc) {
-return DiagLevelAndFormatString(
+return {
 static_cast(
 DiagEngine->getDiagnosticLevel(DiagnosticID, Loc)),
 std::string(
-DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
+DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID))};
   }
 
   void setOptionsCollector(llvm::StringSet<> *Collector) {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
index 8650e46b8833e6..7432229fda8007 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.cpp
@@ -46,8 +46,6 @@ ClangTidyCheckFactories::createChecksForLanguage(
   return Checks;
 }
 
-ClangTidyOptions ClangTidyModule::getModuleOptions() {
-  return ClangTidyOptions();
-}
+ClangTidyOptions ClangTidyModule::getModuleOptions() { return {}; }
 
 } // namespace clang::tidy

diff  --git a/clang-tools-extra/clang-tidy/GlobList.cpp 
b/clang-tools-extra/clang-tidy/GlobList.cpp
index acd08dd3ee08c4..1d5b3a882fa648 100644
--- a/clang-tools-extra/clang-tidy/GlobList.cpp
+++ b/clang-tools-extra/clang-tidy/GlobList.cpp
@@ -39,7 +39,7 @@ static llvm::Regex consumeGlob(StringRef ) {
 RegexText.push_back(C);
   }
   RegexText.push_back('$');
-  return llvm::Regex(RegexText);
+  return {RegexText};
 }
 
 

[clang-tools-extra] 4d81b14 - [clang-tidy][NFC] Fix performance-unnecessary-copy-initialization findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: 4d81b1450dd227c0d3da615f7e4f5937378cc05c

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

LOG: [clang-tidy][NFC] Fix performance-unnecessary-copy-initialization findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
index 90e68d15e4c00c..ca1ae551cc632a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
@@ -60,7 +60,7 @@ static bool hasDisjointValueRange(const EnumDecl *Enum1,
 }
 
 static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) {
-  llvm::APSInt Val = EnumConst->getInitVal();
+  const llvm::APSInt  = EnumConst->getInitVal();
   if (Val.isPowerOf2() || !Val.getBoolValue())
 return false;
   const Expr *InitExpr = EnumConst->getInitExpr();



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


[clang-tools-extra] c5a4f29 - [clang-tidy][NFC] Fix readability-container-size-empty findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: c5a4f29ef02a48caddca3ab82dbd364ca9db558b

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

LOG: [clang-tidy][NFC] Fix readability-container-size-empty findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index cba29b949fefd7..1b1fbe97e9358e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -177,7 +177,7 @@ static bool isDestBasedOnGivenLength(const 
MatchFinder::MatchResult ) {
   StringRef LengthExprStr =
   exprToStr(Result.Nodes.getNodeAs(LengthExprName), Result).trim();
 
-  return DestCapacityExprStr != "" && LengthExprStr != "" &&
+  return !DestCapacityExprStr.empty() && !LengthExprStr.empty() &&
  DestCapacityExprStr.contains(LengthExprStr);
 }
 

diff  --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index fb04e6e0fa9361..6eefde369c59e5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -104,7 +104,7 @@ static std::optional 
getUnderscoreCapitalFixup(StringRef Name) {
 static bool startsWithUnderscoreInGlobalNamespace(StringRef Name,
   bool IsInGlobalNamespace,
   bool IsMacro) {
-  return !IsMacro && IsInGlobalNamespace && Name.size() >= 1 && Name[0] == '_';
+  return !IsMacro && IsInGlobalNamespace && !Name.empty() && Name[0] == '_';
 }
 
 static std::optional

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
index 49293ab727af4d..43d53f0b6020ae 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -101,7 +101,7 @@ void SuspiciousIncludePPCallbacks::InclusionDirective(
   for (const auto  : Check.HeaderFileExtensions) {
 SmallString<128> GuessedFileName(FileName);
 llvm::sys::path::replace_extension(GuessedFileName,
-   (HFE.size() ? "." : "") + HFE);
+   (!HFE.empty() ? "." : "") + HFE);
 
 OptionalFileEntryRef File =
 PP->LookupFile(DiagLoc, GuessedFileName, IsAngled, nullptr, nullptr,

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
index 138f4bf6b19c29..87e1b058027636 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
@@ -50,7 +50,7 @@ static std::string createReplacementText(const LambdaExpr 
*Lambda) {
   llvm::raw_string_ostream Stream(Replacement);
 
   auto AppendName = [&](llvm::StringRef Name) {
-if (Replacement.size() != 0) {
+if (!Replacement.empty()) {
   Stream << ", ";
 }
 if (Lambda->getCaptureDefault() == LCD_ByRef && Name != "this") {
@@ -68,7 +68,7 @@ static std::string createReplacementText(const LambdaExpr 
*Lambda) {
   AppendName("this");
 }
   }
-  if (Replacement.size() &&
+  if (!Replacement.empty() &&
   Lambda->explicit_capture_begin() != Lambda->explicit_capture_end()) {
 // Add back separator if we are adding explicit capture variables.
 Stream << ", ";

diff  --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 951cc2f9903ba3..74074180b5a9ff 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
@@ -353,7 +353,7 @@ static std::vector handleReturnType(const 
FunctionDecl 

[clang-tools-extra] c8644b1 - [clang-tidy][NFC] Fix modernize-deprecated-headers findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: c8644b18f570be9d26d83cdeeb2369cd3cbddaf1

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

LOG: [clang-tidy][NFC] Fix modernize-deprecated-headers findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index 70a6ab3cc8f3ba..ac458d4b5d35d9 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -10,7 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include 
+#include 
 
 using namespace clang::ast_matchers;
 

diff  --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp 
b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
index ed3b831e89eae7..7bd12adacc4065 100644
--- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
@@ -13,7 +13,7 @@
 #include "clang/AST/OperationKinds.h"
 #include "clang/AST/ParentMapContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
-#include 
+#include 
 
 using namespace clang::ast_matchers;
 



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


[clang-tools-extra] 9999423 - [clang-tidy][NFC] Fix performance-for-range-copy findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: 423fdd7244b7f84f648d9740830269015284

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

LOG: [clang-tidy][NFC] Fix performance-for-range-copy findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index fc88a186484365..96f59c9c0896a1 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -481,7 +481,7 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const 
Diagnostic ) {
 
   // Forward the details.
   auto Builder = ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
-  for (auto Hint : Info.getFixItHints())
+  for (const FixItHint  : Info.getFixItHints())
 Builder << Hint;
   for (auto Range : Info.getRanges())
 Builder << Range;



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


[clang-tools-extra] 4b8accb - [clang-tidy][NFC] Fix readability-redundant-access-specifiers findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: 4b8accbbf40367632f6e7185a553291c74089742

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

LOG: [clang-tidy][NFC] Fix readability-redundant-access-specifiers findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index e20a7d734a199c..e7636cb5d9b063 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -230,7 +230,6 @@ class FileOptionsBaseProvider : public 
DefaultOptionsProvider {
   ClangTidyOptions OverrideOptions,
   ConfigFileHandlers ConfigHandlers);
 
- protected:
   void addRawFileOptions(llvm::StringRef AbsolutePath,
  std::vector );
 

diff  --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index 47c647841d7605..d88db51025ed89 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -467,7 +467,6 @@ class CastSequenceVisitor : public 
RecursiveASTVisitor {
 llvm_unreachable("findContainingAncestor");
   }
 
-private:
   SourceManager 
   ASTContext 
   ArrayRef NullMacros;

diff  --git 
a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h 
b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h
index 9653dd30f078f4..249aa19154 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.h
@@ -57,7 +57,6 @@ class BracesAroundStatementsCheck : public ClangTidyCheck {
 return TK_IgnoreUnlessSpelledInSource;
   }
 
-private:
   std::set ForceBracesStmts;
   const unsigned ShortStatementLines;
 };



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


[clang-tools-extra] d57cf05 - [clang-tidy][NFC] Fix modernize-concat-nested-namespaces findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: d57cf05f9406b9136a5859a53042de8789cfd6aa

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

LOG: [clang-tidy][NFC] Fix modernize-concat-nested-namespaces findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
index 47b96678599039..bd8a0b359c2e00 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
@@ -12,7 +12,8 @@
 #include "clang/Lex/Lexer.h"
 
 using namespace clang::ast_matchers;
-using namespace clang;
+
+namespace clang::tidy::bugprone {
 
 namespace {
 
@@ -50,10 +51,6 @@ bool isExprValueStored(const Expr *E, ASTContext ) {
 
 } // namespace
 
-namespace clang {
-namespace tidy {
-namespace bugprone {
-
 AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
   ast_matchers::internal::Matcher, InnerMatcher) {
   for (unsigned NH = Node.getNumHandlers(), I = 0; I < NH; ++I) {
@@ -157,6 +154,4 @@ void MultipleNewInOneExpressionCheck::check(
 << NewExpr1->getSourceRange() << NewExpr2->getSourceRange();
 }
 
-} // namespace bugprone
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::bugprone

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h
index eba6c84d818caa..29eea12ff71921 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h
@@ -11,9 +11,7 @@
 
 #include "../ClangTidyCheck.h"
 
-namespace clang {
-namespace tidy {
-namespace bugprone {
+namespace clang::tidy::bugprone {
 
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/bugprone/multiple-new-in-one-expression.html
@@ -28,8 +26,6 @@ class MultipleNewInOneExpressionCheck : public ClangTidyCheck 
{
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 };
 
-} // namespace bugprone
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::bugprone
 
 #endif // 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MULTIPLENEWINONEEXPRESSIONCHECK_H

diff  --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index ebb49645b5904e..ea7eaa0b0ff811 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -16,9 +16,7 @@
 using namespace clang::ast_matchers;
 using namespace llvm;
 
-namespace clang {
-namespace tidy {
-namespace bugprone {
+namespace clang::tidy::bugprone {
 
 static constexpr llvm::StringLiteral OptionNameReportMoreUnsafeFunctions =
 "ReportMoreUnsafeFunctions";
@@ -233,6 +231,4 @@ void UnsafeFunctionsCheck::onEndOfTranslationUnit() {
   IsAnnexKAvailable.reset();
 }
 
-} // namespace bugprone
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::bugprone

diff  --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
index 369ea25f693cc0..5adfee60d1a7de 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.h
@@ -12,9 +12,7 @@
 #include "../ClangTidyCheck.h"
 #include 
 
-namespace clang {
-namespace tidy {
-namespace bugprone {
+namespace clang::tidy::bugprone {
 
 /// Checks for functions that have safer, more secure replacements available, 
or
 /// are considered deprecated due to design flaws. This check relies heavily 
on,
@@ -45,8 +43,6 @@ class UnsafeFunctionsCheck : public ClangTidyCheck {
   std::optional IsAnnexKAvailable;
 };
 
-} // namespace bugprone
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::bugprone
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_UNSAFEFUNCTIONSCHECK_H



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


[clang-tools-extra] 87c4113 - [clang-tidy][NFC] Fix modernize-use-using findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:10Z
New Revision: 87c4113708b88ef20d3cac96e2fd43e5c3eabf91

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

LOG: [clang-tidy][NFC] Fix modernize-use-using findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyModule.h
clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/FileExtensionsSet.h
clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
clang-tools-extra/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/clang-tidy/utils/UsingInserter.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 3fd1153eb721a9..ca48388e85a99e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -349,7 +349,7 @@ setStaticAnalyzerCheckerOpts(const ClangTidyOptions ,
   }
 }
 
-typedef std::vector> CheckersList;
+using CheckersList = std::vector>;
 
 static CheckersList getAnalyzerCheckersAndPackages(ClangTidyContext ,
bool IncludeExperimental) {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyModule.h 
b/clang-tools-extra/clang-tidy/ClangTidyModule.h
index 0e55c1ef9dfead..28f54331755a7a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModule.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModule.h
@@ -70,7 +70,7 @@ class ClangTidyCheckFactories {
   std::vector>
   createChecksForLanguage(ClangTidyContext *Context) const;
 
-  typedef llvm::StringMap FactoryMap;
+  using FactoryMap = llvm::StringMap;
   FactoryMap::const_iterator begin() const { return Factories.begin(); }
   FactoryMap::const_iterator end() const { return Factories.end(); }
   bool empty() const { return Factories.empty(); }

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h 
b/clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h
index 30ffe1818431be..78d914bfedbc94 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyModuleRegistry.h
@@ -14,7 +14,7 @@
 
 namespace clang::tidy {
 
-typedef llvm::Registry ClangTidyModuleRegistry;
+using ClangTidyModuleRegistry = llvm::Registry;
 
 } // namespace clang::tidy
 

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index b3b714353642bd..e20a7d734a199c 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -30,7 +30,7 @@ struct FileFilter {
   std::string Name;
 
   /// LineRange is a pair (inclusive).
-  typedef std::pair LineRange;
+  using LineRange = std::pair;
 
   /// A list of line ranges in this file, for which we show warnings.
   std::vector LineRanges;
@@ -118,13 +118,13 @@ struct ClangTidyOptions {
 /// files to disambiguate local vs global value from 
diff erent levels.
 unsigned Priority = 0;
   };
-  typedef std::pair StringPair;
-  typedef llvm::StringMap OptionMap;
+  using StringPair = std::pair;
+  using OptionMap = llvm::StringMap;
 
   /// Key-value mapping used to store check-specific options.
   OptionMap CheckOptions;
 
-  typedef std::vector ArgList;
+  using ArgList = std::vector;
 
   /// Add extra compilation arguments to the end of the list.
   std::optional ExtraArgs;
@@ -165,7 +165,7 @@ class ClangTidyOptionsProvider {
   ///   commandline option is specified, clang-tidy will ignore the
   ///   configuration file.
   ///* '-checks' commandline option.
-  typedef std::pair OptionsSource;
+  using OptionsSource = std::pair;
 
   /// Returns an ordered vector of OptionsSources, in order of increasing
   /// priority.
@@ -199,9 +199,7 @@ class FileOptionsBaseProvider : public 
DefaultOptionsProvider {
 protected:
   // A pair of configuration file base name and a function parsing
   // configuration from text in the corresponding format.
-  typedef std::pair(
- llvm::MemoryBufferRef)>>
-  ConfigFileHandler;
+  using ConfigFileHandler = std::pair (llvm::MemoryBufferRef)>>;
 
   /// Configuration file handlers listed in the order of priority.
   ///
@@ -220,7 +218,7 @@ class FileOptionsBaseProvider : public 
DefaultOptionsProvider {
   ///
   /// With the order of handlers shown above, the ".my-tidy-config" file would
   /// take precedence over ".clang-tidy" if both reside in the same directory.
-  typedef std::vector ConfigFileHandlers;
+  using ConfigFileHandlers = std::vector;
 
   

[clang-tools-extra] ac80017 - [clang-tidy][NFC] Fix modernize-use-emplace findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: ac80017522241a30ed6b87273e1a3b39fb73c6dc

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

LOG: [clang-tidy][NFC] Fix modernize-use-emplace findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
clang-tools-extra/clang-tidy/utils/UsingInserter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index 7d4659c1eaac43..9dacf1562429ce 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -199,11 +199,12 @@ void IncludeModernizePPCallbacks::InclusionDirective(
   // 3. Do nothing and let the user deal with the migration himself.
   SourceLocation DiagLoc = FilenameRange.getBegin();
   if (CStyledHeaderToCxx.count(FileName) != 0) {
-IncludesToBeProcessed.push_back(
+IncludesToBeProcessed.emplace_back(
 IncludeMarker{CStyledHeaderToCxx[FileName], FileName,
   FilenameRange.getAsRange(), DiagLoc});
   } else if (DeleteHeaders.count(FileName) != 0) {
-IncludesToBeProcessed.push_back(
+IncludesToBeProcessed.emplace_back(
+// NOLINTNEXTLINE(modernize-use-emplace) - false-positive
 IncludeMarker{std::string{}, FileName,
   SourceRange{HashLoc, FilenameRange.getEnd()}, DiagLoc});
   }

diff  --git a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
index b1e1189d4ed775..660996aba7b70d 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
@@ -39,10 +39,10 @@ UseStdPrintCheck::UseStdPrintCheck(StringRef Name, 
ClangTidyContext *Context)
   MaybeHeaderToInclude(Options.get("PrintHeader")) {
 
   if (PrintfLikeFunctions.empty() && FprintfLikeFunctions.empty()) {
-PrintfLikeFunctions.push_back("::printf");
-PrintfLikeFunctions.push_back("absl::PrintF");
-FprintfLikeFunctions.push_back("::fprintf");
-FprintfLikeFunctions.push_back("absl::FPrintF");
+PrintfLikeFunctions.emplace_back("::printf");
+PrintfLikeFunctions.emplace_back("absl::PrintF");
+FprintfLikeFunctions.emplace_back("::fprintf");
+FprintfLikeFunctions.emplace_back("absl::FPrintF");
   }
 
   if (!MaybeHeaderToInclude && (ReplacementPrintFunction == "std::print" ||

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
index 5bf77bb8600642..57f13db078020a 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -35,9 +35,9 @@ RedundantStringCStrCheck::RedundantStringCStrCheck(StringRef 
Name,
   StringParameterFunctions(utils::options::parseStringList(
   Options.get("StringParameterFunctions", ""))) {
   if (getLangOpts().CPlusPlus20)
-StringParameterFunctions.push_back("::std::format");
+StringParameterFunctions.emplace_back("::std::format");
   if (getLangOpts().CPlusPlus23)
-StringParameterFunctions.push_back("::std::print");
+StringParameterFunctions.emplace_back("::std::print");
 }
 
 void RedundantStringCStrCheck::registerMatchers(

diff  --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp 
b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
index d9e0f3fc0f61b7..3a2c16ff05dae9 100644
--- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
@@ -53,7 +53,7 @@ std::optional 
UsingInserter::createUsingDeclaration(
  Statement, Context)
.empty();
   if (AlreadyHasUsingDecl) {
-AddedUsing.emplace(NameInFunction(Function, QualifiedName.str()));
+AddedUsing.emplace(Function, QualifiedName.str());
 return std::nullopt;
   }
   // Find conflicting declarations and references.
@@ -69,7 +69,7 @@ std::optional 
UsingInserter::createUsingDeclaration(
   std::string Declaration =
   (llvm::Twine("\nusing ") + QualifiedName + ";").str();
 
-  AddedUsing.emplace(std::make_pair(Function, QualifiedName.str()));
+  AddedUsing.emplace(Function, QualifiedName.str());
   return FixItHint::CreateInsertion(InsertLoc, Declaration);
 }
 



___
cfe-commits mailing list

[clang-tools-extra] b6ea164 - [clang-tidy][NFC] Fix misc-unused-using-decls findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: b6ea16431b58a1d15d2cb7583062ae8d10652329

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

LOG: [clang-tidy][NFC] Fix misc-unused-using-decls findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
index 7c63c8441c33cc..183beb6bfb87d8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
@@ -22,7 +22,6 @@ namespace clang::tidy::bugprone {
 using ast_matchers::MatchFinder;
 using dataflow::UncheckedOptionalAccessDiagnoser;
 using dataflow::UncheckedOptionalAccessModel;
-using dataflow::UncheckedOptionalAccessModelOptions;
 
 static constexpr llvm::StringLiteral FuncID("fun");
 



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


[clang-tools-extra] 95320b5 - [clang-tidy][NFC] Fix modernize-loop-convert findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: 95320b5ff7a8a66c1ce97da2f9c791082d732386

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

LOG: [clang-tidy][NFC] Fix modernize-loop-convert findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index 598a9ae4433ce1..4628c09f196996 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -364,9 +364,7 @@ static void addFunctionCallArgs(ArrayRef Args,
 llvm::raw_ostream ) {
   StringRef Delimiter = "";
 
-  for (int I = 0, Size = Args.size(); I < Size; ++I) {
-const BindArgument  = Args[I];
-
+  for (const BindArgument  : Args) {
 Stream << Delimiter;
 
 if (B.Kind == BK_Placeholder) {



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


[clang-tools-extra] 09c1b2e - [clang-tidy][NFC] Fix cppcoreguidelines-prefer-member-initializer findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: 09c1b2e141d06f293e150b890165713213e397bc

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

LOG: [clang-tidy][NFC] Fix cppcoreguidelines-prefer-member-initializer findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index fa7285744be890..d8c7c52ba89ace 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -1952,13 +1952,12 @@ struct FormattedConversionSequence {
   /// The formatted sequence is trivial if it is "Ty1 -> Ty2", but Ty1 and
   /// Ty2 are the types that are shown in the code. A trivial diagnostic
   /// does not need to be printed.
-  bool Trivial;
+  bool Trivial = true;
 
   FormattedConversionSequence(const PrintingPolicy ,
   StringRef StartTypeAsDiagnosed,
   const model::ConversionSequence ,
   StringRef DestinationTypeAsDiagnosed) {
-Trivial = true;
 llvm::raw_string_ostream OS{DiagnosticText};
 
 // Print the type name as it is printed in other places in the diagnostic.



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


[clang-tools-extra] 76284be - [clang-tidy][NFC] Fix bugprone-optional-value-conversion findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: 76284beb23a3a94682d251fff0261d4db5261408

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

LOG: [clang-tidy][NFC] Fix bugprone-optional-value-conversion findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 9573cc3b7d6b3c..8b261268449cf2 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -94,7 +94,7 @@ static std::optional getAsBool(StringRef Value,
  const llvm::Twine ) {
 
   if (std::optional Parsed = llvm::yaml::parseBool(Value))
-return *Parsed;
+return Parsed;
   // To maintain backwards compatability, we support parsing numbers as
   // booleans, even though its not supported in YAML.
   long long Number;



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


[clang-tools-extra] 8ba103c - [clang-tidy][NFC] Fix readability-static-accessed-through-instance findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: 8ba103ca681670750e0929f74ab72870a871202f

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

LOG: [clang-tidy][NFC] Fix readability-static-accessed-through-instance findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
index bda9b9ec34e638..74ef6e67f00f34 100644
--- a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -43,11 +43,11 @@ std::optional makeCharacterLiteral(const 
StringLiteral *Literal,
 
   // Now replace the " with '.
   std::string::size_type Pos = Result.find_first_of('"');
-  if (Pos == Result.npos)
+  if (Pos == std::string::npos)
 return std::nullopt;
   Result[Pos] = '\'';
   Pos = Result.find_last_of('"');
-  if (Pos == Result.npos)
+  if (Pos == std::string::npos)
 return std::nullopt;
   Result[Pos] = '\'';
   return Result;

diff  --git 
a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
index ca4f6ad409b08c..40ea915a332990 100644
--- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -27,12 +27,12 @@ std::optional makeCharacterLiteral(const 
StringLiteral *Literal) {
   }
   // Now replace the " with '.
   auto OpenPos = Result.find_first_of('"');
-  if (OpenPos == Result.npos)
+  if (OpenPos == std::string::npos)
 return std::nullopt;
   Result[OpenPos] = '\'';
 
   auto ClosePos = Result.find_last_of('"');
-  if (ClosePos == Result.npos)
+  if (ClosePos == std::string::npos)
 return std::nullopt;
   Result[ClosePos] = '\'';
 

diff  --git 
a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index 07cb07f053729b..89e0c89fa933ae 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -59,9 +59,9 @@ static StringRef negatedOperator(const BinaryOperator *BinOp) 
{
   const BinaryOperatorKind Opcode = BinOp->getOpcode();
   for (auto NegatableOp : Opposites) {
 if (Opcode == NegatableOp.first)
-  return BinOp->getOpcodeStr(NegatableOp.second);
+  return BinaryOperator::getOpcodeStr(NegatableOp.second);
 if (Opcode == NegatableOp.second)
-  return BinOp->getOpcodeStr(NegatableOp.first);
+  return BinaryOperator::getOpcodeStr(NegatableOp.first);
   }
   return {};
 }

diff  --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
index dcdbcd36cba3c6..a40433e38a041d 100644
--- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -34,7 +34,7 @@ std::string escapeForDiagnostic(std::string ToEscape) {
   // Optimize for the common case that the string does not contain `%` at the
   // cost of an extra scan over the string in the slow case.
   auto Pos = ToEscape.find('%');
-  if (Pos == ToEscape.npos)
+  if (Pos == std::string::npos)
 return ToEscape;
 
   std::string Result;



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


[clang-tools-extra] f1f1633 - [clang-tidy][NFC] Fix readability-inconsistent-declaration-parameter-name findings

2023-08-27 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-08-27T08:52:09Z
New Revision: f1f16331bd6810a574100a31d369921c1f4adcaf

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

LOG: [clang-tidy][NFC] Fix readability-inconsistent-declaration-parameter-name 
findings

Fix issues found by clang-tidy in clang-tidy source directory.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.h
clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
clang-tools-extra/clang-tidy/google/IntegerTypesCheck.h
clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.h
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.h
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.h
clang-tools-extra/clang-tidy/objc/ForbiddenSubclassingCheck.h
clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.h

clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
clang-tools-extra/clang-tidy/readability/NamespaceCommentCheck.h
clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.h
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.h
clang-tools-extra/clang-tidy/utils/FixItHintUtils.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 18169deaa0681e..9573cc3b7d6b3c 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -22,14 +22,15 @@ ClangTidyCheck::ClangTidyCheck(StringRef CheckName, 
ClangTidyContext *Context)
   assert(!CheckName.empty());
 }
 
-DiagnosticBuilder ClangTidyCheck::diag(SourceLocation Loc, StringRef Message,
+DiagnosticBuilder ClangTidyCheck::diag(SourceLocation Loc,
+   StringRef Description,
DiagnosticIDs::Level Level) {
-  return Context->diag(CheckName, Loc, Message, Level);
+  return Context->diag(CheckName, Loc, Description, Level);
 }
 
-DiagnosticBuilder ClangTidyCheck::diag(StringRef Message,
+DiagnosticBuilder ClangTidyCheck::diag(StringRef Description,
DiagnosticIDs::Level Level) {
-  return Context->diag(CheckName, Message, Level);
+  return Context->diag(CheckName, Description, Level);
 }
 
 DiagnosticBuilder

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 41a210a83a84f3..fc88a186484365 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -342,10 +342,10 @@ void ClangTidyDiagnosticConsumer::finalizeLastError() {
 namespace clang::tidy {
 
 const llvm::StringMap *
-getFixIt(const tooling::Diagnostic , bool GetFixFromNotes) {
+getFixIt(const tooling::Diagnostic , bool AnyFix) {
   if (!Diagnostic.Message.Fix.empty())
 return 
-  if (!GetFixFromNotes)
+  if (!AnyFix)
 return nullptr;
   const llvm::StringMap *Result = nullptr;
   for (const auto  : Diagnostic.Notes) {

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index d3e15e7b2915ea..962f7dc32de3e6 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -87,10 +87,10 @@ class ClangTidyContext {
   /// tablegen'd diagnostic IDs.
   /// FIXME: Figure out a way to manage ID spaces.
   DiagnosticBuilder diag(StringRef CheckName, SourceLocation Loc,
- StringRef Message,
+ StringRef Description,
  DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
 
-  DiagnosticBuilder diag(StringRef CheckName, StringRef Message,
+  DiagnosticBuilder diag(StringRef CheckName, StringRef Description,
  DiagnosticIDs::Level Level = DiagnosticIDs::Warning);
 
   DiagnosticBuilder diag(const tooling::Diagnostic );

diff  --git 

[clang] 3a14993 - Fix typos in documentation

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T00:18:14-07:00
New Revision: 3a14993fa428c67634c979107ca6ddaafeb7037b

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

LOG: Fix typos in documentation

Added: 


Modified: 

clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.insecureAPI.DeprecatedOrUnsafeBufferHandling.rst
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/developer-docs/nullability.rst
lldb/docs/python_api_enums.rst
llvm/docs/AMDGPUUsage.rst
llvm/docs/Atomics.rst
llvm/docs/Coroutines.rst
llvm/docs/GlobalISel/MIRPatterns.rst
llvm/docs/MyFirstTypoFix.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.insecureAPI.DeprecatedOrUnsafeBufferHandling.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.insecureAPI.DeprecatedOrUnsafeBufferHandling.rst
index 8a8880805af702..7b365346b4b39f 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.insecureAPI.DeprecatedOrUnsafeBufferHandling.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/clang-analyzer/security.insecureAPI.DeprecatedOrUnsafeBufferHandling.rst
@@ -5,7 +5,7 @@
 clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
 
 
-Warn on uses of unsecure or deprecated buffer manipulating functions.
+Warn on uses of insecure or deprecated buffer manipulating functions.
 
 The `clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling` 
check is an alias, please see
 `Clang Static Analyzer Available Checkers

diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index a51dea03fcb655..e739ecf3b9df4a 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3163,7 +3163,7 @@ avoid cache misses when the developer has a good 
understanding of which data
 are going to be used next. ``addr`` is the address that needs to be brought 
into
 the cache. ``rw`` indicates the expected access mode: ``0`` for *read* and 
``1``
 for *write*. In case of *read write* access, ``1`` is to be used. ``locality``
-indicates the expected persistance of data in cache, from ``0`` which means 
that
+indicates the expected persistence of data in cache, from ``0`` which means 
that
 data can be discarded from cache after its next use to ``3`` which means that
 data is going to be reused a lot once in cache. ``1`` and ``2`` provide
 intermediate behavior between these two extremes.

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1ba4215e603349..1ed144cea09786 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -221,7 +221,7 @@ Bug Fixes to C++ Support
 
 - Expressions producing ``nullptr`` are correctly evaluated
   by the constant interpreter when appearing as the operand
-  of a binary comparision.
+  of a binary comparison.
   (`#64923 _``)
 
 - Fix a crash when an immediate invocation is not a constant expression

diff  --git a/clang/docs/analyzer/developer-docs/nullability.rst 
b/clang/docs/analyzer/developer-docs/nullability.rst
index 70e1958634ad9f..dc24793a8f4fc0 100644
--- a/clang/docs/analyzer/developer-docs/nullability.rst
+++ b/clang/docs/analyzer/developer-docs/nullability.rst
@@ -62,7 +62,7 @@ Other Issues to keep in mind/take care of:
 * Even though the method might return a nonnull pointer, when it was sent 
to a nullable pointer the return type will be nullable.
* The result is nullable unless the receiver is known to be non null.
 
-  * Sending a message to a unspecified or nonnull pointer
+  * Sending a message to an unspecified or nonnull pointer
 
 * If the pointer is not assumed to be nil, we should be optimistic and use 
the nullability implied by the method.
 

diff  --git a/lldb/docs/python_api_enums.rst b/lldb/docs/python_api_enums.rst
index e34f4656b6ad88..b6a2497ea878e0 100644
--- a/lldb/docs/python_api_enums.rst
+++ b/lldb/docs/python_api_enums.rst
@@ -504,7 +504,7 @@ ValueType
 
 .. py:data:: eValueTypeVariableArgument
 
-   Funfction argument variable.
+   Function argument variable.
 
 .. py:data:: eValueTypeVariableLocal
 

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index c3b3927c4f0f7e..0db4cdf0a5db44 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -966,10 +966,10 @@ The AMDGPU backend implements the following LLVM IR 
intrinsics.
   LLVM Intrinsic   Description
   ==   
==
   llvm.amdgcn.sqrt

[clang] c81ff8b - [Analysis] Use DenseMap::lookup (NFC)

2023-08-27 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-08-27T00:18:17-07:00
New Revision: c81ff8b7007428ab272335b7aa48fbb3e33a42d3

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

LOG: [Analysis] Use DenseMap::lookup (NFC)

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index f586c0ad2caf98..df89ab43638085 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -895,10 +895,7 @@ class DeclUseTracker {
   }
 
   const DeclStmt *lookupDecl(const VarDecl *VD) const {
-auto It = Defs.find(VD);
-if (It == Defs.end())
-  return nullptr;
-return It->second;
+return Defs.lookup(VD);
   }
 };
 } // namespace



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