[PATCH] D147844: Emit warning when implicit cast from int to bool happens in an conditional operator expression

2023-04-20 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 515591.
chaitanyav added a comment.

Place parentheses around conditional expression to prevent precedence warnings 
since -Werror is enabled on build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  libcxx/include/__chrono/duration.h
  libcxx/include/strstream
  libcxx/test/libcxx/algorithms/nth_element_stability.pass.cpp
  libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
  libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
  libcxxabi/src/cxa_personality.cpp

Index: libcxxabi/src/cxa_personality.cpp
===
--- libcxxabi/src/cxa_personality.cpp
+++ libcxxabi/src/cxa_personality.cpp
@@ -718,9 +718,7 @@
 if (actionEntry == 0)
 {
 // Found a cleanup
-results.reason = actions & _UA_SEARCH_PHASE
- ? _URC_CONTINUE_UNWIND
- : _URC_HANDLER_FOUND;
+results.reason = (actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;
 return;
 }
 // Convert 1-based byte offset into
@@ -832,9 +830,8 @@
 // End of action list. If this is phase 2 and we have found
 // a cleanup (ttypeIndex=0), return _URC_HANDLER_FOUND;
 // otherwise return _URC_CONTINUE_UNWIND.
-results.reason = hasCleanup && actions & _UA_CLEANUP_PHASE
- ? _URC_HANDLER_FOUND
- : _URC_CONTINUE_UNWIND;
+results.reason =
+(hasCleanup && (actions & _UA_CLEANUP_PHASE)) ? _URC_HANDLER_FOUND : _URC_CONTINUE_UNWIND;
 return;
 }
 // Go to next action
@@ -1243,10 +1240,9 @@
 {
 const __shim_type_info* excpType =
 static_cast(new_exception_header->exceptionType);
-adjustedPtr =
-__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass ?
-((__cxa_dependent_exception*)new_exception_header)->primaryException :
-new_exception_header + 1;
+adjustedPtr = (__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass)
+  ? ((__cxa_dependent_exception*)new_exception_header)->primaryException
+  : new_exception_header + 1;
 if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
   excpType, adjustedPtr,
   unwind_exception, base))
Index: libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
===
--- libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
+++ libcxx/test/libcxx/algorithms/sort_stability.pass.cpp
@@ -32,7 +32,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   std::less comp;
   std::__sort_dispatch(v.begin(), v.end(), comp);
@@ -44,7 +44,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   auto deterministic_v = deterministic();
   std::sort(v.begin(), v.end());
@@ -62,7 +62,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = kSize / 2 - i * (i % 2 ? -1 : 1);
+v[i].value = kSize / 2 - i * ((i % 2) ? -1 : 1);
   }
   auto snapshot_v = v;
   auto snapshot_custom_v = v;
Index: libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
===
--- libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
+++ libcxx/test/libcxx/algorithms/partial_sort_stability.pass.cpp
@@ -32,7 +32,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = (i % 2 ? 1 : kSize / 2 + i);
+v[i].value = ((i % 2) ? 1 : kSize / 2 + i);
   }
   auto comp = std::less();
   std::__partial_sort_impl(v.begin(), v.begin() + kSize / 2, v.end(), comp);
