[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

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

In D75682#1917257 , @Szelethus wrote:

> Could you please add the warning we discussed? That would be a great 
> demonstration of this patch's capabilities, and wouldn't deserve its own 
> patch.


Was it this warning?

  if (feof(F)) { // note: Assuming the condition is true
 // note: Stream 'F' has the EOF flag set
fgets(F); // warning: Illegal stream operation on a stream that has EOF set
  }

The checker does not work by "assuming feof is true" (this can be a later 
feature, if the `F` is not tracked and a feof call is encountered). Value of 
`feof` (more precisely: if any error happened) is fixed when the file operation 
is called that causes the error. The warning above should be get even if the 
`feof` call is missing because it is still possible that the previous operation 
resulted in EOF state. Adding a similar warning is not a small change and the 
"infrastructure" for it is not ready in this revision. And still that warning 
would not be testable because `FEof` error state is never set in this patch. By 
the way, a file read is not invalid if any error is there, it simply fails 
again. But there is many possibility for warnings such as "file read called in 
EOF state", "feof called when it is proven to be false/true", "invalid file 
read/write after failed fseek/fread/fwrite" but these belong to next revisions.

Probably it would be better to make a full working prototype first, because the 
design decisions made now can turn out to be wrong later when the new 
functionality would be added and we do "not see the full picture" now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249856.
njames93 added a comment.
Herald added a subscriber: mgorny.

- Moved escape/unescape impl to source file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76037

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ReplacementsYaml.cpp
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,35 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() != NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),
+  NewDocR = NewDoc.Replacements.begin(),
+  DocE = Doc.Replacements.end();
+ DocR != DocE; DocR++, NewDocR++) {
+  ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+  ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
Index: clang/lib/Tooling/ReplacementsYaml.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ReplacementsYaml.cpp
@@ -0,0 +1,73 @@
+//===-- ReplacementsYaml.cpp -- Serialiazation for Replacements ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsYaml.h"
+
+namespace llvm {
+namespace yaml {
+
+namespace {
+struct Escapes {
+  char EscapeChar;
+  char WrittenChar;
+};
+} // namespace
+
+static constexpr Escapes EscapeChars[] = {
+{'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+
+std::string
+MappingTraits::NormalizedReplacement::escape(
+StringRef Str) {
+
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  for (char C : Str) {
+if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+  if (C == Escape.EscapeChar) {
+Builder << '\\' << Escape.WrittenChar;
+return true;
+  }
+  return false;
+})) {
+  Builder << C;
+}
+  }
+  return Res;
+}
+std::string
+MappingTraits::NormalizedReplacement::unescape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  while (!Str.empty()) {
+if (Str.consume_front("\\")) {
+  if (Str.empty()) {
+Builder << '\\';
+break;
+  }
+  char C = Str.front();
+  Str = Str.drop_front();
+  if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+if (C == Escape.WrittenChar) {
+  Builder << Escape.EscapeChar;
+  return true;
+}
+return false;
+  })) {
+Builder << '\\' << C;
+  }
+  continue;
+}
+Builder << Str.front();
+Str = Str.drop_front();
+  }
+  return Res;
+}
+} // namespace yaml
+} // namespace llvm
\ No newline at end of file
Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang

[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249857.
njames93 added a comment.

- Small tidy of code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76037

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ReplacementsYaml.cpp
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,35 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() != NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),
+  NewDocR = NewDoc.Replacements.begin(),
+  DocE = Doc.Replacements.end();
+ DocR != DocE; DocR++, NewDocR++) {
+  ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+  ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
Index: clang/lib/Tooling/ReplacementsYaml.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ReplacementsYaml.cpp
@@ -0,0 +1,74 @@
+//===-- ReplacementsYaml.cpp -- Serialiazation for Replacements ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsYaml.h"
+
+namespace llvm {
+namespace yaml {
+
+namespace {
+struct Escapes {
+  char EscapeChar;
+  char WrittenChar;
+};
+} // namespace
+
+static constexpr Escapes EscapeChars[] = {
+{'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+
+std::string
+MappingTraits::NormalizedReplacement::escape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  for (char C : Str) {
+if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+  if (C == Escape.EscapeChar) {
+Builder << '\\' << Escape.WrittenChar;
+return true;
+  }
+  return false;
+})) {
+  Builder << C;
+}
+  }
+  return Res;
+}
+
+std::string
+MappingTraits::NormalizedReplacement::unescape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  while (!Str.empty()) {
+if (Str.consume_front("\\")) {
+  if (Str.empty()) {
+Builder << '\\';
+break;
+  }
+  char C = Str.front();
+  Str = Str.drop_front();
+  if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+if (C == Escape.WrittenChar) {
+  Builder << Escape.EscapeChar;
+  return true;
+}
+return false;
+  })) {
+Builder << '\\' << C;
+  }
+  continue;
+}
+Builder << Str.front();
+Str = Str.drop_front();
+  }
+  return Res;
+}
+
+} // namespace yaml
+} // namespace llvm
Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -25,6 +25,7 @@
   JSONCompilationDatabase.cpp
   Refa

[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249860.
njames93 added a comment.

- Fix test case not being ran


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76037

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ReplacementsYaml.cpp
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,36 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_FALSE(IYAML.error());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() == NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),
+  NewDocR = NewDoc.Replacements.begin(),
+  DocE = Doc.Replacements.end();
+ DocR != DocE; DocR++, NewDocR++) {
+  ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+  ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
Index: clang/lib/Tooling/ReplacementsYaml.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ReplacementsYaml.cpp
@@ -0,0 +1,74 @@
+//===-- ReplacementsYaml.cpp -- Serialiazation for Replacements ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsYaml.h"
+
+namespace llvm {
+namespace yaml {
+
+namespace {
+struct Escapes {
+  char EscapeChar;
+  char WrittenChar;
+};
+} // namespace
+
+static constexpr Escapes EscapeChars[] = {
+{'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+
+std::string
+MappingTraits::NormalizedReplacement::escape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  for (char C : Str) {
+if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+  if (C == Escape.EscapeChar) {
+Builder << '\\' << Escape.WrittenChar;
+return true;
+  }
+  return false;
+})) {
+  Builder << C;
+}
+  }
+  return Res;
+}
+
+std::string
+MappingTraits::NormalizedReplacement::unescape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  while (!Str.empty()) {
+if (Str.consume_front("\\")) {
+  if (Str.empty()) {
+Builder << '\\';
+break;
+  }
+  char C = Str.front();
+  Str = Str.drop_front();
+  if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+if (C == Escape.WrittenChar) {
+  Builder << Escape.EscapeChar;
+  return true;
+}
+return false;
+  })) {
+Builder << '\\' << C;
+  }
+  continue;
+}
+Builder << Str.front();
+Str = Str.drop_front();
+  }
+  return Res;
+}
+
+} // namespace yaml
+} // namespace llvm
Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.txt
+++ clang/lib/Tooling/CMakeLists.txt
@@ -25,6 +25,7 

[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/unittests/Tooling/ReplacementsYamlTest.cpp:68
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() == NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),

Can this ever be false. Does execution of a test case stop once an ASSERT_EQ 
fails


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76037



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


[PATCH] D76053: [clangd] Redirect documentation to clangd.llvm.org.

2020-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.
sammccall updated this revision to Diff 249870.
sammccall added a comment.
sammccall updated this revision to Diff 249871.

also use template for clangd.rst


sammccall added a comment.

Fix accidental capitalization


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76053

Files:
  clang-tools-extra/docs/_templates/clangd_redirect.html
  clang-tools-extra/docs/_templates/layout.html
  clang-tools-extra/docs/clangd.rst
  clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif
  clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif
  clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png
  clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png
  clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png
  clang-tools-extra/docs/clangd/CodeCompletionInYCM.png
  
clang-tools-extra/docs/clangd/CodeCompletionInsertsNamespaceQualifiersInVSCode.gif
  clang-tools-extra/docs/clangd/Configuration.rst
  clang-tools-extra/docs/clangd/DeveloperDocumentation.rst
  clang-tools-extra/docs/clangd/DiagnosticsInEmacsEglot.png
  clang-tools-extra/docs/clangd/ErrorsInVSCode.png
  clang-tools-extra/docs/clangd/Extensions.rst
  clang-tools-extra/docs/clangd/Features.rst
  clang-tools-extra/docs/clangd/FindAllReferencesInVSCode.gif
  clang-tools-extra/docs/clangd/FormatSelectionInVSCode.gif
  clang-tools-extra/docs/clangd/GoToDefinitionInVSCode.gif
  clang-tools-extra/docs/clangd/Installation.rst
  clang-tools-extra/docs/clangd/NavigationWithBreadcrumbsInVSCode.gif
  clang-tools-extra/docs/clangd/OutlineInVSCode.png
  clang-tools-extra/docs/clangd/SignatureHelpInVSCode.gif
  clang-tools-extra/docs/clangd/index.rst
  clang-tools-extra/docs/index.rst

Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -20,8 +20,7 @@
modularize
pp-trace
clang-rename
-   clangd/index
-   clangd/DeveloperDocumentation
+   clangd 
clang-doc
 
 
Index: clang-tools-extra/docs/clangd/index.rst
===
--- clang-tools-extra/docs/clangd/index.rst
+++ clang-tools-extra/docs/clangd/index.rst
@@ -1,28 +1,3 @@
-==
-clangd
-==
-
-.. toctree::
-   :maxdepth: 1
-
-   Installation
-   Features
-   Configuration
-
-What is clangd?
-===
-
-clangd understands your C++ code and adds smart features to your editor: code
-completion, compile errors, go-to-definition and more.
-
-clangd is a language server that implements the `Language Server Protocol
-`__; it can work with
-many editors through a plugin.  Here's Visual Studio Code with the clangd
-plugin, demonstrating code completion:
-
-.. image:: CodeCompletionInVSCode.png
-   :align: center
-   :alt: Code completion in VSCode
-
-clangd is based on the `Clang `__ C++ compiler, and is
-part of the `LLVM `__ project.
+:orphan:
+:template: clangd_redirect.html
+:redirect_target: https://clangd.llvm.org/
Index: clang-tools-extra/docs/clangd/Installation.rst
===
--- clang-tools-extra/docs/clangd/Installation.rst
+++ clang-tools-extra/docs/clangd/Installation.rst
@@ -1,379 +1,3 @@
-===
-Getting started with clangd
-===
-
-.. contents::
-
-.. role:: raw-html(raw)
-   :format: html
-
-To use clangd, you need to:
-
-- install clangd,
-- install a plugin for your editor,
-- tell clangd how your project is built.
-
-Installing clangd
-=
-
-You need a **recent** version of clangd: 7.0 was the first usable release, and
-8.0 is much better.
-
-After installing, ``clangd --version`` should print ``clangd version 7.0.0`` or
-later.
-
-:raw-html:`macOS`
-
-`Homebrew `__ can install clangd along with LLVM:
-
-.. code-block:: console
-
-  $ brew install llvm
-
-If you don't want to use Homebrew, you can download the a binary release of
-LLVM from `releases.llvm.org `__.
-Alongside ``bin/clangd`` you will need at least ``lib/clang/*/include``:
-
-.. code-block:: console
-
-  $ cp clang+llvm-7.0.0/bin/clangd /usr/local/bin/clangd
-  $ cp -r clang+llvm-7.0.0/lib/clang/ /usr/local/lib/
-
-:raw-html:``
-
-:raw-html:`Windows`
-
-Download and run the LLVM installer from `releases.llvm.org
-`__.
-
-:raw-html:``
-
-:raw-html:`Debian/Ubuntu`
-
-The ``clang-tools`` package usually contains an old version of clangd.
-
-Try to install the latest release (8.0):
-
-.. code-block:: console
-
-  $ sudo apt-get install clang-tools-8
-
-If that is not fou

[PATCH] D76053: [clangd] Redirect documentation to clangd.llvm.org.

2020-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 249870.
sammccall added a comment.

also use template for clangd.rst


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76053

Files:
  clang-tools-extra/docs/_templates/clangd_redirect.html
  clang-tools-extra/docs/_templates/layout.html
  clang-tools-extra/docs/clangd.rst
  clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif
  clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif
  clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png
  clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png
  clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png
  clang-tools-extra/docs/clangd/CodeCompletionInYCM.png
  
clang-tools-extra/docs/clangd/CodeCompletionInsertsNamespaceQualifiersInVSCode.gif
  clang-tools-extra/docs/clangd/Configuration.rst
  clang-tools-extra/docs/clangd/DeveloperDocumentation.rst
  clang-tools-extra/docs/clangd/DiagnosticsInEmacsEglot.png
  clang-tools-extra/docs/clangd/ErrorsInVSCode.png
  clang-tools-extra/docs/clangd/Extensions.rst
  clang-tools-extra/docs/clangd/Features.rst
  clang-tools-extra/docs/clangd/FindAllReferencesInVSCode.gif
  clang-tools-extra/docs/clangd/FormatSelectionInVSCode.gif
  clang-tools-extra/docs/clangd/GoToDefinitionInVSCode.gif
  clang-tools-extra/docs/clangd/Installation.rst
  clang-tools-extra/docs/clangd/NavigationWithBreadcrumbsInVSCode.gif
  clang-tools-extra/docs/clangd/OutlineInVSCode.png
  clang-tools-extra/docs/clangd/SignatureHelpInVSCode.gif
  clang-tools-extra/docs/clangd/index.rst
  clang-tools-extra/docs/index.rst

Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -20,8 +20,7 @@
modularize
pp-trace
clang-rename
-   clangd/index
-   clangd/DeveloperDocumentation
+   Clangd 
clang-doc
 
 
Index: clang-tools-extra/docs/clangd/index.rst
===
--- clang-tools-extra/docs/clangd/index.rst
+++ clang-tools-extra/docs/clangd/index.rst
@@ -1,28 +1,3 @@
-==
-clangd
-==
-
-.. toctree::
-   :maxdepth: 1
-
-   Installation
-   Features
-   Configuration
-
-What is clangd?
-===
-
-clangd understands your C++ code and adds smart features to your editor: code
-completion, compile errors, go-to-definition and more.
-
-clangd is a language server that implements the `Language Server Protocol
-`__; it can work with
-many editors through a plugin.  Here's Visual Studio Code with the clangd
-plugin, demonstrating code completion:
-
-.. image:: CodeCompletionInVSCode.png
-   :align: center
-   :alt: Code completion in VSCode
-
-clangd is based on the `Clang `__ C++ compiler, and is
-part of the `LLVM `__ project.
+:orphan:
+:template: clangd_redirect.html
+:redirect_target: https://clangd.llvm.org/
Index: clang-tools-extra/docs/clangd/Installation.rst
===
--- clang-tools-extra/docs/clangd/Installation.rst
+++ clang-tools-extra/docs/clangd/Installation.rst
@@ -1,379 +1,3 @@
-===
-Getting started with clangd
-===
-
-.. contents::
-
-.. role:: raw-html(raw)
-   :format: html
-
-To use clangd, you need to:
-
-- install clangd,
-- install a plugin for your editor,
-- tell clangd how your project is built.
-
-Installing clangd
-=
-
-You need a **recent** version of clangd: 7.0 was the first usable release, and
-8.0 is much better.
-
-After installing, ``clangd --version`` should print ``clangd version 7.0.0`` or
-later.
-
-:raw-html:`macOS`
-
-`Homebrew `__ can install clangd along with LLVM:
-
-.. code-block:: console
-
-  $ brew install llvm
-
-If you don't want to use Homebrew, you can download the a binary release of
-LLVM from `releases.llvm.org `__.
-Alongside ``bin/clangd`` you will need at least ``lib/clang/*/include``:
-
-.. code-block:: console
-
-  $ cp clang+llvm-7.0.0/bin/clangd /usr/local/bin/clangd
-  $ cp -r clang+llvm-7.0.0/lib/clang/ /usr/local/lib/
-
-:raw-html:``
-
-:raw-html:`Windows`
-
-Download and run the LLVM installer from `releases.llvm.org
-`__.
-
-:raw-html:``
-
-:raw-html:`Debian/Ubuntu`
-
-The ``clang-tools`` package usually contains an old version of clangd.
-
-Try to install the latest release (8.0):
-
-.. code-block:: console
-
-  $ sudo apt-get install clang-tools-8
-
-If that is not found, at least ``clang-tools-7`` should be available.
-
-The ``clangd`` executable will be installed as ``/usr/bin/clangd-8``. Make it
-the default ``clangd``:
-
-.. code-block:: console
-
-  $ sudo update-alternatives --install /usr/bin/clangd cla

[PATCH] D76053: [clangd] Redirect documentation to clangd.llvm.org.

2020-03-12 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 249871.
sammccall added a comment.

Fix accidental capitalization


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76053

Files:
  clang-tools-extra/docs/_templates/clangd_redirect.html
  clang-tools-extra/docs/_templates/layout.html
  clang-tools-extra/docs/clangd.rst
  clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif
  clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif
  clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png
  clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png
  clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png
  clang-tools-extra/docs/clangd/CodeCompletionInYCM.png
  
