[clang] 561d307 - Hook up Haiku AArch64 and RISCV64 support

2023-09-02 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-09-02T03:17:16-04:00
New Revision: 561d3076aa6a3de5ae3afcc1f96630df3943c921

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

LOG: Hook up Haiku AArch64 and RISCV64 support

Added: 


Modified: 
clang/lib/Basic/Targets.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 380510e22143d2..bdc570901bdf06 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -148,6 +148,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Fuchsia:
   return std::make_unique>(Triple,
   Opts);
+case llvm::Triple::Haiku:
+  return std::make_unique>(Triple,
+  Opts);
 case llvm::Triple::Linux:
   switch (Triple.getEnvironment()) {
   default:
@@ -449,6 +452,9 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 case llvm::Triple::Fuchsia:
   return std::make_unique>(Triple,
 Opts);
+case llvm::Triple::Haiku:
+  return std::make_unique>(Triple,
+Opts);
 case llvm::Triple::Linux:
   switch (Triple.getEnvironment()) {
   default:



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


[clang-tools-extra] [clang-tidy] readability-identifier-naming - fix StructCase and UnionCase in C (PR #65202)

2023-09-02 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL opened 
https://github.com/llvm/llvm-project/pull/65202
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] readability-identifier-naming - fix StructCase and UnionCase in C (PR #65202)

2023-09-02 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL labeled 
https://github.com/llvm/llvm-project/pull/65202
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] readability-identifier-naming - fix StructCase and UnionCase in C (PR #65202)

2023-09-02 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL review_requested 
https://github.com/llvm/llvm-project/pull/65202
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] readability-identifier-naming - fix StructCase and UnionCase in C (PR #65202)

2023-09-02 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL review_requested 
https://github.com/llvm/llvm-project/pull/65202
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] readability-identifier-naming - fix StructCase and UnionCase in C (PR #65202)

2023-09-02 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL review_requested 
https://github.com/llvm/llvm-project/pull/65202
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159397: [StaticAnalyzer] Use switch statement in MallocChecker::performKernelMalloc. NFC

2023-09-02 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: vabridgers, NoQ.
brad added a project: clang.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, a.sidorin, szepet, baloghadamsoftware.
Herald added a project: All.
brad requested review of this revision.

Use switch statement in MallocChecker::performKernelMalloc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159397

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1141,22 +1141,28 @@
   llvm::Triple::OSType OS = Ctx.getTargetInfo().getTriple().getOS();
 
   if (!KernelZeroFlagVal) {
-if (OS == llvm::Triple::FreeBSD)
+switch (OS) {
+case llvm::Triple::FreeBSD:
   KernelZeroFlagVal = 0x0100;
-else if (OS == llvm::Triple::NetBSD)
+  break;
+case llvm::Triple::NetBSD:
   KernelZeroFlagVal = 0x0002;
-else if (OS == llvm::Triple::OpenBSD)
+  break;
+case llvm::Triple::OpenBSD:
   KernelZeroFlagVal = 0x0008;
-else if (OS == llvm::Triple::Linux)
+  break;
+case llvm::Triple::Linux:
   // __GFP_ZERO
   KernelZeroFlagVal = 0x8000;
-else
+  break;
+default:
   // FIXME: We need a more general way of getting the M_ZERO value.
   // See also: O_CREAT in UnixAPIChecker.cpp.
 
   // Fall back to normal malloc behavior on platforms where we don't
   // know M_ZERO.
   return std::nullopt;
+}
   }
 
   // We treat the last argument as the flags argument, and callers fall-back to


Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1141,22 +1141,28 @@
   llvm::Triple::OSType OS = Ctx.getTargetInfo().getTriple().getOS();
 
   if (!KernelZeroFlagVal) {
-if (OS == llvm::Triple::FreeBSD)
+switch (OS) {
+case llvm::Triple::FreeBSD:
   KernelZeroFlagVal = 0x0100;
-else if (OS == llvm::Triple::NetBSD)
+  break;
+case llvm::Triple::NetBSD:
   KernelZeroFlagVal = 0x0002;
-else if (OS == llvm::Triple::OpenBSD)
+  break;
+case llvm::Triple::OpenBSD:
   KernelZeroFlagVal = 0x0008;
-else if (OS == llvm::Triple::Linux)
+  break;
+case llvm::Triple::Linux:
   // __GFP_ZERO
   KernelZeroFlagVal = 0x8000;
-else
+  break;
+default:
   // FIXME: We need a more general way of getting the M_ZERO value.
   // See also: O_CREAT in UnixAPIChecker.cpp.
 
   // Fall back to normal malloc behavior on platforms where we don't
   // know M_ZERO.
   return std::nullopt;
+}
   }
 
   // We treat the last argument as the flags argument, and callers fall-back to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159398: [AArch64][Clang] Disable out-of-line atomics in ffreestanding env

2023-09-02 Thread Vladislav Khmelevsky via Phabricator via cfe-commits
yota9 created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
yota9 requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, MaskRay.
Herald added a project: clang.

In freestanding environment we don't want extra dependencies on the helpers
that implements atomic operations. So don't enable out-of-line atomics in
this situation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159398

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aarch64-features.c


Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -32,6 +32,12 @@
 // RUN: %clang --target=arm64-unknown-linux -rtlib=compiler-rt \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
 
+// RUN: %clang --target=aarch64-linux-gnu -rtlib=compiler-rt -ffreestanding \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang --target=arm64-unknown-linux -rtlib=compiler-rt -ffreestanding \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
 // RUN: %clang --target=aarch64 -rtlib=compiler-rt \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7494,7 +7494,7 @@
 CmdArgs.push_back("-outline-atomics");
   }
 }
-  } else if (Triple.isAArch64() &&
+  } else if (!Freestanding && Triple.isAArch64() &&
  getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+outline-atomics");


Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -32,6 +32,12 @@
 // RUN: %clang --target=arm64-unknown-linux -rtlib=compiler-rt \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-ON %s
 
+// RUN: %clang --target=aarch64-linux-gnu -rtlib=compiler-rt -ffreestanding \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
+// RUN: %clang --target=arm64-unknown-linux -rtlib=compiler-rt -ffreestanding \
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
+
 // RUN: %clang --target=aarch64 -rtlib=compiler-rt \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-OUTLINE-ATOMICS-OFF %s
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7494,7 +7494,7 @@
 CmdArgs.push_back("-outline-atomics");
   }
 }
-  } else if (Triple.isAArch64() &&
+  } else if (!Freestanding && Triple.isAArch64() &&
  getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+outline-atomics");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159398: [AArch64][Clang] Disable out-of-line atomics in ffreestanding env

2023-09-02 Thread Vladislav Khmelevsky via Phabricator via cfe-commits
yota9 added a comment.

The build failure has nothing to do with the patch and it caused by 
https://reviews.llvm.org/D140612


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159398

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


[clang] 6081d33 - Fix indenting after Haiku addition

2023-09-02 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-09-02T06:27:36-04:00
New Revision: 6081d3342d0e641b03368c0dc8688c3e9ca3c193

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

LOG: Fix indenting after Haiku addition

Added: 


Modified: 
clang/lib/Basic/Targets.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index bdc570901bdf06..2afffc463d18be 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -150,7 +150,7 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
   Opts);
 case llvm::Triple::Haiku:
   return std::make_unique>(Triple,
-  Opts);
+Opts);
 case llvm::Triple::Linux:
   switch (Triple.getEnvironment()) {
   default:
@@ -454,7 +454,7 @@ std::unique_ptr AllocateTarget(const 
llvm::Triple &Triple,
 Opts);
 case llvm::Triple::Haiku:
   return std::make_unique>(Triple,
-Opts);
+  Opts);
 case llvm::Triple::Linux:
   switch (Triple.getEnvironment()) {
   default:



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


[PATCH] D158967: [clang][clangd] Ensure the stack bottom before building AST

2023-09-02 Thread Younan Zhang via Phabricator via cfe-commits
zyounan updated this revision to Diff 77.
zyounan marked an inline comment as done.
zyounan added a comment.

Remove the stray header


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158967

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/test/infinite-instantiation.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang/lib/Frontend/FrontendAction.cpp

Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/Sarif.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -1155,6 +1156,10 @@
   CompilerInstance &CI = getCompilerInstance();
   if (!CI.hasPreprocessor())
 return;
+  // This is a fallback: If the client forgets to invoke this, we mark the
+  // current stack as the bottom. Though not optimal, this could help prevent
+  // stack overflow during deep recursion.
+  clang::noteBottomOfStack();
 
   // FIXME: Move the truncation aspect of this into Sema, we delayed this till
   // here so the source manager would be initialized.
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -29,6 +29,7 @@
 #include "support/ThreadCrashReporter.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
@@ -710,6 +711,9 @@
 };
 
 int clangdMain(int argc, char *argv[]) {
+  // Clang could run on the main thread. e.g., when the flag '-check' or '-sync'
+  // is enabled.
+  clang::noteBottomOfStack();
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   llvm::sys::AddSignalHandler(
Index: clang-tools-extra/clangd/test/infinite-instantiation.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/infinite-instantiation.test
@@ -0,0 +1,13 @@
+// RUN: cp %s %t.cpp
+// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+
+// CHECK: [template_recursion_depth_exceeded]
+
+template 
+constexpr int f(T... args) {
+  return f(0, args...);
+}
+
+int main() {
+  auto i = f();
+}
Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -30,6 +30,7 @@
 #include "support/Trace.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
@@ -108,6 +109,7 @@
   for (unsigned I = 0; I < Opts.ThreadPoolSize; ++I) {
 ThreadPool.runAsync("background-worker-" + llvm::Twine(I + 1),
 [this, Ctx(Context::current().clone())]() mutable {
+  clang::noteBottomOfStack();
   WithContext BGContext(std::move(Ctx));
   Queue.work([&] { Rebuilder.idle(); });
 });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -63,6 +63,7 @@
 #include "support/ThreadCrashReporter.h"
 #include "support/Threading.h"
 #include "support/Trace.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/FunctionExtras.h"
@@ -464,6 +465,10 @@
   }
 
   void run() {
+// We mark the current as the stack bottom so that clang running on this
+// thread can notice the stack usage and prevent stack overflow with best
+// efforts. Same applies to other calls thoughout clangd.
+clang::noteBottomOfStack();
 while (true) {
   std::optional Throttle;
   {
@@ -1383,6 +1388,7 @@
 }
 
 void ASTWorker::run() {
+  clang::noteBottomOfStack();
   while (true) {
 {
   std::unique_lock Lock(Mutex);
@@ -1777,6 +1783,7 @@
Ctx = Context::current().derive(FileBeingProcessed,
std::string(File)),
Action = std::move(Action), this]() mutable {
+clang::noteBottomOfStack();
 ThreadCrashR

[clang-tools-extra] e257c0a - [clang][clangd] Ensure the stack bottom before building AST

2023-09-02 Thread Younan Zhang via cfe-commits

Author: Younan Zhang
Date: 2023-09-02T18:53:06+08:00
New Revision: e257c0a9190637e44e292271103a13d70bec4b03

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

LOG: [clang][clangd] Ensure the stack bottom before building AST

`clang::runWithSufficientStackSpace` requires the address of the
initial stack bottom to prevent potential stack overflows.

In addition, add a fallback to ASTFrontendAction in case any client
forgets to call it when not through CompilerInstance::ExecuteAction,
which is rare.

Fixes https://github.com/clangd/clangd/issues/1745.

Reviewed By: sammccall

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

Added: 
clang-tools-extra/clangd/test/infinite-instantiation.test

Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 6610961b2202d1..57a4897a85efb1 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -34,6 +34,7 @@
 #include "support/MemoryTree.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Format/Format.h"
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -52,8 +53,8 @@
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -112,6 +113,7 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
  FIndex(FIndex),
  // shared_ptr extends lifetime
  Stdlib(Stdlib)]() mutable {
+  clang::noteBottomOfStack();
   IndexFileIn IF;
   IF.Symbols = indexStandardLibrary(std::move(CI), Loc, *TFS);
   if (Stdlib->isBest(LO))

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index dd2ce16147a5dd..324ba1fc8cb895 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -63,6 +63,7 @@
 #include "support/ThreadCrashReporter.h"
 #include "support/Threading.h"
 #include "support/Trace.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/FunctionExtras.h"
@@ -464,6 +465,10 @@ class PreambleThread {
   }
 
   void run() {
+// We mark the current as the stack bottom so that clang running on this
+// thread can notice the stack usage and prevent stack overflow with best
+// efforts. Same applies to other calls thoughout clangd.
+clang::noteBottomOfStack();
 while (true) {
   std::optional Throttle;
   {
@@ -1383,6 +1388,7 @@ void ASTWorker::startTask(llvm::StringRef Name,
 }
 
 void ASTWorker::run() {
+  clang::noteBottomOfStack();
   while (true) {
 {
   std::unique_lock Lock(Mutex);
@@ -1777,6 +1783,7 @@ void TUScheduler::runWithPreamble(llvm::StringRef Name, 
PathRef File,
Ctx = Context::current().derive(FileBeingProcessed,
std::string(File)),
Action = std::move(Action), this]() mutable {
+clang::noteBottomOfStack();
 ThreadCrashReporter ScopedReporter([&Name, &Contents, &Command]() {
   llvm::errs() << "Signalled during preamble action: " << Name << "\n";
   crashDumpCompileCommand(llvm::errs(), Command);

diff  --git a/clang-tools-extra/clangd/index/Background.cpp 
b/clang-tools-extra/clangd/index/Background.cpp
index cbeb74d145401c..5cde4937fee785 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -30,6 +30,7 @@
 #include "support/Trace.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
@@ -108,6 +109,7 @@ BackgroundIndex::BackgroundIndex(
   for (unsigned I = 0; I < Opts.ThreadPoolSize; ++I) {
 ThreadPool.runAsync("background-worker-" + llvm::Twine(I + 1),
 [this, Ctx(Context::current().clone())]() mutable {
+  clang::noteBottomOfStack();
   WithContext BGContext(std::move(Ctx));
   Queue.work([&] { Rebuilder.idle(); });
 });

diff  --git a/clang-tools-extra/clangd/test/infinite-instantiation.test 
b/clang-tools-extra/clangd/test/infinite-instantiation.test
new file mode 100644
index 00..85a1b656f49086
--

[PATCH] D158967: [clang][clangd] Ensure the stack bottom before building AST

2023-09-02 Thread Younan Zhang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe257c0a91906: [clang][clangd] Ensure the stack bottom before 
building AST (authored by zyounan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158967

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/test/infinite-instantiation.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang/lib/Frontend/FrontendAction.cpp

Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LangStandard.h"
 #include "clang/Basic/Sarif.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -1155,6 +1156,10 @@
   CompilerInstance &CI = getCompilerInstance();
   if (!CI.hasPreprocessor())
 return;
+  // This is a fallback: If the client forgets to invoke this, we mark the
+  // current stack as the bottom. Though not optimal, this could help prevent
+  // stack overflow during deep recursion.
+  clang::noteBottomOfStack();
 
   // FIXME: Move the truncation aspect of this into Sema, we delayed this till
   // here so the source manager would be initialized.
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -29,6 +29,7 @@
 #include "support/ThreadCrashReporter.h"
 #include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
@@ -710,6 +711,9 @@
 };
 
 int clangdMain(int argc, char *argv[]) {
+  // Clang could run on the main thread. e.g., when the flag '-check' or '-sync'
+  // is enabled.
+  clang::noteBottomOfStack();
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   llvm::sys::AddSignalHandler(
Index: clang-tools-extra/clangd/test/infinite-instantiation.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/infinite-instantiation.test
@@ -0,0 +1,13 @@
+// RUN: cp %s %t.cpp
+// RUN: not clangd -check=%t.cpp 2>&1 | FileCheck -strict-whitespace %s
+
+// CHECK: [template_recursion_depth_exceeded]
+
+template 
+constexpr int f(T... args) {
+  return f(0, args...);
+}
+
+int main() {
+  auto i = f();
+}
Index: clang-tools-extra/clangd/index/Background.cpp
===
--- clang-tools-extra/clangd/index/Background.cpp
+++ clang-tools-extra/clangd/index/Background.cpp
@@ -30,6 +30,7 @@
 #include "support/Trace.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
@@ -108,6 +109,7 @@
   for (unsigned I = 0; I < Opts.ThreadPoolSize; ++I) {
 ThreadPool.runAsync("background-worker-" + llvm::Twine(I + 1),
 [this, Ctx(Context::current().clone())]() mutable {
+  clang::noteBottomOfStack();
   WithContext BGContext(std::move(Ctx));
   Queue.work([&] { Rebuilder.idle(); });
 });
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -63,6 +63,7 @@
 #include "support/ThreadCrashReporter.h"
 #include "support/Threading.h"
 #include "support/Trace.h"
+#include "clang/Basic/Stack.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
 #include "llvm/ADT/FunctionExtras.h"
@@ -464,6 +465,10 @@
   }
 
   void run() {
+// We mark the current as the stack bottom so that clang running on this
+// thread can notice the stack usage and prevent stack overflow with best
+// efforts. Same applies to other calls thoughout clangd.
+clang::noteBottomOfStack();
 while (true) {
   std::optional Throttle;
   {
@@ -1383,6 +1388,7 @@
 }
 
 void ASTWorker::run() {
+  clang::noteBottomOfStack();
   while (true) {
 {
   std::unique_lock Lock(Mutex);
@@ -1777,6 +1783,7 @@
Ctx = Context::current().derive(FileBeingProcessed,
std::string(File)),

[PATCH] D158883: [Matrix] Try to emit fmuladd for both vector and matrix types

2023-09-02 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

The newly added test cases in ffp-model.c fail on SystemZ, making CI red:
https://lab.llvm.org/buildbot/#/builders/94/builds/16280

The root cause seems to be that by default, the SystemZ back-end targets a 
machine without SIMD support, and therefore vector return types are passed via 
implicit reference according to the ABI:

  
/home/uweigand/sandbox/buildbot/clang-s390x-linux/llvm/clang/test/CodeGen/ffp-model.c:121:12:
 error: CHECK: expected string not found in input
   // CHECK: define{{.*}} <4 x float> @my_m22_muladd
 ^
  :62:28: note: scanning from here
   %4 = fadd fast <2 x float> %2, %3
 ^
  :67:1: note: possible intended match here
  define dso_local void @my_m22_muladd(ptr noalias sret([4 x float]) align 4 
%agg.result, ptr noundef %0, float noundef nofpclass(nan inf) %y, ptr noundef 
%1) #0 {
  ^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158883

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


[PATCH] D70401: [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs

2023-09-02 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added a comment.

In D70401#4635875 , @koute wrote:

> I know that there are still open issues regarding the psABI, but considering 
> how slow it's been going, couldn't we merge this in anyway and mark it as 
> experimental and subject to change? Please?
>
> The patch is simple enough to not become a maintenance burden, and GCC 
> already has it even though the ABI's unfinished, and the RV32E target itself 
> is most likely going to be used for standalone bare metal programs where the 
> exact ABI shouldn't matter too much as long as it works.
>
> I'm asking because I'd **really** like to have this merged so that I could 
> use Rust to target RV32E/RV64E. Right now I have to maintain my own 
> toolchain, which is painful; if this got merged (even in an experimental 
> fashion, like GCC has) I could just get upstream Rust to support it 
> out-of-box.

@asb @kito-cheng @jrtc27 What do you think about?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D157197: [clang][CodeGen][OpenMP] Fix if-clause for 'target teams loop'

2023-09-02 Thread David Pagan via Phabricator via cfe-commits
ddpagan abandoned this revision.
ddpagan added a comment.

Change no longer needed per review/comments.


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

https://reviews.llvm.org/D157197

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


[clang] 2cdfdfd - [CodeGen] Modernize EHScopeStack::Cleanup::Flags (NFC)

2023-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-09-02T09:32:36-07:00
New Revision: 2cdfdfd7b9bc9b4c6c329b1e33b377e24631e9a5

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

LOG: [CodeGen] Modernize EHScopeStack::Cleanup::Flags (NFC)

Added: 


Modified: 
clang/lib/CodeGen/EHScopeStack.h

Removed: 




diff  --git a/clang/lib/CodeGen/EHScopeStack.h 
b/clang/lib/CodeGen/EHScopeStack.h
index 3c8a51590d1b531..0c667e80bb6d8cf 100644
--- a/clang/lib/CodeGen/EHScopeStack.h
+++ b/clang/lib/CodeGen/EHScopeStack.h
@@ -166,10 +166,10 @@ class EHScopeStack {
 F_IsEHCleanupKind = 0x4,
 F_HasExitSwitch = 0x8,
   };
-  unsigned flags;
+  unsigned flags = 0;
 
 public:
-  Flags() : flags(0) {}
+  Flags() = default;
 
   /// isForEH - true if the current emission is for an EH cleanup.
   bool isForEHCleanup() const { return flags & F_IsForEH; }



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


[clang] 2fa1ad8 - [StaticAnalyzer] Modernize IsObjCTypeParamDependentTypeVisitor (NFC)

2023-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-09-02T09:32:40-07:00
New Revision: 2fa1ad8a022fc6ad88f7948d64d12e4a6cc3e39d

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

LOG: [StaticAnalyzer] Modernize IsObjCTypeParamDependentTypeVisitor (NFC)

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
index 1f3e9e00d3e693..eda8302595ba4f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
@@ -713,7 +713,7 @@ static bool isObjCTypeParamDependent(QualType Type) {
   class IsObjCTypeParamDependentTypeVisitor
   : public RecursiveASTVisitor {
   public:
-IsObjCTypeParamDependentTypeVisitor() : Result(false) {}
+IsObjCTypeParamDependentTypeVisitor() = default;
 bool VisitObjCTypeParamType(const ObjCTypeParamType *Type) {
   if (isa(Type->getDecl())) {
 Result = true;
@@ -722,7 +722,7 @@ static bool isObjCTypeParamDependent(QualType Type) {
   return true;
 }
 
-bool Result;
+bool Result = false;
   };
 
   IsObjCTypeParamDependentTypeVisitor Visitor;



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


[clang] cccdf5b - [StaticAnalyzer] Modernize ObjCLoopChecker (NFC)

2023-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-09-02T09:32:38-07:00
New Revision: cccdf5b71d1ccec9155ff6c29a0364c89576a7df

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

LOG: [StaticAnalyzer] Modernize ObjCLoopChecker (NFC)

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp 
b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
index 93679a86966f45..0fb3506eb6e569 100644
--- a/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
@@ -819,13 +819,13 @@ class ObjCLoopChecker
check::PostObjCMessage,
check::DeadSymbols,
check::PointerEscape > {
-  mutable IdentifierInfo *CountSelectorII;
+  mutable IdentifierInfo *CountSelectorII = nullptr;
 
   bool isCollectionCountMethod(const ObjCMethodCall &M,
CheckerContext &C) const;
 
 public:
-  ObjCLoopChecker() : CountSelectorII(nullptr) {}
+  ObjCLoopChecker() = default;
   void checkPostStmt(const ObjCForCollectionStmt *FCS, CheckerContext &C) 
const;
   void checkPostObjCMessage(const ObjCMethodCall &M, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;



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


[clang] 5ac7fb4 - [StaticAnalyzer] Modernize GTestChecker (NFC)

2023-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-09-02T09:32:41-07:00
New Revision: 5ac7fb45e1750fadf123bcd958b3ffdd3d71027a

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

LOG: [StaticAnalyzer] Modernize GTestChecker (NFC)

Added: 


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

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
index 43d2eeeb4b275d..6c32a8dec844cb 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GTestChecker.cpp
@@ -92,11 +92,11 @@ using namespace ento;
 namespace {
 class GTestChecker : public Checker {
 
-  mutable IdentifierInfo *AssertionResultII;
-  mutable IdentifierInfo *SuccessII;
+  mutable IdentifierInfo *AssertionResultII = nullptr;
+  mutable IdentifierInfo *SuccessII = nullptr;
 
 public:
-  GTestChecker();
+  GTestChecker() = default;
 
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
 
@@ -120,8 +120,6 @@ class GTestChecker : public Checker {
 };
 } // End anonymous namespace.
 
-GTestChecker::GTestChecker() : AssertionResultII(nullptr), SuccessII(nullptr) 
{}
-
 /// Model a call to an un-inlined AssertionResult(bool) or
 /// AssertionResult(bool &, ...).
 /// To do so, constrain the value of the newly-constructed instance's 
'success_'



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


[clang] 5dd9568 - Fix typos in documentation

2023-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-09-02T09:32:48-07:00
New Revision: 5dd956871785a5b04903d6da85109c9e1052a8a8

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

LOG: Fix typos in documentation

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
libc/docs/dev/code_style.rst
lldb/docs/use/tutorial.rst
llvm/docs/LangRef.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index ac6919e4c98297..54ea49e7426cc8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2481,13 +2481,13 @@ input refers to a valid file and removing any invalid 
user input.
 if (!filename[0])
   return -1;
 strcat(cmd, filename);
-system(cmd); // Superflous Warning: Untrusted data is passed to a system 
call
+system(cmd); // Superfluous Warning: Untrusted data is passed to a system 
call
   }
 
 Unfortunately, the checker cannot discover automatically that the programmer
 have performed data sanitation, so it still emits the warning.
 
-One can get rid of this superflous warning by telling by specifying the
+One can get rid of this superfluous warning by telling by specifying the
 sanitation functions in the taint configuration file (see
 :doc:`user-docs/TaintAnalysisConfiguration`).
 

diff  --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst
index 0c3171b7c95027..4b03217b18c33f 100644
--- a/libc/docs/dev/code_style.rst
+++ b/libc/docs/dev/code_style.rst
@@ -39,7 +39,7 @@ We define two kinds of macros:
 
* ``src/__support/macros/properties/`` - Build related properties like
  target architecture or enabled CPU features defined by introspecting
- compiler defined preprocessor defininitions.
+ compiler defined preprocessor definitions.
 
  * ``architectures.h`` - Target architecture properties.
e.g., ``LIBC_TARGET_ARCH_IS_ARM``.

diff  --git a/lldb/docs/use/tutorial.rst b/lldb/docs/use/tutorial.rst
index ef268fff775d59..85dc173fa37cd3 100644
--- a/lldb/docs/use/tutorial.rst
+++ b/lldb/docs/use/tutorial.rst
@@ -360,7 +360,7 @@ That is better, but suffers from the problem that when new 
breakpoints get
 added, they don't pick up these modifications, and the options only exist in
 the context of actual breakpoints, so they are hard to store & reuse.
 
-A even better solution is to make a fully configured breakpoint name:
+An even better solution is to make a fully configured breakpoint name:
 
 ::
 

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index cddb20ca6a6f06..d7fde35f63a3ee 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -7159,7 +7159,7 @@ It is illegal for the list node to be empty since it 
might be confused
 with an access group.
 
 The access group metadata node must be 'distinct' to avoid collapsing
-multiple access groups by content. A access group metadata node must
+multiple access groups by content. An access group metadata node must
 always be empty which can be used to distinguish an access group
 metadata node from a list of access groups. Being empty avoids the
 situation that the content must be updated which, because metadata is



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


[clang-tools-extra] 840a968 - [clang-tools-extra] Use range-based for loops (NFC)

2023-09-02 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-09-02T12:12:16-07:00
New Revision: 840a968226c2c6db792d7c1661dfb8a354ff3ebf

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

LOG: [clang-tools-extra] Use range-based for loops (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/Preamble.cpp
clang-tools-extra/include-cleaner/lib/WalkAST.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index ef5d5db0577b0d..e116a739774b85 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -290,10 +290,10 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
 Cmd.resize(DashDashIndex);
   }
   llvm::sort(IndicesToDrop);
-  llvm::for_each(llvm::reverse(IndicesToDrop),
- // +1 to account for the executable name in Cmd[0] that
- // doesn't exist in ArgList.
- [&Cmd](unsigned Idx) { Cmd.erase(Cmd.begin() + Idx + 1); });
+  for (unsigned Idx : llvm::reverse(IndicesToDrop))
+// +1 to account for the executable name in Cmd[0] that
+// doesn't exist in ArgList.
+Cmd.erase(Cmd.begin() + Idx + 1);
   // All the inputs are stripped, append the name for the requested file. Rest
   // of the modifications should respect `--`.
   Cmd.push_back("--");

diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index 3cf6671be9600e..3e06a67566cf75 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -425,8 +425,8 @@ ParsedAST::build(llvm::StringRef Filename, const 
ParseInputs &Inputs,
   StoreDiags ASTDiags;
   ASTDiags.setDiagCallback(
   [&ASTListeners](const clang::Diagnostic &D, clangd::Diag &Diag) {
-llvm::for_each(ASTListeners,
-   [&](const auto &L) { L->sawDiagnostic(D, Diag); });
+for (const auto &L : ASTListeners)
+  L->sawDiagnostic(D, Diag);
   });
 
   std::optional Patch;

diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index 31b38d067b2727..725e6b1e34fea3 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -610,8 +610,8 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
   StoreDiags PreambleDiagnostics;
   PreambleDiagnostics.setDiagCallback(
   [&ASTListeners](const clang::Diagnostic &D, clangd::Diag &Diag) {
-llvm::for_each(ASTListeners,
-   [&](const auto &L) { L->sawDiagnostic(D, Diag); });
+for (const auto &L : ASTListeners)
+  L->sawDiagnostic(D, Diag);
   });
   llvm::IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(&CI.getDiagnosticOpts(),

diff  --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index 15a579afd456c3..796a645ec29466 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -173,9 +173,8 @@ class ASTWalker : public RecursiveASTVisitor {
 
   bool VisitOverloadExpr(OverloadExpr *E) {
 // Since we can't prove which overloads are used, report all of them.
-llvm::for_each(E->decls(), [this, E](NamedDecl *D) {
+for (NamedDecl *D : E->decls())
   report(E->getNameLoc(), D, RefType::Ambiguous);
-});
 return true;
   }
 



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


[PATCH] D159390: Haiku: Enable thread-local storage and disable PIE by default

2023-09-02 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 555604.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159390

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/Haiku.h
  clang/test/Driver/pic.c
  clang/test/Sema/tls.c


Index: clang/test/Sema/tls.c
===
--- clang/test/Sema/tls.c
+++ clang/test/Sema/tls.c
@@ -16,7 +16,8 @@
 // RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
 
-// Haiku does not support TLS.
-// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
+// Haiku supports TLS.
+// RUN: %clang_cc1 -triple x86_64-unknown-haiku -fsyntax-only %s
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
 
 __thread int x;
Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -324,3 +324,9 @@
 // RUN:   -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-PIC-DATA-TEXT-REL-NON-SYSTEMZ
 // RUN: not %clang -fpic -c --target=arm-arm-none-eabi 
-mpic-data-is-text-relative %s \
 // RUN:   -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-PIC-DATA-TEXT-REL-NON-SYSTEMZ
+
+// On Haiku, PIC is enabled by default, and PIE is disabled by default.
+// RUN: %clang -c %s --target=x86_64-unknown-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -22,9 +22,7 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
-  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPICDefault() const override { return true; }
 
   void AddClangSystemIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -268,7 +268,6 @@
 this->IntPtrType = TargetInfo::SignedLong;
 this->PtrDiffType = TargetInfo::SignedLong;
 this->ProcessIDType = TargetInfo::SignedLong;
-this->TLSSupported = false;
 switch (Triple.getArch()) {
 default:
   break;


Index: clang/test/Sema/tls.c
===
--- clang/test/Sema/tls.c
+++ clang/test/Sema/tls.c
@@ -16,7 +16,8 @@
 // RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
 
-// Haiku does not support TLS.
-// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
+// Haiku supports TLS.
+// RUN: %clang_cc1 -triple x86_64-unknown-haiku -fsyntax-only %s
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
 
 __thread int x;
Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -324,3 +324,9 @@
 // RUN:   -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIC-DATA-TEXT-REL-NON-SYSTEMZ
 // RUN: not %clang -fpic -c --target=arm-arm-none-eabi -mpic-data-is-text-relative %s \
 // RUN:   -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-DATA-TEXT-REL-NON-SYSTEMZ
+
+// On Haiku, PIC is enabled by default, and PIE is disabled by default.
+// RUN: %clang -c %s --target=x86_64-unknown-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -22,9 +22,7 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
-  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPICDefault() const override { return true; }
 
   void AddClangSystemIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -268,7 +268,6 @@
 this->IntPtrType = TargetInfo::SignedLong;
 this->PtrDiffType = TargetInfo::SignedLong;
 this->ProcessIDType = TargetInfo::SignedLong;
-this->TLSSupported = false;
 switch (Triple.getArch()) {
 default:
   break;
___

[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-02 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 review_requested 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-02 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 review_requested 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-02 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 opened https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-02 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 review_requested 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-02 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 review_request_removed 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Workaround for MSVC ARM64 build performance regression (PR #65215)

2023-09-02 Thread Alexander Smarus via cfe-commits

https://github.com/lxbndr review_requested 
https://github.com/llvm/llvm-project/pull/65215
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Workaround for MSVC ARM64 build performance regression (PR #65215)

2023-09-02 Thread Alexander Smarus via cfe-commits

https://github.com/lxbndr opened https://github.com/llvm/llvm-project/pull/65215
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159233: [clang-format][NFC] Change duplicate config files to symlinks

2023-09-02 Thread Owen Pan via Phabricator via cfe-commits
owenpan abandoned this revision.
owenpan added a comment.

It seems that git doesn't recreate symbolic links by default on Windows. (See 
e.g. `clang/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas`.) I'll abandon this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159233

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


[clang] [AST] Only dump desugared type when visibly different (PR #65214)

2023-09-02 Thread via cfe-commits

https://github.com/philnik777 labeled 
https://github.com/llvm/llvm-project/pull/65214
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70401: [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs

2023-09-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/CodeGen/Targets/RISCV.cpp:479
+  // 2×XLEN-bit alignment and size at most 2×XLEN bits like `long long`,
+  // `unsigned long long` and `double` to have 4-bytes alignment. This
+  // behavior may be changed when RV32E/ILP32E is ratified.

4-bytes -> 4-byte



Comment at: clang/test/Preprocessor/riscv-target-features.c:6
 
+// CHECK-NOT: __riscv_32e
 // CHECK-NOT: __riscv_div {{.*$}}

__riscv_64e too



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:937
   // TODO: The 'q' extension requires rv64.
-  // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'.
 

This needs to be rebased. These FIXMEs were removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D157072: [clang][ExprConst] Check float operation input for signaling NaNs

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

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157072

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


[PATCH] D159390: Haiku: Enable thread-local storag, disable PIE / enable PIC by default

2023-09-02 Thread Niels Sascha Reedijk via Phabricator via cfe-commits
nielx added a comment.

Can confirm this is correct for Haiku.
For PIC by default, see our GCC haiku.h 
.
These changes have also been part of our patches for clang 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159390

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


[PATCH] D159390: Haiku: Enable thread-local storag, disable PIE / enable PIC by default

2023-09-02 Thread Niels Sascha Reedijk via Phabricator via cfe-commits
nielx accepted this revision.
nielx added a comment.
This revision is now accepted and ready to land.

Looks good to me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159390

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


[clang] 99be6b6 - Haiku: Enable thread-local storag, disable PIE / enable PIC by default

2023-09-02 Thread Brad Smith via cfe-commits

Author: Jerome Duval
Date: 2023-09-03T02:02:51-04:00
New Revision: 99be6b6d598f9ab4f4493b23375fcb87ae8b335d

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

LOG: Haiku: Enable thread-local storag, disable PIE / enable PIC by default

Derived from D49481, but added tests and simplified the diff a bit; isPIEDefault
can just be removed. Also looking through their upstream patches I noticed PIC
is also enabled.

Reviewed By: nielx

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

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h
clang/lib/Driver/ToolChains/Haiku.h
clang/test/Driver/pic.c
clang/test/Sema/tls.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 367defc071417f..f2bd846e670d14 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -268,7 +268,6 @@ class LLVM_LIBRARY_VISIBILITY HaikuTargetInfo : public 
OSTargetInfo {
 this->IntPtrType = TargetInfo::SignedLong;
 this->PtrDiffType = TargetInfo::SignedLong;
 this->ProcessIDType = TargetInfo::SignedLong;
-this->TLSSupported = false;
 switch (Triple.getArch()) {
 default:
   break;

diff  --git a/clang/lib/Driver/ToolChains/Haiku.h 
b/clang/lib/Driver/ToolChains/Haiku.h
index 80b4dd1945de23..cc7f7eb19091a9 100644
--- a/clang/lib/Driver/ToolChains/Haiku.h
+++ b/clang/lib/Driver/ToolChains/Haiku.h
@@ -22,9 +22,7 @@ class LLVM_LIBRARY_VISIBILITY Haiku : public Generic_ELF {
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
-  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPICDefault() const override { return true; }
 
   void AddClangSystemIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,

diff  --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c
index f0a6393a5fd334..86b2a3b041d5f9 100644
--- a/clang/test/Driver/pic.c
+++ b/clang/test/Driver/pic.c
@@ -324,3 +324,9 @@
 // RUN:   -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-PIC-DATA-TEXT-REL-NON-SYSTEMZ
 // RUN: not %clang -fpic -c --target=arm-arm-none-eabi 
-mpic-data-is-text-relative %s \
 // RUN:   -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-PIC-DATA-TEXT-REL-NON-SYSTEMZ
+
+// On Haiku, PIC is enabled by default, and PIE is disabled by default.
+// RUN: %clang -c %s --target=x86_64-unknown-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2

diff  --git a/clang/test/Sema/tls.c b/clang/test/Sema/tls.c
index e4d0656d1dd612..600a69566a7ebe 100644
--- a/clang/test/Sema/tls.c
+++ b/clang/test/Sema/tls.c
@@ -16,7 +16,8 @@
 // RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
 
-// Haiku does not support TLS.
-// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
+// Haiku supports TLS.
+// RUN: %clang_cc1 -triple x86_64-unknown-haiku -fsyntax-only %s
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
 
 __thread int x;



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


[PATCH] D159390: Haiku: Enable thread-local storag, disable PIE / enable PIC by default

2023-09-02 Thread Brad Smith via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99be6b6d598f: Haiku: Enable thread-local storag, disable PIE 
/ enable PIC by default (authored by Jerome Duval 
, committed by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159390

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/Haiku.h
  clang/test/Driver/pic.c
  clang/test/Sema/tls.c


Index: clang/test/Sema/tls.c
===
--- clang/test/Sema/tls.c
+++ clang/test/Sema/tls.c
@@ -16,7 +16,8 @@
 // RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
 
-// Haiku does not support TLS.
-// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
+// Haiku supports TLS.
+// RUN: %clang_cc1 -triple x86_64-unknown-haiku -fsyntax-only %s
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
 
 __thread int x;
Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -324,3 +324,9 @@
 // RUN:   -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-PIC-DATA-TEXT-REL-NON-SYSTEMZ
 // RUN: not %clang -fpic -c --target=arm-arm-none-eabi 
-mpic-data-is-text-relative %s \
 // RUN:   -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-PIC-DATA-TEXT-REL-NON-SYSTEMZ
+
+// On Haiku, PIC is enabled by default, and PIE is disabled by default.
+// RUN: %clang -c %s --target=x86_64-unknown-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -22,9 +22,7 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
-  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPICDefault() const override { return true; }
 
   void AddClangSystemIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -268,7 +268,6 @@
 this->IntPtrType = TargetInfo::SignedLong;
 this->PtrDiffType = TargetInfo::SignedLong;
 this->ProcessIDType = TargetInfo::SignedLong;
-this->TLSSupported = false;
 switch (Triple.getArch()) {
 default:
   break;


Index: clang/test/Sema/tls.c
===
--- clang/test/Sema/tls.c
+++ clang/test/Sema/tls.c
@@ -16,7 +16,8 @@
 // RUN: %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s
 
-// Haiku does not support TLS.
-// RUN: not %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
+// Haiku supports TLS.
+// RUN: %clang_cc1 -triple x86_64-unknown-haiku -fsyntax-only %s
+// RUN: %clang_cc1 -triple i586-pc-haiku -fsyntax-only %s
 
 __thread int x;
Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -324,3 +324,9 @@
 // RUN:   -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-PIC-DATA-TEXT-REL-NON-SYSTEMZ
 // RUN: not %clang -fpic -c --target=arm-arm-none-eabi -mpic-data-is-text-relative %s \
 // RUN:   -### 2>&1 | FileCheck %s --check-prefix=CHECK-PIC-DATA-TEXT-REL-NON-SYSTEMZ
+
+// On Haiku, PIC is enabled by default, and PIE is disabled by default.
+// RUN: %clang -c %s --target=x86_64-unknown-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
+// RUN: %clang -c %s --target=i586-pc-haiku -### 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -22,9 +22,7 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
-  bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
-return getTriple().getArch() == llvm::Triple::x86_64;
-  }
+  bool isPICDefault() const override { return true; }
 
   void AddClangSystemIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -268,7 +2

[PATCH] D159409: Haiku: Pick up a few more codegen parametres from downstream

2023-09-02 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: nielx, korli.
brad added a project: clang.
Herald added a project: All.
brad requested review of this revision.
Herald added a subscriber: MaskRay.

Pick up a few more codegen parametres from downstream.

DWARF version 2, Math Errno handling, ObjC ABI handling, and debug handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159409

Files:
  clang/lib/Driver/ToolChains/Haiku.h
  clang/test/CodeGen/dwarf-version.c
  clang/test/Driver/clang-g-opts.c
  clang/test/Driver/fast-math.c


Index: clang/test/Driver/fast-math.c
===
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -122,6 +122,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### --target=x86_64-unknown-haiku -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
Index: clang/test/Driver/clang-g-opts.c
===
--- clang/test/Driver/clang-g-opts.c
+++ clang/test/Driver/clang-g-opts.c
@@ -9,6 +9,8 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g -target x86_64-pc-freebsd10.0 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
+// RUN: %clang -### -S %s -g --target=x86_64-unknown-haiku 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 
 // 'g0' is the default. Just basic correctness check that it does nothing
 // RUN: %clang -### -S %s -g02>&1 | FileCheck 
--check-prefix=CHECK-WITHOUT-G %s
@@ -27,6 +29,8 @@
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g0 -g -target x86_64-pc-freebsd10.0 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
+// RUN: %clang -### -S %s -g0 -g --target=x86_64-unknown-haiku 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
 // RUN: %clang -### -S %s -g0 -g --target=i386-pc-solaris 2>&1 \
 // RUN: | FileCheck --check-prefix=CHECK-WITH-G %s
 
Index: clang/test/CodeGen/dwarf-version.c
===
--- clang/test/CodeGen/dwarf-version.c
+++ clang/test/CodeGen/dwarf-version.c
@@ -14,6 +14,7 @@
 // RUN: %clang -target x86_64-apple-darwin14 -g -S -emit-llvm -o - %s 
-isysroot %t | FileCheck %s --check-prefix=VER2
 
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
+// RUN: %clang --target=x86_64-unknown-haiku -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER4
 
 // Check which debug info formats we use on Windows. By default, in an MSVC
Index: clang/lib/Driver/ToolChains/Haiku.h
===
--- clang/lib/Driver/ToolChains/Haiku.h
+++ clang/lib/Driver/ToolChains/Haiku.h
@@ -22,6 +22,8 @@
   Haiku(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
 
+  bool IsMathErrnoDefault() const override { return false; }
+  bool IsObjCNonFragileABIDefault() const override { return true; }
   bool isPICDefault() const override { return true; }
 
   void AddClangSystemIncludeArgs(
@@ -33,6 +35,10 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+
+  unsigned GetDefaultDwarfVersion() const override { return 2; }
+
+  bool GetDefaultStandaloneDebug() const override { return true; }
 };
 
 } // end namespace toolchains


Index: clang/test/Driver/fast-math.c
===
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -122,6 +122,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### --target=x86_64-unknown-haiku -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-fuchsia -c %s 2>&1 \
Index: clang/test/Driver/clang-g-opts.c
===
--- clang/test/Driver/clang-g-opts.c
+++ clang/test/Driver/clang-g-opts.c
@@ -9,6 +9,8 @@
 // RUN: | FileCheck --check-prefix=CHECK