[PATCH] D95571: [clangd] Remove some obsolete options that are now always on

2021-01-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 319776.
sammccall added a comment.

group retired flags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95571

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -154,8 +154,7 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = std::make_unique(/*UseDex=*/true,
- /*CollectMainFileRefs=*/true);
+  auto Idx = std::make_unique();
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessorPtr(),
   AST.getCanonicalIncludes());
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -190,7 +190,6 @@
   MemoryShardStorage MSS(Storage, CacheHits);
   OverlayCDB CDB(/*Base=*/nullptr);
   BackgroundIndex::Options Opts;
-  Opts.CollectMainFileRefs = true;
   BackgroundIndex Idx(
   FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
@@ -241,52 +240,25 @@
   FS.Files[testPath("root/A.cc")] =
   "#include \"A.h\"\nstatic void main_sym() { (void)header_sym; }";
 
-  // Check the behaviour with CollectMainFileRefs = false (the default
-  // at the SymbolCollector level).
-  {
-llvm::StringMap Storage;
-size_t CacheHits = 0;
-MemoryShardStorage MSS(Storage, CacheHits);
-OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return &MSS; },
-/*Opts=*/{});
-
-tooling::CompileCommand Cmd;
-Cmd.Filename = testPath("root/A.cc");
-Cmd.Directory = testPath("root");
-Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
-CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
-
-ASSERT_TRUE(Idx.blockUntilIdleForTest());
-EXPECT_THAT(
-runFuzzyFind(Idx, ""),
-UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
- AllOf(Named("main_sym"), NumReferences(0U;
-  }
-
-  // Check the behaviour with CollectMainFileRefs = true.
-  {
-llvm::StringMap Storage;
-size_t CacheHits = 0;
-MemoryShardStorage MSS(Storage, CacheHits);
-OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex::Options Opts;
-Opts.CollectMainFileRefs = true;
-BackgroundIndex Idx(
-FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+  OverlayCDB CDB(/*Base=*/nullptr);
+  BackgroundIndex::Options Opts;
+  BackgroundIndex Idx(
+  FS, CDB, [&](llvm::StringRef) { return &MSS; }, Opts);
 
-tooling::CompileCommand Cmd;
-Cmd.Filename = testPath("root/A.cc");
-Cmd.Directory = testPath("root");
-Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
-CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
 
-ASSERT_TRUE(Idx.blockUntilIdleForTest());
-EXPECT_THAT(
-runFuzzyFind(Idx, ""),
-UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
- AllOf(Named("main_sym"), NumReferences(1U;
-  }
+  ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  EXPECT_THAT(
+  runFuzzyFind(Idx, ""),
+  UnorderedElementsAre(AllOf(Named("header_sym"), NumReferences(1U)),
+   AllOf(Named("main_sym"), NumReferences(1U;
 }
 
 TEST_F(BackgroundIndexTest, ShardStorageTest) {
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -281,6 +281,11 @@
 };
 
 RetiredFlag EnableIndex("index");
+RetiredFlag SuggestMissingIncludes("suggest-missing-includes");
+RetiredFlag RecoveryAST("recovery-ast");
+RetiredFlag RecoveryASTType("recovery-ast-type");
+RetiredFlag AsyncPreamble("async-preamb

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: clang/test/Driver/clang-offload-bundler.c:74
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -inputs=%t.i,%t.tgt1,%t.tgt2.notexist -outputs=%t.bundle.i 2>&1 | \
+// RUN:  FileCheck %s -DFILE=%t.tgt2.notexist -DMSG=%errc_ENOENT 
--check-prefix CK-ERR5
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | \

Add one more space - it helps the indentation stand out more and therefore make 
it clearer this line is a continuation.



Comment at: clang/test/Driver/clang-offload-bundler.c:76
+// RUN: not clang-offload-bundler -type=i 
-targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu
 -outputs=%t.i,%t.tgt1,%t.tgt2 -inputs=%t.bundle.i.notexist -unbundle 2>&1 | \
+// RUN:  FileCheck %s -DFILE=%t.bundle.i.notexist -DMSG=%errc_ENOENT 
--check-prefix CK-ERR5
+// CK-ERR5: error: '[[FILE]]': [[MSG]]





Comment at: llvm/docs/TestingGuide.rst:545-547
+   Example (%errc_ENOENT): ``No such file or directory``
+
+   Example (%errc_ENOENT): ``no such file or directory``

jhenderson wrote:
> This is a slightly different format to the other examples above. I think it 
> should be like the inline edit. this also helps distinguish the difference 
> between the two.
> 
> Note: I can't remember which way around the two versions are, so you might 
> need to swap them!
We probably need to list what error codes are currently supported somewhere.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-351
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple

abhina.sreeskantharajan wrote:
> jhenderson wrote:
> > I'm concerned that someone might start using these substitutions in a 
> > project for the first time, and get confused why they don't work on 
> > non-windows platforms. Maybe the solution is simply to require 
> > LLVM_HOST_TRIPLE to be set in all projects, i.e. go back to what you were 
> > doing before, and letting python fail if it isn't set.
> > 
> > Happy to hear other ideas too.
> I think using sys.platform or platform.system() could be a better 
> alternative. What do you think?
Makes sense to me. Slight issue: cygwin on Windows uses `cygwin`. What error 
message does it produce though?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95576: [clangd] Remove support for pre-standard semanticHighlighting notification

2021-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!

there are also some comments on `ASTWorker::PublishMu` talking about semantic 
highlights publishing.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.h:17
+// 
https://github.com/microsoft/vscode-languageserver-node/blob/release/protocol/3.16.0-next.1/protocol/src/protocol.semanticTokens.proposed.ts
+// We supported a pre-standard `textDocument/semanticHighlighting` 
notification,
+// but this has been removed.

not sure if this sentence will help anyone. if you choose to drop this one, i 
suppose the former can also be rephrased as `Protocol details can be found at 
...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95576

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


[PATCH] D95576: [clangd] Remove support for pre-standard semanticHighlighting notification

2021-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

oh also in addition to `This should not land until the new protocol has feature 
parity, see D77702.`, it might be better to hold on to it a little bit longer, 
since it is touching lots of pieces and might make cherry-picking some fixes 
that touch the same files harder to the release branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95576

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


[PATCH] D95576: [clangd] Remove support for pre-standard semanticHighlighting notification

2021-01-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added a comment.

In D95576#2527407 , @kadircet wrote:

> oh also in addition to `This should not land until the new protocol has 
> feature parity, see D77702.`, it might be better to hold on to it a little 
> bit longer, since it is touching lots of pieces and might make cherry-picking 
> some fixes that touch the same files harder to the release branch.

Yeah I don't want to land this for a couple of weeks in any case.
On the other hand, the release branch has sometimes been long-lived (months) 
and I don't think we should try to avoid invasive changes until the release has 
landed necessarily, it could eat a good fraction of the release cycle.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95576

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


[PATCH] D95576: [clangd] Remove support for pre-standard semanticHighlighting notification

2021-01-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 319779.
sammccall added a comment.

Remove some comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95576

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/refactor/tweaks/AnnotateHighlightings.cpp
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/AnnotateHighlightingsTests.cpp
@@ -18,15 +18,13 @@
 TEST_F(AnnotateHighlightingsTest, Test) {
   EXPECT_AVAILABLE("^vo^id^ ^f(^) {^}^"); // available everywhere.
   EXPECT_AVAILABLE("[[int a; int b;]]");
-  EXPECT_EQ("void /* entity.name.function.cpp */f() {}", apply("void ^f() {}"));
+  EXPECT_EQ("void /* Function */f() {}", apply("void ^f() {}"));
 
-  EXPECT_EQ(apply("[[void f1(); void f2();]]"),
-"void /* entity.name.function.cpp */f1(); "
-"void /* entity.name.function.cpp */f2();");
+  EXPECT_EQ(apply("[[void f1(); void f2();]]"), "void /* Function */f1(); "
+"void /* Function */f2();");
 
-  EXPECT_EQ(apply("void f1(); void f2() {^}"),
-"void f1(); "
-"void /* entity.name.function.cpp */f2() {}");
+  EXPECT_EQ(apply("void f1(); void f2() {^}"), "void f1(); "
+   "void /* Function */f2() {}");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -28,9 +28,6 @@
 using testing::IsEmpty;
 using testing::SizeIs;
 
-MATCHER_P(LineNumber, L, "") { return arg.Line == L; }
-MATCHER(EmptyHighlightings, "") { return arg.Tokens.empty(); }
-
 std::vector
 makeHighlightingTokens(llvm::ArrayRef Ranges, HighlightingKind Kind) {
   std::vector Tokens(Ranges.size());
@@ -42,37 +39,6 @@
   return Tokens;
 }
 
-std::vector getExpectedTokens(Annotations &Test) {
-  static const std::map KindToString{
-  {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::LocalVariable, "LocalVariable"},
-  {HighlightingKind::Parameter, "Parameter"},
-  {HighlightingKind::Function, "Function"},
-  {HighlightingKind::Class, "Class"},
-  {HighlightingKind::Enum, "Enum"},
-  {HighlightingKind::Namespace, "Namespace"},
-  {HighlightingKind::EnumConstant, "EnumConstant"},
-  {HighlightingKind::Field, "Field"},
-  {HighlightingKind::StaticField, "StaticField"},
-  {HighlightingKind::Method, "Method"},
-  {HighlightingKind::StaticMethod, "StaticMethod"},
-  {HighlightingKind::Typedef, "Typedef"},
-  {HighlightingKind::DependentType, "DependentType"},
-  {HighlightingKind::DependentName, "DependentName"},
-  {HighlightingKind::TemplateParameter, "TemplateParameter"},
-  {HighlightingKind::Concept, "Concept"},
-  {HighlightingKind::Primitive, "Primitive"},
-  {HighlightingKind::Macro, "Macro"}};
-  std::vector ExpectedTokens;
-  for (const auto &KindString : KindToString) {
-std::vector Toks = makeHighlightingTokens(
-Test.ranges(KindString.second), KindString.first);
-ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
-  }
-  llvm::sort(ExpectedTokens);
-  return ExpectedTokens;
-}
-
 /// Annotates the input code with provided semantic highlightings. Results look
 /// something like:
 ///   class $Class[[X]] {
@@ -124,39 +90,6 @@
   EXPECT_EQ(Code, annotate(Test.code(), getSemanticHighlightings(AST)));
 }
 
-// Any annotations in OldCode and NewCode are converted into their corresponding
-// HighlightingToken. The tokens are diffed against each other. Any lines where
-// the tokens should diff must be marked with a ^ somewhere on that line in
-// NewCode. If there are diffs that aren't marked with ^ the test fails. The
-// test also fails if there are lines marked with ^ that don't differ.
-void checkDiffedHighlights(llvm::StringRef OldCode, llvm::StringRef NewCode) {
-  Annotations Old

[PATCH] D95448: [flang][driver] Add support for `-J/-module-dir`

2021-01-28 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

@arnamoy10 , could you also add tests that show that `-J/-module-dir` is taken 
into account when deciding where to put module files? Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95448

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


[PATCH] D95166: Disable rosegment for old Android versions.

2021-01-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Out Android build bot is broken after this patch 
http://lab.llvm.org:8011/#/builders/77/builds/3234

  Run Build Command(s):/usr/bin/ninja cmTC_578f8 && [1/2] Building C object 
CMakeFiles/cmTC_578f8.dir/testCCompiler.c.o
  [2/2] Linking C executable cmTC_578f8
  FAILED: cmTC_578f8
  : && 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/bin/clang
 --target=i686-linux-android24 
--sysroot=/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot
 -gcc-toolchain 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64
  
-B/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64
  CMakeFiles/cmTC_578f8.dir/testCCompiler.c.o -o cmTC_578f8   && :
  
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld:
 --no-rosegment: unknown option
  
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/i686-linux-android/4.9.x/../../../../i686-linux-android/bin/ld:
 use the --help option for usage information
  clang-13: error: linker command failed with exit code 1 (use -v to see 
invocation)
  ninja: build stopped: subcommand failed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95166

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


[PATCH] D95536: [clang][sema] Note decl location on missing member

2021-01-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 319780.
tbaeder added a comment.

Answered one of my questions by adding a new function directly to `Sema`.


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

https://reviews.llvm.org/D95536

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
  clang/test/CXX/class.access/class.friend/p1.cpp
  clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr21xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/special/class.copy/p28-cxx11.cpp
  clang/test/CXX/special/class.dtor/p10-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
  clang/test/CXX/temp/temp.res/temp.local/p3.cpp
  clang/test/CXX/temp/temp.res/temp.local/p9.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
  clang/test/Misc/diag-template.cpp
  clang/test/Modules/Inputs/redecl_namespaces_left.h
  clang/test/Modules/cxx-templates.cpp
  clang/test/Modules/module-private.cpp
  clang/test/Modules/redecl-namespaces.mm
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/PCH/decl-attrs.cpp
  clang/test/Parser/recovery.c
  clang/test/Parser/recovery.cpp
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/Sema/anonymous-struct-union.c
  clang/test/Sema/typo-correction-ambiguity.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction-recursive.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/anonymous-union.cpp
  clang/test/SemaCXX/attr-cleanup.cpp
  clang/test/SemaCXX/co_await-range-for.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
  clang/test/SemaCXX/friend.cpp
  clang/test/SemaCXX/invalid-member-expr.cpp
  clang/test/SemaCXX/member-operator-expr.cpp
  clang/test/SemaCXX/missing-members.cpp
  clang/test/SemaCXX/nested-name-spec.cpp
  clang/test/SemaCXX/pseudo-destructors.cpp
  clang/test/SemaCXX/qualified-id-lookup.cpp
  clang/test/SemaCXX/typo-correction-delayed.cpp
  clang/test/SemaCXX/typo-correction.cpp
  clang/test/SemaCXX/unknown-type-name.cpp
  clang/test/SemaObjCXX/deduction.mm
  clang/test/SemaObjCXX/interface-return-type.mm
  clang/test/SemaTemplate/attributes.cpp
  clang/test/SemaTemplate/cxx1z-using-declaration.cpp
  clang/test/SemaTemplate/dependent-base-classes.cpp
  clang/test/SemaTemplate/instantiate-method.cpp
  clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
  clang/test/SemaTemplate/member-access-ambig.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp

Index: clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
===
--- clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -200,7 +200,7 @@
 
 namespace PR16014 {
 
-struct A {
+struct A { // expected-note {{declared here}}
   int a;
   static int sa;
 };
@@ -226,7 +226,8 @@
 };
 
 template struct B;
-template struct C;  // expected-note-re 1+ {{in instantiation of member function 'PR16014::C::{{.*}}' requested here}}
+template struct C;  // expected-note-re 1+ {{in instantiation of member function 'PR16014::C::{{.*}}' requested here}} \
+   // expected-note 2 {{declared here}}
 
 template  struct D : T {
   struct Inner {
Index: clang/test/SemaTemplate/member-access-expr.cpp
===
--- clang/test/SemaTemplate/member-access-expr.cpp
+++ clang/test/SemaTemplate/member-access-expr.cpp
@@ -43,7 +43,7 @@
 
 }
 
-struct OtherBase { };
+struct OtherBase { }; // expected-note 2 {{declared here}}
 
 struct X1 : Base, OtherBase { 
   typedef OtherBase CrazyBase;
@@ -59,7 +59,7 @@
 }
 
 
-struct X2 {
+struct X2 { // expected-note {{declared here}}
   operator int() const;
 };
 
Index: clang/test/SemaTemplate/member-access-ambig.cpp
===
--- clang/test/SemaTemplate/member-access-ambig.cpp
+++ clang/test/SemaTemplate/member-access-ambig.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-comparison %s
 
 // PR8439
-class A
+class A // expected-note {{declared here}}
 {
 };
 
Index: clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
=

[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer updated this revision to Diff 319784.
kentsommer added a comment.

Turn SortIncludes into an enum


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortImportsTestJava.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -269,7 +269,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  FmtStyle.SortIncludes = false;
+  FmtStyle.SortIncludes = FormatStyle::SI_Never;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -598,6 +598,49 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
+  EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseSensitive);
+
+  FmtStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+
+  EXPECT_EQ("#include \"A/B.h\"\n"
+"#include \"A/b.h\"\n"
+"#include \"a/b.h\"\n"
+"#include \"B/A.h\"\n"
+"#include \"B/a.h\"\n",
+sort("#include \"B/a.h\"\n"
+ "#include \"B/A.h\"\n"
+ "#include \"A/B.h\"\n"
+ "#include \"a/b.h\"\n"
+ "#include \"A/b.h\"\n",
+ "a.h"));
+
+  Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
+  Style.IncludeCategories = {
+  {"^\"", 1, 0, false}, {"^<.*\\.h>$", 2, 0, false}, {"^<", 3, 0, false}};
+
+  StringRef UnsortedCode = "#include \"qt.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"vlib.h\"\n"
+   "#include \"Vlib.h\"\n"
+   "#include \"AST.h\"\n";
+
+  EXPECT_EQ("#include \"AST.h\"\n"
+"#include \"qt.h\"\n"
+"#include \"Vlib.h\"\n"
+"#include \"vlib.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort(UnsortedCode));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -32,7 +32,7 @@
   SortImportsTestJava() {
 FmtStyle = getGoogleStyle(FormatStyle::LK_Java);
 FmtStyle.JavaImportGroups = {"com.test", "org", "com"};
-FmtStyle.SortIncludes = true;
+FmtStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
   }
 };
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14406,7 +14406,6 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
-  CHECK_PARSE_BOOL(SortIncludes);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -14828,6 +14827,16 @@
   CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
   IncludeStyle.IncludeIsMainSourceRegex, "abc$");
 
+  Style.SortIncludes = FormatStyle::SI_Never;
+  CHECK_PARSE("SortIncludes: true", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
+  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
+  FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);
+
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
   {
@@ -16819,7 +16828,7 @@
 "#include \"b.h\"\n")});
 
   format::FormatStyle Style = format::getLLVMStyle();
-  Style.SortIncludes = true;
+  Style.SortIncludes = FormatStyle::SI_CaseInsensitive;
   auto FormattedReplaces = formatReplacements(Code, Replaces, Style);
   EXPECT_TRUE(static_cast(FormattedReplaces))
   << llvm::toString(FormattedReplaces.takeError()) << "\n";
Index: clang/tools/clang-format/ClangFormat.cpp
==

[clang] 01b9e61 - [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-28 Thread Tomas Matheson via cfe-commits

Author: Tomas Matheson
Date: 2021-01-28T09:19:19Z
New Revision: 01b9e613c28b833327ab4de93d0638a5c8d3514f

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

LOG: [Clang][Codegen] Truncate initializers of union bitfield members

If an initial value is given for a bitfield that does not fit in the
bitfield, the value should be truncated. Constant folding for
expressions did not account for this truncation in the case of union
member functions, despite a warning being emitted. In some contexts,
evaluation of expressions was not enabled unless C++11, ROPI or RWPI
was enabled.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenCXX/bitfield-layout.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c1973720e49a..0f0c33b0ac85 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,14 @@ bool RecordExprEvaluator::VisitInitListExpr(const 
InitListExpr *E) {
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+if (EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr)) {
+  if (Field->isBitField())
+return truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+ Field);
+  return true;
+}
+
+return false;
   }
 
   if (!Result.hasValue())

diff  --git a/clang/test/CodeGenCXX/bitfield-layout.cpp 
b/clang/test/CodeGenCXX/bitfield-layout.cpp
index 49b196253f3c..79dbf9c691c4 100644
--- a/clang/test/CodeGenCXX/bitfield-layout.cpp
+++ b/clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -emit-llvm -o - -O3 
-std=c++11 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
@@ -84,3 +85,68 @@ int test_init() {
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } const U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } const U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}



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


[PATCH] D93101: [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-28 Thread Tomas Matheson 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 rG01b9e613c28b: [Clang][Codegen] Truncate initializers of 
union bitfield members (authored by tmatheson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93101

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGenCXX/bitfield-layout.cpp

Index: clang/test/CodeGenCXX/bitfield-layout.cpp
===
--- clang/test/CodeGenCXX/bitfield-layout.cpp
+++ clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -emit-llvm -o - -O3 -std=c++11 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
@@ -84,3 +85,68 @@
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } const U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } const U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,14 @@
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+if (EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr)) {
+  if (Field->isBitField())
+return truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+ Field);
+  return true;
+}
+
+return false;
   }
 
   if (!Result.hasValue())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer marked an inline comment as done.
kentsommer added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

HazardyKnusperkeks wrote:
> MyDeveloperDay wrote:
> > curdeius wrote:
> > > kentsommer wrote:
> > > > MyDeveloperDay wrote:
> > > > > Are you sure `IncludeSortAlphabetically` expresses what you mean? 
> > > > > Once these things get released they cannot be changed easily.
> > > > > 
> > > > > If you were not sure of a new option, in my view we should slow down 
> > > > > and make sure we have the correct design, for example you could have 
> > > > > used a enum and it might have given you more possibility for greater 
> > > > > flexibility
> > > > > 
> > > > > ```
> > > > > enum IncludeSort
> > > > > {
> > > > >CaseInsensitive
> > > > >CaseSensitive
> > > > > }
> > > > > ```
> > > > > 
> > > > > Please give people time to re-review your changes before we commit, 
> > > > > especially if they've taken the time to look at your review in the 
> > > > > first place. Just saying.
> > > > > 
> > > > Hi, @MyDeveloperDay I definitely agree. It was not my intention to rush 
> > > > through the review. I was simply trying to follow the process outlined 
> > > > in https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which 
> > > > mentions giving sufficient information to allow for a commit on your 
> > > > behalf when you don't have access after an LGTM (which is all that I 
> > > > did). As you can see from the lack of additional comments from my end, 
> > > > I was happy to let this sit and be reviewed. 
> > > > 
> > > > Per the discussion about the option itself, I do believe 
> > > > `IncludeSortAlphabetically` currently expresses what I mean as the 
> > > > behavior with this off is indeed not an alphabetical sort as case takes 
> > > > precedence over the alphabetical ordering. However, looking at the enum 
> > > > and realizing that others probably will have additional styles they 
> > > > prefer (maybe they want alphabetical but lower case first, etc.) I do 
> > > > believe it might have been a better way to go as it leaves more 
> > > > flexibility and room for additional ordering styles. Given that this 
> > > > just landed, I would be happy to open a patch to turn this into an 
> > > > `enum` as I do see benefits to doing so. What do you think?
> > > Hmmm, and how about using the existing option `SortIncludes` and change 
> > > its type from `bool` to some `enum`?
> > > We could then, for backward-compatibility, map `false` to (tentative) 
> > > `Never` and `true` to `ASCII`/`CaseInsensitive`, and add `CaseSensitive`.
> > > 
> > > This will have the advantage of not adding additional style options.
> > > ... and it will prove once again that using `bool`s for style options is 
> > > not a good idea.
> > I think that is an excellent idea @curdeius 
> I also fully support that! (Although I would not say a bool is per se bad.)
@curdeius @MyDeveloperDay @HazardyKnusperkeks this is now done.

However... The command-line option (`--sort-includes`) is not in a place that I 
like at the moment but I am having trouble thinking of any really good options. 

The issue as it stands is that there are a lot of usages of the flag that 
assume it is a `bool` and therefore sometimes do not pass any value. These of 
course could be updated along with the flag to accept a `std::string` value, 
however, this breaks backward capability for anyone relying on that flag not 
requiring a value. As I have it now, backward compatibility is maintained but 
the command line flag is rather severely limited compared to the configuration 
option. Thoughts on which path to take? A third option I have not considered? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer updated this revision to Diff 319786.
kentsommer added a comment.

Remove improper enum mapping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortImportsTestJava.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -269,7 +269,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  FmtStyle.SortIncludes = false;
+  FmtStyle.SortIncludes = FormatStyle::SI_Never;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -598,6 +598,49 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
+  EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseSensitive);
+
+  FmtStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+
+  EXPECT_EQ("#include \"A/B.h\"\n"
+"#include \"A/b.h\"\n"
+"#include \"a/b.h\"\n"
+"#include \"B/A.h\"\n"
+"#include \"B/a.h\"\n",
+sort("#include \"B/a.h\"\n"
+ "#include \"B/A.h\"\n"
+ "#include \"A/B.h\"\n"
+ "#include \"a/b.h\"\n"
+ "#include \"A/b.h\"\n",
+ "a.h"));
+
+  Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
+  Style.IncludeCategories = {
+  {"^\"", 1, 0, false}, {"^<.*\\.h>$", 2, 0, false}, {"^<", 3, 0, false}};
+
+  StringRef UnsortedCode = "#include \"qt.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"vlib.h\"\n"
+   "#include \"Vlib.h\"\n"
+   "#include \"AST.h\"\n";
+
+  EXPECT_EQ("#include \"AST.h\"\n"
+"#include \"qt.h\"\n"
+"#include \"Vlib.h\"\n"
+"#include \"vlib.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort(UnsortedCode));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -32,7 +32,7 @@
   SortImportsTestJava() {
 FmtStyle = getGoogleStyle(FormatStyle::LK_Java);
 FmtStyle.JavaImportGroups = {"com.test", "org", "com"};
-FmtStyle.SortIncludes = true;
+FmtStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
   }
 };
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14406,7 +14406,6 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
-  CHECK_PARSE_BOOL(SortIncludes);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -14828,6 +14827,16 @@
   CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
   IncludeStyle.IncludeIsMainSourceRegex, "abc$");
 
+  Style.SortIncludes = FormatStyle::SI_Never;
+  CHECK_PARSE("SortIncludes: true", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
+  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
+  FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);
+
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
   {
@@ -16819,7 +16828,7 @@
 "#include \"b.h\"\n")});
 
   format::FormatStyle Style = format::getLLVMStyle();
-  Style.SortIncludes = true;
+  Style.SortIncludes = FormatStyle::SI_CaseInsensitive;
   auto FormattedReplaces = formatReplacements(Code, Replaces, Style);
   EXPECT_TRUE(static_cast(FormattedReplaces))
   << llvm::toString(FormattedReplaces.takeError()) << "\n";
Index: clang/tools/clang-format/ClangFormat.cpp

[clang] 01b9e61 - [Clang][Codegen] Truncate initializers of union bitfield members

2021-01-28 Thread Tomas Matheson via cfe-commits

Author: Tomas Matheson
Date: 2021-01-28T09:19:19Z
New Revision: 01b9e613c28b833327ab4de93d0638a5c8d3514f

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

LOG: [Clang][Codegen] Truncate initializers of union bitfield members

If an initial value is given for a bitfield that does not fit in the
bitfield, the value should be truncated. Constant folding for
expressions did not account for this truncation in the case of union
member functions, despite a warning being emitted. In some contexts,
evaluation of expressions was not enabled unless C++11, ROPI or RWPI
was enabled.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGenCXX/bitfield-layout.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c1973720e49a..0f0c33b0ac85 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9798,7 +9798,14 @@ bool RecordExprEvaluator::VisitInitListExpr(const 
InitListExpr *E) {
 ThisOverrideRAII ThisOverride(*Info.CurrentCall, &This,
   isa(InitExpr));
 
-return EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr);
+if (EvaluateInPlace(Result.getUnionValue(), Info, Subobject, InitExpr)) {
+  if (Field->isBitField())
+return truncateBitfieldValue(Info, InitExpr, Result.getUnionValue(),
+ Field);
+  return true;
+}
+
+return false;
   }
 
   if (!Result.hasValue())

diff  --git a/clang/test/CodeGenCXX/bitfield-layout.cpp 
b/clang/test/CodeGenCXX/bitfield-layout.cpp
index 49b196253f3c..79dbf9c691c4 100644
--- a/clang/test/CodeGenCXX/bitfield-layout.cpp
+++ b/clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck %s
 // RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -emit-llvm -o - -O3 
-std=c++11 | FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {
@@ -84,3 +85,68 @@ int test_init() {
   // CHECK: ret i32 0
   return 0;
 }
+
+extern "C" {
+int test_trunc_int() {
+  union {
+int i : 4; // truncated to 0b == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_int()
+// CHECK: ret i32 -1
+
+int test_trunc_three_bits() {
+  union {
+int i : 3; // truncated to 0b111 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_three_bits()
+// CHECK: ret i32 -1
+
+int test_trunc_1() {
+  union {
+int i : 1; // truncated to 0b1 == -1
+  } const U = {15};  // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_1()
+// CHECK: ret i32 -1
+
+int test_trunc_zero() {
+  union {
+int i : 4; // truncated to 0b == 0
+  } const U = {80};  // 0b0101
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_trunc_zero()
+// CHECK: ret i32 0
+
+int test_constexpr() {
+  union {
+int i : 3;   // truncated to 0b111 == -1
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_constexpr()
+// CHECK: ret i32 -1
+
+int test_notrunc() {
+  union {
+int i : 12;  // not truncated
+  } const U = {1 + 2 + 4 + 8}; // 0b
+  return U.i;
+}
+// CHECK: define dso_local i32 @test_notrunc()
+// CHECK: ret i32 15
+
+long long test_trunc_long_long() {
+  union {
+long long i : 14; // truncated to 0b0001001101 ==
+  } const U = {0b010001001101};
+  return U.i;
+}
+// CHECK: define dso_local i64 @test_trunc_long_long()
+// CHECK: ret i64 3917
+}



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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:399
+IO.enumCase(Value, "false", FormatStyle::SI_Never);
+IO.enumCase(Value, "", FormatStyle::SI_CaseInsensitive);
+IO.enumCase(Value, "true", FormatStyle::SI_CaseInsensitive);

Is this needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:399
+IO.enumCase(Value, "false", FormatStyle::SI_Never);
+IO.enumCase(Value, "", FormatStyle::SI_CaseInsensitive);
+IO.enumCase(Value, "true", FormatStyle::SI_CaseInsensitive);

curdeius wrote:
> Is this needed?
Ok. You just fixed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Concerning the `--sort-includes` command-line flag. I'd rather keep it as is 
and, if need be, work on accepting an **optional** string argument.
Please update release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2286
+**IncludeSortAlphabetically** (``bool``)
+  Specify if sorting should be done in an alphabetical and
+  case sensitive fashion.

kentsommer wrote:
> HazardyKnusperkeks wrote:
> > MyDeveloperDay wrote:
> > > curdeius wrote:
> > > > kentsommer wrote:
> > > > > MyDeveloperDay wrote:
> > > > > > Are you sure `IncludeSortAlphabetically` expresses what you mean? 
> > > > > > Once these things get released they cannot be changed easily.
> > > > > > 
> > > > > > If you were not sure of a new option, in my view we should slow 
> > > > > > down and make sure we have the correct design, for example you 
> > > > > > could have used a enum and it might have given you more possibility 
> > > > > > for greater flexibility
> > > > > > 
> > > > > > ```
> > > > > > enum IncludeSort
> > > > > > {
> > > > > >CaseInsensitive
> > > > > >CaseSensitive
> > > > > > }
> > > > > > ```
> > > > > > 
> > > > > > Please give people time to re-review your changes before we commit, 
> > > > > > especially if they've taken the time to look at your review in the 
> > > > > > first place. Just saying.
> > > > > > 
> > > > > Hi, @MyDeveloperDay I definitely agree. It was not my intention to 
> > > > > rush through the review. I was simply trying to follow the process 
> > > > > outlined in 
> > > > > https://llvm.org/docs/Contributing.html#how-to-submit-a-patch which 
> > > > > mentions giving sufficient information to allow for a commit on your 
> > > > > behalf when you don't have access after an LGTM (which is all that I 
> > > > > did). As you can see from the lack of additional comments from my 
> > > > > end, I was happy to let this sit and be reviewed. 
> > > > > 
> > > > > Per the discussion about the option itself, I do believe 
> > > > > `IncludeSortAlphabetically` currently expresses what I mean as the 
> > > > > behavior with this off is indeed not an alphabetical sort as case 
> > > > > takes precedence over the alphabetical ordering. However, looking at 
> > > > > the enum and realizing that others probably will have additional 
> > > > > styles they prefer (maybe they want alphabetical but lower case 
> > > > > first, etc.) I do believe it might have been a better way to go as it 
> > > > > leaves more flexibility and room for additional ordering styles. 
> > > > > Given that this just landed, I would be happy to open a patch to turn 
> > > > > this into an `enum` as I do see benefits to doing so. What do you 
> > > > > think?
> > > > Hmmm, and how about using the existing option `SortIncludes` and change 
> > > > its type from `bool` to some `enum`?
> > > > We could then, for backward-compatibility, map `false` to (tentative) 
> > > > `Never` and `true` to `ASCII`/`CaseInsensitive`, and add 
> > > > `CaseSensitive`.
> > > > 
> > > > This will have the advantage of not adding additional style options.
> > > > ... and it will prove once again that using `bool`s for style options 
> > > > is not a good idea.
> > > I think that is an excellent idea @curdeius 
> > I also fully support that! (Although I would not say a bool is per se bad.)
> @curdeius @MyDeveloperDay @HazardyKnusperkeks this is now done.
> 
> However... The command-line option (`--sort-includes`) is not in a place that 
> I like at the moment but I am having trouble thinking of any really good 
> options. 
> 
> The issue as it stands is that there are a lot of usages of the flag that 
> assume it is a `bool` and therefore sometimes do not pass any value. These of 
> course could be updated along with the flag to accept a `std::string` value, 
> however, this breaks backward capability for anyone relying on that flag not 
> requiring a value. As I have it now, backward compatibility is maintained but 
> the command line flag is rather severely limited compared to the 
> configuration option. Thoughts on which path to take? A third option I have 
> not considered? 
> I also fully support that! (Although I would not say a bool is per se bad.)

@HazardyKnusperkeks, I was of course a bit exaggerating :).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95532: [clang][cli] Use variadic macros for parsing/generating

2021-01-28 Thread Jan Svoboda 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 rG374862d71c1a: [clang][cli] Use variadic macros for 
parsing/generating (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D95532?vs=319581&id=319789#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95532

Files:
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -385,36 +385,44 @@
   return KeyPath & Value;
 }
 
-#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  \
-  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,\
-  IMPLIED_CHECK, IMPLIED_VALUE,\
-  NORMALIZER, MERGER, TABLE_INDEX) \
+#define THIS_PREFIX(KEYPATH) this->KEYPATH
+#define NO_PREFIX(KEYPATH) KEYPATH
+
+#define PARSE_OPTION_WITH_MARSHALLING( \
+ARGS, DIAGS, SUCCESS, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND, GROUP,  \
+ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SPELLING,   \
+SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK,  \
+IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   \
   if ((FLAGS)&options::CC1Option) {\
-KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  \
+PREFIX_KEYPATH(KEYPATH) = MERGER(PREFIX_KEYPATH(KEYPATH), DEFAULT_VALUE);  \
 if (IMPLIED_CHECK) \
-  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);\
+  PREFIX_KEYPATH(KEYPATH) =\
+  MERGER(PREFIX_KEYPATH(KEYPATH), IMPLIED_VALUE);  \
 if (SHOULD_PARSE)  \
   if (auto MaybeValue =\
   NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) \
-KEYPATH =  \
-MERGER(KEYPATH, static_cast(*MaybeValue));  \
+PREFIX_KEYPATH(KEYPATH) = MERGER(  \
+PREFIX_KEYPATH(KEYPATH),   \
+static_cast(*MaybeValue));  \
   }
 
 // Capture the extracted value as a lambda argument to avoid potential issues
 // with lifetime extension of the reference.
 #define GENERATE_OPTION_WITH_MARSHALLING(  \
-ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   \
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  \
+ARGS, STRING_ALLOCATOR, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND,   \
+GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES,  \
+SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,   \
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, \
 TABLE_INDEX)   \
   if ((FLAGS)&options::CC1Option) {\
 [&](const auto &Extracted) {   \
   if (ALWAYS_EMIT ||   \
   (Extracted !=\
-   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)\
-  : (DEFAULT_VALUE \
+   static_cast( \
+   (IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE  \
 DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,\
  TABLE_INDEX, Extracted);  \
-}(EXTRACTOR(KEYPATH)); \
+}(EXTRACTOR(PREFIX_KEYPATH(KEYPATH))); \
   }
 
 static const StringRef GetInputKindName(InputKind IK);
@@ -986,15 +994,8 @@
   // variable name and type.
   const LangOptions *LangOpts = &LangOptsRef;
 
-#define CODEGEN_OPTION_WITH_MARSHALLING(   \
-PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
-HELPTEXT, METAVAR, VALUES, SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH,   \
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
-MER

[clang] 374862d - [clang][cli] Use variadic macros for parsing/generating

2021-01-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-28T10:35:02+01:00
New Revision: 374862d71c1a2f63557a27f1555b37ff0f75117e

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

LOG: [clang][cli] Use variadic macros for parsing/generating

This patch makes all macros forwarding to `PARSE_OPTION_WITH_MARSHALLING` and 
`GENERATE_OPTION_WITH_MARSHALLING` variadic.

Sice we will be splitting up all CompilerInvocation parts, this will allow us 
to avoid a lot of boilerplate code.

The local macros prefix forwarded arguments with local variables required by 
the main macros. The `{THIS,NO}_PREFIX` macros make it possible for forwarding 
macros in member functions (`parseSimpleArgs`, `generateCC1CommandLine`) to 
prefix keypaths with `this->`. (Some build bots seem to require that.)

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d602715ba03e..26093bc1fdf7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -385,36 +385,44 @@ static T extractMaskValue(T KeyPath) {
   return KeyPath & Value;
 }
 
-#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
-  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
-  IMPLIED_CHECK, IMPLIED_VALUE,
\
-  NORMALIZER, MERGER, TABLE_INDEX) 
\
+#define THIS_PREFIX(KEYPATH) this->KEYPATH
+#define NO_PREFIX(KEYPATH) KEYPATH
+
+#define PARSE_OPTION_WITH_MARSHALLING( 
\
+ARGS, DIAGS, SUCCESS, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND, GROUP,  
\
+ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SPELLING,   
\
+SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK,  
\
+IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
-KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  
\
+PREFIX_KEYPATH(KEYPATH) = MERGER(PREFIX_KEYPATH(KEYPATH), DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
-  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);
\
+  PREFIX_KEYPATH(KEYPATH) =
\
+  MERGER(PREFIX_KEYPATH(KEYPATH), IMPLIED_VALUE);  
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
   NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
-KEYPATH =  
\
-MERGER(KEYPATH, static_cast(*MaybeValue));  
\
+PREFIX_KEYPATH(KEYPATH) = MERGER(  
\
+PREFIX_KEYPATH(KEYPATH),   
\
+static_cast(*MaybeValue));  
\
   }
 
 // Capture the extracted value as a lambda argument to avoid potential issues
 // with lifetime extension of the reference.
 #define GENERATE_OPTION_WITH_MARSHALLING(  
\
-ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  
\
+ARGS, STRING_ALLOCATOR, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND,   
\
+GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES,  
\
+SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,   
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
 TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
 [&](const auto &Extracted) {   
\
   if (ALWAYS_EMIT ||   
\
   (Extracted !=
\
-   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)
\
-  : (DEFAULT_VALUE 
\
+   static_cast( 
\
+   (IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE  
\
 DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,
\
 

[PATCH] D95538: [clang][Format] Evaluate FallbackStyle only if needed

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I see little value in not checking FallbackStyle (even if it's not used).
However, I do see value in an early warning (error) on an incorrect style that 
can pop up later if not caught soon enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95538

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


[PATCH] D95538: [clang][Format] Evaluate FallbackStyle only if needed

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I return the question, are there any workflows that would benefit from the 
proposed behaviour? Apart from those that have already a faulty config?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95538

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


[clang] 374862d - [clang][cli] Use variadic macros for parsing/generating

2021-01-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-28T10:35:02+01:00
New Revision: 374862d71c1a2f63557a27f1555b37ff0f75117e

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

LOG: [clang][cli] Use variadic macros for parsing/generating

This patch makes all macros forwarding to `PARSE_OPTION_WITH_MARSHALLING` and 
`GENERATE_OPTION_WITH_MARSHALLING` variadic.

Sice we will be splitting up all CompilerInvocation parts, this will allow us 
to avoid a lot of boilerplate code.

The local macros prefix forwarded arguments with local variables required by 
the main macros. The `{THIS,NO}_PREFIX` macros make it possible for forwarding 
macros in member functions (`parseSimpleArgs`, `generateCC1CommandLine`) to 
prefix keypaths with `this->`. (Some build bots seem to require that.)

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d602715ba03e..26093bc1fdf7 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -385,36 +385,44 @@ static T extractMaskValue(T KeyPath) {
   return KeyPath & Value;
 }
 
-#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
-  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
-  IMPLIED_CHECK, IMPLIED_VALUE,
\
-  NORMALIZER, MERGER, TABLE_INDEX) 
\
+#define THIS_PREFIX(KEYPATH) this->KEYPATH
+#define NO_PREFIX(KEYPATH) KEYPATH
+
+#define PARSE_OPTION_WITH_MARSHALLING( 
\
+ARGS, DIAGS, SUCCESS, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND, GROUP,  
\
+ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SPELLING,   
\
+SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK,  
\
+IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
-KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  
\
+PREFIX_KEYPATH(KEYPATH) = MERGER(PREFIX_KEYPATH(KEYPATH), DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
-  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);
\
+  PREFIX_KEYPATH(KEYPATH) =
\
+  MERGER(PREFIX_KEYPATH(KEYPATH), IMPLIED_VALUE);  
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
   NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
-KEYPATH =  
\
-MERGER(KEYPATH, static_cast(*MaybeValue));  
\
+PREFIX_KEYPATH(KEYPATH) = MERGER(  
\
+PREFIX_KEYPATH(KEYPATH),   
\
+static_cast(*MaybeValue));  
\
   }
 
 // Capture the extracted value as a lambda argument to avoid potential issues
 // with lifetime extension of the reference.
 #define GENERATE_OPTION_WITH_MARSHALLING(  
\
-ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   
\
-DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  
\
+ARGS, STRING_ALLOCATOR, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND,   
\
+GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES,  
\
+SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,   
\
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
 TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
 [&](const auto &Extracted) {   
\
   if (ALWAYS_EMIT ||   
\
   (Extracted !=
\
-   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)
\
-  : (DEFAULT_VALUE 
\
+   static_cast( 
\
+   (IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE  
\
 DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,
\
 

[clang] 2393b03 - Revert "[clang][cli] Use variadic macros for parsing/generating"

2021-01-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-28T10:48:43+01:00
New Revision: 2393b03239c56b9bc1f6fd8bef5cdedaf0570bc7

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

LOG: Revert "[clang][cli] Use variadic macros for parsing/generating"

This reverts commit 374862d7.

Some build bots are failing with:
clang/Driver/Options.inc(4315): warning C4003: not enough arguments for 
function-like macro invocation 'PARSE_OPTION_WITH_MARSHALLING'
clang/Driver/Options.inc(4315): warning C4003: not enough arguments for 
function-like macro invocation 'NO_PREFIX'
clang/Driver/Options.inc(4315): error C2059: syntax error: ')'
clang/Driver/Options.inc(4315): error C2143: syntax error: missing ';' before 
'{'
clang/Driver/Options.inc(4315): error C2059: syntax error: '='

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 26093bc1fdf7..d602715ba03e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -385,44 +385,36 @@ static T extractMaskValue(T KeyPath) {
   return KeyPath & Value;
 }
 
-#define THIS_PREFIX(KEYPATH) this->KEYPATH
-#define NO_PREFIX(KEYPATH) KEYPATH
-
-#define PARSE_OPTION_WITH_MARSHALLING( 
\
-ARGS, DIAGS, SUCCESS, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND, GROUP,  
\
-ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SPELLING,   
\
-SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK,  
\
-IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   
\
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
+  IMPLIED_CHECK, IMPLIED_VALUE,
\
+  NORMALIZER, MERGER, TABLE_INDEX) 
\
   if ((FLAGS)&options::CC1Option) {
\
-PREFIX_KEYPATH(KEYPATH) = MERGER(PREFIX_KEYPATH(KEYPATH), DEFAULT_VALUE);  
\
+KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
-  PREFIX_KEYPATH(KEYPATH) =
\
-  MERGER(PREFIX_KEYPATH(KEYPATH), IMPLIED_VALUE);  
\
+  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
   NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
-PREFIX_KEYPATH(KEYPATH) = MERGER(  
\
-PREFIX_KEYPATH(KEYPATH),   
\
-static_cast(*MaybeValue));  
\
+KEYPATH =  
\
+MERGER(KEYPATH, static_cast(*MaybeValue));  
\
   }
 
 // Capture the extracted value as a lambda argument to avoid potential issues
 // with lifetime extension of the reference.
 #define GENERATE_OPTION_WITH_MARSHALLING(  
\
-ARGS, STRING_ALLOCATOR, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND,   
\
-GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES,  
\
-SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,   
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
+ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  
\
 TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
 [&](const auto &Extracted) {   
\
   if (ALWAYS_EMIT ||   
\
   (Extracted !=
\
-   static_cast( 
\
-   (IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE  
\
+   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)
\
+  : (DEFAULT_VALUE 
\
 DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,
\
  TABLE_INDEX, Extracted);  
\
-}(EXTR

[clang] 2393b03 - Revert "[clang][cli] Use variadic macros for parsing/generating"

2021-01-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-01-28T10:48:43+01:00
New Revision: 2393b03239c56b9bc1f6fd8bef5cdedaf0570bc7

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

LOG: Revert "[clang][cli] Use variadic macros for parsing/generating"

This reverts commit 374862d7.

Some build bots are failing with:
clang/Driver/Options.inc(4315): warning C4003: not enough arguments for 
function-like macro invocation 'PARSE_OPTION_WITH_MARSHALLING'
clang/Driver/Options.inc(4315): warning C4003: not enough arguments for 
function-like macro invocation 'NO_PREFIX'
clang/Driver/Options.inc(4315): error C2059: syntax error: ')'
clang/Driver/Options.inc(4315): error C2143: syntax error: missing ';' before 
'{'
clang/Driver/Options.inc(4315): error C2059: syntax error: '='

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 26093bc1fdf7..d602715ba03e 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -385,44 +385,36 @@ static T extractMaskValue(T KeyPath) {
   return KeyPath & Value;
 }
 
-#define THIS_PREFIX(KEYPATH) this->KEYPATH
-#define NO_PREFIX(KEYPATH) KEYPATH
-
-#define PARSE_OPTION_WITH_MARSHALLING( 
\
-ARGS, DIAGS, SUCCESS, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND, GROUP,  
\
-ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SPELLING,   
\
-SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK,  
\
-IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)   
\
+#define PARSE_OPTION_WITH_MARSHALLING(ARGS, DIAGS, SUCCESS, ID, FLAGS, PARAM,  
\
+  SHOULD_PARSE, KEYPATH, DEFAULT_VALUE,
\
+  IMPLIED_CHECK, IMPLIED_VALUE,
\
+  NORMALIZER, MERGER, TABLE_INDEX) 
\
   if ((FLAGS)&options::CC1Option) {
\
-PREFIX_KEYPATH(KEYPATH) = MERGER(PREFIX_KEYPATH(KEYPATH), DEFAULT_VALUE);  
\
+KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE);  
\
 if (IMPLIED_CHECK) 
\
-  PREFIX_KEYPATH(KEYPATH) =
\
-  MERGER(PREFIX_KEYPATH(KEYPATH), IMPLIED_VALUE);  
\
+  KEYPATH = MERGER(KEYPATH, IMPLIED_VALUE);
\
 if (SHOULD_PARSE)  
\
   if (auto MaybeValue =
\
   NORMALIZER(OPT_##ID, TABLE_INDEX, ARGS, DIAGS, SUCCESS)) 
\
-PREFIX_KEYPATH(KEYPATH) = MERGER(  
\
-PREFIX_KEYPATH(KEYPATH),   
\
-static_cast(*MaybeValue));  
\
+KEYPATH =  
\
+MERGER(KEYPATH, static_cast(*MaybeValue));  
\
   }
 
 // Capture the extracted value as a lambda argument to avoid potential issues
 // with lifetime extension of the reference.
 #define GENERATE_OPTION_WITH_MARSHALLING(  
\
-ARGS, STRING_ALLOCATOR, PREFIX_KEYPATH, PREFIX_TYPE, NAME, ID, KIND,   
\
-GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES,  
\
-SPELLING, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,   
\
-IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, 
\
+ARGS, STRING_ALLOCATOR, KIND, FLAGS, SPELLING, ALWAYS_EMIT, KEYPATH,   
\
+DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, DENORMALIZER, EXTRACTOR,  
\
 TABLE_INDEX)   
\
   if ((FLAGS)&options::CC1Option) {
\
 [&](const auto &Extracted) {   
\
   if (ALWAYS_EMIT ||   
\
   (Extracted !=
\
-   static_cast( 
\
-   (IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE  
\
+   static_cast((IMPLIED_CHECK) ? (IMPLIED_VALUE)
\
+  : (DEFAULT_VALUE 
\
 DENORMALIZER(ARGS, SPELLING, STRING_ALLOCATOR, Option::KIND##Class,
\
  TABLE_INDEX, Extracted);  
\
-}(EXTR

[PATCH] D95538: [clang][Format] Evaluate FallbackStyle only if needed

2021-01-28 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> I see little value in not checking FallbackStyle (even if it's not used).

note that this patch doesn't disable fallbackstyle checking, it is still 
checked, but not eagerly.

> However, I do see value in an early warning (error) on an incorrect style 
> that can pop up later if not caught soon enough.

i don't follow the value proposition here. if user has a valid way to provide 
"style", the fallbackstyle will never be used (malformed or otherwise).
so in such a case, user is currently going to get a "hard error" preventing 
them from formatting with the style they provided whenever they have a 
malformed fallback-style.

what i am trying to say is, "earliness" of the warning/error in such a scenario 
doesn't seem to benefit any user (at least to me).
since fixing their fallbackstyle won't change anything for formatting of the 
particular file in question, and they'll still see the error whenever they try 
to format a file that needs the fallbackstyle.
hence currently the eager validation of a malformed FallbackStyle is *only* 
preventing a user with a valid Style from formatting their file (it is erroring 
in all other cases, but there's nothing much to be done for those).

to add, there will never be a file formatted with the incorrect style.

> I return the question, are there any workflows that would benefit from the 
> proposed behaviour? Apart from those that have already a faulty config?

that's the exact set of workflows that this change is going to effect(if 
`FallbackStyle` is valid, this patch is a no-op). so, no, i don't think there 
will be any other workflows that can benefit from this change, but it feels 
like this is a non-empty set of users (while not regressing any users that 
benefit from current error/warning, as they'll still be surfaced when needed).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95538

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer added a comment.

In D95017#2527512 , @curdeius wrote:

> Concerning the `--sort-includes` command-line flag. I'd rather keep it as is 
> and, if need be, work on accepting an **optional** string argument.
> Please update release notes.

@curdeius Just to confirm, are you asking for the "commit" message to be 
updated or something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

I was thinking of 
https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst#clang-format.
 Look at the history to see how it was written before.
Also, you may change the revision title if you want (it will become the commit 
message).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-01-28 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 319797.
yubing added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix some bugs in lowerTileDPBSSD, lowerTileStore, lowerTileLoad


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

Files:
  clang/lib/Headers/amxintrin.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll

Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -18,7 +18,9 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
-; CHECK-NEXT:   Lower AMX type for load/store
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
 ; CHECK-NEXT:   Shadow Stack GC Lowering
Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -0,0 +1,198 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -lower-amx-intrinsics %s -S | FileCheck %s
+
+define dso_local void @test_amx_load_non_O0(i16 signext %row, i16 signext %col, i8 *%ptr, i64 %stride, <256 x i32>* %vptr) {
+; CHECK-LABEL: @test_amx_load_non_O0(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[AMX:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[ROW:%.*]], i16 [[COL:%.*]], i8* [[PTR:%.*]], i64 [[STRIDE:%.*]])
+; CHECK-NEXT:[[VEC:%.*]] = bitcast x86_amx [[AMX]] to <256 x i32>
+; CHECK-NEXT:store <256 x i32> [[VEC]], <256 x i32>* [[VPTR:%.*]], align 64
+; CHECK-NEXT:ret void
+;
+entry:
+  %amx = call x86_amx @llvm.x86.tileloadd64.internal(i16 %row, i16 %col, i8* %ptr, i64 %stride)
+  %vec = bitcast x86_amx %amx to <256 x i32>
+  store <256 x i32> %vec, <256 x i32>* %vptr, align 64
+  ret void
+}
+
+define dso_local void @test_amx_load(i16 signext %row, i16 signext %col, i8 *%ptr, i64 %stride, <256 x i32>* %vptr) #0 {
+; CHECK-LABEL: @test_amx_load(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = udiv i16 [[COL:%.*]], 4
+; CHECK-NEXT:[[TMP1:%.*]] = udiv i64 [[STRIDE:%.*]], 4
+; CHECK-NEXT:br label [[TILELOAD_UNROLL_ROWS_HEADER:%.*]]
+; CHECK:   tileload.unroll.rows.header:
+; CHECK-NEXT:[[TILELOAD_UNROLL_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TILELOAD_UNROLL_ROWS_STEP:%.*]], [[TILELOAD_UNROLL_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP11:%.*]], [[TILELOAD_UNROLL_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_UNROLL_ROWS_BODY:%.*]]
+; CHECK:   tileload.unroll.rows.body:
+; CHECK-NEXT:br label [[TILELOAD_UNROLL_COLS_HEADER:%.*]]
+; CHECK:   tileload.unroll.cols.header:
+; CHECK-NEXT:[[TILELOAD_UNROLL_COLS_IV:%.*]] = phi i16 [ 0, [[TILELOAD_UNROLL_ROWS_BODY]] ], [ [[TILELOAD_UNROLL_COLS_STEP:%.*]], [[TILELOAD_UNROLL_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI:%.*]] = phi <256 x i32> [ [[VEC_PHI_ROW]], [[TILELOAD_UNROLL_ROWS_BODY]] ], [ [[TMP11]], [[TILELOAD_UNROLL_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_UNROLL_COLS_BODY:%.*]]
+; CHECK:   tileload.unroll.cols.body:
+; CHECK-NEXT:[[TMP2:%.*]] = zext i16 [[TILELOAD_UNROLL_ROWS_IV]] to i64
+; CHECK-NEXT:[[TMP3:%.*]] = zext i16 [[TILELOAD_UNROLL_COLS_IV]] to i64
+; CHECK-NEXT:[[TMP4:%.*]] = mul i64 [[TMP2]], [[TMP1]]
+; CHECK-NEXT:[[TMP5:%.*]] = add i64 [[TMP4]], [[TMP3]]
+; CHECK-NEXT:[[TMP6:%.*]] = bitcast i8* [[PTR:%.*]] to i32*
+; CHECK-NEXT:[[TMP7:%.*]] = getelementptr i32, i32* [[TMP6]], i64 [[TMP5]]
+; CHECK-NEXT:[[TMP8:%.*]] = load i32, i32* [[TMP7]], align 4
+; CHECK-NEXT:[[TMP9:%.*]] = mul i16 [[TILELOAD_UNROLL_ROWS_IV]], 16
+; CHECK-NEXT:[[TMP10:%.*]] = add i16 [[TMP9]], [[TILELOAD_UNROLL_COLS_IV]]
+; CHECK-NEXT:[[TMP11]] = insertelement <256 x i32> [[VEC_PHI]], i32 [[TMP8]], i16 [[TMP10]]
+; CHECK-NEXT:br label [[TILELOAD_UNROLL_COLS_LATCH]]
+; CHECK:   tileload.unroll.cols.latch:
+; CHECK-NEXT:[[TILELOAD_UNROLL_COLS_STEP]] = add i16 [[TILELOAD_UNROLL_COLS_IV]], 1
+; CHECK-NEXT:[[TILELOAD_UNROLL_COLS_COND:%.*]] = icmp ne i16 [[TILELOAD_UNROLL_COLS_STEP]], [[TMP0]]
+; CHECK-NEXT:br i1 [[TILELOAD_UNROLL_COLS_COND]], label [[TILELOAD_UNROLL_COLS_HEADER]], label [[TILELOAD_UNROLL_ROWS_LATCH]]
+; CHECK:   tileload.unroll.rows.latch:
+; CHECK-NEXT:[[TILELOAD_UNROL

[PATCH] D93585: [AArch64][Clang][Linux] Enable out-of-line atomics by default.

2021-01-28 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

In D93585#2526774 , @ilinpv wrote:

> Clang driver tests for outline atomics were added.

Thanks!

Is there a way we can test `-rtlib=libgcc`?




Comment at: clang/lib/Driver/ToolChains/Linux.cpp:855
+const GCCVersion &Ver = GCCInstallation.getVersion();
+if (Ver.isOlderThan(9, 3, 1))
+  return false;

Nit: if we change this into:

  if (GCCInstallation.getVersion().isOlderThan(9, 3, 1))

we can get rid of the curly brackets.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:857
+  return false;
+  } else if (GetRuntimeLibType(Args) != ToolChain::RLT_CompilerRT) {
+return false;

This means we need one more test and RUN line with the rtlib not being 
compiler-rt or libgcc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93585

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


[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer updated this revision to Diff 319804.
kentsommer added a comment.

Added release notes, updated commit message and summary


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortImportsTestJava.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -269,7 +269,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  FmtStyle.SortIncludes = false;
+  FmtStyle.SortIncludes = FormatStyle::SI_Never;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -598,6 +598,49 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
+  EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseSensitive);
+
+  FmtStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+
+  EXPECT_EQ("#include \"A/B.h\"\n"
+"#include \"A/b.h\"\n"
+"#include \"a/b.h\"\n"
+"#include \"B/A.h\"\n"
+"#include \"B/a.h\"\n",
+sort("#include \"B/a.h\"\n"
+ "#include \"B/A.h\"\n"
+ "#include \"A/B.h\"\n"
+ "#include \"a/b.h\"\n"
+ "#include \"A/b.h\"\n",
+ "a.h"));
+
+  Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
+  Style.IncludeCategories = {
+  {"^\"", 1, 0, false}, {"^<.*\\.h>$", 2, 0, false}, {"^<", 3, 0, false}};
+
+  StringRef UnsortedCode = "#include \"qt.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"vlib.h\"\n"
+   "#include \"Vlib.h\"\n"
+   "#include \"AST.h\"\n";
+
+  EXPECT_EQ("#include \"AST.h\"\n"
+"#include \"qt.h\"\n"
+"#include \"Vlib.h\"\n"
+"#include \"vlib.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort(UnsortedCode));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -32,7 +32,7 @@
   SortImportsTestJava() {
 FmtStyle = getGoogleStyle(FormatStyle::LK_Java);
 FmtStyle.JavaImportGroups = {"com.test", "org", "com"};
-FmtStyle.SortIncludes = true;
+FmtStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
   }
 };
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15463,7 +15463,6 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
-  CHECK_PARSE_BOOL(SortIncludes);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -15959,6 +15958,16 @@
   CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
   IncludeStyle.IncludeIsMainSourceRegex, "abc$");
 
+  Style.SortIncludes = FormatStyle::SI_Never;
+  CHECK_PARSE("SortIncludes: true", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
+  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
+  FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);
+
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
   {
@@ -17950,7 +17959,7 @@
 "#include \"b.h\"\n")});
 
   format::FormatStyle Style = format::getLLVMStyle();
-  Style.SortIncludes = true;
+  Style.SortIncludes = FormatStyle::SI_CaseInsensitive;
   auto FormattedReplaces = formatReplacements(Code, Replaces, Style);
   EXPECT_TRUE(static_cast(FormattedReplaces))
   << llvm::toString(FormattedReplaces.takeError()) << "\n";
Index: clan

[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer updated this revision to Diff 319806.
kentsommer added a comment.

Fixed release notes typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortImportsTestJava.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -269,7 +269,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  FmtStyle.SortIncludes = false;
+  FmtStyle.SortIncludes = FormatStyle::SI_Never;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -598,6 +598,49 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
+  EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseSensitive);
+
+  FmtStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+
+  EXPECT_EQ("#include \"A/B.h\"\n"
+"#include \"A/b.h\"\n"
+"#include \"a/b.h\"\n"
+"#include \"B/A.h\"\n"
+"#include \"B/a.h\"\n",
+sort("#include \"B/a.h\"\n"
+ "#include \"B/A.h\"\n"
+ "#include \"A/B.h\"\n"
+ "#include \"a/b.h\"\n"
+ "#include \"A/b.h\"\n",
+ "a.h"));
+
+  Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
+  Style.IncludeCategories = {
+  {"^\"", 1, 0, false}, {"^<.*\\.h>$", 2, 0, false}, {"^<", 3, 0, false}};
+
+  StringRef UnsortedCode = "#include \"qt.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"vlib.h\"\n"
+   "#include \"Vlib.h\"\n"
+   "#include \"AST.h\"\n";
+
+  EXPECT_EQ("#include \"AST.h\"\n"
+"#include \"qt.h\"\n"
+"#include \"Vlib.h\"\n"
+"#include \"vlib.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort(UnsortedCode));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -32,7 +32,7 @@
   SortImportsTestJava() {
 FmtStyle = getGoogleStyle(FormatStyle::LK_Java);
 FmtStyle.JavaImportGroups = {"com.test", "org", "com"};
-FmtStyle.SortIncludes = true;
+FmtStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
   }
 };
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15463,7 +15463,6 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
-  CHECK_PARSE_BOOL(SortIncludes);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -15959,6 +15958,16 @@
   CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
   IncludeStyle.IncludeIsMainSourceRegex, "abc$");
 
+  Style.SortIncludes = FormatStyle::SI_Never;
+  CHECK_PARSE("SortIncludes: true", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
+  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
+  FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);
+
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
   {
@@ -17950,7 +17959,7 @@
 "#include \"b.h\"\n")});
 
   format::FormatStyle Style = format::getLLVMStyle();
-  Style.SortIncludes = true;
+  Style.SortIncludes = FormatStyle::SI_CaseInsensitive;
   auto FormattedReplaces = formatReplacements(Code, Replaces, Style);
   EXPECT_TRUE(static_cast(FormattedReplaces))
   << llvm::toString(FormattedReplaces.takeError()) << "\n";
Index: clang/tools/clang-format/ClangForma

[PATCH] D95562: [ASTMatchers] Fix traversal below range-for elements

2021-01-28 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 319809.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95562

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2784,6 +2784,36 @@
 EXPECT_FALSE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
   }
 
+  Code = R"cpp(
+  struct Range {
+int* begin() const;
+int* end() const;
+  };
+  Range getRange(int);
+
+  void rangeFor()
+  {
+for (auto i : getRange(42))
+{
+}
+  }
+  )cpp";
+  {
+auto M = integerLiteral(equals(42));
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = callExpr(hasDescendant(integerLiteral(equals(42;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+  {
+auto M = compoundStmt(hasDescendant(integerLiteral(equals(42;
+EXPECT_TRUE(matches(Code, traverse(TK_AsIs, M)));
+EXPECT_TRUE(matches(Code, traverse(TK_IgnoreUnlessSpelledInSource, M)));
+  }
+
   Code = R"cpp(
   void rangeFor()
   {
@@ -2855,6 +2885,40 @@
 matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
  true, {"-std=c++20"}));
   }
+
+  Code = R"cpp(
+  struct Range {
+int* begin() const;
+int* end() const;
+  };
+  Range getRange(int);
+
+  int getNum(int);
+
+  void rangeFor()
+  {
+for (auto j = getNum(42); auto i : getRange(j))
+{
+}
+  }
+  )cpp";
+  {
+auto M = integerLiteral(equals(42));
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_AsIs, M), true, {"-std=c++20"}));
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
+ true, {"-std=c++20"}));
+  }
+  {
+auto M = compoundStmt(hasDescendant(integerLiteral(equals(42;
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_AsIs, M), true, {"-std=c++20"}));
+EXPECT_TRUE(
+matchesConditionally(Code, traverse(TK_IgnoreUnlessSpelledInSource, M),
+ true, {"-std=c++20"}));
+  }
+
   Code = R"cpp(
 void hasDefaultArg(int i, int j = 0)
 {
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -243,10 +243,14 @@
   return true;
 ScopedIncrement ScopedDepth(&CurrentDepth);
 if (auto *Init = Node->getInit())
-  if (!match(*Init))
+  if (!traverse(*Init))
 return false;
-if (!match(*Node->getLoopVariable()) || !match(*Node->getRangeInit()) ||
-!match(*Node->getBody()))
+if (!match(*Node->getLoopVariable()))
+  return false;
+if (match(*Node->getRangeInit()))
+  if (!VisitorBase::TraverseStmt(Node->getRangeInit()))
+return false;
+if (!match(*Node->getBody()))
   return false;
 return VisitorBase::TraverseStmt(Node->getBody());
   }
@@ -488,15 +492,21 @@
 
   bool dataTraverseNode(Stmt *S, DataRecursionQueue *Queue) {
 if (auto *RF = dyn_cast(S)) {
-  for (auto *SubStmt : RF->children()) {
-if (SubStmt == RF->getInit() || SubStmt == RF->getLoopVarStmt() ||
-SubStmt == RF->getRangeInit() || SubStmt == RF->getBody()) {
-  TraverseStmt(SubStmt, Queue);
-} else {
-  ASTNodeNotSpelledInSourceScope RAII(this, true);
-  TraverseStmt(SubStmt, Queue);
+  {
+ASTNodeNotAsIsSourceScope RAII(this, true);
+TraverseStmt(RF->getInit());
+// Don't traverse under the loop variable
+match(*RF->getLoopVariable());
+TraverseStmt(RF->getRangeInit());
+  }
+  {
+ASTNodeNotSpelledInSourceScope RAII(this, true);
+for (auto *SubStmt : RF->children()) {
+  if (SubStmt != RF->getBody())
+TraverseStmt(SubStmt);
 }
   }
+  TraverseStmt(RF->getBody());
   return true;
 } else if (auto *RBO = dyn_cast(S)) {
   {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95557: [WebAssembly] Prototype i8x16 to i32x4 widening instructions

2021-01-28 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin accepted this revision.
aheejin added a comment.
This revision is now accepted and ready to land.

This does not yet have i64x2 version of the instructions in 
https://github.com/WebAssembly/simd/pull/395 yet, right?




Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td:1279
+(I32x4.vt (int_wasm_widen_signed
+  (I8x16.vt V128:$vec), (i32 timm:$idx],
+ "i32x4.widen_i8x16_s\t$dst, $vec, $idx",

I think this is the first time we use `timm` in this file... Haven't we used 
`LaneIdxN` for these? The same for `WIDEN_I8x16_TO_I32x4_U`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95557

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


[PATCH] D94827: [SimplifyCFG] If provided, preserve Dominator Tree

2021-01-28 Thread Roman Lebedev 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 rG8cfa963463d0: [SimplifyCFG] If provided, preserve Dominator 
Tree (authored by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94827

Files:
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6561,20 +6561,10 @@
 bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) {
   bool Changed = simplifyOnceImpl(BB);
 
-  assert((!RequireAndPreserveDomTree ||
-  (DTU &&
-   DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) 
&&
- "Failed to maintain validity of domtree!");
-
   return Changed;
 }
 
 bool SimplifyCFGOpt::run(BasicBlock *BB) {
-  assert((!RequireAndPreserveDomTree ||
-  (DTU &&
-   DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) 
&&
- "Original domtree is invalid?");
-
   bool Changed = false;
 
   // Repeated simplify BB as long as resimplification is requested.
@@ -6592,7 +6582,7 @@
 bool llvm::simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
DomTreeUpdater *DTU, const SimplifyCFGOptions &Options,
ArrayRef LoopHeaders) {
-  return SimplifyCFGOpt(TTI, RequireAndPreserveDomTree ? DTU : nullptr,
-BB->getModule()->getDataLayout(), LoopHeaders, Options)
+  return SimplifyCFGOpt(TTI, DTU, BB->getModule()->getDataLayout(), 
LoopHeaders,
+Options)
   .run(BB);
 }


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -6561,20 +6561,10 @@
 bool SimplifyCFGOpt::simplifyOnce(BasicBlock *BB) {
   bool Changed = simplifyOnceImpl(BB);
 
-  assert((!RequireAndPreserveDomTree ||
-  (DTU &&
-   DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) &&
- "Failed to maintain validity of domtree!");
-
   return Changed;
 }
 
 bool SimplifyCFGOpt::run(BasicBlock *BB) {
-  assert((!RequireAndPreserveDomTree ||
-  (DTU &&
-   DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) &&
- "Original domtree is invalid?");
-
   bool Changed = false;
 
   // Repeated simplify BB as long as resimplification is requested.
@@ -6592,7 +6582,7 @@
 bool llvm::simplifyCFG(BasicBlock *BB, const TargetTransformInfo &TTI,
DomTreeUpdater *DTU, const SimplifyCFGOptions &Options,
ArrayRef LoopHeaders) {
-  return SimplifyCFGOpt(TTI, RequireAndPreserveDomTree ? DTU : nullptr,
-BB->getModule()->getDataLayout(), LoopHeaders, Options)
+  return SimplifyCFGOpt(TTI, DTU, BB->getModule()->getDataLayout(), LoopHeaders,
+Options)
   .run(BB);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 526c42e - [OpenCL] Hide sampler-less read_image builtins before CL1.2

2021-01-28 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-01-28T11:14:19Z
New Revision: 526c42e76c12d9cfe83dfa5957fe1715ab8d1faf

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

LOG: [OpenCL] Hide sampler-less read_image builtins before CL1.2

Ensure sampler-less image read functions are not available with
`-fdeclare-opencl-builtins` before OpenCL 1.2.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 745363a6b43f..fd9e24cfc31e 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1092,24 +1092,26 @@ foreach coordTy = [Int, Float] in {
 }
 
 // --- Table 23: Sampler-less Read Functions ---
-foreach aQual = ["RO", "RW"] in {
-  foreach imgTy = [Image2d, Image1dArray] in {
-def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
-def : Builtin<"read_imagei", [VectorType, ImageType, 
VectorType], Attr.Pure>;
-def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
-  }
-  foreach imgTy = [Image3d, Image2dArray] in {
-def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
-def : Builtin<"read_imagei", [VectorType, ImageType, 
VectorType], Attr.Pure>;
-def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
-  }
-  foreach imgTy = [Image1d, Image1dBuffer] in {
-def : Builtin<"read_imagef", [VectorType, ImageType, Int], Attr.Pure>;
-def : Builtin<"read_imagei", [VectorType, ImageType, 
Int], Attr.Pure>;
-def : Builtin<"read_imageui", [VectorType, ImageType, Int], Attr.Pure>;
+let MinVersion = CL12 in {
+  foreach aQual = ["RO", "RW"] in {
+foreach imgTy = [Image2d, Image1dArray] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
+}
+foreach imgTy = [Image3d, Image2dArray] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
+}
+foreach imgTy = [Image1d, Image1dBuffer] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, Int], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, Int], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, Int], Attr.Pure>;
+}
+def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
+def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
   }
-  def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
-  def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
 }
 
 // --- Table 24: Image Write Functions ---
@@ -1187,16 +1189,18 @@ foreach aQual = ["RO"] in {
 }
 // OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
 // --- Table 9 ---
-foreach aQual = ["RO", "RW"] in {
-  foreach name = ["read_imageh"] in {
-foreach imgTy = [Image2d, Image1dArray] in {
-  def : Builtin, ImageType, 
VectorType], Attr.Pure>;
-}
-foreach imgTy = [Image3d, Image2dArray] in {
-  def : Builtin, ImageType, 
VectorType], Attr.Pure>;
-}
-foreach imgTy = [Image1d, Image1dBuffer] in {
-  def : Builtin, ImageType, Int], 
Attr.Pure>;
+let MinVersion = CL12 in {
+  foreach aQual = ["RO", "RW"] in {
+foreach name = ["read_imageh"] in {
+  foreach imgTy = [Image2d, Image1dArray] in {
+def : Builtin, ImageType, 
VectorType], Attr.Pure>;
+  }
+  foreach imgTy = [Image3d, Image2dArray] in {
+def : Builtin, ImageType, 
VectorType], Attr.Pure>;
+  }
+  foreach imgTy = [Image1d, Image1dBuffer] in {
+def : Builtin, ImageType, 
Int], Attr.Pure>;
+  }
 }
   }
 }

diff  --git a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
index 64f2d89c5818..e4f4db0cd174 100644
--- a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown 
-fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown 
-cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck 
%s
 
 // Test that Attr.Const 

[clang] 526c42e - [OpenCL] Hide sampler-less read_image builtins before CL1.2

2021-01-28 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-01-28T11:14:19Z
New Revision: 526c42e76c12d9cfe83dfa5957fe1715ab8d1faf

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

LOG: [OpenCL] Hide sampler-less read_image builtins before CL1.2

Ensure sampler-less image read functions are not available with
`-fdeclare-opencl-builtins` before OpenCL 1.2.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 745363a6b43f..fd9e24cfc31e 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1092,24 +1092,26 @@ foreach coordTy = [Int, Float] in {
 }
 
 // --- Table 23: Sampler-less Read Functions ---
-foreach aQual = ["RO", "RW"] in {
-  foreach imgTy = [Image2d, Image1dArray] in {
-def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
-def : Builtin<"read_imagei", [VectorType, ImageType, 
VectorType], Attr.Pure>;
-def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
-  }
-  foreach imgTy = [Image3d, Image2dArray] in {
-def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
-def : Builtin<"read_imagei", [VectorType, ImageType, 
VectorType], Attr.Pure>;
-def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
-  }
-  foreach imgTy = [Image1d, Image1dBuffer] in {
-def : Builtin<"read_imagef", [VectorType, ImageType, Int], Attr.Pure>;
-def : Builtin<"read_imagei", [VectorType, ImageType, 
Int], Attr.Pure>;
-def : Builtin<"read_imageui", [VectorType, ImageType, Int], Attr.Pure>;
+let MinVersion = CL12 in {
+  foreach aQual = ["RO", "RW"] in {
+foreach imgTy = [Image2d, Image1dArray] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
+}
+foreach imgTy = [Image3d, Image2dArray] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType], Attr.Pure>;
+}
+foreach imgTy = [Image1d, Image1dBuffer] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, Int], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, Int], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, Int], Attr.Pure>;
+}
+def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
+def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
   }
-  def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
-  def : Builtin<"read_imagef", [Float, ImageType, 
VectorType], Attr.Pure>;
 }
 
 // --- Table 24: Image Write Functions ---
@@ -1187,16 +1189,18 @@ foreach aQual = ["RO"] in {
 }
 // OpenCL extension v2.0 s5.1.10: Built-in Image Sampler-less Read Functions
 // --- Table 9 ---
-foreach aQual = ["RO", "RW"] in {
-  foreach name = ["read_imageh"] in {
-foreach imgTy = [Image2d, Image1dArray] in {
-  def : Builtin, ImageType, 
VectorType], Attr.Pure>;
-}
-foreach imgTy = [Image3d, Image2dArray] in {
-  def : Builtin, ImageType, 
VectorType], Attr.Pure>;
-}
-foreach imgTy = [Image1d, Image1dBuffer] in {
-  def : Builtin, ImageType, Int], 
Attr.Pure>;
+let MinVersion = CL12 in {
+  foreach aQual = ["RO", "RW"] in {
+foreach name = ["read_imageh"] in {
+  foreach imgTy = [Image2d, Image1dArray] in {
+def : Builtin, ImageType, 
VectorType], Attr.Pure>;
+  }
+  foreach imgTy = [Image3d, Image2dArray] in {
+def : Builtin, ImageType, 
VectorType], Attr.Pure>;
+  }
+  foreach imgTy = [Image1d, Image1dBuffer] in {
+def : Builtin, ImageType, 
Int], Attr.Pure>;
+  }
 }
   }
 }

diff  --git a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
index 64f2d89c5818..e4f4db0cd174 100644
--- a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown 
-fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown 
-cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck 
%s
 
 // Test that Attr.Const 

[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Kent Sommer via Phabricator via cfe-commits
kentsommer updated this revision to Diff 319819.
kentsommer added a comment.

NFC Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/tools/clang-format/ClangFormat.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortImportsTestJava.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -269,7 +269,7 @@
 }
 
 TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) {
-  FmtStyle.SortIncludes = false;
+  FmtStyle.SortIncludes = FormatStyle::SI_Never;
   EXPECT_EQ("#include \"a.h\"\n"
 "#include \"c.h\"\n"
 "#include \"b.h\"\n",
@@ -598,6 +598,49 @@
  "a.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveSorting) {
+  EXPECT_FALSE(FmtStyle.SortIncludes == FormatStyle::SI_CaseSensitive);
+
+  FmtStyle.SortIncludes = FormatStyle::SI_CaseSensitive;
+
+  EXPECT_EQ("#include \"A/B.h\"\n"
+"#include \"A/b.h\"\n"
+"#include \"a/b.h\"\n"
+"#include \"B/A.h\"\n"
+"#include \"B/a.h\"\n",
+sort("#include \"B/a.h\"\n"
+ "#include \"B/A.h\"\n"
+ "#include \"A/B.h\"\n"
+ "#include \"a/b.h\"\n"
+ "#include \"A/b.h\"\n",
+ "a.h"));
+
+  Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
+  Style.IncludeCategories = {
+  {"^\"", 1, 0, false}, {"^<.*\\.h>$", 2, 0, false}, {"^<", 3, 0, false}};
+
+  StringRef UnsortedCode = "#include \"qt.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"vlib.h\"\n"
+   "#include \"Vlib.h\"\n"
+   "#include \"AST.h\"\n";
+
+  EXPECT_EQ("#include \"AST.h\"\n"
+"#include \"qt.h\"\n"
+"#include \"Vlib.h\"\n"
+"#include \"vlib.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort(UnsortedCode));
+}
+
 TEST_F(SortIncludesTest, SupportCaseInsensitiveMatching) {
   // Setup an regex for main includes so we can cover those as well.
   Style.IncludeIsMainRegex = "([-_](test|unittest))?$";
Index: clang/unittests/Format/SortImportsTestJava.cpp
===
--- clang/unittests/Format/SortImportsTestJava.cpp
+++ clang/unittests/Format/SortImportsTestJava.cpp
@@ -32,7 +32,7 @@
   SortImportsTestJava() {
 FmtStyle = getGoogleStyle(FormatStyle::LK_Java);
 FmtStyle.JavaImportGroups = {"com.test", "org", "com"};
-FmtStyle.SortIncludes = true;
+FmtStyle.SortIncludes = FormatStyle::SI_CaseInsensitive;
   }
 };
 
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15463,7 +15463,6 @@
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
   CHECK_PARSE_BOOL(Cpp11BracedListStyle);
   CHECK_PARSE_BOOL(ReflowComments);
-  CHECK_PARSE_BOOL(SortIncludes);
   CHECK_PARSE_BOOL(SortUsingDeclarations);
   CHECK_PARSE_BOOL(SpacesInParentheses);
   CHECK_PARSE_BOOL(SpacesInSquareBrackets);
@@ -15959,6 +15958,16 @@
   CHECK_PARSE("IncludeIsMainSourceRegex: 'abc$'",
   IncludeStyle.IncludeIsMainSourceRegex, "abc$");
 
+  Style.SortIncludes = FormatStyle::SI_Never;
+  CHECK_PARSE("SortIncludes: true", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: false", SortIncludes, FormatStyle::SI_Never);
+  CHECK_PARSE("SortIncludes: CaseInsensitive", SortIncludes,
+  FormatStyle::SI_CaseInsensitive);
+  CHECK_PARSE("SortIncludes: CaseSensitive", SortIncludes,
+  FormatStyle::SI_CaseSensitive);
+  CHECK_PARSE("SortIncludes: Never", SortIncludes, FormatStyle::SI_Never);
+
   Style.RawStringFormats.clear();
   std::vector ExpectedRawStringFormats = {
   {
@@ -17950,7 +17959,7 @@
 "#include \"b.h\"\n")});
 
   format::FormatStyle Style = format::getLLVMStyle();
-  Style.SortIncludes = true;
+  Style.SortIncludes = FormatStyle::SI_CaseInsensitive;
   auto FormattedReplaces = formatReplacements(Code, Replaces, Style);
   EXPECT_TRUE(static_cast(FormattedReplaces))
   << llvm::toString(FormattedReplaces.takeError()) << "\n";
Index: clang/tools/clang-format/ClangFormat.cpp

[PATCH] D95536: [clang][sema] Note decl location on missing member

2021-01-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 319820.
tbaeder added a comment.

Fixed the Lambda oddity as well.


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

https://reviews.llvm.org/D95536

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprMember.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
  clang/test/CXX/class.access/class.friend/p1.cpp
  clang/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr21xx.cpp
  clang/test/CXX/drs/dr3xx.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/special/class.copy/p28-cxx11.cpp
  clang/test/CXX/special/class.dtor/p10-0x.cpp
  clang/test/CXX/temp/temp.decls/temp.class/temp.mem.enum/p1.cpp
  clang/test/CXX/temp/temp.res/temp.local/p3.cpp
  clang/test/CXX/temp/temp.res/temp.local/p9.cpp
  clang/test/CXX/temp/temp.spec/temp.expl.spec/p19.cpp
  clang/test/Misc/diag-template.cpp
  clang/test/Modules/Inputs/redecl_namespaces_left.h
  clang/test/Modules/cxx-templates.cpp
  clang/test/Modules/module-private.cpp
  clang/test/Modules/redecl-namespaces.mm
  clang/test/OpenMP/target_map_messages.cpp
  clang/test/OpenMP/target_teams_map_messages.cpp
  clang/test/PCH/decl-attrs.cpp
  clang/test/Parser/recovery.c
  clang/test/Parser/recovery.cpp
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/Sema/anonymous-struct-union.c
  clang/test/Sema/typo-correction-ambiguity.cpp
  clang/test/Sema/typo-correction-no-hang.cpp
  clang/test/Sema/typo-correction-recursive.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/anonymous-union.cpp
  clang/test/SemaCXX/attr-cleanup.cpp
  clang/test/SemaCXX/co_await-range-for.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/conversion-function.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/cxx1y-deduced-return-type.cpp
  clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
  clang/test/SemaCXX/friend.cpp
  clang/test/SemaCXX/invalid-member-expr.cpp
  clang/test/SemaCXX/member-operator-expr.cpp
  clang/test/SemaCXX/missing-members.cpp
  clang/test/SemaCXX/nested-name-spec.cpp
  clang/test/SemaCXX/pseudo-destructors.cpp
  clang/test/SemaCXX/qualified-id-lookup.cpp
  clang/test/SemaCXX/typo-correction-delayed.cpp
  clang/test/SemaCXX/typo-correction.cpp
  clang/test/SemaCXX/unknown-type-name.cpp
  clang/test/SemaObjCXX/deduction.mm
  clang/test/SemaObjCXX/interface-return-type.mm
  clang/test/SemaTemplate/attributes.cpp
  clang/test/SemaTemplate/cxx1z-using-declaration.cpp
  clang/test/SemaTemplate/dependent-base-classes.cpp
  clang/test/SemaTemplate/instantiate-method.cpp
  clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
  clang/test/SemaTemplate/member-access-ambig.cpp
  clang/test/SemaTemplate/member-access-expr.cpp
  clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp

Index: clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
===
--- clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
+++ clang/test/SemaTemplate/ms-lookup-template-base-classes.cpp
@@ -200,7 +200,7 @@
 
 namespace PR16014 {
 
-struct A {
+struct A { // expected-note {{declared here}}
   int a;
   static int sa;
 };
@@ -226,7 +226,8 @@
 };
 
 template struct B;
-template struct C;  // expected-note-re 1+ {{in instantiation of member function 'PR16014::C::{{.*}}' requested here}}
+template struct C;  // expected-note-re 1+ {{in instantiation of member function 'PR16014::C::{{.*}}' requested here}} \
+   // expected-note 2 {{declared here}}
 
 template  struct D : T {
   struct Inner {
Index: clang/test/SemaTemplate/member-access-expr.cpp
===
--- clang/test/SemaTemplate/member-access-expr.cpp
+++ clang/test/SemaTemplate/member-access-expr.cpp
@@ -43,7 +43,7 @@
 
 }
 
-struct OtherBase { };
+struct OtherBase { }; // expected-note 2 {{declared here}}
 
 struct X1 : Base, OtherBase { 
   typedef OtherBase CrazyBase;
@@ -59,7 +59,7 @@
 }
 
 
-struct X2 {
+struct X2 { // expected-note {{declared here}}
   operator int() const;
 };
 
Index: clang/test/SemaTemplate/member-access-ambig.cpp
===
--- clang/test/SemaTemplate/member-access-ambig.cpp
+++ clang/test/SemaTemplate/member-access-ambig.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-comparison %s
 
 // PR8439
-class A
+class A // expected-note {{declared here}}
 {
 };
 
Index: clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
===
--- clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
+++ clang/test/SemaTemplate/instantiate-non-dependent-types.c

[PATCH] D95573: [ASTMatchers] Avoid pathological traversal over nested lambdas

2021-01-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

This fixes the issue with exponential traversal times for deeply nested 
lambdas. Please add a test though. For example, this one:

  void f() {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
[] {
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
}();
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95573

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


[PATCH] D95573: [ASTMatchers] Avoid pathological traversal over nested lambdas

2021-01-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks for the prompt fix, btw!




Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:2064
+  if (const auto *MD = dyn_cast(D)) {
+if (const auto *RD = MD->getParent()) {
+  if (RD->isLambda()) {

Please specify the type explicitly here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95573

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


[clang] 083d151 - Apply https://reviews.llvm.org/D42519

2021-01-28 Thread Russell Gallop via cfe-commits

Author: Russell Gallop
Date: 2021-01-07T17:37:18Z
New Revision: 083d1519465718fb7f7bbe65597ffc23e612ba19

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

LOG: Apply https://reviews.llvm.org/D42519

Tell cmake that Scudo is supported on Windows

Tell cmake that Scudo is supported on Linux

Tell MSVC that Scudo is supported

Need to check that this works on Windows

Change Windows allocator size to be 256GB

Enable scudo on Windows properly

Change literal type to avoid cl warning

Auto-add scudo and scudo_cxx when using -sanitize=scudo to help testing.

This is enough for the tests, though doesn't help as much with large programs 
like LLVM which drive the linker directly
Use same format for adding libraries as asan above

Avoid adding --gc-sections on Windows

Avoid overriding computeHardwareCRC32 on Windows.

This may cause lower performance on Windows, may need another way or
providing this on Windows.

Only enable builtins (actually required for scudo standalone) if compiler 
supports them

Tests
Rename getpagesize() to avoid naming conflict on Linux

Move setting up signal handler later as this was firing on the malloc

Remove stray change in SanitizerArgs.cpp

Port threads test from pthreads to c++11 threads for portability as new
test cxx_threads.cpp

Moved mutex.lock() up before starting other threads or they may get the
lock first.

Change to mark as unsupported on windows, not just win32

Convert some more tests to unsupported on windows instead of win32

Mark tests as unsupported

Test for minimal runtime unsupported on Windows

Unsupported on Windows as relies on LD_LIBRARY_PATH.
Or maybe could have parts of this running on Windows

Mark dealloc-race.c as unsupported on Windows as requried fork()

Clang format tests

Added: 
compiler-rt/test/scudo/cxx_threads.cpp

Modified: 
clang/lib/Driver/ToolChains/MSVC.cpp
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
compiler-rt/lib/scudo/CMakeLists.txt
compiler-rt/lib/scudo/scudo_allocator.cpp
compiler-rt/lib/scudo/scudo_crc32.cpp
compiler-rt/lib/scudo/scudo_new_delete.cpp
compiler-rt/lib/scudo/scudo_platform.h
compiler-rt/lib/scudo/scudo_tsd.h
compiler-rt/lib/scudo/scudo_tsd_shared.cpp
compiler-rt/lib/scudo/scudo_tsd_shared.inc
compiler-rt/test/scudo/dealloc-race.c
compiler-rt/test/scudo/fsanitize.c
compiler-rt/test/scudo/interface.cpp
compiler-rt/test/scudo/lit.cfg.py
compiler-rt/test/scudo/malloc.cpp
compiler-rt/test/scudo/memalign.c
compiler-rt/test/scudo/mismatch.cpp
compiler-rt/test/scudo/overflow.c
compiler-rt/test/scudo/preload.cpp
compiler-rt/test/scudo/rss.c
compiler-rt/test/scudo/secondary.c
compiler-rt/test/scudo/symbols.test
compiler-rt/test/scudo/threads.c
compiler-rt/test/scudo/tsd_destruction.c
compiler-rt/test/scudo/valloc.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index f4b7a57e0bb7..c954d6d9d3b7 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -446,6 +446,13 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 }
   }
 
+  if (TC.getSanitizerArgs().needsScudoRt()) {
+for (const auto &Lib : {"scudo", "scudo_cxx"}) {
+  CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib));
+}
+CmdArgs.push_back(Args.MakeArgString("-include:malloc"));
+  }
+
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
   // Control Flow Guard checks
@@ -1403,6 +1410,7 @@ SanitizerMask MSVCToolChain::getSupportedSanitizers() 
const {
   Res |= SanitizerKind::PointerSubtract;
   Res |= SanitizerKind::Fuzzer;
   Res |= SanitizerKind::FuzzerNoLink;
+  Res |= SanitizerKind::Scudo;
   Res &= ~SanitizerKind::CFIMFCall;
   return Res;
 }

diff  --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index d13e75e41685..eb266ca3a61c 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -58,6 +58,7 @@ check_c_compiler_flag(-ffreestanding 
COMPILER_RT_HAS_FFREESTANDING_FLAG)
 check_c_compiler_flag(-std=c11   COMPILER_RT_HAS_STD_C11_FLAG)
 check_cxx_compiler_flag(-fPICCOMPILER_RT_HAS_FPIC_FLAG)
 check_cxx_compiler_flag(-fPIECOMPILER_RT_HAS_FPIE_FLAG)
+check_cxx_compiler_flag(-fbuiltinCOMPILER_RT_HAS_FBUILTIN_FLAG)
 check_cxx_compiler_flag(-fno-builtin COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
 check_cxx_compiler_flag(-fno-exceptions  
COMPILER_RT_HAS_FNO_EXCEPTIONS_FLAG)
 check_cxx_compiler_flag(-fomit-frame-pointer 
COMPILER_RT_HAS_FOMIT_FRAME_POINTER_FLAG)
@@ -764,7 +765,7 @@ else()
 endif()
 
 if (COMPILER_RT_HAS_

[PATCH] D95017: [clang-format] add case aware include sorting

2021-01-28 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius 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/D95017/new/

https://reviews.llvm.org/D95017

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


[PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-01-28 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

In D95119#2525925 , @MaskRay wrote:

> `#!/usr/bin/env perl -w` (2 arguments) unfortunately does not work on Linux 
> and many other systems.

Not sure if there's a similar thing for `awk`, but I think `use warnings` is 
preferred nowadays over `perl -w`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95119

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


[PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-01-28 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere requested changes to this revision.
JDevlieghere added a comment.
This revision now requires changes to proceed.

Oops, didn't mean to accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95119

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:349-351
+triple = ""
+if hasattr(self.config, 'host_triple'):
+triple = self.config.host_triple

jhenderson wrote:
> abhina.sreeskantharajan wrote:
> > jhenderson wrote:
> > > I'm concerned that someone might start using these substitutions in a 
> > > project for the first time, and get confused why they don't work on 
> > > non-windows platforms. Maybe the solution is simply to require 
> > > LLVM_HOST_TRIPLE to be set in all projects, i.e. go back to what you were 
> > > doing before, and letting python fail if it isn't set.
> > > 
> > > Happy to hear other ideas too.
> > I think using sys.platform or platform.system() could be a better 
> > alternative. What do you think?
> Makes sense to me. Slight issue: cygwin on Windows uses `cygwin`. What error 
> message does it produce though?
I tested this out. On a cygwin terminal on Windows it emits the same error 
message as Linux so it should take the else path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95607: Fix traversal with hasDescendant into lambdas

2021-01-28 Thread Stephen Kelly via Phabricator via cfe-commits
steveire created this revision.
steveire added a reviewer: aaron.ballman.
steveire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95607

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -3184,6 +3184,12 @@
   float i = 42.0;
 }
 
+void func15() {
+  int count = 0;
+  auto l = [&] { ++count; };
+  (void)l;
+}
+
 )cpp";
 
   EXPECT_TRUE(
@@ -3368,6 +3374,15 @@
functionDecl(hasName("func14"), hasDescendant(floatLiteral(,
   langCxx20OrLater()));
 
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   compoundStmt(
+   hasDescendant(varDecl(hasName("count")).bind("countVar")),
+   hasDescendant(
+   
declRefExpr(to(varDecl(equalsBoundNode("countVar"))),
+  langCxx20OrLater()));
+
   Code = R"cpp(
 void foo() {
 int explicit_captured = 0;
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -295,7 +295,7 @@
 if (!match(*Node->getBody()))
   return false;
 
-return true;
+return VisitorBase::TraverseStmt(Node->getBody());
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -3184,6 +3184,12 @@
   float i = 42.0;
 }
 
+void func15() {
+  int count = 0;
+  auto l = [&] { ++count; };
+  (void)l;
+}
+
 )cpp";
 
   EXPECT_TRUE(
@@ -3368,6 +3374,15 @@
functionDecl(hasName("func14"), hasDescendant(floatLiteral(,
   langCxx20OrLater()));
 
+  EXPECT_TRUE(matches(
+  Code,
+  traverse(TK_IgnoreUnlessSpelledInSource,
+   compoundStmt(
+   hasDescendant(varDecl(hasName("count")).bind("countVar")),
+   hasDescendant(
+   declRefExpr(to(varDecl(equalsBoundNode("countVar"))),
+  langCxx20OrLater()));
+
   Code = R"cpp(
 void foo() {
 int explicit_captured = 0;
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -295,7 +295,7 @@
 if (!match(*Node->getBody()))
   return false;
 
-return true;
+return VisitorBase::TraverseStmt(Node->getBody());
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319839.
abhina.sreeskantharajan added a comment.

Address syntax comments, and add a list of supported error code substitutions 
in the guide.

If these changes are ok, I would like to start making changes to all affected 
testcases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/ELF/basic.s
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,16 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   The following error codes are supported: ENOENT, EISDIR.
+
+   Example: ``Linux %errc_ENOENT: No such file or directory``
+
+   Example: ``Windows %errc_ENOENT: no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MI

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-01-28 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 319840.
whisperity marked 9 inline comments as done.
whisperity added a comment.

- NFC Code style and organisation fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-easily-swappable-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-ignore.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len3.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 3}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""} \
+// RUN:  ]}' --
+
+int add(int Left, int Right) { return Left + Right; } // NO-WARN: Only 2 parameters.
+
+int magic(int Left, int Right, int X, int Y) { return 0; }
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 4 adjacent parameters of 'magic' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:15: note: the first parameter in the range is 'Left'
+// CHECK-MESSAGES: :[[@LINE-3]]:43: note: the last parameter in the range is 'Y'
+
+void multipleDistinctTypes(int I, int J, int K,
+   long L, long M,
+   double D, double E, double F) {}
+// CHECK-MESSAGES: :[[@LINE-3]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('int')
+// CHECK-MESSAGES: :[[@LINE-4]]:32: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-5]]:46: note: the last parameter in the range is 'K'
+// NO-WARN: The [long, long] range is length of 2.
+// CHECK-MESSAGES: :[[@LINE-5]]:28: warning: 3 adjacent parameters of 'multipleDistinctTypes' of similar type ('double')
+// CHECK-MESSAGES: :[[@LINE-6]]:35: note: the first parameter in the range is 'D'
+// CHECK-MESSAGES: :[[@LINE-7]]:55: note: the last parameter in the range is 'F'
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-easily-swappable-parameters-len2.cpp
@@ -0,0 +1,141 @@
+// RUN: %check_clang_tidy %s bugprone-easily-swappable-parameters %t \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: bugprone-easily-swappable-parameters.MinimumLength, value: 2}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterNames, value: ""}, \
+// RUN: {key: bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes, value: ""} \
+// RUN:  ]}' --
+
+#define assert(X)
+
+void declaration(int Param, int Other); // NO-WARN: No chance to change this function.
+
+struct S {};
+
+S *allocate() { return nullptr; }   // NO-WARN: 0 parameters.
+void allocate(S **Out) {}   // NO-WARN: 1 parameter.
+bool operator<(const S &LHS, const S &RHS) { return true; } // NO-WARN: Operator.
+
+void redeclChain(int, int, int);
+void redeclChain(int I, int, int);
+void redeclChain(int, int J, int);
+void redeclChain(int I, int J, int K) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 3 adjacent parameters of 'redeclChain' of similar type ('int') are easily swapped by mistake [bugprone-easily-swappable-parameters]
+// CHECK-MESSAGES: :[[@LINE-2]]:22: note: the first parameter in the range is 'I'
+// CHECK-MESSAGES: :[[@LINE-3]]:36: note: the last parameter in the range is 'K'
+
+void copyMany(S *Src, S *Dst, unsigned Num) {}
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 2 adjacent parameters of 'copyMany' of similar type ('S *')
+// CHECK-MESSAGES: :[[@LINE-2]]:18: note: the first parameter in the range is 'Src'
+// CHECK-MESSAGES: :[[@LINE-3]]:26: note: the last parameter in the range is 'Dst'
+
+template 
+bool binaryPredicate(T L, U R) { return false; } // NO-WARN: Distinct types in template.
+
+te

[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-01-28 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:284
+/// The default value for the MinimumLength check option.
+static constexpr unsigned DefaultMinimumLength = 2;
+

aaron.ballman wrote:
> It might be good to move this to a more prominent location since it's a 
> default value.
Moved it to the top.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:302
+ "FowardIt", "bidirit", "BidirIt", "constiterator",
+ "const_iterator", "Const_Iterator", "Constiterator",
+ "ConstIterator"});

aaron.ballman wrote:
> `reverse_iterator` and `reverse_const_iterator` too?
> 
> How about ranges?
> How about ranges?

I would like to say that having an `f(RangeTy, RangeTy)` is //exactly// as 
problematic (especially if both are non-const) as having `f(int, int)` or 
`f(void*, void*)`, and should be taken care of the same way (relatedness 
heuristic, name heuristic).
The idea behind ignoring iterator-ly named things was that //"Iterators more 
often than not comes in pairs and you can't(*) do anything about it"//.

(*): Use ranges. Similarly how `draw(int x, int y)` is `draw(Point2D)` if we 
are enhancing type safety.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

One nit, but otherwise looks good to me, thanks! Please go ahead with the other 
test updates. Do you plan on doing them in this patch?




Comment at: llvm/docs/TestingGuide.rst:545
+
+   The following error codes are supported: ENOENT, EISDIR.
+

Adding "currently" implies to me that someone could add to the list easily.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-28 Thread Faris via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 319842.
FarisRehman marked 12 inline comments as done.
FarisRehman added a comment.

Address review comment

Address the review comment by @awarzynski

Summary of changes:

- Shorten help text
- Add method AddFortranDialectOptions to Flang.cpp
- Change style of code to use quaternary operator
- Update regression tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/Inputs/fixed-form-test.f
  flang/test/Flang-Driver/Inputs/fixed-line-length-test.f
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/fixed-free-flag.f90
  flang/test/Flang-Driver/fixed-line-length.f90

Index: flang/test/Flang-Driver/fixed-line-length.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-line-length.f90
@@ -0,0 +1,50 @@
+! Ensure argument -ffixed-line-length-n works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -E -ffixed-line-length--2 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH
+! RUN: not %flang-new -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!
+! RUN: %flang-new -fc1 -E %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=DEFAULTLENGTH
+! RUN: not %flang-new -fc1 -E -ffixed-line-length--2 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=NEGATIVELENGTH
+! RUN: not %flang-new -fc1 -E -ffixed-line-length-3 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=INVALIDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-none %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-0 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=UNLIMITEDLENGTH
+! RUN: %flang-new -fc1 -E -ffixed-line-length-13 %S/Inputs/fixed-line-length-test.f  2>&1 | FileCheck %s --check-prefix=LENGTH13
+
+!-
+! EXPECTED OUTPUT WITH DEFAULT LENGTH
+!-
+! The line should be trimmed to 72 characters when reading based on the default value of fixed line length.
+! DEFAULTLENGTH: program{{(a{58})}}
+
+!-
+! EXPECTED OUTPUT WITH A NEGATIVE LENGTH
+!-
+! NEGATIVELENGTH: invalid value '-2' in 'ffixed-line-length-','value must be 'none' or a non-negative integer'
+
+!-
+! EXPECTED OUTPUT WITH LENGTH LESS THAN 7
+!-
+! INVALIDLENGTH: invalid value '3' in 'ffixed-line-length-','value must be at least seven'
+
+!---
+! EXPECTED OUTPUT WITH UNLIMITED LENGTH
+!---
+! The line should not be trimmed and so 73 characters (including spaces) should be read.
+! UNLIMITEDLENGTH: program{{(a{59})}}
+
+!
+! EXPECTED OUTPUT WITH LENGTH 13
+!
+! LENGTH13: program
Index: flang/test/Flang-Driver/fixed-free-flag.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fixed-free-flag.f90
@@ -0,0 +1,25 @@
+! Ensure arguments -ffree-form and -ffixed-form work as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -ffree-form %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=FREEFORM
+! RUN: %flang-new -fsyntax-only -ffixed-form %S/Inputs/free-form-test.f90 2>&1 | FileCheck %s --check-prefix=FIXEDFORM
+
+!
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!---

[clang] 0024efc - Relax test expectations in debug-info-gline-tables-only-codeview.cpp

2021-01-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-01-28T14:40:11+01:00
New Revision: 0024efc69ea6cd0b630cd11cef5991b7edb73ffc

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

LOG: Relax test expectations in debug-info-gline-tables-only-codeview.cpp

To make it pass also on 32-bit Windows, see PR48920.

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp 
b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
index 27ac682c10f5..409b62da62c1 100644
--- a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -25,6 +25,6 @@ void test() {
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
-  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
+  // CHECK: ![[MTYPE]] = !DISubroutineType({{.*}}types: !{{.*}})
   c.m();
 }



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


[clang] 0024efc - Relax test expectations in debug-info-gline-tables-only-codeview.cpp

2021-01-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-01-28T14:40:11+01:00
New Revision: 0024efc69ea6cd0b630cd11cef5991b7edb73ffc

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

LOG: Relax test expectations in debug-info-gline-tables-only-codeview.cpp

To make it pass also on 32-bit Windows, see PR48920.

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp 
b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
index 27ac682c10f5..409b62da62c1 100644
--- a/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
+++ b/clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
@@ -25,6 +25,6 @@ void test() {
   // CHECK: ![[C]] = !DICompositeType(tag: DW_TAG_structure_type, name: "C",
   // CHECK-SAME:  flags: DIFlagFwdDecl
   // CHECK-NOT: identifier
-  // CHECK: ![[MTYPE]] = !DISubroutineType(types: !{{.*}})
+  // CHECK: ![[MTYPE]] = !DISubroutineType({{.*}}types: !{{.*}})
   c.m();
 }



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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2527961 , @jhenderson wrote:

> One nit, but otherwise looks good to me, thanks! Please go ahead with the 
> other test updates. Do you plan on doing them in this patch?

This was my initial thought. But if it's preferred to create a second patch to 
make the remaining changes to affected testcases, I have no issue with doing 
that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

2021-01-28 Thread Faris via Phabricator via cfe-commits
FarisRehman marked an inline comment as done.
FarisRehman added inline comments.



Comment at: flang/lib/Frontend/CompilerInstance.cpp:151-158
+  if (invoc.frontendOpts().fortranForm_ == FortranForm::Unknown) {
+// Switch between fixed and free form format based on the input file
+// extension. Ideally we should have all Fortran options set before
+// entering this loop (i.e. processing any input files). However, we
+// can't decide between fixed and free form based on the file extension
+// earlier than this.
+invoc.fortranOpts().isFixedForm = fif.IsFixedForm();

awarzynski wrote:
> Hm, unwanted TABs? 
> 
> Also, please keep note of: https://reviews.llvm.org/D95464 (there should be 
> no conflicts from what I can tell).
I believe this is just Phabricator showing the comments have been indented


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460

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


[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319844.
abhina.sreeskantharajan added a comment.

Add currently in TestingGuide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/ELF/basic.s
  llvm/docs/TestingGuide.rst
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/llvm-ar/move.test
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/llvm-ar/move.test
===
--- llvm/test/tools/llvm-ar/move.test
+++ llvm/test/tools/llvm-ar/move.test
@@ -82,9 +82,9 @@
 ## Member does not exist:
 # RUN: llvm-ar rc %t/missing.a %t/1.o %t/2.o %t/3.o
 # RUN: not llvm-ar m %t/missing.a %t/missing.txt 2>&1 \
-# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt
+# RUN:   | FileCheck %s --check-prefix=MISSING-FILE -DFILE=%t/missing.txt -DMSG=%errc_ENOENT
 
-# MISSING-FILE: error: [[FILE]]: {{[nN]}}o such file or directory
+# MISSING-FILE: error: [[FILE]]: [[MSG]]
 
 --- !ELF
 FileHeader:
Index: llvm/test/Object/directory.ll
===
--- llvm/test/Object/directory.ll
+++ llvm/test/Object/directory.ll
@@ -1,6 +1,6 @@
 ;RUN: rm -rf %t && mkdir -p %t
-;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck %s
-;CHECK: .: {{I|i}}s a directory
+;RUN: not llvm-ar r %t/test.a . 2>&1 | FileCheck -DMSG=%errc_EISDIR %s
+;CHECK: .: [[MSG]]
 
 ;RUN: rm -f %t/test.a
 ;RUN: touch %t/a-very-long-file-name
Index: llvm/test/Object/archive-extract.test
===
--- llvm/test/Object/archive-extract.test
+++ llvm/test/Object/archive-extract.test
@@ -57,5 +57,5 @@
 RUN: llvm-ar p %p/Inputs/thin.a evenlen | FileCheck %s --check-prefix=EVENLEN
 EVENLEN: evenlen
 
-RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --check-prefix=MISSING
-MISSING: error: {{N|n}}o such file or directory
+RUN: not llvm-ar p %p/Inputs/thin-path.a t/test2.o 2>&1 | FileCheck %s --DMSG=%errc_ENOENT --check-prefix=MISSING
+MISSING: error: [[MSG]]
Index: llvm/docs/TestingGuide.rst
===
--- llvm/docs/TestingGuide.rst
+++ llvm/docs/TestingGuide.rst
@@ -537,6 +537,16 @@
 
Example: ``%:s: C\Desktop Files\foo_test.s.tmp``
 
+``%errc_``
+
+ Some error messages may be substituted to allow different spellings
+ based on the host platform.
+
+   The following error codes are currently supported: ENOENT, EISDIR.
+
+   Example: ``Linux %errc_ENOENT: No such file or directory``
+
+   Example: ``Windows %errc_ENOENT: no such file or directory``
 
 **LLVM-specific substitutions:**
 
Index: lld/test/ELF/basic.s
===
--- lld/test/ELF/basic.s
+++ lld/test/ELF/basic.s
@@ -219,8 +219,8 @@
 # INVRSP: invalid response file quoting: patatino
 
 # RUN: not ld.lld %t.foo -o /dev/null 2>&1 | \
-# RUN:  FileCheck --check-prefix=MISSING %s
-# MISSING: cannot open {{.*}}.foo: {{[Nn]}}o such file or directory
+# RUN:  FileCheck -DMSG=%errc_ENOENT --check-prefix=MISSING %s
+# MISSING: cannot open {{.*}}.foo: [[MSG]]
 
 # RUN: not ld.lld -o /dev/null 2>&1 | \
 # RUN:  FileCheck --check-prefix=NO_INPUT %s
Index: clang/te

[PATCH] D95246: [SystemZ][z/OS] Fix No such file or directory expression error matching in lit tests - continued

2021-01-28 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2527999 , 
@abhina.sreeskantharajan wrote:

> In D95246#2527961 , @jhenderson 
> wrote:
>
>> One nit, but otherwise looks good to me, thanks! Please go ahead with the 
>> other test updates. Do you plan on doing them in this patch?
>
> This was my initial thought. But if it's preferred to create a second patch 
> to make the remaining changes to affected testcases, I have no issue with 
> doing that.

I'm happy either way, whichever you prefer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[clang-tools-extra] dfd2374 - [clang-tidy] Remove unnecessary #ifdef

2021-01-28 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2021-01-28T15:00:07+01:00
New Revision: dfd2374ab6c393d675e7b4583bc279b2d7e9b51f

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

LOG: [clang-tidy] Remove unnecessary #ifdef

The code was likely used to verify other changes in 
c3b9d85bd4b7249af9efe3594c6c152a032f83f8.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 346fa66a662a..48c5b0b2f4b7 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -37,10 +37,6 @@
 using namespace clang;
 using namespace tidy;
 
-#ifdef LLVM_CLANG_AST_ATTR_H
-//#error
-#endif
-
 namespace {
 class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
 public:



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


[PATCH] D94865: [ASTMatchers] Add callOrConstruct matcher

2021-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM aside from the list order nit. Thanks!




Comment at: clang/lib/ASTMatchers/Dynamic/Registry.cpp:155
   REGISTER_MATCHER(callExpr);
+  REGISTER_MATCHER(invocation);
   REGISTER_MATCHER(caseStmt);

Please keep this sorted alphabetically.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94865

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


[clang-tools-extra] dfd2374 - [clang-tidy] Remove unnecessary #ifdef

2021-01-28 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2021-01-28T15:00:07+01:00
New Revision: dfd2374ab6c393d675e7b4583bc279b2d7e9b51f

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

LOG: [clang-tidy] Remove unnecessary #ifdef

The code was likely used to verify other changes in 
c3b9d85bd4b7249af9efe3594c6c152a032f83f8.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 346fa66a662a..48c5b0b2f4b7 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -37,10 +37,6 @@
 using namespace clang;
 using namespace tidy;
 
-#ifdef LLVM_CLANG_AST_ATTR_H
-//#error
-#endif
-
 namespace {
 class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
 public:



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


[PATCH] D95616: Change extension handling for -fdeclare-opencl-builtins

2021-01-28 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: jfb, yaxunl.
svenvh requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Until now, the `-fdeclare-opencl-builtins` option behaved differently
compared to inclusion of `opencl-c.h`: builtins that are part of an
extension were only available if the extension was enabled using the
corresponding pragma.

Builtins that belong to an extension are guarded using a preprocessor
macro (that is named after the extension) in `opencl-c.h`.  Align the
behaviour of `-fdeclare-opencl-builtins` with this.

This is inspired on the draft of https://reviews.llvm.org/D91538


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95616

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -38,26 +38,6 @@
 
   prefetch(a, 2);
 
-  atom_add((volatile __global int *)global_p, i);
-#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_1_1
-// expected-error@-2{{no matching function for call to 'atom_add'}}
-
-// There are two potential definitions of the function "atom_add", both are
-// currently disabled because the associated extension is disabled.
-// expected-note@-6{{candidate function not viable: cannot pass pointer to 
address space '__global' as a pointer to address space '__local' in 1st 
argument}}
-// expected-note@-7{{candidate function not viable: no known conversion}}
-// expected-note@-8{{candidate function not viable: no known conversion}}
-// expected-note@-9{{candidate function not viable: no known conversion}}
-// expected-note@-10{{candidate unavailable as it requires OpenCL extension 
'cl_khr_global_int32_base_atomics' to be enabled}}
-// expected-note@-11{{candidate unavailable as it requires OpenCL extension 
'cl_khr_global_int32_base_atomics' to be enabled}}
-// expected-note@-12{{candidate unavailable as it requires OpenCL extension 
'cl_khr_int64_base_atomics' to be enabled}}
-// expected-note@-13{{candidate unavailable as it requires OpenCL extension 
'cl_khr_int64_base_atomics' to be enabled}}
-#endif
-
-#if __OPENCL_C_VERSION__ < CL_VERSION_1_1
-#pragma OPENCL EXTENSION cl_khr_global_int32_base_atomics : enable
-#endif
-
   atom_add((volatile __global int *)global_p, i);
   atom_cmpxchg((volatile __global unsigned int *)global_p, ui, ui);
 }
@@ -146,11 +126,9 @@
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if defined(__OPENCL_CPP_VERSION__)
-  // expected-error@-2{{no matching function for call to 'get_sub_group_size'}}
-  // expected-note@-3{{candidate unavailable as it requires OpenCL extension 
'cl_khr_subgroups' to be enabled}}
-#else
-  // expected-error@-5{{use of declaration 'get_sub_group_size' requires 
cl_khr_subgroups extension to be enabled}}
+#if __OPENCL_C_VERSION__ <= CL_VERSION_1_2 && !defined(__OPENCL_CPP_VERSION__)
+  // expected-error@-2{{implicit declaration of function 'get_sub_group_size' 
is invalid in OpenCL}}
+  // expected-error@-3{{implicit conversion changes signedness}}
 #endif
 }
 
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -743,18 +743,6 @@
   }
 }
 
-/// Add extensions to the function declaration.
-/// \param S (in/out) The Sema instance.
-/// \param BIDecl (in) Description of the builtin.
-/// \param FDecl (in/out) FunctionDecl instance.
-static void AddOpenCLExtensions(Sema &S, const OpenCLBuiltinStruct &BIDecl,
-FunctionDecl *FDecl) {
-  // Fetch extension associated with a function prototype.
-  StringRef E = FunctionExtensionTable[BIDecl.Extension];
-  if (E != "")
-S.setOpenCLExtensionForDecl(FDecl, E);
-}
-
 /// When trying to resolve a function name, if isOpenCLBuiltin() returns a
 /// non-null  pair, then the name is referencing an OpenCL
 /// builtin function.  Add all candidate signatures to the LookUpResult.
@@ -790,6 +778,13 @@
 (OpenCLVersion >= OpenCLBuiltin.MaxVersion))
   continue;
 
+// Ignore this builtin function if it carries an extension macro that is
+// not defined. This indicates that the extension is not supported by the
+// target, so the builtin function should not be available.
+StringRef Ext = FunctionExtensionTable[OpenCLBuiltin.Extension];
+if (!Ext.empty() && !S.getPreprocessor().isMacroDefined(Ext))
+  continue;
+
 SmallVector RetTypes;
 SmallVector, 5> ArgTypes;
 