clang-tools-extra/docs/clangd/CodeCompletionInsertsNamespaceQualifiersInVSCode.gif
  clang-tools-extra/docs/clangd/Configuration.rst
  clang-tools-extra/docs/clangd/DeveloperDocumentation.rst
  clang-tools-extra/docs/clangd/DiagnosticsInEmacsEglot.png
  clang-tools-extra/docs/clangd/ErrorsInVSCode.png
  clang-tools-extra/docs/clangd/Extensions.rst
  clang-tools-extra/docs/clangd/Features.rst
  clang-tools-extra/docs/clangd/FindAllReferencesInVSCode.gif
  clang-tools-extra/docs/clangd/FormatSelectionInVSCode.gif
  clang-tools-extra/docs/clangd/GoToDefinitionInVSCode.gif
  clang-tools-extra/docs/clangd/Installation.rst
  clang-tools-extra/docs/clangd/NavigationWithBreadcrumbsInVSCode.gif
  clang-tools-extra/docs/clangd/OutlineInVSCode.png
  clang-tools-extra/docs/clangd/SignatureHelpInVSCode.gif
  clang-tools-extra/docs/clangd/index.rst
  clang-tools-extra/docs/index.rst

Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -20,8 +20,7 @@
modularize
pp-trace
clang-rename
-   clangd/index
-   clangd/DeveloperDocumentation
+   clangd 
clang-doc
 
 
Index: clang-tools-extra/docs/clangd/index.rst
===
--- clang-tools-extra/docs/clangd/index.rst
+++ clang-tools-extra/docs/clangd/index.rst
@@ -1,28 +1,3 @@
-==
-clangd
-==
-
-.. toctree::
-   :maxdepth: 1
-
-   Installation
-   Features
-   Configuration
-
-What is clangd?
-===
-
-clangd understands your C++ code and adds smart features to your editor: code
-completion, compile errors, go-to-definition and more.
-
-clangd is a language server that implements the `Language Server Protocol
-`__; it can work with
-many editors through a plugin.  Here's Visual Studio Code with the clangd
-plugin, demonstrating code completion:
-
-.. image:: CodeCompletionInVSCode.png
-   :align: center
-   :alt: Code completion in VSCode
-
-clangd is based on the `Clang `__ C++ compiler, and is
-part of the `LLVM `__ project.
+:orphan:
+:template: clangd_redirect.html
+:redirect_target: https://clangd.llvm.org/
Index: clang-tools-extra/docs/clangd/Installation.rst
===
--- clang-tools-extra/docs/clangd/Installation.rst
+++ clang-tools-extra/docs/clangd/Installation.rst
@@ -1,379 +1,3 @@
-===
-Getting started with clangd
-===
-
-.. contents::
-
-.. role:: raw-html(raw)
-   :format: html
-
-To use clangd, you need to:
-
-- install clangd,
-- install a plugin for your editor,
-- tell clangd how your project is built.
-
-Installing clangd
-=
-
-You need a **recent** version of clangd: 7.0 was the first usable release, and
-8.0 is much better.
-
-After installing, ``clangd --version`` should print ``clangd version 7.0.0`` or
-later.
-
-:raw-html:`macOS`
-
-`Homebrew `__ can install clangd along with LLVM:
-
-.. code-block:: console
-
-  $ brew install llvm
-
-If you don't want to use Homebrew, you can download the a binary release of
-LLVM from `releases.llvm.org `__.
-Alongside ``bin/clangd`` you will need at least ``lib/clang/*/include``:
-
-.. code-block:: console
-
-  $ cp clang+llvm-7.0.0/bin/clangd /usr/local/bin/clangd
-  $ cp -r clang+llvm-7.0.0/lib/clang/ /usr/local/lib/
-
-:raw-html:``
-
-:raw-html:`Windows`
-
-Download and run the LLVM installer from `releases.llvm.org
-`__.
-
-:raw-html:``
-
-:raw-html:`Debian/Ubuntu`
-
-The ``clang-tools`` package usually contains an old version of clangd.
-
-Try to install the latest release (8.0):
-
-.. code-block:: console
-
-  $ sudo apt-get install clang-tools-8
-
-If that is not found, at least ``clang-tools-7`` should be available.
-
-The ``clangd`` executable will be installed as ``/usr/bin/clangd-8``. Make it
-the default ``clangd``:
-
-.. code-block:: console
-
-  $ sudo update-alternatives --install /usr/bin/clangd clangd

[clang] b720543 - [AST] Respect shouldTraversePostOrder when traversing type locs

2020-03-12 Thread Dmitri Gribenko via cfe-commits

Author: Marcel Hlopko
Date: 2020-03-12T11:08:33+01:00
New Revision: b720543926c7cda94662ae99182ba63bc23a8ff1

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

LOG: [AST] Respect shouldTraversePostOrder when traversing type locs

Summary: Copy of https://reviews.llvm.org/D72072, submitting with 
ilya-biryukov's permission.

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3dc9af4b8042..ce66eeef7a82 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1127,10 +1127,17 @@ DEF_TRAVERSE_TYPE(PipeType, { 
TRY_TO(TraverseType(T->getElementType())); })
 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE)   
\
   template   
\
   bool RecursiveASTVisitor::Traverse##TYPE##Loc(TYPE##Loc TL) {   
\
-if (getDerived().shouldWalkTypesOfTypeLocs())  
\
-  TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(;   
\
-TRY_TO(WalkUpFrom##TYPE##Loc(TL)); 
\
+if (!getDerived().shouldTraversePostOrder()) { 
\
+  TRY_TO(WalkUpFrom##TYPE##Loc(TL));   
\
+  if (getDerived().shouldWalkTypesOfTypeLocs())
\
+TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(; 
\
+}  
\
 { CODE; }  
\
+if (getDerived().shouldTraversePostOrder()) {  
\
+  TRY_TO(WalkUpFrom##TYPE##Loc(TL));   
\
+  if (getDerived().shouldWalkTypesOfTypeLocs())
\
+TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(; 
\
+}  
\
 return true;   
\
   }
 
@@ -1199,22 +1206,22 @@ bool 
RecursiveASTVisitor::TraverseArrayTypeLocHelper(ArrayTypeLoc TL) {
 
 DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(VariableArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(DependentAddressSpaceType, {



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


[clang-tools-extra] 57e81a2 - [clangd] Redirect documentation to clangd.llvm.org.

2020-03-12 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-12T11:45:40+01:00
New Revision: 57e81a2f649099229e1d50b36aeee5eb1b9e3d49

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

LOG: [clangd] Redirect documentation to clangd.llvm.org.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 
clang-tools-extra/docs/_templates/clangd_redirect.html

Modified: 
clang-tools-extra/docs/_templates/layout.html
clang-tools-extra/docs/clangd.rst
clang-tools-extra/docs/clangd/Configuration.rst
clang-tools-extra/docs/clangd/DeveloperDocumentation.rst
clang-tools-extra/docs/clangd/Extensions.rst
clang-tools-extra/docs/clangd/Features.rst
clang-tools-extra/docs/clangd/Installation.rst
clang-tools-extra/docs/clangd/index.rst
clang-tools-extra/docs/index.rst

Removed: 
clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif
clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif
clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png
clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png
clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png
clang-tools-extra/docs/clangd/CodeCompletionInYCM.png

clang-tools-extra/docs/clangd/CodeCompletionInsertsNamespaceQualifiersInVSCode.gif
clang-tools-extra/docs/clangd/DiagnosticsInEmacsEglot.png
clang-tools-extra/docs/clangd/ErrorsInVSCode.png
clang-tools-extra/docs/clangd/FindAllReferencesInVSCode.gif
clang-tools-extra/docs/clangd/FormatSelectionInVSCode.gif
clang-tools-extra/docs/clangd/GoToDefinitionInVSCode.gif
clang-tools-extra/docs/clangd/NavigationWithBreadcrumbsInVSCode.gif
clang-tools-extra/docs/clangd/OutlineInVSCode.png
clang-tools-extra/docs/clangd/SignatureHelpInVSCode.gif



diff  --git a/clang-tools-extra/docs/_templates/clangd_redirect.html 
b/clang-tools-extra/docs/_templates/clangd_redirect.html
new file mode 100644
index ..c4f6927a3cc2
--- /dev/null
+++ b/clang-tools-extra/docs/_templates/clangd_redirect.html
@@ -0,0 +1,14 @@
+
+{% set target = meta.redirect_target %}
+
+
+  The clangd documentation has moved to clangd.llvm.org
+  
+  
+
+
+  The clangd documentation has moved to clangd.llvm.org
+  The new site
+  window.location='{{ target }}'
+
+

diff  --git a/clang-tools-extra/docs/_templates/layout.html 
b/clang-tools-extra/docs/_templates/layout.html
index b4f5b4e1ebd0..dd20b6f74fdc 100644
--- a/clang-tools-extra/docs/_templates/layout.html
+++ b/clang-tools-extra/docs/_templates/layout.html
@@ -1,3 +1,3 @@
-{% extends "!layout.html" %}
+{% extends (meta|default({})).template|default("!layout.html") %}
 
 {% set css_files = css_files + ['_static/clang-tools-extra-styles.css'] %}

diff  --git a/clang-tools-extra/docs/clangd.rst 
b/clang-tools-extra/docs/clangd.rst
index 7910fac3ec8d..70bab8354a75 100644
--- a/clang-tools-extra/docs/clangd.rst
+++ b/clang-tools-extra/docs/clangd.rst
@@ -1,6 +1,3 @@
 :orphan:
-
-.. meta::
-   :http-equiv=refresh: 0;URL='clangd/'
-
-All :program:`clangd` documentation was moved to the :doc:`clangd/index` pages.
+:template: clangd_redirect.html
+:redirect_target: https://clangd.llvm.org/

diff  --git a/clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif 
b/clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif
deleted file mode 100644
index b07bdeb437df..
Binary files a/clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif and 
/dev/null 
diff er

diff  --git a/clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif 
b/clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif
deleted file mode 100644
index 929a98c31798..
Binary files a/clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif and /dev/null 
diff er

diff  --git 
a/clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png 
b/clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png
deleted file mode 100644
index 1accc5af5771..
Binary files 
a/clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png and 
/dev/null 
diff er

diff  --git a/clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png 
b/clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png
deleted file mode 100644
index b09fed3bdfa2..
Binary files a/clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png 
and /dev/null 
diff er

diff  --git a/clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png 
b/clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png
deleted file mode 100644
index bc42e9dd7321..
Binary files a/clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png and 
/dev/null 
diff er

diff  --git a/clang-tools-extra/docs/clangd/CodeComp

[PATCH] D76037: [clang] tooling replacements are escaped when exporting to YAML

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249875.
njames93 added a comment.

- Fix broken dependencies


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76037

Files:
  clang-tools-extra/clang-apply-replacements/CMakeLists.txt
  clang/include/clang/Tooling/ReplacementsYaml.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ReplacementsYaml.cpp
  clang/unittests/Tooling/ReplacementsYamlTest.cpp

Index: clang/unittests/Tooling/ReplacementsYamlTest.cpp
===
--- clang/unittests/Tooling/ReplacementsYamlTest.cpp
+++ clang/unittests/Tooling/ReplacementsYamlTest.cpp
@@ -46,28 +46,36 @@
YamlContentStream.str().c_str());
 }
 
-TEST(ReplacementsYamlTest, serializesNewLines) {
-  TranslationUnitReplacements Doc;
+TEST(ReplacementsYamlTest, handlesEscaped) {
+  TranslationUnitReplacements Doc, NewDoc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Replacements.emplace_back("/path/to/file1.h", 0, 0, "#include \n");
+  const StringRef FilePath = "/path/to/file1.h";
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "#include \n");
+  Doc.Replacements.emplace_back(FilePath, 0, 0, "'\\\t\r\n");
 
-  std::string YamlContent;
-  llvm::raw_string_ostream YamlContentStream(YamlContent);
+  SmallString<512> YamlContent;
+  llvm::raw_svector_ostream YamlContentStream(YamlContent);
 
   yaml::Output YAML(YamlContentStream);
   YAML << Doc;
+  yaml::Input IYAML(YamlContent);
+  IYAML >> NewDoc;
 
-  // NOTE: If this test starts to fail for no obvious reason, check whitespace.
-  ASSERT_STREQ("---\n"
-   "MainSourceFile:  '/path/to/source.cpp'\n"
-   "Replacements:\n"
-   "  - FilePath:'/path/to/file1.h'\n"
-   "Offset:  0\n"
-   "Length:  0\n"
-   "ReplacementText: '#include \n\n'\n"
-   "...\n",
-   YamlContentStream.str().c_str());
+  ASSERT_FALSE(IYAML.error());
+  ASSERT_EQ(Doc.MainSourceFile, NewDoc.MainSourceFile);
+  ASSERT_EQ(Doc.Replacements.size(), NewDoc.Replacements.size());
+  if (Doc.Replacements.size() == NewDoc.Replacements.size()) {
+for (auto DocR = Doc.Replacements.begin(),
+  NewDocR = NewDoc.Replacements.begin(),
+  DocE = Doc.Replacements.end();
+ DocR != DocE; DocR++, NewDocR++) {
+  ASSERT_EQ(DocR->getFilePath(), NewDocR->getFilePath());
+  ASSERT_EQ(DocR->getLength(), NewDocR->getLength());
+  ASSERT_EQ(DocR->getOffset(), NewDocR->getOffset());
+  ASSERT_EQ(DocR->getReplacementText(), NewDocR->getReplacementText());
+}
+  }
 }
 
 TEST(ReplacementsYamlTest, deserializesReplacements) {
Index: clang/lib/Tooling/ReplacementsYaml.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ReplacementsYaml.cpp
@@ -0,0 +1,74 @@
+//===-- ReplacementsYaml.cpp -- Serialiazation for Replacements ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/ReplacementsYaml.h"
+
+namespace llvm {
+namespace yaml {
+
+namespace {
+struct Escapes {
+  char EscapeChar;
+  char WrittenChar;
+};
+} // namespace
+
+static constexpr Escapes EscapeChars[] = {
+{'\n', 'n'}, {'\r', 'r'}, {'\t', 't'}, {'\\', '\\'}};
+
+std::string
+MappingTraits::NormalizedReplacement::escape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  for (char C : Str) {
+if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+  if (C == Escape.EscapeChar) {
+Builder << '\\' << Escape.WrittenChar;
+return true;
+  }
+  return false;
+})) {
+  Builder << C;
+}
+  }
+  return Res;
+}
+
+std::string
+MappingTraits::NormalizedReplacement::unescape(
+StringRef Str) {
+  std::string Res;
+  llvm::raw_string_ostream Builder(Res);
+  while (!Str.empty()) {
+if (Str.consume_front("\\")) {
+  if (Str.empty()) {
+Builder << '\\';
+break;
+  }
+  char C = Str.front();
+  Str = Str.drop_front();
+  if (llvm::none_of(EscapeChars, [&](Escapes Escape) {
+if (C == Escape.WrittenChar) {
+  Builder << Escape.EscapeChar;
+  return true;
+}
+return false;
+  })) {
+Builder << '\\' << C;
+  }
+  continue;
+}
+Builder << Str.front();
+Str = Str.drop_front();
+  }
+  return Res;
+}
+
+} // namespace yaml
+} // namespace llvm
Index: clang/lib/Tooling/CMakeLists.txt
===
--- clang/lib/Tooling/CMakeLists.

[PATCH] D76054: [clang-apply-replacements] No longer deduplucates replacements from the same TU

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Test cases will follow, just time constrained for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76054



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


[PATCH] D76054: [clang-apply-replacements] No longer deduplucates replacements from the same TU

2020-03-12 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, AlexanderLanin.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
njames93 added a comment.

Test cases will follow, just time constrained for now.


clang-apply-replacements currently deduplicates all diagnostic replacements. 
However if you get a duplicated replacement from one TU then its expected that 
it should not be deduplicated. This goes some way to solving export-fixes to 
yaml adds extra newlines and breaks offsets. 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76054

Files:
  clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp


Index: 
clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -145,16 +145,21 @@
 
   // Deduplicate identical replacements in diagnostics.
   // FIXME: Find an efficient way to deduplicate on diagnostics level.
-  llvm::DenseMap>
+  llvm::DenseMap>
   DiagReplacements;
 
-  auto AddToGroup = [&](const tooling::Replacement &R, bool FromDiag) {
+  auto AddToGroup = [&](const tooling::Replacement &R,
+const tooling::TranslationUnitDiagnostics *FromTU) {
 // Use the file manager to deduplicate paths. FileEntries are
 // automatically canonicalized.
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
-  if (FromDiag) {
+  if (FromTU) {
 auto &Replaces = DiagReplacements[*Entry];
-if (!Replaces.insert(R).second)
+if (Replaces.find(R) == Replaces.end())
+  Replaces.emplace(R, FromTU);
+else if (Replaces.at(R) != FromTU)
   return;
   }
   GroupedReplacements[*Entry].push_back(R);
@@ -166,14 +171,14 @@
 
   for (const auto &TU : TUs)
 for (const tooling::Replacement &R : TU.Replacements)
-  AddToGroup(R, false);
+  AddToGroup(R, nullptr);
 
   for (const auto &TU : TUDs)
 for (const auto &D : TU.Diagnostics)
   if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
 for (const auto &Fix : *ChoosenFix)
   for (const tooling::Replacement &R : Fix.second)
-AddToGroup(R, true);
+AddToGroup(R, &TU);
   }
 
   // Sort replacements per file to keep consistent behavior when


Index: clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
===
--- clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
+++ clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
@@ -145,16 +145,21 @@
 
   // Deduplicate identical replacements in diagnostics.
   // FIXME: Find an efficient way to deduplicate on diagnostics level.
-  llvm::DenseMap>
+  llvm::DenseMap>
   DiagReplacements;
 
-  auto AddToGroup = [&](const tooling::Replacement &R, bool FromDiag) {
+  auto AddToGroup = [&](const tooling::Replacement &R,
+const tooling::TranslationUnitDiagnostics *FromTU) {
 // Use the file manager to deduplicate paths. FileEntries are
 // automatically canonicalized.
 if (auto Entry = SM.getFileManager().getFile(R.getFilePath())) {
-  if (FromDiag) {
+  if (FromTU) {
 auto &Replaces = DiagReplacements[*Entry];
-if (!Replaces.insert(R).second)
+if (Replaces.find(R) == Replaces.end())
+  Replaces.emplace(R, FromTU);
+else if (Replaces.at(R) != FromTU)
   return;
   }
   GroupedReplacements[*Entry].push_back(R);
@@ -166,14 +171,14 @@
 
   for (const auto &TU : TUs)
 for (const tooling::Replacement &R : TU.Replacements)
-  AddToGroup(R, false);
+  AddToGroup(R, nullptr);
 
   for (const auto &TU : TUDs)
 for (const auto &D : TU.Diagnostics)
   if (const auto *ChoosenFix = tooling::selectFirstFix(D)) {
 for (const auto &Fix : *ChoosenFix)
   for (const tooling::Replacement &R : Fix.second)
-AddToGroup(R, true);
+AddToGroup(R, &TU);
   }
 
   // Sort replacements per file to keep consistent behavior when
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72072: [AST] Respect shouldTraversePostOrder when traversing type locs

2020-03-12 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 closed this revision.
gribozavr2 added a comment.

Superseded by https://reviews.llvm.org/D76001.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72072



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


[PATCH] D76053: [clangd] Redirect documentation to clangd.llvm.org.

2020-03-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

woohoo!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76053



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


[PATCH] D76001: [AST] Respect shouldTraversePostOrder when traversing type locs

2020-03-12 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb720543926c7: [AST] Respect shouldTraversePostOrder when 
traversing type locs (authored by hlopko, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76001

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1127,10 +1127,17 @@
 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE)   
\
   template   
\
   bool RecursiveASTVisitor::Traverse##TYPE##Loc(TYPE##Loc TL) {   
\
-if (getDerived().shouldWalkTypesOfTypeLocs())  
\
-  TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(;   
\
-TRY_TO(WalkUpFrom##TYPE##Loc(TL)); 
\
+if (!getDerived().shouldTraversePostOrder()) { 
\
+  TRY_TO(WalkUpFrom##TYPE##Loc(TL));   
\
+  if (getDerived().shouldWalkTypesOfTypeLocs())
\
+TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(; 
\
+}  
\
 { CODE; }  
\
+if (getDerived().shouldTraversePostOrder()) {  
\
+  TRY_TO(WalkUpFrom##TYPE##Loc(TL));   
\
+  if (getDerived().shouldWalkTypesOfTypeLocs())
\
+TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(; 
\
+}  
\
 return true;   
\
   }
 
@@ -1199,22 +1206,22 @@
 
 DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(VariableArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(DependentSizedArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(DependentAddressSpaceType, {


Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -1127,10 +1127,17 @@
 #define DEF_TRAVERSE_TYPELOC(TYPE, CODE)   \
   template   \
   bool RecursiveASTVisitor::Traverse##TYPE##Loc(TYPE##Loc TL) {   \
-if (getDerived().shouldWalkTypesOfTypeLocs())  \
-  TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(;   \
-TRY_TO(WalkUpFrom##TYPE##Loc(TL)); \
+if (!getDerived().shouldTraversePostOrder()) { \
+  TRY_TO(WalkUpFrom##TYPE##Loc(TL));   \
+  if (getDerived().shouldWalkTypesOfTypeLocs())\
+TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(; \
+}  \
 { CODE; }  \
+if (getDerived().shouldTraversePostOrder()) {  \
+  TRY_TO(WalkUpFrom##TYPE##Loc(TL));   \
+  if (getDerived().shouldWalkTypesOfTypeLocs())\
+TRY_TO(WalkUpFrom##TYPE(const_cast(TL.getTypePtr(; \
+}  \
 return true;   \
   }
 
@@ -1199,22 +1206,22 @@
 
 DEF_TRAVERSE_TYPELOC(ConstantArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_TRAVERSE_TYPELOC(IncompleteArrayType, {
   TRY_TO(TraverseTypeLoc(TL.getElementLoc()));
-  return TraverseArrayTypeLocHelper(TL);
+  TRY_TO(TraverseArrayTypeLocHelper(TL));
 })
 
 DEF_T

[PATCH] D76053: [clangd] Redirect documentation to clangd.llvm.org.

2020-03-12 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG57e81a2f6490: [clangd] Redirect documentation to 
clangd.llvm.org. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76053

Files:
  clang-tools-extra/docs/_templates/clangd_redirect.html
  clang-tools-extra/docs/_templates/layout.html
  clang-tools-extra/docs/clangd.rst
  clang-tools-extra/docs/clangd/ApplyClangTidyFixInVSCode.gif
  clang-tools-extra/docs/clangd/ApplyFixInVSCode.gif
  clang-tools-extra/docs/clangd/CodeCompletionInEmacsCompanyMode.png
  clang-tools-extra/docs/clangd/CodeCompletionInSublimeText.png
  clang-tools-extra/docs/clangd/CodeCompletionInVSCode.png
  clang-tools-extra/docs/clangd/CodeCompletionInYCM.png
  
clang-tools-extra/docs/clangd/CodeCompletionInsertsNamespaceQualifiersInVSCode.gif
  clang-tools-extra/docs/clangd/Configuration.rst
  clang-tools-extra/docs/clangd/DeveloperDocumentation.rst
  clang-tools-extra/docs/clangd/DiagnosticsInEmacsEglot.png
  clang-tools-extra/docs/clangd/ErrorsInVSCode.png
  clang-tools-extra/docs/clangd/Extensions.rst
  clang-tools-extra/docs/clangd/Features.rst
  clang-tools-extra/docs/clangd/FindAllReferencesInVSCode.gif
  clang-tools-extra/docs/clangd/FormatSelectionInVSCode.gif
  clang-tools-extra/docs/clangd/GoToDefinitionInVSCode.gif
  clang-tools-extra/docs/clangd/Installation.rst
  clang-tools-extra/docs/clangd/NavigationWithBreadcrumbsInVSCode.gif
  clang-tools-extra/docs/clangd/OutlineInVSCode.png
  clang-tools-extra/docs/clangd/SignatureHelpInVSCode.gif
  clang-tools-extra/docs/clangd/index.rst
  clang-tools-extra/docs/index.rst

Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -20,8 +20,7 @@
modularize
pp-trace
clang-rename
-   clangd/index
-   clangd/DeveloperDocumentation
+   clangd 
clang-doc
 
 
Index: clang-tools-extra/docs/clangd/index.rst
===
--- clang-tools-extra/docs/clangd/index.rst
+++ clang-tools-extra/docs/clangd/index.rst
@@ -1,28 +1,3 @@
-==
-clangd
-==
-
-.. toctree::
-   :maxdepth: 1
-
-   Installation
-   Features
-   Configuration
-
-What is clangd?
-===
-
-clangd understands your C++ code and adds smart features to your editor: code
-completion, compile errors, go-to-definition and more.
-
-clangd is a language server that implements the `Language Server Protocol
-`__; it can work with
-many editors through a plugin.  Here's Visual Studio Code with the clangd
-plugin, demonstrating code completion:
-
-.. image:: CodeCompletionInVSCode.png
-   :align: center
-   :alt: Code completion in VSCode
-
-clangd is based on the `Clang `__ C++ compiler, and is
-part of the `LLVM `__ project.
+:orphan:
+:template: clangd_redirect.html
+:redirect_target: https://clangd.llvm.org/
Index: clang-tools-extra/docs/clangd/Installation.rst
===
--- clang-tools-extra/docs/clangd/Installation.rst
+++ clang-tools-extra/docs/clangd/Installation.rst
@@ -1,379 +1,3 @@
-===
-Getting started with clangd
-===
-
-.. contents::
-
-.. role:: raw-html(raw)
-   :format: html
-
-To use clangd, you need to:
-
-- install clangd,
-- install a plugin for your editor,
-- tell clangd how your project is built.
-
-Installing clangd
-=
-
-You need a **recent** version of clangd: 7.0 was the first usable release, and
-8.0 is much better.
-
-After installing, ``clangd --version`` should print ``clangd version 7.0.0`` or
-later.
-
-:raw-html:`macOS`
-
-`Homebrew `__ can install clangd along with LLVM:
-
-.. code-block:: console
-
-  $ brew install llvm
-
-If you don't want to use Homebrew, you can download the a binary release of
-LLVM from `releases.llvm.org `__.
-Alongside ``bin/clangd`` you will need at least ``lib/clang/*/include``:
-
-.. code-block:: console
-
-  $ cp clang+llvm-7.0.0/bin/clangd /usr/local/bin/clangd
-  $ cp -r clang+llvm-7.0.0/lib/clang/ /usr/local/lib/
-
-:raw-html:``
-
-:raw-html:`Windows`
-
-Download and run the LLVM installer from `releases.llvm.org
-`__.
-
-:raw-html:``
-
-:raw-html:`Debian/Ubuntu`
-
-The ``clang-tools`` package usually contains an old version of clangd.
-
-Try to install the latest release (8.0):
-
-.. code-block:: console
-
-  $ sudo apt-get install clang-tools-8
-
-If that is not found, at least ``clang-tools-7`` should be available.
-
-The ``clangd`` executable will be installed as ``/usr/bin/clangd-8``. Make it
-the default ``clangd``:
-
-.. code-bl

[clang] d608fee - [ARM, MVE] Fix user-namespace violation in arm_mve.h.

2020-03-12 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-03-12T11:13:50Z
New Revision: d608fee8399a9fa6f2819076131c6ac30cc16eef

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

LOG: [ARM,MVE] Fix user-namespace violation in arm_mve.h.

Summary:
We were generating the declarations of polymorphic intrinsics using
`__attribute__((overloadable))`. But `overloadable` is a valid
identifier for an end user to define as a macro in a C program, and if
they do that before including ``, then we shouldn't cause a
compile error.

Fixed to spell the attribute name `__overloadable__` instead.

Reviewers: miyuki, MarkMurrayARM, ostannard

Reviewed By: miyuki

