[PATCH] D125170: [Headers][X86] Replace \operation with \verbatim

2022-05-07 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D125170#3498913 , @RKSimon wrote:

> If people prefer we can alternatively use \code{.unparsed} .. \endcode blocks 
> - I'm unsure if these operation blocks are being used in a particular way 
> downstream

We have used \code .. \endcode blocks in headers, so maybe \code{.operation} .. 
\endcode for precisely match? We haven't used verbatim before, but I'm a little 
concerned we may mix up in future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125170

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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D125177: Recognize scope of thread local variables in CFGBuilder

2022-05-07 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Can we just use VarDecl::hasLocalStorage()?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125177

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


[clang] 6bbf51f - [Frontend] Move, don't copy the predefines buffer into PP. NFC.

2022-05-07 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-08T01:04:46+02:00
New Revision: 6bbf51f3ed59ae37f0fec729f25af002111c9e74

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

LOG: [Frontend] Move, don't copy the predefines buffer into PP. NFC.

It's not trivially small, >10kb.

Added: 


Modified: 
clang/include/clang/Lex/Preprocessor.h
clang/lib/Frontend/InitPreprocessor.cpp

Removed: 




diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index 3c74b48d19bec..f0070b3ab7c0a 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1280,13 +1280,10 @@ class Preprocessor {
   StringRef getLastMacroWithSpelling(SourceLocation Loc,
  ArrayRef Tokens) const;
 
-  const std::string () const { return Predefines; }
-
   /// Set the predefines for this Preprocessor.
   ///
   /// These predefines are automatically injected when parsing the main file.
-  void setPredefines(const char *P) { Predefines = P; }
-  void setPredefines(StringRef P) { Predefines = std::string(P); }
+  void setPredefines(std::string P) { Predefines = std::move(P); }
 
   /// Return information about the specified preprocessor
   /// identifier token.

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 847d3667ff37c..3921f7949a0a9 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1388,5 +1388,5 @@ void clang::InitializePreprocessor(
  InitOpts.PrecompiledPreambleBytes.second);
 
   // Copy PredefinedBuffer into the Preprocessor.
-  PP.setPredefines(Predefines.str());
+  PP.setPredefines(std::move(PredefineBuffer));
 }



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


[PATCH] D125180: [Frontend] when attaching a preamble, don't generate the long predefines buffer.

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We know we're going to overwrite it anyway.
It'd be a bit of work to coordinate not generating it at all, but setting this
flag avoids generating ~10k of the 13k string.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125180

Files:
  clang/lib/Frontend/PrecompiledPreamble.cpp


Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -765,6 +765,10 @@
   PreprocessorOpts.DisablePCHOrModuleValidation =
   DisableValidationForModuleKind::PCH;
 
+  // So don't bother generating the long version of the predefines buffer.
+  // The is going to overwrite it anyway (to almost nothing).
+  PreprocessorOpts.UsePredefines = false;
+
   setupPreambleStorage(*Storage, PreprocessorOpts, VFS);
 }
 


Index: clang/lib/Frontend/PrecompiledPreamble.cpp
===
--- clang/lib/Frontend/PrecompiledPreamble.cpp
+++ clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -765,6 +765,10 @@
   PreprocessorOpts.DisablePCHOrModuleValidation =
   DisableValidationForModuleKind::PCH;
 
+  // So don't bother generating the long version of the predefines buffer.
+  // The is going to overwrite it anyway (to almost nothing).
+  PreprocessorOpts.UsePredefines = false;
+
   setupPreambleStorage(*Storage, PreprocessorOpts, VFS);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106888: [RISC-V] Implement jump tables for CFI-icall

2022-05-07 Thread Wende Tan via Phabricator via cfe-commits
twd2 updated this revision to Diff 427901.
twd2 added a comment.
Herald added subscribers: sunshaoce, StephenFan, arichardson.
Herald added a project: All.

Add tests as suggested.
Use `tail xxx@plt` instruction instead of manually `auipc` + `jr`, which 
eliminates issues when linking dynamically-linked executables.


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

https://reviews.llvm.org/D106888

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/fsanitize.c
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/test/Transforms/LowerTypeTests/function-weak.ll
  llvm/test/Transforms/LowerTypeTests/function.ll

Index: llvm/test/Transforms/LowerTypeTests/function.ll
===
--- llvm/test/Transforms/LowerTypeTests/function.ll
+++ llvm/test/Transforms/LowerTypeTests/function.ll
@@ -5,6 +5,8 @@
 ; RUN: opt -S -lowertypetests -mtriple=arm-unknown-linux-gnu < %s | FileCheck --check-prefixes=ARM,NATIVE %s
 ; RUN: opt -S -lowertypetests -mtriple=thumb-unknown-linux-gnu < %s | FileCheck --check-prefixes=THUMB,NATIVE %s
 ; RUN: opt -S -lowertypetests -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck --check-prefixes=ARM,NATIVE %s
+; RUN: opt -S -lowertypetests -mtriple=riscv32-unknown-linux-gnu < %s | FileCheck --check-prefixes=RISCV,NATIVE %s
+; RUN: opt -S -lowertypetests -mtriple=riscv64-unknown-linux-gnu < %s | FileCheck --check-prefixes=RISCV,NATIVE %s
 ; RUN: opt -S -lowertypetests -mtriple=wasm32-unknown-unknown < %s | FileCheck --check-prefix=WASM32 %s
 
 ; Tests that we correctly handle bitsets containing 2 or more functions.
@@ -23,6 +25,7 @@
 ; X86: @g = internal alias void (), bitcast ([8 x i8]* getelementptr inbounds ([2 x [8 x i8]], [2 x [8 x i8]]* bitcast (void ()* @[[JT]] to [2 x [8 x i8]]*), i64 0, i64 1) to void ()*)
 ; ARM: @g = internal alias void (), bitcast ([4 x i8]* getelementptr inbounds ([2 x [4 x i8]], [2 x [4 x i8]]* bitcast (void ()* @[[JT]] to [2 x [4 x i8]]*), i64 0, i64 1) to void ()*)
 ; THUMB: @g = internal alias void (), bitcast ([4 x i8]* getelementptr inbounds ([2 x [4 x i8]], [2 x [4 x i8]]* bitcast (void ()* @[[JT]] to [2 x [4 x i8]]*), i64 0, i64 1) to void ()*)
+; RISCV: @g = internal alias void (), bitcast ([8 x i8]* getelementptr inbounds ([2 x [8 x i8]], [2 x [8 x i8]]* bitcast (void ()* @[[JT]] to [2 x [8 x i8]]*), i64 0, i64 1) to void ()*)
 
 ; NATIVE: define hidden void @f.cfi()
 ; WASM32: define void @f() !type !{{[0-9]+}} !wasm.index ![[I0:[0-9]+]]
@@ -52,6 +55,7 @@
 ; X86-WIN32:   define private void @[[JT]]() #[[ATTR:.*]] align 8 {
 ; ARM:   define private void @[[JT]]() #[[ATTR:.*]] align 4 {
 ; THUMB: define private void @[[JT]]() #[[ATTR:.*]] align 4 {
+; RISCV: define private void @[[JT]]() #[[ATTR:.*]] align 8 {
 
 ; X86:  jmp ${0:c}@plt
 ; X86-SAME: int3
@@ -68,12 +72,16 @@
 ; THUMB:  b.w $0
 ; THUMB-SAME: b.w $1
 
+; RISCV:  tail $0@plt
+; RISCV-SAME: tail $1@plt
+
 ; NATIVE-SAME: "s,s"(void ()* @f.cfi, void ()* @g.cfi)
 
 ; X86-LINUX: attributes #[[ATTR]] = { naked nounwind }
 ; X86-WIN32: attributes #[[ATTR]] = { nounwind }
 ; ARM: attributes #[[ATTR]] = { naked nounwind
 ; THUMB: attributes #[[ATTR]] = { naked nounwind "target-cpu"="cortex-a8" "target-features"="+thumb-mode" }
+; RISCV: attributes #[[ATTR]] = { naked nounwind "target-features"="-c,-relax" }
 
 ; WASM32: ![[I0]] = !{i64 1}
 ; WASM32: ![[I1]] = !{i64 2}
Index: llvm/test/Transforms/LowerTypeTests/function-weak.ll
===
--- llvm/test/Transforms/LowerTypeTests/function-weak.ll
+++ llvm/test/Transforms/LowerTypeTests/function-weak.ll
@@ -2,6 +2,8 @@
 ; RUN: opt -S -lowertypetests -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck --check-prefixes=CHECK,X86 %s
 ; RUN: opt -S -lowertypetests -mtriple=arm-unknown-linux-gnu < %s | FileCheck --check-prefixes=CHECK,ARM %s
 ; RUN: opt -S -lowertypetests -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck --check-prefixes=CHECK,ARM %s
+; RUN: opt -S -lowertypetests -mtriple=riscv32-unknown-linux-gnu < %s | FileCheck --check-prefixes=CHECK,RISCV %s
+; RUN: opt -S -lowertypetests -mtriple=riscv64-unknown-linux-gnu < %s | FileCheck --check-prefixes=CHECK,RISCV %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
@@ -52,6 +54,7 @@
 
 ; X86: define private void @[[JT]]() #{{.*}} align 8 {
 ; ARM: define private void @[[JT]]() #{{.*}} align 4 {
+; RISCV: define private void @[[JT]]() #{{.*}} align 8 {
 
 ; CHECK: define internal void @__cfi_global_var_init() section ".text.startup" {
 ; CHECK-NEXT: entry:
Index: llvm/lib/Transforms/IPO/LowerTypeTests.cpp
===
--- llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1223,6 +1223,7 @@
 static const unsigned kX86JumpTableEntrySize = 8;
 static const unsigned kARMJumpTableEntrySize = 4;
 static 

[PATCH] D125179: [clangd] Skip (most) predefined macros when scanning for preamble patching.

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(yes, there's a perverse pleasure in writing 20 lines of commit message for one 
line of code with no comments. I think in *hindsight* this is obvious enough 
that it's not worth describing in the code)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125179

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


[PATCH] D125179: [clangd] Skip (most) predefined macros when scanning for preamble patching.

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is unneccesary work.
With this change, we skip generating and lexing ~10k of predefines twice.

A dumb benchmark of building a preamble for an empty file in a loop shows:

- before: 1.90ms/run
- after: 1.36ms/run

So this should be worth 0.5ms for each AST build and code completion.

There can be a functional difference, but it's very minor.
If the preamble contains e.g. `#ifndef __llvm__ ... #endif` then before we would
not take it. After this change we will take the branch (single-file mode takes
all branches with unknown conditions) and so gather different directives.

However I think this is negligible:

- this is already true of non-builtin macros (from included headers). We've had 
no complaints.
- this affects the baseline and modified in the same way, so only makes a 
difference transiently when code guarded by such an #ifdef is being edited


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125179

Files:
  clang-tools-extra/clangd/Preamble.cpp


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -302,6 +302,7 @@
 return error("compiler instance had no inputs");
   // We are only interested in main file includes.
   Clang->getPreprocessorOpts().SingleFileParseMode = true;
+  Clang->getPreprocessorOpts().UsePredefines = false;
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
 return error("failed BeginSourceFile");


Index: clang-tools-extra/clangd/Preamble.cpp
===
--- clang-tools-extra/clangd/Preamble.cpp
+++ clang-tools-extra/clangd/Preamble.cpp
@@ -302,6 +302,7 @@
 return error("compiler instance had no inputs");
   // We are only interested in main file includes.
   Clang->getPreprocessorOpts().SingleFileParseMode = true;
+  Clang->getPreprocessorOpts().UsePredefines = false;
   PreprocessOnlyAction Action;
   if (!Action.BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
 return error("failed BeginSourceFile");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125178: Warn if using `elifdef` & `elifndef` in not C2x mode

2022-05-07 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui created this revision.
ken-matsui added a reviewer: aaron.ballman.
Herald added a project: All.
ken-matsui requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch resolves https://github.com/llvm/llvm-project/issues/55306.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125178

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/PPDirectives.cpp
  clang/test/Preprocessor/ext-c2x-pp-directive.c


Index: clang/test/Preprocessor/ext-c2x-pp-directive.c
===
--- /dev/null
+++ clang/test/Preprocessor/ext-c2x-pp-directive.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -pedantic %s
+// RUN: not %clang_cc1 -std=c99 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -std=c2x -fsyntax-only -verify -pedantic %s
+// RUN: not %clang_cc1 -std=c2x -fsyntax-only -verify %s
+
+#if 1
+#elifndef FOO // expected-warning {{#elifndef is a C2x extension}}
+#endif
+
+#if 1
+#elifdef BAR // expected-warning {{#elifdef is a C2x extension}}
+#endif
+
+// expected-warning {{ISO C requires a translation unit to contain at least 
one declaration}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -3255,6 +3255,17 @@
  : PED_Elifndef;
   ++NumElse;
 
+  // Warn if using `#elifdef` & `#elifndef` in not C2x mode.
+  switch (DirKind) {
+case PED_Elifdef:
+case PED_Elifndef:
+  if (!getLangOpts().C2x)
+Diag(ElifToken, diag::ext_c2x_pp_directive) << DirKind - 1;
+  break;
+default:
+  break;
+  }
+
   // #elif directive in a non-skipping conditional... start skipping.
   // We don't care what the condition is, because we will always skip it (since
   // the block immediately before it was included).
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -693,6 +693,9 @@
 def warn_cxx98_compat_pp_line_too_big : Warning<
   "#line number greater than 32767 is incompatible with C++98">,
   InGroup, DefaultIgnore;
+def ext_c2x_pp_directive : Extension<
+  "%select{#elifdef|#elifndef}0 is a C2x extension">,
+  InGroup;
 
 def err_pp_visibility_non_macro : Error<"no macro named %0">;
 


Index: clang/test/Preprocessor/ext-c2x-pp-directive.c
===
--- /dev/null
+++ clang/test/Preprocessor/ext-c2x-pp-directive.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -pedantic %s
+// RUN: not %clang_cc1 -std=c99 -fsyntax-only -verify %s
+// RUN: not %clang_cc1 -std=c2x -fsyntax-only -verify -pedantic %s
+// RUN: not %clang_cc1 -std=c2x -fsyntax-only -verify %s
+
+#if 1
+#elifndef FOO // expected-warning {{#elifndef is a C2x extension}}
+#endif
+
+#if 1
+#elifdef BAR // expected-warning {{#elifdef is a C2x extension}}
+#endif
+
+// expected-warning {{ISO C requires a translation unit to contain at least one declaration}}
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -3255,6 +3255,17 @@
  : PED_Elifndef;
   ++NumElse;
 
+  // Warn if using `#elifdef` & `#elifndef` in not C2x mode.
+  switch (DirKind) {
+case PED_Elifdef:
+case PED_Elifndef:
+  if (!getLangOpts().C2x)
+Diag(ElifToken, diag::ext_c2x_pp_directive) << DirKind - 1;
+  break;
+default:
+  break;
+  }
+
   // #elif directive in a non-skipping conditional... start skipping.
   // We don't care what the condition is, because we will always skip it (since
   // the block immediately before it was included).
Index: clang/include/clang/Basic/DiagnosticLexKinds.td
===
--- clang/include/clang/Basic/DiagnosticLexKinds.td
+++ clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -693,6 +693,9 @@
 def warn_cxx98_compat_pp_line_too_big : Warning<
   "#line number greater than 32767 is incompatible with C++98">,
   InGroup, DefaultIgnore;
+def ext_c2x_pp_directive : Extension<
+  "%select{#elifdef|#elifndef}0 is a C2x extension">,
+  InGroup;
 
 def err_pp_visibility_non_macro : Error<"no macro named %0">;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125177: Recognize scope of thread local variables in CFGBuilder

2022-05-07 Thread Krzysztof Parzyszek via Phabricator via cfe-commits
kparzysz created this revision.
kparzysz added a reviewer: rsmith.
Herald added subscribers: pengfei, krytarowski, arichardson, emaste.
Herald added a project: All.
kparzysz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Compiling the following testcase causes a crash:

  struct A {
~A() {}
  };
  
  int fred(char *p, int *q) {
if (p != 0) {
  goto bail;
}
thread_local A a;
*q = 0;
  bail:
return 0;
  }

The crash is caused by CFGBuilder thinking that the variable `a` is local (in 
terms of storage scope), and trying to perform some sort of a lifetime analysis 
on it.  The problem is that the program would not have been legal if `a` was 
actually local, and the problem would have been diagnosed earlier, preventing 
CFGBuilder from running in the first place.

This fix recognizes locally declared C++11 `thread_local` variables as `static`.

  Assertion failed: (F != const_iterator() && "L iterator is not reachable from 
F iterator."), function distance, file 
/w/src/llvm.org/clang/lib/Analysis/CFG.cpp, line 334.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: /w/c/org/bin/clang++ -c dd.cc
  1.   parser at end of file
  2.  dd.cc:5:27: parsing function body 'fred'
   #0 0x0561c8aa llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/w/c/org/bin/clang+++0x561c8aa)
   #1 0x0561a788 llvm::sys::RunSignalHandlers() 
(/w/c/org/bin/clang+++0x561a788)
   #2 0x0557edd4 (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) 
CrashRecoveryContext.cpp:0:0
   #3 0x0557efa0 CrashRecoverySignalHandler(int) 
CrashRecoveryContext.cpp:0:0
   #4 0x0008091f35b0 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
   #5 0x0008091f2b6f thr_sighandler 
/usr/src/lib/libthr/thread/thr_sig.c:247:1
   #6 0x72d3 ([vdso]+0x2d3)
   #7 0x00080950f14a thr_kill 
/usr/obj/usr/src/amd64.amd64/lib/libc/thr_kill.S:4:0
   #8 0x000809487c34 _raise /usr/src/lib/libc/gen/raise.c:0:10
   #9 0x000809538e99 abort /usr/src/lib/libc/stdlib/abort.c:73:17
  #10 0x00080946a9d1 (/lib/libc.so.7+0x929d1)
  #11 0x07f2fa66 (anonymous 
namespace)::CFGBuilder::addAutomaticObjHandling((anonymous 
namespace)::LocalScope::const_iterator, (anonymous 
namespace)::LocalScope::const_iterator, clang::Stmt*) CFG.cpp:0:0
  #12 0x07f2adc7 (anonymous 
namespace)::CFGBuilder::VisitGotoStmt(clang::GotoStmt*) CFG.cpp:0:0
  #13 0x07f2866f (anonymous 
namespace)::CFGBuilder::VisitCompoundStmt(clang::CompoundStmt*, bool) 
CFG.cpp:0:0
  #14 0x07f2b612 (anonymous 
namespace)::CFGBuilder::VisitIfStmt(clang::IfStmt*) CFG.cpp:0:0
  #15 0x07f2866f (anonymous 
namespace)::CFGBuilder::VisitCompoundStmt(clang::CompoundStmt*, bool) 
CFG.cpp:0:0
  #16 0x07f211e4 clang::CFG::buildCFG(clang::Decl const*, clang::Stmt*, 
