[PATCH] D143287: [Clang][x86] Change x86 cast intrinsics to use __builtin_nondeterministic_value

2023-02-04 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

What do we gain from using __builtin_nondeterministic_value instead of just 
setzero? https://godbolt.org/z/zrb6858Mr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143287

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


[PATCH] D143091: [clang-format] PackConstructorInitializers support PCIS_OnlyNextLine

2023-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:3891
 
+  * ``PCIS_OnlyNextLine`` (in configuration: ``OnlyNextLine``)
+Put all constructor initializers on the next line if they fit.

Backl1ght wrote:
> @HazardyKnusperkeks   Maybe I misunderstand something, I think I already add 
> an entry here by running `clang/docs/tools/dump_format_style.py`.
`NextLineOnly` instead?



Comment at: clang/unittests/Format/FormatTest.cpp:7296-7298
+verifyFormat("Constructor()\n"
+ ": a(a), b(b) {}",
+ Style);

Can you add this test to before/after colon below (and elsewhere if applicable)?



Comment at: clang/unittests/Format/FormatTest.cpp:7299
+ Style);
+
 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;

Can you add a test here and elsewhere for constructors that don't fit on the 
next line?


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

https://reviews.llvm.org/D143091

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


[PATCH] D142891: [clang-format] Recognize Verilog non-blocking assignment

2023-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1628
 bool InCSharpAttributeSpecifier = false;
+bool AssignmentFound = false;
 enum {





Comment at: clang/lib/Format/TokenAnnotator.cpp:1935-1936
+  }
+  if (Current.getPrecedence() == prec::Assignment)
+Contexts.back().AssignmentFound = true;
 } else if (Current.is(tok::comment)) {

Can you move them into the `if` statement above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142891

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


[PATCH] D140723: [clang][Interp] Only check constructors for global variables

2023-02-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140723

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


cfe-commits@lists.llvm.org

2023-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:123
 private:
+  ScopeType getScopeType(FormatToken &Token) {
+switch (Token.getType()) {

As suggested before.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1195-1198
+  // Handle unbalanced braces.
+  if (!Scopes.empty())
+Scopes.pop_back();
   // Lines can start with '}'.

dkt01 wrote:
> owenpan wrote:
> > dkt01 wrote:
> > > owenpan wrote:
> > > > I don't think it's about unbalanced braces here.
> > > `if (!Scopes.empty())` handles unbalanced braces.  `if(Tok->Previous)` 
> > > handles the case where a line starts with an rbrace.
> > I can't think of an example. Do you have one?
> The format unit test `FormatUnbalancedStructuralElements` feeds in strings 
> that have only right braces, so without this check the pop fails.
Thanks!


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

https://reviews.llvm.org/D141959

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


[PATCH] D143318: [Support] Move ItaniumManglingCanonicalizer and SymbolRemappingReader from Support to ProfileData

2023-02-04 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: rsmith, chapuni, MaskRay, kristina, erik.pilkington.
Herald added subscribers: wenlei, hiraditya.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

As mentioned on 
https://discourse.llvm.org/t/issues-in-llvm-tblgen-high-parallelized-build/68037,
 ItaniumManglingCanonicalizer is often slow to build, resulting in a bottleneck 
for distributed builds while waiting for LLVMSupport to complete.

SymbolRemappingReader is the only current user of ItaniumManglingCanonicalizer, 
and this is only used by ProfileData and llvm-cxxmap - so I propose we move 
both files into the ProfileData library.

An alternative would be to begin a LLVMSymbol library but I don't think we have 
a strong enough need for that yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143318

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/include/llvm/ProfileData/ItaniumManglingCanonicalizer.h
  llvm/include/llvm/ProfileData/SampleProfReader.h
  llvm/include/llvm/ProfileData/SymbolRemappingReader.h
  llvm/lib/ProfileData/CMakeLists.txt
  llvm/lib/ProfileData/InstrProfReader.cpp
  llvm/lib/ProfileData/ItaniumManglingCanonicalizer.cpp
  llvm/lib/ProfileData/SymbolRemappingReader.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/tools/llvm-cxxmap/CMakeLists.txt
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/unittests/ProfileData/CMakeLists.txt
  llvm/unittests/ProfileData/ItaniumManglingCanonicalizerTest.cpp
  llvm/unittests/ProfileData/SymbolRemappingReaderTest.cpp
  llvm/unittests/Support/CMakeLists.txt
  llvm/utils/gn/secondary/llvm/lib/ProfileData/BUILD.gn
  llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
  llvm/utils/gn/secondary/llvm/tools/llvm-cxxmap/BUILD.gn
  llvm/utils/gn/secondary/llvm/unittests/ProfileData/BUILD.gn
  llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/unittests/Support/BUILD.gn
@@ -49,7 +49,6 @@
 "HashBuilderTest.cpp",
 "IndexedAccessorTest.cpp",
 "InstructionCostTest.cpp",
-"ItaniumManglingCanonicalizerTest.cpp",
 "JSONTest.cpp",
 "KnownBitsTest.cpp",
 "LEB128Test.cpp",
@@ -79,7 +78,6 @@
 "SpecialCaseListTest.cpp",
 "SuffixTreeTest.cpp",
 "SwapByteOrderTest.cpp",
-"SymbolRemappingReaderTest.cpp",
 "TarWriterTest.cpp",
 "TaskQueueTest.cpp",
 "ThreadPool.cpp",
Index: llvm/utils/gn/secondary/llvm/unittests/ProfileData/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/unittests/ProfileData/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/unittests/ProfileData/BUILD.gn
@@ -11,7 +11,9 @@
 "CoverageMappingTest.cpp",
 "InstrProfDataTest.cpp",
 "InstrProfTest.cpp",
+"ItaniumManglingCanonicalizerTest.cpp",
 "MemProfTest.cpp",
 "SampleProfTest.cpp",
+"SymbolRemappingReaderTest.cpp",
   ]
 }
Index: llvm/utils/gn/secondary/llvm/tools/llvm-cxxmap/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/tools/llvm-cxxmap/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/tools/llvm-cxxmap/BUILD.gn
@@ -1,6 +1,7 @@
 executable("llvm-cxxmap") {
   deps = [
 "//llvm/lib/IR",
+"//llvm/lib/ProfileData",
 "//llvm/lib/Support",
 "//llvm/lib/Target:TargetsToBuild",
   ]
Index: llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -89,7 +89,6 @@
 "InstructionCost.cpp",
 "IntEqClasses.cpp",
 "IntervalMap.cpp",
-"ItaniumManglingCanonicalizer.cpp",
 "JSON.cpp",
 "KnownBits.cpp",
 "LEB128.cpp",
@@ -133,7 +132,6 @@
 "StringRef.cpp",
 "StringSaver.cpp",
 "SuffixTree.cpp",
-"SymbolRemappingReader.cpp",
 "SystemUtils.cpp",
 "TarWriter.cpp",
 "ThreadPool.cpp",
Index: llvm/utils/gn/secondary/llvm/lib/ProfileData/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/ProfileData/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/ProfileData/BUILD.gn
@@ -14,11 +14,13 @@
 "InstrProfCorrelator.cpp",
 "InstrProfReader.cpp",
 "InstrProfWriter.cpp",
+"ItaniumManglingCanonicalizer.cpp",
 "MemProf.cpp",
 "ProfileSummaryBuilder.cpp",
 "RawMemProfReader.cpp",
 "SampleProf.cpp",
 "SampleProfReader.cpp",
 "SampleProfWriter.cpp",
+"SymbolRemappingReader.cpp",
   ]
 }
Index: llvm/unittests/Support/CMakeLists.txt
===
--- llvm/unittests/Support/CMakeLists.txt
+++ llvm/unittests/Suppo

[PATCH] D143306: [Driver] Default to -fno-openmp-implicit-rpath

2023-02-04 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added reviewers: tianshilei1992, ye-luo, RaviNarayanaswamy.
JonChesterfield added a comment.

Added some people I can remember from the original discussion.

The effect of this patch will be that clang -fopenmp foo.cpp will build an 
executable that doesn't know where its runtime libraries are. If it finds the 
right ones anyway that'll be fine. If it finds ones from some unrelated 
toolchain, that application usually won't work.

