[PATCH] D128807: [clang][transformer] Finish plumbing `Note` all the way to the output.

2022-07-03 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

In D128807#3625676 , @ymandel wrote:

>> For my particular case, I just need multiple notes per rule. I don't need 
>> them to be associated to a particular edit (and in that very particular 
>> case, I don't even need a source location).
>
> I'm not sure I understand: you need this additional note, but it doesn't need 
> to be tied to a source location, so, why can't you concatenate it to the main 
> note?

For my specific check the notes carry structure beyond what's typically in a 
warning, so I need the information to be separate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128807

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


[PATCH] D129057: [clang-format] Break on AfterColon only if not followed by comment

2022-07-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7136
Style);
+  verifyFormat("Constructor() : // NOLINT\n"
+   "() {}",

How about very long comments? They don't get split now? Please add a test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129057

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


[PATCH] D129057: [clang-format] Break on AfterColon only if not followed by comment

2022-07-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:7099
OnePerLine);
-  verifyFormat("SomeClass::Constructor() :\n"
+  verifyFormat("SomeClass::Constructor() : // NOLINT\n"
"a(aa), // Some comment\n"

You should add a test without modifying an existing one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129057

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-03 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added a comment.

Three test cases are failing - Please see: 
https://buildkite.com/llvm-project/premerge-checks/builds/100784#0181c539-bcd1-4d01-a2db-f27a63e2f17e/6-15379
But I think you want to actually modify 
https://github.com/llvm/llvm-project/blob/93d6fdfc232c59975d52146532693178def5ad16/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11133
 and 
https://github.com/llvm/llvm-project/blob/93d6fdfc232c59975d52146532693178def5ad16/clang/include/clang/Basic/DiagnosticSemaKinds.td#L11142.

Please also add more description to the patch as I said before like this - 
Failing a _Static_assert in C should not report that static_assert failed. It’d 
probably be better to reword the diagnostic to be more like GCC and say “static 
assertion” failed in both C and C++.
For example - 
cat test.c
_Static_assert(0, "oh no!");

clang prints
:1:1: error: static_assert failed: oh no!
_Static_assert(0, "oh no!");
^  ~
1 error generated.

while gcc 
:1:1: error: static assertion failed: "oh no!"

1 | _Static_assert(0, "oh no!");
Compiler returned: 1




Comment at: 
clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp:48
 }
\ No newline at end of file


a 'newline' is missing here.



Comment at: 
clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp:85
 }
\ No newline at end of file


same


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D129030: [Driver] Ignore the clang modules validation-related flags if clang modules are not enabled