clang::ASTContext*, clang::CFG::BuildOptions const&) 
(/w/c/org/bin/clang+++0x7f211e4)
  #17 0x07ef12ab clang::AnalysisDeclContext::getCFG() 
(/w/c/org/bin/clang+++0x7ef12ab)
  #18 0x076bb654 
clang::sema::AnalysisBasedWarnings::IssueWarnings(clang::sema::AnalysisBasedWarnings::Policy,
 clang::sema::FunctionScopeInfo*, clang::Decl const*, clang::QualType) 
(/w/c/org/bin/clang+++0x76bb654)
  #19 0x076b05f7 
clang::Sema::PopFunctionScopeInfo(clang::sema::AnalysisBasedWarnings::Policy 
const*, clang::Decl const*, clang::QualType) (/w/c/org/bin/clang+++0x76b05f7)
  #20 0x07817aa2 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, 
clang::Stmt*, bool) (/w/c/org/bin/clang+++0x7817aa2)
  #21 0x075bb3f3 
clang::Parser::ParseFunctionStatementBody(clang::Decl*, 
clang::Parser::ParseScope&) (/w/c/org/bin/clang+++0x75bb3f3)
  #22 0x07590e34 
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, 
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) 
(/w/c/org/bin/clang+++0x7590e34)
  #23 0x07615d7d clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, 
clang::DeclaratorContext, clang::SourceLocation*, clang::Parser::ForRangeInit*) 
(/w/c/org/bin/clang+++0x7615d7d)
  #24 0x0758f681 
clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, 
clang::ParsingDeclSpec&, clang::AccessSpecifier) 
(/w/c/org/bin/clang+++0x758f681)
  #25 0x0758f0a2 
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, 
clang::ParsingDeclSpec*, clang::AccessSpecifier) 
(/w/c/org/bin/clang+++0x758f0a2)
  #26 0x0758de8b 
clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, 
clang::ParsingDeclSpec*) (/w/c/org/bin/clang+++0x758de8b)
  #27 0x0758bdcd 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, 
clang::Sema::ModuleImportState&) 

[PATCH] D125137: [clang-format] Don't remove braces if a 1-statement body would wrap