Subscribers: kristof.beyls, dmgreen, danielkiss, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/utils/TableGen/MveEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/MveEmitter.cpp 
b/clang/utils/TableGen/MveEmitter.cpp
index 9a9fe00eed74..f75f5000f0f6 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -1874,7 +1874,7 @@ void MveEmitter::EmitHeader(raw_ostream &OS) {
 // match your call".
 
 OS << "static __inline__ __attribute__(("
-   << (Polymorphic ? "overloadable, " : "")
+   << (Polymorphic ? "__overloadable__, " : "")
<< "__clang_arm_builtin_alias(__builtin_arm_mve_" << Int.fullName()
<< ")))\n"
<< RetTypeName << FunctionName << "(" << ArgTypesString << ");\n";
@@ -2041,7 +2041,7 @@ void CdeEmitter::EmitHeader(raw_ostream &OS) {
   // Emit the actual declaration. See MveEmitter::EmitHeader for detailed
   // comments
   OS << "static __inline__ __attribute__(("
- << (Polymorphic ? "overloadable, " : "")
+ << (Polymorphic ? "__overloadable__, " : "")
  << "__clang_arm_builtin_alias(__builtin_arm_" << 
Int.builtinExtension()
  << "_" << Int.fullName() << ")))\n"
  << RetTypeName << FunctionName << "(" << ArgTypesString << ");\n";



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


[clang] 3f8e714 - [ARM,MVE] Add intrinsics and isel for MVE fused multiply-add.

2020-03-12 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-03-12T11:13:50Z
New Revision: 3f8e714e2f9f2dc3367d2f3fc569abfaf28f314c

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

LOG: [ARM,MVE] Add intrinsics and isel for MVE fused multiply-add.

Summary:
This adds the ACLE intrinsic family for the VFMA and VFMS
instructions, which perform fused multiply-add on vectors of floats.

I've represented the unpredicated versions in IR using the cross-
platform `@llvm.fma` IR intrinsic. We already had isel rules to
convert one of those into a vector VFMA in the simplest possible way;
but we didn't have rules to detect a negated argument and turn it into
VFMS, or rules to detect a splat argument and turn it into one of the
two vector/scalar forms of the instruction. Now we have all of those.

The predicated form uses a target-specific intrinsic as usual, but
I've stuck to just one, for a predicated FMA. The subtraction and
splat versions are code-generated by passing an fneg or a splat as one
of its operands, the same way as the unpredicated version.

In arm_mve_defs.h, I've had to introduce a tiny extra piece of
infrastructure: a record `id` for use in codegen dags which implements
the identity function. (Just because you can't declare a Tablegen
value of type dag which is //only// a `$varname`: you have to wrap it
in something. Now I can write `(id $varname)` to get the same effect.)

Reviewers: dmgreen, MarkMurrayARM, miyuki, ostannard

Reviewed By: dmgreen

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

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/ternary.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td
llvm/test/CodeGen/Thumb2/mve-fmas.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index d9a2035e8a0e..d2203d650301 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -162,6 +162,46 @@ let pnt = PNT_NType in {
 }
 }
 
+multiclass FMA {
+  // FMS instructions are defined in the ArmARM as if they negate the
+  // second multiply input.
+  defvar m2_cg = !if(add, (id $m2), (fneg $m2));
+
+  defvar unpred_cg = (IRIntBase<"fma", [Vector]> $m1, m2_cg, $addend);
+  defvar pred_cg   = (IRInt<"fma_predicated", [Vector, Predicate]>
+  $m1, m2_cg, $addend, $pred);
+
+  def q: Intrinsic;
+
+  def q_m: Intrinsic;
+
+  // Only FMA has the vector/scalar variants, not FMS
+  if add then let pnt = PNT_NType in {
+
+def q_n: Intrinsic:$m2_s),
+ (seq (splat $m2_s):$m2, unpred_cg)>;
+def sq_n: Intrinsic:$addend_s),
+(seq (splat $addend_s):$addend, unpred_cg)>;
+def q_m_n: Intrinsic:$m2_s,
+   Predicate:$pred),
+ (seq (splat $m2_s):$m2, pred_cg)>;
+def sq_m_n: Intrinsic:$addend_s,
+Predicate:$pred),
+  (seq (splat $addend_s):$addend, pred_cg)>;
+  }
+}
+
+let params = T.Float in {
+  defm vfma: FMA<1>;
+  defm vfms: FMA<0>;
+}
+
 let params = !listconcat(T.Int16, T.Int32) in {
   let pnt = PNT_None in {
 def vmvnq_n: Intrinsic {
 }
 def zip: CGHelperFn<"VectorZip">;
 
+// Trivial 'codegen' function that just returns its argument. Useful
+// for wrapping up a variable name like $foo into a thing you can pass
+// around as type 'dag'.
+def id: IRBuilderBase {
+  // All the other cases of IRBuilderBase use 'prefix' to specify a function
+  // call, including the open parenthesis. MveEmitter puts the closing paren on
+  // the end. So if we _just_ specify an open paren with no function name
+  // before it, then the generated C++ code will simply wrap the input value in
+  // parentheses, returning it unchanged.
+  let prefix = "(";
+}
+
 // Helper for making boolean flags in IR
 def i1: IRBuilderBase {
   let prefix = "llvm::ConstantInt::get(Builder.getInt1Ty(), ";

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/ternary.c 
b/clang/test/CodeGen/arm-mve-intrinsics/ternary.c
new file mode 100644
index ..ab1cb14c3aed
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/ternary.c
@@ -0,0 +1,261 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -sroa | FileCheck %s
+// RUN: %clang_cc1 -triple th

[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-12 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D73534#1916309 , @djtodoro wrote:

> In D73534#1916291 , @djtodoro wrote:
>
> > In D73534#1915048 , @mstorsjo 
> > wrote:
> >
> > > This broke compiling for mingw, repro.c:
> > >
> > >   a(short);
> > >   b() { a(1); }
> > >
> > >
> > > `clang -target x86_64-w64-mingw32 -c repro.c -g -O2`, which gives 
> > > `Assertion '!MI.isMoveImmediate() && "Unexpected MoveImm instruction"' 
> > > failed.`
> >
> >
> > Thanks for reporting this! Since this is the case of the `X86::MOV16ri` the 
> > D75326  will solve this issue.
>
>
> The alternative is D75974 .


The D75974  is commited.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-12 Thread David Stenberg via Phabricator via cfe-commits
dstenb added a comment.

In D73534#1918890 , @manojgupta wrote:

> Hi,
>
> I see another crash with this change when building gdb.
>
> Reduced test case:
>  struct type *a(type *, type *, long, long);
>  enum b {};
>  static int empty_array(type *, int c) { type *d = a(__null, d, c, c - 1); }
>  long e;
>  b f() { empty_array(0, e); }
>
> Repros with:
>  clang -cc1 -triple x86_64-linux-gnu -emit-obj -disable-free 
> -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix 
> -mframe-pointer=all  -mconstructor-aliases -munwind-tables  
> -dwarf-column-info  -debug-info-kind=limited -dwarf-version=4 
> -debugger-tuning=gdb  -O2  -x c++
>
> Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1060788


Oh, that assertion is related to D75036  which 
I did. I can have a look at that.


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-12 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Hi,

I see another crash with this change when building gdb.

Reduced test case:
struct type *a(type *, type *, long, long);
enum b {};
static int empty_array(type *, int c) { type *d = a(__null, d, c, c - 1); }
long e;
b f() { empty_array(0, e); }

Repros with:
clang -cc1 -triple x86_64-linux-gnu -emit-obj -disable-free -mrelocation-model 
pic -pic-level 2 -pic-is-pie -mthread-model posix -mframe-pointer=all  
-mconstructor-aliases -munwind-tables  -dwarf-column-info  
-debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb  -O2  -x c++

Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1060788


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-12 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D73534#1918818 , @djtodoro wrote:

> In D73534#1916309 , @djtodoro wrote:
>
> > In D73534#1916291 , @djtodoro 
> > wrote:
> >
> > > Thanks for reporting this! Since this is the case of the `X86::MOV16ri` 
> > > the D75326  will solve this issue.
> >
> >
> > The alternative is D75974 .
>
>
> The D75974  is commited.


Thanks!


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

https://reviews.llvm.org/D73534



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


[PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-12 Thread David Stenberg via Phabricator via cfe-commits
dstenb added a comment.

In D73534#1918940 , @dstenb wrote:

> In D73534#1918890 , @manojgupta 
> wrote:
>
> > Hi,
> >
> > I see another crash with this change when building gdb.
> >
> > Reduced test case:
> >  struct type *a(type *, type *, long, long);
> >  enum b {};
> >  static int empty_array(type *, int c) { type *d = a(__null, d, c, c - 1); }
> >  long e;
> >  b f() { empty_array(0, e); }
> >
> > Repros with:
> >  clang -cc1 -triple x86_64-linux-gnu -emit-obj -disable-free 
> > -mrelocation-model pic -pic-level 2 -pic-is-pie -mthread-model posix 
> > -mframe-pointer=all  -mconstructor-aliases -munwind-tables  
> > -dwarf-column-info  -debug-info-kind=limited -dwarf-version=4 
> > -debugger-tuning=gdb  -O2  -x c++
> >
> > Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1060788
>
>
> Oh, that assertion is related to D75036  
> which I did. I can have a look at that.


I wrote a PR for that: https://bugs.llvm.org/show_bug.cgi?id=45181.

I'll see if I'm able to put together something for that today.


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

https://reviews.llvm.org/D73534



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


[PATCH] D75443: [AST] Unpack FPFeatures bits to BinaryOperator, NFC.

2020-03-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D75443#1917351 , @mibintc wrote:

> I ran into an obstacle trying to add Trailing storage onto binary operator. 
> it will probably take me longer.


sure, no worries, and thanks for your help. It is not super urgent for us at 
the moment (we have other patches under review).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75443



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


[Diffusion] rG825235c140e7: Revert "[Sema] Use the canonical type in function isVector"

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

> I'm still not sure why __fp16, which is a storage-only type, is used for the 
> element type of float16x4_t if we want to avoid promotion to a float vector 
> type.

About the types: `__fp16` this is the older, storage-only type. So, just 
historically, I think this element type was used to describe the neon vectors, 
which translates to vectors with elements of i16 or f16, which all seems fine.

> Was there a discussion on llvm-dev or phabricator?

I don't think this is necessary, because this is how it's been from let's say 
the beginning.

> Can we change the element type of the vector to _Float16?

I don't see a benefit of doing this, and making this perhaps intrusive change.

> It seems that the original plan discussed on llvm-dev 
> (http://lists.llvm.org/pipermail/cfe-dev/2017-May/053768.html) was to 
> introduce _Float16 and use it instead of __fp16 for ARMv8.2-A, but the 
> subsequent patches that were committed are making NeonEmitter.cpp emit 
> typedefs of vectors that have __fp16 as the element type.

Then `_Float16` came along, which is a proper half type (not a storage only 
type), is defined in a C11 extension, and should be used for the ARMv8.2-A 
native half instructions; the semantics of `__fp16` and `_Float16` are 
different, and as a result using `__fp16` for the v8.2 half FP instructions is 
not an option, so it is not a matter of using `_Float16` instead of `__fp16`.

As I said, your problem wasn't clear to me, so let's look at your example:

> For example, in vneg_f16, __p0 is promoted to a vector of float before it's 
> negated.
> 
> __ai float16x4_t vneg_f16(float16x4_t __p0) {
> 
>   float16x4_t __ret;
>__ret = -__p0;
>return __ret;
> 
> }

when I compile this and emit llvm ir I get this:

  define dso_local <2 x i32> @vneg_f16(<2 x i32> %__p0.coerce) 
local_unnamed_addr #0 {
  entry:
%0 = bitcast <2 x i32> %__p0.coerce to <4 x half>
%fneg = fneg fast <4 x half> %0
%1 = bitcast <4 x half> %fneg to <2 x i32>
ret <2 x i32> %1
  }

so far so good I think: this shows a fneg on vector of halfs.

Where and when do you see problems? Can you describe this, and also provide 
your compile commands?


BRANCHES
  master, release/10.x

Users:
  ahatanak (Author)

https://reviews.llvm.org/rG825235c140e7



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


[PATCH] D75997: [ARM,MVE] Fix user-namespace violation in arm_mve.h.

2020-03-12 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd608fee8399a: [ARM,MVE] Fix user-namespace violation in 
arm_mve.h. (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75997

Files:
  clang/utils/TableGen/MveEmitter.cpp


Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -1874,7 +1874,7 @@
 // match your call".
 
 OS << "static __inline__ __attribute__(("
-   << (Polymorphic ? "overloadable, " : "")
+   << (Polymorphic ? "__overloadable__, " : "")
<< "__clang_arm_builtin_alias(__builtin_arm_mve_" << Int.fullName()
<< ")))\n"
<< RetTypeName << FunctionName << "(" << ArgTypesString << ");\n";
@@ -2041,7 +2041,7 @@
   // Emit the actual declaration. See MveEmitter::EmitHeader for detailed
   // comments
   OS << "static __inline__ __attribute__(("
- << (Polymorphic ? "overloadable, " : "")
+ << (Polymorphic ? "__overloadable__, " : "")
  << "__clang_arm_builtin_alias(__builtin_arm_" << 
Int.builtinExtension()
  << "_" << Int.fullName() << ")))\n"
  << RetTypeName << FunctionName << "(" << ArgTypesString << ");\n";


Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -1874,7 +1874,7 @@
 // match your call".
 
 OS << "static __inline__ __attribute__(("
-   << (Polymorphic ? "overloadable, " : "")
+   << (Polymorphic ? "__overloadable__, " : "")
<< "__clang_arm_builtin_alias(__builtin_arm_mve_" << Int.fullName()
<< ")))\n"
<< RetTypeName << FunctionName << "(" << ArgTypesString << ");\n";
@@ -2041,7 +2041,7 @@
   // Emit the actual declaration. See MveEmitter::EmitHeader for detailed
   // comments
   OS << "static __inline__ __attribute__(("
- << (Polymorphic ? "overloadable, " : "")
+ << (Polymorphic ? "__overloadable__, " : "")
  << "__clang_arm_builtin_alias(__builtin_arm_" << Int.builtinExtension()
  << "_" << Int.fullName() << ")))\n"
  << RetTypeName << FunctionName << "(" << ArgTypesString << ");\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75998: [ARM,MVE] Add intrinsics and isel for MVE fused multiply-add.

2020-03-12 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3f8e714e2f9f: [ARM,MVE] Add intrinsics and isel for MVE 
fused multiply-add. (authored by simon_tatham).

Changed prior to commit:
  https://reviews.llvm.org/D75998?vs=249641&id=249896#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75998

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/ternary.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-fmas.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
@@ -0,0 +1,242 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vfmaq_f16(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
+; CHECK-LABEL: test_vfmaq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vfma.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.fma.v8f16(<8 x half> %b, <8 x half> %c, <8 x half> %a)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vfmaq_f32(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
+; CHECK-LABEL: test_vfmaq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vfma.f32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %b, <4 x float> %c, <4 x float> %a)
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vfmaq_n_f16(<8 x half> %a, <8 x half> %b, float %c.coerce) {
+; CHECK-LABEL: test_vfmaq_n_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov r0, s8
+; CHECK-NEXT:vfma.f16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast float %c.coerce to i32
+  %tmp.0.extract.trunc = trunc i32 %0 to i16
+  %1 = bitcast i16 %tmp.0.extract.trunc to half
+  %.splatinsert = insertelement <8 x half> undef, half %1, i32 0
+  %.splat = shufflevector <8 x half> %.splatinsert, <8 x half> undef, <8 x i32> zeroinitializer
+  %2 = tail call <8 x half> @llvm.fma.v8f16(<8 x half> %b, <8 x half> %.splat, <8 x half> %a)
+  ret <8 x half> %2
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vfmaq_n_f32(<4 x float> %a, <4 x float> %b, float %c) {
+; CHECK-LABEL: test_vfmaq_n_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov r0, s8
+; CHECK-NEXT:vfma.f32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <4 x float> undef, float %c, i32 0
+  %.splat = shufflevector <4 x float> %.splatinsert, <4 x float> undef, <4 x i32> zeroinitializer
+  %0 = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %b, <4 x float> %.splat, <4 x float> %a)
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vfmasq_n_f16(<8 x half> %a, <8 x half> %b, float %c.coerce) {
+; CHECK-LABEL: test_vfmasq_n_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov r0, s8
+; CHECK-NEXT:vfmas.f16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast float %c.coerce to i32
+  %tmp.0.extract.trunc = trunc i32 %0 to i16
+  %1 = bitcast i16 %tmp.0.extract.trunc to half
+  %.splatinsert = insertelement <8 x half> undef, half %1, i32 0
+  %.splat = shufflevector <8 x half> %.splatinsert, <8 x half> undef, <8 x i32> zeroinitializer
+  %2 = tail call <8 x half> @llvm.fma.v8f16(<8 x half> %a, <8 x half> %b, <8 x half> %.splat)
+  ret <8 x half> %2
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vfmasq_n_f32(<4 x float> %a, <4 x float> %b, float %c) {
+; CHECK-LABEL: test_vfmasq_n_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov r0, s8
+; CHECK-NEXT:vfmas.f32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %.splatinsert = insertelement <4 x float> undef, float %c, i32 0
+  %.splat = shufflevector <4 x float> %.splatinsert, <4 x float> undef, <4 x i32> zeroinitializer
+  %0 = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %.splat)
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vfmsq_f16(<8 x half> %a, <8 x half> %b, <8 x half> %c) {
+; CHECK-LABEL: test_vfmsq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vfms.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = fneg <8 x half> %c
+  %1 = tail call <8 x half> @llvm.fma.v8f16(<8 x half> %b, <8 x half> %0, <8 x half> %a)
+  ret <8 x half> %1
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vfmsq_f32(<4 x float> %a, <4 x float> %b, <4 x float> %c) {
+; CHECK-LABEL: test_vfmsq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vfms.f32 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = fneg <4 x float> %c
+  %1 = tail call <4 x fl

[PATCH] D74619: [ARM] Enabling range checks on Neon intrinsics' lane arguments

2020-03-12 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas added a comment.

The clang-format pre-merge check keeps wanting me to update the indentation for 
the entire `ARMSIMDIntrinsicMap` and `AArch64SIMDIntrinsicMap` maps due to the 
change in their first entries.
I believe, though, that this change would not only be out of the scope of this 
patch, but would also bring inconsistencies with the current indentation style 
of the entire file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74619



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


[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM as well, though please run clang-format over the patch (some of the 
formatting looks to have gone weird in places).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76040



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


[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-12 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb added a comment.

@vvereschaka very interesting. I've downloaded CMake 3.10.2 and finally been 
able to reproduce the issue locally. So it //is// a CMake bug which does not 
appear in the latest versions. I'll update this patch to use 
`CMAKE_CURRENT_LIST_DIR` and add a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347



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


[PATCH] D75514: [Analyzer] Only add container note tags to the operations of the affected container

2020-03-12 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 249897.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D75514

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -76,8 +76,7 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.push_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
-  // expected-note@-1{{Container 'V' extended to the right by 1 position}}
+  V.push_back(n); // expected-note 2{{Container 'V' extended to the right by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
  // expected-note@-1{{$V.begin()}}
@@ -203,10 +202,10 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(V1), "$V1.begin()");
 
-  V2.push_back(n); // expected-note{{Container 'V2' extended to the right by 1 position}} FIXME: This note should not appear since `V2` is not affected in the "bug"
+  V2.push_back(n); // no-note
 
   clang_analyzer_express(clang_analyzer_container_begin(V1)); // expected-warning{{$V1.begin()}}
- // expected-note@-1{{$V1.begin()}}
+  // expected-note@-1{{$V1.begin()}}
 }
 
 void push_back2(std::vector &V1, std::vector &V2, int n) {
@@ -218,15 +217,14 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V1), "$V1.begin()");
   clang_analyzer_denote(clang_analyzer_container_begin(V2), "$V2.begin()");
 
-  V1.push_back(n); // expected-note 2{{Container 'V1' extended to the right by 1 position}}
-   // FIXME: This should appear only once since there is only
-   // one "bug" where `V1` is affected
+  V1.push_back(n); // expected-note{{Container 'V1' extended to the right by 1 position}}
+   // Only once!
 
   clang_analyzer_express(clang_analyzer_container_begin(V1)); // expected-warning{{$V1.begin()}}
- // expected-note@-1{{$V1.begin()}}
+  // expected-note@-1{{$V1.begin()}}
 
   clang_analyzer_express(clang_analyzer_container_begin(V2)); // expected-warning{{$V2.begin()}}
- // expected-note@-1{{$V2.begin()}}
+  // expected-note@-1{{$V2.begin()}}
 }
 
 /// Print Container Data as Part of the Program State
Index: clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
@@ -52,9 +52,12 @@
   typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
  CheckerContext &C) const;
 
-  ExplodedNode *reportBug(llvm::StringRef Msg, CheckerContext &C) const;
+  // Optional parameter `ExprVal` for expression value to be marked interesting.
+  ExplodedNode *reportBug(llvm::StringRef Msg, CheckerContext &C,
+  Optional ExprVal = None) const;
   ExplodedNode *reportBug(llvm::StringRef Msg, BugReporter &BR,
-  ExplodedNode *N) const;
+  ExplodedNode *N,
+  Optional ExprVal = None) const;
 
 public:
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
@@ -144,22 +147,28 @@
 }
 
 ExplodedNode *ExprInspectionChecker::reportBug(llvm::StringRef Msg,
-   CheckerContext &C) const {
+   CheckerContext &C,
+   Optional ExprVal) const {
   ExplodedNode *N = C.generateNonFatalErrorNode();
-  reportBug(Msg, C.getBugReporter(), N);
+  reportBug(Msg, C.getBugReporter(), N, ExprVal);
   return N;
 }
 
 ExplodedNode *ExprInspectionChecker::reportBug(llvm::StringRef Msg,
BugReporter &BR,
-   ExplodedNode *N) const {
+   ExplodedNode *N,
+   Optional ExprVal) const {
   if (!N)
 retur

[PATCH] D75514: [Analyzer] Only add container note tags to the operations of the affected container

2020-03-12 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 3 inline comments as done.
baloghadamsoftware added a comment.

In D75514#1917450 , @Szelethus wrote:

> The code from in `ExprInspectionChecker.cpp` is duplicated from D75677 
> , isn't it?


It is. The one accepted earlier will be committed earlier, then I will rebase 
the other one so this part disappears from that one.




Comment at: clang/test/Analysis/container-modeling.cpp:100-101
 
-  V.emplace_back(n); // expected-note 2{{Container 'V' extended to the right 
by 1 position}}
+  V.emplace_back(n); // expected-note{{Container 'V' extended to the right by 
1 position}}
+ // expected-note@-1{{Container 'V' extended to the right 
by 1 position}}
 

Szelethus wrote:
> Why did we unpack this? And the rest?
We did not unpack this but forgot to pack it.


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

https://reviews.llvm.org/D75514



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


[PATCH] D59214: [clang][OpeMP] Model OpenMP structured-block in AST (PR40563)

2020-03-12 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

d5edcb90643104d6911da5c0ff44c4f33fff992f 
, looking 
forward to seeing better error recovery.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D59214



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


[PATCH] D75851: [Analyzer][StreamChecker] Added evaluation of fseek.

2020-03-12 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 249904.
balazske added a comment.

Rebased, added handling of UnknownError.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75851

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -38,3 +38,48 @@
   }
   fclose(F);
 }
+
+void error_fseek() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+int Eof = feof(F), Error = ferror(F);
+// Get feof or ferror or no error.
+clang_analyzer_eval(Eof || Error); // expected-warning {{FALSE}} \
+   // expected-warning {{TRUE}}
+clang_analyzer_eval(Eof && Error); // expected-warning {{FALSE}}
+// Error flags should not change.
+if (Eof)
+  clang_analyzer_eval(feof(F)); // expected-warning {{TRUE}}
+else
+  clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+if (Error)
+  clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+else
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+// Error flags should not change.
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
+
+void error_fseek_clearerr() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc && feof(F)) {
+clearerr(F);
+clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+  } else if (rc && ferror(F)) {
+clearerr(F);
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -26,8 +26,12 @@
 
 namespace {
 
+struct FnDescription;
+
 /// Full state information about a stream pointer.
 struct StreamState {
+  const FnDescription *LastOperation;
+
   /// State of a stream symbol.
   /// FIXME: use a bool isOpened instead.
   enum KindTy {
@@ -45,6 +49,8 @@
 FEof,
 /// Other generic (non-EOF) error (`ferror` is true).
 FError,
+/// Unknown error, the meaning depends on the last operation.
+UnknownError
   } ErrorState = NoError;
 
   bool isOpened() const { return State == Opened; }
@@ -63,21 +69,35 @@
 assert(State == Opened && "Error undefined for closed stream.");
 return ErrorState == FError;
   }
+  bool isUnknownError() const {
+assert(State == Opened && "Error undefined for closed stream.");
+return ErrorState == UnknownError;
+  }
 
   bool operator==(const StreamState &X) const {
 // In not opened state error should always NoError.
-return State == X.State && ErrorState == X.ErrorState;
+return LastOperation == X.LastOperation && State == X.State &&
+   ErrorState == X.ErrorState;
   }
 
-  static StreamState getOpened() { return StreamState{Opened}; }
-  static StreamState getClosed() { return StreamState{Closed}; }
-  static StreamState getOpenFailed() { return StreamState{OpenFailed}; }
-  static StreamState getOpenedWithFEof() { return StreamState{Opened, FEof}; }
-  static StreamState getOpenedWithFError() {
-return StreamState{Opened, FError};
+  static StreamState getOpened(const FnDescription *L) {
+return StreamState{L, Opened};
+  }
+  static StreamState getClosed(const FnDescription *L) {
+return StreamState{L, Closed};
+  }
+  static StreamState getOpenFailed(const FnDescription *L) {
+return StreamState{L, OpenFailed};
+  }
+  static StreamState getOpened(const FnDescription *L, ErrorKindTy E) {
+return StreamState{L, Opened, E};
+  }
+  static StreamState getOpenedWithUnknownError(const FnDescription *L) {
+return StreamState{L, Opened, UnknownError};
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) const {
+ID.AddPointer(LastOperation);
 ID.AddInteger(State);
 ID.AddInteger(ErrorState);
   }
@@ -95,6 +115,11 @@
   FnCheck PreFn;
   FnCheck EvalFn;
   ArgNoTy StreamArgNo;
+  // What errors are possible after this operation.
+  // Used only if this operation resulted in UnknownError
+  // (otherwise there is a known single error).
+  // Must contain 2 or 3 elements, or zero.
+  llvm::SmallVector PossibleErrors = {};
 };
 
 /// Get the value of the stream argument out of the passed call event.
@@ -127,28 +152,42 @@
 
 private:
   CallDescriptionMap FnDescriptions = {
-  {{"fopen"}, {nullpt

[clang-tools-extra] 966cad0 - [clangd] Add README pointing to docs, bugtracker etc. NFC

2020-03-12 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-12T14:00:08+01:00
New Revision: 966cad0c65d796d8824524c7bee62c86d1594d3d

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

LOG: [clangd] Add README pointing to docs, bugtracker etc. NFC

Added: 
clang-tools-extra/clangd/README.md
clang-tools-extra/docs/clangd/README.txt

Modified: 


Removed: 




diff  --git a/clang-tools-extra/clangd/README.md 
b/clang-tools-extra/clangd/README.md
new file mode 100644
index ..c9a75895acab
--- /dev/null
+++ b/clang-tools-extra/clangd/README.md
@@ -0,0 +1,19 @@
+## clangd
+
+clangd is a language server, and provides C++ IDE features to editors.
+This is not its documentation.
+
+- the **website** is https://clangd.llvm.org/.
+- the **bug tracker** is https://github.com/clangd/clangd/issues
+- the **source code** is hosted at 
https://github.com/llvm/llvm-project/tree/master/clang-tools-extra/clangd.
+- the **website source code** is at https://github.com/llvm/clangd-www/
+
+### Communication channels
+
+If you have any questions or feedback, you can reach community and developers
+through one of these channels:
+
+- chat: #clangd room hosted on [LLVM's Discord
+  channel](https://discord.gg/xS7Z362).
+- user questions and feature requests can be asked in the clangd topic on [LLVM
+  Discussion Forums](https://llvm.discourse.group/c/llvm-project/clangd/34)

diff  --git a/clang-tools-extra/docs/clangd/README.txt 
b/clang-tools-extra/docs/clangd/README.txt
new file mode 100644
index ..7d1ca932b60d
--- /dev/null
+++ b/clang-tools-extra/docs/clangd/README.txt
@@ -0,0 +1,4 @@
+The clangd documentation lives in a separate repository.
+
+Source repo: https://github.com/llvm/clangd-www
+Public URL: https://clangd.llvm.org/



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

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



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:937
+case AQ_goto: return "goto";
+case AQ_unspecified:;
+  }

nickdesaulniers wrote:
> aaron.ballman wrote:
> > This looks wrong to me -- it flows through to an unreachable despite being 
> > reachable. I think this should `return "unspecified";`.
> This method is only called for printing; it seems weird to return 
> "unspecified" when it's kind of an invariant that that should never happen.  
> Maybe an assert here would be better?
> 
> I've updated the implementation slightly, but leaving this comment thread 
> open for more feedback.
An assert seems wrong to me -- the enumeration value is valid and the user has 
asked to print it. There's not much to assert on there. It's the caller of the 
method that should know whether it's violating an invariant to have that value 
in the first place. Also, people print from debuggers with relative frequency, 
so I'd personally avoid an assert in this case.



Comment at: clang/lib/Parse/ParseStmtAsm.cpp:684
+SkipUntil(tok::r_paren, StopAtSemi);
+Diag(Tok.getLocation(), diag::err_asm_qualifier_ignored);
+return true;

I think this will point to the right paren because of the preceding `SkipUntil` 
when it should point at the original token location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping! Anyone else have feedback?


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

https://reviews.llvm.org/D75685



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


[PATCH] D75332: [clang-tidy] Add module for llvm-libc and restrict-system-libc-header-check.

2020-03-12 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75332



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


[clang] 592cec7 - [OpenCL] Add missing get_image_array_size builtins

2020-03-12 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-03-12T13:43:51Z
New Revision: 592cec7087d8ea60b7a517d4354eab8d5c7b012c

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

LOG: [OpenCL] Add missing get_image_array_size builtins

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index e5109dfbb048..0d8764a567a4 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1409,7 +1409,9 @@ let Extension = FuncExtKhrGlMsaaSharing in {
   }
   def : Builtin<"get_image_dim", [VectorType, ImageType], Attr.Const>;
 }
-def : Builtin<"get_image_array_size", [Size, 
ImageType], Attr.Const>;
+foreach imgTy = [Image2dArrayMsaa, Image2dArrayMsaaDepth] in {
+  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] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-12 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

LGTM. Thanks!


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

https://reviews.llvm.org/D75685



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-12 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2956
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }

erichkeane wrote:
> Anastasia wrote:
> > We don't seem to add namespace for other OpenCL types, although I am not 
> > against it as I find it actually cleaner.
> > 
> > Since the mangling deviates what is documented can you add some comments 
> > here explaining your mangling scheme?
> The Microsoft mangling scheme is owned by the Microsoft Corporation, so 
> adding something to their mangling (like 8ocl_pipe) isn't permitted.  Thus, 
> the clang project mangles our types that aren't supported by Microsoft as a 
> type in the __clang namespace.  
> 
> You'll note that we do it for a bunch of types above, including 
> AddressSpaceType, VectorType, _Complex, _Float16, _Half, etc.
Are you saying that we have a bug for the other OpenCL type i.e. images, 
samplers, etc?



Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:12
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}

Any reason to test unmangled?



Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:25
+
+#ifdef WIN
+// SPIR Spec specifies mangling on pipes that doesn't include the element type

I am still unclear why is this special case?


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

https://reviews.llvm.org/D75685



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


[PATCH] D76062: [PATCH] [ARM] ARMv8.6-a command-line + BFloat16 Asm Support

2020-03-12 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson created this revision.
LukeGeeson added reviewers: SjoerdMeijer, craig.topper, rjmccall.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, dexonsmith, 
hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.
LukeGeeson edited the summary of this revision.
LukeGeeson edited the summary of this revision.

This patch introduces command-line support for the Armv8.6-a architecture and 
assembly support for BFloat16. Details can be found here:

community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a




in addition to the GCC patch for the 8..6-a CLI:

  
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-11/msg02647.html

In detail this patch

- march options for armv8.6-a
- BFloat16 assembly

This is part of a patch series, starting with command-line and Bfloat16 

  
assembly support. The subsequent patches will upstream intrinsics   

  
support for BFloat16, followed by Matrix Multiplication and the 

  
remaining Virtualization features of the armv8.6-a architecture.

Based on work by:

- labrinea
- MarkMurrayARM
- Luke Cheeseman
- Javed Asbar
- Mikhail Maltsev


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76062

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/lib/Target/ARM/ARMInstrVFP.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
  llvm/test/MC/AArch64/SVE/bfcvt-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfcvt.s
  llvm/test/MC/AArch64/SVE/bfcvtnt-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfcvtnt.s
  llvm/test/MC/AArch64/SVE/bfdot-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfdot.s
  llvm/test/MC/AArch64/SVE/bfmlal-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfmlal.s
  llvm/test/MC/AArch64/SVE/bfmmla-diagnostics.s
  llvm/test/MC/AArch64/SVE/bfmmla.s
  llvm/test/MC/AArch64/armv8.6a-bf16.s
  llvm/test/MC/ARM/bfloat16-a32-errors.s
  llvm/test/MC/ARM/bfloat16-a32-errors2.s
  llvm/test/MC/ARM/bfloat16-a32.s
  llvm/test/MC/ARM/bfloat16-t32-errors.s
  llvm/test/MC/ARM/bfloat16-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.6a-bf16.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-a32_1.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-a32_2.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-t32.txt
  llvm/test/MC/Disassembler/ARM/bfloat16-t32_errors.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -26,9 +26,9 @@
 "armv7e-m","armv7em",  "armv8-a", "armv8","armv8a",
 "armv8l",  "armv8.1-a","armv8.1a","armv8.2-a","armv8.2a",
 "armv8.3-a",   "armv8.3a", "armv8.4-a",   "armv8.4a", "armv8.5-a",
-"armv8.5a", "armv8-r", "armv8r",  "armv8-m.base", "armv8m.base",
-"armv8-m.main", "armv8m.main", "iwmmxt",  "iwmmxt2",  "xscale",
-"armv8.1-m.main",
+"armv8.5a", "armv8.6-a",   "armv8.6a", "armv8-r", "armv8r",
+"armv8-m.base", "armv8m.base", "armv8-m.main", "armv8m.main", "iwmmxt",
+"iwmmxt2",  "xscale",  "armv8.1-m.main",
 };
 
 bool testARMCPU(StringRef CPUName, StringRef ExpectedA

[PATCH] D74347: [CMake] Explicitly specify paths to libc++abi in CrossWinToARMLinux.cmake

2020-03-12 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb updated this revision to Diff 249916.
broadwaylamb added a comment.

Use `CMAKE_CURRENT_LIST_DIR` instead of `CMAKE_SOURCE_DIR` for locating the 
llvm-project directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74347

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -25,6 +25,14 @@
 #  cmake --build . --target check-clang
 #  cmake --build . --target check-lld
 
+# LLVM_PROJECT_DIR is the path to the llvm-project directory.
+# The right way to compute it would probably be to use 
"${CMAKE_SOURCE_DIR}/../",
+# but CMAKE_SOURCE_DIR is set to the wrong value on earlier CMake versions
+# that we still need to support (for instance, 3.10.2).
+get_filename_component(LLVM_PROJECT_DIR
+   "${CMAKE_CURRENT_LIST_DIR}/../../../"
+   ABSOLUTE)
+
 if (NOT DEFINED DEFAULT_SYSROOT)
   message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain 
build.")
 endif()
@@ -83,6 +91,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
 
 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 "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -25,6 +25,14 @@
 #  cmake --build . --target check-clang
 #  cmake --build . --target check-lld
 
+# LLVM_PROJECT_DIR is the path to the llvm-project directory.
+# The right way to compute it would probably be to use "${CMAKE_SOURCE_DIR}/../",
+# but CMAKE_SOURCE_DIR is set to the wrong value on earlier CMake versions
+# that we still need to support (for instance, 3.10.2).
+get_filename_component(LLVM_PROJECT_DIR
+   "${CMAKE_CURRENT_LIST_DIR}/../../../"
+   ABSOLUTE)
+
 if (NOT DEFINED DEFAULT_SYSROOT)
   message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
 endif()
@@ -83,6 +91,9 @@
 set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
 set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
 set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
+set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
+set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
+set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
 
 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 "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75811: [CUDA] Choose default architecture based on CUDA installation

2020-03-12 Thread Raul Tambre via Phabricator via cfe-commits
tambre added a comment.

Thank you for the long and detailed explanation. It's been of great help!

I've gone with the approach of trying the architectures in the most recent 
non-deprecated order – sm_52, sm_30.  
A problem with bumping the default architecture would have been that there are 
already Clang version released, which support CUDA 10, but still use sm_20 by 
default. CMake probably wants to support the widest range possible.

> Can you elaborate on what exactly does cmake attempts to establish with the 
> test?
>  If it looks for a working end-to-end CUDA compilation, then it will need to 
> rely on user input to make sure that correct CUDA location is used.
>  If it wants to check if clang is capable of CUDA compilation, then it should 
> be told *not* to look for CUDA (though you will need to provide a bit of glue 
> similar to what we use for tests 
> https://github.com/llvm/llvm-project/blob/master/clang/test/Driver/cuda-simple.cu).
>  Would something like that be sufficient?

The aim is to check for working end-to-end CUDA compilation.

You're right that CMake ought to rely on the user to provide many of the 
variables.  
I'll be adding a `CUDA_ROOT` option to CMake that will be passed to clang as 
`--cuda-path`.  
CMake also currently lacks options to pass an architecture to the CUDA compiler 
though this feature has been requested multiple times. Users so far had to do 
this themselves by passing raw compiler flags. I'm also working on support for 
this. The first detected working architecture during compiler identification 
will be used as the default.

After some work on my CMake changes, Clang detection as a CUDA compiler works 
and I can compile CUDA code.  
However code using separable compilation doesn't compile. What is the Clang 
equivalent of NVCC's `-dc` (`--device-c`) option for this case?

The CMake code review for CUDA Clang support is here 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75811



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


[PATCH] D76061: [Sema] Fix location of star ('*') inside MemberPointerTypeLoc

2020-03-12 Thread Marcel Hlopko via Phabricator via cfe-commits
hlopko created this revision.
hlopko added a reviewer: gribozavr.
hlopko added a project: clang.
Herald added a subscriber: cfe-commits.

Copy of https://reviews.llvm.org/D72073?id=235842, submitting with 
ilya-biryukov's permission.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76061

Files:
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/unittests/AST/DeclTest.cpp


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -107,3 +107,20 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MemberPointerStarLoc) {
+  StringRef Code = R"(
+struct X {};
+int X::* a;
+  )";
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, {});
+  SourceManager &SM = AST->getSourceManager();
+
+  SmallVector Decls;
+  AST->findFileRegionDecls(SM.getMainFileID(), Code.find('X'), 0, Decls);
+  ASSERT_TRUE(Decls.size() == 2);
+  VarDecl *D = cast(Decls[1]);
+  auto TL = 
D->getTypeSourceInfo()->getTypeLoc().castAs();
+  auto StarLoc = TL.getStarLoc().printToString(SM);
+  ASSERT_EQ(StarLoc, "input.cc:3:12");
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -5840,7 +5840,7 @@
   }
 
   // Finally fill in MemberPointerLocInfo fields.
-  TL.setStarLoc(Chunk.Loc);
+  TL.setStarLoc(SourceLocation::getFromRawEncoding(Chunk.Mem.StarLoc));
   TL.setClassTInfo(ClsTInfo);
 }
 void VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5643,8 +5643,8 @@
 return;
   }
 
-  SourceLocation Loc = ConsumeToken();
-  D.SetRangeEnd(Loc);
+  SourceLocation StarLoc = ConsumeToken();
+  D.SetRangeEnd(StarLoc);
   DeclSpec DS(AttrFactory);
   ParseTypeQualifierListOpt(DS);
   D.ExtendWithDeclSpec(DS);
@@ -5655,7 +5655,7 @@
   // Sema will have to catch (syntactically invalid) pointers into global
   // scope. It has to catch pointers into namespace scope anyway.
   D.AddTypeInfo(DeclaratorChunk::getMemberPointer(
-SS, DS.getTypeQualifiers(), DS.getEndLoc()),
+SS, DS.getTypeQualifiers(), StarLoc, DS.getEndLoc()),
 std::move(DS.getAttributes()),
 /* Don't replace range end. */ SourceLocation());
   return;
Index: clang/include/clang/Sema/DeclSpec.h
===
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -1518,6 +1518,8 @@
   struct MemberPointerTypeInfo {
 /// The type qualifiers: const/volatile/restrict/__unaligned/_Atomic.
 unsigned TypeQuals : 5;
+/// Location of the '*' token.
+unsigned StarLoc;
 // CXXScopeSpec has a constructor, so it can't be a direct member.
 // So we need some pointer-aligned storage and a bit of trickery.
 alignas(CXXScopeSpec) char ScopeMem[sizeof(CXXScopeSpec)];
@@ -1660,11 +1662,13 @@
 
   static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS,
   unsigned TypeQuals,
-  SourceLocation Loc) {
+  SourceLocation StarLoc,
+  SourceLocation EndLoc) {
 DeclaratorChunk I;
 I.Kind  = MemberPointer;
 I.Loc   = SS.getBeginLoc();
-I.EndLoc= Loc;
+I.EndLoc= EndLoc;
+I.Mem.StarLoc   = StarLoc.getRawEncoding();
 I.Mem.TypeQuals = TypeQuals;
 new (I.Mem.ScopeMem) CXXScopeSpec(SS);
 return I;


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -107,3 +107,20 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MemberPointerStarLoc) {
+  StringRef Code = R"(
+struct X {};
+int X::* a;
+  )";
+  auto AST = tooling::buildASTFromCodeWithArgs(Code, {});
+  SourceManager &SM = AST->getSourceManager();
+
+  SmallVector Decls;
+  AST->findFileRegionDecls(SM.getMainFileID(), Code.find('X'), 0, Decls);
+  ASSERT_TRUE(Decls.size() == 2);
+  VarDecl *D = cast(Decls[1]);
+  auto TL = D->getTypeSourceInfo()->getTypeLoc().castAs();
+  auto StarLoc = TL.getStarLoc().printToString(SM);
+  ASSERT_EQ(StarLoc, "input.cc:3:12");
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaTyp

[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 3 inline comments as done.
erichkeane added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2956
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }

Anastasia wrote:
> erichkeane wrote:
> > Anastasia wrote:
> > > We don't seem to add namespace for other OpenCL types, although I am not 
> > > against it as I find it actually cleaner.
> > > 
> > > Since the mangling deviates what is documented can you add some comments 
> > > here explaining your mangling scheme?
> > The Microsoft mangling scheme is owned by the Microsoft Corporation, so 
> > adding something to their mangling (like 8ocl_pipe) isn't permitted.  Thus, 
> > the clang project mangles our types that aren't supported by Microsoft as a 
> > type in the __clang namespace.  
> > 
> > You'll note that we do it for a bunch of types above, including 
> > AddressSpaceType, VectorType, _Complex, _Float16, _Half, etc.
> Are you saying that we have a bug for the other OpenCL type i.e. images, 
> samplers, etc?
I don't know those well enough to answer, but at least in this case 'Pipe' 
isn't a Type.  It is a Type Class.  Because of this, having a single mangling 
for it is incorrect.  It appears images likely is going to have this problem as 
well.



Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:12
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}

Anastasia wrote:
> Any reason to test unmangled?
Because you asked to validate the OpenCL cases as well.



Comment at: clang/test/CodeGenOpenCL/pipe_types_mangling.cl:25
+
+#ifdef WIN
+// SPIR Spec specifies mangling on pipes that doesn't include the element type

Anastasia wrote:
> I am still unclear why is this special case?
It isn't possible to overload on these types in Linux mode, because the OpenCL 
spec on ItaniumABI has a specific mangling that doesn't take element type and 
read/write into effect.  The probelm is that on Linux BOTH versions of 'test2' 
end up with the mangling '@_Z5test28ocl_pipe' (and we get an error in codegen).




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

https://reviews.llvm.org/D75685



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-12 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked an inline comment as done.
erichkeane added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2956
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }

erichkeane wrote:
> Anastasia wrote:
> > erichkeane wrote:
> > > Anastasia wrote:
> > > > We don't seem to add namespace for other OpenCL types, although I am 
> > > > not against it as I find it actually cleaner.
> > > > 
> > > > Since the mangling deviates what is documented can you add some 
> > > > comments here explaining your mangling scheme?
> > > The Microsoft mangling scheme is owned by the Microsoft Corporation, so 
> > > adding something to their mangling (like 8ocl_pipe) isn't permitted.  
> > > Thus, the clang project mangles our types that aren't supported by 
> > > Microsoft as a type in the __clang namespace.  
> > > 
> > > You'll note that we do it for a bunch of types above, including 
> > > AddressSpaceType, VectorType, _Complex, _Float16, _Half, etc.
> > Are you saying that we have a bug for the other OpenCL type i.e. images, 
> > samplers, etc?
> I don't know those well enough to answer, but at least in this case 'Pipe' 
> isn't a Type.  It is a Type Class.  Because of this, having a single mangling 
> for it is incorrect.  It appears images likely is going to have this problem 
> as well.
I've looked closer, and I don't believe this is a problem for other openCL 
types (other than they are not reserved names).  In ~2090 in this file those 
are implemented as a struct named ocl_*, which while not reserved in C++ will 
demangle.  Image types are mangled differently, also as a struct type, so i 
think those are OK.

These pipe types aren't mangled separately in Linux (hence why overloading 
doesn't work with them in Linux).




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

https://reviews.llvm.org/D75685



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


[clang] dbde39e - Fix static analyzer null dereference warning. NFCI.

2020-03-12 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-12T14:56:51Z
New Revision: dbde39e485b5c00b9ad809d169e1650aa2104114

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

LOG: Fix static analyzer null dereference warning. NFCI.

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 58e7e16d6817..3645169b8901 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -3096,7 +3096,7 @@ VarDecl *BindingDecl::getHoldingVar() const {
   if (!DRE)
 return nullptr;
 
-  auto *VD = dyn_cast(DRE->getDecl());
+  auto *VD = cast(DRE->getDecl());
   assert(VD->isImplicit() && "holding var for binding decl not implicit");
   return VD;
 }



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


[clang] 5f9fcfb - Replace getAs with castAs to fix null dereference static analyzer warnings.

2020-03-12 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-12T14:56:50Z
New Revision: 5f9fcfb29e4e30932909ce648ad556a3890e6dce

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

LOG: Replace getAs with castAs to fix null dereference static analyzer warnings.

