[clang] [clang][dataflow] Eliminate `RecordValue::getChild()`. (PR #65586)

2023-09-07 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

LGTM!

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


[clang] [clang][dataflow][NFC] Delete unused function. (PR #65602)

2023-09-07 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.


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


[PATCH] D159480: [Clang][AArch64] Fine-grained ldp and stp policies.

2023-09-07 Thread Manos Anagnostakis via Phabricator via cfe-commits
manosanag updated this revision to Diff 556154.
manosanag added a comment.

Updated Options.td to provide visibility for the options, because
it caused a regression for my fortran tests after rebasing to
current llvm main branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159480

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/test/Driver/aarch64-ldp-policy.c
  clang/test/Driver/aarch64-stp-policy.c
  clang/test/Driver/flang/aarch64-ldp-policy.f90
  clang/test/Driver/flang/aarch64-stp-policy.f90
  llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp
  llvm/test/CodeGen/AArch64/ldp-aligned.ll
  llvm/test/CodeGen/AArch64/ldp-always.ll
  llvm/test/CodeGen/AArch64/ldp-never.ll
  llvm/test/CodeGen/AArch64/stp-aligned.ll
  llvm/test/CodeGen/AArch64/stp-always.ll
  llvm/test/CodeGen/AArch64/stp-never.ll

Index: llvm/test/CodeGen/AArch64/stp-never.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/stp-never.ll
@@ -0,0 +1,105 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc < %s -O2 -mtriple=aarch64 -mcpu=generic -aarch64-stp-policy=never | FileCheck %s
+
+define ptr @stp_aligned_int32_t(ptr %0, i32 %1) #0 {
+; CHECK-LABEL: stp_aligned_int32_t:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:and x0, x0, #0xffc0
+; CHECK-NEXT:str w1, [x0]
+; CHECK-NEXT:str w1, [x0, #4]
+; CHECK-NEXT:ret
+  %3 = ptrtoint ptr %0 to i64
+  %4 = and i64 %3, -64
+  %5 = inttoptr i64 %4 to ptr
+  store i32 %1, ptr %5, align 64
+  %6 = getelementptr inbounds i32, ptr %5, i64 1
+  store i32 %1, ptr %6, align 4
+  ret ptr %5
+}
+
+define ptr @stp_aligned_int64_t(ptr %0, i64 %1) #0 {
+; CHECK-LABEL: stp_aligned_int64_t:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:and x0, x0, #0xff80
+; CHECK-NEXT:str x1, [x0]
+; CHECK-NEXT:str x1, [x0, #8]
+; CHECK-NEXT:ret
+  %3 = ptrtoint ptr %0 to i64
+  %4 = and i64 %3, -128
+  %5 = inttoptr i64 %4 to ptr
+  store i64 %1, ptr %5, align 128
+  %6 = getelementptr inbounds i64, ptr %5, i64 1
+  store i64 %1, ptr %6, align 8
+  ret ptr %5
+}
+
+define ptr @stp_aligned_v4si(ptr %0, <4 x i32> %1) #0 {
+; CHECK-LABEL: stp_aligned_v4si:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:and x0, x0, #0xff00
+; CHECK-NEXT:str q0, [x0]
+; CHECK-NEXT:str q0, [x0, #16]
+; CHECK-NEXT:ret
+  %3 = ptrtoint ptr %0 to i64
+  %4 = and i64 %3, -256
+  %5 = inttoptr i64 %4 to ptr
+  store <4 x i32> %1, ptr %5, align 256
+  %6 = getelementptr inbounds <4 x i32>, ptr %5, i64 1
+  store <4 x i32> %1, ptr %6, align 16
+  ret ptr %5
+}
+
+define ptr @stp_unaligned_int32_t(ptr %0, i32 %1) #0 {
+; CHECK-LABEL: stp_unaligned_int32_t:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:and x8, x0, #0xffc0
+; CHECK-NEXT:orr x0, x8, #0x4
+; CHECK-NEXT:str w1, [x8, #4]
+; CHECK-NEXT:str w1, [x8, #8]
+; CHECK-NEXT:ret
+  %3 = ptrtoint ptr %0 to i64
+  %4 = and i64 %3, -64
+  %5 = inttoptr i64 %4 to ptr
+  %6 = getelementptr inbounds i32, ptr %5, i64 1
+  store i32 %1, ptr %6, align 4
+  %7 = getelementptr inbounds i32, ptr %5, i64 2
+  store i32 %1, ptr %7, align 8
+  ret ptr %6
+}
+
+define ptr @stp_unaligned_int64_t(ptr %0, i64 %1) #0 {
+; CHECK-LABEL: stp_unaligned_int64_t:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:and x8, x0, #0xff80
+; CHECK-NEXT:orr x0, x8, #0x8
+; CHECK-NEXT:str x1, [x8, #8]
+; CHECK-NEXT:str x1, [x8, #16]
+; CHECK-NEXT:ret
+  %3 = ptrtoint ptr %0 to i64
+  %4 = and i64 %3, -128
+  %5 = inttoptr i64 %4 to ptr
+  %6 = getelementptr inbounds i64, ptr %5, i64 1
+  store i64 %1, ptr %6, align 8
+  %7 = getelementptr inbounds i64, ptr %5, i64 2
+  store i64 %1, ptr %7, align 16
+  ret ptr %6
+}
+
+define ptr @stp_unaligned_v4si(ptr %0, <4 x i32> %1) #0 {
+; CHECK-LABEL: stp_unaligned_v4si:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:and x8, x0, #0xff00
+; CHECK-NEXT:orr x0, x8, #0x10
+; CHECK-NEXT:str q0, [x8, #16]
+; CHECK-NEXT:str q0, [x8, #32]
+; CHECK-NEXT:ret
+  %3 = ptrtoint ptr %0 to i64
+  %4 = and i64 %3, -256
+  %5 = inttoptr i64 %4 to ptr
+  %6 = getelementptr inbounds <4 x i32>, ptr %5, i64 1
+  store <4 x i32> %1, ptr %6, align 16
+  %7 = getelementptr inbounds <4 x i32>, ptr %5, i64 2
+  store <4 x i32> %1, ptr %7, align 32
+  ret ptr %6
+}
+
Index: llvm/test/CodeGen/AArch64/stp-always.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/stp-always.ll
@@ -0,0 +1,99 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc < %s -O2 -mtriple=aarch64 -mcpu=generic -aarch64-stp-policy=always | FileCheck %s
+

[PATCH] D141714: Fix ast print of variables with attributes

2023-09-07 Thread Giuliano Belinassi via Phabricator via cfe-commits
giulianobelinassi added a comment.

In D141714#4638225 , @erichkeane 
wrote:

> Looks fine to me, please don't commit for a day or two to give @aaron.ballman 
> a chance to make a final comment.

I am sorry, but how am I supposed to commit those changes to main if I do not 
have write permission?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[PATCH] D141714: Fix ast print of variables with attributes

2023-09-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D141714#4640825 , 
@giulianobelinassi wrote:

> In D141714#4638225 , @erichkeane 
> wrote:
>
>> Looks fine to me, please don't commit for a day or two to give 
>> @aaron.ballman a chance to make a final comment.
>
> I am sorry, but how am I supposed to commit those changes to main if I do not 
> have write permission?

I didn't realize you didn't have commit permissions!  If you send me (either 
here, or privately) your name and email in the form of: "Full Name 
"  I can do it for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -66,16 +66,18 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, 
llvm::opt::ArgList &Args,
  DiagnosticsEngine *Diags = nullptr,
  bool DefaultDiagColor = true);
 
+namespace CompilerInvocationDetail {
 /// The base class of CompilerInvocation with reference semantics.
 ///
 /// This class stores option objects behind reference-counted pointers. This is
 /// useful for clients that want to keep some option object around even after
 /// CompilerInvocation gets destroyed, without making a copy.
 ///
-/// This is a separate class so that we can implement the copy constructor and
-/// assignment here and leave them defaulted in the rest of CompilerInvocation.
-class CompilerInvocationRefBase {
-public:
+/// This is a separate base class so that the client-facing sub-classes can
+/// simply declare the desired copy semantics without managing the internals
+/// themselves (for the most parts).

benlangmuir wrote:

Nit: "for the most part" is always with singular "part".  

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -94,47 +96,37 @@ class CompilerInvocationRefBase {
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationRefBase();
-  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
-  ~CompilerInvocationRefBase();
+  struct ShallowCopy {};
+  struct DeepCopy {};
 
-  LangOptions &getLangOpts() { return *LangOpts; }
-  const LangOptions &getLangOpts() const { return *LangOpts; }
+  RefBase();
 
-  TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
-  const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
+  RefBase(const RefBase &X, DeepCopy);
+  RefBase(const RefBase &X, ShallowCopy);
+  RefBase(const RefBase &) = delete;
 
-  DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
+  RefBase &assign(const RefBase &X, DeepCopy);
+  RefBase &assign(const RefBase &X, ShallowCopy);
+  RefBase &operator=(const RefBase &) = delete;
 
-  HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
+  RefBase(RefBase &&);
+  RefBase &operator=(RefBase &&);
 
-  const HeaderSearchOptions &getHeaderSearchOpts() const {
-return *HeaderSearchOpts;
-  }
+  ~RefBase();
 
-  std::shared_ptr getHeaderSearchOptsPtr() const {
-return HeaderSearchOpts;
-  }
-
-  std::shared_ptr getPreprocessorOptsPtr() {
-return PreprocessorOpts;
-  }
-
-  PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
-
-  const PreprocessorOptions &getPreprocessorOpts() const {
-return *PreprocessorOpts;
-  }
-
-  AnalyzerOptions &getAnalyzerOpts() { return *AnalyzerOpts; }
+public:
+  // clang-format off

benlangmuir wrote:

There seems to be several formatting-off regions here; is this to cheat the 
length limit? I've never seen formatting disabled like this unless there's a 
really strong reason.

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -154,46 +146,158 @@ class CompilerInvocationValueBase {
   PreprocessorOutputOptions PreprocessorOutputOpts;
 
 public:
-  MigratorOptions &getMigratorOpts() { return MigratorOpts; }
+  // clang-format off
   const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
-
-  CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
   const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
+  const DependencyOutputOptions &getDependencyOutputOpts() const { return 
DependencyOutputOpts; }
+  const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
+  const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
+  const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { return 
PreprocessorOutputOpts; }
+  // clang-format on
+};
+} // namespace CompilerInvocationDetail
 
-  DependencyOutputOptions &getDependencyOutputOpts() {
-return DependencyOutputOpts;
-  }
+struct CompilerInvocationBase : CompilerInvocationDetail::RefBase,
+CompilerInvocationDetail::ValBase {
+  CompilerInvocationBase() = default;
 
-  const DependencyOutputOptions &getDependencyOutputOpts() const {
-return DependencyOutputOpts;
-  }
+  CompilerInvocationBase(const CompilerInvocationBase &X, DeepCopy)
+  : RefBase(X, DeepCopy{}), ValBase(X) {}
 
-  FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
+  CompilerInvocationBase(const CompilerInvocationBase &X, ShallowCopy)
+  : RefBase(X, ShallowCopy{}), ValBase(X) {}
 
-  const FileSystemOptions &getFileSystemOpts() const {
-return FileSystemOpts;
+  CompilerInvocationBase &assign(const CompilerInvocationBase &X, DeepCopy) {
+RefBase::assign(X, DeepCopy{});
+ValBase::operator=(X);
+return *this;
   }
 
-  FrontendOptions &getFrontendOpts() { return FrontendOpts; }
-  const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
-
-  PreprocessorOutputOptions &getPreprocessorOutputOpts() {
-return PreprocessorOutputOpts;
+  CompilerInvocationBase &assign(const CompilerInvocationBase &X, ShallowCopy) 
{
+RefBase::assign(X, ShallowCopy{});
+ValBase::operator=(X);
+return *this;
   }
 
-  const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
-return PreprocessorOutputOpts;
+  using StringAllocator = llvm::function_ref;
+  /// Generate cc1-compatible command line arguments from this instance.
+  ///
+  /// \param [out] Args - The generated arguments. Note that the caller is
+  /// responsible for inserting the path to the clang executable and "-cc1" if
+  /// desired.
+  /// \param SA - A function that given a Twine can allocate storage for a 
given
+  /// command line argument and return a pointer to the newly allocated string.
+  /// The returned pointer is what gets appended to Args.
+  void generateCC1CommandLine(llvm::SmallVectorImpl &Args,
+  StringAllocator SA) const {
+generateCC1CommandLine([&](const Twine &Arg) {
+  // No need to allocate static string literals.
+  Args.push_back(Arg.isSingleStringLiteral()
+ ? Arg.getSingleStringRef().data()
+ : SA(Arg));
+});
   }
+
+  using ArgumentConsumer = llvm::function_ref;
+  /// Generate cc1-compatible command line arguments from this instance.
+  ///
+  /// \param Consumer - Callback that gets invoked for every single generated
+  /// command line argument.
+  void generateCC1CommandLine(ArgumentConsumer Consumer) const;
+
+  /// Generate cc1-compatible command line arguments from this instance,
+  /// wrapping the result as a std::vector.
+  ///
+  /// This is a (less-efficient) wrapper over generateCC1CommandLine().
+  std::vector getCC1CommandLine() const;
+
+  /// Generate command line options from DiagnosticOptions.
+  static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts,
+ ArgumentConsumer Consumer,
+ bool DefaultDiagColor);
+
+  /// Generate command line options from LangOptions.
+  static void GenerateLangArgs(const LangOptions &Opts,
+   ArgumentConsumer Consumer, const llvm::Triple 
&T,
+   InputKind IK);
+
+  // Generate command line options from CodeGenOptions.
+  static void GenerateCodeGenArgs(const CodeGenOptions &Opts,
+  ArgumentConsumer Consumer,
+  const llvm::Triple &T,
+  const std::string &OutputFile,
+  const LangOptions *LangOpts);
 };
 
 /// Helper class for holding the data necessary to invoke the compiler.
 ///
 /// This class is designed to represent an abstract "invocation" of the
 /// compiler, including data such as the include paths, the code generation
 /// options, the warning flags, and so on.
-class CompilerInvocation : public CompilerInvocationR

[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -123,49 +123,101 @@ static Expected> 
parseToleranceOption(StringRef Arg) {
 }
 
 
//===--===//
-// Initialization.
+// Storage details.
 
//===--===//
 
-CompilerInvocationRefBase::CompilerInvocationRefBase()
-: LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
-  DiagnosticOpts(new DiagnosticOptions()),
-  HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()),
-  AnalyzerOpts(new AnalyzerOptions()) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-const CompilerInvocationRefBase &X)
-: LangOpts(new LangOptions(X.getLangOpts())),
-  TargetOpts(new TargetOptions(X.getTargetOpts())),
-  DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-  HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
-  AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-CompilerInvocationRefBase &&X) = default;
-
-CompilerInvocationRefBase &
-CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
-  LangOpts.swap(X.LangOpts);
-  TargetOpts.swap(X.TargetOpts);
-  DiagnosticOpts.swap(X.DiagnosticOpts);
-  HeaderSearchOpts.swap(X.HeaderSearchOpts);
-  PreprocessorOpts.swap(X.PreprocessorOpts);
-  AnalyzerOpts.swap(X.AnalyzerOpts);
+namespace clang::CompilerInvocationDetail {
+namespace {
+template  std::shared_ptr make_shared(const T &X) {

benlangmuir wrote:

Why do we have these wrappers?

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -94,47 +96,37 @@ class CompilerInvocationRefBase {
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationRefBase();
-  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
-  ~CompilerInvocationRefBase();
+  struct ShallowCopy {};
+  struct DeepCopy {};
 
-  LangOptions &getLangOpts() { return *LangOpts; }
-  const LangOptions &getLangOpts() const { return *LangOpts; }
+  RefBase();
 
-  TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
-  const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
+  RefBase(const RefBase &X, DeepCopy);
+  RefBase(const RefBase &X, ShallowCopy);
+  RefBase(const RefBase &) = delete;
 
-  DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
+  RefBase &assign(const RefBase &X, DeepCopy);
+  RefBase &assign(const RefBase &X, ShallowCopy);
+  RefBase &operator=(const RefBase &) = delete;
 
-  HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
+  RefBase(RefBase &&);
+  RefBase &operator=(RefBase &&);
 
-  const HeaderSearchOptions &getHeaderSearchOpts() const {
-return *HeaderSearchOpts;
-  }
+  ~RefBase();
 
-  std::shared_ptr getHeaderSearchOptsPtr() const {
-return HeaderSearchOpts;
-  }
-
-  std::shared_ptr getPreprocessorOptsPtr() {
-return PreprocessorOpts;
-  }
-
-  PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
-
-  const PreprocessorOptions &getPreprocessorOpts() const {
-return *PreprocessorOpts;
-  }
-
-  AnalyzerOptions &getAnalyzerOpts() { return *AnalyzerOpts; }
+public:
+  // clang-format off
+  const LangOptions &getLangOpts() const { return *LangOpts; }
+  const TargetOptions &getTargetOpts() const { return *TargetOpts; }
+  const DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; 
}
+  const HeaderSearchOptions &getHeaderSearchOpts() const { return 
*HeaderSearchOpts; }
+  const PreprocessorOptions &getPreprocessorOpts() const { return 
*PreprocessorOpts; }
   const AnalyzerOptions &getAnalyzerOpts() const { return *AnalyzerOpts; }
+  // clang-format on
 };
 
 /// The base class of CompilerInvocation with value semantics.
-class CompilerInvocationValueBase {
+class ValBase {

benlangmuir wrote:

Doesn't have to be this PR, but might be worth just moving everything into 
RefBase... some of these contain a lot of strings like FrontendOptions and it's 
not clear ValBase is providing value.

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -123,49 +123,101 @@ static Expected> 
parseToleranceOption(StringRef Arg) {
 }
 
 
//===--===//
-// Initialization.
+// Storage details.
 
//===--===//
 
-CompilerInvocationRefBase::CompilerInvocationRefBase()
-: LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
-  DiagnosticOpts(new DiagnosticOptions()),
-  HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()),
-  AnalyzerOpts(new AnalyzerOptions()) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-const CompilerInvocationRefBase &X)
-: LangOpts(new LangOptions(X.getLangOpts())),
-  TargetOpts(new TargetOptions(X.getTargetOpts())),
-  DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-  HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
-  AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-CompilerInvocationRefBase &&X) = default;
-
-CompilerInvocationRefBase &
-CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
-  LangOpts.swap(X.LangOpts);
-  TargetOpts.swap(X.TargetOpts);
-  DiagnosticOpts.swap(X.DiagnosticOpts);
-  HeaderSearchOpts.swap(X.HeaderSearchOpts);
-  PreprocessorOpts.swap(X.PreprocessorOpts);
-  AnalyzerOpts.swap(X.AnalyzerOpts);
+namespace clang::CompilerInvocationDetail {
+namespace {
+template  std::shared_ptr make_shared(const T &X) {
+  return std::make_shared(X);
+}
+
+template  llvm::IntrusiveRefCntPtr makeIntrusiveRefCnt(const T &X) 
{
+  return llvm::makeIntrusiveRefCnt(X);
+}
+} // namespace
+
+RefBase::RefBase()
+: LangOpts(std::make_shared()),
+  TargetOpts(std::make_shared()),
+  DiagnosticOpts(llvm::makeIntrusiveRefCnt()),
+  HeaderSearchOpts(std::make_shared()),
+  PreprocessorOpts(std::make_shared()),
+  AnalyzerOpts(llvm::makeIntrusiveRefCnt()) {}
+
+RefBase::RefBase(const RefBase &X, DeepCopy)

benlangmuir wrote:

Would it make sense to implement these constructors using `assign`?

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -94,47 +96,37 @@ class CompilerInvocationRefBase {
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationRefBase();
-  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
-  ~CompilerInvocationRefBase();
+  struct ShallowCopy {};

benlangmuir wrote:

Maybe worth a doc comment for these types. I think it's clear what's going on 
in the constructors themselves, but if someone sees the type itself they might 
wonder.

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


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I think that might be a bit too accelerated. I work mostly with a fork of 
> LLVM (https://github.com/apple/llvm-project) and do care about the usability 
> of `cmd` as a shell (however, it is significantly behind but is working on 
> updating to a more recent version). I think that Swift is a large enough 
> consumer of LLVM to consider testing that before declaring this feature 
> removed.

Thanks for mentioning this.

Given that `cmd` as a lit external shell appears to be have been unusable since 
April, 2022, how is that fork relying on it?  Is it farther behind than that?

Fixing the remaining problem with `cmd` appears to be straight-forward, so I'm 
fine to do that.  However, how hard would it be to use lit's internal shell for 
your use case?

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


[clang] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I think that might be a bit too accelerated. I work mostly with a fork of 
> LLVM (https://github.com/apple/llvm-project) and do care about the usability 
> of `cmd` as a shell (however, it is significantly behind but is working on 
> updating to a more recent version). I think that Swift is a large enough 
> consumer of LLVM to consider testing that before declaring this feature 
> removed.

Thanks for mentioning this.

Given that `cmd` as a lit external shell appears to be have been unusable since 
April, 2022, how is that fork relying on it?  Is it farther behind than that?

Fixing the remaining problem with `cmd` appears to be straight-forward, so I'm 
fine to do that.  However, how hard would it be to use lit's internal shell for 
your use case?

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits


@@ -94,47 +96,37 @@ class CompilerInvocationRefBase {
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationRefBase();
-  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
-  ~CompilerInvocationRefBase();
+  struct ShallowCopy {};
+  struct DeepCopy {};
 
-  LangOptions &getLangOpts() { return *LangOpts; }
-  const LangOptions &getLangOpts() const { return *LangOpts; }
+  RefBase();
 
-  TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
-  const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
+  RefBase(const RefBase &X, DeepCopy);
+  RefBase(const RefBase &X, ShallowCopy);
+  RefBase(const RefBase &) = delete;
 
-  DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
+  RefBase &assign(const RefBase &X, DeepCopy);
+  RefBase &assign(const RefBase &X, ShallowCopy);
+  RefBase &operator=(const RefBase &) = delete;
 
-  HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
+  RefBase(RefBase &&);
+  RefBase &operator=(RefBase &&);
 
-  const HeaderSearchOptions &getHeaderSearchOpts() const {
-return *HeaderSearchOpts;
-  }
+  ~RefBase();
 
-  std::shared_ptr getHeaderSearchOptsPtr() const {
-return HeaderSearchOpts;
-  }
-
-  std::shared_ptr getPreprocessorOptsPtr() {
-return PreprocessorOpts;
-  }
-
-  PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
-
-  const PreprocessorOptions &getPreprocessorOpts() const {
-return *PreprocessorOpts;
-  }
-
-  AnalyzerOptions &getAnalyzerOpts() { return *AnalyzerOpts; }
+public:
+  // clang-format off

jansvoboda11 wrote:

Yes, I find this hard to read when some of these simple getters fit on one line 
while others are spread out over three lines.

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #65407)

2023-09-07 Thread Yusra Syeda via cfe-commits

https://github.com/ysyeda updated 
https://github.com/llvm/llvm-project/pull/65407:

>From d83e1e72f584619b6e035795558618581fdff3fd Mon Sep 17 00:00:00 2001
From: Yusra Syeda 
Date: Tue, 5 Sep 2023 15:43:24 -0400
Subject: [PATCH] [SystemZ][z/OS] This change adds support for the PPA2 section
 in zOS

---
 clang/include/clang/Basic/LangStandard.h  |   1 +
 clang/lib/Basic/LangStandards.cpp |  39 
 clang/lib/CodeGen/CodeGenModule.cpp   |  15 ++
 clang/lib/Driver/ToolChains/Clang.cpp |  13 +-
 clang/lib/Driver/ToolChains/Clang.h   |   3 +-
 clang/test/CodeGen/SystemZ/systemz-ppa2.c |  25 +++
 llvm/include/llvm/BinaryFormat/GOFF.h |   1 +
 llvm/include/llvm/MC/MCObjectFileInfo.h   |   4 +
 llvm/include/llvm/Support/Chrono.h|  26 +++
 llvm/lib/MC/MCObjectFileInfo.cpp  |   5 +
 llvm/lib/Support/Chrono.cpp   |  91 +---
 llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp | 197 +-
 llvm/lib/Target/SystemZ/SystemZAsmPrinter.h   |   7 +-
 llvm/test/CodeGen/SystemZ/zos-ppa2.ll |  26 +++
 14 files changed, 421 insertions(+), 32 deletions(-)
 create mode 100644 clang/test/CodeGen/SystemZ/systemz-ppa2.c
 create mode 100644 llvm/test/CodeGen/SystemZ/zos-ppa2.ll

diff --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index 6356f16acc811e0..d94567adf2bfb99 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/clang/include/clang/Basic/LangStandard.h
@@ -43,6 +43,7 @@ enum class Language : uint8_t {
   HLSL,
   ///@}
 };
+const char *LanguageToString(Language L);
 
 enum LangFeatures {
   LineComment = (1 << 0),
diff --git a/clang/lib/Basic/LangStandards.cpp 
b/clang/lib/Basic/LangStandards.cpp
index af9cf4f273920ee..e9b75d78e820a64 100644
--- a/clang/lib/Basic/LangStandards.cpp
+++ b/clang/lib/Basic/LangStandards.cpp
@@ -10,9 +10,48 @@
 #include "clang/Config/config.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/TargetParser/Triple.h"
 using namespace clang;
 
+const char *clang::LanguageToString(Language L) {
+  // I would like to make this function and the definition of Language
+  // in the .h file simply expand the contents of a .def file.
+  // However, in the .h the members of the enum have doxygen annotations
+  // and/or comments which would be lost.
+  switch (L) {
+  case Language::Unknown:
+return "Unknown";
+  case Language::Asm:
+return "Asm";
+  case Language::LLVM_IR:
+return "LLVM_IR";
+  case Language::C:
+return "C";
+  case Language::CXX:
+return "CXX";
+  case Language::ObjC:
+return "ObjC";
+  case Language::ObjCXX:
+return "ObjCXX";
+  case Language::OpenCL:
+return "OpenCL";
+  case Language::OpenCLCXX:
+return "OpenCLCXX";
+  case Language::CUDA:
+return "CUDA";
+  case Language::RenderScript:
+return "RenderScript";
+  case Language::HIP:
+return "HIP";
+  case Language::HLSL:
+return "HLSL";
+  }
+
+  std::string msg = llvm::formatv("Unknown value ({0}) passed to 
LanguageToString", (unsigned int) L);
+  llvm_unreachable(msg.c_str());
+}
+
 #define LANGSTANDARD(id, name, lang, desc, features)   
\
   static const LangStandard Lang_##id = {name, desc, features, Language::lang};
 #include "clang/Basic/LangStandards.def"
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f5513217bebfbaa..239e3d2bcd16251 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -975,6 +975,21 @@ void CodeGenModule::Release() {
   Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
   getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
 
+  if (getTriple().isOSzOS()) {
+int32_t ProductVersion, ProductRelease, ProductPatch;
+ProductVersion = LLVM_VERSION_MAJOR,
+ProductRelease = LLVM_VERSION_MINOR, ProductPatch = LLVM_VERSION_PATCH;
+getModule().addModuleFlag(llvm::Module::Warning, "Product Major Version", 
ProductVersion);
+getModule().addModuleFlag(llvm::Module::Warning, "Product Minor Version", 
ProductRelease);
+getModule().addModuleFlag(llvm::Module::Warning, "Product Patchlevel", 
ProductPatch);
+
+// Record the language because we need it for the PPA2.
+const char *lang_str = LanguageToString(
+LangStandard::getLangStandardForKind(LangOpts.LangStd).Language);
+getModule().addModuleFlag(llvm::Module::Error, "zos_cu_language",
+  llvm::MDString::get(VMContext, lang_str));
+  }
+
   llvm::Triple::ArchType Arch = Context.getTargetInfo().getTriple().getArch();
   if (   Arch == llvm::Triple::arm
   || Arch == llvm::Triple::armeb
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 531677e92f73252..6d786770386881f 100644
--- a/clang/lib/Driver/ToolC

[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits


@@ -94,47 +96,37 @@ class CompilerInvocationRefBase {
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationRefBase();
-  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
-  ~CompilerInvocationRefBase();
+  struct ShallowCopy {};
+  struct DeepCopy {};
 
-  LangOptions &getLangOpts() { return *LangOpts; }
-  const LangOptions &getLangOpts() const { return *LangOpts; }
+  RefBase();
 
-  TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
-  const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
+  RefBase(const RefBase &X, DeepCopy);
+  RefBase(const RefBase &X, ShallowCopy);
+  RefBase(const RefBase &) = delete;
 
-  DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
+  RefBase &assign(const RefBase &X, DeepCopy);
+  RefBase &assign(const RefBase &X, ShallowCopy);
+  RefBase &operator=(const RefBase &) = delete;
 
-  HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
+  RefBase(RefBase &&);
+  RefBase &operator=(RefBase &&);
 
-  const HeaderSearchOptions &getHeaderSearchOpts() const {
-return *HeaderSearchOpts;
-  }
+  ~RefBase();
 
-  std::shared_ptr getHeaderSearchOptsPtr() const {
-return HeaderSearchOpts;
-  }
-
-  std::shared_ptr getPreprocessorOptsPtr() {
-return PreprocessorOpts;
-  }
-
-  PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
-
-  const PreprocessorOptions &getPreprocessorOpts() const {
-return *PreprocessorOpts;
-  }
-
-  AnalyzerOptions &getAnalyzerOpts() { return *AnalyzerOpts; }
+public:
+  // clang-format off
+  const LangOptions &getLangOpts() const { return *LangOpts; }
+  const TargetOptions &getTargetOpts() const { return *TargetOpts; }
+  const DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; 
}
+  const HeaderSearchOptions &getHeaderSearchOpts() const { return 
*HeaderSearchOpts; }
+  const PreprocessorOptions &getPreprocessorOpts() const { return 
*PreprocessorOpts; }
   const AnalyzerOptions &getAnalyzerOpts() const { return *AnalyzerOpts; }
+  // clang-format on
 };
 
 /// The base class of CompilerInvocation with value semantics.
-class CompilerInvocationValueBase {
+class ValBase {

jansvoboda11 wrote:

Good point, it would simplify the implementation a bit, too. I'll look into it 
as a prep patch.

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


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread Björn Pettersson via cfe-commits

https://github.com/bjope created 
https://github.com/llvm/llvm-project/pull/65624:

- Update CodeGenTypeCache to use a single union for all pointers in
  address space zero.
- Introduce a UnqualPtrTy in CodeGenTypeCache, and use that (for
  example instead of llvm::PointerType::getUnqual) in some places.
- Drop some redundant bit/pointers casts from ptr to ptr.


From 5431b8469b3ebdc92e5dadc9889b7b133da1c38d Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson 
Date: Thu, 7 Sep 2023 13:08:22 +0200
Subject: [PATCH] [clang][CodeGen] Simplify code based on opaque pointers

- Update CodeGenTypeCache to use a single union for all pointers in
  address space zero.
- Introduce a UnqualPtrTy in CodeGenTypeCache, and use that (for
  example instead of llvm::PointerType::getUnqual) in some places.
- Drop some redundant bit/pointers casts from ptr to ptr.
---
 clang/lib/CodeGen/CGAtomic.cpp|  3 +-
 clang/lib/CodeGen/CGBlocks.cpp| 20 ++
 clang/lib/CodeGen/CGBuiltin.cpp   | 99 ---
 clang/lib/CodeGen/CGCUDANV.cpp|  9 +--
 clang/lib/CodeGen/CGExpr.cpp  |  4 +-
 clang/lib/CodeGen/CGObjCRuntime.cpp   |  4 +-
 clang/lib/CodeGen/CGOpenCLRuntime.cpp | 16 ++---
 clang/lib/CodeGen/CodeGenModule.cpp   | 13 ++--
 clang/lib/CodeGen/CodeGenTypeCache.h  |  7 +-
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 39 +--
 clang/lib/CodeGen/Targets/PPC.cpp |  2 +-
 clang/lib/CodeGen/Targets/Sparc.cpp   |  2 +-
 clang/lib/CodeGen/Targets/X86.cpp | 10 +--
 13 files changed, 81 insertions(+), 147 deletions(-)

diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp
index 222b0a192c85e20..83ad6739015b8d2 100644
--- a/clang/lib/CodeGen/CGAtomic.cpp
+++ b/clang/lib/CodeGen/CGAtomic.cpp
@@ -87,8 +87,7 @@ namespace {
 llvm::Value *StoragePtr = CGF.Builder.CreateConstGEP1_64(
 CGF.Int8Ty, BitFieldPtr, OffsetInChars.getQuantity());
 StoragePtr = CGF.Builder.CreateAddrSpaceCast(
-StoragePtr, llvm::PointerType::getUnqual(CGF.getLLVMContext()),
-"atomic_bitfield_base");
+StoragePtr, CGF.UnqualPtrTy, "atomic_bitfield_base");
 BFI = OrigBFI;
 BFI.Offset = Offset;
 BFI.StorageSize = AtomicSizeInBits;
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 4f64012fc1a5c39..aa3e730d28efae5 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1189,8 +1189,8 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr 
*E,
 }
   } else {
 // Bitcast the block literal to a generic block literal.
-BlockPtr = Builder.CreatePointerCast(
-BlockPtr, llvm::PointerType::get(GenBlockTy, 0), "block.literal");
+BlockPtr =
+Builder.CreatePointerCast(BlockPtr, UnqualPtrTy, "block.literal");
 // Get pointer to the block invoke function
 llvm::Value *FuncPtr = Builder.CreateStructGEP(GenBlockTy, BlockPtr, 3);
 
@@ -1208,12 +1208,6 @@ RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr 
*E,
   const CGFunctionInfo &FnInfo =
 CGM.getTypes().arrangeBlockFunctionCall(Args, FuncTy);
 
-  // Cast the function pointer to the right type.
-  llvm::Type *BlockFTy = CGM.getTypes().GetFunctionType(FnInfo);
-
-  llvm::Type *BlockFTyPtr = llvm::PointerType::getUnqual(BlockFTy);
-  Func = Builder.CreatePointerCast(Func, BlockFTyPtr);
-
   // Prepare the callee.
   CGCallee Callee(CGCalleeInfo(), Func);
 
@@ -2589,11 +2583,11 @@ const BlockByrefInfo 
&CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
   SmallVector types;
 
   // void *__isa;
-  types.push_back(Int8PtrTy);
+  types.push_back(VoidPtrTy);
   size += getPointerSize();
 
   // void *__forwarding;
-  types.push_back(llvm::PointerType::getUnqual(byrefType));
+  types.push_back(VoidPtrTy);
   size += getPointerSize();
 
   // int32_t __flags;
@@ -2608,11 +2602,11 @@ const BlockByrefInfo 
&CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
   bool hasCopyAndDispose = getContext().BlockRequiresCopying(Ty, D);
   if (hasCopyAndDispose) {
 /// void *__copy_helper;
-types.push_back(Int8PtrTy);
+types.push_back(VoidPtrTy);
 size += getPointerSize();
 
 /// void *__destroy_helper;
-types.push_back(Int8PtrTy);
+types.push_back(VoidPtrTy);
 size += getPointerSize();
   }
 
@@ -2621,7 +2615,7 @@ const BlockByrefInfo 
&CodeGenFunction::getBlockByrefInfo(const VarDecl *D) {
   if (getContext().getByrefLifetime(Ty, Lifetime, HasByrefExtendedLayout) &&
   HasByrefExtendedLayout) {
 /// void *__byref_variable_layout;
-types.push_back(Int8PtrTy);
+types.push_back(VoidPtrTy);
 size += CharUnits::fromQuantity(PointerSizeInBytes);
   }
 
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a513eae46e358e5..cbd425a1cf2a109 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -978,9 +978,8 @@ static llvm::Value *EmitX86BitTestIntrinsic(CodeGenFunc

[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread Björn Pettersson via cfe-commits

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


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread Björn Pettersson via cfe-commits

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


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65624
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread Björn Pettersson via cfe-commits

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


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65624
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65624
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] Adding an initial version of the "Initialized Class Members" checker. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,32 @@
+.. title:: clang-tidy - google-cpp-init-class-members
+
+google-cpp-init-class-members
+=
+
+Checks that class members are initialized in constructors (implicitly or

adriannistor wrote:

Done!  (int commit ef9c4b68c2ecaf6d092b3398f3bca9fb3e722d7d) 

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


[clang-tools-extra] [clang-tidy] Adding an initial version of the "Initialized Class Members" checker. (PR #65189)

2023-09-07 Thread via cfe-commits

https://github.com/adriannistor edited 
https://github.com/llvm/llvm-project/pull/65189
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Paul T Robinson via cfe-commits

pogo59 wrote:

I have no stake in Apple/Swift, but for myself, `cmd` is the natural shell to 
use on Windows. (When I install Visual Studio, it creates a widget that brings 
up a `cmd` shell with the right environment. I'm not aware of a similar widget 
for PowerShell.) While I rarely try to copy-paste from a `lit` dump into `cmd` 
(the commands are generally too full of long paths to temp locations to work 
well) I think it would be good (but not mandatory) for that copy-paste to 
actually work.

Like others have said, I had not really grokked that Windows defaults to the 
internal shell, although just this week I tripped over a behavioral difference 
in how `diff` works in the two environments (not related to your patches). So, 
if there seems to be benefit to making the external shell Just Not Work on 
Windows, I wouldn't lose a lot of sleep over it.

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


[clang] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Paul T Robinson via cfe-commits

pogo59 wrote:

I have no stake in Apple/Swift, but for myself, `cmd` is the natural shell to 
use on Windows. (When I install Visual Studio, it creates a widget that brings 
up a `cmd` shell with the right environment. I'm not aware of a similar widget 
for PowerShell.) While I rarely try to copy-paste from a `lit` dump into `cmd` 
(the commands are generally too full of long paths to temp locations to work 
well) I think it would be good (but not mandatory) for that copy-paste to 
actually work.

Like others have said, I had not really grokked that Windows defaults to the 
internal shell, although just this week I tripped over a behavioral difference 
in how `diff` works in the two environments (not related to your patches). So, 
if there seems to be benefit to making the external shell Just Not Work on 
Windows, I wouldn't lose a lot of sleep over it.

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits


@@ -154,46 +146,158 @@ class CompilerInvocationValueBase {
   PreprocessorOutputOptions PreprocessorOutputOpts;
 
 public:
-  MigratorOptions &getMigratorOpts() { return MigratorOpts; }
+  // clang-format off
   const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
-
-  CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
   const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
+  const DependencyOutputOptions &getDependencyOutputOpts() const { return 
DependencyOutputOpts; }
+  const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
+  const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
+  const PreprocessorOutputOptions &getPreprocessorOutputOpts() const { return 
PreprocessorOutputOpts; }
+  // clang-format on
+};
+} // namespace CompilerInvocationDetail
 
-  DependencyOutputOptions &getDependencyOutputOpts() {
-return DependencyOutputOpts;
-  }
+struct CompilerInvocationBase : CompilerInvocationDetail::RefBase,
+CompilerInvocationDetail::ValBase {
+  CompilerInvocationBase() = default;
 
-  const DependencyOutputOptions &getDependencyOutputOpts() const {
-return DependencyOutputOpts;
-  }
+  CompilerInvocationBase(const CompilerInvocationBase &X, DeepCopy)
+  : RefBase(X, DeepCopy{}), ValBase(X) {}
 
-  FileSystemOptions &getFileSystemOpts() { return FileSystemOpts; }
+  CompilerInvocationBase(const CompilerInvocationBase &X, ShallowCopy)
+  : RefBase(X, ShallowCopy{}), ValBase(X) {}
 
-  const FileSystemOptions &getFileSystemOpts() const {
-return FileSystemOpts;
+  CompilerInvocationBase &assign(const CompilerInvocationBase &X, DeepCopy) {
+RefBase::assign(X, DeepCopy{});
+ValBase::operator=(X);
+return *this;
   }
 
-  FrontendOptions &getFrontendOpts() { return FrontendOpts; }
-  const FrontendOptions &getFrontendOpts() const { return FrontendOpts; }
-
-  PreprocessorOutputOptions &getPreprocessorOutputOpts() {
-return PreprocessorOutputOpts;
+  CompilerInvocationBase &assign(const CompilerInvocationBase &X, ShallowCopy) 
{
+RefBase::assign(X, ShallowCopy{});
+ValBase::operator=(X);
+return *this;
   }
 
-  const PreprocessorOutputOptions &getPreprocessorOutputOpts() const {
-return PreprocessorOutputOpts;
+  using StringAllocator = llvm::function_ref;
+  /// Generate cc1-compatible command line arguments from this instance.
+  ///
+  /// \param [out] Args - The generated arguments. Note that the caller is
+  /// responsible for inserting the path to the clang executable and "-cc1" if
+  /// desired.
+  /// \param SA - A function that given a Twine can allocate storage for a 
given
+  /// command line argument and return a pointer to the newly allocated string.
+  /// The returned pointer is what gets appended to Args.
+  void generateCC1CommandLine(llvm::SmallVectorImpl &Args,
+  StringAllocator SA) const {
+generateCC1CommandLine([&](const Twine &Arg) {
+  // No need to allocate static string literals.
+  Args.push_back(Arg.isSingleStringLiteral()
+ ? Arg.getSingleStringRef().data()
+ : SA(Arg));
+});
   }
+
+  using ArgumentConsumer = llvm::function_ref;
+  /// Generate cc1-compatible command line arguments from this instance.
+  ///
+  /// \param Consumer - Callback that gets invoked for every single generated
+  /// command line argument.
+  void generateCC1CommandLine(ArgumentConsumer Consumer) const;
+
+  /// Generate cc1-compatible command line arguments from this instance,
+  /// wrapping the result as a std::vector.
+  ///
+  /// This is a (less-efficient) wrapper over generateCC1CommandLine().
+  std::vector getCC1CommandLine() const;
+
+  /// Generate command line options from DiagnosticOptions.
+  static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts,
+ ArgumentConsumer Consumer,
+ bool DefaultDiagColor);
+
+  /// Generate command line options from LangOptions.
+  static void GenerateLangArgs(const LangOptions &Opts,
+   ArgumentConsumer Consumer, const llvm::Triple 
&T,
+   InputKind IK);
+
+  // Generate command line options from CodeGenOptions.
+  static void GenerateCodeGenArgs(const CodeGenOptions &Opts,
+  ArgumentConsumer Consumer,
+  const llvm::Triple &T,
+  const std::string &OutputFile,
+  const LangOptions *LangOpts);
 };
 
 /// Helper class for holding the data necessary to invoke the compiler.
 ///
 /// This class is designed to represent an abstract "invocation" of the
 /// compiler, including data such as the include paths, the code generation
 /// options, the warning flags, and so on.
-class CompilerInvocation : public CompilerInvocationR

[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

2023-09-07 Thread Björn Pettersson via cfe-commits


@@ -51,14 +51,11 @@ struct CodeGenTypeCache {
 llvm::IntegerType *PtrDiffTy;
   };
 
-  /// void* in address space 0
+  /// void*, void** in address space 0
   union {
+llvm::PointerType *UnqualPtrTy;

bjope wrote:

Maybe `OpaquePtrTy` is a better name. But `Unqual` seem to be used in other 
places and I've typically used this instead of `PointerType::getUnqual`. But 
I'm not sure what `unqual` has been denoting originally (a pointer in address 
space zero?).

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits


@@ -123,49 +123,101 @@ static Expected> 
parseToleranceOption(StringRef Arg) {
 }
 
 
//===--===//
-// Initialization.
+// Storage details.
 
//===--===//
 
-CompilerInvocationRefBase::CompilerInvocationRefBase()
-: LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
-  DiagnosticOpts(new DiagnosticOptions()),
-  HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()),
-  AnalyzerOpts(new AnalyzerOptions()) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-const CompilerInvocationRefBase &X)
-: LangOpts(new LangOptions(X.getLangOpts())),
-  TargetOpts(new TargetOptions(X.getTargetOpts())),
-  DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-  HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
-  AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-CompilerInvocationRefBase &&X) = default;
-
-CompilerInvocationRefBase &
-CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
-  LangOpts.swap(X.LangOpts);
-  TargetOpts.swap(X.TargetOpts);
-  DiagnosticOpts.swap(X.DiagnosticOpts);
-  HeaderSearchOpts.swap(X.HeaderSearchOpts);
-  PreprocessorOpts.swap(X.PreprocessorOpts);
-  AnalyzerOpts.swap(X.AnalyzerOpts);
+namespace clang::CompilerInvocationDetail {
+namespace {
+template  std::shared_ptr make_shared(const T &X) {

jansvoboda11 wrote:

Because `std::make_shared(const T&)` doesn't deduce the return type as 
`std::shared_ptr`, so you need to specify `T` explicitly. I find this super 
verbose, so this utility is here to support invoking the copy constructor of 
`T` without repeating the type.

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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" checker. (PR #65189)

2023-09-07 Thread via cfe-commits

https://github.com/adriannistor edited 
https://github.com/llvm/llvm-project/pull/65189
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

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


@@ -51,14 +51,11 @@ struct CodeGenTypeCache {
 llvm::IntegerType *PtrDiffTy;
   };
 
-  /// void* in address space 0
+  /// void*, void** in address space 0
   union {
+llvm::PointerType *UnqualPtrTy;

jrtc27 wrote:

Not qualified (c.f. QualType)

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits


@@ -123,49 +123,101 @@ static Expected> 
parseToleranceOption(StringRef Arg) {
 }
 
 
//===--===//
-// Initialization.
+// Storage details.
 
//===--===//
 
-CompilerInvocationRefBase::CompilerInvocationRefBase()
-: LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
-  DiagnosticOpts(new DiagnosticOptions()),
-  HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()),
-  AnalyzerOpts(new AnalyzerOptions()) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-const CompilerInvocationRefBase &X)
-: LangOpts(new LangOptions(X.getLangOpts())),
-  TargetOpts(new TargetOptions(X.getTargetOpts())),
-  DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-  HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
-  AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-CompilerInvocationRefBase &&X) = default;
-
-CompilerInvocationRefBase &
-CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
-  LangOpts.swap(X.LangOpts);
-  TargetOpts.swap(X.TargetOpts);
-  DiagnosticOpts.swap(X.DiagnosticOpts);
-  HeaderSearchOpts.swap(X.HeaderSearchOpts);
-  PreprocessorOpts.swap(X.PreprocessorOpts);
-  AnalyzerOpts.swap(X.AnalyzerOpts);
+namespace clang::CompilerInvocationDetail {
+namespace {
+template  std::shared_ptr make_shared(const T &X) {
+  return std::make_shared(X);
+}
+
+template  llvm::IntrusiveRefCntPtr makeIntrusiveRefCnt(const T &X) 
{
+  return llvm::makeIntrusiveRefCnt(X);
+}
+} // namespace
+
+RefBase::RefBase()
+: LangOpts(std::make_shared()),
+  TargetOpts(std::make_shared()),
+  DiagnosticOpts(llvm::makeIntrusiveRefCnt()),
+  HeaderSearchOpts(std::make_shared()),
+  PreprocessorOpts(std::make_shared()),
+  AnalyzerOpts(llvm::makeIntrusiveRefCnt()) {}
+
+RefBase::RefBase(const RefBase &X, DeepCopy)

jansvoboda11 wrote:

I think it would, it'd reduce the boilerplate, and the extra 
default-construction of the smart pointers is a non-issue.

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #65407)

2023-09-07 Thread Ulrich Weigand via cfe-commits

uweigand wrote:

SystemZ back-end changes LGTM.Additional reviews as to the Clang and time 
support changes would be appreciated.

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


[clang] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-07 Thread Ronan Keryell via cfe-commits

https://github.com/keryell edited 
https://github.com/llvm/llvm-project/pull/65539
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> When I install Visual Studio, it creates a widget that brings up a cmd shell 
> with the right environment. I'm not aware of a similar widget for PowerShell.

At least in VS 2022, there is a `Developer PowerShell for VS 2022` in Start 
menu beside the usual `x64 Native Tools Command Prompt for VS 2022`. It was 
there in 2019, but IIRC dropped you into x86 toolchain.

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


[PATCH] D141714: Fix ast print of variables with attributes

2023-09-07 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/DeclPrinter.cpp:312
+  // printing on the left side for readbility.
+else if (const VarDecl *VD = dyn_cast(D);
+   VD && VD->getInit() &&

While compiling this, I discovered that the lack of curley braces on the `else 
if (canPrintOnLeftSide(A))` means that this `else-if` is actually an else to 
THAT instead, despite its indention (which implies it should be associated with 
the `if (const FunctionDecl...`).

Which is it?  I presume the indenting is what you mean, but it hasn't been 
tested in a way that matters.  Can you add a test that validates the var-decl 
printing on the LHS ONLY happens when it 'can' print on the LHS?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-09-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

The libc++ changes are reasonable. We could discuss more around how to handle 
C++03 in `__libcpp_is_constant_evaluated` but I don't think it's worth delaying 
this patch for that.




Comment at: libcxx/include/__type_traits/is_constant_evaluated.h:31
+  return false;
+#endif
 }

hazohelet wrote:
> philnik wrote:
> > Mordante wrote:
> > > hazohelet wrote:
> > > > Mordante wrote:
> > > > > Why is this needed? Does this mean the builtin will fail in C++03 
> > > > > mode?
> > > > `__libcpp_is_constant_evaluated` always returns false under C++03 or 
> > > > earlier, where constexpr isn't available. This is a fix to run libc++ 
> > > > tests without seeing warnings from clang with this patch.
> > > > (Live demo: https://godbolt.org/z/oszebM5o5)
> > > I see can you add a comment in that regard? To me it looks like the 
> > > builtin fails in C++03, where returning false indeed is always the right 
> > > answer.
> > https://godbolt.org/z/bafeeY7b7 shows that 
> > `__builtin_is_constant_evaluated()` doesn't always return false in C++03, 
> > so this change seems wrong to me.
> This is NFC.
> The problem is that `__libcpp_is_constant_evaluated()` has different 
> semantics from `__builtin_is_constant_evaluated()` in C++03.
> The cause of this tautological-falsity here is whether 
> `__libcpp_is_constant_evaluated()` is `constexpr`-qualified or not.
> `_LIBCPP_CONSTEXPR` macro expands to `constexpr` since C++11, but in 
> pre-C++11 mode, it expands to nothing.
> So in C++03 mode this function is something like `bool 
> __libcpp_is_constant_evaluated() { return __builtin_is_constant_evaluated(); 
> }`, where it is tautologically-false because it is not constexpr-qualified.
> 
> As you mentioned, `__builtin_is_constant_evaluated` does not change its 
> semantics depending on C++ versions.
> However, `__libcpp_is_constant_evaluated()` always returns false in C++03 as 
> in https://godbolt.org/z/oszebM5o5
This explanation makes sense to me. I think it's reasonable to return `false` 
unconditionally in C++03 mode.


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

https://reviews.llvm.org/D155064

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


[clang] [clang][CodeGen] Simplify code based on opaque pointers (PR #65624)

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


@@ -51,14 +51,11 @@ struct CodeGenTypeCache {
 llvm::IntegerType *PtrDiffTy;
   };
 
-  /// void* in address space 0
+  /// void*, void** in address space 0
   union {
+llvm::PointerType *UnqualPtrTy;

jrtc27 wrote:

(Presumably the IR type's nomenclature has its origins in C's language)

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


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Ben Langmuir via cfe-commits


@@ -123,49 +123,101 @@ static Expected> 
parseToleranceOption(StringRef Arg) {
 }
 
 
//===--===//
-// Initialization.
+// Storage details.
 
//===--===//
 
-CompilerInvocationRefBase::CompilerInvocationRefBase()
-: LangOpts(new LangOptions()), TargetOpts(new TargetOptions()),
-  DiagnosticOpts(new DiagnosticOptions()),
-  HeaderSearchOpts(new HeaderSearchOptions()),
-  PreprocessorOpts(new PreprocessorOptions()),
-  AnalyzerOpts(new AnalyzerOptions()) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-const CompilerInvocationRefBase &X)
-: LangOpts(new LangOptions(X.getLangOpts())),
-  TargetOpts(new TargetOptions(X.getTargetOpts())),
-  DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-  HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-  PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())),
-  AnalyzerOpts(new AnalyzerOptions(X.getAnalyzerOpts())) {}
-
-CompilerInvocationRefBase::CompilerInvocationRefBase(
-CompilerInvocationRefBase &&X) = default;
-
-CompilerInvocationRefBase &
-CompilerInvocationRefBase::operator=(CompilerInvocationRefBase X) {
-  LangOpts.swap(X.LangOpts);
-  TargetOpts.swap(X.TargetOpts);
-  DiagnosticOpts.swap(X.DiagnosticOpts);
-  HeaderSearchOpts.swap(X.HeaderSearchOpts);
-  PreprocessorOpts.swap(X.PreprocessorOpts);
-  AnalyzerOpts.swap(X.AnalyzerOpts);
+namespace clang::CompilerInvocationDetail {
+namespace {
+template  std::shared_ptr make_shared(const T &X) {

benlangmuir wrote:

These seem more confusing than helpful; I would either remove them or rename 
them `make_shared_copy` or similar.

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


[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/65632:

As noticed in D158846, the Solaris driver deviates from other targets in that 
it links every executable with `-lm`, but doesn't for shared objects. For C 
code, this is unnecessary, while for C++ `libm` is always needed, even for 
shared objects.

This patch fixes this by following the `Gnu.cpp` precedent.  It adjusts the 
`solaris-ld.c` test accordingly, adding some more tests.

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

>From 929f162e99118ecea75684975448d72cfe46b58f Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 18:10:01 +0200
Subject: [PATCH] [Driver] Fix linking with -lm on Solaris

As noticed in D158846, the Solaris driver deviates from other targets in
that it links every executable with `-lm`, but doesn't for shared objects.
For C code, this is unnecessary, while for C++ `libm` is always needed,
even for shared objects.

This patch fixes this by following the `Gnu.cpp` precedent.  It adjusts the
`solaris-ld.c` test accordingly, adding some more tests.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp |  9 ++---
 clang/test/Driver/solaris-ld.c  | 21 -
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 4e002e348eac5f..36fe12608eefc6 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -87,6 +87,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
+  const Driver &D = getToolChain().getDriver();
   const bool IsPIE = getPIE(Args, getToolChain());
   ArgStringList CmdArgs;
   bool LinkerIsGnuLd = isLinkerGnuLd(getToolChain(), Args);
@@ -217,8 +218,11 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
-if (getToolChain().ShouldLinkCXXStdlib(Args))
-  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+if (D.CCCIsCXX()) {
+  if (getToolChain().ShouldLinkCXXStdlib(Args))
+getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
@@ -239,7 +243,6 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-lgcc");
-  CmdArgs.push_back("-lm");
 }
 const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {
diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 231e14966ea42f..09e6e8b4f07cf9 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -26,7 +26,6 @@
 // CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
-// CHECK-LD-SPARC32-SAME: "-lm"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtend.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -49,7 +48,6 @@
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
-// CHECK-LD-SPARC64-SAME: "-lm"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtend.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crtn.o"
 
@@ -72,7 +70,6 @@
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
-// CHECK-LD-X32-SAME: "-lm"
 // CHECK-LD-X32-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtend.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -96,7 +93,6 @@
 // CHECK-LD-X64-SAME: "-lgcc_s"
 // CHECK-LD-X64-SAME: "-lc"
 // CHECK-LD-X64-SAME: "-lgcc"
-// CHECK-LD-X64-SAME: "-lm"
 // CHECK-LD-X64-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtend.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crtn.o"
 
@@ -110,7 +106,22 @@
 // CHECK-SPARC32-SHARED-SAME: "-lgcc_s"
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
-// CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// Check that libm is only linked with clang++.
+// RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | 

[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158626: [AArch64] Add missing vrnd intrinsics

2023-09-07 Thread Max Iyengar via Phabricator via cfe-commits
miyengar updated this revision to Diff 556170.
miyengar added a comment.

Moved pattern from `AArchInstrFormats.td` to `AArchInstrInfo.td`


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

https://reviews.llvm.org/D158626

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-v8.5a-neon-frint3264-intrinsic.c
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/v8.5a-neon-frint3264-intrinsic.ll

Index: llvm/test/CodeGen/AArch64/v8.5a-neon-frint3264-intrinsic.ll
===
--- llvm/test/CodeGen/AArch64/v8.5a-neon-frint3264-intrinsic.ll
+++ llvm/test/CodeGen/AArch64/v8.5a-neon-frint3264-intrinsic.ll
@@ -81,3 +81,85 @@
   %val = tail call <4 x float> @llvm.aarch64.neon.frint64z.v4f32(<4 x float> %a)
   ret <4 x float> %val
 }
+
+declare <1 x double> @llvm.aarch64.neon.frint32x.v1f64(<1 x double>)
+declare <2 x double> @llvm.aarch64.neon.frint32x.v2f64(<2 x double>)
+declare <1 x double> @llvm.aarch64.neon.frint32z.v1f64(<1 x double>)
+declare <2 x double> @llvm.aarch64.neon.frint32z.v2f64(<2 x double>)
+
+define dso_local <1 x double> @t_vrnd32x_f64(<1 x double> %a) {
+; CHECK-LABEL: t_vrnd32x_f64:
+; CHECK: frint32x d0, d0
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <1 x double> @llvm.aarch64.neon.frint32x.v1f64(<1 x double> %a)
+  ret <1 x double> %val
+}
+
+define dso_local <2 x double> @t_vrnd32xq_f64(<2 x double> %a) {
+; CHECK-LABEL: t_vrnd32xq_f64:
+; CHECK: frint32x v0.2d, v0.2d
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <2 x double> @llvm.aarch64.neon.frint32x.v2f64(<2 x double> %a)
+  ret <2 x double> %val
+}
+
+define dso_local <1 x double> @t_vrnd32z_f64(<1 x double> %a) {
+; CHECK-LABEL: t_vrnd32z_f64:
+; CHECK: frint32z d0, d0
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <1 x double> @llvm.aarch64.neon.frint32z.v1f64(<1 x double> %a)
+  ret <1 x double> %val
+}
+
+define dso_local <2 x double> @t_vrnd32zq_f64(<2 x double> %a) {
+; CHECK-LABEL: t_vrnd32zq_f64:
+; CHECK: frint32z v0.2d, v0.2d
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <2 x double> @llvm.aarch64.neon.frint32z.v2f64(<2 x double> %a)
+  ret <2 x double> %val
+}
+
+declare <1 x double> @llvm.aarch64.neon.frint64x.v1f64(<1 x double>)
+declare <2 x double> @llvm.aarch64.neon.frint64x.v2f64(<2 x double>)
+declare <1 x double> @llvm.aarch64.neon.frint64z.v1f64(<1 x double>)
+declare <2 x double> @llvm.aarch64.neon.frint64z.v2f64(<2 x double>)
+
+define dso_local <1 x double> @t_vrnd64x_f64(<1 x double> %a) {
+; CHECK-LABEL: t_vrnd64x_f64:
+; CHECK: frint64x d0, d0
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <1 x double> @llvm.aarch64.neon.frint64x.v1f64(<1 x double> %a)
+  ret <1 x double> %val
+}
+
+define dso_local <2 x double> @t_vrnd64xq_f64(<2 x double> %a) {
+; CHECK-LABEL: t_vrnd64xq_f64:
+; CHECK: frint64x v0.2d, v0.2d
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <2 x double> @llvm.aarch64.neon.frint64x.v2f64(<2 x double> %a)
+  ret <2 x double> %val
+}
+
+define dso_local <1 x double> @t_vrnd64z_f64(<1 x double> %a) {
+; CHECK-LABEL: t_vrnd64z_f64:
+; CHECK: frint64z d0, d0
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <1 x double> @llvm.aarch64.neon.frint64z.v1f64(<1 x double> %a)
+  ret <1 x double> %val
+}
+
+define dso_local <2 x double> @t_vrnd64zq_f64(<2 x double> %a) {
+; CHECK-LABEL: t_vrnd64zq_f64:
+; CHECK: frint64z v0.2d, v0.2d
+; CHECK-NEXT:ret
+entry:
+  %val = tail call <2 x double> @llvm.aarch64.neon.frint64z.v2f64(<2 x double> %a)
+  ret <2 x double> %val
+}
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -4446,6 +4446,16 @@
   defm FRINT64X : FRIntNNT<0b11, "frint64x", int_aarch64_frint64x>;
 } // HasFRInt3264
 
+// Pattern to convert 1x64 vector intrinsics to equivalent scalar instructions
+def : Pat<(v1f64 (int_aarch64_neon_frint32z (v1f64 FPR64:$Rn))),
+  (FRINT32ZDr FPR64:$Rn)>;
+def : Pat<(v1f64 (int_aarch64_neon_frint64z (v1f64 FPR64:$Rn))),
+  (FRINT64ZDr FPR64:$Rn)>;
+def : Pat<(v1f64 (int_aarch64_neon_frint32x (v1f64 FPR64:$Rn))),
+  (FRINT32XDr FPR64:$Rn)>;
+def : Pat<(v1f64 (int_aarch64_neon_frint64x (v1f64 FPR64:$Rn))),
+  (FRINT64XDr FPR64:$Rn)>;
+
 // Emitting strict_lrint as two instructions is valid as any exceptions that
 // occur will happen in exactly one of the instructions (e.g. if the input is
 // not an integer the inexact exception will happen in the FRINTX but not then
Index: clang/test/CodeGen/aarch64-v8.5a-neon-frint3264-intrinsic.c
===
--- clang/test/CodeGen/aarch64-v8.5a-neon-frint3264-intrinsic.c
+++ clang/test/CodeGen/aarch64-v8.5a-neon-frint3264-intrinsic.c
@@ -62,3

[PATCH] D158626: [AArch64] Add missing vrnd intrinsics

2023-09-07 Thread Max Iyengar via Phabricator via cfe-commits
miyengar added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:6309
+
+  def : Pat<(v1f64 (OpNode (v1f64 FPR64:$Rn))),
+   (!cast(NAME # Dr) FPR64:$Rn)>;

dmgreen wrote:
> miyengar wrote:
> > dmgreen wrote:
> > > I think the instructions in this multiclass are the vector variants. Can 
> > > the pattern be moved to the FRIntNNT/SingleOperandFPNo16 class?
> > Thanks for the comment. I have tried to do this, but have run into a 
> > problem:
> > 
> > This pattern targets the LLVM internal intrinsic: 
> > `int_aarch64_neon_frint***_v1f64`, as referenced in `AArch64InstrInfo.td`: 
> > 
> > ```
> > defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z", int_aarch64_neon_frint32z>;
> > ```
> > It pattern matches 'v1f64' to 'Dr', which corresponds to a scalar 
> > instruction defined in FRIntNNT/SingleOperandFPNo16 - I.e. it is matching 
> > the vector variant to the scalar variant.
> > 
> > Moving the pattern to FRIntNNT results in an error "Cannot select: 
> > intrinsic %llvm.aarch64.neon.frint64x" as FRIntNNT is designed to match the 
> > intrinsics whose name does not contain "neon". Since the current patch 
> > deals specifically with the neon variant, I don't see an uncomplicated way 
> > to modify FRIntNNT to accommodate both variants of such intrinsic (neon and 
> > vanilla).
> > 
> > I have moved the pattern from SIMDTwoVectorSD to FRIntNNTVector though 
> > which is hopefully a better place to put it.
> > 
> > Does this seem like a sensible solution? Thanks!
> I see, Because there is a difference between int_aarch64_frint32z and 
> int_aarch64_neon_frint32z.
> 
> Could you pass int_aarch64_neon_frint32z to FRIntNNT too, or make them free 
> patterns in AArch64InstrInfo.td? Otherwise this is using the class to 
> generate vector variants of FRINT32Z to also generate the scalar FRINT32ZDr 
> instruction too. It likely doesn't matter a huge amount, but it feels like it 
> breaks the encapsulation of the FRIntNNTVector class.
Ah okay, this makes sense, thank you!

I have moved the patterns from FRIntNNTVector to make them free patterns in 
AArch64InstrInfo.td instead - this should preserve the encapsulation of the 
FRIntNNTVector class. 


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

https://reviews.llvm.org/D158626

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


[PATCH] D92361: [trivial-abi] Support types without a copy or move constructor.

2023-09-07 Thread Louis Dionne via Phabricator via cfe-commits
ldionne resigned from this revision.
ldionne added a subscriber: philnik.
ldionne added a comment.
Herald added a subscriber: wangpc.
Herald added a project: All.

@philnik you might be interested by this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92361

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


[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay approved this pull request.


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


[PATCH] D148381: [Clang] Add counted_by attribute

2023-09-07 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Patch LGTM; just want moar tests.

---

Mind adding a test for

  #if !__has_attribute(counted_by)
  #error "has attribute broken"
  #endif




Comment at: clang/test/CodeGen/attr-counted-by.c:2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O2 -Wall 
-fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 
-emit-llvm -o - %s | FileCheck %s
+

Can you add another run line without the `-fsanitize` flags set, and use 2 
different `--check-prefixes` for the two RUN lines?  I'd be curious to see the 
differences in codegen between those set or not.  I assume this attribute 
should affect codegen even with all of those disabled (maybe trapping instead 
of libcalling into ubsan runtime).  I think update_cc_test_checks should be 
able to handle that.



Comment at: clang/test/CodeGen/attr-counted-by.c:39-51
+// CHECK-LABEL: define dso_local void @test2(
+// CHECK-SAME: ptr noundef [[P:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[COUNT:%.*]] = getelementptr inbounds 
[[STRUCT_ANNOTATED:%.*]], ptr [[P]], i64 0, i32 1
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[COUNT]], align 8, !tbaa 
[[TBAA2]]
+// CHECK-NEXT:[[TMP1:%.*]] = shl i32 [[TMP0]], 2
+// CHECK-NEXT:[[TMP2:%.*]] = zext i32 [[TMP1]] to i64

Is the call to `func` is unnecessary for this test or can we just `return 
__builtin_dynamic_object_size(p->array, 1)`?



Comment at: clang/test/CodeGen/attr-counted-by.c:67-73
+// CHECK-NEXT:br i1 [[TMP4]], label [[TRAP:%.*]], label [[TMP5:%.*]]
+// CHECK:   5:
+// CHECK-NEXT:tail call void @func(i64 noundef [[ADD1]]) #[[ATTR5]]
+// CHECK-NEXT:ret void
+// CHECK:   trap:
+// CHECK-NEXT:tail call void @llvm.trap() #[[ATTR4]]
+// CHECK-NEXT:unreachable

What is the intent of this test? Mind adding a comment?

In particular, it's not clear to my //why// this case should conditionally 
trap, seeing as the dynamically allocated object's `array` field is yet to be 
accessed in this example.  What am I missing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148381

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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits

https://github.com/adriannistor edited 
https://github.com/llvm/llvm-project/pull/65189
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-07 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

What about an option that just redirects the PrintIRInstrumentation output to 
files instead of stderr? The files can be something like `$N-$modulename.ll` 
where `$N` is an int that increments.

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


[clang-tools-extra] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-07 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

What about an option that just redirects the PrintIRInstrumentation output to 
files instead of stderr? The files can be something like `$N-$modulename.ll` 
where `$N` is an int that increments.

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


[PATCH] D159103: [Driver][HLSL] Improve diagnostics for invalid shader model and stage

2023-09-07 Thread Justin Bogner via Phabricator via cfe-commits
bogner added a comment.

Ping. Please take another look when you get a chance, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159103

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


[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

2023-09-07 Thread Jerin Philip via cfe-commits

https://github.com/jerinphilip created 
https://github.com/llvm/llvm-project/pull/65638:

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

Additionally accounts for `_AlignAs` when constructing Attribute Form. This
breaks a few tests because `IsAlignAs` is coupled with `CXX11Attribute`.
Decoupling `isAlignas()` one level up gets the broken tests back functional.

Once an instance of `_AlignAs` existing in source is recorded properly, it is
possible to narrow the case at a later stage to stream in a solution.  

Based on https://reviews.llvm.org/D141177. 

>From 941af68ab8dad68ed8df65f6e0559476f137bfe2 Mon Sep 17 00:00:00 2001
From: Jerin Philip 
Date: Sat, 19 Aug 2023 16:43:53 +0530
Subject: [PATCH 1/6] Fix `Form` to recognize `_Alignas` in addition to
 `alignas`

---
 clang/include/clang/Basic/AttributeCommonInfo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index e57adc4bf5b99a2..36f4eb885cf12f8 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -94,7 +94,7 @@ class AttributeCommonInfo {
   IsRegularKeywordAttribute(IsRegularKeywordAttribute) {}
 constexpr Form(tok::TokenKind Tok)
 : SyntaxUsed(AS_Keyword), SpellingIndex(SpellingNotCalculated),
-  IsAlignas(Tok == tok::kw_alignas),
+  IsAlignas(Tok == tok::kw_alignas || Tok == tok::kw__Alignas),
   IsRegularKeywordAttribute(tok::isRegularKeywordAttribute(Tok)) {}
 
 Syntax getSyntax() const { return Syntax(SyntaxUsed); }

>From 8c0bfe350dfa2d4d24988eb544f5c1a9eb1aec6d Mon Sep 17 00:00:00 2001
From: Jerin Philip 
Date: Thu, 7 Sep 2023 18:53:57 +0530
Subject: [PATCH 2/6] Avoid mixing `isCXX11Attribute` with `isAlignAs`

---
 clang/include/clang/Basic/AttributeCommonInfo.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 36f4eb885cf12f8..669227589dfacd5 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -186,14 +186,14 @@ class AttributeCommonInfo {
   bool isGNUScope() const;
   bool isClangScope() const;
 
-  bool isCXX11Attribute() const { return SyntaxUsed == AS_CXX11 || IsAlignas; }
+  bool isCXX11Attribute() const { return SyntaxUsed == AS_CXX11; }
 
   bool isC23Attribute() const { return SyntaxUsed == AS_C23; }
 
   /// The attribute is spelled [[]] in either C or C++ mode, including standard
   /// attributes spelled with a keyword, like alignas.
   bool isStandardAttributeSyntax() const {
-return isCXX11Attribute() || isC23Attribute();
+return isCXX11Attribute() || isC23Attribute() || IsAlignas;
   }
 
   bool isGNUAttribute() const { return SyntaxUsed == AS_GNU; }

>From 8f699d5dfe62b2a1eb1f67f37ffa3d4ba1f2bfce Mon Sep 17 00:00:00 2001
From: Jerin Philip 
Date: Thu, 7 Sep 2023 19:15:03 +0530
Subject: [PATCH 3/6] Fix diagnostic warning post `isAlignAs` decoupling

---
 clang/include/clang/Basic/AttributeCommonInfo.h | 2 +-
 clang/lib/Parse/ParseDecl.cpp   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/AttributeCommonInfo.h 
b/clang/include/clang/Basic/AttributeCommonInfo.h
index 669227589dfacd5..f1e3325d44f0e1a 100644
--- a/clang/include/clang/Basic/AttributeCommonInfo.h
+++ b/clang/include/clang/Basic/AttributeCommonInfo.h
@@ -186,8 +186,8 @@ class AttributeCommonInfo {
   bool isGNUScope() const;
   bool isClangScope() const;
 
+  bool isAlignas() const { return IsAlignas; }
   bool isCXX11Attribute() const { return SyntaxUsed == AS_CXX11; }
-
   bool isC23Attribute() const { return SyntaxUsed == AS_C23; }
 
   /// The attribute is spelled [[]] in either C or C++ mode, including standard
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 4a9f2caf654713e..f91141f7cd39cbf 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3405,8 +3405,8 @@ void Parser::ParseDeclarationSpecifiers(
   else {
 // Reject C++11 / C23 attributes that aren't type attributes.
 for (const ParsedAttr &PA : attrs) {
-  if (!PA.isCXX11Attribute() && !PA.isC23Attribute() &&
-  !PA.isRegularKeywordAttribute())
+  if (!PA.isAlignas() && !PA.isCXX11Attribute() &&
+  !PA.isC23Attribute() && !PA.isRegularKeywordAttribute())
 continue;
   if (PA.getKind() == ParsedAttr::UnknownAttribute)
 // We will warn about the unknown attribute elsewhere (in

>From e7ddd755f1a873421809a05a4d5d999b7a15f62e Mon Sep 17 00:00:00 2001
From: Jerin Philip 
Date: Sat, 19 Aug 2023 16:44:51 +0530
Subject: [PATCH 4/6] Add attribute-ignored diagnostic warning variant

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 6 +-
 1 file change

[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

2023-09-07 Thread Jerin Philip via cfe-commits

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


[clang] [clang] Improve `_Alignas` on a `struct` declaration diagnostic (PR #65638)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65638
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-07 Thread Nuri Amari via cfe-commits

NuriAmari wrote:

> What about an option that just redirects the PrintIRInstrumentation output to 
> files instead of stderr? The files can be something like `$N-$modulename.ll` 
> where `$N` is an int that increments.

Yeah that's more or less what I'm working on now. My plan is:

- Add a flag that provides a directory to write files to
- If that flag is passed, write files of the structure 
`$N-$modulename-$passname-(before|after).ll` into that directory instead of 
writing to stderr
- If you pass both `-print-after=foo` and `-print-before=foo` the dump files 
for a particular run of Foo on a particular unit of IR should match except for 
the before / after suffix.

This should be relatively easy to implement in the old pass manager as well.

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


[clang] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-07 Thread Nuri Amari via cfe-commits

NuriAmari wrote:

> What about an option that just redirects the PrintIRInstrumentation output to 
> files instead of stderr? The files can be something like `$N-$modulename.ll` 
> where `$N` is an int that increments.

Yeah that's more or less what I'm working on now. My plan is:

- Add a flag that provides a directory to write files to
- If that flag is passed, write files of the structure 
`$N-$modulename-$passname-(before|after).ll` into that directory instead of 
writing to stderr
- If you pass both `-print-after=foo` and `-print-before=foo` the dump files 
for a particular run of Foo on a particular unit of IR should match except for 
the before / after suffix.

This should be relatively easy to implement in the old pass manager as well.

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


[PATCH] D155064: [clang][SemaCXX] Diagnose tautological uses of consteval if and is_constant_evaluated

2023-09-07 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.

LGTM, thanks!


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

https://reviews.llvm.org/D155064

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


[clang-tools-extra] [lit] Are all RUN lines skipped in windows cmd? (PR #65242)

2023-09-07 Thread Joel E. Denny via cfe-commits

jdenny-ornl wrote:

> I have no stake in Apple/Swift, but for myself, `cmd` is the natural shell to 
> use on Windows. (When I install Visual Studio, it creates a widget that 
> brings up a `cmd` shell with the right environment. I'm not aware of a 
> similar widget for PowerShell.) While I rarely try to copy-paste from a `lit` 
> dump into `cmd` (the commands are generally too full of long paths to temp 
> locations to work well) I think it would be good (but not mandatory) for that 
> copy-paste to actually work.
> 
> Like others have said, I had not really grokked that Windows defaults to the 
> internal shell, although just this week I tripped over a behavioral 
> difference in how `diff` works in the two environments (not related to your 
> patches). So, if there seems to be benefit to making the external shell Just 
> Not Work on Windows, I wouldn't lose a lot of sleep over it.

In case it isn't clear, there are two somewhat orthogonal issues here:

- This PR is about whether lit can execute RUN lines in `cmd`.  That does not 
appear to have worked since April, 2022. 
- The copy-paste issue is about whether lit can print RUN lines in a form that 
the user can easily copy to `cmd`.  For RUN lines that were written for lit's 
internal shell, that might require lit to *translate* the RUN lines to a form 
compatible with `cmd`.  I say might because I don't have much experience there. 
 The `diff` example above sounds like an example.



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


[clang] 1e6b0df - [Driver] Fix linking with -lm on Solaris (#65632)

2023-09-07 Thread via cfe-commits

Author: Rainer Orth
Date: 2023-09-07T19:14:55+02:00
New Revision: 1e6b0df3503567488e7df2d574c90f8f31a001a2

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

LOG: [Driver] Fix linking with -lm on Solaris (#65632)

As noticed in D158846, the Solaris driver deviates from other targets in
that it links every executable with `-lm`, but doesn't for shared
objects. For C code, this is unnecessary, while for C++ `libm` is always
needed, even for shared objects.

This patch fixes this by following the `Gnu.cpp` precedent. It adjusts
the `solaris-ld.c` test accordingly, adding some more tests.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 4e002e348eac5f4..36fe12608eefc6c 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -87,6 +87,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
+  const Driver &D = getToolChain().getDriver();
   const bool IsPIE = getPIE(Args, getToolChain());
   ArgStringList CmdArgs;
   bool LinkerIsGnuLd = isLinkerGnuLd(getToolChain(), Args);
@@ -217,8 +218,11 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
options::OPT_r)) {
-if (getToolChain().ShouldLinkCXXStdlib(Args))
-  getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+if (D.CCCIsCXX()) {
+  if (getToolChain().ShouldLinkCXXStdlib(Args))
+getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
@@ -239,7 +243,6 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-lgcc");
-  CmdArgs.push_back("-lm");
 }
 const SanitizerArgs &SA = getToolChain().getSanitizerArgs(Args);
 if (NeedsSanitizerDeps) {

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 231e14966ea42ff..09e6e8b4f07cf91 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -26,7 +26,6 @@
 // CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
-// CHECK-LD-SPARC32-SAME: "-lm"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtend.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -49,7 +48,6 @@
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
-// CHECK-LD-SPARC64-SAME: "-lm"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtend.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crtn.o"
 
@@ -72,7 +70,6 @@
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
-// CHECK-LD-X32-SAME: "-lm"
 // CHECK-LD-X32-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtend.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crtn.o"
 
@@ -96,7 +93,6 @@
 // CHECK-LD-X64-SAME: "-lgcc_s"
 // CHECK-LD-X64-SAME: "-lc"
 // CHECK-LD-X64-SAME: "-lgcc"
-// CHECK-LD-X64-SAME: "-lm"
 // CHECK-LD-X64-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtend.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crtn.o"
 
@@ -110,7 +106,22 @@
 // CHECK-SPARC32-SHARED-SAME: "-lgcc_s"
 // CHECK-SPARC32-SHARED-SAME: "-lc"
 // CHECK-SPARC32-SHARED-NOT: "-lgcc"
-// CHECK-SPARC32-SHARED-NOT: "-lm"
+
+// Check that libm is only linked with clang++.
+// RUN: %clang -### %s --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
+// RUN: %clang -### %s -shared --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc_tree 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NOLIBM %s
+// RUN: %clangxx -### %s --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain="" --sysroot=%S/Inputs/solaris_sparc

[clang] [Driver] Fix linking with -lm on Solaris (PR #65632)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth closed https://github.com/llvm/llvm-project/pull/65632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Reland "[CUDA][HIP] Fix overloading resolution in global variable ini… (PR #65606)

2023-09-07 Thread Artem Belevich via cfe-commits

https://github.com/Artem-B approved this pull request.

LGTM.

I'm still figuring out the github-based workflow. One thing that may be useful 
in the future 
would be to start the pull request branch with the original/reverted commit and 
put the updates into separate commits, so one could see incremental changes, 
similar to what phabricator's "history" was providing.


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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

https://github.com/rorth created 
https://github.com/llvm/llvm-project/pull/65644:

I noticed that `flang-new` cannot link Fortran executables on Solaris since the 
runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase is 
augmented to test for this.

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

>From 31bdd3477d9f54996b71584598bdd75f2cef31db Mon Sep 17 00:00:00 2001
From: Rainer Orth 
Date: Thu, 7 Sep 2023 19:19:32 +0200
Subject: [PATCH] [Driver] Link Flang runtime on Solaris

I noticed that `flang-new` cannot link Fortran executables on Solaris since
the runtime libs are missing.

This patch fixes this, following `Gnu.cpp`.  The `linker-flags.f90` testcase
is augmented to test for this.

Tested on `amd64-pc-solaris2.11`, `sparcv9-sun-solaris2.11`, and
`x86_64-pc-linux-gnu`.
---
 clang/lib/Driver/ToolChains/Solaris.cpp | 8 
 flang/test/Driver/linker-flags.f90  | 1 +
 2 files changed, 9 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 36fe12608eefc6c..252c71d3379eab4 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -223,6 +223,14 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
   CmdArgs.push_back("-lm");
 }
+// Additional linker set-up and flags for Fortran. This is required in 
order
+// to generate executables. As Fortran runtime depends on the C runtime,
+// these dependencies need to be listed before the C runtime below.
+if (D.IsFlangMode()) {
+  addFortranRuntimeLibraryPath(getToolChain(), Args, CmdArgs);
+  addFortranRuntimeLibs(getToolChain(), CmdArgs);
+  CmdArgs.push_back("-lm");
+}
 if (Args.hasArg(options::OPT_fstack_protector) ||
 Args.hasArg(options::OPT_fstack_protector_strong) ||
 Args.hasArg(options::OPT_fstack_protector_all)) {
diff --git a/flang/test/Driver/linker-flags.f90 
b/flang/test/Driver/linker-flags.f90
index 09b8a224df13828..717dcc7775e2126 100644
--- a/flang/test/Driver/linker-flags.f90
+++ b/flang/test/Driver/linker-flags.f90
@@ -4,6 +4,7 @@
 
 ! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target sparc-sun-solaris2.11 %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,GNU
 ! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | 
FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread Rainer Orth via cfe-commits

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


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Link Flang runtime on Solaris (PR #65644)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65644
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Switch declaration of vtable information to be [0 x ptr] (PR #65596)

2023-09-07 Thread Eli Friedman via cfe-commits


@@ -14,8 +14,8 @@ class B : A {
 // NO-AS: @_ZTISt9type_info = external constant ptr
 // AS: @_ZTIi = external addrspace(1) constant ptr addrspace(1)
 // NO-AS: @_ZTIi = external constant ptr
-// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global 
ptr addrspace(1)
-// NO-AS: @_ZTVN10__cxxabiv117__class_type_infoE = external global ptr
+// AS: @_ZTVN10__cxxabiv117__class_type_infoE = external addrspace(1) global 
[0 x ptr]

efriedma-quic wrote:

Maybe this should be `[0 x ptr addrspace(1)]`?  Not sure that makes any 
semantic difference, but it would be more clear.  (So use 
`llvm::ArrayType::get(CGM.GlobalsInt8PtrTy, 0)`.)

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #65407)

2023-09-07 Thread Yusra Syeda via cfe-commits

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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits

https://github.com/adriannistor updated 
https://github.com/llvm/llvm-project/pull/65189:

>From c6d70f6f851f0553e3e83b762618d48744a4f706 Mon Sep 17 00:00:00 2001
From: Adrian Nistor 
Date: Fri, 1 Sep 2023 15:35:59 -0700
Subject: [PATCH 1/3] Adding an initial version of the "Initialized Class
 Members" checker.

The goal of this checker is to eliminate UUM (Use of Uninitialized Memory) bugs 
caused by uninitialized class members.

This checker is different from ProTypeMemberInitCheck in that this checker 
attempts to eliminate UUMs as a bug class, at the expense of false positives.

This checker is WIP. We are incrementally adding features and increasing 
coverage until we get to a shape that is acceptable.
---
 .../clang-tidy/google/CMakeLists.txt  |   1 +
 .../google/CppInitClassMembersCheck.cpp   | 105 ++
 .../google/CppInitClassMembersCheck.h |  51 +
 .../clang-tidy/google/GoogleTidyModule.cpp|   3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   7 ++
 .../checks/google/cpp-init-class-members.rst  |  32 ++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../google/cpp-init-class-members.cpp |  56 ++
 8 files changed, 256 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/google/CppInitClassMembersCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/google/CppInitClassMembersCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/google/cpp-init-class-members.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/google/cpp-init-class-members.cpp

diff --git a/clang-tools-extra/clang-tidy/google/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/google/CMakeLists.txt
index fcba2b1b214adc..527f682062bb35 100644
--- a/clang-tools-extra/clang-tidy/google/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/google/CMakeLists.txt
@@ -8,6 +8,7 @@ add_clang_library(clangTidyGoogleModule
   AvoidNSObjectNewCheck.cpp
   AvoidThrowingObjCExceptionCheck.cpp
   AvoidUnderscoreInGoogletestNameCheck.cpp
+  CppInitClassMembersCheck.cpp
   DefaultArgumentsCheck.cpp
   ExplicitConstructorCheck.cpp
   ExplicitMakePairCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/google/CppInitClassMembersCheck.cpp 
b/clang-tools-extra/clang-tidy/google/CppInitClassMembersCheck.cpp
new file mode 100644
index 00..fea8dcbd50ff03
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/google/CppInitClassMembersCheck.cpp
@@ -0,0 +1,105 @@
+//===--- CppInitClassMembersCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "CppInitClassMembersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::google {
+
+namespace {
+
+// Matches records that have a default constructor.
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
+// Returns the names of `Fields` in a comma separated string.
+std::string
+toCommaSeparatedString(const SmallVector &Fields) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+  llvm::interleave(
+  Fields, OS, [&OS](const FieldDecl *Decl) { OS << Decl->getName(); },
+  ", ");
+  return Buffer;
+}
+
+// Returns `true` for field types that should be reported (if additional
+// conditions are also met). For example, returns `true` for `int` because an
+// uninitialized `int` field can contain uninitialized values.
+bool shouldReportThisFieldType(QualType Ty) {
+  if (Ty.isNull())
+return false;
+
+  // FIXME: For now, this checker focuses on several allowlisted types. We will
+  // expand coverage in future.
+  return Ty->isIntegerType() || Ty->isBooleanType();
+}
+
+} // anonymous namespace
+
+void CppInitClassMembersCheck::checkMissingMemberInitializer(
+ASTContext &Context, const CXXRecordDecl &ClassDecl,
+const CXXConstructorDecl *Ctor) {
+  SmallVector FieldsToReport;
+
+  for (const FieldDecl *F : ClassDecl.fields()) {
+if (shouldReportThisFieldType(F->getType()) && !F->hasInClassInitializer())
+  FieldsToReport.push_back(F);
+  }
+
+  if (FieldsToReport.empty())
+return;
+
+  DiagnosticBuilder Diag =
+  diag(Ctor ? Ctor->getBeginLoc() : ClassDecl.getLocation(),
+   "%select{these fields should be initialized|constructor should "
+   "initialize these fields}0: %1")
+  << (C

[clang] [clang][dataflow] Remove RecordValue.getLog() usage in HTMLLogger (PR #65645)

2023-09-07 Thread Kinuko Yasuda via cfe-commits

https://github.com/kinu created https://github.com/llvm/llvm-project/pull/65645:

We can dump the same information from RecordStorageLocation.

Tested the behavior before and after patch, that generates the field values in 
the HTML
in both cases (and also made sure that removing the relevant code makes the 
field values
in the HTML go away)

>From 74c4f7999db0cda33aade39a916a122cea2f11b6 Mon Sep 17 00:00:00 2001
From: Kinuko Yasuda 
Date: Thu, 7 Sep 2023 17:22:17 +
Subject: [PATCH] [clang][dataflow] Remove RecordValue.getLog() usage in
 HTMLLogger

We can dump the same information from RecordStorageLocation.

Tested the behavior before and after patch, that generates the
field values in the HTML in both cases
(And also made sure if we remove the code it goes away)
---
 .../lib/Analysis/FlowSensitive/HTMLLogger.cpp  | 18 ++
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index b1bfe10db202435..a5f64021eb6ba4b 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -95,6 +95,7 @@ class ModelDumper {
 
 switch (V.getKind()) {
 case Value::Kind::Integer:
+case Value::Kind::Record:
 case Value::Kind::TopBool:
 case Value::Kind::AtomicBool:
 case Value::Kind::FormulaBool:
@@ -103,14 +104,6 @@ class ModelDumper {
   JOS.attributeObject(
   "pointee", [&] { dump(cast(V).getPointeeLoc()); });
   break;
-case Value::Kind::Record:
-  for (const auto &Child : cast(V).getLoc().children())
-JOS.attributeObject("f:" + Child.first->getNameAsString(), [&] {
-  if (Child.second)
-if (Value *Val = Env.getValue(*Child.second))
-  dump(*Val);
-});
-  break;
 }
 
 for (const auto& Prop : V.properties())
@@ -136,6 +129,15 @@ class ModelDumper {
 JOS.attribute("type", L.getType().getAsString());
 if (auto *V = Env.getValue(L))
   dump(*V);
+
+if (auto *RLoc = dyn_cast(&L)) {
+  for (const auto &Child : RLoc->children())
+JOS.attributeObject("f:" + Child.first->getNameAsString(), [&] {
+  if (Child.second)
+if (Value *Val = Env.getValue(*Child.second))
+  dump(*Val);
+});
+}
   }
 
   llvm::DenseSet Visited;

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


[clang] [clang][dataflow] Remove RecordValue.getLog() usage in HTMLLogger (PR #65645)

2023-09-07 Thread Kinuko Yasuda via cfe-commits

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


[clang] [clang][dataflow] Remove RecordValue.getLog() usage in HTMLLogger (PR #65645)

2023-09-07 Thread via cfe-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65645
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,105 @@
+//===--- CppInitClassMembersCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "CppInitClassMembersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::google {
+
+namespace {
+
+// Matches records that have a default constructor.
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
+// Returns the names of `Fields` in a comma separated string.
+std::string
+toCommaSeparatedString(const SmallVector &Fields) {

adriannistor wrote:

fixed in a0d227088b9d099b23ed68af80714e2f96a7a2a8. thanks!

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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,105 @@
+//===--- CppInitClassMembersCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "CppInitClassMembersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::google {
+
+namespace {
+
+// Matches records that have a default constructor.
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
+// Returns the names of `Fields` in a comma separated string.
+std::string
+toCommaSeparatedString(const SmallVector &Fields) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+  llvm::interleave(
+  Fields, OS, [&OS](const FieldDecl *Decl) { OS << Decl->getName(); },
+  ", ");
+  return Buffer;
+}
+
+// Returns `true` for field types that should be reported (if additional
+// conditions are also met). For example, returns `true` for `int` because an
+// uninitialized `int` field can contain uninitialized values.
+bool shouldReportThisFieldType(QualType Ty) {

adriannistor wrote:

fixed in a0d227088b9d099b23ed68af80714e2f96a7a2a8 . Thanks!

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


[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Erick Velez via cfe-commits

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


[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Erick Velez via cfe-commits

https://github.com/evelez7 created 
https://github.com/llvm/llvm-project/pull/65646:

Issue raised here: https://reviews.llvm.org/D158474#inline-1543925

We can still test that `bool` is properly serialized using the `bool.cpp` test.

>From 966ff8288a16f710c5220b152cb7ce0fa735a2ee Mon Sep 17 00:00:00 2001
From: Erick Velez 
Date: Thu, 7 Sep 2023 10:27:36 -0700
Subject: [PATCH] [clang][ExtractAPI] Remove test with system header

---
 clang/test/ExtractAPI/bool.c | 204 ---
 1 file changed, 204 deletions(-)
 delete mode 100644 clang/test/ExtractAPI/bool.c

diff --git a/clang/test/ExtractAPI/bool.c b/clang/test/ExtractAPI/bool.c
deleted file mode 100644
index fc013792c67991..00
--- a/clang/test/ExtractAPI/bool.c
+++ /dev/null
@@ -1,204 +0,0 @@
-// RUN: rm -rf %t
-// RUN: split-file %s %t
-// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
-// RUN: %t/reference.output.json.in >> %t/reference.output.json
-// RUN: %clang -extract-api -target arm64-apple-macosx \
-// RUN: %t/input.h -o %t/output.json
-
-// Generator version is not consistent across test runs, normalize it.
-// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
-// RUN: %t/output.json >> %t/output-normalized.json
-// RUN: diff %t/reference.output.json %t/output-normalized.json
-
-//--- input.h
-#include 
-bool Foo;
-
-bool IsFoo(bool Bar);
-/// expected-no-diagnostics
-
-//--- reference.output.json.in
-{
-  "metadata": {
-"formatVersion": {
-  "major": 0,
-  "minor": 5,
-  "patch": 3
-},
-"generator": "?"
-  },
-  "module": {
-"name": "",
-"platform": {
-  "architecture": "arm64",
-  "operatingSystem": {
-"minimumVersion": {
-  "major": 11,
-  "minor": 0,
-  "patch": 0
-},
-"name": "macosx"
-  },
-  "vendor": "apple"
-}
-  },
-  "relationships": [],
-  "symbols": [
-{
-  "accessLevel": "public",
-  "declarationFragments": [
-{
-  "kind": "typeIdentifier",
-  "preciseIdentifier": "c:b",
-  "spelling": "bool"
-},
-{
-  "kind": "text",
-  "spelling": " "
-},
-{
-  "kind": "identifier",
-  "spelling": "Foo"
-},
-{
-  "kind": "text",
-  "spelling": ";"
-}
-  ],
-  "identifier": {
-"interfaceLanguage": "c",
-"precise": "c:@Foo"
-  },
-  "kind": {
-"displayName": "Global Variable",
-"identifier": "c.var"
-  },
-  "location": {
-"position": {
-  "character": 6,
-  "line": 2
-},
-"uri": "file://INPUT_DIR/input.h"
-  },
-  "names": {
-"navigator": [
-  {
-"kind": "identifier",
-"spelling": "Foo"
-  }
-],
-"subHeading": [
-  {
-"kind": "identifier",
-"spelling": "Foo"
-  }
-],
-"title": "Foo"
-  },
-  "pathComponents": [
-"Foo"
-  ]
-},
-{
-  "accessLevel": "public",
-  "declarationFragments": [
-{
-  "kind": "typeIdentifier",
-  "preciseIdentifier": "c:b",
-  "spelling": "bool"
-},
-{
-  "kind": "text",
-  "spelling": " "
-},
-{
-  "kind": "identifier",
-  "spelling": "IsFoo"
-},
-{
-  "kind": "text",
-  "spelling": "("
-},
-{
-  "kind": "typeIdentifier",
-  "preciseIdentifier": "c:b",
-  "spelling": "bool"
-},
-{
-  "kind": "text",
-  "spelling": " "
-},
-{
-  "kind": "internalParam",
-  "spelling": "Bar"
-},
-{
-  "kind": "text",
-  "spelling": ");"
-}
-  ],
-  "functionSignature": {
-"parameters": [
-  {
-"declarationFragments": [
-  {
-"kind": "typeIdentifier",
-"preciseIdentifier": "c:b",
-"spelling": "bool"
-  },
-  {
-"kind": "text",
-"spelling": " "
-  },
-  {
-"kind": "internalParam",
-"spelling": "Bar"
-  }
-],
-"name": "Bar"
-  }
-],
-"returns": [
-  {
-"kind": "typeIdentifier",
-"preciseIdentifier": "c:b",
-"spelling": "bool"
-  }
-]
-  },
-  "identifier": {
-"interfaceLanguage": "c",
-"precise": "c:@F@IsFoo"
-  },
-  "kind": {
-"displayName": "Function",
-"identifier": "c.func"
-  },
-  "location": {
-"position": {
-  "character": 6,
-  "line": 4
-},
-"uri": "file://INPUT_DIR/input.h"
-  },
-  "

[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Erick Velez via cfe-commits

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


[clang] [clang] Make the entire `CompilerInvocation` ref-counted (PR #65647)

2023-09-07 Thread Jan Svoboda via cfe-commits

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


[clang] [clang] Make the entire `CompilerInvocation` ref-counted (PR #65647)

2023-09-07 Thread Jan Svoboda via cfe-commits

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


[clang] [clang] Make the entire `CompilerInvocation` ref-counted (PR #65647)

2023-09-07 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 created 
https://github.com/llvm/llvm-project/pull/65647:

This enables making the whole `CompilerInvocation` more efficient through 
copy-on-write.

>From 4a29ff15728ac3e93de26066274493c1fd6c50fa Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Thu, 7 Sep 2023 10:30:06 -0700
Subject: [PATCH] [clang] Make the entire `CompilerInvocation` ref-counted

This enables making the whole `CompilerInvocation` more efficient through 
copy-on-write.
---
 .../clang/Frontend/CompilerInvocation.h   | 150 --
 clang/lib/Frontend/CompilerInvocation.cpp | 130 ---
 2 files changed, 133 insertions(+), 147 deletions(-)

diff --git a/clang/include/clang/Frontend/CompilerInvocation.h 
b/clang/include/clang/Frontend/CompilerInvocation.h
index 5dc55bb7abdbab..2dc73b85bd4afe 100644
--- a/clang/include/clang/Frontend/CompilerInvocation.h
+++ b/clang/include/clang/Frontend/CompilerInvocation.h
@@ -66,16 +66,12 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, 
llvm::opt::ArgList &Args,
  DiagnosticsEngine *Diags = nullptr,
  bool DefaultDiagColor = true);
 
-/// The base class of CompilerInvocation with reference semantics.
-///
-/// This class stores option objects behind reference-counted pointers. This is
-/// useful for clients that want to keep some option object around even after
-/// CompilerInvocation gets destroyed, without making a copy.
-///
-/// This is a separate class so that we can implement the copy constructor and
-/// assignment here and leave them defaulted in the rest of CompilerInvocation.
-class CompilerInvocationRefBase {
-public:
+/// The base class of CompilerInvocation. It keeps individual option objects
+/// behind reference-counted pointers, which is useful for clients that want to
+/// keep select option objects alive (even after CompilerInvocation gets
+/// destroyed) without making a copy.
+class CompilerInvocationBase {
+protected:
   /// Options controlling the language variant.
   std::shared_ptr LangOpts;
 
@@ -86,103 +82,71 @@ class CompilerInvocationRefBase {
   IntrusiveRefCntPtr DiagnosticOpts;
 
   /// Options controlling the \#include directive.
-  std::shared_ptr HeaderSearchOpts;
+  std::shared_ptr HSOpts;
 
   /// Options controlling the preprocessor (aside from \#include handling).
-  std::shared_ptr PreprocessorOpts;
+  std::shared_ptr PPOpts;
 
   /// Options controlling the static analyzer.
   AnalyzerOptionsRef AnalyzerOpts;
 
-  CompilerInvocationRefBase();
-  CompilerInvocationRefBase(const CompilerInvocationRefBase &X);
-  CompilerInvocationRefBase(CompilerInvocationRefBase &&X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase X);
-  CompilerInvocationRefBase &operator=(CompilerInvocationRefBase &&X);
-  ~CompilerInvocationRefBase();
-
-  LangOptions &getLangOpts() { return *LangOpts; }
-  const LangOptions &getLangOpts() const { return *LangOpts; }
-
-  TargetOptions &getTargetOpts() { return *TargetOpts.get(); }
-  const TargetOptions &getTargetOpts() const { return *TargetOpts.get(); }
-
-  DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
-
-  HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
-
-  const HeaderSearchOptions &getHeaderSearchOpts() const {
-return *HeaderSearchOpts;
-  }
-
-  std::shared_ptr getHeaderSearchOptsPtr() const {
-return HeaderSearchOpts;
-  }
-
-  std::shared_ptr getPreprocessorOptsPtr() {
-return PreprocessorOpts;
-  }
-
-  PreprocessorOptions &getPreprocessorOpts() { return *PreprocessorOpts; }
-
-  const PreprocessorOptions &getPreprocessorOpts() const {
-return *PreprocessorOpts;
-  }
-
-  AnalyzerOptions &getAnalyzerOpts() { return *AnalyzerOpts; }
-  const AnalyzerOptions &getAnalyzerOpts() const { return *AnalyzerOpts; }
-};
-
-/// The base class of CompilerInvocation with value semantics.
-class CompilerInvocationValueBase {
-protected:
-  MigratorOptions MigratorOpts;
+  std::shared_ptr MigratorOpts;
 
   /// Options controlling IRgen and the backend.
-  CodeGenOptions CodeGenOpts;
-
-  /// Options controlling dependency output.
-  DependencyOutputOptions DependencyOutputOpts;
+  std::shared_ptr CodeGenOpts;
 
   /// Options controlling file system operations.
-  FileSystemOptions FileSystemOpts;
+  std::shared_ptr FSOpts;
 
   /// Options controlling the frontend itself.
-  FrontendOptions FrontendOpts;
+  std::shared_ptr FrontendOpts;
+
+  /// Options controlling dependency output.
+  std::shared_ptr DependencyOutputOpts;
 
   /// Options controlling preprocessed output.
-  PreprocessorOutputOptions PreprocessorOutputOpts;
+  std::shared_ptr PreprocessorOutputOpts;
 
 public:
-  MigratorOptions &getMigratorOpts() { return MigratorOpts; }
-  const MigratorOptions &getMigratorOpts() const { return MigratorOpts; }
-
-  CodeGenOptions &getCodeGenOpts() { return CodeGenOpts; }
-  const CodeGenOptions &getCodeGenOpts() const { return CodeGenOpts; }
-
-

[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits


@@ -4588,28 +4641,29 @@ std::string CompilerInvocation::getModuleHash() const {
   return toString(llvm::APInt(64, Hash), 36, /*Signed=*/false);
 }
 
-void CompilerInvocation::generateCC1CommandLine(
+void CompilerInvocationBase::generateCC1CommandLine(
 ArgumentConsumer Consumer) const {
-  llvm::Triple T(TargetOpts->Triple);
-
-  GenerateFileSystemArgs(FileSystemOpts, Consumer);
-  GenerateMigratorArgs(MigratorOpts, Consumer);
-  GenerateAnalyzerArgs(*AnalyzerOpts, Consumer);
-  GenerateDiagnosticArgs(*DiagnosticOpts, Consumer, false);
-  GenerateFrontendArgs(FrontendOpts, Consumer, LangOpts->IsHeaderFile);
-  GenerateTargetArgs(*TargetOpts, Consumer);
-  GenerateHeaderSearchArgs(*HeaderSearchOpts, Consumer);
-  GenerateLangArgs(*LangOpts, Consumer, T, FrontendOpts.DashX);
-  GenerateCodeGenArgs(CodeGenOpts, Consumer, T, FrontendOpts.OutputFile,
-  &*LangOpts);
-  GeneratePreprocessorArgs(*PreprocessorOpts, Consumer, *LangOpts, 
FrontendOpts,
-   CodeGenOpts);
-  GeneratePreprocessorOutputArgs(PreprocessorOutputOpts, Consumer,
- FrontendOpts.ProgramAction);
-  GenerateDependencyOutputArgs(DependencyOutputOpts, Consumer);
+  llvm::Triple T(getTargetOpts().Triple);
+
+  GenerateFileSystemArgs(getFileSystemOpts(), Consumer);
+  GenerateMigratorArgs(getMigratorOpts(), Consumer);
+  GenerateAnalyzerArgs(getAnalyzerOpts(), Consumer);
+  GenerateDiagnosticArgs(getDiagnosticOpts(), Consumer, false);

jansvoboda11 wrote:

Done in #65647.

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


[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Daniel Grumberg via cfe-commits

https://github.com/daniel-grumberg approved this pull request.

LGTM

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


[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Erick Velez via cfe-commits

https://github.com/evelez7 edited 
https://github.com/llvm/llvm-project/pull/65646
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Introduce copy-on-write `CompilerInvocation` (PR #65412)

2023-09-07 Thread Jan Svoboda via cfe-commits

jansvoboda11 wrote:

Made the entirety of `ValBase` ref-counted in 
https://github.com/llvm/llvm-project/pull/65647, which also resolves some other 
comments here.

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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,105 @@
+//===--- CppInitClassMembersCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+
+#include "CppInitClassMembersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::google {
+
+namespace {
+
+// Matches records that have a default constructor.
+AST_MATCHER(CXXRecordDecl, hasDefaultConstructor) {
+  return Node.hasDefaultConstructor();
+}
+
+// Returns the names of `Fields` in a comma separated string.
+std::string
+toCommaSeparatedString(const SmallVector &Fields) {
+  std::string Buffer;
+  llvm::raw_string_ostream OS(Buffer);
+  llvm::interleave(
+  Fields, OS, [&OS](const FieldDecl *Decl) { OS << Decl->getName(); },
+  ", ");
+  return Buffer;
+}
+
+// Returns `true` for field types that should be reported (if additional
+// conditions are also met). For example, returns `true` for `int` because an
+// uninitialized `int` field can contain uninitialized values.
+bool shouldReportThisFieldType(QualType Ty) {
+  if (Ty.isNull())
+return false;
+
+  // FIXME: For now, this checker focuses on several allowlisted types. We will
+  // expand coverage in future.
+  return Ty->isIntegerType() || Ty->isBooleanType();
+}
+
+} // anonymous namespace
+
+void CppInitClassMembersCheck::checkMissingMemberInitializer(
+ASTContext &Context, const CXXRecordDecl &ClassDecl,
+const CXXConstructorDecl *Ctor) {
+  SmallVector FieldsToReport;
+
+  for (const FieldDecl *F : ClassDecl.fields()) {
+if (shouldReportThisFieldType(F->getType()) && !F->hasInClassInitializer())
+  FieldsToReport.push_back(F);
+  }
+
+  if (FieldsToReport.empty())
+return;
+
+  DiagnosticBuilder Diag =

adriannistor wrote:

Thanks for the feedback! I added this in an internal Feature Request tracker 
for this check (I have two other internal reviewers who suggested something 
similar, so I am clustering this feedback and I will implement a version that 
meets all 3 feedback: from you and from the two reviewers).

Is tracking this as a Feature Request internally ok ? Or would you prefer I 
open a Feature Request in the [LLVM 
tracker](https://github.com/llvm/llvm-project/issues). I am a bit worried that, 
with this check being in very early stages, I will just be spamming the LLVM 
tracker with feature requests for an under-development check. However, if you 
think using the LLVM tracker is the right thing to do, I would be very glad to 
use the LLVM tracker, just let me know! Thanks! 



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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,56 @@
+// RUN: %check_clang_tidy %s google-cpp-init-class-members %t
+
+class PositiveDefaultedDefaultConstructor {
+public:
+  PositiveDefaultedDefaultConstructor() = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor should initialize 
these fields: X
+
+private:
+  int X;
+};
+
+class PositiveDefaultedDefaultConstructorWithInitializedField {
+public:
+  PositiveDefaultedDefaultConstructorWithInitializedField() = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor should initialize 
these fields: X
+
+private:
+  int X;
+  int Y = 4; // no-warning
+};
+
+class Helper {
+ public:
+  Helper(int x) : X(x) {}
+
+ private:
+  int X;
+};
+
+class PositiveDefaultedConstructorObjectAndPrimitive {
+ public:
+  PositiveDefaultedConstructorObjectAndPrimitive() = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor should initialize 
these fields: Y
+
+  Helper* GetHelper() { return &X; }
+
+  void SetY(bool enabled) { Y = enabled; }
+
+  bool IsY() { return Y; }
+
+ private:
+  Helper X;
+  bool Y;
+};
+
+struct PositiveStruct {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: these fields should be 
initialized: X, Y
+  int X;
+  int Y;
+};
+
+struct PositiveStructWithInitializedField {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: these fields should be 
initialized: Y
+  int X = 3; // no-warning
+  int Y;
+};

adriannistor wrote:

Fixed in a0d227088b9d099b23ed68af80714e2f96a7a2a8 ! Thanks!

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


[clang] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #65407)

2023-09-07 Thread Yusra Syeda via cfe-commits

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


[PATCH] D158474: [clang][ExtractAPI] Fix bool spelling coming from the macro definition.

2023-09-07 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: clang/test/ExtractAPI/bool.c:14
+//--- input.h
+#include 
+bool Foo;

aeubanks wrote:
> clang tests should not be including system headers since that makes the tests 
> non-hermetic (this test fails in our internal builds that provide more 
> isolated test environments), could you make this not include ?
ignore my previous comment, stdbool.h is provided by clang, sorry for the 
trouble


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158474

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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,32 @@
+.. title:: clang-tidy - google-cpp-init-class-members
+
+google-cpp-init-class-members
+=
+
+Checks that class members are initialized in constructors (implicitly or
+explicitly). Reports constructors or classes where class members are not
+initialized. The goal of this checker is to eliminate UUM (Use of
+Uninitialized Memory) bugs caused by uninitialized class members.
+
+This checker is different from ProTypeMemberInitCheck in that this checker
+attempts to eliminate UUMs as a bug class, at the expense of false
+positives.
+
+This checker is WIP. We are incrementally adding features and increasing
+coverage until we get to a shape that is acceptable.
+
+For now, this checker reports `X` in the following two patterns:
+
+.. code-block:: c++
+  class SomeClass {
+  public:
+SomeClass() = default;
+
+  private:
+int X;
+  };
+
+.. code-block:: c++
+  struct SomeStruct {
+int X;
+  };

adriannistor wrote:

You are right, fully agree! I added a [broader discussion 
below](https://github.com/llvm/llvm-project/pull/65189#issuecomment-1709185690).
 To summarize (full context there), we are still working the high level 
specifications and the low level specifications based on data. Once we have a 
stable and mature version, we will update the documentation for this checker in 
a more concrete and actionable way. Until then, we will keep this file 
(`cpp-init-class-members.rst`) and the unit tests as a high level and low level 
specifications, respectively. Full details in the [broader discussion 
below](https://github.com/llvm/llvm-project/pull/65189#issuecomment-1709185690).
 Thanks!



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


[clang-tools-extra] [clang-tidy] The first PR our of many PRs for the "Initialized Class Members" check. (PR #65189)

2023-09-07 Thread via cfe-commits


@@ -0,0 +1,51 @@
+//===--- CppInitClassMembersCheck.h - clang-tidy *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_CPPINITCLASSMEMBERSCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_CPPINITCLASSMEMBERSCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::google {
+
+/// Checks that class members are initialized in constructors (implicitly or
+/// explicitly). Reports constructors or classes where class members are not
+/// initialized. The goal of this checker is to eliminate UUM (Use of
+/// Uninitialized Memory) bugs caused by uninitialized class members.
+///
+/// This checker is different from ProTypeMemberInitCheck in that this checker
+/// attempts to eliminate UUMs as a bug class, at the expense of false
+/// positives.
+///
+/// This checker is WIP. We are incrementally adding features and increasing
+/// coverage until we get to a shape that is acceptable.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/google/cpp-init-class-members.html
+class CppInitClassMembersCheck : public ClangTidyCheck {
+public:
+  CppInitClassMembersCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus && !LangOpts.ObjC;

adriannistor wrote:

Fixed in a0d227088b9d099b23ed68af80714e2f96a7a2a8 ! Thanks!

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


[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Erick Velez via cfe-commits

https://github.com/evelez7 closed 
https://github.com/llvm/llvm-project/pull/65646
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ExtractAPI] Remove test with system header (PR #65646)

2023-09-07 Thread Erick Velez via cfe-commits

evelez7 wrote:

Nevermind: https://reviews.llvm.org/D158474#inline-1544258

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


[clang] Add Documentation for Execution Results Handling in Clang-Repl (PR #65650)

2023-09-07 Thread Krishna Narayanan via cfe-commits

https://github.com/Krishna-13-cyber created 
https://github.com/llvm/llvm-project/pull/65650:

[clang-repl] Add Documentation for Execution Results Handling.

This patch adds documentation for execution results handling in Clang-REPL with
the below features:

- Automatic Printf feature
- Value Synthesis feature
- Pretty Printing feature


Continuing this work https://reviews.llvm.org/D156858 with this PR. I am 
issuing this patch on behalf of Saqib.

Reviewers:
@vgvassilev 
@junaire

>From 145ff3877b588aebd811f26b6d596257ea889957 Mon Sep 17 00:00:00 2001
From: Krishna-13-cyber 
Date: Thu, 7 Sep 2023 22:35:53 +0530
Subject: [PATCH] Add Documentation for Execution Results Handling in
 Clang-Repl

---
 clang/docs/CMakeLists.txt |   7 +
 clang/docs/ClangRepl.rst  | 405 ++
 clang/docs/conf.py|   1 +
 3 files changed, 413 insertions(+)

diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 4163dd2d90ad5b..356814f994c32c 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -103,6 +103,13 @@ function (gen_rst_file_from_td output_file td_option 
source docs_targets)
 endfunction()
 
 if (LLVM_ENABLE_SPHINX)
+  llvm_find_program(dot)
+  if (HAVE_DOT)
+set(DOT ${LLVM_PATH_DOT})
+  else()
+message(FATAL_ERROR "Cannot find DOT")
+  endif()
+
   include(AddSphinxTarget)
   if (SPHINX_FOUND AND (${SPHINX_OUTPUT_HTML} OR ${SPHINX_OUTPUT_MAN}))
 # Copy rst files to build directory before generating the html
diff --git a/clang/docs/ClangRepl.rst b/clang/docs/ClangRepl.rst
index bd99bc82f1..47513dec18f04e 100644
--- a/clang/docs/ClangRepl.rst
+++ b/clang/docs/ClangRepl.rst
@@ -213,6 +213,411 @@ concept helps support advanced use cases such as template 
instantiations on dema
 automatic language interoperability. It also helps static languages such as 
C/C++ become
 apt for data science.
 
+Execution Results Handling in Clang-Repl
+
+
+Execution Results Handling features discussed below help extend the Clang-Repl
+functionality by creating an interface between the execution results of a
+program and the compiled program.
+
+1. **Capture Execution Results**: This feature helps capture the execution 
results
+of a program and bring them back to the compiled program.
+
+2. **Dump Captured Execution Results**: This feature helps create a temporary 
dump
+for Value Printing/Automatic Printf, that is, to display the value and type of
+the captured data.
+
+
+1. Capture Execution Results
+
+
+In many cases, it is useful to bring back the program execution result to the
+compiled program. This result can be stored in an object of type **Value**.
+
+How Execution Results are captured (Value Synthesis):
+-
+
+The synthesizer chooses which expression to synthesize, and then it replaces
+the original expression with the synthesized expression. Depending on the
+expression type, it may choose to save an object (``LastValue``) of type 
'value'
+while allocating memory to it (``SetValueWithAlloc()``), or not (
+``SetValueNoAlloc()``).
+
+.. graphviz::
+:name: valuesynthesis
+:caption: Value Synthesis
+:alt: Shows how an object of type 'Value' is synthesized
+:align: center
+
+ digraph "valuesynthesis" {
+ rankdir="LR";
+ graph [fontname="Verdana", fontsize="12"];
+ node [fontname="Verdana", fontsize="12"];
+ edge [fontname="Sans", fontsize="9"];
+
+ start [label=" Create an Object \n 'Last Value' \n of type 'Value' ", 
shape="note", fontcolor=white, fillcolor="#ff", style=filled];
+ assign [label=" Assign the result \n to the 'LastValue' \n (based on 
respective \n Memory Allocation \n scenario) ", shape="box"]
+ print [label=" Pretty Print \n the Value Object ", shape="Msquare", 
fillcolor="yellow", style=filled];
+ start -> assign;
+ assign -> print;
+
+   subgraph SynthesizeExpression {
+ synth [label=" SynthesizeExpr() ", shape="note", fontcolor=white, 
fillcolor="#ff", style=filled];
+ mem [label=" New Memory \n Allocation? ", shape="diamond"];
+ withaloc [label=" SetValueWithAlloc() ", shape="box"];
+ noaloc [label=" SetValueNoAlloc() ", shape="box"];
+ right [label=" 1. RValue Structure \n (a temporary value)", 
shape="box"];
+ left2 [label=" 2. LValue Structure \n (a variable with \n an 
address)", shape="box"];
+ left3 [label=" 3. Built-In Type \n (int, float, etc.)", 
shape="box"];
+ output [label=" move to 'Assign' step ", shape="box"];
+
+ synth -> mem;
+ mem -> withaloc [label="Yes"];
+ mem -> noaloc [label="No"];
+ withaloc -> right;
+ noaloc -> left2;
+ noaloc -> left3;
+ right -> output;
+ left2 -> output;
+  

[clang] Add Documentation for Execution Results Handling in Clang-Repl (PR #65650)

2023-09-07 Thread Krishna Narayanan via cfe-commits

https://github.com/Krishna-13-cyber review_requested 
https://github.com/llvm/llvm-project/pull/65650
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Add Documentation for Execution Results Handling in Clang-Repl (PR #65650)

2023-09-07 Thread Vassil Vassilev via cfe-commits

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


  1   2   3   4   5   6   >