[PATCH] D156344: Disable call to fma for soft-float

2023-08-13 Thread Kishan Parmar via Phabricator via cfe-commits
long5hot added a comment.

In D156344#4583559 , @shchenz wrote:

> compiler-rt builtins library should not just undefining fma for PPC, right 
> (see https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html)? 
> If so, maybe we should at least first try not generating fma for soft-float 
> at the first place where fmul + fadd is fused, like `tryEmitFMulAdd` in clang 
> front end?

I actually raised D154605  for that one, but 
it's only for X86.
I was relying on target-features containing "+fma", which is wrong. The review 
was raised just to get feedback from community working on various targets.
Plan is to disable fma-intrinsic from IR for all targets which doesn't support 
fma.


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

https://reviews.llvm.org/D156344

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


[PATCH] D157833: [C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty

2023-08-13 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 549795.

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

https://reviews.llvm.org/D157833

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
  clang/test/CodeGenCoroutines/pr56301.cpp

Index: clang/test/CodeGenCoroutines/pr56301.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/pr56301.cpp
@@ -0,0 +1,85 @@
+// An end-to-end test to make sure things get processed correctly.
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s -O3 | \
+// RUN: FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+struct SomeAwaitable {
+  // Resume the supplied handle once the awaitable becomes ready,
+  // returning a handle that should be resumed now for the sake of symmetric transfer.
+  // If the awaitable is already ready, return an empty handle without doing anything.
+  //
+  // Defined in another translation unit. Note that this may contain
+  // code that synchronizees with another thread.
+  std::coroutine_handle<> Register(std::coroutine_handle<>);
+};
+
+// Defined in another translation unit.
+void DidntSuspend();
+
+struct Awaiter {
+  SomeAwaitable&& awaitable;
+  bool suspended;
+
+  bool await_ready() { return false; }
+
+  std::coroutine_handle<> await_suspend(const std::coroutine_handle<> h) {
+// Assume we will suspend unless proven otherwise below. We must do
+// this *before* calling Register, since we may be destroyed by another
+// thread asynchronously as soon as we have registered.
+suspended = true;
+
+// Attempt to hand off responsibility for resuming/destroying the coroutine.
+const auto to_resume = awaitable.Register(h);
+
+if (!to_resume) {
+  // The awaitable is already ready. In this case we know that Register didn't
+  // hand off responsibility for the coroutine. So record the fact that we didn't
+  // actually suspend, and tell the compiler to resume us inline.
+  suspended = false;
+  return h;
+}
+
+// Resume whatever Register wants us to resume.
+return to_resume;
+  }
+
+  void await_resume() {
+// If we didn't suspend, make note of that fact.
+if (!suspended) {
+  DidntSuspend();
+}
+  }
+};
+
+struct MyTask{
+  struct promise_type {
+MyTask get_return_object() { return {}; }
+std::suspend_never initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception();
+
+Awaiter await_transform(SomeAwaitable&& awaitable) {
+  return Awaiter{static_cast(awaitable)};
+}
+  };
+};
+
+MyTask FooBar() {
+  co_await SomeAwaitable();
+}
+
+// CHECK-LABEL: @_Z6FooBarv
+// CHECK: %[[to_resume:.*]] = {{.*}}call ptr @_ZN13SomeAwaitable8RegisterESt16coroutine_handleIvE
+// CHECK-NEXT: %[[to_bool:.*]] = icmp eq ptr %[[to_resume]], null
+// CHECK-NEXT: br i1 %[[to_bool]], label %[[then:.*]], label %[[else:.*]]
+
+// CHECK: [[then]]:
+// We only access the coroutine frame conditionally as the sources did.
+// CHECK:   store i8 0,
+// CHECK-NEXT: br label %[[else]]
+
+// CHECK: [[else]]:
+// No more access to the coroutine frame until suspended.
+// CHECK-NOT: store
+// CHECK: }
Index: clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
@@ -0,0 +1,207 @@
+// Tests that we can mark await-suspend as noinline correctly.
+//
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s \
+// RUN: -disable-llvm-passes | FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+struct Task {
+  struct promise_type {
+struct FinalAwaiter {
+  bool await_ready() const noexcept { return false; }
+  template 
+  std::coroutine_handle<> await_suspend(std::coroutine_handle h) noexcept {
+return h.promise().continuation;
+  }
+  void await_resume() noexcept {}
+};
+
+Task get_return_object() noexcept {
+  return std::coroutine_handle::from_promise(*this);
+}
+
+std::suspend_always initial_suspend() noexcept { return {}; }
+FinalAwaiter final_suspend() noexcept { return {}; }
+void unhandled_exception() noexcept {}
+void return_void() noexcept {}
+
+std::coroutine_handle<> continuation;
+  };
+
+  Task(std::coroutine_handle handle);
+  ~Task();
+
+private:
+  std::coroutine_handle handle;
+};
+
+struct StatefulAwaiter {
+int value;
+bool await_ready() const noexcept { return false; }
+template 
+void await_suspend(std::coroutine_handle h) noexcept {}
+void await_resume() noexcept {}
+};
+
+typedef std::suspend_always NoStateAwaiter;
+using AnotherStatefulAwaiter = StatefulAwaiter;
+
+template 

[PATCH] D157833: [C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty

2023-08-13 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/CodeGen/CGCoroutine.cpp:158-169
+assert(Result && "Why can't we find the record type from the common "
+ "expression of a coroutine suspend expression? "
+ "Maybe we missed some types or the Sema get something "
+ "incorrect");
+
+// In a release build without assertions enabled, return false directly
+// to give users better user experience. It doesn't matter with the

Note that the may cause a crash if there are some types we are not able to 
covered. This is intentional. Since such crash is easy to fix by adding new 
type to the TypeVisitor. I guess this may be understandable since the type 
system of clang frontend (or should I say C++?) is really complex.

Also note that this only matters with people who enabled assertions, possibly 
developers or testers.

For end users who use a clean release build, it is completely OK to not match 
the type. They may only need to pay 1 bit memory overhead for that. I feel this 
is better for the user experience.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157833

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


[PATCH] D157833: [C++20] [Coroutines] Mark await_suspend as noinline if the awaiter is not empty

2023-08-13 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: rjmccall, ilya-biryukov, weiwang, cor3ntin, 
clang-language-wg.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Close https://github.com/llvm/llvm-project/issues/56301
Close https://github.com/llvm/llvm-project/issues/64151

See the summary and the discussion of https://reviews.llvm.org/D157070 to get 
the full context.

As @rjmccall pointed out, the key point of the root cause is that currently we 
didn't implement the semantics well ("after the await-ready returns false, the 
coroutine is considered to be suspended ") well. Since the semantics implies 
that we (the compiler) shouldn't write the spills into the coroutine frame in 
the await_suspend. Now it is possible due to some combinations of the 
optimizations so the semantics are broken. And the inlining is the root 
optimization of such optimizations. So in this patch, we tried to add the 
`noinline` attribute to the await_suspend call.

Also as an optimization, we don't add the `noinline` attribute to the 
await_suspend call if the awaiter is an empty class. This should be correct 
since the programmers can't access the local variables in await_suspend if the 
awaiter is empty. I think this is necessary for the performance since it is 
pretty common.

Another potential optimization chance is to convert the remove noinline 
attribute in CoroSplit so that we can still inline it finally. But I didn't do 
that in this patch since I want to separate the llvm patches and clang patches 
as much as possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157833

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCoroutines/coro-awaiter-noinline-suspend.cpp
  clang/test/CodeGenCoroutines/pr56301.cpp

Index: clang/test/CodeGenCoroutines/pr56301.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/pr56301.cpp
@@ -0,0 +1,85 @@
+// An end-to-end test to make sure things get processed correctly.
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -emit-llvm -o - %s -O3 | \
+// RUN: FileCheck %s
+
+#include "Inputs/coroutine.h"
+
+struct SomeAwaitable {
+  // Resume the supplied handle once the awaitable becomes ready,
+  // returning a handle that should be resumed now for the sake of symmetric transfer.
+  // If the awaitable is already ready, return an empty handle without doing anything.
+  //
+  // Defined in another translation unit. Note that this may contain
+  // code that synchronizees with another thread.
+  std::coroutine_handle<> Register(std::coroutine_handle<>);
+};
+
+// Defined in another translation unit.
+void DidntSuspend();
+
+struct Awaiter {
+  SomeAwaitable&& awaitable;
+  bool suspended;
+
+  bool await_ready() { return false; }
+
+  std::coroutine_handle<> await_suspend(const std::coroutine_handle<> h) {
+// Assume we will suspend unless proven otherwise below. We must do
+// this *before* calling Register, since we may be destroyed by another
+// thread asynchronously as soon as we have registered.
+suspended = true;
+
+// Attempt to hand off responsibility for resuming/destroying the coroutine.
+const auto to_resume = awaitable.Register(h);
+
+if (!to_resume) {
+  // The awaitable is already ready. In this case we know that Register didn't
+  // hand off responsibility for the coroutine. So record the fact that we didn't
+  // actually suspend, and tell the compiler to resume us inline.
+  suspended = false;
+  return h;
+}
+
+// Resume whatever Register wants us to resume.
+return to_resume;
+  }
+
+  void await_resume() {
+// If we didn't suspend, make note of that fact.
+if (!suspended) {
+  DidntSuspend();
+}
+  }
+};
+
+struct MyTask{
+  struct promise_type {
+MyTask get_return_object() { return {}; }
+std::suspend_never initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception();
+
+Awaiter await_transform(SomeAwaitable&& awaitable) {
+  return Awaiter{static_cast(awaitable)};
+}
+  };
+};
+
+MyTask FooBar() {
+  co_await SomeAwaitable();
+}
+
+// CHECK-LABEL: @_Z6FooBarv
+// CHECK: %[[to_resume:.*]] = {{.*}}call ptr @_ZN13SomeAwaitable8RegisterESt16coroutine_handleIvE
+// CHECK-NEXT: %[[to_bool:.*]] = icmp eq ptr %[[to_resume]], null
+// CHECK-NEXT: br i1 %[[to_bool]], label %[[then:.*]], label %[[else:.*]]
+
+// CHECK: [[then]]:
+// We only access the coroutine frame conditionally as the sources did.
+// CHECK:   store i8 0,
+// CHECK-NEXT: br label %[[else]]
+
+// CHECK: [[else]]:
+// No more access to the coroutine frame until suspended.
+// CHECK-NOT: store
+// CHECK: }
Index: 

[PATCH] D157474: [RISCV] Add missing Xsfvcp extension check in clang sema

2023-08-13 Thread Brandon Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
4vtomat marked an inline comment as done.
Closed by commit rGa23d65ac89ce: [RISCV] Add missing Xsfvcp extension check in 
clang sema (authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157474

Files:
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/test/Sema/rvv-required-features-invalid.c
  clang/test/Sema/rvv-required-features.c


Index: clang/test/Sema/rvv-required-features.c
===
--- /dev/null
+++ clang/test/Sema/rvv-required-features.c
@@ -0,0 +1,19 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +xsfvcp 
%s -fsyntax-only -verify
+
+// expected-no-diagnostics
+
+#include 
+#include 
+
+vint8m1_t test_vloxei64_v_i8m1(const int8_t *base, vuint64m8_t bindex, size_t 
vl) {
+  return __riscv_vloxei64(base, bindex, vl);
+}
+
+void test_vsoxei64_v_i8m1(int8_t *base, vuint64m8_t bindex, vint8m1_t value, 
size_t vl) {
+  __riscv_vsoxei64(base, bindex, value, vl);
+}
+
+void test_sf_vc_x_se_u64m1(uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_x_se_u64m1(1, 1, 1, rs1, vl);
+}
Index: clang/test/Sema/rvv-required-features-invalid.c
===
--- /dev/null
+++ clang/test/Sema/rvv-required-features-invalid.c
@@ -0,0 +1,17 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +v %s -fsyntax-only -verify
+
+#include 
+#include 
+
+vint8m1_t test_vloxei64_v_i8m1(const int8_t *base, vuint64m8_t bindex, size_t 
vl) {
+  return __riscv_vloxei64(base, bindex, vl); // expected-error {{call to 
undeclared function '__riscv_vloxei64'}} expected-error {{returning 'int' from 
a function with incompatible result type 'vint8m1_t'}}
+}
+
+void test_vsoxei64_v_i8m1(int8_t *base, vuint64m8_t bindex, vint8m1_t value, 
size_t vl) {
+  __riscv_vsoxei64(base, bindex, value, vl); // expected-error {{call to 
undeclared function '__riscv_vsoxei64'}}
+}
+
+void test_xsfvcp_sf_vc_x_se_u64m1(uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_x_se_u64m1(1, 1, 1, rs1, vl); // expected-error {{call to 
undeclared function '__riscv_sf_vc_x_se_u64m1'}}
+}
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -202,10 +202,20 @@
 void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
 ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo  = Context.getTargetInfo();