This is likely to be more painful for people with multiple toolchains installed.

How do the other projects deal with this hazard?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143306

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


[PATCH] D143319: [clangd] Support iwyu pragma: no_include

2023-02-04 Thread Younan Zhang via Phabricator via cfe-commits
zyounan created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
zyounan updated this revision to Diff 494815.
zyounan added a comment.
zyounan updated this revision to Diff 494816.
zyounan added reviewers: hokein, sammccall, kadircet, nridge.
zyounan published this revision for review.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Remove extra headers


zyounan added a comment.

Update test


This patch is one of the steps trying to optimize experience
of header insertion in code completion.
IWYU supports `no_include` pragma that helps user to get rid
of specified headers in main file.
The patch consists of two parts: Code completion part that
prevent auto insertion if the header to be inserted is under
the guard of `no_include` pragma. The other part is for include
cleaner, which emits diagnostic message pointing out that user
is including `no_include` headers.

A possible workaround for clangd/clangd#1481.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143319

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/unittests/HeadersTests.cpp
  clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp

Index: clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
===
--- clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
+++ clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "Config.h"
 #include "IncludeCleaner.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "TestFS.h"
 #include "TestTU.h"
@@ -22,8 +23,10 @@
 namespace clangd {
 namespace {
 
+using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::ElementsAreArray;
+using ::testing::Field;
 using ::testing::IsEmpty;
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
@@ -611,6 +614,36 @@
   EXPECT_THAT(computeUnusedIncludesExperimental(AST), IsEmpty());
 }
 
+MATCHER_P(message, Message, "") { return arg.Message == Message; }
+MATCHER_P2(range, Start, End, "") {
+  return arg.start == Start && arg.end == End;
+}
+
+TEST(IncludeCleaner, IWYUPragmaNoInclude) {
+  TestTU TU;
+  TU.Code = R"cpp(
+#include "foo.h"
+#include "bar.h"
+// IWYU pragma: no_include "bar.h"
+  )cpp";
+  TU.AdditionalFiles["foo.h"] = guard("");
+  TU.AdditionalFiles["bar.h"] = guard("");
+  ParsedAST AST = TU.build();
+
+  auto Diags = issueNoIncludesDiagnostics(AST, TU.Code);
+  EXPECT_THAT(
+  Diags,
+  UnorderedElementsAre(AllOf(
+  message(
+  "included header 'bar.h' is marked as `no_include` at line 4"),
+  Field(&DiagBase::Range, range(Position{2, 0}, Position{2, 16});
+  ASSERT_TRUE(Diags.size() == 1);
+  EXPECT_THAT(Diags.back().Fixes.size(), 1);
+  ASSERT_TRUE(Diags.back().Fixes.back().Edits.size() == 1);
+  EXPECT_THAT(Diags.back().Fixes.back().Edits.back().range,
+  range(Position{2, 0}, Position{3, 0}));
+}
+
 TEST(IncludeCleaner, NoDiagsForObjC) {
   TestTU TU;
   TU.Code = R"cpp(
Index: clang-tools-extra/clangd/unittests/HeadersTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeadersTests.cpp
+++ clang-tools-extra/clangd/unittests/HeadersTests.cpp
@@ -93,7 +93,8 @@
   // Calculates the include path, or returns "" on error or header should not be
   // inserted.
   std::string calculate(PathRef Original, PathRef Preferred = "",
-const std::vector &Inclusions = {}) {
+const std::vector &Inclusions = {},
+const std::vector &IwyuNoIncludes = {}) {
 Clang = setupClang();
 PreprocessOnlyAction Action;
 EXPECT_TRUE(
@@ -111,6 +112,8 @@
  &Clang->getPreprocessor().getHeaderSearchInfo());
 for (const auto &Inc : Inclusions)
   Inserter.addExisting(Inc);
+for (const auto &Inc : IwyuNoIncludes)
+  Inserter.addNoInclude(Inc);
 auto Inserted = ToHeaderFile(Preferred);
 if (!Inserter.shouldInsertInclude(Original, Inserted))
   return "";
@@ -275,6 +278,29 @@
AllOf(written("\"bar.h\""), hasPragmaKeep(true;
 }
 
+TEST_F(HeadersTest, IWYUPragmaNoInclude) {
+  FS.Files[MainFile] = R"cpp(
+// IWYU pragma: no_include "baz.h"
+#include "foo.h"
+// IWYU pragma: no_include 
+// IWYU pragma: no_include  "headers.hpp" invalid
+// IWYU pragma: no_include no_quotes are considered invalid
+// IWYU pragma: no_include 
+  )cpp";
+  FS.Files["foo.h"] = "";
+
+  auto NI = collectIncludes().IwyuNoIncludes;
+  ASSERT_

[PATCH] D143109: [Sema] Push a LambdaScopeInfo before calling SubstDefaultArgument

2023-02-04 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

My question is, why do we need to mess up with scopes in that way outside of 
parsing  (there are only a couple places where we do that at the moment, and 
they are dummy scopes which only exist to balance some push and pop, afaict 
they serve no other purpose).
As i said, I have no objection to this at all, it clearly fixes the issue and 
we should land it! But the fact we have to do this in the first place *may* be 
a sign that there is a deeper issue, one that we clearly should not try to 
address as part of this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143109

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


[PATCH] D143091: [clang-format] PackConstructorInitializers support PCIS_OnlyNextLine

2023-02-04 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght updated this revision to Diff 494821.
Backl1ght added a comment.

add more unittest


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

https://reviews.llvm.org/D143091

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7289,6 +7289,19 @@
  Style);
 verifyFormat("Constructor() : a(a), b(b) {}", Style);
 
+Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
+verifyFormat("Constructor()\n"
+ ": (a), b(b) {}",
+ Style);
+verifyFormat("Constructor()\n"
+ ": a(a), b(b) {}",
+ Style);
+verifyFormat("Constructor()\n"
+ ": (a)\n"
+ ", b(b)\n"
+ ", cc(c) {}",
+ Style);
+
 Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeColon;
 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
 verifyFormat("Constructor()\n"
@@ -7301,6 +7314,19 @@
  "  b(b) {}",
  Style);
 
+Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
+verifyFormat("Constructor()\n"
+ ": (a), b(b) {}",
+ Style);
+verifyFormat("Constructor()\n"
+ ": a(a), b(b) {}",
+ Style);
+verifyFormat("Constructor()\n"
+ ": (a),\n"
+ "  b(b),\n"
+ "  cc(c) {}",
+ Style);
+
 Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
 Style.PackConstructorInitializers = FormatStyle::PCIS_NextLine;
 verifyFormat("Constructor() :\n"
@@ -7312,6 +7338,19 @@
  "aa(a),\n"
  "b(b) {}",
  Style);
+
+Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
+verifyFormat("Constructor() :\n"
+ "aa(a), b(b) {}",
+ Style);
+verifyFormat("Constructor() :\n"
+ "a(a), b(b) {}",
+ Style);
+verifyFormat("Constructor() :\n"
+ "(a),\n"
+ "b(b),\n"
+ "cc(c) {}",
+ Style);
   }
 
   // Test interactions between AllowAllParametersOfDeclarationOnNextLine and
@@ -7319,6 +7358,7 @@
   // BreakConstructorInitializers modes
   Style.BreakConstructorInitializers = FormatStyle::BCIS_BeforeComma;
   Style.AllowAllParametersOfDeclarationOnNextLine = true;
+  Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
   verifyFormat("SomeClassWithALongName::Constructor(\n"
"int , int b)\n"
": (a)\n"
@@ -7333,6 +7373,14 @@
": (a), b(b) {}",
Style);
 
+  Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
+  verifyFormat("SomeClassWithALongName::Constructor(\n"
+   "int ,\n"
+   "int b,\n"
+   "int )\n"
+   ": (a), b(b) {}",
+   Style);
+
   Style.AllowAllParametersOfDeclarationOnNextLine = false;
   Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
   verifyFormat("SomeClassWithALongName::Constructor(\n"
@@ -7359,6 +7407,14 @@
": (a), b(b) {}",
Style);
 
+  Style.PackConstructorInitializers = FormatStyle::PCIS_NextLineOnly;
+  verifyFormat("SomeClassWithALongName::Constructor(\n"
+   "int ,\n"
+   "int b,\n"
+   "int )\n"
+   ": (a), b(b) {}",
+   Style);
+
   Style.AllowAllParametersOfDeclarationOnNextLine = false;
   Style.PackConstructorInitializers = FormatStyle::PCIS_CurrentLine;
   verifyFormat("SomeClassWithALongName::Constructor(\n"
@@ -7384,6 +7440,14 @@
"

[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

2023-02-04 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

> Also, why are these diagnostics off by default? Do we have some idea as to 
> the false positive rate?

As for the false positive rate, I have checked for instances of this warning in 
the codebases for 'oneapi-src/oneTBB', 'rui314/mold', and 'microsoft/lightgbm', 
but did not find any new cases.
I also ran a test on  'tensorflow/tensorflow' using gcc '-Wparentheses' and 
found six lines of code that trigger the new diagnostic. They all relate to 
checking whether `x` and `y` have the same sign using `x > 0 == y > 0` and 
alike. I tried to build with tensorflow using clang, but I stumbled upon some 
errors (for my poor knowledge of bazel configuration), so here I am using gcc.

I set the diagnostic disabled by default for compatibility with gcc. 
Considering the test against tensorflow above, it would be too noisy if we 
turned on the suggest-parentheses diagnostic by default (From my best guess, it 
would generate at least 18 new instances of warning on the tensorflow build for 
the six lines).
However, in my opinion, it is reasonable enough to have the diagnostic on 
chained relational operators enabled by default. The following is an excerpt 
from the 'Existing Code in C++' section of the proposal document of the 
introduction of chaining comparison for C++17.

> Overall, what we found was:
>
> - Zero instances of chained arithmetic comparisons that are correct today. 
> That is, intentionally using the current standard behavior.
> - Four instances of currently-erroneous arithmetic chaining, of the assert(0 
> <= ratio <= 1.0); variety. These are bugs that compile today but don’t do 
> what the programmer intended, but with this proposal would change in meaning 
> to become correct.
> - Many instances of using successive comparison operators in DSLs that 
> overloaded these operators to give meaning unrelated to comparisons.

Note that the 'chaining comparisons' in the document are

> - all `==`, such as `a == b == c == d`;
> - all `{<, <=}`, such as `a < b <= c < d`; and
> - all `{>, >=}` (e.g., `a >= b > c > d`).

URL: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0893r0.html

Although this paper is five years old now, I think we can conclude chaining 
relational operators are bug-prone and should be diagnosed by default.
Also, reading the document above, I think it would be reasonable to suggest 
adding '&&' in `a == b == c` case, too.

tensorflow/tensorflow newly-warned lines:

- 
https://github.com/tensorflow/tensorflow/blob/12eef948f12e47ab9ce736d8967c72fc4436db79/tensorflow/compiler/xla/overflow_util.h#L67
- 
https://github.com/tensorflow/tensorflow/blob/78034c6ee8f20932d7c43498326ea190966c5a19/tensorflow/core/kernels/cwise_ops.h#L366
- 
https://github.com/tensorflow/tensorflow/blob/78034c6ee8f20932d7c43498326ea190966c5a19/tensorflow/core/kernels/cwise_ops.h#L436
- 
https://github.com/tensorflow/tensorflow/blob/78034c6ee8f20932d7c43498326ea190966c5a19/tensorflow/core/kernels/cwise_ops.h#L457
- 
https://github.com/tensorflow/tensorflow/blob/9edf0d9eb621f18217c2a0cc5d9b67f53b40901e/tensorflow/compiler/xla/service/while_loop_analysis.cc#L364
- 
https://github.com/tensorflow/tensorflow/blob/9edf0d9eb621f18217c2a0cc5d9b67f53b40901e/tensorflow/compiler/xla/service/while_loop_analysis.cc#L377


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

https://reviews.llvm.org/D142800

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


[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

2023-02-04 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp:27
+  // Consider only explicitly or implicitly inline functions.
+  if (!FuncDecl->isInlined())
+return;

Check if FuncDecl is not a nullptr before dereferencing. You can do an early 
return like:

```
if (!FuncDecl)
  return;
```



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h:27-36
+  InlineFunctionDeclCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context),
+RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
+"HeaderFileExtensions", utils::defaultHeaderFileExtensions())) {
+if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
+HeaderFileExtensions,
+utils::defaultFileExtensionDelimiters())) {

Please implement constructor in the .cpp file.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h:39-41
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;
+  }

This is OK to keep in the header as it's only one line.



Comment at: 
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h:43-51
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override {
+Options.store(Opts, "HeaderFileExtensions", RawStringHeaderFileExtensions);
+if (!utils::parseFileExtensions(RawStringHeaderFileExtensions,
+HeaderFileExtensions,
+utils::defaultFileExtensionDelimiters())) {
+  this->configurationDiag("Invalid header file extension: '%0'")
+  << RawStringHeaderFileExtensions;

Ditto



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
 
+New `llvmlibc-inline-function-decl-check 
`_
+check.

I believe you'll need a rebase since a new check was recently added.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:104
+Checks that all implicit and explicit inline functions in header files are
+tagged with the ``LIBC_INLINE`` macro.
+

You need to also add the check to 
`clang-tools-extra/docs/clang-tidy/checks/list.rst`



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp:2
+// RUN: %check_clang_tidy %s llvmlibc-inline-function-decl-check %t \
+// RUN:   -- -header-filter=.* -- -I %S
+

I believe this can be removed.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp:20
+constexpr long long addll(long long a, long long b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: 'addll' must be tagged with the 
LIBC_INLINE macro
+  return a + b;

Missing check name:

```
... LIBC_INLINE macro [llvmlibc-inline-function-decl]
```



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/llvmlibc/inline-function-decl.hpp:45
+  static int getVal(const MyClass &V) {
+  // CHECK-MESSAGES: warning: 'getVal' must be tagged with the LIBC_INLINE 
macro
+return V.A;

Missing line and column info


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

2023-02-04 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst:8
+tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
+`_ for more information about this 
macro.

Document the `HeaderFileExtensions` option, see existing checks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-04 Thread Erik Desjardins via Phabricator via cfe-commits
erikdesjardins updated this revision to Diff 494835.
erikdesjardins added a comment.

rebase, remove now-unnecessary test changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

Files:
  clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
  clang/unittests/Basic/SarifTest.cpp
  compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  llvm/lib/Support/StringMap.cpp
  llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
  llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
  llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
  llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
  llvm/test/DebugInfo/X86/gnu-public-names.ll
  llvm/test/ObjectYAML/Offload/binary.yaml
  llvm/test/ObjectYAML/Offload/multiple_members.yaml
  llvm/test/tools/dsymutil/ARM/extern-alias.test
  llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
  mlir/test/mlir-lsp-server/completion.test

Index: mlir/test/mlir-lsp-server/completion.test
===
--- mlir/test/mlir-lsp-server/completion.test
+++ mlir/test/mlir-lsp-server/completion.test
@@ -84,18 +84,18 @@
 // CHECK-NEXT:"isIncomplete": false,
 // CHECK-NEXT:"items": [
 // CHECK-NEXT:  {
-// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
-// CHECK-NEXT:"insertText": "cast",
-// CHECK-NEXT:"insertTextFormat": 1,
-// CHECK-NEXT:"kind": 6,
-// CHECK-NEXT:"label": "%cast"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  {
 // CHECK-NEXT:"detail": "arg #0: i32",
 // CHECK-NEXT:"insertText": "arg",
 // CHECK-NEXT:"insertTextFormat": 1,
 // CHECK-NEXT:"kind": 6,
 // CHECK-NEXT:"label": "%arg"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
+// CHECK-NEXT:"insertText": "cast",
+// CHECK-NEXT:"insertTextFormat": 1,
+// CHECK-NEXT:"kind": 6,
+// CHECK-NEXT:"label": "%cast"
 // CHECK-NEXT:  }
 // CHECK: ]
 // CHECK-NEXT:  }
Index: llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
===
--- llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
+++ llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
@@ -6,15 +6,15 @@
 RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX1
 
-MIX1: foo:
-MIX1-NEXT: Hash: 0x0007
-MIX1-NEXT: Counters: 5
-MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
 MIX1: goo:
 MIX1-NEXT: Hash: 0x0005
 MIX1-NEXT: Counters: 3
 MIX1-NOT: Block counts:
 MIX1-SAME: 
+MIX1: foo:
+MIX1-NEXT: Hash: 0x0007
+MIX1-NEXT: Counters: 5
+MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
 MIX1: moo:
 MIX1-NEXT: Hash: 0x0009
 MIX1-NEXT: Counters: 4
@@ -27,16 +27,16 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX2
 
-MIX2: foo:
-MIX2-NEXT: Hash: 0x0007
-MIX2-NEXT: Counters: 5
-MIX2-NOT: Block counts:
-MIX2-SAME: 
 MIX2: goo:
 MIX2-NEXT: Hash: 0x0005
 MIX2-NEXT: Counters: 3
 MIX2-NOT: Block counts:
 MIX2-SAME: 
+MIX2: foo:
+MIX2-NEXT: Hash: 0x0007
+MIX2-NEXT: Counters: 5
+MIX2-NOT: Block counts:
+MIX2-SAME: 
 MIX2: moo:
 MIX2-NEXT: Hash: 0x0009
 MIX2-NEXT: Counters: 4
@@ -49,15 +49,15 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX3
 
-MIX3: foo:
-MIX3-NEXT: Hash: 0x0007
-MIX3-NEXT: Counters: 5
-MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
 MIX3: goo:
 MIX3-NEXT: Hash: 0x0005
 MIX3-NEXT: Counters: 3
 MIX3-NOT: Block counts:
 MIX3-SAME: 
+MIX3: foo:
+MIX3-NEXT: Hash: 0x0007
+MIX3-NEXT: Counters: 5
+MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
 MIX3: moo:
 MIX3-NEXT: Hash: 0x0009
 MIX3-NEXT: Counters: 4
@@ -71,15 +71,15 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4
 
-MIX4: foo:
-MIX4-NEXT: Hash: 0x0007
-MIX4-NEXT: Counters: 1
-MIX4-NEXT: Block counts: [0]
 MIX4: goo:
 MIX4-NEXT: Hash: 0x0005
 MIX4-NEXT: Counters: 3
 MIX4-NOT: Block counts:
 MIX4-SAME: 
+MIX4: foo:
+MIX4-NEXT: Hash: 0x0007
+MIX4-NEXT: Counters: 1
+MIX4-NEXT: Block counts: [0]
 MIX4: moo:
 MIX4-NEXT: Hash: 0x0009
 MIX4-NEXT: Counters: 1
Index: llvm/test/tools/dsymutil/ARM/extern-alias.test

[PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-04 Thread Erik Desjardins via Phabricator via cfe-commits
erikdesjardins updated this revision to Diff 494836.
erikdesjardins edited the summary of this revision.
erikdesjardins added a comment.

update description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

Files:
  clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
  clang/unittests/Basic/SarifTest.cpp
  compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  llvm/lib/Support/StringMap.cpp
  llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
  llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
  llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
  llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
  llvm/test/DebugInfo/X86/gnu-public-names.ll
  llvm/test/ObjectYAML/Offload/binary.yaml
  llvm/test/ObjectYAML/Offload/multiple_members.yaml
  llvm/test/tools/dsymutil/ARM/extern-alias.test
  llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
  mlir/test/mlir-lsp-server/completion.test

Index: mlir/test/mlir-lsp-server/completion.test
===
--- mlir/test/mlir-lsp-server/completion.test
+++ mlir/test/mlir-lsp-server/completion.test
@@ -84,18 +84,18 @@
 // CHECK-NEXT:"isIncomplete": false,
 // CHECK-NEXT:"items": [
 // CHECK-NEXT:  {
-// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
-// CHECK-NEXT:"insertText": "cast",
-// CHECK-NEXT:"insertTextFormat": 1,
-// CHECK-NEXT:"kind": 6,
-// CHECK-NEXT:"label": "%cast"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  {
 // CHECK-NEXT:"detail": "arg #0: i32",
 // CHECK-NEXT:"insertText": "arg",
 // CHECK-NEXT:"insertTextFormat": 1,
 // CHECK-NEXT:"kind": 6,
 // CHECK-NEXT:"label": "%arg"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
+// CHECK-NEXT:"insertText": "cast",
+// CHECK-NEXT:"insertTextFormat": 1,
+// CHECK-NEXT:"kind": 6,
+// CHECK-NEXT:"label": "%cast"
 // CHECK-NEXT:  }
 // CHECK: ]
 // CHECK-NEXT:  }
Index: llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
===
--- llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
+++ llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
@@ -6,15 +6,15 @@
 RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX1
 
-MIX1: foo:
-MIX1-NEXT: Hash: 0x0007
-MIX1-NEXT: Counters: 5
-MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
 MIX1: goo:
 MIX1-NEXT: Hash: 0x0005
 MIX1-NEXT: Counters: 3
 MIX1-NOT: Block counts:
 MIX1-SAME: 
+MIX1: foo:
+MIX1-NEXT: Hash: 0x0007
+MIX1-NEXT: Counters: 5
+MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
 MIX1: moo:
 MIX1-NEXT: Hash: 0x0009
 MIX1-NEXT: Counters: 4
@@ -27,16 +27,16 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX2
 
-MIX2: foo:
-MIX2-NEXT: Hash: 0x0007
-MIX2-NEXT: Counters: 5
-MIX2-NOT: Block counts:
-MIX2-SAME: 
 MIX2: goo:
 MIX2-NEXT: Hash: 0x0005
 MIX2-NEXT: Counters: 3
 MIX2-NOT: Block counts:
 MIX2-SAME: 
+MIX2: foo:
+MIX2-NEXT: Hash: 0x0007
+MIX2-NEXT: Counters: 5
+MIX2-NOT: Block counts:
+MIX2-SAME: 
 MIX2: moo:
 MIX2-NEXT: Hash: 0x0009
 MIX2-NEXT: Counters: 4
@@ -49,15 +49,15 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX3
 
-MIX3: foo:
-MIX3-NEXT: Hash: 0x0007
-MIX3-NEXT: Counters: 5
-MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
 MIX3: goo:
 MIX3-NEXT: Hash: 0x0005
 MIX3-NEXT: Counters: 3
 MIX3-NOT: Block counts:
 MIX3-SAME: 
+MIX3: foo:
+MIX3-NEXT: Hash: 0x0007
+MIX3-NEXT: Counters: 5
+MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
 MIX3: moo:
 MIX3-NEXT: Hash: 0x0009
 MIX3-NEXT: Counters: 4
@@ -71,15 +71,15 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4
 
-MIX4: foo:
-MIX4-NEXT: Hash: 0x0007
-MIX4-NEXT: Counters: 1
-MIX4-NEXT: Block counts: [0]
 MIX4: goo:
 MIX4-NEXT: Hash: 0x0005
 MIX4-NEXT: Counters: 3
 MIX4-NOT: Block counts:
 MIX4-SAME: 
+MIX4: foo:
+MIX4-NEXT: Hash: 0x0007
+MIX4-NEXT: Counters: 1
+MIX4-NEXT: Block counts: [0]
 MIX4: moo:
 MIX4-NEXT: Hash: 0x0009
 MIX4-NEXT: Counters: 1
Index: llvm/test/tools/dsymutil/ARM/extern-alias.test
=

[PATCH] D142592: [clang-tidy][libc] Add an inline function checker for the libc project.

2023-02-04 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp:28
+CheckFactories.registerCheck(
+"llvmlibc-inline-function-decl-check");
 CheckFactories.registerCheck(

Remove



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
 
+New `llvmlibc-inline-function-decl-check 
`_
+check.

carlosgalvezp wrote:
> I believe you'll need a rebase since a new check was recently added.
Remove



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:100
 
+New `llvmlibc-inline-function-decl-check 
`_
+check.

carlosgalvezp wrote:
> carlosgalvezp wrote:
> > I believe you'll need a rebase since a new check was recently added.
> Remove
Remove



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst:1
+.. title:: clang-tidy - llvmlibc-inline-funciton-decl-check
+

Remove



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst:3
+
+llvmlibc-inline-function-decl-check
+

Remove



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl-check.rst:4
+llvmlibc-inline-function-decl-check
+
+

Nit: remove extra `=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142592

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-04 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp:88
+
+  if (!Param) {
+return;

Nit: the style convention in LLVM is to not use braces with one-line `if/else`.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:52
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter is 
never moved from inside the function body 
[cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter is 
never moved from inside the function body 
[cppcoreguidelines-rvalue-reference-param-not-moved]

It would be good for the check to specify which parameter it's referring to, 
for example:

```
rvalue reference paramter 'o1' is never moved...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D142891: [clang-format] Recognize Verilog non-blocking assignment

2023-02-04 Thread sstwcw via Phabricator via cfe-commits
sstwcw updated this revision to Diff 494839.
sstwcw added a comment.

- add parentheses
- rename field


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142891

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTestVerilog.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1247,6 +1247,21 @@
   EXPECT_TOKEN(Tokens[5], tok::question, TT_ConditionalExpr);
   EXPECT_TOKEN(Tokens[7], tok::colon, TT_ConditionalExpr);
   EXPECT_TOKEN(Tokens[9], tok::colon, TT_GotoLabelColon);
+  // Non-blocking assignments.
+  Tokens = Annotate("a <= b;");
+  ASSERT_EQ(Tokens.size(), 5u);
+  EXPECT_TOKEN(Tokens[1], tok::lessequal, TT_BinaryOperator);
+  EXPECT_TOKEN_PRECEDENCE(Tokens[1], prec::Assignment);
+  Tokens = Annotate("if (a <= b) break;");
+  ASSERT_EQ(Tokens.size(), 9u);
+  EXPECT_TOKEN(Tokens[3], tok::lessequal, TT_BinaryOperator);
+  EXPECT_TOKEN_PRECEDENCE(Tokens[3], prec::Relational);
+  Tokens = Annotate("a <= b <= a;");
+  ASSERT_EQ(Tokens.size(), 7u);
+  EXPECT_TOKEN(Tokens[1], tok::lessequal, TT_BinaryOperator);
+  EXPECT_TOKEN_PRECEDENCE(Tokens[1], prec::Assignment);
+  EXPECT_TOKEN(Tokens[3], tok::lessequal, TT_BinaryOperator);
+  EXPECT_TOKEN_PRECEDENCE(Tokens[3], prec::Relational);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandConstructors) {
Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -45,6 +45,58 @@
   }
 };
 
+TEST_F(FormatTestVerilog, Align) {
+  FormatStyle Style = getLLVMStyle(FormatStyle::LK_Verilog);
+  Style.AlignConsecutiveAssignments.Enabled = true;
+  verifyFormat("x<= x;\n"
+   "sfdbddfbdfbb <= x;\n"
+   "x = x;",
+   Style);
+  verifyFormat("x= x;\n"
+   "sfdbddfbdfbb = x;\n"
+   "x= x;",
+   Style);
+  // Compound assignments are not aligned by default. '<=' is not a compound
+  // assignment.
+  verifyFormat("x<= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x += x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x <<= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x <<<= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x >>= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x >>>= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  Style.AlignConsecutiveAssignments.AlignCompound = true;
+  verifyFormat("x<= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x+= x;\n"
+   "sfdbddfbdfbb <= x;",
+   Style);
+  verifyFormat("x<<= x;\n"
+   "sfdbddfbdfbb  <= x;",
+   Style);
+  verifyFormat("x<<<= x;\n"
+   "sfdbddfbdfbb   <= x;",
+   Style);
+  verifyFormat("x>>= x;\n"
+   "sfdbddfbdfbb  <= x;",
+   Style);
+  verifyFormat("x>>>= x;\n"
+   "sfdbddfbdfbb   <= x;",
+   Style);
+}
+
 TEST_F(FormatTestVerilog, BasedLiteral) {
   verifyFormat("x = '0;");
   verifyFormat("x = '1;");
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -838,7 +838,12 @@
 
 return Style.AlignConsecutiveAssignments.AlignCompound
? C.Tok->getPrecedence() == prec::Assignment
-   : C.Tok->is(tok::equal);
+   : (C.Tok->is(tok::equal) ||
+  // In Verilog the '<=' is not a compound assignment, thus
+  // it is aligned even when the AlignCompound option is not
+  // set.
+  (Style.isVerilog() && C.Tok->is(tok::lessequal) &&
+   C.Tok->getPrecedence() == prec::Assignment));
   },
   Changes, /*StartAt=*/0, Style.AlignConsecutiveAssignments,
   /*RightJustify=*/true);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1625,6 +1625,7 @@
 bool CaretFound = false;
 bool InCpp11AttributeSpecifier = false;
 bool InCSharpAttributeSpecifier = false;
+bool VerilogAssignment

[PATCH] D143318: [Support] Move ItaniumManglingCanonicalizer and SymbolRemappingReader from Support to ProfileData

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`ItaniumManglingCanonicalizer.cpp` doesn't have many includes. I think it is 
fine to remain in llvm/lib/Support ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143318

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


[PATCH] D143318: [Support] Move ItaniumManglingCanonicalizer and SymbolRemappingReader from Support to ProfileData

2023-02-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Another alternative would be to move these classes to the Demangle library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143318

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


[PATCH] D143318: [Support] Move ItaniumManglingCanonicalizer and SymbolRemappingReader from Support to ProfileData

2023-02-04 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D143318#4104408 , @MaskRay wrote:

> `ItaniumManglingCanonicalizer.cpp` doesn't have many includes. I think it is 
> fine to remain in llvm/lib/Support ...

The frontend cost might not be high - but ItaniumManglingCanonicalizer.cpp is 
still slow to build, so getting it out of something as core as Support still 
make senses


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143318

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


[PATCH] D143306: [Driver] Default to -fno-openmp-implicit-rpath

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D143306#4104208 , @JonChesterfield 
wrote:

> Added some people I can remember from the original discussion.
>
> The effect of this patch will be that clang -fopenmp foo.cpp will build an 
> executable that doesn't know where its runtime libraries are. If it finds the 
> right ones anyway that'll be fine. If it finds ones from some unrelated 
> toolchain, that application usually won't work.
>
> This is likely to be more painful for people with multiple toolchains 
> installed.
>
> How do the other projects deal with this hazard?

For libc++.so libc++abi.so libunwind.so users, there is no implicit 
`-Wl,-rpath=`. The user should ensure the built executable will get correct 
libraries at run-time.
Some build systems may provide some rpath mechanism.

As already mentioned, you can set `-Wl,-rpath` in your Clang configuration file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143306

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


[PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: llvm/test/ObjectYAML/Offload/multiple_members.yaml:21
   Value:"gfx908"
 Content:  "cafefeed"  
 

Rebase:) I fixed obj2yaml



Comment at: llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test:1
 Some basic tests for supplementing instrumentation profile with sample profile.
 

llvm-profdata uses OnDiskHashTable.h which I think is infeasible to stabilize 
without drastic change to the format. So keep the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

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


[clang] 7e3943f - [clang-linker-wrapper] Fix build after MapVector change

2023-02-04 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-02-04T12:54:26-08:00
New Revision: 7e3943f5767d63b24c99aad056ad01cf7e6bfe52

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

LOG: [clang-linker-wrapper] Fix build after MapVector change

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 6ec089a8233c0..8779042f81fde 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -185,7 +185,8 @@ Expected getInputBitcodeLibrary(StringRef 
Input) {
   OffloadingImage Image{};
   Image.TheImageKind = IMG_Bitcode;
   Image.TheOffloadKind = getOffloadKind(Kind);
-  Image.StringData = {{"triple", Triple}, {"arch", Arch}};
+  Image.StringData["triple"] = Triple;
+  Image.StringData["arch"] = Arch;
   Image.Image = std::move(*ImageOrError);
 
   std::unique_ptr Binary = OffloadBinary::write(Image);
@@ -1058,11 +1059,8 @@ linkAndWrapDeviceFiles(SmallVectorImpl 
&LinkerInputFiles,
   TheImage.TheImageKind =
   Args.hasArg(OPT_embed_bitcode) ? IMG_Bitcode : IMG_Object;
   TheImage.TheOffloadKind = Kind;
-  TheImage.StringData = {
-  {"triple",
-   Args.MakeArgString(LinkerArgs.getLastArgValue(OPT_triple_EQ))},
-  {"arch",
-   Args.MakeArgString(LinkerArgs.getLastArgValue(OPT_arch_EQ))}};
+  TheImage.StringData["triple"] = 
Args.MakeArgString(LinkerArgs.getLastArgValue(OPT_triple_EQ));
+  TheImage.StringData["arch"] = 
Args.MakeArgString(LinkerArgs.getLastArgValue(OPT_arch_EQ));
   TheImage.Image = std::move(*FileOrErr);
 
   Images[Kind].emplace_back(std::move(TheImage));



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


[PATCH] D143325: [Driver] Add -mllvm= as an alias for -mllvm

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: jdoerfert, jhuber6, tra, yaxunl.
Herald added a reviewer: sscalpone.
Herald added a subscriber: jeroen.dobbelaere.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Similar to D131455  (-Xclang=). As well as 
making it convenient for some build
systems, this allows `-Xarch_device '-mllvm=--inline-threshold=100'` (and
`-Xarch_host`; so we don't need to allow space separators which are uncommon in
driver code).

Bear in mind that -mllvm options are unstable and should be avoided if possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143325

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -27,10 +27,10 @@
 // MLLVM-NOT: 
"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
 
 // RUN: %clang -### -Xarch_device -g -nogpulib --cuda-gpu-arch=gfx900 \
-// RUN:   -Xarch_device -fcf-protection=branch \
+// RUN:   -Xarch_device -fcf-protection=branch -Xarch_device 
-mllvm=--inline-threshold=100 \
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=DEV %s
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch"
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch" "-mllvm" "--inline-threshold=100"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch" "-mllvm" "--inline-threshold=100"
 // DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
 
 // RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3478,6 +3478,8 @@
 def mllvm : Separate<["-"], 
"mllvm">,Flags<[CC1Option,CC1AsOption,CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
+def : Joined<["-"], "mllvm=">, Flags<[CoreOption,FlangOption]>, Alias,
+  HelpText<"Alias for -mllvm">, MetaVarName<"">;
 def mmlir : Separate<["-"], "mmlir">, 
Flags<[CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to MLIR's option processing">;
 def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -27,10 +27,10 @@
 // MLLVM-NOT: "-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
 
 // RUN: %clang -### -Xarch_device -g -nogpulib --cuda-gpu-arch=gfx900 \
-// RUN:   -Xarch_device -fcf-protection=branch \
+// RUN:   -Xarch_device -fcf-protection=branch -Xarch_device -mllvm=--inline-threshold=100 \
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=DEV %s
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch"
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch" "-mllvm" "--inline-threshold=100"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch" "-mllvm" "--inline-threshold=100"
 // DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
 
 // RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3478,6 +3478,8 @@
 def mllvm : Separate<["-"], "mllvm">,Flags<[CC1Option,CC1AsOption,CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
+def : Joined<["-"], "mllvm=">, Flags<[CoreOption,FlangOption]>, Alias,
+  HelpText<"Alias for -mllvm">, MetaVarName<"">;
 def mmlir : Separate<["-"], "mmlir">, Flags<[CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to MLIR's option processing">;
 def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/c

[PATCH] D143305: [clang] Fix -Xarch_ for -mllvm and alike

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

An option value treating a space differently (as a delimiter in this case) is 
uncommon. I suggest an alias `-mllvm=` (D143325 
) which is more inline with the convention of 
the majority of options that take a value (`=` instead of ` `).


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

https://reviews.llvm.org/D143305

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


[PATCH] D143325: [Driver] Add -mllvm= as an alias for -mllvm

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 494844.
MaskRay added a comment.

fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143325

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -27,10 +27,10 @@
 // MLLVM-NOT: 
"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
 
 // RUN: %clang -### -Xarch_device -g -nogpulib --cuda-gpu-arch=gfx900 \
-// RUN:   -Xarch_device -fcf-protection=branch \
+// RUN:   -Xarch_device -fcf-protection=branch -Xarch_device 
-mllvm=--inline-threshold=100 \
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=DEV %s
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch"
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch" {{.*}}"-mllvm" "--inline-threshold=100"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch" {{.*}}"-mllvm" "--inline-threshold=100"
 // DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
 
 // RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3478,6 +3478,8 @@
 def mllvm : Separate<["-"], 
"mllvm">,Flags<[CC1Option,CC1AsOption,CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
+def : Joined<["-"], "mllvm=">, Flags<[CoreOption,FlangOption]>, Alias,
+  HelpText<"Alias for -mllvm">, MetaVarName<"">;
 def mmlir : Separate<["-"], "mmlir">, 
Flags<[CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to MLIR's option processing">;
 def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -27,10 +27,10 @@
 // MLLVM-NOT: "-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
 
 // RUN: %clang -### -Xarch_device -g -nogpulib --cuda-gpu-arch=gfx900 \
-// RUN:   -Xarch_device -fcf-protection=branch \
+// RUN:   -Xarch_device -fcf-protection=branch -Xarch_device -mllvm=--inline-threshold=100 \
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=DEV %s
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch"
-// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch" {{.*}}"-mllvm" "--inline-threshold=100"
+// DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch" {{.*}}"-mllvm" "--inline-threshold=100"
 // DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
 
 // RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3478,6 +3478,8 @@
 def mllvm : Separate<["-"], "mllvm">,Flags<[CC1Option,CC1AsOption,CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to LLVM's option processing">,
   MarshallingInfoStringVector>;
+def : Joined<["-"], "mllvm=">, Flags<[CoreOption,FlangOption]>, Alias,
+  HelpText<"Alias for -mllvm">, MetaVarName<"">;
 def mmlir : Separate<["-"], "mmlir">, Flags<[CoreOption,FC1Option,FlangOption]>,
   HelpText<"Additional arguments to forward to MLIR's option processing">;
 def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141389: [DFSAN] Add support for strnlen, strncat, strsep, sscanf and _tolower

2023-02-04 Thread Tomasz Kuchta via Phabricator via cfe-commits
tkuchta added inline comments.



Comment at: compiler-rt/lib/dfsan/dfsan_custom.cpp:213
+  char *res = strsep(s, delim);
+  s_label = dfsan_read_label(base, strlen(base));
+  if (res && (res != base)) {

browneee wrote:
> tkuchta wrote:
> > browneee wrote:
> > > tkuchta wrote:
> > > > browneee wrote:
> > > > > tkuchta wrote:
> > > > > > browneee wrote:
> > > > > > > The `s_label` represents the taint label for `s` (the pointer).
> > > > > > > 
> > > > > > > This line would clobber the taint label of the pointer (`s`) with 
> > > > > > > a taint label from `s[0][0..n]`.
> > > > > > > 
> > > > > > > I think this line should be deleted.
> > > > > > Agree, s_label represents the taint associated with the **s 
> > > > > > pointer. However I am now wondering if that is the taint wich we 
> > > > > > would like to return.
> > > > > > For example, if we have
> > > > > > if (flags().strict_data_dependencies) {
> > > > > > *ret_label = res ? s_label : 0;
> > > > > > 
> > > > > > We would taint the return value with the value of the pointer, not 
> > > > > > the data. It means that if we operate on a string for which the 
> > > > > > characters are tainted, but the pointer itself isn't, we are likely 
> > > > > > going to return label 0. My understanding was that we are more 
> > > > > > concerned with the taint of the data, not the pointer, am I missing 
> > > > > > something?
> > > > > > 
> > > > > Yes, we are usually more concerned with the taint of the data, not 
> > > > > the pointer.
> > > > > 
> > > > > With strict dependencies:
> > > > > // If the input pointer is tainted, the output pointer would be 
> > > > > tainted (because it is derived from the input pointer - maybe the 
> > > > > same value).
> > > > > taint(s[0]) == dfsan_read_label(s, sizeof(s)) > taint(ret) == 
> > > > > ret_label[0]
> > > > > 
> > > > > // If the input data is tainted, the output data would be tainted 
> > > > > (because it is derived from the input data).
> > > > > taint(s[0][0]) == MEM_TO_SHADOW(s[0])[0] > taint(ret[0]) == 
> > > > > MEM_TO_SHADOW(ret)[0]
> > > > > 
> > > > > Because s[0] == ret  (or ret==null), (for the non-null case) the 
> > > > > output shadow bytes are the same bytes as input shadow bytes and so 
> > > > > these taint labels for the string data in shadow memory do not need 
> > > > > to be explicitly propagated in this function. 
> > > > > 
> > > > > I think the only case actually changing/copying string data is 
> > > > > writing a delimiter byte to NULL, which you handled.
> > > > I am working on the changes and I came across a strange behavior that I 
> > > > would like to ask about.
> > > > 
> > > > It turned out that if we do
> > > > 
> > > > char *s = " ... ";
> > > > dfsan_set_label(label, &p_s, sizeof(&p_s));
> > > > 
> > > > Then, the s_label within the handler is 0, not "label". This is 
> > > > unexpected, as we would like the pointer itself to be labeled here.
> > > > I believe this has something to do with the fact that the input string 
> > > > in strsep is a double pointer. For example this works as expected for 
> > > > the delimiter string, which is a single pointer. 
> > > > It's either I'm doing something incorrectly or there is some issue with 
> > > > propagating labels for double pointers.
> > > > Have you perhaps come across this behavior before?
> > > I'm not sure what p_s is in your example. Could you provide a more 
> > > complete example?
> > > (and maybe all in one function, not half in __dfsw_strsep and half in 
> > > another function)
> > > 
> > > Here is an example showing taint labels at different levels of 
> > > indirection:
> > > 
> > > ```
> > > #include 
> > > #include 
> > > #include 
> > > 
> > > int main(void) {
> > >   char *s = " ... ";
> > >   char **p_s = &s;
> > >   char ***pp_s = &p_s;
> > > 
> > >   dfsan_label i_label = 1 << 0;
> > >   dfsan_label j_label = 1 << 1;
> > >   dfsan_label k_label = 1 << 2;
> > >   dfsan_label m_label = 1 << 3;
> > > 
> > >   // string data
> > >   dfsan_set_label(i_label, s, strlen(s));
> > >   // pointer s
> > >   dfsan_set_label(j_label, &s, sizeof(s));
> > >   // pointer to pointer s
> > >   dfsan_set_label(k_label, &p_s, sizeof(p_s));
> > >   // pointer to pointer to pointer s
> > >   dfsan_set_label(m_label, &pp_s, sizeof(pp_s));
> > > 
> > >   assert(pp_s[0][0] == s);
> > > 
> > >   // string data
> > >   assert(dfsan_read_label(s, strlen(s)) == i_label);
> > >   // pointer s
> > >   assert(dfsan_read_label(&s, sizeof(s)) == j_label);
> > >   // pointer to pointer s
> > >   assert(dfsan_read_label(&p_s, sizeof(p_s)) == k_label);
> > >   // pointer to pointer to pointer s
> > >   assert(dfsan_read_label(&pp_s, sizeof(pp_s)) == m_label);
> > > 
> > >   return 0;
> > > }
> > > ```
> > Hello,
> > 
> > Thank you for the comment.
> > 
> > I should have provided a more complete example.
> > What I meant is a behavior I've found while working on the tests.
> > In the test file I have somet

[PATCH] D143325: [Driver] Add -mllvm= as an alias for -mllvm

2023-02-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 accepted this revision.
jhuber6 added a comment.
This revision is now accepted and ready to land.

This looks good. I've had similar problems when trying to pass things with 
arguments via the `-Xarch` or `-Xopenmp-target=` options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143325

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


[PATCH] D143300: [randstruct] Don't allow implicit forward decl to stop struct randomization

2023-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`clang/test/CodeGen/init-randomized-struct-fwd-decl.c` passes without this 
patch. Is it correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143300

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-04 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 494850.
ccotter added a comment.

- Add parameter name to diagnostic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,293 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = [&o]() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = [&o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [&o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = [&o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+#if __cplusplus >= 201402L
+  auto never_moves_with_auto_param = [](

[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-04 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 494852.
ccotter added a comment.

- Update per https://github.com/isocpp/CppCoreGuidelines/issues/2026


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,295 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = [&o]() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = [&o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [&o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = [&o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+#if __cplusplus >= 201402L
+  auto

[PATCH] D143304: [Coverage] Map regions from system headers

2023-02-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek 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/D143304/new/

https://reviews.llvm.org/D143304

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


[PATCH] D142862: [Support] change StringMap hash function from djbHash to xxHash

2023-02-04 Thread Erik Desjardins via Phabricator via cfe-commits
erikdesjardins updated this revision to Diff 494861.
erikdesjardins added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142862

Files:
  clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
  clang/unittests/Basic/SarifTest.cpp
  compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  llvm/lib/Support/StringMap.cpp
  llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
  llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
  llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
  llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
  llvm/test/DebugInfo/X86/gnu-public-names.ll
  llvm/test/tools/dsymutil/ARM/extern-alias.test
  llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
  mlir/test/mlir-lsp-server/completion.test

Index: mlir/test/mlir-lsp-server/completion.test
===
--- mlir/test/mlir-lsp-server/completion.test
+++ mlir/test/mlir-lsp-server/completion.test
@@ -84,18 +84,18 @@
 // CHECK-NEXT:"isIncomplete": false,
 // CHECK-NEXT:"items": [
 // CHECK-NEXT:  {
-// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
-// CHECK-NEXT:"insertText": "cast",
-// CHECK-NEXT:"insertTextFormat": 1,
-// CHECK-NEXT:"kind": 6,
-// CHECK-NEXT:"label": "%cast"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  {
 // CHECK-NEXT:"detail": "arg #0: i32",
 // CHECK-NEXT:"insertText": "arg",
 // CHECK-NEXT:"insertTextFormat": 1,
 // CHECK-NEXT:"kind": 6,
 // CHECK-NEXT:"label": "%arg"
+// CHECK-NEXT:  },
+// CHECK-NEXT:  {
+// CHECK-NEXT:"detail": "builtin.unrealized_conversion_cast: !pdl.value",
+// CHECK-NEXT:"insertText": "cast",
+// CHECK-NEXT:"insertTextFormat": 1,
+// CHECK-NEXT:"kind": 6,
+// CHECK-NEXT:"label": "%cast"
 // CHECK-NEXT:  }
 // CHECK: ]
 // CHECK-NEXT:  }
Index: llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
===
--- llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
+++ llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
@@ -6,15 +6,15 @@
 RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX1
 
-MIX1: foo:
-MIX1-NEXT: Hash: 0x0007
-MIX1-NEXT: Counters: 5
-MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
 MIX1: goo:
 MIX1-NEXT: Hash: 0x0005
 MIX1-NEXT: Counters: 3
 MIX1-NOT: Block counts:
 MIX1-SAME: 
+MIX1: foo:
+MIX1-NEXT: Hash: 0x0007
+MIX1-NEXT: Counters: 5
+MIX1-NEXT: Block counts: [12, 13, 0, 0, 0]
 MIX1: moo:
 MIX1-NEXT: Hash: 0x0009
 MIX1-NEXT: Counters: 4
@@ -27,16 +27,16 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX2
 
-MIX2: foo:
-MIX2-NEXT: Hash: 0x0007
-MIX2-NEXT: Counters: 5
-MIX2-NOT: Block counts:
-MIX2-SAME: 
 MIX2: goo:
 MIX2-NEXT: Hash: 0x0005
 MIX2-NEXT: Counters: 3
 MIX2-NOT: Block counts:
 MIX2-SAME: 
+MIX2: foo:
+MIX2-NEXT: Hash: 0x0007
+MIX2-NEXT: Counters: 5
+MIX2-NOT: Block counts:
+MIX2-SAME: 
 MIX2: moo:
 MIX2-NEXT: Hash: 0x0009
 MIX2-NEXT: Counters: 4
@@ -49,15 +49,15 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX3
 
-MIX3: foo:
-MIX3-NEXT: Hash: 0x0007
-MIX3-NEXT: Counters: 5
-MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
 MIX3: goo:
 MIX3-NEXT: Hash: 0x0005
 MIX3-NEXT: Counters: 3
 MIX3-NOT: Block counts:
 MIX3-SAME: 
+MIX3: foo:
+MIX3-NEXT: Hash: 0x0007
+MIX3-NEXT: Counters: 5
+MIX3-NEXT: Block counts: [1384, 1500, 0, 0, 0]
 MIX3: moo:
 MIX3-NEXT: Hash: 0x0009
 MIX3-NEXT: Counters: 4
@@ -71,15 +71,15 @@
 RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t
 RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4
 
-MIX4: foo:
-MIX4-NEXT: Hash: 0x0007
-MIX4-NEXT: Counters: 1
-MIX4-NEXT: Block counts: [0]
 MIX4: goo:
 MIX4-NEXT: Hash: 0x0005
 MIX4-NEXT: Counters: 3
 MIX4-NOT: Block counts:
 MIX4-SAME: 
+MIX4: foo:
+MIX4-NEXT: Hash: 0x0007
+MIX4-NEXT: Counters: 1
+MIX4-NEXT: Block counts: [0]
 MIX4: moo:
 MIX4-NEXT: Hash: 0x0009
 MIX4-NEXT: Counters: 1
Index: llvm/test/tools/dsymutil/ARM/extern-alias.test
===
--- llvm/test/tools/dsymutil/ARM/extern-alias.test
+++ llvm/test/tools/dsymutil/ARM/extern-alias.test

[PATCH] D143091: [clang-format] PackConstructorInitializers support PCIS_NextLineOnly

2023-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/Format.cpp:446
 IO.enumCase(Value, "NextLine", FormatStyle::PCIS_NextLine);
+IO.enumCase(Value, "OnlyNextLine", FormatStyle::PCIS_NextLineOnly);
   }





Comment at: clang/unittests/Format/ConfigParseTest.cpp:403
   PackConstructorInitializers, FormatStyle::PCIS_NextLine);
+  CHECK_PARSE("PackConstructorInitializers: OnlyNextLine",
+  PackConstructorInitializers, FormatStyle::PCIS_NextLineOnly);




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

https://reviews.llvm.org/D143091

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


[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-02-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142630

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


[PATCH] D141215: [clang-repl][WIP] Implement pretty printing

2023-02-04 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 494865.
junaire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141215

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Value.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/Value.cpp
  clang/lib/Interpreter/ValueSynthesize.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Interpreter/pretty-print.cpp
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -18,6 +19,8 @@
 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h" // llvm_shutdown
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
@@ -66,6 +69,29 @@
   return (Errs || HasError) ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
+static void DeclareMagicFunctions(clang::Interpreter &Interp) {
+  llvm::ArrayRef MagicFunctions = {
+  "void __InterpreterCreateValue(void*, void*, bool);",
+  "void __InterpreterCreateValue(void*, void*, char);",
+  "void __InterpreterCreateValue(void*, void*, signed char);",
+  "void __InterpreterCreateValue(void*, void*, short);",
+  "void __InterpreterCreateValue(void*, void*, int);",
+  "void __InterpreterCreateValue(void*, void*, long);",
+  "void __InterpreterCreateValue(void*, void*, long long);",
+  "void __InterpreterCreateValue(void*, void*, unsigned char);",
+  "void __InterpreterCreateValue(void*, void*, unsigned short);",
+  "void __InterpreterCreateValue(void*, void*, unsigned int);",
+  "void __InterpreterCreateValue(void*, void*, unsigned long);",
+  "void __InterpreterCreateValue(void*, void*, unsigned long long);",
+  "void __InterpreterCreateValue(void*, void*, float);",
+  "void __InterpreterCreateValue(void*, void*, double);",
+  "void __InterpreterCreateValue(void*, void*, void*);"};
+
+  for (llvm::StringRef Function : MagicFunctions) {
+llvm::cantFail(Interp.ParseAndExecute(Function));
+  }
+}
+
 llvm::ExitOnError ExitOnErr;
 int main(int argc, const char **argv) {
   ExitOnErr.setBanner("clang-repl: ");
@@ -110,6 +136,7 @@
 
   bool HasError = false;
 
+  DeclareMagicFunctions(*Interp);
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 // FIXME: Add LE.setListCompleter
Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -12,6 +12,7 @@
   )
 
 clang_target_link_libraries(clang-repl PRIVATE
+  clangAST
   clangBasic
   clangFrontend
   clangInterpreter
Index: clang/test/Interpreter/pretty-print.cpp
===
--- /dev/null
+++ clang/test/Interpreter/pretty-print.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
+// RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck --check-prefix=CHECK-DRIVER %s
+// UNSUPPORTED: system-aix
+// CHECK-DRIVER: i = 10
+// RUN: cat %s | clang-repl | FileCheck %s
+int x = 42;
+x
+// CHECK: (int) 42
+x - 2
+// CHECK-NEXT: (int) 40
+%quit
+
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -154,10 +154,20 @@
   return true;
 }
 
-bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed) {
+bool Parser::ExpectAndConsumeSemi(unsigned DiagID, StringRef TokenUsed,
+  bool IsTopExpr) {
   if (TryConsumeToken(tok::semi))
 return false;
 
+  // If this is in the incremental C++ mode, then it means we need to pretty
+  // print this expression. Thus, let's pretend we have this semi and continue
+  // parsing.
+  if (PP.isIncrementalProcessingEnabled() && IsTopExpr &&
+  DiagID == diag::err_expected_semi_after_expr) {
+setPrettyPrintMode();
+return false;
+  }
+
   if (Tok.is(tok::code_completion)) {
 handleUnexpectedCodeCompletionToken();
 return false;
Index: clang/

[PATCH] D141950: Use find_last_of when seraching for code in getRawCommentForDeclNoCacheImpl

2023-02-04 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv updated this revision to Diff 494870.
kuganv added a comment.

Rebasing branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141950

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -348,7 +348,7 @@
 
   // There should be no other declarations or preprocessor directives between
   // comment and declaration.
-  if (Text.find_first_of(";{}#@") != StringRef::npos)
+  if (Text.find_last_of(";{}#@") != StringRef::npos)
 return nullptr;
 
   return CommentBeforeDecl;


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -348,7 +348,7 @@
 
   // There should be no other declarations or preprocessor directives between
   // comment and declaration.
-  if (Text.find_first_of(";{}#@") != StringRef::npos)
+  if (Text.find_last_of(";{}#@") != StringRef::npos)
 return nullptr;
 
   return CommentBeforeDecl;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142878: Add testing for Fuchsia multilib

2023-02-04 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:316-317
+void Fuchsia::configureMultilibFlags(Multilib::flags_list &Flags,
+ bool Exceptions, bool Asan, bool Hwasan,
+ bool Itanium) {
+  addMultilibFlag(Exceptions, "fexceptions", Flags);

Could we pass `const ArgList &Args` instead? I'm concerned that this approach 
won't scale in the future as we keep on adding more flags.



Comment at: clang/unittests/Driver/FuchsiaTest.cpp:18-23
+/*
+This test was added prior to changing the behaviour of Multilib.
+The way that Fuchsia used Multilib made it very likely that the change
+would cause it to break so by adding this exhaustive test we avoid that
+possibility.
+*/

Nit: we prefer `//` for comments.



Comment at: clang/unittests/Driver/FuchsiaTest.cpp:30-43
+  for (bool Itanium : {false, true}) {
+for (bool Hwasan : {false, true}) {
+  for (bool Asan : {false, true}) {
+for (bool Exceptions : {false, true}) {
+  Multilib::flags_list Flags;
+  toolchains::Fuchsia::configureMultilibFlags(Flags, Exceptions, Asan,
+  Hwasan, Itanium);

While exhaustive, I'm concerned about the scalability of this approach. We plan 
on adding more multilibs in the future so the number of combinations is going 
to grow exponentially. A more scalable approach would be to check only the 
minimal set of combination necessary to achieve full coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142878

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