[PATCH] D49864: [clang-tidy] The script clang-tidy-diff.py doesn't accept 'pass by' options (--)

2022-01-07 Thread Jano Simas via Phabricator via cfe-commits
janosimas updated this revision to Diff 398314.
janosimas added a comment.
Herald added a subscriber: carlosgalvezp.

I added a comment in the docs noting this is a breaking change.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D49864

Files:
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
@@ -1,11 +1,11 @@
 // REQUIRES: shell
 // RUN: sed 's/placeholder_for_f/f/' %s > %t.cpp
 // RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s
-// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
-// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -- -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -- -checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s
 // RUN: mkdir -p %T/compilation-database-test/
 // RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 %t.cpp", "file": "%t.cpp"}]' > %T/compilation-database-test/compile_commands.json
-// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | FileCheck -check-prefix=CHECK %s
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -- -checks=-*,modernize-use-override -p=%T/compilation-database-test 2>&1 | FileCheck -check-prefix=CHECK %s
 struct A {
   virtual void f() {}
   virtual void g() {}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -79,6 +79,8 @@
 - Generalized the `modernize-use-default-member-init` check to handle non-default
   constructors.
 
+- `clang-tidy-diff.py` allows using `clang-tidy` flags after `--`. This is a breaking change, check the script help for usage.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -17,9 +17,9 @@
 detect clang-tidy regressions in the lines touched by a specific patch.
 Example usage for git/svn users:
 
-  git diff -U0 HEAD^ | clang-tidy-diff.py -p1
+  git diff -U0 HEAD^ | clang-tidy-diff.py -strip 1
   svn diff --diff-cmd=diff -x-U0 | \
-  clang-tidy-diff.py -fix -checks=-*,modernize-use-override
+  clang-tidy-diff.py -- -fix -checks=-*,modernize-use-override
 
 """
 
@@ -119,12 +119,13 @@
   parser = argparse.ArgumentParser(description=
'Run clang-tidy against changed files, and '
'output diagnostics only for modified '
-   'lines.')
+   'lines.'
+   '\nclang-tidy arguments should be passed after a \'--\' .')
   parser.add_argument('-clang-tidy-binary', metavar='PATH',
   default='clang-tidy',
   help='path to clang-tidy binary')
-  parser.add_argument('-p', metavar='NUM', default=0,
-  help='strip the smallest prefix containing P slashes')
+  parser.add_argument('-strip', metavar='NUM', default=0,
+  help='strip the smallest prefix containing NUM slashes')
   parser.add_argument('-regex', metavar='PATTERN', default=None,
   help='custom pattern selecting file paths to check '
   '(case sensitive, overrides -iregex)')
@@ -136,34 +137,14 @@
   help='number of tidy instances to be run in parallel.')
   parser.add_argument('-timeout', type=int, default=None,
   help='timeout per each file in seconds.')
-  parser.add_argument('-fix', action='store_true', default=False,
-  help='apply suggested fixes')
-  parser.add_argument('-checks',
-  help='checks filter, when not specified, use clang-tidy '
-  'default',
-  default='')
-  parser.add_argument('-use-color', action='store_true',
-  help='Use colors in output')
-  parser.add_argument('-path', dest='build_path',
-  

[PATCH] D116856: [docs] Fix documentation of -fstrict-float-cast-overflow after D115804.

2022-01-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: spatel, nikic.
craig.topper requested review of this revision.
Herald added a project: clang.

Previously this was documented as having the behavior of the
"target's native float-to-int conversion". After D115804 
, clang
uses saturating FP cast intrinsics which have the same behavior
on all targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116856

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1380,8 +1380,8 @@
When a floating-point value is not representable in a destination integer
type, the code has undefined behavior according to the language standard.
By default, Clang will not guarantee any particular result in that case.
-   With the 'no-strict' option, Clang attempts to match the overflowing 
behavior
-   of the target's native float-to-int conversion instructions.
+   With the 'no-strict' option, Clang will saturate towards the smallest and
+   largest representable integer values instead. NaNs will be converted to 
zero.
 
 .. _opt_fmath-errno:
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -243,6 +243,9 @@
   -ffp-contract=fast, whereas the (now corrected) default behavior is
   -ffp-contract=on.
   -ffp-model=precise is now exactly the default mode of the compiler.
+- -fstrict-float-cast-overflow no longer has target specific behavior. Clang
+  will saturate towards the smallest and largest representable integer values.
+  NaNs will be converted to zero.
 
 Internal API Changes
 


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1380,8 +1380,8 @@
When a floating-point value is not representable in a destination integer
type, the code has undefined behavior according to the language standard.
By default, Clang will not guarantee any particular result in that case.
-   With the 'no-strict' option, Clang attempts to match the overflowing behavior
-   of the target's native float-to-int conversion instructions.
+   With the 'no-strict' option, Clang will saturate towards the smallest and
+   largest representable integer values instead. NaNs will be converted to zero.
 
 .. _opt_fmath-errno:
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -243,6 +243,9 @@
   -ffp-contract=fast, whereas the (now corrected) default behavior is
   -ffp-contract=on.
   -ffp-model=precise is now exactly the default mode of the compiler.
+- -fstrict-float-cast-overflow no longer has target specific behavior. Clang
+  will saturate towards the smallest and largest representable integer values.
+  NaNs will be converted to zero.
 
 Internal API Changes
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116634: enable msan-eager-checks with -fsanitize-memory-param-retval.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 398310.
kda added a comment.

add 3 parameter constructor for MemorySanitizerOptions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116634

Files:
  llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll

Index: llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
===
--- llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
+++ llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -msan-eager-checks -S -passes='module(msan-module),function(msan)' 2>&1 | \
 ; RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s
+; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S -passes='msan' 2>&1 | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -493,6 +493,9 @@
   MemorySanitizer(Module , MemorySanitizerOptions Options)
   : CompileKernel(Options.Kernel), TrackOrigins(Options.TrackOrigins),
 Recover(Options.Recover) {
+if (Options.EagerChecksRequested) {
+  ClEagerChecks = true;
+}
 initializeModule(M);
   }
 
@@ -665,10 +668,13 @@
 
 } // end anonymous namespace
 
-MemorySanitizerOptions::MemorySanitizerOptions(int TO, bool R, bool K)
+MemorySanitizerOptions::MemorySanitizerOptions(int TO, bool R, bool K,
+   bool EagerChecksRequested)
 : Kernel(getOptOrDefault(ClEnableKmsan, K)),
   TrackOrigins(getOptOrDefault(ClTrackOrigins, Kernel ? 2 : TO)),
-  Recover(getOptOrDefault(ClKeepGoing, Kernel || R)) {}
+  Recover(getOptOrDefault(ClKeepGoing, Kernel || R)),
+  EagerChecksRequested(
+  getOptOrDefault(ClEagerChecks, EagerChecksRequested)) {}
 
 PreservedAnalyses MemorySanitizerPass::run(Function ,
FunctionAnalysisManager ) {
@@ -695,7 +701,9 @@
 OS << "recover;";
   if (Options.Kernel)
 OS << "kernel;";
-  OS << "track-origins=" << Options.TrackOrigins;
+  OS << "track-origins=" << Options.TrackOrigins << ";";
+  if (Options.EagerChecksRequested)
+OS << "param-retval;";
   OS << ">";
 }
 
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -412,7 +412,7 @@
  return MemorySanitizerPass(Opts);
},
   parseMSanPassOptions,
-  "recover;kernel;track-origins=N")
+  "recover;kernel;track-origins=N,param-retval")
 FUNCTION_PASS_WITH_PARAMS("simplifycfg",
   "SimplifyCFGPass",
[](SimplifyCFGOptions Opts) {
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -656,6 +656,8 @@
 ParamName)
 .str(),
 inconvertibleErrorCode());
+} else if (ParamName == "param-retval") {
+  Result.EagerChecksRequested = true;
 } else {
   return make_error(
   formatv("invalid MemorySanitizer pass parameter '{0}' ", ParamName)
Index: llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
@@ -19,11 +19,15 @@
 namespace llvm {
 
 struct MemorySanitizerOptions {
-  MemorySanitizerOptions() : MemorySanitizerOptions(0, false, false){};
-  MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel);
+  MemorySanitizerOptions() : MemorySanitizerOptions(0, false, false, false){};
+  MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel)
+  : MemorySanitizerOptions(TrackOrigins, Recover, Kernel, false) {}
+  MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel,
+ bool 

[PATCH] D116634: enable msan-eager-checks with -fsanitize-memory-param-retval.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda added inline comments.



Comment at: llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h:28
   bool Recover;
+  bool EagerChecks;
 };

vitalybuka wrote:
> maybe we should use CheckParamRetVal something here?
> 
How about EagerChecksRequested?



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:496
 Recover(Options.Recover) {
+if (Options.EagerChecks) {
+  ClEagerChecks = Options.EagerChecks;

vitalybuka wrote:
> mllvm is lower level flag, so it should be opposite
> -mllvm flag should override MemorySanitizerOptions
> 
> with getOptOrDefault below you don't need anything here
I disagree.  The variable ClEagerChecks is referenced in the code.  If it is 
not configured based on EagerChecksRequested, there is no way to change the 
behavior based on the presence of the flag.

I will admit that with the change below, it is a bit circular, because 
Options.EagerChecksRequested prefers the -msan-eager-checks flag, but may 
default to EagerChecksRequested parameter, and then here the flag variable 
(ClEagerChecks) is set based on Options.EagerChecksRequested.

An alternative is to have a member variable of MemorySanitizer that is 
consulted in the code.  It is configured based on Options.EagerChecksRequested. 
 The flag (-msan-eager-checks) is only consulted below with the call to 
getOptOrDefault.  (I coded this up: https://reviews.llvm.org/D116855)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116634

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


[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398308.
owenpan added a comment.

- Rebased to `main`.
- Removed unused code.
- Updated release notes.


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

https://reviews.llvm.org/D116316

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18776,6 +18776,7 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
+  CHECK_PARSE_BOOL(RemoveBracesLLVM);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -23212,6 +23213,319 @@
Style);
 }
 
+TEST_F(FormatTest, RemoveBraces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.RemoveBracesLLVM = true;
+
+  // The following eight test cases are fully-braced versions of the examples at
+  // "llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-
+  // statement-bodies-of-if-else-loop-statements".
+
+  // 1. Omit the braces, since the body is simple and clearly associated with
+  // the if.
+  verifyFormat("if (isa(D))\n"
+   "  handleFunctionDecl(D);\n"
+   "else if (isa(D))\n"
+   "  handleVarDecl(D);",
+   "if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else if (isa(D)) {\n"
+   "  handleVarDecl(D);\n"
+   "}",
+   Style);
+
+  // 2. Here we document the condition itself and not the body.
+  verifyFormat("if (isa(D)) {\n"
+   "  // It is necessary that we explain the situation with this\n"
+   "  // surprisingly long comment, so it would be unclear\n"
+   "  // without the braces whether the following statement is in\n"
+   "  // the scope of the `if`.\n"
+   "  // Because the condition is documented, we can't really\n"
+   "  // hoist this comment that applies to the body above the\n"
+   "  // if.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 3. Use braces on the outer `if` to avoid a potential dangling else
+  // situation.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs())\n"
+   "if (shouldProcessAttr(A))\n"
+   "  handleAttr(A);\n"
+   "}",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "if (shouldProcessAttr(A)) {\n"
+   "  handleAttr(A);\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 4. Use braces for the `if` block to keep it uniform with the else block.
+  verifyFormat("if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else {\n"
+   "  // In this else case, it is necessary that we explain the\n"
+   "  // situation with this surprisingly long comment, so it\n"
+   "  // would be unclear without the braces whether the\n"
+   "  // following statement is in the scope of the `if`.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 5. This should also omit braces.  The `for` loop contains only a single
+  // statement, so it shouldn't have braces.  The `if` also only contains a
+  // single simple statement (the for loop), so it also should omit braces.
+  verifyFormat("if (isa(D))\n"
+   "  for (auto *A : D.attrs())\n"
+   "handleAttr(A);",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 6. Use braces for the outer `if` since the nested `for` is braced.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "// In this for loop body, it is necessary that we explain\n"
+   "// the situation with this surprisingly long comment,\n"
+   "// forcing braces on the `for` block.\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 7. Use braces on the outer block because there are more than two levels of
+  // nesting.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs())\n"
+   "for (ssize_t i : 

[PATCH] D116634: enable msan-eager-checks with -fsanitize-memory-param-retval.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 398303.
kda marked 2 inline comments as done.
kda added a comment.

Reworked for comments and to be llvm only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116634

Files:
  llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll


Index: llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
===
--- llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
+++ llvm/test/Instrumentation/MemorySanitizer/msan_eager.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 
-msan-eager-checks -S -passes='module(msan-module),function(msan)' 2>&1 | \
 ; RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s
+; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S 
-passes='msan' 2>&1 | \
+; RUN:   FileCheck -allow-deprecated-dag-overlap --check-prefix=CHECK %s
 
 target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -493,6 +493,9 @@
   MemorySanitizer(Module , MemorySanitizerOptions Options)
   : CompileKernel(Options.Kernel), TrackOrigins(Options.TrackOrigins),
 Recover(Options.Recover) {
+if (Options.EagerChecksRequested) {
+  ClEagerChecks = true;
+}
 initializeModule(M);
   }
 
@@ -665,10 +668,13 @@
 
 } // end anonymous namespace
 
-MemorySanitizerOptions::MemorySanitizerOptions(int TO, bool R, bool K)
+MemorySanitizerOptions::MemorySanitizerOptions(int TO, bool R, bool K,
+   bool EagerChecksRequested)
 : Kernel(getOptOrDefault(ClEnableKmsan, K)),
   TrackOrigins(getOptOrDefault(ClTrackOrigins, Kernel ? 2 : TO)),
-  Recover(getOptOrDefault(ClKeepGoing, Kernel || R)) {}
+  Recover(getOptOrDefault(ClKeepGoing, Kernel || R)),
+  EagerChecksRequested(
+  getOptOrDefault(ClEagerChecks, EagerChecksRequested)) {}
 
 PreservedAnalyses MemorySanitizerPass::run(Function ,
FunctionAnalysisManager ) {
@@ -695,7 +701,9 @@
 OS << "recover;";
   if (Options.Kernel)
 OS << "kernel;";
-  OS << "track-origins=" << Options.TrackOrigins;
+  OS << "track-origins=" << Options.TrackOrigins << ";";
+  if (Options.EagerChecksRequested)
+OS << "param-retval;";
   OS << ">";
 }
 
Index: llvm/lib/Passes/PassRegistry.def
===
--- llvm/lib/Passes/PassRegistry.def
+++ llvm/lib/Passes/PassRegistry.def
@@ -412,7 +412,7 @@
  return MemorySanitizerPass(Opts);
},
   parseMSanPassOptions,
-  "recover;kernel;track-origins=N")
+  "recover;kernel;track-origins=N,param-retval")
 FUNCTION_PASS_WITH_PARAMS("simplifycfg",
   "SimplifyCFGPass",
[](SimplifyCFGOptions Opts) {
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -656,6 +656,8 @@
 ParamName)
 .str(),
 inconvertibleErrorCode());
+} else if (ParamName == "param-retval") {
+  Result.EagerChecksRequested = true;
 } else {
   return make_error(
   formatv("invalid MemorySanitizer pass parameter '{0}' ", ParamName)
Index: llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
===
--- llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
+++ llvm/include/llvm/Transforms/Instrumentation/MemorySanitizer.h
@@ -19,11 +19,13 @@
 namespace llvm {
 
 struct MemorySanitizerOptions {
-  MemorySanitizerOptions() : MemorySanitizerOptions(0, false, false){};
-  MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel);
+  MemorySanitizerOptions() : MemorySanitizerOptions(0, false, false, false){};
+  MemorySanitizerOptions(int TrackOrigins, bool Recover, bool Kernel,
+ bool EagerChecksRequested);
   bool Kernel;
   int TrackOrigins;
   bool Recover;
+  bool EagerChecksRequested;
 };
 
 // Insert 

[PATCH] D116318: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Revision".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd97025ad3a70: [clang-format][NFC] Fix a bug in 
getPreviousToken() in the parser (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116318

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -32,7 +32,7 @@
   // Returns the next token in the token stream.
   virtual FormatToken *getNextToken() = 0;
 
-  // Returns the token precedint the token returned by the last call to
+  // Returns the token preceding the token returned by the last call to
   // getNextToken() in the token stream, or nullptr if no such token exists.
   virtual FormatToken *getPreviousToken() = 0;
 
@@ -246,8 +246,7 @@
   }
 
   FormatToken *getPreviousToken() override {
-assert(Position > 0);
-return Tokens[Position - 1];
+return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
   FormatToken *peekNextToken() override {


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -32,7 +32,7 @@
   // Returns the next token in the token stream.
   virtual FormatToken *getNextToken() = 0;
 
-  // Returns the token precedint the token returned by the last call to
+  // Returns the token preceding the token returned by the last call to
   // getNextToken() in the token stream, or nullptr if no such token exists.
   virtual FormatToken *getPreviousToken() = 0;
 
@@ -246,8 +246,7 @@
   }
 
   FormatToken *getPreviousToken() override {
-assert(Position > 0);
-return Tokens[Position - 1];
+return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
   FormatToken *peekNextToken() override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d97025a - [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

2022-01-07 Thread via cfe-commits

Author: owenca
Date: 2022-01-07T21:12:18-08:00
New Revision: d97025ad3a70c322843232036e2a11598b9fb9a6

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

LOG: [clang-format][NFC] Fix a bug in getPreviousToken() in the parser

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 2bf5cedd2ae4c..c1c87c776f714 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -32,7 +32,7 @@ class FormatTokenSource {
   // Returns the next token in the token stream.
   virtual FormatToken *getNextToken() = 0;
 
-  // Returns the token precedint the token returned by the last call to
+  // Returns the token preceding the token returned by the last call to
   // getNextToken() in the token stream, or nullptr if no such token exists.
   virtual FormatToken *getPreviousToken() = 0;
 
@@ -246,8 +246,7 @@ class IndexedTokenSource : public FormatTokenSource {
   }
 
   FormatToken *getPreviousToken() override {
-assert(Position > 0);
-return Tokens[Position - 1];
+return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
   FormatToken *peekNextToken() override {



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


[PATCH] D111566: [SYCL] Fix function pointer address space

2022-01-07 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Block pointers are actually data pointers and should stay in the generic 
address space.  I... don't honestly know why they get lowered as function 
pointers; they probably shouldn't be.


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

https://reviews.llvm.org/D111566

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


[clang] 5be1319 - [NFC] Test commit.

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

Author: Jun Zhang
Date: 2022-01-08T10:36:09+08:00
New Revision: 5be131922cb78b4d1ff9bbfe4f524261c12f9cf8

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

LOG: [NFC] Test commit.

This is just a test commit to check whether the permission I got is
correct or not.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index e98c9d5fd8444..716134b123dd6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -159,6 +159,7 @@ static Value *EmitFromInt(CodeGenFunction , llvm::Value 
*V,
 static Value *MakeBinaryAtomicValue(
 CodeGenFunction , llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E,
 AtomicOrdering Ordering = AtomicOrdering::SequentiallyConsistent) {
+
   QualType T = E->getType();
   assert(E->getArg(0)->getType()->isPointerType());
   assert(CGF.getContext().hasSameUnqualifiedType(T,



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


[PATCH] D116425: [clang-tidy] Improve modernize-redundant-void-arg to recognize macro uses

2022-01-07 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood updated this revision to Diff 398281.
LegalizeAdulthood edited the summary of this revision.
LegalizeAdulthood added a comment.

Add more test cases and improve the Lexing state machine


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

https://reviews.llvm.org/D116425

Files:
  clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp
@@ -199,6 +199,7 @@
 // CHECK-FIXES-NEXT: {{^\);$}}
 
 // intentionally not LLVM style to check preservation of whitespace
+// clang-format off
 typedef
 void
 (
@@ -240,7 +241,7 @@
 // CHECK-FIXES-NOT:  {{[^ ]}}
 // CHECK-FIXES:  {{^\)$}}
 // CHECK-FIXES-NEXT: {{^;$}}
-
+// clang-format on
 
 void (gronk::*p1)(void);
 // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}} in variable declaration
@@ -556,3 +557,38 @@
   S_3();
   g_3();
 }
+
+#define return_t(T) T
+extern return_t(void) func(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: redundant void argument list in function declaration
+// CHECK-FIXES: extern return_t(void) func();
+
+return_t(void) func(void) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: redundant void argument list in function definition
+  // CHECK-FIXES: return_t(void) func() {
+  int a;
+  (void)a;
+}
+
+extern return_t(void) func(return_t(void) (*fp)(void));
+// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: redundant void argument list in variable declaration
+// CHECK-FIXES: extern return_t(void) func(return_t(void) (*fp)());
+
+return_t(void) func(return_t(void) (*fp)(void)) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: redundant void argument list in variable declaration
+  // CHECK-FIXES: return_t(void) func(return_t(void) (*fp)()) {
+  int a;
+  (void)a;
+}
+
+extern return_t(return_t(void)) func2(return_t(return_t(void)) (*fp)(void));
+// CHECK-MESSAGES: :[[@LINE-1]]:70: warning: redundant void argument list in variable declaration
+// CHECK-FIXES: extern return_t(return_t(void)) func2(return_t(return_t(void)) (*fp)());
+
+return_t(return_t(void)) func2(return_t(return_t(void)) (*fp)(void)) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:63: warning: redundant void argument list in variable declaration
+  // CHECK-FIXES: return_t(return_t(void)) func2(return_t(return_t(void)) (*fp)()) {
+  int a;
+  (void)a;
+}
+#undef return_t
Index: clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -48,7 +48,7 @@
   unless(isInstantiated()), unless(isExternC()))
  .bind(FunctionId),
  this);
-  Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
+  Finder->addMatcher(typedefNameDecl(unless(isImplicit())).bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
@@ -97,9 +97,12 @@
 
 void RedundantVoidArgCheck::processFunctionDecl(
 const MatchFinder::MatchResult , const FunctionDecl *Function) {
+  const auto *Method = dyn_cast(Function);
+  SourceLocation Start = Method && Method->getParent()->isLambda()
+ ? Method->getBeginLoc()
+ : Function->getLocation();
+  SourceLocation End = Function->getEndLoc();
   if (Function->isThisDeclarationADefinition()) {
-SourceLocation Start = Function->getBeginLoc();
-SourceLocation End = Function->getEndLoc();
 if (const Stmt *Body = Function->getBody()) {
   End = Body->getBeginLoc();
   if (End.isMacroID() &&
@@ -110,11 +113,16 @@
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
   } else {
-removeVoidArgumentTokens(Result, Function->getSourceRange(),
+removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function declaration");
   }
 }
 
+bool isMacroIdentifier(IdentifierTable , const Token ) {
+  return ProtoToken.is(tok::TokenKind::raw_identifier) &&
+ Idents.get(ProtoToken.getRawIdentifier()).hadMacroDefinition();
+}
+
 void RedundantVoidArgCheck::removeVoidArgumentTokens(
 const ast_matchers::MatchFinder::MatchResult , SourceRange Range,
 StringRef GrammarLocation) {
@@ -127,47 +135,93 @@
   .str();
   Lexer PrototypeLexer(CharRange.getBegin(), getLangOpts(), DeclText.data(),
DeclText.data(), DeclText.data() + 

[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D114639#3228704 , @rnk wrote:

> In D114639#3199458 , @RKSimon wrote:
>
>> @rnk I'm not certain but I think the only buildbot still using VS2017 is 
>> windows-gcebot2 ?
>
> Yes, it probably uses VS2017, and probably also the sanitizer-windows bot as 
> well:
> https://lab.llvm.org/buildbot/#/builders/sanitizer-windows
> https://lab.llvm.org/buildbot/#/builders/clang-x64-windows-msvc
>
> I'm going to delegate this task, so give me some time to get to it.

Would you like me to do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

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


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG244dd2913a43: Dont pass uninitialized QueryKind 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1298,7 +1298,7 @@
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   llvm::DenseSet IDs;
-  RelationKind QueryKind;
+  RelationKind QueryKind = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations)) {
 if (const auto *CXXMD = llvm::dyn_cast(ND)) {
   if (CXXMD->isVirtual()) {


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1298,7 +1298,7 @@
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   llvm::DenseSet IDs;
-  RelationKind QueryKind;
+  RelationKind QueryKind = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations)) {
 if (const auto *CXXMD = llvm::dyn_cast(ND)) {
   if (CXXMD->isVirtual()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 244dd29 - Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-01-07T17:14:08-08:00
New Revision: 244dd2913a43a200f5a6544d424cdc37b771028b

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

LOG: Don't pass uninitialized QueryKind

Even if findImplementors does not use
uninitialized parameter it's still UB and
it's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 36aa251717bd..28ee2096f3fb 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1298,7 +1298,7 @@ std::vector findImplementations(ParsedAST 
, Position Pos,
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   llvm::DenseSet IDs;
-  RelationKind QueryKind;
+  RelationKind QueryKind = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations)) {
 if (const auto *CXXMD = llvm::dyn_cast(ND)) {
   if (CXXMD->isVirtual()) {



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


[PATCH] D100810: [llvm] Use `GNUInstallDirs` to support custom installation dirs

2022-01-07 Thread John Ericson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfeeff8a37c35: [llvm] Use `GNUInstallDirs` to support custom 
installation dirs (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

Files:
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt

Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(LLVM_TOOLS_INSTALL_DIR);
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,7 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
Index: llvm/examples/Bye/CMakeLists.txt
===
--- llvm/examples/Bye/CMakeLists.txt
+++ llvm/examples/Bye/CMakeLists.txt
@@ -14,6 +14,6 @@
 BUILDTREE_ONLY
)
 
-  install(TARGETS ${name} RUNTIME DESTINATION examples)
+  install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}")
   set_target_properties(${name} PROPERTIES FOLDER "Examples")
 endif()
Index: llvm/docs/CMake.rst
===
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -252,6 +252,22 @@
   Sets the C++ standard to conform to when building LLVM.  Possible values are
   14, 17, 20.  LLVM Requires C++ 14 or higher.  This defaults to 14.
 
+**CMAKE_INSTALL_BINDIR**:PATH
+  The path to install executables, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "bin".
+
+**CMAKE_INSTALL_INCLUDEDIR**:PATH
+  The path to install header files, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "include".
+
+**CMAKE_INSTALL_DOCDIR**:PATH
+  The path to install documentation, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "share/doc".
+
+**CMAKE_INSTALL_MANDIR**:PATH
+  The path to install manpage files, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "share/man".
+
 .. _LLVM-related variables:
 
 LLVM-related 

[PATCH] D100810: [llvm] Use `GNUInstallDirs` to support custom installation dirs

2022-01-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added inline comments.



Comment at: llvm/cmake/modules/AddSphinxTarget.cmake:1
 include(GNUInstallDirs)
 

N.B. this already had it from an earlier revision of mine, so didn't need to 
add it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 398271.
vitalybuka added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1298,7 +1298,7 @@
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   llvm::DenseSet IDs;
-  RelationKind QueryKind;
+  RelationKind QueryKind = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations)) {
 if (const auto *CXXMD = llvm::dyn_cast(ND)) {
   if (CXXMD->isVirtual()) {


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1298,7 +1298,7 @@
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   llvm::DenseSet IDs;
-  RelationKind QueryKind;
+  RelationKind QueryKind = RelationKind::OverriddenBy;
   for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations)) {
 if (const auto *CXXMD = llvm::dyn_cast(ND)) {
   if (CXXMD->isVirtual()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116844: [Driver][Fuchsia] -r: imply -nostdlib like GCC

2022-01-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added a reviewer: phosek.
Herald added a subscriber: abrachet.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Similar to D116843 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116844

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -72,6 +72,8 @@
 // CHECK-RELOCATABLE-NOT: "-pie"
 // CHECK-RELOCATABLE-NOT: "--build-id"
 // CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: crt{{[^.]+}}.o
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia -nodefaultlibs 
-fuse-ld=lld 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -109,7 +109,8 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
 }
@@ -131,7 +132,8 @@
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (Args.hasArg(options::OPT_static))
   CmdArgs.push_back("-Bdynamic");
 


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -72,6 +72,8 @@
 // CHECK-RELOCATABLE-NOT: "-pie"
 // CHECK-RELOCATABLE-NOT: "--build-id"
 // CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: crt{{[^.]+}}.o
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia -nodefaultlibs -fuse-ld=lld 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -109,7 +109,8 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("Scrt1.o")));
 }
@@ -131,7 +132,8 @@
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
   ToolChain.addProfileRTLibs(Args, CmdArgs);
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (Args.hasArg(options::OPT_static))
   CmdArgs.push_back("-Bdynamic");
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D100810: [llvm] Use `GNUInstallDirs` to support custom installation dirs

2022-01-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

OK, at long last, I this is the attempt that's gonna make it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

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


[PATCH] D116843: [Driver][Gnu] -r: imply -nostdlib like GCC

2022-01-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: thesamesam, phosek.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

See `gcc -dumpspecs` that -r essentially implies -nostdlib and suppresses
default -l* and crt*.o. The behavior makes sense because otherwise there will be
assuredly conflicting definitions when the relocatable output is linked into the
final executable/shared object.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116843

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-cross.cpp


Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -210,3 +210,14 @@
 // RUN: %clang -### %s --target=i686-linux-musl -mx32 --sysroot= \
 // RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s 
--check-prefix=MUSL_X32
 // MUSL_X32: "-dynamic-linker" "/lib/ld-musl-x32.so.1"
+
+/// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -### %s --target=x86_64-linux-gnu 
--sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin 
-resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform -r 2>&1 | FileCheck %s 
--check-prefix=RELOCATABLE
+// RELOCATABLE:  "-internal-isystem"
+// RELOCATABLE-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10"
+// RELOCATABLE:  "-L
+// RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
+// RELOCATABLE-NOT:  "-l
+// RELOCATABLE-NOT:  crt{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -487,7 +487,8 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
@@ -563,7 +564,8 @@
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 
   if (D.CCCIsCXX() &&
-  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+   options::OPT_r)) {
 if (ToolChain.ShouldLinkCXXStdlib(Args)) {
   bool OnlyLibstdcxxStatic = Args.hasArg(options::OPT_static_libstdcxx) &&
  !Args.hasArg(options::OPT_static);
@@ -578,7 +580,7 @@
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
-  if (!Args.hasArg(options::OPT_nostdlib)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_r)) {
 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
   if (IsStatic || IsStaticPIE)
 CmdArgs.push_back("--start-group");


Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -210,3 +210,14 @@
 // RUN: %clang -### %s --target=i686-linux-musl -mx32 --sysroot= \
 // RUN:   --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s --check-prefix=MUSL_X32
 // MUSL_X32: "-dynamic-linker" "/lib/ld-musl-x32.so.1"
+
+/// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/debian_multiarch_tree \
+// RUN:   -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin -resource-dir=%S/Inputs/resource_dir \
+// RUN:   --stdlib=platform --rtlib=platform -r 2>&1 | FileCheck %s --check-prefix=RELOCATABLE
+// RELOCATABLE:  "-internal-isystem"
+// RELOCATABLE-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10"
+// RELOCATABLE:  "-L
+// RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
+// RELOCATABLE-NOT:  "-l
+// RELOCATABLE-NOT:  crt{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -487,7 +487,8 @@
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+   options::OPT_r)) {
 if (!isAndroid && !IsIAMCU) {
   const char *crt1 = nullptr;
   if (!Args.hasArg(options::OPT_shared)) {
@@ -563,7 +564,8 @@
   getToolChain().addProfileRTLibs(Args, CmdArgs);
 
   if (D.CCCIsCXX() &&
-  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+  

[PATCH] D116633: Add -fsanitize-address-param-retval to clang.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1675
+  PosFlag, NegFlag,
+  BothFlags<[], "Detect uninitialized parameters and return values.">>,
+Group;

kda wrote:
> kda wrote:
> > MaskRay wrote:
> > > MaskRay wrote:
> > > > `--help` messages don't have periods.
> > > Does --help message render clearly?
> > Indeed:
> > 
> > ```
> >   -fsanitize-memory-param-retval
> >   EnableDetect uninitialized parameters and return 
> > values
> > ```
> Maybe not...
much better
```
  -fsanitize-memory-param-retval
  Enable detection of uninitialized parameters and 
return values
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116633

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


[PATCH] D116633: Add -fsanitize-address-param-retval to clang.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 398266.
kda added a comment.

refined rendering of help text


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116633

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1667,6 +1667,13 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+defm sanitize_memory_param_retval
+  : BoolOption<"f", "sanitize-memory-param-retval",
+  CodeGenOpts<"SanitizeMemoryParamRetval">,
+  DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[], " detection of uninitialized parameters and return 
values">>,
+Group;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -231,6 +231,9 @@
 ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+CODEGENOPT(SanitizeMemoryParamRetval, 1, 0) ///< Enable detection of 
uninitialized
+///< parameters and return values
+///< in MemorySanitizer
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1667,6 +1667,13 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+defm sanitize_memory_param_retval
+  : BoolOption<"f", "sanitize-memory-param-retval",
+  CodeGenOpts<"SanitizeMemoryParamRetval">,
+  DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[], " detection of uninitialized parameters and return values">>,
+Group;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -231,6 +231,9 @@
 ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+CODEGENOPT(SanitizeMemoryParamRetval, 1, 0) ///< Enable detection of uninitialized
+///< parameters and return values
+///< in MemorySanitizer
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114639: Raise the minimum Visual Studio version to VS2019

2022-01-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D114639#3199458 , @RKSimon wrote:

> @rnk I'm not certain but I think the only buildbot still using VS2017 is 
> windows-gcebot2 ?

Yes, it probably uses VS2017, and probably also the sanitizer-windows bot as 
well:
https://lab.llvm.org/buildbot/#/builders/sanitizer-windows
https://lab.llvm.org/buildbot/#/builders/clang-x64-windows-msvc

I'm going to delegate this task, so give me some time to get to it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114639

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


[PATCH] D116633: Add -fsanitize-address-param-retval to clang.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1675
+  PosFlag, NegFlag,
+  BothFlags<[], "Detect uninitialized parameters and return values.">>,
+Group;

kda wrote:
> MaskRay wrote:
> > MaskRay wrote:
> > > `--help` messages don't have periods.
> > Does --help message render clearly?
> Indeed:
> 
> ```
>   -fsanitize-memory-param-retval
>   EnableDetect uninitialized parameters and return 
> values
> ```
Maybe not...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116633

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


[PATCH] D116633: Add -fsanitize-address-param-retval to clang.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda updated this revision to Diff 398263.
kda added a comment.

  adjust help text


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116633

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1667,6 +1667,13 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+defm sanitize_memory_param_retval
+  : BoolOption<"f", "sanitize-memory-param-retval",
+  CodeGenOpts<"SanitizeMemoryParamRetval">,
+  DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[], "Detect uninitialized parameters and return values">>,
+Group;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -231,6 +231,8 @@
 ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+CODEGENOPT(SanitizeMemoryParamRetval, 1, 0) ///< Detect uninitialized 
parameters and return values
+ ///< in MemorySanitizer
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete 
detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1667,6 +1667,13 @@
   NormalizedValuesScope<"llvm::AsanDtorKind">,
   NormalizedValues<["None", "Global"]>,
   MarshallingInfoEnum, "Global">;
+defm sanitize_memory_param_retval
+  : BoolOption<"f", "sanitize-memory-param-retval",
+  CodeGenOpts<"SanitizeMemoryParamRetval">,
+  DefaultFalse,
+  PosFlag, NegFlag,
+  BothFlags<[], "Detect uninitialized parameters and return values">>,
+Group;
 // Note: This flag was introduced when it was necessary to distinguish between
 //   ABI for correct codegen.  This is no longer needed, but the flag is
 //   not removed since targeting either ABI will behave the same.
Index: clang/include/clang/Basic/CodeGenOptions.def
===
--- clang/include/clang/Basic/CodeGenOptions.def
+++ clang/include/clang/Basic/CodeGenOptions.def
@@ -231,6 +231,8 @@
 ENUM_CODEGENOPT(SanitizeAddressDtor, llvm::AsanDtorKind, 2,
 llvm::AsanDtorKind::Global)  ///< Set how ASan global
  ///< destructors are emitted.
+CODEGENOPT(SanitizeMemoryParamRetval, 1, 0) ///< Detect uninitialized parameters and return values
+ ///< in MemorySanitizer
 CODEGENOPT(SanitizeMemoryUseAfterDtor, 1, 0) ///< Enable use-after-delete detection
  ///< in MemorySanitizer
 CODEGENOPT(SanitizeCfiCrossDso, 1, 0) ///< Enable cross-dso support in CFI.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116633: Add -fsanitize-address-param-retval to clang.

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda marked 2 inline comments as done.
kda added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1675
+  PosFlag, NegFlag,
+  BothFlags<[], "Detect uninitialized parameters and return values.">>,
+Group;

MaskRay wrote:
> MaskRay wrote:
> > `--help` messages don't have periods.
> Does --help message render clearly?
Indeed:

```
  -fsanitize-memory-param-retval
  EnableDetect uninitialized parameters and return 
values
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116633

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


[PATCH] D115942: [X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match with ICC

2022-01-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

However, do we need to make changes to `llvm::UpgradeDataLayoutString`? 
Otherwise, I believe old bitcode for MSVC targets will no longer be able to be 
loaded for LTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115942

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


[PATCH] D115942: [X86][MS] Change the alignment of f80 to 16 bytes on Windows 32bits to match with ICC

2022-01-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D115942#3227047 , @pengfei wrote:

> In D115942#3226146 , @rnk wrote:
>
>> Yeah, let's try to reach some resolution on that.
>
> The things are different. We don't support f80 type on Windows 32 bits 
> previously. It means we don't have the burden to upgrade, since there's no 
> global/load/store/GEP/etc for f80.

Good point, I buy that argument.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115942

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


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1313
   }
+  if (IDs.empty())
+return {};

vitalybuka wrote:
> kda wrote:
> > It seems like the first line of 'findImplementors' is 'if (IDs.empty() || 
> > !Index)`.
> > I wonder if the correct fix is to drop the '!Index' check in 
> > findImplementors.
> Sorry, I am no following how "Index" is related to uninitialized QueryKind?
Oh.  Ignore some of my previous discussion, I missed the summary.

Why not just initialize QueryKind?
That seems like a more direct solution for the specific issue.
I believe it would be safe, as IDs is only inserted into when QueryKind is 
explicitly set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


[PATCH] D116835: Use sha256 for source file debug info checksums with MSVC compat >= 1930

2022-01-07 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think it's worth taking the time to hook up /ZH. Sorry we missed the patch 
last March.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116835

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


[PATCH] D116828: Initialize HighlightingsBuilder::Resolver

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG669eb6004670: Initialize HighlightingsBuilder::Resolver 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116828

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


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -468,7 +468,7 @@
   const LangOptions 
   std::vector Tokens;
   std::map> ExtraModifiers;
-  const HeuristicResolver *Resolver;
+  const HeuristicResolver *Resolver = nullptr;
   // returned from addToken(InvalidLoc)
   HighlightingToken InvalidHighlightingToken;
 };


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -468,7 +468,7 @@
   const LangOptions 
   std::vector Tokens;
   std::map> ExtraModifiers;
-  const HeuristicResolver *Resolver;
+  const HeuristicResolver *Resolver = nullptr;
   // returned from addToken(InvalidLoc)
   HighlightingToken InvalidHighlightingToken;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 669eb60 - Initialize HighlightingsBuilder::Resolver

2022-01-07 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-01-07T15:21:22-08:00
New Revision: 669eb60046706c096d4d7804359670f3ca18ed7a

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

LOG: Initialize HighlightingsBuilder::Resolver

Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1

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

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index 76e810f5a3b83..796efedcc3991 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -468,7 +468,7 @@ class HighlightingsBuilder {
   const LangOptions 
   std::vector Tokens;
   std::map> ExtraModifiers;
-  const HeuristicResolver *Resolver;
+  const HeuristicResolver *Resolver = nullptr;
   // returned from addToken(InvalidLoc)
   HighlightingToken InvalidHighlightingToken;
 };



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


[PATCH] D115183: [clang][HeaderSearch] Support framework includes in suggestPath...

2022-01-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Lex/HeaderSearch.cpp:1955
+  bool IsPrivateHeader;
+  SmallString<128> FrameworkName, IncludeSpelling;
+  if (BestPrefixIsFramework &&

sammccall wrote:
> nit: I don't think these strings need to be so big, framework includes are a 
> fairly uncommon case probably?
nvm, not sure where I got that idea.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115183

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


[PATCH] D115183: [clang][HeaderSearch] Support framework includes in suggestPath...

2022-01-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Lex/HeaderSearch.cpp:1955
+  bool IsPrivateHeader;
+  SmallString<128> FrameworkName, IncludeSpelling;
+  if (BestPrefixIsFramework &&

nit: I don't think these strings need to be so big, framework includes are a 
fairly uncommon case probably?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115183

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


[PATCH] D113752: [Parse] Use empty RecoveryExpr when if/while/do/switch conditions fail to parse

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

Anything left to do here?
I think it would be nice to get this into 14 release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113752

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


[PATCH] D113838: Sema: Don't erroneously reject `void{}`

2022-01-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This is CWG issue 2351. Please add a corresponding test to 
`tests/CXX/drs/dr23xx.cpp`.




Comment at: clang/lib/Sema/SemaInit.cpp:1311-1319
+  } else if (DeclType->isVoidType()) {
+// [expr.type.conv]p2: Otherwise, if the type is cv void and the
+// initializer is () or {} (after pack expansion, if any), the expression
+// is a prvalue of type void that performs no initialization.
+if (IList->getNumInits() > 0) {
+  if (!VerifyOnly)
+SemaRef.Diag(IList->getBeginLoc(), diag::err_init_list_void_nonempty);

Hm, this seems like the wrong place for this check, given the wording -- the 
language rule is specific to functional casts, and shouldn't apply to 
initialization of `void`-typed objects in general -- but perhaps it's the best 
place we have (and I think we deal with the `void()` case here in SemaInit 
too). Please at least make sure that we still properly reject things like:
```
void f() {
  return {};
}
```
We also need to decide whether to accept the compound-literal form of this:
```
void g() {
  (void){};
}
```
GCC trunk does, but I'm not sure whether that's intentional or an oversight. We 
certainly shouldn't accept that (without a diagnostic, at least) in C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113838

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


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:311
 llvm::StringRef MainFilePath) {
   if (IDs.empty() || !Index)
 return {};

here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D116827#3228594 , @vitalybuka 
wrote:

> In D116827#3228524 , @kda wrote:
>
>> This seems to introduce a new branch, should there be a new unit test in: 
>> XRefsTests.cpp?
>
> It's not functional change, test should not be able to see a difference after 
> this patch.

to clarify: it's not realy new branch, as findImplementors already does exactly 
the same check.
I considered removing that check, but it will complicated other callers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


[PATCH] D116840: [HIP] Fix device only linking for -fgpu-rdc

2022-01-07 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3173
+  AssociatedOffloadKind);
+AL.clear();
+// Offload the host object to the host linker.

Doing `clear()` in a function intended to append looks suspicious.  
We may potentially discard whatever was in AL on entry to the function, plus 
whatever has been added per `DeviceLinkerInputs`. 

I wonder if a better API would be to return a new action list, instead of 
modifying one. 

At the very least I'd like to see a comment explaining what's going on here 
and, maybe, some assertions (e.g. if we expect AL to be empty on entry).


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

https://reviews.llvm.org/D116840

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


[PATCH] D116764: [clang][OpenMP5.1] Initial parsing/sema for 'indirect' clause

2022-01-07 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 398249.
jyu2 added a comment.

Fix format problem.


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

https://reviews.llvm.org/D116764

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/AttrImpl.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/OpenMP/declare_target_ast_print.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -358,6 +358,7 @@
 def OMPC_Link : Clause<"link"> {
   let flangClass = "OmpObjectList";
 }
+def OMPC_Indirect : Clause<"indirect"> {}
 def OMPC_Inbranch : Clause<"inbranch"> {}
 def OMPC_Notinbranch : Clause<"notinbranch"> {}
 def OMPC_Filter : Clause<"filter"> {
@@ -973,12 +974,14 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
 }
 def OMP_DeclareTarget : Directive<"declare target"> {
   let allowedClauses = [
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_EndDeclareTarget : Directive<"end declare target"> {}
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1528,6 +1528,7 @@
 CHECK_SIMPLE_CLAUSE(Inbranch, OMPC_inbranch)
 CHECK_SIMPLE_CLAUSE(IsDevicePtr, OMPC_is_device_ptr)
 CHECK_SIMPLE_CLAUSE(Link, OMPC_link)
+CHECK_SIMPLE_CLAUSE(Indirect, OMPC_indirect)
 CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
 CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
 CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
Index: clang/test/OpenMP/declare_target_messages.cpp
===
--- clang/test/OpenMP/declare_target_messages.cpp
+++ clang/test/OpenMP/declare_target_messages.cpp
@@ -5,11 +5,13 @@
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,host5 -fopenmp-simd -fopenmp-targets=x86_64-apple-macos10.7.0 -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5,host5 -fopenmp-simd -fopenmp-is-device -fopenmp-targets=x86_64-apple-macos10.7.0 -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp -fopenmp-version=51 -fnoopenmp-use-tls -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp51 -fopenmp-version=51 -fopenmp-simd -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify=expected,omp5 -fopenmp -fnoopenmp-use-tls -ferror-limit 100 -o - %s
 #pragma omp end declare target // expected-error {{unexpected OpenMP directive '#pragma omp end declare target'}}
 
-int a, b, z; // omp5-error {{variable captured in declare target region must appear in a to clause}}
+int a, b, z; // omp5-error {{variable captured in declare target region must appear in a to clause}} // omp51-error {{variable captured in declare target region must appear in a to clause}}
 __thread int t; // expected-note {{defined as threadprivate or thread local}}
 
 #pragma omp declare target . // expected-error {{expected '(' after 'declare target'}}
@@ -18,7 +20,7 @@
 void f();
 #pragma omp end declare target shared(a) // expected-warning {{extra tokens at the end of '#pragma omp end declare target' are ignored}}
 
-#pragma omp declare target map(a) // expected-error {{expected at least one 'to' or 'link' clause}} omp45-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}} omp5-error {{unexpected 'map' clause, only 'to', 'link' or 'device_type' clauses expected}}
+#pragma omp declare target map(a) // omp45-error {{expected at least one 'to' or 'link' clause}} omp5-error {{expected at least one 'to' or 'link' clause}} omp51-error {{expected at least one 'to', 'link' or 'indirect' clause}} omp45-error {{unexpected 'map' clause, only 'to' or 'link' clauses expected}} omp5-error {{unexpected 'map' clause, only 'to', 'link' or 'device_type' clauses expected}} omp51-error {{unexpected 'map' clause, only 'to', 'link', 'device_type' or 'indirect' clauses expected}}
 
 #pragma omp declare target to(foo1) // expected-error {{use of undeclared identifier 'foo1'}}
 
@@ -27,17 +29,46 @@
 #pragma omp declare target 

[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D116827#3228524 , @kda wrote:

> This seems to introduce a new branch, should there be a new unit test in: 
> XRefsTests.cpp?

It's not functional change, test should not be able to see a difference after 
this patch.




Comment at: clang-tools-extra/clangd/XRefs.cpp:1313
   }
+  if (IDs.empty())
+return {};

kda wrote:
> It seems like the first line of 'findImplementors' is 'if (IDs.empty() || 
> !Index)`.
> I wonder if the correct fix is to drop the '!Index' check in findImplementors.
Sorry, I am no following how "Index" is related to uninitialized QueryKind?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


[PATCH] D116713: [clangd] Support configuration of inlay hints.

2022-01-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:51
   bool VisitCXXConstructExpr(CXXConstructExpr *E) {
+if (!Cfg.InlayHints.DeducedTypes)
+  return true;

hokein wrote:
> this should be `!Cfg.InlayHints.ParameterNames`.
> 
> What do you think the idea of moving guards deeper (`processCall` and 
> `addTypeHint`)? The code seems clearer and we don't have to add them in all 
> Visit* implementation,  this means that we pay cost of running some necessary 
> code, but I think it is trivial and probably worthy. 
I agree where to put the checks is an annoying question (and worth minimizing, 
since I've managed to get two wrong already).
I do think there needs to be a pattern so we don't accidentally skip checks.

- Easest is to postfilter (check in addInlayHint). That *does* hurt 
performance. Debug build on my laptop is ~170ms for all hints, ~160ms for 
postfilter with all categories disabled, ~5ms for current impl (prefilter) with 
all categories disabled. (On SemaCodeComplete.cpp, just eyeballing traces)
- Checking in VisitXXX methods (as done here) is a very regular pattern. 
Downside is you need many checks, and you can forget/break one
- Checks in helpers so that one is always hit (as you propose) touches fewer 
places but it's ad-hoc. I'm afraid of getting it wrong as the impl is modified 
(missing checks, doing too much work first, etc).
- Splitting RAV per category is an interesting option. Checking is very 
elegant, nicer code structure, can trace per-category latency, disabled 
categories can't crash... The downside is extra overhead, but this must be <5ms 
in the performance above. We can still choose to bundle simple categories 
together...

I think I'll do as you propose for now, improve the tests, and refactor to try 
to make it feel less ad-hoc later.
Also I should work out what we're spending 170ms on... EDIT: it turns out it's 
just assembling JSON objects :-\


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116713

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


[PATCH] D116272: [Clang][Sema] Avoid crashing for va_arg expressions with bool argument

2022-01-07 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

In D116272#3228427 , @tstellar wrote:

> We may have time to fit it in to the release, but no guarantees.  Can you 
> file an issue for this?

That would be great. I filed an issue: 
https://github.com/llvm/llvm-project/issues/53078.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116272

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


[PATCH] D116256: [-fms-extensions] Make some exception specification warnings/errors compatible with what cl.exe does

2022-01-07 Thread Amy Huang 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 rG28d2977ff236: [-fms-extensions] Make some exception 
specification warnings/errors compatible… (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116256

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 
-fms-compatibility-version=19.27
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 
-fms-compatibility-version=19.00
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 
-fms-compatibility-version=18.00
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++17 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+
 
 #if defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT
 char16_t x;
@@ -350,6 +352,7 @@
 void foo(); // expected-note {{previous declaration}}
 void foo() throw(); // expected-warning {{exception specification in 
declaration does not match previous declaration}}
 
+#if __cplusplus < 201703L
 void r6() throw(...); // expected-note {{previous declaration}}
 void r6() throw(int); // expected-warning {{exception specification in 
declaration does not match previous declaration}}
 
@@ -362,6 +365,7 @@
   virtual void f2() throw(...);
   virtual void f3();
 };
+#endif
 
 class A {
   virtual ~A() throw();
@@ -377,14 +381,14 @@
 #endif
 };
 
-}
+void f4() throw(); // expected-note {{previous declaration is here}}
+void f4() {}   // expected-warning {{'f4' is missing exception 
specification 'throw()'}}
 
-namespace PR25265 {
-struct S {
-  int fn() throw(); // expected-note {{previous declaration is here}}
-};
+__declspec(nothrow) void f5();
+void f5() {}
 
-int S::fn() { return 0; } // expected-warning {{is missing exception 
specification}}
+void f6() noexcept; // expected-note {{previous declaration is here}}
+void f6() {}// expected-error {{'f6' is missing exception 
specification 'noexcept'}}
 }
 
 namespace PR43265 {
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/lib/Sema/SemaExceptionSpec.cpp
+++ clang/lib/Sema/SemaExceptionSpec.cpp
@@ -391,9 +391,8 @@
 NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
   }
 
-  if (getLangOpts().MSVCCompat && ESI.Type != EST_DependentNoexcept) {
-// Allow missing exception specifications in redeclarations as an 
extension.
-DiagID = diag::ext_ms_missing_exception_specification;
+  if (getLangOpts().MSVCCompat && isDynamicExceptionSpec(ESI.Type)) {
+DiagID = diag::ext_missing_exception_specification;
 ReturnValueOnError = false;
   } else if (New->isReplaceableGlobalAllocationFunction() &&
  ESI.Type != EST_DependentNoexcept) {
@@ -402,6 +401,10 @@
 DiagID = diag::ext_missing_exception_specification;
 ReturnValueOnError = false;
   } else if (ESI.Type == EST_NoThrow) {
+// Don't emit any warning for missing 'nothrow' in MSVC.
+if (getLangOpts().MSVCCompat) {
+  return false;
+}
 // Allow missing attribute 'nothrow' in redeclarations, since this is a 
very
 // common omission.
 DiagID = diag::ext_missing_exception_specification;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1695,9 +1695,6 @@
 def ext_missing_exception_specification : ExtWarn<
   err_missing_exception_specification.Text>,
   InGroup>;
-def ext_ms_missing_exception_specification : ExtWarn<
-  err_missing_exception_specification.Text>,
-  InGroup;
 def err_noexcept_needs_constant_expression : Error<
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<


Index: clang/test/SemaCXX/MicrosoftCompatibility.cpp
===
--- clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 

[clang] 28d2977 - [-fms-extensions] Make some exception specification warnings/errors compatible with what cl.exe does

2022-01-07 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2022-01-07T14:42:16-08:00
New Revision: 28d2977ff236dffa2a955714aee86e798ca9acd9

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

LOG: [-fms-extensions] Make some exception specification warnings/errors 
compatible with what cl.exe does

Make clang-cl error when a function definition is missing 'noexcept',
and succeed without warnings when missing '__declspec(nothrow)' or 'throw'.

Fixes pr52860

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExceptionSpec.cpp
clang/test/SemaCXX/MicrosoftCompatibility.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index afc63d480627..1c8cd79910ad 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1695,9 +1695,6 @@ def err_missing_exception_specification : Error<
 def ext_missing_exception_specification : ExtWarn<
   err_missing_exception_specification.Text>,
   InGroup>;
-def ext_ms_missing_exception_specification : ExtWarn<
-  err_missing_exception_specification.Text>,
-  InGroup;
 def err_noexcept_needs_constant_expression : Error<
   "argument to noexcept specifier must be a constant expression">;
 def err_exception_spec_not_parsed : Error<

diff  --git a/clang/lib/Sema/SemaExceptionSpec.cpp 
b/clang/lib/Sema/SemaExceptionSpec.cpp
index 3af4c6f4bc41..29cb4be7b1ba 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -391,9 +391,8 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, 
FunctionDecl *New) {
 NewProto->getExtProtoInfo().withExceptionSpec(ESI)));
   }
 
-  if (getLangOpts().MSVCCompat && ESI.Type != EST_DependentNoexcept) {
-// Allow missing exception specifications in redeclarations as an 
extension.
-DiagID = diag::ext_ms_missing_exception_specification;
+  if (getLangOpts().MSVCCompat && isDynamicExceptionSpec(ESI.Type)) {
+DiagID = diag::ext_missing_exception_specification;
 ReturnValueOnError = false;
   } else if (New->isReplaceableGlobalAllocationFunction() &&
  ESI.Type != EST_DependentNoexcept) {
@@ -402,6 +401,10 @@ bool Sema::CheckEquivalentExceptionSpec(FunctionDecl *Old, 
FunctionDecl *New) {
 DiagID = diag::ext_missing_exception_specification;
 ReturnValueOnError = false;
   } else if (ESI.Type == EST_NoThrow) {
+// Don't emit any warning for missing 'nothrow' in MSVC.
+if (getLangOpts().MSVCCompat) {
+  return false;
+}
 // Allow missing attribute 'nothrow' in redeclarations, since this is a 
very
 // common omission.
 DiagID = diag::ext_missing_exception_specification;

diff  --git a/clang/test/SemaCXX/MicrosoftCompatibility.cpp 
b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
index 20d478d1b591..961a63cada20 100644
--- a/clang/test/SemaCXX/MicrosoftCompatibility.cpp
+++ b/clang/test/SemaCXX/MicrosoftCompatibility.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 
-fms-compatibility-version=19.27
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 
-fms-compatibility-version=19.00
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions 
-fms-compatibility-version=18.00
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++17 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
+
 
 #if defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT
 char16_t x;
@@ -350,6 +352,7 @@ namespace microsoft_exception_spec {
 void foo(); // expected-note {{previous declaration}}
 void foo() throw(); // expected-warning {{exception specification in 
declaration does not match previous declaration}}
 
+#if __cplusplus < 201703L
 void r6() throw(...); // expected-note {{previous declaration}}
 void r6() throw(int); // expected-warning {{exception specification in 
declaration does not match previous declaration}}
 
@@ -362,6 +365,7 @@ struct Derived : Base {
   virtual void f2() throw(...);
   virtual void f3();
 };
+#endif
 
 class A {
   virtual ~A() throw();
@@ -377,14 +381,14 @@ class B : public A {
 #endif
 };
 
-}
+void f4() throw(); // expected-note {{previous declaration is here}}
+void f4() {}   // expected-warning {{'f4' is missing exception 
specification 'throw()'}}
 
-namespace PR25265 {
-struct S {
-  int fn() throw(); // expected-note {{previous declaration is here}}
-};

[PATCH] D116840: [HIP] Fix device only linking for -fgpu-rdc

2022-01-07 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

Currently when -fgpu-rdc is specified, HIP toolchain always does host linking 
even
if --cuda-device-only is specified.

This patch fixes that. Only device linking is performed when --cuda-device-only
is specified.


https://reviews.llvm.org/D116840

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/hip-phases.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip

Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -88,47 +88,66 @@
 // RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
 // RUN:   -fuse-ld=lld -fgpu-rdc -nogpuinc \
 // RUN:   %T/a.o %T/b.o \
-// RUN: 2>&1 | FileCheck -check-prefix=LINK %s
+// RUN: 2>&1 | FileCheck -check-prefixes=LINK,LINK-HOST-UNBUNDLE,LLD-TMP,LINK-BUNDLE,LINK-EMBED %s
 
-// LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// LINK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
-// LINK-SAME: "-inputs=[[A_O:.*a.o]]" "-outputs=[[A_OBJ_HOST:.*o]],{{.*o}},{{.*o}}"
-// LINK: "-unbundle" "-allow-missing-bundles"
+// RUN: %clang --hip-link -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -fuse-ld=lld -fgpu-rdc -nogpuinc \
+// RUN:   %T/a.o %T/b.o --cuda-device-only \
+// RUN: 2>&1 | FileCheck -check-prefixes=LINK,LLD-TMP,LINK-BUNDLE,LINK-NOEMBED %s
 
-// LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// LINK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
-// LINK-SAME: "-inputs=[[B_O:.*b.o]]" "-outputs=[[B_OBJ_HOST:.*o]],{{.*o}},{{.*o}}"
-// LINK: "-unbundle" "-allow-missing-bundles"
+// RUN: %clang --hip-link -### -target x86_64-linux-gnu \
+// RUN:   --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 \
+// RUN:   -fuse-ld=lld -fgpu-rdc -nogpuinc \
+// RUN:   %T/a.o %T/b.o --cuda-device-only --no-gpu-bundle-output \
+// RUN: 2>&1 | FileCheck -check-prefixes=LINK,LLD-FIN,LINK-NOBUNDLE,LINK-NOEMBED %s
+
+// LINK-HOST-UNBUNDLE: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
+// LINK-HOST-UNBUNDLE-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
+// LINK-HOST-UNBUNDLE-SAME: "-inputs=[[A_O:.*a.o]]" "-outputs=[[A_OBJ_HOST:.*o]],{{.*o}},{{.*o}}"
+// LINK-HOST-UNBUNDLE: "-unbundle" "-allow-missing-bundles"
+
+// LINK-HOST-UNBUNDLE: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
+// LINK-HOST-UNBUNDLE-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
+// LINK-HOST-UNBUNDLE-SAME: "-inputs=[[B_O:.*b.o]]" "-outputs=[[B_OBJ_HOST:.*o]],{{.*o}},{{.*o}}"
+// LINK-HOST-UNBUNDLE: "-unbundle" "-allow-missing-bundles"
 
 // LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
-// LINK-SAME: "-inputs=[[A_O]]" "-outputs={{.*o}},[[A_BC1:.*o]],[[A_BC2:.*o]]"
-// LINK: "-unbundle" "-allow-missing-bundles"
+// LINK-SAME: "-inputs=[[A_O:.*a.o]]" "-outputs={{.*o}},[[A_BC1:.*o]],[[A_BC2:.*o]]"
+// LINK-SAME: "-unbundle" "-allow-missing-bundles"
 
 // LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-SAME: "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
-// LINK-SAME: "-inputs=[[B_O]]" "-outputs={{.*o}},[[B_BC1:.*o]],[[B_BC2:.*o]]"
-// LINK: "-unbundle" "-allow-missing-bundles"
+// LINK-SAME: "-inputs=[[B_O:.*b.o]]" "-outputs={{.*o}},[[B_BC1:.*o]],[[B_BC2:.*o]]"
+// LINK-SAME: "-unbundle" "-allow-missing-bundles"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
-// LINK: "-plugin-opt=mcpu=gfx803"
-// LINK-SAME: "-o" "[[IMG_DEV1:.*.out]]" "[[A_BC1]]" "[[B_BC1]]"
+// LINK-SAME: "-plugin-opt=mcpu=gfx803"
+// LLD-TMP-SAME: "-o" "[[IMG_DEV1:.*.out]]"
+// LLD-FIN-SAME: "-o" "[[IMG_DEV1:a.out-.*gfx803]]"
+// LINK-SAME "[[A_BC1]]" "[[B_BC1]]"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
 // LINK: {{".*lld.*"}} {{.*}} "-plugin-opt=-amdgpu-internalize-symbols"
-// LINK: "-plugin-opt=mcpu=gfx900"
-// LINK-SAME: "-o" "[[IMG_DEV2:.*.out]]" "[[A_BC2]]" "[[B_BC2]]"
-
-// LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// LINK-SAME: "-targets={{.*}},hipv4-amdgcn-amd-amdhsa--gfx803,hipv4-amdgcn-amd-amdhsa--gfx900"
-// LINK-SAME: "-inputs={{.*}},[[IMG_DEV1]],[[IMG_DEV2]]" "-outputs=[[BUNDLE:.*hipfb]]"
-
-// LINK: {{".*llvm-mc.*"}} "-o" "[[OBJBUNDLE:.*o]]" "{{.*}}.mcin" "--filetype=obj"
-
-// LINK: [[LD:".*ld.*"]] {{.*}} "-o" "a.out" {{.*}} "[[A_OBJ_HOST]]"
-// LINK-SAME: "[[B_OBJ_HOST]]" "[[OBJBUNDLE]]"
+// LINK-SAME: 

[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda requested changes to this revision.
kda added a comment.
This revision now requires changes to proceed.

I think I forgot to 'Request Changes'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Kevin Athey via Phabricator via cfe-commits
kda added a comment.

This seems to introduce a new branch, should there be a new unit test in: 
XRefsTests.cpp?




Comment at: clang-tools-extra/clangd/XRefs.cpp:1313
   }
+  if (IDs.empty())
+return {};

It seems like the first line of 'findImplementors' is 'if (IDs.empty() || 
!Index)`.
I wonder if the correct fix is to drop the '!Index' check in findImplementors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116827

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


[PATCH] D116059: [Clang][CFG] check children statements of asm goto

2022-01-07 Thread Nick Desaulniers 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 rG3a604fdbcd5f: [Clang][CFG] check children statements of asm 
goto (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116059

Files:
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Analysis/asm-goto.cpp
  clang/test/Analysis/uninit-asm-goto.cpp
  clang/test/Sema/array-bounds-ptr-arith.c

Index: clang/test/Sema/array-bounds-ptr-arith.c
===
--- clang/test/Sema/array-bounds-ptr-arith.c
+++ clang/test/Sema/array-bounds-ptr-arith.c
@@ -37,3 +37,15 @@
   RDar11387038_B *pRDar11387038_B;
   struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4];
 }
+
+void pr51682 (void) {
+  int arr [1];
+  switch (0) {
+case 0:
+  break;
+case 1:
+  asm goto (""::"r"(arr[42] >> 1)::failed); // no-warning
+  break;
+  }
+failed:;
+}
Index: clang/test/Analysis/uninit-asm-goto.cpp
===
--- clang/test/Analysis/uninit-asm-goto.cpp
+++ clang/test/Analysis/uninit-asm-goto.cpp
@@ -3,19 +3,19 @@
 // test1: Expect no diagnostics
 int test1(int x) {
 int y;
-asm goto("nop" : "=r"(y) : "r"(x) : : err);
+asm goto("" : "=r"(y) : "r"(x) : : err);
 return y;
   err:
 return -1;
 }
 
 int test2(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
- // expected-note {{initialize the variable}}
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
+ // expected-note@-1 {{initialize the variable}}
   if (x < 42)
-asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
+asm goto("" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
   else
-asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2);
+asm goto("" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2);
   return x + y;
 indirect_1:
   return -42;
@@ -24,9 +24,9 @@
 }
 
 int test3(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
- // expected-note {{initialize the variable}}
-  asm goto("xorl %1, %0; jmp %l2" : "="(y) : "r"(x) : : fail);
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
+ // expected-note@-1 {{initialize the variable}}
+  asm goto("" : "="(y) : "r"(x) : : fail);
 normal:
   y += x;
   return y;
@@ -38,20 +38,20 @@
 }
 
 int test4(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
- // expected-note {{initialize the variable}}
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}}
+ // expected-note@-1 {{initialize the variable}}
   goto forward;
 backward:
   return y; // expected-note {{uninitialized use occurs here}}
 forward:
-  asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : backward);
+  asm goto("" : "=r"(y) : "r"(x) : : backward);
   return y;
 }
 
 // test5: Expect no diagnostics
 int test5(int x) {
   int y;
-  asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough);
+  asm goto("" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough);
 fallthrough:
   return y;
 indirect:
@@ -63,9 +63,30 @@
   unsigned int val;
 
   // See through casts and unary operators.
-  asm goto("nop" : "=r" (*(unsigned int *)()) ::: indirect);
+  asm goto("" : "=r" (*(unsigned int *)()) ::: indirect);
   *x = val;
   return 0;
 indirect:
   return -1;
 }
+
+int test7(int z) {
+int x; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}}
+   // expected-note@-1 {{initialize the variable 'x' to silence this warning}}
+if (z)
+  asm goto ("":"=r"(x):::A1,A2);
+return 0;
+A1:
+A2:
+return x; // expected-note {{uninitialized use occurs here}}
+}
+
+int test8() {
+int x = 0; // expected-warning {{variable 'x' is used uninitialized whenever its declaration is reached}}
+   // expected-note@-1 {{variable 'x' is declared here}}
+asm goto ("":"=r"(x):::A1,A2);
+return 0;
+A1:
+A2:
+return x; // expected-note {{uninitialized use occurs here}}
+}
Index: clang/test/Analysis/asm-goto.cpp
===
--- clang/test/Analysis/asm-goto.cpp
+++ clang/test/Analysis/asm-goto.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1  -triple i386-pc-linux-gnu -analyzer-checker=debug.DumpCFG %s 2>&1 | 

[clang] 3a604fd - [Clang][CFG] check children statements of asm goto

2022-01-07 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2022-01-07T14:11:08-08:00
New Revision: 3a604fdbcd5fd9ca41f6659692bb4ad2151c3cf4

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

LOG: [Clang][CFG] check children statements of asm goto

When performing CFG based analyses, don't forget to check the child
statements of an asm goto, such as the expressions used for
inputs+outputs.

Fixes: https://github.com/llvm/llvm-project/issues/51024
Fixes: https://github.com/ClangBuiltLinux/linux/issues/1439

Reviewed By: void, jyknight, jyu2, efriedma

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

Added: 


Modified: 
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/UninitializedValues.cpp
clang/test/Analysis/asm-goto.cpp
clang/test/Analysis/uninit-asm-goto.cpp
clang/test/Sema/array-bounds-ptr-arith.c

Removed: 




diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 9bde034d5e099..8246854dc1b51 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -3352,7 +3352,7 @@ CFGBlock *CFGBuilder::VisitGCCAsmStmt(GCCAsmStmt *G, 
AddStmtChoice asc) {
   // Save "Succ" in BackpatchBlocks. In the backpatch processing, "Succ" is
   // used to avoid adding "Succ" again.
   BackpatchBlocks.push_back(JumpSource(Succ, ScopePos));
-  return Block;
+  return VisitChildren(G);
 }
 
 CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {

diff  --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index a38ae34f4b811..811146e50b45a 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -819,12 +819,11 @@ void TransferFunctions::VisitGCCAsmStmt(GCCAsmStmt *as) {
 while (const auto *UO = dyn_cast(Ex))
   Ex = stripCasts(C, UO->getSubExpr());
 
+// Mark the variable as potentially uninitialized for those cases where
+// it's used on an indirect path, where it's not guaranteed to be
+// defined.
 if (const VarDecl *VD = findVar(Ex).getDecl())
-  if (vals[VD] != Initialized)
-// If the variable isn't initialized by the time we get here, then we
-// mark it as potentially uninitialized for those cases where it's used
-// on an indirect path, where it's not guaranteed to be defined.
-vals[VD] = MayUninitialized;
+  vals[VD] = MayUninitialized;
   }
 }
 

diff  --git a/clang/test/Analysis/asm-goto.cpp 
b/clang/test/Analysis/asm-goto.cpp
index bc212f800401a..75f907a209b2d 100644
--- a/clang/test/Analysis/asm-goto.cpp
+++ b/clang/test/Analysis/asm-goto.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1  -triple i386-pc-linux-gnu 
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
-// RUN: %clang_analyze_cc1  -triple x86_64-pc-linux-gnu 
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -triple i386-pc-linux-gnu 
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -triple x86_64-pc-linux-gnu 
-analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
 
 int foo(int cond)
 {
@@ -17,11 +17,12 @@ int foo(int cond)
 // CHECK-NEXT: Succs (1): B0
 
 // CHECK-LABEL: label_true
-// CHECK-NEXT: asm goto
+// CHECK-NEXT: cond
+// CHECK-NEXT: [B3.1]
+// CHECK-NEXT: T: asm goto
 // CHECK-NEXT: Preds (2): B3 B4
 // CHECK-NEXT: Succs (3): B2 B3 B1
 
-
 int bar(int cond)
 {
   asm goto("testl %0, %0; jne %l1;" :: "r"(cond)::L1, L2);
@@ -32,7 +33,9 @@ int bar(int cond)
 }
 
 // CHECK: [B4]
-// CHECK-NEXT: asm goto
+// CHECK-NEXT: cond
+// CHECK-NEXT: [B4.1]
+// CHECK-NEXT: T: asm goto
 // CHECK-NEXT: Preds (1): B5
 // CHECK-NEXT: Succs (3): B3 B2 B1
 
@@ -48,6 +51,20 @@ int zoo(int n)
 }
 
 // CHECK-LABEL: A1
-// CHECK-NEXT: asm goto
+// CHECK-NEXT: n
+// CHECK-NEXT: [B4.1]
+// CHECK-NEXT: T: asm goto
 // CHECK-NEXT: Preds (2): B5 B4
 // CHECK-NEXT: Succs (5): B3 B4 B2 B1 B5
+
+void baz(void)
+{
+  asm goto("" :: "r"(1 ? 2 : 0 << -1) :: error);
+error:;
+}
+
+// CHECK: [B2]
+// CHECK-NEXT: 1: [B5.2] ? [B3.1] : [B4.4]
+// CHECK-NEXT: T: asm goto ("" :  : "r" ([B2.1]) :  : error);
+// CHECK-NEXT: Preds (2): B3 B4
+// CHECK-NEXT: Succs (1): B1

diff  --git a/clang/test/Analysis/uninit-asm-goto.cpp 
b/clang/test/Analysis/uninit-asm-goto.cpp
index 9da21584ec864..1b9d1689b036f 100644
--- a/clang/test/Analysis/uninit-asm-goto.cpp
+++ b/clang/test/Analysis/uninit-asm-goto.cpp
@@ -3,19 +3,19 @@
 // test1: Expect no diagnostics
 int test1(int x) {
 int y;
-asm goto("nop" : "=r"(y) : "r"(x) : : err);
+asm goto("" : "=r"(y) : "r"(x) : : err);
 return y;
   err:
 return -1;
 }
 
 int test2(int x) {
-  int y; // expected-warning {{variable 'y' is used uninitialized whenever its 
declaration is reached}} \
- // expected-note {{initialize the variable}}
+  int y; 

[PATCH] D111566: [SYCL] Fix function pointer address space

2022-01-07 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added inline comments.



Comment at: clang/lib/CodeGen/CodeGenTypes.cpp:636-638
+unsigned AS = PointeeType->isFunctionTy()
+  ? getDataLayout().getProgramAddressSpace()
+  : Context.getTargetAddressSpace(ETy);

rjmccall wrote:
> aaron.ballman wrote:
> > eandrews wrote:
> > > aaron.ballman wrote:
> > > > The review summary says that this is a fix for SYCL, but the fix itself 
> > > > happens for all targets, not just SYCL. If that's intentional, are we 
> > > > sure it's correct?
> > > Yes this affects all targets. To be honest, I'm not sure if this change 
> > > is correct for CUDA/openCL, etc. My first patch (which I didn't upload) 
> > > restricted the change to SYCL. However, I saw the same thing was done in 
> > > a generic manner for function pointers  - 
> > > https://github.com/llvm/llvm-project/commit/57fd86de879cf2b4c7001b6d0a09df60877ce24d,
> > >  and so followed the same logic. I'm hoping reviewers more familiar with 
> > > address spaces can help here. 
> > @Anastasia -- can you comment as OpenCL code owner?
> I think the more systematic fix is probably for `getTargetAddressSpace` to 
> check for function types and return the program address space, yeah.
@rjmccall @dylanmckay I took a look into this today. Moving the code to 
`getTargetAddressSpace ` causes a few openCL tests to fail because address 
space changes for block pointers.

```
 case Type::BlockPointer: {
 const QualType FTy = cast(Ty)->getPointeeType();
 llvm::Type *PointeeType = CGM.getLangOpts().OpenCL
   ? CGM.getGenericBlockLiteralType()
   : ConvertTypeForMem(FTy);
 unsigned AS = Context.getTargetAddressSpace(FTy);
 ResultType = llvm::PointerType::get(PointeeType, AS);
 break;
   }
```
Here PointeeType (FTy) is a function type and so 
Context.getTargetAddressSpace(FTy) will return ProgramAddressSpace after my 
change. 

IR Change  - 


```
void foo(){
int (^ block_B)(void) = ^{
return i;
  };
  block_B();
}

OLDIR   %block_B = alloca %struct.__opencl_block_literal_generic addrspace(4)*, 
align 4
---
NEWIR   %block_B = alloca %struct.__opencl_block_literal_generic*, align 4
```

Would you know if this is correct behavior for block pointers? Or is the 
existing behavior correct here?

I apologize for the delay in responding to your review. I did not get a chance 
to work on this before I left for vacation last month.


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

https://reviews.llvm.org/D111566

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


[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

2022-01-07 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 398231.
owenpan added a comment.

- Use `verifyFormat` instead of `EXPECT_EQ`.
- Make this option have less impact on the unwrapped line parser by checking 
`Style.RemoveBracesLLVM`.
- Remove some unused code.


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

https://reviews.llvm.org/D116316

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18682,6 +18682,7 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
+  CHECK_PARSE_BOOL(RemoveBracesLLVM);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -23020,6 +23021,319 @@
Style);
 }
 
+TEST_F(FormatTest, RemoveBraces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.RemoveBracesLLVM = true;
+
+  // The following eight test cases are fully-braced versions of the examples at
+  // "llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-
+  // statement-bodies-of-if-else-loop-statements".
+
+  // 1. Omit the braces, since the body is simple and clearly associated with
+  // the if.
+  verifyFormat("if (isa(D))\n"
+   "  handleFunctionDecl(D);\n"
+   "else if (isa(D))\n"
+   "  handleVarDecl(D);",
+   "if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else if (isa(D)) {\n"
+   "  handleVarDecl(D);\n"
+   "}",
+   Style);
+
+  // 2. Here we document the condition itself and not the body.
+  verifyFormat("if (isa(D)) {\n"
+   "  // It is necessary that we explain the situation with this\n"
+   "  // surprisingly long comment, so it would be unclear\n"
+   "  // without the braces whether the following statement is in\n"
+   "  // the scope of the `if`.\n"
+   "  // Because the condition is documented, we can't really\n"
+   "  // hoist this comment that applies to the body above the\n"
+   "  // if.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 3. Use braces on the outer `if` to avoid a potential dangling else
+  // situation.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs())\n"
+   "if (shouldProcessAttr(A))\n"
+   "  handleAttr(A);\n"
+   "}",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "if (shouldProcessAttr(A)) {\n"
+   "  handleAttr(A);\n"
+   "}\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 4. Use braces for the `if` block to keep it uniform with the else block.
+  verifyFormat("if (isa(D)) {\n"
+   "  handleFunctionDecl(D);\n"
+   "} else {\n"
+   "  // In this else case, it is necessary that we explain the\n"
+   "  // situation with this surprisingly long comment, so it\n"
+   "  // would be unclear without the braces whether the\n"
+   "  // following statement is in the scope of the `if`.\n"
+   "  handleOtherDecl(D);\n"
+   "}",
+   Style);
+
+  // 5. This should also omit braces.  The `for` loop contains only a single
+  // statement, so it shouldn't have braces.  The `if` also only contains a
+  // single simple statement (the for loop), so it also should omit braces.
+  verifyFormat("if (isa(D))\n"
+   "  for (auto *A : D.attrs())\n"
+   "handleAttr(A);",
+   "if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 6. Use braces for the outer `if` since the nested `for` is braced.
+  verifyFormat("if (isa(D)) {\n"
+   "  for (auto *A : D.attrs()) {\n"
+   "// In this for loop body, it is necessary that we explain\n"
+   "// the situation with this surprisingly long comment,\n"
+   "// forcing braces on the `for` block.\n"
+   "handleAttr(A);\n"
+   "  }\n"
+   "}",
+   Style);
+
+  // 7. Use braces on the outer block because there are more than two levels of
+  // nesting.
+  verifyFormat("if (isa(D)) {\n"
+   "  

[PATCH] D116713: [clangd] Support configuration of inlay hints.

2022-01-07 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 398228.
sammccall marked 2 inline comments as done.
sammccall added a comment.

Simplify & fix category checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116713

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -6,11 +6,13 @@
 //
 //===--===//
 #include "Annotations.h"
+#include "Config.h"
 #include "InlayHints.h"
 #include "Protocol.h"
 #include "TestTU.h"
 #include "TestWorkspace.h"
 #include "XRefs.h"
+#include "support/Context.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -24,6 +26,8 @@
 namespace {
 
 using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAre;
 
 std::vector hintsOfKind(ParsedAST , InlayHintKind Kind) {
   std::vector Result;
@@ -56,6 +60,13 @@
 
 MATCHER_P(labelIs, Label, "") { return arg.label == Label; }
 
+Config noHintsConfig() {
+  Config C;
+  C.InlayHints.Parameters = false;
+  C.InlayHints.DeducedTypes = false;
+  return C;
+}
+
 template 
 void assertHints(InlayHintKind Kind, llvm::StringRef AnnotatedSource,
  ExpectedHints... Expected) {
@@ -66,6 +77,10 @@
 
   EXPECT_THAT(hintsOfKind(AST, Kind),
   ElementsAre(HintMatcher(Expected, Source)...));
+  // Sneak in a cross-cutting check that hints are disabled by config.
+  // We'll hit an assertion failure if addInlayHint still gets called.
+  WithContextValue WithCfg(Config::Key, noHintsConfig());
+  EXPECT_THAT(inlayHints(AST, llvm::None), IsEmpty());
 }
 
 // Hack to allow expression-statements operating on parameter packs in C++14.
Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -228,6 +228,23 @@
   ASSERT_EQ(Results.size(), 1u);
   EXPECT_THAT(Results[0].Hover.ShowAKA, llvm::ValueIs(Val(true)));
 }
+
+TEST(ParseYAML, InlayHints) {
+  CapturedDiags Diags;
+  Annotations YAML(R"yaml(
+InlayHints:
+  Enabled: No
+  ParameterNames: Yes
+  )yaml");
+  auto Results =
+  Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+  ASSERT_EQ(Results.size(), 1u);
+  EXPECT_THAT(Results[0].InlayHints.Enabled, llvm::ValueIs(Val(false)));
+  EXPECT_THAT(Results[0].InlayHints.ParameterNames, llvm::ValueIs(Val(true)));
+  EXPECT_EQ(Results[0].InlayHints.DeducedTypes, llvm::None);
+}
+
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 #include "InlayHints.h"
+#include "Config.h"
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
 #include "clang/AST/DeclarationName.h"
@@ -23,8 +24,8 @@
 class InlayHintVisitor : public RecursiveASTVisitor {
 public:
   InlayHintVisitor(std::vector , ParsedAST ,
-   llvm::Optional RestrictRange)
-  : Results(Results), AST(AST.getASTContext()),
+   const Config , llvm::Optional RestrictRange)
+  : Results(Results), AST(AST.getASTContext()), Cfg(Cfg),
 RestrictRange(std::move(RestrictRange)),
 MainFileID(AST.getSourceManager().getMainFileID()),
 Resolver(AST.getHeuristicResolver()),
@@ -65,6 +66,9 @@
   }
 
   bool VisitCallExpr(CallExpr *E) {
+if (!Cfg.InlayHints.Parameters)
+  return true;
+
 // Do not show parameter hints for operator calls written using operator
 // syntax or user-defined literals. (Among other reasons, the resulting
 // hints can look awkard, e.g. the expression can itself be a function
@@ -135,7 +139,7 @@
   // the entire argument list likely appears in the main file and can be hinted.
   void processCall(SourceLocation Anchor, const FunctionDecl *Callee,
llvm::ArrayRef Args) {
-if (Args.size() == 0 || !Callee)
+if (!Cfg.InlayHints.Parameters || Args.size() == 0 || !Callee)
   return;
 
 // If the anchor location comes from a macro defintion, there's nowhere to
@@ -323,6 +327,23 @@
   void 

[PATCH] D116272: [Clang][Sema] Avoid crashing for va_arg expressions with bool argument

2022-01-07 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

We may have time to fit it in to the release, but no guarantees.  Can you file 
an issue for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116272

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


[PATCH] D116059: [Clang][CFG] check children statements of asm goto

2022-01-07 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 accepted this revision.
jyu2 added a comment.

Looks good to me.  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116059

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


[PATCH] D116272: [Clang][Sema] Avoid crashing for va_arg expressions with bool argument

2022-01-07 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

Thank you @aaron.ballman, I will try to get this patch into the next 13.0.x 
release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116272

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


[PATCH] D116585: Fix wrong JS import linebreak

2022-01-07 Thread Armen Khachkinaev via Phabricator via cfe-commits
futuarmo abandoned this revision.
futuarmo added a comment.

Issue was fixed by other patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116585

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


[PATCH] D116492: [lld] Deprecate using llvm-config to detect llvm installation

2022-01-07 Thread John Ericson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1da5f3c2d65: [lld] Deprecate using llvm-config to detect 
llvm installation (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116492

Files:
  lld/CMakeLists.txt

Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -1,58 +1,77 @@
+cmake_minimum_required(VERSION 3.13.4)
+
 include(GNUInstallDirs)
 
-# Check if lld is built as a standalone project.
+# If we are not building as a part of LLVM, build LLD as an
+# standalone project, using LLVM as an external library:
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(lld)
-  cmake_minimum_required(VERSION 3.13.4)
 
   set(CMAKE_INCLUDE_CURRENT_DIR ON)
-  set(LLD_BUILT_STANDALONE TRUE)
 
-  find_program(LLVM_CONFIG_PATH "llvm-config" DOC "Path to llvm-config binary")
-  if(NOT LLVM_CONFIG_PATH)
-message(FATAL_ERROR "llvm-config not found: specify LLVM_CONFIG_PATH")
-  endif()
+  # Rely on llvm-config.
+  set(LLVM_CONFIG_OUTPUT)
+  if(LLVM_CONFIG)
+set (LLVM_CONFIG_FOUND 1)
+message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
+  deprecated.  The installed cmake files should be used \
+  instead.  CMake should be able to detect your LLVM install \
+  automatically, but you can also use LLVM_DIR to specify \
+  the path containing LLVMConfig.cmake.")
+set(CONFIG_COMMAND ${LLVM_CONFIG}
+  "--includedir"
+  "--prefix"
+  "--src-root"
+  "--cmakedir"
+  )
+execute_process(
+  COMMAND ${CONFIG_COMMAND}
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
+)
+if(NOT HAD_ERROR)
+  string(REGEX REPLACE
+"[ \t]*[\r\n]+[ \t]*" ";"
+LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT})
+else()
+  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
+  message(STATUS "${CONFIG_COMMAND_STR}")
+  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
+endif()
+
+list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR)
+list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
+list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR)
+list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR)
 
-  execute_process(COMMAND "${LLVM_CONFIG_PATH}"
-  "--obj-root"
-  "--includedir"
-  "--cmakedir"
-  "--src-root"
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
-  OUTPUT_STRIP_TRAILING_WHITESPACE)
-  if(HAD_ERROR)
-message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
+# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes.
+# CMake assumes slashes as PATH.
+file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR)
   endif()
 
-  string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" LLVM_CONFIG_OUTPUT "${LLVM_CONFIG_OUTPUT}")
+  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
+  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
 
-  list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
-  list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_DIR)
-  list(GET LLVM_CONFIG_OUTPUT 3 MAIN_SRC_DIR)
+  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
+  # LLVM_CONFIG.
+  if (NOT LLVM_CONFIG_FOUND)
+# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
+# path is removed.
+set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
+set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+  endif()
 
-  set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree")
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "path to llvm/include")
+  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
   set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
-  file(TO_CMAKE_PATH "${LLVM_OBJ_ROOT}" LLVM_BINARY_DIR)
-  file(TO_CMAKE_PATH "${LLVM_CMAKE_DIR}" LLVM_CMAKE_DIR)
-
-  if(NOT EXISTS "${LLVM_CMAKE_DIR}/LLVMConfig.cmake")
-message(FATAL_ERROR "LLVMConfig.cmake not found")
-  endif()
-  include("${LLVM_CMAKE_DIR}/LLVMConfig.cmake")
-
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
+  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
+NO_DEFAULT_PATH)
 
-  set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
-  include_directories("${LLVM_BINARY_DIR}/include" ${LLVM_INCLUDE_DIRS})
-  link_directories(${LLVM_LIBRARY_DIRS})
-
-  set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
+  # They are used as destination of target 

[PATCH] D114908: [clang] Don't call inheritDefaultTemplateArguments() on CXXDeductionGuideDecl's template parameters

2022-01-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Serialization/ASTReaderDecl.cpp:3784-3790
+  if (auto *TD = dyn_cast(D)) {
+// CXXDeductionGuideDecls reference the class template parameters so we 
need
+// to make sure not to call this twice on the same template parameters.
+if (!isa(TD->getTemplatedDecl()))
+  inheritDefaultTemplateArguments(Reader.getContext(),
+  cast(Previous), TD);
+  }

An implicit deduction guide can get template parameters from both the class 
template and the constructor template. The ones from the class template are not 
copied and owned by the deduction guide, but the ones from the constructor 
template are. So I think we may need to do this for *some* of the template 
parameters and not others. Perhaps we could check to see if the template 
parameter is actually owned by this template and skip updating it if not.

(Alternatively, I think it'd be fine, and probably simpler and cleaner, to make 
implicit deduction guide generation always clone the template parameters of the 
class template. The confusion caused by having the template parameters appear 
in the "wrong" template is probably not justified by the time / memory savings.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114908

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


[PATCH] D100810: [llvm] Use `GNUInstallDirs` to support custom installation dirs

2022-01-07 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 398219.
Ericson2314 marked 4 inline comments as done.
Ericson2314 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100810

Files:
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMInstallSymlink.cmake
  llvm/docs/CMake.rst
  llvm/examples/Bye/CMakeLists.txt
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/opt-viewer/CMakeLists.txt
  llvm/tools/remarks-shlib/CMakeLists.txt

Index: llvm/tools/remarks-shlib/CMakeLists.txt
===
--- llvm/tools/remarks-shlib/CMakeLists.txt
+++ llvm/tools/remarks-shlib/CMakeLists.txt
@@ -19,7 +19,7 @@
   endif()
   
   install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/Remarks.h
-DESTINATION include/llvm-c
+DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
 COMPONENT Remarks)
 
   if (APPLE)
Index: llvm/tools/opt-viewer/CMakeLists.txt
===
--- llvm/tools/opt-viewer/CMakeLists.txt
+++ llvm/tools/opt-viewer/CMakeLists.txt
@@ -8,7 +8,7 @@
 
 foreach (file ${files})
   install(PROGRAMS ${file}
-DESTINATION share/opt-viewer
+DESTINATION "${CMAKE_INSTALL_DATADIR}/opt-viewer"
 COMPONENT opt-viewer)
 endforeach (file)
 
Index: llvm/tools/lto/CMakeLists.txt
===
--- llvm/tools/lto/CMakeLists.txt
+++ llvm/tools/lto/CMakeLists.txt
@@ -33,7 +33,7 @@
 ${SOURCES} DEPENDS intrinsics_gen)
 
 install(FILES ${LLVM_MAIN_INCLUDE_DIR}/llvm-c/lto.h
-  DESTINATION include/llvm-c
+  DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/llvm-c"
   COMPONENT LTO)
 
 if (APPLE)
Index: llvm/tools/llvm-config/llvm-config.cpp
===
--- llvm/tools/llvm-config/llvm-config.cpp
+++ llvm/tools/llvm-config/llvm-config.cpp
@@ -357,10 +357,16 @@
 ("-I" + ActiveIncludeDir + " " + "-I" + ActiveObjRoot + "/include");
   } else {
 ActivePrefix = CurrentExecPrefix;
-ActiveIncludeDir = ActivePrefix + "/include";
-SmallString<256> path(LLVM_TOOLS_INSTALL_DIR);
-sys::fs::make_absolute(ActivePrefix, path);
-ActiveBinDir = std::string(path.str());
+{
+  SmallString<256> Path(LLVM_INSTALL_INCLUDEDIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveIncludeDir = std::string(Path.str());
+}
+{
+  SmallString<256> Path(LLVM_TOOLS_INSTALL_DIR);
+  sys::fs::make_absolute(ActivePrefix, Path);
+  ActiveBinDir = std::string(Path.str());
+}
 ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
 ActiveCMakeDir = ActiveLibDir + "/cmake/llvm";
 ActiveIncludeOption = "-I" + ActiveIncludeDir;
Index: llvm/tools/llvm-config/BuildVariables.inc.in
===
--- llvm/tools/llvm-config/BuildVariables.inc.in
+++ llvm/tools/llvm-config/BuildVariables.inc.in
@@ -23,6 +23,7 @@
 #define LLVM_CXXFLAGS "@LLVM_CXXFLAGS@"
 #define LLVM_BUILDMODE "@LLVM_BUILDMODE@"
 #define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define LLVM_INSTALL_INCLUDEDIR "@CMAKE_INSTALL_INCLUDEDIR@"
 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
Index: llvm/examples/Bye/CMakeLists.txt
===
--- llvm/examples/Bye/CMakeLists.txt
+++ llvm/examples/Bye/CMakeLists.txt
@@ -14,6 +14,6 @@
 BUILDTREE_ONLY
)
 
-  install(TARGETS ${name} RUNTIME DESTINATION examples)
+  install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}")
   set_target_properties(${name} PROPERTIES FOLDER "Examples")
 endif()
Index: llvm/docs/CMake.rst
===
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -252,6 +252,22 @@
   Sets the C++ standard to conform to when building LLVM.  Possible values are
   14, 17, 20.  LLVM Requires C++ 14 or higher.  This defaults to 14.
 
+**CMAKE_INSTALL_BINDIR**:PATH
+  The path to install executables, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "bin".
+
+**CMAKE_INSTALL_INCLUDEDIR**:PATH
+  The path to install header files, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "include".
+
+**CMAKE_INSTALL_DOCDIR**:PATH
+  The path to install documentation, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "share/doc".
+
+**CMAKE_INSTALL_MANDIR**:PATH
+  The path to install manpage files, relative to the *CMAKE_INSTALL_PREFIX*.
+  Defaults to "share/man".
+
 .. _LLVM-related variables:
 
 LLVM-related variables
@@ -598,12 +614,12 @@
 

[PATCH] D116512: [clang-tidy] Limit non-Strict mode to public functions

2022-01-07 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini abandoned this revision.
mehdi_amini added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-unused-parameters.rst:43
+   a human reader, and there's basically no place for a bug to hide. On the 
other
+   hand for non-public functions, all the call-sites are visible and the 
parameter
+   can be eliminated entirely.

aaron.ballman wrote:
> mehdi_amini wrote:
> > aaron.ballman wrote:
> > > Call sites are not always visible for protected functions, so this seems 
> > > a bit suspicious. The changes are missing test coverage for that 
> > > situation.
> > You're using `public` for "access control" while I was using the linkage 
> > aspect: my reasoning is that if a method isn't "externally visible" from 
> > the current translation unit, you see all the call-sites. This is 
> > orthogonal to public/private/protected as far as I know.
> > 
> > I am likely missing a check for "isDefinedInMainFile" (or whatever the api 
> > is called) to not flag included headers.
> > You're using public for "access control" while I was using the linkage 
> > aspect: my reasoning is that if a method isn't "externally visible" from 
> > the current translation unit, you see all the call-sites.
> 
> Oh, thanks for pointing out that I was confused! I'm not used to "public" 
> when describing linkage, usually that's "external" or "externally visible". 
> Any appetite for rewording in those terms? Something like "On the other hand, 
> for functions with internal linkage, all the call sites are visible and 
> parameters can be safely removed."
Sure: happy to reword.

(We use public/private for symbol visibility at a module level in MLIR 
unfortunately, I've been "contaminated" ;) ).



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp:157-159
+// CHECK-FIXES: C() {}
+  C(int i) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning

aaron.ballman wrote:
> mehdi_amini wrote:
> > aaron.ballman wrote:
> > > I think this demonstrates a bad fix -- this changes code meaning from 
> > > being a converting constructor to being a default constructor, which are 
> > > very different things.
> > Oh you're right: so we can't do it for a Ctor with a single parameter...
> > 
> > But we also can't do it for a Ctor with two parameters as it'll turn it 
> > into a converting ctor. Unless you can eliminate both parameters, in which 
> > case it is become a default ctor (which can conflict with an existing one, 
> > in which case it can be just deleted?)
> Yeah, I think we need to not transform ctors at all currently.
In this case I can fix the existing bug by disabling the fixit  (as discussed 
in D116513) and abandon this revision I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116512

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


[PATCH] D116113: Add LLDB synthetic child and summary scripts for llvm::SmallVector, llvm::Optional, llvm::ErrorOr and llvm::Expected.

2022-01-07 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

How does this relate to the code in `llvm/utils/lldbDataFormatters.py` and 
should it be added there instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116113

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


[PATCH] D116386: [clang-tidy] Narrow cppguidelines-macro-usage to actual constants

2022-01-07 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a reviewer: JonasToth.
LegalizeAdulthood added a comment.

I'm adding the original author of this check as a reviewer.


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

https://reviews.llvm.org/D116386

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


[PATCH] D116386: [clang-tidy] Narrow cppguidelines-macro-usage to actual constants

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

In D116386#3227236 , @aaron.ballman 
wrote:

> We're in strong agreement that guideline checkers with untenable false 
> positive rates are a
> very bad thing. I think this particular check is of insufficient quality to 
> have been added in
> the first place because it's based on a set of rules that are not generally 
> enforceable in a
> way that isn't a constantly nagging for reasonable real world code.

I think this guideline is mostly what this check is trying to accomplish:
ES.31: Don't use macros for constants or "functions"

Now, for the first part about constants, the check was issuing way too many
false positives.  That's what I fix in this review: it now only suggests that 
the
macro be replaced with a `constexpr` constant when the macro expansion is
truly a constant.

Ironically I was working on my own check that covers some aspects of 
"Enum.1: Prefer enumerations over macros 
".
However, there isn't any way an automated tool could recognize the example
given in the guidelines because the macros in question don't share a common
prefix, which I've found is a good heuristic for enums disguised as macros.
There are additional heuristics one could apply, such as when a bunch of
constant macros are defined on successive lines.


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

https://reviews.llvm.org/D116386

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


[PATCH] D116492: [lld] Deprecate using llvm-config to detect llvm installation

2022-01-07 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz 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/D116492/new/

https://reviews.llvm.org/D116492

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


[PATCH] D116425: [clang-tidy] Improve modernize-redundant-void-arg to recognize macro uses

2022-01-07 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-redundant-void-arg.cpp:561
+#define return_t(T) T
+return_t(void) func(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: redundant void argument list in 
function declaration

jrtc27 wrote:
> LegalizeAdulthood wrote:
> > LegalizeAdulthood wrote:
> > > aaron.ballman wrote:
> > > > LegalizeAdulthood wrote:
> > > > > aaron.ballman wrote:
> > > > > > Can you also add a test for:
> > > > > > ```
> > > > > > void func(return_t(void));
> > > > > > ```
> > > > > `:-)`
> > > > > 
> > > > > What are you suggesting the result should be?  Honestly, looking at 
> > > > > that, I'm not sure myself `:)`
> > > > > 
> > > > > IMO, if I saw this in a code review, I would flag it because you're 
> > > > > using a macro called "return type" to specify the type of an argument.
> > > > LoL, yeah, the name `return_t` would certainly be novel to use in a 
> > > > parameter list, but what I was hoping to test is whether we try to fix 
> > > > the use of the macro within the parameter list or not. I *think* it 
> > > > probably makes sense to issue the diagnostic, but I don't think it 
> > > > makes sense to try to fix it because the macro could be defined 
> > > > differently for different configurations. But the diagnostic is 
> > > > silenced as well as the fix-it, I wouldn't lose a whole lot of sleep 
> > > > over it.
> > > Well it could conceivably be used to declare a function pointer argument 
> > > like this:
> > > 
> > > `void func(return_t(void) (*fp)(void));`
> > > 
> > > In that case, my expectation is that the check would fix the void arg, 
> > > but not the arg to the macro.
> > OK, that was a good idea to add the test I described above because it 
> > failed `:)`,
> > so let me improve the check some more.
> If you want a less-contrived example that shows up all over the place in 
> crusty old C code that supports (or, perhaps, supported and let bitrot 
> support for) pre-ANSI C compilers:
> 
> ```
> #define __P(x) x
> void foo __P((void));
> ```
> 
> (the idea being that, for pre-ANSI C compilers, you'd instead define __P(x) 
> as () to get `void foo ();`)
Well, in (modern) C you don't want to remove the `void` in `(void)` at all.

This check applies only to C++ code, so we should be safe here.

I'll add a test case just to cover it -- I think the correct result should be
that the check leaves this instance of `(void)` intact.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116425

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


[PATCH] D116835: Use sha256 for source file debug info checksums with MSVC compat >= 1930

2022-01-07 Thread Arlo Siemsen via Phabricator via cfe-commits
arlosi added a comment.

I submitted a change last year to hook up the /ZH option, but it was never 
completed. https://reviews.llvm.org/D98438


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116835

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


[PATCH] D116521: [CMake] Factor out config prefix finding logic

2022-01-07 Thread John Ericson 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 rG44e336577510: [CMake] Factor out config prefix finding logic 
(authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116521

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/CMakeLists.txt
  cmake/Modules/FindPrefixFromConfig.cmake
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/CMakeLists.txt
  mlir/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt

Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -1,4 +1,5 @@
 include(LLVMDistributionSupport)
+include(FindPrefixFromConfig)
 
 # Generate a list of CMake library targets so that other CMake projects can
 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
@@ -44,16 +45,7 @@
   )
 
 # Generate MLIRConfig.cmake for the install tree.
-set(MLIR_CONFIG_CODE "
-# Compute the installation prefix from this MLIRConfig.cmake file location.
-get_filename_component(MLIR_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${MLIR_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(MLIR_CONFIG_CODE "${MLIR_CONFIG_CODE}
-get_filename_component(MLIR_INSTALL_PREFIX \"\${MLIR_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+find_prefix_from_config(MLIR_CONFIG_CODE MLIR_INSTALL_PREFIX "${MLIR_INSTALL_PACKAGE_DIR}")
 set(MLIR_CONFIG_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${MLIR_INSTALL_PACKAGE_DIR}")
 set(MLIR_CONFIG_LLVM_CMAKE_DIR "\${MLIR_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 get_config_exports_includes(MLIR MLIR_CONFIG_INCLUDE_EXPORTS)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -33,7 +33,16 @@
 set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
 set(MLIR_TOOLS_DIR   ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
 
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+# Make sure that our source directory is on the current cmake module path so
+# that we can include cmake files from this directory.
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
 
 include(AddMLIR)
 
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -1,4 +1,5 @@
 include(LLVMDistributionSupport)
+include(FindPrefixFromConfig)
 
 set(LLVM_INSTALL_PACKAGE_DIR lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm)
 set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/${LLVM_INSTALL_PACKAGE_DIR}")
@@ -99,16 +100,7 @@
   )
 
 # Generate LLVMConfig.cmake for the install tree.
-set(LLVM_CONFIG_CODE "
-# Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(LLVM_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${LLVM_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(LLVM_CONFIG_CODE "${LLVM_CONFIG_CODE}
-get_filename_component(LLVM_INSTALL_PREFIX \"\${LLVM_INSTALL_PREFIX}\" PATH)")
-endforeach(p)
+find_prefix_from_config(LLVM_CONFIG_CODE LLVM_INSTALL_PREFIX "${LLVM_INSTALL_PACKAGE_DIR}")
 set(LLVM_CONFIG_INCLUDE_DIRS "\${LLVM_INSTALL_PREFIX}/include")
 set(LLVM_CONFIG_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
 set(LLVM_CONFIG_MAIN_INCLUDE_DIR "${LLVM_CONFIG_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -200,11 +200,13 @@
   set(LLVM_GISEL_COV_PREFIX "${CMAKE_BINARY_DIR}/gisel-coverage-" CACHE STRING "Provide a filename prefix to collect the GlobalISel rule coverage")
 endif()
 
+set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+
 # Add path for custom modules
-set(CMAKE_MODULE_PATH
-  ${CMAKE_MODULE_PATH}
+list(INSERT CMAKE_MODULE_PATH 0
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
   "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
   )
 
 # Generate a CompilationDatabase (compile_commands.json file) for our build,
@@ -312,7 +314,6 @@
 set(LLVM_BINARY_DIR   ${CMAKE_CURRENT_BINARY_DIR}  ) # --prefix
 
 set(LLVM_THIRD_PARTY_DIR  ${CMAKE_CURRENT_SOURCE_DIR}/../third-party)
-set(LLVM_COMMON_CMAKE_UTILS 

[clang] 44e3365 - [CMake] Factor out config prefix finding logic

2022-01-07 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2022-01-07T20:16:18Z
New Revision: 44e3365775101fec3fd355eda339282258d74415

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

LOG: [CMake] Factor out config prefix finding logic

See the docs in the new function for details.

 I think I found every instance of this copy pasted code. Polly could
 also use it, but currently does something different, so I will save the
 behavior change for a future revision.

We get the shared, non-installed CMake modules following the pattern
established in D116472.

It might be good to have LLD and Flang also use this, but that would be
a functional change and so I leave it as future work.

Reviewed By: beanz, lebedev.ri

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

Added: 
cmake/Modules/FindPrefixFromConfig.cmake

Modified: 
clang/CMakeLists.txt
clang/cmake/modules/CMakeLists.txt
flang/cmake/modules/CMakeLists.txt
lld/cmake/modules/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/CMakeLists.txt
mlir/CMakeLists.txt
mlir/cmake/modules/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index aa21d05882430..7ea37850ad609 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -192,9 +192,16 @@ else()
   set(BACKEND_PACKAGE_STRING "${PACKAGE_STRING}")
 endif() # standalone
 
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
 # Make sure that our source directory is on the current cmake module path so 
that
 # we can include cmake files from this directory.
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
 
 if(LLVM_ENABLE_LIBXML2)
   # Don't look for libxml if we're using MSan, since uninstrumented third party

diff  --git a/clang/cmake/modules/CMakeLists.txt 
b/clang/cmake/modules/CMakeLists.txt
index 561665d58cad9..3890ea14d06c6 100644
--- a/clang/cmake/modules/CMakeLists.txt
+++ b/clang/cmake/modules/CMakeLists.txt
@@ -1,4 +1,5 @@
 include(LLVMDistributionSupport)
+include(FindPrefixFromConfig)
 
 # Generate a list of CMake library targets so that other CMake projects can
 # link against them. LLVM calls its version of this file LLVMExports.cmake, but
@@ -29,16 +30,7 @@ set(CLANG_CONFIG_CMAKE_DIR)
 set(CLANG_CONFIG_LLVM_CMAKE_DIR)
 
 # Generate ClangConfig.cmake for the install tree.
-set(CLANG_CONFIG_CODE "
-# Compute the installation prefix from this LLVMConfig.cmake file location.
-get_filename_component(CLANG_INSTALL_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" 
PATH)")
-# Construct the proper number of get_filename_component(... PATH)
-# calls to compute the installation prefix.
-string(REGEX REPLACE "/" ";" _count "${CLANG_INSTALL_PACKAGE_DIR}")
-foreach(p ${_count})
-  set(CLANG_CONFIG_CODE "${CLANG_CONFIG_CODE}
-get_filename_component(CLANG_INSTALL_PREFIX \"\${CLANG_INSTALL_PREFIX}\" 
PATH)")
-endforeach(p)
+find_prefix_from_config(CLANG_CONFIG_CODE CLANG_INSTALL_PREFIX 
"${CLANG_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${CLANG_INSTALL_PACKAGE_DIR}")
 set(CLANG_CONFIG_LLVM_CMAKE_DIR 
"\${CLANG_INSTALL_PREFIX}/${LLVM_INSTALL_PACKAGE_DIR}")
 get_config_exports_includes(Clang CLANG_CONFIG_INCLUDE_EXPORTS)

diff  --git a/cmake/Modules/FindPrefixFromConfig.cmake 
b/cmake/Modules/FindPrefixFromConfig.cmake
new file mode 100644
index 0..aa9fb0d03413d
--- /dev/null
+++ b/cmake/Modules/FindPrefixFromConfig.cmake
@@ -0,0 +1,41 @@
+# Find the prefix from the `*Config.cmake` file being generated.
+#
+# When generating an installed `*Config.cmake` file, we often want to be able
+# to refer to the ancestor directory which contains all the installed files.
+#
+# We want to do this without baking in an absolute path when the config file is
+# generated, in order to allow for a "relocatable" binary distribution that
+# doesn't need to know what path it ends up being installed at when it is
+# built.
+#
+# The solution that we know the relative path that the config file will be at
+# within that prefix, like `"${prefix_var}/lib/cmake/${project}"`, so we count
+# the number of components in that path to figure out how many parent dirs we
+# need to traverse from the location of the config file to get to the prefix
+# dir.
+#
+# out_var:
+#   variable to set the "return value" of the function, which is the code to
+#   include in the config file under construction.
+#
+# prefix_var:
+#   Name of the variable to define in the returned code (not directory for the
+#   faller!) that will contain the prefix path.
+#
+# path_to_leave:
+#   Path from the prefix to the config file, a 

[PATCH] D116835: Use sha256 for source file debug info checksums with MSVC compat >= 1930

2022-01-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

After sending this, I realized we should probably have a test to make sure it 
gets all the way into the .o and .pdb files correctly...

And, maybe we should hook up the /ZH flag? 
(https://docs.microsoft.com/en-us/cpp/build/reference/zh?view=msvc-170=true
 still says MD5 is default, but I guess that's just out of date)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116835

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


[PATCH] D116835: Use sha256 for source file debug info checksums with MSVC compat >= 1930

2022-01-07 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk, arlosi.
Herald added subscribers: dexonsmith, hiraditya.
hans requested review of this revision.
Herald added projects: clang, LLVM.

>From the VS2022 release notes, it sounds like newer MSVC versions are using 
>SHA256 for these checksums: (search for "SHA-256" in 
>https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes#17.0.0)

Since D75785  laid the groundwork, let's hook 
it up.

While here, I noticed llvm::SHA256 doesn't have a method to get the hash as a 
hex string, like llvm::MD5. But we can use llvm::toHex() and actually that 
could be made more efficient and llvm::MD5 could use that too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116835

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/debug-info-file-checksum.c
  llvm/include/llvm/ADT/StringExtras.h
  llvm/include/llvm/Support/MD5.h
  llvm/lib/Support/MD5.cpp

Index: llvm/lib/Support/MD5.cpp
===
--- llvm/lib/Support/MD5.cpp
+++ llvm/lib/Support/MD5.cpp
@@ -40,10 +40,9 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Endian.h"
-#include "llvm/Support/Format.h"
-#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -281,14 +280,12 @@
 
 SmallString<32> MD5::MD5Result::digest() const {
   SmallString<32> Str;
-  raw_svector_ostream Res(Str);
-  for (int i = 0; i < 16; ++i)
-Res << format("%.2x", Bytes[i]);
+  toHex(Bytes, /*LowerCase*/ true, Str);
   return Str;
 }
 
-void MD5::stringifyResult(MD5Result , SmallString<32> ) {
-  Str = Result.digest();
+void MD5::stringifyResult(MD5Result , SmallVectorImpl ) {
+  toHex(Result.Bytes, /*LowerCase*/ true, Str);
 }
 
 std::array MD5::hash(ArrayRef Data) {
Index: llvm/include/llvm/Support/MD5.h
===
--- llvm/include/llvm/Support/MD5.h
+++ llvm/include/llvm/Support/MD5.h
@@ -88,7 +88,7 @@
 
   /// Translates the bytes in \p Res to a hex string that is
   /// deposited into \p Str. The result will be of length 32.
-  static void stringifyResult(MD5Result , SmallString<32> );
+  static void stringifyResult(MD5Result , SmallVectorImpl );
 
   /// Computes the hash for a given bytes.
   static std::array hash(ArrayRef Data);
Index: llvm/include/llvm/ADT/StringExtras.h
===
--- llvm/include/llvm/ADT/StringExtras.h
+++ llvm/include/llvm/ADT/StringExtras.h
@@ -162,21 +162,26 @@
   return std::string(BufPtr, std::end(Buffer));
 }
 
-/// Convert buffer \p Input to its hexadecimal representation.
-/// The returned string is double the size of \p Input.
-inline std::string toHex(StringRef Input, bool LowerCase = false) {
+inline void toHex(ArrayRef Input, bool LowerCase,
+  SmallVectorImpl ) {
   static const char *const LUT = "0123456789ABCDEF";
   const uint8_t Offset = LowerCase ? 32 : 0;
   size_t Length = Input.size();
+  Output.resize_for_overwrite(Length * 2);
 
-  std::string Output;
-  Output.reserve(2 * Length);
   for (size_t i = 0; i < Length; ++i) {
-const unsigned char c = Input[i];
-Output.push_back(LUT[c >> 4] | Offset);
-Output.push_back(LUT[c & 15] | Offset);
+const uint8_t c = Input[i];
+Output[i * 2] = LUT[c >> 4] | Offset;
+Output[i * 2 + 1] = LUT[c & 15] | Offset;
   }
-  return Output;
+}
+
+/// Convert buffer \p Input to its hexadecimal representation.
+/// The returned string is double the size of \p Input.
+inline std::string toHex(StringRef Input, bool LowerCase = false) {
+  SmallString<16> Output;
+  toHex(arrayRefFromStringRef(Input), LowerCase, Output);
+  return std::string(Output);
 }
 
 inline std::string toHex(ArrayRef Input, bool LowerCase = false) {
Index: clang/test/CodeGen/debug-info-file-checksum.c
===
--- clang/test/CodeGen/debug-info-file-checksum.c
+++ clang/test/CodeGen/debug-info-file-checksum.c
@@ -16,3 +16,7 @@
 // RUN: %clang -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix CHECKSUM
 
 // CHECKSUM: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_MD5, checksum: "7b568574d0e3c56c28e5e0234d1f4a06")
+
+// Later MSVC versions use SHA256.
+// RUN: %clang -target i686-pc-windows-msvc19.30.0 -emit-llvm -S -g -gcodeview -x c %S/Inputs/debug-info-file-checksum-line.cpp -o - | FileCheck %s --check-prefix SHA256
+// SHA256: !DIFile(filename: "{{.*}}debug-info-file-checksum-line.cpp", directory:{{.*}}, checksumkind: CSK_SHA256, checksum: 

[PATCH] D116521: [CMake] Factor out config prefix finding logic

2022-01-07 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116521

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


[PATCH] D115103: Leak Sanitizer port to Windows

2022-01-07 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser added a comment.

All the lsan tests, when run in lsan+asan mode, Deadlock in `StopTheWord` when 
creating the tracer thread...
F21505206: image.png 
-> `check-lsan` gets stuck, due to all the deadlocking tests :(

Could it be caused by asan intercepting the Win32 calls in `StopTheWorld?
@vitalybuka Could this be a problem? If so, how can I call the "real" 
functions, without being intercepted by asan?
Is there a way (for now), to only run the lsan tests in lsan only mode (no 
asan)?


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

https://reviews.llvm.org/D115103

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


[PATCH] D116521: [CMake] Factor out config prefix finding logic

2022-01-07 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Seems like a cleanup to me, and consistent with D116524 
.
Soft-accept, but only if D116524  is accepted 
first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116521

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


[PATCH] D116806: [clang-format] Ensure we can correctly parse lambda in the template argument list

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



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2872-2874
+  if (FormatTok->is(tok::l_square))
+if (!tryToParseLambda())
+  break;

Fewer ifs and lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116806

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


[PATCH] D116834: [clang][dataflow] Change `transfer` function to update lattice element in place.

2022-01-07 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: sgatev, gribozavr2.
ymandel requested review of this revision.
Herald added a project: clang.

Currently, the transfer function returns a new lattice element, which forces an
unnecessary copy on processing each CFG statement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116834

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -113,9 +113,8 @@
 
   static NonConvergingLattice initialElement() { return {0}; }
 
-  NonConvergingLattice transfer(const Stmt *S, const NonConvergingLattice ,
-Environment ) {
-return {E.State + 1};
+  void transfer(const Stmt *S, NonConvergingLattice , Environment ) {
+++E.State;
   }
 };
 
@@ -165,15 +164,12 @@
 
   static FunctionCallLattice initialElement() { return {}; }
 
-  FunctionCallLattice transfer(const Stmt *S, const FunctionCallLattice ,
-   Environment ) {
-FunctionCallLattice R = E;
+  void transfer(const Stmt *S, FunctionCallLattice , Environment ) {
 if (auto *C = dyn_cast(S)) {
   if (auto *F = dyn_cast(C->getCalleeDecl())) {
 R.CalledFunctions.insert(F->getNameInfo().getAsString());
   }
 }
-return R;
   }
 };
 
Index: clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
@@ -121,9 +121,8 @@
 return ConstantPropagationLattice::bottom();
   }
 
-  ConstantPropagationLattice transfer(const Stmt *S,
-  const ConstantPropagationLattice ,
-  Environment ) {
+  void transfer(const Stmt *S, ConstantPropagationLattice ,
+Environment ) {
 auto matcher = stmt(
 anyOf(declStmt(hasSingleDecl(varDecl(hasType(isInteger()),
  hasInitializer(expr().bind(kInit)))
@@ -137,7 +136,7 @@
 ASTContext  = getASTContext();
 auto Results = match(matcher, *S, Context);
 if (Results.empty())
-  return Element;
+  return;
 const BoundNodes  = Results[0];
 
 const auto *Var = Nodes.getNodeAs(kVar);
@@ -145,30 +144,26 @@
 
 if (const auto *E = Nodes.getNodeAs(kInit)) {
   Expr::EvalResult R;
-  if (E->EvaluateAsInt(R, Context) && R.Val.isInt())
-return ConstantPropagationLattice{
-{{Var, R.Val.getInt().getExtValue()}}};
-  return ConstantPropagationLattice::top();
-}
-
-if (Nodes.getNodeAs(kJustAssignment)) {
+  Element =
+  (E->EvaluateAsInt(R, Context) && R.Val.isInt())
+  ? ConstantPropagationLattice{{{Var,
+ R.Val.getInt().getExtValue()}}}
+  : ConstantPropagationLattice::top();
+} else if (Nodes.getNodeAs(kJustAssignment)) {
   const auto *RHS = Nodes.getNodeAs(kRHS);
   assert(RHS != nullptr);
 
   Expr::EvalResult R;
-  if (RHS->EvaluateAsInt(R, Context) && R.Val.isInt())
-return ConstantPropagationLattice{
-{{Var, R.Val.getInt().getExtValue()}}};
-  return ConstantPropagationLattice::top();
-}
-
-// Any assignment involving the expression itself resets the variable to
-// "unknown". A more advanced analysis could try to evaluate the compound
-// assignment. For example, `x += 0` need not invalidate `x`.
-if (Nodes.getNodeAs(kAssignment))
-  return ConstantPropagationLattice::top();
-
-llvm_unreachable("expected at least one bound identifier");
+  Element =
+  (RHS->EvaluateAsInt(R, Context) && R.Val.isInt())
+  ? ConstantPropagationLattice{{{Var,
+ R.Val.getInt().getExtValue()}}}
+  : ConstantPropagationLattice::top();
+} else if (Nodes.getNodeAs(kAssignment))
+  // Any assignment involving the expression itself resets the variable to
+  // "unknown". A more advanced analysis could try to evaluate the compound
+  // assignment. For example, `x += 0` need not 

[PATCH] D115060: [clang-format][NFC] Code Tidies in UnwrappedLineFormatter

2022-01-07 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks planned changes to this revision.
HazardyKnusperkeks marked 2 inline comments as done.
HazardyKnusperkeks added a comment.

In D115060#3227120 , @owenpan wrote:

> Maybe option 4 for now

So I can get it through.

> and the refactoring in another patch?

Probably won't do it.




Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:317
+   : 0;
+  }
+  if (TheLine->First->isOneOf(tok::kw_else, tok::kw_catch) &&

owenpan wrote:
> Ditto.
Same.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:335-360
+  // Handle empty record blocks where the brace has already been wrapped.
+  if (TheLine->Last->is(tok::l_brace) && TheLine->First == TheLine->Last) {
+bool EmptyBlock = NextLine.First->is(tok::r_brace);
+
+const FormatToken *Tok = PreviousLine.First;
+if (Tok && Tok->is(tok::comment))
+  Tok = Tok->getNextNonComment();

owenpan wrote:
> Handling empty record blocks here instead of earlier may have unknown side 
> effects?
Of course it //may// have side effects.


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

https://reviews.llvm.org/D115060

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


[PATCH] D116833: [clang][Sema] Disable -Wc++20-designator in system macros

2022-01-07 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7161
+!DiagnosedNestedDesignator && !DiagnosedMixedDesignator &&
+!getSourceManager().isInSystemMacro(FirstDesignator)) {
   Diag(FirstDesignator, getLangOpts().CPlusPlus20

rsmith wrote:
> I think we should be checking `Diags.getSuppressSystemWarnings()` before 
> considering whether we're in a system header. (Eg, if we're building libc++ 
> and it enables warnings even in system headers, we want to warn if it uses 
> non-C++ designator syntax.)
> 
> Given that this is something that we will presumably want to do for a bunch 
> of diagnostics, not just this one, I think we should extend the current 
> `ShowInSystemHeader` / `SuppressInSystemHeader` markings in our diagnostics 
> `.td` files to also have a `SuppressInSystemMacro` level, and handle this 
> centrally with the other "suppress warnings in system headers" logic, rather 
> than special-casing this here.
Thanks for the quick feedback!

Fully agree, thanks for the pointers. I tried to apply a similar fix [[ 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/DiagnosticIDs.cpp#L584
 | here ]] but got quite a few tests failing so I thought maybe the intention 
was to apply this on a case-by-case basis.

I'll see what I can do with the `.td` files, thanks!

What unit test file should I use to verify my changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116833

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


[PATCH] D116833: [clang][Sema] Disable -Wc++20-designator in system macros

2022-01-07 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7161
+!DiagnosedNestedDesignator && !DiagnosedMixedDesignator &&
+!getSourceManager().isInSystemMacro(FirstDesignator)) {
   Diag(FirstDesignator, getLangOpts().CPlusPlus20

I think we should be checking `Diags.getSuppressSystemWarnings()` before 
considering whether we're in a system header. (Eg, if we're building libc++ and 
it enables warnings even in system headers, we want to warn if it uses non-C++ 
designator syntax.)

Given that this is something that we will presumably want to do for a bunch of 
diagnostics, not just this one, I think we should extend the current 
`ShowInSystemHeader` / `SuppressInSystemHeader` markings in our diagnostics 
`.td` files to also have a `SuppressInSystemMacro` level, and handle this 
centrally with the other "suppress warnings in system headers" logic, rather 
than special-casing this here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116833

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


[PATCH] D116833: [clang][Sema] Disable -Wc++20-designator in system macros

2022-01-07 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
carlosgalvezp requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To be consistent with GCC.

Fixes #52944.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116833

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/warn-sysheader-macro.cpp


Index: clang/test/SemaCXX/warn-sysheader-macro.cpp
===
--- clang/test/SemaCXX/warn-sysheader-macro.cpp
+++ clang/test/SemaCXX/warn-sysheader-macro.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast 
-Wc++20-designator %s
 
 // Test that macro expansions from system headers don't trigger 'syntactic'
 // warnings that are not actionable.
@@ -12,6 +12,11 @@
 
 #define OLD_STYLE_CAST(a) ((int) (a))
 
+struct Foo {
+  int x;
+};
+#define DESIGNATED_INITIALIZERS (Foo{.x = 123})
+
 #else
 
 #define IS_SYSHEADER
@@ -32,4 +37,9 @@
   int i = OLD_STYLE_CAST(0);
 }
 
+void PR52944() {
+  // no -Wc++20-designator in system macro expansion
+  auto i = DESIGNATED_INITIALIZERS;
+}
+
 #endif
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7157,7 +7157,8 @@
 // Only diagnose designated initiaization as a C++20 extension if we didn't
 // already diagnose use of (non-C++20) C99 designator syntax.
 if (getLangOpts().CPlusPlus && !DiagnosedArrayDesignator &&
-!DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
+!DiagnosedNestedDesignator && !DiagnosedMixedDesignator &&
+!getSourceManager().isInSystemMacro(FirstDesignator)) {
   Diag(FirstDesignator, getLangOpts().CPlusPlus20
 ? diag::warn_cxx17_compat_designated_init
 : diag::ext_cxx_designated_init);


Index: clang/test/SemaCXX/warn-sysheader-macro.cpp
===
--- clang/test/SemaCXX/warn-sysheader-macro.cpp
+++ clang/test/SemaCXX/warn-sysheader-macro.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast %s
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow -Wold-style-cast -Wc++20-designator %s
 
 // Test that macro expansions from system headers don't trigger 'syntactic'
 // warnings that are not actionable.
@@ -12,6 +12,11 @@
 
 #define OLD_STYLE_CAST(a) ((int) (a))
 
+struct Foo {
+  int x;
+};
+#define DESIGNATED_INITIALIZERS (Foo{.x = 123})
+
 #else
 
 #define IS_SYSHEADER
@@ -32,4 +37,9 @@
   int i = OLD_STYLE_CAST(0);
 }
 
+void PR52944() {
+  // no -Wc++20-designator in system macro expansion
+  auto i = DESIGNATED_INITIALIZERS;
+}
+
 #endif
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7157,7 +7157,8 @@
 // Only diagnose designated initiaization as a C++20 extension if we didn't
 // already diagnose use of (non-C++20) C99 designator syntax.
 if (getLangOpts().CPlusPlus && !DiagnosedArrayDesignator &&
-!DiagnosedNestedDesignator && !DiagnosedMixedDesignator) {
+!DiagnosedNestedDesignator && !DiagnosedMixedDesignator &&
+!getSourceManager().isInSystemMacro(FirstDesignator)) {
   Diag(FirstDesignator, getLangOpts().CPlusPlus20
 ? diag::warn_cxx17_compat_designated_init
 : diag::ext_cxx_designated_init);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116828: Initialize HighlightingsBuilder::Resolver

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: kda, eugenis.
Herald added subscribers: usaxena95, kadircet, arphaman.
vitalybuka requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116828

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


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -468,7 +468,7 @@
   const LangOptions 
   std::vector Tokens;
   std::map> ExtraModifiers;
-  const HeuristicResolver *Resolver;
+  const HeuristicResolver *Resolver = nullptr;
   // returned from addToken(InvalidLoc)
   HighlightingToken InvalidHighlightingToken;
 };


Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -468,7 +468,7 @@
   const LangOptions 
   std::vector Tokens;
   std::map> ExtraModifiers;
-  const HeuristicResolver *Resolver;
+  const HeuristicResolver *Resolver = nullptr;
   // returned from addToken(InvalidLoc)
   HighlightingToken InvalidHighlightingToken;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116827: Don't pass uninitialized QueryKind

2022-01-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: kda, eugenis.
Herald added subscribers: usaxena95, kadircet, arphaman.
vitalybuka requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Even if findImplementors does not use
uninitialized parameter it's still UB and
it's going to be detected by msan with:
-Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116827

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


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1310,6 +1310,8 @@
   QueryKind = RelationKind::BaseOf;
 }
   }
+  if (IDs.empty())
+return {};
   return findImplementors(std::move(IDs), QueryKind, Index, *MainFilePath);
 }
 


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1310,6 +1310,8 @@
   QueryKind = RelationKind::BaseOf;
 }
   }
+  if (IDs.empty())
+return {};
   return findImplementors(std::move(IDs), QueryKind, Index, *MainFilePath);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112913: Misleading bidirectional detection

2022-01-07 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 398195.
serge-sans-paille added a comment.

rebased


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

https://reviews.llvm.org/D112913

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
  clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-misleading-bidirectional.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-misleading-bidirectional.cpp

Index: clang-tools-extra/docs/clang-tidy/checks/misc-misleading-bidirectional.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-misleading-bidirectional.rst
@@ -0,0 +1,21 @@
+.. title:: clang-tidy - misc-misleading-bidirectional
+
+misc-misleading-bidirectional
+=
+
+Warn about unterminated bidirectional unicode sequence, detecting potential attack
+as described in the `Trojan Source `_ attack.
+
+Example:
+
+.. code-block:: c++
+
+#include 
+
+int main() {
+bool isAdmin = false;
+/*‮ } ⁦if (isAdmin)⁩ ⁦ begin admins only */
+std::cout << "You are an admin.\n";
+/* end admins only ‮ { ⁦*/
+return 0;
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -212,7 +212,8 @@
`llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
-   `misc-misleading-identifier `_,
+   `misc-misleading-bidirectional `_,
+   `misc-misleading-identifier `_,
`misc-misplaced-const `_,
`misc-new-delete-overloads `_,
`misc-no-recursion `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -123,6 +123,10 @@
   Reports identifiers whose names are too short. Currently checks local
   variables and function parameters only.
 
+- New :doc:`misc-misleading-bidirectional ` check.
+
+  Inspects string literal and comments for unterminated bidirectional Unicode
+  characters.
 
 New check aliases
 ^
Index: clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.h
@@ -0,0 +1,38 @@
+//===--- MisleadingBidirectionalCheck.h - clang-tidy *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+class MisleadingBidirectionalCheck : public ClangTidyCheck {
+public:
+  MisleadingBidirectionalCheck(StringRef Name, ClangTidyContext *Context);
+  ~MisleadingBidirectionalCheck();
+
+  void registerPPCallbacks(const SourceManager , Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+
+private:
+  class MisleadingBidirectionalHandler;
+  std::unique_ptr Handler;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MISLEADINGBIDIRECTIONALCHECK_H
Index: clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/misc/MisleadingBidirectional.cpp
@@ -0,0 +1,142 @@
+//===--- MisleadingBidirectional.cpp - clang-tidy -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MisleadingBidirectional.h"
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/Preprocessor.h"
+#include "llvm/Support/ConvertUTF.h"
+
+using namespace 

[PATCH] D101759: [PowerPC] Scalar IBM MASS library conversion pass

2022-01-07 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei added inline comments.



Comment at: llvm/include/llvm/Analysis/ScalarFuncs.def:19
+TLI_DEFINE_SCALAR_MASS_FUNC("acosf", "__xl_acosf")
+TLI_DEFINE_SCALAR_MASS_FUNC("__acosf_finite", "__xl_acosf")
+TLI_DEFINE_SCALAR_MASS_FUNC("acos", "__xl_acos")

efriedma wrote:
> Do "__acosf_finite" etc. actually exist on AIX?  I thought they only existed 
> on glibc, and the glibc functions are all deprecated.
> 
> I think I'd prefer to track this information in TargetLibraryInfo, like we do 
> for the vector functions, so we can more easily generalize this mechanism in 
> the future.
Some machines still have the old glibc, so I kept them for compatibility.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101759

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


[PATCH] D116822: [Clang][Sema] Use VersionMap from SDKSettings for remapping tvOS and watchOS availability

2022-01-07 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan updated this revision to Diff 398192.
egorzhdan added a comment.

Remove accidental change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116822

Files:
  clang/include/clang/Basic/DarwinSDKInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/Inputs/AppleTVOS15.0.sdk/SDKSettings.json
  clang/test/Sema/Inputs/WatchOS7.0.sdk/SDKSettings.json
  clang/test/Sema/attr-availability-tvos.c
  clang/test/Sema/attr-availability-watchos.c

Index: clang/test/Sema/attr-availability-watchos.c
===
--- clang/test/Sema/attr-availability-watchos.c
+++ clang/test/Sema/attr-availability-watchos.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 "-triple" "arm64-apple-watchos3.0" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "arm64-apple-watchos4.0" -DUSE_VERSION_MAP -isysroot %S/Inputs/WatchOS7.0.sdk -fsyntax-only -verify %s
 
 void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
 void f1(int) __attribute__((availability(ios,introduced=2.1)));
@@ -58,3 +59,12 @@
 void test_ios_correctly_map_to_watchos() {
   deprecatedAfterIntroduced(); // expected-warning {{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}
 }
+
+#ifdef USE_VERSION_MAP
+// iOS 10.3.1 corresponds to watchOS 3.2, as indicated in 'SDKSettings.json'.
+void f9(int) __attribute__((availability(ios,deprecated=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}
+
+void testWithVersionMap() {
+  f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.2}}
+}
+#endif
Index: clang/test/Sema/attr-availability-tvos.c
===
--- clang/test/Sema/attr-availability-tvos.c
+++ clang/test/Sema/attr-availability-tvos.c
@@ -1,63 +1,73 @@
-// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos3.0" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos13.0" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos13.0" -DUSE_VERSION_MAP -isysroot %S/Inputs/AppleTVOS15.0.sdk -fsyntax-only -verify %s
 
-void f0(int) __attribute__((availability(tvos,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
-void f1(int) __attribute__((availability(tvos,introduced=2.1)));
-void f2(int) __attribute__((availability(tvos,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
-void f3(int) __attribute__((availability(tvos,introduced=3.0)));
-void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(tvos,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+void f0(int) __attribute__((availability(tvos,introduced=12.0,deprecated=12.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
+void f1(int) __attribute__((availability(tvos,introduced=12.1)));
+void f2(int) __attribute__((availability(tvos,introduced=12.0,deprecated=13.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(tvos,introduced=13.0)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(tvos,introduced=12.0,deprecated=12.1,obsoleted=13.0))); // expected-note{{explicitly marked unavailable}}
 
-void f5(int) __attribute__((availability(tvos,introduced=2.0))) __attribute__((availability(tvos,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
-void f6(int) __attribute__((availability(tvos,deprecated=3.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
-void f6(int) __attribute__((availability(tvos,introduced=2.0)));
+void f5(int) __attribute__((availability(tvos,introduced=12.0))) __attribute__((availability(tvos,deprecated=13.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(tvos,deprecated=13.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(tvos,introduced=12.0)));
 
 void test() {
-  f0(0); // expected-warning{{'f0' is deprecated: first deprecated in tvOS 2.1}}
+  f0(0); // expected-warning{{'f0' is deprecated: first deprecated in tvOS 12.1}}
   f1(0);
-  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in tvOS 3.0}}
+  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in tvOS 13.0}}
   f3(0);
-  f4(0); // expected-error{{f4' is unavailable: obsoleted in tvOS 3.0}}
-  f5(0); // expected-warning{{'f5' is deprecated: first deprecated in tvOS 3.0}}
-  f6(0); // expected-warning{{'f6' is deprecated: first 

[PATCH] D112718: Add intrinsics and builtins for PTX atomics with semantic orders

2022-01-07 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsNVPTX.def:1057
+
+BUILTIN(__nvvm_atom_xchg_global_i, "iiD*i", "n")
+TARGET_BUILTIN(__nvvm_atom_cta_xchg_global_i, "iiD*i", "n", SM_60)

t4c1 wrote:
> tra wrote:
> > We need to figure out how address-space-specific builtins are supposed to 
> > work.
> > Right now two competing approaches.
> > 
> > This patch declares builtins with generic pointer as an argument, but, 
> > according to the test, expects to be used with the AS-specific pointer.
> > It probably does not catch a wrong-AS pointer passed as an argument, either.
> > It does happen to work, but I think it's mostly due to the fact that LLVM 
> > intrinsics are overloaded and we happen to end up addrspacecast'ing  things 
> > correctly if the builtin gets the right kind of pointer.
> > 
> > The other approach is to declare the pointer with the expected AS. E.g:
> > > TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", 
> > > AND(SM_80,PTX70))
> > 
> > IMO, this is the correct way to do it, but it is also rather inconvenient 
> > to use from CUDA code as it operates on generic pointers.
> > 
> > @jdoerfert - WDYT?
> >TARGET_BUILTIN(__nvvm_mbarrier_init_shared, "vWi*3i", "", AND(SM_80,PTX70))
> >IMO, this is the correct way to do it, but it is also rather inconvenient to 
> >use from CUDA code as it operates on generic pointers.
> 
> I tried doing this, however it is also completely unusable from OpenCL code 
> (which is our use case). Trying to use it gives you errors about how casting 
> pointers to different address spaces  - for example from local to AS3 is not 
> allowed.
Hmm. It should've worked. It would need the same explicit cast to a pointer in 
AS(3) as in your tests, but it would safeguard against attempts to pass it a 
generic pointer. E.g. https://godbolt.org/z/qE6oxzheM

Explicit casting to AS(X) for AS-specific variants is annoying, but it's 
probably unavoidable at the moment regardless of whether we declare the pointer 
argument to be AS-specific or not.  LLVM will not always be able to infer that 
a pointer is in particular AS.
Using specific AS in the declaration has a minor benefit of safeguarding at 
compile time against unintentional use of generic pointers.

Ideally we may want to convert generic variant of the builtin to AS-specific 
one, if LLVM does know the AS. We currently do this for loads/stores, but not 
for other instructions.




Comment at: clang/test/CodeGen/builtins-nvptx.c:557
+  // expected-error@+1 {{'__nvvm_atom_acquire_add_global_i' needs target 
feature sm_70}}
+  __nvvm_atom_acquire_add_global_i((__attribute__((address_space(1))) int 
*)ip, i);
+

t4c1 wrote:
> tra wrote:
> > What happens if I pass a wrong pointer kind? E.g. a generic or shared 
> > pointer?
> It will silently accept it. I can look into how to output appropriate error 
> message.
I guest the bast we can do here is to safeguard against unintentional use of 
generic pointer.
There's not much we can do if someone explicitly casts a pointer to a wrong AS.

I think declaring pointer arg to be in specific AS would be sufficient. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112718

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


[PATCH] D116774: AST: Move __va_list tag to the top level on ARM architectures.

2022-01-07 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

I'm not aware of any of those places causing an actual problem though? The AST 
isn't a stable interface, and __builtin_dump_struct is for debugging purposes 
only. I would expect debug info consumers to be able to handle __va_list in the 
global namespace as this is the status quo for C.

So I'm somewhat inclined to do the simple thing here first, and then look at 
making things more conditional if a problem comes up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116774

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


[PATCH] D116824: [clang-tidy] Fix RenamerClangTidyChecks suggesting invalid macro identifiers

2022-01-07 Thread Logan Smith via Phabricator via cfe-commits
logan-5 created this revision.
logan-5 added reviewers: njames93, aaron.ballman.
logan-5 added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
logan-5 requested review of this revision.
Herald added a subscriber: cfe-commits.

This behavior was fixed for regular identifiers in 
9f3edc323a88c1a179a0a5a9dc9a87a2964c0d48 
, but the 
same fix was not applied to macro fixits.

This addresses https://github.com/llvm/llvm-project/issues/52895.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116824

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
@@ -171,6 +171,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '_', 
which is reserved in the global namespace; cannot be fixed automatically 
[bugprone-reserved-identifier]
 // CHECK-FIXES: {{^}}int _;{{$}}
 
+// https://github.com/llvm/llvm-project/issues/52895
+#define _5_kmph_rpm 459
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier 
'_5_kmph_rpm', which is reserved in the global namespace; cannot be fixed 
automatically [bugprone-reserved-identifier]
+// CHECK-FIXES: {{^}}#define _5_kmph_rpm 459{{$}}
+
 // these should pass
 #define MACRO(m) int m = 0
 
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -486,6 +486,9 @@
   NamingCheckFailure  = NamingCheckFailures[ID];
   SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());
 
+  if (!isValidAsciiIdentifier(Info.Fixup))
+Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
+
   Failure.Info = std::move(Info);
   addUsage(ID, Range);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
@@ -171,6 +171,11 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration uses identifier '_', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier]
 // CHECK-FIXES: {{^}}int _;{{$}}
 
+// https://github.com/llvm/llvm-project/issues/52895
+#define _5_kmph_rpm 459
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: declaration uses identifier '_5_kmph_rpm', which is reserved in the global namespace; cannot be fixed automatically [bugprone-reserved-identifier]
+// CHECK-FIXES: {{^}}#define _5_kmph_rpm 459{{$}}
+
 // these should pass
 #define MACRO(m) int m = 0
 
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -486,6 +486,9 @@
   NamingCheckFailure  = NamingCheckFailures[ID];
   SourceRange Range(MacroNameTok.getLocation(), MacroNameTok.getEndLoc());
 
+  if (!isValidAsciiIdentifier(Info.Fixup))
+Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
+
   Failure.Info = std::move(Info);
   addUsage(ID, Range);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116722: [clang] Verify ssp buffer size is a valid integer

2022-01-07 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3204
   if (StackProtectorLevel) {
-CmdArgs.push_back("-stack-protector-buffer-size");
-// FIXME: Verify the argument is a valid integer.
-CmdArgs.push_back(Args.MakeArgString(Str.drop_front(16)));
+auto BufferSize = Str.drop_front(16);
+if (IsInteger(BufferSize)) {

I really am not a fan of the `16` here.  Why not just use `split` and split on 
`=`?  Or use [constexpr] `strlen`?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3209
+} else
+  D.Diag(clang::diag::err_invalid_ssp_buffer_size);
   }

Please consistently use the braces (either applied to both or on neither).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116722

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


[PATCH] D116822: [Clang][Sema] Use VersionMap from SDKSettings for remapping tvOS and watchOS availability

2022-01-07 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan created this revision.
Herald added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
egorzhdan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This makes the mapping between iOS & tvOS/watchOS versions more accurate. For 
example, iOS 9.3 now gets correctly mapped into tvOS 9.2 and not tvOS 9.3.

Before this change, the incorrect mapping could cause excessive or missing 
warnings for code that specifies availability for iOS, but not for tvOS/watchOS.

rdar://81491680


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116822

Files:
  clang/include/clang/Basic/DarwinSDKInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/Inputs/AppleTVOS15.0.sdk/SDKSettings.json
  clang/test/Sema/Inputs/WatchOS7.0.sdk/SDKSettings.json
  clang/test/Sema/attr-availability-tvos.c
  clang/test/Sema/attr-availability-watchos-infer-from-ios.c
  clang/test/Sema/attr-availability-watchos.c

Index: clang/test/Sema/attr-availability-watchos-infer-from-ios.c
===
--- clang/test/Sema/attr-availability-watchos-infer-from-ios.c
+++ clang/test/Sema/attr-availability-watchos-infer-from-ios.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 "-triple" "arm64-apple-watchos3.0" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "arm64-apple-watchos4.0" -DUSE_VERSION_MAP -isysroot %S/Inputs/WatchOS7.0.sdk -fsyntax-only -verify %s
 
 void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
 void f1(int) __attribute__((availability(ios,introduced=2.1)));
@@ -58,3 +59,12 @@
 void test_ios_correctly_map_to_watchos() {
   deprecatedAfterIntroduced(); // expected-warning {{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}
 }
+
+#ifdef USE_VERSION_MAP
+// iOS 10.3.1 corresponds to watchOS 3.2, as indicated in 'SDKSettings.json'.
+void f9(int) __attribute__((availability(ios,deprecated=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}
+
+void testWithVersionMap() {
+  f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.2}}
+}
+#endif
Index: clang/test/Sema/attr-availability-tvos.c
===
--- clang/test/Sema/attr-availability-tvos.c
+++ clang/test/Sema/attr-availability-tvos.c
@@ -1,63 +1,73 @@
-// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos3.0" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos13.0" -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-apple-tvos13.0" -DUSE_VERSION_MAP -isysroot %S/Inputs/AppleTVOS15.0.sdk -fsyntax-only -verify %s
 
-void f0(int) __attribute__((availability(tvos,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
-void f1(int) __attribute__((availability(tvos,introduced=2.1)));
-void f2(int) __attribute__((availability(tvos,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
-void f3(int) __attribute__((availability(tvos,introduced=3.0)));
-void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(tvos,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}}
+void f0(int) __attribute__((availability(tvos,introduced=12.0,deprecated=12.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
+void f1(int) __attribute__((availability(tvos,introduced=12.1)));
+void f2(int) __attribute__((availability(tvos,introduced=12.0,deprecated=13.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(tvos,introduced=13.0)));
+void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(tvos,introduced=12.0,deprecated=12.1,obsoleted=13.0))); // expected-note{{explicitly marked unavailable}}
 
-void f5(int) __attribute__((availability(tvos,introduced=2.0))) __attribute__((availability(tvos,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
-void f6(int) __attribute__((availability(tvos,deprecated=3.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
-void f6(int) __attribute__((availability(tvos,introduced=2.0)));
+void f5(int) __attribute__((availability(tvos,introduced=12.0))) __attribute__((availability(tvos,deprecated=13.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(tvos,deprecated=13.0))); // expected-note {{'f6' has been explicitly marked deprecated here}}
+void f6(int) __attribute__((availability(tvos,introduced=12.0)));
 
 void test() {
-  f0(0); // expected-warning{{'f0' is deprecated: first 

[PATCH] D114622: [clang-tidy][analyzer] Fix false-positive in IdenticalExprChecker and misc-redundant-expression

2022-01-07 Thread David Rector via Phabricator via cfe-commits
davrec added a comment.

> There are already two way more sophisticated (forgive me my bias) 
> implementations in Clang that are for checking if two statements or decls are 
> the same.
>
> 1. ODRHash, used in modules to discover ODR violations
> 2. ASTStructuralEquivalenceContext, used in ASTImporter to discover if two 
> AST nodes are the same or not (as a side effect we diagnose ODR violations as 
> well).
>
> It is not the first time, when such a similarity check is needed (see 
> https://reviews.llvm.org/D75041). Of course reusing the before mentioned 
> components would require some architectural changes, but it might be 
> beneficial.

I do not quite see the overlap.  This patch addresses the structural 
equivalence of DeclRefExprs: as the `std::is_same` (or any type trait example) 
demonstrates, two declarations may be the "same" (e.g. they are both 
`std::false_type::value`), but two DeclRefExprs referring to those declarations 
should not necessarily be considered the "same": the qualifier, specifying the 
path that was taken to look them up, can matter to a user.  It's not a matter 
of the sophistication of the similarity check, it's a matter of what we mean by 
similarity.

I do not see DeclRefExprs handled in ODRHash or ASTStructuralEquivalence.  I do 
see NestedNameSpecifiers handled in both, but I don't think the implementation 
quite matches what is needed here (e.g. in ASTStructuralEquivalence check, if 
one NNS is a NamespaceAlias, the other one is assumed to be a NamespaceAlias: 
not what we want).  It's probably not worth the trouble to factor something 
common out of those; though they should certainly be used as a guide to make 
sure no cases have been missed.


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

https://reviews.llvm.org/D114622

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


[PATCH] D106518: [RISCV] Disable EEW=64 for index values when XLEN=32.

2022-01-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D106518/new/

https://reviews.llvm.org/D106518

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


[PATCH] D116778: [clang-tidy][clang] Don't trigger unused-parameter warnings on naked functions

2022-01-07 Thread Tommaso Bonvicini via Phabricator via cfe-commits
MuAlphaOmegaEpsilon updated this revision to Diff 398182.
MuAlphaOmegaEpsilon added a comment.

Rebased to more recent main branch, updated comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116778

Files:
  clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
  clang/lib/Sema/SemaDecl.cpp


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14632,8 +14632,17 @@
 Diag(FD->getLocation(), diag::ext_pure_function_definition);
 
   if (!FD->isInvalidDecl()) {
-// Don't diagnose unused parameters of defaulted or deleted functions.
-if (!FD->isDeleted() && !FD->isDefaulted() && !FD->hasSkippedBody())
+bool FDHasNakedAttr{false};
+if (FD->hasAttrs())
+  for (const clang::Attr *A : FD->getAttrs())
+if (A->getParsedKind() == Attr::AT_Naked) {
+  FDHasNakedAttr = true;
+  break;
+}
+// Don't diagnose unused parameters of defaulted, deleted or naked
+// functions.
+if (!FD->isDeleted() && !FD->isDefaulted() && !FD->hasSkippedBody() &&
+!FDHasNakedAttr)
   DiagnoseUnusedParameters(FD->parameters());
 DiagnoseSizeOfParametersAndReturnValue(FD->parameters(),
FD->getReturnType(), FD);
Index: clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
@@ -174,6 +174,10 @@
   const auto *Function = Result.Nodes.getNodeAs("function");
   if (!Function->hasWrittenPrototype() || Function->isTemplateInstantiation())
 return;
+  if (Function->hasAttrs())
+for (const clang::Attr *A : Function->getAttrs())
+  if (A->getParsedKind() == Attr::AT_Naked)
+return;
   if (const auto *Method = dyn_cast(Function))
 if (Method->isLambdaStaticInvoker())
   return;


Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14632,8 +14632,17 @@
 Diag(FD->getLocation(), diag::ext_pure_function_definition);
 
   if (!FD->isInvalidDecl()) {
-// Don't diagnose unused parameters of defaulted or deleted functions.
-if (!FD->isDeleted() && !FD->isDefaulted() && !FD->hasSkippedBody())
+bool FDHasNakedAttr{false};
+if (FD->hasAttrs())
+  for (const clang::Attr *A : FD->getAttrs())
+if (A->getParsedKind() == Attr::AT_Naked) {
+  FDHasNakedAttr = true;
+  break;
+}
+// Don't diagnose unused parameters of defaulted, deleted or naked
+// functions.
+if (!FD->isDeleted() && !FD->isDefaulted() && !FD->hasSkippedBody() &&
+!FDHasNakedAttr)
   DiagnoseUnusedParameters(FD->parameters());
 DiagnoseSizeOfParametersAndReturnValue(FD->parameters(),
FD->getReturnType(), FD);
Index: clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
@@ -174,6 +174,10 @@
   const auto *Function = Result.Nodes.getNodeAs("function");
   if (!Function->hasWrittenPrototype() || Function->isTemplateInstantiation())
 return;
+  if (Function->hasAttrs())
+for (const clang::Attr *A : Function->getAttrs())
+  if (A->getParsedKind() == Attr::AT_Naked)
+return;
   if (const auto *Method = dyn_cast(Function))
 if (Method->isLambdaStaticInvoker())
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116549: [OpenMP][Clang] Allow passing target features in ISA trait for metadirective clause

2022-01-07 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 398179.
saiislam marked an inline comment as done.
saiislam added a comment.

Added diagnostic remarks for when ISA trait is not selected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116549

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/metadirective_device_isa_codegen.cpp
  clang/test/OpenMP/metadirective_device_isa_messages.c

Index: clang/test/OpenMP/metadirective_device_isa_messages.c
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_device_isa_messages.c
@@ -0,0 +1,15 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple x86_64-unknown-linux -emit-llvm-only -target-cpu znver1 %s -Rremark-backend-plugin
+
+#ifndef HEADER
+#define HEADER
+
+void bar();
+
+void foo() {
+#pragma omp metadirective when(device = {isa("some-unsupported-feature")} \
+   : parallel) default(single) // expected-remark {{isa trait 'some-unsupported-feature' is not a valid feature of the target 'x86_64'}}
+  bar();
+}
+
+#endif
Index: clang/test/OpenMP/metadirective_device_isa_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_device_isa_codegen.cpp
@@ -0,0 +1,81 @@
+// REQUIRES: amdgpu-registered-target
+// REQUIRES: x86-registered-target
+
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -target-cpu gfx906 -o - | FileCheck %s -check-prefix=AMDGPUISA
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope -target-cpu x86-64| FileCheck %s -check-prefixes=X86_64ISA
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+int amdgcn_device_isa_selected() {
+  int threadCount = 0;
+
+#pragma omp target map(tofrom \
+   : threadCount)
+  {
+#pragma omp metadirective \
+when(device = {isa("flat-address-space")} \
+ : parallel) default(single)
+threadCount++;
+  }
+
+  return threadCount;
+}
+
+// AMDGPUISA: define weak amdgpu_kernel void @__omp_offloading_{{.*}}amdgcn_device_isa_selected
+// AMDGPUISA: user_code.entry:
+// AMDGPUISA: call void @__kmpc_parallel_51
+// AMDGPUISA-NOT: call i32 @__kmpc_single
+// AMDGPUISA: ret void
+
+int amdgcn_device_isa_not_selected() {
+  int threadCount = 0;
+
+#pragma omp target map(tofrom \
+   : threadCount)
+  {
+#pragma omp metadirective  \
+when(device = {isa("sse")} \
+ : parallel)   \
+when(device = {isa("another-unsupported-gpu-feature")} \
+ : parallel) default(single)
+threadCount++;
+  }
+
+  return threadCount;
+}
+// AMDGPUISA: define weak amdgpu_kernel void @__omp_offloading_{{.*}}amdgcn_device_isa_not_selected
+// AMDGPUISA: user_code.entry:
+// AMDGPUISA: call i32 @__kmpc_single
+// AMDGPUISA-NOT: call void @__kmpc_parallel_51
+// AMDGPUISA: ret void
+
+void bar();
+
+void x86_64_device_isa_selected() {
+#pragma omp metadirective when(device = {isa("sse2")} \
+   : parallel) default(single)
+  bar();
+}
+// X86_64ISA-LABEL: void @_Z26x86_64_device_isa_selectedv()
+// X86_64ISA: ...) @__kmpc_fork_call{{.*}}@.omp_outlined..1
+// X86_64ISA: ret void
+
+// X86_64ISA: define internal void @.omp_outlined..1(
+// X86_64ISA: @_Z3barv
+// X86_64ISA: ret void
+
+void x86_64_device_isa_not_selected() {
+#pragma omp metadirective when(device = {isa("some-unsupported-feature")} \
+   : parallel) default(single)
+  bar();
+}
+// X86_64ISA-LABEL: void @_Z30x86_64_device_isa_not_selectedv()
+// X86_64ISA: call i32 @__kmpc_single
+// X86_64ISA:  @_Z3barv
+// X86_64ISA: call void @__kmpc_end_single
+// X86_64ISA: ret void
+#endif
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2529,7 +2529,12 @@
 TPA.Revert();
 // End of the first iteration. Parser is reset to the start of metadirective
 
-TargetOMPContext OMPCtx(ASTContext, /* DiagUnknownTrait */ nullptr,
+std::function DiagUnknownTrait =
+[this, Loc](StringRef ISATrait) {
+  Diag(Loc, diag::remark_unknown_declare_variant_isa_trait)
+  << ISATrait << this->getTargetInfo().getTriple().getArchName();
+};
+

[PATCH] D115183: [clang][HeaderSearch] Support framework includes in suggestPath...

2022-01-07 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 398178.
dgoldman added a comment.

Don't suggest umbrella headers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115183

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/double-quotes.m
  clang/unittests/Lex/HeaderSearchTest.cpp

Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -47,6 +47,15 @@
 Search.AddSearchPath(DL, /*isAngled=*/false);
   }
 
+  void addSystemFrameworkSearchDir(llvm::StringRef Dir) {
+VFS->addFile(Dir, 0, llvm::MemoryBuffer::getMemBuffer(""), /*User=*/None,
+ /*Group=*/None, llvm::sys::fs::file_type::directory_file);
+auto DE = FileMgr.getOptionalDirectoryRef(Dir);
+assert(DE);
+auto DL = DirectoryLookup(*DE, SrcMgr::C_System, /*isFramework=*/true);
+Search.AddSystemSearchPath(DL);
+  }
+
   void addHeaderMap(llvm::StringRef Filename,
 std::unique_ptr Buf,
 bool isAngled = false) {
@@ -155,6 +164,29 @@
 "y/z/t.h");
 }
 
+TEST_F(HeaderSearchTest, SdkFramework) {
+  addSystemFrameworkSearchDir(
+  "/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/Frameworks/");
+  bool IsSystem = false;
+  EXPECT_EQ(Search.suggestPathToFileForDiagnostics(
+"/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/"
+"Frameworks/AppKit.framework/Headers/NSView.h",
+/*WorkingDir=*/"",
+/*MainFile=*/"", ),
+"AppKit/NSView.h");
+  EXPECT_TRUE(IsSystem);
+}
+
+TEST_F(HeaderSearchTest, NestedFramework) {
+  addSystemFrameworkSearchDir("/Platforms/MacOSX/Frameworks");
+  EXPECT_EQ(Search.suggestPathToFileForDiagnostics(
+"/Platforms/MacOSX/Frameworks/AppKit.framework/Frameworks/"
+"Sub.framework/Headers/Sub.h",
+/*WorkingDir=*/"",
+/*MainFile=*/""),
+"Sub/Sub.h");
+}
+
 // Helper struct with null terminator character to make MemoryBuffer happy.
 template 
 struct NullTerminatedFile : public FileTy {
Index: clang/test/Modules/double-quotes.m
===
--- clang/test/Modules/double-quotes.m
+++ clang/test/Modules/double-quotes.m
@@ -24,8 +24,17 @@
 // because they only show up under the module A building context.
 // RUN: FileCheck --input-file=%t/stderr %s
 // CHECK: double-quoted include "A0.h" in framework header, expected angle-bracketed instead
+// CHECK: #include "A0.h"
+// CHECK:  ^~
+// CHECK: 
 // CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed instead
+// CHECK: #include "B.h"
+// CHECK:  ^
+// CHECK: 
 // CHECK: double-quoted include "B.h" in framework header, expected angle-bracketed instead
+// CHECK: #import "B.h" // Included from Z.h & A.h
+// CHECK: ^
+// CHECK: 
 
 #import "A.h"
 #import 
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -721,7 +721,8 @@
 }
 
 static bool isFrameworkStylePath(StringRef Path, bool ,
- SmallVectorImpl ) {
+ SmallVectorImpl ,
+ SmallVectorImpl ) {
   using namespace llvm::sys;
   path::const_iterator I = path::begin(Path);
   path::const_iterator E = path::end(Path);
@@ -737,15 +738,22 @@
   // and some other variations among these lines.
   int FoundComp = 0;
   while (I != E) {
-if (*I == "Headers")
+if (*I == "Headers") {
   ++FoundComp;
-if (I->endswith(".framework")) {
-  FrameworkName.append(I->begin(), I->end());
-  ++FoundComp;
-}
-if (*I == "PrivateHeaders") {
+} else if (*I == "PrivateHeaders") {
   ++FoundComp;
   IsPrivateHeader = true;
+} else if (I->endswith(".framework")) {
+  StringRef Name = I->drop_back(10); // Drop .framework
+  // Need to reset the strings and counter to support nested frameworks.
+  FrameworkName.clear();
+  FrameworkName.append(Name.begin(), Name.end());
+  IncludeSpelling.clear();
+  IncludeSpelling.append(Name.begin(), Name.end());
+  FoundComp = 1;
+} else if (FoundComp >= 2) {
+  IncludeSpelling.push_back('/');
+  IncludeSpelling.append(I->begin(), I->end());
 }
 ++I;
   }
@@ -760,20 +768,24 @@
  bool FoundByHeaderMap = false) {
   bool IsIncluderPrivateHeader = false;
   SmallString<128> FromFramework, ToFramework;
-  if (!isFrameworkStylePath(Includer, IsIncluderPrivateHeader, FromFramework))
+  SmallString<128> FromIncludeSpelling, ToIncludeSpelling;
+  if 

[PATCH] D116814: Accept string literal decay in conditional operator

2022-01-07 Thread Elvis Stansvik via Phabricator via cfe-commits
estan updated this revision to Diff 398177.
estan added a comment.

Add entry in clang-tools-extra/docs/ReleaseNotes.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116814

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -49,3 +49,14 @@
   void *a[2];
   f2(static_cast(a)); // OK, explicit cast
 }
+
+void issue31155(int i) {
+  const char *a = i ? "foo" : "bar";// OK, decay string literal to pointer
+  const char *b = i ? "foo" : "foobar"; // OK, decay string literal to pointer
+
+  char arr[1];
+  const char *c = i ? arr : "bar";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: do not implicitly decay an 
array into a pointer
+  const char *d = i ? "foo" : arr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: do not implicitly decay an 
array into a pointer
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,6 +67,10 @@
 Improvements to clang-tidy
 --
 
+- Make the `cppcoreguidelines-pro-bounds-array-to-pointer-decay` check accept
+  string literal to pointer decay in conditional operator even if operands are
+  of the same length.
+
 - Ignore warnings from macros defined in system headers, if not using the
   `-system-headers` flag.
 
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -54,13 +54,17 @@
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
-  traverse(TK_AsIs,
-   implicitCastExpr(
-   unless(hasParent(arraySubscriptExpr())),
-   unless(hasParentIgnoringImpCasts(explicitCastExpr())),
-   unless(isInsideOfRangeBeginEndStmt()),
-   
unless(hasSourceExpression(ignoringParens(stringLiteral()
-   .bind("cast")),
+  traverse(
+  TK_AsIs,
+  implicitCastExpr(
+  unless(hasParent(arraySubscriptExpr())),
+  unless(hasParentIgnoringImpCasts(explicitCastExpr())),
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParens(stringLiteral(,
+  unless(hasSourceExpression(ignoringParens(conditionalOperator(
+  allOf(hasTrueExpression(stringLiteral()),
+hasFalseExpression(stringLiteral(
+  .bind("cast")),
   this);
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -49,3 +49,14 @@
   void *a[2];
   f2(static_cast(a)); // OK, explicit cast
 }
+
+void issue31155(int i) {
+  const char *a = i ? "foo" : "bar";// OK, decay string literal to pointer
+  const char *b = i ? "foo" : "foobar"; // OK, decay string literal to pointer
+
+  char arr[1];
+  const char *c = i ? arr : "bar";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: do not implicitly decay an array into a pointer
+  const char *d = i ? "foo" : arr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: do not implicitly decay an array into a pointer
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,6 +67,10 @@
 Improvements to clang-tidy
 --
 
+- Make the `cppcoreguidelines-pro-bounds-array-to-pointer-decay` check accept
+  string literal to pointer decay in conditional operator even if operands are
+  of the same length.
+
 - Ignore warnings from macros defined in system headers, if not using the
   `-system-headers` flag.
 
Index: 

[PATCH] D115103: Leak Sanitizer port to Windows

2022-01-07 Thread Clemens Wasser via Phabricator via cfe-commits
clemenswasser added a comment.

@aganea Thanks for your help. I already did everything you wrote (I am however 
using the coreutils provided by Git).
`check-asan` works on my new computer. I still don't know why it didn't work on 
my older one...
I will try to get the lsan tests working (and hopefully passing ) on windows 
soon.


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

https://reviews.llvm.org/D115103

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


[PATCH] D88833: [clang-tidy] Do not warn on pointer decays in system macros

2022-01-07 Thread Elvis Stansvik via Phabricator via cfe-commits
estan commandeered this revision.
estan added a reviewer: fiesh.
estan added a comment.

I think we can close this one now that https://reviews.llvm.org/D116378 has 
landed though, since this revision was originally only about warnings in system 
macros case which is now solved (?)

I'll commandeer and close, but feel free to re-open if that's the wrong move 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88833

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


[PATCH] D114622: [clang-tidy][analyzer] Fix false-positive in IdenticalExprChecker and misc-redundant-expression

2022-01-07 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D114622#3200678 , @NoQ wrote:

> These checks are almost 2000 lines of code each and it looks like all they do 
> is figure out if two statements are the same and we have a very flexible 
> reusable solution for this sort of stuff - `CloneDetector`, but none of them 
> use it. Your patch demonstrates that they all have the same bugs that need to 
> be fixed in each of them separately, so reusability seems really valuable. If 
> I was to work on these checks, the first thing I'd try would be to throw out 
> their machines and plug in a reusable solution.

There are already two way more sophisticated (forgive me my bias) 
implementations in Clang that are for checking if two statements or decls are 
the same.

1. ODRHash, used in modules to discover ODR violations
2. ASTStructuralEquivalenceContext, used in ASTImporter to discover if two AST 
nodes are the same or not (as a side effect we diagnose ODR violations as well).

It is not the first time, when such a similarity check is needed (see 
https://reviews.llvm.org/D75041). Of course reusing the before mentioned 
components would require some architectural changes, but it might be beneficial.


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

https://reviews.llvm.org/D114622

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


[PATCH] D116814: Accept string literal decay in conditional operator

2022-01-07 Thread Elvis Stansvik via Phabricator via cfe-commits
estan created this revision.
Herald added subscribers: carlosgalvezp, kbarton, nemanjai.
estan edited the summary of this revision.
estan edited the summary of this revision.
estan edited the summary of this revision.
estan edited the summary of this revision.
estan updated this revision to Diff 398165.
estan added a comment.
estan added reviewers: aaron.ballman, alexfh, JonasToth, george.burgess.iv.
estan published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Format code with git-clang-format


The cppcoreguidelines-pro-bounds-array-to-pointer-decay check currently accepts

  const char *b = i ? "foo" : "foobar";

but not

  const char *a = i ? "foo" : "bar";

This is because the AST is slightly different in the latter case (see 
https://godbolt.org/z/MkHVvs).

This fixes up the inconsistency by making it accept the latter form as well.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116814

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -49,3 +49,14 @@
   void *a[2];
   f2(static_cast(a)); // OK, explicit cast
 }
+
+void issue31155(int i) {
+  const char *a = i ? "foo" : "bar";// OK, decay string literal to pointer
+  const char *b = i ? "foo" : "foobar"; // OK, decay string literal to pointer
+
+  char arr[1];
+  const char *c = i ? arr : "bar";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: do not implicitly decay an 
array into a pointer
+  const char *d = i ? "foo" : arr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: do not implicitly decay an 
array into a pointer
+}
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -54,13 +54,17 @@
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to a pointer
   Finder->addMatcher(
-  traverse(TK_AsIs,
-   implicitCastExpr(
-   unless(hasParent(arraySubscriptExpr())),
-   unless(hasParentIgnoringImpCasts(explicitCastExpr())),
-   unless(isInsideOfRangeBeginEndStmt()),
-   
unless(hasSourceExpression(ignoringParens(stringLiteral()
-   .bind("cast")),
+  traverse(
+  TK_AsIs,
+  implicitCastExpr(
+  unless(hasParent(arraySubscriptExpr())),
+  unless(hasParentIgnoringImpCasts(explicitCastExpr())),
+  unless(isInsideOfRangeBeginEndStmt()),
+  unless(hasSourceExpression(ignoringParens(stringLiteral(,
+  unless(hasSourceExpression(ignoringParens(conditionalOperator(
+  allOf(hasTrueExpression(stringLiteral()),
+hasFalseExpression(stringLiteral(
+  .bind("cast")),
   this);
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp
@@ -49,3 +49,14 @@
   void *a[2];
   f2(static_cast(a)); // OK, explicit cast
 }
+
+void issue31155(int i) {
+  const char *a = i ? "foo" : "bar";// OK, decay string literal to pointer
+  const char *b = i ? "foo" : "foobar"; // OK, decay string literal to pointer
+
+  char arr[1];
+  const char *c = i ? arr : "bar";
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: do not implicitly decay an array into a pointer
+  const char *d = i ? "foo" : arr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: do not implicitly decay an array into a pointer
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp
@@ -54,13 +54,17 @@
   // 2) inside a range-for over an array
   // 3) if it converts a string literal to 

  1   2   >