@@ -44,7 +44,7 @@
   std::vector v;
   v.resize(kSize);
   for (int i = 0; i < kSize; ++i) {
-v[i].value = (i % 2 ? 1 : kSize / 2 + i);
+

[PATCH] D137258: [clang] Optimize storage and lookup of analyzer options

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

I liked the idea of sorting these options at compile time.
I think the most dummy sort should work just fine inthis case, as the number of 
elements are not that large.
Do you think worth it?

Anyway , I think moving the runtime sort out of the ctor is a good 
middleground. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137258

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


[clang] 0304aa2 - [dataflow] allow specifying path to dot with $GRAPHVIZ_DOT

2023-04-20 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-04-21T05:29:11+02:00
New Revision: 0304aa25e0be5f322a76d16c6b6069eb9e153430

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

LOG: [dataflow] allow specifying path to dot with $GRAPHVIZ_DOT

I'd like to use this in a CI system where it's easier to tell the
program about paths than manipulate $PATH.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index cbf7a22bf7fa7..b229194bc8f44 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -394,10 +394,16 @@ class HTMLLogger : public Logger {
 
 // Nothing interesting here, just subprocess/temp-file plumbing.
 llvm::Expected renderSVG(llvm::StringRef DotGraph) {
-  auto Dot = llvm::sys::findProgramByName("dot");
-  if (!Dot)
-return llvm::createStringError(Dot.getError(),
-   "Can't draw CFG: 'dot' not found on PATH");
+  std::string DotPath;
+  if (const auto *FromEnv = ::getenv("GRAPHVIZ_DOT"))
+DotPath = FromEnv;
+  else {
+auto FromPath = llvm::sys::findProgramByName("dot");
+if (!FromPath)
+  return llvm::createStringError(FromPath.getError(),
+ "'dot' not found on PATH");
+DotPath = FromPath.get();
+  }
 
   // Create input and output files for `dot` subprocess.
   // (We create the output file as empty, to reserve the temp filename).
@@ -419,7 +425,7 @@ llvm::Expected renderSVG(llvm::StringRef 
DotGraph) {
   /*stderr=*/std::nullopt};
   std::string ErrMsg;
   int Code = llvm::sys::ExecuteAndWait(
-  *Dot, {"dot", "-Tsvg"}, /*Env=*/std::nullopt, Redirects,
+  DotPath, {"dot", "-Tsvg"}, /*Env=*/std::nullopt, Redirects,
   /*SecondsToWait=*/0, /*MemoryLimit=*/0, );
   if (!ErrMsg.empty())
 return llvm::createStringError(llvm::inconvertibleErrorCode(),



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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-04-20 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl added inline comments.



Comment at: compiler-rt/lib/asabi/CMakeLists.txt:2
+# Build for the ASAN Stable ABI runtime support library.
+set(ASABI_SOURCES
+  asabi_shim.cpp

vitalybuka wrote:
> does it need to be asabi?
> maybe better asan_abi, files and macro?
The idea is that "asabi" replaces "asan" (where the "s" stands in for 
"stable"), but I understand the distraction of sounding like a hot condiment! I 
wonder what you think of "asan_stable" (over "asan_stable_abi" or "asan_abi" as 
you suggest). I am more at ease with emphasizing the "stable" over the "abi" 
since both "asan" and "asan_stable" share ABI-ness without calling it out. This 
might read and organize a bit more naturally with what we already have. Thanks 
for the input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-04-20 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl marked an inline comment as done.
rsundahl added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1785
HelpText<"Use default code 
inlining logic for the address sanitizer">;
+def fsanitize_address_stable_abi : Flag<["-"], "fsanitize-address-stable-abi">,
+Group,

vitalybuka wrote:
> how likely you will need thus for  other sanitizers in future
> should this be rather -fsanitize-stable-abi which is ignore for now for other 
> sanitizers?
Thanks @vitalybuka. I agree and made this change. For now I still only consume 
the flag if sanitizer=address so that we continue to get the unused option 
warning in the other cases and left the test for that warning intact.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D148757: [clang] Follow user-provided order for prefix map

2023-04-20 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem added a comment.

I compared Clang and GCC behavior.
**1) Following user-specified prefix mapping order**
GCC uses a linked list to store the prefix mappings, so it applies the prefix 
mappings based on the user-provided order.
https://github.com/gcc-mirror/gcc/blob/master/gcc/file-prefix-map.cc#L27
Whereas, Clang currently uses an `std::map`, which does **NOT** follow 
user-provided order.  So, Clang and GCC behavior do not match on that.

**2) Applying multiple prefix mappings**
Both Clang and GCC apply the first matching prefix mapping, and does not apply 
the following prefix mappings. So, they are consistent in that.

https://github.com/gcc-mirror/gcc/blob/master/gcc/file-prefix-map.cc#L88
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CoverageMappingGen.cpp#L1653


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

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


[PATCH] D148869: [Driver][BareMetal] Support --emit-static-lib in BareMetal driver

2023-04-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: abrachet.
Herald added a project: All.
phosek requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This allows building static libraries with Clang driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148869

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/BareMetal.h
  clang/test/Driver/baremetal.cpp

Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -1,5 +1,9 @@
 // UNSUPPORTED: system-windows
 
+// RUN: %clang -### %s --target=armv6-none-eabi --emit-static-lib 2>&1 \
+// RUN:   | FileCheck -check-prefixes=CHECK-STATIC-LIB %s
+// CHECK-STATIC-LIB: {{.*}}llvm-ar{{.*}}" "rcsD"
+
 // RUN: %clang %s -### --target=armv6m-none-eabi -o %t.out 2>&1 \
 // RUN: -T semihosted.lds \
 // RUN: -L some/directory/user/asked/for \
Index: clang/lib/Driver/ToolChains/BareMetal.h
===
--- clang/lib/Driver/ToolChains/BareMetal.h
+++ clang/lib/Driver/ToolChains/BareMetal.h
@@ -32,6 +32,7 @@
 
 protected:
   Tool *buildLinker() const override;
+  Tool *buildStaticLibTool() const override;
 
 public:
   bool useIntegratedAs() const override { return true; }
@@ -78,6 +79,20 @@
 namespace tools {
 namespace baremetal {
 
+class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool {
+public:
+  StaticLibTool(const ToolChain )
+  : Tool("baremetal::StaticLibTool", "llvm-ar", TC) {}
+
+  bool hasIntegratedCPP() const override { return false; }
+  bool isLinkJob() const override { return true; }
+
+  void ConstructJob(Compilation , const JobAction ,
+const InputInfo , const InputInfoList ,
+const llvm::opt::ArgList ,
+const char *LinkingOutput) const override;
+};
+
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
   Linker(const ToolChain ) : Tool("baremetal::Linker", "ld.lld", TC) {}
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -175,6 +175,10 @@
   return new tools::baremetal::Linker(*this);
 }
 
+Tool *BareMetal::buildStaticLibTool() const {
+  return new tools::baremetal::StaticLibTool(*this);
+}
+
 std::string BareMetal::computeSysRoot() const {
   if (!getDriver().SysRoot.empty())
 return getDriver().SysRoot + SelectedMultilib.osSuffix();
@@ -302,6 +306,51 @@
   llvm_unreachable("Unhandled RuntimeLibType.");
 }
 
+void baremetal::StaticLibTool::ConstructJob(Compilation , const JobAction ,
+const InputInfo ,
+const InputInfoList ,
+const ArgList ,
+const char *LinkingOutput) const {
+  const Driver  = getToolChain().getDriver();
+
+  // Silence warning for "clang -g foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_g_Group);
+  // and "clang -emit-llvm foo.o -o foo"
+  Args.ClaimAllArgs(options::OPT_emit_llvm);
+  // and for "clang -w foo.o -o foo". Other warning options are already
+  // handled somewhere else.
+  Args.ClaimAllArgs(options::OPT_w);
+  // Silence warnings when linking C code with a C++ '-stdlib' argument.
+  Args.ClaimAllArgs(options::OPT_stdlib_EQ);
+
+  // ar tool command "llvm-ar   ".
+  ArgStringList CmdArgs;
+  // Create and insert file members with a deterministic index.
+  CmdArgs.push_back("rcsD");
+  CmdArgs.push_back(Output.getFilename());
+
+  for (const auto  : Inputs) {
+if (II.isFilename()) {
+   CmdArgs.push_back(II.getFilename());
+}
+  }
+
+  // Delete old output archive file if it already exists before generating a new
+  // archive file.
+  const char *OutputFileName = Output.getFilename();
+  if (Output.isFilename() && llvm::sys::fs::exists(OutputFileName)) {
+if (std::error_code EC = llvm::sys::fs::remove(OutputFileName)) {
+  D.Diag(diag::err_drv_unable_to_remove_file) << EC.message();
+  return;
+}
+  }
+
+  const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath());
+  C.addCommand(std::make_unique(JA, *this,
+ ResponseFileSupport::AtFileCurCP(),
+ Exec, CmdArgs, Inputs, Output));
+}
+
 void baremetal::Linker::ConstructJob(Compilation , const JobAction ,
  const InputInfo ,
  const InputInfoList ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148757: [clang] Follow user-provided order for prefix map

2023-04-20 Thread Gulfem Savrun Yeniceri via Phabricator via cfe-commits
gulfem updated this revision to Diff 515560.
gulfem added a comment.

Modified the test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148757

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/test/Profile/coverage-prefix-map.c


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom 
-fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck 
--check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that user provided prefix replacement order is followed 
(-fcoverage-prefix-map==newpath is applied because it is the first one in the 
user-provided prefix-map order).
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath 
-fcoverage-prefix-map=%/t/root=. -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-ORDER %s
+// COVERAGE-PREFIX-MAP-ORDER: @__llvm_coverage_mapping = 
{{.*"\\02.*newpath.*root.*nested.*coverage-prefix-map\.c}}
+
+// Test that -fcoverage-prefix-map=%/t/root=. is applied but 
-fcoverage-prefix-map==newpath is NOT because of the order.
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm 
-mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c 
%t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map=%/t/root=. 
-fcoverage-prefix-map==newpath -o - | FileCheck 
--check-prefix=COVERAGE-PREFIX-MAP-REORDER %s
+// COVERAGE-PREFIX-MAP-REORDER: @__llvm_coverage_mapping =
+// COVERAGE-PREFIX-MAP-REORDER-NOT: newpath
+// COVERAGE-PREFIX-MAP-REORDER-SAME: nested{{.*coverage-prefix-map\.c}}
Index: clang/lib/CodeGen/CoverageMappingGen.h
===
--- clang/lib/CodeGen/CoverageMappingGen.h
+++ clang/lib/CodeGen/CoverageMappingGen.h
@@ -18,6 +18,8 @@
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -107,7 +109,8 @@
   llvm::SmallDenseMap FileEntries;
   std::vector FunctionNames;
   std::vector FunctionRecords;
-  std::map CoveragePrefixMap;
+  llvm::MapVector>
+  CoveragePrefixMap;
 
   std::string getCurrentDirname();
   std::string normalizeFilename(StringRef Filename);
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -17,6 +17,8 @@
 #include "clang/Basic/XRayInstr.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/Frontend/Debug/Options.h"
+#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Target/TargetOptions.h"
@@ -206,8 +208,13 @@
   /// if non-empty.
   std::string RecordCommandLine;
 
-  std::map DebugPrefixMap;
-  std::map CoveragePrefixMap;
+  /// Prefix replacement map for coverage.
+  llvm::MapVector>
+  CoveragePrefixMap;
+
+  /// Prefix replacement map for debug info.
+  llvm::MapVector>
+  DebugPrefixMap;
 
   /// The ABI to use for passing floating point arguments.
   std::string FloatABI;


Index: clang/test/Profile/coverage-prefix-map.c
===
--- clang/test/Profile/coverage-prefix-map.c
+++ clang/test/Profile/coverage-prefix-map.c
@@ -19,3 +19,13 @@
 
 // RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -fcoverage-compilation-dir=/custom -fcoverage-prefix-map=/custom=/nonsense -o - | FileCheck --check-prefix=COVERAGE-COMPILATION-DIR %s
 // COVERAGE-COMPILATION-DIR: @__llvm_coverage_mapping = {{.*"\\02.*}}nonsense
+
+// Test that user provided prefix replacement order is followed (-fcoverage-prefix-map==newpath is applied because it is the first one in the user-provided prefix-map order).
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-file-name coverage-prefix-map.c %t/root/nested/coverage-prefix-map.c -fcoverage-prefix-map==newpath -fcoverage-prefix-map=%/t/root=. -o - 

[clang] 20d9aa1 - [doc] [C++20] [Modules] Document that the interfaces of header units is experimental

2023-04-20 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-04-21T10:43:24+08:00
New Revision: 20d9aa1a439f95468baa9cc40c5c6482ed7665d5

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

LOG: [doc] [C++20] [Modules] Document that the interfaces of header units is 
experimental

Close https://github.com/llvm/llvm-project/issues/62241

In tooling group (SG15), it is still unclear how tools should support
header units. Add a warning in the documentation to avoid further
confusions.

Added: 


Modified: 
clang/docs/StandardCPlusPlusModules.rst

Removed: 




diff  --git a/clang/docs/StandardCPlusPlusModules.rst 
b/clang/docs/StandardCPlusPlusModules.rst
index e14bbe4e1c655..0b44265374a8b 100644
--- a/clang/docs/StandardCPlusPlusModules.rst
+++ b/clang/docs/StandardCPlusPlusModules.rst
@@ -707,6 +707,13 @@ Header Units
 How to build projects using header unit
 ---
 
+.. warning::
+
+   The user interfaces of header units is highly experimental. There are still
+   many unanswered question about how tools should interact with header units.
+   The user interfaces described here may change after we have progress on how
+   tools should support for header units.
+
 Quick Start
 ~~~
 



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


[PATCH] D148812: [NFC][clang] Fix static analyzer concerns

2023-04-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna marked an inline comment as done.
Manna added a comment.

Thank you @tahonermann and @erichkeane for reviews and feedback.




Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:4262
   // will be using.
-  for (auto I : Attrs) {
+  for (const auto  : Attrs) {
 const Record  = *I.second;

erichkeane wrote:
> Manna wrote:
> > Passes as a reference 
> Each element is a pair of a `std::string` and `const Record*`, which should 
> justify this.  Not sure what you mean by 'passes as a reference'?
>>Each element is a pair of a std::string and const Record*, which should 
>>justify this.

Sorry i meant to say this instead since ParsedAttrMap Attrs = 
getParsedAttrList(Records, );


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

https://reviews.llvm.org/D148812

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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-04-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

> I think we probably should add LLVM_DISABLE_SYMBOLIZATION=1 to the lit level, 
> not in individual tests.

Though I'm not sure how  to do that in a way that it doesn't apply to test that 
are genuinely failing, where a symbolized backtrace is 
helpful/important/exactly what want?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-04-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I'm OK with this, though I wouldn't mind a more robust/general solution to this 
- especially all gunit death tests have this problem too - they crash and spend 
significant time symbolizing, I think? So it'd be great if we could find some 
way to run those with symbolization disabled too, not sure if there would be a 
more general place that'd cover both of these cases (but it might be 
interesting to you & perhaps you can find a fix for gunit too, even if it's a 
distinct solution, if the problem in general is of interest)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

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


[PATCH] D141310: [clang] add -Wcompare-function-pointers

2023-04-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

FWIW I think it's still worth some data from applying this to a broad codebase 
like Chromium/wherever it's planned to be used - whether it's practical to make 
a codebase clean of this warning, what sort of challenges arise, whether we 
should consider/need some way to suppress the warning in particular cases, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141310

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-04-20 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl updated this revision to Diff 515559.
rsundahl added a comment.

Rename fsanitize_address_stable_abi to fsanitize_stable_abi


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/docs/asabi.md
  compiler-rt/lib/asabi/CMakeLists.txt
  compiler-rt/lib/asabi/asabi.cpp
  compiler-rt/lib/asabi/asabi.h
  compiler-rt/lib/asabi/asabi_shim.cpp
  compiler-rt/lib/asabi/asabi_shim.h
  compiler-rt/test/asabi/CMakeLists.txt

Index: compiler-rt/test/asabi/CMakeLists.txt
===
--- /dev/null
+++ compiler-rt/test/asabi/CMakeLists.txt
@@ -0,0 +1 @@
+#TODO: Setup asabi test suite.
\ No newline at end of file
Index: compiler-rt/lib/asabi/asabi_shim.h
===
--- /dev/null
+++ compiler-rt/lib/asabi/asabi_shim.h
@@ -0,0 +1,224 @@
+//===-asabi_shim.h - ASan Stable ABI Shim Interface===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef ASABI_SHIM_H
+#define ASABI_SHIM_H
+
+typedef unsigned long uptr;
+typedef unsigned long u64;
+typedef unsigned int u32;
+
+extern void __asan_register_image_globals(uptr *flag);
+extern void __asan_unregister_image_globals(uptr *flag);
+
+extern void __asan_register_elf_globals(uptr *flag, void *start, void *stop);
+extern void __asan_unregister_elf_globals(uptr *flag, void *start, void *stop);
+
+extern void __asan_register_globals(__asan_global *globals, uptr n);
+extern void __asan_unregister_globals(__asan_global *globals, uptr n);
+
+extern void __asan_before_dynamic_init(const char *module_name);
+extern void __asan_after_dynamic_init(void);
+
+// Interceptors
+extern void *__asan_memcpy(void *dst, const void *src, uptr size);
+extern void *__asan_memset(void *s, int c, uptr n);
+extern void *__asan_memmove(void *dest, const void *src, uptr n);
+
+// RTL (Interface)
+extern void __asan_init(void);
+extern void __asan_version_mismatch_check(void);
+extern void __asan_handle_no_return(void);
+
+// RTL (Variables)
+extern uptr __asan_shadow_memory_dynamic_address;
+extern int __asan_option_detect_stack_use_after_return;
+
+// RTL (Report)
+extern void __asan_report_load1(uptr addr);
+extern void __asan_report_load2(uptr addr);
+extern void __asan_report_load4(uptr addr);
+extern void __asan_report_load8(uptr addr);
+extern void __asan_report_load16(uptr addr);
+extern void __asan_report_load_n(uptr addr, uptr size);
+extern void __asan_report_store1(uptr addr);
+extern void __asan_report_store2(uptr addr);
+extern void __asan_report_store4(uptr addr);
+extern void __asan_report_store8(uptr addr);
+extern void __asan_report_store16(uptr addr);
+extern void __asan_report_store_n(uptr addr, uptr size);
+
+// RTL (Report-experimental)
+extern void __asan_report_exp_load1(uptr addr, u32 exp);
+extern void __asan_report_exp_load2(uptr addr, u32 exp);
+extern void __asan_report_exp_load4(uptr addr, u32 exp);
+extern void __asan_report_exp_load8(uptr addr, u32 exp);
+extern void __asan_report_exp_load16(uptr addr, u32 exp);
+extern void __asan_report_exp_load_n(uptr addr, uptr size, u32 exp);
+extern void __asan_report_exp_store1(uptr addr, u32 exp);
+extern void __asan_report_exp_store2(uptr addr, u32 exp);
+extern void __asan_report_exp_store4(uptr addr, u32 exp);
+extern void __asan_report_exp_store8(uptr addr, u32 exp);
+extern void __asan_report_exp_store16(uptr addr, u32 exp);
+extern void __asan_report_exp_store_n(uptr addr, uptr size, u32 exp);
+
+// RTL (Report-noabort)
+extern void __asan_report_load1_noabort(uptr addr);
+extern void __asan_report_load2_noabort(uptr addr);
+extern void __asan_report_load4_noabort(uptr addr);
+extern void __asan_report_load8_noabort(uptr addr);
+extern void __asan_report_load16_noabort(uptr addr);
+extern void __asan_report_load_n_noabort(uptr addr, uptr size);
+extern void __asan_report_store1_noabort(uptr addr);
+extern void __asan_report_store2_noabort(uptr addr);
+extern void __asan_report_store4_noabort(uptr addr);
+extern void __asan_report_store8_noabort(uptr addr);
+extern void __asan_report_store16_noabort(uptr addr);
+extern void __asan_report_store_n_noabort(uptr addr, uptr size);
+
+// RTL (Access)
+extern void __asan_load1(uptr p);
+extern void __asan_load2(uptr p);
+extern void __asan_load4(uptr p);
+extern void __asan_load8(uptr p);
+extern void __asan_load16(uptr p);
+extern void __asan_loadN(uptr p, uptr size);
+extern void __asan_store1(uptr p);

[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D148851#4285583 , @shafik wrote:

> Do you know why these started timing out? I saw this locally the other day 
> but could not figure out the root cause.

D86170  provides some information about 
llvm-symbolizer performance with an unoptimized debug build.
I think we probably should add `LLVM_DISABLE_SYMBOLIZATION=1` to the lit level, 
not in individual tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-04-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Do you know why these started timing out? I saw this locally the other day but 
could not figure out the root cause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

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


[PATCH] D148596: [KMSAN] Enable on SystemZ

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:1498
+if (MS.TargetTriple.getArch() == Triple::systemz)
+  MS.MsanMetadataAlloca = IRB.CreateAlloca(MS.MsanMetadata, (unsigned)0);
   }

Just  use 0. 

Even 0u is better than `(unsigned)0`.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148596

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


[PATCH] D148596: [KMSAN] Enable on SystemZ

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/Instrumentation/MemorySanitizer/SystemZ/basic-kernel.ll:12
+
+; CHECK-LABEL: @Store1
+; CHECK: [[META_PTR:%[a-z0-9_]+]] = alloca { ptr, ptr }, align 8

`; CHECK-LABEL: define {{[^@]+}}@Store1(` to match the `@Store` definition, not 
calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148596

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


[PATCH] D148751: [CMake] Add llvm-lib to Clang bootstrap dependency for LTO builds on Windows

2023-04-20 Thread Igor Kudrin 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 rG43c307fd690f: [CMake] Add llvm-lib to Clang bootstrap 
dependency for LTO builds on Windows (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148751

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -613,6 +613,9 @@
   # variable, and have LLVM's CMake append the envar to the archiver calls.
   set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
+elseif(MSVC)
+  add_dependencies(clang-bootstrap-deps llvm-lib)
+  set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lib)
 elseif(NOT WIN32)
   add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
   if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR)


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -613,6 +613,9 @@
   # variable, and have LLVM's CMake append the envar to the archiver calls.
   set(LTO_LIBRARY -DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
+elseif(MSVC)
+  add_dependencies(clang-bootstrap-deps llvm-lib)
+  set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lib)
 elseif(NOT WIN32)
   add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
   if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 43c307f - [CMake] Add llvm-lib to Clang bootstrap dependency for LTO builds on Windows

2023-04-20 Thread Igor Kudrin via cfe-commits

Author: Igor Kudrin
Date: 2023-04-20T17:02:17-07:00
New Revision: 43c307fd690ffa97877f371ff18530fcd0bddd82

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

LOG: [CMake] Add llvm-lib to Clang bootstrap dependency for LTO builds on 
Windows

Without this dependency, it is possible that llvm-lib.exe will not be
built, in which case CMake will try to use lib.exe to build libraries,
but this tool cannot handle bitcode files.

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 1fff005d65251..4508ea4c77aa5 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -613,6 +613,9 @@ if (CLANG_ENABLE_BOOTSTRAP)
   # variable, and have LLVM's CMake append the envar to the archiver calls.
   set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
 -DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
+elseif(MSVC)
+  add_dependencies(clang-bootstrap-deps llvm-lib)
+  set(${CLANG_STAGE}_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-lib)
 elseif(NOT WIN32)
   add_dependencies(clang-bootstrap-deps llvm-ar llvm-ranlib)
   if(NOT BOOTSTRAP_LLVM_ENABLE_LLD AND LLVM_BINUTILS_INCDIR)



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


[PATCH] D148596: [KMSAN] Enable on SystemZ

2023-04-20 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis 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/D148596/new/

https://reviews.llvm.org/D148596

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


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-04-20 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

>> That's a new one -- would you be able to give some context and a reproducer? 
>> Thanks for reporting!
>
> Yep -- as of LLVM commit 3c9083f6757cbaf6f8d6c601586d99a11faf642e 
> , Halide 
> is still broken. Working on a repro case now.

This is regrettably large, but easy to repro:

- Unzip the file
- `llc gpu_object_lifetime.runtime.ll`
- See the assertion failure and stack dump (pasted below):

  Assertion failed: (!(Elmt.getFragmentOrDefault() == 
Next.getFragmentOrDefault())), function operator(), file 
AssignmentTrackingAnalysis.cpp, line 2020.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.Program arguments: /Users/srj/llvm-17-install/bin/llc 
gpu_object_lifetime.runtime.ll
  1.Running pass 'Function Pass Manager' on module 
'gpu_object_lifetime.runtime.ll'.
  2.Running pass 'Assignment Tracking Analysis' on function 
'@halide_debug_to_file'
   #0 0x000106b92697 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/Users/srj/llvm-17-install/bin/llc+0x101fab697)
   #1 0x000106b90638 llvm::sys::RunSignalHandlers() 
(/Users/srj/llvm-17-install/bin/llc+0x101fa9638)
   #2 0x000106b92e40 SignalHandler(int) 
(/Users/srj/llvm-17-install/bin/llc+0x101fabe40)
   #3 0x7ff81c079dfd 
(/usr/lib/system/libsystem_platform.dylib+0x7ff800336dfd)
   #4 0x7ff7bb316720
   #5 0x7ff81bfafd24 (/usr/lib/system/libsystem_c.dylib+0x7ff80026cd24)
   #6 0x7ff81bfaf0cb (/usr/lib/system/libsystem_c.dylib+0x7ff80026c0cb)
   #7 0x0001076f1da3 void 
std::__1::__sort, 
llvm::DenseMapInfo, void>> const&, llvm::DenseMap, 1u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair, 
1u>>>&, unsigned int&)::$_1&, llvm::DebugVariable*>(llvm::DebugVariable*, 
llvm::DebugVariable*, buildOverlapMapAndRecordDeclares(llvm::Function&, 
FunctionVarLocsBuilder*, llvm::DenseSet, 
llvm::DenseMapInfo, void>> const&, llvm::DenseMap, 1u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair, 
1u>>>&, unsigned int&)::$_1&) (.cold.4) 
(/Users/srj/llvm-17-install/bin/llc+0x102b0ada3)
   #8 0x000105e3b47d void 
std::__1::__sort, 
llvm::DenseMapInfo, void>> const&, llvm::DenseMap, 1u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair, 
1u>>>&, unsigned int&)::$_1&, llvm::DebugVariable*>(llvm::DebugVariable*, 
llvm::DebugVariable*, buildOverlapMapAndRecordDeclares(llvm::Function&, 
FunctionVarLocsBuilder*, llvm::DenseSet, 
llvm::DenseMapInfo, void>> const&, llvm::DenseMap, 1u>, llvm::DenseMapInfo, llvm::detail::DenseMapPair, 
1u>>>&, unsigned int&)::$_1&) (/Users/srj/llvm-17-install/bin/llc+0x10125447d)
   #9 0x000105e2ff8c (anonymous 
namespace)::AssignmentTrackingLowering::run(FunctionVarLocsBuilder*) 
(/Users/srj/llvm-17-install/bin/llc+0x101248f8c)
  #10 0x000105e2ce9e 
llvm::AssignmentTrackingAnalysis::runOnFunction(llvm::Function&) 
(/Users/srj/llvm-17-install/bin/llc+0x101245e9e)
  #11 0x00010649a082 llvm::FPPassManager::runOnFunction(llvm::Function&) 
(/Users/srj/llvm-17-install/bin/llc+0x1018b3082)
  #12 0x0001064a08a1 llvm::FPPassManager::runOnModule(llvm::Module&) 
(/Users/srj/llvm-17-install/bin/llc+0x1018b98a1)
  #13 0x00010649a687 llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(/Users/srj/llvm-17-install/bin/llc+0x1018b3687)
  #14 0x000104beed44 compileModule(char**, llvm::LLVMContext&) 
(/Users/srj/llvm-17-install/bin/llc+0x17d44)
  #15 0x000104beca4f main (/Users/srj/llvm-17-install/bin/llc+0x15a4f)

F27211069: gpu_object_lifetime.runtime.ll.zip 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


[PATCH] D148849: [OpenMP-OPT] Remove limit for heap to stack conversions of __kmpc_alloc_shared allocations

2023-04-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148849

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


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-04-20 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D146987#4285299 , @jmorse wrote:

> In D146987#4285275 , @srj wrote:
>
>> For the record, this also breaks (broke?) Halide:
>>
>> Assertion failed: (!(Elmt.getFragmentOrDefault() == 
>> Next.getFragmentOrDefault())), function operator(), file 
>> AssignmentTrackingAnalysis.cpp, line 2020.
>
> That's a new one -- would you be able to give some context and a reproducer? 
> Thanks for reporting!

Yep -- as of LLVM commit 3c9083f6757cbaf6f8d6c601586d99a11faf642e 
, Halide 
is still broken. Working on a repro case now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


[PATCH] D148849: [OpenMP-OPT] Remove limit for heap to stack conversions of __kmpc_alloc_shared allocations

2023-04-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 added a comment.

In D148849#4285236 , @jdoerfert wrote:

> Make a test for the attributor/openmp-opt, also don't use O2 
>  in tests, the IR only test is 
> sufficient.

I removed the clang test since it wasn't testing anything new.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148849

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


[PATCH] D148849: [OpenMP-OPT] Remove limit for heap to stack conversions of __kmpc_alloc_shared allocations

2023-04-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 updated this revision to Diff 515516.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148849

Files:
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp
  llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll


Index: llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
===
--- llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
+++ llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
@@ -741,6 +741,21 @@
   ret void
 }
 
+define void @convert_large_kmpc_alloc_shared() {
+; CHECK-LABEL: define {{[^@]+}}@convert_large_kmpc_alloc_shared() {
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:[[I_H2S:%.*]] = alloca i8, i64 256, align 1, addrspace(5)
+; CHECK-NEXT:[[MALLOC_CAST:%.*]] = addrspacecast ptr addrspace(5) 
[[I_H2S]] to ptr
+; CHECK-NEXT:tail call void @usei8(ptr noalias nocapture nofree 
[[MALLOC_CAST]]) #[[ATTR7]]
+; CHECK-NEXT:ret void
+;
+bb:
+  %i = tail call noalias ptr @__kmpc_alloc_shared(i64 256)
+  tail call void @usei8(ptr nocapture nofree %i) nosync nounwind willreturn
+  tail call void @__kmpc_free_shared(ptr %i, i64 256)
+  ret void
+}
+
 
 ;.
 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn }
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7180,7 +7180,8 @@
 }
 
 std::optional Size = getSize(A, *this, AI);
-if (MaxHeapToStackSize != -1) {
+if (AI.LibraryFunctionId != LibFunc___kmpc_alloc_shared &&
+MaxHeapToStackSize != -1) {
   if (!Size || Size->ugt(MaxHeapToStackSize)) {
 LLVM_DEBUG({
   if (!Size)


Index: llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
===
--- llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
+++ llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
@@ -741,6 +741,21 @@
   ret void
 }
 
+define void @convert_large_kmpc_alloc_shared() {
+; CHECK-LABEL: define {{[^@]+}}@convert_large_kmpc_alloc_shared() {
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:[[I_H2S:%.*]] = alloca i8, i64 256, align 1, addrspace(5)
+; CHECK-NEXT:[[MALLOC_CAST:%.*]] = addrspacecast ptr addrspace(5) [[I_H2S]] to ptr
+; CHECK-NEXT:tail call void @usei8(ptr noalias nocapture nofree [[MALLOC_CAST]]) #[[ATTR7]]
+; CHECK-NEXT:ret void
+;
+bb:
+  %i = tail call noalias ptr @__kmpc_alloc_shared(i64 256)
+  tail call void @usei8(ptr nocapture nofree %i) nosync nounwind willreturn
+  tail call void @__kmpc_free_shared(ptr %i, i64 256)
+  ret void
+}
+
 
 ;.
 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn }
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7180,7 +7180,8 @@
 }
 
 std::optional Size = getSize(A, *this, AI);
-if (MaxHeapToStackSize != -1) {
+if (AI.LibraryFunctionId != LibFunc___kmpc_alloc_shared &&
+MaxHeapToStackSize != -1) {
   if (!Size || Size->ugt(MaxHeapToStackSize)) {
 LLVM_DEBUG({
   if (!Size)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-04-20 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

In D146987#4285275 , @srj wrote:

> For the record, this also breaks (broke?) Halide:
>
> Assertion failed: (!(Elmt.getFragmentOrDefault() == 
> Next.getFragmentOrDefault())), function operator(), file 
> AssignmentTrackingAnalysis.cpp, line 2020.

That's a new one -- would you be able to give some context and a reproducer? 
Thanks for reporting!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-04-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

These tests are all timing out after 600 seconds. 
https://green.lab.llvm.org/green/job/clang-stage1-RA/34005/#showFailuresLink


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-04-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: delcypher, MaskRay, dblaikie.
ahatanak added a project: clang.
Herald added a project: All.
ahatanak requested review of this revision.

These tests don't require invoking llvm-symbolizer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148851

Files:
  clang/test/Driver/crash-diagnostics-dir-3.c
  clang/test/Driver/crash-diagnostics-dir.c
  clang/test/Driver/crash-report-clang-cl.cpp
  clang/test/Driver/crash-report-header.h
  clang/test/Driver/crash-report-spaces.c
  clang/test/Driver/crash-report-with-asserts.c
  clang/test/Driver/crash-report.cpp
  clang/test/Driver/emit-reproducer.c
  clang/test/Driver/output-file-cleanup.c
  clang/test/Driver/rewrite-map-in-diagnostics.c


Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- clang/test/Driver/rewrite-map-in-diagnostics.c
+++ clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf "%t"
 // RUN: mkdir -p "%t"
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
Index: clang/test/Driver/output-file-cleanup.c
===
--- clang/test/Driver/output-file-cleanup.c
+++ clang/test/Driver/output-file-cleanup.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -f "%t.d" "%t1.s" "%t2.s" "%t3.s" "%t4.s" "%t5.s"
 //
 // RUN: touch %t.s
Index: clang/test/Driver/emit-reproducer.c
===
--- clang/test/Driver/emit-reproducer.c
+++ clang/test/Driver/emit-reproducer.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t && mkdir %t
 
 // RUN: echo "%s -fcrash-diagnostics-dir=%t -fsyntax-only" | sed -e 
's/\\//g' > %t.rsp
Index: clang/test/Driver/crash-report.cpp
===
--- clang/test/Driver/crash-report.cpp
+++ clang/test/Driver/crash-report.cpp
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
Index: clang/test/Driver/crash-report-with-asserts.c
===
--- clang/test/Driver/crash-report-with-asserts.c
+++ clang/test/Driver/crash-report-with-asserts.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
Index: clang/test/Driver/crash-report-spaces.c
===
--- clang/test/Driver/crash-report-spaces.c
+++ clang/test/Driver/crash-report-spaces.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf "%t"
 // RUN: mkdir "%t"
 // RUN: cp "%s" "%t/crash report spaces.c"
Index: clang/test/Driver/crash-report-header.h
===
--- clang/test/Driver/crash-report-header.h
+++ clang/test/Driver/crash-report-header.h
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTIONS=1 not %clang 
-fsyntax-only %s 2>&1 | FileCheck %s
Index: clang/test/Driver/crash-report-clang-cl.cpp
===
--- clang/test/Driver/crash-report-clang-cl.cpp
+++ clang/test/Driver/crash-report-clang-cl.cpp
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: mkdir %t
 
Index: clang/test/Driver/crash-diagnostics-dir.c
===
--- clang/test/Driver/crash-diagnostics-dir.c
+++ clang/test/Driver/crash-diagnostics-dir.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: not %clang -fcrash-diagnostics-dir=%t -c %s -o - 2>&1 | FileCheck %s
 #pragma clang __debug parser_crash
Index: clang/test/Driver/crash-diagnostics-dir-3.c
===
--- clang/test/Driver/crash-diagnostics-dir-3.c
+++ clang/test/Driver/crash-diagnostics-dir-3.c
@@ -1,4 +1,5 @@
 // RUN: export LSAN_OPTIONS=detect_leaks=0
+// RUN: export LLVM_DISABLE_SYMBOLIZATION=1
 // RUN: rm -rf %t
 // RUN: not env CLANG_CRASH_DIAGNOSTICS_DIR=%t %clang -c %s -o - 2>&1 | 
FileCheck %s
 #pragma clang __debug parser_crash


Index: clang/test/Driver/rewrite-map-in-diagnostics.c
===
--- 

[PATCH] D147844: Emit warning when implicit cast from int to bool happens in an conditional operator expression

2023-04-20 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 515513.
chaitanyav added a comment.

clang-format the changes to the file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  libcxx/include/__chrono/duration.h
  libcxxabi/src/cxa_personality.cpp

Index: libcxxabi/src/cxa_personality.cpp
===
--- libcxxabi/src/cxa_personality.cpp
+++ libcxxabi/src/cxa_personality.cpp
@@ -718,9 +718,7 @@
 if (actionEntry == 0)
 {
 // Found a cleanup
-results.reason = actions & _UA_SEARCH_PHASE
- ? _URC_CONTINUE_UNWIND
- : _URC_HANDLER_FOUND;
+results.reason = (actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;
 return;
 }
 // Convert 1-based byte offset into
@@ -832,9 +830,8 @@
 // End of action list. If this is phase 2 and we have found
 // a cleanup (ttypeIndex=0), return _URC_HANDLER_FOUND;
 // otherwise return _URC_CONTINUE_UNWIND.
-results.reason = hasCleanup && actions & _UA_CLEANUP_PHASE
- ? _URC_HANDLER_FOUND
- : _URC_CONTINUE_UNWIND;
+results.reason =
+(hasCleanup && (actions & _UA_CLEANUP_PHASE)) ? _URC_HANDLER_FOUND : _URC_CONTINUE_UNWIND;
 return;
 }
 // Go to next action
@@ -1243,10 +1240,9 @@
 {
 const __shim_type_info* excpType =
 static_cast(new_exception_header->exceptionType);
-adjustedPtr =
-__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass ?
-((__cxa_dependent_exception*)new_exception_header)->primaryException :
-new_exception_header + 1;
+adjustedPtr = (__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass)
+  ? ((__cxa_dependent_exception*)new_exception_header)->primaryException
+  : new_exception_header + 1;
 if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
   excpType, adjustedPtr,
   unwind_exception, base))
Index: libcxx/include/__chrono/duration.h
===
--- libcxx/include/__chrono/duration.h
+++ libcxx/include/__chrono/duration.h
@@ -194,7 +194,7 @@
 return __lower;
 if (__lower_diff > __upper_diff)
 return __upper;
-return __lower.count() & 1 ? __upper : __lower;
+return (__lower.count() & 1) ? __upper : __lower;
 }
 #endif
 
Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -41,7 +41,7 @@
   uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
-  overflow = 4608 * 1024 * 1024 ?  4608 * 1024 * 1024 : 0;
+  overflow = (4608 * 1024 * 1024) ?  4608 * 1024 * 1024 : 0;
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
   overflow =  0 ? 0 : 4608 * 1024 * 1024;
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -87,7 +87,7 @@
 }
 
 #define SIZE 10
-#define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1
+#define ARR_IN_MACRO(flag, arr, idx) (flag ? arr[idx] : 1)
 
 int test_no_warn_macro_unreachable() {
   int arr[SIZE]; // expected-note {{array 'arr' declared here}}
Index: clang/test/Sema/parentheses.cpp
===
--- clang/test/Sema/parentheses.cpp
+++ clang/test/Sema/parentheses.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only 

[PATCH] D148812: [NFC][clang] Fix static analyzer concerns

2023-04-20 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Thanks, Soumi! Looks good to me!


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

https://reviews.llvm.org/D148812

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


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-04-20 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

For the record, this also breaks (broke?) Halide:

Assertion failed: (!(Elmt.getFragmentOrDefault() == 
Next.getFragmentOrDefault())), function operator(), file 
AssignmentTrackingAnalysis.cpp, line 2020.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 515511.
craig.topper added a comment.

Fix more review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/riscv-default-build-attributes.s


Index: clang/test/Driver/riscv-default-build-attributes.s
===
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,19 @@
+ Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ENABLED
+
+/// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ENABLED
+
+/// Option ignored for C/C++ (since we always emit hardware and ABI build
+/// attributes during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 
\
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
+
+  if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+   options::OPT_mno_default_build_attributes, true)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-riscv-add-build-attributes");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,


Index: clang/test/Driver/riscv-default-build-attributes.s
===
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,19 @@
+ Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ENABLED
+
+/// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ENABLED
+
+/// Option ignored for C/C++ (since we always emit hardware and ABI build
+/// attributes during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
+
+  if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+   options::OPT_mno_default_build_attributes, true)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-riscv-add-build-attributes");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148849: [OpenMP-OPT] Remove limit for heap to stack conversions of __kmpc_alloc_shared allocations

2023-04-20 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Make a test for the attributor/openmp-opt, also don't use O2 
 in tests, the IR only test is 
sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148849

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


[PATCH] D141310: [clang] add -Wcompare-function-pointers

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

@aaron.ballman are you okay with this being merged now, provided that it's off 
by default? Apologies for letting this one fall through the cracks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141310

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


[PATCH] D140125: [clang] splits diagnostic message into summary and reason

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

Abandoning since we're going down a different design path now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140125

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


[PATCH] D138939: [WIP][clang] adds a way to provide user-oriented reasons

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.
Herald added a subscriber: PiotrZSL.
Herald added a project: clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.

Abandoning since we're heading down a different design path now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138939

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


[PATCH] D135338: [clang] adds move-assignable type-trait builtins

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

Abandoning, since this doesn't have consensus.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135338

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


[PATCH] D135240: [clang] adds move-constructible type-trait builtins

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

Abandoning, since this doesn't have consensus.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135240

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


[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/test/Driver/riscv-default-build-attributes.s:3
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+

craig.topper wrote:
> jrtc27 wrote:
> > jrtc27 wrote:
> > > `=` for these
> > Also aren't these indented 1 too many spaces?
> Cleary I should not have copied ARM's test :(
Yeah... :( ARM and AArch64 tests can be pretty iffy in my experience


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

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


[PATCH] D135239: [clang] adds copy-assignable type-trait builtins

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

Abandoning, since this doesn't have consensus.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135239

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


[PATCH] D135238: [clang] adds copy-constructible type-trait builtins

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

Abandoning, since this doesn't have consensus.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135238

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


[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Driver/riscv-default-build-attributes.s:3
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+

jrtc27 wrote:
> jrtc27 wrote:
> > `=` for these
> Also aren't these indented 1 too many spaces?
Cleary I should not have copied ARM's test :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

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


[PATCH] D107292: [clang] adds warning to alert user when they use alternative tokens in declarations

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.
Herald added a project: All.

I think there was a clang-tidy patch that handled this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107292

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


[PATCH] D129951: adds `__disable_adl` attribute

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5756
+  if (FunctionDecl *F = D->getAsFunction();
+  F->isOverloadedOperator() || F->isCXXClassMember()) {
+S.Diag(AL.getLoc(), diag::err_disable_adl_no_operators)

cor3ntin wrote:
> aaron.ballman wrote:
> > cor3ntin wrote:
> > > aaron.ballman wrote:
> > > > cjdb wrote:
> > > > > rsmith wrote:
> > > > > > Maybe also global `operator new` / `operator delete`?
> > > > > How does ADL even work in with the global namespace? Should it be 
> > > > > invalid to apply here?
> > > > Should this be `isCXXInstanceMember()` instead? Or do we intend to 
> > > > disallow this on static member functions?
> > > Static member functions would be qualified, and not involve ADL. This 
> > > seems correct.
> > Hmmm, I think they're *normally* qualified, but if you call the static 
> > function from within a member function, it doesn't have to be qualified.
> nvm, they can be found by adl from within member functions.
Do we have a use-case for this? I'd rather start with global functions and add 
static member functions if a genuine need arises.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

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


[PATCH] D129951: adds `__disable_adl` attribute

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 515497.
cjdb marked 6 inline comments as done.
cjdb added a comment.
Herald added subscribers: aheejin, dschuff.

- undoes whitespace changes as requested
- documents feature

I think the only thing left is to address the global new/delete and static 
member function discussion, which should be quickly implementable!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129951

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/disable-adl.cpp

Index: clang/test/SemaCXX/disable-adl.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/disable-adl.cpp
@@ -0,0 +1,179 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++20
+// RUN: %clang_cc1 %s -fsyntax-only -verify -std=c++2b
+
+namespace NS1 {
+  struct S1 {};
+  S1 inhibited(S1); // expected-note 2 {{candidate function}}
+
+  namespace NNS1 {
+struct S2 {};
+__disable_adl void hidden(S2);   // expected-note{{declared here}}
+__disable_adl int inhibited(S1); // expected-note 4 {{candidate function}}
+  }
+}
+
+namespace NS2 {
+  __disable_adl void inhibited(NS1::S1); // expected-note 2 {{candidate function}}
+}
+
+void test_functions() {
+  hidden(NS1::NNS1::S2{}); // expected-error{{use of undeclared identifier 'hidden'; did you mean 'NS1::NNS1::hidden'?}}
+  {
+NS1::S1 x = inhibited(NS1::S1{}); // no error
+  }
+  {
+using namespace NS1::NNS1;
+int x = inhibited(NS1::S1{}); // no error
+
+using namespace NS1;
+S1 y = inhibited(NS1::S1{}); // expected-error{{call to 'inhibited' is ambiguous}}
+  }
+  {
+using NS1::NNS1::inhibited;
+int x = inhibited(NS1::S1{}); // no error
+
+using NS1::inhibited;
+NS1::S1 y = inhibited(NS1::S1{}); // expected-error{{call to 'inhibited' is ambiguous}}
+  }
+  {
+using namespace NS2;
+inhibited(NS1::S1{}); // no error
+
+using namespace NS1::NNS1;
+inhibited(NS1::S1{}); // expected-error{{call to 'inhibited' is ambiguous}}
+  }
+  {
+using NS2::inhibited;
+inhibited(NS1::S1{}); // no error
+
+using NS1::NNS1::inhibited;
+inhibited(NS1::S1{}); // expected-error{{call to 'inhibited' is ambiguous}}
+  }
+}
+
+namespace NS1 {
+  template
+  S1 inhibited_template(T); // expected-note 2 {{candidate function}}
+
+  namespace NNS1 {
+template
+__disable_adl void hidden_template(T); // expected-note{{declared here}}
+
+template
+__disable_adl int inhibited_template(T); // expected-note 4 {{candidate function}}
+  }
+}
+
+namespace NS2 {
+  template
+  __disable_adl int inhibited_template(T); // expected-note 2 {{candidate function}}
+}
+
+void test_function_templates() {
+  hidden_template(NS1::NNS1::S2{}); // expected-error{{use of undeclared identifier 'hidden_template'; did you mean 'NS1::NNS1::hidden_template'?}}
+
+  {
+NS1::S1 x = inhibited_template(NS1::S1{}); // no error
+  }
+  {
+using namespace NS1::NNS1;
+int x = inhibited_template(NS1::S1{}); // no error
+
+using namespace NS1;
+S1 y = inhibited_template(NS1::S1{}); // expected-error{{call to 'inhibited_template' is ambiguous}}
+  }
+  {
+using NS1::NNS1::inhibited_template;
+int x = inhibited_template(NS1::S1{}); // no error
+
+using NS1::inhibited_template;
+NS1::S1 y = inhibited_template(NS1::S1{}); // expected-error{{call to 'inhibited_template' is ambiguous}}
+  }
+  {
+using namespace NS2;
+inhibited_template(NS1::S1{}); // no error
+
+using namespace NS1::NNS1;
+inhibited_template(NS1::S1{}); // expected-error{{call to 'inhibited_template' is ambiguous}}
+  }
+  {
+using NS2::inhibited_template;
+inhibited_template(NS1::S1{}); // no error
+
+using NS1::NNS1::inhibited_template;
+inhibited_template(NS1::S1{}); // expected-error{{call to 'inhibited_template' is ambiguous}}
+  }
+}
+
+namespace NS1 {
+  S1 inhibited_mixed(S1);
+
+  namespace NNS1 {
+template
+__disable_adl int inhibited_mixed(T);
+  }
+}
+
+void test_mixed() {
+  using namespace NS1::NNS1;
+  int x = inhibited_mixed(NS1::S1{}); // no error
+}
+
+// Should be covered by the hidden functions checks, but just to be sure.
+void test_NNS1_hidden() {
+  {
+NS1::S1 a = inhibited(NS1::S1{});
+NS1::S1 b = inhibited_template(NS1::S1{});
+NS1::S1 c = inhibited_mixed(NS1::S1{});
+  }
+  {
+using namespace NS1;
+NS1::S1 a = inhibited(NS1::S1{});
+NS1::S1 b = inhibited_template(NS1::S1{});
+NS1::S1 c = inhibited_mixed(NS1::S1{});
+  }
+}
+
+namespace NS1 {
+  namespace NNS1 {
+__disable_adl void operator-(S2); // 

[PATCH] D148812: [NFC][clang] Fix static analyzer concerns

2023-04-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 515494.
Manna marked an inline comment as done and an inline comment as not done.
Manna edited the summary of this revision.
Manna added a comment.

I have removed the case involving the `Policy` class


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

https://reviews.llvm.org/D148812

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/Lex/Pragma.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -4259,7 +4259,7 @@
 
   // Generate all of the custom appertainsTo functions that the attributes
   // will be using.
-  for (auto I : Attrs) {
+  for (const auto  : Attrs) {
 const Record  = *I.second;
 if (Attr.isValueUnset("Subjects"))
   continue;
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3971,7 +3971,7 @@
 }
 
 llvm::SmallPtrSet UninitializedBaseClasses;
-for (auto I : RD->bases())
+for (const auto  : RD->bases())
   UninitializedBaseClasses.insert(I.getType().getCanonicalType());
 
 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1107,7 +1107,7 @@
 return;
   ModuleMap  = PP.getHeaderSearchInfo().getModuleMap();
   Module *M = nullptr;
-  for (auto IIAndLoc : ModuleName) {
+  for (const auto  : ModuleName) {
 M = MM.lookupModuleQualified(IIAndLoc.first->getName(), M);
 if (!M) {
   PP.Diag(IIAndLoc.second, diag::warn_pragma_debug_unknown_module)
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1269,13 +1269,13 @@
   else
 TypeVis = llvm::GlobalObject::VCallVisibilityPublic;
 
-  for (auto B : RD->bases())
+  for (const auto  : RD->bases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
   TypeVis = std::min(
   TypeVis,
   GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
-  for (auto B : RD->vbases())
+  for (const auto  : RD->vbases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
   TypeVis = std::min(
   TypeVis,
Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -1008,7 +1008,7 @@
Diagnostics *) const override {
 
 std::vector NodeKinds;
-for (auto Arg : Args) {
+for (const auto  : Args) {
   if (!Arg.Value.isNodeKind())
 return {};
   NodeKinds.push_back(Arg.Value.getNodeKind());
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -760,7 +760,7 @@
   D |= getDependenceInExpr(E->getNameInfo());
   if (auto *Q = E->getQualifier())
 D |= toExprDependence(Q->getDependence());
-  for (auto A : E->template_arguments())
+  for (const auto  : E->template_arguments())
 D |= toExprDependence(A.getArgument().getDependence());
   return D;
 }
@@ -813,7 +813,7 @@
   if (auto *Q = E->getQualifier())
 D |= toExprDependence(Q->getDependence());
   D |= getDependenceInExpr(E->getMemberNameInfo());
-  for (auto A : E->template_arguments())
+  for (const auto  : E->template_arguments())
 D |= toExprDependence(A.getArgument().getDependence());
   return D;
 }
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8203,7 +8203,7 @@
   if (!CXXRD->hasDefinition() || !VisitBasesAndFields)
 return false;
 
-  for (auto B : CXXRD->bases())
+  for (const auto  : CXXRD->bases())
 if (hasTemplateSpecializationInEncodedString(B.getType().getTypePtr(),
  true))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147844: Emit warning when implicit cast from int to bool happens in an conditional operator expression

2023-04-20 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 515492.
chaitanyav added a comment.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

Place parentheses around conditional expression to prevent precedence warnings 
since -Werror is enabled on build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  libcxx/include/__chrono/duration.h
  libcxxabi/src/cxa_personality.cpp

Index: libcxxabi/src/cxa_personality.cpp
===
--- libcxxabi/src/cxa_personality.cpp
+++ libcxxabi/src/cxa_personality.cpp
@@ -718,7 +718,7 @@
 if (actionEntry == 0)
 {
 // Found a cleanup
-results.reason = actions & _UA_SEARCH_PHASE
+  results.reason = (actions & _UA_SEARCH_PHASE)
  ? _URC_CONTINUE_UNWIND
  : _URC_HANDLER_FOUND;
 return;
@@ -832,7 +832,7 @@
 // End of action list. If this is phase 2 and we have found
 // a cleanup (ttypeIndex=0), return _URC_HANDLER_FOUND;
 // otherwise return _URC_CONTINUE_UNWIND.
-results.reason = hasCleanup && actions & _UA_CLEANUP_PHASE
+  results.reason = (hasCleanup && (actions & _UA_CLEANUP_PHASE))
  ? _URC_HANDLER_FOUND
  : _URC_CONTINUE_UNWIND;
 return;
@@ -1244,7 +1244,7 @@
 const __shim_type_info* excpType =
 static_cast(new_exception_header->exceptionType);
 adjustedPtr =
-__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass ?
+  (__getExceptionClass(_exception_header->unwindHeader) == kOurDependentExceptionClass) ?
 ((__cxa_dependent_exception*)new_exception_header)->primaryException :
 new_exception_header + 1;
 if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
Index: libcxx/include/__chrono/duration.h
===
--- libcxx/include/__chrono/duration.h
+++ libcxx/include/__chrono/duration.h
@@ -194,7 +194,7 @@
 return __lower;
 if (__lower_diff > __upper_diff)
 return __upper;
-return __lower.count() & 1 ? __upper : __lower;
+return (__lower.count() & 1) ? __upper : __lower;
 }
 #endif
 
Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -41,7 +41,7 @@
   uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
-  overflow = 4608 * 1024 * 1024 ?  4608 * 1024 * 1024 : 0;
+  overflow = (4608 * 1024 * 1024) ?  4608 * 1024 * 1024 : 0;
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
   overflow =  0 ? 0 : 4608 * 1024 * 1024;
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -87,7 +87,7 @@
 }
 
 #define SIZE 10
-#define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1
+#define ARR_IN_MACRO(flag, arr, idx) (flag ? arr[idx] : 1)
 
 int test_no_warn_macro_unreachable() {
   int arr[SIZE]; // expected-note {{array 'arr' declared here}}
Index: clang/test/Sema/parentheses.cpp
===
--- clang/test/Sema/parentheses.cpp
+++ clang/test/Sema/parentheses.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 bool someConditionFunc();
 
@@ -38,7 +38,7 @@
   Stream >>(const char*);
 };
 
-void f(Stream& s, bool b) {
+void f(Stream& s, bool b, int x) {
   (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
   // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
   

[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Some more... hopefully spotted everything this time, sorry




Comment at: clang/test/Driver/riscv-default-build-attributes.s:1
+ Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \





Comment at: clang/test/Driver/riscv-default-build-attributes.s:3
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+

`=` for these



Comment at: clang/test/Driver/riscv-default-build-attributes.s:3
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+

jrtc27 wrote:
> `=` for these
Also aren't these indented 1 too many spaces?



Comment at: clang/test/Driver/riscv-default-build-attributes.s:20
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation: 
'-mno-default-build-attributes'}}

There aren't any uses of -verify?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

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


[PATCH] D148263: [clang] Mark CWG2009 as N/A

2023-04-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM, from what I can tell this did not change anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148263

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


[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 515484.
craig.topper added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/riscv-default-build-attributes.s


Index: clang/test/Driver/riscv-default-build-attributes.s
===
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,20 @@
+ Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+/// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+/// Option ignored for C/C++ (since we always emit hardware and ABI build
+/// attributes during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 
\
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation: 
'-mno-default-build-attributes'}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
+
+  if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+   options::OPT_mno_default_build_attributes, true)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-riscv-add-build-attributes");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,


Index: clang/test/Driver/riscv-default-build-attributes.s
===
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,20 @@
+ Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+/// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+/// Option ignored for C/C++ (since we always emit hardware and ABI build
+/// attributes during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation: '-mno-default-build-attributes'}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
+
+  if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+   options::OPT_mno_default_build_attributes, true)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-riscv-add-build-attributes");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148812: [NFC][clang] Fix static analyzer concerns

2023-04-20 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

With the exception of the case involving the `Policy` class, these changes all 
look fine to me.




Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:562
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
-  for (auto P : SupportedUnMaskedPolicies) {
+  for (const auto  : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =

erichkeane wrote:
> What type is 'P' here?  What size is it?  It is being used quite a few times 
> in this loop, which means it would have to be pretty sizable to justify 
> making it a reference unless it has a copy ctor of cost.
`P` is class `Policy` from 
`clang/include/clang/Support/RISCVVIntrinsicUtils.h`. It holds two enum values 
(with non-fixed underlying type) and has an implicit copy constructor, so cheap 
to copy. I suspect the code gen impact is negligible here, but I see no need 
for reference semantics. I recommend skipping this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148812

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


[PATCH] D145197: [clang][deps] NFC: Refactor and comment ModuleDeps sorting

2023-04-20 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D145197/new/

https://reviews.llvm.org/D145197

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


[PATCH] D148462: [clang-tidy] Ignore declarations in bugprone-exception-escape

2023-04-20 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

@njames93 What do you thing ? Should bugprone-exception-escape provide warnings 
for all forward declarations and definition, or only for definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148462

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


[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-04-20 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 515476.
PiotrZSL added a comment.

Marked check as one that provides fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147357

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/optional-value-conversion.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp
@@ -0,0 +1,213 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-optional-value-conversion %t -- --fix-notes
+// RUN: %check_clang_tidy -check-suffix=CUSTOM -std=c++17-or-later %s bugprone-optional-value-conversion %t -- \
+// RUN: -config="{CheckOptions: [{key: 'bugprone-optional-value-conversion.OptionalTypes', value: 'CustomOptional'}, \
+// RUN:  {key: 'bugprone-optional-value-conversion.ValueMethods', value: '::Read$;::Ooo$'}]}" --fix-notes
+
+namespace std {
+  template
+  struct optional
+  {
+constexpr optional() noexcept;
+constexpr optional(T&&) noexcept;
+constexpr optional(const T&) noexcept;
+template
+constexpr optional(U&&) noexcept;
+const T& operator*() const;
+T* operator->();
+const T* operator->() const;
+T& operator*();
+const T& value() const;
+T& value();
+const T& get() const;
+T& get();
+T value_or(T) const;
+  };
+
+  template 
+  T&& move(T ) {
+return static_cast(x);
+  }
+}
+
+namespace boost {
+  template
+  struct optional {
+constexpr optional() noexcept;
+constexpr optional(const T&) noexcept;
+const T& operator*() const;
+const T& get() const;
+  };
+}
+
+namespace absl {
+  template
+  struct optional {
+constexpr optional() noexcept;
+constexpr optional(const T&) noexcept;
+const T& operator*() const;
+const T& value() const;
+  };
+}
+
+template
+struct CustomOptional {
+  CustomOptional();
+  CustomOptional(const T&);
+  const T& Read() const;
+  T& operator*();
+  T& Ooo();
+};
+
+void takeOptionalValue(std::optional);
+void takeOptionalRef(const std::optional&);
+void takeOptionalRRef(std::optional&&);
+void takeOtherOptional(std::optional);
+void takeBOptionalValue(boost::optional);
+void takeAOptionalValue(absl::optional);
+
+void incorrect(std::optional param)
+{
+  std::optional* ptr = 
+  takeOptionalValue(**ptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalValue(*param);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(param.value());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(ptr->value());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalValue(param.operator*());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(ptr->operator*());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalRef(*param);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalRef(param);
+  takeOptionalRef(param.value());
+ 

[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-04-20 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

Ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147357

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


[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-04-20 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 515475.
PiotrZSL marked an inline comment as done.
PiotrZSL added a comment.

Added support for ->, added more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147357

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/optional-value-conversion.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp
@@ -0,0 +1,213 @@
+// RUN: %check_clang_tidy -std=c++17-or-later %s bugprone-optional-value-conversion %t -- --fix-notes
+// RUN: %check_clang_tidy -check-suffix=CUSTOM -std=c++17-or-later %s bugprone-optional-value-conversion %t -- \
+// RUN: -config="{CheckOptions: [{key: 'bugprone-optional-value-conversion.OptionalTypes', value: 'CustomOptional'}, \
+// RUN:  {key: 'bugprone-optional-value-conversion.ValueMethods', value: '::Read$;::Ooo$'}]}" --fix-notes
+
+namespace std {
+  template
+  struct optional
+  {
+constexpr optional() noexcept;
+constexpr optional(T&&) noexcept;
+constexpr optional(const T&) noexcept;
+template
+constexpr optional(U&&) noexcept;
+const T& operator*() const;
+T* operator->();
+const T* operator->() const;
+T& operator*();
+const T& value() const;
+T& value();
+const T& get() const;
+T& get();
+T value_or(T) const;
+  };
+
+  template 
+  T&& move(T ) {
+return static_cast(x);
+  }
+}
+
+namespace boost {
+  template
+  struct optional {
+constexpr optional() noexcept;
+constexpr optional(const T&) noexcept;
+const T& operator*() const;
+const T& get() const;
+  };
+}
+
+namespace absl {
+  template
+  struct optional {
+constexpr optional() noexcept;
+constexpr optional(const T&) noexcept;
+const T& operator*() const;
+const T& value() const;
+  };
+}
+
+template
+struct CustomOptional {
+  CustomOptional();
+  CustomOptional(const T&);
+  const T& Read() const;
+  T& operator*();
+  T& Ooo();
+};
+
+void takeOptionalValue(std::optional);
+void takeOptionalRef(const std::optional&);
+void takeOptionalRRef(std::optional&&);
+void takeOtherOptional(std::optional);
+void takeBOptionalValue(boost::optional);
+void takeAOptionalValue(absl::optional);
+
+void incorrect(std::optional param)
+{
+  std::optional* ptr = 
+  takeOptionalValue(**ptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalValue(*param);
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(param.value());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(ptr->value());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalValue(param.operator*());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(param);
+  takeOptionalValue(ptr->operator*());
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: takeOptionalValue(*ptr);
+  takeOptionalRef(*param);
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: conversion from 'std::optional' into 'int' and back into 'std::optional', remove potentially error-prone optional dereference [bugprone-optional-value-conversion]
+  // CHECK-FIXES: 

[PATCH] D147357: [clang-tidy] Add bugprone-optional-value-conversion check

2023-04-20 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL marked 2 inline comments as done.
PiotrZSL added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/optional-value-conversion.cpp:16
+  };
+}
+

njames93 wrote:
> PiotrZSL wrote:
> > njames93 wrote:
> > > It'd be good to have tests demonstating `boost::optional` and 
> > > `absl::optional` as well as the (non standard) get accessor
> > I added them to config just to add them, as they should work, I could add 
> > some tests for them, but behavior should be same...
> On the subject of boost(unsure about absl as I've never used that library)
> Would you ever add support for `T& boost::get(boost::optional &)` or its 
> const ref cousin?
No, I'm not planing to add support for boost::get. I added basic support for 
boost and absl only because it's cheap, and interfaces are similar. Main target 
is std::optional. And configuration is provider just because for example in 
project that I work for we got custom optional implementation. 
Added info about limited support for non-standard optional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147357

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


[PATCH] D148802: [Sema] Lambdas are not part of immediate context for deduction

2023-04-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/CXX/temp/temp.deduct/p9.cpp:2
+// RUN:  %clang_cc1 -std=c++20 -verify %s
+template 
+auto f(T) -> decltype([]() { T::invalid; } ());

Maybe helpful to quote p9?



Comment at: clang/test/CXX/temp/temp.deduct/p9.cpp:36
+template 
+auto j(T t) -> decltype([](auto x) -> decltype(x.invalid) { } (t));   // #1
+void j(...);// #2

I know the note in the standard does not explain why this is ok but a comment 
would be helpful to future readers.



Comment at: clang/test/CXX/temp/temp.deduct/p9.cpp:39
+void test_j() {
+  j(0);
+}

I think the comment from the draft is helpful here "deduction fails on #1, 
calls #2" 



Comment at: clang/test/SemaCXX/warn-unused-lambda-capture.cpp:192
 void test_use_template() {
-  test_templated(); // expected-note{{in instantiation of function 
template specialization 'test_templated' requested here}}
+  test_templated(); // expected-note 13{{in instantiation of function 
template specialization 'test_templated' requested here}}
 }

Why the 12 extra notes here, I feel I am missing something but not sure what. I 
see the increase in notes in other cases as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148802

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


[PATCH] D148835: [clang] removes trailing whitespace

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

I've had some very good input about why this probably shouldn't go ahead: git 
history erasure :')


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148835

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


[PATCH] D137258: [clang] Optimize storage and lookup of analyzer options

2023-04-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 515455.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

Move from `llvm::StringSwitch` back to binary search on sorted vector


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137258

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h


Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -260,9 +260,10 @@
 #undef ANALYZER_OPTION
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 
-  // Create an array of all -analyzer-config command line options. Sort it in
-  // the constructor.
-  std::vector AnalyzerConfigCmdFlags = {
+  bool isUnknownAnalyzerConfig(llvm::StringRef Name) {
+static std::vector AnalyzerConfigCmdFlags = []() {
+  // Create an array of all -analyzer-config command line options.
+  std::vector AnalyzerConfigCmdFlags = {
 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,
\
  SHALLOW_VAL, DEEP_VAL)
\
   ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)
@@ -273,10 +274,10 @@
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
 #undef ANALYZER_OPTION
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
-  };
-
-  bool isUnknownAnalyzerConfig(StringRef Name) const {
-assert(llvm::is_sorted(AnalyzerConfigCmdFlags));
+  };
+  llvm::sort(AnalyzerConfigCmdFlags);
+  return AnalyzerConfigCmdFlags;
+}();
 
 return !std::binary_search(AnalyzerConfigCmdFlags.begin(),
AnalyzerConfigCmdFlags.end(), Name);
@@ -292,9 +293,7 @@
 AnalyzerDisplayProgress(false), eagerlyAssumeBinOpBifurcation(false),
 TrimGraph(false), visualizeExplodedGraphWithGraphViz(false),
 UnoptimizedCFG(false), PrintStats(false), NoRetryExhausted(false),
-AnalyzerWerror(false) {
-llvm::sort(AnalyzerConfigCmdFlags);
-  }
+AnalyzerWerror(false) {}
 
   /// Interprets an option's string value as a boolean. The "true" string is
   /// interpreted as true and the "false" string is interpreted as false.


Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -260,9 +260,10 @@
 #undef ANALYZER_OPTION
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
 
-  // Create an array of all -analyzer-config command line options. Sort it in
-  // the constructor.
-  std::vector AnalyzerConfigCmdFlags = {
+  bool isUnknownAnalyzerConfig(llvm::StringRef Name) {
+static std::vector AnalyzerConfigCmdFlags = []() {
+  // Create an array of all -analyzer-config command line options.
+  std::vector AnalyzerConfigCmdFlags = {
 #define ANALYZER_OPTION_DEPENDS_ON_USER_MODE(TYPE, NAME, CMDFLAG, DESC,\
  SHALLOW_VAL, DEEP_VAL)\
   ANALYZER_OPTION(TYPE, NAME, CMDFLAG, DESC, SHALLOW_VAL)
@@ -273,10 +274,10 @@
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.def"
 #undef ANALYZER_OPTION
 #undef ANALYZER_OPTION_DEPENDS_ON_USER_MODE
-  };
-
-  bool isUnknownAnalyzerConfig(StringRef Name) const {
-assert(llvm::is_sorted(AnalyzerConfigCmdFlags));
+  };
+  llvm::sort(AnalyzerConfigCmdFlags);
+  return AnalyzerConfigCmdFlags;
+}();
 
 return !std::binary_search(AnalyzerConfigCmdFlags.begin(),
AnalyzerConfigCmdFlags.end(), Name);
@@ -292,9 +293,7 @@
 AnalyzerDisplayProgress(false), eagerlyAssumeBinOpBifurcation(false),
 TrimGraph(false), visualizeExplodedGraphWithGraphViz(false),
 UnoptimizedCFG(false), PrintStats(false), NoRetryExhausted(false),
-AnalyzerWerror(false) {
-llvm::sort(AnalyzerConfigCmdFlags);
-  }
+AnalyzerWerror(false) {}
 
   /// Interprets an option's string value as a boolean. The "true" string is
   /// interpreted as true and the "false" string is interpreted as false.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1a0a030 - Add documentation for -Wwrite-strings

2023-04-20 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-04-20T16:14:03-04:00
New Revision: 1a0a0305c03dc6cf42d042f39199ca37c16f6dda

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

LOG: Add documentation for -Wwrite-strings

This is the first instance where we've really needed to add
documentation for a diagnostic group, but -Wwrite-strings really
deserves it.

This warning option changes the semantic behavior of code, so enabling
it can cause code to break (and disabling it can too). That's worth
calling out loudly in our documentation.

Added: 


Modified: 
clang/include/clang/Basic/Diagnostic.td
clang/include/clang/Basic/DiagnosticDocs.td
clang/include/clang/Basic/DiagnosticGroups.td

Removed: 




diff  --git a/clang/include/clang/Basic/Diagnostic.td 
b/clang/include/clang/Basic/Diagnostic.td
index 21de05b707a58..503b833e63bbf 100644
--- a/clang/include/clang/Basic/Diagnostic.td
+++ b/clang/include/clang/Basic/Diagnostic.td
@@ -55,11 +55,11 @@ class DiagCategory {
 }
 
 // Diagnostic Groups.
-class DiagGroup subgroups = []> {
+class DiagGroup subgroups = [], code docs = [{}]> 
{
   string GroupName = Name;
   list SubGroups = subgroups;
   string CategoryName = "";
-  code Documentation = [{}];
+  code Documentation = docs;
 }
 class InGroup { DiagGroup Group = G; }
 //class IsGroup { DiagGroup Group = DiagGroup; }

diff  --git a/clang/include/clang/Basic/DiagnosticDocs.td 
b/clang/include/clang/Basic/DiagnosticDocs.td
index bf88d5d04567e..e9862422b4997 100644
--- a/clang/include/clang/Basic/DiagnosticDocs.td
+++ b/clang/include/clang/Basic/DiagnosticDocs.td
@@ -81,3 +81,9 @@ Diagnostic flags
 }];
 }
 
+defvar GCCWriteStringsDocs = [{
+**Note:** enabling this warning in C will change the semantic behavior of the
+program by treating all string literals as having type ``const char *``
+instead of ``char *``. This can cause unexpected behaviors with type-sensitive
+constructs like ``_Generic``.
+}];

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 31f64f4eceb7c..0ee43fb8837a1 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -847,7 +847,8 @@ def WritableStrings : DiagGroup<"writable-strings", 
[DeprecatedWritableStr]>;
 //
 // FIXME: Should this affect C++11 (where this is an error,
 //not just deprecated) or not?
-def GCCWriteStrings : DiagGroup<"write-strings" , [WritableStrings]>;
+def GCCWriteStrings : DiagGroup<"write-strings" , [WritableStrings],
+GCCWriteStringsDocs>;
 
 def CharSubscript : DiagGroup<"char-subscripts">;
 def LargeByValueCopy : DiagGroup<"large-by-value-copy">;



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


[PATCH] D147844: Emit warning when implicit cast to bool happens in an conditional operator expression when used inside an overloaded shift operator expression

2023-04-20 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 515445.
chaitanyav added a comment.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Place parentheses around conditional operator since & has higher precedence


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp
  libcxx/include/__chrono/duration.h

Index: libcxx/include/__chrono/duration.h
===
--- libcxx/include/__chrono/duration.h
+++ libcxx/include/__chrono/duration.h
@@ -194,7 +194,7 @@
 return __lower;
 if (__lower_diff > __upper_diff)
 return __upper;
-return __lower.count() & 1 ? __upper : __lower;
+return (__lower.count() & 1) ? __upper : __lower;
 }
 #endif
 
Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -41,7 +41,7 @@
   uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
-  overflow = 4608 * 1024 * 1024 ?  4608 * 1024 * 1024 : 0;
+  overflow = (4608 * 1024 * 1024) ?  4608 * 1024 * 1024 : 0;
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
   overflow =  0 ? 0 : 4608 * 1024 * 1024;
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -87,7 +87,7 @@
 }
 
 #define SIZE 10
-#define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1
+#define ARR_IN_MACRO(flag, arr, idx) (flag ? arr[idx] : 1)
 
 int test_no_warn_macro_unreachable() {
   int arr[SIZE]; // expected-note {{array 'arr' declared here}}
Index: clang/test/Sema/parentheses.cpp
===
--- clang/test/Sema/parentheses.cpp
+++ clang/test/Sema/parentheses.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 bool someConditionFunc();
 
@@ -38,7 +38,7 @@
   Stream >>(const char*);
 };
 
-void f(Stream& s, bool b) {
+void f(Stream& s, bool b, int x) {
   (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
   // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
   // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
@@ -62,6 +62,30 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
+
+  void(s << "Test" << x ? "foo" : "bar"); //expected-warning {{operator '?:' has lower precedence than '<<'}} \
+ // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:8-[[@LINE-3]]:8}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:24-[[@LINE-4]]:24}:")"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:23-[[@LINE-5]]:23}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:40-[[@LINE-6]]:40}:")"
+
+  void(s << x == 1 ? "foo": "bar"); //expected-warning {{overloaded operator << has higher precedence than comparison operator}} \
+   //expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+  // expected-note {{place parentheses around comparison expression to evaluate it first}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:8-[[@LINE-3]]:8}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:14-[[@LINE-4]]:14}:")"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
+
+  void(s << static_cast(x) ? "foo" : "bar"); //expected-warning {{operator '?:' has lower precedence than '<<'}} \
+  

[PATCH] D148835: [clang] removes trailing whitespace

2023-04-20 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added reviewers: aaron.ballman, shafik, erichkeane, dblaikie.
Herald added subscribers: luke, steakhal, bzcheeseman, kosarev, pmatos, asb, 
ormris, frasercrmck, jdoerfert, martong, luismarques, apazos, sameer.abuasal, 
pengfei, s.egerton, Jim, jocewei, PkmX, arphaman, the_o, brucehoult, 
MartinMosbeck, rogfer01, steven_wu, atanasyan, edward-jones, zzheng, jrtc27, 
niosHD, sabuasal, simoncook, johnrusso, rbar, kbarton, hiraditya, krytarowski, 
whisperity, sbc100, jvesely, nemanjai, dschuff.
Herald added a reviewer: paulkirth.
Herald added a reviewer: NoQ.
Herald added a reviewer: ributzka.
Herald added a project: All.
Herald added a comment.
cjdb requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, pcwang-thead, sstefan1, MaskRay, 
aheejin.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: dang.
Herald added a project: clang.

NOTE: Clang-Format Team Automated Review Comment

Your review contains a change to ClangFormatStyleOptions.rst but not a change 
to clang/include/clang/Format/Format.h

ClangFormatStyleOptions.rst is auto generated from Format.h via 
clang/docs/tools/dump_format_style.py,  please run this to regenerate the .rst

You can validate that the rst is valid by running.

  ./docs/tools/dump_format_style.py
  mkdir -p html
  /usr/bin/sphinx-build -n ./docs ./html


Lots of files have trailing whitespace characters, which get removed by
many text editors upon save. I've run `sed -i 's/\s*$//g'` on all files
in `clang` except for clang-format, and manually reverted anything that
causes `ninja check-clang check-clang-utils` to fail. This ensures that
commits of substance don't accrue bogus diffs and commentary requesting
they be reverted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148835

Files:
  clang/ModuleInfo.txt
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ClangLinkerWrapper.rst
  clang/docs/ClangOffloadPackager.rst
  clang/docs/ClangTransformerTutorial.rst
  clang/docs/DebuggingCoroutines.rst
  clang/docs/ExternalClangExamples.rst
  clang/docs/JSONCompilationDatabase.rst
  clang/docs/MisExpect.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/StandardCPlusPlusModules.rst
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/docs/analyzer/checkers.rst
  clang/docs/analyzer/developer-docs/DebugChecks.rst
  clang/docs/tools/dump_ast_matchers.py
  clang/examples/PrintFunctionNames/PrintFunctionNames.cpp
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Analysis/AnalysisDeclContext.h
  clang/include/clang/Analysis/CallGraph.h
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/include/clang/Basic/TypeNodes.td
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Sema/CMakeLists.txt
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
  clang/test/ARCMT/Common.h
  clang/test/ARCMT/Inputs/module.map
  clang/test/ARCMT/atautorelease-check.m
  clang/test/ARCMT/checking.m
  clang/test/ARCMT/cxx-checking.mm
  clang/test/ARCMT/designated-init-in-header/file2.m.in
  clang/test/ARCMT/designated-init-in-header/file2.m.in.result
  clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m
  clang/test/ARCMT/objcmt-arc-cf-annotations.m.result
  clang/test/ARCMT/objcmt-atomic-property.m
  clang/test/ARCMT/objcmt-atomic-property.m.result
  clang/test/ARCMT/objcmt-boxing.m
  clang/test/ARCMT/objcmt-boxing.m.result
  clang/test/ARCMT/objcmt-migrate-all.m
  clang/test/ARCMT/objcmt-migrate-all.m.result
  clang/test/ARCMT/objcmt-ns-macros.m
  clang/test/ARCMT/objcmt-ns-macros.m.result
  clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m
  clang/test/ARCMT/objcmt-ns-nonatomic-iosonly.m.result
  clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m
  clang/test/ARCMT/objcmt-ns-returns-inner-pointer.m.result
  clang/test/ARCMT/objcmt-numeric-literals.m
  clang/test/ARCMT/objcmt-numeric-literals.m.result
  clang/test/ARCMT/objcmt-property-dot-syntax.m
  clang/test/ARCMT/objcmt-property-dot-syntax.m.result
  clang/test/ARCMT/objcmt-property.m
  clang/test/ARCMT/objcmt-property.m.result
  clang/test/ARCMT/objcmt-protocol-conformance.m
  

[PATCH] D146591: [dataflow] add HTML logger: browse code/cfg/analysis timeline/state

2023-04-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Sorry about the delay. I hope this is fixed by 
28114722baabb468732a9cc24784abafd6c47792 
. I wasn't 
able to reproduce the problem locally, so I'm not sure.

add_llvm_library says DEPENDS is the same as add_dependencies, but reading the 
code it appears to do the thing we want instead. Fingers crossed...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146591

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


[clang] 2811472 - [dataflow] Try to fix missing order dependency in HTMLLogger

2023-04-20 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2023-04-20T21:37:53+02:00
New Revision: 28114722baabb468732a9cc24784abafd6c47792

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

LOG: [dataflow] Try to fix missing order dependency in HTMLLogger

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/CMakeLists.txt 
b/clang/lib/Analysis/FlowSensitive/CMakeLists.txt
index b356116bcb542..5176c0924902e 100644
--- a/clang/lib/Analysis/FlowSensitive/CMakeLists.txt
+++ b/clang/lib/Analysis/FlowSensitive/CMakeLists.txt
@@ -11,6 +11,8 @@ add_clang_library(clangAnalysisFlowSensitive
   WatchedLiteralsSolver.cpp
   DebugSupport.cpp
 
+  DEPENDS
+  clangAnalysisFlowSensitiveResources
   LINK_LIBS
   clangAnalysis
   clangAST
@@ -29,4 +31,3 @@ add_custom_command(OUTPUT HTMLLogger.inc
   DEPENDS ${CLANG_SOURCE_DIR}/utils/bundle_resources.py HTMLLogger.html 
HTMLLogger.css HTMLLogger.js
   VERBATIM)
 add_custom_target(clangAnalysisFlowSensitiveResources DEPENDS HTMLLogger.inc)
-add_dependencies(clangAnalysisFlowSensitive 
clangAnalysisFlowSensitiveResources)



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


[PATCH] D148796: [AMDGPU][GFX908] Add builtin support for global add atomic f16/f32

2023-04-20 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In D148796#4284504 , @rampitec wrote:

> We used to support it that way and decided just not doing it. It is very hard 
> to explain why a supported atomic results in error. Someone who really needs 
> it can use intrinsic.

I tend to agree.  This oddity is probably best handled with an intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148796

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


[PATCH] D148827: -fsanitize=function: support C

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This patch is also available 
https://github.com/MaskRay/llvm-project/tree/function-c , which may make 
inspecting stacked patches easier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148827

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


[PATCH] D148827: -fsanitize=function: support C

2023-04-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: Sanitizers, efriedma, pcc, peter.smith, sberg, 
samitolvanen.
Herald added a subscriber: Enna1.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added a subscriber: cfe-commits.

With D148785 , -fsanitize=function no longer 
uses C++ RTTI objects and therefore
can support C. The rationale for reporting errors is C11 6.5.2.2p9:

> If the function is defined with a type that is not compatible with the type 
> (of the expression) pointed to by the expression that denotes the called 
> function, the behavior is undefined.

The mangled types approach we use does not exactly match the C type
compatibility (see `f(callee1)` below).
This is probably fine as the rules are unlikely leveraged in practice. In
addition, the call is warned by -Wincompatible-function-pointer-types-strict.

  void callee0(int (*a)[]) {}
  void callee1(int (*a)[1]) {}
  void f(void (*fp)(int (*)[])) { fp(0); }
  int main() {
int a[1];
f(callee0);
f(callee1); // compatible but flagged by -fsanitize=function, 
-fsanitize=kcfi, and -Wincompatible-function-pointer-types-strict
  }

Skip indirect call sites of a function type without a prototype to avoid deal
with C11 6.5.2.2p6. -fsanitize=kcfi skips such calls as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148827

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-function.c
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c


Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
@@ -0,0 +1,14 @@
+// RUN: %clang -g -fsanitize=function %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK 
--implicit-check-not='runtime error:'
+
+void f(void (*fp)(int (*)[])) { fp(0); }
+
+void callee0(int (*a)[]) {}
+void callee1(int (*a)[1]) {}
+
+int main() {
+  int a[1];
+  f(callee0);
+  // CHECK: runtime error: call to function callee1 through pointer to 
incorrect function type 'void (*)(int (*)[])'
+  f(callee1); // compatible type in C, but flagged
+}
Index: clang/test/CodeGen/ubsan-function.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s 
-o - | FileCheck %s
+
+// CHECK-LABEL: define{{.*}} @call_no_prototype(
+// CHECK-NOT: __ubsan_handle_function_type_mismatch
+void call_no_prototype(void (*f)()) { f(); }
+
+// CHECK-LABEL: define{{.*}} @call_prototype(
+// CHECK: __ubsan_handle_function_type_mismatch
+void call_prototype(void (*f)(void)) { f(); }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,10 +572,11 @@
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
-  auto ProtoTy = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
+  if (!isa(Ty))
+Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
   std::string Mangled;
   llvm::raw_string_ostream Out(Mangled);
-  CGM.getCXXABI().getMangleContext().mangleTypeName(ProtoTy, Out, false);
+  CGM.getCXXABI().getMangleContext().mangleTypeName(Ty, Out, false);
   return llvm::ConstantInt::get(CGM.Int32Ty,
 
static_cast(llvm::xxHash64(Mangled)));
 }
@@ -945,7 +946,7 @@
 
   // If we are checking function types, emit a function type signature as
   // prologue data.
-  if (FD && getLangOpts().CPlusPlus && SanOpts.has(SanitizerKind::Function)) {
+  if (FD && SanOpts.has(SanitizerKind::Function)) {
 if (llvm::Constant *PrologueSig = getPrologueSignature(CGM, FD)) {
   llvm::LLVMContext  = Fn->getContext();
   llvm::MDBuilder MDB(Ctx);
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5349,8 +5349,9 @@
 
   CGCallee Callee = OrigCallee;
 
-  if (getLangOpts().CPlusPlus && SanOpts.has(SanitizerKind::Function) &&
-  (!TargetDecl || !isa(TargetDecl))) {
+  if (SanOpts.has(SanitizerKind::Function) &&
+  (!TargetDecl || !isa(TargetDecl)) &&
+  !isa(PointeeType)) {
 if (llvm::Constant *PrefixSig =
 CGM.getTargetCodeGenInfo().getUBSanFunctionSignature(CGM)) {
   SanitizerScope SanScope(this);


Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
===
--- /dev/null
+++ 

[PATCH] D148796: [AMDGPU][GFX908] Add builtin support for global add atomic f16/f32

2023-04-20 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec requested changes to this revision.
rampitec added a comment.
This revision now requires changes to proceed.

We used to support it that way and decided just not doing it. It is very hard 
to explain why a supported atomic results in error. Someone who really needs it 
can use intrinsic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148796

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


[PATCH] D147572: [Clang][OpenMP] Fix failure with team-wide allocated variable

2023-04-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
doru1004 closed this revision.
doru1004 added a comment.

Commit: 01910787d386584ea5a3d5dc317a908423ba39ed 



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

https://reviews.llvm.org/D147572

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


[clang] 0191078 - Fix failure with team-wide allocated variable

2023-04-20 Thread Doru Bercea via cfe-commits

Author: Doru Bercea
Date: 2023-04-20T14:40:35-04:00
New Revision: 01910787d386584ea5a3d5dc317a908423ba39ed

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

LOG: Fix failure with team-wide allocated variable

Review: https://reviews.llvm.org/D147572

Added: 
clang/test/OpenMP/target_team_variable_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 2fea9c219f358..3f231703aa651 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -3353,7 +3353,7 @@ Address 
CGOpenMPRuntimeGPU::getAddressOfLocalVariable(CodeGenFunction ,
 llvm::Type *VarTy = CGF.ConvertTypeForMem(VD->getType());
 auto *GV = new llvm::GlobalVariable(
 CGM.getModule(), VarTy, /*isConstant=*/false,
-llvm::GlobalValue::InternalLinkage, 
llvm::Constant::getNullValue(VarTy),
+llvm::GlobalValue::InternalLinkage, llvm::PoisonValue::get(VarTy),
 VD->getName(),
 /*InsertBefore=*/nullptr, llvm::GlobalValue::NotThreadLocal,
 CGM.getContext().getTargetAddressSpace(AS));

diff  --git a/clang/test/OpenMP/target_team_variable_codegen.cpp 
b/clang/test/OpenMP/target_team_variable_codegen.cpp
new file mode 100644
index 0..cc82503a52d2a
--- /dev/null
+++ b/clang/test/OpenMP/target_team_variable_codegen.cpp
@@ -0,0 +1,57 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --prefix-filecheck-ir-name _ --global-value-regex 
"llvm.compiler.used" "_[0-9a-zA-Z]+A[0-9a-zA-Z]+pi[0-9a-zA-Z]+" 
"_[0-9a-zA-Z]+anotherPi" --version 2
+// REQUIRES: amdgpu-registered-target
+
+
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host-amd.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple amdgcn-amd-amdhsa 
-fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-amd.bc -o - | 
FileCheck %s --check-prefix=CHECK-AMD
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host-nvidia.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-fopenmp-targets=nvptx64-unknown-unknown -emit-llvm %s -fopenmp-target-debug 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host-nvidia.bc -o - | 
FileCheck %s --check-prefix=CHECK-NVIDIA
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+typedef enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+} omp_allocator_handle_t;
+
+//.
+// CHECK-AMD: @local_a = internal addrspace(3) global [10 x i32] poison, align 
4
+//.
+// CHECK-NVIDIA: @local_a = internal addrspace(3) global [10 x i32] poison, 
align 4
+//.
+int main()
+{
+   int N = 1;
+   int *a = new int[N];
+#pragma omp target data map(tofrom:a[:N])
+   {
+#pragma omp target teams distribute parallel for
+for(int i = 0; i < N; i++)
+{
+  int local_a[10];
+#pragma omp allocate(local_a) allocator(omp_pteam_mem_alloc)
+  for(int j = 0; j < 10; j++)
+   local_a[j] = a[(i + j) % N];
+  a[i] = local_a[0];
+}
+   }
+  return a[17];
+}
+
+#endif
+ NOTE: These prefixes are unused and the list is autogenerated. Do not add 
tests below this line:
+// CHECK-AMD: {{.*}}
+// CHECK-NVIDIA: {{.*}}



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


[PATCH] D148812: [NFC][clang] Fix static analyzer concerns

2023-04-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8206
 
-  for (auto B : CXXRD->bases())
+  for (const auto  : CXXRD->bases())
 if (hasTemplateSpecializationInEncodedString(B.getType().getTypePtr(),

Manna wrote:
> CXXBaseSpecifier is less in size, but most of cases we are using reference 
> semantics.
A bit bigger than 2 pointers actually, its ~1 byte in bitfields, 12 bytes in 
`SourceLocation`, and a pointer.

So perhaps still on the line.  However, it is only dereferenced 1x.



Comment at: clang/lib/Lex/Pragma.cpp:1110
   Module *M = nullptr;
-  for (auto IIAndLoc : ModuleName) {
+  for (const auto  : ModuleName) {
 M = MM.lookupModuleQualified(IIAndLoc.first->getName(), M);

Manna wrote:
> This returns a std::pair which is not 
> particularly expensive to copy
In that case, I'd skip the change here and leave it as a copy.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:4262
   // will be using.
-  for (auto I : Attrs) {
+  for (const auto  : Attrs) {
 const Record  = *I.second;

Manna wrote:
> Passes as a reference 
Each element is a pair of a `std::string` and `const Record*`, which should 
justify this.  Not sure what you mean by 'passes as a reference'?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:562
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
-  for (auto P : SupportedUnMaskedPolicies) {
+  for (const auto  : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =

What type is 'P' here?  What size is it?  It is being used quite a few times in 
this loop, which means it would have to be pretty sizable to justify making it 
a reference unless it has a copy ctor of cost.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148812

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


[PATCH] D148822: [clang][BFloat] Avoid redefining bfloat16_t in arm_neon.h

2023-04-20 Thread Dimitry Andric via Phabricator via cfe-commits
dim updated this revision to Diff 515409.
dim added a comment.

Also fix up arm_sve.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148822

Files:
  clang/utils/TableGen/NeonEmitter.cpp
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1103,7 +1103,6 @@
   OS << "typedef __SVBFloat16_t svbfloat16_t;\n";
 
   OS << "#include \n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   OS << "typedef __SVFloat32_t svfloat32_t;\n";
   OS << "typedef __SVFloat64_t svfloat64_t;\n";
Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2353,7 +2353,6 @@
   OS << "#include \n\n";
 
   OS << "#include \n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   // Emit NEON-specific scalar typedefs.
   OS << "typedef float float32_t;\n";


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1103,7 +1103,6 @@
   OS << "typedef __SVBFloat16_t svbfloat16_t;\n";
 
   OS << "#include \n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   OS << "typedef __SVFloat32_t svfloat32_t;\n";
   OS << "typedef __SVFloat64_t svfloat64_t;\n";
Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2353,7 +2353,6 @@
   OS << "#include \n\n";
 
   OS << "#include \n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   // Emit NEON-specific scalar typedefs.
   OS << "typedef float float32_t;\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148176: [clang][modules] Avoid re-exporting PCH imports on every later module import

2023-04-20 Thread Ben Langmuir 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 rGe06a91c5996b: [clang][modules] Avoid re-exporting PCH 
imports on every later module import (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148176

Files:
  clang/include/clang/Serialization/ASTReader.h
  clang/lib/Serialization/ASTReader.cpp
  clang/test/ClangScanDeps/modules-pch-imports.c
  clang/test/Modules/submodule-visibility-pch.c

Index: clang/test/Modules/submodule-visibility-pch.c
===
--- /dev/null
+++ clang/test/Modules/submodule-visibility-pch.c
@@ -0,0 +1,56 @@
+// Verify that the use of a PCH does not accidentally make modules from the PCH
+// visible to submodules when using -fmodules-local-submodule-visibility
+// and -fmodule-name to trigger a textual include.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// First check that it works with a header
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
+// RUN:   -fmodules-local-submodule-visibility -fimplicit-module-maps \
+// RUN:   -fmodule-name=Mod \
+// RUN:   %t/tu.c -include %t/prefix.h -I %t -verify
+
+// Now with a PCH
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
+// RUN:   -fmodules-local-submodule-visibility -fimplicit-module-maps \
+// RUN:   -x c-header %t/prefix.h -emit-pch -o %t/prefix.pch -I %t
+
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
+// RUN:   -fmodules-local-submodule-visibility -fimplicit-module-maps \
+// RUN:   -fmodule-name=Mod \
+// RUN:   %t/tu.c -include-pch %t/prefix.pch -I %t -verify
+
+//--- module.modulemap
+module ModViaPCH { header "ModViaPCH.h" }
+module ModViaInclude { header "ModViaInclude.h" }
+module Mod { header "Mod.h" }
+module SomeOtherMod { header "SomeOtherMod.h" }
+
+//--- ModViaPCH.h
+#define ModViaPCH 1
+
+//--- ModViaInclude.h
+#define ModViaInclude 2
+
+//--- SomeOtherMod.h
+// empty
+
+//--- Mod.h
+#include "SomeOtherMod.h"
+#ifdef ModViaPCH
+#error "Visibility violation ModViaPCH"
+#endif
+#ifdef ModViaInclude
+#error "Visibility violation ModViaInclude"
+#endif
+
+//--- prefix.h
+#include "ModViaPCH.h"
+
+//--- tu.c
+#include "ModViaInclude.h"
+#include "Mod.h"
+// expected-no-diagnostics
Index: clang/test/ClangScanDeps/modules-pch-imports.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-pch-imports.c
@@ -0,0 +1,108 @@
+// Check that a module from -fmodule-name= does not accidentally pick up extra
+// dependencies that come from a PCH.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+// RUN: sed "s|DIR|%/t|g" %t/cdb_pch.json.template > %t/cdb_pch.json
+
+// Scan PCH
+// RUN: clang-scan-deps -compilation-database %t/cdb_pch.json \
+// RUN:   -format experimental-full -mode preprocess-dependency-directives \
+// RUN:   > %t/deps_pch.json
+
+// Build PCH
+// RUN: %deps-to-rsp %t/deps_pch.json --module-name A > %t/A.rsp
+// RUN: %deps-to-rsp %t/deps_pch.json --module-name B > %t/B.rsp
+// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
+// RUN: %clang @%t/A.rsp
+// RUN: %clang @%t/B.rsp
+// RUN: %clang @%t/pch.rsp
+
+// Scan TU with PCH
+// RUN: clang-scan-deps -compilation-database %t/cdb.json \
+// RUN:   -format experimental-full -mode preprocess-dependency-directives \
+// RUN:   > %t/deps.json
+
+// RUN: cat %t/deps.json | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// Verify that the only modular import in C is E and not the unrelated modules
+// A or B that come from the PCH.
+
+// CHECK:  {
+// CHECK-NEXT:  "modules": [
+// CHECK-NEXT: {
+// CHECK:"clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK:"module-name": "E"
+// CHECK:  }
+// CHECK-NEXT:   ]
+// CHECK:"clang-modulemap-file": "[[PREFIX]]/module.modulemap"
+// CHECK:"command-line": [
+// CHECK-NOT:  "-fmodule-file=
+// CHECK:  "-fmodule-file={{(E=)?}}[[PREFIX]]/{{.*}}/E-{{.*}}.pcm"
+// CHECK-NOT:  "-fmodule-file=
+// CHECK:]
+// CHECK:"name": "C"
+// CHECK:  }
+
+
+//--- cdb_pch.json.template
+[{
+  "file": "DIR/prefix.h",
+  "directory": "DIR",
+  "command": "clang -x c-header DIR/prefix.h -o DIR/prefix.h.pch -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
+}]
+
+//--- cdb.json.template
+[{
+  "file": "DIR/tu.c",
+  "directory": "DIR",
+  "command": "clang -fsyntax-only DIR/tu.c -include DIR/prefix.h -fmodule-name=C -fmodules -fimplicit-modules -fimplicit-module-maps -fmodules-cache-path=DIR/module-cache"
+}]
+
+//--- module.modulemap
+module A { header "A.h" export * }
+module B { header "B.h" export * }
+module C { header 

[clang] e06a91c - [clang][modules] Avoid re-exporting PCH imports on every later module import

2023-04-20 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-04-20T11:29:23-07:00
New Revision: e06a91c5996b039cacd55e6ead0baf14424c740c

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

LOG: [clang][modules] Avoid re-exporting PCH imports on every later module 
import

We only want to make PCH imports visible once for the the TU, not
repeatedly after every subsequent import. This causes some incorrect
behaviour with submodule visibility, and causes us to get extra module
dependencies in the scanner. So far I have only seen obviously incorrect
behaviour when building with -fmodule-name to cause a submodule to be
textually included when using the PCH, though the old behaviour seems
wrong regardless.

rdar://107449644

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

Added: 
clang/test/ClangScanDeps/modules-pch-imports.c
clang/test/Modules/submodule-visibility-pch.c

Modified: 
clang/include/clang/Serialization/ASTReader.h
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index 4f9457d8653e3..1360ee1877c1a 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -948,8 +948,14 @@ class ASTReader
 
 private:
   /// A list of modules that were imported by precompiled headers or
-  /// any other non-module AST file.
-  SmallVector ImportedModules;
+  /// any other non-module AST file and have not yet been made visible. If a
+  /// module is made visible in the ASTReader, it will be transfered to
+  /// \c PendingImportedModulesSema.
+  SmallVector PendingImportedModules;
+
+  /// A list of modules that were imported by precompiled headers or
+  /// any other non-module AST file and have not yet been made visible for 
Sema.
+  SmallVector PendingImportedModulesSema;
   //@}
 
   /// The system include root to be used when loading the

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 9dbe56123e40e..b27304deb33c9 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3728,7 +3728,7 @@ llvm::Error ASTReader::ReadASTBlock(ModuleFile ,
   unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
   SourceLocation Loc = ReadSourceLocation(F, Record, I);
   if (GlobalID) {
-ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
+PendingImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
 if (DeserializationListener)
   DeserializationListener->ModuleImportRead(GlobalID, Loc);
   }
@@ -4445,8 +4445,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef 
FileName,
   UnresolvedModuleRefs.clear();
 
   if (Imported)
-Imported->append(ImportedModules.begin(),
- ImportedModules.end());
+Imported->append(PendingImportedModules.begin(),
+ PendingImportedModules.end());
 
   // FIXME: How do we load the 'use'd modules? They may not be submodules.
   // Might be unnecessary as use declarations are only used to build the
@@ -5050,7 +5050,7 @@ void ASTReader::InitializeContext() {
 
   // Re-export any modules that were imported by a non-module AST file.
   // FIXME: This does not make macro-only imports visible again.
-  for (auto  : ImportedModules) {
+  for (auto  : PendingImportedModules) {
 if (Module *Imported = getSubmodule(Import.ID)) {
   makeModuleVisible(Imported, Module::AllVisible,
 /*ImportLoc=*/Import.ImportLoc);
@@ -5060,6 +5060,10 @@ void ASTReader::InitializeContext() {
   // nullptr here, we do the same later, in UpdateSema().
 }
   }
+
+  // Hand off these modules to Sema.
+  PendingImportedModulesSema.append(PendingImportedModules);
+  PendingImportedModules.clear();
 }
 
 void ASTReader::finalizeForWriting() {
@@ -8105,13 +8109,14 @@ void ASTReader::UpdateSema() {
   }
 
   // For non-modular AST files, restore visiblity of modules.
-  for (auto  : ImportedModules) {
+  for (auto  : PendingImportedModulesSema) {
 if (Import.ImportLoc.isInvalid())
   continue;
 if (Module *Imported = getSubmodule(Import.ID)) {
   SemaObj->makeModuleVisible(Imported, Import.ImportLoc);
 }
   }
+  PendingImportedModulesSema.clear();
 }
 
 IdentifierInfo *ASTReader::get(StringRef Name) {

diff  --git a/clang/test/ClangScanDeps/modules-pch-imports.c 
b/clang/test/ClangScanDeps/modules-pch-imports.c
new file mode 100644
index 0..63c6055efe061
--- /dev/null
+++ b/clang/test/ClangScanDeps/modules-pch-imports.c
@@ -0,0 +1,108 @@
+// Check that a module from -fmodule-name= does not accidentally pick up extra
+// dependencies that come from a 

[PATCH] D147626: [clang] Reject flexible array member in a union in C++

2023-04-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

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


[PATCH] D146090: [Clang] Updating handling of defaulted comparison operators to reflect changes from P2448R2

2023-04-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

ping


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

https://reviews.llvm.org/D146090

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


[PATCH] D147815: [clang][deps] Print timing information

2023-04-20 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe766e3afedeb: [clang][deps] Print timing information 
(authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D147815?vs=511802=515401#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147815

Files:
  clang/test/ClangScanDeps/print-timing.c
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  clang/tools/clang-scan-deps/Opts.td


Index: clang/tools/clang-scan-deps/Opts.td
===
--- clang/tools/clang-scan-deps/Opts.td
+++ clang/tools/clang-scan-deps/Opts.td
@@ -31,8 +31,10 @@
 
 defm resource_dir_recipe : Eq<"resource-dir-recipe", "How to produce missing 
'-resource-dir' argument">;
 
+def print_timing : F<"print-timing", "Print timing information">;
+
 def verbose : F<"v", "Use verbose output">;
 
 def round_trip_args : F<"round-trip-args", "verify that command-line arguments 
are canonical by parsing and re-serializing">;
 
 def DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>;
\ No newline at end of file
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/LLVMDriver.h"
@@ -26,6 +27,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/TargetParser/Host.h"
 #include 
 #include 
@@ -90,6 +92,7 @@
 static bool DeprecatedDriverCommand;
 static ResourceDirRecipeKind ResourceDirRecipe;
 static bool Verbose;
+static bool PrintTiming;
 static std::vector CommandLine;
 
 #ifndef NDEBUG
@@ -200,6 +203,8 @@
 ResourceDirRecipe = *Kind;
   }
 
+  PrintTiming = Args.hasArg(OPT_print_timing);
+
   Verbose = Args.hasArg(OPT_verbose);
 
   RoundTripArgs = Args.hasArg(OPT_round_trip_args);
@@ -857,6 +862,10 @@
 llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
  << " files using " << Pool.getThreadCount() << " workers\n";
   }
+
+  llvm::Timer T;
+  T.startTimer();
+
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I) {
 Pool.async([&, I]() {
   llvm::StringSet<> AlreadySeenModules;
@@ -946,6 +955,12 @@
   }
   Pool.wait();
 
+  T.stopTimer();
+  if (PrintTiming)
+llvm::errs() << llvm::format(
+"clang-scan-deps timing: %0.2fs wall, %0.2fs process\n",
+T.getTotalTime().getWallTime(), T.getTotalTime().getProcessTime());
+
   if (RoundTripArgs)
 if (FD && FD->roundTripCommands(llvm::errs()))
   HadErrors = true;
Index: clang/test/ClangScanDeps/print-timing.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/print-timing.c
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -print-timing > 
%t/result.json 2>%t/errs
+// RUN: cat %t/errs | FileCheck %s
+// CHECK: clang-scan-deps timing: {{[0-9]+}}.{{[0-9][0-9]}}s wall, 
{{[0-9]+}}.{{[0-9][0-9]}}s process
+
+//--- cdb.json
+[]


Index: clang/tools/clang-scan-deps/Opts.td
===
--- clang/tools/clang-scan-deps/Opts.td
+++ clang/tools/clang-scan-deps/Opts.td
@@ -31,8 +31,10 @@
 
 defm resource_dir_recipe : Eq<"resource-dir-recipe", "How to produce missing '-resource-dir' argument">;
 
+def print_timing : F<"print-timing", "Print timing information">;
+
 def verbose : F<"v", "Use verbose output">;
 
 def round_trip_args : F<"round-trip-args", "verify that command-line arguments are canonical by parsing and re-serializing">;
 
 def DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>;
\ No newline at end of file
Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/LLVMDriver.h"
@@ -26,6 +27,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/TargetParser/Host.h"
 #include 
 #include 
@@ -90,6 +92,7 @@
 static bool DeprecatedDriverCommand;
 static ResourceDirRecipeKind ResourceDirRecipe;
 static bool 

[clang] e766e3a - [clang][deps] Print timing information

2023-04-20 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-04-20T11:18:32-07:00
New Revision: e766e3afedeba90dfbd0513a675a9bf32c5cc8e9

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

LOG: [clang][deps] Print timing information

This patch adds new `-print-timing` option to `clang-scan-deps`. It measures 
the wall and process time taken to scan dependencies for the compilation 
database. This provides more representative data compared to measuring the 
timing for the whole tool invocation, since that includes parsing and 
generating JSON files, which can be significant for larger inputs.

Reviewed By: akyrtzi

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

Added: 
clang/test/ClangScanDeps/print-timing.c

Modified: 
clang/tools/clang-scan-deps/ClangScanDeps.cpp
clang/tools/clang-scan-deps/Opts.td

Removed: 




diff  --git a/clang/test/ClangScanDeps/print-timing.c 
b/clang/test/ClangScanDeps/print-timing.c
new file mode 100644
index 0..f27df1ebf732a
--- /dev/null
+++ b/clang/test/ClangScanDeps/print-timing.c
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: split-file %s %t
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -print-timing > 
%t/result.json 2>%t/errs
+// RUN: cat %t/errs | FileCheck %s
+// CHECK: clang-scan-deps timing: {{[0-9]+}}.{{[0-9][0-9]}}s wall, 
{{[0-9]+}}.{{[0-9][0-9]}}s process
+
+//--- cdb.json
+[]

diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 60be5d256b053..93c60eb2cdf59 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/JSON.h"
 #include "llvm/Support/LLVMDriver.h"
@@ -26,6 +27,7 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadPool.h"
 #include "llvm/Support/Threading.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/TargetParser/Host.h"
 #include 
 #include 
@@ -90,6 +92,7 @@ static std::vector ModuleDepTargets;
 static bool DeprecatedDriverCommand;
 static ResourceDirRecipeKind ResourceDirRecipe;
 static bool Verbose;
+static bool PrintTiming;
 static std::vector CommandLine;
 
 #ifndef NDEBUG
@@ -200,6 +203,8 @@ static void ParseArgs(int argc, char **argv) {
 ResourceDirRecipe = *Kind;
   }
 
+  PrintTiming = Args.hasArg(OPT_print_timing);
+
   Verbose = Args.hasArg(OPT_verbose);
 
   RoundTripArgs = Args.hasArg(OPT_round_trip_args);
@@ -857,6 +862,10 @@ int clang_scan_deps_main(int argc, char **argv, const 
llvm::ToolContext &) {
 llvm::outs() << "Running clang-scan-deps on " << Inputs.size()
  << " files using " << Pool.getThreadCount() << " workers\n";
   }
+
+  llvm::Timer T;
+  T.startTimer();
+
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I) {
 Pool.async([&, I]() {
   llvm::StringSet<> AlreadySeenModules;
@@ -946,6 +955,12 @@ int clang_scan_deps_main(int argc, char **argv, const 
llvm::ToolContext &) {
   }
   Pool.wait();
 
+  T.stopTimer();
+  if (PrintTiming)
+llvm::errs() << llvm::format(
+"clang-scan-deps timing: %0.2fs wall, %0.2fs process\n",
+T.getTotalTime().getWallTime(), T.getTotalTime().getProcessTime());
+
   if (RoundTripArgs)
 if (FD && FD->roundTripCommands(llvm::errs()))
   HadErrors = true;

diff  --git a/clang/tools/clang-scan-deps/Opts.td 
b/clang/tools/clang-scan-deps/Opts.td
index 0d121ed7f4f54..27917b4f4808a 100644
--- a/clang/tools/clang-scan-deps/Opts.td
+++ b/clang/tools/clang-scan-deps/Opts.td
@@ -31,6 +31,8 @@ def deprecated_driver_command : 
F<"deprecated-driver-command", "use a single dri
 
 defm resource_dir_recipe : Eq<"resource-dir-recipe", "How to produce missing 
'-resource-dir' argument">;
 
+def print_timing : F<"print-timing", "Print timing information">;
+
 def verbose : F<"v", "Use verbose output">;
 
 def round_trip_args : F<"round-trip-args", "verify that command-line arguments 
are canonical by parsing and re-serializing">;



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


[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/test/Driver/riscv-default-build-attributes.s:1
+// Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \

jrtc27 wrote:
> Do we use /// for non-lit/FileCheck lines like we use ;; in IR tests?
I don't know. I copied it from ARM's test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

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


[PATCH] D146595: [clang] Add "debug_trampoline" attribute

2023-04-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D146595#4284268 , @aaron.ballman 
wrote:

> In D146595#4284220 , @dblaikie 
> wrote:
>
>> In D146595#4281710 , @aprantl 
>> wrote:
>>
>>> Now if we are going to say this explicitly DWARF only feature, that could 
>>> be an argument to stick with the `trampoline` name. But I'd rather say this 
>>> is a general feature that — at this point in time — is only implement on 
>>> DWARF targets.
>>
>> Yeah, I'd be inclined to think of this as not a DWARF-specific feature, but 
>> one only implemented in DWARF at the moment. If CV adds some way to inject 
>> names into the database of uninteresting symbols, they could use this too.
>
> To clarify, my concerns with non-DWARF aren't of the "this needs to work with 
> every debug format before we should accept it" variety. It's more of the "if 
> other debug formats support this concept or conceivably would support this 
> concept in the near future, would we need to materially change the attribute 
> from what's proposed here?" kind. Basically, I want to try to avoid a 
> situation where we have to introduce a second attribute for this same 
> feature, or this attribute needs to be a decl attribute for DWARF and a type 
> attribute for others, needs arguments for some reason, that sort of thing. I 
> want to avoid having a set of attributes for DWARF and a different set of 
> attribute code CodeView, basically.

Fair - we DWARF folks don't probably have enough context to answer that 
authoritatively. I'm not sure if the CV folks do either (in the sense of 
knowing all the corners of a less public format is harder - so the usual 
challenges of proving non-existence come up more), but @akhuang - do you happen 
to know anything about CV's ability to encode places not to stop when stepping 
through code?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146595

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


[PATCH] D148822: [clang][BFloat] Avoid redefining bfloat16_t in arm_neon.h

2023-04-20 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.
dim added reviewers: t.p.northover, fpetrogalli, sdesmalen, az, LukeGeeson, 
stuij.
Herald added a project: All.
dim requested review of this revision.
Herald added a project: clang.

As of https://reviews.llvm.org/D79708, clang-tblgen generates both
`arm_neon.h` and `arm_bf16.h`, and both generated files will contain a
typedef of `bfloat16_t`. However, `arm_neon.h` includes `arm_bf16.h`
immediately before its own typedef:

  #include 
  typedef __bf16 bfloat16_t;

With a recent version of clang (I used 16.0.1) this results in warnings:

  /usr/lib/clang/16/include/arm_neon.h:38:16: error: redefinition of typedef 
'bfloat16_t' is a C11 feature [-Werror,-Wtypedef-redefinition]

Since `arm_bf16.h` is very likely supposed to be the one true place
where `bfloat16_t` is defined, I propose to delete the duplicate typedef
from the generated `arm_neon.h`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148822

Files:
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2353,7 +2353,6 @@
   OS << "#include \n\n";
 
   OS << "#include \n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   // Emit NEON-specific scalar typedefs.
   OS << "typedef float float32_t;\n";


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -2353,7 +2353,6 @@
   OS << "#include \n\n";
 
   OS << "#include \n";
-  OS << "typedef __bf16 bfloat16_t;\n";
 
   // Emit NEON-specific scalar typedefs.
   OS << "typedef float float32_t;\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148094: [DRAFT][clang][CodeGen] Break up TargetInfo.cpp [6/6]

2023-04-20 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

ping
Does the approach look right?
Would it be better to put everything into cpp files and only expose a factory 
method e.g. createMyTargetCodeGenInfo?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D148812: [NFC][clang] Fix static analyzer concerns

2023-04-20 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8206
 
-  for (auto B : CXXRD->bases())
+  for (const auto  : CXXRD->bases())
 if (hasTemplateSpecializationInEncodedString(B.getType().getTypePtr(),

CXXBaseSpecifier is less in size, but most of cases we are using reference 
semantics.



Comment at: clang/lib/AST/ComputeDependence.cpp:763
 D |= toExprDependence(Q->getDependence());
-  for (auto A : E->template_arguments())
+  for (const auto  : E->template_arguments())
 D |= toExprDependence(A.getArgument().getDependence());

TemplateArgumentLoc has a TemplateArgument (pass by value usually), but it also 
has a TemplateArgumentLocInfo, which is a pair of pointers + source locations.



Comment at: clang/lib/ASTMatchers/Dynamic/Marshallers.h:1011
 std::vector NodeKinds;
-for (auto Arg : Args) {
+for (const auto  : Args) {
   if (!Arg.Value.isNodeKind())

This returns ParserValue which passes as a reference. 



Comment at: clang/lib/CodeGen/CGVTables.cpp:1278
 
-  for (auto B : RD->vbases())
+  for (const auto  : RD->vbases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())

CXXBaseSpecifier is less in size, but most of cases we are using reference 
semantics.



Comment at: clang/lib/Lex/Pragma.cpp:1110
   Module *M = nullptr;
-  for (auto IIAndLoc : ModuleName) {
+  for (const auto  : ModuleName) {
 M = MM.lookupModuleQualified(IIAndLoc.first->getName(), M);

This returns a std::pair which is not 
particularly expensive to copy



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:3974
 llvm::SmallPtrSet UninitializedBaseClasses;
-for (auto I : RD->bases())
+for (const auto  : RD->bases())
   UninitializedBaseClasses.insert(I.getType().getCanonicalType());

CXXBaseSpecifier is less in size, but most of cases we are using reference 
semantics.



Comment at: clang/utils/TableGen/ClangAttrEmitter.cpp:4262
   // will be using.
-  for (auto I : Attrs) {
+  for (const auto  : Attrs) {
 const Record  = *I.second;

Passes as a reference 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148812

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


[PATCH] D148723: [clang] Enforce internal linkage for inline builtin

2023-04-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D148723#4283094 , 
@serge-sans-paille wrote:

> In D148723#4280916 , @efriedma 
> wrote:
>
>> The point of an "inline builtin" is that the inline function is actually the 
>> original function; it's just the inline implementation is only used in 
>> limited circumstances (in particular, it can't be used recursively).  
>> Changing the linkage could have unexpected side-effects.
>
> That's not my understanding. An inline builtin provides an alternate 
> implementation of the builtin that usually wraps the original builtin in some 
> way. It's not meant to be externally visible (it would probably collide with 
> libc's implementation in that case).

The "linkage" here is the linkage of the declaration.  Any code that refers to 
the declaration has to treat it like something externally visible.  Off the top 
of my head, not sure how much it matters for C, but the linkage at the AST 
level has cascading effects in C++.

For normal C99 inline functions, there's a definition somewhere else, but 
there's an inline body which is supposed to be equivalent.  Sort of a 
substitute for "linkonce", which doesn't normally exist in C.  The issue with 
builtins specifically is that glibc headers do weird things, and the inline 
version ends up recursively calling itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148723

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-04-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D142907

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


[PATCH] D137259: [clang][modules][deps] WIP: In-memory module transfer

2023-04-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 abandoned this revision.
jansvoboda11 added a comment.

Using `CompilerInstance` as the module storage dramatically increases memory 
usage (peak ~30GB) of `clang-scan-deps` when scanning LLVM. (Memory mapping 
serialized files peaks at ~300MB.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137259

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


[PATCH] D138224: WIP: AST{Reader,Writer} alternative

2023-04-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 abandoned this revision.
jansvoboda11 added a comment.

Using `CompilerInstance` as the module storage dramatically increases memory 
usage (peak ~30GB) of `clang-scan-deps` when scanning LLVM. (Memory mapping 
serialized files peaks at ~300MB.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138224

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


[PATCH] D146595: [clang] Add "debug_trampoline" attribute

2023-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146595#4284220 , @dblaikie wrote:

> In D146595#4281710 , @aprantl wrote:
>
>> Now if we are going to say this explicitly DWARF only feature, that could be 
>> an argument to stick with the `trampoline` name. But I'd rather say this is 
>> a general feature that — at this point in time — is only implement on DWARF 
>> targets.
>
> Yeah, I'd be inclined to think of this as not a DWARF-specific feature, but 
> one only implemented in DWARF at the moment. If CV adds some way to inject 
> names into the database of uninteresting symbols, they could use this too.

To clarify, my concerns with non-DWARF aren't of the "this needs to work with 
every debug format before we should accept it" variety. It's more of the "if 
other debug formats support this concept or conceivably would support this 
concept in the near future, would we need to materially change the attribute 
from what's proposed here?" kind. Basically, I want to try to avoid a situation 
where we have to introduce a second attribute for this same feature, or this 
attribute needs to be a decl attribute for DWARF and a type attribute for 
others, needs arguments for some reason, that sort of thing. I want to avoid 
having a set of attributes for DWARF and a different set of attribute code 
CodeView, basically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146595

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


[PATCH] D147844: Emit warning when implicit cast to bool happens in an conditional operator expression when used inside an overloaded shift operator expression

2023-04-20 Thread NagaChaitanya Vellanki via Phabricator via cfe-commits
chaitanyav updated this revision to Diff 515394.
chaitanyav added a comment.

Update test to use parentheses around conditional operator


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147844

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/uninit-vals.c
  clang/test/Sema/integer-overflow.c
  clang/test/Sema/parentheses.c
  clang/test/Sema/parentheses.cpp
  clang/test/SemaCXX/array-bounds.cpp
  clang/test/SemaCXX/integer-overflow.cpp

Index: clang/test/SemaCXX/integer-overflow.cpp
===
--- clang/test/SemaCXX/integer-overflow.cpp
+++ clang/test/SemaCXX/integer-overflow.cpp
@@ -41,7 +41,7 @@
   uint64_t not_overflow2 = (1ULL * ((uint64_t)(4608) * (1024 * 1024)) + 2ULL);
 
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
-  overflow = 4608 * 1024 * 1024 ?  4608 * 1024 * 1024 : 0;
+  overflow = (4608 * 1024 * 1024) ?  4608 * 1024 * 1024 : 0;
 
 // expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}}
   overflow =  0 ? 0 : 4608 * 1024 * 1024;
Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -87,7 +87,7 @@
 }
 
 #define SIZE 10
-#define ARR_IN_MACRO(flag, arr, idx) flag ? arr[idx] : 1
+#define ARR_IN_MACRO(flag, arr, idx) (flag ? arr[idx] : 1)
 
 int test_no_warn_macro_unreachable() {
   int arr[SIZE]; // expected-note {{array 'arr' declared here}}
Index: clang/test/Sema/parentheses.cpp
===
--- clang/test/Sema/parentheses.cpp
+++ clang/test/Sema/parentheses.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -verify %s
-// RUN: %clang_cc1 -Wparentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wparentheses -Woverloaded-shift-op-parentheses -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 bool someConditionFunc();
 
@@ -38,7 +38,7 @@
   Stream >>(const char*);
 };
 
-void f(Stream& s, bool b) {
+void f(Stream& s, bool b, int x) {
   (void)(s << b ? "foo" : "bar"); // expected-warning {{operator '?:' has lower precedence than '<<'}} \
   // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
   // expected-note {{place parentheses around the '?:' expression to evaluate it first}}
@@ -62,6 +62,30 @@
   // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:16-[[@LINE-4]]:16}:")"
   // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:15-[[@LINE-5]]:15}:"("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:21-[[@LINE-6]]:21}:")"
+
+  void(s << "Test" << x ? "foo" : "bar"); //expected-warning {{operator '?:' has lower precedence than '<<'}} \
+ // expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+// expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:8-[[@LINE-3]]:8}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:24-[[@LINE-4]]:24}:")"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:23-[[@LINE-5]]:23}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:40-[[@LINE-6]]:40}:")"
+
+  void(s << x == 1 ? "foo": "bar"); //expected-warning {{overloaded operator << has higher precedence than comparison operator}} \
+   //expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+  // expected-note {{place parentheses around comparison expression to evaluate it first}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:8-[[@LINE-3]]:8}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:14-[[@LINE-4]]:14}:")"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
+
+  void(s << static_cast(x) ? "foo" : "bar"); //expected-warning {{operator '?:' has lower precedence than '<<'}} \
+  //expected-note {{place parentheses around the '<<' expression to silence this warning}} \
+ //expected-note {{place parentheses around the '?:' expression to evaluate it first}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:8-[[@LINE-3]]:8}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-4]]:33-[[@LINE-4]]:33}:")"
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:13-[[@LINE-5]]:13}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:49-[[@LINE-6]]:49}:")"
 }
 
 struct S {
Index: clang/test/Sema/parentheses.c

[PATCH] D147989: [clang] Fix Attribute Placement

2023-04-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Thank you for working on this! I spotted a little more that needs to be done, 
but this is pretty close to ready. I *think* the precommit CI failures are 
unrelated to this change, but you should double-check just to be sure.




Comment at: clang/lib/Sema/SemaDecl.cpp:5031
+static unsigned GetDiagnosticTypeSpecifierID(const DeclSpec ) {
+  DeclSpec::TST T=DS.getTypeSpecType();
   switch (T) {

Style nit; NFC



Comment at: clang/lib/Sema/SemaDecl.cpp:5042-5046
+if (const EnumDecl *ED = dyn_cast(DS.getRepAsDecl())) {
+  if (ED->isScopedUsingClassTag())
+return 5;
+}
 return 4;

There's a subtle bug hiding in here, consider code like:
```
 __attribute__((visibility("hidden")))  __attribute__((aligned)) enum struct E 
{};
```
The diagnostic will emit `enum` because the `EnumDecl` is scoped using the 
`struct` tag rather than the `class` tag. I think you should add another entry 
to the `%select` for `enum struct` and return that value here if 
`ED->isScoped()` is true, and only return `4` for a plain `enum`.



Comment at: clang/test/Sema/attr-declspec-ignored.c:23
+__attribute__((visibility("hidden")))  __attribute__((aligned)) enum F {F} f;
\ No newline at end of file


I'm not seeing what changed with this line, I think  you can revert the changes 
to this file.



Comment at: clang/test/SemaCXX/attr-declspec-ignored.cpp:12
   // expected-warning{{attribute 'aligned' is ignored, place it after "enum" 
to apply attribute to type declaration}}
+  __attribute__((visibility("hidden")))  __attribute__((aligned)) enum class 
EC {}; // expected-warning{{attribute 'visibility' is ignored, place it after 
"enum class" to apply attribute to type declaration}} \
+  // expected-warning{{attribute 'aligned' is ignored, place it after "enum 
class" to apply attribute to type declaration}}

Once you fix the `enum struct` diagnostic above, I'd recommend adding some 
`enum struct` test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147989

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


[PATCH] D146595: [clang] Add "debug_trampoline" attribute

2023-04-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D146595#4281710 , @aprantl wrote:

> In D146595#4278361 , @dblaikie 
> wrote:
>
>> In D146595#4235340 , @augusto2112 
>> wrote:
>>
>>> In D146595#4235333 , @aprantl 
>>> wrote:
>>>
 I hope I'm not kicking off a long bike-shedding thread, but I would 
 propose to either call the attribute `transparent` to match the DWARF 
 attribute name, or if we want to be more descriptive, `debug_transparent`, 
 or `transparentdebug` to fit better with other attributes such as 
 `nodebug`. My vote is on `transparent`.
>>>
>>> The dwarf attribute is actually called `trampoline`, not `transparent`. 
>>> `trampoline` is a pretty generic name which could be used for other things 
>>> other than debugging, so maybe `trampolinedebug`?
>>
>> FWIW, trampoline seems weird to me (both for the DWARF attribute, and the 
>> source level attribute) - my understanding is that trampolines are small 
>> functions that just immediately jump to some other function. In this case 
>> the intermediate function can be arbitrarily complicated, but just not 
>> /interesting/ to the average developer. Doesn't seem like a trampoline to 
>> me. (though maybe I'm thinking of a "thunk" specifically - at least 
>> wikipedia's deefinition of a programming trampoline is fairly broad/involves 
>> some fairly higher level "do some non-trivial things" operations, I guess)
>>
>> I guess an example of something that might be transparent but not 
>> trampoline-like would be std::sort - the ability to step into the comparison 
>> function, but skip over the actual sorting logic (or for_each, etc - you 
>> might want to step into your functor, but skip the intermediate logic that's 
>> handling the looping, etc). Those don't feel like trampolines, I guess?
>
> I think I agree. If we go with some kind of `transparent` we have the options 
> of
>
> 1. `transparent` (which is quite broad)
> 2. `transparentdebug` (which follows the schema started by `nodebug`) I think 
> this is ugly
> 3. `transparent_debug` (which is oddly inconsistent with `nodebug` but more 
> readable)
> 4. `debug_transparent` (which starts a new nomenclature)
>
> My preferential vote is 4 (best), 2, 3, 1.

We do already have 
https://clang.llvm.org/docs/AttributeReference.html#standalone-debug - so maybe 
(3) is the way to go? but worst comes to worst we could rename standalone_debug 
to debug_standalone and deprecate the old spelling if it's worth it.

 & there was some tangent about DWARF v COFF too, which I wouldn't mind 
 weighing in on, but feel like it's all a bit fragmented, so not sure where 
 all the discussions are/how to keep track of them.
>>>
>>> That was also in this review; @aaron.ballman pointed out that it would be 
>>> best if new Clang attributes weren't targeting only DWARF, though I believe 
>>> this request may run into some hard limitations of what CodeView/PDB can 
>>> support.
>>
>> Yeah, that seems like a bit of a big ask, since there's a specific DWARF 
>> feature we're lowering to here - feels out of scope to go trying to figure 
>> out how it might be implemented in CodeView. For features that are 
>> format-agnostic (like simple template names, no-standalone-debug (various 
>> type homing strategies), etc) yeah, makes total sense for them to be 
>> format-agnostic. This isn't one of those, though.
>>
>> but, I guess, worth at least asking the question if there's an equivalent 
>> feature in CV already that this should be mapped to
>
> I already tried to research this — see my comment above "just my code" above. 
> My layman understanding is that they use an external database of 
> uninteresting symbols.
>
> Now if we are going to say this explicitly DWARF only feature, that could be 
> an argument to stick with the `trampoline` name. But I'd rather say this is a 
> general feature that — at this point in time — is only implement on DWARF 
> targets.

Yeah, I'd be inclined to think of this as not a DWARF-specific feature, but one 
only implemented in DWARF at the moment. If CV adds some way to inject names 
into the database of uninteresting symbols, they could use this too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146595

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


[PATCH] D148176: [clang][modules] Avoid re-exporting PCH imports on every later module import

2023-04-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

That makes sense to me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148176

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


[clang] c1ee219 - arm_bf16.td: fix copy/paste typo in comment header

2023-04-20 Thread Dimitry Andric via cfe-commits

Author: Dimitry Andric
Date: 2023-04-20T19:43:51+02:00
New Revision: c1ee2192dd0f28cdf02a0544d25d0710c037bf9b

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

LOG: arm_bf16.td: fix copy/paste typo in comment header

Added: 


Modified: 
clang/include/clang/Basic/arm_bf16.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_bf16.td 
b/clang/include/clang/Basic/arm_bf16.td
index d837a7666d403..f70c7221f8d6d 100644
--- a/clang/include/clang/Basic/arm_bf16.td
+++ b/clang/include/clang/Basic/arm_bf16.td
@@ -1,4 +1,4 @@
-//===--- arm_fp16.td - ARM BF16 compiler interface 
===//
+//===--- arm_bf16.td - ARM BF16 compiler interface 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.



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


[PATCH] D148483: [RISCV] Zvk (vector crypto) specification update to 0.5.1 (Zvbb/Zvbc/Zvkt/Zvkng/Zvksg)

2023-04-20 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D148483#4283898 , @ego wrote:

> Thanks for the clarification. I went with the additional alignment. I used to 
> overdo vertical alignment but it was beaten out of me by the Google C++ style 
> guide and automatic formatters.

Yes, once there's a decent .td auto-formatting solution I'll probably miss some 
of the niceties of manually aligned instruction definitions, but it will also 
be nice to spend less review time going back and forth on whitespace :)

Thanks for the rapid iteration on this - I've now landed the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148483

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


[PATCH] D148483: [RISCV] Zvk (vector crypto) specification update to 0.5.1 (Zvbb/Zvbc/Zvkt/Zvkng/Zvksg)

2023-04-20 Thread Alex Bradbury 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 rGcb7dffdc9a83: [RISCV] Zvk (vector crypto) specification 
update to 0.5.1… (authored by ego, committed by asb).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D148483?vs=515356=515384#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148483

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvbb.s
  llvm/test/MC/RISCV/rvv/zvbc.s
  llvm/test/MC/RISCV/rvv/zvkb.s
  llvm/test/MC/RISCV/rvv/zvkg.s

Index: llvm/test/MC/RISCV/rvv/zvkg.s
===
--- llvm/test/MC/RISCV/rvv/zvkg.s
+++ llvm/test/MC/RISCV/rvv/zvkg.s
@@ -13,3 +13,9 @@
 # CHECK-ENCODING: [0x77,0x25,0x94,0xb2]
 # CHECK-ERROR: instruction requires the following: 'Zvkg' (Vector GCM instructions for Cryptography.){{$}}
 # CHECK-UNKNOWN: 77 25 94 b2   
+
+vgmul.vv v10, v9
+# CHECK-INST: vgmul.vv v10, v9
+# CHECK-ENCODING: [0x77,0xa5,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvkg' (Vector GCM instructions for Cryptography.){{$}}
+# CHECK-UNKNOWN: 77 a5 98 a2   
Index: llvm/test/MC/RISCV/rvv/zvkb.s
===
--- llvm/test/MC/RISCV/rvv/zvkb.s
+++ /dev/null
@@ -1,87 +0,0 @@
-# RUN: llvm-mc -triple=riscv32 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkb %s \
-# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
-# RUN: not llvm-mc -triple=riscv32 -show-encoding %s 2>&1 \
-# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
-# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkb %s \
-# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkb  - \
-# RUN:| FileCheck %s --check-prefix=CHECK-INST
-# RUN: llvm-mc -triple=riscv32 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkb %s \
-# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
-
-vandn.vv v10, v9, v8, v0.t
-# CHECK-INST: vandn.vv v10, v9, v8, v0.t
-# CHECK-ENCODING: [0x57,0x05,0x94,0x04]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 05 94 04   
-
-vandn.vx v10, v9, a0, v0.t
-# CHECK-INST: vandn.vx v10, v9, a0, v0.t
-# CHECK-ENCODING: [0x57,0x45,0x95,0x04]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 45 95 04   
-
-vbrev8.v v10, v9, v0.t
-# CHECK-INST: vbrev8.v v10, v9, v0.t
-# CHECK-ENCODING: [0x57,0x25,0x94,0x48]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 25 94 48   
-
-vclmul.vv v10, v9, v8
-# CHECK-INST: vclmul.vv v10, v9, v8
-# CHECK-ENCODING: [0x57,0x25,0x94,0x32]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 25 94 32   
-   
-vclmul.vx v10, v9, a0
-# CHECK-INST: vclmul.vx v10, v9, a0
-# CHECK-ENCODING: [0x57,0x65,0x95,0x32]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 65 95 32   
-
-vclmulh.vv v10, v9, v8
-# CHECK-INST: vclmulh.vv v10, v9, v8
-# CHECK-ENCODING: [0x57,0x25,0x94,0x36]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 25 94 36   
-
-vclmulh.vx v10, v9, a0
-# CHECK-INST: vclmulh.vx v10, v9, a0
-# CHECK-ENCODING: [0x57,0x65,0x95,0x36]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 65 95 36   
-   
-vrev8.v v10, v9, v0.t
-# CHECK-INST: vrev8.v v10, v9, v0.t
-# CHECK-ENCODING: [0x57,0xa5,0x94,0x48]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 a5 94 48   
-
-vrol.vv v10, v9, v8, v0.t
-# CHECK-INST: vrol.vv v10, v9, v8, v0.t
-# CHECK-ENCODING: [0x57,0x05,0x94,0x54]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 57 05 94 54   
-
-vrol.vx v10, v9, a0, v0.t
-# CHECK-INST: vrol.vx v10, v9, a0, v0.t
-# CHECK-ENCODING: [0x57,0x45,0x95,0x54]
-# CHECK-ERROR: instruction requires the following: 'Zvkb' (Vector Bitmanip instructions for Cryptography.){{$}}
-# CHECK-UNKNOWN: 

[clang] cb7dffd - [RISCV] Zvk (vector crypto) specification update to 0.5.1 (Zvbb/Zvbc/Zvkt/Zvkng/Zvksg)

2023-04-20 Thread Alex Bradbury via cfe-commits

Author: Eric Gouriou
Date: 2023-04-20T18:25:19+01:00
New Revision: cb7dffdc9a83f400410657431bda14e79f6e0176

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

LOG: [RISCV] Zvk (vector crypto) specification update to 0.5.1 
(Zvbb/Zvbc/Zvkt/Zvkng/Zvksg)

Update the Zvk support from 0.3.x to 0.5.1, tracking the extension as
documented in
.

- Zvkb is split into Zvbb and Zvbc
- Zvbc (vector carryless multiply) requires 64 bit elements (Zve64x)
- Use the extension descriptions from the specification for Zvbb/Zvbc
- Zvkt is introduced (no instructions, but adds an attribute and macro)
- Zvkn and Zvks both imply Zvkt
- Zvkng and Zvksg are introduced, adding Zvkg (GMAC) to Zvkn and Zvks
- In Zvbb, add vrev.v, vclz.v, vctz.v, vcpop.v, vwsll.{vv,vx,vi}

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

Added: 
llvm/test/MC/RISCV/rvv/zvbb.s
llvm/test/MC/RISCV/rvv/zvbc.s

Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s
llvm/test/MC/RISCV/rvv/zvkg.s

Removed: 
llvm/test/MC/RISCV/rvv/zvkb.s



diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 79b7af954898d..c4135e4d3ddfa 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -49,15 +49,19 @@
 // CHECK-NOT: __riscv_zcd {{.*$}}
 // CHECK-NOT: __riscv_zcf {{.*$}}
 // CHECK-NOT: __riscv_h {{.*$}}
-// CHECK-NOT: __riscv_zvkb {{.*$}}
+// CHECK-NOT: __riscv_zvbb {{.*$}}
+// CHECK-NOT: __riscv_zvbc {{.*$}}
 // CHECK-NOT: __riscv_zvkg {{.*$}}
 // CHECK-NOT: __riscv_zvkn {{.*$}}
+// CHECK-NOT: __riscv_zvkned {{.*$}}
+// CHECK-NOT: __riscv_zvkng {{.*$}}
 // CHECK-NOT: __riscv_zvknha {{.*$}}
 // CHECK-NOT: __riscv_zvknhb {{.*$}}
-// CHECK-NOT: __riscv_zvkned {{.*$}}
 // CHECK-NOT: __riscv_zvks {{.*$}}
 // CHECK-NOT: __riscv_zvksed {{.*$}}
+// CHECK-NOT: __riscv_zvksg {{.*$}}
 // CHECK-NOT: __riscv_zvksh {{.*$}}
+// CHECK-NOT: __riscv_zvkt {{.*$}}
 // CHECK-NOT: __riscv_zicond {{.*$}}
 
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32i -x c -E -dM %s \
@@ -526,76 +530,108 @@
 // CHECK-ZFA-EXT: __riscv_zfa 2000{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvkb0p3 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-ZVKB-EXT %s
+// RUN: -march=rv32i_zve64x_zvbb0p5 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVBB-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvkb0p3 -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-ZVKB-EXT %s
-// CHECK-ZVKB-EXT: __riscv_zvkb  3000{{$}}
+// RUN: -march=rv64i_zve64x_zvbb0p5 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVBB-EXT %s
+// CHECK-ZVBB-EXT: __riscv_zvbb  5000{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve32x_zvkg0p3 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvbc0p5 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVBC-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64i_zve64x_zvbc0p5 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZVBC-EXT %s
+// CHECK-ZVBC-EXT: __riscv_zvbc  5000{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32i_zve32x_zvkg0p5 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKG-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve32x_zvkg0p3 -x c -E -dM %s \
+// RUN: -march=rv64i_zve32x_zvkg0p5 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKG-EXT %s
-// CHECK-ZVKG-EXT: __riscv_zvkg  3000{{$}}
+// CHECK-ZVKG-EXT: __riscv_zvkg  5000{{$}}
 
 // RUN: %clang -target riscv32 -menable-experimental-extensions \
-// RUN: -march=rv32i_zve64x_zvkn0p3 -x c -E -dM %s \
+// RUN: -march=rv32i_zve64x_zvkn0p5 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKN-EXT %s
 // RUN: %clang -target riscv64 -menable-experimental-extensions \
-// RUN: -march=rv64i_zve64x_zvkn0p3 -x c -E -dM %s \
+// RUN: -march=rv64i_zve64x_zvkn0p5 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZVKN-EXT %s
-// CHECK-ZVKN-EXT: __riscv_zvkn 3000{{$}}
+// CHECK-ZVKN-EXT: __riscv_zvkn 5000{{$}}
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: 

[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Surprised that we didn't already do this; seems like a bit of an oversight.




Comment at: clang/test/Driver/riscv-default-build-attributes.s:1
+// Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \

Do we use /// for non-lit/FileCheck lines like we use ;; in IR tests?



Comment at: clang/test/Driver/riscv-default-build-attributes.s:11
+
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes

Gap is a bit odd



Comment at: clang/test/Driver/riscv-default-build-attributes.s:12
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes
+// during codegen).

missing "for"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148817

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


[PATCH] D148817: [RISCV] Add Tag_RISCV_arch attribute by default when using clang as an assembler.

2023-04-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: kito-cheng, asb, jrtc27, reames.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
jdoerfert, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, 
psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, 
kristof.beyls, arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

Can be disabled with -mno-default-build-attributes just like ARM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148817

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/riscv-default-build-attributes.s


Index: clang/test/Driver/riscv-default-build-attributes.s
===
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,22 @@
+// Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes
+// during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 
\
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation: 
'-mno-default-build-attributes'}}
+// expected-warning {{argument unused during compilation: 
'-mno-default-build-attributes'}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
+
+  if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+   options::OPT_mno_default_build_attributes, true)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-riscv-add-build-attributes");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,


Index: clang/test/Driver/riscv-default-build-attributes.s
===
--- /dev/null
+++ clang/test/Driver/riscv-default-build-attributes.s
@@ -0,0 +1,22 @@
+// Enabled by default for assembly
+// RUN: %clang --target=riscv64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+// Can be forced on or off for assembly.
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mno-default-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### %s 2>&1 -mdefault-build-attributes \
+// RUN:| FileCheck %s -check-prefix CHECK-ENABLED
+
+
+// Option ignored C/C++ (since we always emit hardware and ABI build attributes
+// during codegen).
+// RUN: %clang --target=riscv64 -### -x c %s -mdefault-build-attributes 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+// RUN: %clang --target=riscv64 -### -x c++ %s -mdefault-build-attributes 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DISABLED
+
+// CHECK-DISABLED-NOT: "-riscv-add-build-attributes"
+// CHECK-ENABLED: "-riscv-add-build-attributes"
+// expected-warning {{argument unused during compilation: '-mno-default-build-attributes'}}
+// expected-warning {{argument unused during compilation: '-mno-default-build-attributes'}}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7903,6 +7903,12 @@
 
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName.data());
+
+  if (Args.hasFlag(options::OPT_mdefault_build_attributes,
+   options::OPT_mno_default_build_attributes, true)) {
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-riscv-add-build-attributes");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >