[PATCH] D71365: expand printf when compiling HIP to AMDGPU

2020-01-14 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds updated this revision to Diff 237864.
sameerds added a comment.

- Added a test for address spaces
- Removed an unnecessary addrspacecast in the strlen expansion
- Updated the tests to pass -fcuda-is-device
- printf is not a builtin for device code, so removed the code and tests 
related to that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71365

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGGPUBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/CodeGenHIP/printf-aggregate.cpp
  clang/test/CodeGenHIP/printf.cpp
  clang/test/Driver/hip-printf.hip
  llvm/include/llvm/Transforms/Utils/AMDGPUEmitPrintf.h
  llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt

Index: llvm/lib/Transforms/Utils/CMakeLists.txt
===
--- llvm/lib/Transforms/Utils/CMakeLists.txt
+++ llvm/lib/Transforms/Utils/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_llvm_component_library(LLVMTransformUtils
+  AMDGPUEmitPrintf.cpp
   ASanStackFrameLayout.cpp
   AddDiscriminators.cpp
   BasicBlockUtils.cpp
Index: llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
===
--- /dev/null
+++ llvm/lib/Transforms/Utils/AMDGPUEmitPrintf.cpp
@@ -0,0 +1,246 @@
+//===- AMDGPUEmitPrintf.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Utility function to lower a printf call into a series of device
+// library calls on the AMDGPU target.
+//
+// WARNING: This file knows about certain library functions. It recognizes them
+// by name, and hardwires knowledge of their semantics.
+//
+//===--===//
+
+#include "llvm/Transforms/Utils/AMDGPUEmitPrintf.h"
+#include "llvm/ADT/SparseBitVector.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/IRBuilder.h"
+
+#include 
+
+using namespace llvm;
+
+#define DEBUG_TYPE "amdgpu-emit-printf"
+
+static bool isCString(const Value *Arg) {
+  auto Ty = Arg->getType();
+  auto PtrTy = dyn_cast(Ty);
+  if (!PtrTy)
+return false;
+
+  auto IntTy = dyn_cast(PtrTy->getElementType());
+  if (!IntTy)
+return false;
+
+  return IntTy->getBitWidth() == 8;
+}
+
+static Value *fitArgInto64Bits(IRBuilder<> &Builder, Value *Arg) {
+  auto Int64Ty = Builder.getInt64Ty();
+  auto Ty = Arg->getType();
+
+  if (auto IntTy = dyn_cast(Ty)) {
+switch (IntTy->getBitWidth()) {
+case 32:
+  return Builder.CreateZExt(Arg, Int64Ty);
+case 64:
+  return Arg;
+}
+  }
+
+  if (Ty->getTypeID() == Type::DoubleTyID) {
+return Builder.CreateBitCast(Arg, Int64Ty);
+  }
+
+  if (auto PtrTy = dyn_cast(Ty)) {
+return Builder.CreatePtrToInt(Arg, Int64Ty);
+  }
+
+  llvm_unreachable("unexpected type");
+}
+
+static Value *callPrintfBegin(IRBuilder<> &Builder, Value *Version) {
+  auto Int64Ty = Builder.getInt64Ty();
+  auto M = Builder.GetInsertBlock()->getModule();
+  auto Fn = M->getOrInsertFunction("__ockl_printf_begin", Int64Ty, Int64Ty);
+  return Builder.CreateCall(Fn, Version);
+}
+
+static Value *callAppendArgs(IRBuilder<> &Builder, Value *Desc, int NumArgs,
+ Value *Arg0, Value *Arg1, Value *Arg2, Value *Arg3,
+ Value *Arg4, Value *Arg5, Value *Arg6,
+ bool IsLast) {
+  auto Int64Ty = Builder.getInt64Ty();
+  auto Int32Ty = Builder.getInt32Ty();
+  auto M = Builder.GetInsertBlock()->getModule();
+  auto Fn = M->getOrInsertFunction("__ockl_printf_append_args", Int64Ty,
+   Int64Ty, Int32Ty, Int64Ty, Int64Ty, Int64Ty,
+   Int64Ty, Int64Ty, Int64Ty, Int64Ty, Int32Ty);
+  auto IsLastValue = Builder.getInt32(IsLast);
+  auto NumArgsValue = Builder.getInt32(NumArgs);
+  return Builder.CreateCall(Fn, {Desc, NumArgsValue, Arg0, Arg1, Arg2, Arg3,
+ Arg4, Arg5, Arg6, IsLastValue});
+}
+
+static Value *appendArg(IRBuilder<> &Builder, Value *Desc, Value *Arg,
+bool IsLast) {
+  auto Arg0 = fitArgInto64Bits(Builder, Arg);
+  auto Zero = Builder.getInt64(0);
+  return callAppendArgs(Builder, Desc, 1, Arg0, Zero, Zero, Zero, Zero, Zero,
+Zero, IsLast);
+}
+
+// The device library does not provide strlen, so we build our own loop
+// here. While we are at it, we also include the terminating null in the length.
+static Value *getStrlenWithNull(IRBuilder<> &Builder, Value *Str) {
+  auto *Prev = Builder.GetInsertBlock();
+  

[PATCH] D72647: [clangd] Only re-open files if their flags changed

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



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1125
   // Per-file update to the compilation database.
-  bool ShouldReparseOpenFiles = false;
+  std::set ModifiedFiles;
+  auto Sub =

nit: llvm::StringSet<> or DenseSet are the usual type here



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1126
+  std::set ModifiedFiles;
+  auto Sub =
+  CDB->watch([&ModifiedFiles](const std::vector Changes) {

this is a clever technique. (Why not just use compilationDatabaseChanges 
directly? I suppose because then you have to deal more with path 
canonicalization?)

it risks having the CDB change concurrently and reloading those files too, 
though.
I guess there's not much harm in it. But in that case, why aren't we just 
permanently subscribing to CDB changes and re-parsing affected files? Lack of a 
thread to do it on?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72647



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


[PATCH] D71365: expand printf when compiling HIP to AMDGPU

2020-01-14 Thread Sameer Sahasrabuddhe via Phabricator via cfe-commits
sameerds marked 2 inline comments as done.
sameerds added inline comments.



Comment at: clang/test/CodeGenHIP/printf.cpp:18
+}
+
+// CHECK: [[BEGIN:%.*]]   = call i64 @__ockl_printf_begin(i64 0)

arsenm wrote:
> sameerds wrote:
> > sameerds wrote:
> > > arsenm wrote:
> > > > This could use a lot more testcases. Can you add some half, float, and 
> > > > double as well as pointers (including different address spaces) and 
> > > > vectors?
> > > I am not sure what exactly should be tested. The validity of this 
> > > expansion depends on the signature of the builtin printf function. Since 
> > > printf is variadic, the "default argument promotions" in the C/C++ spec 
> > > guarantee that the arguments are 32/64 bit integers or doubles if they 
> > > are not pointers. The printf signature as well as the device library 
> > > functions are defined using only generic pointers, so the address space 
> > > does not matter. Non-scalar arguments are not supported, which is checked 
> > > by another test using a struct. I could add a vector there, but that 
> > > doesn't seem to be adding any value.
> > Bump!
> The address space shouldn't matter, but it's good to make sure it doesn't. 
> 
> Vector arguments are 100% supported in OpenCL printf, and are not subject to 
> argument promotion. You have to use a width modifier for them though.
Added a test with address spaces on the pointer arguments.

Vectors are supported in OpenCL, but this initial implementation is 
specifically for HIP. The printf expansion is invoked by Clang CodeGen only 
when the language is HIP.

Vector support will arrive later. It's not sufficient to just implement the 
transmission via hostcall; it also needs changes to the printf processing 
performed by the hostcall listener thread on the host.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71365



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


[PATCH] D71174: [clang-tidy] new check: bugprone-signed-char-misuse

2020-01-14 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

In D71174#1774249 , @ztamas wrote:

> I run the new check on LibreOffice codebase with the option 
> CharTypdefsToIgnore = "sal_Int8".
>  The check produced 32 findings.


Interesting. It found 31 issues on the Firefox code base!
I can share the list if you are interested!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71174



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


[PATCH] D71510: [clang][checkers] Added new checker 'error-return-checker'.

2020-01-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The checker was implemented in smaller parts that are visible in the commit 
list. I can split the patch at the commits (and figure out how to use git 
history manipulations and phabricator in a better way?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71510



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


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 237886.
kadircet marked 5 inline comments as done.
kadircet added a comment.

- Increase control around paddings for plaintext rendering.
- Add another ruler before definition.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1700,6 +1700,7 @@
 HI.NamespaceScope.emplace();
   },
   R"(class foo
+
 documentation
 
 template  class Foo {})",
@@ -1723,6 +1724,7 @@
 HI.Definition = "ret_type foo(params) {}";
   },
   R"(function foo → ret_type
+
 - 
 - type
 - type foo
@@ -1741,6 +1743,7 @@
 HI.Definition = "def";
   },
   R"(variable foo : type
+
 Value = value
 
 // In test::bar
@@ -1774,7 +1777,8 @@
   HI.Name = "foo";
   HI.Type = "type";
 
-  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
+  EXPECT_EQ(HI.present().asMarkdown(),
+"### variable `foo` \\: `type`  \n\n---");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -136,13 +136,32 @@
   EXPECT_EQ(D.asPlainText(), ExpectedText);
 }
 
-TEST(Document, Spacer) {
+TEST(Document, Ruler) {
   Document D;
   D.addParagraph().appendText("foo");
-  D.addSpacer();
+  D.addRuler();
+
+  // Ruler followed by paragraph.
   D.addParagraph().appendText("bar");
-  EXPECT_EQ(D.asMarkdown(), "foo  \n\nbar");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nbar");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addCodeBlock("bar");
+  // Ruler followed by a codeblock.
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n```cpp\nbar\n```");
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  // Ruler followed by another ruler
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addRuler();
+  // FIXME: Should we trim trailing rulers also in markdown?
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n\n---");
+  EXPECT_EQ(D.asPlainText(), "foo");
 }
 
 TEST(Document, Heading) {
@@ -182,15 +201,11 @@
 foo
 ```)md";
   EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
-  // FIXME: we shouldn't have 2 empty lines in between. A solution might be
-  // having a `verticalMargin` method for blocks, and let container insert new
-  // lines according to that before/after blocks.
   ExpectedPlainText =
   R"pt(foo
   bar
   baz
 
-
 foo)pt";
   EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -542,10 +542,14 @@
 Header.appendCode(*Type);
   }
 
+  bool HasMiddleSection = false;
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();
   // For functions we display signature in a list form, e.g.:
   // - `bool param1`
   // - `int param2 = 5`
   if (Parameters && !Parameters->empty()) {
+HasMiddleSection = true;
 markup::BulletList &L = Output.addBulletList();
 for (const auto &Param : *Parameters) {
   std::string Buffer;
@@ -556,15 +560,21 @@
   }
 
   if (Value) {
+HasMiddleSection = true;
 markup::Paragraph &P = Output.addParagraph();
 P.appendText("Value =");
 P.appendCode(*Value);
   }
 
-  if (!Documentation.empty())
+  if (!Documentation.empty()) {
+HasMiddleSection = true;
 Output.addParagraph().appendText(Documentation);
+  }
 
   if (!Definition.empty()) {
+// No need to add an extra ruler if hovercard didn't have a middle section.
+if (HasMiddleSection)
+  Output.addRuler();
 std::string ScopeComment;
 // Drop trailing "::".
 if (!LocalScope.empty()) {
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -33,6 +33,12 @@
   std::string asMarkdown() const;
   std::string asPlainText() const;
 
+  /// Padding information to imitate spacing while rendering for plaintext. As
+  /// markdown renderers should already add appropriate padding between
+  /// different blocks.
+  virtual bool hasTrailingPa

[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 237887.
kadircet added a comment.

- Update comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1700,6 +1700,7 @@
 HI.NamespaceScope.emplace();
   },
   R"(class foo
+
 documentation
 
 template  class Foo {})",
@@ -1723,6 +1724,7 @@
 HI.Definition = "ret_type foo(params) {}";
   },
   R"(function foo → ret_type
+
 - 
 - type
 - type foo
@@ -1741,6 +1743,7 @@
 HI.Definition = "def";
   },
   R"(variable foo : type
+
 Value = value
 
 // In test::bar
@@ -1774,7 +1777,8 @@
   HI.Name = "foo";
   HI.Type = "type";
 
-  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
+  EXPECT_EQ(HI.present().asMarkdown(),
+"### variable `foo` \\: `type`  \n\n---");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -136,13 +136,32 @@
   EXPECT_EQ(D.asPlainText(), ExpectedText);
 }
 
-TEST(Document, Spacer) {
+TEST(Document, Ruler) {
   Document D;
   D.addParagraph().appendText("foo");
-  D.addSpacer();
+  D.addRuler();
+
+  // Ruler followed by paragraph.
   D.addParagraph().appendText("bar");
-  EXPECT_EQ(D.asMarkdown(), "foo  \n\nbar");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nbar");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addCodeBlock("bar");
+  // Ruler followed by a codeblock.
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n```cpp\nbar\n```");
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  // Ruler followed by another ruler
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addRuler();
+  // FIXME: Should we trim trailing rulers also in markdown?
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n\n---");
+  EXPECT_EQ(D.asPlainText(), "foo");
 }
 
 TEST(Document, Heading) {
@@ -182,15 +201,11 @@
 foo
 ```)md";
   EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
-  // FIXME: we shouldn't have 2 empty lines in between. A solution might be
-  // having a `verticalMargin` method for blocks, and let container insert new
-  // lines according to that before/after blocks.
   ExpectedPlainText =
   R"pt(foo
   bar
   baz
 
-
 foo)pt";
   EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -542,10 +542,14 @@
 Header.appendCode(*Type);
   }
 
+  bool HasMiddleSection = false;
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();
   // For functions we display signature in a list form, e.g.:
   // - `bool param1`
   // - `int param2 = 5`
   if (Parameters && !Parameters->empty()) {
+HasMiddleSection = true;
 markup::BulletList &L = Output.addBulletList();
 for (const auto &Param : *Parameters) {
   std::string Buffer;
@@ -556,15 +560,21 @@
   }
 
   if (Value) {
+HasMiddleSection = true;
 markup::Paragraph &P = Output.addParagraph();
 P.appendText("Value =");
 P.appendCode(*Value);
   }
 
-  if (!Documentation.empty())
+  if (!Documentation.empty()) {
+HasMiddleSection = true;
 Output.addParagraph().appendText(Documentation);
+  }
 
   if (!Definition.empty()) {
+// No need to add an extra ruler if hovercard didn't have a middle section.
+if (HasMiddleSection)
+  Output.addRuler();
 std::string ScopeComment;
 // Drop trailing "::".
 if (!LocalScope.empty()) {
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -33,6 +33,12 @@
   std::string asMarkdown() const;
   std::string asPlainText() const;
 
+  /// Padding information to imitate spacing while rendering for plaintext. As
+  /// markdown renderers should already add appropriate padding between
+  /// different blocks.
+  virtual bool hasTrailingPadding() const { return false; }
+  virtual bool requiresPrecedingPadding() const { return false; }
+
   virtual ~Block() = d

[clang-tools-extra] 45924eb - [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via cfe-commits

Author: Malcolm Parsons
Date: 2020-01-14T10:05:12Z
New Revision: 45924eb4671692b3fa9fd52fe39c81ec0647a848

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

LOG: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

Summary:
Initialising a pointer from nullptr involves an implicit cast.
Ignore it after getting initialiser from InitListExpr.

Fixes: PR0

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: JonasToth

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index 1e59acb1ff17..e99a90ffba57 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@ static const Expr *ignoreUnaryPlus(const Expr *E) {
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast(E);
   if (InitList && InitList->getNumInits() == 1)
-return InitList->getInit(0);
+return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
index 5af9855835ca..0dffeea1c9b7 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@ struct ExistingInt {
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@ struct ExistingDouble {
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@ struct ExistingBool {
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@ struct ExistingPointer {
   // CHECK-FIXES: ExistingPointer(long) :  e4(&e2) {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = &e1;
 };
 



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


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 237888.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Address comments and rebase on top of ruler patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/test/hover.test
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1723,8 +1723,10 @@
 HI.NamespaceScope = "ns::";
 HI.Definition = "ret_type foo(params) {}";
   },
-  R"(function foo → ret_type
+  R"(function foo
 
+🡺 ret_type
+Parameters:
 - 
 - type
 - type foo
@@ -1742,8 +1744,9 @@
 HI.Type = "type";
 HI.Definition = "def";
   },
-  R"(variable foo : type
+  R"(variable foo
 
+Type: type
 Value = value
 
 // In test::bar
@@ -1775,10 +1778,8 @@
   HoverInfo HI;
   HI.Kind = index::SymbolKind::Variable;
   HI.Name = "foo";
-  HI.Type = "type";
 
-  EXPECT_EQ(HI.present().asMarkdown(),
-"### variable `foo` \\: `type`  \n\n---");
+  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo`  \n\n---");
 }
 
 } // namespace
Index: clang-tools-extra/clangd/test/hover.test
===
--- clang-tools-extra/clangd/test/hover.test
+++ clang-tools-extra/clangd/test/hover.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"contents": {
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo\n\n🡺 void\n\nvoid foo()"
 # CHECK-NEXT:},
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -507,11 +507,11 @@
 markup::Document HoverInfo::present() const {
   markup::Document Output;
   // Header contains a text of the form:
-  // variable `var` : `int`
+  // variable `var`
   //
   // class `X`
   //
-  // function `foo` → `int`
+  // function `foo`
   // Note that we are making use of a level-3 heading because VSCode renders
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
@@ -534,29 +534,33 @@
 
   Header.appendText(index::getSymbolKindString(Kind));
   Header.appendCode(Name);
-  if (ReturnType) {
-Header.appendText("→");
-Header.appendCode(*ReturnType);
-  } else if (Type) {
-Header.appendText(":");
-Header.appendCode(*Type);
-  }
 
   bool HasMiddleSection = false;
   // Put a linebreak after header to increase readability.
   Output.addRuler();
-  // For functions we display signature in a list form, e.g.:
-  // - `bool param1`
-  // - `int param2 = 5`
-  if (Parameters && !Parameters->empty()) {
+  // Print Types on their own lines to reduce chances of getting line-wrapped by
+  // editor, as they might be long.
+  if (ReturnType) {
 HasMiddleSection = true;
-markup::BulletList &L = Output.addBulletList();
-for (const auto &Param : *Parameters) {
-  std::string Buffer;
-  llvm::raw_string_ostream OS(Buffer);
-  OS << Param;
-  L.addItem().addParagraph().appendCode(std::move(OS.str()));
+// For functions we display signature in a list form, e.g.:
+// 🡺 `x`
+// Parameters:
+// - `bool param1`
+// - `int param2 = 5`
+Output.addParagraph().appendText("🡺").appendCode(*ReturnType);
+if (Parameters && !Parameters->empty()) {
+  Output.addParagraph().appendText("Parameters:");
+  markup::BulletList &L = Output.addBulletList();
+  for (const auto &Param : *Parameters) {
+std::string Buffer;
+llvm::raw_string_ostream OS(Buffer);
+OS << Param;
+L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  }
 }
+  } else if (Type) {
+HasMiddleSection = true;
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }
 
   if (Value) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72622: [clangd] Add a ruler after header in hover

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



Comment at: clang-tools-extra/clangd/Hover.cpp:553
 
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();

sammccall wrote:
> (When merging with D72623, I'm assuming return type will go below this line?)
yes it will



Comment at: clang-tools-extra/clangd/test/hover.test:12
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo → void\n\n\nvoid foo()"
 # CHECK-NEXT:},

sammccall wrote:
> Why are we getting two blank lines here?
> 
> (I understand why this patch increases it by one, but don't understand why it 
> was two before. Ideally I think we never want \n\n\n in plaintext)
it was two before because of extra padding around `codeblocks`.

but agreed that we shouldn't have that much spacing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622



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


[PATCH] D71510: [clang][checkers] Added new checker 'error-return-checker'.

2020-01-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I wanted to implement the rules described here:
https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors
This lists the functions to check so this knowledge has to be built into the 
checker and there are examples of this in other checkers (stream or memory or 
string functions for example). The functions have different kinds conditions on 
the return value in case of error. It is not sufficient to simply check that 
the return value is assigned to something or used because it may be used 
without check for error. So I tried to do something that can find if exactly a 
check for the error condition was made. (Still it is not perfect because the 
value can be used before the error checking.)
The cast to `void` is the special way to avoid the warning, in every other case 
the return value has to be checked for error or there is an exception that 
should be documented (if the function "can not fail" or the error does not 
matter). This may be too much warnings for a normal project but acceptable if 
extra safe code is needed. If we want to have that clang SA can (at least 
partially) check for that rule "ERR33-C" this (or similar) check is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71510



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500



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


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

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



Comment at: clang-tools-extra/clangd/Hover.cpp:567
+  } else if (Type) {
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }

sammccall wrote:
> consider **`∈`**, which would be short and symmetrical with the arrow for 
> return type...
> 
> Too obscure?
it is a good way to make the output shorter, not sure about the symmetry though 
as type and returntype never show up in the same hovercard.
but I believe it is too obscure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623



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


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61802 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622



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


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623



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


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61802 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622



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


[PATCH] D72630: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
malcolm.parsons marked an inline comment as done.
Closed by commit rG45924eb46716: [clang-tidy] Ignore implicit casts in 
modernize-use-default-member-init (authored by malcolm.parsons).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72630

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@
   // CHECK-FIXES: ExistingPointer(long) :  e4(&e2) {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = &e1;
 };
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast(E);
   if (InitList && InitList->getNumInits() == 1)
-return InitList->getInit(0);
+return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@
   // CHECK-FIXES: ExistingPointer(long) :  e4(&e2) {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = &e1;
 };
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast(E);
   if (InitList && InitList->getNumInits() == 1)
-return InitList->getInit(0);
+return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:567
+  } else if (Type) {
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }

kadircet wrote:
> sammccall wrote:
> > consider **`∈`**, which would be short and symmetrical with the arrow for 
> > return type...
> > 
> > Too obscure?
> it is a good way to make the output shorter, not sure about the symmetry 
> though as type and returntype never show up in the same hovercard.
> but I believe it is too obscure.
The symmetry I mean is two kinds of hover cards for functions vs values that 
when scanned have approximately the same layout (type information is introduced 
by a similar-sized symbol) but can still be distinguished.

> but I believe it is too obscure.
:-( fair enough



Comment at: clang-tools-extra/clangd/Hover.cpp:538
 
   bool HasMiddleSection = false;
   // Put a linebreak after header to increase readability.

as discussed offline, better IMO to allow the middle section to be empty, emit 
both rulers, and fix it in post :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-01-14 Thread Luboš Luňák via Phabricator via cfe-commits
llunak marked 2 inline comments as done.
llunak added a comment.

In D69585#1818205 , @rnk wrote:

> I'm interested in making clang do this, but I think this needs significantly 
> more work until this is ready to land. It needs in-tree tests.


What tests specifically? I can add one test that just uses the option and then 
checks the PCH already contains what it should, but besides that this would 
need to repeat all PCH tests with this enabled. Should I just do that?

> I assumed we'd want to hook it up to `clang-cl /Yc` and `/Yu`.

If you mean automatically, then probably not. As said in the description, this 
leads to an error if a PCH'd template has a specialization that's not at least 
mentioned in the PCH. That's not a big deal and it's easy to handle, but it's 
still technically a regression. I myself wouldn't mind and would be fine with 
making this the default, but I assume (plural) you wouldn't.




Comment at: clang/include/clang/Basic/LangOptions.def:163
 BENIGN_LANGOPT(CacheGeneratedPCH, 1, 0, "cache generated PCH files in memory")
+BENIGN_LANGOPT(PCHInstantiateTemplates, 1, 0, "performing pending template 
instantiations already while building a pch")
 COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module 
uses")

rnk wrote:
> I think both sides of a PCH user and creator will need to agree on this, so 
> this isn't a "benign" langopt, is it? This is a regular one, and we should 
> diagnose mismatches between the PCH creation and use.
The flag needs to be used only when creating the PCH. Users don't care, they'll 
run the instantiation too, the flag will just make users do less repeated work.





Comment at: clang/lib/Sema/Sema.cpp:985-986
+
+// FIXME: Instantiating implicit templates already in the PCH breaks some
+// OpenMP-specific code paths, see https://reviews.llvm.org/D69585 .
+if(LangOpts.PCHInstantiateTemplates && !LangOpts.OpenMP) {

rnk wrote:
> This really deserves to be debugged before we land it.
I debugged this more than 2 months ago, that's why the OpenMP code owner is 
added as a reviewer.  The initial diff (that I have no idea how to display 
here) included a suggested fix and the description said this was a WIP and 
included my findings about it. As far as I can tell the only effect that had 
was that this patch was sitting here all the time without a single reaction, so 
if nobody OpenMP related cares then I do not either.




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

https://reviews.llvm.org/D69585



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


[PATCH] D72690: [ARM,MVE] Use the new Tablegen `defvar` and `if` statements.

2020-01-14 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added reviewers: MarkMurrayARM, miyuki.
Herald added subscribers: llvm-commits, cfe-commits, dmgreen, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.

This cleans up a lot of ugly `foreach` bodges that I've been using to
work around the lack of those two language features. Now they both
exist, I can make then all into something more legible!

In particular, in the common pattern in `ARMInstrMVE.td` where a
multiclass defines an `Instruction` instance plus one or more `Pat` that
select it, I've used a `defvar` to wrap `!cast(NAME)` so
that the patterns themselves become a little more legible.

Replacing a `foreach` with a `defvar` removes a level of block
structure, so several pieces of code have their indentation changed by
this patch. Best viewed with whitespace ignored.

NFC: the output of `llvm-tblgen -print-records` on the two affected
Tablegen sources is exactly identical before and after this change, so
there should be no effect at all on any of the other generated files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72690

Files:
  clang/include/clang/Basic/arm_mve.td
  llvm/lib/Target/ARM/ARMInstrMVE.td

Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -594,25 +594,24 @@
 
 multiclass MVE_VABAV_m {
   def "" : MVE_VABAV;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 def : Pat<(i32 (int_arm_mve_vabav
-(i32 VTI.Unsigned),
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
-  (i32 (!cast(NAME)
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
+ (i32 VTI.Unsigned),
+ (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
+  (i32 (Inst (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
 
 def : Pat<(i32 (int_arm_mve_vabav_predicated
-(i32 VTI.Unsigned),
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
-(VTI.Pred VCCR:$mask))),
-  (i32 (!cast(NAME)
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
-ARMVCCThen, (VTI.Pred VCCR:$mask)))>;
+ (i32 VTI.Unsigned),
+ (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
+ (VTI.Pred VCCR:$mask))),
+  (i32 (Inst (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
+ ARMVCCThen, (VTI.Pred VCCR:$mask)))>;
   }
 }
 
@@ -769,11 +768,11 @@
   MVEVectorVTInfo VTI, Intrinsic intr> {
   def "": MVE_VMINMAXV;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in
   def _pat : Pat<(i32 (intr (i32 rGPR:$prev), (VTI.Vec MQPR:$vec))),
- (i32 (!cast(NAME)
-   (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>;
+ (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>;
 }
 
 multiclass MVE_VMINMAXV_ty {
   def "" : MVE_VMINMAX;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated min/max
 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
 
 // Predicated min/max
 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
 (VTI.Vec MQPR:$inactive))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
-ARMVCCThen, (VTI.Pred VCCR:$mask),
-(VTI.Vec MQPR:$inactive)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+ ARMVCCThen, (VTI.Pred VCCR:$mask),
+ (VTI.Vec MQPR:$inactive)))>;
   }
 }
 
@@ -1633,20 +1631,19 @@
 multiclass MVE_VMUL_m {
   def "" : MVE_VMULt1;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated multiply
 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Ve

[PATCH] D67843: [clang-format] DisableFormat also now disables SortIncludes

2020-01-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I also am worried that this makes it impossible to just sort includes.

Alternatively, we could update the documentation of the `DisableFormat` option 
to mention this quirk:
https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Format/Format.h#L1231
It's not ideal, but it would be an improvement over the current version.


Repository:
  rC Clang

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

https://reviews.llvm.org/D67843



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


[PATCH] D72500: [clangd] Show hover info for expressions

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



Comment at: clang-tools-extra/clangd/Hover.cpp:431
+
+// Generates hover info for string literals and evaluatable expressions.
+//  FIXME: Support hover for user-defined literals.

I'd really like to avoid *any literals here in the initial patch.

While there may be value in hover to see string length, I'm not sure the 
generic expr display code (which happens to show a type, which happens to 
include length) is the best way to get at this - seems pretty clunky.

(Similarly I think there's a case for UDLs, maybe showing numbers in different 
bases etc - but that's not the central point of this patch, so let's not try to 
work out exactly where the line is)



Comment at: clang-tools-extra/clangd/Hover.cpp:438
+  // (apart from Expr), therefore this is a nasty blacklist.
+  if (llvm::isa(E) || llvm::isa(E) ||
+  llvm::isa(E) || llvm::isa(E) 
||

you could extract a isLiteral(StmtClass) function here and dispense with the 
second half of this comment, if you like.



Comment at: clang-tools-extra/clangd/Hover.cpp:528
+  if (Name.empty()) {
+// User is hovering over an expression, we only have Type and Value set.
+// We'll have an output of the form:

I don't think it's a good idea to try to infer here what's being hovered on 
from which fields happen to be set, or to bail out assuming there's no 
documentation etc. (e.g it would be pretty reasonable for a UDL to return the 
doc of the operator as doc).

I'm also not sure abandoning the standard layout of properties is such a good 
idea, vs e.g.

---
### Binary expression

Type: `int`
Value = `4`

---

which would be consistent with the others (and simpler here).
We could always use "Expression" or "BinaryOperator" (from StmtClass) for now. 
Or maybe

---

### Expression: `int`

Value = `4`

---

Which still requires some special-casing, but less.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500



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


[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2020-01-14 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 237906.
kmclaughlin added a comment.

- Rebased patch
- Updated comments and extended getSVEContainerType to handle nxv8i16 & nxv16i8


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

https://reviews.llvm.org/D71698

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads-nf.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+define  @ldnf1b( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b:
+; CHECK: ldnf1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv16i8( %pg, i8* %a)
+  ret  %load
+}
+
+define  @ldnf1b_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_h:
+; CHECK: ldnf1b { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_h( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_h:
+; CHECK: ldnf1sb { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8i16( %pg, i16* %a)
+  ret  %load
+}
+
+define  @ldnf1h_f16( %pg, half* %a) {
+; CHECK-LABEL: ldnf1h_f16:
+; CHECK: ldnf1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv8f16( %pg, half* %a)
+  ret  %load
+}
+
+define  @ldnf1b_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_s:
+; CHECK: ldnf1b { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_s( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_s:
+; CHECK: ldnf1sb { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_s:
+; CHECK: ldnf1h { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_s( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_s:
+; CHECK: ldnf1sh { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4i32( %pg, i32* %a)
+  ret  %load
+}
+
+define  @ldnf1w_f32( %pg, float* %a) {
+; CHECK-LABEL: ldnf1w_f32:
+; CHECK: ldnf1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv4f32( %pg, float* %a)
+  ret  %load
+}
+
+define  @ldnf1b_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1b_d:
+; CHECK: ldnf1b { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sb_d( %pg, i8* %a) {
+; CHECK-LABEL: ldnf1sb_d:
+; CHECK: ldnf1sb { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i8( %pg, i8* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1h_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1h_d:
+; CHECK: ldnf1h { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sh_d( %pg, i16* %a) {
+; CHECK-LABEL: ldnf1sh_d:
+; CHECK: ldnf1sh { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i16( %pg, i16* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1w_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1w_d:
+; CHECK: ldnf1w { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = zext  %load to 
+  ret  %res
+}
+
+define  @ldnf1sw_d( %pg, i32* %a) {
+; CHECK-LABEL: ldnf1sw_d:
+; CHECK: ldnf1sw { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i32( %pg, i32* %a)
+  %res = sext  %load to 
+  ret  %res
+}
+
+define  @ldnf1d( %pg, i64* %a) {
+; CHECK-LABEL: ldnf1d:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch64.sve.ldnf1.nxv2i64( %pg, i64* %a)
+  ret  %load
+}
+
+define  @ldnf1d_f64( %pg, double* %a) {
+; CHECK-LABEL: ldnf1d_f64:
+; CHECK: ldnf1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %load = call  @llvm.aarch6

[PATCH] D71698: [AArch64][SVE] Add intrinsic for non-faulting loads

2020-01-14 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 5 inline comments as done.
kmclaughlin added a comment.

Thanks for your suggestions, @andwar!


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

https://reviews.llvm.org/D71698



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


[clang] 3d6c492 - [RISCV] Fix ILP32D lowering for double+double/double+int return types

2020-01-14 Thread James Clarke via cfe-commits

Author: James Clarke
Date: 2020-01-14T11:17:19Z
New Revision: 3d6c492d7a9830a1a39b85dfa215743581d52715

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

LOG: [RISCV] Fix ILP32D lowering for double+double/double+int return types

Summary:
Previously, since these aggregates are > 2*XLen, Clang would think they
were being returned indirectly and thus would decrease the number of
available GPRs available by 1. For long argument lists this could lead
to a struct argument incorrectly being passed indirectly.

Reviewers: asb, lenary

Reviewed By: asb, lenary

Subscribers: luismarques, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, 
kito-cheng, shiva0217, zzheng, edward-jones, rogfer01, MartinMosbeck, 
brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, lenary, 
s.egerton, pzheng, sameer.abuasal, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 7068fa0fcc69..dd6597f154bb 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -9377,11 +9377,21 @@ void RISCVABIInfo::computeInfo(CGFunctionInfo &FI) 
const {
 FI.getReturnInfo() = classifyReturnType(RetTy);
 
   // IsRetIndirect is true if classifyArgumentType indicated the value should
-  // be passed indirect or if the type size is greater than 2*xlen. e.g. fp128
-  // is passed direct in LLVM IR, relying on the backend lowering code to
-  // rewrite the argument list and pass indirectly on RV32.
-  bool IsRetIndirect = FI.getReturnInfo().getKind() == ABIArgInfo::Indirect ||
-   getContext().getTypeSize(RetTy) > (2 * XLen);
+  // be passed indirect, or if the type size is a scalar greater than 2*XLen
+  // and not a complex type with elements <= FLen. e.g. fp128 is passed direct
+  // in LLVM IR, relying on the backend lowering code to rewrite the argument
+  // list and pass indirectly on RV32.
+  bool IsRetIndirect = FI.getReturnInfo().getKind() == ABIArgInfo::Indirect;
+  if (!IsRetIndirect && RetTy->isScalarType() &&
+  getContext().getTypeSize(RetTy) > (2 * XLen)) {
+if (RetTy->isComplexType() && FLen) {
+  QualType EltTy = RetTy->getAs()->getElementType();
+  IsRetIndirect = getContext().getTypeSize(EltTy) > FLen;
+} else {
+  // This is a normal scalar > 2*XLen, such as fp128 on RV32.
+  IsRetIndirect = true;
+}
+  }
 
   // We must track the number of GPRs used in order to conform to the RISC-V
   // ABI, as integer scalars passed in registers should have signext/zeroext

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.c 
b/clang/test/CodeGen/riscv32-ilp32d-abi.c
index 078fcb6b5ab1..b5b451cee151 100644
--- a/clang/test/CodeGen/riscv32-ilp32d-abi.c
+++ b/clang/test/CodeGen/riscv32-ilp32d-abi.c
@@ -280,3 +280,27 @@ void f_double_u_arg(union double_u a) {}
 union double_u f_ret_double_u() {
   return (union double_u){1.0};
 }
+
+// Test that we don't incorrectly think double+int/double+double structs will
+// be returned indirectly and thus have an off-by-one error for the number of
+// GPRs available (this is an edge case when structs > 2*XLEN are still
+// returned in registers). This includes complex doubles, which are treated as
+// double+double structs by the ABI.
+
+// CHECK: define { double, i32 } 
@f_ret_double_int32_s_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 
%c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+struct double_int32_s f_ret_double_int32_s_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return (struct double_int32_s){1.0, 2};
+}
+
+// CHECK: define { double, double } 
@f_ret_double_double_s_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 
%c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+struct double_double_s 
f_ret_double_double_s_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return (struct double_double_s){1.0, 2.0};
+}
+
+// CHECK: define { double, double } 
@f_ret_doublecomplex_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 
%c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+double __complex__ f_ret_doublecomplex_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return 1.0;
+}



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


[PATCH] D69590: [RISCV] Fix ILP32D lowering for double+double/double+int return types

2020-01-14 Thread James Clarke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d6c492d7a98: [RISCV] Fix ILP32D lowering for 
double+double/double+int return types (authored by jrtc27).

Changed prior to commit:
  https://reviews.llvm.org/D69590?vs=226981&id=237912#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69590

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


Index: clang/test/CodeGen/riscv32-ilp32d-abi.c
===
--- clang/test/CodeGen/riscv32-ilp32d-abi.c
+++ clang/test/CodeGen/riscv32-ilp32d-abi.c
@@ -280,3 +280,27 @@
 union double_u f_ret_double_u() {
   return (union double_u){1.0};
 }
+
+// Test that we don't incorrectly think double+int/double+double structs will
+// be returned indirectly and thus have an off-by-one error for the number of
+// GPRs available (this is an edge case when structs > 2*XLEN are still
+// returned in registers). This includes complex doubles, which are treated as
+// double+double structs by the ABI.
+
+// CHECK: define { double, i32 } 
@f_ret_double_int32_s_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 
%c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+struct double_int32_s f_ret_double_int32_s_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return (struct double_int32_s){1.0, 2};
+}
+
+// CHECK: define { double, double } 
@f_ret_double_double_s_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 
%c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+struct double_double_s 
f_ret_double_double_s_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return (struct double_double_s){1.0, 2.0};
+}
+
+// CHECK: define { double, double } 
@f_ret_doublecomplex_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 
%c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+double __complex__ f_ret_doublecomplex_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return 1.0;
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9377,11 +9377,21 @@
 FI.getReturnInfo() = classifyReturnType(RetTy);
 
   // IsRetIndirect is true if classifyArgumentType indicated the value should
-  // be passed indirect or if the type size is greater than 2*xlen. e.g. fp128
-  // is passed direct in LLVM IR, relying on the backend lowering code to
-  // rewrite the argument list and pass indirectly on RV32.
-  bool IsRetIndirect = FI.getReturnInfo().getKind() == ABIArgInfo::Indirect ||
-   getContext().getTypeSize(RetTy) > (2 * XLen);
+  // be passed indirect, or if the type size is a scalar greater than 2*XLen
+  // and not a complex type with elements <= FLen. e.g. fp128 is passed direct
+  // in LLVM IR, relying on the backend lowering code to rewrite the argument
+  // list and pass indirectly on RV32.
+  bool IsRetIndirect = FI.getReturnInfo().getKind() == ABIArgInfo::Indirect;
+  if (!IsRetIndirect && RetTy->isScalarType() &&
+  getContext().getTypeSize(RetTy) > (2 * XLen)) {
+if (RetTy->isComplexType() && FLen) {
+  QualType EltTy = RetTy->getAs()->getElementType();
+  IsRetIndirect = getContext().getTypeSize(EltTy) > FLen;
+} else {
+  // This is a normal scalar > 2*XLen, such as fp128 on RV32.
+  IsRetIndirect = true;
+}
+  }
 
   // We must track the number of GPRs used in order to conform to the RISC-V
   // ABI, as integer scalars passed in registers should have signext/zeroext


Index: clang/test/CodeGen/riscv32-ilp32d-abi.c
===
--- clang/test/CodeGen/riscv32-ilp32d-abi.c
+++ clang/test/CodeGen/riscv32-ilp32d-abi.c
@@ -280,3 +280,27 @@
 union double_u f_ret_double_u() {
   return (union double_u){1.0};
 }
+
+// Test that we don't incorrectly think double+int/double+double structs will
+// be returned indirectly and thus have an off-by-one error for the number of
+// GPRs available (this is an edge case when structs > 2*XLEN are still
+// returned in registers). This includes complex doubles, which are treated as
+// double+double structs by the ABI.
+
+// CHECK: define { double, i32 } @f_ret_double_int32_s_double_int32_s_just_sufficient_gprs(i32 %a, i32 %b, i32 %c, i32 %d, i32 %e, i32 %f, i32 %g, double %0, i32 %1)
+struct double_int32_s f_ret_double_int32_s_double_int32_s_just_sufficient_gprs(
+int a, int b, int c, int d, int e, int f, int g, struct double_int32_s h) {
+  return (struct double_int32_s){1.0, 2};
+}
+
+// CHECK: define { double, double } @f_ret_double_double_s_double_int32_s_just_sufficient

[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-14 Thread liu hui via Phabricator via cfe-commits
lh123 added a comment.

I think the character "🡺" should be avoided, as it may not display properly in 
some environments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623



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


[PATCH] D72245: [PoC][RISCV][LTO] Pass target-abi via module flag metadata

2020-01-14 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/lib/LTO/LTOBackend.cpp:151
 
+  TargetMachine::initTargetOptions(M, Conf.Options);
+

tejohnson wrote:
> lenary wrote:
> > tejohnson wrote:
> > > lenary wrote:
> > > > tejohnson wrote:
> > > > > This is going to be problematic. The Conf is a reference to the 
> > > > > Config object saved on the LTO class instance shared by all backend 
> > > > > invocations (the regular LTO module if one exists and any ThinLTO 
> > > > > modules). They will end up clobbering each other's values here - 
> > > > > although from the assert in initTargetOptions I see they are required 
> > > > > to all have the same value anyway. Still, it is not good as the 
> > > > > assert may actually be missed with unlucky interference between the 
> > > > > threads. The Config object here should really be marked const, let me 
> > > > > see if I can change that.
> > > > > 
> > > > > You could make a copy of the Config here, but that essentially misses 
> > > > > the assertion completely. 
> > > > > 
> > > > > A better way to do this would be in LTO::addModule, which is invoked 
> > > > > serially to add each Module to the LTO object.
> > > > > 
> > > > > However - this misses other places that invoke createTargetMachine - 
> > > > > should other places be looking at this new module flag as well? One 
> > > > > example I can think of is the old LTO API (*LTOCodeGenerator.cpp 
> > > > > files), used by linkers such as ld64 and some other proprietary 
> > > > > linkers and the llvm-lto testing tool. But I have no idea about other 
> > > > > invocations of createTargetMachine.
> > > > > 
> > > > > Note that changes to LTO.cpp/LTOBackend.cpp (the new LTO API) needs 
> > > > > some kind of llvm-lto2 based test.
> > > > Thank you for this feedback. 
> > > > 
> > > > I've been looking at how to add an overridable TargetMachine hook which 
> > > > is not dissimilar to this static function, but is overridable by 
> > > > TargetMachine subclasses. It sounds like this approach will also not 
> > > > work (unless the TargetMachine is allowed to update its 
> > > > (Default)Options in LTO without issue). 
> > > > 
> > > > I am hoping to get a patch out today for review (which does not include 
> > > > the RISC-V specific parts of this patch, and only includes a default 
> > > > empty implementation), but I imagine it will remain unsatisfactory for 
> > > > LTO for the same reasons this is.
> > > Presumably you could still do the same thing I'm suggesting here - 
> > > validate and aggregate the value across modules in LTO::addModule. Then 
> > > your hook would just check the aggregated setting on the Config.
> > D72624 is the patch I have prepared, noting I haven't had time to implement 
> > the aggregation yet, which suggests that patch's approach is too general.
> FYI I committed a change to make the Config object passed down to the 
> backends a const reference in d0aad9f56e1588effa94b15804b098e6307da6b4.
Thank you! It is useful to have this restriction explicit :)


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

https://reviews.llvm.org/D72245



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


[PATCH] D72690: [ARM,MVE] Use the new Tablegen `defvar` and `if` statements.

2020-01-14 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM accepted this revision.
MarkMurrayARM added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:2464
+  defvar pred_int   = int_arm_mve_vshll_imm_predicated;
+  defvar imm= inst_imm.immediateType;
+

MUCH better!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72690



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


[PATCH] D72691: [clang-tidy] Match InitListExpr in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh, JonasToth.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

modernize-use-default-member-init wasn't warning about redundant initialisers
when the initialiser was an InitListExpr.  Add initListExpr to the matcher.

Fixes: PR44439


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72691

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -247,24 +247,24 @@
 };
 
 struct ExistingChar {
-  ExistingChar(short) : e1(), e2(), e3(), e4() {}
+  ExistingChar(short) : e1(), e2{}, e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:31: warning: member initializer for 'e2' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is redundant
   // CHECK-FIXES: ExistingChar(short) :  e4() {}
-  ExistingChar(int) : e1(0), e2(0), e3(0), e4(0) {}
+  ExistingChar(int) : e1(0), e2{0}, e3(0), e4(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is redundant
   // CHECK-FIXES: ExistingChar(int) :  e4(0) {}
-  ExistingChar(long) : e1('\0'), e2('\0'), e3('\0'), e4('\0') {}
+  ExistingChar(long) : e1('\0'), e2{'\0'}, e3('\0'), e4('\0') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:44: warning: member initializer for 'e3' is redundant
   // CHECK-FIXES: ExistingChar(long) :  e4('\0') {}
-  ExistingChar(char) : e1('a'), e2('a'), e3('a'), e4('a') {}
+  ExistingChar(char) : e1('a'), e2{'a'}, e3('a'), e4('a') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: member initializer for 'e4' is redundant
-  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2('a'), e3('a') {}
+  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2{'a'}, e3('a') {}
   char e1{};
   char e2 = 0;
   char e3 = '\0';
@@ -272,22 +272,22 @@
 };
 
 struct ExistingInt {
-  ExistingInt(short) : e1(), e2(), e3(), e4(), e5(), e6() {}
+  ExistingInt(short) : e1(), e2{}, e3(), e4(), e5(), e6() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant
   // CHECK-FIXES: ExistingInt(short) :  e3(), e4(), e5(), e6() {}
-  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0), e5(0), e6(0) {}
+  ExistingInt(int) : e1(0), e2{0}, e3(0), e4(0), e5(0), e6(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is redundant
   // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0), e5(0), e6(0) {}
-  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5), e5(5), e6(5) {}
+  ExistingInt(long) : e1(5), e2{5}, e3(5), e4(5), e5(5), e6(5) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: member initializer for 'e3' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: member initializer for 'e4' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: member initializer for 'e6' is redundant
-  // CHECK-FIXES: ExistingInt(long) : e1(5), e2(5),  e5(5) {}
-  ExistingInt(char) : e1(-5), e2(-5), e3(-5), e4(-5), e5(-5), e6(-5) {}
+  // CHECK-FIXES: ExistingInt(long) : e1(5), e2{5},  e5(5) {}
+  ExistingInt(char) : e1(-5), e2{-5}, e3(-5), e4(-5), e5(-5), e6(-5) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:55: warning: member initializer for 'e5' is redundant
-  // CHECK-FIXES: ExistingInt(char) : e1(-5), e2(-5), e3(-5), e4(-5),  e6(-5) {}
+  // CHECK-FIXES: ExistingInt(char) : e1(-5), e2{-5}, e3(-5), e4(-5),  e6(-5) {}
   int e1{};
   int e2 = 0;
   int e3 = {5};
@@ -297,21 +297,21 @@
 };
 
 struct ExistingDouble {
-  ExistingDouble(short) : e1(), e2(), e3(), e4(), e5() {}
+  ExistingDouble(short) : e1(), e2{}, e3(), e4(), e5() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: member initializer for 'e2' is redundant
   // CHECK-FIXES: ExistingDouble(short) :  e3(), e4(), e5() {}
-  ExistingDouble(int) : e1(0.0), e2(0.0), e3(0.0), e4(0.0), e5(0.0) {}
+  Exist

[clang] 71d5454 - [ARM, MVE] Use the new Tablegen `defvar` and `if` statements.

2020-01-14 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-01-14T12:08:03Z
New Revision: 71d5454b377239213874a0d762860e6a3e60bf54

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

LOG: [ARM,MVE] Use the new Tablegen `defvar` and `if` statements.

Summary:
This cleans up a lot of ugly `foreach` bodges that I've been using to
work around the lack of those two language features. Now they both
exist, I can make then all into something more legible!

In particular, in the common pattern in `ARMInstrMVE.td` where a
multiclass defines an `Instruction` instance plus one or more `Pat` that
select it, I've used a `defvar` to wrap `!cast(NAME)` so
that the patterns themselves become a little more legible.

Replacing a `foreach` with a `defvar` removes a level of block
structure, so several pieces of code have their indentation changed by
this patch. Best viewed with whitespace ignored.

NFC: the output of `llvm-tblgen -print-records` on the two affected
Tablegen sources is exactly identical before and after this change, so
there should be no effect at all on any of the other generated files.

Reviewers: MarkMurrayARM, miyuki

Reviewed By: MarkMurrayARM

Subscribers: kristof.beyls, hiraditya, dmgreen, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 6d0bb96cba6f..0e023b85459c 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -212,20 +212,17 @@ def vmaxvq: Intrinsic $prev, $vec))>;
 }
 
-foreach half = [ "b", "t" ] in
-foreach halfconst = [ !if(!eq(half, "b"), 0, 1) ] in {
-
-let params = [f32], pnt = PNT_None in {
-
-def vcvt#half#q_f16: Intrinsic<
-VecOf, (args VecOf:$inactive, Vector:$a),
-(IRInt<"vcvt_narrow"> $inactive, $a, halfconst)>;
-def vcvt#half#q_m_f16: Intrinsic<
-VecOf, (args VecOf:$inactive, Vector:$a, PredOf:$pred),
-(IRInt<"vcvt_narrow_predicated"> $inactive, $a, halfconst, $pred)>;
-
-} // params = [f32], pnt = PNT_None
-
+foreach half = [ "b", "t" ] in {
+  defvar halfconst = !if(!eq(half, "b"), 0, 1);
+
+  let params = [f32], pnt = PNT_None in {
+def vcvt#half#q_f16: Intrinsic<
+  VecOf, (args VecOf:$inactive, Vector:$a),
+  (IRInt<"vcvt_narrow"> $inactive, $a, halfconst)>;
+def vcvt#half#q_m_f16: Intrinsic<
+  VecOf, (args VecOf:$inactive, Vector:$a, PredOf:$pred),
+  (IRInt<"vcvt_narrow_predicated"> $inactive, $a, halfconst, $pred)>;
+  } // params = [f32], pnt = PNT_None
 } // loop over half = "b", "t"
 
 multiclass compare_with_pred;
 
 multiclass DyadicImmShift {
-  foreach intparams = [!if(!eq(!cast(outtype), !cast(Vector)),
-   [Vector], [outtype, Vector])] in {
-def q_n: Intrinsic<
-outtype, (args outtype:$a, Vector:$b, imm:$sh),
-!con((IRInt $a, $b, $sh), extraargs)>;
-
-def q_m_n: Intrinsic<
-outtype, (args outtype:$a, Vector:$b, imm:$sh, Predicate:$pred),
-!con((IRInt
- $a, $b, $sh), extraargs, (? $pred))>;
-  }
+  defvar intparams = !if(!eq(!cast(outtype), !cast(Vector)),
+ [Vector], [outtype, Vector]);
+
+  def q_n: Intrinsic<
+  outtype, (args outtype:$a, Vector:$b, imm:$sh),
+  !con((IRInt $a, $b, $sh), extraargs)>;
+
+  def q_m_n: Intrinsic<
+  outtype, (args outtype:$a, Vector:$b, imm:$sh, Predicate:$pred),
+  !con((IRInt
+   $a, $b, $sh), extraargs, (? $pred))>;
 }
 
 multiclass VSHRN {
@@ -672,12 +669,11 @@ multiclass VSHRN {
 }
 
 let params = [s16, s32, u16, u32], pnt = PNT_NType in {
-  foreach U = [(unsignedflag Scalar)] in {
-defm vshrn   : VSHRN;
-defm vqshrn  : VSHRN;
-defm vrshrn  : VSHRN;
-defm vqrshrn : VSHRN;
-  }
+  defvar U = (unsignedflag Scalar);
+  defm vshrn   : VSHRN;
+  defm vqshrn  : VSHRN;
+  defm vrshrn  : VSHRN;
+  defm vqrshrn : VSHRN;
 }
 let params = [s16, s32], pnt = PNT_NType in {
   defm vqshrun  : VSHRN;

diff  --git a/llvm/lib/Target/ARM/ARMInstrMVE.td 
b/llvm/lib/Target/ARM/ARMInstrMVE.td
index 325c9153491d..604291be822c 100644
--- a/llvm/lib/Target/ARM/ARMInstrMVE.td
+++ b/llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -594,25 +594,24 @@ class MVE_VABAV size>
 
 multiclass MVE_VABAV_m {
   def "" : MVE_VABAV;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 def : Pat<(i32 (int_arm_mve_vabav
-(i32 VTI.Unsigned),
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
-  (i32 (!cast(NAME)
-(i32 rGPR:$Rda_src),
-  

[PATCH] D72362: [clang-tidy] misc-no-recursion: a new check

2020-01-14 Thread Alexey Bader via Phabricator via cfe-commits
bader added a subscriber: Naghasan.
bader added a comment.

In D72362#1817682 , @lebedev.ri wrote:

> In D72362#1817599 , @bader wrote:
>
> > Does it make sense to implement such diagnostics in clang Sema, considering 
> > that OpenCL does not allow recursion?
> >  We implemented similar diagnostics for SYCL programming model and would be 
> > like to upstream it to clang later 
> > (https://github.com/intel/llvm/commit/4efe9fcf2dc6f6150b5b477b0f8320ea13a7f596).
> >  Can we somehow leverage this work for the compiler?
>
>
> Implementing it elsewhere will be more restrictive in the future - somehow i 
> suspect
>  it will be easier to make clang-tidy CTU-aware rather than clang sema.
>
> That being said, is SYCL inherently single-TU, does it not support
>  linking multiple separately compiled object files together?


SYCL doesn't require multi-TU support. AFAIK, ComputeCPP implementation is 
signle-TU. +@Naghasan to confirm/clarify.
The open source implementation I referred to, does support linking separately 
compiled object files, but still I think detecting single-TU recursion in clang 
is very useful.
Is it possible to have both: intra-TU diagnostics in clang and inter-TU 
diagnostics in clang-tidy tool? Share any infrastructure (e.g. recursion 
detection)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72362



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


[PATCH] D72690: [ARM,MVE] Use the new Tablegen `defvar` and `if` statements.

2020-01-14 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d5454b3772: [ARM,MVE] Use the new Tablegen `defvar` and 
`if` statements. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72690

Files:
  clang/include/clang/Basic/arm_mve.td
  llvm/lib/Target/ARM/ARMInstrMVE.td

Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -594,25 +594,24 @@
 
 multiclass MVE_VABAV_m {
   def "" : MVE_VABAV;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 def : Pat<(i32 (int_arm_mve_vabav
-(i32 VTI.Unsigned),
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
-  (i32 (!cast(NAME)
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
+ (i32 VTI.Unsigned),
+ (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
+  (i32 (Inst (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
 
 def : Pat<(i32 (int_arm_mve_vabav_predicated
-(i32 VTI.Unsigned),
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
-(VTI.Pred VCCR:$mask))),
-  (i32 (!cast(NAME)
-(i32 rGPR:$Rda_src),
-(VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
-ARMVCCThen, (VTI.Pred VCCR:$mask)))>;
+ (i32 VTI.Unsigned),
+ (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
+ (VTI.Pred VCCR:$mask))),
+  (i32 (Inst (i32 rGPR:$Rda_src),
+ (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
+ ARMVCCThen, (VTI.Pred VCCR:$mask)))>;
   }
 }
 
@@ -769,11 +768,11 @@
   MVEVectorVTInfo VTI, Intrinsic intr> {
   def "": MVE_VMINMAXV;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in
   def _pat : Pat<(i32 (intr (i32 rGPR:$prev), (VTI.Vec MQPR:$vec))),
- (i32 (!cast(NAME)
-   (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>;
+ (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>;
 }
 
 multiclass MVE_VMINMAXV_ty {
   def "" : MVE_VMINMAX;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated min/max
 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
 
 // Predicated min/max
 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
 (VTI.Vec MQPR:$inactive))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
-ARMVCCThen, (VTI.Pred VCCR:$mask),
-(VTI.Vec MQPR:$inactive)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+ ARMVCCThen, (VTI.Pred VCCR:$mask),
+ (VTI.Vec MQPR:$inactive)))>;
   }
 }
 
@@ -1633,20 +1631,19 @@
 multiclass MVE_VMUL_m {
   def "" : MVE_VMULt1;
+  defvar Inst = !cast(NAME);
 
   let Predicates = [HasMVEInt] in {
 // Unpredicated multiply
 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
 
 // Predicated multiply
 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
 (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
-  (VTI.Vec (!cast(NAME)
-(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
-ARMVCCThen, (VTI.Pred VCCR:$mask),
-(VTI.Vec MQPR:$inactive)))>;
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+ ARMVCCThen, (VTI.Pred VCCR:$mask),
+ (VTI.Vec MQPR:$inactive)))>;
   }
 }
 
@@ -1673,20 +1670,19 @@
   SDNode unpred_op, Intrinsic pred_int,
   bit rounding> {
   def "" : MVE_VQxDMULH_Base;
+  defva

[PATCH] D71607: [clang-tidy] Add unsigned subtraction warning, with suggestion to convert to unsigned literals.

2020-01-14 Thread Jeffrey Sorensen via Phabricator via cfe-commits
sorenj added a comment.

Anything further needed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71607



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


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 237934.
kadircet added a comment.

- Per offline discussions, do post processing to get rid of multiple ruler 
occurences.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1700,6 +1700,7 @@
 HI.NamespaceScope.emplace();
   },
   R"(class foo
+
 documentation
 
 template  class Foo {})",
@@ -1723,6 +1724,7 @@
 HI.Definition = "ret_type foo(params) {}";
   },
   R"(function foo → ret_type
+
 - 
 - type
 - type foo
@@ -1741,6 +1743,7 @@
 HI.Definition = "def";
   },
   R"(variable foo : type
+
 Value = value
 
 // In test::bar
@@ -1777,6 +1780,30 @@
   EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
 }
 
+// This is a separate test as rulers behave differently in markdown vs
+// plaintext.
+TEST(Hover, PresentRulers) {
+  HoverInfo HI;
+  HI.Kind = index::SymbolKind::Variable;
+  HI.Name = "foo";
+  HI.Value = "val";
+  HI.Definition = "def";
+
+  EXPECT_EQ(HI.present().asMarkdown(), R"md(### variable `foo`  
+
+---
+Value \= `val`  
+
+---
+```cpp
+def
+```)md");
+  EXPECT_EQ(HI.present().asPlainText(), R"pt(variable foo
+
+Value = val
+
+def)pt");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -136,13 +136,37 @@
   EXPECT_EQ(D.asPlainText(), ExpectedText);
 }
 
-TEST(Document, Spacer) {
+TEST(Document, Ruler) {
   Document D;
   D.addParagraph().appendText("foo");
-  D.addSpacer();
+  D.addRuler();
+
+  // Ruler followed by paragraph.
   D.addParagraph().appendText("bar");
-  EXPECT_EQ(D.asMarkdown(), "foo  \n\nbar");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nbar");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addCodeBlock("bar");
+  // Ruler followed by a codeblock.
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n```cpp\nbar\n```");
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  // Ruler followed by another ruler
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addRuler();
+  EXPECT_EQ(D.asMarkdown(), "foo");
+  EXPECT_EQ(D.asPlainText(), "foo");
+
+  // Multiple rulers between blocks
+  D.addRuler();
+  D.addParagraph().appendText("foo");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nfoo");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nfoo");
 }
 
 TEST(Document, Heading) {
@@ -182,15 +206,11 @@
 foo
 ```)md";
   EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
-  // FIXME: we shouldn't have 2 empty lines in between. A solution might be
-  // having a `verticalMargin` method for blocks, and let container insert new
-  // lines according to that before/after blocks.
   ExpectedPlainText =
   R"pt(foo
   bar
   baz
 
-
 foo)pt";
   EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -542,6 +542,8 @@
 Header.appendCode(*Type);
   }
 
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();
   // For functions we display signature in a list form, e.g.:
   // - `bool param1`
   // - `int param2 = 5`
@@ -565,6 +567,7 @@
 Output.addParagraph().appendText(Documentation);
 
   if (!Definition.empty()) {
+Output.addRuler();
 std::string ScopeComment;
 // Drop trailing "::".
 if (!LocalScope.empty()) {
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -33,6 +33,12 @@
   std::string asMarkdown() const;
   std::string asPlainText() const;
 
+  /// Padding information to imitate spacing while rendering for plaintext. As
+  /// markdown renderers should already add appropriate padding between
+  /// different blocks.
+  virtual bool hasTrailingPadding() const { return false; }
+  virtual bool requiresPrecedingPadding() const { return false; }
+
   virtual ~Block() = default;
 };
 
@@ -82,8 +88,8 @@
 public:
   /// Adds a semantical bl

[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61819 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622



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


[PATCH] D71174: [clang-tidy] new check: bugprone-signed-char-misuse

2020-01-14 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas added a comment.

In D71174#1818883 , @sylvestre.ledru 
wrote:

> In D71174#1774249 , @ztamas wrote:
>
> > I run the new check on LibreOffice codebase with the option 
> > CharTypdefsToIgnore = "sal_Int8".
> >  The check produced 32 findings.
>
>
> Interesting. It found 31 issues on the Firefox code base!
>  I can share the list if you are interested!


Yes, share it, please! It would be very useful to see how the check works on 
another project.

In D71174#1818883 , @sylvestre.ledru 
wrote:

> In D71174#1774249 , @ztamas wrote:
>
> > I run the new check on LibreOffice codebase with the option 
> > CharTypdefsToIgnore = "sal_Int8".
> >  The check produced 32 findings.
>
>
> Interesting. It found 31 issues on the Firefox code base!
>  I can share the list if you are interested!





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71174



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


[PATCH] D72624: [WIP] TargetMachine Hook for Module Metadata

2020-01-14 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen added a comment.

In D72624#1818605 , @khchen wrote:

> I think putting the resetTargetDefaultOptions after instance of TargetMachine 
> is too late.
>  for example: 
>  ppc 
> 
>  and mips 
> 
>  compute the TargetABI in TargetMachine constructor. In addition , mips 
> 
>  compute the DataLayout with target ABI in TargetMachine constructor.


Sorry, I didn't notice the resetTargetDefaultOptions is a virtual function, so 
the backend need to care this issue themselves if they want take this approach. 
I think this approach is better than D72245 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72624



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


[clang] df18650 - Make helper functions static or move them into anonymous namespaces. NFC.

2020-01-14 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-01-14T14:06:37+01:00
New Revision: df186507e1d07c3ddba091a076ba7a33dbdc5867

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

LOG: Make helper functions static or move them into anonymous namespaces.  NFC.

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
mlir/lib/Analysis/AffineAnalysis.cpp
mlir/lib/Analysis/AffineStructures.cpp
mlir/lib/Analysis/Liveness.cpp
mlir/lib/Analysis/Utils.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Dialect/AffineOps/AffineOps.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/lib/Dialect/Linalg/Transforms/LinalgToLoops.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/LoopOps/LoopOps.cpp
mlir/lib/Dialect/QuantOps/Transforms/ConvertSimQuant.cpp
mlir/lib/Dialect/SDBM/SDBMExpr.cpp
mlir/lib/Dialect/SPIRV/SPIRVDialect.cpp
mlir/lib/Dialect/SPIRV/Serialization/TranslateRegistration.cpp
mlir/lib/Dialect/VectorOps/VectorOps.cpp
mlir/lib/Dialect/VectorOps/VectorTransforms.cpp
mlir/lib/ExecutionEngine/ExecutionEngine.cpp
mlir/lib/IR/SymbolTable.cpp
mlir/lib/Pass/PassStatistics.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/test/lib/TestDialect/TestPatterns.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f6c3aa1a3c1d..8eb58b32ae17 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3081,7 +3081,7 @@ Error 
ASTNodeImporter::ImportFunctionDeclBody(FunctionDecl *FromFD,
 
 // Returns true if the given D has a DeclContext up to the TranslationUnitDecl
 // which is equal to the given DC.
-bool isAncestorDeclContextOf(const DeclContext *DC, const Decl *D) {
+static bool isAncestorDeclContextOf(const DeclContext *DC, const Decl *D) {
   const DeclContext *DCi = D->getDeclContext();
   while (DCi != D->getTranslationUnitDecl()) {
 if (DCi == DC)

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7b2b0336c32a..09fd3087b494 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14260,6 +14260,7 @@ CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned 
BuiltinID, const CallExpr *E) {
   }
 }
 
+namespace {
 struct BuiltinAlignArgs {
   llvm::Value *Src = nullptr;
   llvm::Type *SrcType = nullptr;
@@ -14288,6 +14289,7 @@ struct BuiltinAlignArgs {
 Mask = CGF.Builder.CreateSub(Alignment, One, "mask");
   }
 };
+} // namespace
 
 /// Generate (x & (y-1)) == 0.
 RValue CodeGenFunction::EmitBuiltinIsAligned(const CallExpr *E) {

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 0d96c5a2f73f..97b17799a03e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1438,6 +1438,7 @@ CGOpenMPRuntime::getUserDefinedReduction(const 
OMPDeclareReductionDecl *D) {
   return UDRMap.lookup(D);
 }
 
+namespace {
 // Temporary RAII solution to perform a push/pop stack event on the OpenMP IR
 // Builder if one is present.
 struct PushAndPopStackRAII {
@@ -1481,6 +1482,7 @@ struct PushAndPopStackRAII {
   }
   llvm::OpenMPIRBuilder *OMPBuilder;
 };
+} // namespace
 
 static llvm::Function *emitParallelOrTeamsOutlinedFunction(
 CodeGenModule &CGM, const OMPExecutableDirective &D, const CapturedStmt 
*CS,
@@ -11122,8 +11124,8 @@ bool checkContext(
   return true;
 }
 
-bool matchesContext(CodeGenModule &CGM,
-const CompleteOMPContextSelectorData &ContextData) {
+static bool matchesContext(CodeGenModule &CGM,
+   const CompleteOMPContextSelectorData &ContextData) {
   for (const OMPContextSelectorData &Data : ContextData) {
 switch (Data.Ctx) {
 case OMP_CTX_vendor:

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index ae1d7eaf7089..a1923e731489 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -63,9 +63,9 @@ static void getARMHWDivFeatures(const Driver &D, const Arg *A,
 }
 
 // Han

[PATCH] D71467: [FPEnv] Generate constrained FP comparisons from clang

2020-01-14 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D71467#1817939 , @rjmccall wrote:

> Is this approach going to work with scope-local strictness?  We need a way to 
> do a comparison that has the non-strict properties but appears in a function 
> that enables strictness elsewhere.


Well, just like for all the other FP builder methods, you can use the 
setIsFPConstrained method on the builder object to switch between strict and 
non-strict mode.   Does this not suffice, or is there anything particular about 
the comparisons that would require anything extra?

> Please document the difference between these two methods.

OK, checked in header file comments as 6aca3e8 
.

> Can you make a helper method for the common code in the non-constrained paths 
> here?

Would you prefer something like

  private:
Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
const Twine &Name, MDNode *FPMathTag) {
  if (auto *LC = dyn_cast(LHS))
if (auto *RC = dyn_cast(RHS))
  return Insert(Folder.CreateFCmp(P, LC, RC), Name);
  return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), 
Name);
}
  
  public:
Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
  const Twine &Name = "", MDNode *FPMathTag = nullptr) {
  if (IsFPConstrained)
return CreateConstrainedFPCmp(Intrinsic::experimental_constrained_fcmp,
  P, LHS, RHS, Name);
  
  return CreateFCmpHelper(P, LHS, RHS, Name, FPMathTag);
}
[...]

or rather something like:

  private:
Value *CreateFCmpHelper(CmpInst::Predicate P, Value *LHS, Value *RHS,
bool IsSignaling, const Twine &Name, MDNode 
*FPMathTag) {
  if (IsFPConstrained)
return CreateConstrainedFPCmp(IsSignaling ? 
Intrinsic::experimental_constrained_fcmps
  : 
Intrinsic::experimental_constrained_fcmp,
  P, LHS, RHS, Name);
  
  if (auto *LC = dyn_cast(LHS))
if (auto *RC = dyn_cast(RHS))
  return Insert(Folder.CreateFCmp(P, LC, RC), Name);
  return Insert(setFPAttrs(new FCmpInst(P, LHS, RHS), FPMathTag, FMF), 
Name);
}
  
  public:
Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
  const Twine &Name = "", MDNode *FPMathTag = nullptr) {
  return CreateFCmpHelper(P, LHS, RHS, false, Name, FPMathTag);
}
[...]

or maybe simply have CreateFCmpS call CreateFCmp directly in the non-strict 
case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71467



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


[PATCH] D68115: Zero initialize padding in unions

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

In D68115#1811091 , @lebedev.ri wrote:

> In D68115#1811089 , 
> @hubert.reinterpretcast wrote:
>
> > In D68115#1810891 , @lebedev.ri 
> > wrote:
> >
> > > Does this have to be an unilateral change,
> > >  likely penalizing non-`-ftrivial-auto-var-init=` cases,
> > >  i.e. [why] can't it be **only** done for when `-ftrivial-auto-var-init=` 
> > > is enabled?
> >
> >
> > We left off near that conclusion (https://reviews.llvm.org/D68115#1686887);
>
>
> Would be great if @rsmith / @aaron.ballman could comment on that


I don't have super strong opinions on it, but I think a separate feature for 
zeroing union padding is what gives users the most flexibility.

In D68115#1811089 , 
@hubert.reinterpretcast wrote:

> A separate option to control zeroing for union padding would help in cases 
> where the zeroing does not happen for reasons other than 
> `-ftrivial-auto-var-init`.


Agreed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115



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


[PATCH] D72518: [clang] New __attribute__((__clang_arm_mve_strict_polymorphism)).

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



Comment at: clang/include/clang/Basic/Attr.td:1473
 
+def ArmMveStrictPolymorphism : TypeAttr {
+  let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];

Should this be a target-specific attribute?



Comment at: clang/include/clang/Basic/Attr.td:1474
+def ArmMveStrictPolymorphism : TypeAttr {
+  let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
+  let Documentation = [ArmMveStrictPolymorphismDocs];

Why does this have a `__clang` prefix? That seems a bit strange given that the 
attribute can be spelled `[[clang::__clang_arm_mve_strict_polymorphism]]`. I'd 
probably drop the `__clang_` prefix entirely.



Comment at: clang/include/clang/Basic/AttrDocs.td:4793
+conversion. The aim is to prevent spurious ambiguity in ARM MVE polymorphic
+intrinsics.
+

I think adding a code example of correct vs erroneous code would be useful.



Comment at: clang/include/clang/Basic/AttrDocs.td:4796
+However, this attribute does not prohibit lax vector conversions in contexts
+other than overloading.
+}];

If you have an easy code example demonstrating this, that would be useful as 
well.



Comment at: clang/lib/Sema/SemaType.cpp:7548
+  ASTContext &Ctx = state.getSema().Context;
+  type = state.getAttributedType(
+  createSimpleAttr(Ctx, attr), type,

So this attribute can be written on any type? I would have expected it to be 
limited to just types that can interact through vector operations. Does it make 
sense to declare, for instance, a struct having this type?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72518



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


[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

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

Do you need someone to commit this on your behalf? (If you plan to continue 
contributing, which I hope you do, it may be a good time for you to obtain 
commit privileges: 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access but I am 
happy to commit on your behalf if you'd prefer.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[clang] 25dc5c7 - Fix "pointer is null" static analyzer warnings. NFCI.

2020-01-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-14T14:00:37Z
New Revision: 25dc5c7cd159522ec2375544f473c757ee13a03b

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

LOG: Fix "pointer is null" static analyzer warnings. NFCI.

Use castAs<> instead of getAs<> since the pointer is dereferenced immediately 
below and castAs will perform the null assertion for us.

Added: 


Modified: 
clang/lib/CodeGen/CGObjC.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 3c11aa7f2f42..c52aa6bb5496 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -488,7 +488,7 @@ tryEmitSpecializedAllocInit(CodeGenFunction &CGF, const 
ObjCMessageExpr *OME) {
 Receiver = CGF.EmitScalarExpr(SelfInClassMethod);
   } else {
 QualType ReceiverType = SubOME->getClassReceiver();
-const ObjCObjectType *ObjTy = ReceiverType->getAs();
+const ObjCObjectType *ObjTy = ReceiverType->castAs();
 const ObjCInterfaceDecl *ID = ObjTy->getInterface();
 assert(ID && "null interface should be impossible here");
 Receiver = CGF.CGM.getObjCRuntime().GetClass(CGF, ID);
@@ -555,9 +555,7 @@ RValue CodeGenFunction::EmitObjCMessageExpr(const 
ObjCMessageExpr *E,
 
   case ObjCMessageExpr::Class: {
 ReceiverType = E->getClassReceiver();
-const ObjCObjectType *ObjTy = ReceiverType->getAs();
-assert(ObjTy && "Invalid Objective-C class message send");
-OID = ObjTy->getInterface();
+OID = ReceiverType->castAs()->getInterface();
 assert(OID && "Invalid Objective-C class message send");
 Receiver = Runtime.GetClass(*this, OID);
 isClassMessage = true;



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


[clang] 7ec7a6e - Fix "null pointer passed to nonnull argument" clang static analyzer warnings. NFCI.

2020-01-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-14T14:00:36Z
New Revision: 7ec7a6e5bfa745c285d5c651af02b93f2cb923e1

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

LOG: Fix "null pointer passed to nonnull argument" clang static analyzer 
warnings. NFCI.

Assert that the memcpy arguments are valid.

Added: 


Modified: 
clang/lib/AST/NestedNameSpecifier.cpp

Removed: 




diff  --git a/clang/lib/AST/NestedNameSpecifier.cpp 
b/clang/lib/AST/NestedNameSpecifier.cpp
index 09d85102585b..137953fa8203 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -472,7 +472,7 @@ TypeLoc NestedNameSpecifierLoc::getTypeLoc() const {
 }
 
 static void Append(char *Start, char *End, char *&Buffer, unsigned &BufferSize,
-  unsigned &BufferCapacity) {
+   unsigned &BufferCapacity) {
   if (Start == End)
 return;
 
@@ -489,9 +489,9 @@ static void Append(char *Start, char *End, char *&Buffer, 
unsigned &BufferSize,
 Buffer = NewBuffer;
 BufferCapacity = NewCapacity;
   }
-
+  assert(Buffer && Start && End && End > Start && "Illegal memory buffer 
copy");
   memcpy(Buffer + BufferSize, Start, End - Start);
-  BufferSize += End-Start;
+  BufferSize += End - Start;
 }
 
 /// Save a source location to the given buffer.



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


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-14 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This broke NetBSD buildbot:

  + : 'RUN: at line 1'
  + env -u CLANG_SPAWN_CC1 /home/motus/netbsd8/netbsd8/build-stage2/bin/clang 
-c 
/data/motus/netbsd8/netbsd8/llvm-project/clang/test/Driver/cc1-spawnprocess.c 
-o /dev/null
  env: unknown option -- u
  Usage: env [-i] [name=value ...] [command]

Please fix.




Comment at: clang/test/Driver/cc1-spawnprocess.c:1
+// RUN: env -u CLANG_SPAWN_CC1 %clang -c %s -o /dev/null
+// RUN: env CLANG_SPAWN_CC1=0 %clang -c %s -o /dev/null

`env -u` is not portable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69825



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


[PATCH] D72488: [clang-tidy] Add check for CERT-OOP57-CPP

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



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:33-44
+static const char BuiltinMemSet[] = "::std::memset;"
+"::memset;";
+static const char BuiltinMemCpy[] = "::std::memcpy;"
+"::memcpy;"
+"::std::memmove;"
+"::memmove;"
+"::std::strcpy;"

I think these should also include the `w` variants of the calls.

Other APIs to consider: `strncmp`, `strncpy`, and `memccpy` (note the extra `c` 
in the name) as all of these are part of the C standard these days.

You may also want to look through the POSIX docs to see if we should add those 
APIs as well 
(https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/string.h.html)



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:45
+"::strcmp;";
+static constexpr llvm::StringRef EqualityComparison[] = {"operator==",
+ "operator!="};

Was there a reason you were not also looking for the relational operators like 
`<` or `>`?



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:55-57
+static std::vector toStringRefVec(const 
std::vector & Items){
+  return std::vector(Items.begin(), Items.end());
+}

The formatting looks off here, but I would prefer if we could find a way to 
remove this code entirely. It looks very dangerous (`StringRef` is a non-owning 
data type) and also seems wasteful (you need two copies of the vector in memory 
at once).

The way it's being used seems to be safe and functional, but this still feels 
unclean.



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:75
+MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

I think this should probably also be disabled for ObjC. The CERT rule doesn't 
cover it, and I don't know enough about the "right way" to perform the 
comparisons there.



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:102
+
+  auto IsIntZero = expr(integerLiteral(equals(0)));
+

This can be lowered into its only use.



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:126
+  if (const auto *Caller = Result.Nodes.getNodeAs("lazyConstruct")) {
+diag(Caller->getBeginLoc(), "Calling '%0' on a non trivially default "
+"constructible class is undefined")

Calling -> calling
non trivially -> non-trivially

(Same comments apply to the other diagnostics.)



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.cpp:128
+"constructible class is undefined")
+<< getName(*Caller);
+  }

Rather than calling `getName()`, you can pass in the `NamedDecl*` directly and 
the diagnostic engine handles properly printing the name. e.g. 
`getName(*Caller)` should be `cast(Caller->getCalleeDecl())`



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.h:18
+
+/// This check flags use of the c standard library functions 'memset', 
'memcpy',
+/// 'memmove', 'strcpy', 'memcmp' and 'strcmp' on non trivial types.

c -> C



Comment at: 
clang-tools-extra/clang-tidy/cert/NotTrivialTypesLibcMemoryCallsCheck.h:23
+/// http://clang.llvm.org/extra/clang-tidy/checks/cert-oop57-cpp.html
+class NotTrivialTypesLibcMemoryCallsCheck : public ClangTidyCheck {
+public:

I prefer the file to be named `NonTrivialTypesLibcMemoryCallsCheck.h` -- the 
`Not` looks strange to my eyes. Same for the class name.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-oop57-cpp.rst:12
+
+.. option:: MemSetNames
+

You should specify that all of these options take a semicolon-delimited list of 
names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72488



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


[PATCH] D71966: [Wdocumentation][RFC] Improve identifier's of \param

2020-01-14 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Thank you for the patch!




Comment at: clang/docs/ReleaseNotes.rst:68
+- -Wdocumentation properly handles Doxygen comments with multiple identifiers 
in
+  one \param command. The validation whether the name of the identifier is 
valid
+  has been improved.

validation *of*



Comment at: clang/docs/ReleaseNotes.rst:360
+- Function ``clang_ParamCommandComment_getNumParams`` has been added to
+  determine the number of parameters to a single Doxygen \param command.p
+- Function ``clang_ParamCommandComment_isVarArgParam`` has been added to

Need backticks around \param. Also a spurious "p" at the end of the line.



Comment at: clang/include/clang-c/Documentation.h:383
 CINDEX_LINKAGE
-CXString clang_ParamCommandComment_getParamName(CXComment Comment);
 

Please don't modify existing APIs in libclang -- it provides a stable API and 
ABI, and what has shipped, can't be changed. New functionality has to be 
exposed as new functions, while old functions should be kept working to the 
extent possible. It means that the resulting API can be subpar, but oh well, a 
stable ABI is a contract of libclang.



Comment at: clang/include/clang/AST/Comment.h:715
 private:
-  /// Parameter index in the function declaration.
-  unsigned ParamIndex;
+  /// The index of the identifier in the function declaration.
+  MutableArrayRef ParamIndex;

"Indices of the parameters referenced by this command in the function 
declaration."



Comment at: clang/include/clang/AST/Comment.h:763
 
-  StringRef getParamName(const FullComment *FC) const;
+  void setParamIndex(MutableArrayRef Idx) {
+assert(ParamIndex.empty() && "Can't initialize more than once.");

`setParamIndices`



Comment at: clang/include/clang/AST/Comment.h:781
+  /// @param Idx The index of the identifier in the \\param command.
+  StringRef getParamName(unsigned Idx) const LLVM_READONLY {
+return getArgText(Idx);

Users can already call getArgText, do we need a second function that does the 
same?



Comment at: clang/include/clang/AST/Comment.h:793
+
+  SourceRange getParamRange(unsigned Idx) const LLVM_READONLY {
+return getArgRange(Idx);

Ditto, duplicated API.



Comment at: clang/include/clang/AST/Comment.h:797
 
-  void setIsVarArgParam() {
-ParamIndex = VarArgParamIndex;
-assert(isParamIndexValid());
+  const Argument *getParam(unsigned Idx) const LLVM_READONLY {
+assert(Idx < Args.size());

I'd call it `getArgument` and define it in `BlockCommandComment`.



Comment at: clang/include/clang/AST/Comment.h:804
+assert(Idx < ParamIndex.size());
+return !isVarArgParam(Idx) && ParamIndex[Idx] != InvalidParamIndex;
   }

Why does vararg have an invalid index? Previously it was considered valid.



Comment at: clang/include/clang/AST/CommentSema.h:111
+  void
+  actOnParamCommandParamNameArg(ParamCommandComment *Command,
+ArrayRef Args);

s/NameArg/NameArgs/



Comment at: clang/include/clang/Basic/DiagnosticCommentKinds.td:113
+def warn_doc_param_undocumented : Warning<
+  "parameter '%0' is not documented">,
+  InGroup, DefaultIgnore;

This warning should be in a separate group. `-Wdocumentation` contains 
generally useful, non-controversial stuff (that would have been an error if 
documentation comments were a part of the language). Warning about every 
undocumented parameter is only useful for certain style guides.

(Digression: And even then, I personally question the value of a style rule 
that requires every parameter (or every public API, or every file, or every 
whatever else) to be documented. Unless there's a tech writer on the team, in 
response to a such rule engineers are highly likely just to write useless 
comments like "\param frobnicator The Frobnicator necessary for this call." 
Engineers are already doing the best they can when writing comments. The choice 
we have is not between "no comments for some parameters" and "good comments for 
every parameter because the warning reminded you", it is between "no comments 
for some parameters" and "placeholder stuff that people will write to make the 
warning go away".)

I'd also suggest to implement this functionality in a separate patch.



Comment at: clang/lib/AST/Comment.cpp:376
+  case InvalidParamIndex:
+return getParamName(Idx);
+

Previously, it was necessary for the index to be valid. Why relax the contract? 
(This change also makes things in consistent with, say, TParam).



Comment at: clang/lib/AST/CommentParser.cpp:362
+  do {
+if (Retokenizer.lexIdentifier(Arg)) {
+  ArgumentTokens.push_back(Arg

[PATCH] D72378: [clang-tidy] Add `bugprone-reserved-identifier`

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

I think this patch is getting pretty close to finished -- have you tried 
running it over a large corpus of code to see if it spots reserved identifiers 
(or unreserved ones)? If not, I would recommend running it over LLVM + clang + 
clang-tools-extra to see how it operates when looking for reserved identifiers 
and libc++ for unreserved ones.




Comment at: 
clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp:27-34
+static const char NonReservedMessage[] =
+"declaration uses identifier '%0', which is not a reserved "
+"identifier";
+static const char GlobalUnderscoreMessage[] =
+"declaration uses identifier '%0', which is reserved in the global "
+"namespace; this causes undefined behavior";
+static const char DefaultMessage[] = "declaration uses reserved identifier "

I think you can reasonably combine these into a single diagnostic using 
`%select`. e.g.,
`"declaration uses identifier %0, which is %select{a reserved identifier|not a 
reserved identifier|reserved in the global namespace}1"`

I took out the bits about causing undefined behavior because that doesn't 
really add much to the diagnostic (the "is a reserved identifier" bit should be 
sufficient). Also, I removed the manual quoting around the `%0` because it 
shouldn't be needed if you pass in a `NamedDecl*` as opposed to a string (which 
you should prefer doing because it automatically formats the identifier 
properly).



Comment at: clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp:65
+getDoubleUnderscoreFixup(StringRef Name, const LangOptions &LangOpts) {
+  if (hasReservedDoubleUnderscore(Name, LangOpts)) {
+return collapseConsecutive(Name, '_');

Elide braces.



Comment at: clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h:35
+  const bool Invert;
+  const std::vector Whitelist;
+

Personal preference to name this `AllowedIdentifiers` or something along those 
lines (and same for the user-facing option).



Comment at: clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h:42
+
+protected:
+  llvm::Optional

This class is marked `final`, so why are these `protected` rather than 
`private`?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-reserved-identifier.rst:8
+
+Checks for usages of identifiers reserved for use by the implementation. 
+

You should mention that it currently does not check for all reserved names such 
as future library or zombie names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72378



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


[clang] 92451f0 - [OpenCL] Add MSAA sharing extension builtin functions

2020-01-14 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-01-14T14:46:42Z
New Revision: 92451f0904ceab1d81d71a9f17ab366bf57eddc7

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

LOG: [OpenCL] Add MSAA sharing extension builtin functions

Add the MSAA sharing builtin functions from the OpenCL Extension
Specification.

Patch by Pierre Gondois and Sven van Haastregt.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index d4c473e2a68f..9d6bb411eff8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -60,6 +60,7 @@ def FuncExtKhrLocalInt32ExtendedAtomics  : 
FunctionExtension<"cl_khr_local_int32
 def FuncExtKhrInt64BaseAtomics   : 
FunctionExtension<"cl_khr_int64_base_atomics">;
 def FuncExtKhrInt64ExtendedAtomics   : 
FunctionExtension<"cl_khr_int64_extended_atomics">;
 def FuncExtKhrMipmapImage: 
FunctionExtension<"cl_khr_mipmap_image">;
+def FuncExtKhrGlMsaaSharing  : 
FunctionExtension<"cl_khr_gl_msaa_sharing">;
 
 // Multiple extensions
 def FuncExtKhrMipmapAndWrite3d   : 
FunctionExtension<"cl_khr_mipmap_image cl_khr_3d_image_writes">;
@@ -1312,3 +1313,39 @@ let Extension = FuncExtKhrMipmapImage in {
 }
   }
 }
+
+
+//
+// OpenCL Extension v2.0 s18.3 - Creating OpenCL Memory Objects from OpenGL 
MSAA Textures
+let Extension = FuncExtKhrGlMsaaSharing in {
+  // --- Table 6.13.14.3 ---
+  foreach aQual = ["RO", "RW"] in {
+foreach imgTy = [Image2dMsaa] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+}
+foreach imgTy = [Image2dArrayMsaa] in {
+  def : Builtin<"read_imagef", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imagei", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+  def : Builtin<"read_imageui", [VectorType, ImageType, VectorType, Int], Attr.Pure>;
+}
+foreach name = ["read_imagef"] in {
+  def : Builtin, 
VectorType, Int], Attr.Pure>;
+  def : Builtin, 
VectorType, Int], Attr.Pure>;
+}
+  }
+
+  // --- Table 6.13.14.5 ---
+  foreach aQual = ["RO", "WO", "RW"] in {
+foreach imgTy = [Image2dMsaa, Image2dArrayMsaa, Image2dMsaaDepth, 
Image2dArrayMsaaDepth] in {
+  foreach name = ["get_image_width", "get_image_height",
+  "get_image_channel_data_type", "get_image_channel_order",
+  "get_image_num_samples"] in {
+def : Builtin], Attr.Const>;
+  }
+  def : Builtin<"get_image_dim", [VectorType, ImageType], Attr.Const>;
+}
+def : Builtin<"get_image_array_size", [Size, 
ImageType], Attr.Const>;
+  }
+}



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


[PATCH] D72691: [clang-tidy] Match InitListExpr in modernize-use-default-member-init

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72691



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


[PATCH] D65616: Ignore -fsemantic-interposition/-fno-semantic-interposition flag for gcc compatibility

2020-01-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

(back on that one) The default in clang is implicitly 
`-fno-semantic-interposition`. I think we can safely support it, and either 
warn or error on  `-fsemantic-interposition`. @hfinkel does that seem correct 
to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65616



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


[PATCH] D72703: Add a warning, flags and pragmas to limit the number of pre-processor tokens in a translation unit

2020-01-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk, rsmith.

See 
https://docs.google.com/document/d/1xMkTZMKx9llnMPgso0jrx3ankI4cv60xeZ0y4ksf4wc/preview
 for background discussion.

This adds a warning, flags and pragmas to limit the number of pre-processor 
tokens either at a certain point in a translation unit, or overall.

The idea is that this would allow projects to limit the size of certain widely 
included headers, or for translation units overall, as a way to insert 
backstops for header bloat and prevent compile-time regressions.

What do you think?


https://reviews.llvm.org/D72703

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Parse/Parser.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Parser/max-tokens.cpp

Index: clang/test/Parser/max-tokens.cpp
===
--- /dev/null
+++ clang/test/Parser/max-tokens.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS  -fmax-tokens 2
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DMAX_TOKENS_OVERRIDE -fmax-tokens 9
+
+int x, y, z;
+
+#pragma clang max_tokens // expected-error  {{missing argument to '#pragma clang max_tokens'; expected integer}}
+#pragma clang max_tokens foo // expected-error  {{expected an integer argument in '#pragma clang max_tokens'}}
+#pragma clang max_tokens 123 456 // expected-warning{{extra tokens at end of '#pragma clang max_tokens' - ignored}}
+
+#pragma clang max_tokens 1 // expected-warning{{the number of preprocessor source tokens (7) exceeds this token limit (1)}}
+
+
+#pragma clang max_file_tokens // expected-error{{missing argument to '#pragma clang max_file_tokens'; expected integer}}
+#pragma clang max_file_tokens foo // expected-error{{expected an integer argument in '#pragma clang max_file_tokens'}}
+#pragma clang max_file_tokens 123 456 // expected-warning{{extra tokens at end of '#pragma clang max_file_tokens' - ignored}}
+
+#ifdef MAX_TOKENS_OVERRIDE
+#pragma clang max_file_tokens 3 // expected-warning@+4{{the number of preprocessor source tokens in this file (8) exceeds the token limit (3)}}
+// expected-note@-1{{file token limit set here}}
+#elif MAX_TOKENS
+// expected-warning@+1{{the number of preprocessor source tokens in this file (8) exceeds the token limit (2)}}
+#endif
Index: clang/test/Driver/autocomplete.c
===
--- clang/test/Driver/autocomplete.c
+++ clang/test/Driver/autocomplete.c
@@ -99,6 +99,7 @@
 // WARNING-NEXT: -Wmain-return-type
 // WARNING-NEXT: -Wmalformed-warning-check
 // WARNING-NEXT: -Wmany-braces-around-scalar-init
+// WARNING-NEXT: -Wmax-tokens
 // WARNING-NEXT: -Wmax-unsigned-zero
 // RUN: %clang --autocomplete=-Wno-invalid-pp- | FileCheck %s -check-prefix=NOWARNING
 // NOWARNING: -Wno-invalid-pp-token
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -650,6 +650,16 @@
 return false;
 
   case tok::eof:
+// Check whether -fmax-tokens was reached.
+if (PP.getTokenCount() > PP.getMaxTokens()) {
+  PP.Diag(Tok.getLocation(), diag::warn_max_tokens_file)
+  << PP.getTokenCount() << PP.getMaxTokens();
+  SourceLocation OverrideLoc = PP.getMaxTokensOverrideLoc();
+  if (OverrideLoc.isValid()) {
+PP.Diag(OverrideLoc, diag::note_max_tokens_file_override);
+  }
+}
+
 // Late template parsing can begin.
 if (getLangOpts().DelayedTemplateParsing)
   Actions.SetLateTemplateParser(LateTemplateParserCallback,
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -262,6 +262,18 @@
   ParsedAttributes AttributesForPragmaAttribute;
 };
 
+struct PragmaMaxTokensHandler : public PragmaHandler {
+  PragmaMaxTokensHandler() : PragmaHandler("max_tokens") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
+Token &FirstToken) override;
+};
+
+struct PragmaMaxFileTokensHandler : public PragmaHandler {
+  PragmaMaxFileTokensHandler() : PragmaHandler("max_file_tokens") {}
+  void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
+Token &FirstToken) override;
+};
+
 }  // end namespace
 
 void Parser::initializePragmaHandlers() {
@@ -382,6 +394,12 @@
   AttributePragmaHandler =
   std::make_unique(AttrFactory);
   

[clang-tools-extra] 9738c75 - [clang-tidy] Match InitListExpr in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via cfe-commits

Author: Malcolm Parsons
Date: 2020-01-14T15:19:37Z
New Revision: 9738c757bd9bc2fdca935f2b4e356f1d5e5f3682

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

LOG: [clang-tidy] Match InitListExpr in modernize-use-default-member-init

Summary:
modernize-use-default-member-init wasn't warning about redundant initialisers
when the initialiser was an InitListExpr.  Add initListExpr to the matcher.

Fixes: PR44439

Reviewers: aaron.ballman, alexfh, JonasToth

Reviewed By: aaron.ballman

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index e99a90ffba57..5d62e5446f6a 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -201,7 +201,7 @@ void 
UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
 unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")),
   hasUnaryOperand(floatLiteral())),
 cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-declRefExpr(to(enumConstantDecl(;
+initListExpr(), declRefExpr(to(enumConstantDecl(;
 
   Finder->addMatcher(
   cxxConstructorDecl(

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
index 0dffeea1c9b7..196eec91b8e8 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -247,24 +247,24 @@ struct NegativeDefaultArg
 };
 
 struct ExistingChar {
-  ExistingChar(short) : e1(), e2(), e3(), e4() {}
+  ExistingChar(short) : e1(), e2{}, e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:31: warning: member initializer for 'e2' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is 
redundant
   // CHECK-FIXES: ExistingChar(short) :  e4() {}
-  ExistingChar(int) : e1(0), e2(0), e3(0), e4(0) {}
+  ExistingChar(int) : e1(0), e2{0}, e3(0), e4(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: member initializer for 'e1' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is 
redundant
   // CHECK-FIXES: ExistingChar(int) :  e4(0) {}
-  ExistingChar(long) : e1('\0'), e2('\0'), e3('\0'), e4('\0') {}
+  ExistingChar(long) : e1('\0'), e2{'\0'}, e3('\0'), e4('\0') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:44: warning: member initializer for 'e3' is 
redundant
   // CHECK-FIXES: ExistingChar(long) :  e4('\0') {}
-  ExistingChar(char) : e1('a'), e2('a'), e3('a'), e4('a') {}
+  ExistingChar(char) : e1('a'), e2{'a'}, e3('a'), e4('a') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: member initializer for 'e4' is 
redundant
-  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2('a'), e3('a') {}
+  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2{'a'}, e3('a') {}
   char e1{};
   char e2 = 0;
   char e3 = '\0';
@@ -272,22 +272,22 @@ struct ExistingChar {
 };
 
 struct ExistingInt {
-  ExistingInt(short) : e1(), e2(), e3(), e4(), e5(), e6() {}
+  ExistingInt(short) : e1(), e2{}, e3(), e4(), e5(), e6() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is 
redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is 
redundant
   // CHECK-FIXES: ExistingInt(short) :  e3(), e4(), e5(), e6() {}
-  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0), e5(0), e6(0) {}
+  ExistingInt(int) : e1(0), e2{0}, e3(0), e4(0), e5(0), e6(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is 
redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is 
redundant
   // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0), e5(0), e6(0) {}
-  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5), e5(5), e6(5) {}
+  ExistingInt

[clang] 3b929fe - [Syntax] Assert invariants on tree structure and fix a bug in mutations

2020-01-14 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2020-01-14T16:31:08+01:00
New Revision: 3b929fe7763570fc1d4a4691a53257a4a0b7760e

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

LOG: [Syntax] Assert invariants on tree structure and fix a bug in mutations

Add checks for some structural invariants when building and mutating
the syntax trees.

Fix a bug failing the invariants after mutations: the parent of nodes
added into the tree was null.

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Tree.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Mutations.cpp
clang/lib/Tooling/Syntax/Synthesis.cpp
clang/lib/Tooling/Syntax/Tree.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Tree.h 
b/clang/include/clang/Tooling/Syntax/Tree.h
index 7e34ed2d438d..640697a25f3d 100644
--- a/clang/include/clang/Tooling/Syntax/Tree.h
+++ b/clang/include/clang/Tooling/Syntax/Tree.h
@@ -110,6 +110,12 @@ class Node {
   /// Dumps the tokens forming this subtree.
   std::string dumpTokens(const Arena &A) const;
 
+  /// Asserts invariants on this node of the tree and its immediate children.
+  /// Will not recurse into the subtree. No-op if NDEBUG is set.
+  void assertInvariants() const;
+  /// Runs checkInvariants on all nodes in the subtree. No-op if NDEBUG is set.
+  void assertInvariantsRecursive() const;
+
 private:
   // Tree is allowed to change the Parent link and Role.
   friend class Tree;

diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 7357cab6f976..aa8844771d37 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -92,7 +92,9 @@ class syntax::TreeBuilder {
 Pending.foldChildren(Arena, Tokens.drop_back(),
  new (Arena.allocator()) syntax::TranslationUnit);
 
-return cast(std::move(Pending).finalize());
+auto *TU = cast(std::move(Pending).finalize());
+TU->assertInvariantsRecursive();
+return TU;
   }
 
   /// getRange() finds the syntax tokens corresponding to the passed source

diff  --git a/clang/lib/Tooling/Syntax/Mutations.cpp 
b/clang/lib/Tooling/Syntax/Mutations.cpp
index 7278aff5f18b..72458528202e 100644
--- a/clang/lib/Tooling/Syntax/Mutations.cpp
+++ b/clang/lib/Tooling/Syntax/Mutations.cpp
@@ -29,30 +29,43 @@ class syntax::MutationsImpl {
 public:
   /// Add a new node with a specified role.
   static void addAfter(syntax::Node *Anchor, syntax::Node *New, NodeRole Role) 
{
+assert(Anchor != nullptr);
 assert(New->Parent == nullptr);
 assert(New->NextSibling == nullptr);
 assert(!New->isDetached());
 assert(Role != NodeRole::Detached);
 
 New->Role = static_cast(Role);
-Anchor->parent()->replaceChildRangeLowLevel(Anchor, Anchor, New);
+auto *P = Anchor->parent();
+P->replaceChildRangeLowLevel(Anchor, Anchor, New);
+
+P->assertInvariants();
   }
 
   /// Replace the node, keeping the role.
   static void replace(syntax::Node *Old, syntax::Node *New) {
+assert(Old != nullptr);
+assert(Old->Parent != nullptr);
+assert(Old->canModify());
 assert(New->Parent == nullptr);
 assert(New->NextSibling == nullptr);
 assert(New->isDetached());
 
 New->Role = Old->Role;
-Old->parent()->replaceChildRangeLowLevel(findPrevious(Old),
- Old->nextSibling(), New);
+auto *P = Old->parent();
+P->replaceChildRangeLowLevel(findPrevious(Old), Old->nextSibling(), New);
+
+P->assertInvariants();
   }
 
   /// Completely remove the node from its parent.
   static void remove(syntax::Node *N) {
-N->parent()->replaceChildRangeLowLevel(findPrevious(N), N->nextSibling(),
-   /*New=*/nullptr);
+auto *P = N->parent();
+P->replaceChildRangeLowLevel(findPrevious(N), N->nextSibling(),
+ /*New=*/nullptr);
+
+P->assertInvariants();
+N->assertInvariants();
   }
 
 private:
@@ -69,6 +82,7 @@ class syntax::MutationsImpl {
 };
 
 void syntax::removeStatement(syntax::Arena &A, syntax::Statement *S) {
+  assert(S);
   assert(S->canModify());
 
   if (isa(S->parent())) {

diff  --git a/clang/lib/Tooling/Syntax/Synthesis.cpp 
b/clang/lib/Tooling/Syntax/Synthesis.cpp
index 73ae71f9a6c8..cbd9579f4f06 100644
--- a/clang/lib/Tooling/Syntax/Synthesis.cpp
+++ b/clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -26,7 +26,9 @@ clang::syntax::Leaf 
*syntax::createPunctuation(clang::syntax::Arena &A,
 .second;
   assert(Tokens.size() == 1);
   assert(Tokens.front().kind() == K);
-  return new (A.allocator()) clang::syntax::Leaf(Tokens.begin());
+  auto *L = new (A.allocator()) clang::syntax::Leaf(Tokens.begin());
+  L->assertInvariants

[PATCH] D72691: [clang-tidy] Match InitListExpr in modernize-use-default-member-init

2020-01-14 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9738c757bd9b: [clang-tidy] Match InitListExpr in 
modernize-use-default-member-init (authored by malcolm.parsons).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72691

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -247,24 +247,24 @@
 };
 
 struct ExistingChar {
-  ExistingChar(short) : e1(), e2(), e3(), e4() {}
+  ExistingChar(short) : e1(), e2{}, e3(), e4() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:31: warning: member initializer for 'e2' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is redundant
   // CHECK-FIXES: ExistingChar(short) :  e4() {}
-  ExistingChar(int) : e1(0), e2(0), e3(0), e4(0) {}
+  ExistingChar(int) : e1(0), e2{0}, e3(0), e4(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is redundant
   // CHECK-FIXES: ExistingChar(int) :  e4(0) {}
-  ExistingChar(long) : e1('\0'), e2('\0'), e3('\0'), e4('\0') {}
+  ExistingChar(long) : e1('\0'), e2{'\0'}, e3('\0'), e4('\0') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:44: warning: member initializer for 'e3' is redundant
   // CHECK-FIXES: ExistingChar(long) :  e4('\0') {}
-  ExistingChar(char) : e1('a'), e2('a'), e3('a'), e4('a') {}
+  ExistingChar(char) : e1('a'), e2{'a'}, e3('a'), e4('a') {}
   // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: member initializer for 'e4' is redundant
-  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2('a'), e3('a') {}
+  // CHECK-FIXES: ExistingChar(char) : e1('a'), e2{'a'}, e3('a') {}
   char e1{};
   char e2 = 0;
   char e3 = '\0';
@@ -272,22 +272,22 @@
 };
 
 struct ExistingInt {
-  ExistingInt(short) : e1(), e2(), e3(), e4(), e5(), e6() {}
+  ExistingInt(short) : e1(), e2{}, e3(), e4(), e5(), e6() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
   // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant
   // CHECK-FIXES: ExistingInt(short) :  e3(), e4(), e5(), e6() {}
-  ExistingInt(int) : e1(0), e2(0), e3(0), e4(0), e5(0), e6(0) {}
+  ExistingInt(int) : e1(0), e2{0}, e3(0), e4(0), e5(0), e6(0) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is redundant
   // CHECK-FIXES: ExistingInt(int) :  e3(0), e4(0), e5(0), e6(0) {}
-  ExistingInt(long) : e1(5), e2(5), e3(5), e4(5), e5(5), e6(5) {}
+  ExistingInt(long) : e1(5), e2{5}, e3(5), e4(5), e5(5), e6(5) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: member initializer for 'e3' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: member initializer for 'e4' is redundant
   // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: member initializer for 'e6' is redundant
-  // CHECK-FIXES: ExistingInt(long) : e1(5), e2(5),  e5(5) {}
-  ExistingInt(char) : e1(-5), e2(-5), e3(-5), e4(-5), e5(-5), e6(-5) {}
+  // CHECK-FIXES: ExistingInt(long) : e1(5), e2{5},  e5(5) {}
+  ExistingInt(char) : e1(-5), e2{-5}, e3(-5), e4(-5), e5(-5), e6(-5) {}
   // CHECK-MESSAGES: :[[@LINE-1]]:55: warning: member initializer for 'e5' is redundant
-  // CHECK-FIXES: ExistingInt(char) : e1(-5), e2(-5), e3(-5), e4(-5),  e6(-5) {}
+  // CHECK-FIXES: ExistingInt(char) : e1(-5), e2{-5}, e3(-5), e4(-5),  e6(-5) {}
   int e1{};
   int e2 = 0;
   int e3 = {5};
@@ -297,21 +297,21 @@
 };
 
 struct ExistingDouble {
-  ExistingDouble(short) : e1(), e2(), e3(), e4(), e5() {}
+  ExistingDouble(short) : e1(), e2{}, e3(), e4(), e5() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: member initializer for 'e1' is redundant
   // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: member initializer for 'e2' is redundant
   // CHECK-FIXES: ExistingDouble(short) :  e3(), e4(), e5() {}
-  ExistingDouble(int) : e1(0.0), e2(0.0), e3(0.0), e4(0.0), e5(0.0) {}
+  ExistingDouble(int) : e1(0.0), e2{0.0}, e3(0.0), e4(0.0), e5(0.0) {}
   // CHECK-MESSAGES:

[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2020-01-14 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added inline comments.



Comment at: clang/test/Driver/cc1-spawnprocess.c:1
+// RUN: env -u CLANG_SPAWN_CC1 %clang -c %s -o /dev/null
+// RUN: env CLANG_SPAWN_CC1=0 %clang -c %s -o /dev/null

mgorny wrote:
> `env -u` is not portable.
I think just going for `env CLANG_SPAWN_CC1=` works for the purpose of this 
test. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69825



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


[clang] 07a4101 - [Syntax] Mark synthesized nodes as modifiable

2020-01-14 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2020-01-14T16:41:09+01:00
New Revision: 07a41018e9d27f67f7b4295eb7e00e0345c0aacf

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

LOG: [Syntax] Mark synthesized nodes as modifiable

This was an oversight in the original patch.
Also add corresponding tests.

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Tree.h
clang/lib/Tooling/Syntax/Synthesis.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Tree.h 
b/clang/include/clang/Tooling/Syntax/Tree.h
index 640697a25f3d..8702fe60ce1b 100644
--- a/clang/include/clang/Tooling/Syntax/Tree.h
+++ b/clang/include/clang/Tooling/Syntax/Tree.h
@@ -123,6 +123,8 @@ class Node {
   friend class TreeBuilder;
   // MutationsImpl sets roles and CanModify flag.
   friend class MutationsImpl;
+  // FactoryImpl sets CanModify flag.
+  friend class FactoryImpl;
 
   Tree *Parent;
   Node *NextSibling;

diff  --git a/clang/lib/Tooling/Syntax/Synthesis.cpp 
b/clang/lib/Tooling/Syntax/Synthesis.cpp
index cbd9579f4f06..aa01a34c761f 100644
--- a/clang/lib/Tooling/Syntax/Synthesis.cpp
+++ b/clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -13,6 +13,8 @@ using namespace clang;
 /// Should not be used for anything else.
 class syntax::FactoryImpl {
 public:
+  static void setCanModify(syntax::Node *N) { N->CanModify = true; }
+
   static void prependChildLowLevel(syntax::Tree *T, syntax::Node *Child,
syntax::NodeRole R) {
 T->prependChildLowLevel(Child, R);
@@ -27,6 +29,7 @@ clang::syntax::Leaf 
*syntax::createPunctuation(clang::syntax::Arena &A,
   assert(Tokens.size() == 1);
   assert(Tokens.front().kind() == K);
   auto *L = new (A.allocator()) clang::syntax::Leaf(Tokens.begin());
+  FactoryImpl::setCanModify(L);
   L->assertInvariants();
   return L;
 }
@@ -34,6 +37,7 @@ clang::syntax::Leaf 
*syntax::createPunctuation(clang::syntax::Arena &A,
 clang::syntax::EmptyStatement *
 syntax::createEmptyStatement(clang::syntax::Arena &A) {
   auto *S = new (A.allocator()) clang::syntax::EmptyStatement;
+  FactoryImpl::setCanModify(S);
   FactoryImpl::prependChildLowLevel(S, createPunctuation(A, clang::tok::semi),
 NodeRole::Unknown);
   S->assertInvariants();

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index b54d06319e83..c457c7888124 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -906,4 +907,21 @@ TEST_F(SyntaxTreeTest, Mutations) {
 CheckTransformation(C.first, C.second, RemoveStatement);
 }
 
+TEST_F(SyntaxTreeTest, SynthesizedNodes) {
+  buildTree("");
+
+  auto *C = syntax::createPunctuation(*Arena, tok::comma);
+  ASSERT_NE(C, nullptr);
+  EXPECT_EQ(C->token()->kind(), tok::comma);
+  EXPECT_TRUE(C->canModify());
+  EXPECT_FALSE(C->isOriginal());
+  EXPECT_TRUE(C->isDetached());
+
+  auto *S = syntax::createEmptyStatement(*Arena);
+  ASSERT_NE(S, nullptr);
+  EXPECT_TRUE(S->canModify());
+  EXPECT_FALSE(S->isOriginal());
+  EXPECT_TRUE(S->isDetached());
+}
+
 } // namespace



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


[PATCH] D72647: [clangd] Only re-open files if their flags changed

2020-01-14 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1126
+  std::set ModifiedFiles;
+  auto Sub =
+  CDB->watch([&ModifiedFiles](const std::vector Changes) {

sammccall wrote:
> this is a clever technique. (Why not just use compilationDatabaseChanges 
> directly? I suppose because then you have to deal more with path 
> canonicalization?)
> 
> it risks having the CDB change concurrently and reloading those files too, 
> though.
> I guess there's not much harm in it. But in that case, why aren't we just 
> permanently subscribing to CDB changes and re-parsing affected files? Lack of 
> a thread to do it on?
Yeah I think `compilationDatabaseChanges` would be equivalent to what is here 
now, I can just swap to that.

For the perma subscribe I wasn't sure of the threading. If addDocument is 
thread safe I think we're okay to just call `Server->AddDocument` from whatever 
thread without holding a mutex?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72647



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


[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

2020-01-14 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D72217#1819437 , @aaron.ballman 
wrote:

> Do you need someone to commit this on your behalf? (If you plan to continue 
> contributing, which I hope you do, it may be a good time for you to obtain 
> commit privileges: 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access but I am 
> happy to commit on your behalf if you'd prefer.)


For now I would appreciate it, I have fired off an email though, cheers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[PATCH] D72705: [clang][checkers] Added new checker 'alpha.unix.ErrorReturn'.

2020-01-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, mgorny.
Herald added a project: clang.

First simple implementation, infrastructure is ready.
Only one kind of check (NULL error return value) is implemented.
Documentation not added yet.
Idea of the checker is taken from:
https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72705

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/error-return.c

Index: clang/test/Analysis/error-return.c
===
--- /dev/null
+++ clang/test/Analysis/error-return.c
@@ -0,0 +1,323 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.unix.ErrorReturn -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+/*
+Functions from CERT ERR33-C that should be checked for error:
+https://wiki.sei.cmu.edu/confluence/display/c/ERR33-C.+Detect+and+handle+standard+library+errors
+
+void *aligned_alloc( size_t alignment, size_t size );
+errno_t asctime_s(char *buf, rsize_t bufsz, const struct tm *time_ptr);
+int at_quick_exit( void (*func)(void) );
+int atexit( void (*func)(void) );
+void* bsearch( const void *key, const void *ptr, size_t count, size_t size,
+   int (*comp)(const void*, const void*) );
+void* bsearch_s( const void *key, const void *ptr, rsize_t count, rsize_t size,
+ int (*comp)(const void *, const void *, void *),
+ void *context );
+wint_t btowc( int c );
+size_t c16rtomb( char * restrict s, char16_t c16, mbstate_t * restrict ps );
+size_t c32rtomb( char * restrict s, char32_t c32, mbstate_t * restrict ps );
+void* calloc( size_t num, size_t size );
+clock_t clock(void);
+int cnd_broadcast( cnd_t *cond );
+int cnd_init( cnd_t* cond );
+int cnd_signal( cnd_t *cond );
+int cnd_timedwait( cnd_t* restrict cond, mtx_t* restrict mutex,
+   const struct timespec* restrict time_point );
+int cnd_wait( cnd_t* cond, mtx_t* mutex );
+errno_t ctime_s(char *buffer, rsize_t bufsz, const time_t *time);
+int fclose( FILE *stream );
+int fflush( FILE *stream );
+int fgetc( FILE *stream );
+int fgetpos( FILE *restrict stream, fpos_t *restrict pos );
+char *fgets( char *restrict str, int count, FILE *restrict stream );
+wint_t fgetwc( FILE *stream );
+FILE *fopen( const char *restrict filename, const char *restrict mode );
+errno_t fopen_s(FILE *restrict *restrict streamptr,
+const char *restrict filename,
+const char *restrict mode);
+int fprintf( FILE *restrict stream, const char *restrict format, ... );
+int fprintf_s(FILE *restrict stream, const char *restrict format, ...);
+int fputc( int ch, FILE *stream );
+int fputs( const char *restrict str, FILE *restrict stream );
+wint_t fputwc( wchar_t ch, FILE *stream );
+int fputws( const wchar_t * restrict str, FILE * restrict stream );
+size_t fread( void *restrict buffer, size_t size, size_t count,
+  FILE *restrict stream );
+FILE *freopen( const char *restrict filename, const char *restrict mode,
+   FILE *restrict stream );
+errno_t freopen_s(FILE *restrict *restrict newstreamptr,
+  const char *restrict filename, const char *restrict mode,
+  FILE *restrict stream);
+int fscanf( FILE *restrict stream, const char *restrict format, ... );
+int fscanf_s(FILE *restrict stream, const char *restrict format, ...);
+int fseek( FILE *stream, long offset, int origin );
+int fsetpos( FILE *stream, const fpos_t *pos );
+long ftell( FILE *stream );
+int fwprintf( FILE *restrict stream,
+  const wchar_t *restrict format, ... );
+int fwprintf_s( FILE *restrict stream,
+const wchar_t *restrict format, ...);
+size_t fwrite( const void *restrict buffer, size_t size, size_t count,
+   FILE *restrict stream ); // more exact error return: < count
+int fwscanf( FILE *restrict stream,
+ const wchar_t *restrict format, ... );
+int fwscanf_s( FILE *restrict stream,
+   const wchar_t *restrict format, ...);
+int getc( FILE *stream );
+int getchar(void);
+char *getenv( const char *name );
+errno_t getenv_s( size_t *restrict len, char *restrict value,
+  rsize_t valuesz, const char *restrict name );
+char *gets_s( char *str, rsize_t n );
+wint_t getwc( FILE *stream );
+wint_t getwchar(void);
+struct tm *gmtime( const time_t *time );
+struct tm *gmtime_s(const time_t *restrict time, struct tm *restrict result);
+struct tm *localtime( const time_t *time );
+struct tm *localtime_s(const time_t *restrict time, struct tm *restrict result);
+void* malloc( size_t size );
+int mblen( const char* s, size_t n );
+size_t mbrle

[clang] 013c07f - [Syntax] Unset IsOriginal flag on nodes removed from the tree

2020-01-14 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2020-01-14T17:00:33+01:00
New Revision: 013c07f697886649b068cd97127e528b4fe7c03e

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

LOG: [Syntax] Unset IsOriginal flag on nodes removed from the tree

And add a corresponding test.
Only nodes inside the TranslationUnit subtree can be marked as original,
computeReplacements() relies on this.

Added: 


Modified: 
clang/lib/Tooling/Syntax/Tree.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/Tree.cpp 
b/clang/lib/Tooling/Syntax/Tree.cpp
index 5282857df5a9..9f028c0be3b4 100644
--- a/clang/lib/Tooling/Syntax/Tree.cpp
+++ b/clang/lib/Tooling/Syntax/Tree.cpp
@@ -15,6 +15,23 @@
 
 using namespace clang;
 
+namespace {
+static void traverse(const syntax::Node *N,
+ llvm::function_ref Visit) {
+  if (auto *T = dyn_cast(N)) {
+for (auto *C = T->firstChild(); C; C = C->nextSibling())
+  traverse(C, Visit);
+  }
+  Visit(N);
+}
+static void traverse(syntax::Node *N,
+ llvm::function_ref Visit) {
+  traverse(static_cast(N), [&](const syntax::Node *N) {
+Visit(const_cast(N));
+  });
+};
+} // namespace
+
 syntax::Arena::Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
  TokenBuffer Tokens)
 : SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(std::move(Tokens)) {}
@@ -80,6 +97,8 @@ void syntax::Tree::replaceChildRangeLowLevel(Node 
*BeforeBegin, Node *End,
 N->Role = static_cast(NodeRole::Detached);
 N->Parent = nullptr;
 N->NextSibling = nullptr;
+if (N->Original)
+  traverse(N, [&](Node *C) { C->Original = false; });
 
 N = Next;
   }
@@ -105,14 +124,6 @@ void syntax::Tree::replaceChildRangeLowLevel(Node 
*BeforeBegin, Node *End,
 }
 
 namespace {
-static void traverse(const syntax::Node *N,
- llvm::function_ref Visit) {
-  if (auto *T = dyn_cast(N)) {
-for (auto *C = T->firstChild(); C; C = C->nextSibling())
-  traverse(C, Visit);
-  }
-  Visit(N);
-}
 static void dumpTokens(llvm::raw_ostream &OS, ArrayRef Tokens,
const SourceManager &SM) {
   assert(!Tokens.empty());

diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index c457c7888124..42d77d893536 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -895,6 +895,9 @@ TEST_F(SyntaxTreeTest, Mutations) {
 auto *S = cast(nodeByRange(Input.range(), TU));
 ASSERT_TRUE(S->canModify()) << "cannot remove a statement";
 syntax::removeStatement(*Arena, S);
+EXPECT_TRUE(S->isDetached());
+EXPECT_FALSE(S->isOriginal())
+<< "node removed from tree cannot be marked as original";
   };
 
   std::vector>



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


[PATCH] D71510: [clang][checkers] Added new checker 'error-return-checker'.

2020-01-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

Smaller diff with first part:
https://reviews.llvm.org/D72705


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71510



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


[PATCH] D72707: [clang][OpenCL] Fix covered switch warning

2020-01-14 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
jsji added a reviewer: svenvh.
Herald added subscribers: cfe-commits, Anastasia, yaxunl.
Herald added a project: clang.
jsji edited the summary of this revision.

-Werror clang build is broken now.

tools/clang/lib/Sema/OpenCLBuiltins.inc:11824:5: error: default label in
switch which covers all enumeration values
[-Werror,-Wcovered-switch-default]

  default:

We don't need default now, since all enumeration values are covered.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72707

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -751,9 +751,7 @@
   }
 
   // End of switch statement.
-  OS << "default:\n"
- << "  llvm_unreachable(\"OpenCL builtin type not handled yet\");\n"
- << "  } // end of switch (Ty.ID)\n\n";
+  OS << "  } // end of switch (Ty.ID)\n\n";
 
   // Step 2.
   // Add ExtVector types if this was a generic type, as the switch statement


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -751,9 +751,7 @@
   }
 
   // End of switch statement.
-  OS << "default:\n"
- << "  llvm_unreachable(\"OpenCL builtin type not handled yet\");\n"
- << "  } // end of switch (Ty.ID)\n\n";
+  OS << "  } // end of switch (Ty.ID)\n\n";
 
   // Step 2.
   // Add ExtVector types if this was a generic type, as the switch statement
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72217: [clang-tidy] Added readability-qualified-auto check

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

In D72217#1819678 , @njames93 wrote:

> In D72217#1819437 , @aaron.ballman 
> wrote:
>
> > Do you need someone to commit this on your behalf? (If you plan to continue 
> > contributing, which I hope you do, it may be a good time for you to obtain 
> > commit privileges: 
> > https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access but I am 
> > happy to commit on your behalf if you'd prefer.)
>
>
> For now I would appreciate it, I have fired off an email though, cheers.


Happy to do so -- can you upload a rebased patch? I am getting merge conflicts:

  c:\llvm-project>git apply C:\Users\aballman\Desktop\D72217.diff
  C:/Users/aballman/Desktop/D72217.diff:402: trailing whitespace.
Adds pointer and ``const`` qualifications to ``auto``-typed variables
  C:/Users/aballman/Desktop/D72217.diff:468: trailing whitespace.
  make it obvious if a ``auto`` typed variable is a pointer, constant pointer or
  C:/Users/aballman/Desktop/D72217.diff:469: trailing whitespace.
  constant reference. This check will transform ``auto`` to ``auto *`` when the
  error: patch failed: clang-tools-extra/docs/clang-tidy/checks/list.rst:397
  error: clang-tools-extra/docs/clang-tidy/checks/list.rst: patch does not apply


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72217



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


[PATCH] D72707: [clang][OpenCL] Fix covered switch warning

2020-01-14 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

Nice catch, LGTM.  Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72707



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


[PATCH] D72707: [clang][OpenCL] Fix covered switch warning

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61822 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72707



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


[PATCH] D71612: [analyzer] Add PlacementNewChecker

2020-01-14 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D71612#1812476 , @NoQ wrote:

> In D71612#1812036 , @martong wrote:
>
> > In D71612#1790045 , @NoQ wrote:
> >
> > > I wonder if this checker will find any misuses of placement into 
> > > `llvm::TrailingObjects`.
> >
> >
> > I've evaluated this checker on LLVM/Clang source and it did not find any 
> > results, though there are many placement new calls there. I think this is 
> > good, because there are no false positives.
>
>
> In such cases it's usually a good idea to verify that the checker works 
> correctly by artificially injecting a bug into the codebase. If the bug is 
> not found, the checker is probably not working. If the bug is found, change 
> it to be more and more realistic, so that to see what limitations does the 
> checker have in terms of false negatives. Monitor analyzer stats closely 
> (max-nodes limits, block count limits, inlining limits) in order to see what 
> exactly goes wrong (or debug on the Exploded Graph as usual, depending on how 
> it goes wrong). This exercise often uncovers interesting omissions :)
>
> Can we enable the check by default then? What pieces are missing? Like, the 
> symbolic extent/offset case is not a must. I think we have everything except 
> maybe some deeper testing. I'd rather spend some time on the above exercise, 
> but then enable by default if it goes well.


Artem, I've made some more experiments with this checker. I searched for 
default placement new call expressions in the LLVM codebase and slightly 
modified the checker's code to log if we have concrete values for both sizes 
(target and place).

  @@ -95,6 +96,15 @@ void PlacementNewChecker::checkPreStmt(const CXXNewExpr 
*NE,
 if (!SizeOfPlaceCI)
   return;
  
  +  //auto& SM = C.getASTContext().getSourceManager();
  +  //NE->dump();
  +  //NE->getBeginLoc().dump(SM);
  +  //NE->getOperatorNew()->dump();
  +  //SizeOfTarget.dump();
  +  //llvm::errs() << "\n";
  +  //SizeOfPlace.dump();
  +  //llvm::errs() << "\n";
  +

This way I could pick one specific file for analysis: DeclBase.cpp.
Based on the logs, I modified two LLVM headers, thus introducing bugs, which 
should be found by this checker:

  diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
  index ed25b2cd89f..3a2c2df383d 100644
  --- a/llvm/include/llvm/ADT/APFloat.h
  +++ b/llvm/include/llvm/ADT/APFloat.h
  @@ -744,11 +744,11 @@ class APFloat : public APFloatBase {
  
   Storage(Storage &&RHS) {
 if (usesLayout(*RHS.semantics)) {
  -new (this) IEEEFloat(std::move(RHS.IEEE));
  +new ((char*)this+9) IEEEFloat(std::move(RHS.IEEE));
   return;
 }
 if (usesLayout(*RHS.semantics)) {
  -new (this) DoubleAPFloat(std::move(RHS.Double));
  +new ((char*)this+9) DoubleAPFloat(std::move(RHS.Double));
   return;
 }
 llvm_unreachable("Unexpected semantics");
  diff --git a/llvm/include/llvm/ADT/DenseMap.h 
b/llvm/include/llvm/ADT/DenseMap.h
  index 148d319c860..d0b23ed531b 100644
  --- a/llvm/include/llvm/ADT/DenseMap.h
  +++ b/llvm/include/llvm/ADT/DenseMap.h
  @@ -1024,8 +1024,8 @@ public:
   !KeyInfoT::isEqual(P->getFirst(), TombstoneKey)) {
 assert(size_t(TmpEnd - TmpBegin) < InlineBuckets &&
"Too many inline buckets!");
  -  ::new (&TmpEnd->getFirst()) KeyT(std::move(P->getFirst()));
  -  ::new (&TmpEnd->getSecond()) ValueT(std::move(P->getSecond()));
  +  ::new ((char*)(&TmpEnd->getFirst())+1) 
KeyT(std::move(P->getFirst()));
  +  ::new ((char*)(&TmpEnd->getSecond())+1) 
ValueT(std::move(P->getSecond()));
 ++TmpEnd;
 P->getSecond().~ValueT();
   }

And the results were what we expect, the checker did find the bugs:

  ) CodeChecker parse --print-steps reports
  Found no defects in DeclBase.cpp
  [LOW] /usr/include/c++/7/bits/atomic_base.h:188:20: Value stored to '__b' 
during its initialization is never read [deadcode.DeadStores]
memory_order __b = __m & __memory_order_mask;
 ^
Report hash: 311a73855b3f4477ee6a4d02482e7c09
Steps:
  1, atomic_base.h:188:20: Value stored to '__b' during its initialization 
is never read
  
  [LOW] /usr/include/c++/7/bits/atomic_base.h:199:20: Value stored to '__b' 
during its initialization is never read [deadcode.DeadStores]
memory_order __b = __m & __memory_order_mask;
 ^
Report hash: 890f61293b984671c6bf407dbbf4352a
Steps:
  1, atomic_base.h:199:20: Value stored to '__b' during its initialization 
is never read
  
  Found 2 defect(s) in atomic_base.h
  
  [UNSPECIFIED] 
/home/egbomrt/WORK/llvm3/git/llvm-project/llvm/include/llvm/ADT/DenseMap.h:1027:11:
 Storage provided to placement new is only 7 bytes, whereas the allocated type 
requires 8 bytes

[clang] e2b8e21 - [clang][OpenCL] Fix covered switch warning

2020-01-14 Thread Jinsong Ji via cfe-commits

Author: Jinsong Ji
Date: 2020-01-14T16:21:42Z
New Revision: e2b8e2113a4929027a237b67f7be86db4ec103d3

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

LOG: [clang][OpenCL] Fix covered switch warning

-Werror clang build is broken now.

tools/clang/lib/Sema/OpenCLBuiltins.inc:11824:5: error: default label in
switch which covers all enumeration values
[-Werror,-Wcovered-switch-default]
default:

We don't need default now, since all enumeration values are covered.

Reviewed By: svenvh

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

Added: 


Modified: 
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp 
b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
index dcdc4bf12e98..41d33b550680 100644
--- a/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ b/clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -751,9 +751,7 @@ static void OCL2Qual(ASTContext &Context, const 
OpenCLTypeStruct &Ty,
   }
 
   // End of switch statement.
-  OS << "default:\n"
- << "  llvm_unreachable(\"OpenCL builtin type not handled yet\");\n"
- << "  } // end of switch (Ty.ID)\n\n";
+  OS << "  } // end of switch (Ty.ID)\n\n";
 
   // Step 2.
   // Add ExtVector types if this was a generic type, as the switch statement



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


[PATCH] D72707: [clang][OpenCL] Fix covered switch warning

2020-01-14 Thread Jinsong Ji via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2b8e2113a49: [clang][OpenCL] Fix covered switch warning 
(authored by jsji).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72707

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -751,9 +751,7 @@
   }
 
   // End of switch statement.
-  OS << "default:\n"
- << "  llvm_unreachable(\"OpenCL builtin type not handled yet\");\n"
- << "  } // end of switch (Ty.ID)\n\n";
+  OS << "  } // end of switch (Ty.ID)\n\n";
 
   // Step 2.
   // Add ExtVector types if this was a generic type, as the switch statement


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -751,9 +751,7 @@
   }
 
   // End of switch statement.
-  OS << "default:\n"
- << "  llvm_unreachable(\"OpenCL builtin type not handled yet\");\n"
- << "  } // end of switch (Ty.ID)\n\n";
+  OS << "  } // end of switch (Ty.ID)\n\n";
 
   // Step 2.
   // Add ExtVector types if this was a generic type, as the switch statement
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] cfd366b - Fix "pointer is null" static analyzer warnings. NFCI.

2020-01-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-14T16:31:17Z
New Revision: cfd366ba74c566038c6f417da9c9becc321fd737

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

LOG: Fix "pointer is null" static analyzer warnings. NFCI.

Use castAs<> instead of getAs<> since the pointer is dereferenced immediately 
in all cases and castAs will perform the null assertion for us.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 497e45631be4..9916d3be77e1 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1501,13 +1501,13 @@ void Sema::MergeVarDeclExceptionSpecs(VarDecl *New, 
VarDecl *Old) {
   // as pointers to member functions.
   if (const ReferenceType *R = NewType->getAs()) {
 NewType = R->getPointeeType();
-OldType = OldType->getAs()->getPointeeType();
+OldType = OldType->castAs()->getPointeeType();
   } else if (const PointerType *P = NewType->getAs()) {
 NewType = P->getPointeeType();
-OldType = OldType->getAs()->getPointeeType();
+OldType = OldType->castAs()->getPointeeType();
   } else if (const MemberPointerType *M = NewType->getAs()) 
{
 NewType = M->getPointeeType();
-OldType = OldType->getAs()->getPointeeType();
+OldType = OldType->castAs()->getPointeeType();
   }
 
   if (!NewType->isFunctionProtoType())
@@ -1633,7 +1633,7 @@ static bool CheckConstexprParameterTypes(Sema &SemaRef,
  const FunctionDecl *FD,
  Sema::CheckConstexprKind Kind) {
   unsigned ArgIndex = 0;
-  const FunctionProtoType *FT = FD->getType()->getAs();
+  const auto *FT = FD->getType()->castAs();
   for (FunctionProtoType::param_type_iterator i = FT->param_type_begin(),
   e = FT->param_type_end();
i != e; ++i, ++ArgIndex) {
@@ -9829,7 +9829,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator &D, 
QualType R,
   // Rebuild the function type "R" without any type qualifiers (in
   // case any of the errors above fired) and with "void" as the
   // return type, since constructors don't have return types.
-  const FunctionProtoType *Proto = R->getAs();
+  const FunctionProtoType *Proto = R->castAs();
   if (Proto->getReturnType() == Context.VoidTy && !D.isInvalidType())
 return R;
 
@@ -10027,7 +10027,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, 
QualType R,
   if (!D.isInvalidType())
 return R;
 
-  const FunctionProtoType *Proto = R->getAs();
+  const FunctionProtoType *Proto = R->castAs();
   FunctionProtoType::ExtProtoInfo EPI = Proto->getExtProtoInfo();
   EPI.Variadic = false;
   EPI.TypeQuals = Qualifiers();
@@ -10101,7 +10101,7 @@ void Sema::CheckConversionDeclarator(Declarator &D, 
QualType &R,
 D.setInvalidType();
   }
 
-  const FunctionProtoType *Proto = R->getAs();
+  const auto *Proto = R->castAs();
 
   // Make sure we don't have any parameters.
   if (Proto->getNumParams() > 0) {
@@ -13015,8 +13015,7 @@ void 
Sema::AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor) {
   //   A declaration of a destructor that does not have an exception-
   //   specification is implicitly considered to have the same exception-
   //   specification as an implicit declaration.
-  const FunctionProtoType *DtorType = Destructor->getType()->
-getAs();
+  const auto *DtorType = Destructor->getType()->castAs();
   if (DtorType->hasExceptionSpec())
 return;
 
@@ -13996,8 +13995,8 @@ void Sema::DefineImplicitMoveAssignment(SourceLocation 
CurrentLocation,
 
   // The parameter for the "other" object, which we are move from.
   ParmVarDecl *Other = MoveAssignOperator->getParamDecl(0);
-  QualType OtherRefType = Other->getType()->
-  getAs()->getPointeeType();
+  QualType OtherRefType =
+  Other->getType()->castAs()->getPointeeType();
 
   // Our location for everything implicitly-generated.
   SourceLocation Loc = MoveAssignOperator->getEndLoc().isValid()
@@ -14791,9 +14790,7 @@ Sema::CompleteConstructorCall(CXXConstructorDecl 
*Constructor,
   unsigned NumArgs = ArgsPtr.size();
   Expr **Args = ArgsPtr.data();
 
-  const FunctionProtoType *Proto
-= Constructor->getType()->getAs();
-  assert(Proto && "Constructor without a prototype?");
+  const auto *Proto = Constructor->getType()->castAs();
   unsigned NumParams = Proto->getNumParams();
 
   // If too few arguments are available, we'll fill in the rest with defaults.
@@ -14856,7 +14853,7 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const 
FunctionDecl *FnDecl,
 unsigned DependentParamTypeDiag,
 unsigned InvalidParamTypeDiag) {

[clang] ab9dbc1 - Fix "pointer is null" clang static analyzer warnings. NFCI.

2020-01-14 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-01-14T16:31:17Z
New Revision: ab9dbc1d124cdf288474073f5233e3fd6ee8e9c3

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

LOG: Fix "pointer is null" clang static analyzer warnings. NFCI.

Use cast<>/castAs<> instead of dyn_cast<>/getAs<> since the pointers are always 
dereferenced and cast<>/castAs<> will perform the null assertion for us.

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 56d9522eee01..0fd932fac970 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2853,8 +2853,8 @@ void Sema::HandleFunctionTypeMismatch(PartialDiagnostic 
&PDiag,
 
   // Get the function type from the pointers.
   if (FromType->isMemberPointerType() && ToType->isMemberPointerType()) {
-const MemberPointerType *FromMember = FromType->getAs(),
-*ToMember = ToType->getAs();
+const auto *FromMember = FromType->castAs(),
+   *ToMember = ToType->castAs();
 if (!Context.hasSameType(FromMember->getClass(), ToMember->getClass())) {
   PDiag << ft_
diff erent_class << QualType(ToMember->getClass(), 0)
 << QualType(FromMember->getClass(), 0);
@@ -3304,8 +3304,7 @@ static bool tryAtomicConversion(Sema &S, Expr *From, 
QualType ToType,
 static bool isFirstArgumentCompatibleWithType(ASTContext &Context,
   CXXConstructorDecl *Constructor,
   QualType Type) {
-  const FunctionProtoType *CtorType =
-  Constructor->getType()->getAs();
+  const auto *CtorType = Constructor->getType()->castAs();
   if (CtorType->getNumParams() > 0) {
 QualType FirstArg = CtorType->getParamType(0);
 if (Context.hasSameUnqualifiedType(Type, FirstArg.getNonReferenceType()))
@@ -4346,14 +4345,10 @@ CompareDerivedToBaseConversions(Sema &S, SourceLocation 
Loc,
   if (SCS1.Second == ICK_Pointer_Member && SCS2.Second == ICK_Pointer_Member &&
   FromType1->isMemberPointerType() && FromType2->isMemberPointerType() &&
   ToType1->isMemberPointerType() && ToType2->isMemberPointerType()) {
-const MemberPointerType * FromMemPointer1 =
-FromType1->getAs();
-const MemberPointerType * ToMemPointer1 =
-  ToType1->getAs();
-const MemberPointerType * FromMemPointer2 =
-  
FromType2->getAs();
-const MemberPointerType * ToMemPointer2 =
-  ToType2->getAs();
+const auto *FromMemPointer1 = FromType1->castAs();
+const auto *ToMemPointer1 = ToType1->castAs();
+const auto *FromMemPointer2 = FromType2->castAs();
+const auto *ToMemPointer2 = ToType2->castAs();
 const Type *FromPointeeType1 = FromMemPointer1->getClass();
 const Type *ToPointeeType1 = ToMemPointer1->getClass();
 const Type *FromPointeeType2 = FromMemPointer2->getClass();
@@ -4534,8 +4529,7 @@ FindConversionForRefInit(Sema &S, 
ImplicitConversionSequence &ICS,
  Expr *Init, QualType T2, bool AllowRvalues,
  bool AllowExplicit) {
   assert(T2->isRecordType() && "Can only find conversions of record types.");
-  CXXRecordDecl *T2RecordDecl
-= dyn_cast(T2->castAs()->getDecl());
+  auto *T2RecordDecl = 
cast(T2->castAs()->getDecl());
 
   OverloadCandidateSet CandidateSet(
   DeclLoc, OverloadCandidateSet::CSK_InitByUserDefinedConversion);
@@ -6097,7 +6091,7 @@ static bool 
IsAcceptableNonMemberOperatorCandidate(ASTContext &Context,
   if (T1->isRecordType() || (!T2.isNull() && T2->isRecordType()))
 return true;
 
-  const FunctionProtoType *Proto = Fn->getType()->getAs();
+  const auto *Proto = Fn->getType()->castAs();
   if (Proto->getNumParams() < 1)
 return false;
 
@@ -10403,7 +10397,7 @@ static void DiagnoseArityMismatch(Sema &S, NamedDecl 
*Found, Decl *D,
   FunctionDecl *Fn = cast(D);
 
   // TODO: treat calls to a missing default constructor as a special case
-  const FunctionProtoType *FnTy = Fn->getType()->getAs();
+  const auto *FnTy = Fn->getType()->castAs();
   unsigned MinParams = Fn->getMinRequiredArguments();
 
   // at least / at most / exactly
@@ -13970,7 +13964,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr 
*MemExprE,
   ResultType = ResultType.getNonLValueExprType(Context);
 
   assert(Method && "Member call to something that isn't a method?");
-  const auto *Proto = Method->getType()->getAs();
+  const auto *Proto = Method->getType()->castAs();
   CXXMemberCallExpr *TheCall =
   CXXMemberCallExpr::Create(Context, MemExprE, Args, ResultType, VK,
 

Re: [PATCH] D72523: [remark][diagnostics] Using clang diagnostic handler for IR input files

2020-01-14 Thread Rong Xu via cfe-commits
Thanks for reviewing this.

The new constructor is to avoid initializing the "OS" field (which is not
used by the empty BackendConsumer. Setting this field will affect the
output). I will add a comment there.

-Rong

On Mon, Jan 13, 2020 at 4:50 PM Teresa Johnson via Phabricator <
revi...@reviews.llvm.org> wrote:

> tejohnson accepted this revision.
> tejohnson added a comment.
> This revision is now accepted and ready to land.
>
> LGTM. One more request for a comment below that I forgot to add earlier.
>
>
>
> 
> Comment at: clang/lib/CodeGen/CodeGenAction.cpp:154
>  }
> +BackendConsumer(BackendAction Action, DiagnosticsEngine &Diags,
> +const HeaderSearchOptions &HeaderSearchOpts,
> 
> Add comment as to what specific case this new constructor is for.
>
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D72523/new/
>
> https://reviews.llvm.org/D72523
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71682: Relax the rules around objc_alloc and objc_alloc_init optimizations.

2020-01-14 Thread Pierre Habouzit via Phabricator via cfe-commits
MadCoder marked an inline comment as done.
MadCoder added inline comments.



Comment at: clang/test/CodeGenObjC/objc-alloc-init.m:30
 
 @implementation Y
++(Class)class {

ahatanak wrote:
> Can you add a test case for `[[self class] alloc]` to test the code in 
> `tryGenerateSpecializedMessageSend`?
isn't it what meth2 is doing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71682



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


[PATCH] D72518: [clang] New __attribute__((__clang_arm_mve_strict_polymorphism)).

2020-01-14 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 237999.
simon_tatham marked 7 inline comments as done.
simon_tatham added a comment.

- Renamed the attribute as suggested.
- Made it target-specific.
- Added a diagnostic when it's applied to anything other than a vector type 
with a vector kind of `NeonVector`.
- Added some error tests demonstrating the new diagnostic.
- Added code examples to the docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72518

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/overload-arm-mve.c
  clang/utils/TableGen/MveEmitter.cpp

Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -1454,8 +1454,9 @@
 raw_ostream &OS = parts[ST->requiresFloat() ? Float : 0];
 const VectorType *VT = getVectorType(ST);
 
-OS << "typedef __attribute__((neon_vector_type(" << VT->lanes() << "))) "
-   << ST->cName() << " " << VT->cName() << ";\n";
+OS << "typedef __attribute__((__neon_vector_type__(" << VT->lanes()
+   << "), __arm_mve_strict_polymorphism__)) " << ST->cName() << " "
+   << VT->cName() << ";\n";
 
 // Every vector type also comes with a pair of multi-vector types for
 // the VLD2 and VLD4 instructions.
Index: clang/test/Sema/overload-arm-mve.c
===
--- /dev/null
+++ clang/test/Sema/overload-arm-mve.c
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -verify -fsyntax-only -DERROR_CHECK %s
+
+typedef   signed short  int16_t;
+typedef   signed intint32_t;
+typedef   signed long long  int64_t;
+typedef unsigned short uint16_t;
+typedef unsigned int   uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef __attribute__((neon_vector_type(8), arm_mve_strict_polymorphism))  int16_t  int16x8_t;
+typedef __attribute__((neon_vector_type(4), arm_mve_strict_polymorphism))  int32_t  int32x4_t;
+typedef __attribute__((neon_vector_type(2), arm_mve_strict_polymorphism))  int64_t  int64x2_t;
+typedef __attribute__((neon_vector_type(8), arm_mve_strict_polymorphism)) uint16_t uint16x8_t;
+typedef __attribute__((neon_vector_type(4), arm_mve_strict_polymorphism)) uint32_t uint32x4_t;
+typedef __attribute__((neon_vector_type(2), arm_mve_strict_polymorphism)) uint64_t uint64x2_t;
+
+__attribute__((overloadable))
+int overload(int16x8_t x, int16_t y); // expected-note {{candidate function}}
+__attribute__((overloadable))
+int overload(int32x4_t x, int32_t y); // expected-note {{candidate function}}
+__attribute__((overloadable))
+int overload(uint16x8_t x, uint16_t y); // expected-note {{candidate function}}
+__attribute__((overloadable))
+int overload(uint32x4_t x, uint32_t y); // expected-note {{candidate function}}
+
+int16_t s16;
+int32_t s32;
+uint16_t u16;
+uint32_t u32;
+
+int16x8_t vs16;
+int32x4_t vs32;
+uint16x8_t vu16;
+uint32x4_t vu32;
+
+// --
+// Simple cases where the types are correctly matched
+
+// CHECK-LABEL: @test_easy_s16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int16
+int test_easy_s16(void) { return overload(vs16, s16); }
+
+// CHECK-LABEL: @test_easy_u16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint16
+int test_easy_u16(void) { return overload(vu16, u16); }
+
+// CHECK-LABEL: @test_easy_s32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int32
+int test_easy_s32(void) { return overload(vs32, s32); }
+
+// CHECK-LABEL: @test_easy_u32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint32
+int test_easy_u32(void) { return overload(vu32, u32); }
+
+// --
+// Do arithmetic on the scalar, and it may get promoted. We still expect the
+// same overloads to be selected if that happens.
+
+// CHECK-LABEL: @test_promote_s16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int16
+int test_promote_s16(void) { return overload(vs16, s16 + 1); }
+
+// CHECK-LABEL: @test_promote_u16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint16
+int test_promote_u16(void) { return overload(vu16, u16 + 1); }
+
+// CHECK-LABEL: @test_promote_s32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int32
+int test_promote_s32(void) { return overload(vs32, s32 + 1); }
+
+// CHECK-LABEL: @test_promote_u32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint32
+int test_promote_u32(voi

[PATCH] D72518: [clang] New __attribute__((arm_mve_strict_polymorphism)).

2020-01-14 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1474
+def ArmMveStrictPolymorphism : TypeAttr {
+  let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
+  let Documentation = [ArmMveStrictPolymorphismDocs];

aaron.ballman wrote:
> Why does this have a `__clang` prefix? That seems a bit strange given that 
> the attribute can be spelled 
> `[[clang::__clang_arm_mve_strict_polymorphism]]`. I'd probably drop the 
> `__clang_` prefix entirely.
I was going by your recommendation for the spelling of `ArmMveAlias` in 
D67159#1659296. I've taken the `__clang_` off this one; should I do the same to 
that one as well, while I'm here?

(It ought to be safe to do that after the fact, because `ArmMveAlias` is locked 
down so hard that surely it //can't// have any users except the tablegen 
MveEmitter backend, which is easy to change.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72518



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


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.

Printing policy was not propogated to functiondecls when creating a
completion string which resulted in canonical template parameters like
`foo`. This patch propogates printing policy to those as
well.

Fixes https://github.com/clangd/clangd/issues/76


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72715

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/test/CodeCompletion/ctor-signature.cpp


Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,16 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, PartialSpec) {
+  const auto Results = signatures(R"cpp(
+  template  struct Foo {};
+  template  struct Foo { Foo(T); };
+  Foo F(^);
+)cpp");
+  EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 TEST(SignatureHelpTest, InsideArgument) {
   {
 const auto Results = signatures(R"cpp(


Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,16 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, PartialSpec) {
+  const auto Results = signatures(R"cpp(
+  template  struct Foo {};
+  template  struct Foo { Foo(T); };
+  Foo F(^);
+)cpp");
+  EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 TEST(SignatureHelpTest, InsideArgument) {
   {
 const auto Results = signatures(R"cpp(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 61795 tests passed, 1 failed 
and 781 were skipped.

  failed: Clangd Unit Tests._/ClangdTests/SignatureHelpTest.PartialSpec

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715



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


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

The patch contains only tests, are we missing the actual functional change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715



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


[PATCH] D71682: Relax the rules around objc_alloc and objc_alloc_init optimizations.

2020-01-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/test/CodeGenObjC/objc-alloc-init.m:30
 
 @implementation Y
++(Class)class {

MadCoder wrote:
> ahatanak wrote:
> > Can you add a test case for `[[self class] alloc]` to test the code in 
> > `tryGenerateSpecializedMessageSend`?
> isn't it what meth2 is doing?
Ah, right. I didn't see the NOT_OPTIMIZED line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71682



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


[PATCH] D72717: [CMake] Disable libc++ filesystem tests in CrossWinToARMLinux cache file

2020-01-14 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb created this revision.
broadwaylamb added reviewers: aorlov, vvereschaka, andreil99.
Herald added subscribers: cfe-commits, ldionne, kristof.beyls, mgorny.
Herald added a reviewer: EricWF.
Herald added a project: clang.

`filesystem` tests are not yet supported when running tests on a remote board, 
because the testing infrastructure isn't quite ready for it yet. Supporting 
`filesystem` in the infrastructure is non-trivial, so I suggest disabling these 
tests for now.

Also, pass through LIT arguments to builtins and runtimes (they were not passed 
through before). I'm not sure about this change though, as we may want to 
differentiate between LIT arguments for llvm/clang tests from those for 
libunwind/libc++abi/libc++ tests. For example, we may want to specify a higher 
number of threads for the tests that are run remotely, as it significantly 
speeds up the test suite. Please let me know what you think.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72717

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -54,7 +54,9 @@
 set(LLVM_ENABLE_RUNTIMES
"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
 set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
-set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE 
STRING "" FORCE)
+
+# Note that testing the 'filesystem' header from libc++ is not yet supported 
in remote configuration.
+set(LLVM_LIT_ARGS   "-vv --param 
enable_filesystem=False ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
 
 set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
 
@@ -84,8 +86,15 @@
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
 
-set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
-set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;\
+ -DCMAKE_AR=${CMAKE_AR};\
+ -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}" 
+ CACHE STRING "")
+
+set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;\
+ -DCMAKE_AR=${CMAKE_AR};\
+ -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}"
+ CACHE STRING "")
 
 # Remote test configuration.
 if(DEFINED REMOTE_TEST_HOST)


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -54,7 +54,9 @@
 set(LLVM_ENABLE_RUNTIMES"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
 set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
-set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
+
+# Note that testing the 'filesystem' header from libc++ is not yet supported in remote configuration.
+set(LLVM_LIT_ARGS   "-vv --param enable_filesystem=False ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
 
 set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
 
@@ -84,8 +86,15 @@
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
 
-set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
-set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;\
+ -DCMAKE_AR=${CMAKE_AR};\
+ -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}" 
+ CACHE STRING "")
+
+set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;\
+ -DCMAKE_AR=${CMAKE_AR};\
+ -DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}"
+ CACHE STRING "")
 
 # Remote test configuration.
 if(DEFINED REMOTE_TEST_HOST)
_

[PATCH] D71682: Relax the rules around objc_alloc and objc_alloc_init optimizations.

2020-01-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71682



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238009.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Populate `Name` for expressions
- Don't special case `StringLiteral`s


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -601,6 +601,19 @@
   R"cpp(// non-named decls don't get hover. Don't crash!
 ^static_assert(1, "");
   )cpp",
+  R"cpp(// non-evaluatable expr
+  template  void foo() {
+(void)[[size^of]](T);
+  })cpp",
+  // literals
+  "auto x = t^rue;",
+  "auto x = '^A';",
+  "auto x = ^(int){42};",
+  "auto x = ^42.;",
+  "auto x = ^42.0i;",
+  "auto x = ^42;",
+  "auto x = ^nullptr;",
+  "auto x = ^\"asdf\";",
   };
 
   for (const auto &Test : Tests) {
@@ -1501,6 +1514,26 @@
 HI.Name = "cls > >";
 HI.Documentation = "type of nested templates.";
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -13,6 +13,7 @@
 #include "FindTarget.h"
 #include "FormattedString.h"
 #include "Logger.h"
+#include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
@@ -21,13 +22,19 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -410,6 +417,45 @@
   }
   return HI;
 }
+
+bool isLiteral(const Expr *E) {
+  // Unfortunately there's no common base Literal classes inherits from
+  // (apart from Expr), therefore this is a nasty blacklist.
+  return llvm::isa(E) || llvm::isa(E) ||
+ llvm::isa(E) ||
+ llvm::isa(E) ||
+ llvm::isa(E) || llvm::isa(E) ||
+ llvm::isa(E) || llvm::isa(E) ||
+ llvm::isa(E) || llvm::isa(E);
+}
+
+llvm::StringLiteral getNameForExpr(const Expr *E) {
+  // FIXME: Come up with names for `special` expressions.
+  return "expression";
+}
+
+// Generates hover info for evaluatable expressions.
+// FIXME: Support hover for literals (esp user-defined)
+llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST) {
+  // There's not much value in hovering over "42" and getting a hover card
+  // saying "42 is an int", similar for other literals.
+  if (isLiteral(E))
+return llvm::None;
+
+  HoverInfo HI;
+  // For expressions we currently print the type and the value, iff it is
+  // evaluatable.
+  if (auto Val = printExprValue(E, AST.getASTContext())) {
+auto Policy =
+printingPolicyForDecls(AST.getASTContext().getPrintingPolicy());
+Policy.SuppressTagKeyword = true;
+HI.Type = E->getType().getAsString(Policy);
+HI.Value = *Val;
+HI.Name = getNameForExpr(E);
+return HI;
+  }
+  return llvm::None;
+}
 } // namespace
 
 llvm::Optional getHover(ParsedAST &AST, Position Pos,
@@ -439,11 +485,11 @@
 // Look for a close enclosing expression to show the value of.
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext());
+  } else if (const Expr *E = N->ASTNode.get()) {
+HI = getHoverContents(E, AST);
   }
   // FIXME: support hovers for other nodes?
-  //  - certain expressions (sizeof etc)
   //  - built-in types
-  //  - literals (esp user-defined)
 }
   }
 
@@ -469,6 +515,8 @@
   // class `X`
   //
   // function `foo` → `int`
+  //
+  // expression : `int`
 

[clang] 57cf6ee - [RISCV] Add Clang frontend support for Bitmanip extension

2020-01-14 Thread Scott Egerton via cfe-commits

Author: Scott Egerton
Date: 2020-01-14T17:45:45Z
New Revision: 57cf6ee9c84434161088c39a6f8dd2aae14eb12d

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

LOG: [RISCV] Add Clang frontend support for Bitmanip extension

Summary: This adds the __riscv_bitmanip macro and the 'b' target feature to 
enable it.

Reviewers: asb, simoncook, lewis-revill, PaoloS, lenary

Reviewed By: lenary

Subscribers: Jim, rbar, johnrusso, sabuasal, niosHD, kito-cheng, shiva0217, 
jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, 
the_o, rkruppe, PkmX, jocewei, psnobl, benna, pzheng, sameer.abuasal, apazos, 
luismarques, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index ab8272c034fd..58285f1d8134 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -125,6 +125,10 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   if (HasC)
 Builder.defineMacro("__riscv_compressed");
+
+  if (HasB) {
+Builder.defineMacro("__riscv_bitmanip");
+  }
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -139,6 +143,7 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
   .Case("f", HasF)
   .Case("d", HasD)
   .Case("c", HasC)
+  .Case("b", HasB)
   .Default(false);
 }
 
@@ -156,6 +161,8 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   HasD = true;
 else if (Feature == "+c")
   HasC = true;
+else if (Feature == "+b")
+  HasB = true;
   }
 
   return true;

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 9118494a87ab..05da13230bf8 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -30,11 +30,12 @@ class RISCVTargetInfo : public TargetInfo {
   bool HasF;
   bool HasD;
   bool HasC;
+  bool HasB;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false) {
+HasD(false), HasC(false), HasB(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 8c343b8693f3..85869ae937e5 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -331,6 +331,9 @@ static bool getArchFeatures(const Driver &D, StringRef 
MArch,
 case 'c':
   Features.push_back("+c");
   break;
+case 'b':
+  Features.push_back("+b");
+  break;
 }
   }
 

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index a93d7e6a9a43..1d2fd60847da 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -7,6 +7,7 @@
 // CHECK-NOT: __riscv_mul
 // CHECK-NOT: __riscv_muldiv
 // CHECK-NOT: __riscv_compressed
+// CHECK-NOT: __riscv_bitmanip
 // CHECK-NOT: __riscv_flen
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
@@ -48,6 +49,12 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ib -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ib -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_bitmanip 1
+
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x 
c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64 -x 
c -E -dM %s \



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


[PATCH] D72284: [clang-tidy] Factor out renaming logic from readability-identifier-naming

2020-01-14 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 238014.
logan-5 added a comment.

Rebased with trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72284

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -0,0 +1,150 @@
+//===--- RenamderClangTidyCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_RENAMERCLANGTIDYCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_RENAMERCLANGTIDYCHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/Optional.h"
+#include 
+#include 
+
+namespace clang {
+
+class MacroInfo;
+
+namespace tidy {
+
+/// Base class for clang-tidy checks that want to flag declarations and/or
+/// macros for renaming based on customizable criteria.
+class RenamerClangTidyCheck : public ClangTidyCheck {
+public:
+  RenamerClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
+  ~RenamerClangTidyCheck();
+
+  /// Derived classes should not implement any matching logic themselves; this
+  /// class will do the matching and call the derived class'
+  /// GetDeclFailureInfo() and GetMacroFailureInfo() for determining whether a
+  /// given identifier passes or fails the check.
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override final;
+  void
+  check(const ast_matchers::MatchFinder::MatchResult &Result) override final;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override final;
+  void onEndOfTranslationUnit() override final;
+
+  /// This enum will be used in %select of the diagnostic message.
+  /// Each value below IgnoreFailureThreshold should have an error message.
+  enum class ShouldFixStatus {
+ShouldFix,
+
+/// The fixup will conflict with a language keyword,
+/// so we can't fix it automatically.
+ConflictsWithKeyword,
+
+/// The fixup will conflict with a macro
+/// definition, so we can't fix it
+/// automatically.
+ConflictsWithMacroDefinition,
+
+/// Values pass this threshold will be ignored completely
+/// i.e no message, no fixup.
+IgnoreFailureThreshold,
+
+/// If the identifier was used or declared within a macro we
+/// won't offer a fixup for safety reasons.
+InsideMacro,
+  };
+
+  /// Information describing a failed check
+  struct FailureInfo {
+std::string KindName; // Tag or misc info to be used as derived classes need
+std::string Fixup;// The name that will be proposed as a fix-it hint
+  };
+
+  /// Holds an identifier name check failure, tracking the kind of the
+  /// identifier, its possible fixup and the starting locations of all the
+  /// identifier usages.
+  struct NamingCheckFailure {
+FailureInfo Info;
+
+/// Whether the failure should be fixed or not.
+///
+/// e.g.: if the identifier was used or declared within a macro we won't
+/// offer a fixup for safety reasons.
+bool ShouldFix() const {
+  return FixStatus == ShouldFixStatus::ShouldFix && !Info.Fixup.empty();
+}
+
+bool ShouldNotify() const {
+  return FixStatus < ShouldFixStatus::IgnoreFailureThreshold;
+}
+
+ShouldFixStatus FixStatus = ShouldFixStatus::ShouldFix;
+
+/// A set of all the identifier usages starting SourceLocation, in
+/// their encoded form.
+llvm::DenseSet RawUsageLocs;
+
+NamingCheckFailure() = default;
+  };
+
+  using NamingCheckId = std::pair;
+
+  using NamingCheckFailureMap =
+  llvm::DenseMap;
+
+  /// Check Macros for style violations.
+  void checkMacro(SourceManager &sourceMgr, const Token &MacroNameTok,
+  const MacroInfo *MI);
+
+  /// Add a usage of a macro if it already has a violation.
+  void expandMacro(const Token &MacroNameTok, const MacroInfo *MI);
+
+protected:
+  /// Overridden by derived classes, returns information about if and how a Decl
+  /// failed the check. A 'None' result means the Decl did not fail the check.
+  virtual llvm::Optional
+  GetDeclFailureInfo(const NamedDecl *Decl, const SourceManager &SM) const = 0;
+
+  /// Overridden by der

[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238017.
kadircet added a comment.

- Upload the correct diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ctor-signature.cpp


Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | 
FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -3701,8 +3702,11 @@
 Result.addBriefComment(RC->getBriefText(S.getASTContext()));
 }
 AddResultTypeChunk(S.Context, Policy, FDecl, QualType(), Result);
-Result.AddTextChunk(
-Result.getAllocator().CopyString(FDecl->getNameAsString()));
+
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+FDecl->getDeclName().print(OS, Policy);
+Result.AddTextChunk(Result.getAllocator().CopyString(OS.str()));
   } else {
 Result.AddResultTypeChunk(Result.getAllocator().CopyString(
 Proto->getReturnType().getAsString(Policy)));
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,15 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, PartialSpec) {
+  const auto Results = signatures(R"cpp(
+  template  struct Foo {};
+  template  struct Foo { Foo(T); };
+  Foo F(^);)cpp");
+  EXPECT_THAT(Results.signatures, Contains(Sig("Foo([[T]])")));
+  EXPECT_EQ(0, Results.activeParameter);
+}
+
 TEST(SignatureHelpTest, InsideArgument) {
   {
 const auto Results = signatures(R"cpp(


Index: clang/test/CodeCompletion/ctor-signature.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/ctor-signature.cpp
@@ -0,0 +1,17 @@
+template 
+struct Foo {};
+template 
+struct Foo { Foo(T); };
+
+void foo() {
+  Foo();
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: OVERLOAD: Foo()
+  // CHECK-CC1: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC1: OVERLOAD: Foo(<#Foo &&#>
+  Foo(3);
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:12:14 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // CHECK-CC2: OVERLOAD: Foo(<#int#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#const Foo &#>)
+  // CHECK-CC2: OVERLOAD: Foo(<#Foo &&#>
+}
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -37,6 +37,7 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -3701,8 +3702,11 @@
 Result.addBriefComment(RC->getBriefText(S.getASTContext()));
 }
 AddResultTypeChunk(S.Context, Policy, FDecl, QualType(), Result);
-Result.AddTextChunk(
-Result.getAllocator().CopyString(FDecl->getNameAsString()));
+
+std::string Name;
+llvm::raw_string_ostream OS(Name);
+FDecl->getDeclName().print(OS, Policy);
+Result.AddTextChunk(Result.getAllocator().CopyString(OS.str()));
   } else {
 Result.AddResultTypeChunk(Result.getAllocator().CopyString(
 Proto->getReturnType().getAsString(Policy)));
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -2297,6 +2297,15 @@
AllOf(Named("TestClangc"), Deprecated(;
 }
 
+TEST(SignatureHelpTest, PartialSpe

[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

2020-01-14 Thread Scott Egerton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG57cf6ee9c844: [RISCV] Add Clang frontend support for 
Bitmanip extension (authored by s.egerton).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71553

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Preprocessor/riscv-target-features.c


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -7,6 +7,7 @@
 // CHECK-NOT: __riscv_mul
 // CHECK-NOT: __riscv_muldiv
 // CHECK-NOT: __riscv_compressed
+// CHECK-NOT: __riscv_bitmanip
 // CHECK-NOT: __riscv_flen
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
@@ -48,6 +49,12 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ib -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ib -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_bitmanip 1
+
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x 
c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64 -x 
c -E -dM %s \
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -331,6 +331,9 @@
 case 'c':
   Features.push_back("+c");
   break;
+case 'b':
+  Features.push_back("+b");
+  break;
 }
   }
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -30,11 +30,12 @@
   bool HasF;
   bool HasD;
   bool HasC;
+  bool HasB;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false) {
+HasD(false), HasC(false), HasB(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -125,6 +125,10 @@
 
   if (HasC)
 Builder.defineMacro("__riscv_compressed");
+
+  if (HasB) {
+Builder.defineMacro("__riscv_bitmanip");
+  }
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -139,6 +143,7 @@
   .Case("f", HasF)
   .Case("d", HasD)
   .Case("c", HasC)
+  .Case("b", HasB)
   .Default(false);
 }
 
@@ -156,6 +161,8 @@
   HasD = true;
 else if (Feature == "+c")
   HasC = true;
+else if (Feature == "+b")
+  HasB = true;
   }
 
   return true;


Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -7,6 +7,7 @@
 // CHECK-NOT: __riscv_mul
 // CHECK-NOT: __riscv_muldiv
 // CHECK-NOT: __riscv_compressed
+// CHECK-NOT: __riscv_bitmanip
 // CHECK-NOT: __riscv_flen
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
@@ -48,6 +49,12 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
 
+// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ib -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ib -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
+// CHECK-B-EXT: __riscv_bitmanip 1
+
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64 -x c -E -dM %s \
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -331,6 +331,9 @@
 case 'c':
   Features.push_back("+c");
   break;
+case 'b':
+  Features.push_back("+b");
+  break;
 }
   }
 
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -3

[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-14 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D72715#1819879 , @ilya-biryukov 
wrote:

> The patch contains only tests, are we missing the actual functional change?


oopsy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715



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


[clang] 2948ec5 - Removed PointerUnion3 and PointerUnion4 aliases in favor of the variadic template

2020-01-14 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-01-14T18:56:29+01:00
New Revision: 2948ec5ca98f8593584f2117bc92fe8d75f6f098

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

LOG: Removed PointerUnion3 and PointerUnion4 aliases in favor of the variadic 
template

Added: 


Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/AST/ExprObjC.h
clang/include/clang/AST/TemplateName.h
clang/lib/AST/ASTContext.cpp
clang/tools/libclang/CXCursor.h
clang/unittests/CodeGen/IRMatchers.h
llvm/include/llvm/ADT/PointerUnion.h
llvm/include/llvm/Support/SourceMgr.h
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/tools/llvm-pdbutil/InputFile.h
llvm/unittests/ADT/PointerUnionTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 623f47b31bb4..43c6c7b85db4 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1859,10 +1859,10 @@ class FunctionDecl : public DeclaratorDecl,
   /// FunctionTemplateSpecializationInfo, which contains information about
   /// the template being specialized and the template arguments involved in
   /// that specialization.
-  llvm::PointerUnion4
+  llvm::PointerUnion
 TemplateOrSpecialization;
 
   /// Provides source/type location info for the declaration name embedded in

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 73b4fb94a494..b716ea453a5a 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -2125,8 +2125,8 @@ class CXXCtorInitializer final {
   /// Either the base class name/delegating constructor type (stored as
   /// a TypeSourceInfo*), an normal field (FieldDecl), or an anonymous field
   /// (IndirectFieldDecl*) being initialized.
-  llvm::PointerUnion3
-Initializee;
+  llvm::PointerUnion
+  Initializee;
 
   /// The source location for the field name or, for a base initializer
   /// pack expansion, the location of the ellipsis.

diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 8b2c271fbf25..23905d12c8b2 100755
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -57,8 +57,8 @@ class VarTemplatePartialSpecializationDecl;
 
 /// Stores a template parameter of any kind.
 using TemplateParameter =
-llvm::PointerUnion3;
+llvm::PointerUnion;
 
 NamedDecl *getAsNamedDecl(TemplateParameter P);
 
@@ -309,7 +309,7 @@ class DefaultArgStorage {
   static_assert(sizeof(Chain) == sizeof(void *) * 2,
 "non-pointer argument type?");
 
-  llvm::PointerUnion3 ValueOrInherited;
+  llvm::PointerUnion ValueOrInherited;
 
   static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
 const DefaultArgStorage &Storage = Parm->getDefaultArgStorage();

diff  --git a/clang/include/clang/AST/ExprObjC.h 
b/clang/include/clang/AST/ExprObjC.h
index dbb2b2ff7099..d76b3a26b1f9 100644
--- a/clang/include/clang/AST/ExprObjC.h
+++ b/clang/include/clang/AST/ExprObjC.h
@@ -642,7 +642,7 @@ class ObjCPropertyRefExpr : public Expr {
   /// the location of the 'super' keyword.  When it's an interface,
   /// this is that interface.
   SourceLocation ReceiverLoc;
-  llvm::PointerUnion3 Receiver;
+  llvm::PointerUnion Receiver;
 
 public:
   ObjCPropertyRefExpr(ObjCPropertyDecl *PD, QualType t,

diff  --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index e99f12121167..cbbcbf6af8ab 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -190,8 +190,8 @@ class SubstTemplateTemplateParmPackStorage
 /// only be understood in the context of
 class TemplateName {
   using StorageType =
-  llvm::PointerUnion4;
+  llvm::PointerUnion;
 
   StorageType Storage;
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 481affafc871..26e76d450424 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -924,15 +924,15 @@ class ASTContext::ParentMap {
   /// only storing a unique pointer to them.
   using ParentMapPointers = llvm::DenseMap<
   const void *,
-  llvm::PointerUnion4>;
+  llvm::PointerUnion>;
 
   /// Parent map for nodes without pointer identity. We store a full
   /// DynTypedNode for all keys.
   using ParentMapOtherNodes = llvm::DenseMap<
   ast_type_traits::DynTypedNode,
-  llvm::PointerUnion4>;
+  llvm::PointerUnion>;
 
   ParentMapPointers PointerParents;
   ParentMapOtherNodes OtherParents;

diff  --git a/clang/tools/libclang/CXCursor.h b/clang/tools/libclang/CXCursor.h
index d17381ba0aca..78e597b2bbea 100644
--- a/clang/tool

[PATCH] D72446: [Syntax] Build mapping from AST to syntax tree nodes

2020-01-14 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:147
+  void add(ASTPtr From, syntax::Tree *To) {
+assert(To != nullptr);
+

Also assert that From is not null either?



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:160
+  // Keys are either Stmt* or Decl*.
+  llvm::DenseMap Nodes;
+};

I think it is possible to use a PointerUnion as a DenseMap key (there's a 
DenseMapInfo for it).



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:491
 /// FIXME: storing the end tokens is redundant.
 /// FIXME: the key of a map is redundant, it is also stored in 
NodeForRange.
+std::map Trees;

I don't understand the first fixme (maybe it is stale).

The second fixme is not applicable after this patch.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72446



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61794 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500



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


[PATCH] D72715: [clang][CodeComplete] Propogate printing policy to FunctionDecl

2020-01-14 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61796 tests passed, 0 failed 
and 781 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72715



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


[PATCH] D72622: [clangd] Add a ruler after header in hover

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



Comment at: clang-tools-extra/clangd/FormattedString.cpp:121
 std::string renderBlocks(llvm::ArrayRef> Children,
- void (Block::*RenderFunc)(llvm::raw_ostream &) const) 
{
+ const RenderType RT) {
   std::string R;

Having thought about this a bit more:

I think it'd be clearer to apply the ruler-filtering "symbolically", dropping 
those blocks before attempting rendering. Need isRuler() I guess.
Then something like

```
vector FilteredBlocks;
for (auto& C : Children) {
  if (C->isRuler() && (FilteredBlocks.empty() || 
FilteredBlocks.back()->isRuler()))
continue;
  FilteredBlocks.push_back(C.get());
}
while (!FilteredBlocks.empty() && FilteredBlocks.back()->isRuler())
  FilteredBlocks.pop_back();
```

Whereas I can't see a good way to apply the plaintext-newline rule 
symbolically, textually seems reasonable:
```
llvm::erase_if(Text, [&](Char &C) { return StringRef(Text.data(), &C - 
Text.data()).endswith("\n\n"); });
```



Comment at: clang-tools-extra/clangd/FormattedString.h:36
 
+  /// Padding information to imitate spacing while rendering for plaintext. As
+  /// markdown renderers should already add appropriate padding between

This is a bit weird layering-wise. I think it'd be cleaner just to do a 
substitution on the rendered output.
Still a hack, but we've got that either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622



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


[PATCH] D72089: [Syntax] Build declarator nodes

2020-01-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 238022.
ilya-biryukov added a comment.

- Rebase, get rid of accidental changes with TemplateDeclaration


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72089

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -174,17 +174,21 @@
 *: TranslationUnit
 |-SimpleDeclaration
 | |-int
-| |-main
-| |-(
-| |-)
+| |-SimpleDeclarator
+| | |-main
+| | `-ParametersAndQualifiers
+| |   |-(
+| |   `-)
 | `-CompoundStatement
 |   |-{
 |   `-}
 `-SimpleDeclaration
   |-void
-  |-foo
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-foo
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 `-}
@@ -201,9 +205,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-int
-  |-main
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-main
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-IfStatement
@@ -246,9 +252,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-ForStatement
@@ -268,18 +276,21 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-DeclarationStatement
 | |-SimpleDeclaration
 | | |-int
-| | |-a
-| | |-=
-| | `-UnknownExpression
-| |   `-10
+| | `-SimpleDeclarator
+| |   |-a
+| |   |-=
+| |   `-UnknownExpression
+| | `-10
 | `-;
 `-}
 )txt"},
@@ -287,9 +298,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-EmptyStatement
@@ -309,9 +322,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-SwitchStatement
@@ -345,9 +360,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-WhileStatement
@@ -375,9 +392,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-int
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-ReturnStatement
@@ -398,26 +417,31 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-DeclarationStatement
 | |-SimpleDeclaration
 | | |-int
-| | |-a
-| | |-[
-| | |-UnknownExpression
-| | | `-3
-| | `-]
+| | `-SimpleDeclarator
+| |   |-a
+| |   `-ArraySubscript
+| | |-[
+| | |-UnknownExpression
+| | | `-3
+| | `-]
 | `-;
 |-RangeBasedForStatement
 | |-for
 | |-(
 | |-SimpleDeclaration
 | | |-int
-| | |-x
+| | |-SimpleDeclarator
+| | | `-x
 | | `-:
 | |-UnknownExpression
 | | `-a
@@ -433,9 +457,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-main
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-main
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-UnknownStatement
@@ -460,9 +486,11 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-test
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-ExpressionStatement
@@ -500,10 +528,12 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-int
-  |-*
-  |-a
+  |-SimpleDeclarator
+  | |-*
+  | `-a
   |-,
-  |-b
+  |-SimpleDeclarator
+  | `-b
   `-;
   )txt"},
   {R"cpp(
@@ -514,10 +544,12 @@
 `-SimpleDeclaration
   |-typedef
   |-int
-  |-*
-  |-a
+  |-SimpleDeclarator
+  | |-*
+  | `-a
   |-,
-  |-b
+  |-SimpleDeclarator
+  | `-b
   `-;
   )txt"},
   // Multiple declarators inside a statement.
@@ -531,27 +563,33 @@
 *: TranslationUnit
 `-SimpleDeclaration
   |-void
-  |-foo
-  |-(
-  |-)
+  |-SimpleDeclarator
+  | |-foo
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   `-)
   `-CompoundStatement
 |-{
 |-DeclarationStatement
 | |-SimpleDeclaration
 | | |-int
-| | |-*
-| | |-a
+| | |-SimpleDeclarator
+

[PATCH] D72334: [Syntax] Build nodes for template declarations.

2020-01-14 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 238023.
ilya-biryukov added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72334

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -678,6 +678,212 @@
   `-;
 )txt"},
   {R"cpp(
+template  struct cls {};
+template  int var = 10;
+template  int fun() {}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-cls
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-int
+|   |-SimpleDeclarator
+|   | |-var
+|   | |-=
+|   | `-UnknownExpression
+|   |   `-10
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-int
+|-SimpleDeclarator
+| |-fun
+| `-ParametersAndQualifiers
+|   |-(
+|   `-)
+`-CompoundStatement
+  |-{
+  `-}
+)txt"},
+  {R"cpp(
+template 
+struct X {
+  template 
+  U foo();
+};
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-{
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-U
+| |->
+| `-SimpleDeclaration
+|   |-U
+|   |-SimpleDeclarator
+|   | |-foo
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   `-)
+|   `-;
+|-}
+`-;
+)txt"},
+  {R"cpp(
+template  struct X {};
+template  struct X {};
+template <> struct X {};
+
+template struct X;
+extern template struct X;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-T
+|   |-*
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-int
+|   |->
+|   |-{
+|   |-}
+|   `-;
+|-ExplicitTemplateInstantiation
+| |-template
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-<
+|   |-double
+|   |->
+|   `-;
+`-ExplicitTemplateInstantiation
+  |-extern
+  |-template
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-float
+|->
+`-;
+)txt"},
+  {R"cpp(
+template  struct X { struct Y; };
+template  struct X::Y {};
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-class
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-struct
+|   |-X
+|   |-{
+|   |-SimpleDeclaration
+|   | |-struct
+|   | |-Y
+|   | `-;
+|   |-}
+|   `-;
+`-TemplateDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  `-SimpleDeclaration
+|-struct
+|-X
+|-<
+|-T
+|->
+|-::
+|-Y
+|-{
+|-}
+`-;
+   )txt"},
+  {R"cpp(
 namespace ns {}
 using namespace ::ns;
 )cpp",
@@ -726,7 +932,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-UnknownDeclaration
+`-TemplateDeclaration
   |-template
   |-<
   |-UnknownDeclaration
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -58,6 +58,10 @@
 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:
@@ -118,6 +122,12 @@
 return OS << "StaticAssertDeclaration_message";
   case syntax::NodeRole::SimpleDeclaration_declarator:
 return OS << "SimpleDeclaration_declarator";
+  case syntax::NodeRole::TemplateDeclaration_declaration:
+return OS << "TemplateDeclaration_declaration";
+  case syntax::NodeRole::ExplicitTemplateInstantiation_externKeyword:
+return OS << "ExplicitTemplateInstantiation_externKeyword";
+  case syntax::NodeRole::ExplicitTemplateInstant

[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2020-01-14 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

Should I wait for the comments to be resolved on D71593 
 before I commit this patch? Ideally if this 
patch makes it into a release then that bug fix should be there too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG!




Comment at: clang-tools-extra/clangd/Hover.cpp:519
+  //
+  // expression : `int`
   // Note that we are making use of a level-3 heading because VSCode renders

nit: this is just "expression"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500



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


[PATCH] D72404: [WIP][ThinLTO] Support Os and Oz

2020-01-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 238028.
ychen added a comment.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

- when optnone is not present, add `optsize` for Os and `minsize` for Oz
- add Os Oz function attribute test.
- add Os Oz pipeline test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72404

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thinlto-debug-pm.c
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/test/COFF/lto-opt-level.ll
  lld/test/ELF/lto/opt-level.ll
  lld/test/wasm/lto/opt-level.ll
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/test/LTO/X86/Inputs/opt-level-size.ll
  llvm/test/LTO/X86/opt-level-size.ll
  llvm/test/tools/lto/opt-level.ll
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/lto/lto.cpp

Index: llvm/tools/lto/lto.cpp
===
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -28,14 +28,13 @@
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 
-// extra command-line flags needed for LTOCodeGenerator
-static cl::opt
+static cl::opt
 OptLevel("O",
- cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
+ cl::desc("Optimization level. [-O0, -O1, -O2, -Os, -Oz or -O3] "
   "(default = '-O2')"),
  cl::Prefix,
  cl::ZeroOrMore,
- cl::init('2'));
+ cl::init("2"));
 
 static cl::opt
 DisableInline("disable-inlining", cl::init(false),
@@ -165,9 +164,15 @@
 CG->setAttr(attrs);
   }
 
-  if (OptLevel < '0' || OptLevel > '3')
-report_fatal_error("Optimization level must be between 0 and 3");
-  CG->setOptLevel(OptLevel - '0');
+  LLVMContext &Ctx = CG->getContext();
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getOptLevel(OptLevel)))
+CG->setOptLevel(*Result);
+
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getSizeLevel(OptLevel)))
+CG->setSizeLevel(*Result);
+
   CG->setFreestanding(EnableFreestanding);
 }
 
@@ -487,25 +492,19 @@
   CodeGen->setTargetOptions(InitTargetOptionsFromCodeGenFlags());
   CodeGen->setFreestanding(EnableFreestanding);
 
-  if (OptLevel.getNumOccurrences()) {
-if (OptLevel < '0' || OptLevel > '3')
-  report_fatal_error("Optimization level must be between 0 and 3");
-CodeGen->setOptLevel(OptLevel - '0');
-switch (OptLevel) {
-case '0':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::None);
-  break;
-case '1':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Less);
-  break;
-case '2':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Default);
-  break;
-case '3':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Aggressive);
-  break;
-}
-  }
+  LLVMContext Ctx;
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getOptLevel(OptLevel)))
+CodeGen->setOptLevel(*Result);
+  else
+return nullptr;
+
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getSizeLevel(OptLevel)))
+CodeGen->setSizeLevel(*Result);
+  else
+return nullptr;
+
   return wrap(CodeGen);
 }
 
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -29,10 +29,11 @@
 using namespace llvm;
 using namespace lto;
 
-static cl::opt
-OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-   "(default = '-O2')"),
- cl::Prefix, cl::ZeroOrMore, cl::init('2'));
+static cl::opt
+OptLevel("O",
+ cl::desc("Optimization level. [-O0, -O1, -O2, -Os, -Oz, or "
+  "-O3] (default = '-O2')"),
+ cl::Prefix, cl::ZeroOrMore, cl::init("2"));
 
 static cl::opt CGOptLevel(
 "cg-opt-level",
@@ -244,7 +245,10 @@
   Conf.OptPipeline = OptPipeline;
   Conf.AAPipeline = AAPipeline;
 
-  Conf.OptLevel = OptLevel - '0';
+  Conf.OptLevel =
+  check(llvm::lto::getOptLevel(OptLevel), "invalid optimization level");
+  Conf.SizeLevel =
+  check(llvm::lto::getSizeLevel(OptLevel), "invalid optimization level");
   Conf.UseNewPM = UseNewPM;
   switch (CGOptLevel) {
   case '0':
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm

[PATCH] D72404: [WIP][ThinLTO] Support Os and Oz

2020-01-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 238034.
ychen added a comment.

- fix a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72404

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/thinlto-debug-pm.c
  lld/COFF/Config.h
  lld/COFF/Driver.cpp
  lld/COFF/LTO.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/LTO.cpp
  lld/test/COFF/lto-opt-level.ll
  lld/test/ELF/lto/opt-level.ll
  lld/test/wasm/lto/opt-level.ll
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/LTO.cpp
  llvm/include/llvm/LTO/Config.h
  llvm/include/llvm/LTO/LTO.h
  llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/test/LTO/X86/Inputs/opt-level-size.ll
  llvm/test/LTO/X86/opt-level-size.ll
  llvm/test/tools/lto/opt-level.ll
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/lto/lto.cpp

Index: llvm/tools/lto/lto.cpp
===
--- llvm/tools/lto/lto.cpp
+++ llvm/tools/lto/lto.cpp
@@ -28,14 +28,13 @@
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
 
-// extra command-line flags needed for LTOCodeGenerator
-static cl::opt
+static cl::opt
 OptLevel("O",
- cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
+ cl::desc("Optimization level. [-O0, -O1, -O2, -Os, -Oz or -O3] "
   "(default = '-O2')"),
  cl::Prefix,
  cl::ZeroOrMore,
- cl::init('2'));
+ cl::init("2"));
 
 static cl::opt
 DisableInline("disable-inlining", cl::init(false),
@@ -165,9 +164,15 @@
 CG->setAttr(attrs);
   }
 
-  if (OptLevel < '0' || OptLevel > '3')
-report_fatal_error("Optimization level must be between 0 and 3");
-  CG->setOptLevel(OptLevel - '0');
+  LLVMContext &Ctx = CG->getContext();
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getOptLevel(OptLevel)))
+CG->setOptLevel(*Result);
+
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getSizeLevel(OptLevel)))
+CG->setSizeLevel(*Result);
+
   CG->setFreestanding(EnableFreestanding);
 }
 
@@ -487,25 +492,19 @@
   CodeGen->setTargetOptions(InitTargetOptionsFromCodeGenFlags());
   CodeGen->setFreestanding(EnableFreestanding);
 
-  if (OptLevel.getNumOccurrences()) {
-if (OptLevel < '0' || OptLevel > '3')
-  report_fatal_error("Optimization level must be between 0 and 3");
-CodeGen->setOptLevel(OptLevel - '0');
-switch (OptLevel) {
-case '0':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::None);
-  break;
-case '1':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Less);
-  break;
-case '2':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Default);
-  break;
-case '3':
-  CodeGen->setCodeGenOptLevel(CodeGenOpt::Aggressive);
-  break;
-}
-  }
+  LLVMContext Ctx;
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getOptLevel(OptLevel)))
+CodeGen->setOptLevel(*Result);
+  else
+return nullptr;
+
+  if (ErrorOr Result = expectedToErrorOrAndEmitErrors(
+  Ctx, llvm::lto::getSizeLevel(OptLevel)))
+CodeGen->setSizeLevel(*Result);
+  else
+return nullptr;
+
   return wrap(CodeGen);
 }
 
Index: llvm/tools/llvm-lto2/llvm-lto2.cpp
===
--- llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -29,10 +29,11 @@
 using namespace llvm;
 using namespace lto;
 
-static cl::opt
-OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-   "(default = '-O2')"),
- cl::Prefix, cl::ZeroOrMore, cl::init('2'));
+static cl::opt
+OptLevel("O",
+ cl::desc("Optimization level. [-O0, -O1, -O2, -Os, -Oz, or "
+  "-O3] (default = '-O2')"),
+ cl::Prefix, cl::ZeroOrMore, cl::init("2"));
 
 static cl::opt CGOptLevel(
 "cg-opt-level",
@@ -244,7 +245,10 @@
   Conf.OptPipeline = OptPipeline;
   Conf.AAPipeline = AAPipeline;
 
-  Conf.OptLevel = OptLevel - '0';
+  Conf.OptLevel =
+  check(llvm::lto::getOptLevel(OptLevel), "invalid optimization level");
+  Conf.SizeLevel =
+  check(llvm::lto::getSizeLevel(OptLevel), "invalid optimization level");
   Conf.UseNewPM = UseNewPM;
   switch (CGOptLevel) {
   case '0':
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -62,10 +62,10 @@
 
 using namespace llvm;
 
-static cl::opt
-OptLevel("O", cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
-   "(default = '-

[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

2020-01-14 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

@s.egerton Please can you revert rG57cf6ee9c84434161088c39a6f8dd2aae14eb12d 
 - this 
patch has open dependencies, including on the LLVM support for RISC-V B 
extension. It would be confusing to users if clang 10.0 contained frontend 
support for the B extension, but LLVM 10.0 did not contain backend support for 
it.

Sorry for the confusion around marking this as approved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71553



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


  1   2   3   >