Use castAs as we know the cast should succeed (and castAs will assert if it 
doesn't) and we're dereferencing it directly in the canAssignObjCInterfaces 
call.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e50d1d608397..436880968b1f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8698,8 +8698,8 @@ bool ASTContext::areComparableObjCPointerTypes(QualType 
LHS, QualType RHS) {
 
 bool ASTContext::canBindObjCObjectType(QualType To, QualType From) {
   return canAssignObjCInterfaces(
-getObjCObjectPointerType(To)->getAs(),
-
getObjCObjectPointerType(From)->getAs());
+  getObjCObjectPointerType(To)->castAs(),
+  getObjCObjectPointerType(From)->castAs());
 }
 
 /// typesAreCompatible - C99 6.7.3p9: For two qualified types to be compatible,



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


[clang] 7c2b3c9 - Replace getAs with castAs to fix null dereference static analyzer warnings.

2020-03-12 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-12T14:56:51Z
New Revision: 7c2b3c9dda37ab25a6849a3670f1bfda6aa17e5e

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

LOG: Replace getAs with castAs to fix null dereference static analyzer warnings.

Use castAs as we know the cast should succeed (and castAs will assert if it 
doesn't) and we're dereferencing it directly in the 
getThisType/getThisObjectType calls.

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 3645169b8901..8e9258a8ab88 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2364,17 +2364,15 @@ QualType CXXMethodDecl::getThisType() const {
   // volatile X*, and if the member function is declared const volatile,
   // the type of this is const volatile X*.
   assert(isInstance() && "No 'this' for static methods!");
-
-  return CXXMethodDecl::getThisType(getType()->getAs(),
+  return CXXMethodDecl::getThisType(getType()->castAs(),
 getParent());
 }
 
 QualType CXXMethodDecl::getThisObjectType() const {
   // Ditto getThisType.
   assert(isInstance() && "No 'this' for static methods!");
-
-  return 
CXXMethodDecl::getThisObjectType(getType()->getAs(),
-  getParent());
+  return CXXMethodDecl::getThisObjectType(
+  getType()->castAs(), getParent());
 }
 
 bool CXXMethodDecl::hasInlineBody() const {



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


[PATCH] D76061: [Sema] Fix location of star ('*') inside MemberPointerTypeLoc

2020-03-12 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/unittests/AST/DeclTest.cpp:125
+  auto StarLoc = TL.getStarLoc().printToString(SM);
+  ASSERT_EQ(StarLoc, "input.cc:3:12");
+}

I'd suggest to rewrite this test (and other tests in this file) to a more 
modern approach to testing. Specifically, I suggest that you imitate 
clang/unittests/Tooling/RangeSelectorTest.cpp. However, since that would be 
refactoring existing tests, I suggest that you do it as a follow-up change -- 
but please do it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76061



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


[PATCH] D76066: [ARM][MachineOutliner] Add Machine Outliner support for ARM

2020-03-12 Thread Yvan Roux via Phabricator via cfe-commits
yroux created this revision.
yroux added reviewers: t.p.northover, efriedma, paquette, samparker, 
SjoerdMeijer.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.

Enables Machine Outlining support on ARM for ARM and Thumb2 modes.  Only the
simplest outlining modes (tailcalls and thunks) are handled here, the patch
also disables LowOverheadLoops pass when the machine outliner is used since
outlined functions are not supprted by this pass.

This is a follow-up of ARM Machine Outliner support RFC D57054 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76066

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/TargetPassConfig.h
  llvm/lib/CodeGen/MachineOutliner.cpp
  llvm/lib/CodeGen/TargetPassConfig.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.h
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/test/CodeGen/ARM/machine-outliner-tail.ll
  llvm/test/CodeGen/ARM/machine-outliner-thunk.ll

Index: llvm/test/CodeGen/ARM/machine-outliner-thunk.ll
===
--- /dev/null
+++ llvm/test/CodeGen/ARM/machine-outliner-thunk.ll
@@ -0,0 +1,111 @@
+; RUN: llc -enable-machine-outliner -verify-machineinstrs -mtriple=armv7-- \
+; RUN: -stop-after=machine-outliner < %s | FileCheck %s --check-prefix=ARM
+; RUN: llc -enable-machine-outliner -verify-machineinstrs -mtriple=thumbv7-- \
+; RUN: -stop-after=machine-outliner < %s | FileCheck %s --check-prefix=THUMB
+; RUN: llc -enable-machine-outliner -verify-machineinstrs \
+; RUN: -mtriple=thumbv7-apple-darwin -stop-after=machine-outliner < %s \
+; RUN: | FileCheck %s --check-prefix=MACHO
+
+declare i32 @thunk_called_fn(i32, i32, i32, i32)
+
+define i32 @a() {
+; ARM-LABEL: name: a
+; ARM:   bb.0.entry:
+; ARM-NEXT:liveins: $r11, $lr
+; ARM: $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r11, killed $lr
+; ARM-NEXT:frame-setup CFI_INSTRUCTION def_cfa_offset 8
+; ARM-NEXT:frame-setup CFI_INSTRUCTION offset $lr, -4
+; ARM-NEXT:frame-setup CFI_INSTRUCTION offset $r11, -8
+; ARM-NEXT:BL @OUTLINED_FUNCTION_0{{.*}}
+; ARM-NEXT:renamable $r0 = ADDri killed renamable $r0, 8, 14, $noreg, $noreg
+; ARM-NEXT:$sp = LDMIA_RET $sp, 14, $noreg, def $r11, def $pc, implicit killed $r0
+
+; THUMB-LABEL: name: a
+; THUMB:   bb.0.entry:
+; THUMB-NEXT:liveins: $r7, $lr
+; THUMB: frame-setup tPUSH 14, $noreg, killed $r7, killed $lr
+; THUMB-NEXT:frame-setup CFI_INSTRUCTION def_cfa_offset 8
+; THUMB-NEXT:frame-setup CFI_INSTRUCTION offset $lr, -4
+; THUMB-NEXT:frame-setup CFI_INSTRUCTION offset $r7, -8
+; THUMB-NEXT:tBL 14, $noreg, @OUTLINED_FUNCTION_0{{.*}}
+; THUMB-NEXT:renamable $r0, dead $cpsr = tADDi8 killed renamable $r0, 8, 14, $noreg
+; THUMB-NEXT:tPOP_RET 14, $noreg, def $r7, def $pc
+
+; MACHO-LABEL: name: a
+; MACHO:   bb.0.entry:
+; MACHO-NEXT:liveins: $lr
+; MACHO: early-clobber $sp = frame-setup t2STR_PRE killed $lr, $sp, -4, 14, $noreg
+; MACHO-NEXT:frame-setup CFI_INSTRUCTION def_cfa_offset 4
+; MACHO-NEXT:frame-setup CFI_INSTRUCTION offset $lr, -4
+; MACHO-NEXT:tBL 14, $noreg, @OUTLINED_FUNCTION_0{{.*}}
+; MACHO-NEXT:renamable $r0, dead $cpsr = tADDi8 killed renamable $r0, 8, 14, $noreg
+; MACHO-NEXT:$lr, $sp = t2LDR_POST $sp, 4, 14, $noreg
+; MACHO-NEXT:tBX_RET 14, $noreg, implicit killed $r0
+entry:
+  %call = tail call i32 @thunk_called_fn(i32 1, i32 2, i32 3, i32 4)
+  %cx = add i32 %call, 8
+  ret i32 %cx
+}
+
+define i32 @b() {
+; ARM-LABEL: name: b
+; ARM:   bb.0.entry:
+; ARM-NEXT:liveins: $r11, $lr
+; ARM: $sp = frame-setup STMDB_UPD $sp, 14, $noreg, killed $r11, killed $lr
+; ARM-NEXT:frame-setup CFI_INSTRUCTION def_cfa_offset 8
+; ARM-NEXT:frame-setup CFI_INSTRUCTION offset $lr, -4
+; ARM-NEXT:frame-setup CFI_INSTRUCTION offset $r11, -8
+; ARM-NEXT:BL @OUTLINED_FUNCTION_0{{.*}}
+; ARM-NEXT:renamable $r0 = ADDri killed renamable $r0, 88, 14, $noreg, $noreg
+; ARM-NEXT:$sp = LDMIA_RET $sp, 14, $noreg, def $r11, def $pc, implicit killed $r0
+
+; THUMB-LABEL: name: b
+; THUMB:   bb.0.entry:
+; THUMB-NEXT:liveins: $r7, $lr
+; THUMB: frame-setup tPUSH 14, $noreg, killed $r7, killed $lr
+; THUMB-NEXT:frame-setup CFI_INSTRUCTION def_cfa_offset 8
+; THUMB-NEXT:frame-setup CFI_INSTRUCTION offset $lr, -4
+; THUMB-NEXT:frame-setup CFI_INSTRUCTION offset $r7, -8
+; THUMB-NEXT:tBL 14, $noreg, @OUTLINED_FUNCTION_0{{.*}}
+; THUMB-NEXT:renamable $r0, dead $cpsr = tADDi8 killed renamable $r0, 88, 14, $noreg
+; THUMB-NEXT:tPOP_RET 14, $noreg, def $r7, def $pc
+
+; MACHO-LABEL: name: b
+; MACHO:   bb.0.entry:
+; MACHO-NEXT:liveins: $lr
+; MACHO: early-clobber 

[PATCH] D74361: [Clang] Undef attribute for global variables

2020-03-12 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

ping @aaron.ballman - does that look right to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D76071: [Tooling] Recognize angle brackets for main header

2020-03-12 Thread Daniele E. Domenichelli via Phabricator via cfe-commits
drdanz created this revision.
drdanz added a reviewer: ioeric.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang-format does not recognize as main header an include that uses
angle brackets. This is a common practice used in many projects.

This patch removes the initial check for the '"' character.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76071

Files:
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp


Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -219,8 +219,6 @@
   return Ret;
 }
 bool IncludeCategoryManager::isMainHeader(StringRef IncludeName) const {
-  if (!IncludeName.startswith("\""))
-return false;
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem) ||


Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -219,8 +219,6 @@
   return Ret;
 }
 bool IncludeCategoryManager::isMainHeader(StringRef IncludeName) const {
-  if (!IncludeName.startswith("\""))
-return false;
   StringRef HeaderStem =
   llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6999335 - ObjCMethodDecl::findPropertyDecl - fix static analyzer null dereference warnings. NFCI.

2020-03-12 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-12T15:36:49Z
New Revision: 69993350aeed08b6392f614c510697579302a39b

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

LOG: ObjCMethodDecl::findPropertyDecl  - fix static analyzer null dereference 
warnings. NFCI.

All paths dereference the ClassDecl pointer, so use a cast<> instead of 
dyn_cast<>, assert that its not null and remove the remaining null tests.

Added: 


Modified: 
clang/lib/AST/DeclObjC.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 9a84e3c4a510..6492f07eb5b0 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -1361,25 +1361,23 @@ ObjCMethodDecl::findPropertyDecl(bool CheckOverrides) 
const {
 return Found;
 } else {
   // Determine whether the container is a class.
-  ClassDecl = dyn_cast(Container);
+  ClassDecl = cast(Container);
 }
+assert(ClassDecl && "Failed to find main class");
 
 // If we have a class, check its visible extensions.
-if (ClassDecl) {
-  for (const auto *Ext : ClassDecl->visible_extensions()) {
-if (Ext == Container)
-  continue;
-
-if (const auto *Found = findMatchingProperty(Ext))
-  return Found;
-  }
+for (const auto *Ext : ClassDecl->visible_extensions()) {
+  if (Ext == Container)
+continue;
+  if (const auto *Found = findMatchingProperty(Ext))
+return Found;
 }
 
 assert(isSynthesizedAccessorStub() && "expected an accessor stub");
+
 for (const auto *Cat : ClassDecl->known_categories()) {
   if (Cat == Container)
 continue;
-
   if (const auto *Found = findMatchingProperty(Cat))
 return Found;
 }



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


[clang-tools-extra] 2c9cf9f - [clang-tidy] New check: bugprone-suspicious-include

2020-03-12 Thread Jonathan Roelofs via cfe-commits

Author: Jonathan Roelofs
Date: 2020-03-12T09:59:28-06:00
New Revision: 2c9cf9f4ddd01ae9eb47522266a6343104f9d0b5

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

LOG: [clang-tidy] New check: bugprone-suspicious-include

Detects and fixes suspicious code like: `#include "foo.cpp"`.

Inspired by: https://twitter.com/lefticus/status/1228458240364687360?s=20

https://reviews.llvm.org/D74669

Added: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/i.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 86936c678562..9dcb315a257a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -45,6 +45,7 @@
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
 #include "SuspiciousEnumUsageCheck.h"
+#include "SuspiciousIncludeCheck.h"
 #include "SuspiciousMemsetUsageCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
 #include "SuspiciousSemicolonCheck.h"
@@ -140,6 +141,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-string-literal-with-embedded-nul");
 CheckFactories.registerCheck(
 "bugprone-suspicious-enum-usage");
+CheckFactories.registerCheck(
+"bugprone-suspicious-include");
 CheckFactories.registerCheck(
 "bugprone-suspicious-memset-usage");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index c9078ed390d1..a24f3bc7eb0d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -37,6 +37,7 @@ add_clang_library(clangTidyBugproneModule
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp
   SuspiciousEnumUsageCheck.cpp
+  SuspiciousIncludeCheck.cpp
   SuspiciousMemsetUsageCheck.cpp
   SuspiciousMissingCommaCheck.cpp
   SuspiciousSemicolonCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
new file mode 100644
index ..87ff284408dc
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -0,0 +1,108 @@
+//===--- SuspiciousIncludeCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "SuspiciousIncludeCheck.h"
+#include "clang/AST/ASTContext.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+namespace {
+class SuspiciousIncludePPCallbacks : public PPCallbacks {
+public:
+  explicit SuspiciousIncludePPCallbacks(SuspiciousIncludeCheck &Check,
+const SourceManager &SM,
+Preprocessor *PP)
+  : Check(Check), PP(PP) {}
+
+  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
+  StringRef FileName, bool IsAngled,
+  CharSourceRange FilenameRange, const FileEntry *File,
+  StringRef SearchPath, StringRef RelativePath,
+  const Module *Imported,
+  SrcMgr::CharacteristicKind FileType) override;
+
+private:
+  SuspiciousIncludeCheck &Check;
+  Preprocessor *PP;
+};
+} // namespace
+
+SuspiciousIncludeCheck::SuspiciousIncludeCheck(StringRef Name

[clang] 7420f96 - [TableGen] Move generated *Attr class methods out of line

2020-03-12 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-03-12T09:07:57-07:00
New Revision: 7420f96924a3889af628c851ff1940aae614f3f3

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

LOG: [TableGen] Move generated *Attr class methods out of line

After this change, clang spends ~200ms parsing Attrs.inc instead of
~560ms. A large part of the cost was from the StringSwitch
instantiations, but this is a good way to avoid similar problems in the
future.

Reviewed By: aaron.ballman, rjmccall

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

Added: 


Modified: 
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index d8b5480c2b26..20fb9bc14439 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -426,8 +426,8 @@ namespace {
 }
 
 void writeCtorBody(raw_ostream &OS) const override {
-  OS << "  if (!" << getUpperName() << ".empty())\n";
-  OS << "std::memcpy(" << getLowerName() << ", " << getUpperName()
+  OS << "if (!" << getUpperName() << ".empty())\n";
+  OS << "  std::memcpy(" << getLowerName() << ", " << getUpperName()
  << ".data(), " << getLowerName() << "Length);\n";
 }
 
@@ -691,8 +691,8 @@ namespace {
 }
 
 void writeCtorBody(raw_ostream &OS) const override {
-  OS << "std::copy(" << getUpperName() << ", " << getUpperName()
- << " + " << ArgSizeName << ", " << ArgName << ");\n";
+  OS << "  std::copy(" << getUpperName() << ", " << getUpperName() << " + "
+ << ArgSizeName << ", " << ArgName << ");\n";
 }
 
 void writeCtorInitializers(raw_ostream &OS) const override {
@@ -894,37 +894,45 @@ namespace {
   OS << "}\n";
 }
 
-void writeConversion(raw_ostream &OS) const {
-  OS << "  static bool ConvertStrTo" << type << "(StringRef Val, ";
-  OS << type << " &Out) {\n";
-  OS << "Optional<" << type << "> R = llvm::StringSwitch R = llvm::StringSwitch>(Val)\n";
   for (size_t I = 0; I < enums.size(); ++I) {
-OS << "  .Case(\"" << values[I] << "\", ";
+OS << ".Case(\"" << values[I] << "\", ";
 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
   }
-  OS << "  .Default(Optional<" << type << ">());\n";
-  OS << "if (R) {\n";
-  OS << "  Out = *R;\n  return true;\n}\n";
-  OS << "return false;\n";
-  OS << "  }\n\n";
+  OS << ".Default(Optional<" << type << ">());\n";
+  OS << "  if (R) {\n";
+  OS << "Out = *R;\n  return true;\n}\n";
+  OS << "  return false;\n";
+  OS << "}\n\n";
 
   // Mapping from enumeration values back to enumeration strings isn't
   // trivial because some enumeration values have multiple named
   // enumerators, such as type_visibility(internal) and
   // type_visibility(hidden) both mapping to TypeVisibilityAttr::Hidden.
-  OS << "  static const char *Convert" << type << "ToStr("
- << type << " Val) {\n"
- << "switch(Val) {\n";
+  OS << "const char *" << getAttrName() << "Attr::Convert" << type
+ << "ToStr(" << type << " Val) {\n"
+ << "  switch(Val) {\n";
   SmallDenseSet Uniques;
   for (size_t I = 0; I < enums.size(); ++I) {
 if (Uniques.insert(enums[I]).second)
-  OS << "case " << getAttrName() << "Attr::" << enums[I]
+  OS << "  case " << getAttrName() << "Attr::" << enums[I]
  << ": return \"" << values[I] << "\";\n";
   }
-  OS << "}\n"
- << "llvm_unreachable(\"No enumerator with that value\");\n"
- << "  }\n";
+  OS << "  }\n"
+ << "  llvm_unreachable(\"No enumerator with that value\");\n"
+ << "}\n";
 }
   };
 
@@ -1006,33 +1014,42 @@ namespace {
   OS << "  " << WritePCHRecord(QualifiedTypeName, "(*i)");
 }
 
-void writeConversion(raw_ostream &OS) const {
-  OS << "  static bool ConvertStrTo" << type << "(StringRef Val, ";
+void writeConversion(raw_ostream &OS, bool Header) const {
+  if (Header) {
+OS << "  static bool ConvertStrTo" << type << "(StringRef Val, " << 
type
+   << " &Out);\n";
+OS << "  static const char *Convert" << type << "ToStr(" << type
+   << " Val);\n";
+return;
+  }
+
+  OS << "bool " << getAttrName() << "Attr::ConvertStrTo" << type
+ << "(StringRef Val, ";
   OS << type << " &Out) {\n";
-  OS << "Optional<" << type << "> R = llvm::StringSwitch R = llvm::StringSwitch>(Val)\n";
   for (size_t I = 0; I < enums.size(); ++I) {
-OS << "  .Case(\"" << values[I] << "\", "

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-12 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

re-landed in 
https://github.com/llvm/llvm-project/commit/2c9cf9f4ddd01ae9eb47522266a6343104f9d0b5


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-12 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D76040#1919170 , @aaron.ballman 
wrote:

> LGTM as well, though please run clang-format over the patch (some of the 
> formatting looks to have gone weird in places).


Thanks, done. I undid some of its more questionable reformattings in 
writeCtorBody where the original formatting more clearly shows the generated 
code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76040



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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-12 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 249954.
MarcusJohnson91 added a comment.

Rebased


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

https://reviews.llvm.org/D75791

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2460,14 +2460,14 @@
 }
 
 TEST_F(FormatTest, FormatsExternC) {
-  verifyFormat("extern \"C\" {\nint a;");
+  verifyFormat("extern \"C\" {\nint a; /*2.1*/");
   verifyFormat("extern \"C\" {}");
   verifyFormat("extern \"C\" {\n"
-   "int foo();\n"
+   "int FormatsExternC_1();\n"
"}");
-  verifyFormat("extern \"C\" int foo() {}");
-  verifyFormat("extern \"C\" int foo();");
-  verifyFormat("extern \"C\" int foo() {\n"
+  verifyFormat("extern \"C\" int FormatsExternC_2() {}");
+  verifyFormat("extern \"C\" int FormatsExternC_3();");
+  verifyFormat("extern \"C\" int FormatsExternC_4() {\n"
"  int i = 42;\n"
"  return i;\n"
"}");
@@ -2475,9 +2475,9 @@
   FormatStyle Style = getLLVMStyle();
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterFunction = true;
-  verifyFormat("extern \"C\" int foo() {}", Style);
-  verifyFormat("extern \"C\" int foo();", Style);
-  verifyFormat("extern \"C\" int foo()\n"
+  verifyFormat("extern \"C\" int FormatsExternC_5() {}", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_6();", Style);
+  verifyFormat("extern \"C\" int FormatsExternC_7()\n"
"{\n"
"  int i = 42;\n"
"  return i;\n"
@@ -2486,16 +2486,41 @@
 
   Style.BraceWrapping.AfterExternBlock = true;
   Style.BraceWrapping.SplitEmptyRecord = false;
-  verifyFormat("extern \"C\"\n"
-   "{}",
-   Style);
-  verifyFormat("extern \"C\"\n"
-   "{\n"
-   "  int foo();\n"
+  verifyFormat("extern \"C\"\n{}", Style);
+  verifyFormat("extern \"C\"\n{\nint FormatsExternC_8();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n"
+   "int FormatsExternC_9();\n"
"}",
Style);
 }
 
+TEST_F(FormatTest, FormatsExternBlock) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IndentWidth = 2;
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_1();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = true;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\n  int FormatsExternBlock_2();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_3();\n}", Style);
+
+  Style.BraceWrapping.AfterExternBlock = false;
+  Style.IndentExternBlock = false;
+  verifyFormat("extern \"C\" {}", Style);
+  verifyFormat("extern \"C\" {\nint FormatsExternBlock_4();\n}", Style);
+}
+
 TEST_F(FormatTest, FormatsInlineASM) {
   verifyFormat("asm(\"xyz\" : \"=a\"(a), \"=d\"(b) : \"a\"(data));");
   verifyFormat("asm(\"nop\" ::: \"memory\");");
@@ -12660,6 +12685,7 @@
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
+  CHECK_PARSE_BOOL(IndentExternBlock);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1094,11 +1094,21 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock) {
+if (Style.BraceWrapping.AfterExternBlock == true &&
+Style.IndentExternBlock == true) {
   addUnwrappedLine();
-  parseBlock(/*MustBeDeclaration=*/true);
-} else {
+  parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/true);
+} else if (Style.BraceWrapping.AfterExternBlock == false &&
+   Style.IndentExternBlock == false) {
   parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
+} else if (Style.BraceWrapping.AfterExternBlock == false &&
+   Style.IndentExternBlock == true) {
+  parseBlock(/*MustBeDeclaration=*/true, /*AddL

[PATCH] D76040: [TableGen] Move generated *Attr class methods out of line

2020-03-12 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7420f96924a3: [TableGen] Move generated *Attr class methods 
out of line (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D76040?vs=249817&id=249956#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76040

Files:
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -426,8 +426,8 @@
 }
 
 void writeCtorBody(raw_ostream &OS) const override {
-  OS << "  if (!" << getUpperName() << ".empty())\n";
-  OS << "std::memcpy(" << getLowerName() << ", " << getUpperName()
+  OS << "if (!" << getUpperName() << ".empty())\n";
+  OS << "  std::memcpy(" << getLowerName() << ", " << getUpperName()
  << ".data(), " << getLowerName() << "Length);\n";
 }
 
@@ -691,8 +691,8 @@
 }
 
 void writeCtorBody(raw_ostream &OS) const override {
-  OS << "std::copy(" << getUpperName() << ", " << getUpperName()
- << " + " << ArgSizeName << ", " << ArgName << ");\n";
+  OS << "  std::copy(" << getUpperName() << ", " << getUpperName() << " + "
+ << ArgSizeName << ", " << ArgName << ");\n";
 }
 
 void writeCtorInitializers(raw_ostream &OS) const override {
@@ -894,37 +894,45 @@
   OS << "}\n";
 }
 
-void writeConversion(raw_ostream &OS) const {
-  OS << "  static bool ConvertStrTo" << type << "(StringRef Val, ";
-  OS << type << " &Out) {\n";
-  OS << "Optional<" << type << "> R = llvm::StringSwitch R = llvm::StringSwitch>(Val)\n";
   for (size_t I = 0; I < enums.size(); ++I) {
-OS << "  .Case(\"" << values[I] << "\", ";
+OS << ".Case(\"" << values[I] << "\", ";
 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
   }
-  OS << "  .Default(Optional<" << type << ">());\n";
-  OS << "if (R) {\n";
-  OS << "  Out = *R;\n  return true;\n}\n";
-  OS << "return false;\n";
-  OS << "  }\n\n";
+  OS << ".Default(Optional<" << type << ">());\n";
+  OS << "  if (R) {\n";
+  OS << "Out = *R;\n  return true;\n}\n";
+  OS << "  return false;\n";
+  OS << "}\n\n";
 
   // Mapping from enumeration values back to enumeration strings isn't
   // trivial because some enumeration values have multiple named
   // enumerators, such as type_visibility(internal) and
   // type_visibility(hidden) both mapping to TypeVisibilityAttr::Hidden.
-  OS << "  static const char *Convert" << type << "ToStr("
- << type << " Val) {\n"
- << "switch(Val) {\n";
+  OS << "const char *" << getAttrName() << "Attr::Convert" << type
+ << "ToStr(" << type << " Val) {\n"
+ << "  switch(Val) {\n";
   SmallDenseSet Uniques;
   for (size_t I = 0; I < enums.size(); ++I) {
 if (Uniques.insert(enums[I]).second)
-  OS << "case " << getAttrName() << "Attr::" << enums[I]
+  OS << "  case " << getAttrName() << "Attr::" << enums[I]
  << ": return \"" << values[I] << "\";\n";
   }
-  OS << "}\n"
- << "llvm_unreachable(\"No enumerator with that value\");\n"
- << "  }\n";
+  OS << "  }\n"
+ << "  llvm_unreachable(\"No enumerator with that value\");\n"
+ << "}\n";
 }
   };
 
@@ -1006,33 +1014,42 @@
   OS << "  " << WritePCHRecord(QualifiedTypeName, "(*i)");
 }
 
-void writeConversion(raw_ostream &OS) const {
-  OS << "  static bool ConvertStrTo" << type << "(StringRef Val, ";
+void writeConversion(raw_ostream &OS, bool Header) const {
+  if (Header) {
+OS << "  static bool ConvertStrTo" << type << "(StringRef Val, " << type
+   << " &Out);\n";
+OS << "  static const char *Convert" << type << "ToStr(" << type
+   << " Val);\n";
+return;
+  }
+
+  OS << "bool " << getAttrName() << "Attr::ConvertStrTo" << type
+ << "(StringRef Val, ";
   OS << type << " &Out) {\n";
-  OS << "Optional<" << type << "> R = llvm::StringSwitch R = llvm::StringSwitch>(Val)\n";
   for (size_t I = 0; I < enums.size(); ++I) {
-OS << "  .Case(\"" << values[I] << "\", ";
+OS << ".Case(\"" << values[I] << "\", ";
 OS << getAttrName() << "Attr::" << enums[I] << ")\n";
   }
-  OS << "  .Default(Optional<" << type << ">());\n";
-  OS << "if (R) {\n";
-  OS << "  Out = *R;\n  return true;\n}\n";
-  OS << "return false;\n";
-  OS << "  }\n\n";
-
-  OS << "  static const char *Convert" << type << "ToStr("
-<< type << " Val) {\n"
-<< "

[clang] fa80803 - [AST][SVE] Add new Type queries for sizeless types

2020-03-12 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-12T16:30:50Z
New Revision: fa8080376e739e2148aa53715dc93e5406f53fd2

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

LOG: [AST][SVE] Add new Type queries for sizeless types

One of the defining features of the SVE ACLE types is that they
are "sizeless"; see the SVE ACLE spec:

https://developer.arm.com/docs/100987//arm-c-language-extensions-for-sve

or the email message:

http://lists.llvm.org/pipermail/cfe-dev/2019-June/062523.html

for a fuller definition of what that means.

This patch adds two associated type queries:

- isSizelessBuiltinType asks specifically about types that are built
  into clang.  It is effectively an enum range check.

- isSizelessType instead tests for any type that has the "sizeless" type
  property.  At the moment it only returns true for the built-in types,
  but it seems better not to hard-code that assumption throughout
  the codebase.  (E.g. we could in principle support some form of
  user-defined sizeless types in future.  Even if that seems unlikely
  and never actually happens, the possibility at least exists.)

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

Added: 
clang/unittests/AST/SizelessTypesTest.cpp

Modified: 
clang/include/clang/AST/CanonicalType.h
clang/include/clang/AST/Type.h
clang/lib/AST/Type.cpp
clang/unittests/AST/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/AST/CanonicalType.h 
b/clang/include/clang/AST/CanonicalType.h
index 31b14c0d39c3..488284713bce 100644
--- a/clang/include/clang/AST/CanonicalType.h
+++ b/clang/include/clang/AST/CanonicalType.h
@@ -264,6 +264,8 @@ class CanProxyBase {
   // Type predicates
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isObjectType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIncompleteType)
+  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSizelessType)
+  LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isSizelessBuiltinType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIncompleteOrObjectType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isVariablyModifiedType)
   LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, isIntegerType)

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index e589d3fa4e64..f9a269e12d2d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1926,6 +1926,15 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
   /// or QualType::getSingleStepDesugaredType(const ASTContext&).
   QualType getLocallyUnqualifiedSingleStepDesugaredType() const;
 
+  /// As an extension, we classify types as one of "sized" or "sizeless";
+  /// every type is one or the other.  Standard types are all sized;
+  /// sizeless types are purely an extension.
+  ///
+  /// Sizeless types contain data with no specified size, alignment,
+  /// or layout.
+  bool isSizelessType() const;
+  bool isSizelessBuiltinType() const;
+
   /// Types are partitioned into 3 broad categories (C99 6.2.5p1):
   /// object types, function types, and incomplete types.
 

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 5099494da5fd..6e1c70f95262 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2182,6 +2182,22 @@ bool Type::isIncompleteType(NamedDecl **Def) const {
   }
 }
 
+bool Type::isSizelessBuiltinType() const {
+  if (const BuiltinType *BT = getAs()) {
+switch (BT->getKind()) {
+  // SVE Types
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/AArch64SVEACLETypes.def"
+  return true;
+default:
+  return false;
+}
+  }
+  return false;
+}
+
+bool Type::isSizelessType() const { return isSizelessBuiltinType(); }
+
 bool QualType::isPODType(const ASTContext &Context) const {
   // C++11 has a more relaxed definition of POD.
   if (Context.getLangOpts().CPlusPlus11)

diff  --git a/clang/unittests/AST/CMakeLists.txt 
b/clang/unittests/AST/CMakeLists.txt
index d1876dff5012..a7012b812596 100644
--- a/clang/unittests/AST/CMakeLists.txt
+++ b/clang/unittests/AST/CMakeLists.txt
@@ -28,6 +28,7 @@ add_clang_unittest(ASTTests
   Language.cpp
   NamedDeclPrinterTest.cpp
   RecursiveASTVisitorTest.cpp
+  SizelessTypesTest.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   StructuralEquivalenceTest.cpp

diff  --git a/clang/unittests/AST/SizelessTypesTest.cpp 
b/clang/unittests/AST/SizelessTypesTest.cpp
new file mode 100644
index ..8daf30e6bbe3
--- /dev/null
+++ b/clang/unittests/AST/SizelessTypesTest.cpp
@@ -0,0 +1,82 @@
+//===- unittests/AST/SizelessTypesTest.cpp --- Sizeless type tests 
===//
+//
+// 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-Iden

[PATCH] D75298: [Clang][SVE] Parse builtin type string for scalable vectors

2020-03-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D75298#1918489 , @efriedma wrote:

> Changing the way we expose the builtins isn't going to affect most of the 
> code related to the SVE intrinsics.  I'm fine sticking with a known working 
> approach, and trying to address that issue later.


Okay, thanks! In that case, are you happy with the patch as it is now?


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

https://reviews.llvm.org/D75298



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


[PATCH] D75570: [AST][SVE] Add new Type queries for sizeless types

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa8080376e73: [AST][SVE] Add new Type queries for sizeless 
types (authored by rsandifo-arm).

Changed prior to commit:
  https://reviews.llvm.org/D75570?vs=248125&id=249961#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75570

Files:
  clang/include/clang/AST/CanonicalType.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/SizelessTypesTest.cpp

Index: clang/unittests/AST/SizelessTypesTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/SizelessTypesTest.cpp
@@ -0,0 +1,82 @@
+//===- unittests/AST/SizelessTypesTest.cpp --- Sizeless type tests ===//
+//
+// 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
+//
+//===--===//
+//
+// This file contains tests for clang::Type queries related to sizeless types.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Type.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+struct SizelessTypeTester : public ::testing::Test {
+  // Declare an incomplete structure type.
+  std::unique_ptr AST = tooling::buildASTFromCodeWithArgs(
+  "struct foo;", {"-target", "aarch64-linux-gnu"});
+  ASTContext &Ctx = AST->getASTContext();
+  TranslationUnitDecl &TU = *Ctx.getTranslationUnitDecl();
+  TypeDecl *Foo = cast(TU.lookup(&Ctx.Idents.get("foo")).front());
+  const Type *FooTy = Foo->getTypeForDecl();
+};
+
+TEST_F(SizelessTypeTester, TestSizelessBuiltin) {
+  ASSERT_TRUE(Ctx.SveInt8Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveInt16Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveInt32Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveInt64Ty->isSizelessBuiltinType());
+
+  ASSERT_TRUE(Ctx.SveUint8Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveUint16Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveUint32Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveUint64Ty->isSizelessBuiltinType());
+
+  ASSERT_TRUE(Ctx.SveFloat16Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveFloat32Ty->isSizelessBuiltinType());
+  ASSERT_TRUE(Ctx.SveFloat64Ty->isSizelessBuiltinType());
+
+  ASSERT_TRUE(Ctx.SveBoolTy->isSizelessBuiltinType());
+
+  ASSERT_FALSE(Ctx.VoidTy->isSizelessBuiltinType());
+  ASSERT_FALSE(Ctx.PseudoObjectTy->isSizelessBuiltinType());
+  ASSERT_FALSE(FooTy->isSizelessBuiltinType());
+
+  ASSERT_FALSE(Ctx.getPointerType(Ctx.SveBoolTy)->isSizelessBuiltinType());
+  ASSERT_FALSE(
+  Ctx.getLValueReferenceType(Ctx.SveBoolTy)->isSizelessBuiltinType());
+  ASSERT_FALSE(
+  Ctx.getRValueReferenceType(Ctx.SveBoolTy)->isSizelessBuiltinType());
+}
+
+TEST_F(SizelessTypeTester, TestSizeless) {
+  ASSERT_TRUE(Ctx.SveInt8Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveInt16Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveInt32Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveInt64Ty->isSizelessType());
+
+  ASSERT_TRUE(Ctx.SveUint8Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveUint16Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveUint32Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveUint64Ty->isSizelessType());
+
+  ASSERT_TRUE(Ctx.SveFloat16Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveFloat32Ty->isSizelessType());
+  ASSERT_TRUE(Ctx.SveFloat64Ty->isSizelessType());
+
+  ASSERT_TRUE(Ctx.SveBoolTy->isSizelessType());
+
+  ASSERT_FALSE(Ctx.VoidTy->isSizelessType());
+  ASSERT_FALSE(Ctx.PseudoObjectTy->isSizelessType());
+  ASSERT_FALSE(FooTy->isSizelessType());
+
+  ASSERT_FALSE(Ctx.getPointerType(Ctx.SveBoolTy)->isSizelessType());
+  ASSERT_FALSE(Ctx.getLValueReferenceType(Ctx.SveBoolTy)->isSizelessType());
+  ASSERT_FALSE(Ctx.getRValueReferenceType(Ctx.SveBoolTy)->isSizelessType());
+}
Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -28,6 +28,7 @@
   Language.cpp
   NamedDeclPrinterTest.cpp
   RecursiveASTVisitorTest.cpp
+  SizelessTypesTest.cpp
   SourceLocationTest.cpp
   StmtPrinterTest.cpp
   StructuralEquivalenceTest.cpp
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2182,6 +2182,22 @@
   }
 }
 
+bool Type::isSizelessBuiltinType() const {
+  if (const BuiltinType *BT = getAs()) {
+switch (BT->getKind()) {
+  // SVE Types
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/AArch64SVEACLETypes.def"
+  return true;
+de

[clang] 7bfc3bf - Replace getAs/dyn_cast with castAs/cast to fix null dereference static analyzer warnings.

2020-03-12 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-12T16:50:50Z
New Revision: 7bfc3bf39b6d279657b480963e72b6c08191b2f2

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

LOG: Replace getAs/dyn_cast with castAs/cast to fix null dereference static 
analyzer warnings.

Both these casts are immediately deferenced and the cast will assert for us 
that they are of the correct type.

Added: 


Modified: 
clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp

Removed: 




diff  --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp 
b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index f3a27804bcac..fff4a45c5330 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -2688,7 +2688,7 @@ Stmt 
*RewriteModernObjC::RewriteObjCBoxedExpr(ObjCBoxedExpr *Exp) {
   // Don't forget the parens to enforce the proper binding.
   ParenExpr *PE = new (Context) ParenExpr(StartLoc, EndLoc, cast);
 
-  const FunctionType *FT = msgSendType->getAs();
+  auto *FT = msgSendType->castAs();
   CallExpr *CE = CallExpr::Create(*Context, PE, MsgExprs, FT->getReturnType(),
   VK_RValue, EndLoc);
   ReplaceStmt(Exp, CE);
@@ -7501,8 +7501,7 @@ Stmt 
*RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
 RD = RD->getDefinition();
 if (RD && !RD->getDeclName().getAsIdentifierInfo()) {
   // decltype(((Foo_IMPL*)0)->bar) *
-  ObjCContainerDecl *CDecl =
-dyn_cast(D->getDeclContext());
+  auto *CDecl = cast(D->getDeclContext());
   // ivar in class extensions requires special treatment.
   if (ObjCCategoryDecl *CatDecl = dyn_cast(CDecl))
 CDecl = CatDecl->getClassInterface();



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


[clang] f09c7d6 - [Sema][SVE] Add tests for valid and invalid type usage

2020-03-12 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-12T16:56:13Z
New Revision: f09c7d642afa932a1e2b66bdcd15e779f8bc5d4e

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

LOG: [Sema][SVE] Add tests for valid and invalid type usage

This patch adds C and C++ tests for various uses of SVE types.
The tests cover valid uses that are already (correctly) accepted and
invalid uses that are already (correctly) rejected.  Later patches
will expand the tests as they fix other cases.[*]

Some of the tests for invalid uses aren't obviously related to
scalable vectors.  Part of the reason for having them is to make
sure that the quality of the error message doesn't regress once/if
the types are treated as incomplete types.

[*] These later patches all fix invalid uses that are being incorrectly
accepted.  I don't know of any cases in which valid uses are being
incorrectly rejected.  In other words, this series is all about
diagnosing invalid code rather than enabling something new.

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

Added: 
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Modified: 


Removed: 




diff  --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c
new file mode 100644
index ..cd30d1a68062
--- /dev/null
+++ b/clang/test/Sema/sizeless-1.c
@@ -0,0 +1,222 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -W -Wno-comment -triple 
arm64-linux-gnu -target-feature +sve -std=c90 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -W -triple arm64-linux-gnu 
-target-feature +sve -std=c11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wall -W -triple arm64-linux-gnu 
-target-feature +sve -std=gnu11 %s
+
+typedef __SVInt8_t svint8_t;
+typedef __SVInt16_t svint16_t;
+
+svint8_t *global_int8_ptr;
+extern svint8_t *extern_int8_ptr;
+static svint8_t *static_int8_ptr;
+
+typedef svint8_t int8_typedef;
+typedef svint8_t *int8_ptr_typedef;
+
+void pass_int8(svint8_t); // expected-note {{passing argument to parameter 
here}}
+
+svint8_t return_int8();
+
+typedef svint8_t vec_int8_a __attribute__((vector_size(64)));// 
expected-error {{invalid vector element type}}
+typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // 
expected-error {{invalid vector element type}}
+
+void dump(const volatile void *);
+
+void __attribute__((overloadable)) overf(svint8_t);
+void __attribute__((overloadable)) overf(svint16_t);
+
+void __attribute__((overloadable)) overf8(svint8_t); // expected-note + {{not 
viable}}
+void __attribute__((overloadable)) overf8(int);  // expected-note + {{not 
viable}}
+
+void __attribute__((overloadable)) overf16(svint16_t); // expected-note + 
{{not viable}}
+void __attribute__((overloadable)) overf16(int);   // expected-note + 
{{not viable}}
+
+void noproto();
+void varargs(int, ...);
+
+void unused() {
+  svint8_t unused_int8; // expected-warning {{unused}}
+}
+
+struct incomplete_struct *incomplete_ptr;
+
+void func(int sel) {
+  svint8_t local_int8;
+  svint16_t local_int16;
+
+  // Using pointers to sizeless data isn't wrong here, but because the
+  // type is incomplete, it doesn't provide any alignment guarantees.
+  _Static_assert(__atomic_is_lock_free(1, &local_int8) == 
__atomic_is_lock_free(1, incomplete_ptr), "");
+  _Static_assert(__atomic_is_lock_free(2, &local_int8) == 
__atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error 
{{static_assert expression is not an integral constant expression}}
+  _Static_assert(__atomic_always_lock_free(1, &local_int8) == 
__atomic_always_lock_free(1, incomplete_ptr), "");
+
+  local_int8; // expected-warning {{expression result unused}}
+
+  (void)local_int8;
+
+  local_int8, 0; // expected-warning + {{expression result unused}}
+
+  0, local_int8; // expected-warning + {{expression result unused}}
+
+  svint8_t init_int8 = local_int8;
+  svint8_t bad_init_int8 = for; // expected-error {{expected expression}}
+
+  int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot 
be empty}}
+
+  const svint8_t const_int8 = local_int8; // expected-note {{declared const 
here}}
+  const svint8_t uninit_const_int8;
+
+  volatile svint8_t volatile_int8;
+
+  const volatile svint8_t const_volatile_int8 = local_int8; // expected-note 
{{declared const here}}
+  const volatile svint8_t uninit_const_volatile_int8;
+
+  __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or 
reference}}
+
+  _Bool test_int8 = init_int8; // expected-error {{initializing '_Bool' with 
an expression of incompatible type 'svint8_t'}}
+
+  int int_int8 = init_int8; // expected-error {{initializing 'int' with an 
expression of incompatible type 'svint8_t'}}
+
+  init_int8 = local_int8;
+  init_int8 = local_int16; // expected-error {{assig

[clang] eb2ba2e - [CUDA] Warn about unsupported CUDA SDK version only if it's used.

2020-03-12 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2020-03-12T10:04:10-07:00
New Revision: eb2ba2ea953b5ea73cdbb598f77470bde1c6a011

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

LOG: [CUDA] Warn about unsupported CUDA SDK version only if it's used.

This fixes an issue with clang issuing a warning about unknown CUDA SDK if it's
detected during non-CUDA compilation.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/Cuda.h
clang/test/Driver/cuda-version-check.cu

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 01c5a9175da2..78139add8a82 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -34,24 +34,28 @@ using namespace llvm::opt;
 
 // Parses the contents of version.txt in an CUDA installation.  It should
 // contain one line of the from e.g. "CUDA Version 7.5.2".
-static CudaVersion ParseCudaVersionFile(const Driver &D, llvm::StringRef V) {
+void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
+  Version = CudaVersion::UNKNOWN;
   if (!V.startswith("CUDA Version "))
-return CudaVersion::UNKNOWN;
+return;
   V = V.substr(strlen("CUDA Version "));
   SmallVector VersionParts;
   V.split(VersionParts, '.');
   if (VersionParts.size() < 2)
-return CudaVersion::UNKNOWN;
-  std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]);
-  CudaVersion Version = CudaStringToVersion(MajorMinor);
+return;
+  DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
+  Version = CudaStringToVersion(DetectedVersion);
   if (Version != CudaVersion::UNKNOWN)
-return Version;
+return;
 
-  // Issue a warning and assume that the version we've found is compatible with
-  // the latest version we support.
-  D.Diag(diag::warn_drv_unknown_cuda_version)
-  << MajorMinor << CudaVersionToString(CudaVersion::LATEST);
-  return CudaVersion::LATEST;
+  Version = CudaVersion::LATEST;
+  DetectedVersionIsNotSupported = true;
+}
+
+void CudaInstallationDetector::WarnIfUnsupportedVersion() {
+  if (DetectedVersionIsNotSupported)
+D.Diag(diag::warn_drv_unknown_cuda_version)
+<< DetectedVersion << CudaVersionToString(Version);
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
@@ -150,7 +154,7 @@ CudaInstallationDetector::CudaInstallationDetector(
   // version.txt isn't present.
   Version = CudaVersion::CUDA_70;
 } else {
-  Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer());
+  ParseCudaVersionFile((*VersionFile)->getBuffer());
 }
 
 if (Version >= CudaVersion::CUDA_90) {
@@ -568,8 +572,10 @@ CudaToolChain::CudaToolChain(const Driver &D, const 
llvm::Triple &Triple,
  const Action::OffloadKind OK)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
-  if (CudaInstallation.isValid())
+  if (CudaInstallation.isValid()) {
+CudaInstallation.WarnIfUnsupportedVersion();
 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
+  }
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);

diff  --git a/clang/lib/Driver/ToolChains/Cuda.h 
b/clang/lib/Driver/ToolChains/Cuda.h
index 72ffda83e556..3de98c11a215 100644
--- a/clang/lib/Driver/ToolChains/Cuda.h
+++ b/clang/lib/Driver/ToolChains/Cuda.h
@@ -30,6 +30,8 @@ class CudaInstallationDetector {
   const Driver &D;
   bool IsValid = false;
   CudaVersion Version = CudaVersion::UNKNOWN;
+  std::string DetectedVersion;
+  bool DetectedVersionIsNotSupported = false;
   std::string InstallPath;
   std::string BinPath;
   std::string LibPath;
@@ -75,6 +77,10 @@ class CudaInstallationDetector {
   std::string getLibDeviceFile(StringRef Gpu) const {
 return LibDeviceMap.lookup(Gpu);
   }
+  void WarnIfUnsupportedVersion();
+
+private:
+  void ParseCudaVersionFile(llvm::StringRef V);
 };
 
 namespace tools {

diff  --git a/clang/test/Driver/cuda-version-check.cu 
b/clang/test/Driver/cuda-version-check.cu
index 5654d4cb7f74..a09b248304f2 100644
--- a/clang/test/Driver/cuda-version-check.cu
+++ b/clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,10 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 
--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// Make sure that we don't warn about CUDA version during C++ compilation.
+// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
+// 

[clang] 39969c7 - [Sema][SVE] Reject sizeof and alignof for sizeless types

2020-03-12 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-12T17:06:53Z
New Revision: 39969c7d3a6da8a60ac3ac7d10f471dea87cfca5

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

LOG: [Sema][SVE] Reject sizeof and alignof for sizeless types

clang current accepts:

  void foo1(__SVInt8_t *x, __SVInt8_t *y) { *x = *y; }
  void foo2(__SVInt8_t *x, __SVInt8_t *y) {
memcpy(y, x, sizeof(__SVInt8_t));
  }

The first function is valid ACLE code and generates correct LLVM IR.
However, the second function is invalid ACLE code and generates a
zero-length memcpy.  The point of this patch is to reject the use
of sizeof in the second case instead.

There's no similar wrong-code bug for alignof.  However, the SVE ACLE
conservatively treats alignof in the same way as sizeof, just as the
C++ standard does for incomplete types.  The idea is that layout of
sizeless types is an implementation property and isn't defined at
the language level.

Implementation-wise, the patch adds a new CompleteTypeKind enum
that controls whether RequireCompleteType & friends accept sizeless
built-in types.  For now the default is to maintain the status quo
and accept sizeless types.  However, the end of the series will flip
the default and remove the Default enum value.

The patch also adds new ...CompleteSized... wrappers that callers can
use if they explicitly want to reject sizeless types.  The callers then
use diagnostics that have an extra 0/1 parameter to indicats whether
the type is sizeless or not.

The idea is to have three cases:

1. calls that explicitly reject sizeless types, with a tweaked diagnostic
   for the sizeless case

2. calls that explicitly allow sizeless types

3. normal/old-style calls that don't make an explicit choice either way

Once the default is flipped, the 3. calls will conservatively reject
sizeless types, using the same diagnostic as for other incomplete types.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/aarch64-sve-types.c
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4193b0390ce0..3a532fedac48 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5939,9 +5939,9 @@ def ext_sizeof_alignof_void_type : Extension<
 def err_opencl_sizeof_alignof_type : Error<
   "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
   "to a void type">;
-def err_sizeof_alignof_incomplete_type : Error<
+def err_sizeof_alignof_incomplete_or_sizeless_type : Error<
   "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
-  "to an incomplete type %1">;
+  "to %select{an incomplete|sizeless}1 type %2">;
 def err_sizeof_alignof_function_type : Error<
   "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
   "to a function type">;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 95f77c4d675c..ee02d3189816 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -1739,6 +1739,7 @@ class Sema final {
   static SourceRange getPrintable(TypeLoc TL) { return TL.getSourceRange();}
 
   template  class BoundTypeDiagnoser : public TypeDiagnoser {
+  protected:
 unsigned DiagID;
 std::tuple Args;
 
@@ -1763,6 +1764,37 @@ class Sema final {
 }
   };
 
+  /// A derivative of BoundTypeDiagnoser for which the diagnostic's type
+  /// parameter is preceded by a 0/1 enum that is 1 if the type is sizeless.
+  /// For example, a diagnostic with no other parameters would generally have
+  /// the form "...%select{incomplete|sizeless}0 type %1...".
+  template 
+  class SizelessTypeDiagnoser : public BoundTypeDiagnoser {
+  public:
+SizelessTypeDiagnoser(unsigned DiagID, const Ts &... Args)
+: BoundTypeDiagnoser(DiagID, Args...) {}
+
+void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
+  const SemaDiagnosticBuilder &DB = S.Diag(Loc, this->DiagID);
+  this->emit(DB, std::index_sequence_for());
+  DB << T->isSizelessType() << T;
+}
+  };
+
+  enum class CompleteTypeKind {
+/// Apply the normal rules for complete types.  In particular,
+/// treat all sizeless types as incomplete.
+Normal,
+
+/// Relax the normal rules for complete types so that they include
+/// sizeless built-in types.
+AcceptSizeless,
+
+// FIXME: Eventually we should flip the default to Normal and opt in
+// to AcceptSizeless rather than opt ou

[PATCH] D75169: [ARM] Enforcing calling convention for half-precision FP arguments and returns for big-endian AArch32

2020-03-12 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a subscriber: mibintc.
spatel added a comment.

In D72675#1917844 , @wristow wrote:

> Revisiting this patch.  I think that before fixing the `-ffp-contract=off` 
> problem I originally raised here, there are two questions that have come up 
> in this discussion that we should first resolve.  Specifically:
>
> (1)  Do we want to enable FMA transformations by default (at appropriate 
> optimization levels), like GCC does?  That is, should FMA be done for targets 
> that support it with a command as simple as the following?
>
>   clang -O2 -c test.c


This has been discussed/tried a few times including very recently. I'm not sure 
where we stand currently, but here's some background:
https://reviews.llvm.org/rL282259
D74436   - cc @mibintc

And (sorry for the various flavors of links to the dev-lists, but that's how it 
showed up in the search results):
http://lists.llvm.org/pipermail/llvm-dev/2017-March/29.html
http://lists.llvm.org/pipermail/cfe-dev/2020-February/064645.html
https://groups.google.com/forum/#!msg/llvm-dev/nBiCD5KvYW0/yfjrVzR7DAAJ
https://groups.google.com/forum/#!topic/llvm-dev/Aev2jQYepKQ
http://clang-developers.42468.n3.nabble.com/RFC-FP-contract-on-td4056277.html


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

https://reviews.llvm.org/D72675



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


[PATCH] D76076: [HIP] Mark kernels with uniform-work-group-size=true

2020-03-12 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: b-sumner.
Herald added subscribers: kerbowa, nhaehnle, jvesely.

https://reviews.llvm.org/D76076

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu


Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = 
{{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = 
{{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8091,6 +8091,10 @@
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
+  if (IsHIPKernel)
+F->addFnAttr("uniform-work-group-size", "true");
+
+
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
 unsigned Min = 0;


Index: clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
@@ -39,7 +39,7 @@
 // NAMD-NOT: "amdgpu-num-vgpr"
 // NAMD-NOT: "amdgpu-num-sgpr"
 
-// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
+// DEFAULT-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"{{.*}}"uniform-work-group-size"="true"
 // MAX1024-DAG: attributes [[FLAT_WORK_GROUP_SIZE_DEFAULT]] = {{.*}}"amdgpu-flat-work-group-size"="1,1024"
 // CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = {{.*}}"amdgpu-flat-work-group-size"="32,64"
 // CHECK-DAG: attributes [[WAVES_PER_EU_2]] = {{.*}}"amdgpu-waves-per-eu"="2"
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8091,6 +8091,10 @@
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
+  if (IsHIPKernel)
+F->addFnAttr("uniform-work-group-size", "true");
+
+
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
 unsigned Min = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75298: [Clang][SVE] Parse builtin type string for scalable vectors

2020-03-12 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 249966.
sdesmalen added a comment.

- Updated license header for the arm_sve.h file to use the LLVM license instead 
of MIT.


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

https://reviews.llvm.org/D75298

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/AArch64SVEACLETypes.def
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/include/clang/Basic/arm_sve.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/module.modulemap
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/SveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -91,6 +91,8 @@
 void EmitNeonSema2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitNeonTest2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
+void EmitSveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
 void EmitMveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -70,6 +70,7 @@
   GenArmMveBuiltinSema,
   GenArmMveBuiltinCG,
   GenArmMveBuiltinAliases,
+  GenArmSveHeader,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -180,6 +181,8 @@
"Generate ARM NEON sema support for clang"),
 clEnumValN(GenArmNeonTest, "gen-arm-neon-test",
"Generate ARM NEON tests for clang"),
+clEnumValN(GenArmSveHeader, "gen-arm-sve-header",
+   "Generate arm_sve.h for clang"),
 clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
"Generate arm_mve.h for clang"),
 clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
@@ -351,6 +354,9 @@
   case GenArmMveBuiltinAliases:
 EmitMveBuiltinAliases(Records, OS);
 break;
+  case GenArmSveHeader:
+EmitSveHeader(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/SveEmitter.cpp
===
--- /dev/null
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -0,0 +1,128 @@
+//===- SveEmitter.cpp - Generate arm_sve.h for use with clang -*- 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
+//
+//===--===//
+//
+// This tablegen backend is responsible for emitting arm_sve.h, which includes
+// a declaration and definition of each function specified by the ARM C/C++
+// Language Extensions (ACLE).
+//
+// For details, visit:
+//  https://developer.arm.com/architectures/system-architectures/software-standards/acle
+//
+// Each SVE instruction is implemented in terms of 1 or more functions which
+// are suffixed with the element type of the input vectors.  Functions may be
+// implemented in terms of generic vector operations such as +, *, -, etc. or
+// by calling a __builtin_-prefixed function which will be handled by clang's
+// CodeGen library.
+//
+// See also the documentation in include/clang/Basic/arm_sve.td.
+//
+//===--===//
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/Error.h"
+#include 
+#include 
+#include 
+#include 
+
+using namespace llvm;
+
+//===--===//
+// SVEEmitter
+//===--===//
+
+namespace {
+
+class SVEEmitter {
+private:
+  RecordKeeper &Records;
+
+public:
+  SVEEmitter(RecordKeeper &R) : Records(R) {}
+
+  // run - Emit arm_sve.h
+  void run(raw_ostream &o);
+};
+
+} // end anonymous namespace
+
+
+//===--===//
+// SVEEmitter implementation
+//===--===//
+
+void SVEEmitter::run(raw_ostream &OS) {
+  OS << "/*=== arm_sve.h - ARM

[PATCH] D75655: [Docs] Document -lto-whole-program-visibility

2020-03-12 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/docs/LTOVisibility.rst:45
+build system, and the binary will not dlopen any libraries deriving from the
+binary’s classes. This is useful in situations where it is not safe to specify
+``-fvisibility=hidden`` at compile time.

tejohnson wrote:
> pcc wrote:
> > I thought that the motivation was avoiding duplicate work in the case where 
> > you need varying LTO visibility? Otherwise you could just build with and 
> > without `-fvisibility=hidden` and it would be the same from an LTO 
> > visibility perspective.
> Yeah I started to write that out but it seemed too verbose (essentially we 
> can't share a single bitcode object anymore without this, because it isn't 
> safe for all dependent links, which to me is included in "situations where it 
> is not safe to specify -fvisibility=hidden"). Also, on D71913, @evgeny777 
> mentioned he had a case were the symbol visibility constraints didn't allow 
> for -fvisibility=hidden, but where LTO visibility for vtables can be hidden. 
> I could add something more verbose about my case if you prefer.
> @evgeny777 mentioned he had a case were the symbol visibility constraints 
> didn't allow for -fvisibility=hidden, but where LTO visibility for vtables 
> can be hidden.

That case seems somewhat questionable to me. If the symbols are being exported, 
it is presumably for the purpose of allowing the symbols to be used outside of 
the defining DSO. But LTO visibility based optimizations could make any such 
use of the symbols unsafe. For example with WPD it's unsafe to derive outside 
of the defining DSO and with dead virtual function elimination it's unsafe to 
call virtual functions outside of the defining DSO.

That makes me think that `-lto-whole-program-visibility` should imply that 
associated symbols are forced to hidden to prevent such use, unless we can 
clearly define what it means to export such a symbol.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75655



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


[PATCH] D76078: [AArch64][SVE] Add a pass for SVE intrinsic optimisations

2020-03-12 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, andwar, efriedma, cameron.mcinally, 
c-rhodes.
Herald added subscribers: danielkiss, psnobl, rkruppe, hiraditya, 
kristof.beyls, tschuett, mgorny.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Creates the SVEIntrinsicOpts pass. In this patch, the pass tries
to remove unnecessary reinterpret intrinsics which convert to
and from svbool_t (llvm.aarch64.sve.convert.[to|from].svbool)

For example, the reinterprets below are redundant:

  %1 = call  
@llvm.aarch64.sve.convert.to.svbool.nxv4i1( %a)
  %2 = call  
@llvm.aarch64.sve.convert.from.svbool.nxv4i1( %1)

The pass also looks for ptest intrinsics and phi instructions where
the operands are being needlessly converted to and from svbool_t.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76078

Files:
  llvm/lib/Target/AArch64/AArch64.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
  llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll
@@ -0,0 +1,196 @@
+; RUN: opt -S -sve-intrinsicopts -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck --check-prefix OPT %s
+
+define  @reinterpret_test_h( %a) {
+; OPT-LABEL: @reinterpret_test_h(
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_h_rev( %a) {
+; OPT-LABEL: @reinterpret_test_h_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_test_w( %a) {
+; OPT-LABEL: @reinterpret_test_w(
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_w_rev( %a) {
+; OPT-LABEL: @reinterpret_test_w_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_test_d( %a) {
+; OPT-LABEL: @reinterpret_test_d(
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_d_rev( %a) {
+; OPT-LABEL: @reinterpret_test_d_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_reductions(i32 %cond,  %a,  %b,  %c) {
+; OPT-LABEL: reinterpret_reductions
+; OPT-NOT: convert
+; OPT-NOT: phi 
+; OPT: phi  [ %a, %br_phi_a ], [ %b, %br_phi_b ], [ %c, %br_phi_c ]
+; OPT-NOT: convert
+; OPT: ret
+
+entry:
+  switch i32 %cond, label %br_phi_c [
+ i32 43, label %br_phi_a
+ i32 45, label %br_phi_b
+  ]
+
+br_phi_a:
+  %a1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  br label %join
+
+br_phi_b:
+  %b1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %b)
+  br label %join
+
+br_phi_c:
+  %c1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %c)
+  br label %join
+
+join:
+  %pg = phi  [ %a1, %br_phi_a ], [ %b1, %br_phi_b ], [ %c1, %br_phi_c ]
+  %pg1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  ret  %pg1
+}
+
+define  @reinterpret_reductions_1(i32 %cond,  %a,  %b,  %c) {
+; OPT-LABEL: reinterpret_reductions_1
+; OPT: convert
+; OPT: phi  [ %a1, %br_phi_a ], [ %b1, %br_phi_b ], [ %c1, %br_phi_c ]
+; OPT-NOT: phi 
+; OPT: tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+; OPT: ret
+
+entry:
+  switch i32 %cond, label %br_phi_c

[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-12 Thread Luke Geeson via Phabricator via cfe-commits
LukeGeeson created this revision.
LukeGeeson added reviewers: SjoerdMeijer, stuij, rjmccall, rsmith, liutianle, 
RKSimon, craig.topper.
Herald added subscribers: cfe-commits, danielkiss, arphaman, kristof.beyls.
Herald added a project: clang.
LukeGeeson added a parent revision: D76062: [PATCH] [ARM] ARMv8.6-a 
command-line + BFloat16 Asm Support.

This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties is specified in the Arm C language
extension specification:

https://developer.arm.com/docs/ihi0055/d/procedure-call-standard-for-the-arm-64-bit-architecture

In detail this patch:

- introduces an opaque, storage-only C-type __bf16, which does not introduce a 
new LLVM IR type, but maps it to either i16 or half type.

This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.

Based on work by:

- Luke Cheeseman
- Momchil Velikov
- labrinea


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76077

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/arm-mangle-16bit-float.cpp
  clang/test/Sema/arm-bfloat.cpp

Index: clang/test/Sema/arm-bfloat.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bfloat.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+
+void test(bool b) {
+  __bf16 bf16;
+
+  bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+
+  __fp16 fp16;
+
+  bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 / fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 / bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 = fp16; // expected-error {{assigning to '__bf16' from incompatible type '__fp16'}}
+  fp16 = bf16; // expected-error {{assigning to '__fp16' from incompatible

[PATCH] D75571: [Sema][SVE] Add tests for valid and invalid type usage

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
rsandifo-arm marked an inline comment as done.
Closed by commit rGf09c7d642afa: [Sema][SVE] Add tests for valid and invalid 
type usage (authored by rsandifo-arm).

Changed prior to commit:
  https://reviews.llvm.org/D75571?vs=248601&id=249971#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75571

Files:
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -0,0 +1,469 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
+
+namespace std {
+struct type_info;
+}
+
+typedef __SVInt8_t svint8_t;
+typedef __SVInt16_t svint16_t;
+
+svint8_t *global_int8_ptr;
+extern svint8_t *extern_int8_ptr;
+static svint8_t *static_int8_ptr;
+
+typedef svint8_t int8_typedef;
+typedef svint8_t *int8_ptr_typedef;
+
+void pass_int8(svint8_t); // expected-note {{no known conversion}}
+
+svint8_t return_int8();
+
+typedef svint8_t vec_int8_a __attribute__((vector_size(64)));// expected-error {{invalid vector element type}}
+typedef svint8_t vec_int8_b __attribute__((ext_vector_type(4))); // expected-error {{invalid vector element type}}
+
+void dump(const volatile void *);
+
+void overf(svint8_t);
+void overf(svint16_t);
+
+void overf8(svint8_t); // expected-note + {{not viable}}
+void overf8(int);  // expected-note + {{not viable}}
+
+void overf16(svint16_t); // expected-note + {{not viable}}
+void overf16(int);   // expected-note + {{not viable}}
+
+void varargs(int, ...);
+
+void unused() {
+  svint8_t unused_int8; // expected-warning {{unused}}
+}
+
+struct incomplete_struct *incomplete_ptr;
+
+void func(int sel) {
+  svint8_t local_int8;
+  svint16_t local_int16;
+
+  // Using pointers to sizeless data isn't wrong here, but because the
+  // type is incomplete, it doesn't provide any alignment guarantees.
+  _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
+  _Static_assert(__atomic_is_lock_free(2, &local_int8) == __atomic_is_lock_free(2, incomplete_ptr), ""); // expected-error {{static_assert expression is not an integral constant expression}}
+  _Static_assert(__atomic_always_lock_free(1, &local_int8) == __atomic_always_lock_free(1, incomplete_ptr), "");
+
+  local_int8; // expected-warning {{expression result unused}}
+
+  (void)local_int8;
+
+  local_int8, 0; // expected-warning + {{expression result unused}}
+
+  0, local_int8; // expected-warning + {{expression result unused}}
+
+  svint8_t init_int8 = local_int8;
+  svint8_t bad_init_int8 = for; // expected-error {{expected expression}}
+
+#if __cplusplus >= 201103L
+  int empty_brace_init_int = {};
+#else
+  int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot be empty}}
+#endif
+
+  const svint8_t const_int8 = local_int8; // expected-note {{declared const here}}
+  const svint8_t uninit_const_int8;   // expected-error {{default initialization of an object of const type 'const svint8_t'}}
+
+  volatile svint8_t volatile_int8;
+
+  const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}}
+  const volatile svint8_t uninit_const_volatile_int8;   // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}}
+
+  __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
+
+  bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}}
+
+  int int_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'int' with an lvalue of type 'svint8_t'}}
+
+  init_int8 = local_int8;
+  init_int8 = local_int16; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'svint16_t'}}
+  init_int8 = sel; // expected-error {{assigning to 'svint8_t' (aka '__SVInt8_t') from incompatible type 'int'}}
+
+  sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}}
+
+  local_int8 = (svint8_t)local_int8;
+  local_int8 = (const svint8_t)local_int8;
+  local_int8 = (svint8_t)local_int16; // expected-error {{C-style cast from 'svint16_t' (aka '__SVInt16_t') to 'svint8_t

[PATCH] D75572: [Sema][SVE] Reject sizeof and alignof for sizeless types

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39969c7d3a6d: [Sema][SVE] Reject sizeof and alignof for 
sizeless types (authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75572

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/aarch64-sve-types.c
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp

Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -17,6 +17,20 @@
 typedef svint8_t int8_typedef;
 typedef svint8_t *int8_ptr_typedef;
 
+int sizeof_int8 = sizeof(svint8_t); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var = sizeof(*extern_int8_ptr); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var_ptr = sizeof(extern_int8_ptr);
+
+#if __cplusplus >= 201103L
+int alignof_int8 = alignof(svint8_t);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+int alignof_int8_var = alignof(*extern_int8_ptr);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
+int alignof_int8_var_ptr = alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
+#else
+int alignof_int8 = _Alignof(svint8_t);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+int alignof_int8_var = _Alignof(*extern_int8_ptr);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
+int alignof_int8_var_ptr = _Alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
+#endif
+
 void pass_int8(svint8_t); // expected-note {{no known conversion}}
 
 svint8_t return_int8();
@@ -47,6 +61,8 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment guarantees.
   _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -12,6 +12,14 @@
 typedef svint8_t int8_typedef;
 typedef svint8_t *int8_ptr_typedef;
 
+int sizeof_int8 = sizeof(svint8_t); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var = sizeof(*extern_int8_ptr); // expected-error {{invalid application of 'sizeof' to sizeless type 'svint8_t'}}
+int sizeof_int8_var_ptr = sizeof(extern_int8_ptr);
+
+int alignof_int8 = _Alignof(svint8_t);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+int alignof_int8_var = _Alignof(*extern_int8_ptr);// expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}} expected-warning {{GNU extension}}
+int alignof_int8_var_ptr = _Alignof(extern_int8_ptr); // expected-warning {{GNU extension}}
+
 void pass_int8(svint8_t); // expected-note {{passing argument to parameter here}}
 
 svint8_t return_int8();
@@ -43,6 +51,8 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
+
   // Using pointers to sizeless data isn't wrong here, but because the
   // type is incomplete, it doesn't provide any alignment guarantees.
   _Static_assert(__atomic_is_lock_free(1, &local_int8) == __atomic_is_lock_free(1, incomplete_ptr), "");
Index: clang/test/Sema/aarch64-sve-types.c
===
--- clang/test/Sema/aarch64-sve-types.c
+++ clang/test/Sema/aarch64-sve-types.c
@@ -1,52 +1,39 @@
 // RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +sve -fsyntax-only -verify
 
-// This test is invalid under the sizeless type extension and is a stop-gap
-// until that extension is added.  The test makes sure that sizeof and
-// alignof queries are handled without assertion failures, since at
-// present there is nothing to prevent such queries being made.
-//
-// Under this scheme, sizeof returns 0 for all built-in sizeless types.
-// This is compatible with correct usage but it relies on the user being
-// careful to avoid constructs that depend directly or indirectly on the
-// value of sizeof.  (The sizeless type extension avoids this by treating
-// 

[PATCH] D76030: [CUDA] Warn about unsupported CUDA SDK version only if it's used.

2020-03-12 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeb2ba2ea953b: [CUDA] Warn about unsupported CUDA SDK version 
only if it's used. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76030

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/cuda-version-check.cu

Index: clang/test/Driver/cuda-version-check.cu
===
--- clang/test/Driver/cuda-version-check.cu
+++ clang/test/Driver/cuda-version-check.cu
@@ -10,6 +10,10 @@
 // RUN:FileCheck %s --check-prefix=OK
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// Make sure that we don't warn about CUDA version during C++ compilation.
+// RUN: %clang --target=x86_64-linux -v -### -x c++ --cuda-gpu-arch=sm_60 \
+// RUN:--cuda-path=%S/Inputs/CUDA-unknown/usr/local/cuda 2>&1 %s | \
+// RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION_CXX
 
 // The installation at Inputs/CUDA is CUDA 7.0, which doesn't support sm_60.
 // RUN: %clang --target=x86_64-linux -v -### --cuda-gpu-arch=sm_60 --cuda-path=%S/Inputs/CUDA/usr/local/cuda 2>&1 %s | \
@@ -62,3 +66,4 @@
 // ERR_SM61-NOT: error: GPU arch sm_61
 
 // UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest supported version
+// UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version
Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -30,6 +30,8 @@
   const Driver &D;
   bool IsValid = false;
   CudaVersion Version = CudaVersion::UNKNOWN;
+  std::string DetectedVersion;
+  bool DetectedVersionIsNotSupported = false;
   std::string InstallPath;
   std::string BinPath;
   std::string LibPath;
@@ -75,6 +77,10 @@
   std::string getLibDeviceFile(StringRef Gpu) const {
 return LibDeviceMap.lookup(Gpu);
   }
+  void WarnIfUnsupportedVersion();
+
+private:
+  void ParseCudaVersionFile(llvm::StringRef V);
 };
 
 namespace tools {
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -34,24 +34,28 @@
 
 // Parses the contents of version.txt in an CUDA installation.  It should
 // contain one line of the from e.g. "CUDA Version 7.5.2".
-static CudaVersion ParseCudaVersionFile(const Driver &D, llvm::StringRef V) {
+void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
+  Version = CudaVersion::UNKNOWN;
   if (!V.startswith("CUDA Version "))
-return CudaVersion::UNKNOWN;
+return;
   V = V.substr(strlen("CUDA Version "));
   SmallVector VersionParts;
   V.split(VersionParts, '.');
   if (VersionParts.size() < 2)
-return CudaVersion::UNKNOWN;
-  std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]);
-  CudaVersion Version = CudaStringToVersion(MajorMinor);
+return;
+  DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
+  Version = CudaStringToVersion(DetectedVersion);
   if (Version != CudaVersion::UNKNOWN)
-return Version;
+return;
 
-  // Issue a warning and assume that the version we've found is compatible with
-  // the latest version we support.
-  D.Diag(diag::warn_drv_unknown_cuda_version)
-  << MajorMinor << CudaVersionToString(CudaVersion::LATEST);
-  return CudaVersion::LATEST;
+  Version = CudaVersion::LATEST;
+  DetectedVersionIsNotSupported = true;
+}
+
+void CudaInstallationDetector::WarnIfUnsupportedVersion() {
+  if (DetectedVersionIsNotSupported)
+D.Diag(diag::warn_drv_unknown_cuda_version)
+<< DetectedVersion << CudaVersionToString(Version);
 }
 
 CudaInstallationDetector::CudaInstallationDetector(
@@ -150,7 +154,7 @@
   // version.txt isn't present.
   Version = CudaVersion::CUDA_70;
 } else {
-  Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer());
+  ParseCudaVersionFile((*VersionFile)->getBuffer());
 }
 
 if (Version >= CudaVersion::CUDA_90) {
@@ -568,8 +572,10 @@
  const Action::OffloadKind OK)
 : ToolChain(D, Triple, Args), HostTC(HostTC),
   CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
-  if (CudaInstallation.isValid())
+  if (CudaInstallation.isValid()) {
+CudaInstallation.WarnIfUnsupportedVersion();
 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
+  }
   // Lookup binaries into the driver directory, this is used to
   // discover the clang-offload-bundler executable.
   getProgramPaths().push_back(getDriver().Dir);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] 627b5c1 - [Sema][SVE] Reject aligned/_Alignas for sizeless types

2020-03-12 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-12T17:12:40Z
New Revision: 627b5c12068cc90b476a9121862a481e1d57be85

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

LOG: [Sema][SVE] Reject aligned/_Alignas for sizeless types

A previous patch rejected alignof for sizeless types.  This patch
extends that to cover the "aligned" attribute and _Alignas.  Since
sizeless types are not meant to be used for long-term data, cannot
be used in aggregates, and cannot have static storage duration,
there shouldn't be any need to fiddle with their alignment.

Like with alignof, this is a conservative position that can be
relaxed in future if it turns out to be too restrictive.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3a532fedac48..fe0f9e959a1b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2807,6 +2807,8 @@ def err_alignas_mismatch : Error<
   "redeclaration has 
diff erent alignment requirement (%1 vs %0)">;
 def err_alignas_underaligned : Error<
   "requested alignment is less than minimum alignment of %1 for type %0">;
+def err_attribute_sizeless_type : Error<
+  "%0 attribute cannot be applied to sizeless type %1">;
 def err_attribute_argument_n_type : Error<
   "%0 attribute requires parameter %1 to be %select{int or bool|an integer "
   "constant|a string|an identifier}2">;

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 2e1710f70753..3385717e3138 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3868,6 +3868,7 @@ void Sema::CheckAlignasUnderalignment(Decl *D) {
   //   not specify an alignment that is less strict than the alignment that
   //   would otherwise be required for the entity being declared.
   AlignedAttr *AlignasAttr = nullptr;
+  AlignedAttr *LastAlignedAttr = nullptr;
   unsigned Align = 0;
   for (auto *I : D->specific_attrs()) {
 if (I->isAlignmentDependent())
@@ -3875,9 +3876,13 @@ void Sema::CheckAlignasUnderalignment(Decl *D) {
 if (I->isAlignas())
   AlignasAttr = I;
 Align = std::max(Align, I->getAlignment(Context));
+LastAlignedAttr = I;
   }
 
-  if (AlignasAttr && Align) {
+  if (Align && DiagTy->isSizelessType()) {
+Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
+<< LastAlignedAttr << DiagTy;
+  } else if (AlignasAttr && Align) {
 CharUnits RequestedAlign = Context.toCharUnitsFromBits(Align);
 CharUnits NaturalAlign = Context.getTypeAlignInChars(UnderlyingTy);
 if (NaturalAlign > RequestedAlign)

diff  --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c
index 3f1bfb93a298..3e3c3259681a 100644
--- a/clang/test/Sema/sizeless-1.c
+++ b/clang/test/Sema/sizeless-1.c
@@ -51,6 +51,10 @@ void func(int sel) {
   svint8_t local_int8;
   svint16_t local_int16;
 
+  svint8_t __attribute__((aligned)) aligned_int8_1;// expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t _Alignas(int) aligned_int8_3;   // expected-error 
{{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
+
   int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application 
of 'alignof' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the

diff  --git a/clang/test/SemaCXX/sizeless-1.cpp 
b/clang/test/SemaCXX/sizeless-1.cpp
index a2ee6205ec97..638eb523ac9c 100644
--- a/clang/test/SemaCXX/sizeless-1.cpp
+++ b/clang/test/SemaCXX/sizeless-1.cpp
@@ -61,6 +61,10 @@ void func(int sel) {
   svint8_t local_int8;
   svint16_t local_int16;
 
+  svint8_t __attribute__((aligned)) aligned_int8_1;// expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t _Alignas(int) aligned_int8_3;   // expected-error 
{{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
+
   int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application 
of 'alignof' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the



__

[clang] adb290d - [Sema][SVE] Reject atomic sizeless types

2020-03-12 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-12T17:20:23Z
New Revision: adb290d97482aa9311ee4b4b5917a0f2ece55b30

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

LOG: [Sema][SVE] Reject atomic sizeless types

It would be difficult to guarantee atomicity for sizeless types,
so the SVE ACLE makes atomic sizeless types invalid.  As it happens,
we already rejected them before the patch, but for the wrong reason:

  error: _Atomic cannot be applied to type 'svint8_t' (aka '__SVInt8_t')
  which is not trivially copyable

The SVE types should be treated as trivially copyable; a later
patch fixes that.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaType.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index fe0f9e959a1b..830787e2663c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5925,7 +5925,7 @@ def err_func_def_incomplete_result : Error<
   "incomplete result type %0 in function definition">;
 def err_atomic_specifier_bad_type : Error<
   "_Atomic cannot be applied to "
-  "%select{incomplete |array |function |reference |atomic |qualified |}0type "
+  "%select{incomplete |array |function |reference |atomic |qualified |sizeless 
|}0type "
   "%1 %select{||which is not trivially copyable}0">;
 
 // Expressions.

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1d9826f1970d..f7da1b13a1bf 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8564,9 +8564,11 @@ QualType Sema::BuildAtomicType(QualType T, 
SourceLocation Loc) {
   DisallowedKind = 4;
 else if (T.hasQualifiers())
   DisallowedKind = 5;
+else if (T->isSizelessType())
+  DisallowedKind = 6;
 else if (!T.isTriviallyCopyableType(Context))
   // Some other non-trivially-copyable type (probably a C++ class)
-  DisallowedKind = 6;
+  DisallowedKind = 7;
 
 if (DisallowedKind != -1) {
   Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;

diff  --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c
index 3e3c3259681a..c33aba8e2e55 100644
--- a/clang/test/Sema/sizeless-1.c
+++ b/clang/test/Sema/sizeless-1.c
@@ -84,6 +84,7 @@ void func(int sel) {
   const volatile svint8_t const_volatile_int8 = local_int8; // expected-note 
{{declared const here}}
   const volatile svint8_t uninit_const_volatile_int8;
 
+  _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be 
applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or 
reference}}
 
   _Bool test_int8 = init_int8; // expected-error {{initializing '_Bool' with 
an expression of incompatible type 'svint8_t'}}

diff  --git a/clang/test/SemaCXX/sizeless-1.cpp 
b/clang/test/SemaCXX/sizeless-1.cpp
index 638eb523ac9c..dda36fdbd0d4 100644
--- a/clang/test/SemaCXX/sizeless-1.cpp
+++ b/clang/test/SemaCXX/sizeless-1.cpp
@@ -98,6 +98,7 @@ void func(int sel) {
   const volatile svint8_t const_volatile_int8 = local_int8; // expected-note 
{{declared const here}}
   const volatile svint8_t uninit_const_volatile_int8;   // expected-error 
{{default initialization of an object of const type 'const volatile svint8_t'}}
 
+  _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be 
applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or 
reference}}
 
   bool test_int8 = init_int8; // expected-error {{cannot initialize a variable 
of type 'bool' with an lvalue of type 'svint8_t'}}



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


[clang] f8700db - [Sema][SVE] Don't allow static or thread-local variables to have sizeless type

2020-03-12 Thread Richard Sandiford via cfe-commits

Author: Richard Sandiford
Date: 2020-03-12T17:39:29Z
New Revision: f8700db7f150287b71453e4ae10dea79a2e4fb03

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

LOG: [Sema][SVE] Don't allow static or thread-local variables to have sizeless 
type

clang accepts a TU containing just:

  __SVInt8_t x;

However, sizeless types are not allowed to have static or thread-local
storage duration and trying to code-generate the TU triggers an LLVM
fatal error:

  Globals cannot contain scalable vectors
  * @x
  fatal error: error in backend: Broken module found, compilation aborted!

This patch adds an associated clang diagnostic.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDecl.cpp
clang/test/Sema/sizeless-1.c
clang/test/SemaCXX/sizeless-1.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 830787e2663c..5312c1987f56 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9145,6 +9145,8 @@ def err_block_on_nonlocal : Error<
   "__block attribute not allowed, only allowed on local variables">;
 def err_block_on_vm : Error<
   "__block attribute not allowed on declaration with a variably modified 
type">;
+def err_sizeless_nonlocal : Error<
+  "non-local variable with sizeless type %0">;
 
 def err_vec_builtin_non_vector : Error<
  "first two arguments to %0 must be vectors">;

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index da40ac188e54..7d56109b7338 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7939,6 +7939,12 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
 return;
   }
 
+  if (!NewVD->hasLocalStorage() && T->isSizelessType()) {
+Diag(NewVD->getLocation(), diag::err_sizeless_nonlocal) << T;
+NewVD->setInvalidDecl();
+return;
+  }
+
   if (isVM && NewVD->hasAttr()) {
 Diag(NewVD->getLocation(), diag::err_block_on_vm);
 NewVD->setInvalidDecl();

diff  --git a/clang/test/Sema/sizeless-1.c b/clang/test/Sema/sizeless-1.c
index c33aba8e2e55..f1f562938dbd 100644
--- a/clang/test/Sema/sizeless-1.c
+++ b/clang/test/Sema/sizeless-1.c
@@ -5,6 +5,10 @@
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 
+svint8_t global_int8;  // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+extern svint8_t extern_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+static svint8_t static_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+__thread svint8_t thread_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
 svint8_t *global_int8_ptr;
 extern svint8_t *extern_int8_ptr;
 static svint8_t *static_int8_ptr;
@@ -48,6 +52,8 @@ void unused() {
 struct incomplete_struct *incomplete_ptr;
 
 void func(int sel) {
+  static svint8_t static_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+
   svint8_t local_int8;
   svint16_t local_int16;
 

diff  --git a/clang/test/SemaCXX/sizeless-1.cpp 
b/clang/test/SemaCXX/sizeless-1.cpp
index dda36fdbd0d4..11cc629620d6 100644
--- a/clang/test/SemaCXX/sizeless-1.cpp
+++ b/clang/test/SemaCXX/sizeless-1.cpp
@@ -10,6 +10,10 @@ struct type_info;
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 
+svint8_t global_int8;  // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+extern svint8_t extern_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+static svint8_t static_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+__thread svint8_t thread_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
 svint8_t *global_int8_ptr;
 extern svint8_t *extern_int8_ptr;
 static svint8_t *static_int8_ptr;
@@ -58,6 +62,8 @@ void unused() {
 struct incomplete_struct *incomplete_ptr;
 
 void func(int sel) {
+  static svint8_t static_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+
   svint8_t local_int8;
   svint16_t local_int16;
 



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


[PATCH] D76079: [Hexagon] Enable init_arrays when target is linux-musl

2020-03-12 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: kparzysz, bcain, adasgupt.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

linux/musl will use init arrays by default.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76079

Files:
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/test/Driver/hexagon-toolchain-elf.c


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -664,3 +664,13 @@
 // CHECK089:   "/hexagon{{/|}}lib{{/|}}crt1.o"
 // CHECK089-NOT:   -lclang_rt.builtins-hexagon
 // CHECK089-NOT:   -lc
+// 
-
+// Not Passing -fno-use-init-array when musl is selected
+// 
-
+// RUN: %clang -### -target hexagon-unknown-linux-musl \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK090 %s
+// CHECK090-NOT:  -fno-use-init-array
+// 
-
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -544,7 +544,8 @@
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
-  bool UseInitArrayDefault = false;
+
+  bool UseInitArrayDefault = (getTriple().isMusl()) ? true : false;
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array,


Index: clang/test/Driver/hexagon-toolchain-elf.c
===
--- clang/test/Driver/hexagon-toolchain-elf.c
+++ clang/test/Driver/hexagon-toolchain-elf.c
@@ -664,3 +664,13 @@
 // CHECK089:   "/hexagon{{/|}}lib{{/|}}crt1.o"
 // CHECK089-NOT:   -lclang_rt.builtins-hexagon
 // CHECK089-NOT:   -lc
+// -
+// Not Passing -fno-use-init-array when musl is selected
+// -
+// RUN: %clang -### -target hexagon-unknown-linux-musl \
+// RUN:   -ccc-install-dir %S/Inputs/hexagon_tree/Tools/bin \
+// RUN:   -mcpu=hexagonv60 \
+// RUN:   %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK090 %s
+// CHECK090-NOT:  -fno-use-init-array
+// -
Index: clang/lib/Driver/ToolChains/Hexagon.cpp
===
--- clang/lib/Driver/ToolChains/Hexagon.cpp
+++ clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -544,7 +544,8 @@
 void HexagonToolChain::addClangTargetOptions(const ArgList &DriverArgs,
  ArgStringList &CC1Args,
  Action::OffloadKind) const {
-  bool UseInitArrayDefault = false;
+
+  bool UseInitArrayDefault = (getTriple().isMusl()) ? true : false;
 
   if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
   options::OPT_fno_use_init_array,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74618: [ARM] Creating 'call_mangled' for Neon intrinsics definitions

2020-03-12 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 249979.
pratlucas added a comment.

Adding example to call_mangled description comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74618

Files:
  clang/include/clang/Basic/arm_neon_incl.td
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -27,8 +27,9 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/None.h"
-#include "llvm/ADT/SmallVector.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"
@@ -518,7 +519,8 @@
 std::pair emitDagDupTyped(DagInit *DI);
 std::pair emitDagShuffle(DagInit *DI);
 std::pair emitDagCast(DagInit *DI, bool IsBitCast);
-std::pair emitDagCall(DagInit *DI);
+std::pair emitDagCall(DagInit *DI,
+ bool MatchMangledName);
 std::pair emitDagNameReplace(DagInit *DI);
 std::pair emitDagLiteral(DagInit *DI);
 std::pair emitDagOp(DagInit *DI);
@@ -546,7 +548,8 @@
 public:
   /// Called by Intrinsic - this attempts to get an intrinsic that takes
   /// the given types as arguments.
-  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types);
+  Intrinsic &getIntrinsic(StringRef Name, ArrayRef Types,
+  Optional MangledName);
 
   /// Called by Intrinsic - returns a globally-unique number.
   unsigned getUniqueNumber() { return UniqueNumber++; }
@@ -1383,8 +1386,8 @@
 return emitDagSaveTemp(DI);
   if (Op == "op")
 return emitDagOp(DI);
-  if (Op == "call")
-return emitDagCall(DI);
+  if (Op == "call" || Op == "call_mangled")
+return emitDagCall(DI, Op == "call_mangled");
   if (Op == "name_replace")
 return emitDagNameReplace(DI);
   if (Op == "literal")
@@ -1411,7 +1414,8 @@
   }
 }
 
-std::pair Intrinsic::DagEmitter::emitDagCall(DagInit *DI) {
+std::pair
+Intrinsic::DagEmitter::emitDagCall(DagInit *DI, bool MatchMangledName) {
   std::vector Types;
   std::vector Values;
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
@@ -1427,7 +1431,13 @@
 N = SI->getAsUnquotedString();
   else
 N = emitDagArg(DI->getArg(0), "").second;
-  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types);
+  Optional MangledName;
+  if (MatchMangledName) {
+if (Intr.getRecord()->getValueAsBit("isLaneQ"))
+  N += "q";
+MangledName = Intr.mangleName(N, ClassS);
+  }
+  Intrinsic &Callee = Intr.Emitter.getIntrinsic(N, Types, MangledName);
 
   // Make sure the callee is known as an early def.
   Callee.setNeededEarly();
@@ -1832,7 +1842,8 @@
 // NeonEmitter implementation
 //===--===//
 
-Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types) {
+Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef Types,
+ Optional MangledName) {
   // First, look up the name in the intrinsic map.
   assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(),
   ("Intrinsic '" + Name + "' not found!").str());
@@ -1861,17 +1872,19 @@
 }
 ErrMsg += ")\n";
 
+if (MangledName && MangledName != I.getMangledName(true))
+  continue;
+
 if (I.getNumParams() != Types.size())
   continue;
 
-bool Good = true;
-for (unsigned Arg = 0; Arg < Types.size(); ++Arg) {
-  if (I.getParamType(Arg) != Types[Arg]) {
-Good = false;
-break;
-  }
-}
-if (Good)
+unsigned ArgNum = 0;
+bool MatchingArgumentTypes =
+std::all_of(Types.begin(), Types.end(), [&](const auto &Type) {
+  return Type == I.getParamType(ArgNum++);
+});
+
+if (MatchingArgumentTypes)
   GoodVec.push_back(&I);
   }
 
Index: clang/include/clang/Basic/arm_neon_incl.td
===
--- clang/include/clang/Basic/arm_neon_incl.td
+++ clang/include/clang/Basic/arm_neon_incl.td
@@ -60,6 +60,15 @@
 // example: (call "vget_high", $p0) -> "vgetq_high_s16(__p0)"
 //(assuming $p0 has type int16x8_t).
 def call;
+// call_mangled - Invoke another intrinsic matching the mangled name variation
+//of the caller's base type. If there is no intrinsic defined
+//that has the variation and takes the given types, an error
+//is generated at tblgen time.
+// example: (call_mangled "vfma_lane", $p0, $p1) -> "vfma_lane(__p0, __p1)"
+//(assuming non-LaneQ caller)
+//  (call_mangled "vfma_lane", $p0, $p1) -> "vfma_laneq(__p0, __p1)"
+//(assuming LaneQ caller)
+def call_mangled;
 //

[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-12 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp:55-71
+  if (const auto *Reference =
+  Result.Nodes.getNodeAs("reference_to_non-const")) {
+diag(Reference->getLocation(),
+ "variable %0 provides global access to non-const type, consider "
+ "making the referenced data const")
+<< Reference; // FIXME: Add fix-it hint to Reference
+return;

aaron.ballman wrote:
> vingeldal wrote:
> > aaron.ballman wrote:
> > > I think these cases should be combined to avoid duplication.
> > > ```
> > > if (const auto *VD = Result.Nodes.getNodeAs("whatever")) {
> > >   diag(VD->getLocation(), "variable %0 provides global access to a 
> > > non-const object; considering making the %select{referenced|pointed-to}1 
> > > data 'const'") << VD << VD->getType()->isReferenceType();
> > >   return;
> > > }
> > > ```
> > > the matcher needs to be changed to bind to the same id for both cases.
> > > 
> > > Note, this rewords the diagnostic slightly to avoid type/object confusion 
> > > (the variable provides access to an object of a non-const type, not to 
> > > the type itself).
> > You mean just the pointer and reference cases right? That matcher seems to 
> > get much more complicated, I'm having some trouble accomplishing that. Are 
> > you sure that's necessary? What would the cases of duplication be?
> > You mean just the pointer and reference cases right? 
> 
> Yup!
> 
> > Are you sure that's necessary? What would the cases of duplication be?
> 
> Not strictly necessary, so if this turns out to be hard, I'm fine skipping 
> it. However, I was thinking it would be something like:
> ```
> // Registering checks
> Finder->addMatcher(GlobalReferenceToNonConst.bind("qual-non-const"), this);
> Finder->addMatcher(GlobalPointerToNonConst.bind("qual-non-const"), this);
> 
> // In check
> if (const auto *VD = Result.Nodes.getNodeAs("qual-non-const")) {
>   diag(VD->getLocation(),
>   "variable %0 provides global access to a non-const object; 
> considering making the %select{pointed-to|referenced}1 data 'const'") << VD 
> << VD->getType()->isReferenceType();
>   return;
>   }
> ```
Oh, I didn't understand I could just keep the two matchers and use the same 
binding string. I should have read more carefully.
Sure I'll do that, its no effort and it looks nicer.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst:33
+char h = 0;
+  }
+

aaron.ballman wrote:
> This isn't legal code either.
> 
> You may want to run the example through the compiler to catch these sort of 
> things.
Oops, will make sure and do that next time to save us all some time and me some 
embarrassment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265



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


[PATCH] D70265: [clang-tidy] Add CppCoreGuidelines I.2 "Avoid non-const global variables" check

2020-03-12 Thread Kim Viggedal via Phabricator via cfe-commits
vingeldal updated this revision to Diff 249980.
vingeldal marked 6 inline comments as done.
vingeldal added a comment.

Made example code in documentation legal C++

Changed implementation according to comments so that both the pointer matcher
and the reference matcher now bind to the same id


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70265

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-avoid-non-const-global-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-avoid-non-const-global-variables.cpp
@@ -0,0 +1,237 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-avoid-non-const-global-variables %t
+
+int nonConstInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+int &nonConstIntReference = nonConstInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'nonConstIntReference' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+
+int *pointerToNonConstInt = &nonConstInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: variable 'pointerToNonConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: variable 'pointerToNonConstInt' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+
+int *const constPointerToNonConstInt = &nonConstInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'constPointerToNonConstInt' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+
+namespace namespace_name {
+int nonConstNamespaceInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+const int constNamespaceInt = 0;
+} // namespace namespace_name
+
+const int constInt = 0;
+
+const int *pointerToConstInt = &constInt;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'pointerToConstInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+const int *const constPointerToConstInt = &constInt;
+
+const int &constReferenceToConstInt = constInt;
+
+constexpr int constexprInt = 0;
+
+int function() {
+  int nonConstReturnValue = 0;
+  return nonConstReturnValue;
+}
+
+namespace {
+int nonConstAnonymousNamespaceInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'nonConstAnonymousNamespaceInt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+} // namespace
+
+class DummyClass {
+public:
+  int nonConstPublicMemberVariable = 0;
+  const int constPublicMemberVariable = 0;
+
+private:
+  int nonConstPrivateMemberVariable = 0;
+  const int constPrivateMemberVariable = 0;
+};
+
+DummyClass nonConstClassInstance;
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'nonConstClassInstance' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+
+DummyClass *pointerToNonConstDummyClass = &nonConstClassInstance;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'pointerToNonConstDummyClass' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
+// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: variable 'pointerToNonConstDummyClass' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+
+DummyClass &referenceToNonConstDummyClass = nonConstClassInstance;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'referenceToNonConstDummyClass' provides global access to a non-const object; consider making the referenced data 'const' [cppcoreguidelines-avoid-non-const-global-variables]
+
+int 

[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D72675#1919685 , @spatel wrote:

> In D72675#1917844 , @wristow wrote:
>
> > Revisiting this patch.  I think that before fixing the `-ffp-contract=off` 
> > problem I originally raised here, there are two questions that have come up 
> > in this discussion that we should first resolve.  Specifically:
> >
> > (1)  Do we want to enable FMA transformations by default (at appropriate 
> > optimization levels), like GCC does?  That is, should FMA be done for 
> > targets that support it with a command as simple as the following?
> >
> >   clang -O2 -c test.c
>
>
> This has been discussed/tried a few times including very recently. I'm not 
> sure where we stand currently, but here's some background:
>  https://reviews.llvm.org/rL282259
>  D74436   - cc @mibintc
>
> And (sorry for the various flavors of links to the dev-lists, but that's how 
> it showed up in the search results):
>  http://lists.llvm.org/pipermail/llvm-dev/2017-March/29.html
>  http://lists.llvm.org/pipermail/cfe-dev/2020-February/064645.html
>  https://groups.google.com/forum/#!msg/llvm-dev/nBiCD5KvYW0/yfjrVzR7DAAJ
>  https://groups.google.com/forum/#!topic/llvm-dev/Aev2jQYepKQ
>  http://clang-developers.42468.n3.nabble.com/RFC-FP-contract-on-td4056277.html


A few weeks ago there was a discussion on cfe-dev and llvm-dev initiated by 
@andrew.w.kaylor and while the response wasn't unanimous, there was an 
overwhelming sentiment (in my opinion) that it is correct and desireable to 
enable ffp-contract=on by default even at -O0.  I had submitted a patch to do 
that. However the patch caused performance regressions in about 20 LNT tests 
and the patch was reverted, the regression was seen on multiple architecture. I 
can send provide a few more details about the performance problems, I don't 
have a solution to the LNT regression.


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

https://reviews.llvm.org/D72675



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

This patch, which hasn't been committed, contains modifications to the 
UserManual with many details concerning 'floating point semantic modes" and the 
relation to floating point command line options. This is from a discussion that 
@andrew.w.kaylor initiated on the discussion lists.  
https://reviews.llvm.org/D74436


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

https://reviews.llvm.org/D72675



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-12 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

I suspect we also need to support saving/loading some of this information in 
the serialized AST, e.g. clang/lib/Serialization/ASTWriter.cpp has code to save 
the HeaderInfo data, around line 1650. And around line 2174, code to save the 
macros per submodule. We'll also need to save the pragma-once-header-state 
per-submodule too, I think.




Comment at: clang/lib/Lex/HeaderSearch.cpp:1264
+  if (FileInfo.isPragmaOnce || FileInfo.isImport){
+if (FileInfo.isModuleHeader && M != nullptr){
+  if (PP.isIncludeVisibleInLocalModule(File, M)) return false;

I don't think whether the header you're trying to include is modular or not 
(isModuleHeader) should matter here, just whether we have a current module M or 
not.




Comment at: clang/lib/Lex/HeaderSearch.cpp:1266
+  if (PP.isIncludeVisibleInLocalModule(File, M)) return false;
+  else  PP.setIncludeVisibleForHeader(File, M);
+} else {

I wonder if this should be just using the CurSubmoduleState. Actually, is "M" 
even needed in this function at all -- why isn't everything just using 
CurSubmoduleState? (It's very likely I'm just confused about what the semantics 
of this are...).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951



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


[PATCH] D75734: [Sema][SVE] Reject atomic sizeless types

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGadb290d97482: [Sema][SVE] Reject atomic sizeless types 
(authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75734

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -98,6 +98,7 @@
   const volatile svint8_t const_volatile_int8 = local_int8; // expected-note 
{{declared const here}}
   const volatile svint8_t uninit_const_volatile_int8;   // expected-error 
{{default initialization of an object of const type 'const volatile svint8_t'}}
 
+  _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be 
applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or 
reference}}
 
   bool test_int8 = init_int8; // expected-error {{cannot initialize a variable 
of type 'bool' with an lvalue of type 'svint8_t'}}
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -84,6 +84,7 @@
   const volatile svint8_t const_volatile_int8 = local_int8; // expected-note 
{{declared const here}}
   const volatile svint8_t uninit_const_volatile_int8;
 
+  _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be 
applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or 
reference}}
 
   _Bool test_int8 = init_int8; // expected-error {{initializing '_Bool' with 
an expression of incompatible type 'svint8_t'}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8564,9 +8564,11 @@
   DisallowedKind = 4;
 else if (T.hasQualifiers())
   DisallowedKind = 5;
+else if (T->isSizelessType())
+  DisallowedKind = 6;
 else if (!T.isTriviallyCopyableType(Context))
   // Some other non-trivially-copyable type (probably a C++ class)
-  DisallowedKind = 6;
+  DisallowedKind = 7;
 
 if (DisallowedKind != -1) {
   Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T;
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5925,7 +5925,7 @@
   "incomplete result type %0 in function definition">;
 def err_atomic_specifier_bad_type : Error<
   "_Atomic cannot be applied to "
-  "%select{incomplete |array |function |reference |atomic |qualified |}0type "
+  "%select{incomplete |array |function |reference |atomic |qualified |sizeless 
|}0type "
   "%1 %select{||which is not trivially copyable}0">;
 
 // Expressions.


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -98,6 +98,7 @@
   const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}}
   const volatile svint8_t uninit_const_volatile_int8;   // expected-error {{default initialization of an object of const type 'const volatile svint8_t'}}
 
+  _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
 
   bool test_int8 = init_int8; // expected-error {{cannot initialize a variable of type 'bool' with an lvalue of type 'svint8_t'}}
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -84,6 +84,7 @@
   const volatile svint8_t const_volatile_int8 = local_int8; // expected-note {{declared const here}}
   const volatile svint8_t uninit_const_volatile_int8;
 
+  _Atomic svint8_t atomic_int8;  // expected-error {{_Atomic cannot be applied to sizeless type 'svint8_t'}}
   __restrict svint8_t restrict_int8; // expected-error {{requires a pointer or reference}}
 
   _Bool test_int8 = init_int8; // expected-error {{initializing '_Bool' with an expression of incompatible type 'svint8_t'}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8564,9 +8564,11 @@
   DisallowedKind = 4;
 else if (T.hasQualifiers())
   DisallowedKind = 5;
+ 

[PATCH] D75573: [Sema][SVE] Reject aligned/_Alignas for sizeless types

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG627b5c12068c: [Sema][SVE] Reject aligned/_Alignas for 
sizeless types (authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75573

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -61,6 +61,10 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  svint8_t __attribute__((aligned)) aligned_int8_1;// expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t _Alignas(int) aligned_int8_3;   // expected-error 
{{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
+
   int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application 
of 'alignof' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -51,6 +51,10 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  svint8_t __attribute__((aligned)) aligned_int8_1;// expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error 
{{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t _Alignas(int) aligned_int8_3;   // expected-error 
{{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
+
   int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application 
of 'alignof' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3868,6 +3868,7 @@
   //   not specify an alignment that is less strict than the alignment that
   //   would otherwise be required for the entity being declared.
   AlignedAttr *AlignasAttr = nullptr;
+  AlignedAttr *LastAlignedAttr = nullptr;
   unsigned Align = 0;
   for (auto *I : D->specific_attrs()) {
 if (I->isAlignmentDependent())
@@ -3875,9 +3876,13 @@
 if (I->isAlignas())
   AlignasAttr = I;
 Align = std::max(Align, I->getAlignment(Context));
+LastAlignedAttr = I;
   }
 
-  if (AlignasAttr && Align) {
+  if (Align && DiagTy->isSizelessType()) {
+Diag(LastAlignedAttr->getLocation(), diag::err_attribute_sizeless_type)
+<< LastAlignedAttr << DiagTy;
+  } else if (AlignasAttr && Align) {
 CharUnits RequestedAlign = Context.toCharUnitsFromBits(Align);
 CharUnits NaturalAlign = Context.getTypeAlignInChars(UnderlyingTy);
 if (NaturalAlign > RequestedAlign)
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2807,6 +2807,8 @@
   "redeclaration has different alignment requirement (%1 vs %0)">;
 def err_alignas_underaligned : Error<
   "requested alignment is less than minimum alignment of %1 for type %0">;
+def err_attribute_sizeless_type : Error<
+  "%0 attribute cannot be applied to sizeless type %1">;
 def err_attribute_argument_n_type : Error<
   "%0 attribute requires parameter %1 to be %select{int or bool|an integer "
   "constant|a string|an identifier}2">;


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -61,6 +61,10 @@
   svint8_t local_int8;
   svint16_t local_int16;
 
+  svint8_t __attribute__((aligned)) aligned_int8_1;// expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t __attribute__((aligned(4))) aligned_int8_2; // expected-error {{'aligned' attribute cannot be applied to sizeless type 'svint8_t'}}
+  svint8_t _Alignas(int) aligned_int8_3;   // expected-error {{'_Alignas' attribute cannot be applied to sizeless type 'svint8_t'}}
+
   int _Alignas(svint8_t) aligned_int; // expected-error {{invalid application of 'alignof' to sizeless type 'svint8_t'}}
 
   // Using pointers to sizeless data isn't wrong here, but because the
Index: clang/test/Sema/sizeless-1.c

[PATCH] D75736: [Sema][SVE] Don't allow static or thread-local variables to have sizeless type

2020-03-12 Thread Richard Sandiford via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8700db7f150: [Sema][SVE] Don't allow static or 
thread-local variables to have sizeless type (authored by rsandifo-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75736

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -10,6 +10,10 @@
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 
+svint8_t global_int8;  // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+extern svint8_t extern_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+static svint8_t static_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+__thread svint8_t thread_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
 svint8_t *global_int8_ptr;
 extern svint8_t *extern_int8_ptr;
 static svint8_t *static_int8_ptr;
@@ -58,6 +62,8 @@
 struct incomplete_struct *incomplete_ptr;
 
 void func(int sel) {
+  static svint8_t static_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+
   svint8_t local_int8;
   svint16_t local_int16;
 
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -5,6 +5,10 @@
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 
+svint8_t global_int8;  // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+extern svint8_t extern_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+static svint8_t static_int8;   // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+__thread svint8_t thread_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
 svint8_t *global_int8_ptr;
 extern svint8_t *extern_int8_ptr;
 static svint8_t *static_int8_ptr;
@@ -48,6 +52,8 @@
 struct incomplete_struct *incomplete_ptr;
 
 void func(int sel) {
+  static svint8_t static_int8; // expected-error {{non-local variable with 
sizeless type 'svint8_t'}}
+
   svint8_t local_int8;
   svint16_t local_int16;
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7939,6 +7939,12 @@
 return;
   }
 
+  if (!NewVD->hasLocalStorage() && T->isSizelessType()) {
+Diag(NewVD->getLocation(), diag::err_sizeless_nonlocal) << T;
+NewVD->setInvalidDecl();
+return;
+  }
+
   if (isVM && NewVD->hasAttr()) {
 Diag(NewVD->getLocation(), diag::err_block_on_vm);
 NewVD->setInvalidDecl();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9145,6 +9145,8 @@
   "__block attribute not allowed, only allowed on local variables">;
 def err_block_on_vm : Error<
   "__block attribute not allowed on declaration with a variably modified 
type">;
+def err_sizeless_nonlocal : Error<
+  "non-local variable with sizeless type %0">;
 
 def err_vec_builtin_non_vector : Error<
  "first two arguments to %0 must be vectors">;


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -10,6 +10,10 @@
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 
+svint8_t global_int8;  // expected-error {{non-local variable with sizeless type 'svint8_t'}}
+extern svint8_t extern_int8;   // expected-error {{non-local variable with sizeless type 'svint8_t'}}
+static svint8_t static_int8;   // expected-error {{non-local variable with sizeless type 'svint8_t'}}
+__thread svint8_t thread_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
 svint8_t *global_int8_ptr;
 extern svint8_t *extern_int8_ptr;
 static svint8_t *static_int8_ptr;
@@ -58,6 +62,8 @@
 struct incomplete_struct *incomplete_ptr;
 
 void func(int sel) {
+  static svint8_t static_int8; // expected-error {{non-local variable with sizeless type 'svint8_t'}}
+
   svint8_t local_int8;
   svint16_t local_int16;
 
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -5,6 +5,10 @@
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 
+svint8_t global_int8;  // expected-error {{non-local var

[libunwind] c53c205 - Cache uwnind frame headers as they are found.

2020-03-12 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-03-12T10:53:33-07:00
New Revision: c53c2058ffb8ff877702bb2dded31c85c1dfe66d

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

LOG: Cache uwnind frame headers as they are found.

Summary:
This improves unwind performance quite substantially, and follows
a somewhat similar approach used in libgcc_s as described in the
thread here:

https://gcc.gnu.org/ml/gcc/2005-02/msg00625.html

On certain extremely exception heavy internal tests, the time
drops from about 80 minutes to about five minutes.

Subscribers: libcxx-commits

Tags: #libc

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

Added: 
libunwind/src/FrameHeaderCache.hpp
libunwind/test/frameheadercache_test.pass.cpp

Modified: 
libunwind/src/AddressSpace.hpp

Removed: 




diff  --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index 83af9aeaef77..a4564cb67328 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -452,6 +452,11 @@ struct _LIBUNWIND_HIDDEN dl_iterate_cb_data {
 #error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires 
_LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
   #endif
 
+#include "FrameHeaderCache.hpp"
+
+// There should be just one of these per process.
+static FrameHeaderCache ProcessFrameHeaderCache;
+
 static bool checkAddrInSegment(const Elf_Phdr *phdr, size_t image_base,
dl_iterate_cb_data *cbdata) {
   if (phdr->p_type == PT_LOAD) {
@@ -466,10 +471,13 @@ static bool checkAddrInSegment(const Elf_Phdr *phdr, 
size_t image_base,
   return false;
 }
 
-int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t, void *data) {
+int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, size_t pinfo_size,
+ void *data) {
   auto cbdata = static_cast(data);
   if (pinfo->dlpi_phnum == 0 || cbdata->targetAddr < pinfo->dlpi_addr)
 return 0;
+  if (ProcessFrameHeaderCache.find(pinfo, pinfo_size, data))
+return 1;
 
   Elf_Addr image_base = calculateImageBase(pinfo);
   bool found_obj = false;
@@ -496,8 +504,10 @@ int findUnwindSectionsByPhdr(struct dl_phdr_info *pinfo, 
size_t, void *data) {
 } else if (!found_obj) {
   found_obj = checkAddrInSegment(phdr, image_base, cbdata);
 }
-if (found_obj && found_hdr)
+if (found_obj && found_hdr) {
+  ProcessFrameHeaderCache.add(cbdata->sects);
   return 1;
+}
   }
   cbdata->sects->dwarf_section_length = 0;
   return 0;

diff  --git a/libunwind/src/FrameHeaderCache.hpp 
b/libunwind/src/FrameHeaderCache.hpp
new file mode 100644
index ..813fcd408b26
--- /dev/null
+++ b/libunwind/src/FrameHeaderCache.hpp
@@ -0,0 +1,149 @@
+//===-FrameHeaderCache.hpp 
===//
+//
+// 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
+//
+// Cache the elf program headers necessary to unwind the stack more efficiently
+// in the presence of many dsos.
+//
+//===--===//
+
+#ifndef __FRAMEHEADER_CACHE_HPP__
+#define __FRAMEHEADER_CACHE_HPP__
+
+#include "config.h"
+#include 
+
+#ifdef _LIBUNWIND_DEBUG_FRAMEHEADER_CACHE
+#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE0(x) _LIBUNWIND_LOG0(x)
+#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE(msg, ...)
\
+  _LIBUNWIND_LOG(msg, __VA_ARGS__)
+#else
+#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE0(x)
+#define _LIBUNWIND_FRAMEHEADERCACHE_TRACE(msg, ...)
+#endif
+
+// This cache should only be be used from within a dl_iterate_phdr callback.
+// dl_iterate_phdr does the necessary synchronization to prevent problems
+// with concurrent access via the libc load lock. Adding synchronization
+// for other uses is possible, but not currently done.
+
+class _LIBUNWIND_HIDDEN FrameHeaderCache {
+  struct CacheEntry {
+uintptr_t LowPC() { return Info.dso_base; };
+uintptr_t HighPC() { return Info.dso_base + Info.dwarf_section_length; };
+UnwindInfoSections Info;
+CacheEntry *Next;
+  };
+
+  static const size_t kCacheEntryCount = 8;
+
+  // Can't depend on the C++ standard library in libunwind, so use an array to
+  // allocate the entries, and two linked lists for ordering unused and 
recently
+  // used entries.  FIXME: Would the the extra memory for a doubly-linked list
+  // be better than the runtime cost of traversing a very short singly-linked
+  // list on a cache miss? The entries themselves are all small and 
consecutive,
+  // so unlikely to cause page faults when following the pointers. The memory
+  // spent on additional pointers could also be spent 

[PATCH] D76079: [Hexagon] Enable init_arrays when target is linux-musl

2020-03-12 Thread Brian Cain via Phabricator via cfe-commits
bcain added inline comments.



Comment at: clang/lib/Driver/ToolChains/Hexagon.cpp:548
+
+  bool UseInitArrayDefault = (getTriple().isMusl()) ? true : false;
 

The ternary is unnecessary.

```
   bool UseInitArrayDefault = getTriple().isMusl();
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76079



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-12 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:69
+  Bfloat16Width = Bfloat16Align = 16;
+  Bfloat16Format = &llvm::APFloat::IEEEhalf();
+

Doesn't Bfloat16 have a different number of mantissa and exponent bits than 
IEEEhalf?



Comment at: clang/test/CodeGen/arm-mangle-16bit-float.cpp:4
+
+// CHECK64: define {{.*}}void @_Z3foou6__bf16(half %b)
+// CHECK32: define {{.*}}void @_Z3foou6__bf16(i32 %b.coerce)

How can bfloat16 be passed as half? Don't they have a different format?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't understand why you wouldn't add a new IR type for this; doing so should 
be totally mechanical.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


[PATCH] D35732: Update system_error tests for more platforms.

2020-03-12 Thread Dan Albert via Phabricator via cfe-commits
danalbert updated this revision to Diff 249989.
danalbert changed the repository for this revision from rL LLVM to rG LLVM 
Github Monorepo.
danalbert added a project: libc++.
danalbert added a comment.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

PTAL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D35732

Files:
  
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
  
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp


Index: 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
===
--- 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
+++ 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::system_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 
Index: 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
===
--- 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
+++ 
libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::generic_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 


Index: libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
===
--- libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
+++ libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/system_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::system_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 
Index: libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
===
--- libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
+++ libcxx/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.objects/generic_category.pass.cpp
@@ -31,7 +31,8 @@
 errno = E2BIG; // something that message will never generate
 const std::error_category& e_cat1 = std::generic_category();
 const std::string msg = e_cat1.message(-1);
-LIBCPP_ASSERT(msg == "Unknown error -1" || msg == "Unknown error");
+// Exact message format varies by platform.
+LIBCPP_ASSERT(msg.starts_with("Unknown error"));
 assert(errno == E2BIG);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75542: [Sema] Prevent UB for uninitialized `IsSurrogate`

2020-03-12 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Friendly ping! `OverloadCandidate` has uninitialized members and so can cause 
UB if used incorrectly in another part of the compiler, so I feel this is a 
fairly straightforward patch: prevent UB by initializing all members. But I'd 
like some review to confirm. @rsmith? @aaron.ballman?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75542



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


[PATCH] D72675: [Clang][Driver] Fix -ffast-math/-ffp-contract interaction

2020-03-12 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D72675#1919793 , @mibintc wrote:

> In D72675#1919685 , @spatel wrote:
>
> > In D72675#1917844 , @wristow wrote:
> >
> > > Revisiting this patch.  I think that before fixing the 
> > > `-ffp-contract=off` problem I originally raised here, there are two 
> > > questions that have come up in this discussion that we should first 
> > > resolve.  Specifically:
> > >
> > > (1)  Do we want to enable FMA transformations by default (at appropriate 
> > > optimization levels), like GCC does?  That is, should FMA be done for 
> > > targets that support it with a command as simple as the following?
> > >
> > >   clang -O2 -c test.c
> >
> >
> > This has been discussed/tried a few times including very recently. I'm not 
> > sure where we stand currently, but here's some background:
> >  https://reviews.llvm.org/rL282259
> >  D74436   - cc @mibintc
> >
> > And (sorry for the various flavors of links to the dev-lists, but that's 
> > how it showed up in the search results):
> >  http://lists.llvm.org/pipermail/llvm-dev/2017-March/29.html
> >  http://lists.llvm.org/pipermail/cfe-dev/2020-February/064645.html
> >  https://groups.google.com/forum/#!msg/llvm-dev/nBiCD5KvYW0/yfjrVzR7DAAJ
> >  https://groups.google.com/forum/#!topic/llvm-dev/Aev2jQYepKQ
> >  
> > http://clang-developers.42468.n3.nabble.com/RFC-FP-contract-on-td4056277.html
>
>
> A few weeks ago there was a discussion on cfe-dev and llvm-dev initiated by 
> @andrew.w.kaylor and while the response wasn't unanimous, there was an 
> overwhelming sentiment (in my opinion) that it is correct and desireable to 
> enable ffp-contract=on by default even at -O0.  I had submitted a patch to do 
> that. However the patch caused performance regressions in about 20 LNT tests 
> and the patch was reverted, the regression was seen on multiple architecture. 
> I can send provide a few more details about the performance problems, I don't 
> have a solution to the LNT regression.


Thanks for the update! I saw your questions about digging into the LNT 
regressions, but I don't have the answers (ping that message in case someone 
out there missed it?). 
Let's break this into pieces and see if we can make progress apart from that:

1. Where is the list of LNT tests that showed problems?
2. Were the regressions on x86 bots? If so, many developers can likely repro 
those locally.
3. For regressions on other targets, we can guess at the problems by comparing 
asm (or recruit someone with the target hardware?).


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

https://reviews.llvm.org/D72675



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-03-12 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Note that we have an IR type for the PPC double-double format, which isn't even 
hardware-supported.  This is literally just an IEEE floating-point format with 
non-standard parameters, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76077



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


  1   2   3   >