2022-05-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan planned changes to this revision.
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:465
+
+bool UnwrappedLineParser::mightFitOnOneLine() const {
+  const auto ColumnLimit = Style.ColumnLimit;

HazardyKnusperkeks wrote:
> A bit explanation what it means that something //might// fit in one line 
> would be nice.
Will do.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:479
+  if (!LastToken->isOneOf(tok::semi, tok::comment))
+return true;
+

HazardyKnusperkeks wrote:
> Especially this one is not clear to me, why do we return true here?
We will remove braces only if the previous line (i.e. the line before the 
closing brace) ends with a semi or comment. I should move this check to the 
caller or rename the function.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:481
+
+  SmallVector SavedTokens;
+  for (const auto  : PreviousLine.Tokens) {

HazardyKnusperkeks wrote:
> Is a FormatToken "big", or expensive to copy? If not I'd save them directly, 
> otherwise I'd prefer a unique_ptr.
We have to make a copy of the FormatToken here so that we can restore it after 
the TokenAnnotator modifies it directly.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:484
+FormatToken *Tok = new FormatToken;
+Tok->copyFrom(*Token.Tok);
+SavedTokens.push_back(Tok);

We must save `Token.Children` as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125137

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


[PATCH] D125142: [clang][auto-init] Remove -enable flag for "zero" mode

2022-05-07 Thread Brooks Davis via Phabricator via cfe-commits
brooks added a comment.

It would be somewhat helpful as a transition aid if 
`-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang` 
remained as a no-op producing a warning (a generic unused argument warning 
would be fine).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125142

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


[PATCH] D125172: [clangd] Disable predefined macros in tests. NFC

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang-tools-extra.

These aren't needed. With them the generated predefines buffer is 13KB.
For every TestTU, we must:

- generate the buffer (3 times: parsing preamble, scanning preamble, main file)
- parse the buffer (again 3 times)
- serialize all the macros it defines in the PCH
- compress the buffer itself to write it into the PCH
- decompress it from the PCH

Avoiding this reduces unit test time by ~25%.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125172

Files:
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp


Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -40,7 +40,9 @@
   ParseInputs Inputs;
   Inputs.FeatureModules = FeatureModules;
   auto  = Inputs.CompileCommand.CommandLine;
-  Argv = {"clang"};
+  // In tests, we don't need predefined macros (__GNUC__, __CHAR_BIT__) etc.
+  // There are hundreds, and we'd generate, parse, serialize, and re-parse 
them!
+  Argv = {"clang", "-Xclang", "-undef"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
   if (!HeaderCode.empty()) {
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -386,9 +386,9 @@
 
 using flags::FLAGS_FOO;
 
-// CLI will come from a define, __llvm__ is a built-in. In both cases, they
+// CLI will come from a define, __cplusplus is a built-in. In both cases, 
they
 // come from non-existent files.
-int y = CLI + __llvm__;
+int y = CLI + __cplusplus;
 
 int concat(a, b) = 42;
 )cpp";


Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -40,7 +40,9 @@
   ParseInputs Inputs;
   Inputs.FeatureModules = FeatureModules;
   auto  = Inputs.CompileCommand.CommandLine;
-  Argv = {"clang"};
+  // In tests, we don't need predefined macros (__GNUC__, __CHAR_BIT__) etc.
+  // There are hundreds, and we'd generate, parse, serialize, and re-parse them!
+  Argv = {"clang", "-Xclang", "-undef"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
   if (!HeaderCode.empty()) {
Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -386,9 +386,9 @@
 
 using flags::FLAGS_FOO;
 
-// CLI will come from a define, __llvm__ is a built-in. In both cases, they
+// CLI will come from a define, __cplusplus is a built-in. In both cases, they
 // come from non-existent files.
-int y = CLI + __llvm__;
+int y = CLI + __cplusplus;
 
 int concat(a, b) = 42;
 )cpp";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125171: Add a new clang-format option AlwaysBreakBeforeFunctionParameters

2022-05-07 Thread jonathan molinatto via Phabricator via cfe-commits
jrmolin created this revision.
Herald added a project: All.
jrmolin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add the definition, documentation, and implementation for a new clang-format 
option.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125171

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp

Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4042,6 +4042,18 @@
   return true;
   }
 
+  // If AlwaysBreakBeforeFunctionParameters is true, we want to break before
+  // the next parameter, if there is one.
+  if (Left.is(tok::l_paren) && Style.AlwaysBreakBeforeFunctionParameters &&
+  !Right.is(tok::r_paren)) {
+if (Left.Previous) {
+  const FormatToken  = *Left.Previous;
+  if (TwoPrevious.is(TT_FunctionDeclarationName)) {
+return true;
+  }
+}
+  }
+
   // If the last token before a '}', ']', or ')' is a comma or a trailing
   // comment, the intention is to insert a line break after it in order to make
   // shuffling around entries easier. Import statements, especially in
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -685,6 +685,8 @@
 
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
Style.AlwaysBreakBeforeMultilineStrings);
+IO.mapOptional("AlwaysBreakBeforeFunctionParameters",
+   Style.AlwaysBreakBeforeFunctionParameters);
 IO.mapOptional("AlwaysBreakTemplateDeclarations",
Style.AlwaysBreakTemplateDeclarations);
 IO.mapOptional("AttributeMacros", Style.AttributeMacros);
@@ -1367,6 +1369,7 @@
   FormatStyle::SIS_WithoutElse;
   GoogleStyle.AllowShortLoopsOnASingleLine = true;
   GoogleStyle.AlwaysBreakBeforeMultilineStrings = true;
+  GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
   GoogleStyle.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
   GoogleStyle.DerivePointerAlignment = true;
   GoogleStyle.IncludeStyle.IncludeCategories = {{"^", 2, 0, false},
@@ -1438,6 +1441,7 @@
 GoogleStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
 GoogleStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
+GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
 GoogleStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
 GoogleStyle.ColumnLimit = 100;
 GoogleStyle.SpaceAfterCStyleCast = true;
@@ -1449,6 +1453,7 @@
 // TODO: still under discussion whether to switch to SLS_All.
 GoogleStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Empty;
 GoogleStyle.AlwaysBreakBeforeMultilineStrings = false;
+GoogleStyle.AlwaysBreakBeforeFunctionParameters = false;
 GoogleStyle.BreakBeforeTernaryOperators = false;
 // taze:, triple slash directives (`/// <...`), tslint:, and @see, which is
 // commonly followed by overlong URLs.
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -335,6 +335,11 @@
 auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
 return LambdaBodyLength > getColumnLimit(State);
   }
+  // Check if we want to break before function parameters in declarations
+  if (startsNextParameter(Current, Style) &&
+  Style.AlwaysBreakBeforeFunctionParameters &&
+  State.Line->MustBeDeclaration)
+return true;
   if (Current.MustBreakBefore || Current.is(TT_InlineASMColon))
 return true;
   if (CurrentState.BreakBeforeClosingBrace &&
@@ -983,7 +988,9 @@
 // If we are breaking after '(', '{', '<', or this is the break after a ':'
 // to start a member initializater list in a constructor, this should not
 // be considered bin packing unless the relevant AllowAll option is false or
-// this is a dict/object literal.
+// this is a dict/object literal. Break if
+// AlwaysBreakBeforeFunctionParameters is true and it's a function
+// declaration.
 bool PreviousIsBreakingCtorInitializerColon =
 Previous.is(TT_CtorInitializerColon) &&
 Style.BreakConstructorInitializers == FormatStyle::BCIS_AfterColon;
@@ -995,7 +1002,9 @@
  !State.Line->MustBeDeclaration) ||
 (Style.PackConstructorInitializers != FormatStyle::PCIS_NextLine &&
  PreviousIsBreakingCtorInitializerColon) ||
-Previous.is(TT_DictLiteral))
+Previous.is(TT_DictLiteral) ||
+

[PATCH] D125170: [Headers][X86] Replace \operation with \verbatim

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

If people prefer we can alternatively use \code{.unparsed} .. \endcode blocks - 
I'm unsure if these operation blocks are being used in a particular way 
downstream


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125170

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


[PATCH] D125170: [Headers][X86] Replace \operation with \verbatim

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: pengfei, craig.topper, tianqing, xiangzhangllvm, 
LiuChen3.
Herald added a subscriber: StephenFan.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a project: clang.

\operation ... \endoperation are not valid doxygen commands and cause issues 
when -Wdocumentation is enabled (Issue #35297)

This patch proposes to replace them with \verbatim ... \endverbatim blocks so 
that the pseudo-code is correctly retained in any documentation


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125170

Files:
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlvnniintrin.h
  clang/lib/Headers/avxvnniintrin.h
  clang/lib/Headers/hresetintrin.h
  clang/lib/Headers/keylockerintrin.h
  clang/lib/Headers/uintrintrin.h

Index: clang/lib/Headers/uintrintrin.h
===
--- clang/lib/Headers/uintrintrin.h
+++ clang/lib/Headers/uintrintrin.h
@@ -39,9 +39,9 @@
 ///
 /// This intrinsic corresponds to the  CLUI  instruction.
 ///
-/// \operation
+/// \verbatim
 ///   UIF := 0
-/// \endoperation
+/// \endverbatim
 static __inline__ void __DEFAULT_FN_ATTRS
 _clui (void)
 {
@@ -60,9 +60,9 @@
 ///
 /// This intrinsic corresponds to the  STUI  instruction.
 ///
-/// \operation
+/// \verbatim
 ///   UIF := 1
-/// \endoperation
+/// \endverbatim
 static __inline__ void __DEFAULT_FN_ATTRS
 _stui (void)
 {
@@ -81,7 +81,7 @@
 ///
 /// \returns The current value of the user interrupt flag (UIF).
 ///
-/// \operation
+/// \verbatim
 ///   CF := UIF
 ///   ZF := 0
 ///   AF := 0
@@ -89,7 +89,7 @@
 ///   PF := 0
 ///   SF := 0
 ///   dst := CF
-/// \endoperation
+/// \endverbatim
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _testui (void)
 {
@@ -110,7 +110,7 @@
 ///Index of user-interrupt target table entry in user-interrupt target
 ///table.
 ///
-/// \operation
+/// \verbatim
 ///   IF __a > UITTSZ
 /// GP (0)
 ///   FI
@@ -143,7 +143,7 @@
 ///   SendOrdinaryIPI(tempUPID.NV, tempUPID.NDST[15:8])
 /// FI
 ///   FI
-/// \endoperation
+/// \endverbatim
 static __inline__ void __DEFAULT_FN_ATTRS
 _senduipi (unsigned long long __a)
 {
Index: clang/lib/Headers/keylockerintrin.h
===
--- clang/lib/Headers/keylockerintrin.h
+++ clang/lib/Headers/keylockerintrin.h
@@ -46,7 +46,7 @@
 ///
 /// This intrinsic corresponds to the  LOADIWKEY  instructions.
 ///
-/// \operation
+/// \verbatim
 /// IF CPL > 0 // LOADKWKEY only allowed at ring 0 (supervisor mode)
 ///   GP (0)
 /// FI
@@ -91,7 +91,7 @@
 /// AF := 0
 /// PF := 0
 /// CF := 0
-/// \endoperation
+/// \endverbatim
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_loadiwkey (unsigned int __ctl, __m128i __intkey,
__m128i __enkey_lo, __m128i __enkey_hi) {
@@ -106,7 +106,7 @@
 ///
 /// This intrinsic corresponds to the  ENCODEKEY128  instructions.
 ///
-/// \operation
+/// \verbatim
 /// InputKey[127:0] := __key[127:0]
 /// KeyMetadata[2:0] := __htype[2:0]
 /// KeyMetadata[23:3] := 0 // Reserved for future usage
@@ -126,7 +126,7 @@
 /// AF := 0
 /// PF := 0
 /// CF := 0
-/// \endoperation
+/// \endverbatim
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _mm_encodekey128_u32(unsigned int __htype, __m128i __key, void *__h) {
   return __builtin_ia32_encodekey128_u32(__htype, (__v2di)__key, __h);
@@ -141,7 +141,7 @@
 ///
 /// This intrinsic corresponds to the  ENCODEKEY256  instructions.
 ///
-/// \operation
+/// \verbatim
 /// InputKey[127:0] := __key_lo[127:0]
 /// InputKey[255:128] := __key_hi[255:128]
 /// KeyMetadata[2:0] := __htype[2:0]
@@ -163,7 +163,7 @@
 /// AF := 0
 /// PF := 0
 /// CF := 0
-/// \endoperation
+/// \endverbatim
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _mm_encodekey256_u32(unsigned int __htype, __m128i __key_lo, __m128i __key_hi,
  void *__h) {
@@ -179,7 +179,7 @@
 ///
 /// This intrinsic corresponds to the  AESENC128KL  instructions.
 ///
-/// \operation
+/// \verbatim
 /// Handle[383:0] := MEM[__h+383:__h] // Load is not guaranteed to be atomic.
 /// IllegalHandle := ( HandleReservedBitSet (Handle[383:0]) ||
 ///(Handle[127:0] AND (CPL > 0)) ||
@@ -202,7 +202,7 @@
 /// AF := 0
 /// PF := 0
 /// CF := 0
-/// \endoperation
+/// \endverbatim
 static __inline__ unsigned char __DEFAULT_FN_ATTRS
 _mm_aesenc128kl_u8(__m128i* __odata, __m128i __idata, const void *__h) {
   return __builtin_ia32_aesenc128kl_u8((__v2di *)__odata, (__v2di)__idata, __h);
@@ -216,7 +216,7 @@
 ///
 /// This intrinsic corresponds to the  AESENC256KL  instructions.
 ///
-/// \operation
+/// \verbatim
 /// Handle[511:0] := MEM[__h+511:__h] // Load is not guaranteed to be atomic.
 /// IllegalHandle := ( HandleReservedBitSet (Handle[511:0]) ||
 ///(Handle[127:0] AND (CPL > 0)) ||
@@ -241,7 +241,7 @@
 /// AF := 0
 /// PF := 0
 /// CF := 0
-/// \endoperation
+/// 

[PATCH] D125167: [WIP] Fix member access of anonymous struct/union fields in C

2022-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm marking this as a WIP -- the content is ready to go, but I'm no longer 
convinced we want to implement this for GCC compatibility as GCC is the only C 
compiler I can find that cares about the qualifiers: 
https://godbolt.org/z/hTqY8zMb5


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125167

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


[PATCH] D124909: Fix issues with using clangd with C++ modules

2022-05-07 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv added a comment.

@sammccall, What are the first steps that is needed for supporting modules with 
clangd. From what I see, options related to handling comments  that are 
specifically added to the compile options by clangd needs handling. This  RFC 
diff is on that note.

AFIK, since, clangd relies on clang proper for compilation action, I thought 
the module semantics would work as in normal clang compilation. I could be 
completely wrong here and  missing some details.

I am happy to look into any other requirements and iterate the diff to get it 
to where we want it to be acceptable by the community.  Any feedback welcome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124909

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


[PATCH] D125169: [clangd] Skip extra round-trip in parsing args in debug builds. NFC

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang-tools-extra.

This is a clever cross-cutting sanity test for clang's arg parsing I suppose.
But clangd creates thousands of invocations, ~all with identical trivial
arguments, and problems with these would be caught by clang's tests.
This overhead accounts for 10% of total unittest time!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125169

Files:
  clang-tools-extra/clangd/Compiler.cpp


Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,10 +85,17 @@
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs , clang::DiagnosticConsumer 
,
 std::vector *CC1Args) {
-  if (Inputs.CompileCommand.CommandLine.empty())
+  llvm::ArrayRef Argv = Inputs.CompileCommand.CommandLine;
+  if (Argv.empty())
 return nullptr;
   std::vector ArgStrs;
-  for (const auto  : Inputs.CompileCommand.CommandLine)
+  ArgStrs.reserve(Argv.size() + 1);
+  ArgStrs.push_back(Argv.front().c_str());
+  // In asserts builds, CompilerInvocation redundantly reads/parses cc1 args as
+  // a sanity test. This is not useful to clangd, and costs 10% of test time.
+  // To avoid mismatches between assert/production builds, disable it always.
+  ArgStrs.push_back("-Xclang=-no-round-trip-args");
+  for (const auto  : Argv.drop_front())
 ArgStrs.push_back(S.c_str());
 
   CreateInvocationOptions CIOpts;


Index: clang-tools-extra/clangd/Compiler.cpp
===
--- clang-tools-extra/clangd/Compiler.cpp
+++ clang-tools-extra/clangd/Compiler.cpp
@@ -85,10 +85,17 @@
 std::unique_ptr
 buildCompilerInvocation(const ParseInputs , clang::DiagnosticConsumer ,
 std::vector *CC1Args) {
-  if (Inputs.CompileCommand.CommandLine.empty())
+  llvm::ArrayRef Argv = Inputs.CompileCommand.CommandLine;
+  if (Argv.empty())
 return nullptr;
   std::vector ArgStrs;
-  for (const auto  : Inputs.CompileCommand.CommandLine)
+  ArgStrs.reserve(Argv.size() + 1);
+  ArgStrs.push_back(Argv.front().c_str());
+  // In asserts builds, CompilerInvocation redundantly reads/parses cc1 args as
+  // a sanity test. This is not useful to clangd, and costs 10% of test time.
+  // To avoid mismatches between assert/production builds, disable it always.
+  ArgStrs.push_back("-Xclang=-no-round-trip-args");
+  for (const auto  : Argv.drop_front())
 ArgStrs.push_back(S.c_str());
 
   CreateInvocationOptions CIOpts;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 427868.
RKSimon added a comment.

Remove superflouous cast from "_inc_ssp"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

Files:
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/bmiintrin.h
  clang/lib/Headers/cetintrin.h
  clang/lib/Headers/ia32intrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/rdseedintrin.h
  clang/lib/Headers/rtmintrin.h
  clang/test/Headers/x86-intrinsics-headers-clean.cpp

Index: clang/test/Headers/x86-intrinsics-headers-clean.cpp
===
--- clang/test/Headers/x86-intrinsics-headers-clean.cpp
+++ clang/test/Headers/x86-intrinsics-headers-clean.cpp
@@ -1,11 +1,11 @@
 // Make sure the intrinsic headers compile cleanly with no warnings or errors.
 
 // RUN: %clang_cc1 -ffreestanding -triple i386-unknown-unknown \
-// RUN:-Werror -Wsystem-headers -Wcast-qual \
+// RUN:-Wextra -Werror -Wsystem-headers -Wsign-conversion -Wcast-qual \
 // RUN:-fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown \
-// RUN:-Werror -Wsystem-headers -Wcast-qual \
+// RUN:-Wextra -Werror -Wsystem-headers -Wsign-conversion -Wcast-qual \
 // RUN:-fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // expected-no-diagnostics
Index: clang/lib/Headers/rtmintrin.h
===
--- clang/lib/Headers/rtmintrin.h
+++ clang/lib/Headers/rtmintrin.h
@@ -29,7 +29,7 @@
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _xbegin(void)
 {
-  return __builtin_ia32_xbegin();
+  return (unsigned int)__builtin_ia32_xbegin();
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/rdseedintrin.h
===
--- clang/lib/Headers/rdseedintrin.h
+++ clang/lib/Headers/rdseedintrin.h
@@ -20,20 +20,20 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdseed16_step(__p);
+  return (int) __builtin_ia32_rdseed16_step(__p);
 }
 
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdseed32_step(__p);
+  return (int) __builtin_ia32_rdseed32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdseed64_step(__p);
+  return (int) __builtin_ia32_rdseed64_step(__p);
 }
 #endif
 
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -276,20 +276,20 @@
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdrand16_step(__p);
+  return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdrand32_step(__p);
+  return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdrand64_step(__p);
+  return (int)__builtin_ia32_rdrand64_step(__p);
 }
 #endif
 #endif /* __RDRND__ */
@@ -360,50 +360,50 @@
 static __inline__ short __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i16(void const * __P) {
   struct __loadu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
+  return (short)__builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _storebe_i16(void * __P, short __D) {
   struct __storeu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  ((struct __storeu_i16*)__P)->__v = __builtin_bswap16(__D);
+  ((struct __storeu_i16*)__P)->__v = __builtin_bswap16((unsigned short)__D);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i32(void const * __P) {
   struct __loadu_i32 {
-int __v;
+unsigned int __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap32(((const struct __loadu_i32*)__P)->__v);
+  return (int)__builtin_bswap32(((const struct __loadu_i32*)__P)->__v);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 

[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Headers/cetintrin.h:37
 static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) {
-  __builtin_ia32_incsspd((int)__a);
+  __builtin_ia32_incsspd((unsigned int)__a);
 }

pengfei wrote:
> Unnecessary cast?
yeah, we can just remove the (int)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[clang] e7806c0 - [Headers][X86] amxintrin.h - fixed unknown parameter Wdocumentation warning. NFC

2022-05-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-05-07T16:20:39+01:00
New Revision: e7806c08dc1b1c80104029b7a28f748f7123593f

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

LOG: [Headers][X86] amxintrin.h - fixed unknown parameter Wdocumentation 
warning. NFC

Noticed while triaging Issue #35297

Added: 


Modified: 
clang/lib/Headers/amxintrin.h

Removed: 




diff  --git a/clang/lib/Headers/amxintrin.h b/clang/lib/Headers/amxintrin.h
index 4940666e8083..ec67a87e39ca 100644
--- a/clang/lib/Headers/amxintrin.h
+++ b/clang/lib/Headers/amxintrin.h
@@ -439,8 +439,6 @@ static __inline__ void __tile_dpbuud(__tile1024i *dst, 
__tile1024i src0,
 ///
 /// This intrinsic corresponds to the  TILESTORED  instruction.
 ///
-/// \param dst
-///A destination tile. Max size is 1024 Bytes.
 /// \param base
 ///A pointer to base address.
 /// \param stride



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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

> These intrinsics are interesting. The descriptions on Intrinsic guide are for 
> immediate variant, but all compilers' implementations are register variant. 
> What's more, the codegen from Clang and GCC don't seem correct according to 
> the description of `vpsrlw  zmm0, zmm0, xmm1`. They should do the same 
> broadcast as ICC. https://godbolt.org/z/dcrqdEs8q

After a second read, I found Clang and GCC's generation are also correct, I 
confused `vpsrlw  zmm0, zmm0, xmm1` with `vpsrlw  zmm0, zmm0, zmm1`. Please 
ignore the noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D124715: Add ThreadPriority::Low, and use QoS class Utility on Mac

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Looks great! I'm happy to land it, will do so on Tuesday unless anyone has 
further comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124715

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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D125164#3498752 , @RKSimon wrote:

> Actually the ia32_tzcnt builtins should stay the way they are - other C/C++ 
> intrinsics return unsigned so we'd still end up with adding explicit casts

No problem, adding explicit casts look good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D124688: [clangd] parse all make_unique-like functions in preamble

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this looks good!

- the plumbing can be simplified by moving the option into ParseOptions, sorry 
about the churn!
- we need to add some tests, probably easiest by checking for the diagnostics 
that are now produced. In `unittests/DiagnosticsTests.cpp` there's 
`TEST(DiagnosticTest, MakeUnique)` which checks the existing make_unique 
support in this way. We should have a similar function with a different name 
and verify that it does/doesn't produce diags depending on the flag. We should 
probably also have a check that two levels of forwarding works.




Comment at: clang-tools-extra/clangd/Preamble.cpp:150
+  // std::make_unique is trivial, and we diagnose bad constructor 
calls.
+  if (FT->isInStdNamespace() && II->isStr("make_unique"))
+return false;

nit: reverse the order of the && here, the isStr should be cheaper to check



Comment at: clang-tools-extra/clangd/Preamble.cpp:155
+  }
+  // Slow path: Check whether its last parameter is a parameter pack...
+  if (const auto *FD = FT->getAsFunction()) {

rather than inlining all this here, can you pull out a function 
`isLikelyForwardingFunction(FunctionTemplateDecl*)`?
That documents the high-level goal and moves that logic away from the flow 
control of the different types of decls/options that shouldSkipFunctionBody 
deals with. It also avoids the confusing "return false" when you found what you 
were looking for!



Comment at: clang-tools-extra/clangd/Preamble.cpp:155
+  }
+  // Slow path: Check whether its last parameter is a parameter pack...
+  if (const auto *FD = FT->getAsFunction()) {

sammccall wrote:
> rather than inlining all this here, can you pull out a function 
> `isLikelyForwardingFunction(FunctionTemplateDecl*)`?
> That documents the high-level goal and moves that logic away from the flow 
> control of the different types of decls/options that shouldSkipFunctionBody 
> deals with. It also avoids the confusing "return false" when you found what 
> you were looking for!
somewhere we need to explain *why* we're parsing these functions. Something 
like:

```Usually we don't need to look inside the bodies of header functions to 
understand the program. However when forwarding function like emplace() forward 
their arguments to some other function, the interesting overload resolution 
happens inside the forwarding function's body. To provide more meaningful 
meaningful diagnostics, code completion, and parameter hints we should parse 
(and later instantiate) the bodies.```

This could either be here, or possibly on the option inside ParseOptions.



Comment at: clang-tools-extra/clangd/Preamble.cpp:156
+  // Slow path: Check whether its last parameter is a parameter pack...
+  if (const auto *FD = FT->getAsFunction()) {
+const auto NumParams = FD->getNumParams();

nit: getTemplatedDecl().

(getAsFunction() is a loose do-what-I-mean helper, and you know the precise 
case you're dealing with here)

There's no need for a null check here, you can't have a FunctionTemplateDecl 
with no function.



Comment at: clang-tools-extra/clangd/Preamble.cpp:160
+  const auto *LastParam = FD->getParamDecl(NumParams - 1);
+  if (isa(LastParam->getType())) {
+const auto *PackTypePtr =

nit: if (const auto* PET = dyn_cast(LastParam->getType()))
and then use it below



Comment at: clang-tools-extra/clangd/Preamble.cpp:163
+dyn_cast(LastParam->getType()
+   .getNonPackExpansionType()
+   .getNonReferenceType()

again, this is a loose function where you can use a precise one.
PET->getPattern()



Comment at: clang-tools-extra/clangd/Preamble.cpp:167
+// ... whose template parameter comes from the function directly
+if (FT->getTemplateParameters()->getDepth() ==
+PackTypePtr->getDepth()) {

upsj wrote:
> Can PackTypePtr ever be nullptr?
sure: `template  int foo(T*...)`.
or even some other more exotic derived type.

I don't think we want to include that case, so a null check is fine, with 
another comment: `// ... of the form T&&...`



Comment at: clang-tools-extra/clangd/Preamble.h:103
   const ParseInputs , bool StoreInMemory,
+  bool ParseForwardingFunctions,
   PreambleParsedCallback PreambleCallback,

instead of passing this as a separate parameter, if you make it part of the 
ParseOptions then it's available in ParseInputs.
This reduces the amount of plumbing/noise needed.



Comment at: clang-tools-extra/clangd/TUScheduler.h:208
+
+// If true, parse make_unique-like 

[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

> What do you want to do about _mm512_maskz_srli_epi16 ? The Intel Intrinsic 
> guide has the same mismatch.

These intrinsics are interesting. The descriptions on Intrinsic guide are for 
immediate variant, but all compilers' implementations are register variant. 
What's more, the codegen from Clang and GCC don't seem correct according to the 
description of `vpsrlw  zmm0, zmm0, xmm1`. They should do the same broadcast as 
ICC.

Back to the question, I think the type in Clang's intrinsics match with 
Intrinsic guide. They just not match each other. I guess it might be historical 
reasons, so let's keep them and using cast?




Comment at: clang/lib/Headers/cetintrin.h:37
 static __inline__ void __DEFAULT_FN_ATTRS _inc_ssp(unsigned int __a) {
-  __builtin_ia32_incsspd((int)__a);
+  __builtin_ia32_incsspd((unsigned int)__a);
 }

Unnecessary cast?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D125167: Fix member access of anonymous struct/union fields in C

2022-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, nickdesaulniers, erichkeane, jyknight, 
clang-language-wg.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

We were accepting invalid code where the qualifiers of the anonymous structure 
were not taken into account when forming a member access to one of the indirect 
fields, as in:

  struct S {
const struct {
  int i;
};
  } s;
  
  void foo(void) {
s.i = 12; // previously accepted, now rejected
  }

We now expose the anonymous structure's field as having a qualified type 
instead of an unqualified type so that access checking notes that an 
intermediate object in the expression is qualified. We also adjusted the 
diagnostic so that it's slightly more user friendly despite this being a rather 
rare case.

Note, this only impacts C; in C++ and with the Microsoft C anonymous structure 
extension, the qualifiers are stripped.

Fixes #48099


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125167

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/anonymous-struct-union.c
  clang/test/Sema/anonymous-struct-union.cpp

Index: clang/test/Sema/anonymous-struct-union.cpp
===
--- /dev/null
+++ clang/test/Sema/anonymous-struct-union.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -Wno-microsoft-anon-tag -x c %s
+// expected-no-diagnostics
+
+struct trivial {
+  int a;
+};
+
+struct GH48099 {
+  const struct {
+int i;
+  };
+#ifndef __cplusplus
+  // This extension is only allowed in C.
+  const struct trivial;
+#endif
+};
+
+// In C++, qualifiers are ignored on the anonymous objects.
+void GH48099_test(void) {
+  struct GH48099 x;
+
+#ifdef __cplusplus  
+  // Test that the member access ignores the qualifiers. This would fail in C.
+  x.i = 12; // ok
+#else
+  // Test that the member access ignores the qualifiers for a Microsoft C
+  // anonymous structure declaration. This would fail in C++ because the
+  // declaration in GH48099 does not declare anything (so 'a' isn't lifted into
+  // the outer structure).
+  x.a = 12; // ok
+#endif
+}
+
Index: clang/test/Sema/anonymous-struct-union.c
===
--- clang/test/Sema/anonymous-struct-union.c
+++ clang/test/Sema/anonymous-struct-union.c
@@ -119,3 +119,26 @@
   struct s3 s;
   s.A = 1; // expected-warning {{'A' is deprecated}}
 }
+
+struct GH48099 {
+  const struct { // expected-note {{anonymous struct declared const here}}
+int i;
+  };
+  volatile union {
+int j;
+  };
+};
+
+// Ensure that qualifiers from the anonymous object are reflected on the
+// fields being hoisted into the outer context.
+void GH48099_test(void) {
+  struct GH48099 x;
+
+  // It's the access path that picks up the qualifiers, not the direct
+  // declaration of the field itself. So 'i' and 'j' are both 'int'.
+  _Static_assert(_Generic(x.i, int : 1, default : 0), "i is not int?");
+  _Static_assert(_Generic(x.j, int : 1, default : 0), "j is not int?");
+
+  // Test that the member access picks up the qualifiers.
+  x.i = 12; // expected-error {{cannot assign to non-static data member 'i' with const-qualified type 'const int'}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -13351,6 +13351,7 @@
   ConstMember,
   ConstMethod,
   NestedConstMember,
+  ConstAnonymousObject, // Only used as a note
   ConstUnknown,  // Keep as last element
 };
 
@@ -13370,6 +13371,10 @@
   // next checked expression is the result of a dereference.
   bool IsDereference = false;
   bool NextIsDereference = false;
+  // Used when diagnosing indirect fields that are const because the anonymous
+  // object is const rather than the field. This allows us to diagnose the
+  // field rather than the anonymous object.
+  const FieldDecl *LastNamedField = nullptr;
 
   // Loop to process MemberExpr chains.
   while (true) {
@@ -13388,16 +13393,44 @@
 
 if (!IsTypeModifiable(Field->getType(), IsDereference)) {
   if (!DiagnosticEmitted) {
-S.Diag(Loc, diag::err_typecheck_assign_const)
-<< ExprRange << ConstMember << false /*static*/ << Field
-<< Field->getType();
+// If the field is an anonymous union or structure, we want to
+// diagnose the last named field rather than the unnamed object.
+// This requires us to combine the qualifiers from the anonymous
+// object with those of the field in order for the diagnostic to
+// make sense.
+if (Field->isAnonymousStructOrUnion()) {
+   

[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 427863.
RKSimon added a comment.

Move the exhaustive headers checks into x86-intrinsics-headers-clean.cpp as 
that's what its for


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

Files:
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/bmiintrin.h
  clang/lib/Headers/cetintrin.h
  clang/lib/Headers/ia32intrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/rdseedintrin.h
  clang/lib/Headers/rtmintrin.h
  clang/test/Headers/x86-intrinsics-headers-clean.cpp

Index: clang/test/Headers/x86-intrinsics-headers-clean.cpp
===
--- clang/test/Headers/x86-intrinsics-headers-clean.cpp
+++ clang/test/Headers/x86-intrinsics-headers-clean.cpp
@@ -1,11 +1,11 @@
 // Make sure the intrinsic headers compile cleanly with no warnings or errors.
 
 // RUN: %clang_cc1 -ffreestanding -triple i386-unknown-unknown \
-// RUN:-Werror -Wsystem-headers -Wcast-qual \
+// RUN:-Wextra -Werror -Wsystem-headers -Wsign-conversion -Wcast-qual \
 // RUN:-fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown \
-// RUN:-Werror -Wsystem-headers -Wcast-qual \
+// RUN:-Wextra -Werror -Wsystem-headers -Wsign-conversion -Wcast-qual \
 // RUN:-fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // expected-no-diagnostics
Index: clang/lib/Headers/rtmintrin.h
===
--- clang/lib/Headers/rtmintrin.h
+++ clang/lib/Headers/rtmintrin.h
@@ -29,7 +29,7 @@
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _xbegin(void)
 {
-  return __builtin_ia32_xbegin();
+  return (unsigned int)__builtin_ia32_xbegin();
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/rdseedintrin.h
===
--- clang/lib/Headers/rdseedintrin.h
+++ clang/lib/Headers/rdseedintrin.h
@@ -20,20 +20,20 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdseed16_step(__p);
+  return (int) __builtin_ia32_rdseed16_step(__p);
 }
 
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdseed32_step(__p);
+  return (int) __builtin_ia32_rdseed32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdseed64_step(__p);
+  return (int) __builtin_ia32_rdseed64_step(__p);
 }
 #endif
 
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -276,20 +276,20 @@
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdrand16_step(__p);
+  return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdrand32_step(__p);
+  return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdrand64_step(__p);
+  return (int)__builtin_ia32_rdrand64_step(__p);
 }
 #endif
 #endif /* __RDRND__ */
@@ -360,50 +360,50 @@
 static __inline__ short __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i16(void const * __P) {
   struct __loadu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
+  return (short)__builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _storebe_i16(void * __P, short __D) {
   struct __storeu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  ((struct __storeu_i16*)__P)->__v = __builtin_bswap16(__D);
+  ((struct __storeu_i16*)__P)->__v = __builtin_bswap16((unsigned short)__D);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i32(void const * __P) {
   struct __loadu_i32 {
-int __v;
+unsigned int __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap32(((const struct __loadu_i32*)__P)->__v);
+  return (int)__builtin_bswap32(((const struct __loadu_i32*)__P)->__v);
 }
 
 static __inline__ void 

[PATCH] D124147: [clang][cmake] correct grammar and style inconsistency

2022-05-07 Thread Mohammed Keyvanzadeh via Phabricator via cfe-commits
VoltrexMaster updated this revision to Diff 427862.
VoltrexMaster added a comment.

Rebase and add upstream changes to resolve conflicts.


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

https://reviews.llvm.org/D124147

Files:
  clang/CMakeLists.txt

Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -1,6 +1,6 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-# If we are not building as a part of LLVM, build Clang as an
+# If we are not building as a part of LLVM, build Clang as a
 # standalone project, using LLVM as an external library:
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(Clang)
@@ -11,7 +11,7 @@
 include(GNUInstallDirs)
 
 if(CLANG_BUILT_STANDALONE)
-  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
+  set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to.")
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
@@ -21,7 +21,7 @@
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
 message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
+  deprecated.  The installed CMake files should be used \
   instead.  CMake should be able to detect your LLVM install \
   automatically, but you can also use LLVM_DIR to specify \
   the path containing LLVMConfig.cmake.")
@@ -65,7 +65,7 @@
 
   if(NOT MSVC_IDE)
 set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
-  CACHE BOOL "Enable assertions")
+  CACHE BOOL "Enable assertions.")
 # Assertions should follow llvm-config's.
 mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
   endif()
@@ -75,7 +75,7 @@
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
-  if (NOT LLVM_CONFIG_FOUND)
+  if(NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
 set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
@@ -86,11 +86,11 @@
 set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
   endif()
 
-  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include")
-  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to llvm/include.")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree.")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source tree.")
+  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to llvm/bin.")
+  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib.")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
@@ -110,7 +110,7 @@
 
   option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
 "Set to ON to force using an old, unsupported host toolchain." OFF)
-  option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
+  option(CLANG_ENABLE_BOOTSTRAP "Generate the Clang bootstrap target." OFF)
   option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
 
   include(AddLLVM)
@@ -124,16 +124,16 @@
   set(BUG_REPORT_URL "${LLVM_PACKAGE_BUGREPORT}" CACHE STRING
 "Default URL where bug reports are to be submitted.")
 
-  if (NOT DEFINED LLVM_INCLUDE_TESTS)
+  if(NOT DEFINED LLVM_INCLUDE_TESTS)
 set(LLVM_INCLUDE_TESTS ON)
   endif()
 
   include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
   link_directories("${LLVM_LIBRARY_DIR}")
 
-  set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
-  set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
-  set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
+  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
+  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
 
   if(LLVM_INCLUDE_TESTS)
 find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
@@ -147,7 +147,7 @@
 endif()
 
 if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
-  # Note: path not really used, except for checking if lit was found
+  # Note: path not really used, except for checking if Lit was found.
   set(LLVM_LIT ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
   if(EXISTS ${LLVM_MAIN_SRC_DIR}/utils/llvm-lit)
 add_subdirectory(${LLVM_MAIN_SRC_DIR}/utils/llvm-lit utils/llvm-lit)
@@ -170,7 +170,7 @@
   find_program(LLVM_LIT
NAMES llvm-lit lit.py lit
   

[clang] 4750be4 - [X86] Add 32-bit target test coverage to clean header tests

2022-05-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-05-07T15:23:46+01:00
New Revision: 4750be4907bc22c1b7575fa53c3568628d6cbbe4

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

LOG: [X86] Add 32-bit target test coverage to clean header tests

Added: 


Modified: 
clang/test/Headers/x86-intrinsics-headers-clean.cpp

Removed: 




diff  --git a/clang/test/Headers/x86-intrinsics-headers-clean.cpp 
b/clang/test/Headers/x86-intrinsics-headers-clean.cpp
index d0b86bafb0a64..b196148bd82dd 100644
--- a/clang/test/Headers/x86-intrinsics-headers-clean.cpp
+++ b/clang/test/Headers/x86-intrinsics-headers-clean.cpp
@@ -1,7 +1,12 @@
 // Make sure the intrinsic headers compile cleanly with no warnings or errors.
 
-// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown 
-Wsystem-headers \
-// RUN:   -Wcast-qual -fsyntax-only -flax-vector-conversions=none -x c++ 
-verify %s
+// RUN: %clang_cc1 -ffreestanding -triple i386-unknown-unknown \
+// RUN:-Werror -Wsystem-headers -Wcast-qual \
+// RUN:-fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
+
+// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown \
+// RUN:-Werror -Wsystem-headers -Wcast-qual \
+// RUN:-fsyntax-only -flax-vector-conversions=none -x c++ -verify %s
 
 // expected-no-diagnostics
 



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


[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 427861.
upsj added a comment.

fix iterator invalidation issue, handle UnresolvedLookupExpr and test recursive 
and split variadic lookup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -170,6 +170,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -182,6 +219,19 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, NamePartiallyInDefinition) {
+  // Parameter name picked up from definition if necessary.
+  assertParameterHints(R"cpp(
+void foo(int, int b);
+void bar() {
+  foo($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
 TEST(ParameterHints, NameMismatch) {
   // Prefer name from declaration.
   assertParameterHints(R"cpp(
@@ -254,6 +304,168 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlain) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicSplitRecursive) {
+  // Name for 

[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 427860.
RKSimon added a comment.

Fix signedness on 32-bit cet tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

Files:
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/bmiintrin.h
  clang/lib/Headers/cetintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/rdseedintrin.h
  clang/lib/Headers/rtmintrin.h
  clang/test/CodeGen/X86/avx512bw-builtins.c
  clang/test/CodeGen/X86/rdrand-builtins.c

Index: clang/test/CodeGen/X86/rdrand-builtins.c
===
--- clang/test/CodeGen/X86/rdrand-builtins.c
+++ clang/test/CodeGen/X86/rdrand-builtins.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +rdrnd -target-feature +rdseed -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
-// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding %s -triple=i386-unknown-unknown -target-feature +rdrnd -target-feature +rdseed -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +rdrnd -target-feature +rdseed -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding %s -triple=i386-unknown-unknown -target-feature +rdrnd -target-feature +rdseed -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s --check-prefixes=CHECK
 
 #include 
 
Index: clang/test/CodeGen/X86/avx512bw-builtins.c
===
--- clang/test/CodeGen/X86/avx512bw-builtins.c
+++ clang/test/CodeGen/X86/avx512bw-builtins.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -fno-signed-char -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -fno-signed-char -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s
 
 
 #include 
Index: clang/lib/Headers/rtmintrin.h
===
--- clang/lib/Headers/rtmintrin.h
+++ clang/lib/Headers/rtmintrin.h
@@ -29,7 +29,7 @@
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _xbegin(void)
 {
-  return __builtin_ia32_xbegin();
+  return (unsigned int)__builtin_ia32_xbegin();
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/rdseedintrin.h
===
--- clang/lib/Headers/rdseedintrin.h
+++ clang/lib/Headers/rdseedintrin.h
@@ -20,20 +20,20 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdseed16_step(__p);
+  return (int) __builtin_ia32_rdseed16_step(__p);
 }
 
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdseed32_step(__p);
+  return (int) __builtin_ia32_rdseed32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdseed64_step(__p);
+  return (int) __builtin_ia32_rdseed64_step(__p);
 }
 #endif
 
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -276,20 +276,20 @@
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdrand16_step(__p);
+  return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdrand32_step(__p);
+  return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdrand64_step(__p);
+  return 

[PATCH] D125165: [Clang] Introduce clang-offload-binary tool to bundle device files

2022-05-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 427858.
jhuber6 added a comment.

Fix missing file in test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125165

Files:
  clang/docs/ClangOffloadBinary.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/amdgpu-openmp-toolchain-new.c
  clang/test/Driver/cuda-openmp-driver.cu
  clang/test/Driver/cuda-phases.cu
  clang/test/Driver/linker-wrapper-image.c
  clang/test/Driver/linker-wrapper.c
  clang/test/Driver/openmp-offload-gpu-new.c
  clang/test/Driver/openmp-offload-infer.c
  clang/test/Frontend/embed-object.c
  clang/test/Frontend/embed-object.ll
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-offload-binary/CMakeLists.txt
  clang/tools/clang-offload-binary/ClangOffloadBinary.cpp

Index: clang/tools/clang-offload-binary/ClangOffloadBinary.cpp
===
--- /dev/null
+++ clang/tools/clang-offload-binary/ClangOffloadBinary.cpp
@@ -0,0 +1,111 @@
+//===-- clang-offload-binary/ClangOffloadBinary.cpp - object file bunder --===//
+//
+// 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
+//
+//===-===//
+//
+// This tool takes several device object files and bundles them into a single
+// binary image using a custom binary format. This is intended to be used to
+// embed many device files into an application to create a fat binary.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+static cl::OptionCategory
+ClangOffloadBinaryCategory("clang-offload-binary options");
+
+static cl::opt OutputFile("o", cl::Required,
+   cl::desc("Write output to ."),
+   cl::value_desc("file"),
+   cl::cat(ClangOffloadBinaryCategory));
+
+static cl::list DeviceImages(
+"image", cl::ZeroOrMore, cl::desc("List of key and value arguments."),
+cl::value_desc("=,..."), cl::cat(ClangOffloadBinaryCategory));
+
+static void PrintVersion(raw_ostream ) {
+  OS << clang::getClangToolFullVersion("clang-offload-binary") << '\n';
+}
+
+int main(int argc, const char **argv) {
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  cl::HideUnrelatedOptions(ClangOffloadBinaryCategory);
+  cl::SetVersionPrinter(PrintVersion);
+  cl::ParseCommandLineOptions(
+  argc, argv,
+  "A utility for bundling several object files into a single binary.\n"
+  "The output binary can then be embedded into the host section table\n"
+  "to create a fatbinary containing offloading code.\n");
+
+  if (Help) {
+cl::PrintHelpMessage();
+return EXIT_SUCCESS;
+  }
+
+  auto reportError = [argv](Error E) {
+logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
+return EXIT_FAILURE;
+  };
+
+  SmallVector BinaryData;
+  raw_svector_ostream OS(BinaryData);
+  for (StringRef Image : DeviceImages) {
+StringMap Args;
+for (StringRef Arg : llvm::split(Image, ","))
+  Args.insert(Arg.split("="));
+
+if (!Args.count("triple") || !Args.count("file"))
+  return reportError(createStringError(
+  inconvertibleErrorCode(),
+  "'file' and 'triple' are required image arguments"));
+
+OffloadBinary::OffloadingImage ImageBinary{};
+std::unique_ptr DeviceImage;
+for (const auto  : Args) {
+  StringRef Key = KeyAndValue.getKey();
+  if (Key == "file") {
+llvm::ErrorOr> ObjectOrErr =
+llvm::MemoryBuffer::getFileOrSTDIN(KeyAndValue.getValue());
+if (std::error_code EC = ObjectOrErr.getError())
+  return reportError(errorCodeToError(EC));
+DeviceImage = std::move(*ObjectOrErr);
+ImageBinary.Image = *DeviceImage;
+ImageBinary.TheImageKind = getImageKind(
+sys::path::extension(KeyAndValue.getValue()).drop_front());
+  } else if (Key == "kind") {
+

[clang] 2cd080c - [X86] rdrand-builtins.c - add 32-bit target coverage and enable -Wall/-Werror

2022-05-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-05-07T14:35:42+01:00
New Revision: 2cd080c884a3dd1fc673f02afd48bfe9ba01ce89

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

LOG: [X86] rdrand-builtins.c - add 32-bit target coverage and enable 
-Wall/-Werror

Added: 


Modified: 
clang/test/CodeGen/X86/rdrand-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/rdrand-builtins.c 
b/clang/test/CodeGen/X86/rdrand-builtins.c
index f85624c643f9..4eb17a400fa8 100644
--- a/clang/test/CodeGen/X86/rdrand-builtins.c
+++ b/clang/test/CodeGen/X86/rdrand-builtins.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -ffreestanding -triple x86_64-unknown-unknown 
-target-feature +rdrnd -target-feature +rdseed -emit-llvm -o - %s | FileCheck %s
-
+// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding %s 
-triple=x86_64-unknown-unknown -target-feature +rdrnd -target-feature +rdseed 
-emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK,X64
+// RUN: %clang_cc1 -no-opaque-pointers -ffreestanding %s 
-triple=i386-unknown-unknown -target-feature +rdrnd -target-feature +rdseed 
-emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes=CHECK
 
 #include 
 
@@ -20,9 +20,9 @@ int rdrand32(unsigned *p) {
 #if __x86_64__
 int rdrand64(unsigned long long *p) {
   return _rdrand64_step(p);
-// CHECK: @rdrand64
-// CHECK: call { i64, i32 } @llvm.x86.rdrand.64
-// CHECK: store i64
+// X64: @rdrand64
+// X64: call { i64, i32 } @llvm.x86.rdrand.64
+// X64: store i64
 }
 #endif
 
@@ -43,8 +43,8 @@ int rdseed32(unsigned *p) {
 #if __x86_64__
 int rdseed64(unsigned long long *p) {
   return _rdseed64_step(p);
-// CHECK: @rdseed64
-// CHECK: call { i64, i32 } @llvm.x86.rdseed.64
-// CHECK: store i64
+// X64: @rdseed64
+// X64: call { i64, i32 } @llvm.x86.rdseed.64
+// X64: store i64
 }
 #endif



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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Actually the ia32_tzcnt builtins should stay the way they are - other C/C++ 
intrinsics return unsigned so we'd still end up with adding explicit casts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D125166: [clang-fuzzer] Add a tiny tool to generate a fuzzing dictionary for clang

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, morehouse.
Herald added a subscriber: mgorny.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It should be useful clang-fuzzer itself, though my own motivation is
to use this in fuzzing clang-pseudo. (clang-tools-extra/pseudo/fuzzer).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125166

Files:
  clang/test/CMakeLists.txt
  clang/test/Misc/fuzzer-dictionary.test
  clang/tools/clang-fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
  clang/tools/clang-fuzzer/dictionary/dictionary.c

Index: clang/tools/clang-fuzzer/dictionary/dictionary.c
===
--- /dev/null
+++ clang/tools/clang-fuzzer/dictionary/dictionary.c
@@ -0,0 +1,57 @@
+//===-- dictionary.c - Generate fuzzing dictionary for clang --===//
+//
+// 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
+//
+//===--===//
+//
+// This binary emits a fuzzing dictionary describing strings that are
+// significant to the clang parser: keywords and other tokens.
+//
+// The dictionary can be used by a fuzzer to reach interesting parser states
+// much more quickly.
+//
+// The output is a single-file dictionary supported by libFuzzer and AFL:
+// https://llvm.org/docs/LibFuzzer.html#dictionaries
+//
+//===--===//
+
+#include 
+
+static void emit(const char *Name, const char *Spelling) {
+  static char Hex[] = "0123456789abcdef";
+
+  printf("%s=\"", Name);
+  unsigned char C;
+  while ((C = *Spelling++)) {
+if (C < 32 || C == '"' || C == '\\')
+  printf("\\x%c%c", Hex[C>>4], Hex[C%16]);
+else
+  printf("%c", C);
+  }
+  printf("\"\n");
+}
+
+int main(int argc, char **argv) {
+#define PUNCTUATOR(Name, Spelling) emit(#Name, Spelling);
+#define KEYWORD(Name, Criteria) emit(#Name, #Name);
+#define PPKEYWORD(Name) emit(#Name, #Name);
+#define CXX_KEYWORD_OPERATOR(Name, Equivalent) emit(#Name, #Name);
+#define OBJC_AT_KEYWORD(Name) emit(#Name, #Name);
+#define ALIAS(Spelling, Equivalent, Criteria) emit(Spelling, Spelling);
+#include "clang/Basic/TokenKinds.def"
+  // Some other sub-token chunks significant to the lexer.
+  emit("ucn16", "\\u");
+  emit("ucn32", "\\U");
+  emit("rawstart", "R\"(");
+  emit("rawend", ")\"");
+  emit("quote", "\"");
+  emit("squote", "'");
+  emit("u8quote", "u8\"");
+  emit("u16quote", "u\"");
+  emit("u32quote", "U\"");
+  emit("esc_nl", "\\\n");
+  emit("hex", "0x");
+}
+
Index: clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/clang-fuzzer/dictionary/CMakeLists.txt
@@ -0,0 +1,2 @@
+add_clang_executable(clang-fuzzer-dictionary dictionary.c)
+
Index: clang/tools/clang-fuzzer/CMakeLists.txt
===
--- clang/tools/clang-fuzzer/CMakeLists.txt
+++ clang/tools/clang-fuzzer/CMakeLists.txt
@@ -109,6 +109,7 @@
 
 add_clang_subdirectory(handle-cxx)
 add_clang_subdirectory(handle-llvm)
+add_clang_subdirectory(dictionary)
 
 add_clang_executable(clang-fuzzer
   EXCLUDE_FROM_ALL
Index: clang/test/Misc/fuzzer-dictionary.test
===
--- /dev/null
+++ clang/test/Misc/fuzzer-dictionary.test
@@ -0,0 +1,4 @@
+RUN: clang-fuzzer-dictionary | FileCheck %s
+CHECK-DAG: ampamp="&&"
+CHECK-DAG: catch="catch"
+CHECK-DAG: rawstart="R\x22("
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -58,6 +58,7 @@
   apinotes-test
   c-index-test
   clang
+  clang-fuzzer-dictionary
   clang-resource-headers
   clang-format
   clang-tblgen
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 427855.
upsj added a comment.

updated patch baseline


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -170,6 +170,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -254,6 +291,123 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlain) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, MatchingNameVariadicForwarded) {
+  // No name hint for variadic parameter with matching name
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int a;
+  bar(a);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, MatchingNameVariadicPlain) {
+  // No name hint for variadic parameter with matching name
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  int a;
+  

[PATCH] D124977: [NFC][Clang] Modify expect of fail test or XFAIL because CSKY align is different

2022-05-07 Thread Renato Golin via Phabricator via cfe-commits
rengolin added inline comments.



Comment at: clang/test/Sema/builtin-alloca-with-align.c:32
 void test8(void) {
+#if defined(__csky__)
   __builtin_alloca_with_align(sizeof(__INT64_TYPE__), 
__alignof__(__INT64_TYPE__)); // expected-warning {{second argument to 
__builtin_alloca_with_align is supposed to be in bits}}

zixuan-wu wrote:
> rengolin wrote:
> > This test is platform agnostic, perhaps the extra error could be in a new 
> > test, exclusively for csky?
> Then I prefer to split the file and add UNSUPPORTED for CSKY in the other 
> file which only contains test8
But then you wouldn't be testing the extra error you want... hmm.

Maybe it would be fine the way you did it originally.

Would be nice to get a clang person to give their opinion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124977

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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D125164#3498723 , @pengfei wrote:

> One question: is it better to change the define of builtins than explicit 
> casts?

I can fix the signedness of the cet / rdseed / xbgen / tzcnt x86 builtins if 
there's a consensus.

What do you want to do about _mm512_maskz_srli_epi16 ? The Intel Intrinsic 
guide has the same mismatch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D124688: [clangd] parse all make_unique-like functions in preamble

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 427854.
upsj added a comment.

accidentally pushed to the wrong revision, this is the previous version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124688

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -101,7 +101,9 @@
   auto ModuleCacheDeleter = llvm::make_scope_exit(
   std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
   return clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
-  /*StoreInMemory=*/true, PreambleCallback);
+  /*StoreInMemory=*/true,
+  /*ParseForwardingFunctions=*/false,
+  PreambleCallback);
 }
 
 ParsedAST TestTU::build() const {
@@ -115,9 +117,10 @@
   auto ModuleCacheDeleter = llvm::make_scope_exit(
   std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
 
-  auto Preamble = clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
-   /*StoreInMemory=*/true,
-   /*PreambleCallback=*/nullptr);
+  auto Preamble =
+  clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
+   /*StoreInMemory=*/true,
+   /*PreambleCallback=*/false, nullptr);
   auto AST = ParsedAST::build(testPath(Filename), Inputs, std::move(CI),
   Diags.take(), Preamble);
   if (!AST.hasValue()) {
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -173,7 +173,8 @@
   TU.AdditionalFiles["c.h"] = "";
   auto PI = TU.inputs(FS);
   auto BaselinePreamble = buildPreamble(
-  TU.Filename, *buildCompilerInvocation(PI, Diags), PI, true, nullptr);
+  TU.Filename, *buildCompilerInvocation(PI, Diags), PI,
+  /*StoreInMemory=*/true, /*ParseForwardingFunctions=*/false, nullptr);
   // We drop c.h from modified and add a new header. Since the latter is patched
   // we should only get a.h in preamble includes.
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -497,7 +497,8 @@
   auto Inputs = TU.inputs(FS);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   auto EmptyPreamble =
-  buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
+  buildPreamble(testPath("foo.cpp"), *CI, Inputs, /*StoreInMemory=*/true,
+/*PreambleCallback=*/false, nullptr);
   ASSERT_TRUE(EmptyPreamble);
   EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, IsEmpty());
 
@@ -540,7 +541,8 @@
   auto Inputs = TU.inputs(FS);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   auto BaselinePreamble =
-  buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
+  buildPreamble(testPath("foo.cpp"), *CI, Inputs, /*StoreInMemory=*/true,
+/*PreambleCallback=*/false, nullptr);
   ASSERT_TRUE(BaselinePreamble);
   EXPECT_THAT(BaselinePreamble->Includes.MainFileIncludes,
   ElementsAre(testing::Field(::Written, "")));
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -306,7 +306,7 @@
   FileIndex Index;
   bool IndexUpdated = false;
   buildPreamble(FooCpp, *CI, PI,
-/*StoreInMemory=*/true,
+/*StoreInMemory=*/true, /*ParseForwardingFunctions=*/false,
 [&](ASTContext , Preprocessor ,
 const CanonicalIncludes ) {
   EXPECT_FALSE(IndexUpdated)
Index: 

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 427853.
upsj marked an inline comment as done.
upsj added a comment.

Work around the currently broken isExpandedParameter, also fix the broken diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -170,6 +170,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -254,6 +291,123 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlain) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, MatchingNameVariadicForwarded) {
+  // No name hint for variadic parameter with matching name
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int a;
+  bar(a);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, MatchingNameVariadicPlain) {
+  // No name hint for variadic parameter with matching name
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+ 

[PATCH] D124688: [clangd] parse all make_unique-like functions in preamble

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 427852.
upsj added a comment.

Work around the currently broken isExpandedParameter, also fix the broken diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124688

Files:
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -170,6 +170,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -254,6 +291,123 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlain) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar($param[[42]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, MatchingNameVariadicForwarded) {
+  // No name hint for variadic parameter with matching name
+  // The forward prototype is not correct, but is converted into builtin anyways
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int a);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  int a;
+  bar(a);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, MatchingNameVariadicPlain) {
+  // No name hint for variadic parameter with matching name
+  assertParameterHints(R"cpp(
+void foo(int a);
+template 
+void bar(Args&&... args) { return 

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj marked 10 inline comments as done.
upsj added a comment.

This almost works now, the only thing that needs to be fixed is 
`isExpandedParameter`, which for some reason picks up the first call, but not 
the second: (Compare `ParameterHints.Forwarded` and 
`ParameterHints.VariadicPlain`)

  cpp
  void foo(int a);
  template 
  void bar(Args&&... args) { return foo(args...); }
  void baz() {
int b;
bar(42); // This parameter is recognized as expanded
bar(b); // This one doesn't, so its inlay hint is @args: instead of a:
  }




Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:178
+  // No hint for anonymous variadic parameter
+  // The prototype is not correct, but is converted into builtin anyways.
+  assertParameterHints(R"cpp(

nridge wrote:
> What does "converted into builtin" mean here?
I am talking about std::forward being a builtin function, which can be detected 
by its BuiltinID, so it doesn't matter if the signature doesn't match 100%.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

One question: is it better to change the define of builtins than explicit casts?




Comment at: clang/lib/Headers/cetintrin.h:26
 #ifdef __x86_64__
 static __inline__ void __DEFAULT_FN_ATTRS _incsspq(unsigned long long __a) {
   __builtin_ia32_incsspq(__a);

RKSimon wrote:
> @pengfei The Intel Intrisics guide has this taking a int ?
I think both make sense in some way. The instruction `incsspq` only takes the 
low 8-bit of a 64-bit register, but the operand is still 64-bit anyway.
I'm not sure which one we should change. Might be Clang given we specify 
`unsigned int` for `_inc_ssp`? Any special reason we use `unsigned long long` 
here @craig.topper ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-07 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 427851.
upsj added a comment.
Herald added a subscriber: javed.absar.

use an RecursiveASTVisitor instead of ASTMatcher


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/PreambleTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -101,7 +101,9 @@
   auto ModuleCacheDeleter = llvm::make_scope_exit(
   std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
   return clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
-  /*StoreInMemory=*/true, PreambleCallback);
+  /*StoreInMemory=*/true,
+  /*ParseForwardingFunctions=*/false,
+  PreambleCallback);
 }
 
 ParsedAST TestTU::build() const {
@@ -115,9 +117,10 @@
   auto ModuleCacheDeleter = llvm::make_scope_exit(
   std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
 
-  auto Preamble = clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
-   /*StoreInMemory=*/true,
-   /*PreambleCallback=*/nullptr);
+  auto Preamble =
+  clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
+   /*StoreInMemory=*/true,
+   /*PreambleCallback=*/false, nullptr);
   auto AST = ParsedAST::build(testPath(Filename), Inputs, std::move(CI),
   Diags.take(), Preamble);
   if (!AST.hasValue()) {
Index: clang-tools-extra/clangd/unittests/PreambleTests.cpp
===
--- clang-tools-extra/clangd/unittests/PreambleTests.cpp
+++ clang-tools-extra/clangd/unittests/PreambleTests.cpp
@@ -173,7 +173,8 @@
   TU.AdditionalFiles["c.h"] = "";
   auto PI = TU.inputs(FS);
   auto BaselinePreamble = buildPreamble(
-  TU.Filename, *buildCompilerInvocation(PI, Diags), PI, true, nullptr);
+  TU.Filename, *buildCompilerInvocation(PI, Diags), PI,
+  /*StoreInMemory=*/true, /*ParseForwardingFunctions=*/false, nullptr);
   // We drop c.h from modified and add a new header. Since the latter is patched
   // we should only get a.h in preamble includes.
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -497,7 +497,8 @@
   auto Inputs = TU.inputs(FS);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   auto EmptyPreamble =
-  buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
+  buildPreamble(testPath("foo.cpp"), *CI, Inputs, /*StoreInMemory=*/true,
+/*PreambleCallback=*/false, nullptr);
   ASSERT_TRUE(EmptyPreamble);
   EXPECT_THAT(EmptyPreamble->Includes.MainFileIncludes, IsEmpty());
 
@@ -540,7 +541,8 @@
   auto Inputs = TU.inputs(FS);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   auto BaselinePreamble =
-  buildPreamble(testPath("foo.cpp"), *CI, Inputs, true, nullptr);
+  buildPreamble(testPath("foo.cpp"), *CI, Inputs, /*StoreInMemory=*/true,
+/*PreambleCallback=*/false, nullptr);
   ASSERT_TRUE(BaselinePreamble);
   EXPECT_THAT(BaselinePreamble->Includes.MainFileIncludes,
   ElementsAre(testing::Field(::Written, "")));
Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -170,6 +170,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, 

[clang] 6e34542 - [X86] Remove unused 'hint' argument from prefetch tests

2022-05-07 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2022-05-07T13:38:40+01:00
New Revision: 6e345426de370479c322962f7aa1dd1cde817adf

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

LOG: [X86] Remove unused 'hint' argument from prefetch tests

hint is a compile time constant and can't be passed in as a variable - we 
already hardcode

Added: 


Modified: 
clang/test/CodeGen/X86/avx512pf-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx512pf-builtins.c 
b/clang/test/CodeGen/X86/avx512pf-builtins.c
index e1b63d7208eac..4ca70f5787968 100644
--- a/clang/test/CodeGen/X86/avx512pf-builtins.c
+++ b/clang/test/CodeGen/X86/avx512pf-builtins.c
@@ -3,49 +3,49 @@
 
 #include 
 
-void test_mm512_mask_prefetch_i32gather_pd(__m256i index, __mmask8 mask, void 
const *addr, int hint) {
+void test_mm512_mask_prefetch_i32gather_pd(__m256i index, __mmask8 mask, void 
const *addr) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i32gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.dpd
   return _mm512_mask_prefetch_i32gather_pd(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_prefetch_i32gather_pd(__m256i index, void const *addr, int 
hint) {
+void test_mm512_prefetch_i32gather_pd(__m256i index, void const *addr) {
   // CHECK-LABEL: @test_mm512_prefetch_i32gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.dpd
   return _mm512_prefetch_i32gather_pd(index, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, void 
const *addr, int hint) {
+void test_mm512_mask_prefetch_i32gather_ps(__m512i index, __mmask16 mask, void 
const *addr) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i32gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.dps
   return _mm512_mask_prefetch_i32gather_ps(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_prefetch_i32gather_ps(__m512i index,  void const *addr, int 
hint) {
+void test_mm512_prefetch_i32gather_ps(__m512i index,  void const *addr) {
   // CHECK-LABEL: @test_mm512_prefetch_i32gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.dps
   return _mm512_prefetch_i32gather_ps(index, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_mask_prefetch_i64gather_pd(__m512i index, __mmask8 mask, void 
const *addr, int hint) {
+void test_mm512_mask_prefetch_i64gather_pd(__m512i index, __mmask8 mask, void 
const *addr) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i64gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.qpd
   return _mm512_mask_prefetch_i64gather_pd(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_prefetch_i64gather_pd(__m512i index, void const *addr, int 
hint) {
+void test_mm512_prefetch_i64gather_pd(__m512i index, void const *addr) {
   // CHECK-LABEL: @test_mm512_prefetch_i64gather_pd
   // CHECK: @llvm.x86.avx512.gatherpf.qpd
   return _mm512_prefetch_i64gather_pd(index, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_mask_prefetch_i64gather_ps(__m512i index, __mmask8 mask, void 
const *addr, int hint) {
+void test_mm512_mask_prefetch_i64gather_ps(__m512i index, __mmask8 mask, void 
const *addr) {
   // CHECK-LABEL: @test_mm512_mask_prefetch_i64gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.qps
   return _mm512_mask_prefetch_i64gather_ps(index, mask, addr, 2, _MM_HINT_T0); 
 }
 
-void test_mm512_prefetch_i64gather_ps(__m512i index, void const *addr, int 
hint) {
+void test_mm512_prefetch_i64gather_ps(__m512i index, void const *addr) {
   // CHECK-LABEL: @test_mm512_prefetch_i64gather_ps
   // CHECK: @llvm.x86.avx512.gatherpf.qps
   return _mm512_prefetch_i64gather_ps(index, addr, 2, _MM_HINT_T0); 



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


[PATCH] D125165: [Clang] Introduce clang-offload-binary tool to bundle device files

2022-05-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 427849.
jhuber6 added a comment.

Fix test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125165

Files:
  clang/docs/ClangOffloadBinary.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/amdgpu-openmp-toolchain-new.c
  clang/test/Driver/cuda-openmp-driver.cu
  clang/test/Driver/cuda-phases.cu
  clang/test/Driver/linker-wrapper-image.c
  clang/test/Driver/linker-wrapper.c
  clang/test/Driver/openmp-offload-gpu-new.c
  clang/test/Driver/openmp-offload-infer.c
  clang/test/Frontend/embed-object.c
  clang/test/Frontend/embed-object.ll
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-offload-binary/CMakeLists.txt
  clang/tools/clang-offload-binary/ClangOffloadBinary.cpp

Index: clang/tools/clang-offload-binary/ClangOffloadBinary.cpp
===
--- /dev/null
+++ clang/tools/clang-offload-binary/ClangOffloadBinary.cpp
@@ -0,0 +1,111 @@
+//===-- clang-offload-binary/ClangOffloadBinary.cpp - object file bunder --===//
+//
+// 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
+//
+//===-===//
+//
+// This tool takes several device object files and bundles them into a single
+// binary image using a custom binary format. This is intended to be used to
+// embed many device files into an application to create a fat binary.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+static cl::OptionCategory
+ClangOffloadBinaryCategory("clang-offload-binary options");
+
+static cl::opt OutputFile("o", cl::Required,
+   cl::desc("Write output to ."),
+   cl::value_desc("file"),
+   cl::cat(ClangOffloadBinaryCategory));
+
+static cl::list DeviceImages(
+"image", cl::ZeroOrMore, cl::desc("List of key and value arguments."),
+cl::value_desc("=,..."), cl::cat(ClangOffloadBinaryCategory));
+
+static void PrintVersion(raw_ostream ) {
+  OS << clang::getClangToolFullVersion("clang-offload-binary") << '\n';
+}
+
+int main(int argc, const char **argv) {
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  cl::HideUnrelatedOptions(ClangOffloadBinaryCategory);
+  cl::SetVersionPrinter(PrintVersion);
+  cl::ParseCommandLineOptions(
+  argc, argv,
+  "A utility for bundling several object files into a single binary.\n"
+  "The output binary can then be embedded into the host section table\n"
+  "to create a fatbinary containing offloading code.\n");
+
+  if (Help) {
+cl::PrintHelpMessage();
+return EXIT_SUCCESS;
+  }
+
+  auto reportError = [argv](Error E) {
+logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
+return EXIT_FAILURE;
+  };
+
+  SmallVector BinaryData;
+  raw_svector_ostream OS(BinaryData);
+  for (StringRef Image : DeviceImages) {
+StringMap Args;
+for (StringRef Arg : llvm::split(Image, ","))
+  Args.insert(Arg.split("="));
+
+if (!Args.count("triple") || !Args.count("file"))
+  return reportError(createStringError(
+  inconvertibleErrorCode(),
+  "'file' and 'triple' are required image arguments"));
+
+OffloadBinary::OffloadingImage ImageBinary{};
+std::unique_ptr DeviceImage;
+for (const auto  : Args) {
+  StringRef Key = KeyAndValue.getKey();
+  if (Key == "file") {
+llvm::ErrorOr> ObjectOrErr =
+llvm::MemoryBuffer::getFileOrSTDIN(KeyAndValue.getValue());
+if (std::error_code EC = ObjectOrErr.getError())
+  return reportError(errorCodeToError(EC));
+DeviceImage = std::move(*ObjectOrErr);
+ImageBinary.Image = *DeviceImage;
+ImageBinary.TheImageKind = getImageKind(
+sys::path::extension(KeyAndValue.getValue()).drop_front());
+  } else if (Key == "kind") {
+

[PATCH] D125165: [Clang] Introduce clang-offload-binary tool to bundle device files

2022-05-07 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, saiislam, yaxunl, tra.
Herald added subscribers: ormris, kerbowa, mgorny, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a project: clang.

In order to do offloading compilation we need to embed files into the
host and create fatbainaries. Clang uses a special binary format to
bundle several files along with their metadata into a single binary
image. This is currently performed using the `-fembed-offload-binary`
option. However this is not very extensibile since it requires changing
the command flag every time we want to add something and makes optional
arguments difficult. This patch introduces a new tool called
`clang-offload-binary` that behaves similarly to CUDA's `fatbinary`.
This tool takes several input files with metadata and embeds it into a
single image that can then be embedded in the host.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125165

Files:
  clang/docs/ClangOffloadBinary.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Action.h
  clang/include/clang/Driver/ToolChain.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/Action.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Clang.h
  clang/test/Driver/amdgpu-openmp-toolchain-new.c
  clang/test/Driver/cuda-openmp-driver.cu
  clang/test/Driver/cuda-phases.cu
  clang/test/Driver/linker-wrapper-image.c
  clang/test/Driver/linker-wrapper.c
  clang/test/Driver/openmp-offload-gpu-new.c
  clang/test/Driver/openmp-offload-infer.c
  clang/test/Frontend/embed-object.c
  clang/test/Frontend/embed-object.ll
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-offload-binary/CMakeLists.txt
  clang/tools/clang-offload-binary/ClangOffloadBinary.cpp

Index: clang/tools/clang-offload-binary/ClangOffloadBinary.cpp
===
--- /dev/null
+++ clang/tools/clang-offload-binary/ClangOffloadBinary.cpp
@@ -0,0 +1,111 @@
+//===-- clang-offload-binary/ClangOffloadBinary.cpp - object file bunder --===//
+//
+// 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
+//
+//===-===//
+//
+// This tool takes several device object files and bundles them into a single
+// binary image using a custom binary format. This is intended to be used to
+// embed many device files into an application to create a fat binary.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::object;
+
+static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+
+static cl::OptionCategory
+ClangOffloadBinaryCategory("clang-offload-binary options");
+
+static cl::opt OutputFile("o", cl::Required,
+   cl::desc("Write output to ."),
+   cl::value_desc("file"),
+   cl::cat(ClangOffloadBinaryCategory));
+
+static cl::list DeviceImages(
+"image", cl::ZeroOrMore, cl::desc("List of key and value arguments."),
+cl::value_desc("=,..."), cl::cat(ClangOffloadBinaryCategory));
+
+static void PrintVersion(raw_ostream ) {
+  OS << clang::getClangToolFullVersion("clang-offload-binary") << '\n';
+}
+
+int main(int argc, const char **argv) {
+  sys::PrintStackTraceOnErrorSignal(argv[0]);
+  cl::HideUnrelatedOptions(ClangOffloadBinaryCategory);
+  cl::SetVersionPrinter(PrintVersion);
+  cl::ParseCommandLineOptions(
+  argc, argv,
+  "A utility for bundling several object files into a single binary.\n"
+  "The output binary can then be embedded into the host section table\n"
+  "to create a fatbinary containing offloading code.\n");
+
+  if (Help) {
+cl::PrintHelpMessage();
+return EXIT_SUCCESS;
+  }
+
+  auto reportError = [argv](Error E) {
+logAllUnhandledErrors(std::move(E), WithColor::error(errs(), argv[0]));
+return EXIT_FAILURE;
+  };
+
+  SmallVector BinaryData;
+  raw_svector_ostream OS(BinaryData);
+  for (StringRef Image : DeviceImages) {
+StringMap Args;
+for (StringRef Arg : llvm::split(Image, ","))
+  Args.insert(Arg.split("="));
+
+if (!Args.count("triple") || 

[PATCH] D124658: [analyzer] Canonicalize SymIntExpr so the RHS is positive when possible

2022-05-07 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

The patch doesn't apply to me.


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

https://reviews.llvm.org/D124658

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


[clang] e571e1a - Reland "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR."

2022-05-07 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-07T13:49:54+02:00
New Revision: e571e1a6c356ef045a69220cb8a96e6e26a72209

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

LOG: Reland "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on 
IR."

This reverts commit a1bb952e833b34fdf03bd571e7f8c948191be018.

I'd somehow missed updating llvm-yaml-parser-fuzzer, now fixed.

Added: 


Modified: 
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt
llvm/lib/FuzzMutate/CMakeLists.txt
llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-parser-fuzzer/CMakeLists.txt
mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index 5600a354decb3..eaf4478585290 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt 
b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
index fc583de8b011b..556c2f438d388 100644
--- a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index 4b2243c5ceb97..80ae9b611f65b 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_LIB_FUZZING_ENGINE)

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt 
b/llvm/lib/FuzzMutate/CMakeLists.txt
index 47ddeb5e1d2a9..0aea7fe0d8f0f 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,9 +1,23 @@
-add_llvm_component_library(LLVMFuzzMutate
+# Generic helper for fuzzer binaries.
+# This should not depend on LLVM IR etc.
+add_llvm_component_library(LLVMFuzzerCLI
   FuzzerCLI.cpp
+  PARTIAL_SOURCES_INTENDED
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
+
+  LINK_COMPONENTS
+  Support
+  )
+
+# Library for using LLVM IR together with fuzzers.
+add_llvm_component_library(LLVMFuzzMutate
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
+  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

diff  --git a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
index 5f90def79847b..427aff5c6d2ea 100644
--- a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 6ce0835f0465a..32b65384144ce 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
 BitWriter
 CodeGen
 Core
+FuzzerCLI
 FuzzMutate
 IRReader
 MC

diff  --git a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
index 07f02a35b2031..18b160d2b9c8b 100644
--- a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
index d3db43a686bbd..bacb88a3d5633 100644
--- a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-opt-fuzzer/CMakeLists.txt 

[clang-tools-extra] e571e1a - Reland "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR."

2022-05-07 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-07T13:49:54+02:00
New Revision: e571e1a6c356ef045a69220cb8a96e6e26a72209

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

LOG: Reland "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on 
IR."

This reverts commit a1bb952e833b34fdf03bd571e7f8c948191be018.

I'd somehow missed updating llvm-yaml-parser-fuzzer, now fixed.

Added: 


Modified: 
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt
llvm/lib/FuzzMutate/CMakeLists.txt
llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-parser-fuzzer/CMakeLists.txt
mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index 5600a354decb3..eaf4478585290 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt 
b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
index fc583de8b011b..556c2f438d388 100644
--- a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index 4b2243c5ceb97..80ae9b611f65b 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_LIB_FUZZING_ENGINE)

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt 
b/llvm/lib/FuzzMutate/CMakeLists.txt
index 47ddeb5e1d2a9..0aea7fe0d8f0f 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,9 +1,23 @@
-add_llvm_component_library(LLVMFuzzMutate
+# Generic helper for fuzzer binaries.
+# This should not depend on LLVM IR etc.
+add_llvm_component_library(LLVMFuzzerCLI
   FuzzerCLI.cpp
+  PARTIAL_SOURCES_INTENDED
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
+
+  LINK_COMPONENTS
+  Support
+  )
+
+# Library for using LLVM IR together with fuzzers.
+add_llvm_component_library(LLVMFuzzMutate
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
+  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

diff  --git a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
index 5f90def79847b..427aff5c6d2ea 100644
--- a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 6ce0835f0465a..32b65384144ce 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
 BitWriter
 CodeGen
 Core
+FuzzerCLI
 FuzzMutate
 IRReader
 MC

diff  --git a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
index 07f02a35b2031..18b160d2b9c8b 100644
--- a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
index d3db43a686bbd..bacb88a3d5633 100644
--- a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-opt-fuzzer/CMakeLists.txt 

[PATCH] D125162: [clang-format] fix alignment w/o binpacked args

2022-05-07 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

FYI, I like to have a bug report because people that encounter the same problem 
(in an older release) can find it easily, and see if/when it was fixed. It also 
avoid working on the same thing by different people.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125162

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


[PATCH] D125162: [clang-format] fix alignment w/o binpacked args

2022-05-07 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius requested changes to this revision.
curdeius added a comment.
This revision now requires changes to proceed.

Thanks for working on this!
Is there a bug report somewhere? If not, may you create one please?




Comment at: clang/lib/Format/WhitespaceManager.cpp:398
+Changes[i].Tok->is(tok::l_brace) &&
+Changes[i].Tok->is(BK_BracedInit)) {
+  return true;

Elide braces please.



Comment at: clang/unittests/Format/FormatTest.cpp:17321
+
+verifyFormat(Expected, ToFormat, Alignment);
+  }

I don't think you need to create variables, just online the strings.

Also, could you minimize (and possibly split) as much as possible these test 
cases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125162

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


[PATCH] D125162: [clang-format] fix alignment w/o binpacked args

2022-05-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

For me there needs no bug report, but could you comment on the misformatting 
without the patch?




Comment at: clang/unittests/Format/FormatTest.cpp:17289
+  Alignment.BinPackArguments = false;
+  {
+const char *Expected = "struct A {\n"

Drop the scope, we don't have that in other tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125162

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


[PATCH] D125081: [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for reverting, looks like I missed a target, sorry about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125081

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


[PATCH] D125081: [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

2022-05-07 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Sorry for the trouble, but I had to revert in 
a1bb952e833b34fdf03bd571e7f8c948191be018 
 because 
this broke a lot of bots:

https://lab.llvm.org/buildbot/#/builders/171/builds/14222
https://lab.llvm.org/buildbot/#/builders/188/builds/13748
https://lab.llvm.org/buildbot/#/builders/109/builds/38127


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125081

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


[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/lib/Headers/cetintrin.h:26
 #ifdef __x86_64__
 static __inline__ void __DEFAULT_FN_ATTRS _incsspq(unsigned long long __a) {
   __builtin_ia32_incsspq(__a);

@pengfei The Intel Intrisics guide has this taking a int ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

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


[clang-tools-extra] a1bb952 - Revert "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR."

2022-05-07 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-05-07T07:29:57-04:00
New Revision: a1bb952e833b34fdf03bd571e7f8c948191be018

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

LOG: Revert "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on 
IR."

This reverts commit 1c5e85b3da649c89db87abecc53b42f6eaa574c2.

It broke a lot of bots with a link error:
https://lab.llvm.org/buildbot/#/builders/171/builds/14222
https://lab.llvm.org/buildbot/#/builders/188/builds/13748
https://lab.llvm.org/buildbot/#/builders/109/builds/38127

Added: 


Modified: 
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt
llvm/lib/FuzzMutate/CMakeLists.txt
llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index eaf4478585290..5600a354decb3 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzerCLI
+  FuzzMutate
   Support
   )
 

diff  --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt 
b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
index 556c2f438d388..fc583de8b011b 100644
--- a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzerCLI
+  FuzzMutate
   Support
   )
 

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index 80ae9b611f65b..4b2243c5ceb97 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_LIB_FUZZING_ENGINE)

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt 
b/llvm/lib/FuzzMutate/CMakeLists.txt
index 0aea7fe0d8f0f..47ddeb5e1d2a9 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,23 +1,9 @@
-# Generic helper for fuzzer binaries.
-# This should not depend on LLVM IR etc.
-add_llvm_component_library(LLVMFuzzerCLI
-  FuzzerCLI.cpp
-  PARTIAL_SOURCES_INTENDED
-
-  ADDITIONAL_HEADER_DIRS
-  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
-
-  LINK_COMPONENTS
-  Support
-  )
-
-# Library for using LLVM IR together with fuzzers.
 add_llvm_component_library(LLVMFuzzMutate
+  FuzzerCLI.cpp
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
-  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

diff  --git a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
index 427aff5c6d2ea..5f90def79847b 100644
--- a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzerCLI
+  FuzzMutate
   Support
 )
 

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 32b65384144ce..6ce0835f0465a 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,7 +9,6 @@ set(LLVM_LINK_COMPONENTS
 BitWriter
 CodeGen
 Core
-FuzzerCLI
 FuzzMutate
 IRReader
 MC

diff  --git a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
index 18b160d2b9c8b..07f02a35b2031 100644
--- a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzerCLI
+  FuzzMutate
   Support
 )
 

diff  --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
index bacb88a3d5633..d3db43a686bbd 100644
--- a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzerCLI
+  FuzzMutate
   Support
 )
 

diff  --git 

[clang] a1bb952 - Revert "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR."

2022-05-07 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-05-07T07:29:57-04:00
New Revision: a1bb952e833b34fdf03bd571e7f8c948191be018

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

LOG: Revert "[FuzzMutate] Split out FuzzerCLI library that doesn't depend on 
IR."

This reverts commit 1c5e85b3da649c89db87abecc53b42f6eaa574c2.

It broke a lot of bots with a link error:
https://lab.llvm.org/buildbot/#/builders/171/builds/14222
https://lab.llvm.org/buildbot/#/builders/188/builds/13748
https://lab.llvm.org/buildbot/#/builders/109/builds/38127

Added: 


Modified: 
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt
llvm/lib/FuzzMutate/CMakeLists.txt
llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index eaf4478585290..5600a354decb3 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzerCLI
+  FuzzMutate
   Support
   )
 

diff  --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt 
b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
index 556c2f438d388..fc583de8b011b 100644
--- a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzerCLI
+  FuzzMutate
   Support
   )
 

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index 80ae9b611f65b..4b2243c5ceb97 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_LIB_FUZZING_ENGINE)

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt 
b/llvm/lib/FuzzMutate/CMakeLists.txt
index 0aea7fe0d8f0f..47ddeb5e1d2a9 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,23 +1,9 @@
-# Generic helper for fuzzer binaries.
-# This should not depend on LLVM IR etc.
-add_llvm_component_library(LLVMFuzzerCLI
-  FuzzerCLI.cpp
-  PARTIAL_SOURCES_INTENDED
-
-  ADDITIONAL_HEADER_DIRS
-  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
-
-  LINK_COMPONENTS
-  Support
-  )
-
-# Library for using LLVM IR together with fuzzers.
 add_llvm_component_library(LLVMFuzzMutate
+  FuzzerCLI.cpp
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
-  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

diff  --git a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
index 427aff5c6d2ea..5f90def79847b 100644
--- a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzerCLI
+  FuzzMutate
   Support
 )
 

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 32b65384144ce..6ce0835f0465a 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,7 +9,6 @@ set(LLVM_LINK_COMPONENTS
 BitWriter
 CodeGen
 Core
-FuzzerCLI
 FuzzMutate
 IRReader
 MC

diff  --git a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
index 18b160d2b9c8b..07f02a35b2031 100644
--- a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzerCLI
+  FuzzMutate
   Support
 )
 

diff  --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
index bacb88a3d5633..d3db43a686bbd 100644
--- a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzerCLI
+  FuzzMutate
   Support
 )
 

diff  --git 

[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon updated this revision to Diff 427844.
RKSimon added a comment.

Remove a couple of superfluous casts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125164

Files:
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/bmiintrin.h
  clang/lib/Headers/cetintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/rdseedintrin.h
  clang/lib/Headers/rtmintrin.h
  clang/test/CodeGen/X86/avx512bw-builtins.c

Index: clang/test/CodeGen/X86/avx512bw-builtins.c
===
--- clang/test/CodeGen/X86/avx512bw-builtins.c
+++ clang/test/CodeGen/X86/avx512bw-builtins.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -fno-signed-char -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -fno-signed-char -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s
 
 
 #include 
Index: clang/lib/Headers/rtmintrin.h
===
--- clang/lib/Headers/rtmintrin.h
+++ clang/lib/Headers/rtmintrin.h
@@ -29,7 +29,7 @@
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _xbegin(void)
 {
-  return __builtin_ia32_xbegin();
+  return (unsigned int)__builtin_ia32_xbegin();
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/rdseedintrin.h
===
--- clang/lib/Headers/rdseedintrin.h
+++ clang/lib/Headers/rdseedintrin.h
@@ -20,20 +20,20 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdseed16_step(__p);
+  return (int) __builtin_ia32_rdseed16_step(__p);
 }
 
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdseed32_step(__p);
+  return (int) __builtin_ia32_rdseed32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdseed64_step(__p);
+  return (int) __builtin_ia32_rdseed64_step(__p);
 }
 #endif
 
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -276,20 +276,20 @@
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdrand16_step(__p);
+  return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdrand32_step(__p);
+  return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdrand64_step(__p);
+  return (int)__builtin_ia32_rdrand64_step(__p);
 }
 #endif
 #endif /* __RDRND__ */
@@ -360,50 +360,50 @@
 static __inline__ short __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i16(void const * __P) {
   struct __loadu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
+  return (short)__builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _storebe_i16(void * __P, short __D) {
   struct __storeu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  ((struct __storeu_i16*)__P)->__v = __builtin_bswap16(__D);
+  ((struct __storeu_i16*)__P)->__v = __builtin_bswap16((unsigned short)__D);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i32(void const * __P) {
   struct __loadu_i32 {
-int __v;
+unsigned int __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap32(((const struct 

[PATCH] D125164: [X86] Fix some signedness errors in x86 headers

2022-05-07 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: pengfei, craig.topper.
Herald added a subscriber: StephenFan.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a project: clang.

Another step toward enabling -Wsystem-headers testing across all x86 headers

Fix a number of cases where the arg / return value signedness doesn't match the 
C/C++ intrinsic.

So far I've just added explicit casts as necessary, but we might want to 
address some of the mismatches directly:

e.g.

  _mm512_srli_epi16(__m512i __A, unsigned int __B)
  _mm512_mask_srli_epi16(__m512i __W, __mmask32 __U, __m512i __A, unsigned int 
__B)
  _mm512_maskz_srli_epi16(__mmask32 __U, __m512i __A, int __B)  // < 
unsigned int?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125164

Files:
  clang/lib/Headers/avx512bwintrin.h
  clang/lib/Headers/avx512fintrin.h
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/lib/Headers/avx512vlbwintrin.h
  clang/lib/Headers/avx512vlintrin.h
  clang/lib/Headers/bmiintrin.h
  clang/lib/Headers/cetintrin.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/rdseedintrin.h
  clang/lib/Headers/rtmintrin.h
  clang/test/CodeGen/X86/avx512bw-builtins.c

Index: clang/test/CodeGen/X86/avx512bw-builtins.c
===
--- clang/test/CodeGen/X86/avx512bw-builtins.c
+++ clang/test/CodeGen/X86/avx512bw-builtins.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
-// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -fno-signed-char -emit-llvm -o - -Wall -Werror -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +avx512bw -fno-signed-char -emit-llvm -o - -Wall -Werror -Wsystem-headers -Wsign-conversion | FileCheck %s
 
 
 #include 
Index: clang/lib/Headers/rtmintrin.h
===
--- clang/lib/Headers/rtmintrin.h
+++ clang/lib/Headers/rtmintrin.h
@@ -29,7 +29,7 @@
 static __inline__ unsigned int __DEFAULT_FN_ATTRS
 _xbegin(void)
 {
-  return __builtin_ia32_xbegin();
+  return (unsigned int)__builtin_ia32_xbegin();
 }
 
 static __inline__ void __DEFAULT_FN_ATTRS
Index: clang/lib/Headers/rdseedintrin.h
===
--- clang/lib/Headers/rdseedintrin.h
+++ clang/lib/Headers/rdseedintrin.h
@@ -20,20 +20,20 @@
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdseed16_step(__p);
+  return (int) __builtin_ia32_rdseed16_step(__p);
 }
 
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdseed32_step(__p);
+  return (int) __builtin_ia32_rdseed32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __DEFAULT_FN_ATTRS
 _rdseed64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdseed64_step(__p);
+  return (int) __builtin_ia32_rdseed64_step(__p);
 }
 #endif
 
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -276,20 +276,20 @@
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
-  return __builtin_ia32_rdrand16_step(__p);
+  return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
-  return __builtin_ia32_rdrand32_step(__p);
+  return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
 {
-  return __builtin_ia32_rdrand64_step(__p);
+  return (int)__builtin_ia32_rdrand64_step(__p);
 }
 #endif
 #endif /* __RDRND__ */
@@ -360,50 +360,50 @@
 static __inline__ short __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _loadbe_i16(void const * __P) {
   struct __loadu_i16 {
-short __v;
+unsigned short __v;
   } __attribute__((__packed__, __may_alias__));
-  return __builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
+  return (short)__builtin_bswap16(((const struct __loadu_i16*)__P)->__v);
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movbe")))
 _storebe_i16(void * 

[clang-tools-extra] 8614674 - Fix underlining in docs to fix the sphinx build

2022-05-07 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-05-07T07:21:43-04:00
New Revision: 8614674b55669025e349324f31eb11505becede1

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

LOG: Fix underlining in docs to fix the sphinx build

Added: 


Modified: 

clang-tools-extra/docs/clang-tidy/checks/bugprone-unchecked-optional-access.rst

Removed: 




diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-unchecked-optional-access.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-unchecked-optional-access.rst
index 56ce90c726b2a..9c53c8a6d175f 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone-unchecked-optional-access.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone-unchecked-optional-access.rst
@@ -211,7 +211,7 @@ instead, check explicitly that the optional object has a 
value. For example:
 instead of the `HasProperty`, `GetProperty` pairing we saw above.
 
 Do not rely on caller-performed checks
-~
+~~
 
 If you know that all of a function's callers have checked that an optional
 argument has a value, either change the function to take the value directly or



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


[PATCH] D125162: [clang-format] fix alignment w/o binpacked args

2022-05-07 Thread cha5on via Phabricator via cfe-commits
cha5on created this revision.
Herald added a project: All.
cha5on requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The combination of

- AlignConsecutiveAssignments.Enabled = true
- BinPackArguments = false

would result in the first continuation line of a braced-init-list being
improperly indented (missing a shift) when in a continued function call.
Indentation was also wrong for braced-init-lists continuing a
direct-list-initialization.  Check for opening braced lists in
continuation and ensure that the correct shift occurs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125162

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17280,6 +17280,46 @@
   //  "ccc ? a : b,\n"
   //  "dd);",
   //  Alignment);
+
+  // Confirm proper handling of AlignConsecutiveAssignments with
+  // BinPackArguments.
+  Alignment = getLLVMStyleWithColumns(50);
+  Alignment.AlignConsecutiveAssignments.Enabled = true;
+  Alignment.BinPackArguments = false;
+  {
+const char *Expected = "struct A {\n"
+   "  int a;\n"
+   "  int b;\n"
+   "};\n"
+   "struct B {\n"
+   "  A a1;\n"
+   "  A a2;\n"
+   "};\n"
+   "int a_longer_name_for_wrap = 1;\n"
+   "// comment to prevent alignment\n"
+   "int a_long_name = 1;\n"
+   "auto b  = B({a_long_name, a_long_name},\n"
+   "{a_longer_name_for_wrap,\n"
+   " a_longer_name_for_wrap});";
+
+const char *ToFormat = "struct A {\n"
+   "int a;\n"
+   "int  b;\n"
+   "};\n"
+   "struct B{\n"
+   " A a1;\n"
+   "  A a2;\n"
+   "};\n"
+   "int a_longer_name_for_wrap = 1;\n"
+   "// comment to prevent alignment\n"
+   "int a_long_name = 1;\n"
+   "auto b  = B({a_long_name,\n"
+   " a_long_name},\n"
+   " {a_longer_name_for_wrap,\n"
+   "a_longer_name_for_wrap});";
+
+verifyFormat(Expected, ToFormat, Alignment);
+  }
 }
 
 TEST_F(FormatTest, AlignConsecutiveBitFields) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -371,6 +371,9 @@
 return false;
   if (Changes[ScopeStart].NewlinesBefore > 0)
 return false;
+  if (Changes[i].Tok->is(tok::l_brace) &&
+  Changes[i].Tok->is(BK_BracedInit))
+return true;
   return Style.BinPackArguments;
 }
 
@@ -387,6 +390,15 @@
 Changes[i].Tok->Previous->is(TT_ConditionalExpr))
   return true;
 
+// Continued direct-list-initialization using braced list.
+if (ScopeStart > Start + 1 &&
+Changes[ScopeStart - 2].Tok->is(tok::identifier) &&
+Changes[ScopeStart - 1].Tok->is(tok::l_brace) &&
+Changes[i].Tok->is(tok::l_brace) &&
+Changes[i].Tok->is(BK_BracedInit)) {
+  return true;
+}
+
 // Continued braced list.
 if (ScopeStart > Start + 1 &&
 Changes[ScopeStart - 2].Tok->isNot(tok::identifier) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17280,6 +17280,46 @@
   //  "ccc ? a : b,\n"
   //  "dd);",
   //  Alignment);
+
+  // Confirm proper handling of AlignConsecutiveAssignments with
+  // BinPackArguments.
+  Alignment = getLLVMStyleWithColumns(50);
+  Alignment.AlignConsecutiveAssignments.Enabled = true;
+  Alignment.BinPackArguments = false;
+  {
+const char *Expected = "struct A {\n"
+   "  int a;\n"
+   "  int b;\n"
+   "};\n"
+   "struct B {\n"
+   "  A a1;\n"
+   "  A a2;\n"
+   "};\n"
+  

[PATCH] D125137: [clang-format] Don't remove braces if a 1-statement body would wrap

2022-05-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:465
+
+bool UnwrappedLineParser::mightFitOnOneLine() const {
+  const auto ColumnLimit = Style.ColumnLimit;

A bit explanation what it means that something //might// fit in one line would 
be nice.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:479
+  if (!LastToken->isOneOf(tok::semi, tok::comment))
+return true;
+

Especially this one is not clear to me, why do we return true here?



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:481
+
+  SmallVector SavedTokens;
+  for (const auto  : PreviousLine.Tokens) {

Is a FormatToken "big", or expensive to copy? If not I'd save them directly, 
otherwise I'd prefer a unique_ptr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125137

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


[PATCH] D124836: [AArch64] Add support for -fzero-call-used-regs

2022-05-07 Thread Bill Wendling via Phabricator via cfe-commits
void added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp:682
+// The called routine is expected to preserve r19-r28
+// r29 and r30 are used as frame pointer and link register resp.
+return 0;

nickdesaulniers wrote:
> What happens if `-fomit-frame-pointer` is specified? Is X29 used as a GPR 
> then?
GCC only clears registers R0-R18 with or without `-fomit-frame-pointer`. 
(That's using `-fzero-call-used-regs=all`, so register usage isn't a 
consideration.) I assume that it's correct, or at least close to it.



Comment at: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp:752
+#undef CASE
+  }
+}

peterwaller-arm wrote:
> void wrote:
> > kristof.beyls wrote:
> > > Just a drive-by comment: I'm wondering if SVE registers should also be 
> > > listed here?
> > I'm not familiar with the SVE registers (I assume you mean the `Z#` and 
> > `P#` ones). Could you give an example program?
> SVE is slightly tricker here because the set of registers the caller must 
> preserve depends on the signature of the function.
> 
> This is described here: 
> https://github.com/ARM-software/abi-aa/blob/8a7b266879c60ca1c76e94ebb279b2dac60ed6a5/aapcs64/aapcs64.rst#613scalable-vector-registers
> 
> The callee-preserved registers are z8-z23 and p4-p15 if the function is using 
> the VARIANT_PCS, the code for that condition in the asm printer is here:
> 
> https://github.com/llvm/llvm-project/blob/78fd413cf736953ac623cabf3d5f84c8219e31f8/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp#L864-L875
> 
> 
> ```
>  if (MF->getFunction().getCallingConv() == CallingConv::AArch64_VectorCall ||
>   MF->getFunction().getCallingConv() ==
>   CallingConv::AArch64_SVE_VectorCall ||
>   STI->getRegisterInfo()->hasSVEArgsOrReturn(MF)) {
> ```
> 
> Hope that helps a little.
Okay, so GCC does clear out SVE registers when using `-march=armv8-a+sve`:

```
mov z0.h, #0
mov z1.h, #0
mov z2.h, #0
mov z3.h, #0
mov z4.h, #0
mov z5.h, #0
mov z6.h, #0
mov z7.h, #0
mov z16.h, #0
mov z17.h, #0
mov z18.h, #0
mov z19.h, #0
mov z20.h, #0
mov z21.h, #0
mov z22.h, #0
mov z23.h, #0
mov z24.h, #0
mov z25.h, #0
mov z26.h, #0
mov z27.h, #0
mov z28.h, #0
mov z29.h, #0
mov z30.h, #0
mov z31.h, #0
pfalse  p0.b
pfalse  p1.b
pfalse  p2.b
pfalse  p3.b
pfalse  p4.b
pfalse  p5.b
pfalse  p6.b
pfalse  p7.b
pfalse  p8.b
pfalse  p9.b
pfalse  p10.b
pfalse  p11.b
pfalse  p12.b
pfalse  p13.b
pfalse  p14.b
pfalse  p15.b
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124836

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


[PATCH] D125081: [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

2022-05-07 Thread Sam McCall via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c5e85b3da64: [FuzzMutate] Split out FuzzerCLI library that 
doesnt depend on IR. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125081

Files:
  clang-tools-extra/clangd/fuzzer/CMakeLists.txt
  clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
  clang/tools/clang-fuzzer/CMakeLists.txt
  llvm/lib/FuzzMutate/CMakeLists.txt
  llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
  llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
  llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
  llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
  llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
  llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
  llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
  llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
  mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Index: mlir/tools/mlir-parser-fuzzer/CMakeLists.txt
===
--- mlir/tools/mlir-parser-fuzzer/CMakeLists.txt
+++ mlir/tools/mlir-parser-fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 add_llvm_fuzzer(mlir-parser-fuzzer
Index: llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
-  FuzzMutate
+  FuzzerCLI
 )
 
 add_llvm_fuzzer(llvm-yaml-numeric-parser-fuzzer
Index: llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Support
-  FuzzMutate
+  FuzzerCLI
 )
 
 add_llvm_fuzzer(llvm-special-case-list-fuzzer
Index: llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 
Index: llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
@@ -14,6 +14,7 @@
   AggressiveInstCombine
   InstCombine
   Instrumentation
+  FuzzerCLI
   FuzzMutate
   MC
   ObjCARCOpts
Index: llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 
Index: llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 
Index: llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,6 +9,7 @@
 BitWriter
 CodeGen
 Core
+FuzzerCLI
 FuzzMutate
 IRReader
 MC
Index: llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
===
--- llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 
Index: llvm/lib/FuzzMutate/CMakeLists.txt
===
--- llvm/lib/FuzzMutate/CMakeLists.txt
+++ llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,9 +1,23 @@
-add_llvm_component_library(LLVMFuzzMutate
+# Generic helper for fuzzer binaries.
+# This should not depend on LLVM IR etc.
+add_llvm_component_library(LLVMFuzzerCLI
   FuzzerCLI.cpp
+  PARTIAL_SOURCES_INTENDED
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
+
+  LINK_COMPONENTS
+  Support
+  )
+
+# Library for using LLVM IR together with fuzzers.
+add_llvm_component_library(LLVMFuzzMutate
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
+  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

[clang] 1c5e85b - [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

2022-05-07 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-07T12:11:51+02:00
New Revision: 1c5e85b3da649c89db87abecc53b42f6eaa574c2

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

LOG: [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

All llvm-project fuzzers use this library to parse command-line arguments.
Many of them don't deal with LLVM IR or modules in any way. Bundling those
functions in one library forces build dependencies that don't need to be there.

Among other things, this means check-clang-pseudo no longer depends on most of
LLVM.

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

Added: 


Modified: 
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt
llvm/lib/FuzzMutate/CMakeLists.txt
llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index 5600a354decb3..eaf4478585290 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt 
b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
index fc583de8b011b..556c2f438d388 100644
--- a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index 4b2243c5ceb97..80ae9b611f65b 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_LIB_FUZZING_ENGINE)

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt 
b/llvm/lib/FuzzMutate/CMakeLists.txt
index 47ddeb5e1d2a9..0aea7fe0d8f0f 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,9 +1,23 @@
-add_llvm_component_library(LLVMFuzzMutate
+# Generic helper for fuzzer binaries.
+# This should not depend on LLVM IR etc.
+add_llvm_component_library(LLVMFuzzerCLI
   FuzzerCLI.cpp
+  PARTIAL_SOURCES_INTENDED
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
+
+  LINK_COMPONENTS
+  Support
+  )
+
+# Library for using LLVM IR together with fuzzers.
+add_llvm_component_library(LLVMFuzzMutate
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
+  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

diff  --git a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
index 5f90def79847b..427aff5c6d2ea 100644
--- a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 6ce0835f0465a..32b65384144ce 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
 BitWriter
 CodeGen
 Core
+FuzzerCLI
 FuzzMutate
 IRReader
 MC

diff  --git a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
index 07f02a35b2031..18b160d2b9c8b 100644
--- a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
index d3db43a686bbd..bacb88a3d5633 100644
--- a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ 

[clang-tools-extra] 1c5e85b - [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

2022-05-07 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-05-07T12:11:51+02:00
New Revision: 1c5e85b3da649c89db87abecc53b42f6eaa574c2

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

LOG: [FuzzMutate] Split out FuzzerCLI library that doesn't depend on IR.

All llvm-project fuzzers use this library to parse command-line arguments.
Many of them don't deal with LLVM IR or modules in any way. Bundling those
functions in one library forces build dependencies that don't need to be there.

Among other things, this means check-clang-pseudo no longer depends on most of
LLVM.

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

Added: 


Modified: 
clang-tools-extra/clangd/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang/tools/clang-fuzzer/CMakeLists.txt
llvm/lib/FuzzMutate/CMakeLists.txt
llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-opt-fuzzer/CMakeLists.txt
llvm/tools/llvm-rust-demangle-fuzzer/CMakeLists.txt
llvm/tools/llvm-special-case-list-fuzzer/CMakeLists.txt
llvm/tools/llvm-yaml-numeric-parser-fuzzer/CMakeLists.txt
mlir/tools/mlir-parser-fuzzer/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt 
b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
index 5600a354decb3..eaf4478585290 100644
--- a/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/clangd/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt 
b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
index fc583de8b011b..556c2f438d388 100644
--- a/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -1,5 +1,5 @@
 set(LLVM_LINK_COMPONENTS
-  FuzzMutate
+  FuzzerCLI
   Support
   )
 

diff  --git a/clang/tools/clang-fuzzer/CMakeLists.txt 
b/clang/tools/clang-fuzzer/CMakeLists.txt
index 4b2243c5ceb97..80ae9b611f65b 100644
--- a/clang/tools/clang-fuzzer/CMakeLists.txt
+++ b/clang/tools/clang-fuzzer/CMakeLists.txt
@@ -1,4 +1,4 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_LIB_FUZZING_ENGINE)

diff  --git a/llvm/lib/FuzzMutate/CMakeLists.txt 
b/llvm/lib/FuzzMutate/CMakeLists.txt
index 47ddeb5e1d2a9..0aea7fe0d8f0f 100644
--- a/llvm/lib/FuzzMutate/CMakeLists.txt
+++ b/llvm/lib/FuzzMutate/CMakeLists.txt
@@ -1,9 +1,23 @@
-add_llvm_component_library(LLVMFuzzMutate
+# Generic helper for fuzzer binaries.
+# This should not depend on LLVM IR etc.
+add_llvm_component_library(LLVMFuzzerCLI
   FuzzerCLI.cpp
+  PARTIAL_SOURCES_INTENDED
+
+  ADDITIONAL_HEADER_DIRS
+  ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate
+
+  LINK_COMPONENTS
+  Support
+  )
+
+# Library for using LLVM IR together with fuzzers.
+add_llvm_component_library(LLVMFuzzMutate
   IRMutator.cpp
   OpDescriptor.cpp
   Operations.cpp
   RandomIRBuilder.cpp
+  PARTIAL_SOURCES_INTENDED
 
   ADDITIONAL_HEADER_DIRS
   ${LLVM_MAIN_INCLUDE_DIR}/llvm/FuzzMutate

diff  --git a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
index 5f90def79847b..427aff5c6d2ea 100644
--- a/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-dlang-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
index 6ce0835f0465a..32b65384144ce 100644
--- a/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-isel-fuzzer/CMakeLists.txt
@@ -9,6 +9,7 @@ set(LLVM_LINK_COMPONENTS
 BitWriter
 CodeGen
 Core
+FuzzerCLI
 FuzzMutate
 IRReader
 MC

diff  --git a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
index 07f02a35b2031..18b160d2b9c8b 100644
--- a/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-itanium-demangle-fuzzer/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   Demangle
-  FuzzMutate
+  FuzzerCLI
   Support
 )
 

diff  --git a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt 
b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
index d3db43a686bbd..bacb88a3d5633 100644
--- a/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
+++ b/llvm/tools/llvm-microsoft-demangle-fuzzer/CMakeLists.txt
@@ 

[PATCH] D124715: Add ThreadPriority::Low, and use QoS class Utility on Mac

2022-05-07 Thread Stefan Haller via Phabricator via cfe-commits
stefanhaller added a comment.

@sammccall I addressed your last change requests with a revised patch, do you 
want to have a final look?

Also, I don't have commit rights, could somebody please land this for me once 
everybody is happy with it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124715

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


[PATCH] D124726: Suggest typoed directives in preprocessor conditionals

2022-05-07 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:362-365
 
+def warn_pp_typo_directive : Warning<
+  "'#%0' directive not found, did you mean '#%1'?">,
+  InGroup;

aaron.ballman wrote:
> ken-matsui wrote:
> > aaron.ballman wrote:
> > > Rather than adding a warning over the top of an existing error, I think 
> > > we should modify `err_pp_invalid_directive` to have an optional "did you 
> > > mean?" when we find a plausible typo to correct.
> > > 
> > > However, we do not issue that diagnostic when it's inside of a skipped 
> > > conditional block, and that's what the crux of 
> > > https://github.com/llvm/llvm-project/issues/51598 is about. As @rsmith 
> > > pointed out in that issue (and I agree), compilers are free to support 
> > > custom directives and those will validly appear inside of a conditional 
> > > block that is skipped. We need to be careful not to diagnose those kinds 
> > > of situations as an error. However, we still want to diagnose when the 
> > > unknown directive is "sufficiently close" to another one which can 
> > > control the conditional chain. e.g.,
> > > ```
> > > #fi FOO // error unknown directive, did you mean #if?
> > > #endfi // error unknown directive, did you mean #endif?
> > > 
> > > #if FOO
> > > #esle // diag: unknown directive, did you mean #else?
> > > #elfi // diag: unknown directive, did you mean #elif?
> > > #elfidef // diag: unknown directive, did you mean #elifdef
> > > #elinfdef // diag: unknown directive, did you mean #elifndef
> > > 
> > > #frobble // No diagnostic, not close enough to a conditional directive to 
> > > warrant diagnosing
> > > #eerp // No diagnostic, not close enough to a conditional directive to 
> > > warrant diagnosing
> > > 
> > > #endif
> > > ```
> > > Today, if `FOO` is defined to a nonzero value, you'll get diagnostics for 
> > > all of those, but if `FOO` is not defined or is defined to 0, then 
> > > there's no diagnostics. I think we want to consider directives that are 
> > > *very likely* to be a typo (edit distance of 1, maybe 2?) for a 
> > > conditional directive as a special case.
> > > 
> > > Currently, we only diagnose unknown directives as an error. I think for 
> > > these special cased conditional directive diagnostics, we'll want to use 
> > > a warning rather than an error in this circumstance (just in case it 
> > > turns out to be a valid directive in a skipped conditional block). If we 
> > > do go that route and make it a warning, I think the warning group should 
> > > be `-Wunknown-directives` to mirror `-Wunknown-pragmas`, 
> > > `-Wunknown-attributes`, etc and it should be defined to have the same 
> > > text as the error case. e.g., 
> > > ```
> > > def err_pp_invalid_directive : Error<
> > >   "invalid preprocessing directive%select{|; did you mean '#%1'?}0"
> > > >;
> > > def warn_pp_invalid_directive : Warning<
> > >   err_pp_invalid_directive.Text>, 
> > > InGroup>;
> > > ```
> > > WDYT?
> > > 
> > > (These were my thoughts before seeing the rest of the patch. After 
> > > reading the patch, it looks like we have pretty similar ideas here, which 
> > > is great, but leaving the comment anyway in case you have further 
> > > opinions.)
> > > Currently, we only diagnose unknown directives as an error. I think for 
> > > these special cased conditional directive diagnostics, we'll want to use 
> > > a warning rather than an error in this circumstance (just in case it 
> > > turns out to be a valid directive in a skipped conditional block). If we 
> > > do go that route and make it a warning, I think the warning group should 
> > > be `-Wunknown-directives` to mirror `-Wunknown-pragmas`, 
> > > `-Wunknown-attributes`, etc and it should be defined to have the same 
> > > text as the error case. e.g., 
> > > ```
> > > def err_pp_invalid_directive : Error<
> > >   "invalid preprocessing directive%select{|; did you mean '#%1'?}0"
> > > >;
> > > def warn_pp_invalid_directive : Warning<
> > >   err_pp_invalid_directive.Text>, 
> > > InGroup>;
> > > ```
> > > WDYT?
> > > 
> > > (These were my thoughts before seeing the rest of the patch. After 
> > > reading the patch, it looks like we have pretty similar ideas here, which 
> > > is great, but leaving the comment anyway in case you have further 
> > > opinions.)
> > 
> > For now, I totally agree with deriving a new warning from 
> > `err_pp_invalid_directive`.
> > 
> > However, for future scalability, I think it would be great if we could 
> > split those diagnostics into Error & Warning and Help, for example. Rustc 
> > does split the diagnostics like the following, and I think this is quite 
> > clear. So, a bit apart from this patch, I speculate creating a diagnostic 
> > system that can split them would bring Clang diagnostics much more readable.
> > 
> > https://github.com/rust-lang/rust/blob/598d89bf142823b5d84e2eb0f0f9e418ee966a4b/src/test/ui/suggestions/suggest-trait-items.stderr

[PATCH] D124534: [clang] Add a diagnostic for line directive of a gnu extension

2022-05-07 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

After some investigations, some directives behave weirdly.
I will continue investigating, but do you have any suggestions here?




Comment at: clang/test/Preprocessor/line-directive.c:33
 # 42 "foo" 2 // expected-error {{invalid line marker flag '2': cannot pop 
empty include stack}}
 # 42 "foo" 1 3  // enter
 # 42 "foo" 2 3  // exit

aaron.ballman wrote:
> Something is still not quite correct -- these should also be diagnosed as an 
> extension (it's the same feature just with flags).
This didn't cause a warning on this test file, but another test file I created 
caused a warning.

```
// RUN: %clang_cc1 -std=c99 -fsyntax-only -verify -pedantic %s

# 42 "foo" 1 3  // enter: expected-warning {{this style of line directive is a 
GNU extension}}
```



Comment at: clang/test/Preprocessor/line-directive.c:61
 
 # 192 "glomp.h" 3 // System header.
 typedef int y;  // ok

aaron.ballman wrote:
> This should also be diagnosed.
This directive didn't cause a warning when marking both `# 192 "glomp.h"` and 
this. Marking only either directive works.

Works:
```
...
# 192 "glomp.h" // not a system header.: expected-warning {{this style of line 
directive is a GNU extension}}
typedef int x;  // expected-note {{previous definition is here}}
typedef int x;  // expected-warning {{redefinition of typedef 'x' is a C11 
feature}}

# 192 "glomp.h" 3 // System header.
...
```

Works:
```
...
# 192 "glomp.h" // not a system header.
typedef int x;  // expected-note {{previous definition is here}}
typedef int x;  // expected-warning {{redefinition of typedef 'x' is a C11 
feature}}

# 192 "glomp.h" 3 // System header.: expected-warning {{this style of line 
directive is a GNU extension}}
...
```

Does NOT work:
```
...
# 192 "glomp.h" // not a system header.: expected-warning {{this style of line 
directive is a GNU extension}}
typedef int x;  // expected-note {{previous definition is here}}
typedef int x;  // expected-warning {{redefinition of typedef 'x' is a C11 
feature}}

# 192 "glomp.h" 3 // System header.: expected-warning {{this style of line 
directive is a GNU extension}}
...
```

```
Command Output (stderr):
--
error: 'warning' diagnostics expected but not seen: 
  File /tmp/llvm/llvm-project/clang/test/Preprocessor/line-directive.c Line 
191: this style of line directive is a GNU extension
1 error generated.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D125157: [RISCV][NFC] Add more tests for clang driver.

2022-05-07 Thread Pretty-box via Phabricator via cfe-commits
Pretty-box updated this revision to Diff 427825.
Pretty-box edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125157

Files:
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -559,3 +559,24 @@
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ifdzve64d -### %s -c 
2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-ZVE64D-GOOD %s
 // RV32-ZVE64D-GOOD: "-target-feature" "+zve64d"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFINX-GOOD %s
+// RV32-ZFINX-GOOD: "-target-feature" "+zfinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izdinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZDINX-GOOD %s
+// RV32-ZDINX-GOOD: "-target-feature" "+zdinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izhinxmin -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINXMIN-GOOD %s
+// RV32-ZHINXMIN-GOOD: "-target-feature" "+zhinxmin"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izhinx1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-GOOD %s
+// RV32-ZHINX-GOOD: "-target-feature" "+zhinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izhinx0p1 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-BADVERS %s
+// RV32-ZHINX-BADVERS: error: invalid arch name 'rv32izhinx0p1'
+// RV32-ZHINX-BADVERS: unsupported version number 0.1 for extension 'zhinx'
\ No newline at end of file


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -559,3 +559,24 @@
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ifdzve64d -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-ZVE64D-GOOD %s
 // RV32-ZVE64D-GOOD: "-target-feature" "+zve64d"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFINX-GOOD %s
+// RV32-ZFINX-GOOD: "-target-feature" "+zfinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izdinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZDINX-GOOD %s
+// RV32-ZDINX-GOOD: "-target-feature" "+zdinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izhinxmin -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINXMIN-GOOD %s
+// RV32-ZHINXMIN-GOOD: "-target-feature" "+zhinxmin"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izhinx1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-GOOD %s
+// RV32-ZHINX-GOOD: "-target-feature" "+zhinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izhinx0p1 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-BADVERS %s
+// RV32-ZHINX-BADVERS: error: invalid arch name 'rv32izhinx0p1'
+// RV32-ZHINX-BADVERS: unsupported version number 0.1 for extension 'zhinx'
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124534: [clang] Add a diagnostic for line directive of a gnu extension

2022-05-07 Thread Ken Matsui via Phabricator via cfe-commits
ken-matsui added a comment.

@aaron.ballman

Thank you for your review and sorry to have missed those directives!

I also found additional directives that I might have to diagnose.
Could you please tell me if these are also required?




Comment at: clang/test/Preprocessor/line-directive.c:67-77
 #line 42 "blonk.h"  // doesn't change system headerness.
 
 typedef int z;  // ok
 typedef int z;  // ok
 
 # 97 // doesn't change system headerness.
 

Should these directives also be diagnosed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124534

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


[PATCH] D124816: [LibTooling] use ToolFileManager to store file managers for each CWD

2022-05-07 Thread Shi Chen via Phabricator via cfe-commits
Kale updated this revision to Diff 427822.
Kale added a comment.
Herald added subscribers: carlosgalvezp, usaxena95, kadircet, arphaman.
Herald added a project: clang-tools-extra.

Fix tests & runInvocation in clang-tools-extra.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124816

Files:
  clang-tools-extra/clang-include-fixer/IncludeFixer.cpp
  clang-tools-extra/clang-include-fixer/IncludeFixer.h
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clangd/indexer/IndexerMain.cpp
  clang-tools-extra/clangd/unittests/IndexActionTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/unittests/clang-include-fixer/IncludeFixerTest.cpp
  
clang-tools-extra/unittests/clang-include-fixer/find-all-symbols/FindAllSymbolsTests.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/Tooling.cpp
  
clang/test/Tooling/multiple-source-include-different-header-with-same-relative-path.cpp
  clang/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -179,8 +179,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
   std::vector Args;
   Args.push_back("tool-executable");
   Args.push_back("-Idef");
@@ -205,8 +205,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
   std::vector Args;
   Args.push_back("tool-executable");
   Args.push_back("-Idef");
@@ -231,8 +231,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
 
   std::vector Args;
   Args.push_back("tool-executable");
@@ -260,8 +260,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
 
   std::vector Args;
   Args.push_back("tool-executable");
@@ -306,8 +306,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
   std::vector Args;
   Args.push_back("tool-executable");
   // Note: intentional error; user probably meant -ferror-limit=0.
Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -51,18 +51,18 @@
   TestDependencyScanningAction(std::vector ) : Deps(Deps) {}
 
   bool runInvocation(std::shared_ptr Invocation,
- FileManager *FileMgr,
+ ToolFileManager *FileMgr,
  std::shared_ptr PCHContainerOps,
  DiagnosticConsumer *DiagConsumer) override {
 CompilerInstance Compiler(std::move(PCHContainerOps));
 Compiler.setInvocation(std::move(Invocation));
-Compiler.setFileManager(FileMgr);
+Compiler.setFileManager(FileMgr->getOrCreateFileManager().get());
 
 Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
 if (!Compiler.hasDiagnostics())
   return false;
 
-Compiler.createSourceManager(*FileMgr);
+Compiler.createSourceManager(*FileMgr->getOrCreateFileManager());
 Compiler.addDependencyCollector(std::make_shared(
 

[PATCH] D123612: [Driver] Support linking to compiler-rt on AVR

2022-05-07 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:430
+  // libgcc distributed with avr-gcc always named 'libgcc.a' even on windows.
+  return (Twine("libclang_rt.") + Component + Arch + ".a").str();
+}

benshi001 wrote:
> MaskRay wrote:
> > benshi001 wrote:
> > > This method decides the file name of compiler-rt, it is expected to be 
> > > 
> > > `libclang_rt.builtins-avrfamily.a`, such as
> > > 
> > > `libclang_rt.builtins-avr51.a`
> > > `libclang_rt.builtins-avrtiny.a`
> > > `libclang_rt.builtins-avrxmega3.a`
> > > 
> > > 
> > In `-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on` mode this should be 
> > `lib/clang/$version/lib/$triple/libclang_rt.xxx.a` where there is no 
> > `-microarch` infix.
> But I would expect each subarch has its own specific build with specific 
>  optimization. That is the way in avr-gcc distribution.
This hook `buildCompilerRTBasename` with be called twice by the base class. The 
first time is called with `AddArch = false`, for which I do not append 
-microarch infix.

For the second call with `AddArch = true`, I will append -microarch infix.


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

https://reviews.llvm.org/D123612

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


[PATCH] D123612: [Driver] Support linking to compiler-rt on AVR

2022-05-07 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:430
+  // libgcc distributed with avr-gcc always named 'libgcc.a' even on windows.
+  return (Twine("libclang_rt.") + Component + Arch + ".a").str();
+}

MaskRay wrote:
> benshi001 wrote:
> > This method decides the file name of compiler-rt, it is expected to be 
> > 
> > `libclang_rt.builtins-avrfamily.a`, such as
> > 
> > `libclang_rt.builtins-avr51.a`
> > `libclang_rt.builtins-avrtiny.a`
> > `libclang_rt.builtins-avrxmega3.a`
> > 
> > 
> In `-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=on` mode this should be 
> `lib/clang/$version/lib/$triple/libclang_rt.xxx.a` where there is no 
> `-microarch` infix.
But I would expect each subarch has its own specific build with specific 
 optimization. That is the way in avr-gcc distribution.


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

https://reviews.llvm.org/D123612

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


[PATCH] D123612: [Driver] Support linking to compiler-rt on AVR

2022-05-07 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 427821.

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

https://reviews.llvm.org/D123612

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/gcc/avr/5.4.0/avr5/libgcc.a
  
clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/avr/libclang_rt.builtins-avr5.a
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -58,3 +58,17 @@
 // NOGCC-NOT: warning: {{.*}} microcontroller
 // NOGCC-NOT: warning: {{.*}} avr-libc
 // NOGCC-NOT: warning: {{.*}} data section address
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=LIBGCC %s
+// LIBGCC: "-lgcc"
+// LIBGCC-NOT: libclang_rt
+
+// RUN: %clang %s -### --target=avr -mmcu=atmega328 --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=COMRT %s
+// COMRT: libclang_rt.builtins-avr5.a
+// COMRT-NOT: "-lgcc"
+
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=compiler-rt 2>&1 | FileCheck --check-prefix=NOMCU %s
+// RUN: %clang %s -### --target=avr --sysroot=%S/Inputs/basic_avr_tree/ -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir --rtlib=libgcc 2>&1 | FileCheck --check-prefix=NOMCU %s
+// NOMCU-NOT: libclang_rt
+// NOMCU-NOT: "-lgcc"
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -34,11 +34,20 @@
   llvm::Optional findAVRLibcInstallation() const;
   StringRef getGCCInstallPath() const { return GCCInstallPath; }
 
+  std::string buildCompilerRTBasename(const llvm::opt::ArgList ,
+  StringRef Component, FileType Type,
+  bool AddArch) const override;
+
+  std::string getCompilerRTPath() const override;
+
+  ToolChain::RuntimeLibType GetDefaultRuntimeLibType() const override;
+
 protected:
   Tool *buildLinker() const override;
 
 private:
   StringRef GCCInstallPath;
+  std::string MCU;
 };
 
 } // end namespace toolchains
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -19,6 +19,7 @@
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::toolchains;
@@ -369,14 +370,13 @@
 : Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
-  std::string CPU = getCPUName(D, Args, Triple);
-  if (CPU.empty())
+  MCU = getCPUName(D, Args, Triple);
+  if (MCU.empty())
 D.Diag(diag::warn_drv_avr_mcu_not_specified);
 
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs) &&
-  GCCInstallation.isValid()) {
+  !Args.hasArg(options::OPT_nodefaultlibs) && GCCInstallation.isValid()) {
 GCCInstallPath = GCCInstallation.getInstallPath();
 std::string GCCParentPath(GCCInstallation.getParentLibPath());
 getProgramPaths().push_back(GCCParentPath + "/../bin");
@@ -415,6 +415,40 @@
 CC1Args.push_back("-fno-use-cxa-atexit");
 }
 
+std::string
+AVRToolChain::buildCompilerRTBasename(const llvm::opt::ArgList ,
+  StringRef Component, FileType Type,
+  bool AddArch) const {
+  std::string Arch;
+  // Each device family should has its own build with specific optimization.
+  if (AddArch) {
+Optional FamilyName = GetMCUFamilyName(MCU);
+if (FamilyName)
+  Arch = "-" + (*FamilyName).str();
+// Neither libgcc nor compiler-rt will be linked if no '-mmcu' specified.
+// However we still append a default "-avr" for future changes.
+else
+  Arch = "-avr";
+  }
+  // libgcc distributed with avr-gcc always named 'libgcc.a' even on windows.
+  return (Twine("libclang_rt.") + Component + Arch + ".a").str();
+}
+
+std::string AVRToolChain::getCompilerRTPath() const {
+  // Return default path appended with "/avr", if it exists.
+  SmallString<128> Path(ToolChain::getCompilerRTPath());
+  

[PATCH] D124816: [Tooling] use different FileManager for each CWD

2022-05-07 Thread Shi Chen via Phabricator via cfe-commits
Kale updated this revision to Diff 427820.
Kale added a comment.

Reimplement ToolFileManager as a container of filemanagers which ToolInvocation 
takes by parameter. Also invalidate all file managers when using 
FileManager::setVirtualFileSystem().


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124816

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/Tooling.cpp
  
clang/test/Tooling/multiple-source-include-different-header-with-same-relative-path.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -179,8 +179,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
   std::vector Args;
   Args.push_back("tool-executable");
   Args.push_back("-Idef");
@@ -205,8 +205,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
   std::vector Args;
   Args.push_back("tool-executable");
   Args.push_back("-Idef");
@@ -231,8 +231,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
 
   std::vector Args;
   Args.push_back("tool-executable");
@@ -260,8 +260,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
 
   std::vector Args;
   Args.push_back("tool-executable");
@@ -306,8 +306,8 @@
   llvm::IntrusiveRefCntPtr InMemoryFileSystem(
   new llvm::vfs::InMemoryFileSystem);
   OverlayFileSystem->pushOverlay(InMemoryFileSystem);
-  llvm::IntrusiveRefCntPtr Files(
-  new FileManager(FileSystemOptions(), OverlayFileSystem));
+  llvm::IntrusiveRefCntPtr Files(
+  new ToolFileManager(FileSystemOptions(), OverlayFileSystem));
   std::vector Args;
   Args.push_back("tool-executable");
   // Note: intentional error; user probably meant -ferror-limit=0.
Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -51,18 +51,18 @@
   TestDependencyScanningAction(std::vector ) : Deps(Deps) {}
 
   bool runInvocation(std::shared_ptr Invocation,
- FileManager *FileMgr,
+ ToolFileManager *FileMgr,
  std::shared_ptr PCHContainerOps,
  DiagnosticConsumer *DiagConsumer) override {
 CompilerInstance Compiler(std::move(PCHContainerOps));
 Compiler.setInvocation(std::move(Invocation));
-Compiler.setFileManager(FileMgr);
+Compiler.setFileManager(FileMgr->getOrCreateFileManager().get());
 
 Compiler.createDiagnostics(DiagConsumer, /*ShouldOwnClient=*/false);
 if (!Compiler.hasDiagnostics())
   return false;
 
-Compiler.createSourceManager(*FileMgr);
+Compiler.createSourceManager(*FileMgr->getOrCreateFileManager());
 Compiler.addDependencyCollector(std::make_shared(
 Compiler.getInvocation().getDependencyOutputOpts(), Deps));
 
Index: clang/test/Tooling/multiple-source-include-different-header-with-same-relative-path.cpp
===
--- /dev/null
+++ clang/test/Tooling/multiple-source-include-different-header-with-same-relative-path.cpp
@@ -0,0 +1,42 @@
+// This test case presents a circumstance that the information related one file
+// is misused by another.
+//
+// The path tree of the test directory is as follors.
+//   .
+//   ├── a
+//   │   ├── a.c
+//   │   └── config.h
+//  

[PATCH] D125157: [RISCV][NFC] Add more tests for clang driver.

2022-05-07 Thread Pretty-box via Phabricator via cfe-commits
Pretty-box created this revision.
Pretty-box added reviewers: benshi001, craig.topper.
Pretty-box added projects: All, LLVM.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb, arichardson.
Pretty-box requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD.
Herald added a project: clang.

[RISCV][NFC] add more tests for clang driver.

Test experimental arch, Zfinx, Zdinx, Zhinx and Zhinxmin arch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125157

Files:
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -559,3 +559,24 @@
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ifdzve64d -### %s -c 
2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-ZVE64D-GOOD %s
 // RV32-ZVE64D-GOOD: "-target-feature" "+zve64d"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFINX-GOOD %s
+// RV32-ZFINX-GOOD: "-target-feature" "+zfinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zdinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZDINX-GOOD %s
+// RV32-ZDINX-GOOD: "-target-feature" "+zdinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zhinxmin -### %s 
\
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINXMIN-GOOD %s
+// RV32-ZHINXMIN-GOOD: "-target-feature" "+zhinxmin"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zhinx1p0 -### %s 
\
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-GOOD %s
+// RV32-ZHINX-GOOD: "-target-feature" "+zhinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zhinx0p1 -### %s 
\
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-BADVERS %s
+// RV32-ZHINX-BADVERS: error: invalid arch name 'rv32izfinx_zhinx0p1'
+// RV32-ZHINX-BADVERS: unsupported version number 0.1 for extension 'zhinx'
\ No newline at end of file


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -559,3 +559,24 @@
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ifdzve64d -### %s -c 2>&1 | \
 // RUN:   FileCheck -check-prefix=RV32-ZVE64D-GOOD %s
 // RV32-ZVE64D-GOOD: "-target-feature" "+zve64d"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZFINX-GOOD %s
+// RV32-ZFINX-GOOD: "-target-feature" "+zfinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zdinx -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZDINX-GOOD %s
+// RV32-ZDINX-GOOD: "-target-feature" "+zdinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zhinxmin -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINXMIN-GOOD %s
+// RV32-ZHINXMIN-GOOD: "-target-feature" "+zhinxmin"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zhinx1p0 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-GOOD %s
+// RV32-ZHINX-GOOD: "-target-feature" "+zhinx"
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfinx_zhinx0p1 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ZHINX-BADVERS %s
+// RV32-ZHINX-BADVERS: error: invalid arch name 'rv32izfinx_zhinx0p1'
+// RV32-ZHINX-BADVERS: unsupported version number 0.1 for extension 'zhinx'
\ No newline at end of file
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits