[PATCH] D91239: Update attribute example to fit the new Annotation API

2020-11-11 Thread Yafei Liu via Phabricator via cfe-commits
psionic12 created this revision.
psionic12 added reviewers: john.brawn, aaron.ballman, Tyker, erichkeane.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
psionic12 requested review of this revision.

Since AnnotationAttr can add extra arguments
now, update Attribute plugin example to fit this API
to make this example compiled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91239

Files:
  clang/examples/Attribute/Attribute.cpp
  clang/test/Frontend/plugin-attribute.cpp


Index: clang/test/Frontend/plugin-attribute.cpp
===
--- clang/test/Frontend/plugin-attribute.cpp
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -6,20 +6,17 @@
 [[example]] void fn1b() { }
 [[plugin::example]] void fn1c() { }
 void fn2() __attribute__((example("somestring"))) { }
-// ATTRIBUTE: warning: 'example' attribute only applies to functions
+// ATTRIBUTE: warning: 'example' attribute only applies to functions 
[-Wignored-attributes]
 int var1 __attribute__((example("otherstring"))) = 1;
 
-// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] 
c"example()\00"
-// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] 
c"example(somestring)\00"
-// ATTRIBUTE: @llvm.global.annotations = 
{{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]
+// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [8 x i8] 
c"example\00", section "llvm.metadata"
+// ATTRIBUTE: @llvm.global.annotations = 
{{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}
 
 #ifdef BAD_ATTRIBUTE
 class Example {
   // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
   void __attribute__((example)) fn3();
 };
-// BADATTRIBUTE: error: 'example' attribute requires a string
-void fn4() __attribute__((example(123))) { }
 // BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
 void fn5() __attribute__((example("a","b"))) { }
 #endif
Index: clang/examples/Attribute/Attribute.cpp
===
--- clang/examples/Attribute/Attribute.cpp
+++ clang/examples/Attribute/Attribute.cpp
@@ -55,23 +55,29 @@
   S.Diag(Attr.getLoc(), ID);
   return AttributeNotApplied;
 }
-// Check if we have an optional string argument.
-StringRef Str = "";
-if (Attr.getNumArgs() > 0) {
-  Expr *ArgExpr = Attr.getArgAsExpr(0);
-  StringLiteral *Literal =
-  dyn_cast(ArgExpr->IgnoreParenCasts());
-  if (Literal) {
-Str = Literal->getString();
-  } else {
-S.Diag(ArgExpr->getExprLoc(), diag::err_attribute_argument_type)
-<< Attr.getAttrName() << AANT_ArgumentString;
-return AttributeNotApplied;
-  }
+
+// First we have to create an `StringLiteralExpr`.
+StringRef AnnotationString = "example";
+QualType StrTy = S.Context.getConstantArrayType(
+S.Context.adjustStringLiteralBaseType(S.Context.CharTy.withConst()),
+llvm::APInt(32, AnnotationString.size()), nullptr, ArrayType::Normal,
+0);
+const auto AnnotationStringLoc = Attr.getLoc();
+auto *StringExpr =
+StringLiteral::Create(S.Context, AnnotationString, 
StringLiteral::Ascii,
+  /*Pascal*/ false, StrTy, &AnnotationStringLoc, 
1);
+
+llvm::SmallVector Args;
+Args.reserve(Attr.getNumArgs() + 1);
+
+// Add the `StringLiteralExpr` as the first argument to an `AnnotationAttr`
+Args.push_back(StringExpr);
+for (unsigned Idx = 1; Idx < Attr.getNumArgs(); Idx++) {
+  Args.push_back(Attr.getArgAsExpr(Idx));
 }
+
 // Attach an annotate attribute to the Decl.
-D->addAttr(AnnotateAttr::Create(S.Context, "example(" + Str.str() + ")",
-Attr.getRange()));
+S.AddAnnotationAttr(D, {Attr.getRange()}, AnnotationString, Args);
 return AttributeApplied;
   }
 };


Index: clang/test/Frontend/plugin-attribute.cpp
===
--- clang/test/Frontend/plugin-attribute.cpp
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -6,20 +6,17 @@
 [[example]] void fn1b() { }
 [[plugin::example]] void fn1c() { }
 void fn2() __attribute__((example("somestring"))) { }
-// ATTRIBUTE: warning: 'example' attribute only applies to functions
+// ATTRIBUTE: warning: 'example' attribute only applies to functions [-Wignored-attributes]
 int var1 __attribute__((example("otherstring"))) = 1;
 
-// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
-// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
-// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}

[PATCH] D91239: Update attribute example to fit the new Annotation API

2020-11-11 Thread Yafei Liu via Phabricator via cfe-commits
psionic12 added inline comments.



Comment at: clang/examples/Attribute/Attribute.cpp:59
+
+// First we have to create an `StringLiteralExpr`.
+StringRef AnnotationString = "example";

`AnnotationAttr` is used as an extra information in attribute plugin designs. 
Usually after handling the customized attribute, coders will add an 
`AnnotationAttr` into the AST, for later use.

Before the new API released, create an `AnnotationAttr` is not very hard.

But now `AnnotationAttr` accepts a StringLiteralExpr as it's first argument, in 
order to do the same thing I mentioned above, we have to create an 
`StringLiteralExpr` from nowhere, which looks not very elegant to me. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91239

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


[PATCH] D91134: [clangd] Abort rename when given the same name

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304423.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.

- Change error message to description rather than suggestion.
- Move test to more appropriate location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91134

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(//
+void func() {
+  int V^ar;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "Var"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, 
{/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
 
-  // single-file rename on global symbols, we should report an error.
+  // Single-file rename on global symbols, we should report an error.
   Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
  /*NewName=*/llvm::None, {/*CrossFile=*/false});
   EXPECT_FALSE(Results);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,6 +123,7 @@
 
   // name validation.
   RenameToKeywords,
+  SameName,
 };
 
 llvm::Optional renameable(const NamedDecl &RenameDecl,
@@ -213,6 +214,8 @@
   return "there are multiple symbols at the given location";
 case ReasonToReject::RenameToKeywords:
   return "the chosen name is a keyword";
+case ReasonToReject::SameName:
+  return "new name is the same as the old name";
 }
 llvm_unreachable("unhandled reason kind");
   };
@@ -558,6 +561,8 @@
 return makeError(ReasonToReject::AmbiguousSymbol);
   const auto &RenameDecl =
   llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  if (RenameDecl.getName() == RInputs.NewName)
+return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
 return makeError(*Invalid);


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(//
+void func() {
+  int V^ar;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "Var"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, {/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
 
-  // single-file rename on global symbols, we should report an error.
+  // Single-file rename on global symbols, we should report an error.
   Re

[PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:636
+// Filter out any reformat fixits, we don't handle these.
+// FIXME: Can we?
+llvm::erase_if(FixIts,

in theory yes, as we have access to source manager, we can fetch file contents 
and create formatted  replacements (see `cleanupAndFormat`). but formatting 
those fixes can imply significant delays on clangd's diagnostic cycles (if 
there are many of those), that's the reason why we currently don't format 
fixits.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:637
+// FIXME: Can we?
+llvm::erase_if(FixIts,
+   [](const FixItHint &Fix) { return Fix.isReformatFixit(); });

rather than doing an extra loop, can we just skip those in the for loop below ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-11-11 Thread Simon Moll via Phabricator via cfe-commits
simoll abandoned this revision.
simoll added a comment.

Taking this off the review queues - we will use the `ext_vector_type` attribute 
instead (D88905 ).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D91134: [clangd] Abort rename when given the same name

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked an inline comment as not done.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:218
+case ReasonToReject::SameName:
+  return "new name should differ from the old name";
 }

hokein wrote:
> sammccall wrote:
> > hokein wrote:
> > > returning an error seems to be an interesting idea, thinking more about 
> > > that, it might be better than just returning an empty workspaceEdit 
> > > silently without noticing user.
> > > 
> > We don't know what the user's intent was here - it's at least somewhat 
> > likely they changed their mind about the operation but hit "enter" instead 
> > of "escape". So a message describing the situation "new name is the same as 
> > the old name" would be more appropriate than suggesting a correction.
> > 
> > But I'm wondering whether this error message actually helps (vs 
> > "succeeding" with no edits). Is it actionable? What's the scenario where 
> > the user:
> > a) doesn't already know that the name is the same, and
> > b) will take some action as a result (rather than leave the name unchanged)
> > 
> >  a message describing the situation "new name is the same as the old name" 
> > would be more appropriate than suggesting a correction.
> 
> SG.
> 
> In an ideal world, I'd expect we emit a non-error message to inform that 
> there is nothing happen for the rename, but LSP doesn't have such option :(
> 
> The behavior of editors are varied on this case, e.g.
> - VSCode just succeeds with no edits;
> - our internal editor emits a message like "nothing to rename";
> But I'm wondering whether this error message actually helps (vs "succeeding" 
> with no edits). Is it actionable? What's the  scenario where the user:
> a) doesn't already know that the name is the same, and
> b) will take some action as a result (rather than leave the name unchanged)

I can understand this point of view, but I'm a bit sceptical of the "fail" 
silently approach. The "actionable" for user would be to not type in the same 
name as before :)

Also, user might wanted to rename the symbol to something slightly different 
(e.g. fix typo) and then have a typo in new name, too. I think there is value 
in telling the user that there was no rename because the name is the same - I 
don't think it hurts them in any way. We're just being explicit in what 
happened/didn't happen. I think "new name = old name" can be a reasonable 
"error" scenario and I think there is a definite value in being explicit about 
what we do or decide not to do.

My point is that I can't see a scenario when user actually wants to rename the 
symbol deliberately using the same name and I think this should, in fact, be an 
error to do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91134

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


[PATCH] D91124: [clangd] Call hierarchy (ClangdLSPServer layer)

2020-11-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/test/call-hierarchy.test:39
+---
+{"jsonrpc":"2.0","id":2,"method":"callHierarchy/incomingCalls","params":{"item":{"data":"F0E64FE3F8FEA480","kind":12,"name":"callee","range":{"end":{"character":16,"line":0},"start":{"character":0,"line":0}},"selectionRange":{"end":{"character":11,"line":0},"start":{"character":5,"line":0}},"uri":"test:///main.cpp"}}}
+#  CHECK:  "id": 2,

nridge wrote:
> kadircet wrote:
> > it feels fragile to depend on USRs here :/
> > 
> > can we change this lit file to only test for preparecallhierarchy with a 
> > wildcard match for the symbolid and introduce a new test into 
> > ClangdLSPServerTests.cpp for the incomingcalls ?
> We could do this, but note that `type-hierarchy.test` does the same thing.
i believe we didn't have clangdlspservertests at the time, it would be nice to 
migrate that one too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91124

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


[PATCH] D91186: [clangd] Add documentation for building and testing clangd

2020-11-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/README.md:30
+  We suggest building in RELEASE mode as building DEBUG binaries requires
+  considerably more resources. You can check [Building LLVM with CMake
+  documentation](https://llvm.org/docs/CMake.html) for more details about cmake

nridge wrote:
> I guess it might depend on whether you just want to build from source, or if 
> you're doing clangd development. For development purposes, I find release 
> builds to be very hard to debug due to inlining and other optimizations.
yeah i suppose it might make sense to add something like `CXX_FLAGS="-gmlt 
-O1"` but I am not sure if we mention that in this minimal one :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91186

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


[PATCH] D91134: [clangd] Abort rename when given the same name

2020-11-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:780
+void func() {
+  int V^ar;
+}

Add a comment or rename `Var` => `SameName`, to make the "new_name == old_name" 
more explicitly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91134

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


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-11 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-redundant-branch-condition.cpp:1092
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: redundant condition 'isSet' 
[bugprone-redundant-branch-condition]
+  // CHECK-FIXES: {{^\ *$}}
+}

This line isn't really doing anything. `CHECK-FIXES` just runs FileCheck on the 
whole file after clang tidy has applied any fixes. You need to explicitly say 
what you are expecting it to be. 


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

https://reviews.llvm.org/D91037

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


[PATCH] D91240: [clangd] Continue test adoption from Clang-Rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Tests can not be adopted 1:1 (e.g. Clang-Rename modifies namespace for some
symbols) and some tests appear to not be working due to our selection/other
factors. However, this helps us expose some unexpected bugs and prepares for
the decl canonicalization fix.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91240

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -608,6 +608,222 @@
   }
 }
 
+struct Case {
+  std::string Before;
+  std::string After;
+  std::string NewName;
+};
+
+// FIXME: Unfortunately, we can not have actual header + source file for
+// within-file rename (all references to renamed symbol must be within the
+// file). The workaround is to have the "header" finish with --END--\n and split
+// the "source" and "header" within the test. Is there a better way to do that?
+class ComplicatedRenameTest : public testing::Test,
+  public testing::WithParamInterface {
+protected:
+  void appendToHeader(StringRef AdditionalCode) {
+HeaderCode += AdditionalCode.str();
+  }
+
+  void runRenameOnCode(llvm::StringRef Before, llvm::StringRef After,
+   llvm::StringRef NewName) {
+SCOPED_TRACE(Before);
+Annotations Code((HeaderCode + Before).str());
+auto TU = TestTU::withCode(Code.code());
+TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+auto AST = TU.build();
+for (const auto &RenamePos : Code.points()) {
+  auto RenameResult =
+  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
+  ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
+  const auto Result =
+  applyEdits(std::move(RenameResult->GlobalChanges)).front().second;
+  const std::string Delimiter = "---END---\n";
+  EXPECT_EQ(Result.substr(Result.find(Delimiter) + Delimiter.size()),
+After);
+}
+  }
+
+  std::string HeaderCode;
+};
+
+class RenameAliasTest : public ComplicatedRenameTest {
+public:
+  RenameAliasTest() {
+appendToHeader(R"(
+#define MACRO(x) x
+namespace some_ns {
+class A {
+ public:
+  void foo() {}
+  struct Nested {
+   enum NestedEnum {
+ E1, E2,
+   };
+  };
+};
+} // namespace some_ns
+namespace a {
+typedef some_ns::A TA;
+using UA = some_ns::A;
+} // namespace a
+namespace b {
+typedef some_ns::A TA;
+using UA = some_ns::A;
+}
+template  class ptr {};
+template 
+
+using TPtr = ptr;
+
+// ---END---
+)");
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(
+RenameAliasTests, RenameAliasTest,
+testing::ValuesIn(std::vector({
+// basic functions
+{"void f(a::[[T^A]] a1) {}", "void f(a::TB a1) {}", "TB"},
+{"void f(a::[[U^A]] a1) {}", "void f(a::UB a1) {}", "UB"},
+{"void f(a::[[T^A]]* a1) {}", "void f(a::TB* a1) {}", "TB"},
+{"void f(a::[[T^A]]** a1) {}", "void f(a::TB** a1) {}", "TB"},
+{"a::[[T^A]] f() { return a::[[T^A]](); }",
+ "a::TB f() { return a::TB(); }", "TB"},
+{"a::[[T^A]] f() { return a::UA(); }", "a::TB f() { return a::UA(); }",
+ "TB"},
+{"a::TA f() { return a::[[U^A]](); }", "a::TA f() { return a::UB(); }",
+ "UB"},
+{"void f() { a::[[T^A]] a; }", "void f() { a::TB a; }", "TB"},
+{"void f(const a::[[T^A]]& a1) {}", "void f(const a::TB& a1) {}", "TB"},
+{"void f(const a::[[U^A]]& a1) {}", "void f(const a::UB& a1) {}", "UB"},
+{"void f(const a::[[T^A]]* a1) {}", "void f(const a::TB* a1) {}", "TB"},
+{"namespace a { void f([[T^A]] a1) {} }",
+ "namespace a { void f(TB a1) {} }", "TB"},
+{"void f(MACRO(a::[[T^A]]) a1) {}", "void f(MACRO(a::TB) a1) {}", "TB"},
+{"void f(MACRO(a::[[T^A]] a1)) {}", "void f(MACRO(a::TB a1)) {}", "TB"},
+
+// use namespace and typedefs
+{"struct S { using T = a::[[T^A]]; T a_; };",
+ "struct S { using T = a::TB; T a_; };", "TB"},
+{"using T = a::[[T^A]]; T gA;", "using T = a::TB; T gA;", "TB"},
+{"using T = a::[[U^A]]; T gA;", "using T = a::UB; T gA;", "UB"},
+{"typedef a::[[T^A]] T; T gA;", "typedef a::TB T; T gA;", "TB"},
+{"typedef a::[[U^A]] T; T gA;", "typedef a::UB T; T gA;", "UB"},
+{"typedef MACRO(a::[[T^A]]) T; T gA;", "typedef MACRO(a::TB) T; T 

[PATCH] D91134: [clangd] Abort rename when given the same name

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304434.
kbobyrev added a comment.

Add a comment to the test to make it more explicit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91134

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(// Trying to rename into the same name, SameName == SameName.
+void func() {
+  int S^ameName;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "SameName"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, 
{/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
 
-  // single-file rename on global symbols, we should report an error.
+  // Single-file rename on global symbols, we should report an error.
   Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
  /*NewName=*/llvm::None, {/*CrossFile=*/false});
   EXPECT_FALSE(Results);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,6 +123,7 @@
 
   // name validation.
   RenameToKeywords,
+  SameName,
 };
 
 llvm::Optional renameable(const NamedDecl &RenameDecl,
@@ -213,6 +214,8 @@
   return "there are multiple symbols at the given location";
 case ReasonToReject::RenameToKeywords:
   return "the chosen name is a keyword";
+case ReasonToReject::SameName:
+  return "new name is the same as the old name";
 }
 llvm_unreachable("unhandled reason kind");
   };
@@ -558,6 +561,8 @@
 return makeError(ReasonToReject::AmbiguousSymbol);
   const auto &RenameDecl =
   llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  if (RenameDecl.getName() == RInputs.NewName)
+return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
 return makeError(*Invalid);


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(// Trying to rename into the same name, SameName == SameName.
+void func() {
+  int S^ameName;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "SameName"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, {/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
 
-  // single-file rename on global symbols, we should report an error.
+  // Single-file rename on globa

[clang-tools-extra] 91ce6fb - [clangd] Abort rename when given the same name

2020-11-11 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-11-11T11:13:47+01:00
New Revision: 91ce6fb5a65f75c1b29c898f2cb76e2c5d1ac681

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

LOG: [clangd] Abort rename when given the same name

When user wants to rename the symbol to the same name we shouldn't do any work.
Bail out early and return error to save compute.

Resolves: https://github.com/clangd/clangd/issues/580

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 5adcf6d0e86e..33a9c845beaa 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,6 +123,7 @@ enum class ReasonToReject {
 
   // name validation.
   RenameToKeywords,
+  SameName,
 };
 
 llvm::Optional renameable(const NamedDecl &RenameDecl,
@@ -213,6 +214,8 @@ llvm::Error makeError(ReasonToReject Reason) {
   return "there are multiple symbols at the given location";
 case ReasonToReject::RenameToKeywords:
   return "the chosen name is a keyword";
+case ReasonToReject::SameName:
+  return "new name is the same as the old name";
 }
 llvm_unreachable("unhandled reason kind");
   };
@@ -556,6 +559,8 @@ llvm::Expected rename(const RenameInputs 
&RInputs) {
 return makeError(ReasonToReject::AmbiguousSymbol);
   const auto &RenameDecl =
   llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  if (RenameDecl.getName() == RInputs.NewName)
+return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
 return makeError(*Invalid);

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index b1c0d1d5e2d9..daf63d25ed7f 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@ TEST(RenameTest, Renameable) {
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(// Trying to rename into the same name, SameName == SameName.
+void func() {
+  int S^ameName;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "SameName"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@ TEST(RenameTest, PrepareRename) {
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, 
{/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@ TEST(RenameTest, PrepareRename) {
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@ TEST(RenameTest, PrepareRename) {
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
 
-  // single-file rename on global symbols, we should report an error.
+  // Single-file rename on global symbols, we should report an error.
   Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
  /*NewName=*/llvm::None, {/*CrossFile=*/false});
   EXPECT_FALSE(Results);



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


[PATCH] D91134: [clangd] Abort rename when given the same name

2020-11-11 Thread Kirill Bobyrev 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 rG91ce6fb5a65f: [clangd] Abort rename when given the same name 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91134

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(// Trying to rename into the same name, SameName == SameName.
+void func() {
+  int S^ameName;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "SameName"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, 
{/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"));
 
-  // single-file rename on global symbols, we should report an error.
+  // Single-file rename on global symbols, we should report an error.
   Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
  /*NewName=*/llvm::None, {/*CrossFile=*/false});
   EXPECT_FALSE(Results);
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -123,6 +123,7 @@
 
   // name validation.
   RenameToKeywords,
+  SameName,
 };
 
 llvm::Optional renameable(const NamedDecl &RenameDecl,
@@ -213,6 +214,8 @@
   return "there are multiple symbols at the given location";
 case ReasonToReject::RenameToKeywords:
   return "the chosen name is a keyword";
+case ReasonToReject::SameName:
+  return "new name is the same as the old name";
 }
 llvm_unreachable("unhandled reason kind");
   };
@@ -556,6 +559,8 @@
 return makeError(ReasonToReject::AmbiguousSymbol);
   const auto &RenameDecl =
   llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  if (RenameDecl.getName() == RInputs.NewName)
+return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
 return makeError(*Invalid);


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -774,6 +774,13 @@
 }
   )cpp",
nullptr, !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(// Trying to rename into the same name, SameName == SameName.
+void func() {
+  int S^ameName;
+}
+  )cpp",
+   "new name is the same", !HeaderFile, nullptr, "SameName"},
   };
 
   for (const auto& Case : Cases) {
@@ -876,7 +883,7 @@
 
   auto Results = runPrepareRename(Server, FooCCPath, FooCC.point(),
   /*NewName=*/llvm::None, {/*CrossFile=*/true});
-  // verify that for multi-file rename, we only return main-file occurrences.
+  // Verify that for multi-file rename, we only return main-file occurrences.
   ASSERT_TRUE(bool(Results)) << Results.takeError();
   // We don't know the result is complete in prepareRename (passing a nullptr
   // index internally), so GlobalChanges should be empty.
@@ -884,7 +891,7 @@
   EXPECT_THAT(FooCC.ranges(),
   testing::UnorderedElementsAreArray(Results->LocalChanges));
 
-  // verify name validation.
+  // Name validation.
   Results =
   runPrepareRename(Server, FooCCPath, FooCC.point(),
/*NewName=*/std::string("int"), {/*CrossFile=*/true});
@@ -892,7 +899,7 @@
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("keyword"))

[PATCH] D84232: [clangd] Set minimum gRPC version to 1.27

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev abandoned this revision.
kbobyrev added a comment.

There are more revisions that are buggy, can't test them all :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84232

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


[libunwind] e7b8d37 - [libunwind] LIBUNWIND_REMEMBER_HEAP_ALLOC to cmake.

2020-11-11 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2020-11-11T11:21:17+01:00
New Revision: e7b8d3776f36beb9b73cd0f7c81fdc4b832b6df3

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

LOG: [libunwind] LIBUNWIND_REMEMBER_HEAP_ALLOC to cmake.

Missed it originally in https://reviews.llvm.org/D85005.

Reviewed By: gargaroff

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

Added: 


Modified: 
libunwind/CMakeLists.txt

Removed: 




diff  --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt
index d7e13b78a9c9..e344263173b0 100644
--- a/libunwind/CMakeLists.txt
+++ b/libunwind/CMakeLists.txt
@@ -69,6 +69,7 @@ option(LIBUNWIND_USE_COMPILER_RT "Use compiler-rt instead of 
libgcc" OFF)
 option(LIBUNWIND_INCLUDE_DOCS "Build the libunwind documentation." 
${LLVM_INCLUDE_DOCS})
 option(LIBUNWIND_IS_BAREMETAL "Build libunwind for baremetal targets." OFF)
 option(LIBUNWIND_USE_FRAME_HEADER_CACHE "Cache frame headers for unwinding. 
Requires locking dl_iterate_phdr." OFF)
+option(LIBUNWIND_REMEMBER_HEAP_ALLOC "Use heap instead of the stack for 
.cfi_remember_state." OFF)
 
 set(LIBUNWIND_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
 "Define suffix of library directory name (32/64)")
@@ -312,6 +313,10 @@ if(LIBUNWIND_USE_FRAME_HEADER_CACHE)
   add_compile_definitions(_LIBUNWIND_USE_FRAME_HEADER_CACHE)
 endif()
 
+if(LIBUNWIND_REMEMBER_HEAP_ALLOC)
+  add_compile_definitions(_LIBUNWIND_REMEMBER_HEAP_ALLOC)
+endif()
+
 # This is the _ONLY_ place where add_definitions is called.
 if (MSVC)
   add_definitions(-D_CRT_SECURE_NO_WARNINGS)



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


[clang] 454579e - Reland [Syntax] Add minimal TableGen for syntax nodes. NFC

2020-11-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-11T11:24:47+01:00
New Revision: 454579e46a87b67c20504e12eadd865c8f40ccd3

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

LOG: Reland [Syntax] Add minimal TableGen for syntax nodes. NFC

This reverts commit 09c6259d6d0eb51b282f6c3a28052a8146bc095b.
(Fixed side-effecting code being buried in an assert)

Added: 
clang/include/clang/Tooling/Syntax/CMakeLists.txt
clang/include/clang/Tooling/Syntax/Nodes.td
clang/include/clang/Tooling/Syntax/Syntax.td
clang/utils/TableGen/ClangSyntaxEmitter.cpp

Modified: 
clang/include/clang/CMakeLists.txt
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/Nodes.cpp
clang/lib/Tooling/Syntax/Tree.cpp
clang/utils/TableGen/CMakeLists.txt
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/include/clang/CMakeLists.txt 
b/clang/include/clang/CMakeLists.txt
index feb81f0686ca..0dc9ea5ed8ac 100644
--- a/clang/include/clang/CMakeLists.txt
+++ b/clang/include/clang/CMakeLists.txt
@@ -5,3 +5,4 @@ add_subdirectory(Parse)
 add_subdirectory(Sema)
 add_subdirectory(Serialization)
 add_subdirectory(StaticAnalyzer/Checkers)
+add_subdirectory(Tooling/Syntax)

diff  --git a/clang/include/clang/Tooling/Syntax/CMakeLists.txt 
b/clang/include/clang/Tooling/Syntax/CMakeLists.txt
new file mode 100644
index ..a740015de365
--- /dev/null
+++ b/clang/include/clang/Tooling/Syntax/CMakeLists.txt
@@ -0,0 +1,4 @@
+clang_tablegen(Nodes.inc -gen-clang-syntax-node-list
+  SOURCE Nodes.td
+  TARGET ClangSyntaxNodeList)
+

diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 33ed2ec5c349..ed170beb75c8 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -35,82 +35,8 @@ namespace syntax {
 /// blocks of enumerator constants must correspond to the inheritance hierarchy
 /// of syntax::Node.
 enum class NodeKind : uint16_t {
-  Leaf,
-  TranslationUnit,
-
-  // Expressions.
-  UnknownExpression,
-  PrefixUnaryOperatorExpression,
-  PostfixUnaryOperatorExpression,
-  BinaryOperatorExpression,
-  ParenExpression,
-  IntegerLiteralExpression,
-  CharacterLiteralExpression,
-  FloatingLiteralExpression,
-  StringLiteralExpression,
-  BoolLiteralExpression,
-  CxxNullPtrExpression,
-  IntegerUserDefinedLiteralExpression,
-  FloatUserDefinedLiteralExpression,
-  CharUserDefinedLiteralExpression,
-  StringUserDefinedLiteralExpression,
-  IdExpression,
-  MemberExpression,
-  ThisExpression,
-  CallExpression,
-
-  // Statements.
-  UnknownStatement,
-  DeclarationStatement,
-  EmptyStatement,
-  SwitchStatement,
-  CaseStatement,
-  DefaultStatement,
-  IfStatement,
-  ForStatement,
-  WhileStatement,
-  ContinueStatement,
-  BreakStatement,
-  ReturnStatement,
-  RangeBasedForStatement,
-  ExpressionStatement,
-  CompoundStatement,
-
-  // Declarations.
-  UnknownDeclaration,
-  EmptyDeclaration,
-  StaticAssertDeclaration,
-  LinkageSpecificationDeclaration,
-  SimpleDeclaration,
-  TemplateDeclaration,
-  ExplicitTemplateInstantiation,
-  NamespaceDefinition,
-  NamespaceAliasDefinition,
-  UsingNamespaceDirective,
-  UsingDeclaration,
-  TypeAliasDeclaration,
-
-  // Declarators.
-  SimpleDeclarator,
-  ParenDeclarator,
-
-  ArraySubscript,
-  TrailingReturnType,
-  ParametersAndQualifiers,
-  MemberPointer,
-  UnqualifiedId,
-
-  // Lists
-  DeclaratorList,
-  ParameterDeclarationList,
-  CallArguments,
-  NestedNameSpecifier,
-
-  // Name Specifiers.
-  GlobalNameSpecifier,
-  DecltypeNameSpecifier,
-  IdentifierNameSpecifier,
-  SimpleTemplateNameSpecifier,
+#define CONCRETE_NODE(Kind, Base) Kind,
+#include "clang/Tooling/Syntax/Nodes.inc"
 };
 /// For debugging purposes.
 raw_ostream &operator<<(raw_ostream &OS, NodeKind K);
@@ -194,9 +120,7 @@ class SimpleDeclarator;
 class TranslationUnit final : public Tree {
 public:
   TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
-  static bool classof(const Node *N) {
-return N->getKind() == NodeKind::TranslationUnit;
-  }
+  static bool classof(const Node *N);
 };
 
 /// A base class for all expressions. Note that expressions are not statements,
@@ -204,10 +128,7 @@ class TranslationUnit final : public Tree {
 class Expression : public Tree {
 public:
   Expression(NodeKind K) : Tree(K) {}
-  static bool classof(const Node *N) {
-return NodeKind::UnknownExpression <= N->getKind() &&
-   N->getKind() <= NodeKind::CallExpression;
-  }
+  static bool classof(const Node *N);
 };
 
 /// A sequence of these specifiers make a `nested-name-specifier`.
@@ -215,12 +136,7 @@ class Expression : public Tree {
 class NameSpecifier : public Tree {
 public:
   NameSpecifier

[PATCH] D91240: [clangd] Continue test adoption from Clang-Rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 30.
kbobyrev added a comment.

Check for equality with .endswith() and remove ---END--- hack


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91240

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -608,6 +608,218 @@
   }
 }
 
+struct Case {
+  std::string Before;
+  std::string After;
+  std::string NewName;
+};
+
+class ComplicatedRenameTest : public testing::Test,
+  public testing::WithParamInterface {
+protected:
+  void appendToHeader(StringRef AdditionalCode) {
+HeaderCode += AdditionalCode.str();
+  }
+
+  void runRenameOnCode(llvm::StringRef Before, llvm::StringRef After,
+   llvm::StringRef NewName) {
+SCOPED_TRACE(Before);
+Annotations Code((HeaderCode + Before).str());
+auto TU = TestTU::withCode(Code.code());
+TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+auto AST = TU.build();
+for (const auto &RenamePos : Code.points()) {
+  auto RenameResult =
+  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
+  ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
+  const auto Result =
+  applyEdits(std::move(RenameResult->GlobalChanges)).front().second;
+  // FIXME: This is much worse than comparing modified Before and After but
+  // after the rename we lose track of where Before was. We can't put
+  // HeaderCode into an actual header because rename within file does not
+  // allow references outside of the main file.
+  EXPECT_TRUE(llvm::StringRef(Result).endswith(After));
+}
+  }
+
+  std::string HeaderCode;
+};
+
+class RenameAliasTest : public ComplicatedRenameTest {
+public:
+  RenameAliasTest() {
+appendToHeader(R"(
+#define MACRO(x) x
+namespace some_ns {
+class A {
+ public:
+  void foo() {}
+  struct Nested {
+   enum NestedEnum {
+ E1, E2,
+   };
+  };
+};
+} // namespace some_ns
+namespace a {
+typedef some_ns::A TA;
+using UA = some_ns::A;
+} // namespace a
+namespace b {
+typedef some_ns::A TA;
+using UA = some_ns::A;
+}
+template  class ptr {};
+template 
+
+using TPtr = ptr;
+)");
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(
+RenameAliasTests, RenameAliasTest,
+testing::ValuesIn(std::vector({
+// Basic functions.
+{"void f(a::[[T^A]] a1) {}", "void f(a::TB a1) {}", "TB"},
+{"void f(a::[[U^A]] a1) {}", "void f(a::UB a1) {}", "UB"},
+{"void f(a::[[T^A]]* a1) {}", "void f(a::TB* a1) {}", "TB"},
+{"void f(a::[[T^A]]** a1) {}", "void f(a::TB** a1) {}", "TB"},
+{"a::[[T^A]] f() { return a::[[T^A]](); }",
+ "a::TB f() { return a::TB(); }", "TB"},
+{"a::[[T^A]] f() { return a::UA(); }", "a::TB f() { return a::UA(); }",
+ "TB"},
+{"a::TA f() { return a::[[U^A]](); }", "a::TA f() { return a::UB(); }",
+ "UB"},
+{"void f() { a::[[T^A]] a; }", "void f() { a::TB a; }", "TB"},
+{"void f(const a::[[T^A]]& a1) {}", "void f(const a::TB& a1) {}", "TB"},
+{"void f(const a::[[U^A]]& a1) {}", "void f(const a::UB& a1) {}", "UB"},
+{"void f(const a::[[T^A]]* a1) {}", "void f(const a::TB* a1) {}", "TB"},
+{"namespace a { void f([[T^A]] a1) {} }",
+ "namespace a { void f(TB a1) {} }", "TB"},
+{"void f(MACRO(a::[[T^A]]) a1) {}", "void f(MACRO(a::TB) a1) {}", "TB"},
+{"void f(MACRO(a::[[T^A]] a1)) {}", "void f(MACRO(a::TB a1)) {}", "TB"},
+
+// Use namespace and typedefs.
+{"struct S { using T = a::[[T^A]]; T a_; };",
+ "struct S { using T = a::TB; T a_; };", "TB"},
+{"using T = a::[[T^A]]; T gA;", "using T = a::TB; T gA;", "TB"},
+{"using T = a::[[U^A]]; T gA;", "using T = a::UB; T gA;", "UB"},
+{"typedef a::[[T^A]] T; T gA;", "typedef a::TB T; T gA;", "TB"},
+{"typedef a::[[U^A]] T; T gA;", "typedef a::UB T; T gA;", "UB"},
+{"typedef MACRO(a::[[T^A]]) T; T gA;", "typedef MACRO(a::TB) T; T gA;",
+ "TB"},
+
+// Struct members and other oddities.
+{"struct S : public a::[[T^A]] {};", "struct S : public a::TB {};",
+ "TB"},
+{"struct S : public a::[[U^A]] {};", "struct S : public a::UB {};",
+ "UB"},
+{"struct F { void f(a::[[T^A]] a1) {} };",
+ "struct F { void f(a::TB a1) {} };", "TB"},
+{"struct F { a::[[T^A]] a_; };", "struct F { a::TB a_; };", "TB"},
+  

[PATCH] D91237: [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

2020-11-11 Thread Elvina Yakubova via Phabricator via cfe-commits
Elvina added a comment.

Failure on test "linux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp" looks 
bogus. I had the same issue with another PR https://reviews.llvm.org/D89972 and 
other people also faced it https://reviews.llvm.org/D89895


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91237

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


[PATCH] D88220: [C++20] P1825R0: More implicit moves

2020-11-11 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp updated this revision to Diff 304447.
nullptr.cpp added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88220

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
  clang/test/SemaCXX/warn-return-std-move.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1202,6 +1202,11 @@
   https://wg21.link/p0593r6";>P0593R6 (DR)
   Clang 11
 
+
+More implicit moves
+https://wg21.link/p1825r0";>P1825R0 (DR)
+Clang 12
+
 
 
 
Index: clang/test/SemaCXX/warn-return-std-move.cpp
===
--- clang/test/SemaCXX/warn-return-std-move.cpp
+++ clang/test/SemaCXX/warn-return-std-move.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -Wreturn-std-move-in-c++11 -std=c++14 -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -Wreturn-std-move-in-c++11 -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -Wreturn-std-move -std=c++14 -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 // definitions for std::move
 namespace std {
@@ -77,10 +77,7 @@
 }
 ConstructFromDerived test3() {
 Derived d3;
-return d3;  // e2-cxx11
-// expected-warning@-1{{would have been copied despite being returned by name}}
-// expected-note@-2{{to avoid copying on older compilers}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:14}:"std::move(d3)"
+return d3;  // ok
 }
 ConstructFromBase test4() {
 Derived d4;
@@ -153,10 +150,7 @@
 // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
 }
 ConstructFromDerived testParam3(Derived d) {
-return d;  // e7-cxx11
-// expected-warning@-1{{would have been copied despite being returned by name}}
-// expected-note@-2{{to avoid copying on older compilers}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:13}:"std::move(d)"
+return d;  // ok
 }
 ConstructFromBase testParam4(Derived d) {
 return d;  // e8
@@ -231,10 +225,7 @@
 }
 ConstructFromDerived testParens2() {
 Derived d;
-return (d);  // e18-cxx11
-// expected-warning@-1{{would have been copied despite being returned by name}}
-// expected-note@-2{{to avoid copying}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:12-[[@LINE-3]]:15}:"std::move(d)"
+return (d);  // ok
 }
 
 
Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- /dev/null
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -0,0 +1,144 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only -fcxx-exceptions -verify %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fcxx-exceptions -verify %s
+
+// In C++20, implicitly movable entity can be rvalue reference to non-volatile
+// automatic object.
+namespace test_implicitly_movable_rvalue_ref {
+#if __cplusplus >= 202002L
+class C {
+public:
+  C() {}
+  ~C() {}
+  C(C &&);
+
+private:
+  C(const C &);
+};
+
+C test(C &&c) {
+  return c;
+}
+#else
+class C {
+public:
+  C() {}
+  ~C() {}
+  C(C &&);
+
+private:
+  C(const C &); // expected-note {{declared private here}}
+};
+
+C test(C &&c) {
+  return c; // expected-error {{calling a private constructor of class 'test_implicitly_movable_rvalue_ref::C'}}
+}
+#endif
+} // namespace test_implicitly_movable_rvalue_ref
+
+// In C++20, operand of throw-expression can be function parameter or
+// catch-clause parameter.
+namespace test_throw_parameter {
+#if __cplusplus >= 202002L
+class C {
+public:
+  C() {}
+  ~C() {}
+  C(const C &);
+
+private:
+  C(C &&); // expected-note {{declared private here}}
+};
+
+void func();
+void test() {
+  try {
+func();
+  } catch (C c_move) {
+throw c_move; // expected-error {{calling a private constructor of class 'test_throw_parameter::C'}}
+  }
+}
+#else
+class C {
+public:
+  C() {}
+  ~C() {}
+  C(const C &);
+
+private:
+  C(C &&);
+};
+
+void func();
+void test() {
+  try {
+func();
+  } catch (C c_copy) {
+throw c_copy;
+  }
+}
+#endif
+} // namespace test_throw_parameter
+
+// In C++20, during the first overload resolution, the first parameter of the
+// selected constructor no need to be rvalue reference to the object's type.
+namespace test_ctor_param_rvalue_ref 

[PATCH] D91240: [clangd] Continue test adoption from Clang-Rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev abandoned this revision.
kbobyrev added a comment.

As discussed offline, these tests are for qualified rename paths so not really 
useful :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91240

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


[PATCH] D90543: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added a comment.

In D90543#2373962 , @eduucaldas wrote:

>> Compared to Dmitri's prototype, Nodes.td looks more like a class hierarchy 
>> and
>> less like a grammar. (E.g. variants list the Alternatives parent rather than
>> vice versa).
>
>
>
>> e.g. we may introduce abstract bases like "loop" that the grammar doesn't 
>> care about in order to model is-a concepts that might make refactorings more 
>> expressive. This is less natural in a grammar-like idiom.
>
> Do you have a concrete example of such abstract base -- loop is in the 
> grammar  ? And in 
> the case such an example appear, in my mind we would just change "our 
> grammar" to have an alternative for this "loop" abstract base.

Not really, I think you're right. This is a bad argument.

>> e.g. we're likely to have to model some alternatives as variants and others 
>> as class hierarchies, the choice will probably be based on natural is-a 
>> relationships.
>
> I agree, alternatives and the two ways to model them are a tricky subject...
>
>> it reduces the cognitive load of switching from editing *.td to working with 
>> code that uses the generated classes
>
> I think we should consider reading prior to editing.

Agree. I think the same load exists for reading though.

> A grammar is how we represent syntax, and syntax trees model syntax, as such 
> I think we should rather consider the cognitive load of switching between the 
> grammar and the definition of syntax trees.

I don't think people reason about concrete grammar as a collection of 
productions though, rather as a collection of kinds of nodes and what they're 
composed of.
And we model it that way in the C++ API! I think the tablegen should follow 
that too...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90543

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


[PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-11 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:636
+// Filter out any reformat fixits, we don't handle these.
+// FIXME: Can we?
+llvm::erase_if(FixIts,

kadircet wrote:
> in theory yes, as we have access to source manager, we can fetch file 
> contents and create formatted  replacements (see `cleanupAndFormat`). but 
> formatting those fixes can imply significant delays on clangd's diagnostic 
> cycles (if there are many of those), that's the reason why we currently don't 
> format fixits.
I mean if clangd is extended to support async code actions for diagnostics 
instead of just using the inline extension. Having said that, if that were the 
case, this would probably not be where that support is implemented.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:637
+// FIXME: Can we?
+llvm::erase_if(FixIts,
+   [](const FixItHint &Fix) { return Fix.isReformatFixit(); });

kadircet wrote:
> rather than doing an extra loop, can we just skip those in the for loop below 
> ?
We could, however that would result in messier code further down when trying to 
build a synthetic message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-11 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

I think it should be good for merging now. I addressed all remarks. I'm still 
convinced that "workaround" is the proper term though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[clang] 77b4841 - [clang-format] do not break before @tags in JS comments

2020-11-11 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2020-11-11T12:27:15+01:00
New Revision: 77b484116971337c9584fe101cdf1bca7f07f4dd

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

LOG: [clang-format] do not break before @tags in JS comments

In JavaScript breaking before a `@tag` in a comment puts it on a new line, and
machinery that parses these comments will fail to understand such comments.

This adapts clang-format to not break before `@`. Similar functionality exists
for not breaking before `{`.

Reviewed By: mprobst

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

Added: 


Modified: 
clang/lib/Format/BreakableToken.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/BreakableToken.cpp 
b/clang/lib/Format/BreakableToken.cpp
index c3853687c228..4975c89164a4 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -124,9 +124,10 @@ getCommentSplit(StringRef Text, unsigned 
ContentStartColumn,
   continue;
 }
 
-// Avoid ever breaking before a { in JavaScript.
+// Avoid ever breaking before a @tag or a { in JavaScript.
 if (Style.Language == FormatStyle::LK_JavaScript &&
-SpaceOffset + 1 < Text.size() && Text[SpaceOffset + 1] == '{') {
+SpaceOffset + 1 < Text.size() &&
+(Text[SpaceOffset + 1] == '{' || Text[SpaceOffset + 1] == '@')) {
   SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
   continue;
 }

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 84d76c67764a..8963c9f19024 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -187,22 +187,11 @@ TEST_F(FormatTestJS, JSDocComments) {
 format("/** @returns j */", getGoogleJSStyleWithColumns(20)));
 
   // Break a single line long jsdoc comment pragma.
-  EXPECT_EQ("/**\n"
-" * @returns {string} jsdoc line 12\n"
-" */",
-format("/** @returns {string} jsdoc line 12 */",
-   getGoogleJSStyleWithColumns(20)));
   EXPECT_EQ("/**\n"
 " * @returns {string}\n"
 " * jsdoc line 12\n"
 " */",
 format("/** @returns {string} jsdoc line 12 */",
-   getGoogleJSStyleWithColumns(25)));
-
-  EXPECT_EQ("/**\n"
-" * @returns {string} jsdoc line 12\n"
-" */",
-format("/** @returns {string} jsdoc line 12  */",
getGoogleJSStyleWithColumns(20)));
 
   // FIXME: this overcounts the */ as a continuation of the 12 when breaking.
@@ -2194,6 +2183,16 @@ TEST_F(FormatTestJS, JSDocAnnotations) {
  " */",
  getGoogleJSStyleWithColumns(ColumnLimit));
   }
+  // don't break before @tags
+  verifyFormat("/**\n"
+   " * This\n"
+   " * tag @param\n"
+   " * stays.\n"
+   " */",
+   "/**\n"
+   " * This tag @param stays.\n"
+   " */",
+   getGoogleJSStyleWithColumns(13));
   verifyFormat("/**\n"
" * @see http://very/very/long/url/is/long\n";
" */",



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


[PATCH] D91078: [clang-format] do not break before @tags in JS comments

2020-11-11 Thread Krasimir Georgiev 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 rG77b484116971: [clang-format] do not break before @tags in JS 
comments (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91078

Files:
  clang/lib/Format/BreakableToken.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -187,22 +187,11 @@
 format("/** @returns j */", getGoogleJSStyleWithColumns(20)));
 
   // Break a single line long jsdoc comment pragma.
-  EXPECT_EQ("/**\n"
-" * @returns {string} jsdoc line 12\n"
-" */",
-format("/** @returns {string} jsdoc line 12 */",
-   getGoogleJSStyleWithColumns(20)));
   EXPECT_EQ("/**\n"
 " * @returns {string}\n"
 " * jsdoc line 12\n"
 " */",
 format("/** @returns {string} jsdoc line 12 */",
-   getGoogleJSStyleWithColumns(25)));
-
-  EXPECT_EQ("/**\n"
-" * @returns {string} jsdoc line 12\n"
-" */",
-format("/** @returns {string} jsdoc line 12  */",
getGoogleJSStyleWithColumns(20)));
 
   // FIXME: this overcounts the */ as a continuation of the 12 when breaking.
@@ -2194,6 +2183,16 @@
  " */",
  getGoogleJSStyleWithColumns(ColumnLimit));
   }
+  // don't break before @tags
+  verifyFormat("/**\n"
+   " * This\n"
+   " * tag @param\n"
+   " * stays.\n"
+   " */",
+   "/**\n"
+   " * This tag @param stays.\n"
+   " */",
+   getGoogleJSStyleWithColumns(13));
   verifyFormat("/**\n"
" * @see http://very/very/long/url/is/long\n";
" */",
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -124,9 +124,10 @@
   continue;
 }
 
-// Avoid ever breaking before a { in JavaScript.
+// Avoid ever breaking before a @tag or a { in JavaScript.
 if (Style.Language == FormatStyle::LK_JavaScript &&
-SpaceOffset + 1 < Text.size() && Text[SpaceOffset + 1] == '{') {
+SpaceOffset + 1 < Text.size() &&
+(Text[SpaceOffset + 1] == '{' || Text[SpaceOffset + 1] == '@')) {
   SpaceOffset = Text.find_last_of(Blanks, SpaceOffset);
   continue;
 }


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -187,22 +187,11 @@
 format("/** @returns j */", getGoogleJSStyleWithColumns(20)));
 
   // Break a single line long jsdoc comment pragma.
-  EXPECT_EQ("/**\n"
-" * @returns {string} jsdoc line 12\n"
-" */",
-format("/** @returns {string} jsdoc line 12 */",
-   getGoogleJSStyleWithColumns(20)));
   EXPECT_EQ("/**\n"
 " * @returns {string}\n"
 " * jsdoc line 12\n"
 " */",
 format("/** @returns {string} jsdoc line 12 */",
-   getGoogleJSStyleWithColumns(25)));
-
-  EXPECT_EQ("/**\n"
-" * @returns {string} jsdoc line 12\n"
-" */",
-format("/** @returns {string} jsdoc line 12  */",
getGoogleJSStyleWithColumns(20)));
 
   // FIXME: this overcounts the */ as a continuation of the 12 when breaking.
@@ -2194,6 +2183,16 @@
  " */",
  getGoogleJSStyleWithColumns(ColumnLimit));
   }
+  // don't break before @tags
+  verifyFormat("/**\n"
+   " * This\n"
+   " * tag @param\n"
+   " * stays.\n"
+   " */",
+   "/**\n"
+   " * This tag @param stays.\n"
+   " */",
+   getGoogleJSStyleWithColumns(13));
   verifyFormat("/**\n"
" * @see http://very/very/long/url/is/long\n";
" */",
Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -124,9 +124,10 @@
   continue;
 }
 
-// Avoid ever breaking before a { in JavaScript.
+// Avoid ever breaking before a @tag or a { in JavaScript.
 if (Style.Language == FormatStyle::LK_JavaScript &&
-SpaceOffset + 1 < Text.size() && Text[SpaceOffset + 1] == '{') {
+SpaceOffset + 1 < Text.size() &&
+(Text[SpaceOffset + 1] == '{' || Tex

[PATCH] D91051: [clangd] Improve clangd-indexer performance

2020-11-11 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdad804a193ed: [clangd] Improve clangd-indexer performance 
(authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91051

Files:
  clang-tools-extra/clangd/indexer/IndexerMain.cpp


Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -43,6 +43,16 @@
   std::unique_ptr create() override {
 SymbolCollector::Options Opts;
 Opts.CountReferences = true;
+Opts.FileFilter = [&](const SourceManager &SM, FileID FID) {
+  const auto *F = SM.getFileEntryForID(FID);
+  if (!F)
+return false; // Skip invalid files.
+  auto AbsPath = getCanonicalPath(F, SM);
+  if (!AbsPath)
+return false; // Skip files without absolute path.
+  std::lock_guard Lock(FilesMu);
+  return Files.insert(*AbsPath).second; // Skip already processed files.
+};
 return createStaticIndexingAction(
 Opts,
 [&](SymbolSlab S) {
@@ -56,7 +66,7 @@
   }
 },
 [&](RefSlab S) {
-  std::lock_guard Lock(SymbolsMu);
+  std::lock_guard Lock(RefsMu);
   for (const auto &Sym : S) {
 // Deduplication happens during insertion.
 for (const auto &Ref : Sym.second)
@@ -64,7 +74,7 @@
   }
 },
 [&](RelationSlab S) {
-  std::lock_guard Lock(SymbolsMu);
+  std::lock_guard Lock(RelsMu);
   for (const auto &R : S) {
 Relations.insert(R);
   }
@@ -82,9 +92,13 @@
 
 private:
   IndexFileIn &Result;
+  std::mutex FilesMu;
+  llvm::StringSet<> Files;
   std::mutex SymbolsMu;
   SymbolSlab::Builder Symbols;
+  std::mutex RefsMu;
   RefSlab::Builder Refs;
+  std::mutex RelsMu;
   RelationSlab::Builder Relations;
 };
 


Index: clang-tools-extra/clangd/indexer/IndexerMain.cpp
===
--- clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -43,6 +43,16 @@
   std::unique_ptr create() override {
 SymbolCollector::Options Opts;
 Opts.CountReferences = true;
+Opts.FileFilter = [&](const SourceManager &SM, FileID FID) {
+  const auto *F = SM.getFileEntryForID(FID);
+  if (!F)
+return false; // Skip invalid files.
+  auto AbsPath = getCanonicalPath(F, SM);
+  if (!AbsPath)
+return false; // Skip files without absolute path.
+  std::lock_guard Lock(FilesMu);
+  return Files.insert(*AbsPath).second; // Skip already processed files.
+};
 return createStaticIndexingAction(
 Opts,
 [&](SymbolSlab S) {
@@ -56,7 +66,7 @@
   }
 },
 [&](RefSlab S) {
-  std::lock_guard Lock(SymbolsMu);
+  std::lock_guard Lock(RefsMu);
   for (const auto &Sym : S) {
 // Deduplication happens during insertion.
 for (const auto &Ref : Sym.second)
@@ -64,7 +74,7 @@
   }
 },
 [&](RelationSlab S) {
-  std::lock_guard Lock(SymbolsMu);
+  std::lock_guard Lock(RelsMu);
   for (const auto &R : S) {
 Relations.insert(R);
   }
@@ -82,9 +92,13 @@
 
 private:
   IndexFileIn &Result;
+  std::mutex FilesMu;
+  llvm::StringSet<> Files;
   std::mutex SymbolsMu;
   SymbolSlab::Builder Symbols;
+  std::mutex RefsMu;
   RefSlab::Builder Refs;
+  std::mutex RelsMu;
   RelationSlab::Builder Relations;
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] dad804a - [clangd] Improve clangd-indexer performance

2020-11-11 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2020-11-11T14:38:06+03:00
New Revision: dad804a193edf092322d80bb404fabb2f6f2c888

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

LOG: [clangd] Improve clangd-indexer performance

This is a try to improve clangd-indexer tool performance:
- avoid processing already processed files.
- use different mutexes for different entities (e.g. do not block insertion of 
references while symbols are inserted)

Results for LLVM project indexing:
- before: ~30 minutes
- after: ~10 minutes

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/indexer/IndexerMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/indexer/IndexerMain.cpp 
b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
index 46224238c3fc..fd8404be677a 100644
--- a/clang-tools-extra/clangd/indexer/IndexerMain.cpp
+++ b/clang-tools-extra/clangd/indexer/IndexerMain.cpp
@@ -43,6 +43,16 @@ class IndexActionFactory : public 
tooling::FrontendActionFactory {
   std::unique_ptr create() override {
 SymbolCollector::Options Opts;
 Opts.CountReferences = true;
+Opts.FileFilter = [&](const SourceManager &SM, FileID FID) {
+  const auto *F = SM.getFileEntryForID(FID);
+  if (!F)
+return false; // Skip invalid files.
+  auto AbsPath = getCanonicalPath(F, SM);
+  if (!AbsPath)
+return false; // Skip files without absolute path.
+  std::lock_guard Lock(FilesMu);
+  return Files.insert(*AbsPath).second; // Skip already processed files.
+};
 return createStaticIndexingAction(
 Opts,
 [&](SymbolSlab S) {
@@ -56,7 +66,7 @@ class IndexActionFactory : public 
tooling::FrontendActionFactory {
   }
 },
 [&](RefSlab S) {
-  std::lock_guard Lock(SymbolsMu);
+  std::lock_guard Lock(RefsMu);
   for (const auto &Sym : S) {
 // Deduplication happens during insertion.
 for (const auto &Ref : Sym.second)
@@ -64,7 +74,7 @@ class IndexActionFactory : public 
tooling::FrontendActionFactory {
   }
 },
 [&](RelationSlab S) {
-  std::lock_guard Lock(SymbolsMu);
+  std::lock_guard Lock(RelsMu);
   for (const auto &R : S) {
 Relations.insert(R);
   }
@@ -82,9 +92,13 @@ class IndexActionFactory : public 
tooling::FrontendActionFactory {
 
 private:
   IndexFileIn &Result;
+  std::mutex FilesMu;
+  llvm::StringSet<> Files;
   std::mutex SymbolsMu;
   SymbolSlab::Builder Symbols;
+  std::mutex RefsMu;
   RefSlab::Builder Refs;
+  std::mutex RelsMu;
   RelationSlab::Builder Relations;
 };
 



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


[PATCH] D90543: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 304457.
sammccall added a comment.

Address comments, rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90543

Files:
  clang/include/clang/Tooling/Syntax/CMakeLists.txt
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Nodes.td
  clang/include/clang/Tooling/Syntax/Syntax.td
  clang/utils/TableGen/ClangSyntaxEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -85,6 +85,8 @@
 
 void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
+llvm::raw_ostream &OS);
 
 void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -56,6 +56,7 @@
   GenClangOpcodes,
   GenClangSACheckers,
   GenClangSyntaxNodeList,
+  GenClangSyntaxNodeClasses,
   GenClangCommentHTMLTags,
   GenClangCommentHTMLTagsProperties,
   GenClangCommentHTMLNamedCharacterReferences,
@@ -169,6 +170,8 @@
"Generate Clang Static Analyzer checkers"),
 clEnumValN(GenClangSyntaxNodeList, "gen-clang-syntax-node-list",
"Generate list of Clang Syntax Tree node types"),
+clEnumValN(GenClangSyntaxNodeClasses, "gen-clang-syntax-node-classes",
+   "Generate definitions of Clang Syntax Tree node clasess"),
 clEnumValN(GenClangCommentHTMLTags, "gen-clang-comment-html-tags",
"Generate efficient matchers for HTML tag "
"names that are used in documentation comments"),
@@ -362,6 +365,9 @@
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
+  case GenClangSyntaxNodeClasses:
+EmitClangSyntaxNodeClasses(Records, OS);
+break;
   case GenArmNeon:
 EmitNeon(Records, OS);
 break;
Index: clang/utils/TableGen/ClangSyntaxEmitter.cpp
===
--- clang/utils/TableGen/ClangSyntaxEmitter.cpp
+++ clang/utils/TableGen/ClangSyntaxEmitter.cpp
@@ -16,19 +16,25 @@
 //   ABSTRACT_NODE(Type, Base, FirstKind, LastKind)
 // similar to those for AST nodes such as AST/DeclNodes.inc.
 //
-// In future, the class definitions will be produced by additional backends.
+// The -gen-clang-syntax-node-classes backend produces definitions for the
+// syntax::Node subclasses (except those marked as External).
+//
+// In future, another backend will encode the structure of the various node
+// types in tables so their invariants can be checked and enforced.
 //
 //===--===//
 #include "TableGenBackends.h"
 
 #include 
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 
 namespace {
+using llvm::formatv;
 
 // The class hierarchy of Node types.
 // We assemble this in order to be able to define the NodeKind enum in a
@@ -41,10 +47,15 @@
 for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType"))
   if (llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
 link(Derived, Base);
-for (NodeType &N : AllTypes)
+for (NodeType &N : AllTypes) {
   llvm::sort(N.Derived, [](const NodeType *L, const NodeType *R) {
 return L->Record->getName() < R->Record->getName();
   });
+  // Alternatives nodes must have subclasses, External nodes may do.
+  assert(N.Record->isSubClassOf("Alternatives") ||
+ N.Record->isSubClassOf("External") || N.Derived.empty());
+  assert(!N.Record->isSubClassOf("Alternatives") || !N.Derived.empty());
+}
   }
 
   struct NodeType {
@@ -60,6 +71,16 @@
 return *NI->second;
   }
 
+  // Traverse the hierarchy in pre-order (base classes before derived).
+  void visit(llvm::function_ref CB,
+ const NodeType *Start = nullptr) {
+if (Start == nullptr)
+  Start = &get();
+CB(*Start);
+for (const NodeType *D : Start->Derived)
+  visit(CB, D);
+  }
+
 private:
   void add(const llvm::Record *R) {
 AllTypes.emplace_back();
@@ -87,26 +108,12 @@
   return N.Derived.empty() ? N : lastConcrete(*N.Derived.back());
 }
 
-void emitNodeList(const Hierarchy::NodeType &N, llvm::raw_ostream &OS) {
-  // Don't emit ABSTRACT_NODE for node it

[PATCH] D90543: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

2020-11-11 Thread Sam McCall 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 rG98aa067109ed: [Syntax] Start to move trivial Node class 
definitions to TableGen. NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90543

Files:
  clang/include/clang/Tooling/Syntax/CMakeLists.txt
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Nodes.td
  clang/include/clang/Tooling/Syntax/Syntax.td
  clang/utils/TableGen/ClangSyntaxEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -85,6 +85,8 @@
 
 void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangSyntaxNodeClasses(llvm::RecordKeeper &Records,
+llvm::raw_ostream &OS);
 
 void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -56,6 +56,7 @@
   GenClangOpcodes,
   GenClangSACheckers,
   GenClangSyntaxNodeList,
+  GenClangSyntaxNodeClasses,
   GenClangCommentHTMLTags,
   GenClangCommentHTMLTagsProperties,
   GenClangCommentHTMLNamedCharacterReferences,
@@ -169,6 +170,8 @@
"Generate Clang Static Analyzer checkers"),
 clEnumValN(GenClangSyntaxNodeList, "gen-clang-syntax-node-list",
"Generate list of Clang Syntax Tree node types"),
+clEnumValN(GenClangSyntaxNodeClasses, "gen-clang-syntax-node-classes",
+   "Generate definitions of Clang Syntax Tree node clasess"),
 clEnumValN(GenClangCommentHTMLTags, "gen-clang-comment-html-tags",
"Generate efficient matchers for HTML tag "
"names that are used in documentation comments"),
@@ -362,6 +365,9 @@
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
+  case GenClangSyntaxNodeClasses:
+EmitClangSyntaxNodeClasses(Records, OS);
+break;
   case GenArmNeon:
 EmitNeon(Records, OS);
 break;
Index: clang/utils/TableGen/ClangSyntaxEmitter.cpp
===
--- clang/utils/TableGen/ClangSyntaxEmitter.cpp
+++ clang/utils/TableGen/ClangSyntaxEmitter.cpp
@@ -16,19 +16,25 @@
 //   ABSTRACT_NODE(Type, Base, FirstKind, LastKind)
 // similar to those for AST nodes such as AST/DeclNodes.inc.
 //
-// In future, the class definitions will be produced by additional backends.
+// The -gen-clang-syntax-node-classes backend produces definitions for the
+// syntax::Node subclasses (except those marked as External).
+//
+// In future, another backend will encode the structure of the various node
+// types in tables so their invariants can be checked and enforced.
 //
 //===--===//
 #include "TableGenBackends.h"
 
 #include 
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 
 namespace {
+using llvm::formatv;
 
 // The class hierarchy of Node types.
 // We assemble this in order to be able to define the NodeKind enum in a
@@ -41,10 +47,15 @@
 for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType"))
   if (llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
 link(Derived, Base);
-for (NodeType &N : AllTypes)
+for (NodeType &N : AllTypes) {
   llvm::sort(N.Derived, [](const NodeType *L, const NodeType *R) {
 return L->Record->getName() < R->Record->getName();
   });
+  // Alternatives nodes must have subclasses, External nodes may do.
+  assert(N.Record->isSubClassOf("Alternatives") ||
+ N.Record->isSubClassOf("External") || N.Derived.empty());
+  assert(!N.Record->isSubClassOf("Alternatives") || !N.Derived.empty());
+}
   }
 
   struct NodeType {
@@ -60,6 +71,16 @@
 return *NI->second;
   }
 
+  // Traverse the hierarchy in pre-order (base classes before derived).
+  void visit(llvm::function_ref CB,
+ const NodeType *Start = nullptr) {
+if (Start == nullptr)
+  Start = &get();
+CB(*Start);
+for (const NodeType *D : Start->Derived)
+  visit(CB, D);
+  }
+
 private:
   void add(const llvm::Record *R) {
 AllTypes.emplace_back();
@@ -87,26 +108,12 @@
   return N.Derived.empty() ? 

[clang] 98aa067 - [Syntax] Start to move trivial Node class definitions to TableGen. NFC

2020-11-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-11T12:39:43+01:00
New Revision: 98aa067109ed482e428bc16e1321dbe756efc57c

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

LOG: [Syntax] Start to move trivial Node class definitions to TableGen. NFC

This defines two node archetypes with trivial class definitions:
 - Alternatives: the generated abstract classes are trivial as all
   functionality is via LLVM RTTI
 - Unconstrained: this is a placeholder, I think all of these are going to be
   Lists but today they have no special accessors etc, so we just say
   "could contain anything", and migrate them one-by-one to Sequence later.

Compared to Dmitri's prototype, Nodes.td looks more like a class hierarchy and
less like a grammar. (E.g. variants list the Alternatives parent rather than
vice versa).
The main reasons for this:
 - the hierarchy is an important part of the API we want direct control over.
   - e.g. we may introduce abstract bases like "loop" that the grammar doesn't
 care about in order to model is-a concepts that might make refactorings
 more expressive. This is less natural in a grammar-like idiom.
   - e.g. we're likely to have to model some alternatives as variants and others
 as class hierarchies, the choice will probably be based on natural is-a
 relationships.
 - it reduces the cognitive load of switching from editing *.td to working with
   code that uses the generated classes

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/CMakeLists.txt
clang/include/clang/Tooling/Syntax/Nodes.h
clang/include/clang/Tooling/Syntax/Nodes.td
clang/include/clang/Tooling/Syntax/Syntax.td
clang/utils/TableGen/ClangSyntaxEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/CMakeLists.txt 
b/clang/include/clang/Tooling/Syntax/CMakeLists.txt
index a740015de365..b71bcb4a9797 100644
--- a/clang/include/clang/Tooling/Syntax/CMakeLists.txt
+++ b/clang/include/clang/Tooling/Syntax/CMakeLists.txt
@@ -2,3 +2,6 @@ clang_tablegen(Nodes.inc -gen-clang-syntax-node-list
   SOURCE Nodes.td
   TARGET ClangSyntaxNodeList)
 
+clang_tablegen(NodeClasses.inc -gen-clang-syntax-node-classes
+  SOURCE Nodes.td
+  TARGET ClangSyntaxNodeClasses)

diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index ed170beb75c8..54b8c33199ff 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -114,67 +114,7 @@ enum class NodeRole : uint8_t {
 /// For debugging purposes.
 raw_ostream &operator<<(raw_ostream &OS, NodeRole R);
 
-class SimpleDeclarator;
-
-/// A root node for a translation unit. Parent is always null.
-class TranslationUnit final : public Tree {
-public:
-  TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
-  static bool classof(const Node *N);
-};
-
-/// A base class for all expressions. Note that expressions are not statements,
-/// even though they are in clang.
-class Expression : public Tree {
-public:
-  Expression(NodeKind K) : Tree(K) {}
-  static bool classof(const Node *N);
-};
-
-/// A sequence of these specifiers make a `nested-name-specifier`.
-/// e.g. the `std` or `vector` in `std::vector::size`.
-class NameSpecifier : public Tree {
-public:
-  NameSpecifier(NodeKind K) : Tree(K) {}
-  static bool classof(const Node *N);
-};
-
-/// The global namespace name specifier, this specifier doesn't correspond to a
-/// token instead an absence of tokens before a `::` characterizes it, in
-/// `::std::vector` it would be characterized by the absence of a token
-/// before the first `::`
-class GlobalNameSpecifier final : public NameSpecifier {
-public:
-  GlobalNameSpecifier() : NameSpecifier(NodeKind::GlobalNameSpecifier) {}
-  static bool classof(const Node *N);
-};
-
-/// A name specifier holding a decltype, of the form: `decltype ( expression ) 
`
-/// e.g. the `decltype(s)` in `decltype(s)::size`.
-class DecltypeNameSpecifier final : public NameSpecifier {
-public:
-  DecltypeNameSpecifier() : NameSpecifier(NodeKind::DecltypeNameSpecifier) {}
-  static bool classof(const Node *N);
-};
-
-/// A identifier name specifier, of the form `identifier`
-/// e.g. the `std` in `std::vector::size`.
-class IdentifierNameSpecifier final : public NameSpecifier {
-public:
-  IdentifierNameSpecifier()
-  : NameSpecifier(NodeKind::IdentifierNameSpecifier) {}
-  static bool classof(const Node *N);
-};
-
-/// A name specifier with a simple-template-id, of the form `template_opt
-/// identifier < template-args >` e.g. the `vector` in
-/// `std::vector::size`.
-class SimpleTemplateNameSpecifier final : public NameSp

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304463.
kbobyrev added a comment.

Reset unittests to HEAD.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -91,10 +91,86 @@
 }
 
 TEST(RenameTest, WithinFileRename) {
-  // rename is runnning on all "^" points, and "[[]]" ranges point to the
-  // identifier that is being renamed.
+  // For each "^" this test moves cursor to its location and applies renaming
+  // while checking that all identifiers enclosed in [[]] ranges are handled
+  // correctly.
   llvm::StringRef Tests[] = {
-  // Function.
+  // Templated static method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Class template (partial) specialization forward declarations.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+
+  // Class template (full) specialization forward declaration.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization forward declaration.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+
+  // Function template specialization forward declaration.
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+
+  // Function template specialization forward declaration without function
+  // definition.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  // Simple recursive function.
   R"cpp(
 void [[foo^]]() {
   [[fo^o]]();
@@ -104,7 +180,7 @@
   // Type.
   R"cpp(
 struct [[foo^]] {};
-[[foo]] test() {
+[[foo^]] test() {
[[f^oo]] x;
return x;
 }
@@ -114,20 +190,21 @@
   R"cpp(
 void bar() {
   if (auto [[^foo]] = 5) {
-[[foo]] = 3;
+[[fo^o]] = 3;
   }
 }
   )cpp",
 
-  // Rename class, including constructor/destructor.
+  // Class, its constructor and destructor.
   R"cpp(
 class [[F^oo]] {
+public:
   [[F^oo]]();
-  ~[[Foo]]();
+  ~[[Fo^o]]();
   void foo(int x);
 };
-[[Foo]]::[[Fo^o]]() {}
-void [[Foo]]::foo(int x) {}
+[[Fo^o]]::[[Fo^o]]() {}
+void [[Fo^o]]::foo(int x) {}
   )cpp",
 
   // Rename template class, including constructor/destructor.
@@ -199,9 +276,9 @@
 class [[F^oo]] {};
 
 void test() {
-  [[Foo]] x;
-  [[Foo]] y;
-  [[Foo]] z;
+  [[F^oo]] x;
+  [[Fo^o]] y;
+  [[Foo^]] z;
 }
   )cpp",
 
@@ -360,8 +437,8 @@
 void boo(int);
 
 void qoo() {
-  [[foo]]();
-  boo([[foo]]());
+  [[f^oo]]();
+  boo([[fo^o]]());
   M1();
   boo(M1());
   M2([[foo]]());
@@ -454,7 +531,7 @@
 }
   )cpp",
 
-  // template class in template argument list.
+  // Template class in template argument list.
   R"cpp(
 template
 class [[Fo^o]] {};
@@ -510,6 +587,263 @@
   }
 }
 
+TEST(RenameTest, Alias) {
+  // For each "^" this test moves cursor to its location and applies renaming
+  // while checking that all identifiers enclosed in [[]] ranges are handled
+  // correctly.
+  llvm::StringRef Tests[] = {
+  R"cpp(
+class X {};
+typedef X [[Fo^o]];
+  )cpp",
+
+  R"cpp(
+class X {};
+using [[U^Old]] = X;
+  )cpp",
+
+  R"cpp(
+template 
+class X { T t; };
+
+template 
+using [[O^ld]] = X;
+  )cpp",
+
+  R"cpp(
+namespace x { class X {}; }
+namespace ns {
+using [[F^oo]] = x::X;
+}
+  )cpp",
+
+  R"cpp(
+namespace x { class Old {}; }
+namespace ns {
+#define REF(alias) alias alias_var;
+
+#define ALIAS(old) \
+  using old##Alias = x::old; \
+

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304464.
kbobyrev added a comment.

Actually reset RenameTests.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -92,6 +92,7 @@
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
 // Get to CXXRecordDecl from constructor or destructor.
+// FIXME(kirillbobyrev): Just use getRenameRoot?
 D = tooling::getCanonicalSymbolDeclaration(D);
 Result.insert(D);
   }
@@ -219,23 +220,80 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const Decl *getRenameRootDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const Decl *getRenameRootDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const Decl *getRenameRootDecl(const CXXMethodDecl *D) {
+  const auto *Result = D;
+  if (const auto *InstantiatedMethod = D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const Decl *getRenameRootDecl(const FunctionDecl *D) {
+  const auto *Definition = D->getDefinition();
+  const auto *Candidate = Definition ? Definition : D->getMostRecentDecl();
+  return Candidate->isTemplateInstantiation()
+ ? Candidate->getPrimaryTemplate()->getTemplatedDecl()
+ : Candidate;
+}
+
+const Decl *getRenameRootDecl(const FieldDecl *D) {
+  // This is a hacky way to do something like
+  // CXXMethodDecl::getINstantiatedFromMemberFunction for the field because
+  // Clang AST does not store relevant information about the field that is
+  // instantiated.
+  const auto *TemplateSpec =
+  dyn_cast(D->getParent());
+  if (!TemplateSpec)
+return D;
+  const auto *FieldParent = TemplateSpec->getTemplateInstantiationPattern();
+  if (!FieldParent)
+return D;
+  for (const auto *Field : FieldParent->fields())
+if (Field->getFieldIndex() == D->getFieldIndex() &&
+Field->getLocation() == D->getLocation())
+  return Field;
+  return D;
+}
+
+// FIXME(kirillbobyrev): Write documentation.
+const Decl *getRenameRootDecl(const Decl *D) {
+  const auto *Candidate = D;
+  if (const auto *RD = dyn_cast(D)) {
+const auto *Definition = RD->getDefinition();
+Candidate = Definition ? Definition : RD->getMostRecentDecl();
+  }
+  if (const auto *Template = dyn_cast(Candidate))
+return getRenameRootDecl(Template);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(Candidate))
+return getRenameRootDecl(ClassTemplateSpecialization);
+  if (const auto *Constructor = dyn_cast(Candidate))
+return getRenameRootDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(Candidate))
+return getRenameRootDecl(Destructor->getParent());
+  if (const auto *Method = dyn_cast(Candidate))
+return getRenameRootDecl(Method);
+  if (const auto *Function = dyn_cast(Candidate))
+return getRenameRootDecl(Function);
+  if (const auto *Field = dyn_cast(Candidate))
+return getRenameRootDecl(Field);
+  return Candidate;
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrenceeWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-TargetIDs.insert(SymbolID(USR));
+  const auto *RenameDeclRoot = getRenameRootDecl(&ND);
 
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
@@ -243,11 +301,11 @@
   if (Ref.Targets.empty())
 return;
   for (const auto *Target : Ref.Targets) {
-auto ID = getSymbolID(Target);
-if (!ID || TargetIDs.find(ID) == TargetIDs.end())
+if (getRenameRootDecl(Target) == RenameDeclRoot) {
+  Results.push_back(Ref.NameLoc);
   return;
+}
   }
-  Result

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev planned changes to this revision.
kbobyrev added a comment.

Still WIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

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


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304466.
kbobyrev added a comment.

Rebase on top of master.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -92,6 +92,7 @@
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
 // Get to CXXRecordDecl from constructor or destructor.
+// FIXME(kirillbobyrev): Just use getRenameRoot?
 D = tooling::getCanonicalSymbolDeclaration(D);
 Result.insert(D);
   }
@@ -222,23 +223,80 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const Decl *getRenameRootDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const Decl *getRenameRootDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const Decl *getRenameRootDecl(const CXXMethodDecl *D) {
+  const auto *Result = D;
+  if (const auto *InstantiatedMethod = D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const Decl *getRenameRootDecl(const FunctionDecl *D) {
+  const auto *Definition = D->getDefinition();
+  const auto *Candidate = Definition ? Definition : D->getMostRecentDecl();
+  return Candidate->isTemplateInstantiation()
+ ? Candidate->getPrimaryTemplate()->getTemplatedDecl()
+ : Candidate;
+}
+
+const Decl *getRenameRootDecl(const FieldDecl *D) {
+  // This is a hacky way to do something like
+  // CXXMethodDecl::getINstantiatedFromMemberFunction for the field because
+  // Clang AST does not store relevant information about the field that is
+  // instantiated.
+  const auto *TemplateSpec =
+  dyn_cast(D->getParent());
+  if (!TemplateSpec)
+return D;
+  const auto *FieldParent = TemplateSpec->getTemplateInstantiationPattern();
+  if (!FieldParent)
+return D;
+  for (const auto *Field : FieldParent->fields())
+if (Field->getFieldIndex() == D->getFieldIndex() &&
+Field->getLocation() == D->getLocation())
+  return Field;
+  return D;
+}
+
+// FIXME(kirillbobyrev): Write documentation.
+const Decl *getRenameRootDecl(const Decl *D) {
+  const auto *Candidate = D;
+  if (const auto *RD = dyn_cast(D)) {
+const auto *Definition = RD->getDefinition();
+Candidate = Definition ? Definition : RD->getMostRecentDecl();
+  }
+  if (const auto *Template = dyn_cast(Candidate))
+return getRenameRootDecl(Template);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(Candidate))
+return getRenameRootDecl(ClassTemplateSpecialization);
+  if (const auto *Constructor = dyn_cast(Candidate))
+return getRenameRootDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(Candidate))
+return getRenameRootDecl(Destructor->getParent());
+  if (const auto *Method = dyn_cast(Candidate))
+return getRenameRootDecl(Method);
+  if (const auto *Function = dyn_cast(Candidate))
+return getRenameRootDecl(Function);
+  if (const auto *Field = dyn_cast(Candidate))
+return getRenameRootDecl(Field);
+  return Candidate;
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-TargetIDs.insert(SymbolID(USR));
+  const auto *RenameDeclRoot = getRenameRootDecl(&ND);
 
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
@@ -246,11 +304,11 @@
   if (Ref.Targets.empty())
 return;
   for (const auto *Target : Ref.Targets) {
-auto ID = getSymbolID(Target);
-if (!ID || TargetIDs.find(ID) == TargetIDs.end())
+if (getRenameRootDecl(Target) == RenameDeclRoot) {
+  Results.push_back(Ref.NameLoc);
   return;
+}
   }
-  Results.push

[PATCH] D82860: Port ObjCMTAction to new option parsing system

2020-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG09248a5d25bb: [clang][cli] Port ObjCMTAction to new option 
parsing system (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82860

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/Opts.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -61,74 +61,20 @@
   OS << "[" << PrefixLength << "]";
 }
 
-class MarshallingKindInfo {
+class MarshallingInfo {
 public:
+  static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
+
   const Record &R;
-  const char *MacroName;
   bool ShouldAlwaysEmit;
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
-
-  void emit(raw_ostream &OS) const {
-write_cstring(OS, StringRef(getOptionSpelling(R)));
-OS << ", ";
-OS << ShouldAlwaysEmit;
-OS << ", ";
-OS << KeyPath;
-OS << ", ";
-emitScopedNormalizedValue(OS, DefaultValue);
-OS << ", ";
-emitSpecific(OS);
-  }
-
-  virtual Optional emitValueTable(raw_ostream &OS) const {
-return None;
-  }
-
-  virtual ~MarshallingKindInfo() = default;
-
-  static std::unique_ptr create(const Record &R);
-
-protected:
-  void emitScopedNormalizedValue(raw_ostream &OS,
- StringRef NormalizedValue) const {
-if (!NormalizedValuesScope.empty())
-  OS << NormalizedValuesScope << "::";
-OS << NormalizedValue;
-  }
-
-  virtual void emitSpecific(raw_ostream &OS) const = 0;
-  MarshallingKindInfo(const Record &R, const char *MacroName)
-  : R(R), MacroName(MacroName) {}
-};
-
-class MarshallingFlagInfo final : public MarshallingKindInfo {
-public:
-  bool IsPositive;
-
-  void emitSpecific(raw_ostream &OS) const override { OS << IsPositive; }
-
-  static std::unique_ptr create(const Record &R) {
-std::unique_ptr Ret(new MarshallingFlagInfo(R));
-Ret->IsPositive = R.getValueAsBit("IsPositive");
-// FIXME: This is a workaround for a bug in older versions of clang (< 3.9)
-//   The constructor that is supposed to allow for Derived to Base
-//   conversion does not work. Remove this if we drop support for such
-//   configurations.
-return std::unique_ptr(Ret.release());
-  }
-
-private:
-  MarshallingFlagInfo(const Record &R)
-  : MarshallingKindInfo(R, "OPTION_WITH_MARSHALLING_FLAG") {}
-};
-
-class MarshallingStringInfo final : public MarshallingKindInfo {
-public:
   StringRef NormalizerRetTy;
   StringRef Normalizer;
   StringRef Denormalizer;
+  StringRef ValueMerger;
+  StringRef ValueExtractor;
   int TableIndex = -1;
   std::vector Values;
   std::vector NormalizedValues;
@@ -149,17 +95,29 @@
   static constexpr const char *ValueTablesDecl =
   "static const SimpleEnumValueTable SimpleEnumValueTables[] = ";
 
-  void emitSpecific(raw_ostream &OS) const override {
+  void emit(raw_ostream &OS) const {
+write_cstring(OS, StringRef(getOptionSpelling(R)));
+OS << ", ";
+OS << ShouldAlwaysEmit;
+OS << ", ";
+OS << KeyPath;
+OS << ", ";
+emitScopedNormalizedValue(OS, DefaultValue);
+OS << ", ";
 emitScopedNormalizedValue(OS, NormalizerRetTy);
 OS << ", ";
 OS << Normalizer;
 OS << ", ";
 OS << Denormalizer;
 OS << ", ";
+OS << ValueMerger;
+OS << ", ";
+OS << ValueExtractor;
+OS << ", ";
 OS << TableIndex;
   }
 
-  Optional emitValueTable(raw_ostream &OS) const override {
+  Optional emitValueTable(raw_ostream &OS) const {
 if (TableIndex == -1)
   return {};
 OS << "static const SimpleEnumValue " << ValueTableName << "[] = {\n";
@@ -175,23 +133,32 @@
 return StringRef(ValueTableName);
   }
 
-  static std::unique_ptr create(const Record &R) {
-assert(!isa(R.getValueInit("NormalizerRetTy")) &&
-   "String options must have a type");
-
-std::unique_ptr Ret(new MarshallingStringInfo(R));
-Ret->NormalizerRetTy = R.getValueAsString("NormalizerRetTy");
-
-Ret->Normalizer = R.getValueAsString("Normalizer");
-Ret->Denormalizer = R.getValueAsString("Denormalizer");
+  static MarshallingInfo create(const Record &R) {
+assert(!isa(R.getValueInit("KeyPath")) &&
+   !isa(R.getValueInit("DefaultValue")) &&
+   !isa(R.getValueInit("NormalizerRetTy")) &&
+   !isa(R.getValueInit("ValueMerger")) &&
+   "MarshallingInfo must have a type");
+
+MarshallingInfo Ret(R);
+Ret.ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
+Ret.KeyPath = R.getValueAsString("KeyPath");
+Ret.Defaul

[clang] 09248a5 - [clang][cli] Port ObjCMTAction to new option parsing system

2020-11-11 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-11T13:03:02+01:00
New Revision: 09248a5d25bb1c9f357247fa3da8fbe4470e9c67

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

LOG: [clang][cli] Port ObjCMTAction to new option parsing system

Merge existing marhsalling info kinds and add some primitives to
express flag options that contribute to a bitfield.

Depends on D82574

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/unittests/Option/Opts.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f5e403057f57..75b63d49bb24 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -340,36 +340,53 @@ def ccc_objcmt_migrate : Separate<["-"], 
"ccc-objcmt-migrate">,
   InternalDriverOpt,
   HelpText<"Apply modifications and produces temporary files to migrate to "
"modern ObjC syntax">;
+
 def objcmt_migrate_literals : Flag<["-"], "objcmt-migrate-literals">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC literals">;
+  HelpText<"Enable migration to modern ObjC literals">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Literals">;
 def objcmt_migrate_subscripting : Flag<["-"], "objcmt-migrate-subscripting">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC subscripting">;
+  HelpText<"Enable migration to modern ObjC subscripting">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Subscripting">;
 def objcmt_migrate_property : Flag<["-"], "objcmt-migrate-property">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC property">;
+  HelpText<"Enable migration to modern ObjC property">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Property">;
 def objcmt_migrate_all : Flag<["-"], "objcmt-migrate-all">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC">;
+  HelpText<"Enable migration to modern ObjC">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_MigrateDecls">;
 def objcmt_migrate_readonly_property : Flag<["-"], 
"objcmt-migrate-readonly-property">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC readonly property">;
+  HelpText<"Enable migration to modern ObjC readonly property">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ReadonlyProperty">;
 def objcmt_migrate_readwrite_property : Flag<["-"], 
"objcmt-migrate-readwrite-property">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to modern ObjC readwrite property">;
+  HelpText<"Enable migration to modern ObjC readwrite property">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_ReadwriteProperty">;
 def objcmt_migrate_property_dot_syntax : Flag<["-"], 
"objcmt-migrate-property-dot-syntax">, Flags<[CC1Option]>,
-  HelpText<"Enable migration of setter/getter messages to property-dot 
syntax">;
+  HelpText<"Enable migration of setter/getter messages to property-dot 
syntax">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_PropertyDotSyntax">;
 def objcmt_migrate_annotation : Flag<["-"], "objcmt-migrate-annotation">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to property and method annotations">;
+  HelpText<"Enable migration to property and method annotations">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Annotation">;
 def objcmt_migrate_instancetype : Flag<["-"], "objcmt-migrate-instancetype">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to infer instancetype for method result type">;
+  HelpText<"Enable migration to infer instancetype for method result type">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_Instancetype">;
 def objcmt_migrate_nsmacros : Flag<["-"], "objcmt-migrate-ns-macros">, 
Flags<[CC1Option]>,
-  HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">;
+  HelpText<"Enable migration to NS_ENUM/NS_OPTIONS macros">,
+  MarshallingInfoBitfieldFlag<"FrontendOpts.ObjCMTAction", 
"FrontendOptions::ObjCMT_NsMacros">;
 def objcmt_migrate_protocol_conformance : Flag<["-"], 
"objcmt-migrate-protocol-conformance">, Flags<[CC1Option]>,
-  HelpText<"Enable migration to add protocol conformance on classes">;
+  HelpText<"Enable migration to add protocol conformance on classes">,
+  MarshallingInfoBitfieldFlag<"

[PATCH] D91067: [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-11 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis marked an inline comment as done.
joechrisellis added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:8563-8566
+if (const auto *BT = FirstType->getAs()) {
+  if (const auto *VT = SecondType->getAs()) {
+if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector) {
+  const LangOptions::LaxVectorConversionKind LVCKind =

fpetrogalli wrote:
> May I ask to avoid this triple if statement? Given that `BT` is not used 
> after being defined, I think the following form would be easier to understand:
> 
> ```
> if (!FirstType->getAs())
>   return false;
> 
> const auto *VT = SecondType->getAs();
> 
> if (VT && VT->getVectorKind() == VectorType::SveFixedLengthDataVector) {
>/// ...
> return ...
> }
> 
> return false;
> ```
> 
> May I ask you to give meaningful names to the variables? BT and VT are quite 
> cryptic to me.
> 
> Moreover.. are BT and VT really needed? You are asserting 
> `FirstType->isSizelessBuiltinType() && SecondType->isVectorType()` ... the 
> `getAs` calls should not fail, no? given that the lambda is local to this 
> method, I wouldn't bother making it work for the generic case.
Simplified the code as per your suggestion, but the lambda here here serves a 
purpose: it makes sure that `areLaxCompatibleSveTypes` has the same behaviour 
irrespective of the ordering of the parameters. So we do actually need the if 
statements inside the lambda.



Comment at: clang/lib/Sema/SemaCast.cpp:
   if (srcIsVector || destIsVector) {
+// Scalable vectors can be cast to and from liberally.
+if (SrcType->isSizelessBuiltinType() || DestType->isSizelessBuiltinType()) 
{

fpetrogalli wrote:
> This code path seems untested.
Thinking about it, this could do with being broken out into its own patch. Will 
do this.



Comment at: clang/lib/Sema/SemaOverload.cpp:1650-1652
+  ICK = ICK_SVE_Vector_Conversion;
+  return true;
+}

fpetrogalli wrote:
> tabs!
Not sure where these came from, since I ran `clang-format` over the patch. 
Think they should be gone now...



Comment at: clang/test/Sema/aarch64-sve-lax-vector-conversions.cpp:19
+
+  // This explicit cast is always allowed, irrespective of the value of 
-flax-vector-conversions.
+  ff32 = (fixed_float32_t)sf64;

fpetrogalli wrote:
> Why this one in particular? To me the comment would make more sense if saying 
> 
> ```
> // An explicit cast is always allowed, irrespective of the value of 
> -flax-vector-conversions.
> ```
Will break this out into another patch as mentioned above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91067

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


[PATCH] D91067: [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-11 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 304469.
joechrisellis marked 3 inline comments as done.
joechrisellis added a comment.

Address @fpetrogalli's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91067

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/Sema/aarch64-sve-lax-vector-conversions.cpp
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-lax-vector-conversions.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-none %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=integer -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-integer %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=all -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify=lax-vector-all %s
+
+// lax-vector-all-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+
+void allowed_with_integer_lax_conversions() {
+  fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+}
+
+void allowed_with_all_lax_conversions() {
+  fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1644,11 +1644,12 @@
 }
   }
 
-  if ((ToType->isSizelessBuiltinType() || FromType->isSizelessBuiltinType()) &&
-  S.Context.areCompatibleSveTypes(FromType, ToType)) {
-ICK = ICK_SVE_Vector_Conversion;
-return true;
-  }
+  if (ToType->isSizelessBuiltinType() || FromType->isSizelessBuiltinType())
+if (S.Context.areCompatibleSveTypes(FromType, ToType) ||
+S.Context.areLaxCompatibleSveTypes(FromType, ToType)) {
+  ICK = ICK_SVE_Vector_Conversion;
+  return true;
+}
 
   // We can perform the conversion between vector types in the following cases:
   // 1)vector types are equivalent AltiVec and GCC vector types
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8553,6 +8553,41 @@
  IsValidCast(SecondType, FirstType);
 }
 
+bool ASTContext::areLaxCompatibleSveTypes(QualType FirstType,
+  QualType SecondType) {
+  assert(((FirstType->isSizelessBuiltinType() && SecondType->isVectorType()) ||
+  (FirstType->isVectorType() && SecondType->isSizelessBuiltinType())) &&
+ "Expected SVE builtin type and vector type!");
+
+  auto IsLaxCompatible = [this](QualType FirstType, QualType SecondType) {
+if (!FirstType->getAs())
+  return false;
+
+const auto *VecTy = SecondType->getAs();
+if (VecTy &&
+VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector) {
+  const LangOptions::LaxVectorConversionKind LVCKind =
+  getLangOpts().getLaxVectorConversions();
+
+  // If -flax-vector-conversions=all is specified, the types are
+  // certainly compatible.
+  if (LVCKind == LangOptions::LaxVectorConversionKind::All)
+return true;
+
+  // If -flax-vector-conversions=integer is specified, the types are
+  // compatible if the elements are integer types.
+  if (LVCKind == LangOptions::LaxVectorConversionKind::Integer)
+return VecTy->getElementType().getCanonicalType()->isIntegerType() &&
+   FirstType->getSveEltType(*this)->isIntegerType();
+}
+
+return false;
+  };
+
+  return IsLaxCompatible(FirstType, SecondType) ||
+ IsLaxCompatible(SecondType, FirstType);
+}
+
 bool ASTContext::hasDirectOwnershipQualifier(QualType Ty) const {
   while 

[PATCH] D90956: [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

2020-11-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 304473.
fpetrogalli added a comment.

I have added more test coverage for the codegen of the examples mentioned in 
section 3.7.3.3 of the SVE ACLE. The tests are generic to work for 
`-msve-vector-bits=128|...|2048`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90956

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -440,14 +440,10 @@
 // CHECK-BFLOAT: __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1
 
 // == Check sve-vector-bits flag.
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=128 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-128 %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=256 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-256 %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=512 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-512 %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=1024 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-1024 %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=2048 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-2048 %s
-// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=2048 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-2048 %s
-// CHECK-SVE-VECTOR-BITS-128: __ARM_FEATURE_SVE_BITS 128
-// CHECK-SVE-VECTOR-BITS-256: __ARM_FEATURE_SVE_BITS 256
-// CHECK-SVE-VECTOR-BITS-512: __ARM_FEATURE_SVE_BITS 512
-// CHECK-SVE-VECTOR-BITS-1024: __ARM_FEATURE_SVE_BITS 1024
-// CHECK-SVE-VECTOR-BITS-2048: __ARM_FEATURE_SVE_BITS 2048
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=128  -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=128  %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=256  -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=256  %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=512  -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=512  %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=1024 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=1024 %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=2048 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS -D#VBITS=2048 %s
+// CHECK-SVE-VECTOR-BITS: __ARM_FEATURE_SVE_BITS [[#VBITS:]]
+// CHECK-SVE-VECTOR-BITS: __ARM_FEATURE_SVE_VECTOR_OPERATORS 1
Index: clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s -msve-vector-bits=128  | FileCheck %s -D#VBITS=128  --check-prefixes=CHECK,CHECK128
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s -msve-vector-bits=256  | FileCheck %s -D#VBITS=256  --check-prefixes=CHECK,CHECKWIDE
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s -msve-vector-bits=512  | FileCheck %s -D#VBITS=512  --check-prefixes=CHECK,CHECKWIDE
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s -msve-vector-bits=1024 | FileCheck %s -D#VBITS=1024 --check-prefixes=CHECK,CHECKWIDE
+// RUN: %clang_cc1 -x c++ -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s -msve-vector-bits=2048 | FileCheck %s -D#VBITS=2048 --check-prefixes=CHECK,CHECKWIDE
+// REQUIRES: aarch64-registered-target
+
+// Examples taken from section "3.7.3.3 Behavior specific to SVE
+// vectors" of the SVE ACLE (Version 00bet6) that can be found at
+// https://developer.arm.com/documen

[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-11 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp:45
   ifStmt(
   hasCondition(ignoringParenImpCasts(anyOf(
   declRefExpr(hasDeclaration(ImmutableVar)),

Just noticed, as this is ignoring Parenthesis and implicit nodes/casts, maybe 
we should also be ignoring those when getting the condition in the check
`InnerIf->getCond()->IgnoreParenImpCasts()`
I reckon if that change isnt made this could fail on
```lang=c++
if (IsSet){
  if ((OtherCond && IsSet))
;
}
```


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

https://reviews.llvm.org/D91037

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


[PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-11 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 304477.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Removed the first loop for clangd diagnostic, turns out it didnt make the 
following code that much messier.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clangd/Diagnostics.cpp
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/SourceLocation.h
  clang/include/clang/Tooling/Core/Replacement.h
  clang/lib/Frontend/DiagnosticRenderer.cpp
  clang/lib/Frontend/Rewrite/FixItRewriter.cpp
  clang/lib/Tooling/Core/Replacement.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1167,9 +1167,10 @@
   // This is cobbed from clang::Rewrite::FixItRewriter.
   if (fixit.CodeToInsert.empty()) {
 if (fixit.InsertFromRange.isValid()) {
-  commit.insertFromRange(fixit.RemoveRange.getBegin(),
- fixit.InsertFromRange, /*afterToken=*/false,
- fixit.BeforePreviousInsertions);
+  if (!fixit.isReformatFixit())
+commit.insertFromRange(fixit.RemoveRange.getBegin(),
+   fixit.InsertFromRange, /*afterToken=*/false,
+   fixit.BeforePreviousInsertions);
   return;
 }
 commit.remove(fixit.RemoveRange);
Index: clang/lib/Tooling/Core/Replacement.cpp
===
--- clang/lib/Tooling/Core/Replacement.cpp
+++ clang/lib/Tooling/Core/Replacement.cpp
@@ -22,6 +22,7 @@
 #include "clang/Rewrite/Core/RewriteBuffer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
@@ -42,32 +43,57 @@
 
 static const char * const InvalidLocation = "";
 
-Replacement::Replacement() : FilePath(InvalidLocation) {}
+FileRange::FileRange() : FilePath(InvalidLocation), RangeInFile(0, 0) {}
+
+FileRange::FileRange(StringRef FilePath, Range RangeInFile)
+: FilePath(FilePath), RangeInFile(RangeInFile) {}
+FileRange::FileRange(StringRef FilePath, unsigned Offset, unsigned Length)
+: FileRange(FilePath, Range(Offset, Length)) {}
+
+FileRange::FileRange(const SourceManager &Sources, SourceLocation Start,
+ unsigned Length) {
+  setFromSourceLocation(Sources, Start, Length);
+}
+
+FileRange::FileRange(const SourceManager &Sources, const CharSourceRange &Range,
+ const LangOptions &LangOpts) {
+  setFromSourceRange(Sources, Range, LangOpts);
+}
+
+bool FileRange::isValid() const { return FilePath != InvalidLocation; }
+
+void FileRange::setFromSourceLocation(const SourceManager &Sources,
+  SourceLocation Start, unsigned Length) {
+  const std::pair DecomposedLocation =
+  Sources.getDecomposedLoc(Start);
+  const FileEntry *Entry = Sources.getFileEntryForID(DecomposedLocation.first);
+  this->FilePath = std::string(Entry ? Entry->getName() : InvalidLocation);
+  this->RangeInFile = {DecomposedLocation.second, Length};
+}
+
+Replacement::Replacement() : ReplacementRange() {}
+
+Replacement::Replacement(FileRange FileRange, StringRef ReplacementText)
+: ReplacementRange(FileRange), ReplacementText(ReplacementText) {}
 
 Replacement::Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
  StringRef ReplacementText)
-: FilePath(std::string(FilePath)), ReplacementRange(Offset, Length),
-  ReplacementText(std::string(ReplacementText)) {}
+: Replacement(FileRange(FilePath, Offset, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager &Sources, SourceLocation Start,
- unsigned Length, StringRef ReplacementText) {
-  setFromSourceLocation(Sources, Start, Length, ReplacementText);
-}
+ unsigned Length, StringRef ReplacementText)
+: Replacement(FileRange(Sources, Start, Length), ReplacementText) {}
 
 Replacement::Replacement(const SourceManager &Sources,
  const CharSourceRange &Range,
- StringRef ReplacementText,
- const LangOptions &LangOpts) {
-  setFromSourceRange(Sources, Range, ReplacementText, LangOpts);
-}
+ StringRef ReplacementText, const LangOptions &LangOpts)
+: Replacement(FileRange(Sources, Range, LangOpts), ReplacementText) {}
 
-b

[PATCH] D91103: [tooling] Add support for fixits that indicate code will need reformatting

2020-11-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Diagnostics.cpp:677
 // If requested and possible, create a message like "change 'foo' to 
'bar'".
-if (SyntheticMessage && FixIts.size() == 1) {
-  const auto &FixIt = FixIts.front();
+if (SyntheticMessage && *SingleFixIt) {
+  const auto &FixIt = **SingleFixIt;

nit: you can check `Edits.size() == 1` here, `s/SingleFixIt/FixItForLastEdit` 
and get rid of the optional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91103

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


[PATCH] D91229: [FileCheck] Flip -allow-unused-prefixes to false by default

2020-11-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin created this revision.
mtrofin added a reviewer: jhenderson.
Herald added subscribers: llvm-commits, cfe-commits, frasercrmck, nikic, okura, 
jdoerfert, kuter, kerbowa, luismarques, apazos, sameer.abuasal, pzheng, 
pengfei, s.egerton, lenary, dmgreen, Jim, asbirlea, thopre, mstorsjo, jocewei, 
PkmX, jfb, arphaman, the_o, brucehoult, MartinMosbeck, rogfer01, steven_wu, 
atanasyan, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb, fedor.sergeev, kbarton, hiraditya, nhaehnle, jvesely, 
nemanjai, sdardis, jyknight, dschuff, qcolombet, jholewinski.
Herald added projects: clang, LLVM.
mtrofin requested review of this revision.
Herald added subscribers: bbn, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.

Automatically inserted --allow-unused-prefixes=true for tests that are
still failing.

Added a FIXME above each line where this was inserted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91229

Files:
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.c
  clang/test/Analysis/exploded-graph-rewriter/trimmers.dot
  clang/test/CodeGen/arm-varargs.c
  clang/test/CodeGen/asan-static-odr.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-lvalue.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-alloc_align-on-function-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function-two-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-true-negatives.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-when-nullptr-is-defined.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGen/catch-pointer-overflow-volatile.c
  clang/test/CodeGen/catch-pointer-overflow.c
  clang/test/CodeGen/cmse-clear-return.c
  clang/test/CodeGen/ms-barriers-intrinsics.c
  clang/test/CodeGen/ms-mixed-ptr-sizes.c
  clang/test/CodeGen/neon-immediate-ubsan.c
  clang/test/CodeGen/ppc-smmintrin.c
  clang/test/CodeGenCUDA/device-stub.cu
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/attr-cpuspecific.cpp
  clang/test/CodeGenCXX/bitfield-layout.cpp
  clang/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
  clang/test/CodeGenCXX/catch-implicit-integer-truncations.cpp
  clang/test/CodeGenCXX/conditional-temporaries.cpp
  clang/test/CodeGenCXX/dllexport.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
  clang/test/CodeGenCXX/inheriting-constructor.cpp
  clang/test/CodeGenCXX/lifetime-sanitizer.cpp
  clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
  clang/test/CodeGenCXX/member-function-pointer-calls.cpp
  clang/test/CodeGenCXX/runtime-dllstorage.cpp
  clang/test/CodeGenCXX/ubsan-vtable-checks.cpp
  clang/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m
  clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/cuda-detect.cu
  clang/test/Driver/fsanitize.c
  clang/test/Driver/hip-toolchain-device-only.hip
  clang/test/Driver/ps4-visibility-dllstorageclass.c
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Modules/codegen.test
  clang/test/Modules/preprocess-nested.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_reduction_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/irbuilder_nested_openmp_parallel_empty.c
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_gen

[PATCH] D91229: [FileCheck] Flip -allow-unused-prefixes to false by default

2020-11-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

FYI - I realize the change is enormous. I don't necessarily mean to land it 
as-is, we can chunk it by directories and iteratively update this as those land.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91229

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


[PATCH] D91229: [FileCheck] Flip -allow-unused-prefixes to false by default

2020-11-11 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a subscriber: RKSimon.
jhenderson added a comment.

Maybe one way to do this is to do what @RKSimon suggests in the D90281 
, and to enable it on a per-directory basis 
using lit.local.cfg. That would potentially require changing the "0 or 1" 
occurrences limitation of the option, in favour of "last one wins" (or first 
one). Then, you make the change in the lit.local.cfg, flipping the default in 
each directory as you go. Eventually, once all tests that need it are covered, 
you can just change the default in FileCheck itself. How does that sound?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91229

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


[PATCH] D43002: Emit S_OBJNAME symbol in CodeView

2020-11-11 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea updated this revision to Diff 304364.
aganea edited the summary of this revision.
aganea edited reviewers, added: mstorsjo; removed: reames, espindola.
aganea added a comment.

Simplify.
Added coverage when using `clang-cl` since this is a MSVC-specific feature.
When `-fdebug-compilation-dir=.` is used, relative paths are now emitted in the 
`S_OBJNAME` record.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/CodeGenCXX/debug-info-objname.cpp
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/Support/ToolOutputFile.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/LTO/Caching.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/test/DebugInfo/COFF/globals.ll
  llvm/test/DebugInfo/COFF/multifunction.ll
  llvm/test/DebugInfo/COFF/pr28747.ll
  llvm/test/DebugInfo/COFF/simple.ll
  llvm/test/DebugInfo/COFF/vframe-fpo.ll
  llvm/test/MC/AArch64/coff-debug.ll
  llvm/test/MC/ARM/coff-debugging-secrel.ll
  llvm/test/MC/COFF/cv-compiler-info.ll
  llvm/tools/llc/llc.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp

Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -352,7 +352,7 @@
 std::error_code EC;
 auto S = std::make_unique(Path, EC, sys::fs::OF_None);
 check(EC, Path);
-return std::make_unique(std::move(S));
+return std::make_unique(std::move(S), Path);
   };
 
   auto AddBuffer = [&](size_t Task, std::unique_ptr MB) {
Index: llvm/tools/llc/llc.cpp
===
--- llvm/tools/llc/llc.cpp
+++ llvm/tools/llc/llc.cpp
@@ -535,6 +535,9 @@
   GetOutputStream(TheTarget->getName(), TheTriple.getOS(), argv[0]);
   if (!Out) return 1;
 
+  // Ensure the filename is passed down to CodeViewDebug.
+  Target->Options.MCOptions.COFFOutputFilename = Out->outputFilename();
+
   std::unique_ptr DwoOut;
   if (!SplitDwarfOutputFile.empty()) {
 std::error_code EC;
Index: llvm/test/MC/COFF/cv-compiler-info.ll
===
--- llvm/test/MC/COFF/cv-compiler-info.ll
+++ llvm/test/MC/COFF/cv-compiler-info.ll
@@ -1,4 +1,6 @@
-; RUN: llc -mtriple i686-pc-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple i686-pc-windows-msvc < %s | FileCheck %s --check-prefixes=CHECK,STDOUT
+; RUN: llc -mtriple i686-pc-windows-msvc < %s -o %t
+; RUN: FileCheck %s --input-file=%t --check-prefixes=CHECK,FILE
 ; ModuleID = 'D:\src\scopes\foo.cpp'
 source_filename = "D:\5Csrc\5Cscopes\5Cfoo.cpp"
 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
@@ -20,19 +22,23 @@
 ; One .debug$S section should contain an S_COMPILE3 record that identifies the
 ; source language and the version of the compiler based on the DICompileUnit.
 ; CHECK: 	.section	.debug$S,"dr"
+; CHECK:.short  4353# Record kind: S_OBJNAME
+; CHECK-NEXT:   .long   0   # Signature
+; STDOUT-NEXT:  .byte   0   # Object name
+; FILE-NEXT:.asciz	"{{.*}}{{|/}}cv-compiler-info.ll.tmp" # Object name
 ; CHECK: 		.short	4412  # Record kind: S_COMPILE3
-; CHECK: 		.long	1   # Flags and language
-; CHECK: 		.short	7 # CPUType
-; CHECK: 		.short	4 # Frontend version
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.short	[[BACKEND_VERSION:[0-9]+]]  # Backend version
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.short	0
-; CHECK: 		.asciz	"clang version 4.0.0 "  # Null-terminated compiler version string
-; CHECK-NOT: .short	4412  # Record kind: S_COMPILE3
+; CHECK-NEXT:   .long	1   # Flags and language
+; CHECK-NEXT: 	.short	7 # CPUType
+; CHECK-NEXT: 	.short	4 # Frontend version
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	[[BACKEND_VERSION:[0-9]+]]  # Backend version
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.short	0
+; CHECK-NEXT: 	.asciz	"clang version 4.0.0 "  # Null-terminated compiler version string
+; CHECK-NOT:.short	4412  # Record kind: S_COMPILE3
 !1 = !DIFile(filename: "D:\5Csrc\5Cscopes\5Cfoo.cpp", directory: "D:\5Csrc\5Cscopes\5Cclang")
 !2 = !{}
 !7 = !{i32 2, !"CodeView", i32 1}
Index: llvm/test/MC/ARM/coff-debugging-secrel.ll
===
--- llvm/test/MC/ARM/coff-debugging-secrel.ll
+++ llvm/test/MC/ARM/coff-debugging-secrel.ll
@@ -42,10 +42,10 @@
 
 ; CHECK-MSVC: Relocations [
 ;

[PATCH] D91251: [VE] Support vector register in inline asm

2020-11-11 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 created this revision.
kaz7 added reviewers: simoll, k-ishizaka.
kaz7 added projects: clang, VE.
Herald added a subscriber: cfe-commits.
kaz7 requested review of this revision.

Support a vector register constraint in inline asm of clang.
Add a regression test also.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91251

Files:
  clang/lib/Basic/Targets/VE.h
  clang/test/CodeGen/VE/ve-inline-asm.c


Index: clang/test/CodeGen/VE/ve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/VE/ve-inline-asm.c
@@ -0,0 +1,23 @@
+// REQUIRES: ve-registered-target
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+void r(long v) {
+  long b;
+  asm("lea %0, 256(%1)"
+  : "=r"(b)
+  : "r"(v));
+  // CHECK: %1 = call i64 asm "lea $0, 256($1)", "=r,r"(i64 %0)
+}
+
+void v(char *ptr, char *ptr2) {
+  typedef double __vr __attribute__((__vector_size__(2048)));
+  __vr a;
+  asm("vld %0, 8, %1"
+  : "=v"(a)
+  : "r"(ptr));
+  asm("vst %0, 8, %1"
+  :
+  : "v"(a), "r"(ptr2));
+  // CHECK: %1 = call <256 x double> asm "vld $0, 8, $1", "=v,r"(i8* %0)
+  // CHECK: call void asm sideeffect "vst $0, 8, $1", "v,r"(<256 x double> %2, 
i8* %3)
+}
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -160,6 +160,13 @@
 
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
+switch (*Name) {
+default:
+  return false;
+case 'v':
+  Info.setAllowsRegister();
+  return true;
+}
 return false;
   }
 


Index: clang/test/CodeGen/VE/ve-inline-asm.c
===
--- /dev/null
+++ clang/test/CodeGen/VE/ve-inline-asm.c
@@ -0,0 +1,23 @@
+// REQUIRES: ve-registered-target
+// RUN: %clang_cc1 -triple ve-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+void r(long v) {
+  long b;
+  asm("lea %0, 256(%1)"
+  : "=r"(b)
+  : "r"(v));
+  // CHECK: %1 = call i64 asm "lea $0, 256($1)", "=r,r"(i64 %0)
+}
+
+void v(char *ptr, char *ptr2) {
+  typedef double __vr __attribute__((__vector_size__(2048)));
+  __vr a;
+  asm("vld %0, 8, %1"
+  : "=v"(a)
+  : "r"(ptr));
+  asm("vst %0, 8, %1"
+  :
+  : "v"(a), "r"(ptr2));
+  // CHECK: %1 = call <256 x double> asm "vld $0, 8, $1", "=v,r"(i8* %0)
+  // CHECK: call void asm sideeffect "vst $0, 8, $1", "v,r"(<256 x double> %2, i8* %3)
+}
Index: clang/lib/Basic/Targets/VE.h
===
--- clang/lib/Basic/Targets/VE.h
+++ clang/lib/Basic/Targets/VE.h
@@ -160,6 +160,13 @@
 
   bool validateAsmConstraint(const char *&Name,
  TargetInfo::ConstraintInfo &Info) const override {
+switch (*Name) {
+default:
+  return false;
+case 'v':
+  Info.setAllowsRegister();
+  return true;
+}
 return false;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91239: Update attribute example to fit the new Annotation API

2020-11-11 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

I recently made it much easier to create AnnotationAttr in this context with 
https://reviews.llvm.org/rGd093401a2617d3c46aaed9eeaecf877e3ae1a9f1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91239

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


[PATCH] D91067: [AArch64][SVE] Support implicit lax vector conversions for SVE types

2020-11-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli accepted this revision.
fpetrogalli added a comment.
This revision is now accepted and ready to land.

Thank you @joechrisellis  - LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91067

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


[PATCH] D83071: Add support for options with two flags for controlling the same field.

2020-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking control of this revision, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83071

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


[PATCH] D90956: [clang][SVE] Activate macro `__ARM_FEATURE_SVE_VECTOR_OPERATORS`.

2020-11-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

@rengolin - thank you for looking into this. The patch has changed quite a bit 
since you approved it (faulty codegen for one of the macros, which I have 
removed from this patch). You might want to re-look at it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90956

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


[clang] fdbc7e5 - [flang][driver] Make sure that `-###` is marked as supported (NFC)

2020-11-11 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2020-11-11T13:12:51Z
New Revision: fdbc7e505c0cb424bf629a0d6901bc6812302dcc

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

LOG: [flang][driver] Make sure that `-###` is marked as supported (NFC)

`-###` has always been supported in the new flang driver. This patch
merely makes sure that it's included when printing the help screen (i.e.
`flang-new -help`).

Added: 


Modified: 
clang/include/clang/Driver/Options.td
flang/test/Flang-Driver/driver-help-hidden.f90
flang/test/Flang-Driver/driver-help.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 75b63d49bb24..867b47857295 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -398,7 +398,7 @@ def ccc_ : Joined<["-"], "ccc-">, Group, 
Flags<[Unsupported]>;
 
 // Standard Options
 
-def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption]>,
+def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption, 
FlangOption]>,
 HelpText<"Print (but do not run) the commands to run for this 
compilation">;
 def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
 Flags<[NoXarchOption, CoreOption]>;

diff  --git a/flang/test/Flang-Driver/driver-help-hidden.f90 
b/flang/test/Flang-Driver/driver-help-hidden.f90
index 3d4a237a2aa9..3143cfd3d715 100644
--- a/flang/test/Flang-Driver/driver-help-hidden.f90
+++ b/flang/test/Flang-Driver/driver-help-hidden.f90
@@ -18,6 +18,7 @@
 ! CHECK:USAGE: flang-new
 ! CHECK-EMPTY:
 ! CHECK-NEXT:OPTIONS:
+! CHECK-NEXT: -###  Print (but do not run) the commands to run for this 
compilation
 ! CHECK-NEXT: -EOnly run the preprocessor
 ! CHECK-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics

diff  --git a/flang/test/Flang-Driver/driver-help.f90 
b/flang/test/Flang-Driver/driver-help.f90
index 2fc19f3830cf..58fa8fc79aca 100644
--- a/flang/test/Flang-Driver/driver-help.f90
+++ b/flang/test/Flang-Driver/driver-help.f90
@@ -18,6 +18,7 @@
 ! HELP:USAGE: flang-new
 ! HELP-EMPTY:
 ! HELP-NEXT:OPTIONS:
+! HELP-NEXT: -###   Print (but do not run) the commands to run 
for this compilation
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics



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


[PATCH] D83071: Add support for options with two flags for controlling the same field.

2020-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 304487.
jansvoboda11 added a comment.

Rebase on top of recent changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83071

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -63,8 +63,9 @@
 
 class MarshallingInfo {
 public:
-  static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
+  using Ptr = std::unique_ptr;
 
+  const char *MacroName;
   const Record &R;
   bool ShouldAlwaysEmit;
   StringRef KeyPath;
@@ -80,6 +81,8 @@
   std::vector NormalizedValues;
   std::string ValueTableName;
 
+  static size_t NextTableIndex;
+
   static constexpr const char *ValueTablePreamble = R"(
 struct SimpleEnumValue {
   const char *Name;
@@ -95,7 +98,14 @@
   static constexpr const char *ValueTablesDecl =
   "static const SimpleEnumValueTable SimpleEnumValueTables[] = ";
 
-  void emit(raw_ostream &OS) const {
+  MarshallingInfo(const Record &R)
+  : MacroName("OPTION_WITH_MARSHALLING"), R(R) {}
+  MarshallingInfo(const char *MacroName, const Record &R)
+  : MacroName(MacroName), R(R){};
+
+  virtual ~MarshallingInfo() = default;
+
+  virtual void emit(raw_ostream &OS) const {
 write_cstring(OS, StringRef(getOptionSpelling(R)));
 OS << ", ";
 OS << ShouldAlwaysEmit;
@@ -133,53 +143,6 @@
 return StringRef(ValueTableName);
   }
 
-  static MarshallingInfo create(const Record &R) {
-assert(!isa(R.getValueInit("KeyPath")) &&
-   !isa(R.getValueInit("DefaultValue")) &&
-   !isa(R.getValueInit("NormalizerRetTy")) &&
-   !isa(R.getValueInit("ValueMerger")) &&
-   "MarshallingInfo must have a type");
-
-MarshallingInfo Ret(R);
-Ret.ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
-Ret.KeyPath = R.getValueAsString("KeyPath");
-Ret.DefaultValue = R.getValueAsString("DefaultValue");
-Ret.NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
-Ret.NormalizerRetTy = R.getValueAsString("NormalizerRetTy");
-
-Ret.Normalizer = R.getValueAsString("Normalizer");
-Ret.Denormalizer = R.getValueAsString("Denormalizer");
-Ret.ValueMerger = R.getValueAsString("ValueMerger");
-Ret.ValueExtractor = R.getValueAsString("ValueExtractor");
-
-if (!isa(R.getValueInit("NormalizedValues"))) {
-  assert(!isa(R.getValueInit("Values")) &&
- "Cannot provide normalized values for value-less options");
-  Ret.TableIndex = NextTableIndex++;
-  Ret.NormalizedValues = R.getValueAsListOfStrings("NormalizedValues");
-  Ret.Values.reserve(Ret.NormalizedValues.size());
-  Ret.ValueTableName = getOptionName(R) + "ValueTable";
-
-  StringRef ValuesStr = R.getValueAsString("Values");
-  for (;;) {
-size_t Idx = ValuesStr.find(',');
-if (Idx == StringRef::npos)
-  break;
-if (Idx > 0)
-  Ret.Values.push_back(ValuesStr.slice(0, Idx));
-ValuesStr = ValuesStr.slice(Idx + 1, StringRef::npos);
-  }
-  if (!ValuesStr.empty())
-Ret.Values.push_back(ValuesStr);
-
-  assert(Ret.Values.size() == Ret.NormalizedValues.size() &&
- "The number of normalized values doesn't match the number of "
- "values");
-}
-
-return Ret;
-  }
-
 private:
   void emitScopedNormalizedValue(raw_ostream &OS,
  StringRef NormalizedValue) const {
@@ -187,13 +150,81 @@
   OS << NormalizedValuesScope << "::";
 OS << NormalizedValue;
   }
+};
+
+size_t MarshallingInfo::NextTableIndex = 0;
 
-  MarshallingInfo(const Record &R) : R(R){};
+class MarshallingInfoBooleanFlag : public MarshallingInfo {
+public:
+  const Record &NegOption;
 
-  static size_t NextTableIndex;
+  MarshallingInfoBooleanFlag(const Record &Option, const Record &NegOption)
+  : MarshallingInfo("OPTION_WITH_MARSHALLING_BOOLEAN", Option),
+NegOption(NegOption) {}
+
+  void emit(raw_ostream &OS) const override {
+MarshallingInfo::emit(OS);
+OS << ", ";
+OS << getOptionName(NegOption);
+OS << ", ";
+write_cstring(OS, getOptionSpelling(NegOption));
+  }
 };
 
-size_t MarshallingInfo::NextTableIndex = 0;
+static MarshallingInfo::Ptr createMarshallingInfo(const Record &R) {
+  assert(!isa(R.getValueInit("KeyPath")) &&
+ !isa(R.getValueInit("DefaultValue")) &&
+ !isa(R.getValueInit("NormalizerRetTy")) &&
+ !isa(R.getValueInit("ValueMerger")) &&
+ "MarshallingInfo must have a type");
+
+  MarshallingInfo::Ptr Ret;
+  StringRef KindString = R.getValueAsString("MarshallingInfoKind");
+  if (KindString == "Defa

[PATCH] D91237: [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

2020-11-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D91237#2388168 , @Elvina wrote:

> Failure on test "linux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp" 
> looks bogus. I had the same issue with another PR 
> https://reviews.llvm.org/D89972 and other people also faced it 
> https://reviews.llvm.org/D89895

I agree they don't work very well, unfortunately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91237

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


[PATCH] D91237: [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

2020-11-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for fixing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91237

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-11 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 304488.

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

https://reviews.llvm.org/D89031

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  clang/test/CodeGenCXX/pragma-scalable-loop.cpp

Index: clang/test/CodeGenCXX/pragma-scalable-loop.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/pragma-scalable-loop.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve -std=c++11 -emit-llvm -o - %s | FileCheck %s
+
+// Verify do loop is performing scalable vectorization
+void for_test_scalable(int *List, int Length) {
+#pragma clang loop vectorize_width(16, scalable) interleave_count(4) unroll(disable) distribute(disable)
+  for (int i = 0; i < Length; i++) {
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP_1:.*]]
+List[i] = i * 2;
+  }
+}
+
+// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_SCALABLE:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
+// CHECK: ![[DISTRIBUTE_DISABLE]] = !{!"llvm.loop.distribute.enable", i1 false}
+// CHECK: ![[WIDTH_16_SCALABLE]] = !{!"llvm.loop.vectorize.width", ![[ELEMENT_COUNT_16_SCALABLE:.*]]}
+// CHECK: ![[ELEMENT_COUNT_16_SCALABLE]] = !{i32 16, i1 true}
+// CHECK: ![[INTERLEAVE_4]] = !{!"llvm.loop.interleave.count", i32 4}
+// CHECK: ![[VECTORIZE_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true}
Index: clang/test/CodeGenCXX/pragma-loop.cpp
===
--- clang/test/CodeGenCXX/pragma-loop.cpp
+++ clang/test/CodeGenCXX/pragma-loop.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s 2>%t | FileCheck %s
+// RUN: FileCheck --check-prefix=CHECK-SCALABLE %s < %t
 
 // Verify while loop is recognized after sequence of pragma clang loop directives.
 void while_test(int *List, int Length) {
@@ -158,6 +159,26 @@
   for_template_constant_expression_test(List, Length);
 }
 
+// Verify for loop is performing fixed width vectorization
+void for_test_fixed(int *List, int Length) {
+#pragma clang loop vectorize_width(16, fixed) interleave_count(4) unroll(disable) distribute(disable)
+  for (int i = 0; i < Length; i++) {
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP_15:.*]]
+List[i] = i * 2;
+  }
+}
+
+// Verify for loop rejects scalable vectorization due to lack of target support
+// CHECK-SCALABLE: warning: the 'scalable' property of #pragma vectorize_width is unsupported by the target; assuming 'fixed' instead
+void for_test_scalable(int *List, int Length) {
+#pragma clang loop vectorize_width(16, scalable) interleave_count(4) unroll(disable) distribute(disable)
+  for (int i = 0; i < Length; i++) {
+// CHECK: br label {{.*}}, !llvm.loop ![[LOOP_16:.*]]
+// CHECK-SVE: br label {{.*}}, !llvm.loop ![[LOOP_16_SVE:.*]]
+List[i] = i * 2;
+  }
+}
+
 // CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[UNROLL_FULL:.*]]}
 // CHECK: ![[UNROLL_FULL]] = !{!"llvm.loop.unroll.full"}
 
@@ -215,3 +236,8 @@
 
 // CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[WIDTH_10:.*]], ![[VECTORIZE_ENABLE]]}
 // CHECK: ![[WIDTH_10]] = !{!"llvm.loop.vectorize.width", i32 10}
+
+// CHECK: ![[LOOP_15]] = distinct !{![[LOOP_15]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_FIXED:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
+// CHECK: ![[WIDTH_16_FIXED]] = !{!"llvm.loop.vectorize.width", i32 16}
+
+// CHECK: ![[LOOP_16]] = distinct !{![[LOOP_16]], ![[UNROLL_DISABLE:.*]], ![[DISTRIBUTE_DISABLE:.*]], ![[WIDTH_16_FIXED:.*]], ![[INTERLEAVE_4:.*]], ![[VECTORIZE_ENABLE:.*]]}
Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -14,6 +14,7 @@
 #include "clang/Sema/SemaInternal.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Sema/DelayedDiagnostic.h"
 #include "clang/Sema/Lookup.h"
 #include "clang/Sema/ScopeInfo.h"
@@ -139,10 +140,21 @@
LoopHintAttr::PipelineInitiationInterval)
  .Case("distribute", LoopHintAttr::Distribute)
  .Default(LoopHintAttr::Vectorize);
-if (Option == LoopHintAttr::VectorizeWidth ||
-Option == LoopHintAttr::InterleaveCoun

[PATCH] D90275: [clang][IR] Add support for leaf attribute

2020-11-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1435
+  let Spellings = [GCC<"leaf">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];

gulfem wrote:
> aaron.ballman wrote:
> > gulfem wrote:
> > > aaron.ballman wrote:
> > > > gulfem wrote:
> > > > > aaron.ballman wrote:
> > > > > > gulfem wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > gulfem wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > Should this attribute also be supported on things like ObjC 
> > > > > > > > > > method decls or other function-like interfaces?
> > > > > > > > > Do I need to do anything else to support this attribute in 
> > > > > > > > > Objective-C as well?
> > > > > > > > > I think we should support it in all the C languages family.
> > > > > > > > >I think we should support it in all the C languages family.
> > > > > > > > 
> > > > > > > > That's already happening automatically -- there's a C and C++ 
> > > > > > > > spelling available for it and the attribute doesn't specify 
> > > > > > > > that it requires a particular language mode or target.
> > > > > > > > 
> > > > > > > > > Do I need to do anything else to support this attribute in 
> > > > > > > > > Objective-C as well?
> > > > > > > > You can add multiple subjects to the list here, so you can have 
> > > > > > > > this apply to `Function, ObjCMethod` for both of those. Another 
> > > > > > > > one to consider is whether this attribute can be written on a 
> > > > > > > > block declaration (like a lambda, but with different syntax). 
> > > > > > > > Beyond that, it's mostly just documentation, devising the test 
> > > > > > > > cases to ensure the ObjC functionality behaves as expected, 
> > > > > > > > possibly some codegen changes, etc.
> > > > > > > AFAIK, users can specify function attributes in lambda 
> > > > > > > expressions.
> > > > > > > Lambda functions can only be accessed/called by the functions in 
> > > > > > > the same translation unit, right?
> > > > > > > Leaf attribute does not have any effect on the functions that are 
> > > > > > > defined in the same translation unit.
> > > > > > > For this reason, I'm thinking that leaf attribute would not have 
> > > > > > > any effect if they are used in lambda expressions.
> > > > > > > Do you agree with me?
> > > > > > > AFAIK, users can specify function attributes in lambda 
> > > > > > > expressions.
> > > > > > 
> > > > > > I always forget that you can do that for declaration attributes 
> > > > > > using GNU-style syntax...
> > > > > > 
> > > > > > > Lambda functions can only be accessed/called by the functions in 
> > > > > > > the same translation unit, right?
> > > > > > 
> > > > > > Not necessarily, you could pass one across TU boundaries like a 
> > > > > > function pointer, for instance. e.g.,
> > > > > > ```
> > > > > > // TU1.cpp
> > > > > > void foo() {
> > > > > >   auto l = []() { ... };
> > > > > >   bar(l);
> > > > > > }
> > > > > > 
> > > > > > // TU2.cpp
> > > > > > void bar(auto func) {
> > > > > >   func();
> > > > > > }
> > > > > > ```
> > > > > > Not necessarily, you could pass one across TU boundaries like a 
> > > > > > function pointer, for instance. e.g.,
> > > > > As I mentioned before, leaf attribute is specifically intended for 
> > > > > library functions and I think all the existing usage of leaf 
> > > > > attribute is in the library function declarations. For this reason, I 
> > > > > think we do not need to support them for lambdas. Is that reasonable?
> > > > > 
> > > > > For this reason, I think we do not need to support them for lambdas. 
> > > > > Is that reasonable?
> > > > 
> > > > Is this considered a library function?
> > > > 
> > > > ```
> > > > struct S {
> > > >   void f(); // Is this a library function?
> > > >   void operator()(); // How about this?
> > > > };
> > > > ```
> > > > If the answer is "no", then I think we only need to support 
> > > > `FunctionDecl` and nothing else (not even `ObjCMethodDecl`, which is 
> > > > like a member function for ObjC). If the answer is "yes", then it's not 
> > > > clear to me whether lambdas should or should not be supported given 
> > > > that the attribute on the lambda expression is attached to the function 
> > > > call operator for the lambda declaration.
> > > > If the answer is "no", then I think we only need to support 
> > > > `FunctionDecl` and nothing else (not even `ObjCMethodDecl`, which is 
> > > > like a member function for ObjC). If the answer is "yes", then it's not 
> > > > clear to me whether lambdas should or should not be supported given 
> > > > that the attribute on the lambda expression is attached to the function 
> > > > call operator for the lambda declaration.
> > > 
> > > I see your point @aaron.ballman. I would say the second one is not really 
> > > a library function.
> > > @jdoerfert also suggested to allow leaf attribute only on declarations.
> > > I can add Funct

[PATCH] D91035: [NFC, Refactor] Convert FunctionDefinitionKind from DeclSpech.h to a scoped enum

2020-11-11 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added inline comments.



Comment at: clang/include/clang/Sema/DeclSpec.h:1837
   /// Actually a FunctionDefinitionKind.
-  unsigned FunctionDefinition : 2;
+  FunctionDefinitionKind FunctionDefinition : 2;
 

aaron.ballman wrote:
> faisalv wrote:
> > aaron.ballman wrote:
> > > I think we need to keep this as `unsigned` because some compilers 
> > > struggle with bit-fields of enumeration types (even when the enumeration 
> > > underlying type is fixed): https://godbolt.org/z/P8x8Kz
> > As Barry had reminded me - this warning was deemed a bug: 
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242.  Are you sure we should 
> > still tailor our code to appease it? Is there a config file we can use to 
> > #define an ENUM_UNSIGNED_BITFIELD(x) or some such - that does the right 
> > thing for most compilers - (and are we even comfortable from a style-guide 
> > perpective, with such a conditional-define strategy?
> > 
> > Your thoughts?
> > 
> > Thanks!
> The warning in GCC was a bug, but the fact that GCC issues the warning means 
> `-Werror` builds will not be able to handle it. GCC 9.2 is really recent, so 
> we can't just bump the supported version of GCC to 9.3 to avoid the issue. We 
> could use macros to work around it for GCC, but IIRC, MSVC also had some 
> hiccups over the years with using an enumeration as a bit-field member (I 
> seem to recall it not wanting to pack the bits with surrounding fields, but I 
> could be remembering incorrectly). I'm not certain whether macros are worth 
> the effort, but my personal inclination is to just stick with `unsigned` 
> unless there's a really big win from coming up with something more complex.
Well - the biggest downside of making it unsigned (vs leaving it as an enum) is 
that each assignment or initialization now requires a static_cast.  

What would you folks suggest:
1) do not modernize such enums into scoped enums
2) scope these enums - sticking to unsigned bit-fields - and add static_casts
3) teach the bots to ignore that gcc warning? (is this even an option)

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91035

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


[PATCH] D83071: Add support for options with two flags for controlling the same field.

2020-11-11 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 304491.
jansvoboda11 added a comment.

Apply unique_ptr workaround for older Clang versions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83071

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -63,8 +63,9 @@
 
 class MarshallingInfo {
 public:
-  static constexpr const char *MacroName = "OPTION_WITH_MARSHALLING";
+  using Ptr = std::unique_ptr;
 
+  const char *MacroName;
   const Record &R;
   bool ShouldAlwaysEmit;
   StringRef KeyPath;
@@ -80,6 +81,8 @@
   std::vector NormalizedValues;
   std::string ValueTableName;
 
+  static size_t NextTableIndex;
+
   static constexpr const char *ValueTablePreamble = R"(
 struct SimpleEnumValue {
   const char *Name;
@@ -95,7 +98,14 @@
   static constexpr const char *ValueTablesDecl =
   "static const SimpleEnumValueTable SimpleEnumValueTables[] = ";
 
-  void emit(raw_ostream &OS) const {
+  MarshallingInfo(const Record &R)
+  : MacroName("OPTION_WITH_MARSHALLING"), R(R) {}
+  MarshallingInfo(const char *MacroName, const Record &R)
+  : MacroName(MacroName), R(R){};
+
+  virtual ~MarshallingInfo() = default;
+
+  virtual void emit(raw_ostream &OS) const {
 write_cstring(OS, StringRef(getOptionSpelling(R)));
 OS << ", ";
 OS << ShouldAlwaysEmit;
@@ -133,53 +143,6 @@
 return StringRef(ValueTableName);
   }
 
-  static MarshallingInfo create(const Record &R) {
-assert(!isa(R.getValueInit("KeyPath")) &&
-   !isa(R.getValueInit("DefaultValue")) &&
-   !isa(R.getValueInit("NormalizerRetTy")) &&
-   !isa(R.getValueInit("ValueMerger")) &&
-   "MarshallingInfo must have a type");
-
-MarshallingInfo Ret(R);
-Ret.ShouldAlwaysEmit = R.getValueAsBit("ShouldAlwaysEmit");
-Ret.KeyPath = R.getValueAsString("KeyPath");
-Ret.DefaultValue = R.getValueAsString("DefaultValue");
-Ret.NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
-Ret.NormalizerRetTy = R.getValueAsString("NormalizerRetTy");
-
-Ret.Normalizer = R.getValueAsString("Normalizer");
-Ret.Denormalizer = R.getValueAsString("Denormalizer");
-Ret.ValueMerger = R.getValueAsString("ValueMerger");
-Ret.ValueExtractor = R.getValueAsString("ValueExtractor");
-
-if (!isa(R.getValueInit("NormalizedValues"))) {
-  assert(!isa(R.getValueInit("Values")) &&
- "Cannot provide normalized values for value-less options");
-  Ret.TableIndex = NextTableIndex++;
-  Ret.NormalizedValues = R.getValueAsListOfStrings("NormalizedValues");
-  Ret.Values.reserve(Ret.NormalizedValues.size());
-  Ret.ValueTableName = getOptionName(R) + "ValueTable";
-
-  StringRef ValuesStr = R.getValueAsString("Values");
-  for (;;) {
-size_t Idx = ValuesStr.find(',');
-if (Idx == StringRef::npos)
-  break;
-if (Idx > 0)
-  Ret.Values.push_back(ValuesStr.slice(0, Idx));
-ValuesStr = ValuesStr.slice(Idx + 1, StringRef::npos);
-  }
-  if (!ValuesStr.empty())
-Ret.Values.push_back(ValuesStr);
-
-  assert(Ret.Values.size() == Ret.NormalizedValues.size() &&
- "The number of normalized values doesn't match the number of "
- "values");
-}
-
-return Ret;
-  }
-
 private:
   void emitScopedNormalizedValue(raw_ostream &OS,
  StringRef NormalizedValue) const {
@@ -187,13 +150,85 @@
   OS << NormalizedValuesScope << "::";
 OS << NormalizedValue;
   }
+};
+
+size_t MarshallingInfo::NextTableIndex = 0;
 
-  MarshallingInfo(const Record &R) : R(R){};
+class MarshallingInfoBooleanFlag : public MarshallingInfo {
+public:
+  const Record &NegOption;
 
-  static size_t NextTableIndex;
+  MarshallingInfoBooleanFlag(const Record &Option, const Record &NegOption)
+  : MarshallingInfo("OPTION_WITH_MARSHALLING_BOOLEAN", Option),
+NegOption(NegOption) {}
+
+  void emit(raw_ostream &OS) const override {
+MarshallingInfo::emit(OS);
+OS << ", ";
+OS << getOptionName(NegOption);
+OS << ", ";
+write_cstring(OS, getOptionSpelling(NegOption));
+  }
 };
 
-size_t MarshallingInfo::NextTableIndex = 0;
+static MarshallingInfo::Ptr createMarshallingInfo(const Record &R) {
+  assert(!isa(R.getValueInit("KeyPath")) &&
+ !isa(R.getValueInit("DefaultValue")) &&
+ !isa(R.getValueInit("NormalizerRetTy")) &&
+ !isa(R.getValueInit("ValueMerger")) &&
+ "MarshallingInfo must have a type");
+
+  MarshallingInfo::Ptr Ret;
+  StringRef KindString = R.getValueAsString("MarshallingInfoKind");
+  if 

[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-11 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 304493.
azabaznov added a comment.

Addressed all concerns except replacing //__opencl_c_int64 //definition into 
header. The reason for this as follows: this macro should be predefined 
regardless if clang includes default header or not.


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

https://reviews.llvm.org/D89869

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/include/clang/Basic/OpenCLOptions.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaOpenCL/opencl-feature-extension-simult.cl
  clang/test/SemaOpenCL/opencl-features.cl

Index: clang/test/SemaOpenCL/opencl-features.cl
===
--- /dev/null
+++ clang/test/SemaOpenCL/opencl-features.cl
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CL20
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0  -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple spir-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple spir-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+
+// x86_64 and spir support all features by default
+
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple spir-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+
+// CL20: #define __opencl_c_atomic_order_acq_rel 1
+// CL20: #define __opencl_c_atomic_order_seq_cst 1
+// CL20: #define __opencl_c_atomic_scope_all_devices 1
+// CL20: #define __opencl_c_atomic_scope_device 1
+

[PATCH] D90691: [analyzer] Add new checker for unchecked return value.

2020-11-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added a comment.

Maybe it is better to have this check for every system function that has 
non-void return value (except specific functions)? This check is applicable to 
CERT rule ERR33-C, POS54-C and EXP12-C too (it is restricted but can find a 
part of the problems).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90691

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


[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

2020-11-11 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 304494.
yaxunl edited the summary of this revision.
yaxunl added a comment.

added diagnosing referencing host variable in device functions


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

https://reviews.llvm.org/D91088

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCUDA/function-overload.cu
  clang/test/CodeGenCUDA/lambda-reference-var.cu
  clang/test/SemaCUDA/device-use-host-var.cu

Index: clang/test/SemaCUDA/device-use-host-var.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/device-use-host-var.cu
@@ -0,0 +1,160 @@
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify=dev %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=host %s
+
+// host-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+int global_host_var;
+__device__ int global_dev_var;
+__constant__ int global_constant_var;
+__shared__ int global_shared_var;
+constexpr int global_constexpr_var = 1;
+const int global_const_var = 1;
+
+template
+__global__ void kernel(F f) { f(); } // dev-note2 {{called by 'kernel<(lambda}}
+
+__device__ void dev_fun(int *out) {
+  int &ref_host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+__global__ void global_fun(int *out) {
+  int &ref_host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __global__ function}}
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __global__ function}}
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+__host__ __device__ void host_dev_fun(int *out) {
+  int &ref_host_var = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __host__ __device__ function}}
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __host__ __device__ function}}
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+inline __host__ __device__ void inline_host_dev_fun(int *out) {
+  int &ref_host_var = global_host_var;
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var;
+  *out = global_dev_var;
+  *out = global_constant_var;
+  *out = global_shared_var;
+  *out = global_constexpr_var;
+  *out = global_const_var;
+
+  *out = ref_host_var;
+  *out = ref_dev_var;
+  *out = ref_constant_var;
+  *out = ref_shared_var;
+  *out = ref_constexpr_var;
+  *out = ref_const_var;
+}
+
+void dev_lambda_capture_by_ref(int *out) {
+  int &ref_host_var = global_host_var;
+  kernel<<<1,1>>>([&]() {
+  int &ref_dev_var = global_dev_var;
+  int &ref_constant_var = global_constant_var;
+  int &ref_shared_var = global_shared_var;
+  const int &ref_constexpr_var = global_constexpr_var;
+  const int &ref_const_var = global_const_var;
+
+  *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __host__ __device__ function}}
+  // dev-error@-1 {{capture host variable 'out' by refere

[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-11 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> What did you think in mind regarding activation of features for SPIR?

I don't see any difference between extensions and features in that case (at 
least for now), so in the latest patch x86 and spir targets will define all the 
features.


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

https://reviews.llvm.org/D89869

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


[PATCH] D91035: [NFC, Refactor] Convert FunctionDefinitionKind from DeclSpech.h to a scoped enum

2020-11-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/DeclSpec.h:1837
   /// Actually a FunctionDefinitionKind.
-  unsigned FunctionDefinition : 2;
+  FunctionDefinitionKind FunctionDefinition : 2;
 

faisalv wrote:
> aaron.ballman wrote:
> > faisalv wrote:
> > > aaron.ballman wrote:
> > > > I think we need to keep this as `unsigned` because some compilers 
> > > > struggle with bit-fields of enumeration types (even when the 
> > > > enumeration underlying type is fixed): https://godbolt.org/z/P8x8Kz
> > > As Barry had reminded me - this warning was deemed a bug: 
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242.  Are you sure we 
> > > should still tailor our code to appease it? Is there a config file we can 
> > > use to #define an ENUM_UNSIGNED_BITFIELD(x) or some such - that does the 
> > > right thing for most compilers - (and are we even comfortable from a 
> > > style-guide perpective, with such a conditional-define strategy?
> > > 
> > > Your thoughts?
> > > 
> > > Thanks!
> > The warning in GCC was a bug, but the fact that GCC issues the warning 
> > means `-Werror` builds will not be able to handle it. GCC 9.2 is really 
> > recent, so we can't just bump the supported version of GCC to 9.3 to avoid 
> > the issue. We could use macros to work around it for GCC, but IIRC, MSVC 
> > also had some hiccups over the years with using an enumeration as a 
> > bit-field member (I seem to recall it not wanting to pack the bits with 
> > surrounding fields, but I could be remembering incorrectly). I'm not 
> > certain whether macros are worth the effort, but my personal inclination is 
> > to just stick with `unsigned` unless there's a really big win from coming 
> > up with something more complex.
> Well - the biggest downside of making it unsigned (vs leaving it as an enum) 
> is that each assignment or initialization now requires a static_cast.  
> 
> What would you folks suggest:
> 1) do not modernize such enums into scoped enums
> 2) scope these enums - sticking to unsigned bit-fields - and add static_casts
> 3) teach the bots to ignore that gcc warning? (is this even an option)
> 
> Thank you!
For #2, do you have an idea of how often we'd need to insert the static_casts 
for this particular enum? I don't think we assign to this field all that often 
in a place where we only have an integer rather than an enumeration value, so 
my preference is for #2 on a case-by-case basis (for instance, we could add a 
helper function to set unsigned bit-fields to an enum value -- we already have 
one here with `setFunctionDefinitionKind()`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91035

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


[PATCH] D91157: [AArch64] Out-of-line atomics (-moutline-atomics) implementation.

2020-11-11 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:2170
+  SmallVector Ops;
+  if (TLI.getLibcallName(LC)) {
+Ops.append(Node->op_begin() + 2, Node->op_end());

jyknight wrote:
> t.p.northover wrote:
> > I think this is a bit of an abuse of the `LibcallName` mechanism. A 
> > separate function in `TargetLowering` would probably be better.
> I don't think that's odd or unusual -- we often condition libcall 
> availability on getLibcallName != nullptr.
> 
> What does strike me here is the (pre-existing) code duplication between this 
> function (DAGTypeLegalizer::ExapndAtomic) and 
> SelectionDAGLegalize::ConvertNodeToLibcall. Not sure what's up with that...
Fair enough. Didn't realise it was that common.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91157

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


[PATCH] D91253: [Matrix] Update mangling to use paramterized vendor ext type syntax.

2020-11-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: rjmccall, rsmith, Bigcheese.
Herald added a subscriber: tschuett.
Herald added a project: clang.
fhahn requested review of this revision.

The Itanium CXX ABI grammer has been extended to support parameterized
vendor extended types [1].

This patch updates Clang's mangling for matrix types to use the new
extension.

[1] 
https://github.com/itanium-cxx-abi/cxx-abi/commit/b359d28971bdb961dd9b61bd0ef8c884452b4740


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91253

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/matrix-type-builtins.cpp
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/CodeGenCXX/matrix-type.cpp

Index: clang/test/CodeGenCXX/matrix-type.cpp
===
--- clang/test/CodeGenCXX/matrix-type.cpp
+++ clang/test/CodeGenCXX/matrix-type.cpp
@@ -6,7 +6,7 @@
 // CHECK: %struct.Matrix = type { i8, [12 x float], float }
 
 void load_store(dx5x5_t *a, dx5x5_t *b) {
-  // CHECK-LABEL:  define void @_Z10load_storePU11matrix_typeLm5ELm5EdS0_(
+  // CHECK-LABEL:  define void @_Z10load_storePu11matrix_typeELm5ELm5EdIS0_(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
   // CHECK-NEXT:%b.addr = alloca [25 x double]*, align 8
@@ -26,7 +26,7 @@
 typedef float fx3x3_t __attribute__((matrix_type(3, 3)));
 
 void parameter_passing(fx3x3_t a, fx3x3_t *b) {
-  // CHECK-LABEL: define void @_Z17parameter_passingU11matrix_typeLm3ELm3EfPS_(
+  // CHECK-LABEL: define void @_Z17parameter_passingu11matrix_typeELm3ELm3EfIPS_(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [9 x float], align 4
   // CHECK-NEXT:%b.addr = alloca [9 x float]*, align 8
@@ -42,7 +42,7 @@
 }
 
 fx3x3_t return_matrix(fx3x3_t *a) {
-  // CHECK-LABEL: define <9 x float> @_Z13return_matrixPU11matrix_typeLm3ELm3Ef(
+  // CHECK-LABEL: define <9 x float> @_Z13return_matrixPu11matrix_typeELm3ELm3EfI(
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%a.addr = alloca [9 x float]*, align 8
   // CHECK-NEXT:store [9 x float]* %a, [9 x float]** %a.addr, align 8
@@ -215,42 +215,42 @@
   // CHECK-NEXT:%m4 = alloca [144 x float], align 4
   // CHECK-NEXT:%v = alloca %struct.selector.3, align 1
   // CHECK-NEXT:%undef.agg.tmp4 = alloca %struct.selector.3, align 1
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERU11matrix_typeXLm10EEXT0_ET_([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
-  // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERU11matrix_typeLm10ELm10ET_([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERU11matrix_typeXT0_EXLm10EET_([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
-  // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERU11matrix_typeXT0_EXT1_ET_([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
-  // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERU11matrix_typeXT_EXT0_Ef([144 x float]* nonnull align 4 dereferenceable(576) %m4)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeEXLm10EEXT0_ET_I([120 x i32]* nonnull align 4 dereferenceable(480) %m0)
+  // CHECK-NEXT:call void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeELm10ELm10ET_I([100 x i32]* nonnull align 4 dereferenceable(400) %m1)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12EE8selectorILi1EERu11matrix_typeEXT0_EXLm10EET_I([120 x i32]* nonnull align 4 dereferenceable(480) %m2)
+  // CHECK-NEXT:call void @_Z10use_matrixIiLm12ELm12EE8selectorILi0EERu11matrix_typeEXT0_EXT1_ET_I([144 x i32]* nonnull align 4 dereferenceable(576) %m3)
+  // CHECK-NEXT:call void @_Z10use_matrixILm12ELm12EE8selectorILi4EERu11matrix_typeEXT_EXT0_EfI([144 x float]* nonnull align 4 dereferenceable(576) %m4)
   // CHECK-NEXT:ret void
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERU11matrix_typeXLm10EEXT0_ET_([120 x i32]* nonnull align 4 dereferenceable(480) %m)
+  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiLm12EE8selectorILi3EERu11matrix_typeEXLm10EEXT0_ET_I([120 x i32]* nonnull align 4 dereferenceable(480) %m)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%m.addr = alloca [120 x i32]*, align 8
   // CHECK-NEXT:store [120 x i32]* %m, [120 x i32]** %m.addr, align 8
   // CHECK-NEXT:call void @llvm.trap()
   // CHECK-NEXT:unreachable
 
-  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiE8selectorILi2EERU11matrix_typeLm10ELm10ET_([100 x i32]* nonnull align 4 dereferenceable(400) %m)
+  // CHECK-LABEL: define linkonce_odr void @_Z10use_matrixIiE8selectorILi2EERu11matrix_typeELm10ELm10ET_I([100 x i32]* nonnull align 4 dereferenceable(400) %m)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%m.addr = alloca [100 x i32]*, align 8
   // CHECK-NEXT:store [100 x i32]* %m, [100 x i32]** %

[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-11 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3032
+The vector width is specified by
+``vectorize_width(_value_[, fixed|scalable])``, where __value__ is a positive
+integer and the type of vectorization can be specified with an optional

nit: `s/__value__/_value_/`


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

https://reviews.llvm.org/D89031

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


[PATCH] D72281: [Matrix] Add matrix type to Clang.

2020-11-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3353-3371
+  auto &ASTCtx = getASTContext();
+  unsigned BitWidth = ASTCtx.getTypeSize(ASTCtx.getSizeType());
+  llvm::APSInt Rows(BitWidth);
+  Rows = T->getNumRows();
+  mangleIntegerLiteral(ASTCtx.getSizeType(), Rows);
+  llvm::APSInt Columns(BitWidth);
+  Columns = T->getNumColumns();

rsmith wrote:
> This mangling doesn't conform to the Itanium ABI rules: you're missing the 
> `I` ... `E` surrounding the template arguments. Also, the ABI rules let you 
> use `u`... manglings now if you want.
Thanks! Unfortunately I didn't get around to updating the code after the update 
to the spec landed, but I just put up a patch to address this: D91253


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72281

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


[PATCH] D91037: [clang-tidy] Fix crash in bugprone-redundant-branch-condition on ExprWithCleanups

2020-11-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D91037#2387377 , @njames93 wrote:

> Taking a step back, rather than worrying about if its an `ExprWithCleanups`. 
> Shouldn't we just get the condition removing all implicit nodes.
>
>   const Expr* Cond = InnerIf->getCond()->ignoreImplicit();
>
> This has to be simpler and will likely future proof this against any other 
> implicit nodes potentially added in future that can appear between the 
> Condition and the binary operator.

Good call!


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

https://reviews.llvm.org/D91037

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


[PATCH] D91237: [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

2020-11-11 Thread Elvina Yakubova via Phabricator via cfe-commits
Elvina added a comment.

Anastasia, thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91237

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


[PATCH] D91237: [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

2020-11-11 Thread Elvina Yakubova 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 rG624bced7eec0: [OpenCL] Make Clang recognize -cl-std=1.0 as a 
value argument (authored by Elvina).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91237

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/opencl.cl
  clang/test/Frontend/stdlang.c
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -123,6 +123,8 @@
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.1 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL11
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.2 \
Index: clang/test/Frontend/stdlang.c
===
--- clang/test/Frontend/stdlang.c
+++ clang/test/Frontend/stdlang.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
 // RUN: %clang_cc1 -x cl -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl1.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
Index: clang/test/Driver/opencl.cl
===
--- clang/test/Driver/opencl.cl
+++ clang/test/Driver/opencl.cl
@@ -1,4 +1,5 @@
 // RUN: %clang -S -### -cl-std=CL %s 2>&1 | FileCheck --check-prefix=CHECK-CL 
%s
+// RUN: %clang -S -### -cl-std=CL1.0 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL10 %s
 // RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL11 %s
 // RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL12 %s
 // RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL20 %s
@@ -20,6 +21,7 @@
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
 // CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL10: "-cc1" {{.*}} "-cl-std=CL1.0"
 // CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
 // CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
 // CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -37,6 +37,8 @@
 
 // CLSTDALL: cl
 // CLSTDALL-NEXT: CL
+// CLSTDALL-NEXT: cl1.0
+// CLSTDALL-NEXT: CL1.0
 // CLSTDALL-NEXT: cl1.1
 // CLSTDALL-NEXT: CL1.1
 // CLSTDALL-NEXT: cl1.2
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2596,6 +2596,7 @@
 LangStandard::Kind OpenCLLangStd
   = llvm::StringSwitch(A->getValue())
 .Cases("cl", "CL", LangStandard::lang_opencl10)
+.Cases("cl1.0", "CL1.0", LangStandard::lang_opencl10)
 .Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
 .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
 .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -605,7 +605,7 @@
   HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">,
   MarshallingInfoFlag<"LangOpts->CLNoSignedZero">;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], 
"cl-fp32-correctly-rounded-divide-sqrt">, Group, 
Flags<[CC1Option]>,


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -123,6 +123,8 @

[clang] 624bced - [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

2020-11-11 Thread Elvina Yakubova via cfe-commits

Author: Elvina Yakubova
Date: 2020-11-11T17:01:57+03:00
New Revision: 624bced7eec09a6a70f6e04faeddd0adc1553799

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

LOG: [OpenCL] Make Clang recognize -cl-std=1.0 as a value argument

This patch makes Clang recognize -cl-std=1.0 as a value argument,
before only -std=cl1.0 has to be used instead.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47981

Reviewed By: Anastasia

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/autocomplete.c
clang/test/Driver/opencl.cl
clang/test/Frontend/stdlang.c
clang/test/Preprocessor/predefined-macros.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 867b47857295..2e6efef04dbb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -605,7 +605,7 @@ def cl_no_signed_zeros : Flag<["-"], "cl-no-signed-zeros">, 
Group,
   HelpText<"OpenCL only. Allow use of less precise no signed zeros 
computations in the generated binary.">,
   MarshallingInfoFlag<"LangOpts->CLNoSignedZero">;
 def cl_std_EQ : Joined<["-"], "cl-std=">, Group, 
Flags<[CC1Option]>,
-  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
+  HelpText<"OpenCL language standard to compile for.">, 
Values<"cl,CL,cl1.0,CL1.0,cl1.1,CL1.1,cl1.2,CL1.2,cl2.0,CL2.0,cl3.0,CL3.0,clc++,CLC++">;
 def cl_denorms_are_zero : Flag<["-"], "cl-denorms-are-zero">, 
Group,
   HelpText<"OpenCL only. Allow denormals to be flushed to zero.">;
 def cl_fp32_correctly_rounded_divide_sqrt : Flag<["-"], 
"cl-fp32-correctly-rounded-divide-sqrt">, Group, 
Flags<[CC1Option]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 590808cf69a0..0a776bfe4518 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2596,6 +2596,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList 
&Args, InputKind IK,
 LangStandard::Kind OpenCLLangStd
   = llvm::StringSwitch(A->getValue())
 .Cases("cl", "CL", LangStandard::lang_opencl10)
+.Cases("cl1.0", "CL1.0", LangStandard::lang_opencl10)
 .Cases("cl1.1", "CL1.1", LangStandard::lang_opencl11)
 .Cases("cl1.2", "CL1.2", LangStandard::lang_opencl12)
 .Cases("cl2.0", "CL2.0", LangStandard::lang_opencl20)

diff  --git a/clang/test/Driver/autocomplete.c 
b/clang/test/Driver/autocomplete.c
index c9f66de7cd5d..89f7c6e76125 100644
--- a/clang/test/Driver/autocomplete.c
+++ b/clang/test/Driver/autocomplete.c
@@ -37,6 +37,8 @@
 
 // CLSTDALL: cl
 // CLSTDALL-NEXT: CL
+// CLSTDALL-NEXT: cl1.0
+// CLSTDALL-NEXT: CL1.0
 // CLSTDALL-NEXT: cl1.1
 // CLSTDALL-NEXT: CL1.1
 // CLSTDALL-NEXT: cl1.2

diff  --git a/clang/test/Driver/opencl.cl b/clang/test/Driver/opencl.cl
index cc0a9143ab37..44ae12330662 100644
--- a/clang/test/Driver/opencl.cl
+++ b/clang/test/Driver/opencl.cl
@@ -1,4 +1,5 @@
 // RUN: %clang -S -### -cl-std=CL %s 2>&1 | FileCheck --check-prefix=CHECK-CL 
%s
+// RUN: %clang -S -### -cl-std=CL1.0 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL10 %s
 // RUN: %clang -S -### -cl-std=CL1.1 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL11 %s
 // RUN: %clang -S -### -cl-std=CL1.2 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL12 %s
 // RUN: %clang -S -### -cl-std=CL2.0 %s 2>&1 | FileCheck 
--check-prefix=CHECK-CL20 %s
@@ -20,6 +21,7 @@
 // RUN: not %clang -cl-std=invalid -DOPENCL %s 2>&1 | FileCheck 
--check-prefix=CHECK-INVALID %s
 
 // CHECK-CL: "-cc1" {{.*}} "-cl-std=CL"
+// CHECK-CL10: "-cc1" {{.*}} "-cl-std=CL1.0"
 // CHECK-CL11: "-cc1" {{.*}} "-cl-std=CL1.1"
 // CHECK-CL12: "-cc1" {{.*}} "-cl-std=CL1.2"
 // CHECK-CL20: "-cc1" {{.*}} "-cl-std=CL2.0"

diff  --git a/clang/test/Frontend/stdlang.c b/clang/test/Frontend/stdlang.c
index 35a2116859d5..0cb67deef23b 100644
--- a/clang/test/Frontend/stdlang.c
+++ b/clang/test/Frontend/stdlang.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -x cuda -std=c++11 -DCUDA %s
 // RUN: %clang_cc1 -x cl -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=cl1.0 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s

diff  --git a/clang/test/Preprocessor/predefined-macros.c 
b/clang/test/Preprocessor/predefined-macros.c
index 6c80517ec4d4..e406b9a70570 100644
--- a/clang/test/Preprocessor/predefined-macros.c
+++ b/clang/test/Preprocessor/predefined-macros.c
@@ -123,6 +123,8 @@
 
 // RUN: %clang_cc1 %s -E -

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-11 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 304500.
kbobyrev added a comment.

I think this is the first version that is ready for a review. Let me know if
you have any questions, @hokein!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -588,6 +588,147 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  // Fields in classes & partial and full specialiations.
+  R"cpp(
+class Foo {
+public:
+  Foo(int Variable) : [[Variabl^e]](Variable) {}
+
+  int [[Va^riable]] = 42;
+
+private:
+  void foo() { ++[[Vari^able]]; }
+};
+
+void bar() {
+  Foo f(9000);
+  f.[[Variable^]] = -1;
+}
+  )cpp",
+  R"cpp(
+template
+struct Foo {
+  T [[Vari^able]] = 42;
+};
+
+void foo() {
+  Foo f;
+  f.[[Varia^ble]] = 9000;
+}
+  )cpp",
+  R"cpp(
+template
+struct Foo {
+  T Variable[42];
+  U Another;
+
+  void bar() {}
+};
+
+template
+struct Foo {
+  T [[Var^iable]];
+  void bar() { ++[[Var^iable]]; }
+};
+
+void foo() {
+  Foo f;
+  f.[[Var^iable]] = 9000;
+}
+  )cpp",
+  R"cpp(
+template
+struct Foo {
+  T Variable[42];
+  U Another;
+
+  void bar() {}
+};
+
+template
+struct Foo {
+  T Variable;
+  void bar() { ++Variable; }
+};
+
+template<>
+struct Foo {
+  unsigned [[Var^iable]];
+  void bar() { ++[[Var^iable]]; }
+};
+
+void foo() {
+  Foo f;
+  f.[[Var^iable]] = 9000;
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,7 +18,6 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -76,6 +75,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -92,8 +93,7 @@
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
 // Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +222,89 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const CXXMethodDecl *D) {
+  const auto *Result = D;
+  if (const auto *InstantiatedMethod =

[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

I am very sorry that I am late to this... but I do have some concerns.

The concern that I have is that we extend vecorize_width with a scalable/fixed 
boolean, but there are more vectorisation pragma that set vectorisation options 
which imply enabling vectorisation:

> Pragmas setting transformation options imply the transformation is enabled, 
> as if it was enabled via the corresponding transformation pragma (e.g. 
> vectorize(enable))

Thus, unless I miss something, I don't think this should be an option to 
vectorize_width, but to me it looks like we need a separate one, e.g.:

  vectorize_scalable(enable|disable)

what do you think?


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

https://reviews.llvm.org/D89031

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


[clang] 3109ce5 - clang-cl: Expose -f[no-]delete-null-pointer-checks as clang-cl flag

2020-11-11 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-11-11T09:19:02-05:00
New Revision: 3109ce51d465b7c6e40f855bd88776654eaf08cc

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

LOG: clang-cl: Expose -f[no-]delete-null-pointer-checks as clang-cl flag

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2e6efef04dbb..05a218ca09f0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1285,7 +1285,8 @@ defm rewrite_includes : OptInFFlag<"rewrite-includes", 
"">;
 
 defm delete_null_pointer_checks : OptOutFFlag<"delete-null-pointer-checks",
   "Treat usage of null pointers as undefined behavior (default)",
-  "Do not treat usage of null pointers as undefined behavior">;
+  "Do not treat usage of null pointers as undefined behavior",
+  "", [CoreOption]>;
 
 def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
 Group,

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 89dbdebbaf69..43713d955b9b 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -311,6 +311,14 @@
 // RUN: %clang_cl -c -fno-strict-aliasing -### -- %s 2>&1 | FileCheck 
-check-prefix=NOSTRICT %s
 // NOSTRICT: "-relaxed-aliasing"
 
+// We recognize -f[no-]delete-null-pointer-checks.
+// RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTNULL %s
+// DEFAULTNULL-NOT: "-fno-delete-null-pointer-checks"
+// RUN: %clang_cl -c -fdelete-null-pointer-checks -### -- %s 2>&1 | FileCheck 
-check-prefix=NULL %s
+// NULL-NOT: "-fno-delete-null-pointer-checks"
+// RUN: %clang_cl -c -fno-delete-null-pointer-checks -### -- %s 2>&1 | 
FileCheck -check-prefix=NONULL %s
+// NONULL: "-fno-delete-null-pointer-checks"
+
 // We recognize -f[no-]delayed-template-parsing.
 // /Zc:twoPhase[-] has the opposite meaning.
 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT 
%s



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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-11 Thread Alexey Bader via Phabricator via cfe-commits
bader added a subscriber: sdmitriev.
bader added a comment.

In D89909#2353931 , @Anastasia wrote:

> In the RFC it has been discussed to either use target address spaces or 
> perhaps to introduce a new attribute to reflect a semantic needed for SYCL, 
> but it seems to me in this change you are building on top of the existing 
> language address space attribute with new entries for SYCL.
>
> http://lists.llvm.org/pipermail/cfe-dev/2020-August/066632.html

Right, this patch adds new semantic attributes for SYCL and I left a comment to 
decide whether we need a separate representation for parsed attribute and 
spelling as well. Do you suggest adding SYCL specific spelling for these 
attributes?

WRT to a solution built on top of https://reviews.llvm.org/D62574, I'm hesitate 
investing into this direction as it's not clear to me when we can get this 
patch in (it's on review for 17 months already). I'd like to make some progress 
with address space attributes to unblock upstreaming of other changes depending 
on this change.

> Has there been any other discussion regarding the approach which is not 
> captured in the cfe-dev thread I have linked?

I think everything is captured in the mailing list thread.




Comment at: clang/lib/CodeGen/CGCall.cpp:4596
+
IRFuncTy->getParamType(FirstIRArg));
+}
+

rjmccall wrote:
> This seems problematic; code like this shouldn't be necessary in every place 
> that uses a pointer value.  The general rule needs to be that expression 
> emission produces a value of its expected type, so the places that emit 
> pointers need to be casting to the generic address space.  We can avoid that 
> in some special expression emitters, like maybe EmitLValue, as long as the 
> LValue records what happened and can apply the appropriate transform later.
> 
> Also, in IRGen we work as much as possible with AST address spaces rather 
> than IR address spaces.  That is, code like this that's checking for address 
> space mismatches needs to be comparing the source AST address space with the 
> destination AST address space and calling a method on the TargetInfo when a 
> mismatch is detected, rather than comparing IR address spaces and directly 
> building an `addrspacecast`.  The idea is that in principle a target should 
> be able to have two logical address spaces that are actually implemented in 
> IR with the same underlying address space, with some arbitrary transform 
> between them.
@erichkeane, @asavonic, could you help with addressing this concern, please?



Comment at: clang/lib/CodeGen/CGExpr.cpp:4554
+
+  // Language rules define if it is legal to cast from one address space
+  // to another, and which address space we should use as a "common

Anastasia wrote:
> What language rules?
I suppose it's a generic note and author didn't meant some particular language 
here. This change was contributed by @sdmitriev. 
@sdmitriev, could you clarify, please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D90799: [PowerPC] Add paired vector load and store builtins and intrinsics

2020-11-11 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir accepted this revision.
saghir added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90799

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


[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Previously a corrupted index shard could cause us to resize arrays to an
arbitrary int32. This tends to be a huge number, and can render the
system unresponsive.

Instead, cap this at the amount of data that might reasonably be read
(e.g. the #bytes in the file). If the specified length is more than that,
assume the data is corrupt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91258

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp

Index: clang-tools-extra/clangd/unittests/SerializationTests.cpp
===
--- clang-tools-extra/clangd/unittests/SerializationTests.cpp
+++ clang-tools-extra/clangd/unittests/SerializationTests.cpp
@@ -7,15 +7,21 @@
 //===--===//
 
 #include "Headers.h"
+#include "RIFF.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
+#include "support/Logger.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#ifdef LLVM_ON_UNIX
+#include 
+#endif
 
-using ::testing::_;
-using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Pair;
 using ::testing::UnorderedElementsAre;
@@ -297,6 +303,87 @@
 EXPECT_NE(SerializedCmd.Output, Cmd.Output);
   }
 }
+
+#if LLVM_ON_UNIX // rlimit is part of POSIX
+class ScopedMemoryLimit {
+  struct rlimit OriginalLimit;
+  bool Succeeded = false;
+
+public:
+  ScopedMemoryLimit(rlim_t Bytes) {
+if (!getrlimit(RLIMIT_AS, &OriginalLimit)) {
+  struct rlimit NewLimit = OriginalLimit;
+  NewLimit.rlim_cur = Bytes;
+  Succeeded = !setrlimit(RLIMIT_AS, &NewLimit);
+}
+if (!Succeeded)
+  elog("Failed to set rlimit");
+  }
+
+  ~ScopedMemoryLimit() {
+if (Succeeded)
+  setrlimit(RLIMIT_AS, &OriginalLimit);
+  }
+};
+#else
+class ScopedMemoryLimit {
+public:
+  ScopedMemoryLimit(unsigned Bytes) {}
+};
+#endif
+
+// Test that our deserialization detects invalid array sizes without allocating.
+// If this detection fails, the test should allocate a huge array and crash.
+TEST(SerializationTest, NoCrashOnBadArraySize) {
+  // This test is tricky because we need to construct a subtly invalid file.
+  // First, create a valid serialized file.
+  auto In = readIndexFile(YAML);
+  ASSERT_FALSE(!In) << In.takeError();
+  IndexFileOut Out(*In);
+  Out.Format = IndexFileFormat::RIFF;
+  std::string Serialized = llvm::to_string(Out);
+  llvm::consumeError(readIndexFile(Serialized).takeError());
+
+  // Low-level parse it again and find the `srcs` chunk we're going to corrupt.
+  auto Parsed = riff::readFile(Serialized);
+  ASSERT_FALSE(!Parsed) << Parsed.takeError();
+  auto Srcs = llvm::find_if(Parsed->Chunks, [](riff::Chunk C) {
+return C.ID == riff::fourCC("srcs");
+  });
+  ASSERT_NE(Srcs, Parsed->Chunks.end());
+
+  // Srcs consists of a sequence of IncludeGraphNodes. In our case, just one.
+  // The node has:
+  //  - 1 byte: flags (1)
+  //  - varint(stringID): URI
+  //  - 8 byte: file digest
+  //  - varint: DirectIncludes.length
+  //  - repeated varint(stringID): DirectIncludes
+  // We want to set DirectIncludes.length to a huge number.
+  // The offset isn't trivial to find, so we use the file digest.
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+  unsigned Pos = Srcs->Data.find_first_of(FileDigest);
+  ASSERT_NE(Pos, StringRef::npos) << "Couldn't locate file digest";
+  Pos += FileDigest.size();
+
+  // Varints are little-endian base-128 numbers, where the top-bit of each byte
+  // indicates whether there are more. 8fff7f -> 0x.
+  std::string CorruptSrcs =
+  (Srcs->Data.take_front(Pos) + llvm::fromHex("8fff7f") +
+   "some_random_garbage")
+  .str();
+  Srcs->Data = CorruptSrcs;
+
+  // Try to crash rather than hang on large allocation.
+  ScopedMemoryLimit MemLimit(1000 * 1024 * 1024); // 1GB
+
+  std::string CorruptFile = llvm::to_string(*Parsed);
+  auto CorruptParsed = readIndexFile(CorruptFile);
+  ASSERT_TRUE(!CorruptParsed);
+  EXPECT_EQ(llvm::toString(CorruptParsed.takeError()),
+"malformed or truncated include uri");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -16,6 +16,7 @@
 #include "support/Trace.h"
 #include "cla

[clang] 3e5533b - [CodeGen] Remove unused check prefixes

2020-11-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-11T14:57:38Z
New Revision: 3e5533bafdc956c3ba04acfb430a68d8c13765ce

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

LOG: [CodeGen] Remove unused check prefixes

Added: 


Modified: 
clang/test/CodeGen/arm-varargs.c
clang/test/CodeGen/asan-static-odr.cpp
clang/test/CodeGen/ms-barriers-intrinsics.c
clang/test/CodeGen/ms-mixed-ptr-sizes.c
clang/test/CodeGen/ppc-smmintrin.c

Removed: 




diff  --git a/clang/test/CodeGen/arm-varargs.c 
b/clang/test/CodeGen/arm-varargs.c
index b4d629978e8a..40f562796acc 100644
--- a/clang/test/CodeGen/arm-varargs.c
+++ b/clang/test/CodeGen/arm-varargs.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple arm-none-eabi -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK --check-prefix=CHECK-LE %s
-// RUN: %clang_cc1 -triple armeb-none-eabi -emit-llvm -o - %s | FileCheck 
--check-prefix=CHECK --check-prefix=CHECK-BE %s
+// RUN: %clang_cc1 -triple arm-none-eabi -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple armeb-none-eabi -emit-llvm -o - %s | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/asan-static-odr.cpp 
b/clang/test/CodeGen/asan-static-odr.cpp
index 6b23b62e16fb..7ec3a306cd39 100644
--- a/clang/test/CodeGen/asan-static-odr.cpp
+++ b/clang/test/CodeGen/asan-static-odr.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s 
| FileCheck %s --check-prefixes=CHECK,ALIAS1
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s 
| FileCheck %s
 
 // No alias on Windows but indicators should work.
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple 
x86_64-windows-msvc %s | FileCheck %s --check-prefixes=CHECK,ALIAS0
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple 
x86_64-windows-msvc %s | FileCheck %s
 
 static int global;
 

diff  --git a/clang/test/CodeGen/ms-barriers-intrinsics.c 
b/clang/test/CodeGen/ms-barriers-intrinsics.c
index 7f87c9017046..e0e948209e3e 100644
--- a/clang/test/CodeGen/ms-barriers-intrinsics.c
+++ b/clang/test/CodeGen/ms-barriers-intrinsics.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-I386
+// RUN: | FileCheck %s
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -emit-llvm %s -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-X64

diff  --git a/clang/test/CodeGen/ms-mixed-ptr-sizes.c 
b/clang/test/CodeGen/ms-mixed-ptr-sizes.c
index 111d29b4bb03..08e4a5f81cff 100644
--- a/clang/test/CodeGen/ms-mixed-ptr-sizes.c
+++ b/clang/test/CodeGen/ms-mixed-ptr-sizes.c
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 \
-// RUN:   < %s | FileCheck %s --check-prefixes=X64,CHECK
-// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 \
-// RUN:   < %s | FileCheck %s --check-prefixes=X86,CHECK
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 
< %s | FileCheck %s --check-prefix=X64
+// RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 < %s | 
FileCheck %s --check-prefix=X86
 
 struct Foo {
   int * __ptr32 p32;

diff  --git a/clang/test/CodeGen/ppc-smmintrin.c 
b/clang/test/CodeGen/ppc-smmintrin.c
index 8deec9ee650a..644037f03afb 100644
--- a/clang/test/CodeGen/ppc-smmintrin.c
+++ b/clang/test/CodeGen/ppc-smmintrin.c
@@ -2,9 +2,9 @@
 // REQUIRES: powerpc-registered-target
 
 // RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,LE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s
 // RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr8 
-ffreestanding -DNO_WARN_X86_INTRINSICS %s \
-// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes=CHECK,BE
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | 
llvm-cxxfilt -n | FileCheck %s
 
 #include 
 



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


[clang] 8cb97fb - [CodeGen] Fix check prefix mismatch on neon-immediate-ubsan.c tests

2020-11-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-11T14:57:37Z
New Revision: 8cb97fb9c9c76878afcd6678ab5311ee2766530d

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

LOG: [CodeGen] Fix check prefix mismatch on neon-immediate-ubsan.c tests

Noticed while fixing unused prefix warnings,

Added: 


Modified: 
clang/test/CodeGen/neon-immediate-ubsan.c

Removed: 




diff  --git a/clang/test/CodeGen/neon-immediate-ubsan.c 
b/clang/test/CodeGen/neon-immediate-ubsan.c
index aacf76a6338b..69a54c846421 100644
--- a/clang/test/CodeGen/neon-immediate-ubsan.c
+++ b/clang/test/CodeGen/neon-immediate-ubsan.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple armv7s-linux-gnu -target-abi apcs-gnu -emit-llvm -o 
- %s \
 // RUN: -target-feature +neon -target-cpu cortex-a8 \
 // RUN: -fsanitize=signed-integer-overflow \
-// RUN:   | FileCheck %s --check-prefix=CHECK --check-prefix=ARMV7
+// RUN:   | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ARMV7
 
 // RUN: %clang_cc1 -triple aarch64-unknown-unknown -emit-llvm -o - %s \
 // RUN: -target-feature +neon -target-cpu cortex-a53 \
 // RUN: -fsanitize=signed-integer-overflow \
-// RUN:   | FileCheck %s --check-prefix=CHECK --check-prefix=AARCH64
+// RUN:   | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-AARCH64
 
 // Verify we emit constants for "immediate" builtin arguments.
 // Emitting a scalar expression can make the immediate be generated as



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


[PATCH] D90662: [Syntax] Tablegen operator<<(NodeKind). NFC

2020-11-11 Thread Sam McCall 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 rG138189ee33ab: [Syntax] Tablegen operator<<(NodeKind). 
NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90662

Files:
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -12,132 +12,10 @@
 
 raw_ostream &syntax::operator<<(raw_ostream &OS, NodeKind K) {
   switch (K) {
-  case NodeKind::Leaf:
-return OS << "Leaf";
-  case NodeKind::TranslationUnit:
-return OS << "TranslationUnit";
-  case NodeKind::UnknownExpression:
-return OS << "UnknownExpression";
-  case NodeKind::ParenExpression:
-return OS << "ParenExpression";
-  case NodeKind::ThisExpression:
-return OS << "ThisExpression";
-  case NodeKind::IntegerLiteralExpression:
-return OS << "IntegerLiteralExpression";
-  case NodeKind::CharacterLiteralExpression:
-return OS << "CharacterLiteralExpression";
-  case NodeKind::FloatingLiteralExpression:
-return OS << "FloatingLiteralExpression";
-  case NodeKind::StringLiteralExpression:
-return OS << "StringLiteralExpression";
-  case NodeKind::BoolLiteralExpression:
-return OS << "BoolLiteralExpression";
-  case NodeKind::CxxNullPtrExpression:
-return OS << "CxxNullPtrExpression";
-  case NodeKind::IntegerUserDefinedLiteralExpression:
-return OS << "IntegerUserDefinedLiteralExpression";
-  case NodeKind::FloatUserDefinedLiteralExpression:
-return OS << "FloatUserDefinedLiteralExpression";
-  case NodeKind::CharUserDefinedLiteralExpression:
-return OS << "CharUserDefinedLiteralExpression";
-  case NodeKind::StringUserDefinedLiteralExpression:
-return OS << "StringUserDefinedLiteralExpression";
-  case NodeKind::PrefixUnaryOperatorExpression:
-return OS << "PrefixUnaryOperatorExpression";
-  case NodeKind::PostfixUnaryOperatorExpression:
-return OS << "PostfixUnaryOperatorExpression";
-  case NodeKind::BinaryOperatorExpression:
-return OS << "BinaryOperatorExpression";
-  case NodeKind::UnqualifiedId:
-return OS << "UnqualifiedId";
-  case NodeKind::IdExpression:
-return OS << "IdExpression";
-  case NodeKind::CallExpression:
-return OS << "CallExpression";
-  case NodeKind::UnknownStatement:
-return OS << "UnknownStatement";
-  case NodeKind::DeclarationStatement:
-return OS << "DeclarationStatement";
-  case NodeKind::EmptyStatement:
-return OS << "EmptyStatement";
-  case NodeKind::SwitchStatement:
-return OS << "SwitchStatement";
-  case NodeKind::CaseStatement:
-return OS << "CaseStatement";
-  case NodeKind::DefaultStatement:
-return OS << "DefaultStatement";
-  case NodeKind::IfStatement:
-return OS << "IfStatement";
-  case NodeKind::ForStatement:
-return OS << "ForStatement";
-  case NodeKind::WhileStatement:
-return OS << "WhileStatement";
-  case NodeKind::ContinueStatement:
-return OS << "ContinueStatement";
-  case NodeKind::BreakStatement:
-return OS << "BreakStatement";
-  case NodeKind::ReturnStatement:
-return OS << "ReturnStatement";
-  case NodeKind::RangeBasedForStatement:
-return OS << "RangeBasedForStatement";
-  case NodeKind::ExpressionStatement:
-return OS << "ExpressionStatement";
-  case NodeKind::CompoundStatement:
-return OS << "CompoundStatement";
-  case NodeKind::UnknownDeclaration:
-return OS << "UnknownDeclaration";
-  case NodeKind::EmptyDeclaration:
-return OS << "EmptyDeclaration";
-  case NodeKind::StaticAssertDeclaration:
-return OS << "StaticAssertDeclaration";
-  case NodeKind::LinkageSpecificationDeclaration:
-return OS << "LinkageSpecificationDeclaration";
-  case NodeKind::SimpleDeclaration:
-return OS << "SimpleDeclaration";
-  case NodeKind::TemplateDeclaration:
-return OS << "TemplateDeclaration";
-  case NodeKind::ExplicitTemplateInstantiation:
-return OS << "ExplicitTemplateInstantiation";
-  case NodeKind::NamespaceDefinition:
-return OS << "NamespaceDefinition";
-  case NodeKind::NamespaceAliasDefinition:
-return OS << "NamespaceAliasDefinition";
-  case NodeKind::UsingNamespaceDirective:
-return OS << "UsingNamespaceDirective";
-  case NodeKind::UsingDeclaration:
-return OS << "UsingDeclaration";
-  case NodeKind::TypeAliasDeclaration:
-return OS << "TypeAliasDeclaration";
-  case NodeKind::SimpleDeclarator:
-return OS << "SimpleDeclarator";
-  case NodeKind::ParenDeclarator:
-return OS << "ParenDeclarator";
-  case NodeKind::ArraySubscript:
-return OS << "ArraySubscript";
-  case NodeKind::TrailingReturnType:
-return OS << "TrailingReturnType";
-  case NodeKind::ParametersAndQualifiers:
-return OS << "ParametersAndQualif

[clang] 138189e - [Syntax] Tablegen operator<<(NodeKind). NFC

2020-11-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-11T16:02:01+01:00
New Revision: 138189ee33ab4359bbda834d8715b16d096c1087

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

LOG: [Syntax] Tablegen operator<<(NodeKind). NFC

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

Added: 


Modified: 
clang/lib/Tooling/Syntax/Nodes.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/Nodes.cpp 
b/clang/lib/Tooling/Syntax/Nodes.cpp
index 0be9f1f03add..e9e216af5754 100644
--- a/clang/lib/Tooling/Syntax/Nodes.cpp
+++ b/clang/lib/Tooling/Syntax/Nodes.cpp
@@ -12,132 +12,10 @@ using namespace clang;
 
 raw_ostream &syntax::operator<<(raw_ostream &OS, NodeKind K) {
   switch (K) {
-  case NodeKind::Leaf:
-return OS << "Leaf";
-  case NodeKind::TranslationUnit:
-return OS << "TranslationUnit";
-  case NodeKind::UnknownExpression:
-return OS << "UnknownExpression";
-  case NodeKind::ParenExpression:
-return OS << "ParenExpression";
-  case NodeKind::ThisExpression:
-return OS << "ThisExpression";
-  case NodeKind::IntegerLiteralExpression:
-return OS << "IntegerLiteralExpression";
-  case NodeKind::CharacterLiteralExpression:
-return OS << "CharacterLiteralExpression";
-  case NodeKind::FloatingLiteralExpression:
-return OS << "FloatingLiteralExpression";
-  case NodeKind::StringLiteralExpression:
-return OS << "StringLiteralExpression";
-  case NodeKind::BoolLiteralExpression:
-return OS << "BoolLiteralExpression";
-  case NodeKind::CxxNullPtrExpression:
-return OS << "CxxNullPtrExpression";
-  case NodeKind::IntegerUserDefinedLiteralExpression:
-return OS << "IntegerUserDefinedLiteralExpression";
-  case NodeKind::FloatUserDefinedLiteralExpression:
-return OS << "FloatUserDefinedLiteralExpression";
-  case NodeKind::CharUserDefinedLiteralExpression:
-return OS << "CharUserDefinedLiteralExpression";
-  case NodeKind::StringUserDefinedLiteralExpression:
-return OS << "StringUserDefinedLiteralExpression";
-  case NodeKind::PrefixUnaryOperatorExpression:
-return OS << "PrefixUnaryOperatorExpression";
-  case NodeKind::PostfixUnaryOperatorExpression:
-return OS << "PostfixUnaryOperatorExpression";
-  case NodeKind::BinaryOperatorExpression:
-return OS << "BinaryOperatorExpression";
-  case NodeKind::UnqualifiedId:
-return OS << "UnqualifiedId";
-  case NodeKind::IdExpression:
-return OS << "IdExpression";
-  case NodeKind::CallExpression:
-return OS << "CallExpression";
-  case NodeKind::UnknownStatement:
-return OS << "UnknownStatement";
-  case NodeKind::DeclarationStatement:
-return OS << "DeclarationStatement";
-  case NodeKind::EmptyStatement:
-return OS << "EmptyStatement";
-  case NodeKind::SwitchStatement:
-return OS << "SwitchStatement";
-  case NodeKind::CaseStatement:
-return OS << "CaseStatement";
-  case NodeKind::DefaultStatement:
-return OS << "DefaultStatement";
-  case NodeKind::IfStatement:
-return OS << "IfStatement";
-  case NodeKind::ForStatement:
-return OS << "ForStatement";
-  case NodeKind::WhileStatement:
-return OS << "WhileStatement";
-  case NodeKind::ContinueStatement:
-return OS << "ContinueStatement";
-  case NodeKind::BreakStatement:
-return OS << "BreakStatement";
-  case NodeKind::ReturnStatement:
-return OS << "ReturnStatement";
-  case NodeKind::RangeBasedForStatement:
-return OS << "RangeBasedForStatement";
-  case NodeKind::ExpressionStatement:
-return OS << "ExpressionStatement";
-  case NodeKind::CompoundStatement:
-return OS << "CompoundStatement";
-  case NodeKind::UnknownDeclaration:
-return OS << "UnknownDeclaration";
-  case NodeKind::EmptyDeclaration:
-return OS << "EmptyDeclaration";
-  case NodeKind::StaticAssertDeclaration:
-return OS << "StaticAssertDeclaration";
-  case NodeKind::LinkageSpecificationDeclaration:
-return OS << "LinkageSpecificationDeclaration";
-  case NodeKind::SimpleDeclaration:
-return OS << "SimpleDeclaration";
-  case NodeKind::TemplateDeclaration:
-return OS << "TemplateDeclaration";
-  case NodeKind::ExplicitTemplateInstantiation:
-return OS << "ExplicitTemplateInstantiation";
-  case NodeKind::NamespaceDefinition:
-return OS << "NamespaceDefinition";
-  case NodeKind::NamespaceAliasDefinition:
-return OS << "NamespaceAliasDefinition";
-  case NodeKind::UsingNamespaceDirective:
-return OS << "UsingNamespaceDirective";
-  case NodeKind::UsingDeclaration:
-return OS << "UsingDeclaration";
-  case NodeKind::TypeAliasDeclaration:
-return OS << "TypeAliasDeclaration";
-  case NodeKind::SimpleDeclarator:
-return OS << "SimpleDeclarator";
-  case NodeKind::ParenDeclarator:
-return OS << "ParenDeclarator";
-  case NodeKind::ArraySubscript:
- 

[PATCH] D91261: [OPENMP]Do not use OMP_MAP_TARGET_PARAM for data movement directives.

2020-11-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.
ABataev requested review of this revision.

OMP_MAP_TARGET_PARAM flag is used to mark the data that shoud be passed
as arguments to the target kernels, nothing else. But the compiler still
marks the data with OMP_MAP_TARGET_PARAM flags even if the data is
passed to the data movement directives, like target data, target update
etc. This flag is just ignored for this directives and the compiler does
not need to emit it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91261

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp

Index: clang/test/OpenMP/target_update_depend_codegen.cpp
===
--- clang/test/OpenMP/target_update_depend_codegen.cpp
+++ clang/test/OpenMP/target_update_depend_codegen.cpp
@@ -30,15 +30,15 @@
 double gc[100];
 
 // CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i64] [i64 800]
-// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i64] [i64 4]
-// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
-// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i64] [i64 sdiv exact (i64 sub (i64 ptrtoint (double** getelementptr (double*, double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)), i64 24]
-// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 281474976710673]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 281474976710673]
 
 // CK1-LABEL: _Z3fooi
 void foo(int arg) {
Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -36,15 +36,15 @@
 // CK1-64: [[KMP_PRIVATES_T]] = type { [1 x i8*], [1 x i8*], [1 x i64] }
 
 // CK1: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 800]
-// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE02:@.+]] = {{.+}}constant [1 x i[[sz]]] [i[[sz]] 4]
-// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK1: [[MTYPE02:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
-// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 34]
+// CK1: [[MTYPE03:@.+]] = {{.+}}constant [1 x i64] [i64 2]
 
 // CK1: [[SIZE04:@.+]] = {{.+}}constant [2 x i64] [i64 sdiv exact (i64 sub (i64 ptrtoint (double** getelementptr (double*, double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1), i32 1) to i64), i64 ptrtoint (double** getelementptr inbounds (%struct.ST, %struct.ST* @gb, i32 0, i32 1) to i64)), i64 ptrtoint (i8* getelementptr (i8, i8* null, i32 1) to i64)), i64 24]
-// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 281474976710673]
+// CK1: [[MTYPE04:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 281474976710673]
 
 // CK1-LABEL: _Z3fooi
 void foo(int arg) {
@@ -205,7 +205,7 @@
   }
 };
 
-// CK2: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 32, i64 281474976710674]
+// CK2: [[MTYPE00:@.+]] = {{.+}}constant [2 x i64] [i64 0, i64 281474976710674]
 
 // CK2-LABEL: _Z3bari
 int bar(int arg){
@@ -342,7 +342,7 @@
 #ifdef CK5
 
 // CK5: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK5: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
 // CK5-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
@@ -384,7 +384,7 @@
 #ifdef CK6
 
 // CK6: [[SIZE00:@.+]] = {{.+}}constant [1 x i[[sz:64|32]]] [i{{64|32}} 4]
-// CK6: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 33]
+// CK6: [[MTYPE00:@.+]] = {{.+}}constant [1 x i64] [i64 1]
 
 // CK6-LABEL: lvalue
 void lvalue(int *B, int l, int e) {
@@ -431,7 +431,7 @@
 #ifdef CK7
 
 // CK7: [[SIZE00:@

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-11 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis created this revision.
joechrisellis added reviewers: fpetrogalli, peterwaller-arm, DavidTruby.
Herald added subscribers: cfe-commits, psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: clang.
joechrisellis requested review of this revision.

This patch allows C-style casting between fixed-size and scalable
vectors. This kind of cast was previously blocked by the compiler, but
it should be allowed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91262

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp
  clang/test/Sema/aarch64-sve-explicit-casts.cpp

Index: clang/test/Sema/aarch64-sve-explicit-casts.cpp
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+#include 
+
+// SVE types cannot be C-style casted to one another.
+// "To avoid any ambiguity [between the two operations], the ACLE does not allow C-style casting from one
+// vector type to another." ~ACLE Section 3.4 (Vector Types)
+// The functions below check that C-style casting between scalable types correctly raises an error.
+
+void svint32_to_svint64() {
+  svint32_t si32;
+  svint64_t si64;
+
+  si64 = (svint64_t) si32; // expected-error-re {{C-style cast from 'svint32_t' {{.*}} is not allowed}}
+}
+
+void svint64_to_svint32() {
+  svint32_t si32;
+  svint64_t si64;
+
+  si32 = (svint32_t) si64; // expected-error-re {{C-style cast from 'svint64_t' {{.*}} is not allowed}}
+}
+
+void svfloat32_to_svfloat64() {
+  svfloat32_t sf32;
+  svfloat64_t sf64;
+
+  sf64 = (svfloat64_t) sf32; // expected-error-re {{C-style cast from 'svfloat32_t' {{.*}} is not allowed}}
+}
+
+void svfloat64_to_svfloat32() {
+  svfloat32_t sf32;
+  svfloat64_t sf64;
+
+  sf32 = (svfloat32_t) sf64; // expected-error-re {{C-style cast from 'svfloat64_t' {{.*}} is not allowed}}
+}
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// Fixed-size SVE types can be cast to scalable SVE types (regardless of lane size).
+// NOTE: the list below is not exhaustive for all SVE types.
+
+void svint32_to_fixed_int32_t() {
+  svint32_t si32;
+  fixed_int32_t fi32;
+
+  fi32 = (fixed_int32_t)si32;
+}
+
+void fixed_int32_t_to_svint32() {
+  svint32_t si32;
+  fixed_int32_t fi32;
+
+  si32 = (svint32_t)fi32;
+}
+
+void svint64_to_fixed_int32_t() {
+  svint64_t si64;
+  fixed_int32_t fi32;
+
+  fi32 = (fixed_int32_t)si64;
+}
+
+void fixed_int32_t_to_svint64() {
+  svint64_t si64;
+  fixed_int32_t fi32;
+
+  si64 = (svint64_t)fi32;
+}
+
+void svint32_to_fixed_int64_t() {
+  svint32_t si32;
+  fixed_int64_t fi32;
+
+  fi32 = (fixed_int64_t)si32;
+}
+
+void fixed_int64_t_to_svint32() {
+  svint32_t si32;
+  fixed_int64_t fi32;
+
+  si32 = (svint32_t)fi32;
+}
+
+void svint64_to_fixed_int64_t() {
+  svint64_t si64;
+  fixed_int64_t fi32;
+
+  fi32 = (fixed_int64_t)si64;
+}
+
+void fixed_int64_t_to_svint64() {
+  svint64_t si64;
+  fixed_int64_t fi32;
+
+  si64 = (svint64_t)fi32;
+}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2219,6 +2219,13 @@
   bool destIsVector = DestType->isVectorType();
   bool srcIsVector = SrcType->isVectorType();
   if (srcIsVector || destIsVector) {
+// Allow bitcasting if either the source or destination is a scalable
+// vector.
+if (SrcType->isSizelessBuiltinType() || DestType->isSizelessBuiltinType()) {
+  Kind = CK_BitCast;
+  return TC_Success;
+}
+
 // The non-vector type, if any, must have integral type.  This is
 // the same rule that C vector casts use; note, however, that enum
 // types are not integral in C++.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91015: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

2020-11-11 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:29-33
+static ast_matchers::internal::Matcher
+hasAnyNameStdString(std::vector Names) {
+  return ast_matchers::internal::Matcher(
+  new ast_matchers::internal::HasNameMatcher(std::move(Names)));
+}

`hasAnyName` is a `VariadicMatcher`, so it supports passing a list directly (as 
a single argument), see ASTMatchersInternal.h, line 103.

Given that, I'm pretty sure this function is unnecessary; you can just call 
`hasAnyName` directly below instead of this function.



Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:112
   cxxConstructExpr(
-  hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+  hasDeclaration(cxxMethodDecl(hasStringCtorName)),
   hasArgument(0, hasType(CharPtrType)),

Following up on Aaron's comment above, I think you want something like this: 
`hasDeclaration(cxxConstructorDecl(ofClass(cxxRecordDecl(hasAnyName(removeNamespaces(StringNames`



Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:136
+anyOf(
+// do not match std::string(ptr, int)
+// match std::string(ptr, alloc)

nit: I'd put this comment line before the `anyOf` since it describes the whole 
thing, while the following comments describe each branch, respectively.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91015

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


[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-11 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 304513.
joechrisellis added a comment.

Add tests for C-style casts to/from scalable/fixed float vector types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp
  clang/test/Sema/aarch64-sve-explicit-casts.cpp

Index: clang/test/Sema/aarch64-sve-explicit-casts.cpp
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+#include 
+
+// SVE types cannot be C-style casted to one another.
+// "To avoid any ambiguity [between the two operations], the ACLE does not allow C-style casting from one
+// vector type to another." ~ACLE Section 3.4 (Vector Types)
+// The functions below check that C-style casting between scalable types correctly raises an error.
+
+void svint32_to_svint64() {
+  svint32_t si32;
+  svint64_t si64;
+
+  si64 = (svint64_t) si32; // expected-error-re {{C-style cast from 'svint32_t' {{.*}} is not allowed}}
+}
+
+void svint64_to_svint32() {
+  svint32_t si32;
+  svint64_t si64;
+
+  si32 = (svint32_t) si64; // expected-error-re {{C-style cast from 'svint64_t' {{.*}} is not allowed}}
+}
+
+void svfloat32_to_svfloat64() {
+  svfloat32_t sf32;
+  svfloat64_t sf64;
+
+  sf64 = (svfloat64_t) sf32; // expected-error-re {{C-style cast from 'svfloat32_t' {{.*}} is not allowed}}
+}
+
+void svfloat64_to_svfloat32() {
+  svfloat32_t sf32;
+  svfloat64_t sf64;
+
+  sf32 = (svfloat32_t) sf64; // expected-error-re {{C-style cast from 'svfloat64_t' {{.*}} is not allowed}}
+}
Index: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp
===
--- /dev/null
+++ clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp
@@ -0,0 +1,128 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -msve-vector-bits=512 -flax-vector-conversions=none -fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#include 
+
+#define N __ARM_FEATURE_SVE_BITS
+#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+
+typedef svfloat32_t fixed_float32_t FIXED_ATTR;
+typedef svfloat64_t fixed_float64_t FIXED_ATTR;
+typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svint64_t fixed_int64_t FIXED_ATTR;
+
+// Fixed-size SVE types can be cast to scalable SVE types (regardless of lane size).
+// NOTE: the list below is not exhaustive for all SVE types.
+
+void svint32_to_fixed_int32_t() {
+  svint32_t si32;
+  fixed_int32_t fi32;
+
+  fi32 = (fixed_int32_t)si32;
+}
+
+void fixed_int32_t_to_svint32() {
+  svint32_t si32;
+  fixed_int32_t fi32;
+
+  si32 = (svint32_t)fi32;
+}
+
+void svint64_to_fixed_int32_t() {
+  svint64_t si64;
+  fixed_int32_t fi32;
+
+  fi32 = (fixed_int32_t)si64;
+}
+
+void fixed_int32_t_to_svint64() {
+  svint64_t si64;
+  fixed_int32_t fi32;
+
+  si64 = (svint64_t)fi32;
+}
+
+void svint32_to_fixed_int64_t() {
+  svint32_t si32;
+  fixed_int64_t fi32;
+
+  fi32 = (fixed_int64_t)si32;
+}
+
+void fixed_int64_t_to_svint32() {
+  svint32_t si32;
+  fixed_int64_t fi32;
+
+  si32 = (svint32_t)fi32;
+}
+
+void svint64_to_fixed_int64_t() {
+  svint64_t si64;
+  fixed_int64_t fi32;
+
+  fi32 = (fixed_int64_t)si64;
+}
+
+void fixed_int64_t_to_svint64() {
+  svint64_t si64;
+  fixed_int64_t fi32;
+
+  si64 = (svint64_t)fi32;
+}
+
+void svfloat32_to_fixed_float32_t() {
+  svfloat32_t sf32;
+  fixed_float32_t ff32;
+
+  ff32 = (fixed_float32_t)sf32;
+}
+
+void fixed_float32_t_to_svfloat32() {
+  svfloat32_t sf32;
+  fixed_float32_t ff32;
+
+  sf32 = (svfloat32_t)ff32;
+}
+
+void svfloat64_to_fixed_float32_t() {
+  svfloat64_t sf64;
+  fixed_float32_t ff32;
+
+  ff32 = (fixed_float32_t)sf64;
+}
+
+void fixed_float32_t_to_svfloat64() {
+  svfloat64_t sf64;
+  fixed_float32_t ff32;
+
+  sf64 = (svfloat64_t)ff32;
+}
+
+void svfloat32_to_fixed_float64_t() {
+  svfloat32_t sf32;
+  fixed_float64_t ff32;
+
+  ff32 = (fixed_float64_t)sf32;
+}
+
+void fixed_float64_t_to_svfloat32() {
+  svfloat32_t sf32;
+  fixed_float64_t ff32;
+
+  sf32 = (svfloat32_t)ff32;
+}
+
+void svfloat64_to_fixed_float64_t() {
+  svfloat64_t sf64;
+  fixed_float64_t ff32;
+
+  ff32 = (fixed_float64_t)sf64;
+}
+
+void fixed_float64_t_to_svfloat64() {
+  svfloat64_t sf64;
+  fixed_float64_t ff32;
+
+  sf64 = (svfloat64_t)ff32;
+}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2219,6 +2219,13 @@
   bool destIsVector = DestType->isVectorType();
   bool srcIsVector = SrcType->isVectorTyp

[PATCH] D91229: [FileCheck] Flip -allow-unused-prefixes to false by default

2020-11-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added a comment.

In D91229#2387923 , @jhenderson wrote:

> Maybe one way to do this is to do what @RKSimon suggests in the D90281 
> , and to enable it on a per-directory basis 
> using lit.local.cfg. That would potentially require changing the "0 or 1" 
> occurrences limitation of the option, in favour of "last one wins" (or first 
> one). Then, you make the change in the lit.local.cfg, flipping the default in 
> each directory as you go. Eventually, once all tests that need it are 
> covered, you can just change the default in FileCheck itself. How does that 
> sound?

I haven't tried that yet. @RKSimon's case was that the folder was fixed, and 
we'd want to stop the bleeding there. Now, thinking more about it: because 
FileCheck won't accept more than one occurrence of --allow-unused-prefixes, if 
a directory has cases where we want to allow duplicates, we'd probably want 
lit.local.cfg to do 2 things:

- set --allow-unused-prefixes to false, to stop the bleeding - this would be 
removed when we switch defaults
- define a %UnusedPrefixesFileCheck (or better name) which is FileCheck with 
the flag set to true, which we'd then use where needed instead of FileCheck. 
This could stay like this even after we switch defaults.

I'm not very versed with lit.local.cfg - does the above capture what you 
imagined? (@RKSimon too)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91229

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


[PATCH] D90659: [Syntax] Tablegen Sequence classes. NFC

2020-11-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.td:123
+Role<"CloseParen", Token<"r_paren">>,
+  ];
+}

gribozavr2 wrote:
> The reason why in my prototype the grammar rules are separate is to allow 
> expressing rules that depend on each other in a circular fashion. Seems like 
> you avoided the problem right now by removing the need for Expression to 
> refer to all subclasses, but it would come back, in, for example, 
> LambdaExpression -- which is an expression that needs to refer to 
> CompoundStatement that is defined later in this file, while CompoundStatement 
> will need to refer to Expression. Maybe there is also a way to break 
> circularity there by careful ordering -- but we would be mixing the order of 
> expressions and statements.
In the current setup, there's a simple solution to the ordering constraints: 
define all the Alternatives first. It's not ideal, but I think less confusing 
than having separate defs for rule vs nodes.

OTOH if we want Alternatives to have down-edges later (which I think would make 
sense if we use variants rather than subclassing) then we'll definitely run 
into cycles and will need to break them by splitting out the rules.
(Or if we have cycles that don't involve Alternatives, and don't want to 
introduce artificial ones).

I think we probably will hit this case, but would like to punt on it a little 
to see whether it makes sense to break loops only where needed or fully 
separate declaration/definition.



Comment at: clang/include/clang/Tooling/Syntax/Syntax.td:70
+//
+// Each child is characterized by a unique role and an allowed base type.
+// The role sequence and role/type match are enforced invariants of the class.

gribozavr2 wrote:
> 
Hmm, I don't like swapping the order here - the role is both more important and 
written first.
I think the issue is the scope of "unique" is ambiguous, I'll try to fix that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90659

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


[clang] ea4d24c - [Syntax] Tablegen Sequence classes. NFC

2020-11-11 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-11T16:29:19+01:00
New Revision: ea4d24c899ea17ee6bd4a84eff0192503c12a5b6

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

LOG: [Syntax] Tablegen Sequence classes. NFC

Similar to the previous patch, this doesn't convert *all* the classes that
could be converted. It also doesn't enforce any new invariants etc.

It *does* include some data we don't use yet: specific token types that are
allowed and optional/required status of sequence items. (Similar to Dmitri's
prototype). I think these are easier to add as we go than later, and serve
a useful documentation purpose.

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/include/clang/Tooling/Syntax/Nodes.td
clang/include/clang/Tooling/Syntax/Syntax.td
clang/lib/Tooling/Syntax/Nodes.cpp
clang/utils/TableGen/ClangSyntaxEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 54b8c33199ff..6f3436691cc8 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -135,22 +135,6 @@ class UnqualifiedId final : public Tree {
   static bool classof(const Node *N);
 };
 
-/// Models an `id-expression`, e.g. `std::vector::size`.
-/// C++ [expr.prim.id]
-/// id-expression:
-///   unqualified-id
-///   qualified-id
-/// qualified-id:
-///   nested-name-specifier template_opt unqualified-id
-class IdExpression final : public Expression {
-public:
-  IdExpression() : Expression(NodeKind::IdExpression) {}
-  static bool classof(const Node *N);
-  NestedNameSpecifier *getQualifier();
-  Leaf *getTemplateKeyword();
-  UnqualifiedId *getUnqualifiedId();
-};
-
 /// An expression of an unknown kind, i.e. one not currently handled by the
 /// syntax tree.
 class UnknownExpression final : public Expression {
@@ -159,14 +143,6 @@ class UnknownExpression final : public Expression {
   static bool classof(const Node *N);
 };
 
-/// Models a this expression `this`. C++ [expr.prim.this]
-class ThisExpression final : public Expression {
-public:
-  ThisExpression() : Expression(NodeKind::ThisExpression) {}
-  static bool classof(const Node *N);
-  Leaf *getThisKeyword();
-};
-
 /// Models arguments of a function call.
 ///   call-arguments:
 /// delimited_list(expression, ',')
@@ -180,49 +156,6 @@ class CallArguments final : public List {
   std::vector> getArgumentsAndCommas();
 };
 
-/// A function call. C++ [expr.call]
-/// call-expression:
-///   expression '(' call-arguments ')'
-/// e.g `f(1, '2')` or `this->Base::f()`
-class CallExpression final : public Expression {
-public:
-  CallExpression() : Expression(NodeKind::CallExpression) {}
-  static bool classof(const Node *N);
-  Expression *getCallee();
-  Leaf *getOpenParen();
-  CallArguments *getArguments();
-  Leaf *getCloseParen();
-};
-
-/// Models a parenthesized expression `(E)`. C++ [expr.prim.paren]
-/// e.g. `(3 + 2)` in `a = 1 + (3 + 2);`
-class ParenExpression final : public Expression {
-public:
-  ParenExpression() : Expression(NodeKind::ParenExpression) {}
-  static bool classof(const Node *N);
-  Leaf *getOpenParen();
-  Expression *getSubExpression();
-  Leaf *getCloseParen();
-};
-
-/// Models a class member access. C++ [expr.ref]
-/// member-expression:
-///   expression -> template_opt id-expression
-///   expression .  template_opt id-expression
-/// e.g. `x.a`, `xp->a`
-///
-/// Note: An implicit member access inside a class, i.e. `a` instead of
-/// `this->a`, is an `id-expression`.
-class MemberExpression final : public Expression {
-public:
-  MemberExpression() : Expression(NodeKind::MemberExpression) {}
-  static bool classof(const Node *N);
-  Expression *getObject();
-  Leaf *getAccessToken();
-  Leaf *getTemplateKeyword();
-  IdExpression *getMember();
-};
-
 /// Expression for literals. C++ [lex.literal]
 class LiteralExpression : public Expression {
 public:

diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.td 
b/clang/include/clang/Tooling/Syntax/Nodes.td
index 821e78e1dba5..8f3d1e8f182f 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.td
+++ b/clang/include/clang/Tooling/Syntax/Nodes.td
@@ -23,6 +23,15 @@ def TranslationUnit : Unconstrained {
   }];
 }
 
+def UnqualifiedId : External {}
+
+// Lists
+def List : External {}
+def DeclaratorList : External {}
+def ParameterDeclarationList : External {}
+def CallArguments : External {}
+def NestedNameSpecifier : External {}
+
 def Expression : Alternatives {
   let documentation = [{
 A base class for all expressions. Note that expressions are not statements,
@@ -34,7 +43,17 @@ def UnaryOperatorExpression : External {}
 def PrefixUnaryOperatorExpression : Ext

[PATCH] D90659: [Syntax] Tablegen Sequence classes. NFC

2020-11-11 Thread Sam McCall 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 rGea4d24c899ea: [Syntax] Tablegen Sequence classes. NFC 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D90659?vs=302443&id=304516#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90659

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/include/clang/Tooling/Syntax/Nodes.td
  clang/include/clang/Tooling/Syntax/Syntax.td
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/utils/TableGen/ClangSyntaxEmitter.cpp

Index: clang/utils/TableGen/ClangSyntaxEmitter.cpp
===
--- clang/utils/TableGen/ClangSyntaxEmitter.cpp
+++ clang/utils/TableGen/ClangSyntaxEmitter.cpp
@@ -108,6 +108,23 @@
   return N.Derived.empty() ? N : lastConcrete(*N.Derived.back());
 }
 
+struct SyntaxConstraint {
+  SyntaxConstraint(const llvm::Record &R) {
+if (R.isSubClassOf("Optional")) {
+  *this = SyntaxConstraint(*R.getValueAsDef("inner"));
+} else if (R.isSubClassOf("AnyToken")) {
+  NodeType = "Leaf";
+} else if (R.isSubClassOf("NodeType")) {
+  NodeType = R.getName().str();
+} else {
+  assert(false && "Unhandled Syntax kind");
+}
+  }
+
+  std::string NodeType;
+  // optional and leaf types also go here, once we want to use them.
+};
+
 } // namespace
 
 void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
@@ -196,6 +213,21 @@
   OS << formatv("protected:\n  {0}(NodeKind K) : {1}(K) {{}\npublic:\n",
 N.name(), N.Base->name());
 
+if (N.Record->isSubClassOf("Sequence")) {
+  // Getters for sequence elements.
+  for (const auto &C : N.Record->getValueAsListOfDefs("children")) {
+assert(C->isSubClassOf("Role"));
+llvm::StringRef Role = C->getValueAsString("role");
+SyntaxConstraint Constraint(*C->getValueAsDef("syntax"));
+for (const char *Const : {"", "const "})
+  OS << formatv(
+  "  {2}{1} *get{0}() {2} {{\n"
+  "return llvm::cast_or_null<{1}>(findChild(NodeRole::{0}));\n"
+  "  }\n",
+  Role, Constraint.NodeType, Const);
+  }
+}
+
 // classof. FIXME: move definition inline once ~all nodes are generated.
 OS << "  static bool classof(const Node *N);\n";
 
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -196,58 +196,6 @@
   return Children;
 }
 
-syntax::Expression *syntax::MemberExpression::getObject() {
-  return cast_or_null(findChild(syntax::NodeRole::Object));
-}
-
-syntax::Leaf *syntax::MemberExpression::getTemplateKeyword() {
-  return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TemplateKeyword));
-}
-
-syntax::Leaf *syntax::MemberExpression::getAccessToken() {
-  return llvm::cast_or_null(
-  findChild(syntax::NodeRole::AccessToken));
-}
-
-syntax::IdExpression *syntax::MemberExpression::getMember() {
-  return cast_or_null(
-  findChild(syntax::NodeRole::Member));
-}
-
-syntax::NestedNameSpecifier *syntax::IdExpression::getQualifier() {
-  return cast_or_null(
-  findChild(syntax::NodeRole::Qualifier));
-}
-
-syntax::Leaf *syntax::IdExpression::getTemplateKeyword() {
-  return llvm::cast_or_null(
-  findChild(syntax::NodeRole::TemplateKeyword));
-}
-
-syntax::UnqualifiedId *syntax::IdExpression::getUnqualifiedId() {
-  return cast_or_null(
-  findChild(syntax::NodeRole::UnqualifiedId));
-}
-
-syntax::Leaf *syntax::ParenExpression::getOpenParen() {
-  return cast_or_null(findChild(syntax::NodeRole::OpenParen));
-}
-
-syntax::Expression *syntax::ParenExpression::getSubExpression() {
-  return cast_or_null(
-  findChild(syntax::NodeRole::SubExpression));
-}
-
-syntax::Leaf *syntax::ParenExpression::getCloseParen() {
-  return cast_or_null(findChild(syntax::NodeRole::CloseParen));
-}
-
-syntax::Leaf *syntax::ThisExpression::getThisKeyword() {
-  return cast_or_null(
-  findChild(syntax::NodeRole::IntroducerKeyword));
-}
-
 syntax::Leaf *syntax::LiteralExpression::getLiteralToken() {
   return cast_or_null(findChild(syntax::NodeRole::LiteralToken));
 }
@@ -274,23 +222,6 @@
   findChild(syntax::NodeRole::RightHandSide));
 }
 
-syntax::Expression *syntax::CallExpression::getCallee() {
-  return cast_or_null(findChild(syntax::NodeRole::Callee));
-}
-
-syntax::Leaf *syntax::CallExpression::getOpenParen() {
-  return cast_or_null(findChild(syntax::NodeRole::OpenParen));
-}
-
-syntax::CallArguments *syntax::CallExpression::getArguments() {
-  return cast_or_null(
-  findChild(syntax::NodeRole::Arguments));
-}
-
-syntax::Leaf *syntax::CallExpression::getCloseParen() {
-  return cast_or_null(findChild(syntax::NodeRole::CloseParen));
-}
-

[clang] c1e3d38 - [CodeGenOpenCL] Fix check prefix typo on convergent.cl test

2020-11-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-11T15:44:59Z
New Revision: c1e3d38301c305357debcedbda4999335fd727cc

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

LOG: [CodeGenOpenCL] Fix check prefix typo on convergent.cl test

Noticed while fixing unused prefix warnings - there isn't actually any diff in 
the loop unrolled ir between old/new pass managers any more, so the broken 
checks were superfluous

Added: 


Modified: 
clang/test/CodeGenOpenCL/convergent.cl

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/convergent.cl 
b/clang/test/CodeGenOpenCL/convergent.cl
index f7d4cea8373d..ffcd8f495dbe 100644
--- a/clang/test/CodeGenOpenCL/convergent.cl
+++ b/clang/test/CodeGenOpenCL/convergent.cl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-LEGACY
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fexperimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s --check-prefixes=CHECK,CHECK-NEWPM
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fno-experimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - 
-fexperimental-new-pass-manager | opt -instnamer -S | FileCheck 
-enable-var-scope %s
 
 // This is initially assumed convergent, but can be deduced to not require it.
 
@@ -118,12 +118,7 @@ void test_unroll() {
 // CHECK: [[for_body]]:
 // CHECK:  tail call spir_func void @nodupfun() #[[attr5:[0-9]+]]
 // CHECK-NOT: call spir_func void @nodupfun()
-
-// The new PM produces a slightly 
diff erent IR for the loop from the legacy PM,
-// but the test still checks that the loop is not unrolled.
-// CHECK-LEGACY:  br i1 %{{.+}}, label %[[for_body]], label 
%[[for_cond_cleanup]]
-// CHECK-NEW: br i1 %{{.+}}, label %[[for_body_crit_edge:.+]], label 
%[[for_cond_cleanup]]
-// CHECK-NEW: [[for_body_crit_edge]]:
+// CHECK:  br i1 %{{.+}}, label %[[for_body]], label %[[for_cond_cleanup]]
 
 void test_not_unroll() {
   for (int i = 0; i < 10; i++)



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


[clang] fc80931 - [CodeGenCUDA] Fix check prefix typo on device-stub.cu tests

2020-11-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-11T15:44:57Z
New Revision: fc80931b87661ade91502d5301ae90f06560343b

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

LOG: [CodeGenCUDA] Fix check prefix typo on device-stub.cu tests

Noticed while fixing unused prefix warnings

Added: 


Modified: 
clang/test/CodeGenCUDA/device-stub.cu

Removed: 




diff  --git a/clang/test/CodeGenCUDA/device-stub.cu 
b/clang/test/CodeGenCUDA/device-stub.cu
index 16bbef6cfad5..6770c1e6e0ea 100644
--- a/clang/test/CodeGenCUDA/device-stub.cu
+++ b/clang/test/CodeGenCUDA/device-stub.cu
@@ -28,11 +28,11 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - 
\
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
-// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-NEW
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -std=c++17 \
 // RUN: -target-sdk-version=9.2 -fgpu-rdc -fcuda-include-gpubinary %t -o - 
\
 // RUN:   | FileCheck %s -allow-deprecated-dag-overlap \
-// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA_NEW,LNX_17
+// RUN:   --check-prefixes=ALL,LNX,RDC,CUDA,CUDARDC,CUDA-NEW,LNX_17
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \
 // RUN: -target-sdk-version=9.2 -o - \
 // RUN:   | FileCheck -allow-deprecated-dag-overlap %s -check-prefix=NOGPUBIN



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


[clang] 10fc39b - [CodeGenObjC] Remove unused check prefixes

2020-11-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-11T15:44:58Z
New Revision: 10fc39b29171cce5629bf5da09224ae5ac33d7ed

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

LOG: [CodeGenObjC] Remove unused check prefixes

Added: 


Modified: 
clang/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m
clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m

Removed: 




diff  --git a/clang/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m 
b/clang/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m
index 07b194da9435..022b0969a7eb 100644
--- a/clang/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m
+++ b/clang/test/CodeGenObjC/arc-captured-block-var-inlined-layout.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple 
x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout
-// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-64 
--input-file=%t-64.layout %s
+// RUN: FileCheck --input-file=%t-64.layout %s
 // RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple 
i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null  %s > %t-32.layout
-// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-32 
--input-file=%t-32.layout %s
+// RUN: FileCheck --input-file=%t-32.layout %s
 // rdar://12184410
 
 void x(id y) {}

diff  --git a/clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m 
b/clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
index 76b7cfd118b5..c196e5d3531a 100644
--- a/clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
+++ b/clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -fobjc-arc -triple 
x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout
-// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-64 
--input-file=%t-64.layout %s
+// RUN: FileCheck --input-file=%t-64.layout %s
 // RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -fobjc-arc -triple 
i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout
-// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-32 
--input-file=%t-32.layout %s
+// RUN: FileCheck --input-file=%t-32.layout %s
 // rdar://12184410
 // rdar://12184410
 



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


[PATCH] D91258: [clangd] Sanity-check array sizes read from disk before allocating them.

2020-11-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:121
+  template 
+  LLVM_NODISCARD bool consumeSize(T &Container, unsigned MinSize = 1) {
+auto Size = consumeVar();

regarding minsizes, i suppose the idea was to pass `ElementSizeInBytes` for 
containers ? I am OK with the overshooting if you don't want to make this more 
detailed, but can we drop the param?



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:219
   Reader R(Data);
   size_t UncompressedSize = R.consume32();
   if (R.err())

in theory, this could also trip us over. zlib::uncompress does a `reserve` 
using this value. it is harder to come up with an upper bound here, but 
https://zlib.net/zlib_tech.html#:~:text=Maximum%20Compression%20Factor&text=(The%20test%20case%20was%20a,sources)%20is%201032%3A1.
 says the theoretical limit is 1032:1.
Maybe enforce that?

Also to make this more similar to others, it looks like `zlib::uncompress` also 
has an overload taking a `const char *`.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:529
 Reader CmdReader(Chunks.lookup("cmdl"));
 if (CmdReader.err())
   return error("malformed or truncated commandline section");

unrelated to this patch, but it feels like we are checking for the error at the 
wrong place ?



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:320
+if (!Succeeded)
+  elog("Failed to set rlimit");
+  }

should we rather `ADD_FAILURE` ?



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:345
+  std::string Serialized = llvm::to_string(Out);
+  llvm::consumeError(readIndexFile(Serialized).takeError());
+

why not `ASSERT_TRUE(readIndexFile(..))` ? (or `llvm::cantFail`)



Comment at: clang-tools-extra/clangd/unittests/SerializationTests.cpp:364
+  // The offset isn't trivial to find, so we use the file digest.
+  std::string FileDigest = llvm::fromHex("EED8F5EAF25C453C");
+  unsigned Pos = Srcs->Data.find_first_of(FileDigest);

can we use `In.Sources.begin()->Digest` instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91258

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


[clang] e3b64eb - [CodeGenCXX] Remove unused check prefixes

2020-11-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-11T16:19:53Z
New Revision: e3b64eb31c0e9a9f1ac4891b834d71532e545cad

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

LOG: [CodeGenCXX] Remove unused check prefixes

Added: 


Modified: 
clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
clang/test/CodeGenCXX/attr-cpuspecific.cpp
clang/test/CodeGenCXX/bitfield-layout.cpp
clang/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
clang/test/CodeGenCXX/catch-implicit-integer-truncations.cpp
clang/test/CodeGenCXX/conditional-temporaries.cpp
clang/test/CodeGenCXX/dllexport.cpp
clang/test/CodeGenCXX/dllimport.cpp
clang/test/CodeGenCXX/exceptions-seh-filter-captures.cpp
clang/test/CodeGenCXX/inheriting-constructor.cpp
clang/test/CodeGenCXX/lifetime-sanitizer.cpp
clang/test/CodeGenCXX/mangle-ms-cxx17.cpp
clang/test/CodeGenCXX/member-function-pointer-calls.cpp
clang/test/CodeGenCXX/runtime-dllstorage.cpp
clang/test/CodeGenCXX/ubsan-vtable-checks.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp 
b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
index 222956a223d2..7a98d56ca0d9 100644
--- a/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
+++ b/clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
@@ -1,10 +1,10 @@
 // RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -x c++ \
 // RUN: -debug-info-kind=limited < %s | \
-// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+// RUN:   FileCheck %s
 
 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm -x c++ \
 // RUN: -debug-info-kind=limited  < %s | \
-// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+// RUN:   FileCheck %s
 
 struct X {
   X();

diff  --git a/clang/test/CodeGenCXX/attr-cpuspecific.cpp 
b/clang/test/CodeGenCXX/attr-cpuspecific.cpp
index efe6921ec11e..f934f4f19164 100644
--- a/clang/test/CodeGenCXX/attr-cpuspecific.cpp
+++ b/clang/test/CodeGenCXX/attr-cpuspecific.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,LINUX
-// RUN: %clang_cc1 -triple x86_64-windows-pc -fms-compatibility -emit-llvm -o 
- %s | FileCheck %s --check-prefixes=CHECK,WINDOWS
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s 
--check-prefix=LINUX
+// RUN: %clang_cc1 -triple x86_64-windows-pc -fms-compatibility -emit-llvm -o 
- %s | FileCheck %s --check-prefix=WINDOWS
 
 struct S {
   __attribute__((cpu_specific(atom)))

diff  --git a/clang/test/CodeGenCXX/bitfield-layout.cpp 
b/clang/test/CodeGenCXX/bitfield-layout.cpp
index d8f8c87eb28b..c0bd2aa8b779 100644
--- a/clang/test/CodeGenCXX/bitfield-layout.cpp
+++ b/clang/test/CodeGenCXX/bitfield-layout.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | 
FileCheck -check-prefix=CHECK-LP64 -check-prefix=CHECK %s
-// RUN: %clang_cc1 %s -triple=i386-apple-darwin10 -emit-llvm -o - -O3 | 
FileCheck -check-prefix CHECK-LP32 -check-prefix=CHECK %s
-// RUN: %clang_cc1 %s -triple=aarch64_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck -check-prefix CHECK-A64BE -check-prefix=CHECK %s
-// RUN: %clang_cc1 %s -triple=thumbv7_be-none-eabi -emit-llvm -o - -O3 | 
FileCheck -check-prefix CHECK-A32BE -check-prefix=CHECK %s
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -O3 | 
FileCheck -check-prefix=CHECK -check-prefix=CHECK-LP64 %s
+// 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
 
 // CHECK-LP64: %union.Test1 = type { i32, [4 x i8] }
 union Test1 {

diff  --git 
a/clang/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp 
b/clang/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
index 95349387b3b4..c9398c710707 100644
--- 
a/clang/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
+++ 
b/clang/test/CodeGenCXX/catch-implicit-integer-sign-changes-true-negatives.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s 
--check-prefix=CHECK
-// RUN: %clang_cc1 -fsanitize=implicit-integer-sign-change 
-fno-sanitize-recover=implicit-integer-sign-change -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER
-// RUN: %clang_cc1 -fsanitize=implicit-integer-sign-change 
-fsanitize-recover=implicit-integer-sign-change -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-AN

[PATCH] D91269: [Clang][CodeGen][RISCV] Add hard float ABI tests with empty struct

2020-11-11 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: asb, lenary, rjmccall, efriedma.
Herald added subscribers: cfe-commits, frasercrmck, NickHung, evandro, apazos, 
sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
Herald added a project: clang.
luismarques requested review of this revision.

This patch adds tests that showcase a behavior that is currently buggy.
Fix in a follow-up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91269

Files:
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp


Index: clang/test/CodeGen/riscv32-ilp32d-abi.cpp
===
--- /dev/null
+++ clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d \
+// RUN: -Wno-missing-declarations -emit-llvm %s -o - | FileCheck %s
+
+struct empty_float2 { struct {}; float f; float g; };
+
+// CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
+// FIXME: Extraneous padding before the second float
+// CHECK: { [4 x i8], float, [4 x i8], float }
+float f_empty_float2(empty_float2 a) {
+return a.g;
+}
+
+struct empty_double2 { struct {}; double f; double g; };
+
+// CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
+// FIXME: Extraneous padding before the second double
+// CHECK: { [8 x i8], double, [8 x i8], double }
+double f_empty_double2(empty_double2 a) {
+return a.g;
+}
+
+struct empty_float_double { struct {}; float f; double g; };
+
+// CHECK: define double @_Z20f_empty_float_double18empty_float_double(float 
%0, double %1)
+// CHECK: { [4 x i8], float, double }
+double f_empty_float_double(empty_float_double a) {
+return a.g;
+}
+
+struct empty_double_float { struct {}; double f; float g; };
+
+// CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
+// FIXME: Extraneous padding before the float
+// CHECK: { [8 x i8], double, [8 x i8], float }
+double f_empty_double_float(empty_double_float a) {
+return a.g;
+}


Index: clang/test/CodeGen/riscv32-ilp32d-abi.cpp
===
--- /dev/null
+++ clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d \
+// RUN: -Wno-missing-declarations -emit-llvm %s -o - | FileCheck %s
+
+struct empty_float2 { struct {}; float f; float g; };
+
+// CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
+// FIXME: Extraneous padding before the second float
+// CHECK: { [4 x i8], float, [4 x i8], float }
+float f_empty_float2(empty_float2 a) {
+return a.g;
+}
+
+struct empty_double2 { struct {}; double f; double g; };
+
+// CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double %1)
+// FIXME: Extraneous padding before the second double
+// CHECK: { [8 x i8], double, [8 x i8], double }
+double f_empty_double2(empty_double2 a) {
+return a.g;
+}
+
+struct empty_float_double { struct {}; float f; double g; };
+
+// CHECK: define double @_Z20f_empty_float_double18empty_float_double(float %0, double %1)
+// CHECK: { [4 x i8], float, double }
+double f_empty_float_double(empty_float_double a) {
+return a.g;
+}
+
+struct empty_double_float { struct {}; double f; float g; };
+
+// CHECK: define double @_Z20f_empty_double_float18empty_double_float(double %0, float %1)
+// FIXME: Extraneous padding before the float
+// CHECK: { [8 x i8], double, [8 x i8], float }
+double f_empty_double_float(empty_double_float a) {
+return a.g;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91270: [Clang][CodeGen][RISCV] Fix hard float ABI test cases with empty struct

2020-11-11 Thread Luís Marques via Phabricator via cfe-commits
luismarques created this revision.
luismarques added reviewers: asb, lenary, rjmccall, efriedma.
Herald added subscribers: cfe-commits, frasercrmck, NickHung, evandro, apazos, 
sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.
Herald added a project: clang.
luismarques requested review of this revision.

The code seemed not to account for the field 1 offset. This patch hopefully 
fixes that issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91270

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/riscv32-ilp32d-abi.cpp


Index: clang/test/CodeGen/riscv32-ilp32d-abi.cpp
===
--- clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -4,8 +4,7 @@
 struct empty_float2 { struct {}; float f; float g; };
 
 // CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
-// FIXME: Extraneous padding before the second float
-// CHECK: { [4 x i8], float, [4 x i8], float }
+// CHECK: { [4 x i8], float, float }
 float f_empty_float2(empty_float2 a) {
 return a.g;
 }
@@ -13,8 +12,7 @@
 struct empty_double2 { struct {}; double f; double g; };
 
 // CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double 
%1)
-// FIXME: Extraneous padding before the second double
-// CHECK: { [8 x i8], double, [8 x i8], double }
+// CHECK: { [8 x i8], double, double }
 double f_empty_double2(empty_double2 a) {
 return a.g;
 }
@@ -30,8 +28,7 @@
 struct empty_double_float { struct {}; double f; float g; };
 
 // CHECK: define double @_Z20f_empty_double_float18empty_double_float(double 
%0, float %1)
-// FIXME: Extraneous padding before the float
-// CHECK: { [8 x i8], double, [8 x i8], float }
+// CHECK: { [8 x i8], double, float }
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10574,7 +10574,7 @@
 NeededArgFPRs++;
   else if (Field2Ty)
 NeededArgGPRs++;
-  return IsCandidate;
+  return true;
 }
 
 // Call getCoerceAndExpand for the two-element flattened struct described by
@@ -10600,15 +10600,16 @@
 
   CharUnits Field2Align =
   CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(Field2Ty));
-  CharUnits Field1Size =
-  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty));
-  CharUnits Field2OffNoPadNoPack = Field1Size.alignTo(Field2Align);
+  CharUnits Field1EffectiveSize =
+  CharUnits::fromQuantity(getDataLayout().getTypeStoreSize(Field1Ty)) +
+  Field1Off;
+  CharUnits Field2OffNoPadNoPack = Field1EffectiveSize.alignTo(Field2Align);
 
   CharUnits Padding = CharUnits::Zero();
   if (Field2Off > Field2OffNoPadNoPack)
 Padding = Field2Off - Field2OffNoPadNoPack;
-  else if (Field2Off != Field2Align && Field2Off > Field1Size)
-Padding = Field2Off - Field1Size;
+  else if (Field2Off != Field2Align && Field2Off > Field1EffectiveSize)
+Padding = Field2Off - Field1EffectiveSize;
 
   bool IsPacked = !Field2Off.isMultipleOf(Field2Align);
 


Index: clang/test/CodeGen/riscv32-ilp32d-abi.cpp
===
--- clang/test/CodeGen/riscv32-ilp32d-abi.cpp
+++ clang/test/CodeGen/riscv32-ilp32d-abi.cpp
@@ -4,8 +4,7 @@
 struct empty_float2 { struct {}; float f; float g; };
 
 // CHECK: define float @_Z14f_empty_float212empty_float2(float %0, float %1)
-// FIXME: Extraneous padding before the second float
-// CHECK: { [4 x i8], float, [4 x i8], float }
+// CHECK: { [4 x i8], float, float }
 float f_empty_float2(empty_float2 a) {
 return a.g;
 }
@@ -13,8 +12,7 @@
 struct empty_double2 { struct {}; double f; double g; };
 
 // CHECK: define double @_Z15f_empty_double213empty_double2(double %0, double %1)
-// FIXME: Extraneous padding before the second double
-// CHECK: { [8 x i8], double, [8 x i8], double }
+// CHECK: { [8 x i8], double, double }
 double f_empty_double2(empty_double2 a) {
 return a.g;
 }
@@ -30,8 +28,7 @@
 struct empty_double_float { struct {}; double f; float g; };
 
 // CHECK: define double @_Z20f_empty_double_float18empty_double_float(double %0, float %1)
-// FIXME: Extraneous padding before the float
-// CHECK: { [8 x i8], double, [8 x i8], float }
+// CHECK: { [8 x i8], double, float }
 double f_empty_double_float(empty_double_float a) {
 return a.g;
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -10574,7 +10574,7 @@
 NeededArgFPRs++;
   else if (Field2Ty)
 NeededArgGPRs++;
-  return IsCandidate;
+  return true;
 }
 
 //

[PATCH] D91262: [AArch64][SVE] Allow C-style casts between fixed-size and scalable vectors

2020-11-11 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp:1
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-msve-vector-bits=512 -flax-vector-conversions=none 
-fallow-half-arguments-and-returns -ffreestanding -fsyntax-only -verify %s
+

Please add all cases supported, from 128 up to 2048 (doubling the size in each 
invocation).



Comment at: clang/test/Sema/aarch64-sve-explicit-casts-fixed-size.cpp:16
+// Fixed-size SVE types can be cast to scalable SVE types (regardless of lane 
size).
+// NOTE: the list below is not exhaustive for all SVE types.
+

Maybe write a CPP macro to reduce the amount of typing in this test? The 
functions below they all look the same... 



Comment at: clang/test/Sema/aarch64-sve-explicit-casts.cpp:5
+
+// SVE types cannot be C-style casted to one another.
+// "To avoid any ambiguity [between the two operations], the ACLE does not 
allow C-style casting from one

Maybe use the same nomenclature of the ACLE specs, use `SVE VLAT` instead of 
just `SVE`.



Comment at: clang/test/Sema/aarch64-sve-explicit-casts.cpp:7
+// "To avoid any ambiguity [between the two operations], the ACLE does not 
allow C-style casting from one
+// vector type to another." ~ACLE Section 3.4 (Vector Types)
+// The functions below check that C-style casting between scalable types 
correctly raises an error.

Maybe add a link to the specs, and the version? (like in `00bet6`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91262

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


[PATCH] D82860: Port ObjCMTAction to new option parsing system

2020-11-11 Thread Jacques Pienaar via Phabricator via cfe-commits
jpienaar added a comment.

This seems to breaking clang-5 builds:

utils/TableGen/CMakeFiles/llvm-tblgen.dir/OptParserEmitter.cpp.o: In function 
`llvm::EmitOptParser(llvm::RecordKeeper&, llvm::raw_ostream&)':
/var/lib/buildkite-agent/builds/buildkite-69fdf6c495-wt2bd-1/mlir/mlir-core/llvm/utils/TableGen/OptParserEmitter.cpp:(.text._ZN4llvm13EmitOptParserERNS_12RecordKeeperERNS_11raw_ostreamE+0x148a):
 undefined reference to `MarshallingInfo::MacroName'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

(https://buildkite.com/mlir/mlir-core/builds/9273#ae602c1f-8c21-4ac6-90bb-99c9a3ae473e)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82860

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


  1   2   3   >