[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 4 inline comments as done.
mgorny added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:243
+  ``.cfg`` and ``.cfg`` if the former is not found. `Target`
+  is always the effective target (with respect to ``-target``, ``-m32``, etc.)
+  and `driver` first tries the canonical name for the driver (respecting

MaskRay wrote:
> `-target` => `--target=`
> 
> avoid legacy spelling
Ah, so it needs `=` (I really hate the option parsing in clang, you know?).

BTW that's what got me to use `-target`:

```
$ clang --target foo
clang-16: error: unsupported option '--target'; did you mean '-target'?
```



Comment at: clang/test/Driver/config-file3.c:33
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg

pengfei wrote:
> MaskRay wrote:
> > Since %t is rebuilt. You can just use `touch`
> `touch` may not work on Windows?
Well, my experience tells me to avoid external commands when the goal can be 
achieved via a builtin but `touch` is more popular in clang indeed.



Comment at: clang/test/Driver/config-file3.c:47
+// FULL1: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg

MaskRay wrote:
> Is `// FULL1-NOT: Configuration file:` sufficient?
Indeed. I forgot that FileCheck is weird-ish about retrying the matches ;-).


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

https://reviews.llvm.org/D134337

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


[PATCH] D134733: [clang-format][chore] transparent #include name regex

2022-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:400
+llvm::Regex getCppIncludeRegex() {
+  static const char CppIncludeRegexPattern[] =
+  R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";

What if this was overridable via the Style we could experiment with changing 
the regex



Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:407
+const llvm::SmallVectorImpl ) {
+  if (Matches.size() >= 3) {
+return Matches[2];

‘>= 2’


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134733

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-09-27 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/Driver/config-file3.c:33
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg

MaskRay wrote:
> Since %t is rebuilt. You can just use `touch`
`touch` may not work on Windows?


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

https://reviews.llvm.org/D134337

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


[PATCH] D134626: [clang-format] Correctly indent closing brace of compound requires

2022-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134626

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-09-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Thanks. The previous behavior is too magical. I like this version.




Comment at: clang/docs/ReleaseNotes.rst:243
+  ``.cfg`` and ``.cfg`` if the former is not found. `Target`
+  is always the effective target (with respect to ``-target``, ``-m32``, etc.)
+  and `driver` first tries the canonical name for the driver (respecting

`-target` => `--target=`

avoid legacy spelling



Comment at: clang/test/Driver/config-file3.c:33
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg

Since %t is rebuilt. You can just use `touch`



Comment at: clang/test/Driver/config-file3.c:47
+// FULL1: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg

Is `// FULL1-NOT: Configuration file:` sufficient?



Comment at: clang/test/Driver/config-file3.c:62
 //
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= 
--config-user-dir=%t/testdmode -c -### %s 2>&1 | FileCheck %s -check-prefix 
SYMLINK
+// FULL1-I386-NOT: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: 
{{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg

Is // FULL1-NOT: Configuration file: sufficient?


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

https://reviews.llvm.org/D134337

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


[PATCH] D132379: [Support] Class for response file expansion

2022-09-27 Thread Serge Pavlov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e491c48d6b9: [Support] Class for response file expansion 
(NFC) (authored by sepavloff).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132379

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/tools/driver/driver.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/include/llvm/Support/StringSaver.h
  llvm/lib/Support/CommandLine.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -869,10 +869,9 @@
 
   // Expand response files.
   llvm::BumpPtrAllocator A;
-  llvm::StringSaver Saver(A);
-  ASSERT_TRUE(llvm::cl::ExpandResponseFiles(
-  Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true, false,
-  /*CurrentDir=*/StringRef(TestRoot), FS));
+  llvm::cl::ExpansionContext ECtx(A, llvm::cl::TokenizeGNUCommandLine);
+  ECtx.setVFS().setCurrentDir(TestRoot).setRelativeNames(true);
+  ASSERT_TRUE(ECtx.expandResponseFiles(Argv));
   EXPECT_THAT(Argv, testing::Pointwise(
 StringEquality(),
 {"test/test", "-flag_1", "-option_1", "-option_2",
@@ -927,15 +926,14 @@
   SmallVector Argv = {"test/test", SelfFileRef.c_str(),
"-option_3"};
   BumpPtrAllocator A;
-  StringSaver Saver(A);
 #ifdef _WIN32
   cl::TokenizerCallback Tokenizer = cl::TokenizeWindowsCommandLine;
 #else
   cl::TokenizerCallback Tokenizer = cl::TokenizeGNUCommandLine;
 #endif
-  ASSERT_FALSE(
-  cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, false,
-  /*CurrentDir=*/llvm::StringRef(TestRoot), FS));
+  llvm::cl::ExpansionContext ECtx(A, Tokenizer);
+  ECtx.setVFS().setCurrentDir(TestRoot);
+  ASSERT_FALSE(ECtx.expandResponseFiles(Argv));
 
   EXPECT_THAT(Argv,
   testing::Pointwise(StringEquality(),
@@ -971,10 +969,9 @@
   Argv.push_back(ResponseFileRef.c_str());
 
   BumpPtrAllocator A;
-  StringSaver Saver(A);
-  ASSERT_FALSE(cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
-   false, false, false,
-   /*CurrentDir=*/StringRef(TestRoot), FS));
+  llvm::cl::ExpansionContext ECtx(A, cl::TokenizeGNUCommandLine);
+  ECtx.setVFS().setCurrentDir(TestRoot);
+  ASSERT_FALSE(ECtx.expandResponseFiles(Argv));
 
   // ASSERT instead of EXPECT to prevent potential out-of-bounds access.
   ASSERT_EQ(Argv.size(), 1 + NON_RSP_AT_ARGS + 2);
@@ -1006,10 +1003,9 @@
   SmallVector Argv = {"test/test", "@dir/outer.rsp"};
 
   BumpPtrAllocator A;
-  StringSaver Saver(A);
-  ASSERT_TRUE(cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
-  false, true, false,
-  /*CurrentDir=*/StringRef(TestRoot), FS));
+  llvm::cl::ExpansionContext ECtx(A, cl::TokenizeGNUCommandLine);
+  ECtx.setVFS().setCurrentDir(TestRoot).setRelativeNames(true);
+  ASSERT_TRUE(ECtx.expandResponseFiles(Argv));
   EXPECT_THAT(Argv,
   testing::Pointwise(StringEquality(), {"test/test", "-flag"}));
 }
@@ -1026,10 +1022,10 @@
  MemoryBuffer::getMemBuffer("-Xclang -Wno-whatever\n input.cpp"));
   SmallVector Argv = {"clang", "@eols.rsp"};
   BumpPtrAllocator A;
-  StringSaver Saver(A);
-  ASSERT_TRUE(cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine,
-  Argv, true, true, false,
-  /*CurrentDir=*/StringRef(TestRoot), FS));
+  llvm::cl::ExpansionContext ECtx(A, cl::TokenizeWindowsCommandLine);
+  ECtx.setVFS().setCurrentDir(TestRoot).setMarkEOLs(true).setRelativeNames(
+  true);
+  ASSERT_TRUE(ECtx.expandResponseFiles(Argv));
   const char *Expected[] = {"clang", "-Xclang", "-Wno-whatever", nullptr,
 "input.cpp"};
   ASSERT_EQ(std::size(Expected), Argv.size());
@@ -1125,9 +1121,8 @@
   EXPECT_NE(CurrDir.str(), TestDir.path());
 
   llvm::BumpPtrAllocator A;
-  llvm::StringSaver Saver(A);
-  bool Result = llvm::cl::readConfigFile(ConfigFile.path(), Saver, Argv,
-		 *llvm::vfs::getRealFileSystem());
+  llvm::cl::ExpansionContext ECtx(A, cl::tokenizeConfigFile);
+  bool Result = ECtx.readConfigFile(ConfigFile.path(), Argv);
 
   EXPECT_TRUE(Result);
   EXPECT_EQ(Argv.size(), 13U);
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1153,15 +1153,12 @@
 }
 
 // FName must be an absolute path.
-static llvm::Error ExpandResponseFile(StringRef FName, 

[clang] 6e491c4 - [Support] Class for response file expansion (NFC)

2022-09-27 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2022-09-28T11:47:59+07:00
New Revision: 6e491c48d6b9cadcc5b77f730dd83a1448197329

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

LOG: [Support] Class for response file expansion (NFC)

Functions that implement expansion of response and config files depend
on many options, which are passes as arguments. Extending the expansion
requires new options, it in turn causes changing calls in various places
making them even more bulky.

This change introduces a class ExpansionContext, which represents set of
options that control the expansion. Its methods implements expansion of
responce files including config files. It makes extending the expansion
easier.

No functional changes.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
clang/tools/driver/driver.cpp
llvm/include/llvm/Support/CommandLine.h
llvm/include/llvm/Support/StringSaver.h
llvm/lib/Support/CommandLine.cpp
llvm/unittests/Support/CommandLineTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a40a992ac0877..f2ae25df5825e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -956,7 +956,9 @@ static void appendOneArg(InputArgList , const Arg *Opt,
 bool Driver::readConfigFile(StringRef FileName) {
   // Try reading the given file.
   SmallVector NewCfgArgs;
-  if (!llvm::cl::readConfigFile(FileName, Saver, NewCfgArgs, getVFS())) {
+  llvm::cl::ExpansionContext ExpCtx(Alloc, llvm::cl::tokenizeConfigFile);
+  ExpCtx.setVFS(());
+  if (!ExpCtx.readConfigFile(FileName, NewCfgArgs)) {
 Diag(diag::err_drv_cannot_read_config_file) << FileName;
 return true;
   }

diff  --git a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp 
b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
index 75d0d50d851f9..c4b3abc1a0a45 100644
--- a/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
+++ b/clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -60,9 +60,10 @@ class ExpandResponseFilesDatabase : public 
CompilationDatabase {
   if (!SeenRSPFile)
 continue;
   llvm::BumpPtrAllocator Alloc;
-  llvm::StringSaver Saver(Alloc);
-  llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false, 
false,
-llvm::StringRef(Cmd.Directory), *FS);
+  llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
+  ECtx.setVFS(FS.get())
+  .setCurrentDir(Cmd.Directory)
+  .expandResponseFiles(Argv);
   // Don't assign directly, Argv aliases CommandLine.
   std::vector ExpandedArgv(Argv.begin(), Argv.end());
   Cmd.CommandLine = std::move(ExpandedArgv);

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 34335a599a008..11eba44fcf22e 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -308,9 +308,8 @@ static int ExecuteCC1Tool(SmallVectorImpl 
) {
   llvm::cl::ResetAllOptionOccurrences();
 
   llvm::BumpPtrAllocator A;
-  llvm::StringSaver Saver(A);
-  llvm::cl::ExpandResponseFiles(Saver, ::cl::TokenizeGNUCommandLine, ArgV,
-/*MarkEOLs=*/false);
+  llvm::cl::ExpansionContext ECtx(A, llvm::cl::TokenizeGNUCommandLine);
+  ECtx.expandResponseFiles(ArgV);
   StringRef Tool = ArgV[1];
   void *GetExecutablePathVP = (void *)(intptr_t)GetExecutablePath;
   if (Tool == "-cc1")
@@ -373,7 +372,8 @@ int clang_main(int Argc, char **Argv) {
 
   if (MarkEOLs && Args.size() > 1 && StringRef(Args[1]).startswith("-cc1"))
 MarkEOLs = false;
-  llvm::cl::ExpandResponseFiles(Saver, Tokenizer, Args, MarkEOLs);
+  llvm::cl::ExpansionContext ECtx(A, Tokenizer);
+  ECtx.setMarkEOLs(MarkEOLs).expandResponseFiles(Args);
 
   // Handle -cc1 integrated tools, even if -cc1 was expanded from a response
   // file.

diff  --git a/llvm/include/llvm/Support/CommandLine.h 
b/llvm/include/llvm/Support/CommandLine.h
index 58ded2ceee9d9..15deb8a0b027a 100644
--- a/llvm/include/llvm/Support/CommandLine.h
+++ b/llvm/include/llvm/Support/CommandLine.h
@@ -31,6 +31,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -2065,56 +2066,88 @@ void tokenizeConfigFile(StringRef Source, StringSaver 
,
 SmallVectorImpl ,
 bool MarkEOLs = false);
 
-/// Reads command line options from the given configuration file.
-///
-/// \param [in] CfgFileName Path to configuration file.
-/// \param [in] Saver  Objects that saves 

[PATCH] D132379: [Support] Class for response file expansion

2022-09-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132379

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2022-09-27 Thread Guillot Tony via Phabricator via cfe-commits
to268 added a comment.

Here are all the details that i've said earlier




Comment at: clang/lib/Parse/ParseExpr.cpp:1515
+// This is a temporary fix while we don't support C2x 6.5.2.5p4
+if (getLangOpts().C2x && GetLookAheadToken(2).getKind() == tok::l_brace) {
+  Diag(Tok, diag::err_c2x_auto_compound_literal_not_allowed);

aaron.ballman wrote:
> Why would this not be handled from `Sema::ActOnCompoundLiteral()`?
You're right, it's better to handle this in `Sema::ActOnCompoundLiteral()`
The problem is that right now, the usage of the `auto` keyword in a compound 
literal isn't parsed as a compound literal. 
This compound literal is unable to reach `Sema::ActOnCompoundLiteral()` because 
the parser emits that it's an invalid expression.

To summarize, i'm unable to handle handle a compound literal that uses the 
`auto` keyword inside `Sema::ActOnCompoundLiteral()`
if it's never going to be called.
```
int test_ncl = (int){12};   // Parsed as a CL
auto test_cl = (auto){12};  // Not parsed as a CL and emits "expected 
expression"
/*
 * |-DeclStmt 0x562180ede8b0 
 * | `-VarDecl 0x562180ede730  col:9 test_ncl 'int' cinit
 * |   `-ImplicitCastExpr 0x562180ede898  'int' 
 * | `-CompoundLiteralExpr 0x562180ede870  'int' lvalue
 * |   `-InitListExpr 0x562180ede828  'int'
 * | `-IntegerLiteral 0x562180ede7b0  'int' 12
 * |-DeclStmt 0x562180ede970 
 * | `-VarDecl 0x562180ede908  col:10 invalid test_cl 'auto'
 * `-ReturnStmt 0x562180ede9a8 
 *   `-IntegerLiteral 0x562180ede988  'int' 0
 */
```



Comment at: clang/lib/Parse/ParseExpr.cpp:1515
+// This is a temporary fix while we don't support C2x 6.5.2.5p4
+if (getLangOpts().C2x && GetLookAheadToken(2).getKind() == tok::l_brace) {
+  Diag(Tok, diag::err_c2x_auto_compound_literal_not_allowed);

to268 wrote:
> aaron.ballman wrote:
> > Why would this not be handled from `Sema::ActOnCompoundLiteral()`?
> You're right, it's better to handle this in `Sema::ActOnCompoundLiteral()`
> The problem is that right now, the usage of the `auto` keyword in a compound 
> literal isn't parsed as a compound literal. 
> This compound literal is unable to reach `Sema::ActOnCompoundLiteral()` 
> because the parser emits that it's an invalid expression.
> 
> To summarize, i'm unable to handle handle a compound literal that uses the 
> `auto` keyword inside `Sema::ActOnCompoundLiteral()`
> if it's never going to be called.
> ```
> int test_ncl = (int){12};   // Parsed as a CL
> auto test_cl = (auto){12};  // Not parsed as a CL and emits "expected 
> expression"
> /*
>  * |-DeclStmt 0x562180ede8b0 
>  * | `-VarDecl 0x562180ede730  col:9 test_ncl 'int' cinit
>  * |   `-ImplicitCastExpr 0x562180ede898  'int' 
> 
>  * | `-CompoundLiteralExpr 0x562180ede870  'int' lvalue
>  * |   `-InitListExpr 0x562180ede828  'int'
>  * | `-IntegerLiteral 0x562180ede7b0  'int' 12
>  * |-DeclStmt 0x562180ede970 
>  * | `-VarDecl 0x562180ede908  col:10 invalid test_cl 'auto'
>  * `-ReturnStmt 0x562180ede9a8 
>  *   `-IntegerLiteral 0x562180ede988  'int' 0
>  */
> ```
When we are parsing an expression between parentheses in 
`Parser::ParseParenExpression()` line 2972,
we are calling `Parser::isTypeIdInParens()` which when using C will return 
`true` if it's a type specifier,
which is not the case for the `auto` keyword.

Ultimately, we fall into the conditional block of 
`Parser::ParseParenExpression()` line 3191,
which will return an `ExprError()` (AKA: a parsing error).

This is why we are unable to forbid a compound literal using the `auto` keyword 
at the 
Semantic Analysis stage and why this feature is not working out of the box in 
the first place.



Comment at: clang/test/C/C2x/n3007.c:7
+void test_qualifiers(int x, const int y) {
+  // TODO: prohibit cont auto
+  const auto a = x;

aaron.ballman wrote:
> Why? My reading of the grammar is that `const auto` is valid. `const` is a 
> type-specifier-qualifier declaration-specifier, and `auto` is a 
> storage-class-specifier declaration-specifier, and a declaration is allowed 
> to use a sequence of declaration-specifiers.
It's a mistake, i don't remember why i've added this comment in the first place 
and i've forgot his existence


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-27 Thread John McIver via Phabricator via cfe-commits
jmciver added a comment.

Decreased CPU loading during test-suite build did lower times in some 
instances, but not a lot.

F24724990: results-subset.txt 

F24725002: results-full.txt 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134410

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2022-09-27 Thread Guillot Tony via Phabricator via cfe-commits
to268 updated this revision to Diff 463415.
to268 marked 3 inline comments as done.
to268 added a comment.

I've fixed the diagnostic message and all of the bad TODOs comments from the 
Sema test.
I've explained in details why i'm only able to handle `auto` in compound 
literals.

In D133289#3784117 , @aaron.ballman 
wrote:

> One thought that occurred to me is that the way C has this specified is 
> awfully effectively the same way implicit int worked. It may be worth 
> exploring a change to our implicit int functionality to instead generate an 
> implicit `auto` type when in C2x mode.

That's something is was trying to do a few weeks earlier, so i'll work on that 
too.

In D133289#3784117 , @aaron.ballman 
wrote:

> I've been thinking about this more and I'm starting to make myself a bit 
> uncomfortable with the current approach, at least in terms of how we're 
> handling it on the parsing side of things. I think it's reasonable for us to 
> form an `AutoType` when we eventually get down to forming the type. But I'm 
> uncomfortable with not modeling the language when parsing. e.g., I think we 
> want to parse `auto` as a storage class specifier rather than a type 
> specifier, and we want to rely on the lack of a type specifier coupled with 
> use of `auto` as a storage class specifier to determine the situations where 
> we want to infer a type. The resulting semantics should be basically 
> equivalent, but this ensures that we're properly parsing as the language 
> expects which helps us be forwards-compatible with future changes in C that 
> build on top of this being a storage class specifier rather than a type.

I agree, that's a better approach to design it like that, i'll change my 
approach when i'll be able to generate an implicit `auto`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1193,7 +1193,7 @@
 
   Type inference for object declarations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm;>N3007
-  No
+  Clang 16
 
 
   constexpr for object definitions
Index: clang/test/Sema/c2x-auto.c
===
--- /dev/null
+++ clang/test/Sema/c2x-auto.c
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
+
+void test_basic_types(void) {
+  auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
+  auto auto_int = 4;
+  auto auto_long = 4UL;
+}
+
+void test_sizeof_typeof(void) {
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  typeof(auto) tpof = 4;  // expected-error {{expected expression}}
+}
+
+void test_casts(void) {
+  auto int_cast = (int)(4 + 3);
+  auto double_cast = (double)(1 / 3);
+  auto long_cast = (long)(4UL + 3UL);
+  auto auto_cast = (auto)(4 + 3); // expected-error {{expected expression}}
+}
+
+void test_compound_literral(void) {
+  auto int_cl = (int){13};
+  auto double_cl = (double){2.5};
+
+  // FIXME: This should be accepted per C2x 6.5.2.5p4
+  auto auto_cl = (auto){13};  // expected-error {{'auto' is not allowed in a compound literal}}
+  auto array[] = { 1, 2, 3 }; // expected-error {{'array' declared as array of 'auto'}}
+}
+
+void test_qualifiers(int x, const int y) {
+  const auto a = x;
+  auto b = y;
+  static auto c = 1UL;
+  int* pa =  // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}
+  const int* pb = 
+  int* pc =  // expected-warning {{incompatible pointer types initializing 'int *' with an expression of type 'unsigned long *'}}
+}
+
+void test_scopes(void) {
+  {
+auto a = 7;
+auto b = 9;
+auto c = a + b;
+  }
+  {
+auto d = a * b;   // expected-error {{use of undeclared identifier 'a'}} \
+ expected-error {{use of undeclared identifier 'b'}}
+{
+  auto e = d + c; // expected-error {{use of undeclared identifier 'c'}}
+}
+  }
+}
Index: clang/test/Parser/c2x-auto.c
===
--- /dev/null
+++ clang/test/Parser/c2x-auto.c
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c2x -std=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,c17 -std=c17 %s
+
+#define AUTO_MACRO(_NAME, ARG, ARG2, ARG3) \
+  auto _NAME = ARG + 

[PATCH] D134749: [clang][Interp] Implement Div opcode

2022-09-27 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:183
+
+  if (RHS.isZero()) {
+const SourceInfo  = S.Current->getSource(OpPC);

Just like rem we need to catch `INT_MIN / -1`

`CheckICE(...)` looks like it does checking for both in the same spot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134749

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


[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:164
+
+  if (RHS.isZero()) {
+const SourceInfo  = S.Current->getSource(OpPC);

You also need to catch when the result is not representable e.g `INT_MIN % -1`

see `CheckICE(...)`


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

https://reviews.llvm.org/D134744

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Jun Zhang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG89e56e732d5e: [Clang] Dont warn if deferencing void 
pointers in unevaluated context (authored by junaire).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Analysis/misc-ps.m
  clang/test/Sema/no-warn-void-ptr-uneval.c


Index: clang/test/Sema/no-warn-void-ptr-uneval.c
===
--- /dev/null
+++ clang/test/Sema/no-warn-void-ptr-uneval.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+
+// expected-no-diagnostics
+void foo(void *vp) {
+  sizeof(*vp);
+  sizeof(*(vp));
+  void inner(typeof(*vp));
+}
Index: clang/test/Analysis/misc-ps.m
===
--- clang/test/Analysis/misc-ps.m
+++ clang/test/Analysis/misc-ps.m
@@ -133,7 +133,7 @@
   void* q;
   
   if (!flag) {
-if (sizeof(*q) == 1) // expected-warning {{ISO C does not allow 
indirection on operand of type 'void *'}}
+if (sizeof(*q) == 1)
   return;
 // Infeasibe.
 *p = 1; // no-warning
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@
 //   [...] the expression to which [the unary * operator] is applied shall
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && IsAfterAmp))
+if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
   << LO.CPlusPlus << OpTy << Op->getSourceRange();
   }


Index: clang/test/Sema/no-warn-void-ptr-uneval.c
===
--- /dev/null
+++ clang/test/Sema/no-warn-void-ptr-uneval.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+
+// expected-no-diagnostics
+void foo(void *vp) {
+  sizeof(*vp);
+  sizeof(*(vp));
+  void inner(typeof(*vp));
+}
Index: clang/test/Analysis/misc-ps.m
===
--- clang/test/Analysis/misc-ps.m
+++ clang/test/Analysis/misc-ps.m
@@ -133,7 +133,7 @@
   void* q;
   
   if (!flag) {
-if (sizeof(*q) == 1) // expected-warning {{ISO C does not allow indirection on operand of type 'void *'}}
+if (sizeof(*q) == 1)
   return;
 // Infeasibe.
 *p = 1; // no-warning
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@
 //   [...] the expression to which [the unary * operator] is applied shall
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && IsAfterAmp))
+if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
   << LO.CPlusPlus << OpTy << Op->getSourceRange();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 89e56e7 - [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-09-28T12:30:02+08:00
New Revision: 89e56e732d5e89d8715a501158793ac305bc4b70

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

LOG: [Clang] Don't warn if deferencing void pointers in unevaluated context

After https://reviews.llvm.org/D134461, Clang will diagnose a warning if
trying to deference void pointers in C mode. However, this causes a lot
of noises when compiling a 5.19.11 Linux kernel.

This patch reduces the warning by marking deferencing void pointers in
unevaluated context OK, like `sizeof(*void_ptr)`, `typeof(*void_ptr)`
and etc.

Fixes https://github.com/ClangBuiltLinux/linux/issues/1720

Signed-off-by: Jun Zhang 

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

Added: 
clang/test/Sema/no-warn-void-ptr-uneval.c

Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/Analysis/misc-ps.m

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index acbf7d534d49f..fca9240362e76 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -14536,7 +14536,7 @@ static QualType CheckIndirectionOperand(Sema , Expr 
*Op, ExprValueKind ,
 //   [...] the expression to which [the unary * operator] is applied shall
 //   be a pointer to an object type, or a pointer to a function type
 LangOptions LO = S.getLangOpts();
-if (LO.CPlusPlus || !(LO.C99 && IsAfterAmp))
+if (LO.CPlusPlus || !(LO.C99 && (IsAfterAmp || S.isUnevaluatedContext(
   S.Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
   << LO.CPlusPlus << OpTy << Op->getSourceRange();
   }

diff  --git a/clang/test/Analysis/misc-ps.m b/clang/test/Analysis/misc-ps.m
index 4e3783dfc93ac..e9e56315eb268 100644
--- a/clang/test/Analysis/misc-ps.m
+++ b/clang/test/Analysis/misc-ps.m
@@ -133,7 +133,7 @@ void handle_sizeof_void(unsigned flag) {
   void* q;
   
   if (!flag) {
-if (sizeof(*q) == 1) // expected-warning {{ISO C does not allow 
indirection on operand of type 'void *'}}
+if (sizeof(*q) == 1)
   return;
 // Infeasibe.
 *p = 1; // no-warning

diff  --git a/clang/test/Sema/no-warn-void-ptr-uneval.c 
b/clang/test/Sema/no-warn-void-ptr-uneval.c
new file mode 100644
index 0..2aed1180ab0da
--- /dev/null
+++ b/clang/test/Sema/no-warn-void-ptr-uneval.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s
+
+// expected-no-diagnostics
+void foo(void *vp) {
+  sizeof(*vp);
+  sizeof(*(vp));
+  void inner(typeof(*vp));
+}



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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 463413.
mgorny retitled this revision from "[clang] [Driver] More flexible rules for 
loading default configs (WIP)" to "[clang] [Driver] More flexible rules for 
loading default configs".
mgorny added a comment.

Update release notes. I may have been a bit verbose/repeating myself.


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

https://reviews.llvm.org/D134337

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file3.c

Index: clang/test/Driver/config-file3.c
===
--- clang/test/Driver/config-file3.c
+++ clang/test/Driver/config-file3.c
@@ -14,107 +14,261 @@
 // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
 // CHECK-REL: -Wundefined-var-template
 
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: mkdir %t/testbin
+// RUN: ln -s %clang %t/testbin/clang
+// RUN: echo "-Werror" > %t/testbin/aaa.cfg
+// RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
 
-//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
+//--- Invocation x86_64-unknown-linux-gnu-clang-g++ tries x86_64-unknown-linux-gnu-clang++.cfg first.
 //
 // RUN: mkdir %t/testdmode
-// RUN: ln -s %clang %t/testdmode/qqq-clang-g++
-// RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg
-// RUN: echo "-Werror" > %t/testdmode/qqq.cfg
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix FULL-NAME
+// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-clang-g++
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang-g++
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu.cfg
+// RUN: echo > %t/testdmode/clang++.cfg
+// RUN: echo > %t/testdmode/clang-g++.cfg
+// RUN: echo > %t/testdmode/clang.cfg
+// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1
 //
-// FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
-// FULL-NAME: -Wundefined-func-template
-// FULL-NAME-NOT: -Werror
+// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang.cfg
+
+//--- -m32 overrides triple.
 //
-//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
-// (As the clang executable and symlink are in different directories, this
-// requires specifying the path via --config-*-dir= though.)
+// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386
 //
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode -c -### %s 2>&1 | FileCheck %s -check-prefix SYMLINK
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg
+// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: 

[PATCH] D133266: [MinGW] Reject explicit hidden visibility applied to dllexport and hidden/protected applied to dllimport

2022-09-27 Thread ben via Phabricator via cfe-commits
bd1976llvm added a comment.

Whilst reviewing the impact of these dllimport/export restrictions I noticed 
that LLVM IR does not reject dllimport/export on local linkage globals. I have 
put up a PR for adding that restriction: D134784 
 (https://reviews.llvm.org/D134784).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133266

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


[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 463408.
SixWeining added a comment.

Remove the first line "Assertions" in inline-asm-constraint-ZB.ll as it is not 
autogenerated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  llvm/include/llvm/IR/InlineAsm.h
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.h
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZB.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZC.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-k.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll

Index: llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll
@@ -0,0 +1,145 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA32
+; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA64
+
+define i32 @m_offset_neg_2049(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_2049:
+; LA32:   # %bb.0:
+; LA32-NEXT:lu12i.w $a1, -1
+; LA32-NEXT:ori $a1, $a1, 2047
+; LA32-NEXT:add.w $a0, $a0, $a1
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_2049:
+; LA64:   # %bb.0:
+; LA64-NEXT:lu12i.w $a1, -1
+; LA64-NEXT:ori $a1, $a1, 2047
+; LA64-NEXT:add.d $a0, $a0, $a1
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -2049
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_neg_2048(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_2048:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, -2048
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_2048:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, -2048
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -2048
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_neg_1(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_1:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, -1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_1:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, -1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -1
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_0(ptr %p) nounwind {
+; LA32-LABEL: m_offset_0:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_0:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %p)
+  ret i32 %1
+}
+
+define i32 @m_offset_1(ptr %p) nounwind {
+; LA32-LABEL: m_offset_1:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_1:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 1
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_2047(ptr %p) nounwind {
+; LA32-LABEL: m_offset_2047:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 2047
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_2047:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 2047
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 2047
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_2048(ptr %p) nounwind {
+; LA32-LABEL: m_offset_2048:
+; LA32:   # %bb.0:
+; LA32-NEXT:ori $a1, $zero, 2048
+; LA32-NEXT:add.w $a0, $a0, $a1
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret

[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 463404.
SixWeining added a comment.

Handle k and ZB in llvm/include/llvm/IR/InlineAsm.h::getMemConstraintName and 
add relevant tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  llvm/include/llvm/IR/InlineAsm.h
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.h
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZB.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZC.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-k.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll

Index: llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll
@@ -0,0 +1,145 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA32
+; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA64
+
+define i32 @m_offset_neg_2049(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_2049:
+; LA32:   # %bb.0:
+; LA32-NEXT:lu12i.w $a1, -1
+; LA32-NEXT:ori $a1, $a1, 2047
+; LA32-NEXT:add.w $a0, $a0, $a1
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_2049:
+; LA64:   # %bb.0:
+; LA64-NEXT:lu12i.w $a1, -1
+; LA64-NEXT:ori $a1, $a1, 2047
+; LA64-NEXT:add.d $a0, $a0, $a1
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -2049
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_neg_2048(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_2048:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, -2048
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_2048:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, -2048
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -2048
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_neg_1(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_1:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, -1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_1:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, -1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -1
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_0(ptr %p) nounwind {
+; LA32-LABEL: m_offset_0:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_0:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %p)
+  ret i32 %1
+}
+
+define i32 @m_offset_1(ptr %p) nounwind {
+; LA32-LABEL: m_offset_1:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_1:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 1
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_2047(ptr %p) nounwind {
+; LA32-LABEL: m_offset_2047:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 2047
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_2047:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 2047
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 2047
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_2048(ptr %p) nounwind {
+; LA32-LABEL: m_offset_2048:
+; LA32:   # %bb.0:
+; LA32-NEXT:ori $a1, $zero, 2048
+; LA32-NEXT:add.w $a0, $a0, $a1
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:

[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:117
+// parsing.
+R = std::string("^") + std::string(Constraint, 2);
+Constraint++;

MaskRay wrote:
> First `std::string` can be omitted
Thanks.



Comment at: llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp:76
+  // TODO: handle extra code.
+  if (!ExtraCode) {
+const MachineOperand  = MI->getOperand(OpNo);

rengolin wrote:
> NIT: Use early exit.
> 
> if (ExtraCode)
>   return false;
Thanks. But we should return `true` but not `false`.



Comment at: llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZC.ll:16
+;
+; LA64-LABEL: ZC_offset_neg_32769:
+; LA64:   # %bb.0:

rengolin wrote:
> Same comment as before, these CHECK lines look identical for both targets...
Unfortunately this is not the case becuase different instructions like 
`add.w`/`add.d` are used by LA32 and LA64 respectively.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

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


[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 463395.
SixWeining marked 4 inline comments as done.
SixWeining added a comment.

Address comments from @rengolin and @MaskRay. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  llvm/include/llvm/IR/InlineAsm.h
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.h
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZB.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZC.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-k.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll

Index: llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/inline-asm-constraint-m.ll
@@ -0,0 +1,145 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc --mtriple=loongarch32 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA32
+; RUN: llc --mtriple=loongarch64 --verify-machineinstrs < %s | FileCheck %s --check-prefix=LA64
+
+define i32 @m_offset_neg_2049(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_2049:
+; LA32:   # %bb.0:
+; LA32-NEXT:lu12i.w $a1, -1
+; LA32-NEXT:ori $a1, $a1, 2047
+; LA32-NEXT:add.w $a0, $a0, $a1
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_2049:
+; LA64:   # %bb.0:
+; LA64-NEXT:lu12i.w $a1, -1
+; LA64-NEXT:ori $a1, $a1, 2047
+; LA64-NEXT:add.d $a0, $a0, $a1
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -2049
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_neg_2048(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_2048:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, -2048
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_2048:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, -2048
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -2048
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_neg_1(ptr %p) nounwind {
+; LA32-LABEL: m_offset_neg_1:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, -1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_neg_1:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, -1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 -1
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_0(ptr %p) nounwind {
+; LA32-LABEL: m_offset_0:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_0:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 0
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %p)
+  ret i32 %1
+}
+
+define i32 @m_offset_1(ptr %p) nounwind {
+; LA32-LABEL: m_offset_1:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 1
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_1:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 1
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 1
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_2047(ptr %p) nounwind {
+; LA32-LABEL: m_offset_2047:
+; LA32:   # %bb.0:
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 2047
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:ret
+;
+; LA64-LABEL: m_offset_2047:
+; LA64:   # %bb.0:
+; LA64-NEXT:#APP
+; LA64-NEXT:ld.w $a0, $a0, 2047
+; LA64-NEXT:#NO_APP
+; LA64-NEXT:ret
+  %1 = getelementptr inbounds i8, ptr %p, i32 2047
+  %2 = call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %1)
+  ret i32 %2
+}
+
+define i32 @m_offset_2048(ptr %p) nounwind {
+; LA32-LABEL: m_offset_2048:
+; LA32:   # %bb.0:
+; LA32-NEXT:ori $a1, $zero, 2048
+; LA32-NEXT:add.w $a0, $a0, $a1
+; LA32-NEXT:#APP
+; LA32-NEXT:ld.w $a0, $a0, 0
+; LA32-NEXT:#NO_APP
+; LA32-NEXT:

[PATCH] D134371: [clang-doc] Add typedef/using information.

2022-09-27 Thread Haowei Wu via Phabricator via cfe-commits
haowei added a comment.

In D134371#3819605 , @nemanjai wrote:

> This causes failures with `-Werror` such as: 
> https://lab.llvm.org/buildbot/#/builders/57/builds/22322
> Please fix or revert.

Thanks for reporting this. I reverted this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134371

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


[clang-tools-extra] a759477 - Revert "[clang-doc] Add typedef/using information."

2022-09-27 Thread Haowei Wu via cfe-commits

Author: Haowei Wu
Date: 2022-09-27T18:35:34-07:00
New Revision: a7594772225b59ad75cd270aa261b49695985444

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

LOG: Revert "[clang-doc] Add typedef/using information."

This reverts commit eed22583fd78d4d657fb70b99e62fbdc1f83b8f9, which
breaks clang build with -Werror.

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeReader.cpp
clang-tools-extra/clang-doc/BitcodeWriter.cpp
clang-tools-extra/clang-doc/BitcodeWriter.h
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Mapper.cpp
clang-tools-extra/clang-doc/Mapper.h
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-doc/Serialize.h
clang-tools-extra/clang-doc/YAMLGenerator.cpp
clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.h
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MergeTest.cpp
clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 8e1db35532a05..027272691d038 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -24,6 +24,12 @@ llvm::Error decodeRecord(const Record , 
llvm::SmallVectorImpl ,
   return llvm::Error::success();
 }
 
+llvm::Error decodeRecord(const Record , std::string ,
+ llvm::StringRef Blob) {
+  Field.assign(Blob.begin(), Blob.end());
+  return llvm::Error::success();
+}
+
 llvm::Error decodeRecord(const Record , SymbolID ,
  llvm::StringRef Blob) {
   if (R[0] != BitCodeConstants::USRHashSize)
@@ -98,7 +104,6 @@ llvm::Error decodeRecord(const Record , InfoType ,
   case InfoType::IT_function:
   case InfoType::IT_default:
   case InfoType::IT_enum:
-  case InfoType::IT_typedef:
 Field = IT;
 return llvm::Error::success();
   }
@@ -228,23 +233,6 @@ llvm::Error parseRecord(const Record , unsigned ID, 
llvm::StringRef Blob,
   }
 }
 
-llvm::Error parseRecord(const Record , unsigned ID, llvm::StringRef Blob,
-TypedefInfo *I) {
-  switch (ID) {
-  case TYPEDEF_USR:
-return decodeRecord(R, I->USR, Blob);
-  case TYPEDEF_NAME:
-return decodeRecord(R, I->Name, Blob);
-  case TYPEDEF_DEFLOCATION:
-return decodeRecord(R, I->DefLoc, Blob);
-  case TYPEDEF_IS_USING:
-return decodeRecord(R, I->IsUsing, Blob);
-  default:
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "invalid field for TypedefInfo");
-  }
-}
-
 llvm::Error parseRecord(const Record , unsigned ID, llvm::StringRef Blob,
 EnumValueInfo *I) {
   switch (ID) {
@@ -436,11 +424,6 @@ template <> llvm::Error addTypeInfo(EnumInfo *I, TypeInfo 
&) {
   return llvm::Error::success();
 }
 
-template <> llvm::Error addTypeInfo(TypedefInfo *I, TypeInfo &) {
-  I->Underlying = std::move(T);
-  return llvm::Error::success();
-}
-
 template  llvm::Error addReference(T I, Reference &, FieldId F) {
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "invalid type cannot contain Reference");
@@ -492,17 +475,6 @@ template <> llvm::Error addReference(EnumInfo *I, 
Reference &, FieldId F) {
   }
 }
 
-template <> llvm::Error addReference(TypedefInfo *I, Reference &, FieldId F) 
{
-  switch (F) {
-  case FieldId::F_namespace:
-I->Namespace.emplace_back(std::move(R));
-return llvm::Error::success();
-  default:
-return llvm::createStringError(llvm::inconvertibleErrorCode(),
-   "invalid type cannot contain Reference");
-  }
-}
-
 template <>
 llvm::Error addReference(NamespaceInfo *I, Reference &, FieldId F) {
   switch (F) {
@@ -510,10 +482,10 @@ llvm::Error addReference(NamespaceInfo *I, Reference &, 
FieldId F) {
 I->Namespace.emplace_back(std::move(R));
 return llvm::Error::success();
   case FieldId::F_child_namespace:
-I->Children.Namespaces.emplace_back(std::move(R));
+I->ChildNamespaces.emplace_back(std::move(R));
 return llvm::Error::success();
   case FieldId::F_child_record:
-I->Children.Records.emplace_back(std::move(R));
+I->ChildRecords.emplace_back(std::move(R));
 return llvm::Error::success();
   default:
 

[PATCH] D134371: [clang-doc] Add typedef/using information.

2022-09-27 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

This causes failures with `-Werror` such as: 
https://lab.llvm.org/buildbot/#/builders/57/builds/22322
Please fix or revert.




Comment at: clang-tools-extra/clang-doc/Representation.h:45
+  IT_enum,
+  IT_typedef
 };

There are at least a couple of `switch` statements where this enumerator isn't 
covered.
Examples:
```
clang-tools-extra/clang-doc/HTMLGenerator.cpp:847:11:
clang-tools-extra/clang-doc/MDGenerator.cpp:327:15
clang-tools-extra/clang-doc/MDGenerator.cpp:365:11
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134371

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


[PATCH] D134688: MSVC AArch64 ABI: Homogeneous aggregates

2022-09-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie marked 2 inline comments as done.
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:4478-4480
   // MSVC Windows on Arm64 considers a type not HFA if it is not an
   // aggregate according to the C++14 spec. This is not consistent with the
   // AAPCS64, but is defacto spec on that platform.

rnk wrote:
> These comments seem stale. Are the checks below almost equivalent to C++14 
> isAggregate? In any case, they associate with the logic below, which is 
> arm-specific.
> 
> The arm check deserves some kind of comment to say that all aggregates are 
> permitted to be HFAs for non-ARM platforms, which mostly affects vectorcall 
> on x64/x86.
Not especially equivalent to C++14 aggregate, despite Microsoft's reports, I 
think.
For instance - the first requirement of a C++14 aggregate is that it has no 
user-provided ctors, but that's not a requirement for HFA: 
https://godbolt.org/z/Whazeha7v
& the no base classes requirement doesn't apply to HFA either - only no non-HFA 
base classes (& empty classes are considered non-HFA).

Updated the comment as best I could understand (I couldn't actually find the 
AAPCS64 rules to compare/contrast, so I'm hand waving a bit there - perhaps 
these ( 
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#homogeneous-aggregates
 ) are all the rules, though they're pretty slim, and don't discuss special 
members at all, for instance, nor refer to any particular C++ standard for 
further clarification, so far as I can see)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134688

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


[PATCH] D134772: [Clang] Make constraints of auto part of NTTP instead of AutoType

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D134772#3819551 , @mizvekov wrote:

> I don't think the problem here is an uniquing problem per se, it's just that 
> the constraints are part of the canonical type of undeduced auto, which is 
> undesirable for the NTTP.
>
> Maybe it would work to just add a new flag parameter to 
> `ASTContext::getAutoType` which makes it not add the constraints to the 
> canonical type?

Hmm. That sounds promising to me. Let me see if I could get this to work. 
Thanks.

> It is odd that the handling for TTP and NTTP is different here, but perhaps 
> we could move TTP to this solution as well?

Yeah, it is odd from the POV of template handling. From the type hierarchy POV, 
it is consistent because TTP is a type and `auto` is also a type. I guess 
ultimately we choose the one that is easy and extensible for future language 
features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134772

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


[PATCH] D134688: MSVC AArch64 ABI: Homogeneous aggregates

2022-09-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie updated this revision to Diff 463379.
dblaikie added a comment.

Update comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134688

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/homogeneous-aggregates.cpp

Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -92,7 +92,7 @@
 // ARM32: define{{.*}} arm_aapcs_vfpcc void @_Z15with_empty_base16HVAWithEmptyBase(%struct.HVAWithEmptyBase %a.coerce)
 void CC with_empty_base(HVAWithEmptyBase a) {}
 
-// FIXME: MSVC doesn't consider this an HVA because of the empty base.
+// WOA64: define dso_local void @"?with_empty_base@@YAXUHVAWithEmptyBase@@@Z"([2 x i64] %{{.*}})
 // X64: define dso_local x86_vectorcallcc void @"\01_Z15with_empty_base16HVAWithEmptyBase@@16"(%struct.HVAWithEmptyBase inreg %a.coerce)
 
 struct HVAWithEmptyBitField : Float1, Float2 {
@@ -172,4 +172,117 @@
   // WOA64-LABEL: define dso_local void @"?call_copy_haspodbase@pr47611@@YAXPEAUHasPodBase@1@@Z"
   // WOA64: call void @"?copy@pr47611@@YA?AUHasPodBase@1@PEAU21@@Z"(%"struct.pr47611::HasPodBase"* inreg sret(%"struct.pr47611::HasPodBase") align 8 %{{.*}}, %"struct.pr47611::HasPodBase"* noundef %{{.*}})
 }
-}; // namespace pr47611
+} // namespace pr47611
+
+namespace protected_member {
+struct HFA {
+  double x;
+  double y;
+protected:
+  double z;
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@protected_member@@YANUHFA@1@@Z"([3 x double] %{{.*}})
+}
+namespace private_member {
+struct HFA {
+  double x;
+  double y;
+private:
+  double z;
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@private_member@@YANUHFA@1@@Z"([3 x double] %{{.*}})
+}
+namespace polymorphic {
+struct NonHFA {
+  double x;
+  double y;
+  double z;
+  virtual void f1();
+};
+double foo(NonHFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@polymorphic@@YANUNonHFA@1@@Z"(%"struct.polymorphic::NonHFA"* noundef %{{.*}})
+}
+namespace trivial_copy_assignment {
+struct HFA {
+  double x;
+  double y;
+  double z;
+  HFA =(const HFA&) = default;
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@trivial_copy_assignment@@YANUHFA@1@@Z"([3 x double] %{{.*}})
+}
+namespace non_trivial_copy_assignment {
+struct NonHFA {
+  double x;
+  double y;
+  double z;
+  NonHFA =(const NonHFA&);
+};
+double foo(NonHFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@non_trivial_copy_assignment@@YANUNonHFA@1@@Z"(%"struct.non_trivial_copy_assignment::NonHFA"* noundef %{{.*}})
+}
+namespace user_provided_ctor {
+struct HFA {
+  double x;
+  double y;
+  double z;
+  HFA(int);
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@user_provided_ctor@@YANUHFA@1@@Z"([3 x double] %{{.*}})
+}
+namespace trivial_dtor {
+struct HFA {
+  double x;
+  double y;
+  double z;
+  ~HFA() = default;
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@trivial_dtor@@YANUHFA@1@@Z"([3 x double] %{{.*}})
+}
+namespace non_trivial_dtor {
+struct NonHFA {
+  double x;
+  double y;
+  double z;
+  ~NonHFA();
+};
+double foo(NonHFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@non_trivial_dtor@@YANUNonHFA@1@@Z"(%"struct.non_trivial_dtor::NonHFA"* noundef %{{.*}})
+}
+namespace non_empty_base {
+struct non_empty_base { double d; };
+struct HFA : non_empty_base {
+  double x;
+  double y;
+  double z;
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@non_empty_base@@YANUHFA@1@@Z"([4 x double] %{{.*}})
+}
+namespace empty_field {
+struct empty { };
+struct NonHFA {
+  double x;
+  double y;
+  double z;
+  empty e;
+};
+double foo(NonHFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@empty_field@@YANUNonHFA@1@@Z"(%"struct.empty_field::NonHFA"* noundef %{{.*}})
+}
+namespace non_empty_field {
+struct non_empty { double d; };
+struct HFA {
+  double x;
+  double y;
+  double z;
+  non_empty e;
+};
+double foo(HFA v) { return v.x + v.y; }
+// WOA64: define dso_local noundef double @"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -4474,10 +4474,45 @@
 }
 
 bool MicrosoftCXXABI::isPermittedToBeHomogeneousAggregate(
-const CXXRecordDecl *CXXRD) const {
-  // MSVC Windows on Arm64 considers a type not HFA if it is not an
-  // aggregate according to the C++14 spec. This is not consistent with the
-  

[PATCH] D134772: [Clang] Make constraints of auto part of NTTP instead of AutoType

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

@rsmith, thanks for chiming in.

In D134772#3819502 , @rsmith wrote:

> I'm somewhat skeptical of this approach, because constrained `auto` can 
> appear in places within the type of an NTTP other than the top level -- for 
> example, in `template`. (Clang is non-conforming and doesn't support 
> this yet, but it will need to do so eventually.)

Yep, I'm aware of the cases like `template`/`template`/`template`. It would need to retrieve the deduced 
type explicitly and the difference this patch brings is to look for the 
constraints from NTTP instead. It is not geat but doable.

> In principle, there could even be multiple different constrained `auto` types 
> within the type of the same NTTP in the future -- I don't think that can 
> happen with the current language rules, but it could happen in the Concepts 
> TS, and it only seems to be happenstance that prevents it in C++20 rather 
> than design intent. Fundamentally, the constraint is not associated with the 
> NTTP and is instead associated with the relevant portion of the NTTP's type.

I fully agree that fundamentally the constraint is associated with auto (the 
syntax rule suggests that too). I didn't think of the possibility that 
`multiple different constrained auto types within the type of the same NTTP`. 
It is very interesting. Any chance this approach could be tuned for that future 
use case? Like maintaining an array of constrains for the NTTP?

> If something in the design of constrained `auto` is meaning that uniquing 
> isn't working properly, maybe there's some way we can address that directly?

I gave a lot of thought to it but couldn't find a satisfactory approach. One 
way is to recreate injected template argument for constrained `auto` NTTP, but 
without the constraint, then use that the instantiate all the types I need for 
the partial ordering. It is definitely doable but pretty expensive. Any 
suggestions are greatly appreciated. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134772

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


[PATCH] D134657: [Driver] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134657

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


[PATCH] D134772: [Clang] Make constraints of auto part of NTTP instead of AutoType

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

I don't think the problem here is an uniquing problem per se, it's just that 
the constraints are part of the canonical type of undeduced auto, which is 
undesirable for the NTTP.

Maybe it would work to just add a new flag parameter to 
`ASTContext::getAutoType` which makes it not add the constraints to the 
canonical type?

It is odd that the handling for TTP and NTTP is different here, but perhaps we 
could move TTP to this solution as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134772

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


[clang] 697550a - [gn build] re-add hlsl.h after e432108bf254

2022-09-27 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-09-27T20:16:56-04:00
New Revision: 697550ac2a5c508af397f9c936d4a0c9edf0222c

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

LOG: [gn build] re-add hlsl.h after e432108bf254

Added: 


Modified: 
clang/lib/Headers/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Removed: 




diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index b8ee1fec86a2a..0e78238436c94 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -62,7 +62,9 @@ set(hip_files
   __clang_hip_runtime_wrapper.h
   )
 
-set(hlsl_h hlsl.h)
+set(hlsl_h
+  hlsl.h
+  )
 set(hlsl_subdir_files
   hlsl/hlsl_basic_types.h
   hlsl/hlsl_intrinsics.h

diff  --git a/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
index e9123a0e315c7..5101c5d99576c 100644
--- a/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -154,6 +154,7 @@ copy("Headers") {
 "hexagon_circ_brev_intrinsics.h",
 "hexagon_protos.h",
 "hexagon_types.h",
+"hlsl.h",
 "hlsl/hlsl_basic_types.h",
 "hlsl/hlsl_intrinsics.h",
 "hresetintrin.h",



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


[PATCH] D134772: [Clang] Make constraints of auto part of NTTP instead of AutoType

2022-09-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I'm somewhat skeptical of this approach, because constrained `auto` can appear 
in places within the type of an NTTP other than the top level -- for example, 
in `template`. (Clang is non-conforming and doesn't support this yet, 
but it will need to do so eventually.) In principle, there could even be 
multiple different constrained `auto` types within the type of the same NTTP in 
the future -- I don't think that can happen with the current language rules, 
but it could happen in the Concepts TS, and it only seems to be happenstance 
that prevents it in C++20 rather than design intent. Fundamentally, the 
constraint is not associated with the NTTP and is instead associated with the 
relevant portion of the NTTP's type. If something in the design of constrained 
`auto` is meaning that uniquing isn't working properly, maybe there's some way 
we can address that directly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134772

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


[PATCH] D134657: [Driver] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D134657#3819435 , @thakis wrote:

> This breaks `Driver/crash-diagnostics-dir-2.c` on my mac:
>
>   FAIL: Clang :: Driver/crash-diagnostics-dir-2.c (7510 of 15804)
>    TEST 'Clang :: Driver/crash-diagnostics-dir-2.c' 
> FAILED 
>   Script:
>   --
>   : 'RUN: at line 3';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
> -fcrash-diagnostics-dir=mydumps -c 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> 2>&1  | /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> --check-prefix=OPTION
>   : 'RUN: at line 6';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
> -c /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> 2>&1 | /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> --check-prefix=NOOPTION
>   : 'RUN: at line 9';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
> -fcrash-diagnostics-dir=mydumps -flto 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> 2>&1  | /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> --check-prefix=LTO-OPTION
>   : 'RUN: at line 14';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
> -flto 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> 2>&1 | /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
> --check-prefix=LTO-NOOPTION
>   --
>   Exit Code: 1
>   
>   Command Output (stderr):
>   --
>   
> /Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c:12:16:
>  error: LTO-OPTION: expected string not found in input
>   // LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
>  ^
>   :5:58: note: scanning from here
>"/Users/thakis/src/llvm-project/out/gn/bin/clang" "-cc1" "-triple" 
> "arm64-apple-macosx12.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" 
> "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" 
> "-emit-llvm-bc" "-flto=full" "-flto-unit" "-disable-free" 
> "-clear-ast-before-backend" "-main-file-name" "crash-diagnostics-dir-2.c" 
> "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" 
> "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" 
> "-fcompatibility-qualified-id-block-type-checking" 
> "-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-m1" 
> "-target-feature" "+v8.5a" "-target-feature" "+crc" "-target-feature" "+lse" 
> "-target-feature" "+rdm" "-target-feature" "+crypto" "-target-feature" 
> "+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
> "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" 
> "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
> "+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" 
> "-target-feature" "+sha2" "-target-feature" "+aes" "-target-abi" "darwinpcs" 
> "-fallow-half-arguments-and-returns" "-mllvm" 
> "-treat-scalable-fixed-error-as-warning" "-debugger-tuning=lldb" 
> "-target-linker-version" "305" "-mllvm" "-crash-diagnostics-dir=mydumps" 
> "-fcoverage-compilation-dir=/Users/thakis/src/llvm-project/out/gn/obj/clang/test/Driver"
>  "-resource-dir" "/Users/thakis/src/llvm-project/out/gn/lib/clang/16.0.0" 
> "-internal-isystem" "/usr/local/include" "-internal-isystem" 
> "/Users/thakis/src/llvm-project/out/gn/lib/clang/16.0.0/include" 
> "-internal-externc-isystem" "/usr/include" 
> "-fdebug-compilation-dir=/Users/thakis/src/llvm-project/out/gn/obj/clang/test/Driver"
>  "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" 
> "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
> "-fgnuc-version=4.2.1" "-fmax-type-align=16" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" 
> "-o" 
> "/var/folders/w6/wpbtszrs7jl9dc9l5qtdkvg0gn/T/lit-tmp-hggg2hg5/crash-diagnostics-dir-2-cac6d7.o"
>  "-x" "c" 
> "/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c"
>^
>   :5:1241: note: possible intended match here
>"/Users/thakis/src/llvm-project/out/gn/bin/clang" "-cc1" "-triple" 
> "arm64-apple-macosx12.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" 
> "-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" 
> "-emit-llvm-bc" "-flto=full" "-flto-unit" "-disable-free" 
> "-clear-ast-before-backend" "-main-file-name" "crash-diagnostics-dir-2.c" 
> "-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" 
> "-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" 
> "-fcompatibility-qualified-id-block-type-checking" 
> 

[clang] c4b79bf - Fix the test added in 55cd5bc50964449627f6f1

2022-09-27 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-09-27T16:42:55-07:00
New Revision: c4b79bf083e0c50f86f0dfe85b8bd0df1b3506a0

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

LOG: Fix the test added in 55cd5bc50964449627f6f1

It is hard to test the functionality for multiple platforms. Just test it
on Linux as similar patches did in the past.

Added: 
clang/test/Driver/crash-diagnostics-dir-4.c

Modified: 
clang/test/Driver/crash-diagnostics-dir-2.c

Removed: 




diff  --git a/clang/test/Driver/crash-diagnostics-dir-2.c 
b/clang/test/Driver/crash-diagnostics-dir-2.c
index 071afb81ed51b..432a8893f8786 100644
--- a/clang/test/Driver/crash-diagnostics-dir-2.c
+++ b/clang/test/Driver/crash-diagnostics-dir-2.c
@@ -1,16 +1,5 @@
-// UNSUPPORTED: ps4, system-windows
-
 // RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=OPTION
 // OPTION: "-crash-diagnostics-dir=mydumps"
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
 // NOOPTION-NOT: "-crash-diagnostics-dir
-
-// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \
-// RUN: | FileCheck %s --check-prefix=LTO-OPTION
-// LTO-OPTION: "-cc1"
-// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
-
-// RUN: %clang -### -flto %s 2>&1 | FileCheck %s --check-prefix=LTO-NOOPTION
-// LTO-NOOPTION: "-cc1"
-// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"

diff  --git a/clang/test/Driver/crash-diagnostics-dir-4.c 
b/clang/test/Driver/crash-diagnostics-dir-4.c
new file mode 100644
index 0..573e821ca1f81
--- /dev/null
+++ b/clang/test/Driver/crash-diagnostics-dir-4.c
@@ -0,0 +1,8 @@
+// RUN: %clang -target x86_64-linux-unknown -### 
-fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO-OPTION
+// LTO-OPTION: "-cc1"
+// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
+
+// RUN: %clang -target x86_64-linux-unknown -### -flto %s 2>&1 | FileCheck %s 
--check-prefix=LTO-NOOPTION
+// LTO-NOOPTION: "-cc1"
+// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"



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


[PATCH] D134371: [clang-doc] Add typedef/using information.

2022-09-27 Thread Paul Kirth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeed22583fd78: [clang-doc] Add typedef/using information. 
(authored by brettw, committed by paulkirth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134371

Files:
  clang-tools-extra/clang-doc/BitcodeReader.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Mapper.h
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
  clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
  clang-tools-extra/unittests/clang-doc/ClangDocTest.h
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MergeTest.cpp
  clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
  clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -28,15 +28,16 @@
   I.Path = "path/to/A";
   I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
 
-  I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace",
- InfoType::IT_namespace, "path/to/A/Namespace");
-  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
-  "path/to/A/Namespace");
-  I.ChildFunctions.emplace_back();
-  I.ChildFunctions.back().Name = "OneFunction";
-  I.ChildFunctions.back().Access = AccessSpecifier::AS_none;
-  I.ChildEnums.emplace_back();
-  I.ChildEnums.back().Name = "OneEnum";
+  I.Children.Namespaces.emplace_back(EmptySID, "ChildNamespace",
+ InfoType::IT_namespace,
+ "path/to/A/Namespace");
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path/to/A/Namespace");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Functions.back().Access = AccessSpecifier::AS_none;
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
 
   auto G = getYAMLGenerator();
   assert(G);
@@ -100,8 +101,8 @@
   I.TagType = TagTypeKind::TTK_Class;
   I.Bases.emplace_back(EmptySID, "F", "path/to/F", true,
AccessSpecifier::AS_public, true);
-  I.Bases.back().ChildFunctions.emplace_back();
-  I.Bases.back().ChildFunctions.back().Name = "InheritedFunctionOne";
+  I.Bases.back().Children.Functions.emplace_back();
+  I.Bases.back().Children.Functions.back().Name = "InheritedFunctionOne";
   I.Bases.back().Members.emplace_back(TypeInfo("int", "path/to/int"), "N",
   AccessSpecifier::AS_private);
   // F is in the global namespace
@@ -109,12 +110,12 @@
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record,
 "path/to/G");
 
-  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
-  "path/to/A/r");
-  I.ChildFunctions.emplace_back();
-  I.ChildFunctions.back().Name = "OneFunction";
-  I.ChildEnums.emplace_back();
-  I.ChildEnums.back().Name = "OneEnum";
+  I.Children.Records.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record,
+  "path/to/A/r");
+  I.Children.Functions.emplace_back();
+  I.Children.Functions.back().Name = "OneFunction";
+  I.Children.Enums.emplace_back();
+  I.Children.Enums.back().Name = "OneEnum";
 
   auto G = getYAMLGenerator();
   assert(G);
@@ -330,6 +331,30 @@
   EXPECT_EQ(Expected, Actual.str());
 }
 
+TEST(YAMLGeneratorTest, enumTypedefYAML) {
+  TypedefInfo I;
+  I.Name = "MyUsing";
+  I.Underlying = TypeInfo("int");
+  I.IsUsing = true;
+
+  auto G = getYAMLGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual, ClangDocContext());
+  assert(!Err);
+  std::string Expected =
+  R"raw(---
+USR: ''
+Name:'MyUsing'
+Underlying:
+  Name:'int'
+IsUsing: true
+...
+)raw";
+  EXPECT_EQ(Expected, Actual.str());
+}
+
 TEST(YAMLGeneratorTest, emitCommentYAML) {
   FunctionInfo I;
   I.Name = "f";
Index: 

[clang-tools-extra] eed2258 - [clang-doc] Add typedef/using information.

2022-09-27 Thread Paul Kirth via cfe-commits

Author: Brett Wilson
Date: 2022-09-27T23:35:16Z
New Revision: eed22583fd78d4d657fb70b99e62fbdc1f83b8f9

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

LOG: [clang-doc] Add typedef/using information.

Read typedef and "using" type alias declarations and serialize into the 
internal structures. Emit this information in the YAML output. The HTML and MD 
generators are unchanged.

Separate out the logic to create the parent namespace or record object and 
insert the newly created child into it. This logic was previously duplicated 
for every "info" type and is now shared.

To help this, a struct containing the child vectors was separated out so 
children can be added generically and without having too many templates.

A small change was made to populateParentNamespaces() to allow using types that 
aren't themselves DeclContexts (typedefs are the first example of this).

Reviewed By: paulkirth, haowei

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

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeReader.cpp
clang-tools-extra/clang-doc/BitcodeWriter.cpp
clang-tools-extra/clang-doc/BitcodeWriter.h
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Mapper.cpp
clang-tools-extra/clang-doc/Mapper.h
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-doc/Serialize.h
clang-tools-extra/clang-doc/YAMLGenerator.cpp
clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.h
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MergeTest.cpp
clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 027272691d038..8e1db35532a05 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -24,12 +24,6 @@ llvm::Error decodeRecord(const Record , 
llvm::SmallVectorImpl ,
   return llvm::Error::success();
 }
 
-llvm::Error decodeRecord(const Record , std::string ,
- llvm::StringRef Blob) {
-  Field.assign(Blob.begin(), Blob.end());
-  return llvm::Error::success();
-}
-
 llvm::Error decodeRecord(const Record , SymbolID ,
  llvm::StringRef Blob) {
   if (R[0] != BitCodeConstants::USRHashSize)
@@ -104,6 +98,7 @@ llvm::Error decodeRecord(const Record , InfoType ,
   case InfoType::IT_function:
   case InfoType::IT_default:
   case InfoType::IT_enum:
+  case InfoType::IT_typedef:
 Field = IT;
 return llvm::Error::success();
   }
@@ -233,6 +228,23 @@ llvm::Error parseRecord(const Record , unsigned ID, 
llvm::StringRef Blob,
   }
 }
 
+llvm::Error parseRecord(const Record , unsigned ID, llvm::StringRef Blob,
+TypedefInfo *I) {
+  switch (ID) {
+  case TYPEDEF_USR:
+return decodeRecord(R, I->USR, Blob);
+  case TYPEDEF_NAME:
+return decodeRecord(R, I->Name, Blob);
+  case TYPEDEF_DEFLOCATION:
+return decodeRecord(R, I->DefLoc, Blob);
+  case TYPEDEF_IS_USING:
+return decodeRecord(R, I->IsUsing, Blob);
+  default:
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid field for TypedefInfo");
+  }
+}
+
 llvm::Error parseRecord(const Record , unsigned ID, llvm::StringRef Blob,
 EnumValueInfo *I) {
   switch (ID) {
@@ -424,6 +436,11 @@ template <> llvm::Error addTypeInfo(EnumInfo *I, TypeInfo 
&) {
   return llvm::Error::success();
 }
 
+template <> llvm::Error addTypeInfo(TypedefInfo *I, TypeInfo &) {
+  I->Underlying = std::move(T);
+  return llvm::Error::success();
+}
+
 template  llvm::Error addReference(T I, Reference &, FieldId F) {
   return llvm::createStringError(llvm::inconvertibleErrorCode(),
  "invalid type cannot contain Reference");
@@ -475,6 +492,17 @@ template <> llvm::Error addReference(EnumInfo *I, 
Reference &, FieldId F) {
   }
 }
 
+template <> llvm::Error addReference(TypedefInfo *I, Reference &, FieldId F) 
{
+  switch (F) {
+  case FieldId::F_namespace:
+I->Namespace.emplace_back(std::move(R));
+return llvm::Error::success();
+  default:
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "invalid type cannot contain 

[PATCH] D134235: [clang-doc] Clean up *Info constructors.

2022-09-27 Thread Paul Kirth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0afc60858e11: [clang-doc] Clean up *Info constructors. 
(authored by brettw, committed by paulkirth).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134235

Files:
  clang-tools-extra/clang-doc/BitcodeReader.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
  clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/MergeTest.cpp
  clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
  clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -82,7 +82,7 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.Members.emplace_back("int", "path/to/int", "X",
+  I.Members.emplace_back(TypeInfo("int", "path/to/int"), "X",
  AccessSpecifier::AS_private);
 
   // Member documentation.
@@ -102,7 +102,7 @@
AccessSpecifier::AS_public, true);
   I.Bases.back().ChildFunctions.emplace_back();
   I.Bases.back().ChildFunctions.back().Name = "InheritedFunctionOne";
-  I.Bases.back().Members.emplace_back("int", "path/to/int", "N",
+  I.Bases.back().Members.emplace_back(TypeInfo("int", "path/to/int"), "N",
   AccessSpecifier::AS_private);
   // F is in the global namespace
   I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, "");
@@ -174,7 +174,6 @@
 Parents:
   - Type:Record
 Name:'F'
-IsInGlobalNamespace: true
 VirtualParents:
   - Type:Record
 Name:'G'
@@ -206,10 +205,10 @@
 
   I.Access = AccessSpecifier::AS_none;
 
-  I.ReturnType =
-  TypeInfo(EmptySID, "void", InfoType::IT_default, "path/to/void");
-  I.Params.emplace_back("int", "path/to/int", "P");
-  I.Params.emplace_back("double", "path/to/double", "D");
+  I.ReturnType = TypeInfo(
+  Reference(EmptySID, "void", InfoType::IT_default, "path/to/void"));
+  I.Params.emplace_back(TypeInfo("int", "path/to/int"), "P");
+  I.Params.emplace_back(TypeInfo("double", "path/to/double"), "D");
   I.Params.back().DefaultValue = "2.0 * M_PI";
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
@@ -335,9 +334,9 @@
   FunctionInfo I;
   I.Name = "f";
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
-  I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
-  I.Params.emplace_back("int", "I");
-  I.Params.emplace_back("int", "J");
+  I.ReturnType = TypeInfo("void");
+  I.Params.emplace_back(TypeInfo("int"), "I");
+  I.Params.emplace_back(TypeInfo("int"), "J");
   I.Access = AccessSpecifier::AS_none;
 
   CommentInfo Top;
Index: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
+++ clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
@@ -119,7 +119,7 @@
   NamespaceInfo ExpectedBWithFunction(EmptySID);
   FunctionInfo F;
   F.Name = "f";
-  F.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
+  F.ReturnType = TypeInfo("void");
   F.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
   F.Namespace.emplace_back(EmptySID, "B", InfoType::IT_namespace);
   F.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
@@ -165,7 +165,8 @@
InfoType::IT_namespace);
   ExpectedE.TagType = TagTypeKind::TTK_Class;
   ExpectedE.DefLoc = Location(0, llvm::SmallString<16>{"test.cpp"});
-  ExpectedE.Members.emplace_back("int", "value", AccessSpecifier::AS_public);
+  ExpectedE.Members.emplace_back(TypeInfo("int"), "value",
+ AccessSpecifier::AS_public);
   // TODO the data member should have the docstring on it:
   //ExpectedE.Members.back().Description.push_back(MakeOneLineCommentInfo(" Some docs"));
   CheckRecordInfo(, E);
@@ -175,7 +176,7 @@
   FunctionInfo EConstructor;
   EConstructor.Name = "E";
   EConstructor.Parent = Reference(EmptySID, "E", InfoType::IT_record);
-  EConstructor.ReturnType = TypeInfo(EmptySID, "void", 

[clang-tools-extra] 0afc608 - [clang-doc] Clean up *Info constructors.

2022-09-27 Thread Paul Kirth via cfe-commits

Author: Brett Wilson
Date: 2022-09-27T23:31:41Z
New Revision: 0afc60858e1183344e0786eaa3b123f9faed185e

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

LOG: [clang-doc] Clean up *Info constructors.

The *Info object (for the copy of the AST") constructors had many duplicated 
variants. Many of the variants seemed to be in an attempt to avoid default 
arguments. But default arguments are not prohibited and using them allows most 
of the variants to be removed which improves readability.

Remove the IsInGlobalNamespace flag on a Reference. This is set when the path 
is empty, and only read once in the HTML generator with the identical 
condition. The constructor cleanup exposed a problem where this was set to 
false when the constructor with no path was used, but true when the path was 
set to empty.

There should be no observable change with the exception that 
IsInGlobalNamespace is no longer emitted in YAML.

Reviewed By: paulkirth, haowei

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

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeReader.cpp
clang-tools-extra/clang-doc/BitcodeWriter.cpp
clang-tools-extra/clang-doc/BitcodeWriter.h
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/Representation.cpp
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-doc/YAMLGenerator.cpp
clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
clang-tools-extra/unittests/clang-doc/GeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MergeTest.cpp
clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index da7f6246b0292..027272691d038 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -342,8 +342,6 @@ llvm::Error parseRecord(const Record , unsigned ID, 
llvm::StringRef Blob,
 return decodeRecord(R, I->RefType, Blob);
   case REFERENCE_PATH:
 return decodeRecord(R, I->Path, Blob);
-  case REFERENCE_IS_IN_GLOBAL_NAMESPACE:
-return decodeRecord(R, I->IsInGlobalNamespace, Blob);
   case REFERENCE_FIELD:
 return decodeRecord(R, F, Blob);
   default:

diff  --git a/clang-tools-extra/clang-doc/BitcodeWriter.cpp 
b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
index 993e4ddc9d485..194194aef3e2d 100644
--- a/clang-tools-extra/clang-doc/BitcodeWriter.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
@@ -187,8 +187,6 @@ static const llvm::IndexedMap
   {REFERENCE_NAME, {"Name", }},
   {REFERENCE_TYPE, {"RefType", }},
   {REFERENCE_PATH, {"Path", }},
-  {REFERENCE_IS_IN_GLOBAL_NAMESPACE,
-   {"IsInGlobalNamespace", }},
   {REFERENCE_FIELD, {"Field", }}};
   assert(Inits.size() == RecordIdCount);
   for (const auto  : Inits) {
@@ -239,7 +237,7 @@ static const std::vector>>
 // Reference Block
 {BI_REFERENCE_BLOCK_ID,
  {REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH,
-  REFERENCE_IS_IN_GLOBAL_NAMESPACE, REFERENCE_FIELD}}};
+  REFERENCE_FIELD}}};
 
 // AbbreviationMap
 
@@ -412,7 +410,6 @@ void ClangDocBitcodeWriter::emitBlock(const Reference , 
FieldId Field) {
   emitRecord(R.Name, REFERENCE_NAME);
   emitRecord((unsigned)R.RefType, REFERENCE_TYPE);
   emitRecord(R.Path, REFERENCE_PATH);
-  emitRecord(R.IsInGlobalNamespace, REFERENCE_IS_IN_GLOBAL_NAMESPACE);
   emitRecord((unsigned)Field, REFERENCE_FIELD);
 }
 

diff  --git a/clang-tools-extra/clang-doc/BitcodeWriter.h 
b/clang-tools-extra/clang-doc/BitcodeWriter.h
index 4015c5da35bdf..d5aba22db9cf1 100644
--- a/clang-tools-extra/clang-doc/BitcodeWriter.h
+++ b/clang-tools-extra/clang-doc/BitcodeWriter.h
@@ -122,7 +122,6 @@ enum RecordId {
   REFERENCE_NAME,
   REFERENCE_TYPE,
   REFERENCE_PATH,
-  REFERENCE_IS_IN_GLOBAL_NAMESPACE,
   REFERENCE_FIELD,
   RI_LAST,
   RI_FIRST = VERSION

diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 211cc9ff2053f..45f10e0f20dd1 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -308,7 +308,7 @@ static std::unique_ptr genLink(const Twine , 
const Twine ) {
 static std::unique_ptr
 genReference(const Reference , StringRef CurrentDirectory,
  llvm::Optional JumpToSection = None) {
-  if (Type.Path.empty() && !Type.IsInGlobalNamespace) {
+ 

[PATCH] D134657: [Driver] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks `Driver/crash-diagnostics-dir-2.c` on my mac:

  FAIL: Clang :: Driver/crash-diagnostics-dir-2.c (7510 of 15804)
   TEST 'Clang :: Driver/crash-diagnostics-dir-2.c' FAILED 

  Script:
  --
  : 'RUN: at line 3';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
-fcrash-diagnostics-dir=mydumps -c 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 2>&1 
 | /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
--check-prefix=OPTION
  : 'RUN: at line 6';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### -c 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 2>&1 
| /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
--check-prefix=NOOPTION
  : 'RUN: at line 9';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
-fcrash-diagnostics-dir=mydumps -flto 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 2>&1 
 | /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
--check-prefix=LTO-OPTION
  : 'RUN: at line 14';   /Users/thakis/src/llvm-project/out/gn/bin/clang -### 
-flto 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 2>&1 
| /Users/thakis/src/llvm-project/out/gn/bin/FileCheck 
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c 
--check-prefix=LTO-NOOPTION
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c:12:16:
 error: LTO-OPTION: expected string not found in input
  // LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
 ^
  :5:58: note: scanning from here
   "/Users/thakis/src/llvm-project/out/gn/bin/clang" "-cc1" "-triple" 
"arm64-apple-macosx12.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" 
"-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" 
"-emit-llvm-bc" "-flto=full" "-flto-unit" "-disable-free" 
"-clear-ast-before-backend" "-main-file-name" "crash-diagnostics-dir-2.c" 
"-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" 
"-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" 
"-fcompatibility-qualified-id-block-type-checking" 
"-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-m1" 
"-target-feature" "+v8.5a" "-target-feature" "+crc" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+rcpc" 
"-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" 
"-target-feature" "+sm4" "-target-feature" "+sha3" "-target-feature" "+sha2" 
"-target-feature" "+aes" "-target-abi" "darwinpcs" 
"-fallow-half-arguments-and-returns" "-mllvm" 
"-treat-scalable-fixed-error-as-warning" "-debugger-tuning=lldb" 
"-target-linker-version" "305" "-mllvm" "-crash-diagnostics-dir=mydumps" 
"-fcoverage-compilation-dir=/Users/thakis/src/llvm-project/out/gn/obj/clang/test/Driver"
 "-resource-dir" "/Users/thakis/src/llvm-project/out/gn/lib/clang/16.0.0" 
"-internal-isystem" "/usr/local/include" "-internal-isystem" 
"/Users/thakis/src/llvm-project/out/gn/lib/clang/16.0.0/include" 
"-internal-externc-isystem" "/usr/include" 
"-fdebug-compilation-dir=/Users/thakis/src/llvm-project/out/gn/obj/clang/test/Driver"
 "-ferror-limit" "19" "-stack-protector" "1" "-fblocks" 
"-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" 
"-fgnuc-version=4.2.1" "-fmax-type-align=16" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" 
"-o" 
"/var/folders/w6/wpbtszrs7jl9dc9l5qtdkvg0gn/T/lit-tmp-hggg2hg5/crash-diagnostics-dir-2-cac6d7.o"
 "-x" "c" 
"/Users/thakis/src/llvm-project/clang/test/Driver/crash-diagnostics-dir-2.c"
   ^
  :5:1241: note: possible intended match here
   "/Users/thakis/src/llvm-project/out/gn/bin/clang" "-cc1" "-triple" 
"arm64-apple-macosx12.0.0" "-Wundef-prefix=TARGET_OS_" "-Werror=undef-prefix" 
"-Wdeprecated-objc-isa-usage" "-Werror=deprecated-objc-isa-usage" 
"-emit-llvm-bc" "-flto=full" "-flto-unit" "-disable-free" 
"-clear-ast-before-backend" "-main-file-name" "crash-diagnostics-dir-2.c" 
"-mrelocation-model" "pic" "-pic-level" "2" "-mframe-pointer=non-leaf" 
"-ffp-contract=on" "-fno-rounding-math" "-funwind-tables=1" 
"-fcompatibility-qualified-id-block-type-checking" 
"-fvisibility-inlines-hidden-static-local-var" "-target-cpu" "apple-m1" 
"-target-feature" "+v8.5a" "-target-feature" "+crc" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 

[PATCH] D134772: [Clang] Make constraints of auto part of NTTP instead of AutoType

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: mizvekov, saar.raz, rsmith.
Herald added subscribers: arphaman, martong, kristof.beyls.
Herald added a reviewer: shafik.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

While working on D128750 , it is found that 
AutoType is not uniqued as expected in the partial ordering. This is because
AutoType contains the constraints for the NTTP and the NTTP itself has a 
reference to the constraint in AutoType.
Due to this restriction, the partial ordering between `template` and 
`template` could not be handled the same way
as the partial ordering between `template` and `template`. By P2113 
, they should work the same way and if it 
doesn't,
the implementation of P2113  would be much 
harder if at all possible. After this patch, NTTP constraints operates the same 
as
TTP constraints, which is to say, constraints are represented separately from 
the type. This is also easier to understand and maintain.

Note that this patch only changes how `constrained auto` is represented in 
NTTP. Nothing is changed when
`constrained auto` is used as function parameters, as variable declarations etc.

- Add a TypeConstraint to NonTypeTemplateParmDecl in the same way as 
TemplateTypeParmDecl
- During parsing, parse the constraint as a part of NTTP. This also means the 
constraint inside AutoType would be empty (and later in partial ordering, 
AutoType uniquing would work due to this).
- Looking at how the constraint for TemplateTypeParmDecl is handled, add 
similar/same handling for the constraint for NonTypeTemplateParmDecl.

For (TTP `W` is added for comparsion purposes.)

  template  concept C = true;
  template struct A;

AST before this patch:

  `-ClassTemplateDecl 0x9091c60  col:32 A
|-NonTypeTemplateParmDecl 0x9091818  col:17 referenced 'C 
auto' depth 0 index 0 V> C is part of AutoType
| `-ConceptSpecializationExpr 0x9091948  'bool' Concept 0x90916e8 
'C'
|   `-TemplateArgument  type 'decltype(V)'
| `-DecltypeType 0x90918e0 'decltype(V)' dependent
|   `-DeclRefExpr 0x9091878  'C auto' NonTypeTemplateParm 
0x9091818 'V' 'C auto'
|-TemplateTypeParmDecl 0x90919d0  col:22 Concept 0x90916e8 
'C' depth 0 index 1 W
| `-ConceptSpecializationExpr 0x9091b08  'bool' Concept 0x90916e8 
'C'
|   `-TemplateArgument  type 'W'
| `-TemplateTypeParmType 0x9091aa0 'W' dependent depth 0 index 1
|   `-TemplateTypeParm 0x90919d0 'W'
`-CXXRecordDecl 0x9091bb0  col:32 struct A

AST after this patch:

  `-ClassTemplateDecl 0x887dd40  col:32 A
|-NonTypeTemplateParmDecl 0x887d8b8  col:17 referenced 
Concept 0x887d788 'C' 'auto' depth 0 index 0 V   > C is part of NTTP
| `-ConceptSpecializationExpr 0x887da28  'bool' Concept 0x887d788 
'C'
|   `-TemplateArgument  type 'decltype(V)'
| `-DecltypeType 0x887d9c0 'decltype(V)' dependent
|   `-DeclRefExpr 0x887d960  'auto' NonTypeTemplateParm 
0x887d8b8 'V' 'auto'
|-TemplateTypeParmDecl 0x887dab0  col:22 Concept 0x887d788 
'C' depth 0 index 1 W
| `-ConceptSpecializationExpr 0x887dbe8  'bool' Concept 0x887d788 
'C'
|   `-TemplateArgument  type 'W'
| `-TemplateTypeParmType 0x887db80 'W' dependent depth 0 index 1
|   `-TemplateTypeParm 0x887dab0 'W'
`-CXXRecordDecl 0x887dc90  col:32 struct A


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134772

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/ODRHash.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/SemaTemplate/instantiate-expanded-type-constraint.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -933,6 +933,11 @@
 }
 
 bool CursorVisitor::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
+  if (const auto *TC = D->getPlaceholderTypeConstraint()) {
+if (VisitTypeConstraint(*TC))
+  return true;
+  }
+
   if (VisitDeclaratorDecl(D))
 return true;
 
@@ -5356,17 +5361,22 @@
 
   // There is no parameter name, which makes this tricky. Try to come 

[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-27 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 463351.
ayzhao added a comment.

add test and fix for P2092 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr4xx.cpp
  clang/test/CXX/drs/dr5xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p2-2.cpp
  clang/test/CXX/temp/temp.res/p3.cpp
  clang/test/CXX/temp/temp.res/p4.cpp
  clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
  clang/test/FixIt/fixit.cpp
  clang/test/Parser/cxx-member-initializers.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/MicrosoftSuper.cpp
  clang/test/SemaCXX/rounding-math-crash.cpp
  clang/test/SemaCXX/typo-correction.cpp
  clang/test/SemaCXX/unknown-type-name.cpp
  clang/test/SemaTemplate/alias-templates.cpp
  clang/test/SemaTemplate/typename-specifier-3.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -959,11 +959,7 @@
   
   
 https://wg21.link/p2092r0;>P2092R0
-
-  Partial
-typename not yet optional (depends on P0634R3).
-  
-
+Clang 16
   
   
 https://wg21.link/p2113r0;>P2113R0
@@ -1052,7 +1048,7 @@
 
   typename optional in more contexts
   https://wg21.link/p0634r3;>P0634R3
-  No
+  Clang 16
 
 
   Pack expansion in lambda init-capture
Index: clang/test/SemaTemplate/typename-specifier-3.cpp
===
--- clang/test/SemaTemplate/typename-specifier-3.cpp
+++ clang/test/SemaTemplate/typename-specifier-3.cpp
@@ -28,7 +28,7 @@
   typedef int arg;
 };
 struct C {
-  typedef B::X x; // expected-error {{missing 'typename'}}
+  typedef B::X x; // precxx17-warning{{missing 'typename' prior to dependent type name B::X; implicit 'typename' is a C++20 extension}}
 };
   };
 
Index: clang/test/SemaTemplate/alias-templates.cpp
===
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -193,11 +193,10 @@
   struct base {
 template  struct derived;
   };
-  // FIXME: The diagnostics here are terrible.
   template 
-  using derived = base::template derived; // expected-error {{expected a type}} expected-error {{expected ';'}}
+  using derived = base::template derived; // expected-warning {{missing 'typename'}}
   template 
-  using derived2 = ::PR16904::base::template derived; // expected-error {{expected a type}} expected-error {{expected ';'}}
+  using derived2 = ::PR16904::base::template derived; // expected-warning {{missing 'typename'}}
 }
 
 namespace PR14858 {
Index: clang/test/SemaCXX/unknown-type-name.cpp
===
--- clang/test/SemaCXX/unknown-type-name.cpp
+++ clang/test/SemaCXX/unknown-type-name.cpp
@@ -36,15 +36,15 @@
 
   static int n;
   static type m;
-  static int h(T::type, int); // expected-error{{missing 'typename'}}
-  static int h(T::type x, char); // expected-error{{missing 'typename'}}
+  static int h(T::type, int); // expected-warning{{implicit 'typename' is a C++20 extension}}
+  static int h(T::type x, char); // expected-warning{{implicit 'typename' is a C++20 extension}}
 };
 
 template
-A::type g(T t) { return t; } // expected-error{{missing 'typename'}}
+A::type g(T t) { return t; } // expected-warning{{implicit 'typename' is a C++20 extension}}
 
 template
-A::type A::f() { return type(); } // expected-error{{missing 'typename'}}
+A::type A::f() { return type(); } // expected-warning{{implicit 'typename' is a C++20 extension}}
 
 template
 void f(T::type) { } // expected-error{{missing 'typename'}}
@@ -84,11 +84,11 @@
 
 template int A::n(T::value); // ok
 template
-A::type // expected-error{{missing 'typename'}}
+A::type // expected-warning {{implicit 'typename' is a C++20 extension}}
 A::m(T::value, 0); // ok
 
-template int A::h(T::type, int) {} // expected-error{{missing 

[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-27 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

In D53847#3819200 , @cor3ntin wrote:

> Good catch
>
>   template
>   concept K = requires (typename T::Type X) { // (3)
>   X.next();
>   }
>
> That typename should be optional. Can you add a test for that? If it works 
> you can mark P2092  as fully supported.

Done.

The test originally failed, but it was a simple fix to get it to work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

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


[PATCH] D133705: [HIP] Fix unbundling archive

2022-09-27 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl closed this revision.
yaxunl added a comment.

committed by 1172bdecfab364579d90e6aa5ba7fc64a5b96786 



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

https://reviews.llvm.org/D133705

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


[PATCH] D134604: [clang] Instiantiate early substituted entities with sugared template arguments

2022-09-27 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D134604#3815634 , @mizvekov wrote:

> I was aware of those discussions, and I even made a workaround to avoid this 
> extra cost of running unrelated pipelines.
> The patch on the very bottom of this stack (D134079 
> ) disables all the other pipelines except 
> the bootstrapping one.

Oh, awesome, I wasn't aware of that. Okay, this mitigates a lot of my concern 
then. The only remaining annoyance is the additional traffic on the libc++ 
review group, but that's manageable if it gets you the testing you need until 
we've improved the CI situation w/ Clang.

> I have two other patches in the stack which I will need to keep running the 
> libcxx-ci as I update them: D131858  and 
> D127695 . These have had non-trivial libcxx 
> breakages, and I have even seen new problems introduced as you keep working 
> on the ranges implementation.

Understood, in that case I think your usage of the CI is definitely justified. 
I mostly wanted to get the word out that this is not a pattern we want to 
encourage more generally, for the reasons explained, but I think it doesn't 
apply here.

> Thanks by the way for the awesome work on the libcxx-CI, and I hope in the 
> near future these workarounds will not be needed anymore!

Hey, thanks to you for wanting to ensure your patches don't break libc++ :-)!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134604

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


[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp:92
+  case InlineAsm::Constraint_m: {
+SDValue Base, Offset;
+Base = Op;

Prefer initializing the variable when it is declared



Comment at: llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp:113
+  case InlineAsm::Constraint_ZC: {
+SDValue Base, Offset;
+Base = Op;

Prefer initializing the variable when it is declared


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

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


[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:103
+  Info.setAllowsMemory();
+  Name++; // Skip over 'Z'.
+  return true;

`++Name`



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:117
+// parsing.
+R = std::string("^") + std::string(Constraint, 2);
+Constraint++;

First `std::string` can be omitted



Comment at: clang/lib/Basic/Targets/LoongArch.cpp:118
+R = std::string("^") + std::string(Constraint, 2);
+Constraint++;
+break;

pre-increment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

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


[PATCH] D133659: [Clang] P1169R4: static operator()

2022-09-27 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

GCC have implemented this yesterday 
,
 and they also apply the overload resolution change retroactively. So I've done 
it as well and downgraded the errors to ExtWarns.

I'm not sure that the change to the conversion sequences in the overload 
resolution is the best way to implement this but it was the cleanest way I 
found..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133659

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


[PATCH] D133659: [Clang] P1169R4: static operator()

2022-09-27 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 463346.
royjacobson added a comment.

- Fix overload resolution and apply it retroactively
- Allow static lambdas and static operator() as extensions
- Define the feature macros in earlier versions and fix the tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133659

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OperatorKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/over/over.match/over.match.best/over.best.ics/p6.cpp
  clang/test/CXX/over/over.oper/p7.cpp
  clang/test/CodeGenCXX/cxx2b-static-call-operator.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/Parser/cxx2b-lambdas-ext-warns.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/test/SemaCXX/lambda-unevaluated.cpp
  clang/test/SemaCXX/overloaded-operator-decl.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1481,7 +1481,7 @@
 
   static operator()
   https://wg21.link/P1169R4;>P1169R4
-  No
+  Clang 16
 
 
   Extended floating-point types and standard names
Index: clang/test/SemaCXX/overloaded-operator-decl.cpp
===
--- clang/test/SemaCXX/overloaded-operator-decl.cpp
+++ clang/test/SemaCXX/overloaded-operator-decl.cpp
@@ -51,7 +51,7 @@
 
 namespace PR14120 {
   struct A {
-static void operator()(int& i) { ++i; } // expected-error{{overloaded 'operator()' cannot be a static member function}}
+static void operator()(int& i) { ++i; } // expected-warning{{is a C++2b extension}}
   };
   void f() {
 int i = 0;
Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++20 %s -verify
+// RUN: %clang_cc1 -std=c++2b %s -verify
 
 
 template  struct Nothing {};
@@ -120,3 +121,28 @@
 void foo(decltype(+[](T) {}) lambda, T param);
 static_assert(!__is_same(decltype(foo), void));
 } // namespace GH51641
+
+#if __cplusplus > 202002L
+namespace StaticLambdas {
+template  struct Nothing {};
+Nothing<[]() static { return 0; }()> nothing;
+
+template  struct NothingT {};
+Nothing<[]() static { return 0; }> nothingT;
+
+template 
+concept True = [] static { return true; }();
+static_assert(True);
+
+static_assert(sizeof([] static { return 0; }));
+static_assert(sizeof([] static { return 0; }()));
+
+void f()  noexcept(noexcept([] static { return 0; }()));
+
+using a = decltype([] static { return 0; });
+using b = decltype([] static { return 0; }());
+using c = decltype([]() static noexcept(noexcept([] { return 0; }())) { return 0; });
+using d = decltype(sizeof([] static { return 0; }));
+
+}
+#endif
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- clang/test/Parser/cxx2b-lambdas.cpp
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -38,3 +38,31 @@
 auto XL4 = [] requires true {}; // expected-error{{expected body}}
 auto XL5 = [] requires true requires true {}; // expected-error{{expected body}}
 auto XL6 = [] requires true noexcept requires true {}; // expected-error{{expected body}}
+
+auto XL7 = []() static static {}; // expected-error {{cannot appear multiple times}}
+auto XL8 = []() static mutable {}; // expected-error {{cannot be both mutable and static}}
+auto XL9 = []() static consteval {};
+auto XL10 = []() static constexpr {};
+
+auto XL11 = [] static {};
+auto XL12 = []() static {};
+auto XL13 = []() static extern {};  // expected-error {{expected body of lambda expression}}
+auto XL14 = []() extern {};  // expected-error {{expected body of lambda expression}}
+
+
+void static_captures() {
+  int x;
+  auto SC1 = [&]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC4 = [x]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC2 = []() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC3 = [y=x]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note 

[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-27 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a reviewer: JonasToth.
nicovank added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131939

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


[PATCH] D134454: [Driver][Distro] Fix ArchLinux sysroot detection

2022-09-27 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:360-361
 // CSKY toolchains use different names for sysroot folder.
 if (!GCCInstallation.isValid())
   return std::string();
 // GCCInstallation.getInstallPath() =

hoist



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:365-366
 // Path = $GCCToolchainPath/csky-linux-gnuabiv2/libc
 std::string Path = (GCCInstallation.getInstallPath() + "/../../../../" +
 GCCInstallation.getTriple().str() + "/libc")
.str();

duplication with below...



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:373-374
 
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
 return std::string();
 

Cool, now this can be hoisted above `if (getTriple().isCSKY()) {` and not 
checked again within that condition.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:376
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
+  const Distro Distro(getDriver().getVFS(), getTriple());
   const StringRef InstallDir = GCCInstallation.getInstallPath();

I see that `getVFS()` is called already without going through `getDriver()` in 
this method. Can we do so as well here?



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:377-389
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
   const Multilib  = GCCInstallation.getMultilib();
+  std::string BasePath = (InstallDir + "/../../../../" + TripleStr).str();
 
-  std::string Path =
-  (InstallDir + "/../../../../" + TripleStr + "/libc" + 
Multilib.osSuffix())
-  .str();
-
-  if (getVFS().exists(Path))
-return Path;
+  if (Distro.IsArchLinux() && getVFS().exists(BasePath))
+return BasePath;

...seems like some of this is duplicated with CSKY above. Can you please 
refactor the MIPS and CSKY checks to reuse more code?

I doubt arch-linux has a CSKY port; I suspect you might be able to check for 
arch-linux first, then do the CSKY and MIPS special casing after.

All this code is doing is figuring out a Path, then if it exists then return 
it.  Feel like is should be:

```
if android:
  path = ...
elif arch:
  path = ...
elif csky:
  path = ...
elif mips:
  path = ...
else:
  return ""

if path.exists():
  return path
return ""
```



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:377-394
+  if (Distro.IsArchLinux()) {
+std::string Path = (InstallDir + "/../../../../"  + TripleStr).str();
+if (getVFS().exists(Path))
+  return Path;
+  }
+
   if (!GCCInstallation.isValid() || !getTriple().isMIPS())

10ne1 wrote:
> nickdesaulniers wrote:
> > 10ne1 wrote:
> > > nickdesaulniers wrote:
> > > > Do we need the Arch-linux test before the call to 
> > > > `GCCInstallation.isValid()`? Otherwise it seems like this duplicates a 
> > > > fair amount of code computing the `Path`.  The initial parts of the 
> > > > Path seem to match; there's only more to it if the Distro is not 
> > > > arch-linux.
> > > In my testing on ArchLinux, `GCCInstallation.isValid()` is always `true`.
> > > 
> > > The problem is that if test condition doesn't just test for a valid GCC 
> > > install, it also tests `getTriple().isMIPS()` which is always false on 
> > > Arch Linux which does not support mips, so the sysroot will always be an 
> > > empty string.
> > > 
> > > If you wish I can create a separate commit / review to untangle `if 
> > > (!GCCInstallation.isValid() || !getTriple().isMIPS())` and try to reduce 
> > > the code duplication, because really having a valid GCC install is 
> > > independent from running on mips. What do you think?
> > That doesn't make sense.
> > 
> > If `GCCInstallation.isValid()` is always `true` then we should not be 
> > returning the empty string.
> It does makes sense if you read the condition carefully:
> 
> ```
> if (!GCCInstallation.isValid() || !getTriple().isMIPS())
> ```
> 
> results in:
> 
> ```
> if ( ! true || ! false )
> ```
> 
> which means an empty string is always returned because Arch does not support 
> mips even though a valid GCC install is present.
> 
> I think I'll just go ahead and clean up this code and update the diff to drop 
> the triple normalization. 
> 
> 
Ah, ok. Yeah your refactoring is making this clearer.  I think we can refactor 
this method a bit more (in addition to fixing this Arch-Linux specific issue).


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

https://reviews.llvm.org/D134454

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D134687: [clang] Ensure correct metadata for relative vtables

2022-09-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/lib/CodeGen/CGVTables.cpp:1288-1293
+  llvm::Type *ComponentType;
+  if (UseRelativeLayout(*this))
+ComponentType = Int32Ty;
+  else
+ComponentType = Int8PtrTy;
+  CharUnits ComponentWidth = GetTargetTypeStoreSize(ComponentType);

Could we use `getVTableComponentType` method here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134687

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


[PATCH] D134638: [Clang][LoongArch] Add inline asm support for constraints k/m/ZB/ZC

2022-09-27 Thread Renato Golin via Phabricator via cfe-commits
rengolin accepted this revision.
rengolin added a comment.

Looks good, with some nits. Thanks!




Comment at: llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp:76
+  // TODO: handle extra code.
+  if (!ExtraCode) {
+const MachineOperand  = MI->getOperand(OpNo);

NIT: Use early exit.

if (ExtraCode)
  return false;



Comment at: llvm/test/CodeGen/LoongArch/inline-asm-constraint-ZC.ll:16
+;
+; LA64-LABEL: ZC_offset_neg_32769:
+; LA64:   # %bb.0:

Same comment as before, these CHECK lines look identical for both targets...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134638

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


[PATCH] D134688: MSVC AArch64 ABI: Homogeneous aggregates

2022-09-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Nice! Mostly comment copy edits.




Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:4478-4480
   // MSVC Windows on Arm64 considers a type not HFA if it is not an
   // aggregate according to the C++14 spec. This is not consistent with the
   // AAPCS64, but is defacto spec on that platform.

These comments seem stale. Are the checks below almost equivalent to C++14 
isAggregate? In any case, they associate with the logic below, which is 
arm-specific.

The arm check deserves some kind of comment to say that all aggregates are 
permitted to be HFAs for non-ARM platforms, which mostly affects vectorcall on 
x64/x86.



Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:4498
+  // anything containing/derived from one is non-homogeneous.
+  // Instnead we could add another CXXABI entry point to query this property 
and
+  // have ABIInfo::isHomogeneousAggregate use that property.

typo Instnead



Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:4501-4503
+  // base/field while not true of the outer struct (eg: if you have a 
base/field
+  // that has an non-trivial copy assignment/dtor/default ctor, then the outer
+  // struct's corresponding operation must be non-trivial.

There's an open parenthetical here, maybe just make it `. For example, if you 
have...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134688

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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Good catch

  template
  concept K = requires (typename T::Type X) { // (3)
  X.next();
  }

That typename should be optional. Can you add a test for that? If it works you 
can mark P2092  as fully supported.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

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


[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

2022-09-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D134456#3819042 , @aaron.ballman 
wrote:

> Alternatively, we could document that we don't follow the intent of the 
> standard feature and that's just the way things are, and add a command line 
> option to honor that intent. However, given that GCC honors the attribute 
> over PGO, I think we should change our default behavior.

That makes sense to me. I think it's reasonable to request folks to add a flag 
in the context of a bug fix, but it would be too much to ask a drive by 
contributor to go through the multi-step process to change the default flag 
behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134456

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-27 Thread John McIver via Phabricator via cfe-commits
jmciver added a comment.

In D134410#3816881 , @vitalybuka 
wrote:

> Are these patches uploaded with arc tool?

Yes, the patches were uploaded with `arc`. The size of the patch was too large 
to use the web interface.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134410

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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-27 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

In D53847#3817376 , @cor3ntin wrote:

> It's great to see this make progress.
> Can you update cxx_status.html and ReleaseNotes.txt?

Done.

I also saw that P2092R0 was marked as partially supported in `cxx_status.html` 
due to missing support for P0634R3, but I'm not familiar enough with P2092R0 to 
update that entry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

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


[clang] fbfb4a6 - Fix test after 5839fb6d25b4ba6edb

2022-09-27 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-09-27T14:01:13-07:00
New Revision: fbfb4a6359c100ac4f33982688cb0e2c299fb239

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

LOG: Fix test after 5839fb6d25b4ba6edb

The test is not expected for Windows.

Added: 


Modified: 
clang/test/Driver/crash-diagnostics-dir-2.c

Removed: 




diff  --git a/clang/test/Driver/crash-diagnostics-dir-2.c 
b/clang/test/Driver/crash-diagnostics-dir-2.c
index 9910a0a155fb..071afb81ed51 100644
--- a/clang/test/Driver/crash-diagnostics-dir-2.c
+++ b/clang/test/Driver/crash-diagnostics-dir-2.c
@@ -1,4 +1,4 @@
-// UNSUPPORTED: ps4
+// UNSUPPORTED: ps4, system-windows
 
 // RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=OPTION



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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-27 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 463334.
ayzhao added a comment.

update cxx_status.html and ReleaseNotes.rst + rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr4xx.cpp
  clang/test/CXX/drs/dr5xx.cpp
  clang/test/CXX/module/module.interface/p2-2.cpp
  clang/test/CXX/temp/temp.res/p3.cpp
  clang/test/CXX/temp/temp.res/p4.cpp
  clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
  clang/test/FixIt/fixit.cpp
  clang/test/Parser/cxx-member-initializers.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/MicrosoftSuper.cpp
  clang/test/SemaCXX/rounding-math-crash.cpp
  clang/test/SemaCXX/typo-correction.cpp
  clang/test/SemaCXX/unknown-type-name.cpp
  clang/test/SemaTemplate/alias-templates.cpp
  clang/test/SemaTemplate/typename-specifier-3.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1052,7 +1052,7 @@
 
   typename optional in more contexts
   https://wg21.link/p0634r3;>P0634R3
-  No
+  Clang 16
 
 
   Pack expansion in lambda init-capture
Index: clang/test/SemaTemplate/typename-specifier-3.cpp
===
--- clang/test/SemaTemplate/typename-specifier-3.cpp
+++ clang/test/SemaTemplate/typename-specifier-3.cpp
@@ -28,7 +28,7 @@
   typedef int arg;
 };
 struct C {
-  typedef B::X x; // expected-error {{missing 'typename'}}
+  typedef B::X x; // precxx17-warning{{missing 'typename' prior to dependent type name B::X; implicit 'typename' is a C++20 extension}}
 };
   };
 
Index: clang/test/SemaTemplate/alias-templates.cpp
===
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -193,11 +193,10 @@
   struct base {
 template  struct derived;
   };
-  // FIXME: The diagnostics here are terrible.
   template 
-  using derived = base::template derived; // expected-error {{expected a type}} expected-error {{expected ';'}}
+  using derived = base::template derived; // expected-warning {{missing 'typename'}}
   template 
-  using derived2 = ::PR16904::base::template derived; // expected-error {{expected a type}} expected-error {{expected ';'}}
+  using derived2 = ::PR16904::base::template derived; // expected-warning {{missing 'typename'}}
 }
 
 namespace PR14858 {
Index: clang/test/SemaCXX/unknown-type-name.cpp
===
--- clang/test/SemaCXX/unknown-type-name.cpp
+++ clang/test/SemaCXX/unknown-type-name.cpp
@@ -36,15 +36,15 @@
 
   static int n;
   static type m;
-  static int h(T::type, int); // expected-error{{missing 'typename'}}
-  static int h(T::type x, char); // expected-error{{missing 'typename'}}
+  static int h(T::type, int); // expected-warning{{implicit 'typename' is a C++20 extension}}
+  static int h(T::type x, char); // expected-warning{{implicit 'typename' is a C++20 extension}}
 };
 
 template
-A::type g(T t) { return t; } // expected-error{{missing 'typename'}}
+A::type g(T t) { return t; } // expected-warning{{implicit 'typename' is a C++20 extension}}
 
 template
-A::type A::f() { return type(); } // expected-error{{missing 'typename'}}
+A::type A::f() { return type(); } // expected-warning{{implicit 'typename' is a C++20 extension}}
 
 template
 void f(T::type) { } // expected-error{{missing 'typename'}}
@@ -84,11 +84,11 @@
 
 template int A::n(T::value); // ok
 template
-A::type // expected-error{{missing 'typename'}}
+A::type // expected-warning {{implicit 'typename' is a C++20 extension}}
 A::m(T::value, 0); // ok
 
-template int A::h(T::type, int) {} // expected-error{{missing 'typename'}}
-template int A::h(T::type x, char) {} // expected-error{{missing 'typename'}}
+template int A::h(T::type, int) {} // expected-warning{{implicit 'typename' is a C++20 extension}}
+template int A::h(T::type x, char) {} // expected-warning{{implicit 'typename' is a C++20 extension}}
 
 template int h(T::type, int); // expected-error{{missing 

[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D86049#3818981 , @plotfi wrote:

> @ahatanak I can revive some of what I was working on from 
> https://reviews.llvm.org/D86049?id=285923 if we think we need a thunk for the 
> checks as @rjmccall mentioned.

I believe the generated direct methods already handle the null checks and class 
init in `CGObjCCommonMac::GenerateDirectMethodPrologue`, meaning the thunks 
aren't strictly necessary for the callee to handle them.

Could the thunks instead allow us to have publicly-visible mangled names 
(something akin to the new selector stubs `_objc_msgSend$selectorName` but for 
`_objc_direct$Class_selectorName`) while leaving the actual impl name alone, 
letting the stack traces see normal ObjC symbol names?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a reviewer: thesamesam.
mgorny added a comment.

Adding @thesamesam to reviewers since he's been testing it on Gentoo, and I'd 
like to get his ACK too.


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

https://reviews.llvm.org/D134337

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


[clang] c12c26c - Fix test after 5839fb6d25b4ba6edb

2022-09-27 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-09-27T13:39:56-07:00
New Revision: c12c26c1768ac1525ce4240adf194c59bed11097

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

LOG: Fix test after 5839fb6d25b4ba6edb

The test is not expected for PS4.

Added: 


Modified: 
clang/test/Driver/crash-diagnostics-dir-2.c

Removed: 




diff  --git a/clang/test/Driver/crash-diagnostics-dir-2.c 
b/clang/test/Driver/crash-diagnostics-dir-2.c
index 664acd9b7959..9910a0a155fb 100644
--- a/clang/test/Driver/crash-diagnostics-dir-2.c
+++ b/clang/test/Driver/crash-diagnostics-dir-2.c
@@ -1,3 +1,5 @@
+// UNSUPPORTED: ps4
+
 // RUN: %clang -### -fcrash-diagnostics-dir=mydumps -c %s 2>&1 \
 // RUN: | FileCheck %s --check-prefix=OPTION
 // OPTION: "-crash-diagnostics-dir=mydumps"



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


[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 463327.
aeubanks added a comment.

mention -fno-sanitize-memory-param-retval in release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134669

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/kmsan-param-retval.c
  clang/test/CodeGen/msan-param-retval.c
  clang/test/Driver/fsanitize-memory-param-retval.c

Index: clang/test/Driver/fsanitize-memory-param-retval.c
===
--- clang/test/Driver/fsanitize-memory-param-retval.c
+++ clang/test/Driver/fsanitize-memory-param-retval.c
@@ -1,14 +1,14 @@
-// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
 
-// CHECK: "-fsanitize-memory-param-retval"
+// CHECK: "-fno-sanitize-memory-param-retval"
 
-// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s
-// 11: "-fsanitize-memory-param-retval"
+// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s
+// 11: "-fno-sanitize-memory-param-retval"
 
-// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s -fsanitize=memory -fsanitize-memory-param-retval=1 2>&1 | FileCheck --check-prefix=EXCESS %s
-// EXCESS: error: unknown argument: '-fsanitize-memory-param-retval=
+// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s -fsanitize=memory -fno-sanitize-memory-param-retval=1 2>&1 | FileCheck --check-prefix=EXCESS %s
+// EXCESS: error: unknown argument: '-fno-sanitize-memory-param-retval=
Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -o - %s | \
 // RUN: FileCheck %s --check-prefix=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -fno-sanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -mllvm -msan-eager-checks -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -fsanitize-memory-param-retval -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 
 void bar(int x) {
Index: clang/test/CodeGen/kmsan-param-retval.c
===
--- clang/test/CodeGen/kmsan-param-retval.c
+++ clang/test/CodeGen/kmsan-param-retval.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 -fsanitize=kernel-memory -no-enable-noundef-analysis -o - %s | \
 // RUN: FileCheck %s --check-prefix=CLEAN
-// RUN: %clang_cc1 -triple 

[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

2022-09-27 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a subscriber: davidxl.
wenlei added a comment.

For instr PGO, changing behavior may have perf implication. cc @davidxl


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134456

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


[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-27 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:452
+--
+- ``-fsanitize-memory-param-retval`` is turned on by default. With
+  ``-fsanitize=memory``, passing uninitialized variables to functions and

Probably I would mention that there is -fno-sanitize-memory-param-retval to 
disable it.

So one can use “-fsanitize=memory -fno-sanitize-memory-param-retval“ to unblock 
failed builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134669

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


[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

2022-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D134456#3818982 , @rnk wrote:

> In D134456#3818952 , @aaron.ballman 
> wrote:
>
>> I think that would be reasonable to at least consider; the default behavior 
>> can be "the attribute wins" and this gives users an escape hatch to say "no, 
>> I trust PGO more, let that win instead".
>
> Right, but that's a policy change. We'd need to update docs, update release 
> notes, and all of that. We'll need this fix in any case for the mode where 
> PGO wins, which will remain long term for the users that rely on it.
>
> What commitments can we make to land this fix without making a policy change, 
> which is quite a great deal of work (RFC, docs, notes, etc)?

Personally, I consider it a bug fix and not a policy change (which doesn't mean 
we don't need to make all these updates, of course). We didn't carefully 
consider this aspect of the original design when doing the implementation work, 
now we'd like to correct that as responsibly as we can.

Alternatively, we could document that we don't follow the intent of the 
standard feature and that's just the way things are, and add a command line 
option to honor that intent. However, given that GCC honors the attribute over 
PGO, I think we should change our default behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134456

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


[PATCH] D134657: [Driver] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Yuanfang Chen 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 rG5839fb6d25b4: [Driver] pass -fcrash-diagnostics-dir to LTO 
(authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134657

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/crash-diagnostics-dir-2.c


Index: clang/test/Driver/crash-diagnostics-dir-2.c
===
--- clang/test/Driver/crash-diagnostics-dir-2.c
+++ clang/test/Driver/crash-diagnostics-dir-2.c
@@ -3,3 +3,12 @@
 // OPTION: "-crash-diagnostics-dir=mydumps"
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
 // NOOPTION-NOT: "-crash-diagnostics-dir
+
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO-OPTION
+// LTO-OPTION: "-cc1"
+// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
+
+// RUN: %clang -### -flto %s 2>&1 | FileCheck %s --check-prefix=LTO-NOOPTION
+// LTO-NOOPTION: "-cc1"
+// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -632,6 +632,11 @@
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile));
 
+  // Setup crash diagnostics dir.
+  if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-plugin-opt=-crash-diagnostics-dir=") + A->getValue()));
+
   addX86AlignBranchArgs(D, Args, CmdArgs, /*IsLTO=*/true);
 
   // Handle remark diagnostics on screen options: '-Rpass-*'.


Index: clang/test/Driver/crash-diagnostics-dir-2.c
===
--- clang/test/Driver/crash-diagnostics-dir-2.c
+++ clang/test/Driver/crash-diagnostics-dir-2.c
@@ -3,3 +3,12 @@
 // OPTION: "-crash-diagnostics-dir=mydumps"
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
 // NOOPTION-NOT: "-crash-diagnostics-dir
+
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO-OPTION
+// LTO-OPTION: "-cc1"
+// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
+
+// RUN: %clang -### -flto %s 2>&1 | FileCheck %s --check-prefix=LTO-NOOPTION
+// LTO-NOOPTION: "-cc1"
+// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -632,6 +632,11 @@
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile));
 
+  // Setup crash diagnostics dir.
+  if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-plugin-opt=-crash-diagnostics-dir=") + A->getValue()));
+
   addX86AlignBranchArgs(D, Args, CmdArgs, /*IsLTO=*/true);
 
   // Handle remark diagnostics on screen options: '-Rpass-*'.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134659: [Driver] pass -fjmc to LTO

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54967c01d2bb: [Driver] pass -fjmc to LTO (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134659

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/clang_f_opts.c


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -601,10 +601,15 @@
 // RUN: %clang -### -S -fjmc -target x86_64-pc-windows-msvc %s 2>&1 | 
FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC %s
 // RUN: %clang -### -S -fjmc -g -target x86_64-unknown-linux %s 2>&1 | 
FileCheck -check-prefix=CHECK_JMC %s
 // RUN: %clang -### -S -fjmc -g -fno-jmc -target x86_64-unknown-linux %s 2>&1 
| FileCheck -check-prefix=CHECK_NOJMC %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-pc-windows-msvc %s 2>&1 | 
FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-unknown-linux %s 2>&1 | 
FileCheck -check-prefix=CHECK_JMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -fno-jmc -target x86_64-unknown-linux %s 
2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
 // CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that 
enable debugger's stepping function; option ignored
 // CHECK_JMC_WARN_NOT_ELF: -fjmc works only for ELF; option ignored
 // CHECK_NOJMC-NOT: -fjmc
 // CHECK_JMC: -fjmc
+// CHECK_NOJMC_LTO-NOT: -plugin-opt=-enable-jmc-instrument
+// CHECK_JMC_LTO: -plugin-opt=-enable-jmc-instrument
 
 // RUN: %clang -### -fintegrated-objemitter -target x86_64 %s 2>&1 | FileCheck 
-check-prefix=CHECK-INT-OBJEMITTER %s
 // CHECK-INT-OBJEMITTER-NOT: unsupported option '-fintegrated-objemitter' for 
target
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -626,6 +626,14 @@
  Path));
   }
 
+  // This controls whether or not we perform JustMyCode instrumentation.
+  if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
+if (ToolChain.getEffectiveTriple().isOSBinFormatELF())
+  CmdArgs.push_back("-plugin-opt=-enable-jmc-instrument");
+else
+  D.Diag(clang::diag::warn_drv_fjmc_for_elf_only);
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())


Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -601,10 +601,15 @@
 // RUN: %clang -### -S -fjmc -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC %s
 // RUN: %clang -### -S -fjmc -g -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s
 // RUN: %clang -### -S -fjmc -g -fno-jmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-pc-windows-msvc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_JMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -fno-jmc -target x86_64-unknown-linux %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
 // CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that enable debugger's stepping function; option ignored
 // CHECK_JMC_WARN_NOT_ELF: -fjmc works only for ELF; option ignored
 // CHECK_NOJMC-NOT: -fjmc
 // CHECK_JMC: -fjmc
+// CHECK_NOJMC_LTO-NOT: -plugin-opt=-enable-jmc-instrument
+// CHECK_JMC_LTO: -plugin-opt=-enable-jmc-instrument
 
 // RUN: %clang -### -fintegrated-objemitter -target x86_64 %s 2>&1 | FileCheck -check-prefix=CHECK-INT-OBJEMITTER %s
 // CHECK-INT-OBJEMITTER-NOT: unsupported option '-fintegrated-objemitter' for target
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -626,6 +626,14 @@
  Path));
   }
 
+  // This controls whether or not we perform JustMyCode instrumentation.
+  if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
+if (ToolChain.getEffectiveTriple().isOSBinFormatELF())
+  CmdArgs.push_back("-plugin-opt=-enable-jmc-instrument");
+else
+  D.Diag(clang::diag::warn_drv_fjmc_for_elf_only);
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())

[PATCH] D134673: [Driver][PS4] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG55cd5bc50964: [Driver][PS4] pass -fcrash-diagnostics-dir to 
LTO (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134673

Files:
  clang/lib/Driver/ToolChains/PS4CPU.cpp
  clang/test/Driver/debug-options.c
  clang/test/Driver/ps4-ps5-linker-jmc.c
  clang/test/Driver/ps4-ps5-linker.c

Index: clang/test/Driver/ps4-ps5-linker.c
===
--- clang/test/Driver/ps4-ps5-linker.c
+++ clang/test/Driver/ps4-ps5-linker.c
@@ -7,14 +7,23 @@
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck --check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
 
 // CHECK-PS4-NOT: -enable-jmc-instrument
-
 // CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
 // CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
-
-// CHECK-PS5-NOT: "-enable-jmc-instrument"
-
-// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+// CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
+// CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
 // CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
 // CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" "--no-whole-archive"
+
+// Test the driver's control over the -fcrash-diagnostics-dir behavior with linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS4-THIN-LTO %s
+// RUN: %clang --target=x86_64-scei-ps4 -flto=full -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS4-FULL-LTO %s
+// RUN: %clang --target=x86_64-scei-ps5 -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5 %s
+// RUN: %clang --target=x86_64-scei-ps5 -flto -fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck --check-prefixes=CHECK-DIAG-PS5-LTO %s
+
+// CHECK-DIAG-PS4-THIN-LTO: -lto-thin-debug-options=-crash-diagnostics-dir=mydumps
+// CHECK-DIAG-PS4-FULL-LTO: -lto-debug-options=-crash-diagnostics-dir=mydumps
+// CHECK-DIAG-PS5-NOT: -plugin-opt=-crash-diagnostics-dir=mydumps
+// CHECK-DIAG-PS5-LTO: -plugin-opt=-crash-diagnostics-dir=mydumps
Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -375,8 +375,8 @@
 //
 
 // LDGARANGE: {{".*ld.*"}} {{.*}}
-// LDGARANGE-NOT: "-generate-arange-section"
-// LLDGARANGE: {{".*lld.*"}} {{.*}} "-generate-arange-section"
+// LDGARANGE-NOT: "-plugin-opt=-generate-arange-section"
+// LLDGARANGE: {{".*lld.*"}} {{.*}} "-plugin-opt=-generate-arange-section"
 // SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-thin-debug-options=-generate-arange-section"
 // SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} "-lto-debug-options=-generate-arange-section"
 
Index: clang/lib/Driver/ToolChains/PS4CPU.cpp
===
--- clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -158,34 +158,32 @@
   const bool IsPS4 = TC.getTriple().isPS4();
   const bool IsPS5 = TC.getTriple().isPS5();
   assert(IsPS4 || IsPS5);
-  (void)IsPS5;
 
-  ArgStringList DbgOpts;
-
-  // This tells LTO to perform JustMyCode instrumentation.
-  if (UseLTO && UseJMC)
-DbgOpts.push_back("-enable-jmc-instrument");
+  auto AddCodeGenFlag = [&](Twine Flag) {
+const char *Prefix = nullptr;
+if (IsPS4 && D.getLTOMode() == LTOK_Thin)
+  Prefix = "-lto-thin-debug-options=";
+else if (IsPS4 && D.getLTOMode() == LTOK_Full)
+  Prefix = "-lto-debug-options=";
+else if (IsPS5)
+  Prefix = "-plugin-opt=";
+else
+  llvm_unreachable("new LTO mode?");
 
-  // We default to creating the arange section, but LTO does not. Enable it
-  // here.
-  if (UseLTO)
-DbgOpts.push_back("-generate-arange-section");
+CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag));
+  };
 
   if (UseLTO) {
-if (IsPS4) {
-  StringRef F = (D.getLTOMode() == LTOK_Thin) ?
-  "-lto-thin-debug-options=" : "-lto-debug-options=";
-  F = makeArgString(Args, F.data(), DbgOpts.front(), "");
-  DbgOpts.erase(DbgOpts.begin());
-  for (auto X : DbgOpts)
-F = makeArgString(Args, F.data(), " ", X);
-  CmdArgs.push_back(F.data());
-} else {
-  for (auto D : DbgOpts) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(D);
-  }
-}
+// We default to creating the arange section, but LTO does not. Enable it
+// here.
+AddCodeGenFlag("-generate-arange-section");
+
+// This tells LTO to perform JustMyCode instrumentation.
+if (UseJMC)
+  AddCodeGenFlag("-enable-jmc-instrument");
+
+if (Arg *A = 

[clang] 54967c0 - [Driver] pass -fjmc to LTO

2022-09-27 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-09-27T13:14:16-07:00
New Revision: 54967c01d2bb6daa1959865d9a780678e652419d

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

LOG: [Driver] pass -fjmc to LTO

So the behavior is consistent with non-LTO mode.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index c926e98a7f9e..4bc16710e194 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -626,6 +626,14 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
  Path));
   }
 
+  // This controls whether or not we perform JustMyCode instrumentation.
+  if (Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
+if (ToolChain.getEffectiveTriple().isOSBinFormatELF())
+  CmdArgs.push_back("-plugin-opt=-enable-jmc-instrument");
+else
+  D.Diag(clang::diag::warn_drv_fjmc_for_elf_only);
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())

diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index d529f9ad5c48..9c38b5906b7b 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -601,10 +601,15 @@
 // RUN: %clang -### -S -fjmc -target x86_64-pc-windows-msvc %s 2>&1 | 
FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC %s
 // RUN: %clang -### -S -fjmc -g -target x86_64-unknown-linux %s 2>&1 | 
FileCheck -check-prefix=CHECK_JMC %s
 // RUN: %clang -### -S -fjmc -g -fno-jmc -target x86_64-unknown-linux %s 2>&1 
| FileCheck -check-prefix=CHECK_NOJMC %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-pc-windows-msvc %s 2>&1 | 
FileCheck -check-prefixes=CHECK_JMC_WARN_NOT_ELF,CHECK_NOJMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -target x86_64-unknown-linux %s 2>&1 | 
FileCheck -check-prefix=CHECK_JMC_LTO %s
+// RUN: %clang -### -fjmc -g -flto -fno-jmc -target x86_64-unknown-linux %s 
2>&1 | FileCheck -check-prefix=CHECK_NOJMC_LTO %s
 // CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that 
enable debugger's stepping function; option ignored
 // CHECK_JMC_WARN_NOT_ELF: -fjmc works only for ELF; option ignored
 // CHECK_NOJMC-NOT: -fjmc
 // CHECK_JMC: -fjmc
+// CHECK_NOJMC_LTO-NOT: -plugin-opt=-enable-jmc-instrument
+// CHECK_JMC_LTO: -plugin-opt=-enable-jmc-instrument
 
 // RUN: %clang -### -fintegrated-objemitter -target x86_64 %s 2>&1 | FileCheck 
-check-prefix=CHECK-INT-OBJEMITTER %s
 // CHECK-INT-OBJEMITTER-NOT: unsupported option '-fintegrated-objemitter' for 
target



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


[clang] 55cd5bc - [Driver][PS4] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-09-27T13:14:16-07:00
New Revision: 55cd5bc50964449627f6f1fa82ce8268d0629d9e

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

LOG: [Driver][PS4] pass -fcrash-diagnostics-dir to LTO

Also refactor the existing code a little bit.

Reviewed By: probinson

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

Added: 
clang/test/Driver/ps4-ps5-linker.c

Modified: 
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/test/Driver/debug-options.c

Removed: 
clang/test/Driver/ps4-ps5-linker-jmc.c



diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp 
b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 989bdb4065eaa..643f815c5835a 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -158,34 +158,32 @@ void tools::PScpu::Linker::ConstructJob(Compilation , 
const JobAction ,
   const bool IsPS4 = TC.getTriple().isPS4();
   const bool IsPS5 = TC.getTriple().isPS5();
   assert(IsPS4 || IsPS5);
-  (void)IsPS5;
 
-  ArgStringList DbgOpts;
-
-  // This tells LTO to perform JustMyCode instrumentation.
-  if (UseLTO && UseJMC)
-DbgOpts.push_back("-enable-jmc-instrument");
+  auto AddCodeGenFlag = [&](Twine Flag) {
+const char *Prefix = nullptr;
+if (IsPS4 && D.getLTOMode() == LTOK_Thin)
+  Prefix = "-lto-thin-debug-options=";
+else if (IsPS4 && D.getLTOMode() == LTOK_Full)
+  Prefix = "-lto-debug-options=";
+else if (IsPS5)
+  Prefix = "-plugin-opt=";
+else
+  llvm_unreachable("new LTO mode?");
 
-  // We default to creating the arange section, but LTO does not. Enable it
-  // here.
-  if (UseLTO)
-DbgOpts.push_back("-generate-arange-section");
+CmdArgs.push_back(Args.MakeArgString(Twine(Prefix) + Flag));
+  };
 
   if (UseLTO) {
-if (IsPS4) {
-  StringRef F = (D.getLTOMode() == LTOK_Thin) ?
-  "-lto-thin-debug-options=" : "-lto-debug-options=";
-  F = makeArgString(Args, F.data(), DbgOpts.front(), "");
-  DbgOpts.erase(DbgOpts.begin());
-  for (auto X : DbgOpts)
-F = makeArgString(Args, F.data(), " ", X);
-  CmdArgs.push_back(F.data());
-} else {
-  for (auto D : DbgOpts) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back(D);
-  }
-}
+// We default to creating the arange section, but LTO does not. Enable it
+// here.
+AddCodeGenFlag("-generate-arange-section");
+
+// This tells LTO to perform JustMyCode instrumentation.
+if (UseJMC)
+  AddCodeGenFlag("-enable-jmc-instrument");
+
+if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
+  AddCodeGenFlag(Twine("-crash-diagnostics-dir=") + A->getValue());
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index bd13a63162c8e..7e33d8d393eb2 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -375,8 +375,8 @@
 //
 
 // LDGARANGE: {{".*ld.*"}} {{.*}}
-// LDGARANGE-NOT: "-generate-arange-section"
-// LLDGARANGE: {{".*lld.*"}} {{.*}} "-generate-arange-section"
+// LDGARANGE-NOT: "-plugin-opt=-generate-arange-section"
+// LLDGARANGE: {{".*lld.*"}} {{.*}} "-plugin-opt=-generate-arange-section"
 // SNLDTLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} 
"-lto-thin-debug-options=-generate-arange-section"
 // SNLDFLTOGARANGE: {{".*orbis-ld.*"}} {{.*}} 
"-lto-debug-options=-generate-arange-section"
 

diff  --git a/clang/test/Driver/ps4-ps5-linker-jmc.c 
b/clang/test/Driver/ps4-ps5-linker.c
similarity index 50%
rename from clang/test/Driver/ps4-ps5-linker-jmc.c
rename to clang/test/Driver/ps4-ps5-linker.c
index f5accd14291c4..ee8e96bbfbd02 100644
--- a/clang/test/Driver/ps4-ps5-linker-jmc.c
+++ b/clang/test/Driver/ps4-ps5-linker.c
@@ -7,14 +7,23 @@
 // RUN: %clang --target=x86_64-scei-ps5 -flto -fjmc %s -### 2>&1 | FileCheck 
--check-prefixes=CHECK-PS5-LTO,CHECK-PS5-LIB %s
 
 // CHECK-PS4-NOT: -enable-jmc-instrument
-
 // CHECK-PS4-THIN-LTO: -lto-thin-debug-options=-enable-jmc-instrument
 // CHECK-PS4-FULL-LTO: -lto-debug-options=-enable-jmc-instrument
-
-// CHECK-PS5-NOT: "-enable-jmc-instrument"
-
-// CHECK-PS5-LTO: "-mllvm" "-enable-jmc-instrument"
+// CHECK-PS5-NOT: -plugin-opt=-enable-jmc-instrument
+// CHECK-PS5-LTO: -plugin-opt=-enable-jmc-instrument
 
 // Check the default library name.
 // CHECK-PS4-LIB: "--whole-archive" "-lSceDbgJmc" "--no-whole-archive"
 // CHECK-PS5-LIB: "--whole-archive" "-lSceJmc_nosubmission" 
"--no-whole-archive"
+
+// Test the driver's control over the -fcrash-diagnostics-dir behavior with 
linker flags.
+
+// RUN: %clang --target=x86_64-scei-ps4 -flto=thin 
-fcrash-diagnostics-dir=mydumps %s -### 2>&1 | FileCheck 

[clang] 5839fb6 - [Driver] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-09-27T13:14:16-07:00
New Revision: 5839fb6d25b4ba6edb4d9a707c75bffd178d6cc6

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

LOG: [Driver] pass -fcrash-diagnostics-dir to LTO

So the behavior is consistent with non-LTO mode.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/crash-diagnostics-dir-2.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index d0abc4a0e26c..c926e98a7f9e 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -632,6 +632,11 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile));
 
+  // Setup crash diagnostics dir.
+  if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
+CmdArgs.push_back(Args.MakeArgString(
+Twine("-plugin-opt=-crash-diagnostics-dir=") + A->getValue()));
+
   addX86AlignBranchArgs(D, Args, CmdArgs, /*IsLTO=*/true);
 
   // Handle remark diagnostics on screen options: '-Rpass-*'.

diff  --git a/clang/test/Driver/crash-diagnostics-dir-2.c 
b/clang/test/Driver/crash-diagnostics-dir-2.c
index 432a8893f878..664acd9b7959 100644
--- a/clang/test/Driver/crash-diagnostics-dir-2.c
+++ b/clang/test/Driver/crash-diagnostics-dir-2.c
@@ -3,3 +3,12 @@
 // OPTION: "-crash-diagnostics-dir=mydumps"
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
 // NOOPTION-NOT: "-crash-diagnostics-dir
+
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=LTO-OPTION
+// LTO-OPTION: "-cc1"
+// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
+
+// RUN: %clang -### -flto %s 2>&1 | FileCheck %s --check-prefix=LTO-NOOPTION
+// LTO-NOOPTION: "-cc1"
+// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"



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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133683#3819003 , @mizvekov wrote:

> In D133683#3818935 , @ychen wrote:
>
>> This is described in https://eel.is/c++draft/temp.deduct.partial#13. 
>> Parietal ordering currently doesn't consider the number of deduced 
>> arguments. During the partial ordering stage, by 
>> https://eel.is/c++draft/temp.func.order#3, `template > typename... U> void g(T, U...);` would become `void g(UniqueT1, UniqueT2);`. 
>> And then it applies https://eel.is/c++draft/temp.deduct.partial#3.1 to 
>> decide which parameters are compared for partial ordering.
>
> Sure, one thing is, given that we deduced a pack, does the number of elements 
> deduced for that pack matter in partial ordering. I think 
> `temp.deduct.partial#13` answers that it doesn't.
>
> The other thing is, is a given template parameter pack used, or deduced, as 
> opposed to just not being used. and I think the answer here is yes for that 
> second overload of `g`.
>
> If a template parameter pack appears as a type of a function parameter in an 
> expansion pattern, such as `void g(T, U...);`, then I think that, notionally, 
> there is no way to not use it.

That's right. That requires the wording says something like `pack is always 
used for partial ordering`. I just realized that this `g(42)` example is from 
https://eel.is/c++draft/temp.func.order#note-3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 463322.
aeubanks added a comment.

rebase (to run through presubmits with test fixes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134669

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/kmsan-param-retval.c
  clang/test/CodeGen/msan-param-retval.c
  clang/test/Driver/fsanitize-memory-param-retval.c

Index: clang/test/Driver/fsanitize-memory-param-retval.c
===
--- clang/test/Driver/fsanitize-memory-param-retval.c
+++ clang/test/Driver/fsanitize-memory-param-retval.c
@@ -1,14 +1,14 @@
-// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
 
-// CHECK: "-fsanitize-memory-param-retval"
+// CHECK: "-fno-sanitize-memory-param-retval"
 
-// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory -fsanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s
-// 11: "-fsanitize-memory-param-retval"
+// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory -fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s
+// 11: "-fno-sanitize-memory-param-retval"
 
-// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s -fsanitize=memory -fsanitize-memory-param-retval=1 2>&1 | FileCheck --check-prefix=EXCESS %s
-// EXCESS: error: unknown argument: '-fsanitize-memory-param-retval=
+// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s -fsanitize=memory -fno-sanitize-memory-param-retval=1 2>&1 | FileCheck --check-prefix=EXCESS %s
+// EXCESS: error: unknown argument: '-fno-sanitize-memory-param-retval=
Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -o - %s | \
 // RUN: FileCheck %s --check-prefix=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -fno-sanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -mllvm -msan-eager-checks -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -fsanitize-memory-param-retval -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 
 void bar(int x) {
Index: clang/test/CodeGen/kmsan-param-retval.c
===
--- clang/test/CodeGen/kmsan-param-retval.c
+++ clang/test/CodeGen/kmsan-param-retval.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 -fsanitize=kernel-memory -no-enable-noundef-analysis -o - %s | \
 // RUN: FileCheck %s --check-prefix=CLEAN
-// RUN: %clang_cc1 -triple 

[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D133683#3818935 , @ychen wrote:

> This is described in https://eel.is/c++draft/temp.deduct.partial#13. Parietal 
> ordering currently doesn't consider the number of deduced arguments. During 
> the partial ordering stage, by https://eel.is/c++draft/temp.func.order#3, 
> `template  void g(T, U...);` would become `void 
> g(UniqueT1, UniqueT2);`. And then it applies 
> https://eel.is/c++draft/temp.deduct.partial#3.1 to decide which parameters 
> are compared for partial ordering.

Sure, one thing is, given that we deduced a pack, does the number of elements 
deduced for that pack matter in partial ordering. I think 
`temp.deduct.partial#13` answers that it doesn't.

The other thing is, is a given template parameter pack used, or deduced, as 
opposed to just not being used. and I think the answer here is yes for that 
second overload of `g`.

If a template parameter pack appears as a type of a function parameter in an 
expansion pattern, such as `void g(T, U...);`, then I think that, notionally, 
there is no way to not use it.

For any call to that overload, that parameter pack will be deduced, no matter 
if to an empty pack or otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

2022-09-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D134456#3818952 , @aaron.ballman 
wrote:

> I think that would be reasonable to at least consider; the default behavior 
> can be "the attribute wins" and this gives users an escape hatch to say "no, 
> I trust PGO more, let that win instead".

Right, but that's a policy change. We'd need to update docs, update release 
notes, and all of that. We'll need this fix in any case for the mode where PGO 
wins, which will remain long term for the users that rely on it.

What commitments can we make to land this fix without making a policy change, 
which is quite a great deal of work (RFC, docs, notes, etc)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134456

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

@ahatanak I can revive some of what I was working on from 
https://reviews.llvm.org/D86049?id=285923 if we think we need a thunk for the 
checks as @rjmccall mentioned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a subscriber: kyulee1.
plotfi added a comment.

In D86049#3818923 , @ahatanak wrote:

> In D86049#3818696 , @plotfi wrote:
>
>> In D86049#3818435 , @mwyman wrote:
>>
>>> In D86049#3816006 , @plotfi wrote:
>>>
 @dmaclach @ahatanak @mwyman How do things look from here? Do you want 
 something for properties as well or would it be ok if we did this in a 
 later commit?
>>>
>>> Huh, for some reason I thought when I'd last poked at using the 
>>> `visibility` attribute it wasn't allowed on ObjC methods, which is why I'd 
>>> suggested adding the enum on `objc_direct`, but as that no longer appears 
>>> to be the case yes I like this approach better.
>>
>> @dmaclach @mwyman  I am also very happy with the fact that we can just reuse 
>> the regular `visibility` attribute. In the future we can decide on revised 
>> behavior for `hasMethodVisibilityDefault`.
>>
>> @ahatanak Do you have feedback on this?
>
> The visibility attribute changes look good to me.
>
> Do we have the answers to the last two questions John raised in 
> https://reviews.llvm.org/D86049#2255738? I think we should get it right the 
> first time since, once we make the direct methods visible, it'd be hard to 
> change where the null check or class initialization is done since that would 
> be an ABI change. Should we run experiments to measure the impact on code 
> size?

I think it may be required to do thunk generation after all to do the null and 
init checks at the callee. What are your thoughts on this @ahatanak ?




Comment at: clang/lib/AST/Mangle.cpp:371
+  OS << (MD->isInstanceMethod() ? '-' : '+');
+  OS << (MD->hasMethodVisibilityDefault() ? '<' : '[');
   if (const auto *CID = MD->getCategory()) {

plotfi wrote:
> ahatanak wrote:
> > Sorry, I might have missed the discussion, but what's the reason we need 
> > this change in mangling? Is it because the linker cannot handle the 
> > standard mangling scheme?
> Yeah. These are for ld and dyld. Not having a preceding underscore and the 
> square brackets causes problems. 
I need to ask @kyulee / @kyulee1 about the details. We went with these mangling 
changes some time ago and it is not fresh in my mind. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

2022-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D134456#3818548 , @thakis wrote:

> Maybe we could have a `-f` flag to control whether to prefer annotations or 
> profile data when they conflict?

I think that would be reasonable to at least consider; the default behavior can 
be "the attribute wins" and this gives users an escape hatch to say "no, I 
trust PGO more, let that win instead".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134456

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D134042: [clang-format] Fix alignment in #else preprocessor blocks

2022-09-27 Thread 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 rGc0779756a0c4: [clang-format] Fix alignment in #else 
preprocessor blocks (authored by mitchell 
56368743+mitchell-stel...@users.noreply.github.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134042

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
@@ -5825,6 +5825,98 @@
Style);
 }
 
+TEST_F(FormatTest, FormatAlignInsidePreprocessorElseBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveAssignments.Enabled = true;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+
+  // Test with just #if blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   "#endif\n"
+   "}\n"
+   "#if 1\n"
+   "int baz = 3;\n"
+   "#endif\n"
+   "void f2() {\n"
+   "#if 1\n"
+   "  char *foobarbaz = \"foobarbaz\";\n"
+   "  int   quux  = 4;\n"
+   "}",
+   Style);
+
+  // Test with just #else blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   "#endif\n"
+   "}\n"
+   "#if 1\n"
+   "#else\n"
+   "int baz = 3;\n"
+   "#endif\n"
+   "void f2() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  char *foobarbaz = \"foobarbaz\";\n"
+   "  int   quux  = 4;\n"
+   "}",
+   Style);
+
+  // Test with a mix of #if and #else blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   "#endif\n"
+   "}\n"
+   "#if 1\n"
+   "int baz = 3;\n"
+   "#endif\n"
+   "void f2() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  // prevent alignment with #else in f1\n"
+   "  char *foobarbaz = \"foobarbaz\";\n"
+   "  int   quux  = 4;\n"
+   "}",
+   Style);
+
+  // Test with nested #if and #else blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "#else\n"
+   "#if 2\n"
+   "#else\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   "#endif\n"
+   "#endif\n"
+   "}\n"
+   "#if 1\n"
+   "#else\n"
+   "#if 2\n"
+   "int baz = 3;\n"
+   "#endif\n"
+   "#endif\n"
+   "void f2() {\n"
+   "#if 1\n"
+   "#if 2\n"
+   "#else\n"
+   "  // prevent alignment with #else in f1\n"
+   "  char *foobarbaz = \"foobarbaz\";\n"
+   "  int   quux  = 4;\n"
+   "#endif\n"
+   "#endif\n"
+   "}",
+   Style);
+}
+
 TEST_F(FormatTest, FormatHashIfNotAtStartOfLine) {
   verifyFormat("{\n  { a #c; }\n}");
 }
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -522,6 +522,13 @@
? Changes[StartAt].indentAndNestingLevel()
: std::tuple();
 
+  // Keep track if the first token has a non-zero indent and nesting level.
+  // This can happen when aligning the contents of "#else" preprocessor blocks,
+  // which is done separately.
+  bool HasInitialIndentAndNesting =
+  StartAt == 0 &&
+  IndentAndNestingLevel > std::tuple();
+
   // Keep track of the number of commas before the matching tokens, we will only
   // align a sequence of matching tokens if they are preceded by the same number
   // of commas.
@@ -556,8 +563,19 @@
 
   unsigned i = StartAt;
   for (unsigned e = Changes.size(); i != e; ++i) {
-if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel)
-  break;
+if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel) {
+  if (!HasInitialIndentAndNesting)
+break;
+  // The contents of preprocessor blocks are aligned separately.
+  // If the initial preprocessor block is indented or nested (e.g. it's in
+  // a function), do not align 

[clang] c077975 - [clang-format] Fix alignment in #else preprocessor blocks

2022-09-27 Thread via cfe-commits

Author: mitchell
Date: 2022-09-27T15:41:09-04:00
New Revision: c0779756a0c4cc84d9f98714734d47879701cc3d

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

LOG: [clang-format] Fix alignment in #else preprocessor blocks
Summary:
clang-format makes multiple passes when #if/#else preprocessor blocks are 
found.  It will make
one pass for normal code and code in the #if block, and then it will make 
another pass for just
the code in #else blocks. This often results in invalid alignment inside the 
else blocks because
they do not have any scope or indentAndNestingLevel context from their 
surrounding tokens/lines.

This patch remedies that by caching any initial indentAndNestingLevel from a 
second pass and
not breaking/returning early when a scope change is detected.

Fixes #36070

Reviewers: HazardyKnusperkeks, MyDeveloperDay

Tags: clang, clang-format

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 6ec788ad23c66..895d0c8e818c2 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -522,6 +522,13 @@ static unsigned AlignTokens(const FormatStyle , F 
&,
? Changes[StartAt].indentAndNestingLevel()
: std::tuple();
 
+  // Keep track if the first token has a non-zero indent and nesting level.
+  // This can happen when aligning the contents of "#else" preprocessor blocks,
+  // which is done separately.
+  bool HasInitialIndentAndNesting =
+  StartAt == 0 &&
+  IndentAndNestingLevel > std::tuple();
+
   // Keep track of the number of commas before the matching tokens, we will 
only
   // align a sequence of matching tokens if they are preceded by the same 
number
   // of commas.
@@ -556,8 +563,19 @@ static unsigned AlignTokens(const FormatStyle , F 
&,
 
   unsigned i = StartAt;
   for (unsigned e = Changes.size(); i != e; ++i) {
-if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel)
-  break;
+if (Changes[i].indentAndNestingLevel() < IndentAndNestingLevel) {
+  if (!HasInitialIndentAndNesting)
+break;
+  // The contents of preprocessor blocks are aligned separately.
+  // If the initial preprocessor block is indented or nested (e.g. it's in
+  // a function), do not align and exit after finishing this scope block.
+  // Instead, align, and then lower the baseline indent and nesting level
+  // in order to continue aligning subsequent blocks.
+  EndOfSequence = i;
+  AlignCurrentSequence();
+  IndentAndNestingLevel =
+  Changes[i].indentAndNestingLevel(); // new baseline
+}
 
 if (Changes[i].NewlinesBefore != 0) {
   CommasBeforeMatch = 0;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index f27fff1e9ebd0..4c11104343a4d 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -5825,6 +5825,98 @@ TEST_F(FormatTest, IndentPreprocessorDirectives) {
Style);
 }
 
+TEST_F(FormatTest, FormatAlignInsidePreprocessorElseBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AlignConsecutiveAssignments.Enabled = true;
+  Style.AlignConsecutiveDeclarations.Enabled = true;
+
+  // Test with just #if blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   "#endif\n"
+   "}\n"
+   "#if 1\n"
+   "int baz = 3;\n"
+   "#endif\n"
+   "void f2() {\n"
+   "#if 1\n"
+   "  char *foobarbaz = \"foobarbaz\";\n"
+   "  int   quux  = 4;\n"
+   "}",
+   Style);
+
+  // Test with just #else blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   "#endif\n"
+   "}\n"
+   "#if 1\n"
+   "#else\n"
+   "int baz = 3;\n"
+   "#endif\n"
+   "void f2() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  char *foobarbaz = \"foobarbaz\";\n"
+   "  int   quux  = 4;\n"
+   "}",
+   Style);
+
+  // Test with a mix of #if and #else blocks.
+  verifyFormat("void f1() {\n"
+   "#if 1\n"
+   "#else\n"
+   "  int foo= 1;\n"
+   "  int foobar = 2;\n"
+   

[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133683#3818887 , @mizvekov wrote:

> In D133683#3818858 , @ychen wrote:
>
>> It is clear cut by https://eel.is/c++draft/temp.deduct.partial#3.1. It is 
>> orthogonal to the DRs implemented in D128745 
>>  and here.
>> https://godbolt.org/z/s49sqrabY  : if you call `g(42,42)`, it would reveal 
>> that the function without pack indeed wins. It is ambiguous because the 
>> caller `g(42)` does not use the pack. So the wording prevents us from 
>> letting the non-pack version win. I do somewhat agree that it is more 
>> consistent and predictable to always consider all function parameters for 
>> partial ordering. Yeah, that needs a whole separate discussion on 
>> https://eel.is/c++draft/temp.deduct.partial#3.1.
>
> I think it's using the pack, the pack is just being deduced as an empty pack. 
> This is different from a template parameter which is not being deduced 
> because it does not appear in the arguments.
>
> To reiterate, what you said would make sense if the second overload was 
> written as:
>
> `template  void g(T);`
>
> Instead of `template  void g(T, U...);` as it is.

This is described in https://eel.is/c++draft/temp.deduct.partial#13. Parietal 
ordering currently doesn't consider the number of deduced arguments. During the 
partial ordering stage, by https://eel.is/c++draft/temp.func.order#3, `template 
 void g(T, U...);` would become `void g(UniqueT1, 
UniqueT2);`. And then it applies 
https://eel.is/c++draft/temp.deduct.partial#3.1 to decide which parameters are 
compared for partial ordering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added inline comments.



Comment at: clang/lib/AST/Mangle.cpp:371
+  OS << (MD->isInstanceMethod() ? '-' : '+');
+  OS << (MD->hasMethodVisibilityDefault() ? '<' : '[');
   if (const auto *CID = MD->getCategory()) {

ahatanak wrote:
> Sorry, I might have missed the discussion, but what's the reason we need this 
> change in mangling? Is it because the linker cannot handle the standard 
> mangling scheme?
Yeah. These are for ld and dyld. Not having a preceding underscore and the 
square brackets causes problems. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In D86049#3818696 , @plotfi wrote:

> In D86049#3818435 , @mwyman wrote:
>
>> In D86049#3816006 , @plotfi wrote:
>>
>>> @dmaclach @ahatanak @mwyman How do things look from here? Do you want 
>>> something for properties as well or would it be ok if we did this in a 
>>> later commit?
>>
>> Huh, for some reason I thought when I'd last poked at using the `visibility` 
>> attribute it wasn't allowed on ObjC methods, which is why I'd suggested 
>> adding the enum on `objc_direct`, but as that no longer appears to be the 
>> case yes I like this approach better.
>
> @dmaclach @mwyman  I am also very happy with the fact that we can just reuse 
> the regular `visibility` attribute. In the future we can decide on revised 
> behavior for `hasMethodVisibilityDefault`.
>
> @ahatanak Do you have feedback on this?

The visibility attribute changes look good to me.

Do we have the answers to the last two questions John raised in 
https://reviews.llvm.org/D86049#2255738? I think we should get it right the 
first time since, once we make the direct methods visible, it'd be hard to 
change where the null check or class initialization is done since that would be 
an ABI change. Should we run experiments to measure the impact on code size?




Comment at: clang/lib/AST/Mangle.cpp:371
+  OS << (MD->isInstanceMethod() ? '-' : '+');
+  OS << (MD->hasMethodVisibilityDefault() ? '<' : '[');
   if (const auto *CID = MD->getCategory()) {

Sorry, I might have missed the discussion, but what's the reason we need this 
change in mangling? Is it because the linker cannot handle the standard 
mangling scheme?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D133683#3818858 , @ychen wrote:

> It is clear cut by https://eel.is/c++draft/temp.deduct.partial#3.1. It is 
> orthogonal to the DRs implemented in D128745 
>  and here.
> https://godbolt.org/z/s49sqrabY  : if you call `g(42,42)`, it would reveal 
> that the function without pack indeed wins. It is ambiguous because the 
> caller `g(42)` does not use the pack. So the wording prevents us from letting 
> the non-pack version win. I do somewhat agree that it is more consistent and 
> predictable to always consider all function parameters for partial ordering. 
> Yeah, that needs a whole separate discussion on 
> https://eel.is/c++draft/temp.deduct.partial#3.1.

I think it's using the pack, the pack is just being deduced as an empty pack. 
This is different from a template parameter which is not being deduced because 
it does not appear in the arguments.

To reiterate, what you said would make sense if the second overload was written 
as:

`template  void g(T);`

Instead of `template  void g(T, U...);` as it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 463309.
ychen added a comment.

- Update release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaCXX/pre-dr692.cpp

Index: clang/test/SemaCXX/pre-dr692.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pre-dr692.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -std=c++11 -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -fclang-abi-compat=15
+
+template  struct A1 {};
+template  struct A2 {};
+template  void e1(A1);  // expected-note {{candidate}}
+template  void e1(A1);  // expected-note {{candidate}}
+template  void e2(A2);  // expected-note {{candidate}}
+template  void e2(A2);  // expected-note {{candidate}}
+void h() {
+  A1 b1;
+  e1(b1); // expected-error{{call to 'e1' is ambiguous}}
+  A2 b2;
+  e2(b2); // expected-error{{call to 'e2' is ambiguous}}
+}
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1083,13 +1083,23 @@
   // Also see dr1395.
 
   namespace temp_func_order_example2 {
-template  struct A {};
-template  void f(U, A *p = 0); // expected-note {{candidate}}
-template  int (U, A *p = 0); // expected-note {{candidate}}
+template  struct A1 {}; // expected-error 0-1{{C++11}}
+template  struct A2 {}; // expected-error 0-1{{C++11}}
+template  void e1(A1) = delete; // expected-error 0-2{{C++11}}
+template  void e1(A1);
+template  void e2(A2) = delete; // expected-error 0-2{{C++11}}
+template  void e2(A2);
+template  void f(U, A1 *p = 0) = delete; // expected-note {{candidate}} expected-error 0-1{{C++11}}
+template  int (U, A1 *p = 0); // expected-note {{candidate}}
 template  void g(T, T = T()); // expected-note {{candidate}}
 template  void g(T, U...); // expected-note {{candidate}} expected-error 0-1{{C++11}}
 void h() {
-  int  = f(42, (A *)0);
+  A1 a;
+  int  = f(42, );
+  A1 b1;
+  e1(b1);
+  A2 b2;
+  e2(b2);
   f(42); // expected-error {{ambiguous}}
   g(42); // expected-error {{ambiguous}}
 }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5222,6 +5222,39 @@
   return FT1;
   }
 
+  // This a speculative fix for CWG1432 (Similar to the fix for CWG1395) that
+  // there is no wording or even resolution for this issue.
+  bool ClangABICompat15 =
+  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
+  if (!ClangABICompat15) {
+for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
+  QualType T1 = FD1->getParamDecl(i)->getType().getCanonicalType();
+  QualType T2 = FD2->getParamDecl(i)->getType().getCanonicalType();
+  auto *TST1 = dyn_cast(T1);
+  auto *TST2 = dyn_cast(T2);
+  if (!TST1 || !TST2)
+continue;
+  const TemplateArgument  = TST1->template_arguments().back();
+  if (TA1.getKind() == TemplateArgument::Pack) {
+assert(TST1->getNumArgs() == TST2->getNumArgs());
+const TemplateArgument  = TST2->template_arguments().back();
+assert(TA2.getKind() == TemplateArgument::Pack);
+unsigned PackSize1 = TA1.pack_size();
+unsigned PackSize2 = TA2.pack_size();
+bool IsPackExpansion1 =
+PackSize1 && TA1.pack_elements().back().isPackExpansion();
+bool IsPackExpansion2 =
+PackSize2 && TA2.pack_elements().back().isPackExpansion();
+if (PackSize1 != PackSize2 && IsPackExpansion1 != IsPackExpansion2) {
+  if (PackSize1 > PackSize2 && IsPackExpansion1)
+return FT2;
+  if (PackSize1 < PackSize2 && IsPackExpansion2)
+return FT1;
+}
+  }
+}
+  }
+
   return JudgeByConstraints();
 }
 
@@ -5457,30 +5490,29 @@
 return nullptr;
 
   if (Better1 && Better2) {
+// This a speculative fix for CWG1432 (Similar to the fix for CWG1395) that
+// there is no wording or even resolution for this issue.
 bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
 LangOptions::ClangABI::Ver15;
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
-  auto *TST1 = T1->castAs();
-  auto *TST2 = T2->castAs();
-  if (TST1->getNumArgs()) {
-const TemplateArgument  = TST1->template_arguments().back();
-if (TA1.getKind() == TemplateArgument::Pack) {
-  assert(TST1->getNumArgs() == TST2->getNumArgs());
-  const TemplateArgument  = 

[clang] 30cc712 - [Clang][OpenMP] Fix run time crash when use_device_addr is used.

2022-09-27 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2022-09-27T11:53:57-07:00
New Revision: 30cc712eb6f23a5c7beaae669bf2ab6beede7f20

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

LOG: [Clang][OpenMP] Fix run time crash when use_device_addr is used.

It is data mapping ordering problem.

According omp spec
If one or more map clauses are present, the list item conversions that
are performed for any use_device_ptr or use_device_addr clause occur
after all variables are mapped on entry to the region according to those
map clauses.

The change is to put mapping data for use_device_addr at end of data
mapping array.

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

Added: 
openmp/libomptarget/test/mapping/target_use_device_addr.c

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_data_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6ff36c72e0319..5bf0e0815111e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8547,49 +8547,92 @@ class MappableExprsHandler {
   }
 }
 
-// Look at the use_device_ptr clause information and mark the existing map
-// entries as such. If there is no map information for an entry in the
-// use_device_ptr list, we create one with map type 'alloc' and zero size
-// section. It is the user fault if that was not mapped before. If there is
-// no map information and the pointer is a struct member, then we defer the
-// emission of that entry until the whole struct has been processed.
+// Look at the use_device_ptr and use_device_addr clauses information and
+// mark the existing map entries as such. If there is no map information 
for
+// an entry in the use_device_ptr and use_device_addr list, we create one
+// with map type 'alloc' and zero size section. It is the user fault if 
that
+// was not mapped before. If there is no map information and the pointer is
+// a struct member, then we defer the emission of that entry until the 
whole
+// struct has been processed.
 llvm::MapVector,
 SmallVector>
 DeferredInfo;
-MapCombinedInfoTy UseDevicePtrCombinedInfo;
+MapCombinedInfoTy UseDeviceDataCombinedInfo;
+
+auto & =
+[](const ValueDecl *VD, llvm::Value *Ptr,
+ CodeGenFunction ) {
+  UseDeviceDataCombinedInfo.Exprs.push_back(VD);
+  UseDeviceDataCombinedInfo.BasePointers.emplace_back(Ptr, VD);
+  UseDeviceDataCombinedInfo.Pointers.push_back(Ptr);
+  UseDeviceDataCombinedInfo.Sizes.push_back(
+  llvm::Constant::getNullValue(CGF.Int64Ty));
+  UseDeviceDataCombinedInfo.Types.push_back(OMP_MAP_RETURN_PARAM);
+  UseDeviceDataCombinedInfo.Mappers.push_back(nullptr);
+};
 
-for (const auto *Cl : Clauses) {
-  const auto *C = dyn_cast(Cl);
-  if (!C)
-continue;
-  for (const auto L : C->component_lists()) {
-OMPClauseMappableExprCommon::MappableExprComponentListRef Components =
-std::get<1>(L);
-assert(!Components.empty() &&
-   "Not expecting empty list of components!");
-const ValueDecl *VD = Components.back().getAssociatedDeclaration();
-VD = cast(VD->getCanonicalDecl());
-const Expr *IE = Components.back().getAssociatedExpression();
-// If the first component is a member expression, we have to look into
-// 'this', which maps to null in the map of map information. Otherwise
-// look directly for the information.
-auto It = Info.find(isa(IE) ? nullptr : VD);
-
-// We potentially have map information for this declaration already.
-// Look for the first set of components that refer to it.
-if (It != Info.end()) {
-  bool Found = false;
-  for (auto  : It->second) {
-auto *CI = llvm::find_if(Data, [VD](const MapInfo ) {
-  return MI.Components.back().getAssociatedDeclaration() == VD;
-});
-// If we found a map entry, signal that the pointer has to be
-// returned and move on to the next declaration. Exclude cases 
where
-// the base pointer is mapped as array subscript, array section or
-// array shaping. The base address is passed as a pointer to base 
in
-// this case and cannot be used as a base for use_device_ptr list
-// item.
-if (CI != Data.end()) {
+auto & =
+[, ,
+ ](CodeGenFunction , const Expr *IE, const ValueDecl *VD,
+   OMPClauseMappableExprCommon::MappableExprComponentListRef
+   

[PATCH] D134556: [Clang][OpenMP] Fix run time crash when use_device_addr is used.

2022-09-27 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
jyu2 marked an inline comment as done.
Closed by commit rG30cc712eb6f2: [Clang][OpenMP] Fix run time crash when 
use_device_addr is used. (authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134556

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  openmp/libomptarget/test/mapping/target_use_device_addr.c

Index: openmp/libomptarget/test/mapping/target_use_device_addr.c
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/target_use_device_addr.c
@@ -0,0 +1,18 @@
+// RUN: %libomptarget-compile-generic -fopenmp-version=51
+// RUN: %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic
+
+#include 
+int main() {
+  short x[10];
+  short *xp = [0];
+
+  x[1] = 111;
+
+  printf("%d, %p\n", xp[1], [1]);
+#pragma omp target data use_device_addr(xp [1:3]) map(tofrom : x)
+#pragma omp target is_device_ptr(xp)
+  { xp[1] = 222; }
+  // CHECK: 222
+  printf("%d, %p\n", xp[1], [1]);
+}
Index: clang/test/OpenMP/target_data_codegen.cpp
===
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -596,15 +596,18 @@
 }
 #endif
 ///==///
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK7 --check-prefix CK7-64
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK7 --check-prefix CK7-64
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK7 --check-prefix CK7-64
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp -fopenmp-targets=x86_64 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK7 --check-prefix CK7-64
 
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY7 %s
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY7 %s
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp-simd -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY7 %s
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp-simd -fopenmp-targets=x86_64 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY7 %s
 // SIMD-ONLY7-NOT: {{__kmpc|__tgt}}
 #ifdef CK7
+// CK7: private unnamed_addr constant [2 x i64] [i64 64, i64 64]
+// CK7: private unnamed_addr constant [2 x i64] [i64 3, i64 64]
+// CK7-NOT: private unnamed_addr constant [2 x i64] [i64 64, i64 3]
 // CK7: test_device_ptr_addr
 void test_device_ptr_addr(int arg) {
   int *p;
@@ -612,6 +615,16 @@
   // CK7: add nsw i32
   #pragma omp target data use_device_ptr(p) use_device_addr(arg)
   { ++arg, ++(*p); }
+
+  short x[10];
+  short *xp = [0];
+
+  x[1] = 111;
+
+  #pragma omp target data map(tofrom: x) use_device_addr(xp[1:3])
+  {
+xp[1] = 222;
+  }
 }
 #endif
 ///==///
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8547,49 +8547,92 @@
   }
 }
 
-// Look at the use_device_ptr clause information and mark the existing map
-// entries as such. If there is no map information for an entry in the
-// use_device_ptr list, we create one with map type 'alloc' and zero size
-// section. It is the user fault if that was not mapped before. If there is
-// no map information and the pointer is a struct member, then we defer 

[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133683#3818804 , @mizvekov wrote:

> In D133683#3818752 , @ychen wrote:
>
>> I didn't add that because this patch is logically part of D128745 
>>  which has a release note already.
>
> Okay, I see that the existing release note entry talks just about 
> implementing those DRs without going specific, so that is fine.
> It does not mention that DR1432 implementation is tentative as there is no 
> published resolution though.
>
>> I think GCC is the one that is not conforming. MSVC agrees it is ambiguous 
>> (https://godbolt.org/z/T5zbxaTYq). Basically, only the first parameter is 
>> considered for partial ordering. 
>> (https://eel.is/c++draft/temp.deduct.partial#3.1)
>
> I could totally buy that the GCC behavior is accidental, but it does make 
> sense, with the idea behind DR1432, that we should prefer the first overload 
> because that deduction is simpler, or because it does not deduce a parameter 
> pack.
>
> If there was a resolution, the answer here would be clear cut, but since 
> there isn't, we are making up our own rules and getting into a language 
> design discussion.
> If you don't think that is clear cut, it's fine, we can move this discussion 
> elsewhere :)

It is clear cut by https://eel.is/c++draft/temp.deduct.partial#3.1. It is 
orthogonal to the DRs implemented in D128745  
and here.
https://godbolt.org/z/s49sqrabY  : if you call `g(42,42)`, it would reveal that 
the function without pack indeed wins. It is ambiguous because the caller 
`g(42)` does not use the pack. So the wording prevents us from letting the 
non-pack version win. I do somewhat agree that it is more consistent and 
predictable to always consider all function parameters for partial ordering. 
Yeah, that needs a whole separate discussion on 
https://eel.is/c++draft/temp.deduct.partial#3.1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D134507#3818765 , @ychen wrote:

> In D134507#3817928 , @probinson 
> wrote:
>
>> It feels odd to use a ClangABI check for something that is affecting what 
>> source is accepted, but this is not my area of expertise.
>> @aaron.ballman or @rjmccall would probably be the right people to weigh in 
>> on this.
>
> This was discussed here https://reviews.llvm.org/D128745#inline-1244757. 
> Yeah, it is somewhat confusing to key the legacy language behavior on 
> ClangABI. I'm not sure there are better choices than inventing new flags.

Right, which points to 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaDeclCXX.cpp#L9786
 concerning the treatment of copy constructors.  But those at least can feed 
into how one goes about conjuring up calling sequences involving parameters of 
types that might have to invoke those constructors, and so that case seems a 
lot more ABI-relevant than subtle details about template parameter packs.

Anyway, I'm going to step out of this now, I don't have the expertise to review 
this responsibly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


[PATCH] D134668: [LTO][clang] Using Single Dash Consistently when Passing LTO Options

2022-09-27 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG86cd3535206d: [LTO][clang] Using Single Dash Consistently 
when Passing LTO Options (authored by Qiongsi Wu 
qiongsiwu@Qiongsis-MacBook-Air.local).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134668

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/opt-record.c

Index: clang/test/Driver/opt-record.c
===
--- clang/test/Driver/opt-record.c
+++ clang/test/Driver/opt-record.c
@@ -53,28 +53,28 @@
 // RUN: %clang -target x86_64-linux -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=100 -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-RPASS
 // RUN: %clang -target x86_64-linux -### -o FOO -fuse-ld=lld -flto=thin -fdiagnostics-hotness-threshold=auto -Rpass=inline -Rpass-missed=inline -Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-AUTO
 
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-filename="
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-passes=inline"
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-format=yaml"
-// CHECK-NOPASS-NOT: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-A:  "--plugin-opt=opt-remarks-filename=a.out.opt.ld.yaml"
-// CHECK-PASS-A-SAME: "--plugin-opt=opt-remarks-passes=inline"
-// CHECK-PASS-A-SAME: "--plugin-opt=opt-remarks-format=yaml"
-// CHECK-PASS-A-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS:  "--plugin-opt=opt-remarks-filename=FOO.opt.ld.yaml"
-// CHECK-PASS-SAME: "--plugin-opt=opt-remarks-passes=inline"
-// CHECK-PASS-SAME: "--plugin-opt=opt-remarks-format=yaml"
-// CHECK-PASS-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-CUSTOM:  "--plugin-opt=opt-remarks-filename=FOO.txt.opt.ld.some-format"
-// CHECK-PASS-CUSTOM-SAME: "--plugin-opt=opt-remarks-format=some-format"
-// CHECK-PASS-CUSTOM-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-RPASS:  "--plugin-opt=-pass-remarks=inline"
-// CHECK-PASS-RPASS-SAME: "--plugin-opt=-pass-remarks-missed=inline"
-// CHECK-PASS-RPASS-SAME: "--plugin-opt=-pass-remarks-analysis=inline"
-// CHECK-PASS-RPASS-SAME: "--plugin-opt=opt-remarks-hotness-threshold=100"
-
-// CHECK-PASS-AUTO:   "--plugin-opt=opt-remarks-hotness-threshold=auto"
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-filename="
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-passes=inline"
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-format=yaml"
+// CHECK-NOPASS-NOT: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-A:  "-plugin-opt=opt-remarks-filename=a.out.opt.ld.yaml"
+// CHECK-PASS-A-SAME: "-plugin-opt=opt-remarks-passes=inline"
+// CHECK-PASS-A-SAME: "-plugin-opt=opt-remarks-format=yaml"
+// CHECK-PASS-A-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS:  "-plugin-opt=opt-remarks-filename=FOO.opt.ld.yaml"
+// CHECK-PASS-SAME: "-plugin-opt=opt-remarks-passes=inline"
+// CHECK-PASS-SAME: "-plugin-opt=opt-remarks-format=yaml"
+// CHECK-PASS-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-CUSTOM:  "-plugin-opt=opt-remarks-filename=FOO.txt.opt.ld.some-format"
+// CHECK-PASS-CUSTOM-SAME: "-plugin-opt=opt-remarks-format=some-format"
+// CHECK-PASS-CUSTOM-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-RPASS:  "-plugin-opt=-pass-remarks=inline"
+// CHECK-PASS-RPASS-SAME: "-plugin-opt=-pass-remarks-missed=inline"
+// CHECK-PASS-RPASS-SAME: "-plugin-opt=-pass-remarks-analysis=inline"
+// CHECK-PASS-RPASS-SAME: "-plugin-opt=opt-remarks-hotness-threshold=100"
+
+// CHECK-PASS-AUTO:   "-plugin-opt=opt-remarks-hotness-threshold=auto"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -67,16 +67,16 @@
 
 static void renderRpassOptions(const ArgList , ArgStringList ) {
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
-CmdArgs.push_back(Args.MakeArgString(Twine("--plugin-opt=-pass-remarks=") +
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=-pass-remarks=") +
  A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+Twine("-plugin-opt=-pass-remarks-missed=") + A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+Twine("-plugin-opt=-pass-remarks-analysis=") + A->getValue()));
 }
 
 

[clang] 86cd353 - [LTO][clang] Using Single Dash Consistently when Passing LTO Options

2022-09-27 Thread Qiongsi Wu via cfe-commits

Author: Qiongsi Wu
Date: 2022-09-27T14:50:41-04:00
New Revision: 86cd3535206d6db611260aae6f2869202eae4bb4

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

LOG: [LTO][clang] Using Single Dash Consistently when Passing LTO Options

The following three static functions in 
`clang/lib/Driver/ToolChains/CommonArgs.cpp`

```
static void renderRpassOptions(...)
static void renderRemarksOptions(...)
static void renderRemarksHotnessOptions(...)
```

use `--plugin-opt` for the plugin option prefix, while the function 
`tools::addLTOOptions`  uses `-plugin-opt`. This patch makes sure that we only 
use `-plugin-opt` (single dash) everywhere. It is not clear to me that why we 
decided to use `--plugin-opt` in https://reviews.llvm.org/D85810. If using 
`--plugin-opt` is intended, I'd love to hear the reason and I will close this 
patch.

We intend to followup this patch with a few other patches that teach `clang` to 
pass plugin options to the AIX linker, which uses a different prefix 
(`-bplugin_opt:`).

Reviewed By: w2yehia

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/opt-record.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 86ed6edfb86fa..d0abc4a0e26c2 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -67,16 +67,16 @@ using namespace llvm::opt;
 
 static void renderRpassOptions(const ArgList , ArgStringList ) {
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_EQ))
-CmdArgs.push_back(Args.MakeArgString(Twine("--plugin-opt=-pass-remarks=") +
+CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=-pass-remarks=") +
  A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_missed_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("--plugin-opt=-pass-remarks-missed=") + A->getValue()));
+Twine("-plugin-opt=-pass-remarks-missed=") + A->getValue()));
 
   if (const Arg *A = Args.getLastArg(options::OPT_Rpass_analysis_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("--plugin-opt=-pass-remarks-analysis=") + A->getValue()));
+Twine("-plugin-opt=-pass-remarks-analysis=") + A->getValue()));
 }
 
 static void renderRemarksOptions(const ArgList , ArgStringList ,
@@ -97,28 +97,28 @@ static void renderRemarksOptions(const ArgList , 
ArgStringList ,
   assert(!F.empty() && "Cannot determine remarks output name.");
   // Append "opt.ld." to the end of the file name.
   CmdArgs.push_back(
-  Args.MakeArgString(Twine("--plugin-opt=opt-remarks-filename=") + F +
+  Args.MakeArgString(Twine("-plugin-opt=opt-remarks-filename=") + F +
  Twine(".opt.ld.") + Format));
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_foptimization_record_passes_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("--plugin-opt=opt-remarks-passes=") + A->getValue()));
+Twine("-plugin-opt=opt-remarks-passes=") + A->getValue()));
 
   CmdArgs.push_back(Args.MakeArgString(
-  Twine("--plugin-opt=opt-remarks-format=") + Format.data()));
+  Twine("-plugin-opt=opt-remarks-format=") + Format.data()));
 }
 
 static void renderRemarksHotnessOptions(const ArgList ,
 ArgStringList ) {
   if (Args.hasFlag(options::OPT_fdiagnostics_show_hotness,
options::OPT_fno_diagnostics_show_hotness, false))
-CmdArgs.push_back("--plugin-opt=opt-remarks-with-hotness");
+CmdArgs.push_back("-plugin-opt=opt-remarks-with-hotness");
 
   if (const Arg *A =
   Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ))
 CmdArgs.push_back(Args.MakeArgString(
-Twine("--plugin-opt=opt-remarks-hotness-threshold=") + A->getValue()));
+Twine("-plugin-opt=opt-remarks-hotness-threshold=") + A->getValue()));
 }
 
 void tools::addPathIfExists(const Driver , const Twine ,

diff  --git a/clang/test/Driver/opt-record.c b/clang/test/Driver/opt-record.c
index 02840f49a86f7..fd7cabb284869 100644
--- a/clang/test/Driver/opt-record.c
+++ b/clang/test/Driver/opt-record.c
@@ -53,28 +53,28 @@
 // RUN: %clang -target x86_64-linux -### -o FOO -fuse-ld=lld -flto=thin 
-fdiagnostics-hotness-threshold=100 -Rpass=inline -Rpass-missed=inline 
-Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-RPASS
 // RUN: %clang -target x86_64-linux -### -o FOO -fuse-ld=lld -flto=thin 
-fdiagnostics-hotness-threshold=auto -Rpass=inline -Rpass-missed=inline 
-Rpass-analysis=inline %s 2>&1 | FileCheck %s -check-prefix=CHECK-PASS-AUTO
 
-// CHECK-NOPASS-NOT: 

[PATCH] D134745: [LV][Metadata] Add loop.interleave.enable for loop vectorizer

2022-09-27 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 463299.
eopXD added a comment.

Fix grammar error in comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134745

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/CodeGenCXX/pragma-loop-safety.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
  llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  
llvm/test/Transforms/LoopVectorize/AArch64/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll
  llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll
  llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll
  
llvm/test/Transforms/LoopVectorize/X86/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/X86/vect.omp.force.ll
  llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_detection.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_nonuniform_inner.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_uniform_diverg_branch.ll
  llvm/test/Transforms/LoopVectorize/no_switch.ll
  llvm/test/Transforms/LoopVectorize/no_switch_disable_vectorization.ll
  llvm/test/Transforms/LoopVectorize/nounroll.ll
  llvm/test/Transforms/LoopVectorize/optsize.ll
  llvm/test/Transforms/LoopVectorize/outer-loop-vec-phi-predecessor-order.ll
  llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll
  llvm/test/Transforms/LoopVectorize/outer_loop_test2.ll
  llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
  llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
  llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
  llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
  llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
  llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll

Index: llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
@@ -196,5 +196,6 @@
 exit:
   ret void
 }
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
@@ -68,5 +68,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
@@ -77,5 +77,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
@@ -69,6 +69,7 @@
   ret void
 }
 
-!1 = distinct !{!1, !2, !3}
+!1 = distinct !{!1, !2, !3, !4}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
 !3 = !{!"llvm.loop.vectorize.enable", i1 true}
+!4 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
@@ -43,5 +43,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
===
--- llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
+++ llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
@@ -2,7 +2,7 @@
 ; REQUIRES: asserts
 
 ; CHECK: LV: Checking a loop in 'foo'
-; CHECK: 

[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-09-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't think I agree that changes to template partial ordering rules are 
"ABI-breaking changes".  They're breaking changes to *language semantics*, and 
the ABI break is downstream of that, just like any other semantic change to 
overload resolution would be.  I think the right approach for Clang is to gate 
this by language version and add a note somewhere that C++23 changed the 
overload resolution rules around function templates and that this means 
adopting C++23 can be ABI-breaking.  Fortunately, it should only be 
ABI-breaking in rare circumstances.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D133683#3818752 , @ychen wrote:

> I didn't add that because this patch is logically part of D128745 
>  which has a release note already.

Okay, I see that the existing release note entry talks just about implementing 
those DRs without going specific, so that is fine.
It does not mention that DR1432 implementation is tentative as there is no 
published resolution though.

> I think GCC is the one that is not conforming. MSVC agrees it is ambiguous 
> (https://godbolt.org/z/T5zbxaTYq). Basically, only the first parameter is 
> considered for partial ordering. 
> (https://eel.is/c++draft/temp.deduct.partial#3.1)

I could totally buy that the GCC behavior is accidental, but it does make 
sense, with the idea behind DR1432, that we should prefer the first overload 
because that deduction is simpler, or because it does not deduce a parameter 
pack.

If there was a resolution, the answer here would be clear cut, but since there 
isn't, we are making up our own rules and getting into a language design 
discussion.
If you don't think that is clear cut, it's fine, we can move this discussion 
elsewhere :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-09-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Yeah okay. I get it now.  Thank you for your patience and your time on 
elaborating the issue.

First, I think we'd need to fabricate a test case that shows us the bug even 
without applying your patch (D103096 ).

Then we can iterate onto the solution. What we could do is to collect the 
constants and types on the way of the cast visitation and then apply the same 
logic that you have in D103096 . But then 
there is an open question: what should we do if there is another kind of symbol 
in the chain of SymbolCasts? E.g SymbolCast, UnarySymExpr, SymbolCast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D134507#3817928 , @probinson wrote:

> It feels odd to use a ClangABI check for something that is affecting what 
> source is accepted, but this is not my area of expertise.
> @aaron.ballman or @rjmccall would probably be the right people to weigh in on 
> this.

This was discussed here https://reviews.llvm.org/D128745#inline-1244757. Yeah, 
it is somewhat confusing to key the legacy language behavior on ClangABI. I'm 
not sure there are better choices than inventing new flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133683#3817523 , @mizvekov wrote:

> - Missing release notes.

I didn't add that because this patch is logically part of D128745 
 which has a release note already.

> - FWIW GCC treats the `g(42)` case as not ambiguous, as I expected, so it 
> might be worth pointing that out with a FIXME regardless.

I think GCC is the one that is not conforming. MSVC agrees it is ambiguous 
(https://godbolt.org/z/T5zbxaTYq). Basically, only the first parameter is 
considered for partial ordering. 
(https://eel.is/c++draft/temp.deduct.partial#3.1)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


  1   2   >