2022-07-03 Thread Argyrios Kyrtzidis 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 rG93d6fdfc232c: [Driver] Ignore the clang modules 
validation-related flags if clang modules are… (authored by akyrtzi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129030

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules.m

Index: clang/test/Driver/modules.m
===
--- clang/test/Driver/modules.m
+++ clang/test/Driver/modules.m
@@ -4,27 +4,27 @@
 // RUN: %clang -fmodules -fno-modules -fmodules -### %s 2>&1 | FileCheck -check-prefix=CHECK-HAS-MODULES %s
 // CHECK-HAS-MODULES: -fmodules
 
-// RUN: %clang -fbuild-session-file=doesntexist -### %s 2>&1 | FileCheck -check-prefix=NOFILE %s
+// RUN: %clang -fmodules -fbuild-session-file=doesntexist -### %s 2>&1 | FileCheck -check-prefix=NOFILE %s
 // NOFILE: no such file or directory: 'doesntexist'
 
 // RUN: touch -m -a -t 201008011501 %t.build-session-file
-// RUN: %clang -fbuild-session-file=%t.build-session-file -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
+// RUN: %clang -fmodules -fbuild-session-file=%t.build-session-file -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
 
-// RUN: %clang -fbuild-session-timestamp=1280703457 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
+// RUN: %clang -fmodules -fbuild-session-timestamp=1280703457 -### %s 2>&1 | FileCheck -check-prefix=TIMESTAMP_ONLY %s
 // TIMESTAMP_ONLY: -fbuild-session-timestamp=128{{([[:digit:]]{7})[^[:digit:]]}}
 
-// RUN: %clang -fbuild-session-file=%t.build-session-file -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=CONFLICT %s
+// RUN: %clang -fmodules -fbuild-session-file=%t.build-session-file -fbuild-session-timestamp=123 -### %s 2>&1 | FileCheck -check-prefix=CONFLICT %s
 // CONFLICT: error: invalid argument '-fbuild-session-file={{.*}}.build-session-file' not allowed with '-fbuild-session-timestamp'
 
-// RUN: %clang -fbuild-session-timestamp=123 -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE %s
+// RUN: %clang -fmodules -fbuild-session-timestamp=123 -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE %s
 // MODULES_VALIDATE_ONCE: -fbuild-session-timestamp=123
 // MODULES_VALIDATE_ONCE: -fmodules-validate-once-per-build-session
 
-// RUN: %clang -fbuild-session-file=%t.build-session-file -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_FILE %s
+// RUN: %clang -fmodules -fbuild-session-file=%t.build-session-file -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_FILE %s
 // MODULES_VALIDATE_ONCE_FILE: -fbuild-session-timestamp=128{{([[:digit:]]{7})[^[:digit:]]}}
 // MODULES_VALIDATE_ONCE_FILE: -fmodules-validate-once-per-build-session
 
-// RUN: %clang -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s
+// RUN: %clang -fmodules -fmodules-validate-once-per-build-session -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_ONCE_ERR %s
 // MODULES_VALIDATE_ONCE_ERR: option '-fmodules-validate-once-per-build-session' requires '-fbuild-session-timestamp=' or '-fbuild-session-file='
 
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT %s
@@ -33,16 +33,16 @@
 // RUN: %clang -fmodules -fsyntax-only -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD: -fmodules-validate-system-headers
 
-// RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
+// RUN: %clang -fmodules -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
-// RUN: %clang -fno-modules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID %s
+// RUN: %clang -fmodules -fno-modules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID-NOT: -fmodules-validate-system-headers
 
 // RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: -fmodules-disable-diagnostic-validation
 
-// RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
+// RUN: %clang -fmodules -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck 

[clang] 93d6fdf - [Driver] Ignore the clang modules validation-related flags if clang modules are not enabled

2022-07-03 Thread Argyrios Kyrtzidis via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2022-07-03T21:26:15-07:00
New Revision: 93d6fdfc232c59975d52146532693178def5ad16

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

LOG: [Driver] Ignore the clang modules validation-related flags if clang 
modules are not enabled

If clang modules are not enabled it becomes unnecessary to read the session 
timestamp file in order
to pass `-fbuild-session-timestamp` to the `cc1` invocation.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/modules.m

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c9bbdb2ac72e3..bc437d66a03ce 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3750,38 +3750,49 @@ static void RenderModulesOptions(Compilation , const 
Driver ,
   Args.AddLastArg(CmdArgs, options::OPT_fmodules_prune_interval);
   Args.AddLastArg(CmdArgs, options::OPT_fmodules_prune_after);
 
-  Args.AddLastArg(CmdArgs, options::OPT_fbuild_session_timestamp);
+  if (HaveClangModules) {
+Args.AddLastArg(CmdArgs, options::OPT_fbuild_session_timestamp);
 
-  if (Arg *A = Args.getLastArg(options::OPT_fbuild_session_file)) {
-if (Args.hasArg(options::OPT_fbuild_session_timestamp))
-  D.Diag(diag::err_drv_argument_not_allowed_with)
-  << A->getAsString(Args) << "-fbuild-session-timestamp";
+if (Arg *A = Args.getLastArg(options::OPT_fbuild_session_file)) {
+  if (Args.hasArg(options::OPT_fbuild_session_timestamp))
+D.Diag(diag::err_drv_argument_not_allowed_with)
+<< A->getAsString(Args) << "-fbuild-session-timestamp";
 
-llvm::sys::fs::file_status Status;
-if (llvm::sys::fs::status(A->getValue(), Status))
-  D.Diag(diag::err_drv_no_such_file) << A->getValue();
-CmdArgs.push_back(Args.MakeArgString(
-"-fbuild-session-timestamp=" +
-Twine((uint64_t)std::chrono::duration_cast(
-  Status.getLastModificationTime().time_since_epoch())
-  .count(;
-  }
+  llvm::sys::fs::file_status Status;
+  if (llvm::sys::fs::status(A->getValue(), Status))
+D.Diag(diag::err_drv_no_such_file) << A->getValue();
+  CmdArgs.push_back(Args.MakeArgString(
+  "-fbuild-session-timestamp=" +
+  Twine((uint64_t)std::chrono::duration_cast(
+Status.getLastModificationTime().time_since_epoch())
+.count(;
+}
 
-  if (Args.getLastArg(options::OPT_fmodules_validate_once_per_build_session)) {
-if (!Args.getLastArg(options::OPT_fbuild_session_timestamp,
- options::OPT_fbuild_session_file))
-  D.Diag(diag::err_drv_modules_validate_once_requires_timestamp);
+if (Args.getLastArg(
+options::OPT_fmodules_validate_once_per_build_session)) {
+  if (!Args.getLastArg(options::OPT_fbuild_session_timestamp,
+   options::OPT_fbuild_session_file))
+D.Diag(diag::err_drv_modules_validate_once_requires_timestamp);
 
-Args.AddLastArg(CmdArgs,
-options::OPT_fmodules_validate_once_per_build_session);
-  }
+  Args.AddLastArg(CmdArgs,
+  options::OPT_fmodules_validate_once_per_build_session);
+}
 
-  if (Args.hasFlag(options::OPT_fmodules_validate_system_headers,
-   options::OPT_fno_modules_validate_system_headers,
-   ImplicitModules))
-CmdArgs.push_back("-fmodules-validate-system-headers");
+if (Args.hasFlag(options::OPT_fmodules_validate_system_headers,
+ options::OPT_fno_modules_validate_system_headers,
+ ImplicitModules))
+  CmdArgs.push_back("-fmodules-validate-system-headers");
 
-  Args.AddLastArg(CmdArgs, 
options::OPT_fmodules_disable_diagnostic_validation);
+Args.AddLastArg(CmdArgs,
+options::OPT_fmodules_disable_diagnostic_validation);
+  } else {
+Args.ClaimAllArgs(options::OPT_fbuild_session_timestamp);
+Args.ClaimAllArgs(options::OPT_fbuild_session_file);
+Args.ClaimAllArgs(options::OPT_fmodules_validate_once_per_build_session);
+Args.ClaimAllArgs(options::OPT_fmodules_validate_system_headers);
+Args.ClaimAllArgs(options::OPT_fno_modules_validate_system_headers);
+Args.ClaimAllArgs(options::OPT_fmodules_disable_diagnostic_validation);
+  }
 }
 
 static void RenderCharacterOptions(const ArgList , const llvm::Triple ,

diff  --git a/clang/test/Driver/modules.m b/clang/test/Driver/modules.m
index 67140926f176b..4b67f7c7bec4f 100644
--- a/clang/test/Driver/modules.m
+++ b/clang/test/Driver/modules.m
@@ -4,27 +4,27 @@
 // RUN: %clang -fmodules 

[PATCH] D128981: [C++20][Modules] Implement include translation.

2022-07-03 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a subscriber: rsmith.
ChuanqiXu added inline comments.



Comment at: clang/include/clang/Lex/Preprocessor.h:434
+/// Saw a 'module' identifier.
+void handleModule(bool ATLTS) {
+  // This was the first module identifier and not preceded by any token

What's the meaning of `ATLTS`?



Comment at: clang/lib/Lex/PPDirectives.cpp:2226-2227
+
+  // FIXME: We do not have a good way to disambiguate C++ clang modules from
+  // C++ standard modules (other than use/non-use of Header Units).
+  Module *SM = SuggestedModule.getModule();

From what @rsmith said in https://reviews.llvm.org/D113391, it looks like the 
ideal direction is to use C++ clang modules and C++ standard modules together. 
So it looks like we couldn't disambiguate them from command line options.



Comment at: clang/test/Modules/cxx20-include-translation.cpp:10
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header h4.h -emit-header-unit -o 
h4.pcm
+
+// RUN: %clang_cc1 -std=c++20 Xlate.cpp -emit-module-interface -o Xlate.pcm \

Maybe we need an example `h5.h` which is not pre-compiled  as a header unit and 
it would be handled correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128981

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


[PATCH] D129045: [C++20][Modules] Update handling of implicit inlines [P1779R3]

2022-07-03 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/AST/TextNodeDumper.cpp:1723-1725
+  if (!D->isInlineSpecified() && D->isInlined()) {
+OS << " implicit-inline";
+  }

Is this necessary to this revision?



Comment at: clang/lib/Sema/SemaDecl.cpp:9362
+  //   to the global module.
+  if (getLangOpts().CPlusPlus20 || getLangOpts().CPlusPlus2b) {
+Module *M = NewFD->getOwningModule();

If I remember correctly, when we run `-std=c++2b`, `getLangOpts().CPlusPlus20` 
would be true too. So we could check `getLangOpts().CPlusPlus20` only here.



Comment at: clang/lib/Sema/SemaDecl.cpp:9363-9365
+Module *M = NewFD->getOwningModule();
+if (!M || M->isGlobalModule())
+  NewFD->setImplicitlyInline();

nit: this is not  required.



Comment at: clang/lib/Sema/SemaDecl.cpp:9657
+  //   in its class definition, it is inline.
+  if (getLangOpts().CPlusPlus20 || getLangOpts().CPlusPlus2b) {
+Module *M = NewFD->getOwningModule();

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129045

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


[PATCH] D129057: [clang-format] Break on AfterColon only if not followed by comment

2022-07-03 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, curdeius.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Break after a constructor initializer colon only if it's not followed by a
comment on the same line.

Fixes https://github.com/llvm/llvm-project/issues/41128.
Fixes https://github.com/llvm/llvm-project/issues/43246.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129057

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7096,7 +7096,7 @@
"a(aa),\n"
"a(aa) {}",
OnePerLine);
-  verifyFormat("SomeClass::Constructor() :\n"
+  verifyFormat("SomeClass::Constructor() : // NOLINT\n"
"a(aa), // Some comment\n"
"a(aa),\n"
"a(aa) {}",
@@ -7133,6 +7133,9 @@
"// Comment forcing unwanted break.\n"
"() {}",
Style);
+  verifyFormat("Constructor() : // NOLINT\n"
+   "() {}",
+   Style);
 
   Style.ColumnLimit = 0;
   verifyFormat("SomeClass::Constructor() :\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -4734,7 +4734,7 @@
 // the first list element. Otherwise, it should be placed outside of the
 // list.
 return Left.is(BK_BracedInit) ||
-   (Left.is(TT_CtorInitializerColon) &&
+   (Left.is(TT_CtorInitializerColon) && Right.NewlinesBefore > 0 &&
 Style.BreakConstructorInitializers == 
FormatStyle::BCIS_AfterColon);
   }
   if (Left.is(tok::question) && Right.is(tok::colon))
@@ -4894,8 +4894,10 @@
   if (Right.is(tok::identifier) && Right.Next && 
Right.Next->is(TT_DictLiteral))
 return true;
 
-  if (Left.is(TT_CtorInitializerColon))
-return Style.BreakConstructorInitializers == FormatStyle::BCIS_AfterColon;
+  if (Left.is(TT_CtorInitializerColon)) {
+return Style.BreakConstructorInitializers == FormatStyle::BCIS_AfterColon 
&&
+   (!Right.isTrailingComment() || Right.NewlinesBefore > 0);
+  }
   if (Right.is(TT_CtorInitializerColon))
 return Style.BreakConstructorInitializers != FormatStyle::BCIS_AfterColon;
   if (Left.is(TT_CtorInitializerComma) &&
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -404,6 +404,7 @@
   (State.Column + State.Line->Last->TotalLength - Previous.TotalLength >
getColumnLimit(State) ||
CurrentState.BreakBeforeParameter) &&
+  (!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
   (Style.AllowShortFunctionsOnASingleLine != FormatStyle::SFS_All ||
Style.BreakConstructorInitializers != FormatStyle::BCIS_BeforeColon ||
Style.ColumnLimit != 0)) {
@@ -793,6 +794,7 @@
   (Previous.is(tok::colon) && Previous.is(TT_ObjCMethodExpr {
 CurrentState.LastSpace = State.Column;
   } else if (Previous.is(TT_CtorInitializerColon) &&
+ (!Current.isTrailingComment() || Current.NewlinesBefore > 0) &&
  Style.BreakConstructorInitializers ==
  FormatStyle::BCIS_AfterColon) {
 CurrentState.Indent = State.Column;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7096,7 +7096,7 @@
"a(aa),\n"
"a(aa) {}",
OnePerLine);
-  verifyFormat("SomeClass::Constructor() :\n"
+  verifyFormat("SomeClass::Constructor() : // NOLINT\n"
"a(aa), // Some comment\n"
"a(aa),\n"
"a(aa) {}",
@@ -7133,6 +7133,9 @@
"// Comment forcing unwanted break.\n"
"() {}",
Style);
+  verifyFormat("Constructor() : // NOLINT\n"
+   "() {}",
+   Style);
 
   Style.ColumnLimit = 0;
   verifyFormat("SomeClass::Constructor() :\n"
Index: clang/lib/Format/TokenAnnotator.cpp

[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-03 Thread Richard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf7a80c3d08d4: [clang-tidy] Properly forward clang-tidy 
output when running tests (authored by nicovank, committed by 
LegalizeAdulthood).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-
print('\n--')
+print(clang_tidy_output.encode(sys.stdout.encoding, 
errors="replace").decode(sys.stdout.encoding))
+print('--')
 
 diff_output = try_run(['diff', '-u', self.original_file_name, 
self.temp_file_name], False)
-print('-- Fixes 
-\n' +
-  diff_output +
-  
'\n--')
+print('-- Fixes -')
+print(diff_output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-print('\n--')
+print(clang_tidy_output.encode(sys.stdout.encoding, errors="replace").decode(sys.stdout.encoding))
+print('--')
 
 diff_output = try_run(['diff', '-u', self.original_file_name, self.temp_file_name], False)
-print('-- Fixes -\n' +
-  diff_output +
-  '\n--')
+print('-- Fixes -')
+print(diff_output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] f7a80c3 - [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-03 Thread via cfe-commits

Author: Nicolas van Kempen
Date: 2022-07-03T16:30:17-06:00
New Revision: f7a80c3d08d4821e621fc88d6a2e435291f82dff

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

LOG: [clang-tidy] Properly forward clang-tidy output when running tests

When running tests, the check_clang_tidy script encodes the output
string, making it hard to read when debugging checks. This removes the
.encode() call.

Test Plan:
Making a new default check for testing (as of right now, it includes a
failing test):

[~/llvm-project/clang-tools-extra] python3 clang-tidy/add_new_check.py
bugprone example
<...>
Pre-changes:

[~/llvm-project/build] ninja check-clang-tools
<...>
 clang-tidy output ---
b"1 warning
generated.\n/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
warning: function 'f' is insufficiently awesome [bugprone-example]\nvoid
f();\n
^\n/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
note: insert 'awesome'\nvoid f();\n ^\n awesome_\n"

--
<...>
Post-changes:

[~/llvm-project/build] ninja check-clang-tools
<...>
 clang-tidy output ---
1 warning generated.
/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
warning: function 'f' is insufficiently awesome [bugprone-example]
void f();
 ^
/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
note: insert 'awesome'
void f();
 ^
 awesome_

--
<...>

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

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/check_clang_tidy.py

Removed: 




diff  --git a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py 
b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
index 4ce6cd4e65de8..760550abd41bc 100755
--- a/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ b/clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@ def run_clang_tidy(self):
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-
print('\n--')
+print(clang_tidy_output.encode(sys.stdout.encoding, 
errors="replace").decode(sys.stdout.encoding))
+print('--')
 
 
diff _output = try_run(['
diff ', '-u', self.original_file_name, self.temp_file_name], False)
-print('-- Fixes 
-\n' +
-  
diff _output +
-  
'\n--')
+print('-- Fixes -')
+print(
diff _output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):



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


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-03 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

I will submit it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-07-03 Thread Richard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa65a3bffd31f: [clang-tidy] Dont treat invalid branches 
as identical (authored by ishaangandhi, committed by LegalizeAdulthood).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128402

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s bugprone-branch-clone %t
+
+int test_unknown_expression() {
+  if (unknown_expression_1) {// CHECK-MESSAGES: :[[@LINE]]:7: error: 
use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error]
+function1(unknown_expression_2); // CHECK-MESSAGES: :[[@LINE]]:15: error: 
use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error]
+  } else {
+function2(unknown_expression_3); // CHECK-MESSAGES: :[[@LINE]]:15: error: 
use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error]
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -158,6 +158,10 @@
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed a false positive in :doc:`bugprone-branch-clone
+  ` when the branches
+  involve unknown expressions.
+
 - Fixed some false positives in :doc:`bugprone-infinite-loop
   ` involving dependent expressions.
 
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -19,6 +19,17 @@
 /// Returns true when the statements are Type I clones of each other.
 static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
const ASTContext ) {
+  if (isa(LHS) && isa(RHS)) {
+// If we have errors in expressions, we will be unable
+// to accurately profile and compute hashes for each
+// of the left and right statements.
+const auto *LHSExpr = llvm::cast(LHS);
+const auto *RHSExpr = llvm::cast(RHS);
+if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
+  return false;
+}
+  }
+
   llvm::FoldingSetNodeID DataLHS, DataRHS;
   LHS->Profile(DataLHS, Context, false);
   RHS->Profile(DataRHS, Context, false);


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s bugprone-branch-clone %t
+
+int test_unknown_expression() {
+  if (unknown_expression_1) {// CHECK-MESSAGES: :[[@LINE]]:7: error: use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error]
+function1(unknown_expression_2); // CHECK-MESSAGES: :[[@LINE]]:15: error: use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error]
+  } else {
+function2(unknown_expression_3); // CHECK-MESSAGES: :[[@LINE]]:15: error: use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error]
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -158,6 +158,10 @@
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed a false positive in :doc:`bugprone-branch-clone
+  ` when the branches
+  involve unknown expressions.
+
 - Fixed some false positives in :doc:`bugprone-infinite-loop
   ` involving dependent expressions.
 
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -19,6 +19,17 @@
 /// Returns true when the statements are Type I clones of each other.
 static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
const ASTContext ) {
+  if (isa(LHS) && isa(RHS)) {
+// If we have errors in expressions, we will be unable
+// to accurately profile and compute hashes 

[clang-tools-extra] a65a3bf - [clang-tidy] Don't treat invalid branches as identical

2022-07-03 Thread via cfe-commits

Author: Ishaan Gandhi
Date: 2022-07-03T15:50:33-06:00
New Revision: a65a3bffd31f57243929b0f50abbd90bd626faee

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

LOG: [clang-tidy] Don't treat invalid branches as identical

The clang-tidy check bugprone-branch-clone has a false positive if some
symbols are undefined. This patch silences the warning when the two
sides of a branch are invalid.

Fixes #56057

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index f5f418b139560..5bc35aa6918d9 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -19,6 +19,17 @@ using namespace clang::ast_matchers;
 /// Returns true when the statements are Type I clones of each other.
 static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
const ASTContext ) {
+  if (isa(LHS) && isa(RHS)) {
+// If we have errors in expressions, we will be unable
+// to accurately profile and compute hashes for each
+// of the left and right statements.
+const auto *LHSExpr = llvm::cast(LHS);
+const auto *RHSExpr = llvm::cast(RHS);
+if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
+  return false;
+}
+  }
+
   llvm::FoldingSetNodeID DataLHS, DataRHS;
   LHS->Profile(DataLHS, Context, false);
   RHS->Profile(DataRHS, Context, false);

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index f148884e90c5d..e6d9a57dccea6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -158,6 +158,10 @@ Changes in existing checks
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed a false positive in :doc:`bugprone-branch-clone
+  ` when the branches
+  involve unknown expressions.
+
 - Fixed some false positives in :doc:`bugprone-infinite-loop
   ` involving dependent expressions.
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
new file mode 100644
index 0..d2641523750c9
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s bugprone-branch-clone %t
+
+int test_unknown_expression() {
+  if (unknown_expression_1) {// CHECK-MESSAGES: :[[@LINE]]:7: error: 
use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error]
+function1(unknown_expression_2); // CHECK-MESSAGES: :[[@LINE]]:15: error: 
use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error]
+  } else {
+function2(unknown_expression_3); // CHECK-MESSAGES: :[[@LINE]]:15: error: 
use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error]
+  }
+}



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


[PATCH] D129049: [clang] Fix gcc-6 compilation error. (NFC)

2022-07-03 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

thanks
I will retrigger the CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129049

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


[PATCH] D129049: [clang] Fix gcc-6 compilation error. (NFC)

2022-07-03 Thread Sunho Kim via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG134363208b92: [clang] Fix gcc-6 compilation error. (NFC) 
(authored by sunho).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129049

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -496,7 +496,7 @@
 
 template 
 const RecordType *ByteCodeExprGen::getRecordTy(QualType Ty) {
-  if (auto *PT = dyn_cast(Ty))
+  if (const PointerType *PT = dyn_cast(Ty))
 return PT->getPointeeType()->getAs();
   else
 return Ty->getAs();


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -496,7 +496,7 @@
 
 template 
 const RecordType *ByteCodeExprGen::getRecordTy(QualType Ty) {
-  if (auto *PT = dyn_cast(Ty))
+  if (const PointerType *PT = dyn_cast(Ty))
 return PT->getPointeeType()->getAs();
   else
 return Ty->getAs();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1343632 - [clang] Fix gcc-6 compilation error. (NFC)

2022-07-03 Thread Sunho Kim via cfe-commits

Author: Sunho Kim
Date: 2022-07-04T05:33:05+09:00
New Revision: 134363208b9272a967c911f7b56c255a72a6f0a0

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

LOG: [clang] Fix gcc-6 compilation error. (NFC)

Fix https://github.com/llvm/llvm-project/issues/55626.

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index da538aa332ffc..9b729e347a245 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -496,7 +496,7 @@ ByteCodeExprGen::getGlobalIdx(const VarDecl *VD) {
 
 template 
 const RecordType *ByteCodeExprGen::getRecordTy(QualType Ty) {
-  if (auto *PT = dyn_cast(Ty))
+  if (const PointerType *PT = dyn_cast(Ty))
 return PT->getPointeeType()->getAs();
   else
 return Ty->getAs();



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


[PATCH] D129050: [clang-format] Update documentation

2022-07-03 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang/docs/ClangFormat.rst:233
 
 Script for patch reformatting
 =

(As far as I can tell, we don't have `git clang-format` docs anywhere? But 
that's for a different patch.)


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

https://reviews.llvm.org/D129050

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


[PATCH] D129030: [Driver] Ignore the clang modules validation-related flags if clang modules are not enabled

2022-07-03 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129030

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


[PATCH] D129050: [clang-format] Update documentation

2022-07-03 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added reviewers: MyDeveloperDay, curdeius.
Herald added a project: All.
thakis requested review of this revision.

- Update `clang-format --help` output after b1f0efc06acc 
.
- Update `clang-format-diff.py` help text, which apparently hasn't been updated 
in a while. Since git and svn examples are now part of the help text, remove 
them in the text following the help text.


https://reviews.llvm.org/D129050

Files:
  clang/docs/ClangFormat.rst

Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -17,7 +17,7 @@
 
 .. code-block:: console
 
-  $ clang-format -help
+  $ clang-format --help
   OVERVIEW: A tool to format C/C++/Java/JavaScript/JSON/Objective-C/Protobuf/C# code.
 
   If no arguments are specified, it formats the code from standard input
@@ -40,9 +40,11 @@
Use with caution, as this might lead to dramatically
differing format depending on an option being
supported or not.
---assume-filename= - Override filename used to determine the language.
- When reading from stdin, clang-format assumes this
- filename to determine the language.
+--assume-filename= - Set filename used to determine the language and to find
+ .clang-format file.
+ Only used when reading from stdin.
+ If this is not passed, the .clang-format file is searched
+ relative to the current working directory when reading stdin.
  Unrecognized filenames are treated as C++.
  supported:
CSharp: .cs
@@ -62,7 +64,7 @@
 --fallback-style=  - The name of the predefined style used as a
  fallback in case clang-format is invoked with
  -style=file, but can not find the .clang-format
- file to use.
+ file to use. Defaults to 'LLVM'.
  Use -fallback-style=none to skip formatting.
 --ferror-limit=  - Set the maximum number of clang-format errors to emit
  before stopping (0 = no limit).
@@ -92,17 +94,19 @@
  determined by the QualifierAlignment style flag
 --sort-includes- If set, overrides the include sorting behavior
  determined by the SortIncludes style flag
---style=   - Coding style, currently supports:
-   LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.
- Use -style=file to load style configuration from
- .clang-format file located in one of the parent
- directories of the source file (or current
- directory for stdin).
- Use -style=file: to explicitly specify
- the configuration file.
- Use -style="{key: value, ...}" to set specific
- parameters, e.g.:
-   -style="{BasedOnStyle: llvm, IndentWidth: 8}"
+--style=   - Set coding style.  can be:
+ 1. A preset: LLVM, GNU, Google, Chromium, Microsoft,
+Mozilla, WebKit.
+ 2. 'file' to load style configuration from a
+.clang-format file in one of the parent directories
+of the source file (for stdin, see --assume-filename).
+If no .clang-format file is found, falls back to
+--fallback-style.
+--style=file is the default.
+ 3. 'file:' to explicitly specify
+the configuration file.
+ 4. "{key: value, ...}" to set specific parameters, e.g.:
+--style="{BasedOnStyle: llvm, IndentWidth: 8}"
 --verbose  - If set, shows the list of processed files
 
   Generic Options:
@@ -235,37 +239,41 @@
 
 .. code-block:: console
 
-  usage: 

[PATCH] D128984: [clang-format] Tweak help text a bit

2022-07-03 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1f0efc06acc: [clang-format] Tweak help text a bit (authored 
by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128984

Files:
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -70,16 +70,18 @@
   cl::desc("The name of the predefined style used as a\n"
"fallback in case clang-format is invoked with\n"
"-style=file, but can not find the .clang-format\n"
-   "file to use.\n"
+   "file to use. Defaults to 'LLVM'.\n"
"Use -fallback-style=none to skip formatting."),
   cl::init(clang::format::DefaultFallbackStyle),
   cl::cat(ClangFormatCategory));
 
 static cl::opt AssumeFileName(
 "assume-filename",
-cl::desc("Override filename used to determine the language.\n"
- "When reading from stdin, clang-format assumes this\n"
- "filename to determine the language.\n"
+cl::desc("Set filename used to determine the language and to find\n"
+ ".clang-format file.\n"
+ "Only used when reading from stdin.\n"
+ "If this is not passed, the .clang-format file is searched\n"
+ "relative to the current working directory when reading stdin.\n"
  "Unrecognized filenames are treated as C++.\n"
  "supported:\n"
  "  CSharp: .cs\n"
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3433,17 +3433,19 @@
 }
 
 const char *StyleOptionHelpDescription =
-"Coding style, currently supports:\n"
-"  LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.\n"
-"Use -style=file to load style configuration from\n"
-".clang-format file located in one of the parent\n"
-"directories of the source file (or current\n"
-"directory for stdin).\n"
-"Use -style=file: to explicitly specify\n"
-"the configuration file.\n"
-"Use -style=\"{key: value, ...}\" to set specific\n"
-"parameters, e.g.:\n"
-"  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
+"Set coding style.  can be:\n"
+"1. A preset: LLVM, GNU, Google, Chromium, Microsoft,\n"
+"   Mozilla, WebKit.\n"
+"2. 'file' to load style configuration from a\n"
+"   .clang-format file in one of the parent directories\n"
+"   of the source file (for stdin, see --assume-filename).\n"
+"   If no .clang-format file is found, falls back to\n"
+"   --fallback-style.\n"
+"   --style=file is the default.\n"
+"3. 'file:' to explicitly specify\n"
+"   the configuration file.\n"
+"4. \"{key: value, ...}\" to set specific parameters, e.g.:\n"
+"   --style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
 
 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
   if (FileName.endswith(".java"))
@@ -3498,6 +3500,7 @@
   return GuessedLanguage;
 }
 
+// Update StyleOptionHelpDescription above when changing this.
 const char *DefaultFormatStyle = "file";
 
 const char *DefaultFallbackStyle = "LLVM";


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -70,16 +70,18 @@
   cl::desc("The name of the predefined style used as a\n"
"fallback in case clang-format is invoked with\n"
"-style=file, but can not find the .clang-format\n"
-   "file to use.\n"
+   "file to use. Defaults to 'LLVM'.\n"
"Use -fallback-style=none to skip formatting."),
   cl::init(clang::format::DefaultFallbackStyle),
   cl::cat(ClangFormatCategory));
 
 static cl::opt AssumeFileName(
 "assume-filename",
-cl::desc("Override filename used to determine the language.\n"
- "When reading from stdin, clang-format assumes this\n"
- "filename to determine the language.\n"
+cl::desc("Set filename used to determine the language and to find\n"
+ ".clang-format file.\n"
+ "Only used when reading from stdin.\n"
+ "If this is not passed, the .clang-format file is searched\n"
+ "relative to the current working directory when reading stdin.\n"
  "Unrecognized filenames are 

[clang] b1f0efc - [clang-format] Tweak help text a bit

2022-07-03 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-07-03T21:54:14+02:00
New Revision: b1f0efc06acc27ea07632452d9cf50eb7cc0c7f1

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

LOG: [clang-format] Tweak help text a bit

In particular, make it clear that `--style=file` is the default,
since there's some confusion about this, e.g. here:
https://stackoverflow.com/questions/61455148/

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 51526dc2a6817..9ce75b66bdc93 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3433,17 +3433,19 @@ LangOptions getFormattingLangOpts(const FormatStyle 
) {
 }
 
 const char *StyleOptionHelpDescription =
-"Coding style, currently supports:\n"
-"  LLVM, GNU, Google, Chromium, Microsoft, Mozilla, WebKit.\n"
-"Use -style=file to load style configuration from\n"
-".clang-format file located in one of the parent\n"
-"directories of the source file (or current\n"
-"directory for stdin).\n"
-"Use -style=file: to explicitly specify\n"
-"the configuration file.\n"
-"Use -style=\"{key: value, ...}\" to set specific\n"
-"parameters, e.g.:\n"
-"  -style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
+"Set coding style.  can be:\n"
+"1. A preset: LLVM, GNU, Google, Chromium, Microsoft,\n"
+"   Mozilla, WebKit.\n"
+"2. 'file' to load style configuration from a\n"
+"   .clang-format file in one of the parent directories\n"
+"   of the source file (for stdin, see --assume-filename).\n"
+"   If no .clang-format file is found, falls back to\n"
+"   --fallback-style.\n"
+"   --style=file is the default.\n"
+"3. 'file:' to explicitly specify\n"
+"   the configuration file.\n"
+"4. \"{key: value, ...}\" to set specific parameters, e.g.:\n"
+"   --style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
 
 static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
   if (FileName.endswith(".java"))
@@ -3498,6 +3500,7 @@ FormatStyle::LanguageKind guessLanguage(StringRef 
FileName, StringRef Code) {
   return GuessedLanguage;
 }
 
+// Update StyleOptionHelpDescription above when changing this.
 const char *DefaultFormatStyle = "file";
 
 const char *DefaultFallbackStyle = "LLVM";

diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index 07110a0db0916..946ba131f6dc9 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -70,16 +70,18 @@ static cl::opt
   cl::desc("The name of the predefined style used as a\n"
"fallback in case clang-format is invoked with\n"
"-style=file, but can not find the .clang-format\n"
-   "file to use.\n"
+   "file to use. Defaults to 'LLVM'.\n"
"Use -fallback-style=none to skip formatting."),
   cl::init(clang::format::DefaultFallbackStyle),
   cl::cat(ClangFormatCategory));
 
 static cl::opt AssumeFileName(
 "assume-filename",
-cl::desc("Override filename used to determine the language.\n"
- "When reading from stdin, clang-format assumes this\n"
- "filename to determine the language.\n"
+cl::desc("Set filename used to determine the language and to find\n"
+ ".clang-format file.\n"
+ "Only used when reading from stdin.\n"
+ "If this is not passed, the .clang-format file is searched\n"
+ "relative to the current working directory when reading stdin.\n"
  "Unrecognized filenames are treated as C++.\n"
  "supported:\n"
  "  CSharp: .cs\n"



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


[PATCH] D128625: [RISCV][Driver] Fix baremetal `GCCInstallation` paths

2022-07-03 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/Driver/ToolChains/RISCVToolchain.cpp:54
+
+  // Set alias for "riscv{64|32}-unknown-unknown-elf"
+  SmallVector TripleAliases;

anton-afanasyev wrote:
> arichardson wrote:
> > This seems like the wrong place to add this workaround, shouldn't the 
> > change be in `GCCInstallation::init`? That way targets other than RISC-V 
> > also benefit from this fix.
> > 
> `GCCInstallation` knows nothing about triple equivalence of the specific 
> targets, but provides `TripleAliases` init variable for installation target 
> callers. Other targets are to do the same initialization as we do here in 
> case of different normalized and layout-used triple names.
What I was trying to say is that the normalization adding `-unknown` affects 
all targets, so maybe `GCCInstallation::init()` should add aliases that have 
the `-unknown` components removed rather than doing this at the call site. This 
way the alias computation does not need to be moved to each target info.

However, I also think we should be passing through the triple as passed to 
--target= rather than the normalized triple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128625

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


[PATCH] D128757: [Driver][test] Add -fuse-ld= option tests for NetBSD

2022-07-03 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus added a comment.

In D128757#3616795 , @MaskRay wrote:

> I am unsure it is useful to add a test for all OSxfuse_ld_value combinations, 
> especially for an ELF OS like NetBSD which shares many characteristics with 
> other ELF OSes. It will be overwhelming.
> The option may be better added in a netbsd specific file.

I noticed there is a `fuse-ld-windows.c` file with some tests, so would putting 
NetBSD ones in a new `fuse-ld-netbsd.c` file make sense?

Either way, I don't have any strong opinion on this. I can also drop the 
revision if those tests do not seem useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128757

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-03 Thread Muhammad Usman Shahid via Phabricator via cfe-commits
Codesbyusman created this revision.
Codesbyusman added reviewers: aaron.ballman, erichkeane, xgupta.
Herald added a project: All.
Codesbyusman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rewording the failing of _Satic_assert to the better word "static assertion"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129048

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/drs/dr19xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/module/module.interface/p3.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
  clang/test/Modules/cxx20-10-2-ex7.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/PCH/cxx-templates.cpp
  clang/test/Parser/objc-static-assert.m
  clang/test/Parser/objc-static-assert.mm
  clang/test/Sema/builtin-align.c
  clang/test/Sema/sizeless-1.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/access-base-class.cpp
  clang/test/SemaCXX/alias-template.cpp
  clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/complex-folding.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx2a-template-lambdas.cpp
  clang/test/SemaCXX/cxx98-compat.cpp
  clang/test/SemaCXX/delete-and-function-templates.cpp
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/static-assert-cxx17.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/test/SemaCXX/using-decl-templates.cpp
  clang/test/SemaCXX/weak-init.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/pr52909.cpp
  clang/test/SemaTemplate/pr52970.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp

Index: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -184,7 +184,7 @@
 
 namespace Diags {
   struct A { int n, m; };
-  template struct X { static_assert(a.n == a.m); }; // expected-error {{static_assert failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
+  template struct X { static_assert(a.n == a.m); }; // expected-error {{static assertion failed due to requirement 'Diags::A{1, 2}.n == Diags::A{1, 2}.m'}}
   template struct X; // expected-note {{in instantiation of template class 'Diags::X<{1, 2}>' requested here}}
 }
 
Index: clang/test/SemaTemplate/pr52970.cpp
===
--- clang/test/SemaTemplate/pr52970.cpp
+++ clang/test/SemaTemplate/pr52970.cpp
@@ -32,7 +32,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingFunctionName::Bad' does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingFunctionName
@@ -57,7 +57,7 @@
 
 static_assert(C);
 static_assert(!C);
-static_assert(C); // cxx20-error {{static_assert failed}}
+static_assert(C); // cxx20-error {{static assertion failed}}
   // cxx20-note@-1 {{because 'DotFollowingPointer::Bad' (aka 'Holder *') does not satisfy 'C'}}
 #endif
 } // namespace DotFollowingPointer
Index: clang/test/SemaTemplate/pr52909.cpp
===
--- clang/test/SemaTemplate/pr52909.cpp
+++ clang/test/SemaTemplate/pr52909.cpp
@@ -15,7 +15,7 @@
   // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
 };
 
-static_assert(Beginable); // expected-error {{static_assert failed}}
+static_assert(Beginable); // expected-error {{static assertion failed}}
  // expected-note@-1 {{does not satisfy 'Beginable'}}
 } // namespace PR52905
 
@@ -48,7 +48,7 @@
 static void begin(double);
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
 
 } // namespace PR52909b
@@ -65,7 +65,7 @@
 int *f() const;
 };
 
-static_assert(C); // expected-error {{static_assert failed}}
+static_assert(C); // expected-error {{static assertion failed}}
   // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
 
 } // namespace PR53075
Index: clang/test/SemaTemplate/instantiate-var-template.cpp

[PATCH] D111081: [clang] [MinGW] Fix paths on Gentoo

2022-07-03 Thread Mark Harmstone via Phabricator via cfe-commits
maharmstone updated this revision to Diff 441952.
maharmstone added a comment.

Rebased patch against current upstream


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

https://reviews.llvm.org/D111081

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/MinGW.h
  clang/test/Driver/mingw-sysroot.cpp
  clang/test/Driver/mingw.cpp

Index: clang/test/Driver/mingw.cpp
===
--- clang/test/Driver/mingw.cpp
+++ clang/test/Driver/mingw.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang -target i686-windows-gnu -rtlib=platform -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE %s
 // CHECK_MINGW_CLANG_TREE: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include"
+// CHECK_MINGW_CLANG_TREE: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}usr{{/|}}include"
 // CHECK_MINGW_CLANG_TREE: "[[BASE]]/Inputs/mingw_clang_tree/mingw32{{/|}}include"
 
 
Index: clang/test/Driver/mingw-sysroot.cpp
===
--- clang/test/Driver/mingw-sysroot.cpp
+++ clang/test/Driver/mingw-sysroot.cpp
@@ -22,6 +22,9 @@
 // CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE:[^"]+]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32"
 // CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}backward"
+// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10.2-posix"
+// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10.2"
+// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}g++-v10"
 // CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include"
 
 
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -103,6 +103,7 @@
 
   std::string Base;
   std::string GccLibDir;
+  clang::driver::toolchains::Generic_GCC::GCCVersion GccVer;
   std::string Ver;
   std::string SubdirName;
   mutable std::unique_ptr Preprocessor;
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -339,8 +339,9 @@
 
 // Simplified from Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple.
 static bool findGccVersion(StringRef LibDir, std::string ,
-   std::string ) {
-  auto Version = toolchains::Generic_GCC::GCCVersion::Parse("0.0.0");
+   std::string ,
+   toolchains::Generic_GCC::GCCVersion ) {
+  Version = toolchains::Generic_GCC::GCCVersion::Parse("0.0.0");
   std::error_code EC;
   for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
LI = LI.increment(EC)) {
@@ -371,7 +372,7 @@
 for (StringRef CandidateSysroot : SubdirNames) {
   llvm::SmallString<1024> LibDir(Base);
   llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot);
-  if (findGccVersion(LibDir, GccLibDir, Ver)) {
+  if (findGccVersion(LibDir, GccLibDir, Ver, GccVer)) {
 SubdirName = std::string(CandidateSysroot);
 return;
   }
@@ -438,6 +439,11 @@
   getFilePaths().push_back(GccLibDir);
   getFilePaths().push_back(
   (Base + SubdirName + llvm::sys::path::get_separator() + "lib").str());
+
+  // Gentoo
+  getFilePaths().push_back(
+  (Base + SubdirName + llvm::sys::path::get_separator() + "mingw/lib").str());
+
   getFilePaths().push_back(Base + "lib");
   // openSUSE
   getFilePaths().push_back(Base + SubdirName + "/sys-root/mingw/lib");
@@ -593,6 +599,11 @@
   addSystemInclude(DriverArgs, CC1Args,
Base + SubdirName + llvm::sys::path::get_separator() +
"include");
+
+  // Gentoo
+  addSystemInclude(DriverArgs, CC1Args,
+   Base + SubdirName + llvm::sys::path::get_separator() + "usr/include");
+
   addSystemInclude(DriverArgs, CC1Args, Base + "include");
 }
 
@@ -620,7 +631,7 @@
   }
 
   case ToolChain::CST_Libstdcxx:
-

[PATCH] D129045: [C++20][Modules] Update handling of implicit inlines [P1779R3]

2022-07-03 Thread Iain Sandoe via Phabricator via cfe-commits
iains created this revision.
Herald added a project: All.
iains added reviewers: urnathan, ChuanqiXu.
iains added a subscriber: clang-modules.
iains published this revision for review.
iains added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

the other provisions of P1779  are handled 
elsewhere:

1. private module fragment (which is also under discussion in core) and
2. implicit inline status for constexpr/consteval which has been implemented 
elsewhere (and is not modules-dependent).


This provides updates to
[class.mfct]:
Pre C++20 [class.mfct]p2:

  A member function may be defined (8.4) in its class definition, in
  which case it is an inline member function (7.1.2)

Post C++20 [class.mfct]p1:

  If a member function is attached to the global module and is defined
  in its class definition, it is inline.

and
[class.friend]:
Pre-C++20 [class.friend]p5

  A function can be defined in a friend declaration of a
  class . . . . Such a function is implicitly inline.

Post C++20 [class.friend]p7

  Such a function is implicitly an inline function if it is attached
  to the global module.

We add the output of implicit-inline to the TextNodeDumper, and amend
a couple of existing tests to account for this, plus add tests for the
cases covered above.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129045

Files:
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-constant-expr.cpp
  clang/test/AST/ast-dump-lambda.cpp
  clang/test/CXX/class/class.friend/p7-cxx20.cpp
  clang/test/CXX/class/class.mfct/p1-cxx20.cpp

Index: clang/test/CXX/class/class.mfct/p1-cxx20.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.mfct/p1-cxx20.cpp
@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 no-modules.cpp -fsyntax-only -ast-dump | \
+// RUN: FileCheck --match-full-lines --check-prefix=CHECK-NM %s
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header header-unit.h -ast-dump | \
+// RUN: FileCheck --match-full-lines --check-prefix=CHECK-HU %s
+// RUN: %clang_cc1 -std=c++20 module.cpp -ast-dump | \
+// RUN: FileCheck --match-full-lines --check-prefix=CHECK-MOD %s
+
+//--- no-modules.cpp
+
+class X {
+  void x(){};
+};
+
+// CHECK-NM: `-CXXRecordDecl {{.*}}  line:2:7 class X definition
+// CHECK-NM:   |-CXXRecordDecl {{.*}}  col:7 implicit class X
+// CHECK-NM-NEXT: `-CXXMethodDecl {{.*}}  col:8 x 'void ()' implicit-inline
+
+//--- header-unit.h
+
+class Y {
+  void y(){};
+};
+
+// CHECK-HU: `-CXXRecordDecl {{.*}} <./header-unit.h:2:1, line:4:1> line:2:7 class Y definition
+// CHECK-HU: |-CXXRecordDecl {{.*}}  col:7 implicit class Y
+// CHECK-HU-NEXT: `-CXXMethodDecl {{.*}}  col:8 y 'void ()' implicit-inline
+
+//--- module.cpp
+export module M;
+
+class Z {
+  void z(){};
+};
+
+// CHECK-MOD: `-CXXRecordDecl {{.*}}  line:3:7 in M hidden class Z{{( ReachableWhenImported)?}} definition
+// CHECK-MOD: |-CXXRecordDecl {{.*}}  col:7 in M hidden implicit class Z{{( ReachableWhenImported)?}}
+// CHECK-MOD-NEXT: `-CXXMethodDecl {{.*}}  col:8 in M hidden z 'void ()'{{( ReachableWhenImported)?}}
Index: clang/test/CXX/class/class.friend/p7-cxx20.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.friend/p7-cxx20.cpp
@@ -0,0 +1,45 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 no-modules.cpp -fsyntax-only -ast-dump | \
+// RUN: FileCheck --match-full-lines --check-prefix=CHECK-NM %s
+// RUN: %clang_cc1 -std=c++20 -xc++-user-header header-unit.h -ast-dump | \
+// RUN: FileCheck --match-full-lines --check-prefix=CHECK-HU %s
+// RUN: %clang_cc1 -std=c++20 module.cpp -ast-dump | \
+// RUN: FileCheck --match-full-lines --check-prefix=CHECK-MOD %s
+
+//--- no-modules.cpp
+
+class X {
+  friend void x(){};
+};
+
+// CHECK-NM: `-CXXRecordDecl {{.*}}  line:2:7 class X definition
+// CHECK-NM:   |-CXXRecordDecl {{.*}}  col:7 implicit class X
+// CHECK-NM-NEXT: `-FriendDecl {{.*}}  col:15
+// CHECK-NM-NEXT: `-FunctionDecl {{.*}} parent {{.*}}  col:15 x 'void ()' implicit-inline
+
+//--- header-unit.h
+
+class Y {
+  friend void y(){};
+};
+
+// CHECK-HU: `-CXXRecordDecl {{.*}} <./header-unit.h:2:1, line:4:1> line:2:7 class Y definition
+// CHECK-HU: |-CXXRecordDecl {{.*}}  col:7 implicit class Y
+// CHECK-HU-NEXT: `-FriendDecl {{.*}}  col:15
+// CHECK-HU-NEXT: `-FunctionDecl {{.*}} parent {{.*}}  col:15 y 'void ()' implicit-inline
+
+//--- module.cpp
+export module M;
+
+class Z {
+  friend void z(){};
+};
+
+// CHECK-MOD: `-CXXRecordDecl {{.*}}  line:3:7 in M hidden class Z{{( ReachableWhenImported)?}} definition
+// CHECK-MOD: |-CXXRecordDecl {{.*}}  col:7 in M hidden implicit class Z{{( ReachableWhenImported)?}}
+// CHECK-MOD-NEXT: `-FriendDecl 

[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-07-03 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson requested changes to this revision.
royjacobson added a comment.
This revision now requires changes to proceed.

Thanks for working on this! I like the approach, but two comments:

I would like more tests for the different forms of template argument deduction. 
Some suggestions for things to test: template template arguments, 'auto' in 
abbreviated function templates, argument packs, non-type template parameters. 
We should at least test that we find the more constrained function when the 
parameters are equal.

I'm also a bit concerned that we're deviating from the standard here w.r.t. to 
the 'reordering' checks for reversed candidates. I support this - I think your 
version makes more sense than what the standard says to do here - but if 
someone could check with the committee (I don't have reflector access myself) 
that we're not breaking some important use case by doing it this way, I think 
it's a good idea.




Comment at: clang/docs/ReleaseNotes.rst:134-138
 - Overload resolution for constrained function templates could use the partial
   order of constraints to select an overload, even if the parameter types of
   the functions were different. It now diagnoses this case correctly as an
   ambiguous call and an error. Fixes
   `Issue 53640 `_.

You can remove this bullet from when I partially implemented this paper :)



Comment at: clang/lib/Sema/SemaTemplate.cpp:7810
+   TemplateParameterList *Old) {
+  SmallVector IterIdxs(Old->size());
+  std::iota(IterIdxs.begin(), IterIdxs.end(), 0);

Consider adding



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5119
-  while (--NumParams > 0) {
-if (Function->getParamDecl(NumParams - 1)->isParameterPack())
-  return false;

Curious, why was this removed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D129043: [RISCV][Clang] Teach RISCVEmitter to generate BitCast for pointer operands.

2022-07-03 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 441943.
fakepaper56 added a comment.

Align output code in riscv_vector_builtin_cg.inc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129043

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -105,6 +105,16 @@
 return;
   }
 
+  // Cast pointer operand of vector load intrinsic.
+  for (const auto  : enumerate(RVVI->getInputTypes())) {
+if (I.value()->isPointer()) {
+  assert(RVVI->getIntrinsicTypes().front() == -1 &&
+ "RVVI should be vector load intrinsic.");
+  OS << "  Ops[" << I.index() << "] = Builder.CreateBitCast(Ops[";
+  OS << I.index() << "], ResultType->getPointerTo());\n";
+}
+  }
+
   if (RVVI->isMasked()) {
 if (RVVI->hasVL()) {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n";
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -225,6 +225,8 @@
 return isFloat() && ElementBitwidth == Width;
   }
 
+  bool isPointer() const { return IsPointer; }
+
 private:
   // Verify RVV vector type and set Valid.
   bool verifyType() const;
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -582,18 +582,8 @@
 }
 
 let HasUnMaskedOverloaded = false,
-MaskedPolicy = NonePolicy,
-ManualCodegen = [{
-  IntrinsicTypes = {ResultType, Ops[1]->getType()};
-  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
-}],
-MaskedManualCodegen= [{
-  // Move mask to right before vl.
-  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-  IntrinsicTypes = {ResultType, Ops[3]->getType()};
-  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-}] in {
-  class RVVVLEMaskBuiltin : RVVBuiltin<"m", "mPCUe", "c"> {
+MaskedPolicy = NonePolicy in {
+  class RVVVLEMaskBuiltin : RVVOutBuiltin<"m", "mPCUe", "c"> {
 let Name = "vlm_v";
 let IRName = "vlm";
 let HasMasked = false;
@@ -601,26 +591,15 @@
 }
 
 let HasUnMaskedOverloaded = false,
-ManualCodegen = [{
-  IntrinsicTypes = {ResultType, Ops[1]->getType()};
-  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
-  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));
-}],
-MaskedManualCodegen= [{
-  // Move mask to right before vl.
-  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-  Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED));
-  IntrinsicTypes = {ResultType, Ops[3]->getType()};
-  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-}] in {
+UnMaskedPolicy = HasPassthruOperand in {
   multiclass RVVVLEBuiltin types> {
 let Name = NAME # "_v",
 IRName = "vle",
 MaskedIRName ="vle_mask" in {
   foreach type = types in {
-def : RVVBuiltin<"v", "vPCe", type>;
+def : RVVOutBuiltin<"v", "vPCe", type>;
 if !not(IsFloat.val) then {
-  def : RVVBuiltin<"Uv", "UvPCUe", type>;
+  def : RVVOutBuiltin<"Uv", "UvPCUe", type>;
 }
   }
 }
@@ -685,61 +664,39 @@
   IRName = "vlse",
   MaskedIRName ="vlse_mask",
   HasUnMaskedOverloaded = false,
-  ManualCodegen = [{
-IntrinsicTypes = {ResultType, Ops[2]->getType()};
-Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
-Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));
-  }],
-  MaskedManualCodegen= [{
-// Move mask to right before vl.
-std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED));
-IntrinsicTypes = {ResultType, Ops[4]->getType()};
-Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-  }] in {
+  UnMaskedPolicy = HasPassthruOperand in {
 foreach type = types in {
-  def : RVVBuiltin<"v", "vPCet", type>;
+  def : RVVOutBuiltin<"v", "vPCet", type>;
   if !not(IsFloat.val) then {
-def : RVVBuiltin<"Uv", "UvPCUet", type>;
+def : RVVOutBuiltin<"Uv", "UvPCUet", type>;
   }
 }
   }
 }
 
 multiclass RVVIndexedLoad {
-  let ManualCodegen = [{
-IntrinsicTypes = {ResultType, Ops[1]->getType(), Ops[2]->getType()};
-Ops[0] = 

[PATCH] D129043: [RISCV][Clang] Teach RISCVEmitter to generate BitCast for pointer operands.

2022-07-03 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 created this revision.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, frasercrmck, 
evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, 
jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, 
zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, 
rbar, asb, arichardson.
Herald added a project: All.
fakepaper56 requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

RVV C intrinsics use pointers to scalar for base address and their corresponding
IR intrinsics but use pointers to vector. It makes some vector load intrinsics
need specific ManualCodegen and MaskedManualCodegen to just add bitcast for
transforming to IR.

For simplifying riscv_vector.td, the patch make RISCVEmitter detect pointer
operands and bitcast them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129043

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -105,6 +105,16 @@
 return;
   }
 
+  // Cast pointer operand of vector load intrinsic.
+  for (const auto  : enumerate(RVVI->getInputTypes())) {
+if (I.value()->isPointer()) {
+  assert(RVVI->getIntrinsicTypes().front() == -1 &&
+ "RVVI should be vector load intrinsic.");
+  OS << "Ops[" << I.index() << "] = Builder.CreateBitCast(Ops[";
+  OS << I.index() << "],ResultType->getPointerTo());\n";
+}
+  }
+
   if (RVVI->isMasked()) {
 if (RVVI->hasVL()) {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n";
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -225,6 +225,8 @@
 return isFloat() && ElementBitwidth == Width;
   }
 
+  bool isPointer() const { return IsPointer; }
+
 private:
   // Verify RVV vector type and set Valid.
   bool verifyType() const;
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -582,18 +582,8 @@
 }
 
 let HasUnMaskedOverloaded = false,
-MaskedPolicy = NonePolicy,
-ManualCodegen = [{
-  IntrinsicTypes = {ResultType, Ops[1]->getType()};
-  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
-}],
-MaskedManualCodegen= [{
-  // Move mask to right before vl.
-  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-  IntrinsicTypes = {ResultType, Ops[3]->getType()};
-  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-}] in {
-  class RVVVLEMaskBuiltin : RVVBuiltin<"m", "mPCUe", "c"> {
+MaskedPolicy = NonePolicy in {
+  class RVVVLEMaskBuiltin : RVVOutBuiltin<"m", "mPCUe", "c"> {
 let Name = "vlm_v";
 let IRName = "vlm";
 let HasMasked = false;
@@ -601,26 +591,15 @@
 }
 
 let HasUnMaskedOverloaded = false,
-ManualCodegen = [{
-  IntrinsicTypes = {ResultType, Ops[1]->getType()};
-  Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
-  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));
-}],
-MaskedManualCodegen= [{
-  // Move mask to right before vl.
-  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-  Ops.push_back(ConstantInt::get(Ops.back()->getType(), TAIL_UNDISTURBED));
-  IntrinsicTypes = {ResultType, Ops[3]->getType()};
-  Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-}] in {
+UnMaskedPolicy = HasPassthruOperand in {
   multiclass RVVVLEBuiltin types> {
 let Name = NAME # "_v",
 IRName = "vle",
 MaskedIRName ="vle_mask" in {
   foreach type = types in {
-def : RVVBuiltin<"v", "vPCe", type>;
+def : RVVOutBuiltin<"v", "vPCe", type>;
 if !not(IsFloat.val) then {
-  def : RVVBuiltin<"Uv", "UvPCUe", type>;
+  def : RVVOutBuiltin<"Uv", "UvPCUe", type>;
 }
   }
 }
@@ -685,61 +664,39 @@
   IRName = "vlse",
   MaskedIRName ="vlse_mask",
   HasUnMaskedOverloaded = false,
-  ManualCodegen = [{
-IntrinsicTypes = {ResultType, Ops[2]->getType()};
-Ops[0] = Builder.CreateBitCast(Ops[0], ResultType->getPointerTo());
-Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));
-  }],
-  MaskedManualCodegen= [{
-// Move mask to right before vl.
-std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-

[clang] 6956840 - Revert "Reland "[NFC] Add a missing test for for clang-repl""

2022-07-03 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-07-03T19:42:39+08:00
New Revision: 6956840b5c0029d7f8e043b3c77bb1ffc230e4d5

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

LOG: Revert "Reland "[NFC] Add a missing test for for clang-repl""

This reverts commit 8679cbc29fb76195544956fe233060bb7a1a6453.
See https://lab.llvm.org/buildbot/#/builders/216/builds/6799

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 3754e8d9f964..f5c70c21ac50 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -3,7 +3,6 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// XFAIL: windows-msvc
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -19,8 +18,4 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, 
reinterpret_casthttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129042: Reland "[NFC] Add a missing test for for clang-repl"

2022-07-03 Thread Jun Zhang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8679cbc29fb7: Reland [NFC] Add a missing test for for 
clang-repl (authored by junaire).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129042

Files:
  clang/test/Interpreter/execute.cpp


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -3,6 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// XFAIL: windows-msvc
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -18,4 +19,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -3,6 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// XFAIL: windows-msvc
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -18,4 +19,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8679cbc - Reland "[NFC] Add a missing test for for clang-repl"

2022-07-03 Thread Jun Zhang via cfe-commits

Author: Jun Zhang
Date: 2022-07-03T19:15:59+08:00
New Revision: 8679cbc29fb76195544956fe233060bb7a1a6453

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

LOG: Reland "[NFC] Add a missing test for for clang-repl"

This reverts 3668d1264e2d246f7e222338b8a5cab18ce1bdab
As far as we know, `__attribute__((weak))` support has been really bad
in runtimeldyld, so we just disable it in Windows at this moment. This
should fix the angry Windows buildbot.

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

Added: 


Modified: 
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index f5c70c21ac50..3754e8d9f964 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -3,6 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// XFAIL: windows-msvc
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -18,4 +19,8 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, 
reinterpret_casthttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129042: Reland "[NFC] Add a missing test for for clang-repl"

2022-07-03 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

Let's move forward and we can remove the XFAIL once  
https://reviews.llvm.org/D128968 lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129042

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


[PATCH] D129042: Reland "[NFC] Add a missing test for for clang-repl"

2022-07-03 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added a reviewer: v.g.vassilev.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts 3668d1264e2d246f7e222338b8a5cab18ce1bdab 

As far as we know, `__attribute__((weak))` support has been really bad
in runtimeldyld, so we just disable it in Windows at this moment. This
should fix the angry Windows buildbot.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129042

Files:
  clang/test/Interpreter/execute.cpp


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -3,6 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// XFAIL: windows-msvc
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -18,4 +19,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit


Index: clang/test/Interpreter/execute.cpp
===
--- clang/test/Interpreter/execute.cpp
+++ clang/test/Interpreter/execute.cpp
@@ -3,6 +3,7 @@
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
+// XFAIL: windows-msvc
 // CHECK-DRIVER: i = 10
 // RUN: cat %s | clang-repl | FileCheck %s
 extern "C" int printf(const char *, ...);
@@ -18,4 +19,8 @@
 inline int foo() { return 42; }
 int r3 = foo();
 
+int __attribute__((weak)) bar() { return 1; }
+auto r4 = printf("bar() = %d\n", bar());
+// CHECK-NEXT: bar() = 1
+
 %quit
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f7819ce - [FPEnv] Allow CompoundStmt to keep FP options

2022-07-03 Thread Serge Pavlov via cfe-commits

Author: Serge Pavlov
Date: 2022-07-03T17:06:26+07:00
New Revision: f7819ce166bcc472108cf7c05f86edcf4ee9e6cf

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

LOG: [FPEnv] Allow CompoundStmt to keep FP options

This is a recommit of b822efc7404bf09ccfdc1ab7657475026966c3b2,
reverted in dc34d8df4c48b3a8f474360970cae8a58e6c84f0. The commit caused
fails because the test ast-print-fp-pragmas.c did not specify particular
target, and it failed on targets which do not support constrained
intrinsics. The original commit message is below.

AST does not have special nodes for pragmas. Instead a pragma modifies
some state variables of Sema, which in turn results in modified
attributes of AST nodes. This technique applies to floating point
operations as well. Every AST node that can depend on FP options keeps
current set of them.

This technique works well for options like exception behavior or fast
math options. They represent instructions to the compiler how to modify
code generation for the affected nodes. However treatment of FP control
modes has problems with this technique. Modifying FP control mode
(like rounding direction) usually requires operations on hardware, like
writing to control registers. It must be done prior to the first
operation that depends on the control mode. In particular, such
operations are required for implementation of `pragma STDC FENV_ROUND`,
compiler should set up necessary rounding direction at the beginning of
compound statement where the pragma occurs. As there is no representation
for pragmas in AST, the code generation becomes a complicated task in
this case.

To solve this issue FP options are kept inside CompoundStmt. Unlike to FP
options in expressions, these does not affect any operation on FP values,
but only inform the codegen about the FP options that act in the body of
the statement. As all pragmas that modify FP environment may occurs only
at the start of compound statement or at global level, such solution
works for all relevant pragmas. The options are kept as a difference
from the options in the enclosing compound statement or default options,
it helps codegen to set only changed control modes.

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

Added: 
clang/test/AST/ast-dump-pragma-json.c
clang/test/AST/ast-print-fp-pragmas.c

Modified: 
clang/include/clang/AST/JSONNodeDumper.h
clang/include/clang/AST/Stmt.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Sema/ScopeInfo.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/Stmt.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/Basic/LangOptions.cpp
clang/lib/CodeGen/CGCoroutine.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/test/AST/ast-dump-fpfeatures.cpp

Removed: 




diff  --git a/clang/include/clang/AST/JSONNodeDumper.h 
b/clang/include/clang/AST/JSONNodeDumper.h
index 5638df42a1c5..ed49e0007a18 100644
--- a/clang/include/clang/AST/JSONNodeDumper.h
+++ b/clang/include/clang/AST/JSONNodeDumper.h
@@ -160,6 +160,7 @@ class JSONNodeDumper
   std::string createPointerRepresentation(const void *Ptr);
   llvm::json::Object createQualType(QualType QT, bool Desugar = true);
   llvm::json::Object createBareDeclRef(const Decl *D);
+  llvm::json::Object createFPOptions(FPOptionsOverride FPO);
   void writeBareDeclRef(const Decl *D);
   llvm::json::Object createCXXRecordDefinitionData(const CXXRecordDecl *RD);
   llvm::json::Object createCXXBaseSpecifier(const CXXBaseSpecifier );
@@ -317,6 +318,7 @@ class JSONNodeDumper
   void VisitGotoStmt(const GotoStmt *GS);
   void VisitWhileStmt(const WhileStmt *WS);
   void VisitObjCAtCatchStmt(const ObjCAtCatchStmt *OACS);
+  void VisitCompoundStmt(const CompoundStmt *IS);
 
   void VisitNullTemplateArgument(const TemplateArgument );
   void VisitTypeTemplateArgument(const TemplateArgument );

diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
index 653ce4b4b90c..49a66a1ea5b8 100644
--- a/clang/include/clang/AST/Stmt.h
+++ b/clang/include/clang/AST/Stmt.h
@@ -19,6 +19,7 @@
 #include "clang/Basic/CapturedStmt.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -128,6 +129,10 @@ class alignas(void *) Stmt {
 
 unsigned : NumStmtBits;
 
+/// 

[PATCH] D128604: [RISCV] Support Zbpbo extension

2022-07-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 441931.
sunshaoce added a comment.

Rebase on D99158 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128604

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvp-intrinsics/riscv32-zbpbo.c
  clang/test/CodeGen/RISCV/rvp-intrinsics/riscv64-zbpbo.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/CodeGen/RISCV/rv32zbpbo-intrinsics.ll
  llvm/test/CodeGen/RISCV/rv32zbpbo.ll
  llvm/test/CodeGen/RISCV/rv64zbpbo-intrinsics.ll
  llvm/test/CodeGen/RISCV/rv64zbpbo.ll
  llvm/test/MC/RISCV/rv32zbpbo-aliases-valid.s
  llvm/test/MC/RISCV/rv32zbpbo-valid.s
  llvm/test/MC/RISCV/rv64zbpbo-aliases-valid.s
  llvm/test/MC/RISCV/rv64zbpbo-valid.s

Index: llvm/test/MC/RISCV/rv64zbpbo-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zbpbo-valid.s
@@ -0,0 +1,29 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zbpbo -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zbpbo -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: pack t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x08]
+pack t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: packu t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x48]
+packu t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: fsrw t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xbb,0x52,0xc3,0x3d]
+fsrw t0, t1, t2, t3
+
+# CHECK-ASM-AND-OBJ: max t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x62,0x73,0x0a]
+max t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: min t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x0a]
+min t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: cmix t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xb3,0x92,0x63,0xe6]
+cmix t0, t1, t2, t3
Index: llvm/test/MC/RISCV/rv64zbpbo-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zbpbo-aliases-valid.s
@@ -0,0 +1,18 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zbpbo -riscv-no-aliases \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
+# RUN: llvm-mc %s  -triple=riscv64 -mattr=+experimental-zbpbo \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump -d -r -M no-aliases --mattr=+experimental-zbpbo - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump -d -r --mattr=+experimental-zbpbo - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 8
+# CHECK-S-OBJ: rev8.h t0, t1
+rev8.h x5, x6
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 63
+# CHECK-S-OBJ: rev t0, t1
+rev x5, x6
Index: llvm/test/MC/RISCV/rv32zbpbo-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zbpbo-valid.s
@@ -0,0 +1,37 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zbpbo -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zbpbo -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: clz t0, t1
+# CHECK-ASM: encoding: [0x93,0x12,0x03,0x60]
+clz t0, t1
+
+# CHECK-ASM-AND-OBJ: pack t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x08]
+pack t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: packu t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x48]
+packu t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: fsr t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xb3,0x52,0xc3,0x3d]
+fsr t0, t1, t2, t3
+
+# CHECK-ASM-AND-OBJ: fsri t0, t1, t2, 0
+# CHECK-ASM: encoding: [0x93,0x52,0x03,0x3c]
+fsri t0, t1, t2, 0
+
+# CHECK-ASM-AND-OBJ: max t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x62,0x73,0x0a]
+max t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: min t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x0a]
+min t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: cmix t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xb3,0x92,0x63,0xe6]
+cmix t0, t1, t2, t3
Index: llvm/test/MC/RISCV/rv32zbpbo-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zbpbo-aliases-valid.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zbpbo 

[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-07-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta marked an inline comment as done.
thieta added a comment.

Thanks for the review! I uploaded a new version addressing all (I think) of 
your feedback and added a release note.

The help text is a bit weird since it's using a commonoptionsparser we can't 
really change the text to add `` as a specific input and we would have to 
create some kind of extension point in the parser or something. Not sure what 
you feel about this issue.

I will try to do some extensive testing - but I need to figure out a way to do 
all that ast building and extdef dumping in a automated way from the 
compile_commands database. I might run it on some internal code instead since I 
have a setup for that. Meanwhile let's make sure the code is in good shape.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

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


[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-07-03 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 441930.
thieta marked 6 inline comments as done.
thieta added a comment.

Addressed review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Analysis/func-mapping-test.cpp
  clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp

Index: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
===
--- clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -1,4 +1,4 @@
-//===- ClangExtDefMapGen.cpp ---===//
+//===- ClangExtDefMapGen.cpp -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,10 +13,12 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -29,12 +31,16 @@
 using namespace clang::cross_tu;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangExtDefMapGenCategory("clang-extdefmapgen options");
+static cl::OptionCategory
+ClangExtDefMapGenCategory("clang-extdefmapgen options");
 
 class MapExtDefNamesConsumer : public ASTConsumer {
 public:
-  MapExtDefNamesConsumer(ASTContext )
-  : Ctx(Context), SM(Context.getSourceManager()) {}
+  MapExtDefNamesConsumer(ASTContext ,
+ StringRef astFilePath = StringRef())
+  : Ctx(Context), SM(Context.getSourceManager()) {
+CurrentFileName = astFilePath.str();
+  }
 
   ~MapExtDefNamesConsumer() {
 // Flush results to standard output.
@@ -111,6 +117,82 @@
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 
+static IntrusiveRefCntPtr Diags;
+
+IntrusiveRefCntPtr GetDiagnosticsEngine() {
+  if (Diags) {
+// Call reset to make sure we don't mix errors
+Diags->Reset(false);
+return Diags;
+  }
+
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  DiagClient->setPrefix("clang-extdef-mappping");
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+
+  IntrusiveRefCntPtr DiagEngine(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+  Diags.swap(DiagEngine);
+
+  // Retain this one time so it's not destroyed by ASTUnit::LoadFromASTFile
+  Diags->Retain();
+  return Diags;
+}
+
+static CompilerInstance *CI = nullptr;
+
+static bool HandleAST(StringRef astPath) {
+
+  if (!CI)
+CI = new CompilerInstance();
+
+  IntrusiveRefCntPtr DiagEngine = GetDiagnosticsEngine();
+
+  std::unique_ptr Unit = ASTUnit::LoadFromASTFile(
+  astPath.str(), CI->getPCHContainerOperations()->getRawReader(),
+  ASTUnit::LoadASTOnly, DiagEngine, CI->getFileSystemOpts());
+
+  if (!Unit)
+return false;
+
+  FileManager fm(CI->getFileSystemOpts());
+  SmallString<128> absPath(astPath);
+  fm.makeAbsolutePath(absPath);
+
+  MapExtDefNamesConsumer Consumer =
+  MapExtDefNamesConsumer(Unit->getASTContext(), absPath);
+  Consumer.HandleTranslationUnit(Unit->getASTContext());
+
+  return true;
+}
+
+static int HandleFiles(ArrayRef sourceFiles,
+   CompilationDatabase ) {
+  std::vector SourcesToBeParsed;
+
+  // Loop over all input files, if they are pre-compiled AST
+  // process them directly in HandleAST, otherwise put them
+  // on a list for ClangTool to handle.
+  for (StringRef Src : sourceFiles) {
+if (Src.endswith(".ast")) {
+  if (!HandleAST(Src)) {
+return 1;
+  }
+} else {
+  SourcesToBeParsed.push_back(Src.str());
+}
+  }
+
+  if (!SourcesToBeParsed.empty()) {
+ClangTool Tool(compilations, SourcesToBeParsed);
+return Tool.run(newFrontendActionFactory().get());
+  }
+
+  return 0;
+}
+
 int main(int argc, const char **argv) {
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0], false);
@@ -118,7 +200,10 @@
 
   const char *Overview = "\nThis tool collects the USR name and location "
  "of external definitions in the source files "
- "(excluding headers).\n";
+ "(excluding headers).\n"
+ "Input can be either source files that are compiled "
+ "with compile database or .ast files that are "
+ "created from clang's 

[PATCH] D108189: [RISCV] Support experimental 'P' extension 0.9.11

2022-07-03 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 441925.
sunshaoce added a comment.

Support for P extension version 0.9.11


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108189

Files:
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -187,3 +187,15 @@
 
 .attribute arch, "rv32if_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
+
+.attribute arch, "rv32ip0p911"
+# CHECK: attribute  5, "rv32i2p0_p0p911_zbpbo0p911_zpn0p911_zpsfoperand0p911"
+
+.attribute arch, "rv32izbpbo0p911"
+# CHECK: attribute  5, "rv32i2p0_zbpbo0p911"
+
+.attribute arch, "rv32izpn0p911"
+# CHECK: attribute  5, "rv32i2p0_zpn0p911"
+
+.attribute arch, "rv32izpsfoperand0p911"
+# CHECK: attribute  5, "rv32i2p0_zpsfoperand0p911"
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -109,6 +109,11 @@
 {"zbr", RISCVExtensionVersion{0, 93}},
 {"zbt", RISCVExtensionVersion{0, 93}},
 {"zvfh", RISCVExtensionVersion{0, 1}},
+
+{"p", RISCVExtensionVersion{0, 911}},
+{"zbpbo", RISCVExtensionVersion{0, 911}},
+{"zpn", RISCVExtensionVersion{0, 911}},
+{"zpsfoperand", RISCVExtensionVersion{0, 911}},
 };
 
 static bool stripExperimentalPrefix(StringRef ) {
@@ -598,8 +603,8 @@
 
 // The order is OK, then push it into features.
 // TODO: Use version number when setting target features
-// Currently LLVM supports only "mafdcbv".
-StringRef SupportedStandardExtension = "mafdcbv";
+// Currently LLVM supports only "mafdcbpv".
+StringRef SupportedStandardExtension = "mafdcbpv";
 if (!SupportedStandardExtension.contains(C))
   return createStringError(errc::invalid_argument,
"unsupported standard user-level extension '%c'",
@@ -773,6 +778,7 @@
 static const char *ImpliedExtsZkn[] = {"zbkb", "zbkc", "zbkx", "zkne", "zknd", "zknh"};
 static const char *ImpliedExtsZks[] = {"zbkb", "zbkc", "zbkx", "zksed", "zksh"};
 static const char *ImpliedExtsZvfh[] = {"zve32f"};
+static const char *ImpliedExtsP[] = {"zbpbo", "zpn", "zpsfoperand"};
 
 struct ImpliedExtsEntry {
   StringLiteral Name;
@@ -787,6 +793,7 @@
 
 // Note: The table needs to be sorted by name.
 static constexpr ImpliedExtsEntry ImpliedExts[] = {
+{{"p"}, {ImpliedExtsP}},
 {{"v"}, {ImpliedExtsV}},
 {{"zdinx"}, {ImpliedExtsZdinx}},
 {{"zfh"}, {ImpliedExtsZfh}},
Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -42,6 +42,10 @@
 // CHECK-NOT: __riscv_zkr
 // CHECK-NOT: __riscv_zkt
 // CHECK-NOT: __riscv_zk
+// CHECK-NOT: __riscv_p
+// CHECK-NOT: __riscv_zbpbo
+// CHECK-NOT: __riscv_zpn
+// CHECK-NOT: __riscv_zpsfoperand
 // CHECK-NOT: __riscv_zicbom
 // CHECK-NOT: __riscv_zicboz
 
@@ -224,6 +228,44 @@
 // CHECK-ZBT-NOT: __riscv_b
 // CHECK-ZBT-EXT: __riscv_zbt 93000{{$}}
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv32ip0p911 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-P-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv64ip0p911 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-P-EXT %s
+// CHECK-P-EXT: __riscv_p 911000{{$}}
+// CHECK-P-EXT: __riscv_zbpbo 911000{{$}}
+// CHECK-P-EXT: __riscv_zpn 911000{{$}}
+// CHECK-P-EXT: __riscv_zpsfoperand 911000{{$}}
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv32izbpbo0p911 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBPBO-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv64izbpbo0p911 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZBPBO-EXT %s
+// CHECK-ZBPBO-NOT: __riscv_p
+// CHECK-ZBPBO-EXT: __riscv_zbpbo 911000{{$}}
+
+// RUN: %clang -target riscv32-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv32izpn0p911 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZPN-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -menable-experimental-extensions \
+// RUN: -march=rv64izpn0p911 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZPN-EXT %s
+// CHECK-ZPN-NOT: __riscv_p
+// CHECK-ZPN-EXT: __riscv_zpn 911000{{$}}
+
+// RUN: %clang -target