-  bool HasRV64 = TI.hasFeature("64bit");
+  static const std::pair FeatureCheckList[] = {
+  {"64bit", RVV_REQ_RV64},
+  {"xsfvcp", RVV_REQ_Xsfvcp}};
+
   // Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
   // in RISCVVEmitter.cpp.
   for (auto  : Recs) {
+// Check requirements.
+if (llvm::any_of(FeatureCheckList, [&](const auto ) {
+  return (Record.RequiredExtensions & Item.second) == Item.second &&
+ !TI.hasFeature(Item.first);
+}))
+  continue;
+
 // Create Intrinsics for each type and LMUL.
 BasicType BaseType = BasicType::Unknown;
 ArrayRef BasicProtoSeq =
@@ -251,11 +261,6 @@
   if ((BaseTypeI & Record.TypeRangeMask) != BaseTypeI)
 continue;
 
-  // Check requirement.
-  if (((Record.RequiredExtensions & RVV_REQ_RV64) == RVV_REQ_RV64) &&
-  !HasRV64)
-continue;
-
   // Expanded with different LMUL.
   for (int Log2LMUL = -3; Log2LMUL <= 3; Log2LMUL++) {
 if (!(Record.Log2LMULMask & (1 << (Log2LMUL + 3


Index: clang/test/Sema/rvv-required-features.c
===
--- /dev/null
+++ clang/test/Sema/rvv-required-features.c
@@ -0,0 +1,19 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +xsfvcp %s -fsyntax-only -verify
+
+// expected-no-diagnostics
+
+#include 
+#include 
+
+vint8m1_t test_vloxei64_v_i8m1(const int8_t *base, vuint64m8_t bindex, size_t vl) {
+  return __riscv_vloxei64(base, bindex, vl);
+}
+
+void test_vsoxei64_v_i8m1(int8_t *base, vuint64m8_t bindex, vint8m1_t value, size_t vl) {
+  __riscv_vsoxei64(base, bindex, value, vl);
+}
+
+void test_sf_vc_x_se_u64m1(uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_x_se_u64m1(1, 1, 1, rs1, vl);
+}
Index: clang/test/Sema/rvv-required-features-invalid.c
===
--- /dev/null
+++ clang/test/Sema/rvv-required-features-invalid.c
@@ -0,0 +1,17 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +v %s -fsyntax-only -verify
+
+#include 
+#include 
+
+vint8m1_t 

[clang] a23d65a - [RISCV] Add missing Xsfvcp extension check in clang sema

2023-08-13 Thread via cfe-commits

Author: 4vtomat
Date: 2023-08-13T22:33:52-07:00
New Revision: a23d65ac89ce1263b58690fa051e81d7cd0b139d

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

LOG: [RISCV] Add missing Xsfvcp extension check in clang sema

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

Added: 
clang/test/Sema/rvv-required-features-invalid.c
clang/test/Sema/rvv-required-features.c

Modified: 
clang/lib/Sema/SemaRISCVVectorLookup.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaRISCVVectorLookup.cpp 
b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
index eec2bc11e35d9e..486f901a6cf1e6 100644
--- a/clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ b/clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -202,10 +202,20 @@ class RISCVIntrinsicManagerImpl : public 
sema::RISCVIntrinsicManager {
 void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
 ArrayRef Recs, IntrinsicKind K) {
   const TargetInfo  = Context.getTargetInfo();
-  bool HasRV64 = TI.hasFeature("64bit");
+  static const std::pair FeatureCheckList[] = {
+  {"64bit", RVV_REQ_RV64},
+  {"xsfvcp", RVV_REQ_Xsfvcp}};
+
   // Construction of RVVIntrinsicRecords need to sync with createRVVIntrinsics
   // in RISCVVEmitter.cpp.
   for (auto  : Recs) {
+// Check requirements.
+if (llvm::any_of(FeatureCheckList, [&](const auto ) {
+  return (Record.RequiredExtensions & Item.second) == Item.second &&
+ !TI.hasFeature(Item.first);
+}))
+  continue;
+
 // Create Intrinsics for each type and LMUL.
 BasicType BaseType = BasicType::Unknown;
 ArrayRef BasicProtoSeq =
@@ -251,11 +261,6 @@ void RISCVIntrinsicManagerImpl::ConstructRVVIntrinsics(
   if ((BaseTypeI & Record.TypeRangeMask) != BaseTypeI)
 continue;
 
-  // Check requirement.
-  if (((Record.RequiredExtensions & RVV_REQ_RV64) == RVV_REQ_RV64) &&
-  !HasRV64)
-continue;
-
   // Expanded with 
diff erent LMUL.
   for (int Log2LMUL = -3; Log2LMUL <= 3; Log2LMUL++) {
 if (!(Record.Log2LMULMask & (1 << (Log2LMUL + 3

diff  --git a/clang/test/Sema/rvv-required-features-invalid.c 
b/clang/test/Sema/rvv-required-features-invalid.c
new file mode 100644
index 00..0d0d00764a31e3
--- /dev/null
+++ b/clang/test/Sema/rvv-required-features-invalid.c
@@ -0,0 +1,17 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +v %s -fsyntax-only -verify
+
+#include 
+#include 
+
+vint8m1_t test_vloxei64_v_i8m1(const int8_t *base, vuint64m8_t bindex, size_t 
vl) {
+  return __riscv_vloxei64(base, bindex, vl); // expected-error {{call to 
undeclared function '__riscv_vloxei64'}} expected-error {{returning 'int' from 
a function with incompatible result type 'vint8m1_t'}}
+}
+
+void test_vsoxei64_v_i8m1(int8_t *base, vuint64m8_t bindex, vint8m1_t value, 
size_t vl) {
+  __riscv_vsoxei64(base, bindex, value, vl); // expected-error {{call to 
undeclared function '__riscv_vsoxei64'}}
+}
+
+void test_xsfvcp_sf_vc_x_se_u64m1(uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_x_se_u64m1(1, 1, 1, rs1, vl); // expected-error {{call to 
undeclared function '__riscv_sf_vc_x_se_u64m1'}}
+}

diff  --git a/clang/test/Sema/rvv-required-features.c 
b/clang/test/Sema/rvv-required-features.c
new file mode 100644
index 00..c3b7965599e68f
--- /dev/null
+++ b/clang/test/Sema/rvv-required-features.c
@@ -0,0 +1,19 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +xsfvcp 
%s -fsyntax-only -verify
+
+// expected-no-diagnostics
+
+#include 
+#include 
+
+vint8m1_t test_vloxei64_v_i8m1(const int8_t *base, vuint64m8_t bindex, size_t 
vl) {
+  return __riscv_vloxei64(base, bindex, vl);
+}
+
+void test_vsoxei64_v_i8m1(int8_t *base, vuint64m8_t bindex, vint8m1_t value, 
size_t vl) {
+  __riscv_vsoxei64(base, bindex, value, vl);
+}
+
+void test_sf_vc_x_se_u64m1(uint64_t rs1, size_t vl) {
+  __riscv_sf_vc_x_se_u64m1(1, 1, 1, rs1, vl);
+}



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


[PATCH] D157793: [Headers] Add missing __need_ macros to stdarg.h

2023-08-13 Thread Ian Anderson via Phabricator via cfe-commits
iana added a comment.

In D157793#4583663 , @MaskRay wrote:

>> Apple needs a __need_ macro for va_list. Add one, and also ones for 
>> va_start/va_arg/va_end, __va_copy, va_copy.
>
> Do you have a link to the specification or the source that this is needed?

We need is so that our  doesn't have to redeclare 
va_list and doesn't pull in all of stdarg.h either. As far as I know there's no 
specification for this (or stddef.h) being include-able in pieces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157793

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


[PATCH] D157150: [Driver] Update BoolOption to handle Visibility. NFC

2023-08-13 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 once the https://reviews.llvm.org/D157151#4582109 "Default" naming 
discussion is agreed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157150

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


[PATCH] D157793: [Headers] Add missing __need_ macros to stdarg.h

2023-08-13 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Apple needs a __need_ macro for va_list. Add one, and also ones for 
> va_start/va_arg/va_end, __va_copy, va_copy.

Do you have a link to the specification or the source that this is needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157793

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


[PATCH] D157239: [clang-tidy] Implement bugprone-incorrect-enable-if

2023-08-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added a comment.

> Do you have plans to also detect the bugprone scenario described in the Notes 
> here?

I didn't have plans in this review, or in the immediate future after. I did 
name this check broadly as "bugprone-incorrect-enable-if," so I imagine this 
other scenario could go into this new check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157239

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


[clang] 9d0cf88 - [clang][doc] Mark _Float16 is support natively when Zfh or Zhinx is available

2023-08-13 Thread Jianjian GUAN via cfe-commits

Author: Jianjian GUAN
Date: 2023-08-14T11:27:15+08:00
New Revision: 9d0cf88e70860b29615253fbbd4d2d62eb08886a

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

LOG: [clang][doc] Mark _Float16 is support natively when Zfh or Zhinx is 
available

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index c771e3457af2b2..386ffa7b48eb93 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -814,6 +814,7 @@ to ``float``; see below for more information on this 
emulation.
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM



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


[PATCH] D157693: [clang][doc] Mark _Float16 is support natively when Zfh or Zhinx is available

2023-08-13 Thread Jianjian Guan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
jacquesguan marked an inline comment as done.
Closed by commit rG9d0cf88e7086: [clang][doc] Mark _Float16 is support natively 
when Zfh or Zhinx is available (authored by jacquesguan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157693

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -814,6 +814,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -814,6 +814,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157693: [clang][doc] Mark _Float16 is support natively when Zfh or Zhinx is available

2023-08-13 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D157693/new/

https://reviews.llvm.org/D157693

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


[PATCH] D157693: [clang][doc] Mark _Float16 is support natively when Zfh or Zhinx is available

2023-08-13 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan marked an inline comment as done.
jacquesguan added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:815
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh is available)
 

craig.topper wrote:
> Zhinx also
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157693

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


[PATCH] D157693: [clang][doc] Mark _Float16 is support natively when Zfh is available

2023-08-13 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan updated this revision to Diff 549779.
jacquesguan added a comment.

Add Zhinx.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157693

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -814,6 +814,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -814,6 +814,7 @@
   * AMDGPU (natively)
   * SPIR (natively)
   * X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
+  * RISC-V (natively if Zfh or Zhinx is available)
 
 * ``__bf16`` is supported on the following targets (currently never natively):
   * 32-bit ARM
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156205: wasm: link crt1 even in case of -shared

2023-08-13 Thread YAMAMOTO Takashi via Phabricator via cfe-commits
yamt marked an inline comment as done.
yamt added a comment.

can this land?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156205

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


[PATCH] D157239: [clang-tidy] Implement bugprone-incorrect-enable-if

2023-08-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter marked an inline comment as done.
ccotter added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp:61-62
+
+  FixItHint TypenameHint =
+  FixItHint::CreateInsertion(ElaboratedLoc->getBeginLoc(), "typename ");
+  FixItHint TypeHint =

PiotrZSL wrote:
> do we still need typename in C++20 in this context ?
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0634r3.html
Oh, I did not know that. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157239

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


[PATCH] D157239: [clang-tidy] Implement bugprone-incorrect-enable-if

2023-08-13 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 549777.
ccotter marked 9 inline comments as done.
ccotter added a comment.

- Fix docs, handle C++20 simplification


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157239

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-if.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-if.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-if.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-if.cpp
@@ -0,0 +1,59 @@
+// RUN: %check_clang_tidy -std=c++11 %s bugprone-incorrect-enable-if %t
+// RUN: %check_clang_tidy -check-suffix=CXX20 -std=c++20 %s bugprone-incorrect-enable-if %t
+
+// NOLINTBEGIN
+namespace std {
+template  struct enable_if { };
+
+template  struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+} // namespace std
+// NOLINTEND
+
+template ::type>
+void valid_function1() {}
+
+template ::type = nullptr>
+void valid_function2() {}
+
+template ::type = nullptr>
+struct ValidClass1 {};
+
+template >
+void invalid() {}
+// CHECK-MESSAGES: [[@LINE-2]]:23: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-FIXES: template ::type>
+// CHECK-FIXES-CXX20: template ::type>
+
+template  >
+void invalid_extra_whitespace() {}
+// CHECK-MESSAGES: [[@LINE-2]]:23: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-FIXES: template ::type >
+// CHECK-FIXES-CXX20: template ::type >
+
+template >
+void invalid_extra_no_whitespace() {}
+// CHECK-MESSAGES: [[@LINE-2]]:23: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-FIXES: template ::type>
+// CHECK-FIXES-CXX20: template ::type>
+
+template /*comment3*/>
+void invalid_extra_comment() {}
+// CHECK-MESSAGES: [[@LINE-2]]:23: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-FIXES: template ::type/*comment3*/>
+
+template , typename = std::enable_if>
+void invalid_multiple() {}
+// CHECK-MESSAGES: [[@LINE-2]]:23: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-MESSAGES: [[@LINE-3]]:65: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-FIXES: template ::type, typename = typename std::enable_if::type>
+// CHECK-FIXES-CXX20: template ::type, typename = std::enable_if::type>
+
+template >
+struct InvalidClass {};
+// CHECK-MESSAGES: [[@LINE-2]]:23: warning: incorrect std::enable_if usage detected; use 'typename std::enable_if<...>::type' [bugprone-incorrect-enable-if]
+// CHECK-FIXES: template ::type>
+// CHECK-FIXES-CXX20: template ::type>
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -94,6 +94,7 @@
`bugprone-implicit-widening-of-multiplication-result `_, "Yes"
`bugprone-inaccurate-erase `_, "Yes"
`bugprone-inc-dec-in-conditions `_,
+   `bugprone-incorrect-enable-if `_, "Yes"
`bugprone-incorrect-roundings `_,
`bugprone-infinite-loop `_,
`bugprone-integer-division `_,
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-if.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-if.rst
@@ -0,0 +1,48 @@
+.. title:: clang-tidy - bugprone-incorrect-enable-if
+
+bugprone-incorrect-enable-if
+
+
+Detects incorrect usages of ``std::enable_if`` that don't name the nested 
+``type`` type.
+
+In C++11 introduced ``std::enable_if`` as a convenient way to leverage SFINAE.
+One form of using ``std::enable_if`` is to declare an unnamed template type
+parameter with a default type equal to
+``typename std::enable_if::type``. If the author forgets to name
+the nested type ``type``, then the code will always consider the candidate
+template even if the condition is not met.
+
+Below are some examples of code using ``std::enable_if`` correctly and
+incorrect 

[PATCH] D146054: [RISCV] Add --print-supported-extensions support

2023-08-13 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

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


[PATCH] D157680: [X86]Support options -mno-gather -mno-scatter

2023-08-13 Thread Wang, Xin via Phabricator via cfe-commits
XinWang10 marked an inline comment as done.
XinWang10 added inline comments.



Comment at: llvm/lib/Target/X86/X86.td:437
+: SubtargetFeature<"prefer-no-gather", "PreferGather", "false",
+   "Indicates if gather prefer to be disabled">;
+def FeaturePreferNoScatter

pengfei wrote:
> XinWang10 wrote:
> > skan wrote:
> > > Does "Prefer no gather instructions" sound better?
> > > 
> > > I think these two should be put under "X86 Subtarget Tuning features"?
> > I think the two options are to mitigate security issues. Could refer to 
> > link in summary.
> It depends on if the micro code was applied. We should assume user care of 
> this option should have applied the micro code. So it's more like a 
> performance turning rather than mitigation. And you cannot disable all 
> gather/scatter instructions with these options.
Micro code applied? You mean we should keep eye on the byte code generated.
And what's the essential difference between performance turning and mitigation? 
Do mitigation for no-gather means we could not emit gather whenever but 
performance turning could exist some gather considering the performance?
Second, I think the intention for this option is to mitigate the security issue 
but not tune the performance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157680

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


[PATCH] D157829: [clang-tidy] Added a new option to lambda-function-name to ignore warnings in macro expansion

2023-08-13 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 created this revision.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
felix642 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Improved check lambda-function-name with option IgnoreMacros to ignore warnings 
in macro expansion.
Relates to #62857 (https://github.com/llvm/llvm-project/issues/62857)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157829

Files:
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/lambda-function-name.cpp
@@ -1,4 +1,6 @@
-// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy -check-suffixes=,NO-CONFIG %s bugprone-lambda-function-name %t
+// RUN: %check_clang_tidy %s bugprone-lambda-function-name %t -- -config="{CheckOptions: [{key: bugprone-lambda-function-name.IgnoreMacros, value: true}]}" --
+
 
 void Foo(const char* a, const char* b, int c) {}
 
@@ -12,11 +14,11 @@
   [] { __FUNCTION__; }();
   // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNC_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { FUNCTION_MACRO; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__FUNCTION__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
   [] { EMBED_IN_ANOTHER_MACRO1; }();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
+  // CHECK-MESSAGES-NO-CONFIG: :[[@LINE-1]]:8: warning: inside a lambda, '__func__' expands to the name of the function call operator; consider capturing the name of the enclosing function explicitly [bugprone-lambda-function-name]
 }
 
 #define FUNC_MACRO_WITH_FILE_AND_LINE Foo(__func__, __FILE__, __LINE__)
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone/lambda-function-name.rst
@@ -25,3 +25,11 @@
 
   Called from FancyFunction
   Now called from FancyFunction
+
+Options
+---
+
+.. option::  IgnoreMacros
+
+  The value `true` specifies that attempting to get the name of a function from
+  within a macro should not be diagnosed. The default value is `false`.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -173,6 +173,10 @@
   `, so that it does not warn
   on macros starting with underscore and lowercase letter.
 
+- Improved :doc:`bugprone-lambda-function-name
+  ` check by adding option
+  `IgnoreMacros` to ignore warnings in macros.
+
 - Improved :doc:`cppcoreguidelines-avoid-non-const-global-variables
   ` check
   to ignore ``static`` variables declared within the scope of
Index: clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
===
--- clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
+++ clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.h
@@ -13,6 +13,8 @@
 
 namespace clang::tidy::bugprone {
 
+inline constexpr bool DefaultIgnoreMacros = false;
+
 /// Detect when __func__ or 

[PATCH] D156344: Disable call to fma for soft-float

2023-08-13 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

compiler-rt builtins library should not just undefining fma for PPC, right (see 
https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html)? If so, 
maybe we should at least first try not generating fma for soft-float at the 
first place where fmul + fadd is fused, like `tryEmitFMulAdd` in clang front 
end?


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

https://reviews.llvm.org/D156344

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


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

2023-08-13 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 549760.
capfredf added a comment.

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/InterpreterCodeCompletion.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterCodeCompletion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
  clang/test/CodeCompletion/incremental-top-level.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,101 @@
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Interpreter/Interpreter.h"
+#include "clang/Interpreter/InterpreterCodeCompletion.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+static std::vector runComp(clang::Interpreter ,
+llvm::StringRef Prefix,
+llvm::Error ) {
+  auto CI = CB.CreateCpp();
+  if (auto Err = CI.takeError()) {
+ErrR = std::move(Err);
+return {};
+  }
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (auto Err = Interp.takeError()) {
+// log the error and returns an empty vector;
+ErrR = std::move(Err);
+
+return {};
+  }
+
+  std::vector Results;
+
+  codeComplete(
+  const_cast((*Interp)->getCompilerInstance()),
+  Prefix, 1, Prefix.size(), MainInterp.getCompilerInstance(), Results);
+
+  std::vector Comps;
+  for (auto c : ConvertToCodeCompleteStrings(Results)) {
+if (c.startswith(Prefix))
+  Comps.push_back(c.substr(Prefix.size()).str());
+  }
+
+  return Comps;
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "f", Err);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0], std::string("oo"));
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "babanana", Err);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "app", Err);
+  EXPECT_EQ((size_t)2, comps.size());
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, CompFunDeclsNoError) {
+  auto Interp = createInterpreter();
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "void app(", Err);
+  EXPECT_EQ((bool)Err, false);
+}
+
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -11,8 +11,8 @@
 //
 

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

2023-08-13 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 549759.
capfredf added a comment.

move everything into InterpreterCodeCompletion.

the entry point for code completion is now a function, codeCompletion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/InterpreterCodeCompletion.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/InterpreterCodeCompletion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
  clang/test/CodeCompletion/incremental-top-level.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,101 @@
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Interpreter/Interpreter.h"
+#include "clang/Interpreter/InterpreterCodeCompletion.h"
+#include "clang/Sema/CodeCompleteConsumer.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+static std::vector runComp(clang::Interpreter ,
+llvm::StringRef Prefix,
+llvm::Error ) {
+  auto CI = CB.CreateCpp();
+  if (auto Err = CI.takeError()) {
+ErrR = std::move(Err);
+return {};
+  }
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (auto Err = Interp.takeError()) {
+// log the error and returns an empty vector;
+ErrR = std::move(Err);
+
+return {};
+  }
+
+  std::vector Results;
+
+  codeComplete(
+  const_cast((*Interp)->getCompilerInstance()),
+  Prefix, 1, Prefix.size(), MainInterp.getCompilerInstance(), Results);
+
+  std::vector Comps;
+  for (auto c : ConvertToCodeCompleteStrings(Results)) {
+if (c.startswith(Prefix))
+  Comps.push_back(c.substr(Prefix.size()).str());
+  }
+
+  return Comps;
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "f", Err);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0], std::string("oo"));
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "babanana", Err);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "app", Err);
+  EXPECT_EQ((size_t)2, comps.size());
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, CompFunDeclsNoError) {
+  auto Interp = createInterpreter();
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "void app(", Err);
+  EXPECT_EQ((bool)Err, false);
+}
+
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp

[PATCH] D157767: [Driver] move Haiku header search path management to the driver

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

Removed:
/boot/system/develop/headers/os/arch

Added:
/boot/system/develop/headers/gnu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157767

Files:
  clang/lib/Driver/ToolChains/Haiku.cpp
  clang/lib/Driver/ToolChains/Haiku.h
  clang/lib/Lex/InitHeaderSearch.cpp

Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -279,42 +279,6 @@
 AddPath(P, System, false);
 break;
   }
-
-  case llvm::Triple::Haiku:
-AddPath("/boot/system/non-packaged/develop/headers", System, false);
-AddPath("/boot/system/develop/headers/os", System, false);
-AddPath("/boot/system/develop/headers/os/app", System, false);
-AddPath("/boot/system/develop/headers/os/arch", System, false);
-AddPath("/boot/system/develop/headers/os/device", System, false);
-AddPath("/boot/system/develop/headers/os/drivers", System, false);
-AddPath("/boot/system/develop/headers/os/game", System, false);
-AddPath("/boot/system/develop/headers/os/interface", System, false);
-AddPath("/boot/system/develop/headers/os/kernel", System, false);
-AddPath("/boot/system/develop/headers/os/locale", System, false);
-AddPath("/boot/system/develop/headers/os/mail", System, false);
-AddPath("/boot/system/develop/headers/os/media", System, false);
-AddPath("/boot/system/develop/headers/os/midi", System, false);
-AddPath("/boot/system/develop/headers/os/midi2", System, false);
-AddPath("/boot/system/develop/headers/os/net", System, false);
-AddPath("/boot/system/develop/headers/os/opengl", System, false);
-AddPath("/boot/system/develop/headers/os/storage", System, false);
-AddPath("/boot/system/develop/headers/os/support", System, false);
-AddPath("/boot/system/develop/headers/os/translation", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/graphics", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/input_server", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/mail_daemon", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/registrar", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/screen_saver", System, false);
-AddPath("/boot/system/develop/headers/os/add-ons/tracker", System, false);
-AddPath("/boot/system/develop/headers/os/be_apps/Deskbar", System, false);
-AddPath("/boot/system/develop/headers/os/be_apps/NetPositive", System, false);
-AddPath("/boot/system/develop/headers/os/be_apps/Tracker", System, false);
-AddPath("/boot/system/develop/headers/3rdparty", System, false);
-AddPath("/boot/system/develop/headers/bsd", System, false);
-AddPath("/boot/system/develop/headers/glibc", System, false);
-AddPath("/boot/system/develop/headers/posix", System, false);
-AddPath("/boot/system/develop/headers",  System, false);
-break;
   case llvm::Triple::RTEMS:
 break;
   case llvm::Triple::Win32:
@@ -388,6 +352,7 @@
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
   case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -26,6 +26,9 @@
 return getTriple().getArch() == llvm::Triple::x86_64;
   }
 
+  void AddClangSystemIncludeArgs(
+  const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const override;
   void addLibCxxIncludePaths(
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override;
Index: clang/lib/Driver/ToolChains/Haiku.cpp
===
--- clang/lib/Driver/ToolChains/Haiku.cpp
+++ clang/lib/Driver/ToolChains/Haiku.cpp
@@ -8,6 +8,8 @@
 
 #include "Haiku.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -21,6 +23,70 @@
 
 }
 
+void Haiku::AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
+  llvm::opt::ArgStringList ) const {
+  const Driver  = getDriver();
+
+  if (DriverArgs.hasArg(options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Add dirs specified via 'configure --with-c-include-dirs'.
+  StringRef CIncludeDirs(C_INCLUDE_DIRS);
+  if 

[PATCH] D157825: [clang] Implement constexpr bit_cast for vectors

2023-08-13 Thread Joey Rabil via Phabricator via cfe-commits
DaPorkchop_ created this revision.
DaPorkchop_ added a project: clang.
Herald added a project: All.
DaPorkchop_ requested review of this revision.
Herald added a subscriber: cfe-commits.

This makes __builtin_bit_cast support converting to and from vector types in a 
constexpr context.

Without this patch, attempting to use `std::bit_cast` with a vector type will 
fail to compile with a message such as:  
`constexpr bit_cast involving type '__attribute__((__vector_size__(4 * 
sizeof(int int const' (vector of 4 'int' values) is not yet supported`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157825

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp


Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
===
--- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
+++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
@@ -463,3 +463,19 @@
 static_assert(round_trip<__int128_t>(34.0L));
 #endif
 }
+
+namespace test_vector {
+
+typedef unsigned uint2 __attribute__((vector_size(2 * sizeof(unsigned;
+typedef char byte8 __attribute__((vector_size(sizeof(unsigned long long;
+
+constexpr uint2 test_vector = { 0x0C05FEFE, 0xCAFEBABE };
+
+static_assert(bit_cast(test_vector) == (LITTLE_END
+? 
0xCAFEBABE0C05FEFE
+: 
0x0C05FEFECAFEBABE), "");
+
+static_assert(round_trip(0xCAFEBABE0C05FEFEULL), "");
+static_assert(round_trip(0xCAFEBABE0C05FEFEULL), "");
+
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6990,10 +6990,11 @@
   return visitArray(Val, Ty, Offset);
 case APValue::Struct:
   return visitRecord(Val, Ty, Offset);
+case APValue::Vector:
+  return visitVector(Val, Ty, Offset);
 
 case APValue::ComplexInt:
 case APValue::ComplexFloat:
-case APValue::Vector:
 case APValue::FixedPoint:
   // FIXME: We should support these.
 
@@ -7080,6 +7081,21 @@
 return true;
   }
 
+  bool visitVector(const APValue , QualType Ty, CharUnits Offset) {
+const auto *VT = Ty->castAs();
+
+CharUnits ElemWidth = Info.Ctx.getTypeSizeInChars(VT->getElementType());
+unsigned VectorLength = Val.getVectorLength();
+// Visit each of the vector elements
+for (unsigned I = 0; I != VectorLength; ++I) {
+  const APValue  = Val.getVectorElt(I);
+  if (!visit(SubObj, VT->getElementType(), Offset + I * ElemWidth))
+return false;
+}
+
+return true;
+  }
+
   bool visitInt(const APSInt , QualType Ty, CharUnits Offset) {
 APSInt AdjustedVal = Val;
 unsigned Width = AdjustedVal.getBitWidth();
@@ -7289,6 +7305,22 @@
 return ArrayValue;
   }
 
+  std::optional visit(const VectorType *Ty, CharUnits Offset) {
+size_t NumElements = Ty->getNumElements();
+CharUnits ElementWidth = Info.Ctx.getTypeSizeInChars(Ty->getElementType());
+
+SmallVector Elts;
+for (size_t I = 0; I != NumElements; ++I) {
+  std::optional ElementValue =
+  visitType(Ty->getElementType(), Offset + I * ElementWidth);
+  if (!ElementValue)
+return std::nullopt;
+  Elts.push_back(std::move(*ElementValue));
+}
+
+return APValue(Elts.data(), Elts.size());
+  }
+
   std::optional visit(const Type *Ty, CharUnits Offset) {
 return unsupportedType(QualType(Ty, 0));
   }


Index: clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
===
--- clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
+++ clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
@@ -463,3 +463,19 @@
 static_assert(round_trip<__int128_t>(34.0L));
 #endif
 }
+
+namespace test_vector {
+
+typedef unsigned uint2 __attribute__((vector_size(2 * sizeof(unsigned;
+typedef char byte8 __attribute__((vector_size(sizeof(unsigned long long;
+
+constexpr uint2 test_vector = { 0x0C05FEFE, 0xCAFEBABE };
+
+static_assert(bit_cast(test_vector) == (LITTLE_END
+? 0xCAFEBABE0C05FEFE
+: 0x0C05FEFECAFEBABE), "");
+
+static_assert(round_trip(0xCAFEBABE0C05FEFEULL), "");
+static_assert(round_trip(0xCAFEBABE0C05FEFEULL), "");
+
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -6990,10 +6990,11 @@
   return visitArray(Val, Ty, Offset);
 case APValue::Struct:
   return visitRecord(Val, Ty, Offset);
+case APValue::Vector:
+  return visitVector(Val, Ty, Offset);
 
 case APValue::ComplexInt:
 case APValue::ComplexFloat:
-case APValue::Vector:
 case 

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

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



Comment at: clang/lib/Interpreter/CodeCompletion.cpp:1
+//===-- CodeCompletion.cpp - Code Completion for ClangRepl ---===//
+//

I would propose to rename this file to `InterpreterCodeCompletion.cpp` and 
implement the `Interpreter::codeComplete` interface. Then we can move all of 
the content of `ExternalSource.{h,cpp}`, `CodeCompletion.h` and 
`ExternalSource.h` in it. That will increase the encapsulation of the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-08-13 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D150646#4581664 , @rnk wrote:

> I think we should be exposing the `__cpudex` builtin any time we are being 
> MSVC-like, not under `fms-compatibility`. Would that make things sensible 
> again?

I think that might sound reasonable - what do we do for other MSVC-specific 
builtins today?

In D150646#4581672 , @aidengrossman 
wrote:

> The main issue here is that there's no way to reliably detect whether the 
> built in is defined (can't check if a function is defined in the 
> preprocessor, preprocessor macro isn't exposed correctly in all 
> configurations), which ends up breaking some configurations.

That's indeed the issue

> I wouldn't be opposed to exposing things more often, but I'm fine with the 
> builtins being exposed under `-fms-extensions`, we just need to expose the 
> preprocessor macro when we expose the builtins.

As far as I can see, @rnk's suggestion is the opposite - to tie whether the 
builtin is enabled to the target only, not to `-fms-extensions`. I.e. mingw + 
`-fms-extensions` doesn't get the builtin. Then the preprocessor check for it 
would simply be `!defined(_MSC_VER)`.

Unfortunately, for Clang tests that invoke `clang -cc1` directly, with an MSVC 
target triple, don't get `_MSC_VER` defined automatically, only if they pass 
`-fms-compatibility-version=` (which the Driver usually passes), so in such 
test conditions, the main way of detecting MSVC right now is `defined(_WIN32) 
&& !defined(__MINGW32__)` which isn't very pretty either.

I played with a patch to make Clang always define `_MSC_VER` for MSVC targets, 
even if `-fms-compatibility-version=` wasn't set. That broke quite a few tests, 
since `_MSC_VER` unlocks lots of codepaths that only work when 
`-fms-extensions` is set (which the Driver usually does for MSVC targets, but 
usually isn't set in `%clang_cc1` tests). So if we want to default to defining 
`_MSC_VER` on the cc1 level without an explicit `-fms-compatibility-version=`, 
we'd also need to imply `-fms-extensions` for MSVC targets, which I guess would 
go against a lot of the driver/frontend logic split.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


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

2023-08-13 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 549751.
capfredf added a comment.

use auto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/CodeCompletion.h
  clang/include/clang/Interpreter/ExternalSource.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/CodeCompletion.cpp
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/ExternalSource.cpp
  clang/lib/Interpreter/ExternalSource.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
  clang/test/CodeCompletion/incremental-top-level.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,100 @@
+#include "clang/Interpreter/CodeCompletion.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+static std::vector runComp(clang::Interpreter ,
+llvm::StringRef Prefix,
+llvm::Error ) {
+  auto CI = CB.CreateCpp();
+  if (auto Err = CI.takeError()) {
+ErrR = std::move(Err);
+return {};
+  }
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (auto Err = Interp.takeError()) {
+// log the error and returns an empty vector;
+ErrR = std::move(Err);
+
+return {};
+  }
+
+  std::vector Results;
+
+  (*Interp)->codeComplete(Prefix, 1, Prefix.size(),
+  MainInterp.getCompilerInstance(), Results);
+
+  std::vector Comps;
+  for (auto c : ConvertToCodeCompleteStrings(Results)) {
+if (c.startswith(Prefix))
+  Comps.push_back(c.substr(Prefix.size()).str());
+  }
+
+  return Comps;
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "f", Err);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0], std::string("oo"));
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "babanana", Err);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "app", Err);
+  EXPECT_EQ((size_t)2, comps.size());
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, CompFunDeclsNoError) {
+  auto Interp = createInterpreter();
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "void app(", Err);
+  EXPECT_EQ((bool)Err, false);
+}
+
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- 

[PATCH] D157568: [clang-format] Handle NamespaceMacro string arg for FixNamespaceComments

2023-08-13 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:177
   llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*)\\)\\.? *(\\*/)?$",
+  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*|\".+\")\\)\\.? *(\\*/)?$",
   llvm::Regex::IgnoreCase);

HazardyKnusperkeks wrote:
> Maybe this?
I don't think we'd need it because the `+` is greedy.


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

https://reviews.llvm.org/D157568

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


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

2023-08-13 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 549750.
capfredf added a comment.

up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/CodeCompletion.h
  clang/include/clang/Interpreter/ExternalSource.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/CodeCompletion.cpp
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/ExternalSource.cpp
  clang/lib/Interpreter/ExternalSource.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
  clang/test/CodeCompletion/incremental-top-level.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,100 @@
+#include "clang/Interpreter/CodeCompletion.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+static std::vector runComp(clang::Interpreter ,
+llvm::StringRef Prefix,
+llvm::Error ) {
+  auto CI = CB.CreateCpp();
+  if (auto Err = CI.takeError()) {
+ErrR = std::move(Err);
+return {};
+  }
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (auto Err = Interp.takeError()) {
+// log the error and returns an empty vector;
+ErrR = std::move(Err);
+
+return {};
+  }
+
+  std::vector Results;
+
+  (*Interp)->codeComplete(Prefix, 1, Prefix.size(),
+  MainInterp.getCompilerInstance(), Results);
+
+  std::vector Comps;
+  for (auto c : ConvertToCodeCompleteStrings(Results)) {
+if (c.startswith(Prefix))
+  Comps.push_back(c.substr(Prefix.size()).str());
+  }
+
+  return Comps;
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "f", Err);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0], std::string("oo"));
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "babanana", Err);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "app", Err);
+  EXPECT_EQ((size_t)2, comps.size());
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, CompFunDeclsNoError) {
+  auto Interp = createInterpreter();
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "void app(", Err);
+  EXPECT_EQ((bool)Err, false);
+}
+
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- 

[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

2023-08-13 Thread QuillPusher via Phabricator via cfe-commits
QuillPusher accepted this revision.
QuillPusher added a comment.
This revision is now accepted and ready to land.

Thanks @Krishna-13-cyber for the prompt efforts
@v.g.vassilev it is ready to commit as far as I can see


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

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


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

2023-08-13 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 549749.
capfredf added a comment.

up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/CodeCompletion.h
  clang/include/clang/Interpreter/ExternalSource.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/CodeCompletion.cpp
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/ExternalSource.cpp
  clang/lib/Interpreter/ExternalSource.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
  clang/test/CodeCompletion/incremental-top-level.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,100 @@
+#include "clang/Interpreter/CodeCompletion.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+static std::vector runComp(clang::Interpreter ,
+llvm::StringRef Prefix,
+llvm::Error ) {
+  auto CI = CB.CreateCpp();
+  if (auto Err = CI.takeError()) {
+ErrR = std::move(Err);
+return {};
+  }
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (auto Err = Interp.takeError()) {
+// log the error and returns an empty vector;
+ErrR = std::move(Err);
+
+return {};
+  }
+
+  std::vector Results;
+
+  (*Interp)->codeComplete(Prefix, 1, Prefix.size(),
+  MainInterp.getCompilerInstance(), Results);
+
+  std::vector Comps;
+  for (auto c : ConvertToCodeCompleteStrings(Results)) {
+if (c.startswith(Prefix))
+  Comps.push_back(c.substr(Prefix.size()).str());
+  }
+
+  return Comps;
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "f", Err);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0], std::string("oo"));
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "babanana", Err);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "app", Err);
+  EXPECT_EQ((size_t)2, comps.size());
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, CompFunDeclsNoError) {
+  auto Interp = createInterpreter();
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "void app(", Err);
+  EXPECT_EQ((bool)Err, false);
+}
+
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- 

[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

2023-08-13 Thread Krishna Narayanan via Phabricator via cfe-commits
Krishna-13-cyber updated this revision to Diff 549745.
Krishna-13-cyber added a comment.

- Address the comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

Files:
  clang/docs/ClangRepl.rst
  clang/docs/conf.py

Index: clang/docs/conf.py
===
--- clang/docs/conf.py
+++ clang/docs/conf.py
@@ -49,6 +49,7 @@
 if sphinx.version_info >= (3, 0):
 # This requires 0.5 or later.
 extensions.append("recommonmark")
+extensions.append('sphinx.ext.graphviz')
 else:
 source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
 source_suffix[".md"] = "markdown"
Index: clang/docs/ClangRepl.rst
===
--- clang/docs/ClangRepl.rst
+++ clang/docs/ClangRepl.rst
@@ -213,6 +213,411 @@
 automatic language interoperability. It also helps static languages such as C/C++ become
 apt for data science.
 
+Execution Results Handling in Clang-Repl
+
+
+Execution Results Handling features discussed below help extend the Clang-Repl
+functionality by creating an interface between the execution results of a
+program and the compiled program.
+
+1. **Capture Execution Results**: This feature helps capture the execution results
+of a program and bring them back to the compiled program.
+
+2. **Dump Captured Execution Results**: This feature helps create a temporary dump
+for Value Printing/Automatic Printf, that is, to display the value and type of
+the captured data.
+
+
+1. Capture Execution Results
+
+
+In many cases, it is useful to bring back the program execution result to the
+compiled program. This result can be stored in an object of type **Value**.
+
+How Execution Results are captured (Value Synthesis):
+-
+
+The synthesizer chooses which expression to synthesize, and then it replaces
+the original expression with the synthesized expression. Depending on the
+expression type, it may choose to save an object (``LastValue``) of type 'value'
+while allocating memory to it (``SetValueWithAlloc()``), or not (
+``SetValueNoAlloc()``).
+
+.. graphviz::
+:name: valuesynthesis
+:caption: Value Synthesis
+:alt: Shows how an object of type 'Value' is synthesized
+:align: center
+
+ digraph "valuesynthesis" {
+ rankdir="LR";
+ graph [fontname="Verdana", fontsize="12"];
+ node [fontname="Verdana", fontsize="12"];
+ edge [fontname="Sans", fontsize="9"];
+
+ start [label=" Create an Object \n 'Last Value' \n of type 'Value' ", shape="note", fontcolor=white, fillcolor="#ff", style=filled];
+ assign [label=" Assign the result \n to the 'LastValue' \n (based on respective \n Memory Allocation \n scenario) ", shape="box"]
+ print [label=" Pretty Print \n the Value Object ", shape="Msquare", fillcolor="yellow", style=filled];
+ start -> assign;
+ assign -> print;
+
+   subgraph SynthesizeExpression {
+ synth [label=" SynthesizeExpr() ", shape="note", fontcolor=white, fillcolor="#ff", style=filled];
+ mem [label=" New Memory \n Allocation? ", shape="diamond"];
+ withaloc [label=" SetValueWithAlloc() ", shape="box"];
+ noaloc [label=" SetValueNoAlloc() ", shape="box"];
+ right [label=" 1. RValue Structure \n (a temporary value)", shape="box"];
+ left2 [label=" 2. LValue Structure \n (a variable with \n an address)", shape="box"];
+ left3 [label=" 3. Built-In Type \n (int, float, etc.)", shape="box"];
+ output [label=" move to 'Assign' step ", shape="box"];
+
+ synth -> mem;
+ mem -> withaloc [label="Yes"];
+ mem -> noaloc [label="No"];
+ withaloc -> right;
+ noaloc -> left2;
+ noaloc -> left3;
+ right -> output;
+ left2 -> output;
+ left3 -> output;
+  }
+output -> assign
+  }
+
+Where is the captured result stored?
+
+
+``LastValue`` holds the last result of the value printing. It is a class member
+because it can be accessed even after subsequent inputs.
+
+**Note:** If no value printing happens, then it is in an invalid state.
+
+Improving Efficiency and User Experience
+
+
+The Value object is essentially used to create a mapping between an expression
+'type' and the allocated 'memory'. Built-in types (bool, char, int,
+float, double, etc.) are copyable. Their their memory allocation size is known
+and the Value object can introduce a small-buffer optimization.
+In case of objects, the ``Value`` class provides reference-counted memory
+management.
+
+The 

[PATCH] D151904: [clang-repl][CUDA] Add an unit test for interactive CUDA

2023-08-13 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

@argentite what is the fate of this patch? Should we move forward with it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151904

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


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

2023-08-13 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a reviewer: sammccall.
v.g.vassilev added a subscriber: sammccall.
v.g.vassilev added a comment.

This looks mostly good to me. I noticed that @sammccall has done some work in 
that area in clangd and I was wondering if he has some thoughts about this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


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

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



Comment at: clang/lib/Interpreter/IncrementalParser.h:91
+
+class IncrementalSyntaxOnlyAction : public SyntaxOnlyAction {
+  const CompilerInstance *ParentCI;

Can we not move this class definition locally to the CodeComplete interface?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

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


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

2023-08-13 Thread Fred Fu via Phabricator via cfe-commits
capfredf updated this revision to Diff 549739.
capfredf added a comment.
Herald added a subscriber: ChuanqiXu.

changes per discussions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154382

Files:
  clang/include/clang/Frontend/ASTUnit.h
  clang/include/clang/Interpreter/CodeCompletion.h
  clang/include/clang/Interpreter/ExternalSource.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/CodeCompletion.cpp
  clang/lib/Interpreter/DeviceOffload.cpp
  clang/lib/Interpreter/ExternalSource.cpp
  clang/lib/Interpreter/ExternalSource.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
  clang/test/CodeCompletion/incremental-top-level.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/CodeCompletionTest.cpp

Index: clang/unittests/Interpreter/CodeCompletionTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/CodeCompletionTest.cpp
@@ -0,0 +1,100 @@
+#include "clang/Interpreter/CodeCompletion.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+namespace {
+auto CB = clang::IncrementalCompilerBuilder();
+
+static std::unique_ptr createInterpreter() {
+  auto CI = cantFail(CB.CreateCpp());
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+static std::vector runComp(clang::Interpreter ,
+llvm::StringRef Prefix,
+llvm::Error ) {
+  auto CI = CB.CreateCpp();
+  if (auto Err = CI.takeError()) {
+ErrR = std::move(Err);
+return {};
+  }
+
+
+  auto Interp = clang::Interpreter::create(std::move(*CI));
+  if (auto Err = Interp.takeError()) {
+// log the error and returns an empty vector;
+ErrR = std::move(Err);
+
+return {};
+  }
+
+  std::vector Results;
+
+  (*Interp)->codeComplete(Prefix, Prefix.size(), MainInterp.getCompilerInstance(), Results);
+
+  std::vector Comps;
+  for (auto c : ConvertToCodeCompleteStrings(Results)) {
+if (c.startswith(Prefix))
+  Comps.push_back(c.substr(Prefix.size()).str());
+  }
+
+  return Comps;
+}
+
+TEST(CodeCompletionTest, Sanity) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "f", Err);
+  EXPECT_EQ((size_t)2, comps.size()); // foo and float
+  EXPECT_EQ(comps[0], std::string("oo"));
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, SanityNoneValid) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int foo = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "babanana", Err);
+  EXPECT_EQ((size_t)0, comps.size()); // foo and float
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, TwoDecls) {
+  auto Interp = createInterpreter();
+  if (auto R = Interp->ParseAndExecute("int application = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  if (auto R = Interp->ParseAndExecute("int apple = 12;")) {
+consumeError(std::move(R));
+return;
+  }
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "app", Err);
+  EXPECT_EQ((size_t)2, comps.size());
+  EXPECT_EQ((bool)Err, false);
+}
+
+TEST(CodeCompletionTest, CompFunDeclsNoError) {
+  auto Interp = createInterpreter();
+  auto Err = llvm::Error::success();
+  auto comps = runComp(*Interp, "void app(", Err);
+  EXPECT_EQ((bool)Err, false);
+}
+
+} // anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- clang/unittests/Interpreter/CMakeLists.txt
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -9,6 +9,7 @@
 add_clang_unittest(ClangReplInterpreterTests
   IncrementalProcessingTest.cpp
   InterpreterTest.cpp
+  CodeCompletionTest.cpp
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- 

[PATCH] D157568: [clang-format] Handle NamespaceMacro string arg for FixNamespaceComments

2023-08-13 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/NamespaceEndCommentsFixer.cpp:177
   llvm::Regex("^/[/*] *(end (of )?)? *(anonymous|unnamed)? *"
-  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*)\\)\\.? *(\\*/)?$",
+  "([a-zA-Z0-9_]+)\\(([a-zA-Z0-9:_]*|\".+\")\\)\\.? *(\\*/)?$",
   llvm::Regex::IgnoreCase);

Maybe this?


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

https://reviews.llvm.org/D157568

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


[PATCH] D157767: [Driver] move Haiku header search path management to the driver

2023-08-13 Thread Niels Sascha Reedijk via Phabricator via cfe-commits
nielx added a comment.

I will test the patch and see if it works as expected. Note that we currently 
have the following preset header paths in our GCC port 
.




Comment at: clang/lib/Driver/ToolChains/Haiku.cpp:58
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/app");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/arch");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/os/device");

Not (or no longer) in GCC default sys path, so can be removed.



Comment at: clang/lib/Driver/ToolChains/Haiku.cpp:86
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/glibc");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers/posix");
+  addSystemInclude(DriverArgs, CC1Args, D.SysRoot + 
"/boot/system/develop/headers");

Missing: /boot/system/develop/headers/gnu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157767

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


[PATCH] D157817: [clang] Fix ClangScanDeps test for #61006.

2023-08-13 Thread Ingo Müller 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 rG1800038fba42: [clang] Fix ClangScanDeps test for #61006. 
(authored by ingomueller-net).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157817

Files:
  clang/test/ClangScanDeps/pr61006.cppm


Index: clang/test/ClangScanDeps/pr61006.cppm
===
--- clang/test/ClangScanDeps/pr61006.cppm
+++ clang/test/ClangScanDeps/pr61006.cppm
@@ -6,10 +6,10 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
-// RUN: ln -s %clang++ %t/clang++
-// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json
-// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \
+// RUN: ln -s %clang++ %t/clang++ && \
+// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json && \
+// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t && \
 // RUN: clang-scan-deps -format=p1689 \
 // RUN:   -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o 
%t/a.o \
 // RUN:  -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp 
-DPREFIX=%/t
@@ -25,7 +25,7 @@
 ]
 
 //--- a.cpp
-#include 
+#include "a.h"
 import b;
 
 // CHECK: {
@@ -42,3 +42,5 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "version": 1
 // CHECK-NEXT: }
+
+//--- a.h


Index: clang/test/ClangScanDeps/pr61006.cppm
===
--- clang/test/ClangScanDeps/pr61006.cppm
+++ clang/test/ClangScanDeps/pr61006.cppm
@@ -6,10 +6,10 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
-// RUN: ln -s %clang++ %t/clang++
-// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json
-// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \
+// RUN: ln -s %clang++ %t/clang++ && \
+// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json && \
+// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t && \
 // RUN: clang-scan-deps -format=p1689 \
 // RUN:   -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o %t/a.o \
 // RUN:  -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp -DPREFIX=%/t
@@ -25,7 +25,7 @@
 ]
 
 //--- a.cpp
-#include 
+#include "a.h"
 import b;
 
 // CHECK: {
@@ -42,3 +42,5 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "version": 1
 // CHECK-NEXT: }
+
+//--- a.h
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1800038 - [clang] Fix ClangScanDeps test for #61006.

2023-08-13 Thread Ingo Müller via cfe-commits