@@ -843,8 +838,6 @@
   if (!S.getLangOpts().OpenCLCPlusPlus)
 NewOpenCLBuiltin->addAttr(OverloadableAttr::CreateImplicit(Context));
 
-  AddOpenCLExtensions(S, OpenC

[PATCH] D95523: [OpenCL] Add cl_khr_subgroup_ballot to TableGen BIFs

2021-01-28 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 319860.
svenvh added a comment.

Add test after rebasing on dependent commit (D95616 
).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95523

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -30,6 +30,11 @@
 typedef int int4 __attribute__((ext_vector_type(4)));
 typedef uint uint4 __attribute__((ext_vector_type(4)));
 typedef long long2 __attribute__((ext_vector_type(2)));
+
+// Enable extensions that are enabled in opencl-c-base.h.
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#define cl_khr_subgroup_ballot 1
+#endif
 #endif
 
 kernel void test_pointers(volatile global void *global_p, global const int4 
*a) {
@@ -132,6 +137,14 @@
 #endif
 }
 
+kernel void extended_subgroup(global uint4 *out) {
+  out[0] = get_sub_group_eq_mask();
+#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(__OPENCL_CPP_VERSION__)
+  // expected-error@-2{{implicit declaration of function 
'get_sub_group_eq_mask' is invalid in OpenCL}}
+  // expected-error@-3{{implicit conversion changes signedness}}
+#endif
+}
+
 kernel void basic_vector_data() {
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
   generic void *generic_p;
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -53,6 +53,7 @@
 // FunctionExtension definitions.
 def FuncExtNone  : FunctionExtension<"">;
 def FuncExtKhrSubgroups  : 
FunctionExtension<"cl_khr_subgroups">;
+def FuncExtKhrSubgroupBallot : 
FunctionExtension<"cl_khr_subgroup_ballot">;
 def FuncExtKhrGlobalInt32BaseAtomics : 
FunctionExtension<"cl_khr_global_int32_base_atomics">;
 def FuncExtKhrGlobalInt32ExtendedAtomics : 
FunctionExtension<"cl_khr_global_int32_extended_atomics">;
 def FuncExtKhrLocalInt32BaseAtomics  : 
FunctionExtension<"cl_khr_local_int32_base_atomics">;
@@ -344,6 +345,7 @@
 // GenType definitions for multiple base types (e.g. all floating point types,
 // or all integer types).
 // All types
+def AGenType1  : GenericType<"AGenType1", TLAll, Vec1>;
 def AGenTypeN  : GenericType<"AGenTypeN", TLAll, VecAndScalar>;
 def AGenTypeNNoScalar  : GenericType<"AGenTypeNNoScalar", TLAll, 
VecNoScalar>;
 // All integer
@@ -1486,6 +1488,44 @@
   }
 }
 
+// OpenCL Extension v3.0 s38 - Extended Subgroup Functions
+
+// Section 38.4.1 - cl_khr_subgroup_extended_types
+// TODO
+
+// Section 38.5.1 - cl_khr_subgroup_non_uniform_vote
+// TODO
+
+// Section 38.6.1 - cl_khr_subgroup_ballot
+let Extension = FuncExtKhrSubgroupBallot in {
+  def : Builtin<"sub_group_non_uniform_broadcast", [AGenTypeN, AGenTypeN, 
UInt]>;
+  def : Builtin<"sub_group_broadcast_first", [AGenType1, AGenType1]>;
+  def : Builtin<"sub_group_ballot", [VectorType, Int]>;
+  def : Builtin<"sub_group_inverse_ballot", [Int, VectorType], 
Attr.Const>;
+  def : Builtin<"sub_group_ballot_bit_extract", [Int, VectorType, 
UInt], Attr.Const>;
+  def : Builtin<"sub_group_ballot_bit_count", [UInt, VectorType], 
Attr.Const>;
+  def : Builtin<"sub_group_ballot_inclusive_scan", [UInt, VectorType]>;
+  def : Builtin<"sub_group_ballot_exclusive_scan", [UInt, VectorType]>;
+  def : Builtin<"sub_group_ballot_find_lsb", [UInt, VectorType]>;
+  def : Builtin<"sub_group_ballot_find_msb", [UInt, VectorType]>;
+
+  foreach op = ["eq", "ge", "gt", "le", "lt"] in {
+def : Builtin<"get_sub_group_" # op # "_mask", [VectorType], 
Attr.Const>;
+  }
+}
+
+// Section 38.7.1 - cl_khr_subgroup_non_uniform_arithmetic
+// TODO
+
+// Section 38.8.1 - cl_khr_subgroup_shuffle
+// TODO
+
+// Section 38.9.1 - cl_khr_subgroup_shuffle_relative
+// TODO
+
+// Section 38.10.1 - cl_khr_subgroup_clustered_reduce
+// TODO
+
 //
 // Arm extensions.
 let Extension = ArmIntegerDotProductInt8 in {


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -30,6 +30,11 @@
 typedef int int4 __attribute__((ext_vector_type(4)));
 typedef uint uint4 __attribute__((ext_vector_type(4)));
 typedef long long2 __attribute__((ext_vector_type(2)));
+
+// Enable extensions that are enabled in opencl-c-base.h.
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+#define cl_khr_subgroup_ballot 1
+#endif
 #endif
 
 kernel void test_pointers(volatile global void *global

[PATCH] D95396: Improve static_assert/_Static_assert diagnostics

2021-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 319862.
aaron.ballman added a comment.

Rebasing.


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

https://reviews.llvm.org/D95396

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/static_assert.c
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/static-assert.cpp

Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
 
 int f(); // expected-note {{declared here}}
 
Index: clang/test/Sema/static-assert.c
===
--- clang/test/Sema/static-assert.c
+++ clang/test/Sema/static-assert.c
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fms-compatibility -DMS -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fms-compatibility -DMS -fsyntax-only -verify=expected,ms %s
 // RUN: %clang_cc1 -std=c99 -pedantic -fsyntax-only -verify=expected,ext %s
 // RUN: %clang_cc1 -xc++ -std=c++11 -pedantic -fsyntax-only -verify=expected,ext,cxx %s
 
@@ -13,7 +13,7 @@
// ext-warning {{'_Static_assert' is a C11 extension}}
 
 #ifdef MS
-static_assert(1, "1 is nonzero");
+static_assert(1, "1 is nonzero"); // ms-warning {{'static_assert' is spelled '_Static_assert' in C; consider including }}
 #endif
 
 void foo(void) {
@@ -21,7 +21,7 @@
   _Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
  // ext-warning {{'_Static_assert' is a C11 extension}}
 #ifdef MS
-  static_assert(1, "1 is nonzero");
+  static_assert(1, "1 is nonzero"); // ms-warning {{'static_assert' is spelled '_Static_assert'}}
 #endif
 }
 
@@ -34,7 +34,7 @@
   _Static_assert(0, "0 is nonzero"); // expected-error {{static_assert failed "0 is nonzero"}} \
  // ext-warning {{'_Static_assert' is a C11 extension}}
 #ifdef MS
-  static_assert(1, "1 is nonzero");
+  static_assert(1, "1 is nonzero"); // ms-warning {{'static_assert' is spelled '_Static_assert'}}
 #endif
 };
 
Index: clang/test/Parser/static_assert.c
===
--- /dev/null
+++ clang/test/Parser/static_assert.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -DTEST_SPELLING -verify=c2x %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -DTEST_SPELLING -fms-compatibility -verify=c2x-ms %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wc89-c99-c11-c17-compat -verify=c2x-compat %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -verify=c99-pedantic %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify=cxx17 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -pedantic -verify=cxx17-pedantic -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify=cxx98 -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -pedantic -verify=cxx98-pedantic -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++98-c++11-c++14-compat -verify=cxx17-compat -x c++ %s
+
+// c99-no-diagnostics
+// cxx17-no-diagnostics
+// cxx98-no-diagnostics
+
+#ifdef TEST_SPELLING
+// Only test the C++ spelling in C mode in some of the tests, to reduce the
+// amount of diagnostics to have to check. This spelling is allowed in MS-
+// compatibility mode in C, but otherwise produces errors.
+static_assert(1, ""); // c2x-error {{expected parameter declarator}} \
+  // c2x-error {{expected ')'}} \
+  // c2x-note {{to match this '('}} \
+  // c2x-warning {{type specifier missing, defaults to 'int'}} \
+  // c2x-ms-warning {{'static_assert' is spelled '_Static_assert' in C; consider including }}
+#endif
+
+// We support _Static_assert as an extension in older C modes and in all C++
+// modes, but only as a pedantic warning.
+_Static_assert(1, ""); // c99-pedantic-warning {{'_Static_assert' is a C11 extension}} \
+   // cxx17-pedantic-warning {{'_Static_assert' is a C11 extension}} \
+   // cxx98-pedantic-warning {{'_Static_assert' is a C11 extension}}
+
+// _Static_assert without a message has more complex diagnostic logic:
+//   * In C++17 or C2x mode, it's supported by default.
+//   * But there is a special compat warning flag to warn about portability to
+// older standards.
+//   * In older standard pedantic modes, warn about supporting without a
+// message as an extension.
+_Static_assert(1); // c99-pedantic-warning {{'_Static_assert' with no m

[PATCH] D94472: [clang][cli] Command line round-trip for HeaderSearch options

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 319868.
jansvoboda11 added a comment.

Ensure Diags get used only once, add disabling flag, clean up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/ArgList.h
  llvm/lib/Option/ArgList.cpp

Index: llvm/lib/Option/ArgList.cpp
===
--- llvm/lib/Option/ArgList.cpp
+++ llvm/lib/Option/ArgList.cpp
@@ -90,11 +90,22 @@
 }
 
 std::vector ArgList::getAllArgValues(OptSpecifier Id) const {
+  recordQueriedOpts(Id);
   SmallVector Values;
   AddAllArgValues(Values, Id);
   return std::vector(Values.begin(), Values.end());
 }
 