Author: Ingo Müller
Date: 2023-08-13T18:23:34Z
New Revision: 1800038fba42741c4013c64ee307611251118ee3

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

LOG: [clang] Fix ClangScanDeps test for #61006.

This patch solves two problems with the recently added test, which
caused CI failure in an internal downstream system:

1. It connects subsequent `RUN` statements with `&&` into a single
   statement; otherwise, the variable defined in the first of them is
   out of scope in the subsequent ones where it is used.
2. In our hermetic testing environment, the clang++ binary under test
   does not have access to standard include paths (`/usr/include` etc.),
   so the test fails because it does not find `stddef.h`. The patch thus
   changes the test to use a locally created `a.h` header file.

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

Added: 


Modified: 
clang/test/ClangScanDeps/pr61006.cppm

Removed: 




diff  --git a/clang/test/ClangScanDeps/pr61006.cppm 
b/clang/test/ClangScanDeps/pr61006.cppm
index 13cfe385be2e2d..f75edd38c81ba9 100644
--- a/clang/test/ClangScanDeps/pr61006.cppm
+++ b/clang/test/ClangScanDeps/pr61006.cppm
@@ -6,10 +6,10 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
-// RUN: ln -s %clang++ %t/clang++
-// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json
-// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \
+// RUN: ln -s %clang++ %t/clang++ && \
+// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json && \
+// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t && \
 // RUN: clang-scan-deps -format=p1689 \
 // RUN:   -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o 
%t/a.o \
 // RUN:  -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp 
-DPREFIX=%/t
@@ -25,7 +25,7 @@
 ]
 
 //--- a.cpp
-#include 
+#include "a.h"
 import b;
 
 // CHECK: {
@@ -42,3 +42,5 @@ import b;
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "version": 1
 // CHECK-NEXT: }
+
+//--- a.h



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


[PATCH] D157817: [clang] Fix ClangScanDeps test for #61006.

2023-08-13 Thread Ingo Müller via Phabricator via cfe-commits
ingomueller-net created this revision.
ingomueller-net added a reviewer: ChuanqiXu.
Herald added a project: All.
ingomueller-net requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch solves two problems with the recently added test, which
caused CI failure in an internal downstream system:

1. It connects subsequent `RUN` statements with `&&` into a single statement; 
otherwise, the variable defined in the first of them is out of scope in the 
subsequent ones where it is used.
2. In our hermetic testing environment, the clang++ binary under test does not 
have access to standard include paths (`/usr/include` etc.), so the test fails 
because it does not find `stddef.h`. The patch thus changes the test to use a 
locally created `a.h` header file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157817

Files:
  clang/test/ClangScanDeps/pr61006.cppm


Index: clang/test/ClangScanDeps/pr61006.cppm
===
--- clang/test/ClangScanDeps/pr61006.cppm
+++ clang/test/ClangScanDeps/pr61006.cppm
@@ -6,10 +6,10 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
-// RUN: ln -s %clang++ %t/clang++
-// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json
-// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \
+// RUN: ln -s %clang++ %t/clang++ && \
+// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" 
%t/P1689.json.in > %t/P1689.json && \
+// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | 
FileCheck %t/a.cpp -DPREFIX=%/t && \
 // RUN: clang-scan-deps -format=p1689 \
 // RUN:   -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o 
%t/a.o \
 // RUN:  -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp 
-DPREFIX=%/t
@@ -25,7 +25,7 @@
 ]
 
 //--- a.cpp
-#include 
+#include "a.h"
 import b;
 
 // CHECK: {
@@ -42,3 +42,5 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "version": 1
 // CHECK-NEXT: }
+
+//--- a.h


Index: clang/test/ClangScanDeps/pr61006.cppm
===
--- clang/test/ClangScanDeps/pr61006.cppm
+++ clang/test/ClangScanDeps/pr61006.cppm
@@ -6,10 +6,10 @@
 // RUN: mkdir -p %t
 // RUN: split-file %s %t
 //
-// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
-// RUN: ln -s %clang++ %t/clang++
-// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json
-// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t
+// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \
+// RUN: ln -s %clang++ %t/clang++ && \
+// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json && \
+// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t && \
 // RUN: clang-scan-deps -format=p1689 \
 // RUN:   -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o %t/a.o \
 // RUN:  -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp -DPREFIX=%/t
@@ -25,7 +25,7 @@
 ]
 
 //--- a.cpp
-#include 
+#include "a.h"
 import b;
 
 // CHECK: {
@@ -42,3 +42,5 @@
 // CHECK-NEXT:   ],
 // CHECK-NEXT:   "version": 1
 // CHECK-NEXT: }
+
+//--- a.h
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-08-13 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

Should we dump the real default argument AST but not only `CXXDefaultArgExpr` 
if `CXXDefaultArgExpr` has been rewritted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D157814: [clang] Add missing field to TLSModelAttr json AST dump

2023-08-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: aaron.ballman.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157814

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -19,6 +19,7 @@
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
+__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -483,3 +484,51 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 724,
+// CHECK-NEXT:   "line": 22,
+// CHECK-NEXT:   "col": 57,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 668,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 724,
+// CHECK-NEXT:"col": 57,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "tls_model_var",
+// CHECK-NEXT:  "mangledName": "tls_model_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "tls": "static",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TLSModelAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 693,
+// CHECK-NEXT:  "col": 26,
+// CHECK-NEXT:  "tokLen": 9
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 716,
+// CHECK-NEXT:  "col": 49,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"tls_model": "local-exec"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -556,6 +556,10 @@
   VA->getVisibility()));
 }
 