+void ArgList::AddAllArgsExcept(ArgStringList &Output,
+   const DenseSet &ExcludeIds) const {
+  for (const Arg *Arg : *this) {
+if (!ExcludeIds.contains(Arg->getOption().getID())) {
+  Arg->claim();
+  Arg->render(*this, Output);
+}
+  }
+}
+
 void ArgList::AddAllArgsExcept(ArgStringList &Output,
ArrayRef Ids,
ArrayRef ExcludeIds) const {
Index: llvm/include/llvm/Option/ArgList.h
===
--- llvm/include/llvm/Option/ArgList.h
+++ llvm/include/llvm/Option/ArgList.h
@@ -137,6 +137,16 @@
   /// The first and last index of each different OptSpecifier ID.
   DenseMap OptRanges;
 
+  /// The OptSpecifiers that were queried from this argument list.
+  mutable DenseSet QueriedOpts;
+
+  /// Record the queried OptSpecifiers.
+  template 
+  void recordQueriedOpts(OptSpecifiers... Ids) const {
+SmallVector OptsSpecifiers({toOptSpecifier(Ids).getID()...});
+QueriedOpts.insert(OptsSpecifiers.begin(), OptsSpecifiers.end());
+  }
+
   /// Get the range of indexes in which options with the specified IDs might
   /// reside, or (0, 0) if there are no such options.
   OptRange getRange(std::initializer_list Ids) const;
@@ -203,6 +213,7 @@
   template
   iterator_range>
   filtered(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.begin() + Range.first;
 auto E = Args.begin() + Range.second;
@@ -214,6 +225,7 @@
   template
   iterator_range>
   filtered_reverse(OptSpecifiers ...Ids) const {
+recordQueriedOpts(Ids...);
 OptRange Range = getRange({toOptSpecifier(Ids)...});
 auto B = Args.rend() - Range.second;
 auto E = Args.rend() - Range.first;
@@ -308,6 +320,10 @@
   A->render(*this, Output);
   }
 
+  /// AddAllArgsExcept - Render all arguments not matching any of the excluded
+  /// ids.
+  void AddAllArgsExcept(ArgStringList &Output,
+const DenseSet &ExcludeIds) const;
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
   void AddAllArgsExcept(ArgStringList &Output, ArrayRef Ids,
@@ -342,6 +358,12 @@
   ///
   void ClaimAllArgs() const;
 
+  /// Return the OptSpecifiers queried from this argument list.
+  const DenseSet &getQueriedOpts() const { return QueriedOpts; }
+
+  /// Clear the set of queried OptSpecifiers.
+  void clearQueriedOpts() const { QueriedOpts.clear(); }
+
   /// @}
   /// @name Arg Synthesis
   /// @{
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -38,6 +38,7 @@
 #include "clang/Frontend/FrontendPluginRegistry.h"
 #include "clang/Frontend/MigratorOptions.h"
 #include "clang/Frontend/PreprocessorOutputOptions.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/PreprocessorOptions.h"
@@ -48,6 +49,7 @@
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/CachedHashString.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/FloatingPointMode.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/None.h"
@@ -204,7 +206,7 @@
   const char *Spelling,
   CompilerInvocation::StringAllocator SA,
   Option::OptionClass OptClass, unsigned,
-  Twine Value) {
+  const Twine &Value) {
   switch (OptClass) {
   case Option::SeparateClass:
   case Option::JoinedOrSeparateClass:
@@ -562,9 +564,127 @@
   return 0;
 }
 
-static std::string GetOptName(llvm::opt::OptSpecifier OptSpecifier) {
-  static const OptTable &OptTable = getDriverOptTable();
-  return OptTable.getOption(OptSpe

[PATCH] D94472: [clang][cli] Command line round-trip for HeaderSearch options

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:593-594
 
+def round_trip_args : Flag<["-"], "round-trip-args">, Flags<[CC1Option, 
NoDriverOption]>,
+  HelpText<"Performs 'parse-generate-parse' round-trip of command line 
arguments.">;
+def round_trip_args_debug : Flag<["-"], "round-trip-args-debug">, 
Flags<[CC1Option, NoDriverOption]>,

dexonsmith wrote:
> Can we make this `=true` vs. `=false`, or add a `-no-round-trip-args`? That 
> will allow:
> ```
> % clang some args -Xclang -no-round-trip-args
> ```
> to disable it in asserts builds; much better than:
> ```
> % clang some args -###
> # Search for -round-trip-args
> % clang -cc1 copy-paste-args-before copy-past-args-after
> ```
Done.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:531
+  Option Opt = getDriverOptTable().getOption(OptSpecifier);
+  denormalizeSimpleFlag(Args, SA(Opt.getPrefix() + Opt.getName()), SA,
+Option::OptionClass::FlagClass, 0);

dexonsmith wrote:
> Hmm, I thought we'd found a way to avoid allocating the prefixed name, by 
> adding it to the options table. This unfortunate, but I guess you can fix it 
> another time.
> 
> 
We can avoid the allocation in the generating macro. I'll come back to this 
later and figure out a way to do the same here.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:540
+  Option Opt = getDriverOptTable().getOption(OptSpecifier);
+  denormalizeString(Args, SA(Opt.getPrefix() + Opt.getName()), SA,
+Opt.getKind(), 0, Value);

dexonsmith wrote:
> Does this allocated string get used, or does `"=some-value"` get added on?
Both. It depends on the kind/class (Joined/Separate/...) of the option.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3211-3214
+  auto ResetHS = [](CompilerInvocation &Res) {
+auto EmptyHeaderSearchOpts = std::make_shared();
+Res.HeaderSearchOpts.swap(EmptyHeaderSearchOpts);
+  };

dexonsmith wrote:
> I'm not sure this works correctly. Callers may depend on the identity of the 
> `HeaderSearchOptions`. It's a shared pointer that could have other 
> references. This will only update / reset one reference.
Resolved by `SwapOpts`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94472

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


[PATCH] D95608: [OpenCL][PR48896] Fix address space in binding of initializer lists to references

2021-01-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 319869.
Anastasia retitled this revision from "[OpenCL][PR48896] Fix address space when 
binding vector literals to references" to "[OpenCL][PR48896] Fix address space 
in binding of initializer lists to references".
Anastasia edited the summary of this revision.
Anastasia added reviewers: rjmccall, ebevhan.
Anastasia added a subscriber: cfe-commits.
Anastasia added a comment.

- Added a test case.


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

https://reviews.llvm.org/D95608

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-references.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-references.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-references.cl
@@ -1,8 +1,16 @@
-//RUN: %clang_cc1 %s -cl-std=clc++ -triple spir -emit-llvm -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++ -triple spir -emit-llvm -o - -O0 | 
FileCheck %s
+
+typedef short short2 __attribute__((ext_vector_type(2)));
 
 int bar(const unsigned int &i);
-// CHECK-LABEL: define{{.*}} spir_func void @_Z3foov() 
-void foo() {
+
+class C {
+public:
+void bar(const short2&);
+};
+
+// CHECK-LABEL: define{{.*}} spir_func void @_Z6scalarv()
+void scalar() {
   // The generic addr space reference parameter object will be bound
   // to a temporary value allocated in private addr space. We need an
   // addrspacecast before passing the value to the function.
@@ -12,3 +20,14 @@
   // CHECK: call spir_func i32 @_Z3barRU3AS4Kj(i32 addrspace(4)* align 4 
dereferenceable(4) [[REG]])
   bar(1);
 }
+
+// Test list initialization
+// CHECK-LABEL: define{{.*}} spir_func void @_Z4listv()
+void list() {
+  C c1;
+// CHECK: [[REF:%.*]] = alloca <2 x i16>
+// CHECK: store <2 x i16> , <2 x i16>* [[REF]]
+// CHECK: [[REG:%[.a-z0-9]+]] = addrspacecast <2 x i16>* [[REF]] to <2 x i16> 
addrspace(4)*
+// CHECK: call {{.*}}void @_ZNU3AS41C3barERU3AS4KDv2_s(%class.C addrspace(4)* 
{{.*}}, <2 x i16> addrspace(4)*{{.*}} [[REG]])
+  c1.bar({1, 2});
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -4289,17 +4289,24 @@
 if (Sequence.step_begin() != Sequence.step_end())
   Sequence.RewrapReferenceInitList(cv1T1, InitList);
   }
-
+  // Ignore address space of reference type at this point and perform address
+  // space conversion after the reference binding step.
+  QualType cv1T1IgnoreAS =
+  T1Quals.hasAddressSpace()
+  ? S.Context.getQualifiedType(T1, T1Quals.withoutAddressSpace())
+  : cv1T1;
   // Not reference-related. Create a temporary and bind to that.
-  InitializedEntity TempEntity = InitializedEntity::InitializeTemporary(cv1T1);
+  InitializedEntity TempEntity = 
InitializedEntity::InitializeTemporary(cv1T1IgnoreAS);
 
   TryListInitialization(S, TempEntity, Kind, InitList, Sequence,
 TreatUnavailableAsInvalid);
   if (Sequence) {
 if (DestType->isRValueReferenceType() ||
-(T1Quals.hasConst() && !T1Quals.hasVolatile()))
-  Sequence.AddReferenceBindingStep(cv1T1, /*BindingTemporary=*/true);
-else
+(T1Quals.hasConst() && !T1Quals.hasVolatile())) {
+  Sequence.AddReferenceBindingStep(cv1T1IgnoreAS, 
/*BindingTemporary=*/true);
+  if (T1Quals.hasAddressSpace())
+Sequence.AddQualificationConversionStep(cv1T1, VK_XValue);
+} else
   Sequence.SetFailed(
   
InitializationSequence::FK_NonConstLValueReferenceBindingToTemporary);
   }


Index: clang/test/CodeGenOpenCLCXX/addrspace-references.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-references.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-references.cl
@@ -1,8 +1,16 @@
-//RUN: %clang_cc1 %s -cl-std=clc++ -triple spir -emit-llvm -o - | FileCheck %s
+//RUN: %clang_cc1 %s -cl-std=clc++ -triple spir -emit-llvm -o - -O0 | FileCheck %s
+
+typedef short short2 __attribute__((ext_vector_type(2)));
 
 int bar(const unsigned int &i);
-// CHECK-LABEL: define{{.*}} spir_func void @_Z3foov() 
-void foo() {
+
+class C {
+public:
+void bar(const short2&);
+};
+
+// CHECK-LABEL: define{{.*}} spir_func void @_Z6scalarv()
+void scalar() {
   // The generic addr space reference parameter object will be bound
   // to a temporary value allocated in private addr space. We need an
   // addrspacecast before passing the value to the function.
@@ -12,3 +20,14 @@
   // CHECK: call spir_func i32 @_Z3barRU3AS4Kj(i32 addrspace(4)* align 4 dereferenceable(4) [[REG]])
   bar(1);
 }
+
+// Test list initialization
+// CHECK-LABEL: define{{.*}} spir_func void @_Z4listv()
+void list() {
+  C c1;
+// CHECK: [[REF:%.*]] = alloca <2 x i16>
+// CHECK: store <2 x i16> , <2 x i16>* [[REF]]
+// CHECK: [[REG:%[.a-z0-9]+]] = addrspacecast <2 x i16>* 

[PATCH] D58634: [PR40778] Generate address space conversion when binding reference to a temporary value in different address space

2021-01-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Sema/SemaInit.cpp:4806-4808
+  if ((RefRelationship == Sema::Ref_Related &&
+   (T1CVRQuals | T2CVRQuals) != T1CVRQuals) ||
+  !T1Quals.isAddressSpaceSupersetOf(T2Quals)) {

ebevhan wrote:
> Sorry for the really late comment on this, but shouldn't this be:
> ```
>   if (RefRelationship == Sema::Ref_Related &&
>   ((T1CVRQuals | T2CVRQuals) != T1CVRQuals ||
>!T1Quals.isAddressSpaceSupersetOf(T2Quals))) {
> ```
> 
> Currently, this fails on AS qualification regardless of ref-compatibility.
Sorry for noticing this late. I agree this doesn't look right... I will create 
a patch to fix this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58634

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-01-28 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 319873.
abhina.sreeskantharajan retitled this revision from "[SystemZ][z/OS] Fix No 
such file or directory expression error matching in lit tests - continued" to 
"[test] Use host platform specific error message substitution in lit tests ".
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.
Herald added a reviewer: JDevlieghere.
Herald added subscribers: wenlei, gbedwell.
Herald added a reviewer: andreadb.

Update all testcases to use -DMSG.
I've also updated the summary to match the changes in the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

Files:
  clang/test/CodeGen/basic-block-sections.c
  clang/test/CodeGen/ubsan-blacklist-vfs.c
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Frontend/output-paths.c
  clang/test/Frontend/stats-file.c
  lld/test/COFF/driver.test
  lld/test/COFF/manifestinput-error.test
  lld/test/COFF/nodefaultlib.test
  lld/test/COFF/pdb-type-server-invalid-signature.yaml
  lld/test/COFF/pdb-type-server-missing.yaml
  lld/test/ELF/archive-thin-missing-member.s
  lld/test/ELF/basic.s
  lld/test/ELF/reproduce-error.s
  lld/test/ELF/symbol-ordering-file.s
  lld/test/MachO/invalid/no-filelist.s
  llvm/docs/TestingGuide.rst
  llvm/test/DebugInfo/symbolize-missing-file.test
  llvm/test/MC/Hexagon/not_found.s
  llvm/test/Object/archive-extract-dir.test
  llvm/test/Object/archive-extract.test
  llvm/test/Object/directory.ll
  llvm/test/tools/dsymutil/X86/papertrail-warnings.test
  llvm/test/tools/dsymutil/archive-timestamp.test
  llvm/test/tools/dsymutil/debug-map-parsing.test
  llvm/test/tools/llvm-ar/error-opening-directory.test
  llvm/test/tools/llvm-ar/missing-thin-archive-member.test
  llvm/test/tools/llvm-ar/move.test
  llvm/test/tools/llvm-ar/print.test
  llvm/test/tools/llvm-ar/quick-append.test
  llvm/test/tools/llvm-ar/replace.test
  llvm/test/tools/llvm-ar/response.test
  llvm/test/tools/llvm-cxxdump/trivial.test
  llvm/test/tools/llvm-libtool-darwin/filelist.test
  llvm/test/tools/llvm-libtool-darwin/invalid-input-output-args.test
  llvm/test/tools/llvm-lipo/create-arch.test
  llvm/test/tools/llvm-lipo/replace-invalid-input.test
  llvm/test/tools/llvm-lto/error.ll
  llvm/test/tools/llvm-lto2/X86/stats-file-option.ll
  llvm/test/tools/llvm-mc/basic.test
  llvm/test/tools/llvm-mca/invalid_input_file_name.test
  llvm/test/tools/llvm-ml/basic.test
  llvm/test/tools/llvm-objcopy/COFF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/add-section.test
  llvm/test/tools/llvm-objcopy/ELF/error-format.test
  llvm/test/tools/llvm-objcopy/MachO/add-section-error.test
  llvm/test/tools/llvm-objcopy/redefine-symbols.test
  llvm/test/tools/llvm-objcopy/wasm/dump-section.test
  llvm/test/tools/llvm-profdata/weight-instr.test
  llvm/test/tools/llvm-profdata/weight-sample.test
  llvm/test/tools/llvm-readobj/ELF/thin-archive-paths.test
  llvm/test/tools/llvm-readobj/basic.test
  llvm/test/tools/llvm-readobj/thin-archive.test
  llvm/test/tools/llvm-size/no-input.test
  llvm/test/tools/llvm-symbolizer/pdb/missing_pdb.test
  llvm/test/tools/llvm-xray/X86/no-such-file.txt
  llvm/test/tools/obj2yaml/invalid_input_file.test
  llvm/test/tools/yaml2obj/output-file.yaml
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -345,6 +345,17 @@
 self.config.substitutions.extend(substitutions)
 return True
 
+def add_err_msg_substitutions(self):
+if (sys.platform == 'zos'):
+self.config.substitutions.append(('%errc_ENOENT', '\'EDC5129I No such file or directory.\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'EDC5123I Is a directory.\''))
+elif (sys.platform == 'win32'):
+self.config.substitutions.append(('%errc_ENOENT', '\'no such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'is a directory\''))
+else:
+self.config.substitutions.append(('%errc_ENOENT', '\'No such file or directory\''))
+self.config.substitutions.append(('%errc_EISDIR', '\'Is a directory\''))
+
 def use_default_substitutions(self):
 tool_patterns = [
 ToolSubst('FileCheck', unresolved='fatal'),
@@ -358,6 +369,8 @@
 self.add_tool_substitutions(
 tool_patterns, [self.config.llvm_tools_dir])
 
+self.add_err_msg_substitutions()
+
 def use_llvm_tool(self, name, search_env=None, required=False, quiet=False):
 """Find the executable program 'name', optionally using the specified
 environment variable as an override before searching the
Index: llvm/test/tools/yaml2obj/output-file.yaml
=

[PATCH] D95119: Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk

2021-01-28 Thread Harmen Stoppels via Phabricator via cfe-commits
haampie updated this revision to Diff 319871.
haampie added a comment.
Herald added a subscriber: arphaman.

I dropped the awk bits, since there's no portable way to do it there, and 
replaced all `perl -w` with `perl` and `use warnings`.


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

https://reviews.llvm.org/D95119

Files:
  clang/test/make_test_dirs.pl
  clang/tools/scan-build/bin/set-xcode-analyzer
  clang/utils/TestUtils/pch-test.pl
  clang/utils/analyzer/reducer.pl
  clang/utils/analyzer/update_plist_test.pl
  clang/www/demo/index.cgi
  debuginfo-tests/llgdb-tests/test_debuginfo.pl
  lldb/docs/use/python-reference.rst
  lldb/scripts/disasm-gdb-remote.pl
  llvm/utils/GenLibDeps.pl
  llvm/utils/codegen-diff
  llvm/utils/findsym.pl
  llvm/utils/llvm-compilers-check
  llvm/utils/llvm-native-gxx
  openmp/runtime/tools/check-execstack.pl
  openmp/runtime/tools/check-instruction-set.pl
  openmp/runtime/tools/message-converter.pl
  polly/lib/External/isl/doc/mypod2latex

Index: polly/lib/External/isl/doc/mypod2latex
===
--- polly/lib/External/isl/doc/mypod2latex
+++ polly/lib/External/isl/doc/mypod2latex
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use Pod::LaTeX;
Index: openmp/runtime/tools/message-converter.pl
===
--- openmp/runtime/tools/message-converter.pl
+++ openmp/runtime/tools/message-converter.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 #//===--===//
Index: openmp/runtime/tools/check-instruction-set.pl
===
--- openmp/runtime/tools/check-instruction-set.pl
+++ openmp/runtime/tools/check-instruction-set.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 #//===--===//
Index: openmp/runtime/tools/check-execstack.pl
===
--- openmp/runtime/tools/check-execstack.pl
+++ openmp/runtime/tools/check-execstack.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 #
 #//===--===//
Index: llvm/utils/llvm-native-gxx
===
--- llvm/utils/llvm-native-gxx
+++ llvm/utils/llvm-native-gxx
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Wrapper around LLVM tools to generate a native .o from llvm-gxx using an
 # LLVM back-end (CBE by default).
 
Index: llvm/utils/llvm-compilers-check
===
--- llvm/utils/llvm-compilers-check
+++ llvm/utils/llvm-compilers-check
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 ##===- utils/llvmbuild - Build the LLVM project *-python-*-===##
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Index: llvm/utils/findsym.pl
===
--- llvm/utils/findsym.pl
+++ llvm/utils/findsym.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Program:  findsym.pl
 #
@@ -8,6 +8,8 @@
 # Syntax:   findsym.pl  
 #
 
+use warnings;
+
 # Give first option a name.
 my $Directory = $ARGV[0];
 my $Symbol = $ARGV[1];
Index: llvm/utils/codegen-diff
===
--- llvm/utils/codegen-diff
+++ llvm/utils/codegen-diff
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use Getopt::Std;
 $DEBUG = 0;
Index: llvm/utils/GenLibDeps.pl
===
--- llvm/utils/GenLibDeps.pl
+++ llvm/utils/GenLibDeps.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # Program:  GenLibDeps.pl
 #
Index: lldb/scripts/disasm-gdb-remote.pl
===
--- lldb/scripts/disasm-gdb-remote.pl
+++ lldb/scripts/disasm-gdb-remote.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 
Index: lldb/docs/use/python-reference.rst
===
--- lldb/docs/use/python-reference.rst
+++ lldb/docs/use/python-reference.rst
@@ -595,7 +595,7 @@
 
 ::
 
-  #!/usr/bin/python
+  #!/usr/bin/env python
 
   import lldb
   import commands
@@ -703,7 +703,7 @@
 
 ::
 
-  #!/usr/bin/python
+  #!/usr/bin/env python
 
   import lldb
   import os
Index: debuginfo-tests/llgdb-tests/test_debuginfo.pl
===
--- debuginfo-tests/llgdb-tests/test_debuginfo.pl
+++ debuginfo-tests/llgdb-tests/test_debuginfo.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 # This script tests debugging information generated by a compiler.
 # Input arguments
Index: clang/www/demo

[PATCH] D95514: [clang][cli] Teach CompilerInvocation to allocate strings on its own

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D95514#2526064 , @dexonsmith wrote:

> Well, the compiler developers are the users, since `-cc1` isn't for 
> end-users. I acknowledge it's a tradeoff. IMO, without actually seeing it in 
> practice, it seems a bit nicer to design this away entirely. But maybe having 
> a `=` is more valuable than I think.



> For string options:
>
> - If `-cc1` accepts only `-opt string`, no need for allocation.
> - If `-cc1` accepts only `-opt=string`, the fully-spelled option is on the 
> original command-line. `ExistingStrings.find()` should turn it up when 
> calling `Strings.save()`.
> - If `-cc1` accepts both `-opt=string` and `-opt string` canonicalize to 
> `-opt string` when generating. No need for allocation.
>
> For numeric / enum options we'll need to allocate, but the allocation doesn't 
> have to live past running the parser.
>
> The only problem would be if `string` gets canonicalized / rewritten somehow 
> during parse + generate, or if an enum value is additionally saved as a 
> string value.

We can definitely ask around how would people feel about that.

>>> Consider that some callers may parse the full command-line and then drop 
>>> everything but one options class. That pattern wouldn’t work anymore since 
>>> the StringRefs won’t be valid.
>>
>> Ah, that's right. So if we don't go with the allocation-less approach, we'd 
>> need to take `StringAllocator` from the client that also ensures proper 
>> lifetimes.
>
> Maybe it wouldn't be terrible to have a `RoundTrip` arg on each options 
> class. When you assign to the CompilerInvocation, it copies the shared ptr 
> into each of the options classes, so that the pool stays alive as long as one 
> of them has it.

I think this is the most robust solution.

Moving `BumpPtrAllocator`/`StringSaver` into `CompilerInvocation` will become 
problematic once we start round-tripping more option classes.

I've looked through all option classes in `CompilerInvocation`, and 
`AnalyzerOptions::Config` seems to be the only member that stores non-owning 
references to command line arguments.
I think the best path forward is to change `AnalyzerOptions` to take ownership 
and avoid dealing with complicated lifetimes. We can look into removing 
allocations later, as an optional optimization.
What do you think?




Comment at: clang/include/clang/Frontend/CompilerInvocation.h:144
+  /// Container holding strings allocated during round-trip.
+  mutable std::forward_list AllocatedStrings;
+

dexonsmith wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > I suggest using llvm::StringPool instead, which also uniques the strings 
> > > and is used elsewhere for this kind of thing. Probably in an Optional to 
> > > make it more clear it’s not always used.
> > > 
> > > Maybe the name RoundTrippedStrings? 
> > From the documentation of `StringPool`, it seems like we would need to 
> > store `PooledStringPtr`s in order to keep them alive. How would that work 
> > with the `const char *` API we have?
> Oops; I meant `StringSet<>` / `StringMap` / etc., which is what 
> I've always used in the past. This is essentially a `StringMap`; I just 
> always call the variable `StringPool`, hence my error. It has the properties 
> you need (stable, kept alive indefinitely, null-terminated).
> 
> Looking around, there are a couple of options designed for this:
> - `StringSaver`, which is an optimized version of your list (uses a 
> bumpptrallocator, no uniquing).
> - `UniqueStringSaver`, which is essentially equivalent to `StringSet<>`; 
> might be slightly more optimized, and if it's not, we should fix it.
> 
> I suggest using one of those since they exactly match what you need.
Thanks for mentioning `StringSaver`s, they fit our needs perfectly (now used in 
D94472).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95514

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


[PATCH] D95514: [clang][cli] Teach CompilerInvocation to allocate strings on its own

2021-01-28 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

In D95514#2528324 , @jansvoboda11 
wrote:

> In D95514#2526064 , @dexonsmith 
> wrote:
>
>> Well, the compiler developers are the users, since `-cc1` isn't for 
>> end-users. I acknowledge it's a tradeoff. IMO, without actually seeing it in 
>> practice, it seems a bit nicer to design this away entirely. But maybe 
>> having a `=` is more valuable than I think.
>
>
>
>> For string options:
>>
>> - If `-cc1` accepts only `-opt string`, no need for allocation.
>> - If `-cc1` accepts only `-opt=string`, the fully-spelled option is on the 
>> original command-line. `ExistingStrings.find()` should turn it up when 
>> calling `Strings.save()`.
>> - If `-cc1` accepts both `-opt=string` and `-opt string` canonicalize to 
>> `-opt string` when generating. No need for allocation.
>>
>> For numeric / enum options we'll need to allocate, but the allocation 
>> doesn't have to live past running the parser.
>>
>> The only problem would be if `string` gets canonicalized / rewritten somehow 
>> during parse + generate, or if an enum value is additionally saved as a 
>> string value.
>
> We can definitely ask around how would people feel about that.
>
 Consider that some callers may parse the full command-line and then drop 
 everything but one options class. That pattern wouldn’t work anymore since 
 the StringRefs won’t be valid.
>>>
>>> Ah, that's right. So if we don't go with the allocation-less approach, we'd 
>>> need to take `StringAllocator` from the client that also ensures proper 
>>> lifetimes.
>>
>> Maybe it wouldn't be terrible to have a `RoundTrip` arg on each options 
>> class. When you assign to the CompilerInvocation, it copies the shared ptr 
>> into each of the options classes, so that the pool stays alive as long as 
>> one of them has it.
>
> I think this is the most robust solution.
>
> Moving `BumpPtrAllocator`/`StringSaver` into `CompilerInvocation` will become 
> problematic once we start round-tripping more option classes.
>
> I've looked through all option classes in `CompilerInvocation`, and 
> `AnalyzerOptions::Config` seems to be the only member that stores non-owning 
> references to command line arguments.
> I think the best path forward is to change `AnalyzerOptions` to take 
> ownership and avoid dealing with complicated lifetimes. We can look into 
> removing allocations later, as an optional optimization.
> What do you think?

I think that makes sense given the rest of `CompilerInvocation` is owning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95514

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


[PATCH] D95628: WIP: clang-scan-deps: Skip the disk when scanning modules dependencies

2021-01-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: Bigcheese, arphaman, sammccall.
Herald added subscribers: ributzka, tschuett.
dexonsmith requested review of this revision.
Herald added a project: clang.

Modules dependendency scanning builds lightweight modules (based on
minimized preprocess-only sources) in order to construct the module
dependency graph. Add `-intercept-module-outputs` (on-by-default), which
keeps these lightweight modules in memory instead of writing to and
reading from disk, leveraging llvm::vfs::OutputManager.

This patch uses a separate cache per worker, but these would ideally be
kept in a shared result cache (could be an in-memory CAS).

This is a WIP because it's based on the OutputManager RFC (see patches 
https://reviews.llvm.org/D95501 / https://reviews.llvm.org/D95502) but I'm 
posting this as well since it's a simple example usage.

I haven't benchmarked (yet); it's motivated by profiling from a couple of years 
ago that showed some slowdowns here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95628

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -160,6 +160,12 @@
 "until reaching the end directive."),
 llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
 
+llvm::cl::opt InterceptModuleOutputs(
+"intercept-module-outputs",
+llvm::cl::desc(
+"Keep the module outputs in-memory only, skipping the on-disk cache."),
+llvm::cl::init(true), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt Verbose("v", llvm::cl::Optional,
 llvm::cl::desc("Use verbose output."),
 llvm::cl::init(false),
@@ -485,7 +491,8 @@
   SharedStream DependencyOS(llvm::outs());
 
   DependencyScanningService Service(ScanMode, Format, ReuseFileManager,
-SkipExcludedPPRanges);
+SkipExcludedPPRanges,
+InterceptModuleOutputs);
   llvm::ThreadPool Pool(llvm::hardware_concurrency(NumThreads));
   std::vector> WorkerTools;
   for (unsigned I = 0; I < Pool.getThreadCount(); ++I)
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -50,12 +50,13 @@
 public:
   DependencyScanningAction(
   StringRef WorkingDirectory, DependencyConsumer &Consumer,
+  std::shared_ptr Outputs,
   llvm::IntrusiveRefCntPtr DepFS,
   ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings,
   ScanningOutputFormat Format)
   : WorkingDirectory(WorkingDirectory), Consumer(Consumer),
-DepFS(std::move(DepFS)), PPSkipMappings(PPSkipMappings),
-Format(Format) {}
+Outputs(std::move(Outputs)), DepFS(std::move(DepFS)),
+PPSkipMappings(PPSkipMappings), Format(Format) {}
 
   bool runInvocation(std::shared_ptr Invocation,
  FileManager *FileMgr,
@@ -65,6 +66,14 @@
 CompilerInstance Compiler(std::move(PCHContainerOps));
 Compiler.setInvocation(std::move(Invocation));
 
+// Configure the output manager.
+if (Outputs) {
+  Compiler.setOutputManager(std::move(Outputs));
+
+  // FIXME: Is this the best way to set the flag?
+  Compiler.getFrontendOpts().BuildingImplicitModuleUsesLock = false;
+}
+
 // Don't print 'X warnings and Y errors generated'.
 Compiler.getDiagnosticOpts().ShowCarets = false;
 // Create the compiler's actual diagnostics engine.
@@ -142,6 +151,7 @@
 private:
   StringRef WorkingDirectory;
   DependencyConsumer &Consumer;
+  std::shared_ptr Outputs;
   llvm::IntrusiveRefCntPtr DepFS;
   ExcludedPreprocessorDirectiveSkipMapping *PPSkipMappings;
   ScanningOutputFormat Format;
@@ -155,6 +165,35 @@
   DiagOpts = new DiagnosticOptions();
   PCHContainerOps = std::make_shared();
   RealFS = llvm::vfs::createPhysicalFileSystem();
+
+  if (Service.interceptModuleOutputs()) {
+using namespace llvm;
+using namespace llvm::vfs;
+
+// Create an in-memory filesystem for storing modules and overlay it on top
+// of RealFS.
+auto InMemoryFS = makeIntrusiveRefCnt();
+{
+  auto OverlayFS =
+makeIntrusiveRefCnt(createPhysicalFileSystem());
+  OverlayFS->pushOverlay(InMemoryFS);
+  RealFS = std::move(OverlayFS

[PATCH] D95369: [WIP][clang][cli] Generate and round-trip analyzer options

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 319894.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95369

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -727,9 +727,108 @@
   Funcs.insert(Funcs.end(), Values.begin(), Values.end());
 }
 
+static void GenerateAnalyzerArgs(AnalyzerOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA) {
+  const AnalyzerOptions *AnalyzerOpts = &Opts;
+
+#define ANALYZER_OPTION_WITH_MARSHALLING(...)  \
+  GENERATE_OPTION_WITH_MARSHALLING(Args, SA, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef ANALYZER_OPTION_WITH_MARSHALLING
+
+  if (Opts.AnalysisStoreOpt != RegionStoreModel) {
+switch (Opts.AnalysisStoreOpt) {
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN)   \
+  case NAME##Model:\
+GenerateArg(Args, OPT_analyzer_store, CMDFLAG, SA);\
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis store.");
+}
+  }
+
+  if (Opts.AnalysisConstraintsOpt != RangeConstraintsModel) {
+switch (Opts.AnalysisConstraintsOpt) {
+#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) \
+  case NAME##Model:\
+GenerateArg(Args, OPT_analyzer_constraints, CMDFLAG, SA);  \
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis constraint.");
+}
+  }
+
+  if (Opts.AnalysisDiagOpt != PD_HTML) {
+switch (Opts.AnalysisDiagOpt) {
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN) \
+  case PD_##NAME:  \
+GenerateArg(Args, OPT_analyzer_output, CMDFLAG, SA);   \
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis diagnostic client.");
+}
+  }
+
+  if (Opts.AnalysisPurgeOpt != PurgeStmt) {
+switch (Opts.AnalysisPurgeOpt) {
+#define ANALYSIS_PURGE(NAME, CMDFLAG, DESC)\
+  case NAME:   \
+GenerateArg(Args, OPT_analyzer_purge, CMDFLAG, SA);\
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis purge mode.");
+}
+  }
+
+  if (Opts.InliningMode != NoRedundancy) {
+switch (Opts.InliningMode) {
+#define ANALYSIS_INLINING_MODE(NAME, CMDFLAG, DESC)\
+  case NAME:   \
+GenerateArg(Args, OPT_analyzer_inlining_mode, CMDFLAG, SA);\
+break;
+#include "clang/StaticAnalyzer/Core/Analyses.def"
+default:
+  llvm_unreachable("Tried to generate unknown analysis inlining mode.");
+}
+  }
+
+  for (const auto &CP : Opts.CheckersAndPackages) {
+OptSpecifier Opt =
+CP.second ? OPT_analyzer_checker : OPT_analyzer_disable_checker;
+GenerateArg(Args, Opt, CP.first, SA);
+  }
+
+  AnalyzerOptions ConfigOpts;
+  parseAnalyzerConfigs(ConfigOpts, nullptr);
+
+  for (const auto &C : Opts.Config) {
+// Don't generate anything that came from parseAnalyzerConfigs. It would be
+// redundant and may not be valid on the command line.
+auto Entry = ConfigOpts.Config.find(C.first);
+if (Entry != ConfigOpts.Config.end() && Entry->second == C.second)
+  continue;
+
+GenerateArg(Args, OPT_analyzer_config, C.first + "=" + C.second, SA);
+  }
+
+  // Nothing to generate for FullCompilerInvocation.
+}
+
 static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags) {
+  AnalyzerOptions *AnalyzerOpts = &Opts;
   bool Success = true;
+
+#define ANALYZER_OPTION_WITH_MARSHALLING(...)  \
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef ANALYZER_OPTION_WITH_MARSHALLING
+
   if (Arg *A = Args.getLastArg(OPT_analyzer_store)) {
 StringRef Name = A->getValue();
 AnalysisStores Value = llvm::StringSwitch(Name)
@@ -853,8 +952,10 @@
   // TODO: Check checker options too, possibly in Checker

[PATCH] D95629: [clang][analyzer] Own string keys in AnalyzerOptions::ConfigTable

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added subscribers: steakhal, ASDenysPetrov, martong, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch replaces `StringMap<...>` with `std::map` in 
`AnalyzerOptions::ConfigTable`. It seems to be the only non-owning reference to 
command line arguments in the whole `CompilerInvocation`, which would introduce 
a lot of complexity with round-tripping arguments (D94472 
).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95629

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
  clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp

Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -358,7 +358,7 @@
   // to it's default value, and if we're in non-compatibility mode, we'll also
   // emit an error.
 
-  StringRef SuppliedValue = It.first->getValue();
+  StringRef SuppliedValue = It.first->second;
 
   if (Option.OptionType == "bool") {
 if (SuppliedValue != "true" && SuppliedValue != "false") {
@@ -367,7 +367,7 @@
 << FullOption << "a boolean value";
   }
 
-  It.first->setValue(std::string(Option.DefaultValStr));
+  It.first->second = std::string(Option.DefaultValStr);
 }
 return;
   }
@@ -381,7 +381,7 @@
 << FullOption << "an integer value";
   }
 
-  It.first->setValue(std::string(Option.DefaultValStr));
+  It.first->second = std::string(Option.DefaultValStr);
 }
 return;
   }
@@ -495,7 +495,7 @@
 StringRef SuppliedCheckerOrPackage;
 StringRef SuppliedOption;
 std::tie(SuppliedCheckerOrPackage, SuppliedOption) =
-Config.getKey().split(':');
+StringRef(Config.first).split(':');
 
 if (SuppliedOption.empty())
   continue;
Index: clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -126,7 +126,7 @@
 ConfigTable::const_iterator I =
 Config.find((Twine(CheckerName) + ":" + OptionName).str());
 if (I != E)
-  return StringRef(I->getValue());
+  return StringRef(I->second);
 size_t Pos = CheckerName.rfind('.');
 if (Pos == StringRef::npos)
   break;
Index: clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
+++ clang/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp
@@ -259,9 +259,9 @@
 class ConfigDumper : public Checker< check::EndOfTranslationUnit > {
   typedef AnalyzerOptions::ConfigTable Table;
 
-  static int compareEntry(const Table::MapEntryTy *const *LHS,
-  const Table::MapEntryTy *const *RHS) {
-return (*LHS)->getKey().compare((*RHS)->getKey());
+  static int compareEntry(const Table::value_type *const *LHS,
+  const Table::value_type *const *RHS) {
+return (*LHS)->first.compare((*RHS)->first);
   }
 
 public:
@@ -270,7 +270,7 @@
  BugReporter &BR) const {
 const Table &Config = mgr.options.Config;
 
-SmallVector Keys;
+SmallVector Keys;
 for (Table::const_iterator I = Config.begin(), E = Config.end(); I != E;
  ++I)
   Keys.push_back(&*I);
@@ -278,7 +278,7 @@
 
 llvm::errs() << "[config]\n";
 for (unsigned I = 0, E = Keys.size(); I != E; ++I)
-  llvm::errs() << Keys[I]->getKey() << " = "
+  llvm::errs() << Keys[I]->first << " = "
<< (Keys[I]->second.empty() ? "\"\"" : Keys[I]->second)
<< '\n';
   }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -859,7 +859,7 @@
   }
 
   A->claim();
-  Opts.Config[key] = std::string(val);
+  Opts.Config[std::string(key)] = std::string(val);
 }
   }
 
@@ -881,7 +881,8 @@
 
 static StringRef getStringOption(AnalyzerOptions::ConfigTable &Config,
  StringRef OptionName, StringRef DefaultVal) {
-  return Config.insert({OptionName, std::string(DefaultVal)}).first->second;
+  return Config.insert({std::string(OptionName), std::string(DefaultVal)})
+  .first->second;
 }
 
 

[PATCH] D95614: [clang-tidy] Applied clang-tidy fixes. NFC

2021-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the cleanup!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95614

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


[PATCH] D94942: [clangd] Add tweak for implementing abstract class

2021-01-28 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 319898.
njames93 added a comment.

- Fix an issue where replacements could conflict with each other.
- Add support for defining method stubs instead of just declaring them, 
possibly need a way to configure this behaviour.
- Change tests to ignore whitespace because we dont clang-format them tweaks in 
tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94942

Files:
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ImplementAbstract.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/ImplementAbstractTests.cpp
@@ -0,0 +1,415 @@
+//===-- ImplementAbstractTests.cpp --*- 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
+//
+//===--===//
+
+#include "TestTU.h"
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+bool stringEqIgnoreWs(StringRef LHS, StringRef RHS) {
+  auto TrimmedL = LHS.trim();
+  auto TrimmedR = RHS.trim();
+  static constexpr llvm::StringLiteral WS(" \t\r\n\f\v");
+
+  while (!TrimmedL.empty() && !TrimmedR.empty()) {
+auto LPos = TrimmedL.find_first_of(WS);
+auto RPos = TrimmedR.find_first_of(WS);
+if (TrimmedL.take_front(LPos) != TrimmedR.take_front(RPos))
+  return false;
+TrimmedL =
+TrimmedL.substr(LPos).drop_while([](char C) { return WS.contains(C); });
+TrimmedR =
+TrimmedR.substr(RPos).drop_while([](char C) { return WS.contains(C); });
+  }
+  return TrimmedL == TrimmedR;
+}
+
+MATCHER_P(STREQWS, EqualTo, "") {
+  if (stringEqIgnoreWs(arg, EqualTo))
+return true;
+
+  auto Result =
+  testing::internal::EqFailure("", "", arg, std::string(EqualTo), false);
+  *result_listener << Result.message();
+  return false;
+}
+
+TWEAK_TEST(ImplementAbstract);
+
+TEST_F(ImplementAbstractTest, TestUnavailable) {
+
+  StringRef Cases[]{
+  // Not a pure virtual method.
+  R"cpp(
+class A {
+  virtual void Foo();
+};
+class ^B : public A {};
+  )cpp",
+  // Pure virtual method overridden in class.
+  R"cpp(
+class A {
+  virtual void Foo() = 0;
+};
+class ^B : public A {
+  void Foo() override;
+};
+  )cpp",
+  // Pure virtual method overridden in class with virtual keyword
+  R"cpp(
+class A {
+  virtual void Foo() = 0;
+};
+class ^B : public A {
+  virtual void Foo() override;
+};
+  )cpp",
+  // Pure virtual method overridden in class without override keyword
+  R"cpp(
+class A {
+  virtual void Foo() = 0;
+};
+class ^B : public A {
+  void Foo();
+};
+  )cpp",
+  // Pure virtual method overriden in base class.
+  R"cpp(
+class A {
+  virtual void Foo() = 0;
+};
+class B : public A {
+  void Foo() override;
+};
+class ^C : public B {};
+  )cpp"};
+  for (const auto &Case : Cases) {
+EXPECT_THAT(Case, Not(isAvailable()));
+  }
+}
+
+TEST_F(ImplementAbstractTest, NormalAvailable) {
+  struct Case {
+llvm::StringRef TestHeader;
+llvm::StringRef TestSource;
+llvm::StringRef ExpectedSource;
+  };
+
+  Case Cases[]{
+  {
+  R"cpp(
+class A {
+  virtual void Foo() = 0;
+};)cpp",
+  R"cpp(
+class B : public A {^};
+  )cpp",
+  R"cpp(
+class B : public A {
+  void Foo() override {
+  }
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+class A {
+public:
+  virtual int Foo() = 0;
+};)cpp",
+  R"cpp(
+class ^B : public A {};
+  )cpp",
+  R"cpp(
+class B : public A {
+public:
+  int Foo() override {
+return {};
+  }
+};
+  )cpp",
+  },
+  {
+  R"cpp(
+class A {
+  virtual void Foo(int Param) = 0;
+};)cpp",
+  R"cpp(
+class ^B : public A {};
+  )cpp",
+  R"cpp(
+class B : public A {
+  void F

[PATCH] D95366: [WIP][clang][cli] Generate and round-trip preprocessor options

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 319902.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95366

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3025,9 +3025,83 @@
   llvm_unreachable("invalid frontend action");
 }
 
-static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
+static void GeneratePreprocessorArgs(PreprocessorOptions &Opts,
+ SmallVectorImpl &Args,
+ CompilerInvocation::StringAllocator SA,
+ const LangOptions &LangOpts,
+ const FrontendOptions &FrontendOpts,
+ const CodeGenOptions &CodeGenOpts) {
+  PreprocessorOptions *PreprocessorOpts = &Opts;
+
+#define PREPROCESSOR_OPTION_WITH_MARSHALLING(...)  \
+  GENERATE_OPTION_WITH_MARSHALLING(Args, SA, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef PREPROCESSOR_OPTION_WITH_MARSHALLING
+
+  if (Opts.PCHWithHdrStop && !Opts.PCHWithHdrStopCreate)
+GenerateArg(Args, OPT_pch_through_hdrstop_use, SA);
+
+  for (const auto &D : Opts.DeserializedPCHDeclsToErrorOn)
+GenerateArg(Args, OPT_error_on_deserialized_pch_decl, D, SA);
+
+  for (const auto &MP : Opts.MacroPrefixMap)
+GenerateArg(Args, OPT_fmacro_prefix_map_EQ, MP.first + "=" + MP.second, SA);
+
+  if (Opts.PrecompiledPreambleBytes != std::make_pair(0u, false))
+GenerateArg(Args, OPT_preamble_bytes_EQ,
+Twine(Opts.PrecompiledPreambleBytes.first) + "," +
+(Opts.PrecompiledPreambleBytes.second ? "1" : "0"),
+SA);
+
+  for (const auto &M : Opts.Macros) {
+// Don't generate __CET__ macro definitions. They are implied by the
+// -fcf-protection option that is generated elsewhere.
+if (M.first == "__CET__=1" && !M.second &&
+!CodeGenOpts.CFProtectionReturn && CodeGenOpts.CFProtectionBranch)
+  continue;
+if (M.first == "__CET__=2" && !M.second && CodeGenOpts.CFProtectionReturn &&
+!CodeGenOpts.CFProtectionBranch)
+  continue;
+if (M.first == "__CET__=3" && !M.second && CodeGenOpts.CFProtectionReturn &&
+CodeGenOpts.CFProtectionBranch)
+  continue;
+
+GenerateArg(Args, M.second ? OPT_U : OPT_D, M.first, SA);
+  }
+
+  for (const auto &I : Opts.Includes) {
+// Don't generate OpenCL includes. They are implied by other flags that are
+// generated elsewhere.
+if (LangOpts.OpenCL && LangOpts.IncludeDefaultHeader &&
+((LangOpts.DeclareOpenCLBuiltins && I == "opencl-c-base.h") ||
+ I == "opencl-c.h"))
+  continue;
+
+GenerateArg(Args, OPT_include, I, SA);
+  }
+
+  for (const auto &CI : Opts.ChainedIncludes)
+GenerateArg(Args, OPT_chain_include, CI, SA);
+
+  for (const auto &RF : Opts.RemappedFiles)
+GenerateArg(Args, OPT_remap_file, RF.first + ";" + RF.second, SA);
+
+  // Don't handle LexEditorPlaceholders. It is implied by the action that is
+  // generated elsewhere.
+}
+
+static bool ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args,
   DiagnosticsEngine &Diags,
-  frontend::ActionKind Action) {
+  frontend::ActionKind Action,
+  const FrontendOptions &FrontendOpts) {
+  PreprocessorOptions *PreprocessorOpts = &Opts;
+  bool Success = true;
+
+#define PREPROCESSOR_OPTION_WITH_MARSHALLING(...)  \
+  PARSE_OPTION_WITH_MARSHALLING(Args, Diags, Success, NO_PREFIX, __VA_ARGS__)
+#include "clang/Driver/Options.inc"
+#undef PREPROCESSOR_OPTION_WITH_MARSHALLING
+
   Opts.PCHWithHdrStop = Args.hasArg(OPT_pch_through_hdrstop_create) ||
 Args.hasArg(OPT_pch_through_hdrstop_use);
 
@@ -3098,6 +3172,48 @@
   // "editor placeholder in source file" error in PP only mode.
   if (isStrictlyPreprocessorAction(Action))
 Opts.LexEditorPlaceholders = false;
+
+  return Success;
+}
+
+static bool ParsePreprocessorArgs(CompilerInvocation &Res,
+  PreprocessorOptions &Opts, ArgList &Args,
+  DiagnosticsEngine &Diags,
+  frontend::ActionKind Action,
+  FrontendOptions &FrontendOpts) {
+  auto Temp = std::make_shared();
+
+  auto Parse = [Action](CompilerInvocation &Res, ArgList &Args,
+DiagnosticsEngine &Diags) {
+return ::ParsePreprocessorArgs(Res.getPreprocessorOpts(), Args, Diags,
+   

[clang] cfcc111 - [NFC] Disallow unused prefixes under clang/test/CodeGenCXX

2021-01-28 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2021-01-28T09:47:21-08:00
New Revision: cfcc1110d7733ad6c275eefd1773d243a719f9f3

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

LOG: [NFC] Disallow unused prefixes under clang/test/CodeGenCXX

The only test that needed change had 'QUAL' as an unused prefix. The
rest of the changes are to simplify the prefix lists.

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

Added: 
clang/test/CodeGenCXX/lit.local.cfg

Modified: 
clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
index 935fded5e67c..4f85effdc700 100644
--- a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview 
-emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN:FileCheck %s
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 
 void freefunc() { }
 // CHECK-DAG: "freefunc"

diff  --git a/clang/test/CodeGenCXX/lit.local.cfg 
b/clang/test/CodeGenCXX/lit.local.cfg
new file mode 100644
index ..c5bb8b60a52a
--- /dev/null
+++ b/clang/test/CodeGenCXX/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+



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


[PATCH] D95499: [NFC] Disallow unused prefixes under clang/test/CodeGenCXX

2021-01-28 Thread Mircea Trofin 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 rGcfcc1110d773: [NFC] Disallow unused prefixes under 
clang/test/CodeGenCXX (authored by mtrofin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95499

Files:
  clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
  clang/test/CodeGenCXX/lit.local.cfg


Index: clang/test/CodeGenCXX/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenCXX/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview 
-emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN:FileCheck %s
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 
 void freefunc() { }
 // CHECK-DAG: "freefunc"


Index: clang/test/CodeGenCXX/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenCXX/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+
Index: clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
===
--- clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN:FileCheck %s
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
 

[clang] cfcc111 - [NFC] Disallow unused prefixes under clang/test/CodeGenCXX

2021-01-28 Thread Mircea Trofin via cfe-commits

Author: Mircea Trofin
Date: 2021-01-28T09:47:21-08:00
New Revision: cfcc1110d7733ad6c275eefd1773d243a719f9f3

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

LOG: [NFC] Disallow unused prefixes under clang/test/CodeGenCXX

The only test that needed change had 'QUAL' as an unused prefix. The
rest of the changes are to simplify the prefix lists.

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

Added: 
clang/test/CodeGenCXX/lit.local.cfg

Modified: 
clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp 
b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
index 935fded5e67c..4f85effdc700 100644
--- a/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
+++ b/clang/test/CodeGenCXX/debug-info-codeview-display-name.cpp
@@ -1,19 +1,19 @@
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=line-tables-only -gcodeview 
-emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++98 | \
 // RUN:grep 'DISubprogram' | sed -e 's/.*name: "\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=QUAL
+// RUN:FileCheck %s
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null -std=c++11 | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 // RUN: %clang_cc1 -fblocks -debug-info-kind=limited -gcodeview -emit-llvm %s \
 // RUN:   -o - -triple=x86_64-pc-win32 -Wno-new-returns-null | \
 // RUN:grep -E 'DISubprogram|DICompositeType' | sed -e 's/.*name: 
"\([^"]*\)".*/"\1"/' | \
-// RUN:FileCheck %s --check-prefix=CHECK --check-prefix=UNQUAL
+// RUN:FileCheck %s --check-prefixes=CHECK,UNQUAL
 
 void freefunc() { }
 // CHECK-DAG: "freefunc"

diff  --git a/clang/test/CodeGenCXX/lit.local.cfg 
b/clang/test/CodeGenCXX/lit.local.cfg
new file mode 100644
index ..c5bb8b60a52a
--- /dev/null
+++ b/clang/test/CodeGenCXX/lit.local.cfg
@@ -0,0 +1,9 @@
+# -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79:
+from lit.llvm.subst import ToolSubst
+
+fc = ToolSubst('FileCheck', unresolved='fatal')
+# Insert this first. Then, we'll first update the blank FileCheck command; 
then,
+# the default substitution of FileCheck will replace it to its full path.
+config.substitutions.insert(0, (fc.regex,
+'FileCheck --allow-unused-prefixes=false'))
+



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


[PATCH] D71016: [SYCL] Implement OpenCL kernel function generation

2021-01-28 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 319909.
bader added a comment.

Addressed comment from Ronan in regression tests and synced them with the 
latest status.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71016

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Parse/ParseAST.cpp
  clang/lib/Sema/SemaSYCL.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenSYCL/Inputs/sycl.hpp
  clang/test/CodeGenSYCL/basic-kernel-wrapper.cpp
  clang/test/CodeGenSYCL/device-functions.cpp
  clang/test/SemaSYCL/Inputs/sycl.hpp
  clang/test/SemaSYCL/accessors-targets.cpp
  clang/test/SemaSYCL/address-space-parameter-conversions.cpp
  clang/test/SemaSYCL/basic-kernel-wrapper.cpp
  clang/test/SemaSYCL/built-in-type-kernel-arg.cpp
  clang/test/SemaSYCL/fake-accessors.cpp
  clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
  clang/test/SemaSYCL/mangle-kernel.cpp

Index: clang/test/SemaSYCL/mangle-kernel.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/mangle-kernel.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -I %S/../Headers/Inputs/include/ -ast-dump %s | FileCheck %s --check-prefix=CHECK-64
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir-unknown-unknown-sycldevice -I %S/../Headers/Inputs/include/ -ast-dump %s | FileCheck %s --check-prefix=CHECK-32
+#include "Inputs/sycl.hpp"
+#include 
+
+// This test checks that SYCL kernel name mangling matches Itanium ABI
+
+template 
+__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
+  kernelFunc();
+}
+
+template 
+class SimpleVadd;
+
+int main() {
+  kernel>(
+  [=](){});
+
+  kernel>(
+  [=](){});
+
+  kernel>(
+  [=](){});
+  return 0;
+}
+
+// CHECK: _ZTS10SimpleVaddIiE
+// CHECK: _ZTS10SimpleVaddIdE
+// CHECK-64: _ZTS10SimpleVaddImE
+// CHECK-32: _ZTS10SimpleVaddIjE
Index: clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
===
--- clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
+++ clang/test/SemaSYCL/kernel-attribute-on-non-sycl.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl-is-device -verify %s
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 
 #ifndef __SYCL_DEVICE_ONLY__
 // expected-warning@+7 {{'sycl_kernel' attribute ignored}}
Index: clang/test/SemaSYCL/fake-accessors.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/fake-accessors.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -ast-dump %s | FileCheck %s
+
+// This test checks that the compiler handles SYCL kenrel parameters of accessor
+// type correctly (i.e. sends a pointer as a separate parameter) and doesn't
+// apply this approach for user types even if they have the same name (e.g. 
+// `accessor` or `foo::cl::sycl::accessor`). We also verify that type aliasing
+// via typedef or using doesn't confuse the compiler.
+
+#include "Inputs/sycl.hpp"
+
+namespace foo {
+namespace cl {
+namespace sycl {
+class accessor {
+public:
+  int field;
+};
+} // namespace sycl
+} // namespace cl
+} // namespace foo
+
+class accessor {
+public:
+  int field;
+};
+
+typedef cl::sycl::accessor
+MyAccessorTD;
+
+using MyAccessorA = cl::sycl::accessor;
+
+template 
+__attribute__((sycl_kernel)) void kernel(const Func &kernelFunc) {
+  kernelFunc();
+}
+
+int main() {
+  foo::cl::sycl::accessor acc = {1};
+  accessor acc1 = {1};
+
+  cl::sycl::accessor accessorA;
+  cl::sycl::accessor accessorB;
+  cl::sycl::accessor accessorC;
+kernel(
+[=]() {
+  accessorA.use((void*)(acc.field + acc1.field));
+});
+kernel(
+[=]() {
+  accessorB.use((void*)(acc.field + acc1.field));
+});
+kernel(
+[=]() {
+  accessorC.use((void*)(acc.field + acc1.field));
+});
+kernel(
+[=]() {
+  acc.field + acc1.field;
+});
+  return 0;
+}
+// CHECK: fake_accessors{{.*}} 'void (__global int *, cl::sycl::range<1>, cl::sycl::range<1>, cl::sycl::id<1>, foo::cl::sycl::accessor, accessor)
+// CHECK: accessor_typedef{{.*}} 'void (__global int *, cl::sycl::range<1>, cl::sycl::range<1>, cl::sycl::id<1>, foo::cl::sycl::accessor, accessor)
+// CHECK: accessor_alias{{.*}} 'void (__global int *, cl::sycl::range<1>, cl::sycl::range<1>, cl::sycl::id<1>, foo::cl::sycl::accessor, accessor)
+// CHECK: user_types{{.*}} 'void (foo::cl::sycl::accessor, accessor)
Index: clang/test/SemaSYCL/built-in-type-kernel-arg.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/built-in-type-kernel-arg.cpp

[PATCH] D71016: [SYCL] Implement OpenCL kernel function generation

2021-01-28 Thread Alexey Bader via Phabricator via cfe-commits
bader commandeered this revision.
bader edited reviewers, added: Fznamznon; removed: bader.
bader added inline comments.



Comment at: clang/test/CodeGenSYCL/device-functions.cpp:2
+// RUN: %clang_cc1 -triple spir64 -fsycl-is-device -S -emit-llvm %s -o - | 
FileCheck %s
+
+template 

keryell wrote:
> Missing description about the purpose of this test
Done.



Comment at: clang/test/SemaSYCL/fake-accessors.cpp:2
+// RUN: %clang_cc1 -I %S/Inputs -fsycl-is-device -ast-dump %s | FileCheck %s
+
+#include 

keryell wrote:
> Missing description about the purpose of this test.
> I am struggling about understanding what this test is for...
> OK, after coming back later, I think I got it. I was confused by the fact 
> that in the kernels you are using both true accessors (A, B & C) *and* some 
> objects with names similar to SYCL accessor.
> Is it possible to have some tests without true accessors?
Added a new test case w/o SYCL accessor and description of the test.



Comment at: clang/test/SemaSYCL/mangle-kernel.cpp:3
+// RUN: %clang_cc1 -triple spir-unknown-unknown-unknown -I %S/Inputs -I 
%S/../Headers/Inputs/include/ -fsycl-is-device -ast-dump %s | FileCheck %s 
--check-prefix=CHECK-32
+#include 
+#include 

keryell wrote:
> Missing description about the purpose of this test
Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71016

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


[PATCH] D95307: [StaticAnalyzer] Add checking for degenerate base class in MemRegion

2021-01-28 Thread Deep Majumder via Phabricator via cfe-commits
RedDocMD added a comment.

@kromanenkov  I guess it won't work then. Thanks for the idea!
Now that I think about it removing duplicates is probably not the right thing 
to do. The problem arises because the call PTMD->getCXXBaseList() should 
ideally return the list of previous casts, but instead returns the base 
class(es) of the struct whose pointer-to-member we are defining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95307

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


[PATCH] D95017: [clang-format] Add case aware include sorting.

2021-01-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

I like this much better LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95017

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


[PATCH] D95516: [WIP][clang][cli] Benchmark command line round-trip

2021-01-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 319917.
jansvoboda11 added a comment.

Remove hard-coded arguments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95516

Files:
  clang/CMakeLists.txt
  clang/benchmarks/CMakeLists.txt
  clang/benchmarks/CompilerInvocationBench.cpp

Index: clang/benchmarks/CompilerInvocationBench.cpp
===
--- /dev/null
+++ clang/benchmarks/CompilerInvocationBench.cpp
@@ -0,0 +1,77 @@
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+
+#include "benchmark/benchmark.h"
+
+using namespace llvm;
+using namespace clang;
+
+// Pointer to '--' in Argv that got replaced by '-round-trip-args'.
+static const char **Begin;
+
+// Pointer to the end of Argv.
+static const char **End;
+
+// Returns a dummy DiagnosticsEngine.
+static DiagnosticsEngine &Diags() {
+  static IntrusiveRefCntPtr Diags =
+  CompilerInstance::createDiagnostics(new DiagnosticOptions,
+  new TextDiagnosticBuffer);
+  return *Diags;
+}
+
+// Parses the command line arguments starting **after** the injected
+// '-round-trip-args', resulting in a parse **without** round-trip.
+static void BM_CompilerInvocationNoRoundTrip(benchmark::State &State) {
+  for (auto _ : State) {
+CompilerInvocation Invocation;
+CompilerInvocation::CreateFromArgs(Invocation, {Begin + 1, End}, Diags());
+  }
+}
+
+// Parses the command line arguments starting **at** the injected
+// '-round-trip-args', resulting in a parse **with** round-trip.
+static void BM_CompilerInvocationDoRoundTrip(benchmark::State &State) {
+  for (auto _ : State) {
+CompilerInvocation Invocation;
+CompilerInvocation::CreateFromArgs(Invocation, {Begin, End}, Diags());
+  }
+}
+
+BENCHMARK(BM_CompilerInvocationNoRoundTrip);
+BENCHMARK(BM_CompilerInvocationDoRoundTrip);
+
+// USAGE:
+// ./CompilerInvocationBench [ Google Benchmark options ... ] \
+//-- [ CompilerInvocation::CreateFromArgs arguments ... ]
+int main(int Argc, const char *Argv[]) {
+  // Find the '--' argument.
+  int DashDashIndex = 0;
+  for (int i = 0; i < Argc; ++i)
+if (StringRef(Argv[i]) == "--")
+  DashDashIndex = i;
+
+  if (DashDashIndex == 0) {
+llvm::errs() << "USAGE:\n"
+ << "  " << Argv[0] << " [ Google Benchmark options ... ] -- "
+ << "[ CompilerInvocation::CreateFromArgs arguments ... ]\n";
+return 1;
+  }
+
+  // Remove all '-round-trip-args' occurrences.
+  for (int i = DashDashIndex + 1; i < Argc; ++i)
+if (StringRef(Argv[i]) == "-round-trip-args")
+  Argv[i] = "";
+
+  // Inject '-round-trip-args' in place of '--'.
+  Argv[DashDashIndex] = "-round-trip-args";
+
+  Begin = Argv + DashDashIndex;
+  End = Argv + Argc;
+
+  int BenchmarkArgc = DashDashIndex - Argc;
+
+  ::benchmark::Initialize(&BenchmarkArgc, const_cast(Argv));
+  ::benchmark::RunSpecifiedBenchmarks();
+}
Index: clang/benchmarks/CMakeLists.txt
===
--- /dev/null
+++ clang/benchmarks/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_benchmark(CompilerInvocationBench CompilerInvocationBench.cpp)
+
+target_link_libraries(CompilerInvocationBench
+  PRIVATE
+  clangFrontend
+  LLVMSupport
+  )
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -879,6 +879,10 @@
   process_llvm_pass_plugins()
 endif()
 
+if (LLVM_INCLUDE_BENCHMARKS)
+  add_subdirectory(benchmarks)
+endif()
+
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
   ${CLANG_BINARY_DIR}/include/clang/Config/config.h)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2021-01-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D69322#2523058 , @tra wrote:

> @hliao -- Can you take a look at  
> https://bugs.llvm.org/show_bug.cgi?id=48866. This patch may be relevant there.

@rnk Reid, looks like this patch does fix a lambda mangling issue in CUDA on 
Windows. Could you take another look at it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

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


[PATCH] D95634: [PowerPC][Power10] Fix XXSPLI32DX not correctly exploiting specific cases

2021-01-28 Thread Albion Fung via Phabricator via cfe-commits
Conanap created this revision.
Conanap added reviewers: nemanjai, saghir, PowerPC.
Conanap added projects: LLVM, clang, PowerPC.
Herald added a subscriber: kbarton.
Conanap requested review of this revision.

Some cases may be transformed into 32 bit splats before hitting the boolean 
statement, which may cause incorrect behaviour and provide XXSPLTI32DX with the 
incorrect values of splat. The condition was reversed so that the shortcut 
prevents this problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95634

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/p10-splatImm32.ll


Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -117,7 +117,8 @@
 define dso_local <16 x i8> @constSplatBug() {
 ; CHECK-LABEL: constSplatBug:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI10_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NEXT:xxsplti32dx vs34, 0, 1191182336
 ; CHECK-NEXT:blr
 entry:
   ret <16 x i8> 
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -8604,11 +8604,12 @@
 
   // If it is a splat of a double, check if we can shrink it to a 32 bit
   // non-denormal float which when converted back to double gives us the same
-  // double. This is to exploit the XXSPLTIDP instruction.+  // If we lose 
precision, we use XXSPLTI32DX.
+  // double. This is to exploit the XXSPLTIDP instruction.
+  // If we lose precision, we use XXSPLTI32DX.
   if (BVNIsConstantSplat && (SplatBitSize == 64) &&
   Subtarget.hasPrefixInstrs()) {
-if (convertToNonDenormSingle(APSplatBits) &&
-(Op->getValueType(0) == MVT::v2f64)) {
+if ((Op->getValueType(0) == MVT::v2f64) &&
+convertToNonDenormSingle(APSplatBits)) {
   SDValue SplatNode = DAG.getNode(
   PPCISD::XXSPLTI_SP_TO_DP, dl, MVT::v2f64,
   DAG.getTargetConstant(APSplatBits.getZExtValue(), dl, MVT::i32));


Index: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm32.ll
@@ -117,7 +117,8 @@
 define dso_local <16 x i8> @constSplatBug() {
 ; CHECK-LABEL: constSplatBug:
 ; CHECK:   # %bb.0: # %entry
-; CHECK-NEXT:plxv vs34, .LCPI10_0@PCREL(0), 1
+; CHECK-NEXT:xxlxor vs34, vs34, vs34
+; CHECK-NEXT:xxsplti32dx vs34, 0, 1191182336
 ; CHECK-NEXT:blr
 entry:
   ret <16 x i8> 
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -8604,11 +8604,12 @@
 
   // If it is a splat of a double, check if we can shrink it to a 32 bit
   // non-denormal float which when converted back to double gives us the same
-  // double. This is to exploit the XXSPLTIDP instruction.+  // If we lose precision, we use XXSPLTI32DX.
+  // double. This is to exploit the XXSPLTIDP instruction.
+  // If we lose precision, we use XXSPLTI32DX.
   if (BVNIsConstantSplat && (SplatBitSize == 64) &&
   Subtarget.hasPrefixInstrs()) {
-if (convertToNonDenormSingle(APSplatBits) &&
-(Op->getValueType(0) == MVT::v2f64)) {
+if ((Op->getValueType(0) == MVT::v2f64) &&
+convertToNonDenormSingle(APSplatBits)) {
   SDValue SplatNode = DAG.getNode(
   PPCISD::XXSPLTI_SP_TO_DP, dl, MVT::v2f64,
   DAG.getTargetConstant(APSplatBits.getZExtValue(), dl, MVT::i32));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94500: Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-01-28 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj marked 8 inline comments as done.
timwoj added a comment.

No problem, sorry it took a bit of back-and-forth there. Is there any way this 
can sneak into 12.0?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D95634: [PowerPC][Power10] Fix XXSPLI32DX not correctly exploiting specific cases

2021-01-28 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM as long as the nits are addressed on the commit.




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:8611
   Subtarget.hasPrefixInstrs()) {
-if (convertToNonDenormSingle(APSplatBits) &&
-(Op->getValueType(0) == MVT::v2f64)) {
+if ((Op->getValueType(0) == MVT::v2f64) &&
+convertToNonDenormSingle(APSplatBits)) {

```
// Check the type first to short-circuit so we don't modify APSplatBits if
// this block isn't executed.
```



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:8617
   return DAG.getBitcast(Op.getValueType(), SplatNode);
 } else if (APSplatBits.getBitWidth() == 64) {
   // We may lose precision, so we have to use XXSPLTI32DX.

We can get rid of this now that the problem is fixed (i.e. this can go back to 
just being an `else`).



Comment at: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll:104
 
 define dso_local <16 x i8> @test_xxsplti32dx_10() {
 ; CHECK-LABEL: test_xxsplti32dx_10:

Get rid of this test case now. It is redundant.



Comment at: llvm/test/CodeGen/PowerPC/p10-splatImm32.ll:114
 
 ; FIXME: It appears that there is something wrong with the computation
 ;of the 64-bit constant to splat so we cannot emit xxsplti32dx for

Get rid of this comment now, the FIXME has been addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95634

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


[PATCH] D95634: [PowerPC][Power10] Fix XXSPLI32DX not correctly exploiting specific cases

2021-01-28 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95634

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


[PATCH] D95557: [WebAssembly] Prototype i8x16 to i32x4 widening instructions

2021-01-28 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td:1279
+(I32x4.vt (int_wasm_widen_signed
+  (I8x16.vt V128:$vec), (i32 timm:$idx],
+ "i32x4.widen_i8x16_s\t$dst, $vec, $idx",

aheejin wrote:
> I think this is the first time we use `timm` in this file... Haven't we used 
> `LaneIdxN` for these? The same for `WIDEN_I8x16_TO_I32x4_U`.
Yes, this is the first use of `timm`. I needed to use `timm` instead of `imm` 
(or a `LaneIdxN`, which is just a restricted `imm`) because `immarg` arguments 
are apparently lowered to TargetConstant nodes rather than Constant nodes. This 
is also the first time I've used an `immarg` arument in one of the intrinsics, 
but I should definitely use them for many other intrinsics as well, and 
probably change `LaneIdxN` to be based on `timm` rather than `imm`. Since these 
are just prototype instructions, I am ok with them working differently from 
other instructions for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95557

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


[PATCH] D95557: [WebAssembly] Prototype i8x16 to i32x4 widening instructions

2021-01-28 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

In D95557#2527731 , @aheejin wrote:

> This does not yet have i64x2 version of the instructions in 
> https://github.com/WebAssembly/simd/pull/395 yet, right?

Yes, that's intentional. These are the only versions implemented in V8 as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95557

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


[PATCH] D95557: [WebAssembly] Prototype i8x16 to i32x4 widening instructions

2021-01-28 Thread Thomas Lively 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 rG4b68b64dcc5b: [WebAssembly] Prototype i8x16 to i32x4 
widening instructions (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95557

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -760,4 +760,10 @@
 # CHECK: f64x2.promote_low_f32x4 # encoding: [0xfd,0x69]
 f64x2.promote_low_f32x4
 
+# CHECK: i32x4.widen_i8x16_s 3 # encoding: [0xfd,0x67,0x03]
+i32x4.widen_i8x16_s 3
+
+# CHECK: i32x4.widen_i8x16_u 3 # encoding: [0xfd,0x68,0x03]
+i32x4.widen_i8x16_u 3
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -586,6 +586,27 @@
   ret <4 x i32> %v
 }
 
+
+; CHECK-LABEL: widen_signed_v4i32:
+; SIMD128-NEXT: .functype widen_signed_v4i32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: i32x4.widen_i8x16_s $push[[R:[0-9]+]]=, $0, 1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.wasm.widen.signed(<16 x i8>, i32 immarg)
+define <4 x i32> @widen_signed_v4i32(<16 x i8> %x) {
+  %v = call <4 x i32> @llvm.wasm.widen.signed(<16 x i8> %x, i32 1)
+  ret <4 x i32> %v
+}
+
+; CHECK-LABEL: widen_unsigned_v4i32:
+; SIMD128-NEXT: .functype widen_unsigned_v4i32 (v128) -> (v128){{$}}
+; SIMD128-NEXT: i32x4.widen_i8x16_u $push[[R:[0-9]+]]=, $0, 1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.wasm.widen.unsigned(<16 x i8>, i32 immarg)
+define <4 x i32> @widen_unsigned_v4i32(<16 x i8> %x) {
+  %v = call <4 x i32> @llvm.wasm.widen.unsigned(<16 x i8> %x, i32 1)
+  ret <4 x i32> %v
+}
+
 ; ==
 ; 2 x i64
 ; ==
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -1256,7 +1256,6 @@
 defm "" : SIMDConvert;
 
-
 // Prototype f64x2 conversions
 defm "" : SIMDConvert;
@@ -1271,6 +1270,25 @@
 defm "" : SIMDConvert;
 
+// Prototype i8x16 to i32x4 widening
+defm WIDEN_I8x16_TO_I32x4_S :
+  SIMD_I<(outs V128:$dst), (ins V128:$vec, vec_i8imm_op:$idx),
+ (outs), (ins vec_i8imm_op:$idx),
+ [(set (I32x4.vt V128:$dst),
+(I32x4.vt (int_wasm_widen_signed
+  (I8x16.vt V128:$vec), (i32 timm:$idx],
+ "i32x4.widen_i8x16_s\t$dst, $vec, $idx",
+ "i32x4.widen_i8x16_s\t$idx", 0x67>;
+defm WIDEN_I8x16_TO_I32x4_U :
+  SIMD_I<(outs V128:$dst), (ins V128:$vec, vec_i8imm_op:$idx),
+ (outs), (ins vec_i8imm_op:$idx),
+ [(set (I32x4.vt V128:$dst),
+(I32x4.vt (int_wasm_widen_unsigned
+  (I8x16.vt V128:$vec), (i32 timm:$idx],
+ "i32x4.widen_i8x16_u\t$dst, $vec, $idx",
+ "i32x4.widen_i8x16_u\t$idx", 0x68>;
+
+
 //===--===//
 // Quasi-Fused Multiply- Add and Subtract (QFMA/QFMS)
 //===--===//
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -348,6 +348,14 @@
   Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty],
 [IntrNoMem, IntrSpeculatable]>;
 
+// TODO: Remove these if possible if they are merged to the spec.
+def int_wasm_widen_signed :
+  Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable, ImmArg>]>;
+def int_wasm_widen_unsigned :
+  Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable, ImmArg>]>;
+
 //===--===//
 // Thread-local storage intrinsics
 //===--===//
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtin

[clang] 4b68b64 - [WebAssembly] Prototype i8x16 to i32x4 widening instructions

2021-01-28 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2021-01-28T10:59:32-08:00
New Revision: 4b68b64dcc5bcd6f29779b820791611c60438385

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

LOG: [WebAssembly] Prototype i8x16 to i32x4 widening instructions

As proposed in https://github.com/WebAssembly/simd/pull/395 and matching the
opcodes used in V8:
https://chromium-review.googlesource.com/c/v8/v8/+/2617385/4/src/wasm/wasm-opcodes.h

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index bb7d6d379e58..84f346bcb928 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -206,6 +206,9 @@ TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i64x2, 
"V2LLiV4i", "nc", "simd1
 TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", 
"simd128")
 
+TARGET_BUILTIN(__builtin_wasm_widen_s_i8x16_i32x4, "V4iV16ScIi", "nc", 
"simd128")
+TARGET_BUILTIN(__builtin_wasm_widen_u_i8x16_i32x4, "V4UiV16UcIi", "nc", 
"simd128")
+
 TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_convert_low_u_i32x4_f64x2, "V2dV4Ui", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_s_f64x2_i32x4, "V4iV2d", 
"nc", "simd128")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 113541bd5024..973a20f2f58c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17220,6 +17220,24 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo);
 return Builder.CreateCall(Callee, Vec);
   }
+  case WebAssembly::BI__builtin_wasm_widen_s_i8x16_i32x4:
+  case WebAssembly::BI__builtin_wasm_widen_u_i8x16_i32x4: {
+Value *Vec = EmitScalarExpr(E->getArg(0));
+llvm::APSInt SubVecConst =
+*E->getArg(1)->getIntegerConstantExpr(getContext());
+Value *SubVec = llvm::ConstantInt::get(getLLVMContext(), SubVecConst);
+unsigned IntNo;
+switch (BuiltinID) {
+case WebAssembly::BI__builtin_wasm_widen_s_i8x16_i32x4:
+  IntNo = Intrinsic::wasm_widen_signed;
+  break;
+case WebAssembly::BI__builtin_wasm_widen_u_i8x16_i32x4:
+  IntNo = Intrinsic::wasm_widen_unsigned;
+  break;
+}
+Function *Callee = CGM.getIntrinsic(IntNo);
+return Builder.CreateCall(Callee, {Vec, SubVec});
+  }
   case WebAssembly::BI__builtin_wasm_convert_low_s_i32x4_f64x2:
   case WebAssembly::BI__builtin_wasm_convert_low_u_i32x4_f64x2: {
 Value *Vec = EmitScalarExpr(E->getArg(0));

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index 61fc76cd1873..771764c85d6b 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -976,6 +976,18 @@ u64x2 widen_high_u_i32x4_i64x2(u32x4 x) {
   // WEBASSEMBLY: ret
 }
 
+i32x4 widen_s_i8x16_i32x4(i8x16 x) {
+  return __builtin_wasm_widen_s_i8x16_i32x4(x, 3);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.widen.signed(<16 x i8> %x, i32 3)
+  // WEBASSEMBLY: ret
+}
+
+u32x4 widen_u_i8x16_i32x4(u8x16 x) {
+  return __builtin_wasm_widen_u_i8x16_i32x4(x, 3);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.widen.unsigned(<16 x i8> %x, i32 3)
+  // WEBASSEMBLY: ret
+}
+
 f64x2 convert_low_s_i32x4_f64x2(i32x4 x) {
   return __builtin_wasm_convert_low_s_i32x4_f64x2(x);
   // WEBASSEMBLY: call <2 x double> @llvm.wasm.convert.low.signed(<4 x i32> %x)

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index d306d0ccb90d..323b9a770c05 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -348,6 +348,14 @@ def int_wasm_promote_low :
   Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty],
 [IntrNoMem, IntrSpeculatable]>;
 
+// TODO: Remove these if possible if they are merged to the spec.
+def int_wasm_widen_signed :
+  Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable, ImmArg>]>;
+def int_wasm_widen_unsigned :
+  Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable, ImmArg>]>;
+
 

[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-28 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau created this revision.
Herald added subscribers: teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, mgorny.
ctetreau requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, stephenneuendorffer, 
nicolasvasilache.
Herald added projects: clang, MLIR, LLVM.

Previously, CMake would find any version of Python3. However, the project
claims to require 3.6 or greater, and 3.6 features are being used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95635

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  llvm/CMakeLists.txt
  mlir/CMakeLists.txt


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,7 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,7 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -79,7 +79,7 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 3.6 COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -697,7 +697,7 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,7 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,7 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 3.6 REQUIRED COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2021-01-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:395-400
 /// The number used to indicate this lambda expression for name
 /// mangling in the Itanium C++ ABI.
 unsigned ManglingNumber : 31;
 
+/// The device side mangling number.
+unsigned DeviceManglingNumber = 0;

hliao wrote:
> rnk wrote:
> > It seems a shame to grow LambdaDefinitionData by a pointer for all users of 
> > C++ that do not use CUDA. Optimizing bitfields may be worth the time, but 
> > I'll leave it to @rjmccall or @rsmith to give guidance on whether that's 
> > worth it.
> > 
> > An alternative would be to store the device numbers in the mangling context 
> > and look them up when needed, since they are so rarely needed.
> I like the alternative way by storing all numbering into the mangle/numbering 
> context instead of AST itself. But, it needs additional numbering 
> post-processing after AST importing. Sound to me a major refactoring work 
> likely to be addressed later.
Generally, I don't think we can count on contributors to come back later and 
optimize memory usage, so it seems reasonable to ask to avoid the regression in 
the first place. Above I see the bitfield usage optimizing memory usage of the 
number of captures, and then here we spent lots of memory storing device 
mangling numbers that are only used for CUDA. I think the memory usage concern 
still stands. I don't think it's unreasonable to maintain these numbers on the 
side in a DenseMap.

@rsmith or @rjmccall, do you agree with that reasoning?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322

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


[PATCH] D95635: [CMake] Actually require python 3.6 or greater

2021-01-28 Thread Julian Lettner via Phabricator via cfe-commits
yln added a comment.

LGTM, thanks!  (I got bitten by this.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-01-28 Thread Alex Orlov via Phabricator via cfe-commits
aorlov added a comment.

One more ping. Please, pay attention to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


  1   2   >