+void JSONNodeDumper::VisitTLSModelAttr(const TLSModelAttr *TA) {
+  JOS.attribute("tls_model", TA->getModel());
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -214,6 +214,7 @@
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
   void VisitVisibilityAttr(const VisibilityAttr *VA);
+  void VisitTLSModelAttr(const TLSModelAttr *TA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -19,6 +19,7 @@
 
 __attribute__ ((visibility ("hidden"))) int visibility_var;
 
+__thread __attribute__ ((tls_model ("local-exec"))) int tls_model_var;
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
@@ -483,3 +484,51 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 724,
+// CHECK-NEXT:   "line": 22,
+// CHECK-NEXT:   "col": 57,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 668,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 8
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 724,
+// CHECK-NEXT:"col": 57,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "tls_model_var",
+// CHECK-NEXT:  "mangledName": "tls_model_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "tls": "static",
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "TLSModelAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 693,
+// CHECK-NEXT:  "col": 26,
+// 

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

2023-08-13 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

FIXME: Need add test in `clang/test/CXX/special/class.temporary/p6.cpp` to 
check generated LLVM IR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

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


[PATCH] D157808: [clang] Add missing field to VisibilityAttr json AST dump

2023-08-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 549717.
serge-sans-paille added a comment.

Fix typo in example


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

https://reviews.llvm.org/D157808

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,9 @@
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visibility_var;
+
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -433,3 +436,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 14
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 14
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visibility_var",
+// CHECK-NEXT:  "mangledName": "visibility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 623,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 643,
+// CHECK-NEXT:  "col": 37,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"visibility": "hidden"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -551,6 +551,11 @@
   JOS.attribute("section_name", SA->getName());
 }
 
+void JSONNodeDumper::VisitVisibilityAttr(const VisibilityAttr *VA) {
+  JOS.attribute("visibility", VisibilityAttr::ConvertVisibilityTypeToStr(
+  VA->getVisibility()));
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -213,6 +213,7 @@
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
+  void VisitVisibilityAttr(const VisibilityAttr *VA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,9 @@
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visibility_var;
+
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -433,3 +436,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 14
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 14
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visibility_var",
+// CHECK-NEXT:  "mangledName": "visibility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 623,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:

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

2023-08-13 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 549715.
yronglin added a comment.

Handle default argument and dependent context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153701

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-for-range-lifetime.cpp

Index: clang/test/AST/ast-dump-for-range-lifetime.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-for-range-lifetime.cpp
@@ -0,0 +1,355 @@
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-linux-gnu -fcxx-exceptions -ast-dump %s \
+// RUN: | FileCheck -strict-whitespace %s
+
+namespace P2718R0 {
+
+// Test basic
+struct A {
+  int a[3] = {1, 2, 3};
+  A() {}
+  ~A() {}
+  const int *begin() const { return a; }
+  const int *end() const { return a + 3; }
+  A& r() { return *this; }
+  A g() { return A(); }
+};
+
+A g() { return A(); }
+const A (const A ) { return t; }
+
+void test1() {
+  [[maybe_unused]] int sum = 0;
+  // CHECK: FunctionDecl {{.*}} test1 'void ()'
+  // CHECK:  |   `-CXXForRangeStmt {{.*}}
+  // CHECK-NEXT: | |-<<>>
+  // CHECK-NEXT: | |-DeclStmt {{.*}}
+  // CHECK-NEXT: | | `-VarDecl {{.*}} implicit used __range1 'const A &' cinit
+  // CHECK-NEXT: | |   `-ExprWithCleanups {{.*}} 'const A':'const P2718R0::A' lvalue
+  // CHECK-NEXT: | | `-CallExpr {{.*}} 'const A':'const P2718R0::A' lvalue
+  // CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} 'const A &(*)(const A &)' 
+  // CHECK-NEXT: | |   | `-DeclRefExpr {{.*}} 'const A &(const A &)' lvalue Function {{.*}} 'f1' 'const A &(const A &)'
+  // CHECK-NEXT: | |   `-MaterializeTemporaryExpr {{.*}} 'const A':'const P2718R0::A' lvalue extended by Var {{.*}} '__range1' 'const A &'
+  // CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} 'const A':'const P2718R0::A' 
+  // CHECK-NEXT: | |   `-CXXBindTemporaryExpr {{.*}} 'A':'P2718R0::A' (CXXTemporary {{.*}})
+  // CHECK-NEXT: | | `-CallExpr {{.*}} 'A':'P2718R0::A'
+  // CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} 'A (*)()' 
+  // CHECK-NEXT: | | `-DeclRefExpr {{.*}} 'A ()' lvalue Function {{.*}} 'g' 'A ()'
+  for (auto e : f1(g()))
+sum += e;
+}
+
+struct B : A {};
+int ((const A *))[3];
+const A *g(const A &);
+void bar(int) {}
+
+void test2() {
+  // CHECK: FunctionDecl {{.*}} test2 'void ()'
+  // CHECK:  |   `-CXXForRangeStmt {{.*}}
+  // CHECK-NEXT: | |-<<>>
+  // CHECK-NEXT: | |-DeclStmt {{.*}}
+  // CHECK-NEXT: | | `-VarDecl {{.*}} implicit used __range1 'int (&)[3]' cinit
+  // CHECK-NEXT: | |   `-ExprWithCleanups {{.*}} 'int[3]':'int[3]' lvalue
+  // CHECK-NEXT: | | `-CallExpr {{.*}} 'int[3]':'int[3]' lvalue
+  // CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} 'int (&(*)(const A *))[3]' 
+  // CHECK-NEXT: | |   | `-DeclRefExpr {{.*}} 'int (&(const A *))[3]' lvalue Function {{.*}} 'f' 'int (&(const A *))[3]'
+  // CHECK-NEXT: | |   `-CallExpr {{.*}} 'const A *'
+  // CHECK-NEXT: | | |-ImplicitCastExpr {{.*}} 'const A *(*)(const A &)' 
+  // CHECK-NEXT: | | | `-DeclRefExpr {{.*}} 'const A *(const A &)' lvalue Function {{.*}} 'g' 'const A *(const A &)'
+  // CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} 'const A':'const P2718R0::A' lvalue 
+  // CHECK-NEXT: | |   `-MaterializeTemporaryExpr {{.*}} 'const B':'const P2718R0::B' lvalue extended by Var {{.*}} '__range1' 'int (&)[3]'
+  // CHECK-NEXT: | | `-ImplicitCastExpr {{.*}} 'const B':'const P2718R0::B' 
+  // CHECK-NEXT: | |   `-CXXBindTemporaryExpr {{.*}} 'B':'P2718R0::B' (CXXTemporary {{.*}})
+  // CHECK-NEXT: | | `-CXXTemporaryObjectExpr {{.*}} 'B':'P2718R0::B' 'void () noexcept(false)' zeroing
+  for (auto e : f(g(B(
+bar(e);
+}
+
+// Test discard statement.
+struct LockGuard {
+LockGuard() {}
+~LockGuard() {}
+};
+
+void test3() {
+  int v[] = {42, 17, 13};
+
+  // CHECK: FunctionDecl {{.*}} test3 'void ()'
+  // CHECK:  -CXXForRangeStmt {{.*}}
+  // CHECK-NEXT:  |-<<>>
+  // CHECK-NEXT:  |-DeclStmt {{.*}}
+  // CHECK-NEXT:  | `-VarDecl {{.*}} implicit used __range1 'int (&)[3]' cinit
+  // CHECK-NEXT:  |   `-ExprWithCleanups {{.*}} 'int[3]' lvalue
+  // CHECK-NEXT:  | `-BinaryOperator {{.*}} 'int[3]' lvalue ','
+  // CHECK-NEXT:  |   |-CXXStaticCastExpr {{.*}} 'void' static_cast 
+  // CHECK-NEXT:  |   | `-MaterializeTemporaryExpr {{.*}} 'LockGuard':'P2718R0::LockGuard' xvalue extended by Var {{.*}} '__range1' 'int (&)[3]'
+  // CHECK-NEXT:  |   |   `-CXXBindTemporaryExpr {{.*}} 'LockGuard':'P2718R0::LockGuard' (CXXTemporary {{.*}})
+  // 

[PATCH] D157813: [VE][Clang] Change to enable VPU flag by default

2023-08-13 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added a reviewer: efocht.
kaz7 added projects: clang, VE.
Herald added a project: All.
kaz7 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, MaskRay.

Change to enable VPU flag for VE by default in order to support vector
intrinsics from clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157813

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/VE.cpp
  clang/test/Driver/ve-features.c


Index: clang/test/Driver/ve-features.c
===
--- /dev/null
+++ clang/test/Driver/ve-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target ve-unknown-linux-gnu -### %s -mvevpu 2>&1 | FileCheck 
%s -check-prefix=VEVPU
+// RUN: %clang -target ve-unknown-linux-gnu -### %s -mno-vevpu 2>&1 | 
FileCheck %s -check-prefix=NO-VEVPU
+// RUN: %clang -target ve-unknown-linux-gnu -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT
+
+// VEVPU: "-target-feature" "+vpu"
+// NO-VEVPU-NOT: "-target-feature" "+vpu"
+// DEFAULT: "-target-feature" "+vpu"
Index: clang/lib/Driver/ToolChains/Arch/VE.cpp
===
--- clang/lib/Driver/ToolChains/Arch/VE.cpp
+++ clang/lib/Driver/ToolChains/Arch/VE.cpp
@@ -18,4 +18,17 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  // Defaults.
+  bool EnableVPU = true;
+
+  // Whether to enable VPU registers and isel.
+  if (auto *A = Args.getLastArg(options::OPT_mvevpu, options::OPT_mno_vevpu)) {
+if (A->getOption().matches(options::OPT_mno_vevpu))
+  EnableVPU = false;
+  }
+
+  // VVP
+  if (EnableVPU)
+Features.push_back("+vpu");
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -202,6 +202,8 @@
Group, Flags<[CoreOption]>, DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
+def m_ve_Features_Group : OptionGroup<"">,
+  Group, DocName<"VE">;
 
 def m_libc_Group : OptionGroup<"">, Group,
Flags<[HelpHidden]>;
@@ -5160,6 +5162,14 @@
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
 } // let Flags = [TargetSpecific]
 
+// VE feature flags
+let Flags = [TargetSpecific, CC1Option] in {
+def mvevpu : Flag<["-"], "mvevpu">, Group,
+  HelpText<"Emit VPU instructions for VE">;
+def mno_vevpu : Flag<["-"], "mno-vevpu">, Group,
+  HelpText<"Do not emit VPU instructions for VE">;
+} // let Flags = [TargetSpecific, CC1Option]
+
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.


Index: clang/test/Driver/ve-features.c
===
--- /dev/null
+++ clang/test/Driver/ve-features.c
@@ -0,0 +1,7 @@
+// RUN: %clang -target ve-unknown-linux-gnu -### %s -mvevpu 2>&1 | FileCheck %s -check-prefix=VEVPU
+// RUN: %clang -target ve-unknown-linux-gnu -### %s -mno-vevpu 2>&1 | FileCheck %s -check-prefix=NO-VEVPU
+// RUN: %clang -target ve-unknown-linux-gnu -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
+// VEVPU: "-target-feature" "+vpu"
+// NO-VEVPU-NOT: "-target-feature" "+vpu"
+// DEFAULT: "-target-feature" "+vpu"
Index: clang/lib/Driver/ToolChains/Arch/VE.cpp
===
--- clang/lib/Driver/ToolChains/Arch/VE.cpp
+++ clang/lib/Driver/ToolChains/Arch/VE.cpp
@@ -18,4 +18,17 @@
 using namespace llvm::opt;
 
 void ve::getVETargetFeatures(const Driver , const ArgList ,
- std::vector ) {}
+ std::vector ) {
+  // Defaults.
+  bool EnableVPU = true;
+
+  // Whether to enable VPU registers and isel.
+  if (auto *A = Args.getLastArg(options::OPT_mvevpu, options::OPT_mno_vevpu)) {
+if (A->getOption().matches(options::OPT_mno_vevpu))
+  EnableVPU = false;
+  }
+
+  // VVP
+  if (EnableVPU)
+Features.push_back("+vpu");
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -202,6 +202,8 @@
Group, Flags<[CoreOption]>, DocName<"X86">;
 def m_riscv_Features_Group : OptionGroup<"">,
  Group, DocName<"RISC-V">;
+def m_ve_Features_Group : OptionGroup<"">,
+  Group, DocName<"VE">;
 
 def m_libc_Group : OptionGroup<"">, Group,
Flags<[HelpHidden]>;
@@ -5160,6 +5162,14 @@
 def mno_vzeroupper : 

[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

2023-08-13 Thread QuillPusher via Phabricator via cfe-commits
QuillPusher added a comment.

@Krishna-13-cyber  added Graphviz code snippets to replace all .png images




Comment at: clang/docs/ClangRepl.rst:248-250
+.. image:: valuesynth.png
+   :align: center
+   :alt: valuesynth design

v.g.vassilev wrote:
> Can we replace that with its graphviz version?
.. graphviz::
:name: valuesynthesis
:caption: Value Synthesis
:alt: Shows how an object of type 'Value' is synthesized
:align: center

 digraph "valuesynthesis" {
 rankdir="LR";
 graph [fontname="Verdana", fontsize="12"];
 node [fontname="Verdana", fontsize="12"];
 edge [fontname="Sans", fontsize="9"];

 start [label=" Create an Object \n 'Last Value' \n of type 'Value' ", 
shape="note", fontcolor=white, fillcolor="#ff", style=filled];
 assign [label=" Assign the result \n to the 'LastValue' \n (based on 
respective \n Memory Allocation \n scenario) ", shape="box"]
 print [label=" Pretty Print \n the Value Object ", shape="Msquare", 
fillcolor="yellow", style=filled];
 start -> assign;
 assign -> print;

   subgraph SynthesizeExpression {
 synth [label=" SynthesizeExpr() ", shape="note", fontcolor=white, 
fillcolor="#ff", style=filled];
 mem [label=" New Memory \n Allocation? ", shape="diamond"];
 withaloc [label=" SetValueWithAlloc() ", shape="box"];
 noaloc [label=" SetValueNoAlloc() ", shape="box"];
 right [label=" 1. RValue Structure \n (a temporary value)", 
shape="box"];
 left2 [label=" 2. LValue Structure \n (a variable with \n an 
address)", shape="box"];
 left3 [label=" 3. Built-In Type \n (int, float, etc.)", 
shape="box"];
 output [label=" move to 'Assign' step ", shape="box"];

 synth -> mem;
 mem -> withaloc [label="Yes"];
 mem -> noaloc [label="No"];
 withaloc -> right;
 noaloc -> left2;
 noaloc -> left3;
 right -> output;
 left2 -> output;
 left3 -> output;
 }
 output -> assign;
}



Comment at: clang/docs/ClangRepl.rst:424-427
+
+.. image:: prettyprint.png
+   :align: center
+   :alt: prettyprint design

@Krishna-13-cyber please replace the image reference with the following code:


.. graphviz::
:name: parsing
:caption: Parsing Mechanism
:alt: Shows the Parsing Mechanism for Pretty Printing
:align: center

 digraph "prettyprint" {
 rankdir="LR";
 graph [fontname="Verdana", fontsize="12"];
 node [fontname="Verdana", fontsize="12"];
 edge [fontname="Verdana", fontsize="9"];

 parse [label=" ParseAndExecute() \n in Clang ", shape="box"];
 capture [label=" Capture 'Value' parameter \n for processing? ", 
shape="diamond"];
 use [label="  Use for processing  ", shape="box"];
 dump [label="  Validate and push  \n to dump()", shape="box"];
 callp [label="  call print() function ", shape="box"];
 type [label="  Print the Type \n ReplPrintTypeImpl()", shape="box"];
 data [label="  Print the Data \n ReplPrintDataImpl() ", shape="box"];
 output [label="  Output Pretty Print \n to the user  ", shape="box", 
fontcolor=white, fillcolor="#ff", style=filled];

 parse -> capture [label="Optional 'Value' Parameter"];
 capture -> use [label="Yes"];
 use -> End;
 capture -> dump [label="No"];
 dump -> callp;
 callp -> type;
 callp -> data;
 type -> output;
 data -> output;
}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

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


[PATCH] D157420: [clang] Enable constexpr on LZCNT/POPCNT MS extension intrinsics

2023-08-13 Thread Alejandro Aguirre via Phabricator via cfe-commits
alexguirre added a comment.

Alejandro Aguirre
alexguirre...@gmail.com


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157420

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


[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

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



Comment at: clang/docs/ClangRepl.rst:221
+
+Execution Results Handling features discussed below help extend the Clang-REPL 
+functionality by creating an interface between the execution results of a 

We should probably spell consistently `Clang-Repl`.



Comment at: clang/docs/ClangRepl.rst:248
+
+.. image:: valuesynth.png
+   :align: center

Can we replace that with its graphviz version?



Comment at: clang/docs/ClangRepl.rst:264
+The Value object is essentially used to create a mapping between an expression 
+'type' and the 'memory' to be allocated. Built-in types (bool, char, int, 
+float, double, etc.) are simpler, since their memory allocation size is known. 





Comment at: clang/docs/ClangRepl.rst:265
+'type' and the 'memory' to be allocated. Built-in types (bool, char, int, 
+float, double, etc.) are simpler, since their memory allocation size is known. 
+In case of objects, a pointer can be saved, since the size of the object is 





Comment at: clang/docs/ClangRepl.rst:266-267
+float, double, etc.) are simpler, since their memory allocation size is known. 
+In case of objects, a pointer can be saved, since the size of the object is 
+not known.
+





Comment at: clang/docs/ClangRepl.rst:269-274
+For further improvement, the underlying Clang Type is also identified. For 
+example, ``X(char, Char_S)``, where ``Char_S`` is the Clang type. Clang types 
are 
+very efficient, which is important since these will be used in hotspots (high 
+utilization areas of the program). The ``Value.h`` header file has a very low 
+token count and was developed with strict constraints in mind, since it can 
+affect the performance of the interpreter.





Comment at: clang/docs/ClangRepl.rst:276-278
+This also enables the user to receive the computed 'type' back in their code 
+and then transform the type into something else (e.g., transform a double into 
+a float). Normally, the compiler can handle these conversions transparently, 





Comment at: clang/docs/ClangRepl.rst:284
+On-request conversions can help improve the user experience, by allowing 
+conversion to a desired 'to' type, when the 'from' type is unknown or unclear
+





Comment at: clang/docs/ClangRepl.rst:296-298
+For example, the CPPYY code makes use of this feature to enable running 
+C++ within Python. It enables transporting values/information between C++ 
+and Python.

QuillPusher wrote:
> @Krishna-13-cyber 
> 
> Please change CPPYY to cppyy
> 
> I just saw they use small caps on their official website




Comment at: clang/docs/ClangRepl.rst:352
+
+In Clang-REPL there is **interpreted code**, and this feature adds a 'value' 
+runtime that can talk to the **compiled code**.





Comment at: clang/docs/ClangRepl.rst:404
+this feature added to upstream Clang repo has essentially extended the syntax 
of
+C++,so that it can be more helpful for people that are writing code for data 
+science applications.





Comment at: clang/docs/ClangRepl.rst:419
+
+The Interpreter in Clang-REPL (``interpreter.cpp``) includes the function 
+``ParseAndExecute()`` that can accept a 'Value' parameter to capture the 
result. 





Comment at: clang/docs/ClangRepl.rst:461
+
+This feature uses a new token (annot_repl_input_end) to consider printing the 
+value of an expression if it doesn't end with a semicolon. When parsing an 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

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


[PATCH] D156858: Add Documentation for Execution Results Handling in Clang-REPL

2023-08-13 Thread QuillPusher via Phabricator via cfe-commits
QuillPusher added inline comments.



Comment at: clang/docs/ClangRepl.rst:393-396
+
+.. image:: autoprint.png
+   :align: center
+   :alt: autoprint design

Please replace the image reference with the following Graphviz code (do not 
delete the image .png for now, we need to commit and see if graphviz works out 
of the box).

.. graphviz::
:name: automaticprintf
:caption: Automatic PrintF
:alt: Shows how Automatic PrintF can be used
:align: center

 digraph "AutomaticPrintF" {
 size="6,4";
 rankdir="LR";
 graph [fontname="Verdana", fontsize="12"];
 node [fontname="Verdana", fontsize="12"];
 edge [fontname="Sans", fontsize="9"];

 manual [label=" Manual PrintF ", shape="box"];
 int1 [label=" int ( &) 42 ", shape="box"]
 auto [label=" Automatic PrintF ", shape="box"];
 int2 [label=" int ( &) 42 ", shape="box"]

 auto -> int2 [label="int x = 42; \n x"];
 manual -> int1 [label="int x = 42; \n printf((int &) %d 
\\n, x);"];
 }



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156858

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


[PATCH] D157420: [clang] Enable constexpr on LZCNT/POPCNT MS extension intrinsics

2023-08-13 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - cheers

@alexguirre  Please post your full name / email and I'll commit this for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157420

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


[clang] 094539c - Fix Wdocumentation "unknown parameter". NFC.

2023-08-13 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-08-13T11:33:00+01:00
New Revision: 094539cfcb46f55824402565e5c18580df689a67

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

LOG: Fix Wdocumentation "unknown parameter". NFC.

Added: 


Modified: 
clang/include/clang/Lex/HeaderSearch.h

Removed: 




diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 37cdbc7519a4ef..059b143535faab 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -670,9 +670,6 @@ class HeaderSearch {
 
   /// Retrieve all the modules corresponding to the given file.
   ///
-  /// \param AllowCreation Whether to allow inference of a new submodule, or to
-  ///only return existing known modules.
-  ///
   /// \ref findModuleForHeader should typically be used instead of this.
   ArrayRef
   findAllModulesForHeader(FileEntryRef File) const;



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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

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

I notices some inconsistency between this `-fstrict-flex-arrays=N` flag and 
what the `RecordDecl::hasFlexibleArrayMember()` returns for an example like 
this:

  typedef unsigned long size_t;
  void *malloc(size_t);
  void free(void *);
  
  void field(void) {
struct vec { size_t len; int data[0]; };
struct vec *a = (struct vec*) malloc(sizeof(struct vec) + 10*sizeof(int));
free(a);
  }

In the example, I use don't specify the `-fstrict-flex-arrays` flag, thus it 
should default to `0`, which means that any trailing arrays (let it be 
incomplete or of any concrete size), to be considered as a 
flexible-array-member.
In the AST, for the `RecordDecl`, I'd expect that the 
`hasFlexibleArrayMember()` member function would reflect this, and return 
`true`, however, it returns `false` instead.
It does so because in SemaDecl.cpp Sema::ActOnFields() 

 before doing some FAM-related checks and diagnostics it performs this check, 
guarding that branch:

  bool IsLastField = (i + 1 == Fields.end());
  if (FDTy->isFunctionType()) {
// ...
  } else if (FDTy->isIncompleteArrayType() &&
 (Record || isa(EnclosingDecl))) {
//This is the FAM handling branch.
// ...
  }

Consequently, Sema will only set the bit for `hasFlexibleArrayMember` if the 
array is //incomplete//.
So my question is, if the `RecordDecl::hasFlexibleArrayMember()` should be 
consistent with the `-fstrict-flex-arrays` flag, or not?
@serge-sans-paille @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D157794: [Driver] Make /Zi and /Z7 aliases of -g rather than handling them specially

2023-08-13 Thread Justin Bogner via Phabricator via cfe-commits
bogner added inline comments.



Comment at: clang/test/Driver/cl-options.c:567
 
-// This test was super sneaky: "/Z7" means "line-tables", but "-gdwarf" occurs
-// later on the command line, so it should win. Interestingly the cc1 arguments
-// came out right, but had wrong semantics, because an invariant assumed by
-// CompilerInvocation was violated: it expects that at most one of {gdwarfN,
-// line-tables-only} appear. If you assume that, then you can safely use
-// Args.hasArg to test whether a boolean flag is present without caring
-// where it appeared. And for this test, it appeared to the left of -gdwarf
-// which made it "win". This test could not detect that bug.
+// If We specify both /Z7 and -gdwarf we should get dwarf, not codeview.
 // RUN: %clang_cl /Z7 -gdwarf /c -### -- %s 2>&1 | FileCheck 
-check-prefix=Z7_gdwarf %s

rnk wrote:
> I think Meta folks depend on a mode that emits both codeview and DWARF. 
> +@smeenai
Hopefully if that's the case there's a better test somewhere than this one that 
discusses in detail how `/Z7` is an alias for `-gline-tables-only`, which 
hasn't been true since 2017.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157794

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


[PATCH] D157810: [clang][ExtractAPI] Create extractapi::RecordLocation

2023-08-13 Thread Ankur Saini via Phabricator via cfe-commits
Arsenic updated this revision to Diff 549691.
Arsenic added a comment.

Fix minor typo in code comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157810

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/tools/libclang/CXExtractAPI.cpp

Index: clang/tools/libclang/CXExtractAPI.cpp
===
--- clang/tools/libclang/CXExtractAPI.cpp
+++ clang/tools/libclang/CXExtractAPI.cpp
@@ -61,9 +61,12 @@
 Context.getSourceManager().getPresumedLoc(Decl->getLocation());
 LinkageInfo Linkage = Decl->getLinkageAndVisibility();
 DocComment Comment;
-if (auto *RawComment = fetchRawCommentForDecl(Interface))
-  Comment = RawComment->getFormattedLines(Context.getSourceManager(),
-  Context.getDiagnostics());
+if (auto *RawComment = fetchRawCommentForDecl(Interface)) {
+  auto RawCommentVec = RawComment->getFormattedLines(
+  Context.getSourceManager(), Context.getDiagnostics());
+  std::copy(RawCommentVec.begin(), RawCommentVec.end(),
+std::back_inserter(Comment));
+}
 
 // Build declaration fragments and sub-heading by generating them for the
 // interface.
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -14,6 +14,7 @@
 #include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Version.h"
+#include "clang/ExtractAPI/API.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
@@ -105,7 +106,7 @@
 }
 
 /// Serialize a source position.
-Object serializeSourcePosition(const PresumedLoc ) {
+Object serializeSourcePosition(const RecordLocation ) {
   assert(Loc.isValid() && "invalid source position");
 
   Object SourcePosition;
@@ -120,7 +121,7 @@
 /// \param Loc The presumed location to serialize.
 /// \param IncludeFileURI If true, include the file path of \p Loc as a URI.
 /// Defaults to false.
-Object serializeSourceLocation(const PresumedLoc ,
+Object serializeSourceLocation(const RecordLocation ,
bool IncludeFileURI = false) {
   Object SourceLocation;
   serializeObject(SourceLocation, "position", serializeSourcePosition(Loc));
@@ -136,8 +137,8 @@
 }
 
 /// Serialize a source range with begin and end locations.
-Object serializeSourceRange(const PresumedLoc ,
-const PresumedLoc ) {
+Object serializeSourceRange(const RecordLocation ,
+const RecordLocation ) {
   Object SourceRange;
   serializeObject(SourceRange, "start", serializeSourcePosition(BeginLoc));
   serializeObject(SourceRange, "end", serializeSourcePosition(EndLoc));
Index: clang/lib/ExtractAPI/API.cpp
===
--- clang/lib/ExtractAPI/API.cpp
+++ clang/lib/ExtractAPI/API.cpp
@@ -45,7 +45,7 @@
 } // namespace
 
 GlobalVariableRecord *
-APISet::addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
+APISet::addGlobalVar(StringRef Name, StringRef USR, RecordLocation Loc,
  AvailabilitySet Availabilities, LinkageInfo Linkage,
  const DocComment , DeclarationFragments Fragments,
  DeclarationFragments SubHeading, bool IsFromSystemHeader) {
@@ -55,7 +55,7 @@
 }
 
 GlobalFunctionRecord *APISet::addGlobalFunction(
-StringRef Name, StringRef USR, PresumedLoc Loc,
+StringRef Name, StringRef USR, RecordLocation Loc,
 AvailabilitySet Availabilities, LinkageInfo Linkage,
 const DocComment , DeclarationFragments Fragments,
 DeclarationFragments SubHeading, FunctionSignature Signature,
@@ -67,7 +67,7 @@
 }
 
 EnumConstantRecord *APISet::addEnumConstant(EnumRecord *Enum, StringRef Name,
-StringRef USR, PresumedLoc Loc,
+StringRef USR, RecordLocation Loc,
 AvailabilitySet Availabilities,
 const DocComment ,
 DeclarationFragments Declaration,
@@ -82,7 +82,7 @@
   return Enum->Constants.emplace_back(std::move(Record)).get();
 }
 
-EnumRecord *APISet::addEnum(StringRef Name, StringRef USR, PresumedLoc Loc,
+EnumRecord *APISet::addEnum(StringRef Name, StringRef USR, RecordLocation Loc,
 AvailabilitySet Availabilities,
   

[PATCH] D157810: [clang][ExtractAPI] Create extractapi::RecordLocation

2023-08-13 Thread Ankur Saini via Phabricator via cfe-commits
Arsenic created this revision.
Arsenic added a reviewer: dang.
Herald added a reviewer: ributzka.
Herald added a project: All.
Arsenic requested review of this revision.
Herald added subscribers: cfe-commits, wangpc.
Herald added a project: clang.

Create and use extractapi::RecordLocation instead of conventional
clang::PresumedLoc to track the location of an APIRecord, this reduces
the dependency of APISet on SourceManager and would help if someone
wants to create APISet from JSON Serialized SymbolGraph.

These changes also add extractapi::CommentLine which is similar to
RawComment::CommentLine but use RecordLocation instead of PresumedLoc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157810

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/tools/libclang/CXExtractAPI.cpp

Index: clang/tools/libclang/CXExtractAPI.cpp
===
--- clang/tools/libclang/CXExtractAPI.cpp
+++ clang/tools/libclang/CXExtractAPI.cpp
@@ -61,9 +61,12 @@
 Context.getSourceManager().getPresumedLoc(Decl->getLocation());
 LinkageInfo Linkage = Decl->getLinkageAndVisibility();
 DocComment Comment;
-if (auto *RawComment = fetchRawCommentForDecl(Interface))
-  Comment = RawComment->getFormattedLines(Context.getSourceManager(),
-  Context.getDiagnostics());
+if (auto *RawComment = fetchRawCommentForDecl(Interface)) {
+  auto RawCommentVec = RawComment->getFormattedLines(
+  Context.getSourceManager(), Context.getDiagnostics());
+  std::copy(RawCommentVec.begin(), RawCommentVec.end(),
+std::back_inserter(Comment));
+}
 
 // Build declaration fragments and sub-heading by generating them for the
 // interface.
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
===
--- clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -14,6 +14,7 @@
 #include "clang/ExtractAPI/Serialization/SymbolGraphSerializer.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Version.h"
+#include "clang/ExtractAPI/API.h"
 #include "clang/ExtractAPI/DeclarationFragments.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
@@ -105,7 +106,7 @@
 }
 
 /// Serialize a source position.
-Object serializeSourcePosition(const PresumedLoc ) {
+Object serializeSourcePosition(const RecordLocation ) {
   assert(Loc.isValid() && "invalid source position");
 
   Object SourcePosition;
@@ -120,7 +121,7 @@
 /// \param Loc The presumed location to serialize.
 /// \param IncludeFileURI If true, include the file path of \p Loc as a URI.
 /// Defaults to false.
-Object serializeSourceLocation(const PresumedLoc ,
+Object serializeSourceLocation(const RecordLocation ,
bool IncludeFileURI = false) {
   Object SourceLocation;
   serializeObject(SourceLocation, "position", serializeSourcePosition(Loc));
@@ -136,8 +137,8 @@
 }
 
 /// Serialize a source range with begin and end locations.
-Object serializeSourceRange(const PresumedLoc ,
-const PresumedLoc ) {
+Object serializeSourceRange(const RecordLocation ,
+const RecordLocation ) {
   Object SourceRange;
   serializeObject(SourceRange, "start", serializeSourcePosition(BeginLoc));
   serializeObject(SourceRange, "end", serializeSourcePosition(EndLoc));
Index: clang/lib/ExtractAPI/API.cpp
===
--- clang/lib/ExtractAPI/API.cpp
+++ clang/lib/ExtractAPI/API.cpp
@@ -45,7 +45,7 @@
 } // namespace
 
 GlobalVariableRecord *
-APISet::addGlobalVar(StringRef Name, StringRef USR, PresumedLoc Loc,
+APISet::addGlobalVar(StringRef Name, StringRef USR, RecordLocation Loc,
  AvailabilitySet Availabilities, LinkageInfo Linkage,
  const DocComment , DeclarationFragments Fragments,
  DeclarationFragments SubHeading, bool IsFromSystemHeader) {
@@ -55,7 +55,7 @@
 }
 
 GlobalFunctionRecord *APISet::addGlobalFunction(
-StringRef Name, StringRef USR, PresumedLoc Loc,
+StringRef Name, StringRef USR, RecordLocation Loc,
 AvailabilitySet Availabilities, LinkageInfo Linkage,
 const DocComment , DeclarationFragments Fragments,
 DeclarationFragments SubHeading, FunctionSignature Signature,
@@ -67,7 +67,7 @@
 }
 
 EnumConstantRecord *APISet::addEnumConstant(EnumRecord *Enum, StringRef Name,
-StringRef USR, PresumedLoc Loc,
+StringRef USR, RecordLocation Loc,
 AvailabilitySet 

[PATCH] D157497: feat: Migrate isArch16Bit

2023-08-13 Thread Evgeniy Makarev via Phabricator via cfe-commits
Pivnoy updated this revision to Diff 549688.
Pivnoy added a comment.
Herald added subscribers: luke, pmatos, frasercrmck, luismarques, apazos, 
sameer.abuasal, pengfei, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, 
rogfer01, edward-jones, zzheng, MaskRay, jrtc27, niosHD, sabuasal, johnrusso, 
rbar, kbarton, jgravelle-google, arichardson, sbc100, nemanjai, dschuff, emaste.

Add test for isArch32Bit to TripleUtilsTest


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157497

Files:
  clang/lib/AST/MicrosoftCXXABI.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Gnu.h
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/TargetParser/Triple.h
  llvm/include/llvm/TargetParser/TripleUtils.h
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/lib/BinaryFormat/MachO.cpp
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/ProfileData/InstrProfCorrelator.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/LoongArch/LoongArchTargetMachine.cpp
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/TripleUtils.cpp
  llvm/lib/XRay/InstrumentationMap.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
  llvm/unittests/TargetParser/CMakeLists.txt
  llvm/unittests/TargetParser/TripleTest.cpp
  llvm/unittests/TargetParser/TripleUtilsTest.cpp

Index: llvm/unittests/TargetParser/TripleUtilsTest.cpp
===
--- /dev/null
+++ llvm/unittests/TargetParser/TripleUtilsTest.cpp
@@ -0,0 +1,179 @@
+//===--- TripleUtils.cpp - TripleUtils unit tests
+//---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/TargetParser/TripleUtils.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+TEST(TripleUtilsTest, CheckArchBitWidth) {
+  Triple T;
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::arm);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hexagon);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::mips64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::msp430);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_TRUE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::ppc64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::x86_64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::amdil64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::hsail64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir);
+  EXPECT_TRUE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  T.setArch(Triple::spir64);
+  EXPECT_FALSE(llvm::TripleUtils::isArch32Bit(T));
+  EXPECT_FALSE(llvm::TripleUtils::isArch16Bit(T));
+
+  

[PATCH] D157808: [clang] Add missing field to VisibilityAttr json AST dump

2023-08-13 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: aaron.ballman.
Herald added a project: All.
serge-sans-paille requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157808

Files:
  clang/include/clang/AST/JSONNodeDumper.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/test/AST/ast-dump-attr-json.cpp


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,8 @@
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visbility_var;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -433,3 +435,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visbility_var",
+// CHECK-NEXT:  "mangledName": "visbility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 623,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 10
+// CHECK-NEXT: },
+// CHECK-NEXT: "end": {
+// CHECK-NEXT:  "offset": 643,
+// CHECK-NEXT:  "col": 37,
+// CHECK-NEXT:  "tokLen": 1
+// CHECK-NEXT: }
+// CHECK-NEXT:},
+// CHECK-NEXT:"visibility": "hidden"
+// CHECK-NEXT:   }
+// CHECK-NEXT:  ]
+// CHECK-NEXT: }
Index: clang/lib/AST/JSONNodeDumper.cpp
===
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -551,6 +551,10 @@
   JOS.attribute("section_name", SA->getName());
 }
 
+void JSONNodeDumper::VisitVisibilityAttr(const VisibilityAttr *VA) {
+  JOS.attribute("visibility",  
VisibilityAttr::ConvertVisibilityTypeToStr(VA->getVisibility()));
+}
+
 void JSONNodeDumper::VisitTypedefType(const TypedefType *TT) {
   JOS.attribute("decl", createBareDeclRef(TT->getDecl()));
   if (!TT->typeMatchesDecl())
Index: clang/include/clang/AST/JSONNodeDumper.h
===
--- clang/include/clang/AST/JSONNodeDumper.h
+++ clang/include/clang/AST/JSONNodeDumper.h
@@ -213,6 +213,7 @@
   void VisitDeprecatedAttr(const DeprecatedAttr *DA);
   void VisitUnavailableAttr(const UnavailableAttr *UA);
   void VisitSectionAttr(const SectionAttr *SA);
+  void VisitVisibilityAttr(const VisibilityAttr *VA);
 
   void VisitTypedefType(const TypedefType *TT);
   void VisitUsingType(const UsingType *TT);


Index: clang/test/AST/ast-dump-attr-json.cpp
===
--- clang/test/AST/ast-dump-attr-json.cpp
+++ clang/test/AST/ast-dump-attr-json.cpp
@@ -17,6 +17,8 @@
 
 __attribute__ ((section ("SECTION_NAME"))) int section_var;
 
+__attribute__ ((visibility ("hidden"))) int visbility_var;
+
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 // using --filters=VarDecl
 
@@ -433,3 +435,50 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
+
+
+// CHECK-NOT: {{^}}Dumping
+// CHECK:  "kind": "VarDecl",
+// CHECK-NEXT:  "loc": {
+// CHECK-NEXT:   "offset": 651,
+// CHECK-NEXT:   "line": 20,
+// CHECK-NEXT:   "col": 45,
+// CHECK-NEXT:   "tokLen": 13
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "range": {
+// CHECK-NEXT:   "begin": {
+// CHECK-NEXT:"offset": 607,
+// CHECK-NEXT:"col": 1,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   },
+// CHECK-NEXT:   "end": {
+// CHECK-NEXT:"offset": 651,
+// CHECK-NEXT:"col": 45,
+// CHECK-NEXT:"tokLen": 13
+// CHECK-NEXT:   }
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "name": "visbility_var",
+// CHECK-NEXT:  "mangledName": "visbility_var",
+// CHECK-NEXT:  "type": {
+// CHECK-NEXT:   "qualType": "int"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  "inner": [
+// CHECK-NEXT:   {
+// CHECK-NEXT:"id": "0x{{.*}}",
+// CHECK-NEXT:"kind": "VisibilityAttr",
+// CHECK-NEXT:"range": {
+// CHECK-NEXT: "begin": {
+// CHECK-NEXT:  "offset": 623,
+// CHECK-NEXT:  "col": 17,
+// CHECK-NEXT:  "tokLen": 10
+// 

[PATCH] D156605: [clangd][CodeComplete] Improve FunctionCanBeCall

2023-08-13 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for the patch, these are nice improvements




Comment at: clang-tools-extra/clangd/CodeCompletionStrings.cpp:258
 case CodeCompletionString::CK_RightParen:
+  if (DropFunctionArguments &&
+  ResultKind == CodeCompletionResult::RK_Declaration)

It looks like we are assuming two things:

 1. Any LeftParen in an RK_Declaration starts a function argument list
 2. Everything that comes after the function argument list can be discarded

I think these assumptions are fine to make, but let's be explicit about them in 
a comment



Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:536
+template 
+void generic(T);
+template 

Suggestion: it would be slightly more interesting to make the function 
signature `generic(U)`. Then, the function can be called as `generic(u)` 
(with the template parameter `U` deduced), and the 
[LastDeducibleArgument](https://searchfox.org/llvm/rev/bd7c6e3c48e9281ceeaae3a93cc493b35a3c9f29/clang/lib/Sema/SemaCodeComplete.cpp#3553)
 logic should make sure that only `` is added to the code completion string, 
not ``.



Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:580
 auto Results = completions(TU, P, /*IndexSymbols*/ {}, Opts);
 EXPECT_THAT(Results.Completions,
 Contains(AllOf(named("method"), snippetSuffix("";

Since you're updating this test anyways, could you add `signature()` matchers 
for the non-template cases as well please?



Comment at: 
clang-tools-extra/clangd/unittests/CodeCompletionStringsTests.cpp:178
+  /*DropFunctionArguments=*/true);
+  EXPECT_EQ(Signature, "(arg1, arg2)");
+  EXPECT_EQ(Snippet, "<${1:typename T}, ${2:int U}>");

Maybe add:

```
// Arguments dropped from snippet, kept in signature
```

so someone reading the test knows it's deliberate



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:345
   void AddResult(Result R, DeclContext *CurContext, NamedDecl *Hiding,
- bool InBaseClass);
+ bool InBaseClass, QualType BaseType);
 

The word "base" is a bit overloaded in this signature; in the parameter 
`InBaseClass` it refers to inheritance, but in `BaseType` it refers to the base 
expression of a `MemberExpr`.

Maybe we can name the new parameter `BaseExprType` to avoid confusion?



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:1285
 Result.ShadowDecl = Using;
 AddResult(Result, CurContext, Hiding);
 return;

Should we propagate `BaseType` into this recursive call?



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:1425
+R.FunctionCanBeCall =
+MaybeDerived == MaybeBase || 
MaybeDerived->isDerivedFrom(MaybeBase);
+  }

Is there any situation where `MaybeDerived == MaybeBase || 
MaybeDerived->isDerivedFrom(MaybeBase)` is false?

I am wondering if we can simplify this to:

```
if (!BaseType.isNull()) {
  R.FunctionCanBeCall = true;
}
```



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3577
   // containing all of the arguments up to the first deducible argument.
+  // Or, if this isn't a call, emit all the template arguments
+  // to disambiguate the (potential) overloads.

1. If this is not a call, we can avoid running the 
`Sema::MarkDeducedTemplateParameters` operation altogether.

2. A future improvement we could consider: if this is not a call, try to detect 
cases where the template parameters can be deduced from the surrounding context 
(["Deducing template arguments taking the address of a function template 
"](https://eel.is/c++draft/temp.deduct.funcaddr)). Maybe add a FIXME for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156605

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