[PATCH] D70048: [LLD] Add NetBSD support as a new flavor of LLD (nb.lld)

2019-12-11 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

lld is not that Linux-centric as you implied in your comment. We have code for 
FreeBSD, OpenBSD, AMDGPU and Fuchsia (which isn't even a POSIX system), and 
adding code for NetBSD is OK and is appreciated. However, the thing we've been 
trying to avoid is to hard-code a platform-specific knowledge such as library 
paths to the linker. Combined with the fact that lld doesn't provide a way to 
enable/disable targets at build-time, all ld.lld executables (sometimes 
installed as /usr/bin/ld) work the same way no matter where they are run on. 
That helps those who do cross compilation a lot. That is a very appreciated 
property of our linker, and I don't think I want make an exception for NetBSD. 
Even on NetBSD, lld should behave the same as running on other kind of hosts.

Also, frankly speaking, having a driver only for NetBSD seems very odd to me. 
We would have 5 drivers for MSVC link.exe, MinGW, ELF-based systems, macOS, and 
NetBSD? That doesn't feel right. If you strongly feel that the linker should 
know the library paths and the like, it shouldn't be too hard to write a shell 
script wrapper to wrap lld.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70048



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


[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

2019-12-11 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248



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


[PATCH] D71393: Default to -fno-use-init-array

2019-12-11 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

The title should probably read "Default to -fuse-init-array" (dropping the 
"no-")?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71393



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


[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

2019-12-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 233513.
kadircet added a comment.

- More tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248

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

Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -8,192 +8,159 @@
 #include "FormattedString.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
+namespace markup {
 namespace {
 
-TEST(FormattedString, Basic) {
-  FormattedString S;
-  EXPECT_EQ(S.renderAsPlainText(), "");
-  EXPECT_EQ(S.renderAsMarkdown(), "");
-
-  S.appendText("foobar  ");
-  S.appendText("baz");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "foobar  baz");
-
-  S = FormattedString();
-  S.appendInlineCode("foobar");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar");
-  EXPECT_EQ(S.renderAsMarkdown(), "`foobar`");
-
-  S = FormattedString();
-  S.appendCodeBlock("foobar");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar");
-  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
-  "foobar\n"
-  "```\n");
+enum RenderKind {
+  PlainText,
+  Markdown,
+};
+std::string renderBlock(const Block , RenderKind RK) {
+  std::string R;
+  llvm::raw_string_ostream OS(R);
+  switch (RK) {
+  case PlainText:
+B.asPlainText(OS);
+break;
+  case Markdown:
+B.asMarkdown(OS);
+break;
+  }
+  return OS.str();
 }
 
-TEST(FormattedString, CodeBlocks) {
-  FormattedString S;
-  S.appendCodeBlock("foobar");
-  S.appendCodeBlock("bazqux", "javascript");
-  S.appendText("after");
-
-  std::string ExpectedText = R"(foobar
-
-bazqux
-
-after)";
-  EXPECT_EQ(S.renderAsPlainText(), ExpectedText);
-  std::string ExpectedMarkdown = R"md(```cpp
-foobar
-```
-```javascript
-bazqux
-```
-after)md";
-  EXPECT_EQ(S.renderAsMarkdown(), ExpectedMarkdown);
-
-  S = FormattedString();
-  S.appendInlineCode("foobar");
-  S.appendInlineCode("bazqux");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar bazqux");
-  EXPECT_EQ(S.renderAsMarkdown(), "`foobar` `bazqux`");
-
-  S = FormattedString();
-  S.appendText("foo");
-  S.appendInlineCode("bar");
-  S.appendText("baz");
-
-  EXPECT_EQ(S.renderAsPlainText(), "foo bar baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "foo `bar` baz");
-}
+MATCHER_P(HasMarkdown, MD, "") { return renderBlock(arg, Markdown) == MD; }
+MATCHER_P(HasPlainText, PT, "") { return renderBlock(arg, PlainText) == PT; }
 
-TEST(FormattedString, Escaping) {
+TEST(Render, Escaping) {
   // Check some ASCII punctuation
-  FormattedString S;
-  S.appendText("*!`");
-  EXPECT_EQ(S.renderAsMarkdown(), "\\*\\!\\`");
+  Paragraph P;
+  P.appendText("*!`");
+  EXPECT_THAT(P, HasMarkdown("\\*\\!\\`"));
 
   // Check all ASCII punctuation.
-  S = FormattedString();
+  P = Paragraph();
   std::string Punctuation = R"txt(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)txt";
   // Same text, with each character escaped.
   std::string EscapedPunctuation;
   EscapedPunctuation.reserve(2 * Punctuation.size());
   for (char C : Punctuation)
 EscapedPunctuation += std::string("\\") + C;
-  S.appendText(Punctuation);
-  EXPECT_EQ(S.renderAsMarkdown(), EscapedPunctuation);
+  P.appendText(Punctuation);
+  EXPECT_THAT(P, HasMarkdown(EscapedPunctuation));
 
   // In code blocks we don't need to escape ASCII punctuation.
-  S = FormattedString();
-  S.appendInlineCode("* foo !+ bar * baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "`* foo !+ bar * baz`");
-  S = FormattedString();
-  S.appendCodeBlock("#define FOO\n* foo !+ bar * baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
-  "#define FOO\n* foo !+ bar * baz\n"
-  "```\n");
+  P = Paragraph();
+  P.appendCode("* foo !+ bar * baz");
+  EXPECT_THAT(P, HasMarkdown("`* foo !+ bar * baz`"));
 
   // But we have to escape the backticks.
-  S = FormattedString();
-  S.appendInlineCode("foo`bar`baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "`foo``bar``baz`");
-
-  S = FormattedString();
-  S.appendCodeBlock("foo`bar`baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
-  "foo`bar`baz\n"
-  "```\n");
+  P = Paragraph();
+  P.appendCode("foo`bar`baz");
+  EXPECT_THAT(P, HasMarkdown("`foo``bar``baz`"));
 
   // Inline code blocks starting or ending with backticks should add spaces.

[PATCH] D71393: Default to -fno-use-init-array

2019-12-11 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Fan of this change, but let's definitely wait for more reviews :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71393



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


[clang] 7292c28 - Fix an error in the block ABI documentation sample code

2019-12-11 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2019-12-11T23:18:32-08:00
New Revision: 7292c2823063fdb9e2200ef7e4571d4f2443e6ca

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

LOG: Fix an error in the block ABI documentation sample code

rdar://problem/38663011

Added: 


Modified: 
clang/docs/Block-ABI-Apple.rst

Removed: 




diff  --git a/clang/docs/Block-ABI-Apple.rst b/clang/docs/Block-ABI-Apple.rst
index e48a24b43ce5..0cc14a35b033 100644
--- a/clang/docs/Block-ABI-Apple.rst
+++ b/clang/docs/Block-ABI-Apple.rst
@@ -152,7 +152,7 @@ would cause the following to be created on a 32-bit system:
 static struct __block_descriptor_1 {
 unsigned long int reserved;
 unsigned long int Block_size;
-} __block_descriptor_1 = { 0, sizeof(struct __block_literal_1), 
__block_invoke_1 };
+} __block_descriptor_1 = { 0, sizeof(struct __block_literal_1) };
 
 and where the ``Block`` literal itself appears:
 



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


[PATCH] D71387: pass -mabi to LTO linker only in RISC-V targets, enable RISC-V LTO

2019-12-11 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen updated this revision to Diff 233508.
khchen added a comment.

update missed code..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71387

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/gold-lto.c

Index: clang/test/Driver/gold-lto.c
===
--- clang/test/Driver/gold-lto.c
+++ clang/test/Driver/gold-lto.c
@@ -26,3 +26,17 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+//
+// RUN: %clang -target riscv64-unknown-elf -### %t.o -flto 2>&1 \
+// RUN: -march=rv64imf -mabi=lp64f \
+// RUN: | FileCheck %s --check-prefix=CHECK-RISCV-BAREMETAL
+//
+// CHECK-RISCV-BAREMETAL: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// CHECK-RISCV-BAREMETAL: "-plugin-opt=-target-abi=lp64f"
+//
+// RUN: %clang -target riscv64-unknown-linux-gnu -### %t.o -flto 2>&1 \
+// RUN: -march=rv64imf -mabi=lp64f \
+// RUN: | FileCheck %s --check-prefix=CHECK-RISCV-LINUX
+//
+// CHECK-RISCV-LINUX: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// CHECK-RISCV-LINUX: "-plugin-opt=-target-abi=lp64f"
Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -28,6 +28,7 @@
   RuntimeLibType GetDefaultRuntimeLibType() const override;
   UnwindLibType
   GetUnwindLibType(const llvm::opt::ArgList ) const override;
+  bool HasNativeLLVMSupport() const override { return true; }
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "RISCVToolchain.h"
+#include "Arch/RISCV.h"
 #include "CommonArgs.h"
 #include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
@@ -145,6 +146,12 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+  }
+
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -11,6 +11,7 @@
 #include "Arch/ARM.h"
 #include "Arch/Mips.h"
 #include "Arch/PPC.h"
+#include "Arch/RISCV.h"
 #include "Arch/SystemZ.h"
 #include "Arch/X86.h"
 #include "HIP.h"
@@ -485,6 +486,17 @@
   if (!StatsFile.empty())
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile));
+
+  // pass more options in specific target
+  switch (ToolChain.getArch()) {
+  default:
+break;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64: {
+riscv::addRISCVGoldPluginAdditionFlags(ToolChain, Args, CmdArgs);
+break;
+  }
+  }
 }
 
 void tools::addArchSpecificRPath(const ToolChain , const ArgList ,
Index: clang/lib/Driver/ToolChains/Arch/RISCV.h
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.h
+++ clang/lib/Driver/ToolChains/Arch/RISCV.h
@@ -26,6 +26,9 @@
   const llvm::Triple );
 StringRef getRISCVArch(const llvm::opt::ArgList ,
const llvm::Triple );
+void addRISCVGoldPluginAdditionFlags(const ToolChain ,
+const llvm::opt::ArgList ,
+llvm::opt::ArgStringList );
 } // end namespace riscv
 } // namespace tools
 } // end namespace driver
Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -579,3 +579,14 @@
   return "rv64imafdc";
   }
 }
+
+void riscv::addRISCVGoldPluginAdditionFlags(const ToolChain ,
+const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) {
+  // -mabi is not encoded in bitcode so we need to pass it to LTO code
+  // 

[PATCH] D70856: [Syntax] Build nodes for simple cases of top level declarations

2019-12-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Landing as is, but happy to address any comments in the follow-up patches.
@gribozavr2, please feel free to leave any suggestions in the review comments, 
despite it being closed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70856



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


[PATCH] D70856: [Syntax] Build nodes for simple cases of top level declarations

2019-12-11 Thread Ilya Biryukov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbe14a22b47e5: [Syntax] Build nodes for simple cases of top 
level declarations (authored by ilya-biryukov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70856

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

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -512,7 +512,190 @@
 | | `-tb
 | `-;
 `-}
-  )txt"}};
+  )txt"},
+  {R"cpp(
+namespace a { namespace b {} }
+namespace a::b {}
+namespace {}
+
+namespace foo = a;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-NamespaceDefinition
+| |-namespace
+| |-a
+| |-{
+| |-NamespaceDefinition
+| | |-namespace
+| | |-b
+| | |-{
+| | `-}
+| `-}
+|-NamespaceDefinition
+| |-namespace
+| |-a
+| |-::
+| |-b
+| |-{
+| `-}
+|-NamespaceDefinition
+| |-namespace
+| |-{
+| `-}
+`-NamespaceAliasDefinition
+  |-namespace
+  |-foo
+  |-=
+  |-a
+  `-;
+)txt"},
+  {R"cpp(
+namespace ns {}
+using namespace ::ns;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-NamespaceDefinition
+| |-namespace
+| |-ns
+| |-{
+| `-}
+`-UsingNamespaceDirective
+  |-using
+  |-namespace
+  |-::
+  |-ns
+  `-;
+   )txt"},
+  {R"cpp(
+namespace ns { int a; }
+using ns::a;
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-NamespaceDefinition
+| |-namespace
+| |-ns
+| |-{
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | `-;
+| `-}
+`-UsingDeclaration
+  |-using
+  |-ns
+  |-::
+  |-a
+  `-;
+   )txt"},
+  {R"cpp(
+template  struct X {
+  using T::foo;
+  using typename T::bar;
+};
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-UnknownDeclaration
+  |-template
+  |-<
+  |-UnknownDeclaration
+  | |-class
+  | `-T
+  |->
+  |-struct
+  |-X
+  |-{
+  |-UsingDeclaration
+  | |-using
+  | |-T
+  | |-::
+  | |-foo
+  | `-;
+  |-UsingDeclaration
+  | |-using
+  | |-typename
+  | |-T
+  | |-::
+  | |-bar
+  | `-;
+  |-}
+  `-;
+   )txt"},
+  {R"cpp(
+using type = int;
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-TypeAliasDeclaration
+  |-using
+  |-type
+  |-=
+  |-int
+  `-;
+   )txt"},
+  {R"cpp(
+;
+)cpp",
+   R"txt(
+*: TranslationUnit
+`-EmptyDeclaration
+  `-;
+   )txt"},
+  {R"cpp(
+static_assert(true, "message");
+static_assert(true);
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-StaticAssertDeclaration
+| |-static_assert
+| |-(
+| |-UnknownExpression
+| | `-true
+| |-,
+| |-UnknownExpression
+| | `-"message"
+| |-)
+| `-;
+`-StaticAssertDeclaration
+  |-static_assert
+  |-(
+  |-UnknownExpression
+  | `-true
+  |-)
+  `-;
+   )txt"},
+  {R"cpp(
+extern "C" int a;
+extern "C" { int b; int c; }
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-LinkageSpecificationDeclaration
+| |-extern
+| |-"C"
+| `-SimpleDeclaration
+|   |-int
+|   |-a
+|   `-;
+`-LinkageSpecificationDeclaration
+  |-extern
+  |-"C"
+  |-{
+  |-SimpleDeclaration
+  | |-int
+  | |-b
+  | `-;
+  |-SimpleDeclaration
+  | |-int
+  | |-c
+  | `-;
+  `-}
+   )txt"},
+  };
 
   for (const auto  : Cases) {
 SCOPED_TRACE(T.first);
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -50,8 +50,24 @@
 return OS << "CompoundStatement";
   case NodeKind::UnknownDeclaration:
 return OS << "UnknownDeclaration";
+  case NodeKind::EmptyDeclaration:
+return OS << "EmptyDeclaration";
+  case NodeKind::StaticAssertDeclaration:
+return OS << "StaticAssertDeclaration";
+  case NodeKind::LinkageSpecificationDeclaration:
+return OS << "LinkageSpecificationDeclaration";
   case NodeKind::SimpleDeclaration:
 return OS << "SimpleDeclaration";
+  case NodeKind::NamespaceDefinition:
+return OS << "NamespaceDefinition";
+  case NodeKind::NamespaceAliasDefinition:
+return OS << "NamespaceAliasDefinition";
+  case NodeKind::UsingNamespaceDirective:
+return OS << "UsingNamespaceDirective";
+  case NodeKind::UsingDeclaration:
+return OS << "UsingDeclaration";
+  case NodeKind::TypeAliasDeclaration:
+return OS << "TypeAliasDeclaration";
   }
   llvm_unreachable("unknown node kind");
 }
@@ -84,6 +100,10 @@
 return OS << "ExpressionStatement_expression";
   case syntax::NodeRole::CompoundStatement_statement:
 return OS << "CompoundStatement_statement";
+  case syntax::NodeRole::StaticAssertDeclaration_condition:
+return OS << "StaticAssertDeclaration_condition";
+  case syntax::NodeRole::StaticAssertDeclaration_message:
+return OS << "StaticAssertDeclaration_message";
   }
   llvm_unreachable("invalid role");
 }

[clang] be14a22 - [Syntax] Build nodes for simple cases of top level declarations

2019-12-11 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2019-12-12T08:04:22+01:00
New Revision: be14a22b47e5c61ff36e4183dcb4f8b138466157

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

LOG: [Syntax] Build nodes for simple cases of top level declarations

Summary:
More complicated nodes (e.g. template declarations) will be implemented
in the follow-up patches.

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: merge_guards_bot, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index c4db4da892c2..25acc1757428 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -60,7 +60,15 @@ enum class NodeKind : uint16_t {
 
   // Declarations
   UnknownDeclaration,
+  EmptyDeclaration,
+  StaticAssertDeclaration,
+  LinkageSpecificationDeclaration,
   SimpleDeclaration,
+  NamespaceDefinition,
+  NamespaceAliasDefinition,
+  UsingNamespaceDirective,
+  UsingDeclaration,
+  TypeAliasDeclaration
 };
 /// For debugging purposes.
 llvm::raw_ostream <<(llvm::raw_ostream , NodeKind K);
@@ -91,7 +99,9 @@ enum class NodeRole : uint8_t {
   IfStatement_elseStatement,
   ReturnStatement_value,
   ExpressionStatement_expression,
-  CompoundStatement_statement
+  CompoundStatement_statement,
+  StaticAssertDeclaration_condition,
+  StaticAssertDeclaration_message
 };
 /// For debugging purposes.
 llvm::raw_ostream <<(llvm::raw_ostream , NodeRole R);
@@ -311,7 +321,7 @@ class Declaration : public Tree {
   Declaration(NodeKind K) : Tree(K) {}
   static bool classof(const Node *N) {
 return NodeKind::UnknownDeclaration <= N->kind() &&
-   N->kind() <= NodeKind::SimpleDeclaration;
+   N->kind() <= NodeKind::TypeAliasDeclaration;
   }
 };
 
@@ -324,6 +334,38 @@ class UnknownDeclaration final : public Declaration {
   }
 };
 
+/// A semicolon in the top-level context. Does not declare anything.
+class EmptyDeclaration final : public Declaration {
+public:
+  EmptyDeclaration() : Declaration(NodeKind::EmptyDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::EmptyDeclaration;
+  }
+};
+
+/// static_assert(, )
+/// static_assert()
+class StaticAssertDeclaration final : public Declaration {
+public:
+  StaticAssertDeclaration() : Declaration(NodeKind::StaticAssertDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::StaticAssertDeclaration;
+  }
+  syntax::Expression *condition();
+  syntax::Expression *message();
+};
+
+/// extern  declaration
+/// extern  {   }
+class LinkageSpecificationDeclaration final : public Declaration {
+public:
+  LinkageSpecificationDeclaration()
+  : Declaration(NodeKind::LinkageSpecificationDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::LinkageSpecificationDeclaration;
+  }
+};
+
 /// Groups multiple declarators (e.g. variables, typedefs, etc.) together. All
 /// grouped declarators share the same declaration specifiers (e.g. 'int' or
 /// 'typedef').
@@ -334,6 +376,54 @@ class SimpleDeclaration final : public Declaration {
 return N->kind() == NodeKind::SimpleDeclaration;
   }
 };
+
+/// namespace  {  }
+class NamespaceDefinition final : public Declaration {
+public:
+  NamespaceDefinition() : Declaration(NodeKind::NamespaceDefinition) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::NamespaceDefinition;
+  }
+};
+
+/// namespace  = 
+class NamespaceAliasDefinition final : public Declaration {
+public:
+  NamespaceAliasDefinition()
+  : Declaration(NodeKind::NamespaceAliasDefinition) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::NamespaceAliasDefinition;
+  }
+};
+
+/// using namespace 
+class UsingNamespaceDirective final : public Declaration {
+public:
+  UsingNamespaceDirective() : Declaration(NodeKind::UsingNamespaceDirective) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::UsingNamespaceDirective;
+  }
+};
+
+/// using ::
+/// using typename ::
+class UsingDeclaration final : public Declaration {
+public:
+  UsingDeclaration() : Declaration(NodeKind::UsingDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::UsingDeclaration;
+  }
+};
+
+/// using  = 
+class TypeAliasDeclaration final : public Declaration {
+public:
+  TypeAliasDeclaration() : Declaration(NodeKind::TypeAliasDeclaration) {}
+  static bool classof(const Node 

[PATCH] D48921: NFC - Typo fix in test/CodeGenCXX/runtime-dllstorage.cpp

2019-12-11 Thread Jim Lin via Phabricator via cfe-commits
Jim accepted this revision.
Jim added a comment.
This revision is now accepted and ready to land.
Herald added a project: clang.

Are you ready to land this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D48921



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


[PATCH] D68161: [TimeProfiler] Fix "OptModule" section and add new "Backend" sections

2019-12-11 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev closed this revision.
anton-afanasyev added a comment.

Commited long time ago (https://reviews.llvm.org/rL373142).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68161



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


[PATCH] D71393: Default to -fno-use-init-array

2019-12-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: brad, kamleshbhalui, lenary, phosek, rnk.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
atanasyan, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, 
johnrusso, rbar, asb, fedor.sergeev, aheejin, kristof.beyls, jgravelle-google, 
krytarowski, sbc100, emaste, dschuff.
Herald added a project: clang.

Very few ELF platforms still use .ctors/.dtors now.  Linux (glibc: 1999-07),
DragonFlyBSD, FreeBSD (2012-03) and Solaris have supported .init_array
for many years. Some architectures like AArch64/RISC-V default to
.init_array . GNU ld and gold can even convert .ctors to .init_array .

It makes more sense to flip the CC1 default, and only uses
-fno-use-init-array on platforms that don't support .init_array .
For example, OpenBSD did not support DT_INIT_ARRAY before Aug 2016
(https://github.com/openbsd/src/commit/86fa57a2792c6374b0849dd7b818a11e676e60ba)

I may miss some ELF platforms that still use .ctors, but their
maintainers can easily diagnose such problems.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71393

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.h
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenObjC/gnu-init.m
  clang/test/Driver/constructors.c
  clang/test/Driver/fembed-bitcode.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/fuchsia.cpp
  clang/test/Driver/mips-mti-linux.c
  clang/test/Driver/nacl-direct.c
  clang/test/Driver/netbsd.c
  clang/test/Driver/openbsd.c
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv32-toolchain.c
  clang/test/Driver/riscv64-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain.c

Index: clang/test/Driver/riscv64-toolchain.c
===
--- clang/test/Driver/riscv64-toolchain.c
+++ clang/test/Driver/riscv64-toolchain.c
@@ -12,7 +12,6 @@
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-LP64 %s
 
-// C-RV64-BAREMETAL-LP64: "-fuse-init-array"
 // C-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
 // C-RV64-BAREMETAL-LP64: "{{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf/lib{{/|}}crt0.o"
@@ -28,7 +27,6 @@
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=C-RV64-BAREMETAL-NOSYSROOT-LP64 %s
 
-// C-RV64-BAREMETAL-NOSYSROOT-LP64: "-fuse-init-array"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/lib{{/|}}crt0.o"
 // C-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1{{/|}}crtbegin.o"
@@ -43,7 +41,6 @@
 // RUN:   --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-LP64 %s
 
-// CXX-RV64-BAREMETAL-LP64: "-fuse-init-array"
 // CXX-RV64-BAREMETAL-LP64: "-internal-isystem" "{{.*}}Inputs/basic_riscv64_tree/riscv64-unknown-elf/include/c++{{/|}}8.0.1"
 // CXX-RV64-BAREMETAL-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
 // CXX-RV64-BAREMETAL-LP64: "--sysroot={{.*}}/Inputs/basic_riscv64_tree/riscv64-unknown-elf"
@@ -60,7 +57,6 @@
 // RUN:   --gcc-toolchain=%S/Inputs/basic_riscv64_tree 2>&1 \
 // RUN:   | FileCheck -check-prefix=CXX-RV64-BAREMETAL-NOSYSROOT-LP64 %s
 
-// CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "-fuse-init-array"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "-internal-isystem" "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/include/c++{{/|}}8.0.1"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}bin{{/|}}riscv64-unknown-elf-ld"
 // CXX-RV64-BAREMETAL-NOSYSROOT-LP64: "{{.*}}/Inputs/basic_riscv64_tree/lib/gcc/riscv64-unknown-elf/8.0.1/../../..{{/|}}..{{/|}}riscv64-unknown-elf/lib{{/|}}crt0.o"
@@ -76,7 +72,6 @@
 // RUN:   --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot 2>&1 \
 // RUN:   | 

[PATCH] D70157: Align branches within 32-Byte boundary

2019-12-11 Thread Kan Shengchen via Phabricator via cfe-commits
skan added a comment.



In D70157#1777272 , @fedor.sergeev 
wrote:

> In D70157#1776424 , @skan wrote:
>
> > > What if I insert explicit align(8) right *after* the sequence?
> >
> > If your insert explicit `.align 8` after the sequence, and the sequence 
> > doesn't has any branch to be aligned, the current solution won't change the 
> > sequence.
>
>
> Well, I kinda figure that from the code behavior right now, however is it 
> really by design or just happens to work now?


It is by design, prefix won't be added to instruction if there is a `align` 
directive int the path to the target branch.

> Seeing that assembler becomes very intelligent now I would rather have a 
> strict guarantee similar to "hardcode" thing that you have here that protects 
> my sequence
>  rather than relying on a fact that in current settings moving my label by 8 
> does not appear to be profitable to assembler.

It depends on what your real need is. If you just need your original implicit 
alignment to work,  turning it into explicit alignment is enough.  Or if you 
need a sequence not changed by
the assembler at all,  maybe we need a new directive such as ".hard " or 
".bundle".


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

https://reviews.llvm.org/D70157



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


[clang] bdaf31e - [OpenMP][Docs] Mark 5.0 features worked on and list 5.1 features

2019-12-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2019-12-12T00:00:38-06:00
New Revision: bdaf31ec95e071b87e4cf160eb1ce570dc37a8c0

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

LOG: [OpenMP][Docs] Mark 5.0 features worked on and list 5.1 features

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 9e16daf93bfe..7a70d05ec7ff 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -121,7 +121,7 @@ implementation.
 
+==+==+==+===+
 | loop extension   | support != in the canonical loop form 
   | :good:`done` | D54441  
  |
 
+--+--+--+---+
-| loop extension   | #pragma omp loop (directive)  
   | :none:`unclaimed`| 
  |
+| loop extension   | #pragma omp loop (directive)  
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | loop extension   | collapse imperfectly nested loop  
   | :good:`done` | 
  |
 
+--+--+--+---+
@@ -225,7 +225,7 @@ implementation.
 
+--+--+--+---+
 | misc extension   | library shutdown (omp_pause_resource[_all])   
   | :none:`unclaimed parts`  | D55078  
  |
 
+--+--+--+---+
-| misc extension   | metadirectives
   | :none:`unclaimed`| 
  |
+| misc extension   | metadirectives
   | :none:`worked on`| 
  |
 
+--+--+--+---+
 | misc extension   | conditional modifier for lastprivate clause   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
@@ -235,3 +235,18 @@ implementation.
 
+--+--+--+---+
 | misc extensions  | prevent new type definitions in clauses   
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+
+
+
+OpenMP 5.1 Implementation Details
+=
+
+The following table provides a quick overview over various OpenMP 5.1 features
+and their implementation status, as defined in the technical report 8 (TR8).
+Please contact *openmp-dev* at *lists.llvm.org* for more information or if you
+want to help with the implementation.
+

[PATCH] D70919: [Hexagon] Avoid passing unsupported options to lld when -fuse-ld=lld is used

2019-12-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Hexagon.cpp:212
   bool UseG0 = false;
+  bool UseLLD = 
Args.getLastArgValue(options::OPT_fuse_ld_EQ).startswith("lld");
   bool UseShared = IsShared && !IsStatic;

bcain wrote:
> Does this still work when `-fuse-ld=ld.lld` ?  How about absolute paths 
> `-fuse-ld=/path/to/lld`?
Fuchsia uses:

```
  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
  if (llvm::sys::path::filename(Exec).equals_lower("ld.lld") ||
  llvm::sys::path::stem(Exec).equals_lower("ld.lld")) {
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70919



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


[PATCH] D71387: pass -mabi to LTO linker only in RISC-V targets, enable RISC-V LTO

2019-12-11 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: efriedma, lenary, asb, shiva0217, tejohnson.
khchen added a project: clang.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, jocewei, PkmX, rkruppe, dexonsmith, the_o, brucehoult, 
MartinMosbeck, rogfer01, steven_wu, edward-jones, zzheng, MaskRay, jrtc27, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, inglorion, 
mehdi_amini.

ABI(-mabi) is not encoded in bitcode function attribute and it is not suitable 
to modeled on a per-function basis because one compilation unit need to have 
the same ABI in risc-v .

in this patch driver will pass -mabi to LTO via option, but there is another 
passing way via module metadata, 
I'm not sure which solution is better.

any suggestion?


Repository:
  rC Clang

https://reviews.llvm.org/D71387

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/gold-lto.c

Index: clang/test/Driver/gold-lto.c
===
--- clang/test/Driver/gold-lto.c
+++ clang/test/Driver/gold-lto.c
@@ -26,3 +26,17 @@
 // RUN: %clang -target i686-linux-android -### %t.o -flto 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECK-X86-ANDROID
 // CHECK-X86-ANDROID: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+//
+// RUN: %clang -target riscv64-unknown-elf -### %t.o -flto 2>&1 \
+// RUN: -march=rv64imf -mabi=lp64f \
+// RUN: | FileCheck %s --check-prefix=CHECK-RISCV-BAREMETAL
+//
+// CHECK-RISCV-BAREMETAL: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// CHECK-RISCV-BAREMETAL: "-plugin-opt=-target-abi=lp64f"
+//
+// RUN: %clang -target riscv64-unknown-linux-gnu -### %t.o -flto 2>&1 \
+// RUN: -march=rv64imf -mabi=lp64f \
+// RUN: | FileCheck %s --check-prefix=CHECK-RISCV-LINUX
+//
+// CHECK-RISCV-LINUX: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
+// CHECK-RISCV-LINUX: "-plugin-opt=-target-abi=lp64f"
Index: clang/lib/Driver/ToolChains/RISCVToolchain.h
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.h
+++ clang/lib/Driver/ToolChains/RISCVToolchain.h
@@ -28,6 +28,7 @@
   RuntimeLibType GetDefaultRuntimeLibType() const override;
   UnwindLibType
   GetUnwindLibType(const llvm::opt::ArgList ) const override;
+  bool HasNativeLLVMSupport() const override { return true; }
   void
   AddClangSystemIncludeArgs(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const override;
Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "RISCVToolchain.h"
+#include "Arch/RISCV.h"
 #include "CommonArgs.h"
 #include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
@@ -145,6 +146,12 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+  }
+
   bool WantCRTs =
   !Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -11,6 +11,7 @@
 #include "Arch/ARM.h"
 #include "Arch/Mips.h"
 #include "Arch/PPC.h"
+#include "Arch/RISCV.h"
 #include "Arch/SystemZ.h"
 #include "Arch/X86.h"
 #include "HIP.h"
@@ -485,6 +486,17 @@
   if (!StatsFile.empty())
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile));
+
+  // pass more options in specific target
+  switch (ToolChain.getArch()) {
+  default:
+break;
+  case llvm::Triple::riscv32:
+  case llvm::Triple::riscv64: {
+riscv::addRISCVGoldPluginAdditionFlags(ToolChain, Args, CmdArgs);
+break;
+  }
+  }
 }
 
 void tools::addArchSpecificRPath(const ToolChain , const ArgList ,
Index: clang/lib/Driver/ToolChains/Arch/RISCV.h
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.h
+++ clang/lib/Driver/ToolChains/Arch/RISCV.h
@@ -26,6 +26,9 @@
   const llvm::Triple );
 StringRef getRISCVArch(const llvm::opt::ArgList ,
const llvm::Triple );
+void addGoldPluginAdditionFlags(const ToolChain ,
+const llvm::opt::ArgList ,
+

[PATCH] D70919: [Hexagon] Avoid passing unsupported options to lld when -fuse-ld=lld is used

2019-12-11 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

In D70919#1771198 , @sidneym wrote:

> Remove quotes around check-not.
>
> -fuse-ld=lld is the correct usage.  -fuse-ld=ld.lld results in an error 
> message:
>  error: invalid linker name in argument '-fuse-ld=ld.lld'


`-fuse-ld` accepts an absolute path to a linker, so you can pass for example 
`-fuse-ld=/absolute/path/to/ld.lld`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70919



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


[PATCH] D71301: [clang][IFS] Prevent Clang-IFS from Leaking symbols from inside a block.

2019-12-11 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D71301#1778834 , @compnerd wrote:

> Should probably add a check for `__block` variables.


I looked into it, I am not sure if anything special needs to be done for block. 
ie:

  echo "void f() { __block int x = 42; void (^sum)(int) = ^(int y) { x = x + y; 
}; }" | clang -x c -fblocks -o - - -c  | llvm-nm -
   U _Block_object_assignecho "void f() { __block int x = 42; 
void (^sum)(int) = ^(int y) { x = x + y; }; }" | clang -x c -fblocks -o - - -c  
| llvm-nm -
   U _Block_object_assign
   U _Block_object_dispose
   U _NSConcreteStackBlock
   r __block_descriptor_tmp
  00c0 W __copy_helper_block_8_32r
  00f0 W __destroy_helper_block_8_32r
  0090 t __f_block_invoke
   T 
   U _Block_object_dispose
   U _NSConcreteStackBlock
   r __block_descriptor_tmp
  00c0 W __copy_helper_block_8_32r
  00f0 W __destroy_helper_block_8_32r
  0090 t __f_block_invoke
   T 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71301



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


[PATCH] D69471: [Coverage] Revise format to reduce binary size

2019-12-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I have a Windows build directory and am motivated to debug this. I'll try to do 
it tomorrow, but I have a couple of other deadlines so I can't make a very firm 
promise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69471



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


[clang] 5d98695 - [IR] Split out target specific intrinsic enums into separate headers

2019-12-11 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-12-11T18:02:14-08:00
New Revision: 5d986953c8b917bacfaa1f800fc1e242559f76be

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

LOG: [IR] Split out target specific intrinsic enums into separate headers

This has two main effects:
- Optimizes debug info size by saving 221.86 MB of obj file size in a
  Windows optimized+debug build of 'all'. This is 3.03% of 7,332.7MB of
  object file size.
- Incremental step towards decoupling target intrinsics.

The enums are still compact, so adding and removing a single
target-specific intrinsic will trigger a rebuild of all of LLVM.
Assigning distinct target id spaces is potential future work.

Part of PR34259

Reviewers: efriedma, echristo, MaskRay

Reviewed By: echristo, MaskRay

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
llvm/include/llvm/Analysis/TargetTransformInfo.h
llvm/include/llvm/Analysis/VectorUtils.h
llvm/include/llvm/IR/CMakeLists.txt
llvm/include/llvm/IR/CallSite.h
llvm/include/llvm/IR/Function.h
llvm/include/llvm/IR/GlobalValue.h
llvm/include/llvm/IR/InstrTypes.h
llvm/include/llvm/IR/Intrinsics.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Analysis/MemoryLocation.cpp
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
llvm/lib/CodeGen/TypePromotion.cpp
llvm/lib/CodeGen/WasmEHPrepare.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/IR/Function.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/lib/Target/AArch64/AArch64StackTagging.cpp
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
llvm/lib/Target/AMDGPU/AMDGPU.h
llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
llvm/lib/Target/AMDGPU/R600ISelLowering.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMInstructionSelector.cpp
llvm/lib/Target/ARM/ARMParallelDSP.cpp
llvm/lib/Target/ARM/MVETailPredication.cpp
llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
llvm/lib/Target/Hexagon/HexagonGenExtract.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAG.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp
llvm/lib/Target/Hexagon/HexagonOptimizeSZextends.cpp
llvm/lib/Target/Hexagon/HexagonVectorLoopCarriedReuse.cpp
llvm/lib/Target/Mips/MipsInstructionSelector.cpp
llvm/lib/Target/Mips/MipsLegalizerInfo.cpp
llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
llvm/lib/Target/Mips/MipsSEISelLowering.cpp
llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/lib/Target/NVPTX/NVPTXImageOptimizer.cpp
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
llvm/lib/Target/NVPTX/NVVMIntrRange.cpp
llvm/lib/Target/NVPTX/NVVMReflect.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZTDC.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
llvm/lib/Target/X86/X86FastISel.cpp
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/X86/X86InstructionSelector.cpp
llvm/lib/Target/X86/X86IntrinsicsInfo.h
llvm/lib/Target/X86/X86WinEHState.cpp
llvm/lib/Target/XCore/XCoreISelDAGToDAG.cpp
llvm/lib/Target/XCore/XCoreISelLowering.cpp
llvm/lib/Target/XCore/XCoreLowerThreadLocal.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
llvm/test/TableGen/intrinsic-long-name.td
llvm/test/TableGen/intrinsic-struct.td
llvm/unittests/IR/IRBuilderTest.cpp
llvm/utils/TableGen/IntrinsicEmitter.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8a53739626e1..29226d6af50c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -31,6 +31,17 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Intrinsics.h"
+#include 

[PATCH] D71325: [Remarks][Driver] Ask for line tables when remarks are enabled

2019-12-11 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG60590b149b33: [Remarks][Driver] Ask for line tables when 
remarks are enabled (authored by thegameg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71325

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -64,6 +64,12 @@
 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
+// RUN: %clang -### -c -g -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE %s
 
 // FreeBSD.
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3717,6 +3717,11 @@
   // Adjust the debug info kind for the given toolchain.
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
+  // When emitting remarks, we need at least debug lines in the output.
+  if (shouldEmitRemarks(Args) &&
+  DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
+DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -64,6 +64,12 @@
 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
+// RUN: %clang -### -c -g -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE %s
 
 // FreeBSD.
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3717,6 +3717,11 @@
   // Adjust the debug info kind for the given toolchain.
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
+  // When emitting remarks, we need at least debug lines in the output.
+  if (shouldEmitRemarks(Args) &&
+  DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
+DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 60590b1 - [Remarks][Driver] Ask for line tables when remarks are enabled

2019-12-11 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-11T17:59:46-08:00
New Revision: 60590b149b33eb80d0b52c1c6723fe35817ee897

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

LOG: [Remarks][Driver] Ask for line tables when remarks are enabled

Serialized remarks contain debug locations for each remark, by storing a
file path, a line, and a column.

Also, remarks support being embedded in a .dSYM bundle using a separate
section in object files, that is found by `dsymutil` through the debug
map.

In order for tools to map addresses to source and display remarks in the
source, we need line tables, and in order for `dsymutil` to find the
object files containing the remark section, we need to keep the debug
map around.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c00d5d07bcf2..38c6acc85512 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3717,6 +3717,11 @@ static void RenderDebugOptions(const ToolChain , 
const Driver ,
   // Adjust the debug info kind for the given toolchain.
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
+  // When emitting remarks, we need at least debug lines in the output.
+  if (shouldEmitRemarks(Args) &&
+  DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
+DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index aacc40f780d6..acbc056573ec 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -64,6 +64,12 @@
 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
+// RUN: %clang -### -c -g -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE %s
 
 // FreeBSD.
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \



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


[clang] bc24014 - [c++20] Implement P1185R2 (as modified by P2002R0).

2019-12-11 Thread Alex Orlov via cfe-commits
Hi Richard,

http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/1353

The bots are broken for a long time now.
When do you expect the fix?

Thanks,
Alex


On Wed, Dec 11, 2019 at 12:13 AM Yvan Roux via cfe-commits 
 wrote:
Hi Richard,

ARM bots are broken after this commit, logs are available here:

http://lab.llvm.org:8011/builders/clang-cmake-armv7-quick/builds/12109/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Acxx2a-three-way-comparison.cpp

Thanks,
Yvan

On Wed, 11 Dec 2019 at 02:24, Richard Smith via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:
>
>
> Author: Richard Smith
> Date: 2019-12-10T17:24:27-08:00
> New Revision: bc24014b9765a454cb5214f4871451a41ffb7d29
>
> URL: 
> https://github.com/llvm/llvm-project/commit/bc24014b9765a454cb5214f4871451a41ffb7d29
> DIFF: 
> https://github.com/llvm/llvm-project/commit/bc24014b9765a454cb5214f4871451a41ffb7d29.diff
>
> LOG: [c++20] Implement P1185R2 (as modified by P2002R0).
>
> For each defaulted operator<=> in a class that doesn't explicitly
> declare any operator==, also inject a matching implicit defaulted
> operator==.
>
> Added:
> clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
>
> Modified:
> clang/include/clang/Basic/DiagnosticSemaKinds.td
> clang/include/clang/Sema/Sema.h
> clang/include/clang/Sema/Template.h
> clang/lib/Frontend/FrontendActions.cpp
> clang/lib/Sema/SemaDeclCXX.cpp
> clang/lib/Sema/SemaOverload.cpp
> clang/lib/Sema/SemaTemplateInstantiate.cpp
> clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
> clang/test/CodeGenCXX/cxx2a-three-way-comparison.cpp
>
> Removed:
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
> b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> index aeeff2b9a76e..a5f35996cfdc 100644
> --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
> +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
> @@ -3840,6 +3840,7 @@ def select_ovl_candidate_kind : TextSubstitution<
>  "constructor (the implicit move constructor)|"
>  "function (the implicit copy assignment operator)|"
>  "function (the implicit move assignment operator)|"
> +"function (the implicit 'operator==' for this 'operator<=>)'|"
>  "inherited constructor}0%select{| template| %2}1">;
>
>  def note_ovl_candidate : Note<
> @@ -8207,7 +8208,8 @@ def warn_defaulted_comparison_deleted : Warning<
>"explicitly defaulted %sub{select_defaulted_comparison_kind}0 is 
> implicitly "
>"deleted">, InGroup;
>  def err_non_first_default_compare_deletes : Error<
> -  "defaulting this %sub{select_defaulted_comparison_kind}0 "
> +  "defaulting %select{this %sub{select_defaulted_comparison_kind}1|"
> +  "the corresponding implicit 'operator==' for this defaulted 
> 'operator<=>'}0 "
>"would delete it after its first declaration">;
>  def note_defaulted_comparison_union : Note<
>"defaulted %0 is implicitly deleted because "
> @@ -8237,14 +8239,19 @@ def note_defaulted_comparison_cannot_deduce : Note<
>  def note_defaulted_comparison_cannot_deduce_callee : Note<
>"selected 'operator<=>' for %select{|member|base class}0 %1 declared 
> here">;
>  def err_incorrect_defaulted_comparison_constexpr : Error<
> -  "defaulted definition of %sub{select_defaulted_comparison_kind}0 "
> -  "cannot be declared %select{constexpr|consteval}1 because it invokes "
> -  "a non-constexpr comparison function">;
> +  "defaulted definition of %select{%sub{select_defaulted_comparison_kind}1|"
> +  "three-way comparison operator}0 "
> +  "cannot be declared %select{constexpr|consteval}2 because "
> +  "%select{it|the corresponding implicit 'operator=='}0 "
> +  "invokes a non-constexpr comparison function">;
>  def note_defaulted_comparison_not_constexpr : Note<
>"non-constexpr comparison function would be used to compare "
>"%select{|member %1|base class %1}0">;
>  def note_defaulted_comparison_not_constexpr_here : Note<
>"non-constexpr comparison function declared here">;
> +def note_in_declaration_of_implicit_equality_comparison : Note<
> +  "while declaring the corresponding implicit 'operator==' "
> +  "for this defaulted 'operator<=>'">;
>
>  def ext_implicit_exception_spec_mismatch : ExtWarn<
>"function previously declared with an %select{explicit|implicit}0 
> exception "
>
> diff  --git a/clang/include/clang/Sema/Sema.h 
> b/clang/include/clang/Sema/Sema.h
> index 1cdaab3dc28c..5a1ee507218c 100644
> --- a/clang/include/clang/Sema/Sema.h
> +++ b/clang/include/clang/Sema/Sema.h
> @@ -6524,6 +6524,8 @@ class Sema final {
>
>bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD,
>DefaultedComparisonKind DCK);
> +  void DeclareImplicitEqualityComparison(CXXRecordDecl *RD,
> + FunctionDecl *Spaceship);
>void DefineDefaultedComparison(SourceLocation Loc, 

[PATCH] D71241: [OpenMP][WIP] Use overload centric declare variants

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D71241#1779097 , @ABataev wrote:

> In D71241#1778963 , @jdoerfert wrote:
>
> > In D71241#1778736 , @ABataev wrote:
> >
> > > In D71241#1778717 , @jdoerfert 
> > > wrote:
> > >
> > > > >> There is no evidence that this is more complicated. By all measures, 
> > > > >> this is less complicated (see also below). It is also actually doing 
> > > > >> the right thing when it comes to code emission. Take 
> > > > >> https://godbolt.org/z/sJiP3B for example. The calls are wrong and 
> > > > >> the definition of base is missing.
> > > > > 
> > > > > How did you measure it? I have a completely different opinion. Also, 
> > > > > tried to reproduce the problem locally, could not reproduce. It seems 
> > > > > to me, the output of the test misses several important things. You 
> > > > > can check it yourself. `tgt_target_teams()` call uses 
> > > > > `@.offload_maptypes` global var but it is not defined.
> > > >
> > > > Here is the link with the globals not hidden: 
> > > > https://godbolt.org/z/5etB5S
> > > >  The base function is called both times but should not be called at 
> > > > all. What is your local output and why does it differ?
> > >
> > >
> > > On the host `base` is an alias for the `hst` function. On the device 
> > > `base` has the body of `dev` function because NVPTX does nit support 
> > > function aliases (10+ suppprts it, but LLVM does not support it yet). Try 
> > > to change the bodies of dev and hst and you will see.
> > >
> > > I tried to keep original function names to improve debugging and make 
> > > users less wonder why instead of `base` something else is called.
> >
> >
> > How does that work with linking? Another translation unit can call both the 
> > base and hst/dev function, right? I mean they both need to be present.
>
>
> If hst or dev are needed, they are emitted too, independently. On the host, 
> the variamt function is emitted and base function is set to be an alias of 
> the variant function. On the device we just inherit the body of the variant 
> function, but this variant function also can be emitted, if used 
> independently.


This is confusing:

1. Especially for debugging we should do the same on host and device.
2. The device function now exists twice, that is bad.
3. How is this supposed to work with type corrections? I mean the variant needs 
to be compatible but not necessarily of the same type, right? 
https://godbolt.org/z/QAXCuv we just produce a cryptic error (locally it 
crashes for me afterwards).
4. On the host the expression ` == ` will evaluate to true with the 
alias.



In D71241#1779779 , @ABataev wrote:

> Here is the example that does not work with the proposed solution but works 
> with the existing one:
>
>   static void cpu() { asm("nop"); }
>  
>   #pragma omp declare variant(cpu) match(device = {kind(cpu)})
>   static __attribute__((used)) void wrong_asm() {
> asm ("xxx");
>   }
>
>
> The existing solution has some problems with the delayed error messages too, 
> but they are very easy to fix.


I don't understand this example. What is the expected outcome here (I get the 
error below from ToT clang). Why is that not achievable by a SemaOverload 
solution?
`asm.c:4:35: error: function with '#pragma omp declare variant' must have a 
prototype`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71241



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


[clang] 9fdcae7 - [analyzer] Do not cache out on some shared implicit AST nodes

2019-12-11 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-12-11T17:15:12-08:00
New Revision: 9fdcae7c81f5ff92ad694f5d993a042a525fd6bc

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

LOG: [analyzer] Do not cache out on some shared implicit AST nodes

Some AST nodes which stands for implicit initialization is shared. The analyzer
will do the same evaluation on the same nodes resulting in the same state. The
analyzer will "cache out", i.e. it thinks that it visited an already existing
node in the exploded graph. This is not true in this case and we lose coverage.
Since these nodes do not really require any processing from the analyzer
we just omit them from the CFG.

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

Added: 
clang/test/Analysis/designated-initializer-values.c

Modified: 
clang/include/clang/Analysis/CFG.h
clang/lib/Analysis/CFG.cpp
clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/Analysis/designated-initializer.c
clang/test/Analysis/initializers-cfg-output.cpp
clang/test/Analysis/temp-obj-dtors-cfg-output.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/CFG.h 
b/clang/include/clang/Analysis/CFG.h
index a8301a0e0063..ea3d8b2921a7 100644
--- a/clang/include/clang/Analysis/CFG.h
+++ b/clang/include/clang/Analysis/CFG.h
@@ -1251,6 +1251,7 @@ class CFG {
 bool AddRichCXXConstructors = false;
 bool MarkElidedCXXConstructors = false;
 bool AddVirtualBaseBranches = false;
+bool OmitImplicitValueInitializers = false;
 
 BuildOptions() = default;
 

diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index bc21d1c9076d..e10bfd805933 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -2135,6 +2135,11 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
 default:
   return VisitStmt(S, asc);
 
+case Stmt::ImplicitValueInitExprClass:
+  if (BuildOpts.OmitImplicitValueInitializers)
+return Block;
+  return VisitStmt(S, asc);
+
 case Stmt::AddrLabelExprClass:
   return VisitAddrLabelExpr(cast(S), asc);
 

diff  --git a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp 
b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
index 73e1a0df..94fc09e64aa0 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -43,6 +43,7 @@ AnalysisManager::AnalysisManager(ASTContext ,
   CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
   options(Options) {
   AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
+  AnaCtxMgr.getCFGBuildOptions().OmitImplicitValueInitializers = true;
 }
 
 AnalysisManager::~AnalysisManager() {

diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 2a23d1cae7b5..f917a4c8637b 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1321,6 +1321,11 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
 case Stmt::WhileStmtClass:
 case Expr::MSDependentExistsStmtClass:
   llvm_unreachable("Stmt should not be in analyzer evaluation loop");
+case Stmt::ImplicitValueInitExprClass:
+  // These nodes are shared in the CFG and would case caching out.
+  // Moreover, no additional evaluation required for them, the
+  // analyzer can reconstruct these values from the AST.
+  llvm_unreachable("Should be pruned from CFG");
 
 case Stmt::ObjCSubscriptRefExprClass:
 case Stmt::ObjCPropertyRefExprClass:
@@ -1391,7 +1396,6 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
 case Stmt::IntegerLiteralClass:
 case Stmt::FixedPointLiteralClass:
 case Stmt::CharacterLiteralClass:
-case Stmt::ImplicitValueInitExprClass:
 case Stmt::CXXScalarValueInitExprClass:
 case Stmt::CXXBoolLiteralExprClass:
 case Stmt::ObjCBoolLiteralExprClass:

diff  --git a/clang/test/Analysis/designated-initializer-values.c 
b/clang/test/Analysis/designated-initializer-values.c
new file mode 100644
index ..1efc10aece60
--- /dev/null
+++ b/clang/test/Analysis/designated-initializer-values.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-std=c99 -verify %s
+
+void clang_analyzer_eval(int);
+
+void array_init() {
+  int a[5] = {[4] = 29, [2] = 15, [0] = 4};
+  clang_analyzer_eval(a[0] == 4);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[2] == 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[3] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[4] == 29); // expected-warning{{TRUE}}
+  int b[5] = {[0 ... 2] = 1, [4] 

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9fdcae7c81f5: [analyzer] Do not cache out on some shared 
implicit AST nodes (authored by xazax.hun).

Changed prior to commit:
  https://reviews.llvm.org/D71371?vs=233468=233475#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71371

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/designated-initializer-values.c
  clang/test/Analysis/designated-initializer.c
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -1224,8 +1224,7 @@
 // CHECK:16: a([B1.15]) (Member initializer)
 // CHECK:17: ~B() (Temporary object destructor)
 // CHECK:18: ~A() (Temporary object destructor)
-// CHECK:19: /*implicit*/(int)0
-// CHECK:20: b([B1.19]) (Member initializer)
+// CHECK:19: b(/*implicit*/(int)0) (Member initializer)
 // CHECK: Preds (1): B2
 // CHECK: Succs (1): B0
 // CHECK:   [B0 (EXIT)]
Index: clang/test/Analysis/initializers-cfg-output.cpp
===
--- clang/test/Analysis/initializers-cfg-output.cpp
+++ clang/test/Analysis/initializers-cfg-output.cpp
@@ -126,14 +126,13 @@
 // WARNINGS-NEXT: 5:  (CXXConstructExpr, class A)
 // ANALYZER-NEXT: 5:  (CXXConstructExpr, A() (Base initializer), class A)
 // CHECK-NEXT: 6: A([B1.5]) (Base initializer)
-// CHECK-NEXT: 7: /*implicit*/(int)0
-// CHECK-NEXT: 8: i([B1.7]) (Member initializer)
-// CHECK-NEXT: 9: this
-// CHECK-NEXT:10: [B1.9]->i
-// CHECK-NEXT:11: r([B1.10]) (Member initializer)
-// WARNINGS-NEXT:12:  (CXXConstructExpr, class A)
-// ANALYZER-NEXT:12:  (CXXConstructExpr, [B1.13], class A)
-// CHECK-NEXT:13: A a;
+// CHECK-NEXT: 7: i(/*implicit*/(int)0) (Member initializer)
+// CHECK-NEXT: 8: this
+// CHECK-NEXT:9: [B1.8]->i
+// CHECK-NEXT:10: r([B1.9]) (Member initializer)
+// WARNINGS-NEXT:11:  (CXXConstructExpr, class A)
+// ANALYZER-NEXT:11:  (CXXConstructExpr, [B1.12], class A)
+// CHECK-NEXT:12: A a;
 // CHECK-NEXT: Preds (2): B2 B3
 // CHECK-NEXT: Succs (1): B0
 // CHECK:[B2]
Index: clang/test/Analysis/designated-initializer.c
===
--- clang/test/Analysis/designated-initializer.c
+++ clang/test/Analysis/designated-initializer.c
@@ -31,11 +31,10 @@
 // CHECK:  11: struct LUQ var = {getUQ(), .uq.q.a = 100};
 // CHECK:  12: 1
 // CHECK:  13: 2
-// CHECK:  14: /*implicit*/(int)0
-// CHECK:  15: {[B1.12], [B1.13]}
+// CHECK:  14: {[B1.12], [B1.13]}
+// CHECK:  17: /*no init*/
 // CHECK:  18: /*no init*/
-// CHECK:  19: /*no init*/
-// CHECK:  20: 3
-// CHECK:  21: {[B1.18], [B1.19], [B1.20]}
-// CHECK:  22: {/*base*/[B1.17], /*updater*/[B1.21]} 
-// CHECK:  24: struct Q s[] = {[0] = (struct Q){1, 2}, [0].c = 3};
+// CHECK:  19: 3
+// CHECK:  20: {[B1.17], [B1.18], [B1.19]}
+// CHECK:  21: {/*base*/[B1.16], /*updater*/[B1.20]} 
+// CHECK:  23: struct Q s[] = {[0] = (struct Q){1, 2}, [0].c = 3};
Index: clang/test/Analysis/designated-initializer-values.c
===
--- /dev/null
+++ clang/test/Analysis/designated-initializer-values.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c99 -verify %s
+
+void clang_analyzer_eval(int);
+
+void array_init() {
+  int a[5] = {[4] = 29, [2] = 15, [0] = 4};
+  clang_analyzer_eval(a[0] == 4);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[2] == 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[3] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[4] == 29); // expected-warning{{TRUE}}
+  int b[5] = {[0 ... 2] = 1, [4] = 5};
+  clang_analyzer_eval(b[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[1] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[2] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[3] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[4] == 5); // expected-warning{{TRUE}}
+}
+
+struct point {
+  int x, y;
+};
+
+void struct_init() {
+  struct point p = {.y = 5, .x = 3};
+  clang_analyzer_eval(p.x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p.y == 5); // expected-warning{{TRUE}}
+}
+
+void array_of_struct() {
+  struct point ptarray[3] = { [2].y = 1, [2].x = 2, [0].x = 3 };
+  clang_analyzer_eval(ptarray[0].x == 3); // 

[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thanks!!




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1318
 case Expr::MSDependentExistsStmtClass:
   llvm_unreachable("Stmt should not be in analyzer evaluation loop");
 

We already have a similar unreachable here :p


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

https://reviews.llvm.org/D71371



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:51
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = std::function;
+

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > `llvm::function_ref`?
> > The lambda that is passed in here might go out of scope so we need to own 
> > it. This is intentional.
> Maybe better to save the intermediate data in CGOpenMPRuntime class rather 
> than rely on owning lambda ref here? Clang does not use escaping decls and 
> instead stores intermediate data explicitly. It really complicates analysis 
> and potential source of resource leakage.
I don't follow. Clang does use `std::function` to store callbacks that have to 
life for a while. Why is this different? What would be the benefit of having a 
function_ref here and a `std::function` in CGOpenMPRuntime? Note that the 
FinaliztionInfo object is created in the front-end and the std::function is 
assigned there already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-11 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht marked an inline comment as done.
rupprecht added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:13047
+  F->setUsesFPIntrin(true);
+  printf("Enclosing function uses fp intrinsics\n");
+}

rupprecht wrote:
> Looks like this is leftover debugging? I'm seeing log spam compiling some 
> files -- this message repeated hundreds of times. I'll go ahead and create a 
> patch that nukes this.
Sorry for the noise, looks like f4a7d5659df7cb56c1baa34a39e9fe2639472741 
already did this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-11 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:13047
+  F->setUsesFPIntrin(true);
+  printf("Enclosing function uses fp intrinsics\n");
+}

Looks like this is leftover debugging? I'm seeing log spam compiling some files 
-- this message repeated hundreds of times. I'll go ahead and create a patch 
that nukes this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 233472.
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

Update the unit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -104,7 +104,15 @@
 
   BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
   new UnreachableInst(Ctx, CBB);
-  OMPBuilder.setCancellationBlock(CBB);
+  auto FiniCB = [CBB](llvm::OpenMPIRBuilder::InsertPointTy IP) {
+assert(IP.getBlock()->end() == IP.getPoint() &&
+   "Clang CG should cause non-terminated block!");
+BranchInst::Create(CBB, IP.getBlock());
+  };
+  // Emulate an outer parallel.
+  llvm::OpenMPIRBuilder::FinalizationInfo FI(
+  {FiniCB, OMPD_parallel, /* HasCancel */ true});
+  OMPBuilder.pushFinalizationCB(std::move(FI));
 
   IRBuilder<> Builder(BB);
 
@@ -113,7 +121,7 @@
   Builder.restoreIP(NewIP);
   EXPECT_FALSE(M->global_empty());
   EXPECT_EQ(M->size(), 3U);
-  EXPECT_EQ(F->size(), 3U);
+  EXPECT_EQ(F->size(), 4U);
   EXPECT_EQ(BB->size(), 4U);
 
   CallInst *GTID = dyn_cast(>front());
@@ -133,10 +141,15 @@
   Instruction *BarrierBBTI = Barrier->getParent()->getTerminator();
   EXPECT_EQ(BarrierBBTI->getNumSuccessors(), 2U);
   EXPECT_EQ(BarrierBBTI->getSuccessor(0), NewIP.getBlock());
-  EXPECT_EQ(BarrierBBTI->getSuccessor(1), CBB);
+  EXPECT_EQ(BarrierBBTI->getSuccessor(1)->getTerminator()->getNumSuccessors(),
+1U);
+  EXPECT_EQ(BarrierBBTI->getSuccessor(1)->getTerminator()->getSuccessor(0),
+CBB);
 
   EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
 
+  OMPBuilder.popFinalizationCB();
+
   Builder.CreateUnreachable();
   EXPECT_FALSE(verifyModule(*M));
 }
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -205,7 +205,8 @@
   // If we are in a cancellable parallel region, barriers are cancellation
   // points.
   // TODO: Check why we would force simple calls or to ignore the cancel flag.
-  bool UseCancelBarrier = !ForceSimpleCall && CancellationBlock;
+  bool UseCancelBarrier =
+  !ForceSimpleCall && isLastFinalizationInfoCancellable(OMPD_parallel);
 
   Value *Result = Builder.CreateCall(
   getOrCreateRuntimeFunction(UseCancelBarrier ? OMPRTL___kmpc_cancel_barrier
@@ -217,19 +218,22 @@
 BasicBlock *BB = Builder.GetInsertBlock();
 BasicBlock *NonCancellationBlock = BasicBlock::Create(
 BB->getContext(), BB->getName() + ".cont", BB->getParent());
+BasicBlock *CancellationBlock = BasicBlock::Create(
+BB->getContext(), BB->getName() + ".cncl", BB->getParent());
 
 // Jump to them based on the return value.
 Value *Cmp = Builder.CreateIsNull(Result);
 Builder.CreateCondBr(Cmp, NonCancellationBlock, CancellationBlock,
  /* TODO weight */ nullptr, nullptr);
 
-Builder.SetInsertPoint(NonCancellationBlock);
-assert(CancellationBlock->getParent() == BB->getParent() &&
-   "Unexpected cancellation block parent!");
+// From the cancellation block we finalize all variables and go to the
+// post finalization block that is known to the FiniCB callback.
+Builder.SetInsertPoint(CancellationBlock);
+auto  = FinalizationStack.back();
+FI.FiniCB(Builder.saveIP());
 
-// TODO: This is a workaround for now, we always reset the cancellation
-// block until we manage it ourselves here.
-CancellationBlock = nullptr;
+// The continuation block is where code generation continues.
+Builder.SetInsertPoint(NonCancellationBlock);
   }
 
   return Builder.saveIP();
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -37,12 +37,44 @@
   /// Add attributes known for \p FnID to \p Fn.
   void addAttributes(omp::RuntimeFunction FnID, Function );
 
-  /// Set the cancellation block to \p CBB.
-  void setCancellationBlock(BasicBlock *CBB) { CancellationBlock = CBB; }
-
   /// Type used throughout for insertion points.
   using InsertPointTy = IRBuilder<>::InsertPoint;
 
+  /// Callback type for variable finalization (think destructors).
+  ///
+  /// \param CodeGenIP is the insertion point at which the finalization code
+  ///  should be placed.
+  ///
+  /// A finalize callback knows about all 

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:51
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = std::function;
+

jdoerfert wrote:
> ABataev wrote:
> > `llvm::function_ref`?
> The lambda that is passed in here might go out of scope so we need to own it. 
> This is intentional.
Maybe better to save the intermediate data in CGOpenMPRuntime class rather than 
rely on owning lambda ref here? Clang does not use escaping decls and instead 
stores intermediate data explicitly. It really complicates analysis and 
potential source of resource leakage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[clang] 5bcd34a - Revert "[clang][clang-scan-deps] Aggregate the full dependency information."

2019-12-11 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2019-12-11T16:35:55-08:00
New Revision: 5bcd34a03ff343674c106b9a6a0406bf249b9b31

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

LOG: Revert "[clang][clang-scan-deps] Aggregate the full dependency 
information."

This reverts commit f978ea498309adaebab8fbf1cd6e520e7e0e11f1.

It broke clang-ppc64be-linux, but not sure why yet.

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/modules_cdb.json
clang/test/ClangScanDeps/modules-full.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index 1c106ed4b765..a0c1900f7ed9 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -11,69 +11,13 @@
 
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
-#include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
-#include "llvm/ADT/StringSet.h"
 #include 
 
 namespace clang{
 namespace tooling{
 namespace dependencies{
 
-/// The full dependencies and module graph for a specific input.
-struct FullDependencies {
-  /// The name of the C++20 module this translation unit exports. This may
-  /// include `:` for C++20 module partitons.
-  ///
-  /// If the translation unit is not a module then this will be empty.
-  std::string ExportedModuleName;
-
-  /// The context hash represents the set of compiler options that may make one
-  /// version of a module incompatible with another. This includes things like
-  /// language mode, predefined macros, header search paths, etc...
-  ///
-  /// Modules with the same name but a 
diff erent \c ContextHash should be
-  /// treated as separate modules for the purpose of a build.
-  std::string ContextHash;
-
-  /// A collection of absolute paths to files that this translation unit
-  /// directly depends on, not including transitive dependencies.
-  std::vector FileDeps;
-
-  /// A list of modules this translation unit directly depends on, not 
including
-  /// transitive dependencies.
-  ///
-  /// This may include modules with a 
diff erent context hash when it can be
-  /// determined that the 
diff erences are benign for this compilation.
-  std::vector ClangModuleDeps;
-
-  /// A partial addtional set of command line arguments that can be used to
-  /// build this translation unit.
-  ///
-  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
-  /// appending to the original command line to pass to clang.
-  std::vector AdditionalNonPathCommandLine;
-
-  /// Gets the full addtional command line suitable for appending to the
-  /// original command line to pass to clang.
-  ///
-  /// \param LookupPCMPath this function is called to fill in `-fmodule-file=`
-  ///  flags and for the `-o` flag. It needs to return a
-  ///  path for where the PCM for the given module is to
-  ///  be located.
-  /// \param LookupModuleDeps this fucntion is called to collect the full
-  /// transitive set of dependencies for this
-  /// compilation.
-  std::vector getAdditionalCommandLine(
-  std::function LookupPCMPath,
-  std::function LookupModuleDeps) 
const;
-};
-
-struct FullDependenciesResult {
-  FullDependencies FullDeps;
-  std::vector DiscoveredModules;
-};
-
 /// The high-level implementation of the dependency discovery tool that runs on
 /// an individual worker thread.
 class DependencyScanningTool {
@@ -91,23 +35,8 @@ class DependencyScanningTool {
   getDependencyFile(const tooling::CompilationDatabase ,
 StringRef CWD);
 
-  /// Collect the full module depenedency graph for the input, ignoring any
-  /// modules which have already been seen.
-  ///
-  /// \param AlreadySeen this is used to not report modules that have 
previously
-  ///been reported. Use the same `llvm::StringSet<>` for 
all
-  ///calls to `getFullDependencies` for a single
-  ///`DependencyScanningTool` for a single build. Use a
-  ///

Re: [clang] f978ea4 - [clang][clang-scan-deps] Aggregate the full dependency information.

2019-12-11 Thread Michael Spencer via cfe-commits
On Wed, Dec 11, 2019 at 2:41 PM Michael Spencer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Michael Spencer
> Date: 2019-12-11T14:40:51-08:00
> New Revision: f978ea498309adaebab8fbf1cd6e520e7e0e11f1
>
> URL:
> https://github.com/llvm/llvm-project/commit/f978ea498309adaebab8fbf1cd6e520e7e0e11f1
> DIFF:
> https://github.com/llvm/llvm-project/commit/f978ea498309adaebab8fbf1cd6e520e7e0e11f1.diff
>
> LOG: [clang][clang-scan-deps] Aggregate the full dependency information.
>
> Differential Revision: https://reviews.llvm.org/D70268
>
> Added:
>
>
> Modified:
> clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
> clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
> clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
> clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
> clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
> clang/test/ClangScanDeps/Inputs/modules_cdb.json
> clang/test/ClangScanDeps/modules-full.cpp
> clang/tools/clang-scan-deps/ClangScanDeps.cpp
>


Looks like this broke clang-ppc64be-linux. Is there a good way to debug
this? It's not failing anywhere else, and none of the code should care
about endianness.

I'll revert for now.

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


[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 233468.
xazax.hun added a comment.

- Removed leftover code from previous approach.


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

https://reviews.llvm.org/D71371

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/designated-initializer-values.c
  clang/test/Analysis/designated-initializer.c
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -1224,8 +1224,7 @@
 // CHECK:16: a([B1.15]) (Member initializer)
 // CHECK:17: ~B() (Temporary object destructor)
 // CHECK:18: ~A() (Temporary object destructor)
-// CHECK:19: /*implicit*/(int)0
-// CHECK:20: b([B1.19]) (Member initializer)
+// CHECK:19: b(/*implicit*/(int)0) (Member initializer)
 // CHECK: Preds (1): B2
 // CHECK: Succs (1): B0
 // CHECK:   [B0 (EXIT)]
Index: clang/test/Analysis/initializers-cfg-output.cpp
===
--- clang/test/Analysis/initializers-cfg-output.cpp
+++ clang/test/Analysis/initializers-cfg-output.cpp
@@ -126,14 +126,13 @@
 // WARNINGS-NEXT: 5:  (CXXConstructExpr, class A)
 // ANALYZER-NEXT: 5:  (CXXConstructExpr, A() (Base initializer), class A)
 // CHECK-NEXT: 6: A([B1.5]) (Base initializer)
-// CHECK-NEXT: 7: /*implicit*/(int)0
-// CHECK-NEXT: 8: i([B1.7]) (Member initializer)
-// CHECK-NEXT: 9: this
-// CHECK-NEXT:10: [B1.9]->i
-// CHECK-NEXT:11: r([B1.10]) (Member initializer)
-// WARNINGS-NEXT:12:  (CXXConstructExpr, class A)
-// ANALYZER-NEXT:12:  (CXXConstructExpr, [B1.13], class A)
-// CHECK-NEXT:13: A a;
+// CHECK-NEXT: 7: i(/*implicit*/(int)0) (Member initializer)
+// CHECK-NEXT: 8: this
+// CHECK-NEXT:9: [B1.8]->i
+// CHECK-NEXT:10: r([B1.9]) (Member initializer)
+// WARNINGS-NEXT:11:  (CXXConstructExpr, class A)
+// ANALYZER-NEXT:11:  (CXXConstructExpr, [B1.12], class A)
+// CHECK-NEXT:12: A a;
 // CHECK-NEXT: Preds (2): B2 B3
 // CHECK-NEXT: Succs (1): B0
 // CHECK:[B2]
Index: clang/test/Analysis/designated-initializer.c
===
--- clang/test/Analysis/designated-initializer.c
+++ clang/test/Analysis/designated-initializer.c
@@ -31,11 +31,10 @@
 // CHECK:  11: struct LUQ var = {getUQ(), .uq.q.a = 100};
 // CHECK:  12: 1
 // CHECK:  13: 2
-// CHECK:  14: /*implicit*/(int)0
-// CHECK:  15: {[B1.12], [B1.13]}
+// CHECK:  14: {[B1.12], [B1.13]}
+// CHECK:  17: /*no init*/
 // CHECK:  18: /*no init*/
-// CHECK:  19: /*no init*/
-// CHECK:  20: 3
-// CHECK:  21: {[B1.18], [B1.19], [B1.20]}
-// CHECK:  22: {/*base*/[B1.17], /*updater*/[B1.21]} 
-// CHECK:  24: struct Q s[] = {[0] = (struct Q){1, 2}, [0].c = 3};
+// CHECK:  19: 3
+// CHECK:  20: {[B1.17], [B1.18], [B1.19]}
+// CHECK:  21: {/*base*/[B1.16], /*updater*/[B1.20]} 
+// CHECK:  23: struct Q s[] = {[0] = (struct Q){1, 2}, [0].c = 3};
Index: clang/test/Analysis/designated-initializer-values.c
===
--- /dev/null
+++ clang/test/Analysis/designated-initializer-values.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c99 -verify %s
+
+void clang_analyzer_eval(int);
+
+void array_init() {
+  int a[5] = {[4] = 29, [2] = 15, [0] = 4};
+  clang_analyzer_eval(a[0] == 4);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[2] == 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[3] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[4] == 29); // expected-warning{{TRUE}}
+  int b[5] = {[0 ... 2] = 1, [4] = 5};
+  clang_analyzer_eval(b[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[1] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[2] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[3] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[4] == 5); // expected-warning{{TRUE}}
+}
+
+struct point {
+  int x, y;
+};
+
+void struct_init() {
+  struct point p = {.y = 5, .x = 3};
+  clang_analyzer_eval(p.x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p.y == 5); // expected-warning{{TRUE}}
+}
+
+void array_of_struct() {
+  struct point ptarray[3] = { [2].y = 1, [2].x = 2, [0].x = 3 };
+  clang_analyzer_eval(ptarray[0].x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[0].y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[1].x == 0); // expected-warning{{TRUE}}
+  

[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 233467.
xazax.hun edited the summary of this revision.
xazax.hun added a comment.

- Omit nodes from CFG instead of trying to make the states distinct.


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

https://reviews.llvm.org/D71371

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/designated-initializer-values.c
  clang/test/Analysis/designated-initializer.c
  clang/test/Analysis/initializers-cfg-output.cpp
  clang/test/Analysis/temp-obj-dtors-cfg-output.cpp

Index: clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
===
--- clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
+++ clang/test/Analysis/temp-obj-dtors-cfg-output.cpp
@@ -1224,8 +1224,7 @@
 // CHECK:16: a([B1.15]) (Member initializer)
 // CHECK:17: ~B() (Temporary object destructor)
 // CHECK:18: ~A() (Temporary object destructor)
-// CHECK:19: /*implicit*/(int)0
-// CHECK:20: b([B1.19]) (Member initializer)
+// CHECK:19: b(/*implicit*/(int)0) (Member initializer)
 // CHECK: Preds (1): B2
 // CHECK: Succs (1): B0
 // CHECK:   [B0 (EXIT)]
Index: clang/test/Analysis/initializers-cfg-output.cpp
===
--- clang/test/Analysis/initializers-cfg-output.cpp
+++ clang/test/Analysis/initializers-cfg-output.cpp
@@ -126,14 +126,13 @@
 // WARNINGS-NEXT: 5:  (CXXConstructExpr, class A)
 // ANALYZER-NEXT: 5:  (CXXConstructExpr, A() (Base initializer), class A)
 // CHECK-NEXT: 6: A([B1.5]) (Base initializer)
-// CHECK-NEXT: 7: /*implicit*/(int)0
-// CHECK-NEXT: 8: i([B1.7]) (Member initializer)
-// CHECK-NEXT: 9: this
-// CHECK-NEXT:10: [B1.9]->i
-// CHECK-NEXT:11: r([B1.10]) (Member initializer)
-// WARNINGS-NEXT:12:  (CXXConstructExpr, class A)
-// ANALYZER-NEXT:12:  (CXXConstructExpr, [B1.13], class A)
-// CHECK-NEXT:13: A a;
+// CHECK-NEXT: 7: i(/*implicit*/(int)0) (Member initializer)
+// CHECK-NEXT: 8: this
+// CHECK-NEXT:9: [B1.8]->i
+// CHECK-NEXT:10: r([B1.9]) (Member initializer)
+// WARNINGS-NEXT:11:  (CXXConstructExpr, class A)
+// ANALYZER-NEXT:11:  (CXXConstructExpr, [B1.12], class A)
+// CHECK-NEXT:12: A a;
 // CHECK-NEXT: Preds (2): B2 B3
 // CHECK-NEXT: Succs (1): B0
 // CHECK:[B2]
Index: clang/test/Analysis/designated-initializer.c
===
--- clang/test/Analysis/designated-initializer.c
+++ clang/test/Analysis/designated-initializer.c
@@ -31,11 +31,10 @@
 // CHECK:  11: struct LUQ var = {getUQ(), .uq.q.a = 100};
 // CHECK:  12: 1
 // CHECK:  13: 2
-// CHECK:  14: /*implicit*/(int)0
-// CHECK:  15: {[B1.12], [B1.13]}
+// CHECK:  14: {[B1.12], [B1.13]}
+// CHECK:  17: /*no init*/
 // CHECK:  18: /*no init*/
-// CHECK:  19: /*no init*/
-// CHECK:  20: 3
-// CHECK:  21: {[B1.18], [B1.19], [B1.20]}
-// CHECK:  22: {/*base*/[B1.17], /*updater*/[B1.21]} 
-// CHECK:  24: struct Q s[] = {[0] = (struct Q){1, 2}, [0].c = 3};
+// CHECK:  19: 3
+// CHECK:  20: {[B1.17], [B1.18], [B1.19]}
+// CHECK:  21: {/*base*/[B1.16], /*updater*/[B1.20]} 
+// CHECK:  23: struct Q s[] = {[0] = (struct Q){1, 2}, [0].c = 3};
Index: clang/test/Analysis/designated-initializer-values.c
===
--- /dev/null
+++ clang/test/Analysis/designated-initializer-values.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c99 -verify %s
+
+void clang_analyzer_eval(int);
+
+void array_init() {
+  int a[5] = {[4] = 29, [2] = 15, [0] = 4};
+  clang_analyzer_eval(a[0] == 4);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[2] == 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[3] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[4] == 29); // expected-warning{{TRUE}}
+  int b[5] = {[0 ... 2] = 1, [4] = 5};
+  clang_analyzer_eval(b[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[1] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[2] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[3] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[4] == 5); // expected-warning{{TRUE}}
+}
+
+struct point {
+  int x, y;
+};
+
+void struct_init() {
+  struct point p = {.y = 5, .x = 3};
+  clang_analyzer_eval(p.x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p.y == 5); // expected-warning{{TRUE}}
+}
+
+void array_of_struct() {
+  struct point ptarray[3] = { [2].y = 1, [2].x = 2, [0].x = 3 };
+  clang_analyzer_eval(ptarray[0].x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[0].y == 0); // expected-warning{{TRUE}}
+  

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 2 inline comments as done.
jdoerfert added a comment.

In D70258#1780611 , @ABataev wrote:

> Tests?


This changes the implementation and does not add features. Thus, this is 
covered by the existing tests for the functionality, e.g. the unit tests to 
build barriers and the front-end barrier test.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:51
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = std::function;
+

ABataev wrote:
> `llvm::function_ref`?
The lambda that is passed in here might go out of scope so we need to own it. 
This is intentional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D71345: [clangd] Fall back to selecting token-before-cursor if token-after-cursor fails.

2019-12-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

I tried to do a less general version of this (for go-to-definition only) in 
D70727  :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71345



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


[PATCH] D71378: Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-11 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: martong, teemperor.
Herald added a subscriber: rnkovacs.

This fix was motivated by a crashes in expression parsing during code 
generation in which we had a `RecordDecl` that had incomplete `FieldDecl`. 
During code generation when computing the layout for the `RecordDecl` we crash 
because we have several incomplete `FieldDecl`.

This fixes the issue by assuring that during `ImportDefinition(...)` for a 
`RecordDecl` we also import the definitions for each `FieldDecl`.


https://reviews.llvm.org/D71378

Files:
  clang/lib/AST/ASTImporter.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py

Index: lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
@@ -1,4 +1,4 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIf(bugnumber="rdar://53756116")])
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
@@ -0,0 +1,41 @@
+// This is a reproducer for a crash in codegen. It happens when we have a
+// RecordDecl used in an expression and one of the FieldDecl are not complete.
+// This case happens when:
+// - A RecordDecl (E) has a FieldDecl which is a reference member variable
+// - The underlying type of the FieldDec is a TypedefDecl
+// - The typedef refers to a ClassTemplateSpecialization (DWrapper)
+// - The typedef is not present in the DeclContext of B
+// - The typedef shows up as a return value of a member function of E (f())
+template 
+struct DWrapper {};
+
+struct D {};
+
+namespace NS {
+typedef DWrapper DW;
+}
+
+struct B {
+  NS::DW spd;
+  int a=0;
+};
+
+struct E {
+   E(B ): b_ref(b){}
+   NS::DW f(){ return {}; };
+   void g() {
+   return; //%self.expect("p b_ref", substrs=['(B) $0 =', '(spd = NS::DW', 'a = 0)'])
+   }
+
+   B _ref;
+};
+
+int main() {
+  B b;
+  E e(b);
+
+  e.g();
+
+  return 0;
+}
+
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1683,6 +1683,33 @@
   Error ChildErrors = Error::success();
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
+
+// If we are in the process of ImportDefinition(...) for a RecordDecl we
+// want to make sure that we are also completeing each FieldDecl. There
+// are currently cases where this does not happen and this is correctness
+// fix since operations such as code generation will expect this to be so.
+if (ImportedOrErr) {
+  FieldDecl *FieldFrom = dyn_cast_or_null(From);
+  Decl *ImportedDecl = (Decl*)*ImportedOrErr;
+  FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
+  if (FieldFrom && FieldTo) {
+const RecordType *RecordFrom = FieldFrom->getType()->getAs();
+const RecordType *RecordTo = FieldTo->getType()->getAs();
+if (RecordFrom && RecordTo) {
+  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
+  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+
+  if (FromRecordDecl->isCompleteDefinition() &&
+  !ToRecordDecl->isCompleteDefinition()) {
+Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);
+
+if (Err)
+  return Err;
+}
+}
+  }
+}
+
 if (!ImportedOrErr) {
   if 

[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Tests?




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:51
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = std::function;
+

`llvm::function_ref`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258



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


[PATCH] D62731: Add support for options -frounding-math, -ftrapping-math, -ffp-model=, and -ffp-exception-behavior=, : Specify floating point behavior

2019-12-11 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally added a comment.

In D62731#1779872 , @mibintc wrote:

> In D62731#1778597 , 
> @michele.scandale wrote:
>
> > >> I've noticed you removed the change for `CompilerInvocation.cpp` about 
> > >> the initialization of the codegen option `NoTrappingMath`. Was that an 
> > >> accident?
>
>
> Thanks again Michele.  I'd like to get rid of Opts.NoTrappingMath, but I 
> haven't been bold enough yet.


I don't see a problem with this, but it would be nice to make the 
`-f[no-]trapping-math` command line option work. GNU compatibility is good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62731



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


[PATCH] D70258: [OpenMP][IR-Builder] Introduce the finalization stack

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 233462.
jdoerfert added a comment.

rebase + ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70258

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -205,7 +205,8 @@
   // If we are in a cancellable parallel region, barriers are cancellation
   // points.
   // TODO: Check why we would force simple calls or to ignore the cancel flag.
-  bool UseCancelBarrier = !ForceSimpleCall && CancellationBlock;
+  bool UseCancelBarrier =
+  !ForceSimpleCall && isLastFinalizationInfoCancellable(OMPD_parallel);
 
   Value *Result = Builder.CreateCall(
   getOrCreateRuntimeFunction(UseCancelBarrier ? OMPRTL___kmpc_cancel_barrier
@@ -217,19 +218,22 @@
 BasicBlock *BB = Builder.GetInsertBlock();
 BasicBlock *NonCancellationBlock = BasicBlock::Create(
 BB->getContext(), BB->getName() + ".cont", BB->getParent());
+BasicBlock *CancellationBlock = BasicBlock::Create(
+BB->getContext(), BB->getName() + ".cncl", BB->getParent());
 
 // Jump to them based on the return value.
 Value *Cmp = Builder.CreateIsNull(Result);
 Builder.CreateCondBr(Cmp, NonCancellationBlock, CancellationBlock,
  /* TODO weight */ nullptr, nullptr);
 
-Builder.SetInsertPoint(NonCancellationBlock);
-assert(CancellationBlock->getParent() == BB->getParent() &&
-   "Unexpected cancellation block parent!");
+// From the cancellation block we finalize all variables and go to the
+// post finalization block that is known to the FiniCB callback.
+Builder.SetInsertPoint(CancellationBlock);
+auto  = FinalizationStack.back();
+FI.FiniCB(Builder.saveIP());
 
-// TODO: This is a workaround for now, we always reset the cancellation
-// block until we manage it ourselves here.
-CancellationBlock = nullptr;
+// The continuation block is where code generation continues.
+Builder.SetInsertPoint(NonCancellationBlock);
   }
 
   return Builder.saveIP();
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -37,12 +37,44 @@
   /// Add attributes known for \p FnID to \p Fn.
   void addAttributes(omp::RuntimeFunction FnID, Function );
 
-  /// Set the cancellation block to \p CBB.
-  void setCancellationBlock(BasicBlock *CBB) { CancellationBlock = CBB; }
-
   /// Type used throughout for insertion points.
   using InsertPointTy = IRBuilder<>::InsertPoint;
 
+  /// Callback type for variable finalization (think destructors).
+  ///
+  /// \param CodeGenIP is the insertion point at which the finalization code
+  ///  should be placed.
+  ///
+  /// A finalize callback knows about all objects that need finalization, e.g.
+  /// destruction, when the scope of the currently generated construct is left
+  /// at the time, and location, the callback is invoked.
+  using FinalizeCallbackTy = std::function;
+
+  struct FinalizationInfo {
+/// The finalization callback provided by the last in-flight invocation of
+/// Create for the directive of kind DK.
+FinalizeCallbackTy FiniCB;
+
+/// The directive kind of the innermost directive that has an associated
+/// region which might require finalization when it is left.
+omp::Directive DK;
+
+/// Flag to indicate if the directive is cancellable.
+bool IsCancellable;
+  };
+
+  /// Push a finalization callback on the finalization stack.
+  ///
+  /// NOTE: Temporary solution until Clang CG is gone.
+  void pushFinalizationCB(const FinalizationInfo ) {
+FinalizationStack.push_back(FI);
+  }
+
+  /// Pop the last finalization callback from the finalization stack.
+  ///
+  /// NOTE: Temporary solution until Clang CG is gone.
+  void popFinalizationCB() { FinalizationStack.pop_back(); }
+
   /// Description of a LLVM-IR insertion point (IP) and a debug/source location
   /// (filename, line, column, ...).
   struct LocationDescription {
@@ -112,6 +144,19 @@
 omp::Directive DK, bool ForceSimpleCall,
 bool CheckCancelFlag);
 
+  /// The finalization stack made up of finalize callbacks currently in-flight,
+  /// wrapped into FinalizationInfo objects that reference also the finalization
+  /// target block and the kind of cancellable directive.
+  SmallVector FinalizationStack;
+
+  /// Return true if the last entry in the finalization stack is of kind \p DK
+  /// and cancellable.
+  bool 

[PATCH] D71325: [Remarks][Driver] Ask for line tables when remarks are enabled

2019-12-11 Thread Francis Visoiu Mistrih via Phabricator via cfe-commits
thegameg updated this revision to Diff 233459.

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

https://reviews.llvm.org/D71325

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -64,6 +64,12 @@
 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
+// RUN: %clang -### -c -g -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE %s
 
 // FreeBSD.
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3717,6 +3717,11 @@
   // Adjust the debug info kind for the given toolchain.
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
+  // When emitting remarks, we need at least debug lines in the output.
+  if (shouldEmitRemarks(Args) &&
+  DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
+DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -64,6 +64,12 @@
 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
+// RUN: %clang -### -c -g -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE %s
 
 // FreeBSD.
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3717,6 +3717,11 @@
   // Adjust the debug info kind for the given toolchain.
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
+  // When emitting remarks, we need at least debug lines in the output.
+  if (shouldEmitRemarks(Args) &&
+  DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
+DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69471: [Coverage] Revise format to reduce binary size

2019-12-11 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Sorry for the delay here. An update: I tested this patch with a sanitized build 
on a Linux install, but could not reproduce the "malformed coverage data" 
errors seen on the Windows bots. At this point, it seems likely that there is a 
bug in CoverageMappingReader (this would explain why the .covmapping testing 
bundles fail to parse), and it may be that there is a separate issue on the 
producer side (this could explain why the 'instrprof-merging.cpp' test from 
`check-profile` failed). I think I need a Windows set up to debug further, and 
will try to find one. Meanwhile, if anyone has the bandwidth to attempt to 
reproduce on Windows, and to share a backtrace from where the 
`CoverageMapError` constructor is called, I would greatly appreciate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69471



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


[PATCH] D69922: [OpenMP] Use the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

> I applied D69853 , D69785 
> , D69922  
> to my local build and found that D69922  is 
> referring to OpenMPIRBuilder.h in llvm/Frontend whereas in D69785 
>  it was introduced in 
> llvm/Transforms/Utils/OpenMPIRBuilder.h

I merged the first few patches. There are some I'm still waiting for the green 
light but the location question is now settled.




Comment at: clang/include/clang/Driver/Options.td:1643-1644
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
+def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
+  HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">;
 def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > Do we need to expose this option to driver or it is enough to have just a 
> > > frontend option? If still need to have a driver option, add a test for 
> > > driver.
> > How do I write a frontend option? Anything that we can query in the 
> > lib/CodeGen is fine with me. (I don't even need an option if we turn this 
> > on by default to get test coverage right away).
> You nedd to move to CC1Options.td file. It means that you can't use it 
> direcly when invoke the drive, instead you will need to use `-Xclang 
> -fopenmp-...`
I think people will need to use it in the short term, having it here seems 
therefor better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69922



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


[PATCH] D69922: [OpenMP] Use the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3c06db45611: [OpenMP] Use the OpenMP-IR-Builder (authored 
by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D69922?vs=233448=233458#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69922

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fopenmp.c
  clang/test/OpenMP/barrier_codegen.cpp
  clang/test/OpenMP/cancel_codegen.cpp

Index: clang/test/OpenMP/cancel_codegen.cpp
===
--- clang/test/OpenMP/cancel_codegen.cpp
+++ clang/test/OpenMP/cancel_codegen.cpp
@@ -2,6 +2,10 @@
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s
+
 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
Index: clang/test/OpenMP/barrier_codegen.cpp
===
--- clang/test/OpenMP/barrier_codegen.cpp
+++ clang/test/OpenMP/barrier_codegen.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CLANGCG
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CLANGCG
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -mllvm -openmp-ir-builder-optimistic-attributes -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER_OPT
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -mllvm -openmp-ir-builder-optimistic-attributes -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER_OPT
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
@@ -34,6 +42,13 @@
   return tmain(argc) + tmain(argv[0][0]) + a;
 }
 
+// CLANGCG:declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+// CLANGCG-NOT:#
+// IRBUILDER:  ; Function Attrs: nounwind
+// IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #
+// IRBUILDER_OPT:  ; Function Attrs: nofree nosync nounwind readonly
+// IRBUILDER_OPT-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #
+
 // CHECK: define {{.+}} [[TMAIN_INT]](
 // CHECK: 

[clang] b3c06db - [OpenMP] Use the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2019-12-11T16:51:13-06:00
New Revision: b3c06db45611152f4ec22670bd83f4354078e6a7

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

LOG: [OpenMP] Use the OpenMP-IR-Builder

This is a follow up patch to use the OpenMP-IR-Builder, as discussed on
the mailing list ([1] and later) and at the US Dev Meeting'19.

[1] 
http://lists.flang-compiler.org/pipermail/flang-dev_lists.flang-compiler.org/2019-May/000197.html

Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, 
sdmitriev, JonChesterfield, hfinkel, fghanim

Subscribers: ppenzin, penzn, llvm-commits, cfe-commits, jfb, guansong, bollu, 
hiraditya, mgorny

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CMakeLists.txt
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/fopenmp.c
clang/test/OpenMP/barrier_codegen.cpp
clang/test/OpenMP/cancel_codegen.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 05d96b6c6a13..82372b098991 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -213,6 +213,7 @@ LANGOPT(OpenMPSimd, 1, 0, "Use SIMD only OpenMP 
support.")
 LANGOPT(OpenMPUseTLS  , 1, 0, "Use TLS for threadprivates or runtime 
calls")
 LANGOPT(OpenMPIsDevice, 1, 0, "Generate code only for OpenMP target 
device")
 LANGOPT(OpenMPCUDAMode, 1, 0, "Generate code for OpenMP pragmas in 
SIMT/SPMD mode")
+LANGOPT(OpenMPIRBuilder   , 1, 0, "Use the experimental OpenMP-IR-Builder 
codegen path.")
 LANGOPT(OpenMPCUDAForceFullRuntime , 1, 0, "Force to use full runtime in all 
constructs when offloading to CUDA devices")
 LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA devices.")
 LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA 
devices.")

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6f404d1f2ea5..b4ff681c70f8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1656,6 +1656,8 @@ def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_simd : Flag<["-"], "fopenmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
   HelpText<"Emit OpenMP code only for SIMD-based constructs.">;
+def fopenmp_enable_irbuilder : Flag<["-"], "fopenmp-enable-irbuilder">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>,
+  HelpText<"Use the experimental OpenMP-IR-Builder codegen path.">;
 def fno_openmp_simd : Flag<["-"], "fno-openmp-simd">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
 def fopenmp_cuda_mode : Flag<["-"], "fopenmp-cuda-mode">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index fda8dbe14db6..e3e9bd4284c3 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -23,6 +23,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SetOperations.h"
 #include "llvm/Bitcode/BitcodeReader.h"
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/Value.h"
@@ -3481,6 +3482,29 @@ void CGOpenMPRuntime::getDefaultScheduleAndChunk(
 void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction , SourceLocation Loc,
   OpenMPDirectiveKind Kind, bool 
EmitChecks,
   bool ForceSimpleCall) {
+  // Check if we should use the OMPBuilder
+  auto *OMPRegionInfo =
+  dyn_cast_or_null(CGF.CapturedStmtInfo);
+  llvm::OpenMPIRBuilder *OMPBuilder = CGF.CGM.getOpenMPIRBuilder();
+  if (OMPBuilder) {
+// TODO: Move cancelation point handling into the IRBuilder.
+if (EmitChecks && !ForceSimpleCall && OMPRegionInfo &&
+OMPRegionInfo->hasCancel() && CGF.Builder.GetInsertBlock()) {
+  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
+  llvm::BasicBlock *ExitBB = CGF.createBasicBlock(
+  ".cancel.exit", CGF.Builder.GetInsertBlock()->getParent());
+  OMPBuilder->setCancellationBlock(ExitBB);
+  CGF.Builder.SetInsertPoint(ExitBB);
+  CodeGenFunction::JumpDest CancelDestination =
+  CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
+  

[PATCH] D70268: [clang][clang-scan-deps] Aggregate the full dependency information.

2019-12-11 Thread Michael Spencer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf978ea498309: [clang][clang-scan-deps] Aggregate the full 
dependency information. (authored by Bigcheese).

Changed prior to commit:
  https://reviews.llvm.org/D70268?vs=233233=233455#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70268

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules_cdb.json
  clang/test/ClangScanDeps/modules-full.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -15,6 +15,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
@@ -129,6 +130,11 @@
 llvm::cl::init(ScanningOutputFormat::Make),
 llvm::cl::cat(DependencyScannerCategory));
 
+static llvm::cl::opt FullCommandLine(
+"full-command-line",
+llvm::cl::desc("Include the full command lines to use to build modules"),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -189,9 +195,10 @@
 /// based on the result.
 ///
 /// \returns True on error.
-static bool handleDependencyToolResult(const std::string ,
-   llvm::Expected ,
-   SharedStream , SharedStream ) {
+static bool
+handleMakeDependencyToolResult(const std::string ,
+   llvm::Expected ,
+   SharedStream , SharedStream ) {
   if (!MaybeFile) {
 llvm::handleAllErrors(
 MaybeFile.takeError(), [, ](llvm::StringError ) {
@@ -206,6 +213,184 @@
   return false;
 }
 
+static llvm::json::Array toJSONSorted(const llvm::StringSet<> ) {
+  std::vector Strings;
+  for (auto & : Set)
+Strings.push_back(I.getKey());
+  std::sort(Strings.begin(), Strings.end());
+  return llvm::json::Array(Strings);
+}
+
+static llvm::json::Array toJSONSorted(std::vector V) {
+  std::sort(V.begin(), V.end(),
+[](const ClangModuleDep , const ClangModuleDep ) {
+  return std::tie(A.ModuleName, A.ContextHash) <
+ std::tie(B.ModuleName, B.ContextHash);
+});
+
+  llvm::json::Array Ret;
+  for (const ClangModuleDep  : V)
+Ret.push_back(llvm::json::Object(
+{{"module-name", CMD.ModuleName}, {"context-hash", CMD.ContextHash}}));
+  return Ret;
+}
+
+// Thread safe.
+class FullDeps {
+public:
+  void mergeDeps(StringRef Input, FullDependenciesResult FDR,
+ size_t InputIndex) {
+const FullDependencies  = FDR.FullDeps;
+
+InputDeps ID;
+ID.FileName = Input;
+ID.ContextHash = std::move(FD.ContextHash);
+ID.FileDeps = std::move(FD.FileDeps);
+ID.ModuleDeps = std::move(FD.ClangModuleDeps);
+
+std::unique_lock ul(Lock);
+for (const ModuleDeps  : FDR.DiscoveredModules) {
+  auto I = Modules.find({MD.ContextHash, MD.ModuleName, 0});
+  if (I != Modules.end()) {
+I->first.InputIndex = std::min(I->first.InputIndex, InputIndex);
+continue;
+  }
+  Modules.insert(
+  I, {{MD.ContextHash, MD.ModuleName, InputIndex}, std::move(MD)});
+}
+
+if (FullCommandLine)
+  ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
+  [&](ClangModuleDep CMD) { return lookupPCMPath(CMD); },
+  [&](ClangModuleDep CMD) -> const ModuleDeps & {
+return lookupModuleDeps(CMD);
+  });
+
+Inputs.push_back(std::move(ID));
+  }
+
+  void printFullOutput(raw_ostream ) {
+// Sort the modules by name to get a deterministic order.
+std::vector ModuleNames;
+for (auto & : Modules)
+  ModuleNames.push_back(M.first);
+std::sort(ModuleNames.begin(), ModuleNames.end(),
+  [](const ContextModulePair , const ContextModulePair ) {
+return std::tie(A.ModuleName, A.InputIndex) <
+   std::tie(B.ModuleName, B.InputIndex);
+  });
+
+std::sort(Inputs.begin(), Inputs.end(),
+  [](const InputDeps , const InputDeps ) {
+return A.FileName < B.FileName;
+  });
+
+using namespace llvm::json;
+
+

[clang] f978ea4 - [clang][clang-scan-deps] Aggregate the full dependency information.

2019-12-11 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2019-12-11T14:40:51-08:00
New Revision: f978ea498309adaebab8fbf1cd6e520e7e0e11f1

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

LOG: [clang][clang-scan-deps] Aggregate the full dependency information.

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/modules_cdb.json
clang/test/ClangScanDeps/modules-full.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index a0c1900f7ed9..1c106ed4b765 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -11,13 +11,69 @@
 
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 
 namespace clang{
 namespace tooling{
 namespace dependencies{
 
+/// The full dependencies and module graph for a specific input.
+struct FullDependencies {
+  /// The name of the C++20 module this translation unit exports. This may
+  /// include `:` for C++20 module partitons.
+  ///
+  /// If the translation unit is not a module then this will be empty.
+  std::string ExportedModuleName;
+
+  /// The context hash represents the set of compiler options that may make one
+  /// version of a module incompatible with another. This includes things like
+  /// language mode, predefined macros, header search paths, etc...
+  ///
+  /// Modules with the same name but a 
diff erent \c ContextHash should be
+  /// treated as separate modules for the purpose of a build.
+  std::string ContextHash;
+
+  /// A collection of absolute paths to files that this translation unit
+  /// directly depends on, not including transitive dependencies.
+  std::vector FileDeps;
+
+  /// A list of modules this translation unit directly depends on, not 
including
+  /// transitive dependencies.
+  ///
+  /// This may include modules with a 
diff erent context hash when it can be
+  /// determined that the 
diff erences are benign for this compilation.
+  std::vector ClangModuleDeps;
+
+  /// A partial addtional set of command line arguments that can be used to
+  /// build this translation unit.
+  ///
+  /// Call \c getFullAdditionalCommandLine() to get a command line suitable for
+  /// appending to the original command line to pass to clang.
+  std::vector AdditionalNonPathCommandLine;
+
+  /// Gets the full addtional command line suitable for appending to the
+  /// original command line to pass to clang.
+  ///
+  /// \param LookupPCMPath this function is called to fill in `-fmodule-file=`
+  ///  flags and for the `-o` flag. It needs to return a
+  ///  path for where the PCM for the given module is to
+  ///  be located.
+  /// \param LookupModuleDeps this fucntion is called to collect the full
+  /// transitive set of dependencies for this
+  /// compilation.
+  std::vector getAdditionalCommandLine(
+  std::function LookupPCMPath,
+  std::function LookupModuleDeps) 
const;
+};
+
+struct FullDependenciesResult {
+  FullDependencies FullDeps;
+  std::vector DiscoveredModules;
+};
+
 /// The high-level implementation of the dependency discovery tool that runs on
 /// an individual worker thread.
 class DependencyScanningTool {
@@ -35,8 +91,23 @@ class DependencyScanningTool {
   getDependencyFile(const tooling::CompilationDatabase ,
 StringRef CWD);
 
+  /// Collect the full module depenedency graph for the input, ignoring any
+  /// modules which have already been seen.
+  ///
+  /// \param AlreadySeen this is used to not report modules that have 
previously
+  ///been reported. Use the same `llvm::StringSet<>` for 
all
+  ///calls to `getFullDependencies` for a single
+  ///`DependencyScanningTool` for a single build. Use a
+  ///
diff erent one for 
diff erent tools, and clear it between
+  ///   

[clang] db4c7ad - Suppress false-positive -Wuninitialized warnings in the constructor of a

2019-12-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-12-11T14:26:28-08:00
New Revision: db4c7adfa365282e8cb9a067c509fa711c4b96fe

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

LOG: Suppress false-positive -Wuninitialized warnings in the constructor of a
templated but non-template class.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/uninitialized.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 5373bb422ad6..ba4d450984a3 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3807,7 +3807,7 @@ namespace {
 
 const CXXRecordDecl *RD = Constructor->getParent();
 
-if (RD->getDescribedClassTemplate())
+if (RD->isDependentContext())
   return;
 
 // Holds fields that are uninitialized.

diff  --git a/clang/test/SemaCXX/uninitialized.cpp 
b/clang/test/SemaCXX/uninitialized.cpp
index 331a948eb6f1..63d5e7b92eac 100644
--- a/clang/test/SemaCXX/uninitialized.cpp
+++ b/clang/test/SemaCXX/uninitialized.cpp
@@ -1449,3 +1449,12 @@ void if_switch_init_stmt(int k) {
 
   switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} 
expected-note {{initialize}} expected-warning {{boolean}}
 }
+
+template struct Outer {
+  struct Inner {
+int a = 1;
+int b;
+Inner() : b(a) {}
+  };
+};
+Outer::Inner outerinner;



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


[PATCH] D70878: [analyzer] Add support for namespaces to GenericTaintChecker

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great but i keep worrying that you're re-inventing `CallDescription` 
which already supports this feature (and many more) and we really need a single 
implementation of this logic because it has been historically very annoying and 
bugprone. Like, if you can convert your configs to a `CallDescriptionMap<>` 
while loading that'd be awesome.




Comment at: clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp:396-407
+template 
+auto GenericTaintChecker::findFunctionInConfig(const ConfigDataMap ,
+   const FunctionData ) {
+  auto Range = Map.equal_range(FData.Name);
+  auto It =
+  std::find_if(Range.first, Range.second, [](const auto ) {
+const auto  = Entry.second;

 `Call`  `Description`  `Map` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70878



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


[PATCH] D70268: [clang][clang-scan-deps] Aggregate the full dependency information.

2019-12-11 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

Looks like the test for -full-command-line got dropped. I'll add that when I 
commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70268



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


[PATCH] D69922: [OpenMP] Use the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 233448.
jdoerfert marked 3 inline comments as done.
jdoerfert added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69922

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/fopenmp.c
  clang/test/OpenMP/barrier_codegen.cpp
  clang/test/OpenMP/cancel_codegen.cpp

Index: clang/test/OpenMP/cancel_codegen.cpp
===
--- clang/test/OpenMP/cancel_codegen.cpp
+++ clang/test/OpenMP/cancel_codegen.cpp
@@ -2,6 +2,10 @@
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck %s
+
 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple x86_64-apple-darwin13.4.0 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -triple x86_64-apple-darwin13.4.0 -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
Index: clang/test/OpenMP/barrier_codegen.cpp
===
--- clang/test/OpenMP/barrier_codegen.cpp
+++ clang/test/OpenMP/barrier_codegen.cpp
@@ -1,6 +1,14 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,CLANGCG
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CLANGCG
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -mllvm -openmp-ir-builder-optimistic-attributes -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER_OPT
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fopenmp-enable-irbuilder -mllvm -openmp-ir-builder-optimistic-attributes -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,IRBUILDER_OPT
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
@@ -34,6 +42,13 @@
   return tmain(argc) + tmain(argv[0][0]) + a;
 }
 
+// CLANGCG:declare i32 @__kmpc_global_thread_num(%struct.ident_t*)
+// CLANGCG-NOT:#
+// IRBUILDER:  ; Function Attrs: nounwind
+// IRBUILDER-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #
+// IRBUILDER_OPT:  ; Function Attrs: nofree nosync nounwind readonly
+// IRBUILDER_OPT-NEXT: declare i32 @__kmpc_global_thread_num(%struct.ident_t*) #
+
 // CHECK: define {{.+}} [[TMAIN_INT]](
 // CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT_T]]* [[LOC]])
 // CHECK: call void @__kmpc_barrier([[IDENT_T]]* 

[PATCH] D70854: [Clang] In tests, do not always assume others permissions are set

2019-12-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think we should remove it.


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

https://reviews.llvm.org/D70854



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


[clang] e0e07a7 - Fix detection of __attribute__((may_alias)) to properly look through

2019-12-11 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2019-12-11T14:04:37-08:00
New Revision: e0e07a7e414e818788144511de0c6328285c43cd

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

LOG: Fix detection of __attribute__((may_alias)) to properly look through
type sugar.

We previously missed the attribute in a lot of cases in C++, because
there's often other type sugar there (eg, ElaboratedType).

Added: 
clang/test/CodeGenCXX/may_alias.cpp

Modified: 
clang/lib/CodeGen/CodeGenTBAA.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTBAA.cpp 
b/clang/lib/CodeGen/CodeGenTBAA.cpp
index 09de9591de7e..7d730cb1ed15 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -78,17 +78,18 @@ llvm::MDNode *CodeGenTBAA::getChar() {
 
 static bool TypeHasMayAlias(QualType QTy) {
   // Tagged types have declarations, and therefore may have attributes.
-  if (const TagType *TTy = dyn_cast(QTy))
-return TTy->getDecl()->hasAttr();
+  if (auto *TD = QTy->getAsTagDecl())
+if (TD->hasAttr())
+  return true;
 
-  // Typedef types have declarations, and therefore may have attributes.
-  if (const TypedefType *TTy = dyn_cast(QTy)) {
-if (TTy->getDecl()->hasAttr())
+  // Also look for may_alias as a declaration attribute on a typedef.
+  // FIXME: We should follow GCC and model may_alias as a type attribute
+  // rather than as a declaration attribute.
+  while (auto *TT = QTy->getAs()) {
+if (TT->getDecl()->hasAttr())
   return true;
-// Also, their underlying types may have relevant attributes.
-return TypeHasMayAlias(TTy->desugar());
+QTy = TT->desugar();
   }
-
   return false;
 }
 

diff  --git a/clang/test/CodeGenCXX/may_alias.cpp 
b/clang/test/CodeGenCXX/may_alias.cpp
new file mode 100644
index ..fbc4e22e731f
--- /dev/null
+++ b/clang/test/CodeGenCXX/may_alias.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 %s -triple %itanium_abi_triple -emit-llvm -O2 
-disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple %ms_abi_triple -emit-llvm -O2 
-disable-llvm-passes -o - | FileCheck %s
+
+enum class __attribute__((may_alias)) E {};
+
+template struct A {
+  using B __attribute__((may_alias)) = enum {};
+};
+
+template using Alias = typename A::B;
+
+// CHECK-LABEL: define {{.*}}foo
+// CHECK: load i{{[0-9]*}}, {{.*}}, !tbaa ![[MAY_ALIAS:[^ ,]*]]
+auto foo(E ) { return r; }
+
+// CHECK-LABEL: define {{.*}}goo
+// CHECK: load i{{[0-9]*}}, {{.*}}, !tbaa ![[MAY_ALIAS]]
+auto goo(A::B ) { return r; }
+
+// CHECK-LABEL: define {{.*}}hoo
+// CHECK: load i{{[0-9]*}}, {{.*}}, !tbaa ![[MAY_ALIAS]]
+auto hoo(Alias ) { return r; }
+
+// CHECK: ![[CHAR:.*]] = !{!"omnipotent char", !{{.*}}, i64 0}
+// CHECK: ![[MAY_ALIAS]] = !{![[CHAR]], ![[CHAR]], i64 0}



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


[PATCH] D69770: [APFloat] Add recoverable string parsing errors to APFloat

2019-12-11 Thread Ehud Katz via Phabricator via cfe-commits
ekatz added a comment.

Ping


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

https://reviews.llvm.org/D69770



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2019-12-11 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added inline comments.



Comment at: clang/lib/AST/Decl.cpp:3006
 
+bool FunctionDecl::isReplaceableSystemFunction() const {
+  FunctionDecl const *Definition;

serge-sans-paille wrote:
> george.burgess.iv wrote:
> > serge-sans-paille wrote:
> > > Note to reviewers: I'm not super happy with that name.
> > Yeah, `isReplaceableBuiltin()` sounds like "can this be replaced at all?" 
> > rather than "is this acting as a replacement for something else?"
> > 
> > `isReplacementForBuiltin()` pops to mind, though in a lot of cases, these 
> > functions may end up calling the "actual" builtin (as you handle later in 
> > the patch), so maybe `isProxyForBuiltin()` is better?
> What about `isBuiltInWrapper()` ?
WFM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I doubt we'll ever need these callbacks. I can't imagine any kind of analysis 
that would need them. Like, these statements have absolutely no effect on the 
runtime program state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71371



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


[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Hmm loops. Right. So this solution is insufficient because it can prevent 
legitimate caching out in loops.

If we remove those initializers from the CFG wouldn't we loose the Pre/PostStmt 
callbacks? Is that acceptable? If not, we might need to create a new program 
point :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71371



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


[clang] 0b97894 - [OPENMP50]Add if clause in teams distribute parallel for simd directive.

2019-12-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-12-11T16:11:41-05:00
New Revision: 0b9789456b616863ab4dd045a977758f527bab8b

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

LOG: [OPENMP50]Add if clause in teams distribute parallel for simd directive.

According to OpenMP 5.0, if clause can be used in for simd directive. If
condition in the if clause if false, the non-vectorized version of the
loop must be executed.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_if_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_if_messages.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e23abdd385fe..3c266a5a3149 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4621,7 +4621,8 @@ void 
CodeGenFunction::EmitOMPTeamsDistributeParallelForSimdDirective(
 CGF, OMPD_distribute, CodeGenDistribute, /*HasCancel=*/false);
 CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_teams);
   };
-  emitCommonOMPTeamsDirective(*this, S, OMPD_distribute_parallel_for, CodeGen);
+  emitCommonOMPTeamsDirective(*this, S, OMPD_distribute_parallel_for_simd,
+  CodeGen);
   emitPostUpdateForReductionClause(*this, S,
[](CodeGenFunction &) { return nullptr; });
 }

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 91d76e648613..d876f04192b0 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4748,6 +4748,8 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 Res = ActOnOpenMPTeamsDistributeParallelForSimdDirective(
 ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
 AllowedNameModifiers.push_back(OMPD_parallel);
+if (LangOpts.OpenMP >= 50)
+  AllowedNameModifiers.push_back(OMPD_simd);
 break;
   case OMPD_teams_distribute_parallel_for:
 Res = ActOnOpenMPTeamsDistributeParallelForDirective(
@@ -10724,8 +10726,14 @@ static OpenMPDirectiveKind 
getOpenMPCaptureRegionForClause(
   if (NameModifier == OMPD_unknown || NameModifier == OMPD_parallel)
 CaptureRegion = OMPD_teams;
   break;
-case OMPD_teams_distribute_parallel_for:
 case OMPD_teams_distribute_parallel_for_simd:
+  if (OpenMPVersion >= 50 &&
+  (NameModifier == OMPD_unknown || NameModifier == OMPD_simd)) {
+CaptureRegion = OMPD_parallel;
+break;
+  }
+  LLVM_FALLTHROUGH;
+case OMPD_teams_distribute_parallel_for:
   CaptureRegion = OMPD_teams;
   break;
 case OMPD_target_update:

diff  --git 
a/clang/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp 
b/clang/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
index f16ea09f17de..099696142492 100644
--- a/clang/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
+++ b/clang/test/OpenMP/teams_distribute_parallel_for_simd_ast_print.cpp
@@ -1,10 +1,16 @@
-// RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s -Wno-openmp-mapping | 
FileCheck %s --check-prefix CHECK --check-prefix OMP45
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print -Wno-openmp-mapping | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix CHECK 
--check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s 
-Wno-openmp-mapping | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch 
%t -fsyntax-only -verify %s -ast-print -Wno-openmp-mapping | FileCheck %s 
--check-prefix CHECK --check-prefix OMP50
 
-// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s -Wno-openmp-mapping | 
FileCheck %s --check-prefix CHECK --check-prefix OMP45
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only 
-verify %s -ast-print -Wno-openmp-mapping | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only 
-verify %s -ast-print -Wno-openmp-mapping | FileCheck %s --check-prefix CHECK 

[PATCH] D71111: [Sema] Improve diagnostic about addr spaces for overload candidates

2019-12-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3838
+"'this' object is in address space %3, but method expects object in "
+"address space %4">;
 def note_ovl_candidate_bad_gc : Note<

I think you need to move "address space" into the diagnostic rendering for 
`ak_addrspace` so that you can say "generic address space" instead of "address 
space generic".



Comment at: clang/lib/AST/TypePrinter.cpp:1776
+  if (AS != LangAS::Default) {
+if (AS != LangAS::opencl_private) {
+  switch (AS) {

Can you just make these two cases in the switch?  `opencl_private` already 
seems to be there.


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

https://reviews.llvm.org/D7



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


[PATCH] D71374: Improve support of GNU mempcpy

2019-12-11 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

On going validation: 
https://github.com/serge-sans-paille/llvm-project/pull/5/checks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71374



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


[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2019-12-11 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked an inline comment as done.
serge-sans-paille added inline comments.



Comment at: clang/lib/AST/Decl.cpp:3006
 
+bool FunctionDecl::isReplaceableSystemFunction() const {
+  FunctionDecl const *Definition;

george.burgess.iv wrote:
> serge-sans-paille wrote:
> > Note to reviewers: I'm not super happy with that name.
> Yeah, `isReplaceableBuiltin()` sounds like "can this be replaced at all?" 
> rather than "is this acting as a replacement for something else?"
> 
> `isReplacementForBuiltin()` pops to mind, though in a lot of cases, these 
> functions may end up calling the "actual" builtin (as you handle later in the 
> patch), so maybe `isProxyForBuiltin()` is better?
What about `isBuiltInWrapper()` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D70836: [analysis] Fix value tracking for pointers to qualified types

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Hmm, it was supposed to get a green tick mark. Let me re-accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70836



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


[PATCH] D71374: Improve support of GNU mempcpy

2019-12-11 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added a reviewer: ddunbar.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Lower to the memcpy intrinsic
- Raise warnings when size/bounds are known


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71374

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Analysis/bstring.c

Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -222,6 +222,9 @@
   char dst[1];
 
   mempcpy(dst, src, 4); // expected-warning{{Memory copy function overflows destination buffer}}
+#ifndef VARIANT
+// expected-warning@-2{{'mempcpy' will always overflow; destination buffer has size 1, but size argument is 4}}
+#endif
 }
 
 void mempcpy3 () {
@@ -243,6 +246,9 @@
   char dst[3];
 
   mempcpy(dst+2, src+2, 2); // expected-warning{{Memory copy function overflows destination buffer}}
+#ifndef VARIANT
+// expected-warning@-2{{'mempcpy' will always overflow; destination buffer has size 1, but size argument is 2}}
+#endif
 }
 
 void mempcpy6() {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -340,7 +340,8 @@
   case Builtin::BI__builtin___strncat_chk:
   case Builtin::BI__builtin___strncpy_chk:
   case Builtin::BI__builtin___stpncpy_chk:
-  case Builtin::BI__builtin___memccpy_chk: {
+  case Builtin::BI__builtin___memccpy_chk:
+  case Builtin::BI__builtin___mempcpy_chk: {
 DiagID = diag::warn_builtin_chk_overflow;
 IsChkVariant = true;
 SizeIndex = TheCall->getNumArgs() - 2;
@@ -379,7 +380,9 @@
   case Builtin::BImemmove:
   case Builtin::BI__builtin_memmove:
   case Builtin::BImemset:
-  case Builtin::BI__builtin_memset: {
+  case Builtin::BI__builtin_memset:
+  case Builtin::BImempcpy:
+  case Builtin::BI__builtin_mempcpy: {
 DiagID = diag::warn_fortify_source_overflow;
 SizeIndex = TheCall->getNumArgs() - 1;
 ObjectIndex = 0;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2506,7 +2506,9 @@
 return RValue::get(nullptr);
   }
   case Builtin::BImemcpy:
-  case Builtin::BI__builtin_memcpy: {
+  case Builtin::BI__builtin_memcpy:
+  case Builtin::BImempcpy:
+  case Builtin::BI__builtin_mempcpy: {
 Address Dest = EmitPointerWithAlignment(E->getArg(0));
 Address Src = EmitPointerWithAlignment(E->getArg(1));
 Value *SizeVal = EmitScalarExpr(E->getArg(2));
@@ -2515,7 +2517,11 @@
 EmitNonNullArgCheck(RValue::get(Src.getPointer()), E->getArg(1)->getType(),
 E->getArg(1)->getExprLoc(), FD, 1);
 Builder.CreateMemCpy(Dest, Src, SizeVal, false);
-return RValue::get(Dest.getPointer());
+if (BuiltinID == Builtin::BImempcpy ||
+BuiltinID == Builtin::BI__builtin_mempcpy)
+  return RValue::get(Dest.getPointer());
+else
+  return RValue::get(Builder.CreateGEP(Dest.getPointer(), SizeVal));
   }
 
   case Builtin::BI__builtin_char_memchr:
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3866,6 +3866,11 @@
   case Builtin::BImemcpy:
 return Builtin::BImemcpy;
 
+  case Builtin::BI__builtin_mempcpy:
+  case Builtin::BI__builtin___mempcpy_chk:
+  case Builtin::BImempcpy:
+return Builtin::BImempcpy;
+
   case Builtin::BI__builtin_memmove:
   case Builtin::BI__builtin___memmove_chk:
   case Builtin::BImemmove:
@@ -3923,6 +3928,8 @@
 return Builtin::BImemset;
   else if (FnInfo->isStr("memcpy"))
 return Builtin::BImemcpy;
+  else if (FnInfo->isStr("mempcpy"))
+return Builtin::BImempcpy;
   else if (FnInfo->isStr("memmove"))
 return Builtin::BImemmove;
   else if (FnInfo->isStr("memcmp"))
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -984,6 +984,7 @@
 LIBBUILTIN(alloca, "v*z", "f", "stdlib.h", ALL_GNU_LANGUAGES)
 // POSIX string.h
 LIBBUILTIN(memccpy, "v*v*vC*iz",  "f", "string.h", ALL_GNU_LANGUAGES)
+LIBBUILTIN(mempcpy, "v*v*vC*z",   "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(stpcpy, "c*c*cC*", "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(stpncpy, "c*c*cC*z",   "f", "string.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(strdup, "c*cC*",   "f", "string.h", ALL_GNU_LANGUAGES)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D70854: [Clang] In tests, do not always assume others permissions are set

2019-12-11 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Yes this was added in rG18627115f4d2db5dc73207e0b5312f52536be7dd 
 and 
rGe08b59f81d950bd5c8b8528fcb3ac4230c7b736c 
. It looks 
like it was only there to validate that specific refactoring.
Should I remove these two files, or simply commit the previous diff? (ie. 
-rw-rw)


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

https://reviews.llvm.org/D70854



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


[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

One way to criticize the current solution would be to put an `InitListExpr` in 
a loop and immediately discard it and see how states after different numbers of 
iterations no longer join together only because they have different 
`NoCachingOutForConsts` values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71371



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd23c61490c28: [OpenMP] Introduce the OpenMP-IR-Builder 
(authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/CMakeLists.txt
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/CMakeLists.txt
  llvm/unittests/Frontend/CMakeLists.txt
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,178 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder 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
+//
+//===--===//
+
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy =
+FunctionType::get(Type::getVoidTy(Ctx), {Type::getInt32Ty(Ctx)},
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+
+DIBuilder DIB(*M);
+auto File = DIB.createFile("test.dbg", "/");
+auto CU =
+DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+auto SP = DIB.createFunction(
+CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+F->setSubprogram(SP);
+auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+DIB.finalize();
+DL = DebugLoc::get(3, 7, Scope);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+  DebugLoc DL;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 1U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 3U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotAccessMemory());
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotFreeMemory());
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+  EXPECT_FALSE(Barrier->getCalledFunction()->doesNotAccessMemory());
+  EXPECT_FALSE(Barrier->getCalledFunction()->doesNotFreeMemory());
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, CreateCancelBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
+  new UnreachableInst(Ctx, CBB);
+  OMPBuilder.setCancellationBlock(CBB);
+
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  auto NewIP = OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  Builder.restoreIP(NewIP);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 3U);
+  EXPECT_EQ(F->size(), 3U);
+  EXPECT_EQ(BB->size(), 4U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+  

[PATCH] D70469: [attributes] [analyzer] Add handle related attributes

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7424
+ ParsedAttr ) {
+  if (CurType->isFunctionType()) {
+State.getSema().Diag(Attr.getLoc(), diag::warn_type_attribute_wrong_type)

xazax.hun wrote:
> aaron.ballman wrote:
> > xazax.hun wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > Is this correct, or should it be `if (!CurType->isFunctionType())`?
> > > > I see now that this is only incorrect for the acquire attribute, but 
> > > > not the other two.
> > > I think we might consider it incorrect for the acquire as well. Because 
> > > if we let the user put acquire on the function, it is ambiguous where to 
> > > put the annotation. If we do not let them put on the function they are 
> > > always forced to put on the return type to express this. But in case this 
> > > kind of ambiguity is a feature and not a bug I can change the behavior.
> > I guess I was considering the semantics as being acquire on a function type 
> > applies to the non-void return value being the handle and release on a 
> > function type applies to the only parameter being passed to the function.
> > 
> > I don't think it makes sense to apply acquire or release semantics to a 
> > handle type itself because that's not really part of the type identity 
> > itself (it's not an "acquiring handle" or a "releasing handle" -- I would 
> > think it's *both* at the same time), so I think that's been throwing me for 
> > a loop with the latest round of patches here. What I was imagining was that 
> > you should mark any place a handle is created or released, which works 
> > almost-fine for parameters (because you can mark the parameter declarations 
> > with an attribute). It doesn't quite work for function pointers, however, 
> > because those don't have parameters. e.g., `void 
> > (*fp)([[clang::acquire_handle]] int &)` won't do what you expect, I 
> > believe. However, for functions which return the acquired handle, there is 
> > no good place to write the attribute except on the function itself 
> > (because, again, it's not a property of the return type, but of the 
> > specific function's return type). For those cases, I imagine you want the 
> > function *type* to be what codifies that a handle is returned, because then 
> > it will work with function pointers. For *using* a handle, I'm not certain 
> > what the benefit is to having an attribute on each use -- that seems likely 
> > for a user to forget to add an annotation somewhere and get incorrect 
> > behavior. I would normally suggest that the attribute be applied to the 
> > type declaration of the handle (e.g., through a typedef), but if you want 
> > this to work with handles coming from system headers (like file descriptors 
> > or sockets, etc) then will this approach work?
> Hmm. The problem is that a function might do multiple things with multiple 
> handles, for example in Fuchsia there are functions that replacing a handle 
> with another one. So I am afraid naively putting the attributes on the 
> function type might end up being ambiguous sometimes. I totally agree with 
> your argument about the annotation not being part of the type identity. If we 
> do want to put this on the function type maybe we could do something similar 
> to `nonnull` and enumerate parameter indices? What do you think? 
> 
> The `use` annotation might be a bit misleading. The user does not necessarily 
> need to annotate all uses.
> Let's consider the following function and a call:
> ```
> void f(int *handle);
> close_handle(handle);
> f(); // What will this do?
> ```
> 
> The function `f` would be free to do anything, like store the address of the 
> handle in a global data structure, overwrite the closed handle and so on. The 
> purpose of the `use` annotation is to tell the analyzer that none of this 
> will happen, so we can safely diagnose a use after release. So the original 
> idea was to annotate those functions that are guaranteed to never close, 
> overwrite etc the handle.
> For unannotated functions the analyzer will be conservative and assume that 
> the code is OK. 
I heard that type attributes are relatively scary and require a lot of work to 
implement, and `nonnull`/`_Nonnull` is definitely one of the historical 
examples of why they're scary. Like, you don't want to mess with the type 
system and find yourself explaining whether it's still the same type or a 
different type simply because it wears an attribute. Declaration attributes are 
much more straightforward in this sense.


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

https://reviews.llvm.org/D70469



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


[PATCH] D71301: [clang][IFS] Prevent Clang-IFS from Leaking symbols from inside a block.

2019-12-11 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 233435.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71301

Files:
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/test/InterfaceStubs/blocks.c
  clang/test/InterfaceStubs/lambda.cpp


Index: clang/test/InterfaceStubs/lambda.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/lambda.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-interface-stubs -o - %s | FileCheck %s
+
+// CHECK: --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT:   "f" : { Type: Object, Size: 1 }
+// CHECK-NEXT: ...
+auto f = [](void* data) { int i; };
Index: clang/test/InterfaceStubs/blocks.c
===
--- /dev/null
+++ clang/test/InterfaceStubs/blocks.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-interface-stubs -fblocks -o - %s | FileCheck %s
+
+// CHECK: --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+static void (^f)(void*) = ^(void* data) { int i; };
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -52,6 +52,14 @@
   if (!isVisible(ND))
 return true;
 
+  if (const VarDecl *VD = dyn_cast(ND))
+if (const auto *Parent = VD->getParentFunctionOrMethod()) {
+  if (const auto *BD = dyn_cast_or_null(Parent))
+return true;
+  if (const auto *MD = dyn_cast_or_null(Parent))
+return true;
+}
+
   if (const VarDecl *VD = dyn_cast(ND))
 if ((VD->getStorageClass() == StorageClass::SC_Extern) ||
 (VD->getStorageClass() == StorageClass::SC_Static &&


Index: clang/test/InterfaceStubs/lambda.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/lambda.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-interface-stubs -o - %s | FileCheck %s
+
+// CHECK: --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT:   "f" : { Type: Object, Size: 1 }
+// CHECK-NEXT: ...
+auto f = [](void* data) { int i; };
Index: clang/test/InterfaceStubs/blocks.c
===
--- /dev/null
+++ clang/test/InterfaceStubs/blocks.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-interface-stubs -fblocks -o - %s | FileCheck %s
+
+// CHECK: --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+static void (^f)(void*) = ^(void* data) { int i; };
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -52,6 +52,14 @@
   if (!isVisible(ND))
 return true;
 
+  if (const VarDecl *VD = dyn_cast(ND))
+if (const auto *Parent = VD->getParentFunctionOrMethod()) {
+  if (const auto *BD = dyn_cast_or_null(Parent))
+return true;
+  if (const auto *MD = dyn_cast_or_null(Parent))
+return true;
+}
+
   if (const VarDecl *VD = dyn_cast(ND))
 if ((VD->getStorageClass() == StorageClass::SC_Extern) ||
 (VD->getStorageClass() == StorageClass::SC_Static &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71317: [clang][IFS] Prevent Clang-IFS from Leaking symbols from inside a block.

2019-12-11 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi abandoned this revision.
plotfi added a comment.

Abandoning. Duplicate diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71317



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 2 inline comments as done.
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:74
+///
+///{
+namespace types {

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > Extra comments?
> > I don't know what you want to tell me.
> I mean, you have this `///{` here. Do you need it?
Yes, to help the doxygen documentation.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:174-177
+if (auto *IdentI = dyn_cast(Ident))
+  Call->moveAfter(IdentI);
+else
+  Call->moveBefore(&*Fn->getEntryBlock().getFirstInsertionPt());

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > Are you sure it will work correctly with late outlining?
> > Yes.
> Ah, the code fro threadid changed already, probably missed it.
I removed the TODOs now, including the caching.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D70401: [WIP][RISCV] Implement ilp32e ABI

2019-12-11 Thread Luís Marques via Phabricator via cfe-commits
luismarques added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVCallingConv.td:36
+// The only physical register that isn't saved is x2 (SP), which is used by the
+// processor when the interrupt happens.
+

Nitpick: "the interrupt happens" -> "an interrupt happens" (or, even better, 
"is serviced").



Comment at: llvm/test/CodeGen/RISCV/calling-conv-ilp32e-double-bug.ll:1
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -target-abi ilp32e -mattr=+f -verify-machineinstrs 
< %s

It would be good to describe in a comment what the bug is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401



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


[PATCH] D70872: [clangd] Implement "textDocument/documentLink" protocol support

2019-12-11 Thread Michael Forster via Phabricator via cfe-commits
MForster updated this revision to Diff 233433.
MForster marked an inline comment as not done.
MForster added a comment.

Adress review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70872

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/test/document-link.test
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1048,6 +1048,27 @@
   }
 }
 
+TEST(DocumentLinks, All) {
+  Annotations MainCpp(R"cpp(
+  #include $foo[["foo.h"]]
+  int end_of_preamble = 0;
+  #include $bar[["bar.h"]]
+)cpp");
+
+  TestTU TU;
+  TU.Code = MainCpp.code();
+  TU.AdditionalFiles = {{"foo.h", ""}, {"bar.h", ""}};
+  auto AST = TU.build();
+
+  EXPECT_THAT(
+  clangd::getDocumentLinks(AST),
+  ElementsAre(
+  DocumentLink({MainCpp.range("foo"),
+URIForFile::canonicalize(testPath("foo.h"), "")}),
+  DocumentLink({MainCpp.range("bar"),
+URIForFile::canonicalize(testPath("bar.h"), "")})));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -18,6 +18,9 @@
 # CHECK-NEXT:  "definitionProvider": true,
 # CHECK-NEXT:  "documentFormattingProvider": true,
 # CHECK-NEXT:  "documentHighlightProvider": true,
+# CHECK-NEXT:  "documentLinkProvider": {
+# CHECK-NEXT:"resolveProvider": false
+# CHECK-NEXT:  }
 # CHECK-NEXT:  "documentOnTypeFormattingProvider": {
 # CHECK-NEXT:"firstTriggerCharacter": "\n",
 # CHECK-NEXT:"moreTriggerCharacter": []
Index: clang-tools-extra/clangd/test/document-link.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/document-link.test
@@ -0,0 +1,42 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"#include \n#include "}}}
+---
+{"jsonrpc":"2.0","id":2,"method":"textDocument/documentLink","params":{"textDocument":{"uri":"test:///main.cpp"}}}
+#  CHECK:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 9,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "target": "file://{{.*}}/stdint.h"
+# CHECK-NEXT:},
+# CHECK-NEXT:{
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 19,
+# CHECK-NEXT:  "line": 1
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 9,
+# CHECK-NEXT:  "line": 1
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "target": "file://{{.*}}/stddef.h"
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+# CHECK-NEXT:}
+
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -49,6 +49,9 @@
 std::vector locateSymbolAt(ParsedAST , Position Pos,
   const SymbolIndex *Index = nullptr);
 
+/// Get all document links
+std::vector getDocumentLinks(ParsedAST );
+
 /// Returns highlights for all usages of a symbol at \p Pos.
 std::vector findDocumentHighlights(ParsedAST ,
   Position Pos);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -166,6 +166,26 @@
 
 } // namespace
 
+std::vector 

[PATCH] D70872: [clangd] Implement "textDocument/documentLink" protocol support

2019-12-11 Thread Michael Forster via Phabricator via cfe-commits
MForster marked 6 inline comments as done.
MForster added a comment.

I think I addressed all review comments. PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70872



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:74
+///
+///{
+namespace types {

jdoerfert wrote:
> ABataev wrote:
> > Extra comments?
> I don't know what you want to tell me.
I mean, you have this `///{` here. Do you need it?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:174-177
+if (auto *IdentI = dyn_cast(Ident))
+  Call->moveAfter(IdentI);
+else
+  Call->moveBefore(&*Fn->getEntryBlock().getFirstInsertionPt());

jdoerfert wrote:
> ABataev wrote:
> > Are you sure it will work correctly with late outlining?
> Yes.
Ah, the code fro threadid changed already, probably missed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D70520: [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

2019-12-11 Thread Sam Clegg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sbc100 marked an inline comment as done.
Closed by commit rG881d877846e2: [WebAssembly] Add new `export_name` clang 
attribute for controlling wasm export… (authored by sbc100).

Changed prior to commit:
  https://reviews.llvm.org/D70520?vs=232673=233432#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70520

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  lld/docs/WebAssembly.rst
  lld/test/wasm/export-name.ll
  lld/wasm/InputChunks.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/include/llvm/Object/Wasm.h
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/test/CodeGen/WebAssembly/export-name.ll
  llvm/test/MC/WebAssembly/export-name.s

Index: llvm/test/MC/WebAssembly/export-name.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
+# Check that it also comiled to object for format.
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
+
+foo:
+.globl foo
+.functype foo () -> ()
+.export_name foo, bar
+end_function
+
+# CHECK: .export_name foo, bar
+
+# CHECK-OBJ:- Type:EXPORT
+# CHECK-OBJ-NEXT: Exports:
+# CHECK-OBJ-NEXT:   - Name:bar
+# CHECK-OBJ-NEXT: Kind:FUNCTION
+# CHECK-OBJ-NEXT: Index:   0
+
+# CHECK-OBJ:  Name:linking
+# CHECK-OBJ-NEXT: Version: 2
+# CHECK-OBJ-NEXT: SymbolTable:
+# CHECK-OBJ-NEXT:   - Index:   0
+# CHECK-OBJ-NEXT: Kind:FUNCTION
+# CHECK-OBJ-NEXT: Name:foo
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Function:0
Index: llvm/test/CodeGen/WebAssembly/export-name.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/export-name.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define void @test() #0 {
+  ret void
+}
+
+declare void @test2() #1
+
+
+attributes #0 = { "wasm-export-name"="foo" }
+attributes #1 = { "wasm-export-name"="bar" }
+
+; CHECK: .export_name test, foo
+; CHECK: .export_name test2, bar
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -96,8 +96,11 @@
   }
 
   for (const auto  : M) {
+if (F.isIntrinsic())
+  continue;
+
 // Emit function type info for all undefined functions
-if (F.isDeclarationForLinker() && !F.isIntrinsic()) {
+if (F.isDeclarationForLinker()) {
   SmallVector Results;
   SmallVector Params;
   computeSignatureVTs(F.getFunctionType(), F, TM, Params, Results);
@@ -130,6 +133,13 @@
 getTargetStreamer()->emitImportName(Sym, Name);
   }
 }
+
+if (F.hasFnAttribute("wasm-export-name")) {
+  auto *Sym = cast(getSymbol());
+  StringRef Name = F.getFnAttribute("wasm-export-name").getValueAsString();
+  Sym->setExportName(Name);
+  getTargetStreamer()->emitExportName(Sym, Name);
+}
   }
 
   for (const auto  : M.globals()) {
Index: llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
===
--- llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
+++ llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
@@ -48,6 +48,9 @@
   /// .import_name
   virtual void emitImportName(const MCSymbolWasm *Sym,
   StringRef ImportName) = 0;
+  /// .export_name
+  virtual void emitExportName(const MCSymbolWasm *Sym,
+  StringRef ExportName) = 0;
 
 protected:
   void emitValueType(wasm::ValType Type);
@@ -68,6 +71,7 @@
   void emitEventType(const MCSymbolWasm *Sym) override;
   void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
   void emitImportName(const 

[PATCH] D71224: [analyzer] Escape symbols stored into specific region after a conservative evalcall.

2019-12-11 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5882e6f36fd9: [analyzer] Escape symbols conjured into 
specific regions during a conservative… (authored by xazax.hun).

Changed prior to commit:
  https://reviews.llvm.org/D71224?vs=233235=233431#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71224

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/expr-inspection.c
  clang/test/Analysis/pointer-escape-on-conservative-calls.c

Index: clang/test/Analysis/pointer-escape-on-conservative-calls.c
===
--- /dev/null
+++ clang/test/Analysis/pointer-escape-on-conservative-calls.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.AnalysisOrder -analyzer-config debug.AnalysisOrder:PointerEscape=true -analyzer-config debug.AnalysisOrder:PostCall=true %s 2>&1 | FileCheck %s
+
+
+void f(int *);
+int *getMem();
+
+int main() {
+f(getMem());
+return 0;
+}
+
+// CHECK: PostCall (f)
+// CHECK-NEXT: PointerEscape
Index: clang/test/Analysis/expr-inspection.c
===
--- clang/test/Analysis/expr-inspection.c
+++ clang/test/Analysis/expr-inspection.c
@@ -50,5 +50,5 @@
 
 void test_field_dumps(struct S s, struct S *p) {
   clang_analyzer_dump_pointer(); // expected-warning{{}}
-  clang_analyzer_dump_pointer(>x); // expected-warning{{{reg_$0}.x}}
+  clang_analyzer_dump_pointer(>x); // expected-warning{{{reg_$1}.x}}
 }
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -37,6 +37,7 @@
 // CHECK-NEXT: debug.AnalysisOrder:EndFunction = false
 // CHECK-NEXT: debug.AnalysisOrder:LiveSymbols = false
 // CHECK-NEXT: debug.AnalysisOrder:NewAllocator = false
+// CHECK-NEXT: debug.AnalysisOrder:PointerEscape = false
 // CHECK-NEXT: debug.AnalysisOrder:PostCall = false
 // CHECK-NEXT: debug.AnalysisOrder:PostStmtArraySubscriptExpr = false
 // CHECK-NEXT: debug.AnalysisOrder:PostStmtCXXNewExpr = false
@@ -97,4 +98,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 94
+// CHECK-NEXT: num-entries = 95
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "clang/AST/Decl.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.h"
@@ -592,9 +593,45 @@
   for (auto I : dstCallEvaluated)
 finishArgumentConstruction(dstArgumentCleanup, I, Call);
 
-  // Finally, run any post-call checks.
-  getCheckerManager().runCheckersForPostCall(Dst, dstArgumentCleanup,
+  ExplodedNodeSet dstPostCall;
+  getCheckerManager().runCheckersForPostCall(dstPostCall, dstArgumentCleanup,
  Call, *this);
+
+  // Escaping symbols conjured during invalidating the regions above.
+  // Note that, for inlined calls the nodes were put back into the worklist,
+  // so we can assume that every node belongs to a conservative call at this
+  // point.
+
+  // Run pointerEscape callback with the newly conjured symbols.
+  SmallVector, 8> Escaped;
+  for (auto I : dstPostCall) {
+NodeBuilder B(I, Dst, *currBldrCtx);
+ProgramStateRef State = I->getState();
+Escaped.clear();
+{
+  unsigned Arg = -1;
+  for (const ParmVarDecl *PVD : Call.parameters()) {
+++Arg;
+QualType ParamTy = PVD->getType();
+if (ParamTy.isNull() ||
+(!ParamTy->isPointerType() && !ParamTy->isReferenceType()))
+  continue;
+QualType Pointee = ParamTy->getPointeeType();
+if (Pointee.isConstQualified() || Pointee->isVoidType())
+  continue;
+if (const MemRegion *MR = Call.getArgSVal(Arg).getAsRegion())
+  Escaped.emplace_back(loc::MemRegionVal(MR), State->getSVal(MR, Pointee));
+  }
+}
+
+State = processPointerEscapedOnBind(State, Escaped, I->getLocationContext(),

[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

2019-12-11 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 233429.
jdoerfert marked 2 inline comments as done.
jdoerfert added a comment.

Remove call caching in anticipation of D69930 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/CMakeLists.txt
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/CMakeLists.txt
  llvm/unittests/Frontend/CMakeLists.txt
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- /dev/null
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -0,0 +1,178 @@
+//===- llvm/unittest/IR/OpenMPIRBuilderTest.cpp - OpenMPIRBuilder 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
+//
+//===--===//
+
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
+#include "llvm/IR/Verifier.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace omp;
+using namespace types;
+
+namespace {
+
+class OpenMPIRBuilderTest : public testing::Test {
+protected:
+  void SetUp() override {
+M.reset(new Module("MyModule", Ctx));
+FunctionType *FTy =
+FunctionType::get(Type::getVoidTy(Ctx), {Type::getInt32Ty(Ctx)},
+  /*isVarArg=*/false);
+F = Function::Create(FTy, Function::ExternalLinkage, "", M.get());
+BB = BasicBlock::Create(Ctx, "", F);
+
+DIBuilder DIB(*M);
+auto File = DIB.createFile("test.dbg", "/");
+auto CU =
+DIB.createCompileUnit(dwarf::DW_LANG_C, File, "llvm-C", true, "", 0);
+auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
+auto SP = DIB.createFunction(
+CU, "foo", "", File, 1, Type, 1, DINode::FlagZero,
+DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
+F->setSubprogram(SP);
+auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
+DIB.finalize();
+DL = DebugLoc::get(3, 7, Scope);
+  }
+
+  void TearDown() override {
+BB = nullptr;
+M.reset();
+uninitializeTypes();
+  }
+
+  LLVMContext Ctx;
+  std::unique_ptr M;
+  Function *F;
+  BasicBlock *BB;
+  DebugLoc DL;
+};
+
+TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  IRBuilder<> Builder(BB);
+
+  OMPBuilder.CreateBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
+  EXPECT_TRUE(M->global_empty());
+  EXPECT_EQ(M->size(), 1U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 0U);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 3U);
+  EXPECT_EQ(F->size(), 1U);
+  EXPECT_EQ(BB->size(), 2U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), "__kmpc_global_thread_num");
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotAccessMemory());
+  EXPECT_FALSE(GTID->getCalledFunction()->doesNotFreeMemory());
+
+  CallInst *Barrier = dyn_cast(GTID->getNextNode());
+  EXPECT_NE(Barrier, nullptr);
+  EXPECT_EQ(Barrier->getNumArgOperands(), 2U);
+  EXPECT_EQ(Barrier->getCalledFunction()->getName(), "__kmpc_barrier");
+  EXPECT_FALSE(Barrier->getCalledFunction()->doesNotAccessMemory());
+  EXPECT_FALSE(Barrier->getCalledFunction()->doesNotFreeMemory());
+
+  EXPECT_EQ(cast(Barrier)->getArgOperand(1), GTID);
+
+  Builder.CreateUnreachable();
+  EXPECT_FALSE(verifyModule(*M));
+}
+
+TEST_F(OpenMPIRBuilderTest, CreateCancelBarrier) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  BasicBlock *CBB = BasicBlock::Create(Ctx, "", F);
+  new UnreachableInst(Ctx, CBB);
+  OMPBuilder.setCancellationBlock(CBB);
+
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
+  auto NewIP = OMPBuilder.CreateBarrier(Loc, OMPD_for);
+  Builder.restoreIP(NewIP);
+  EXPECT_FALSE(M->global_empty());
+  EXPECT_EQ(M->size(), 3U);
+  EXPECT_EQ(F->size(), 3U);
+  EXPECT_EQ(BB->size(), 4U);
+
+  CallInst *GTID = dyn_cast(>front());
+  EXPECT_NE(GTID, nullptr);
+  EXPECT_EQ(GTID->getNumArgOperands(), 1U);
+  EXPECT_EQ(GTID->getCalledFunction()->getName(), 

[clang] 881d877 - [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

2019-12-11 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2019-12-11T11:54:57-08:00
New Revision: 881d877846e2904c731d616731969421ce8cc825

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

LOG: [WebAssembly] Add new `export_name` clang attribute for controlling wasm 
export names

This is equivalent to the existing `import_name` and `import_module`
attributes which control the import names in the final wasm binary
produced by lld.

This maps the existing

This attribute currently requires a string rather than using the
symbol name for a couple of reasons:

1. Avoid confusion with static and dynamic linking which is
   based on symbol name.  Exporting a function from a wasm module using
   this directive is orthogonal to both static and dynamic linking.
2. Avoids name mangling.

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

Added: 
clang/test/CodeGen/wasm-export-name.c
lld/test/wasm/export-name.ll
llvm/test/CodeGen/WebAssembly/export-name.ll
llvm/test/MC/WebAssembly/export-name.s

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
lld/docs/WebAssembly.rst
lld/wasm/InputChunks.h
lld/wasm/Writer.cpp
llvm/include/llvm/BinaryFormat/Wasm.h
llvm/include/llvm/MC/MCSymbolWasm.h
llvm/include/llvm/Object/Wasm.h
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Object/WasmObjectFile.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 40e180f343e7..47d9e641b178 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1600,6 +1600,14 @@ def BPFPreserveAccessIndex : InheritableAttr,
   let LangOpts = [COnly];
 }
 
+def WebAssemblyExportName : InheritableAttr,
+TargetSpecificAttr {
+  let Spellings = [Clang<"export_name">];
+  let Args = [StringArgument<"ExportName">];
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+}
+
 def WebAssemblyImportModule : InheritableAttr,
   TargetSpecificAttr {
   let Spellings = [Clang<"import_module">];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 764ac2485350..c632e52b28d1 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4101,6 +4101,21 @@ For more information see
 or `msvc documentation `_.
 }]; }
 
+def WebAssemblyExportNameDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Clang supports the ``__attribute__((export_name()))``
+attribute for the WebAssembly target. This attribute may be attached to a
+function declaration, where it modifies how the symbol is to be exported
+from the linked WebAssembly.
+
+WebAssembly functions are exported via string name. By default when a symbol
+is exported, the export name for C/C++ symbols are the same as their C/C++
+symbol names. This attribute can be used to override the default behavior, and
+request a specific string name be used instead.
+  }];
+}
+
 def WebAssemblyImportModuleDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 33e7b18d8393..9fd4a5fb17a7 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -779,6 +779,12 @@ class WebAssemblyTargetCodeGenInfo final : public 
TargetCodeGenInfo {
 B.addAttribute("wasm-import-name", Attr->getImportName());
 Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
   }
+  if (const auto *Attr = FD->getAttr()) {
+llvm::Function *Fn = cast(GV);
+llvm::AttrBuilder B;
+B.addAttribute("wasm-export-name", Attr->getExportName());
+Fn->addAttributes(llvm::AttributeList::FunctionIndex, B);
+  }
 }
 
 if (auto *FD = dyn_cast_or_null(D)) {

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 60a998036899..e83688c46be1 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5754,6 +5754,28 @@ static void handleBPFPreserveAccessIndexAttr(Sema , 
Decl *D,
   Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
 }
 
+static void 

[clang] 5882e6f - [analyzer] Escape symbols conjured into specific regions during a conservative EvalCall

2019-12-11 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-12-11T11:44:10-08:00
New Revision: 5882e6f36fd9bfc7382e6763c5591b3497428d83

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

LOG: [analyzer] Escape symbols conjured into specific regions during a 
conservative EvalCall

This patch introduced additional PointerEscape callbacks after conservative
calls for output parameters. This should not really affect the current
checkers but the upcoming FuchsiaHandleChecker relies on this heavily.

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

Added: 
clang/test/Analysis/pointer-escape-on-conservative-calls.c

Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/expr-inspection.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index be455ae14f57..43632e801d2b 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1266,6 +1266,12 @@ def AnalysisOrderChecker : Checker<"AnalysisOrder">,
   "false",
   Released,
   Hide>,
+CmdLineOption,
 CmdLineOption> LocAndVals,
+  const LocationContext *LCtx, PointerEscapeKind Kind,
+  const CallEvent *Call) override;
+
+  ProgramStateRef
+  processPointerEscapedOnBind(ProgramStateRef State,
+  SVal Loc, SVal Val,
+  const LocationContext *LCtx);
+
   /// Call PointerEscape callback when a value escapes as a result of
   /// region invalidation.
   /// \param[in] ITraits Specifies invalidation traits for regions/symbols.
@@ -628,9 +634,10 @@ class ExprEngine : public SubEngine {
RegionAndSymbolInvalidationTraits ) 
override;
 
   /// A simple wrapper when you only need to notify checkers of pointer-escape
-  /// of a single value.
-  ProgramStateRef escapeValue(ProgramStateRef State, SVal V,
-  PointerEscapeKind K) const;
+  /// of some values.
+  ProgramStateRef escapeValues(ProgramStateRef State, ArrayRef Vs,
+   PointerEscapeKind K,
+   const CallEvent *Call = nullptr) const;
 
 public:
   // FIXME: 'tag' should be removed, and a LocationContext should be used

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
index 7789b431c0a6..a7f3c28d4373 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
@@ -15,6 +15,7 @@
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
 
 namespace clang {
 
@@ -148,8 +149,10 @@ class SubEngine {
 return processRegionChanges(state, nullptr, MR, MR, LCtx, nullptr);
   }
 
-  virtual ProgramStateRef
-  processPointerEscapedOnBind(ProgramStateRef State, SVal Loc, SVal Val, const 
LocationContext *LCtx) = 0;
+  virtual ProgramStateRef processPointerEscapedOnBind(
+  ProgramStateRef State, ArrayRef> LocAndVals,
+  const LocationContext *LCtx, PointerEscapeKind Kind,
+  const CallEvent *Call) = 0;
 
   virtual ProgramStateRef
   notifyCheckersOfPointerEscape(ProgramStateRef State,

diff  --git a/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
index d0def6918932..2ef50a727ece 100644
--- a/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/AnalysisOrderChecker.cpp
@@ -40,6 +40,7 @@ class AnalysisOrderChecker
  check::EndFunction,
  check::NewAllocator,
  check::Bind,
+ check::PointerEscape,
  check::RegionChanges,
  check::LiveSymbols> {
 
@@ -165,6 +166,15 @@ class AnalysisOrderChecker
   llvm::errs() << "RegionChanges\n";
 return State;
   }
+
+  ProgramStateRef checkPointerEscape(ProgramStateRef State,
+ 

[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ahaa. Ahaa. Okay.

So the AST is like

  |   |-DeclStmt 0x7f9f3b8932e0 
  |   | `-VarDecl 0x7f9f3b892f50  col:7 used a 'int [5]' cinit
  |   |   `-InitListExpr 0x7f9f3b893268  'int [5]'
  |   | |-array_filler: ImplicitValueInitExpr 0x7f9f3b8932d0 <> 'int'
  |   | |-IntegerLiteral 0x7f9f3b893118  'int' 4
  |   | |-ImplicitValueInitExpr 0x7f9f3b8932d0 <> 'int'
  |   | |-IntegerLiteral 0x7f9f3b893078  'int' 15
  |   | |-ImplicitValueInitExpr 0x7f9f3b8932d0 <> 'int'
  |   | `-IntegerLiteral 0x7f9f3b892fd8  'int' 29

And the CFG is like

  [B1]
 1: 4
 2: [B1.4]
 3: 15
 4: /*implicit*/(int)0
 5: 29
 6: {[4] = [B1.5], [2] = [B1.3], [0] = [B1.1]}
 7: int a[5] = {[4] = 29, [2] = 15, [0] = 4};

And you're trying to avoid agglutinating program points for `[B1.2]` and 
`[B1.4]`.

Can we simply erase the implicit initializers from the CFG? Under an option, of 
course. We ignore them in the static analyzer anyway (like all constants).

We could do a custom program point just for this problem (which includes the 
index as part of its identity), but it's kinda underwhelming to build a whole 
new program point that always does nothing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71371



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 6 inline comments as done.
jdoerfert added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:74
+///
+///{
+namespace types {

ABataev wrote:
> Extra comments?
I don't know what you want to tell me.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:174-177
+if (auto *IdentI = dyn_cast(Ident))
+  Call->moveAfter(IdentI);
+else
+  Call->moveBefore(&*Fn->getEntryBlock().getFirstInsertionPt());

ABataev wrote:
> Are you sure it will work correctly with late outlining?
Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

  failed: 
LLVM-Unit.Frontend/_/LLVMFrontendTests/OpenMPIRBuilderTest.CreateCancelBarrier

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


Re: [clang] 878a24e - Reapply "Fix crash on switch conditions of non-integer types in templates"

2019-12-11 Thread Alexander Kornienko via cfe-commits
After this commit clang started generating assertion failures on valid
code. There are tons of instances in our codebase. Here's a reduced test
case:
template
class a {
  int c : b;
  void f() {
if (c)
  ;
  }
};

Please take a look.

On Wed, Dec 4, 2019 at 12:39 AM Elizabeth Andrews via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Elizabeth Andrews
> Date: 2019-12-03T15:27:19-08:00
> New Revision: 878a24ee244a24c39d1c57e9af2e88c621f7cce9
>
> URL:
> https://github.com/llvm/llvm-project/commit/878a24ee244a24c39d1c57e9af2e88c621f7cce9
> DIFF:
> https://github.com/llvm/llvm-project/commit/878a24ee244a24c39d1c57e9af2e88c621f7cce9.diff
>
> LOG: Reapply "Fix crash on switch conditions of non-integer types in
> templates"
>
> This patch reapplies commit 759948467ea. Patch was reverted due to a
> clang-tidy test fail on Windows. The test has been modified. There
> are no additional code changes.
>
> Patch was tested with ninja check-all on Windows and Linux.
>
> Summary of code changes:
>
> Clang currently crashes for switch statements inside a template when the
> condition is a non-integer field member because contextual implicit
> conversion is skipped when parsing the condition. This conversion is
> however later checked in an assert when the case statement is handled.
> The conversion is skipped when parsing the condition because
> the field member is set as type-dependent based on its containing class.
> This patch sets the type dependency based on the field's type instead.
>
> This patch fixes Bug 40982.
>
> Added:
> clang/test/SemaTemplate/non-integral-switch-cond.cpp
>
> Modified:
>
> clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
> clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
> clang/lib/AST/Expr.cpp
> clang/lib/Sema/SemaChecking.cpp
> clang/test/SemaCXX/constant-expression-cxx2a.cpp
> clang/test/SemaTemplate/dependent-names.cpp
> clang/test/SemaTemplate/enum-argument.cpp
> clang/test/SemaTemplate/member-access-expr.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git
> a/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
> b/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
> index 18fe5ef4e5c2..2c288e0bbddf 100644
> ---
> a/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
> +++
> b/clang-tools-extra/test/clang-tidy/checkers/bugprone-string-integer-assignment.cpp
> @@ -1,4 +1,4 @@
> -// RUN: %check_clang_tidy %s bugprone-string-integer-assignment %t
> +// RUN: %check_clang_tidy %s bugprone-string-integer-assignment %t -- --
> -fno-delayed-template-parsing
>
>  namespace std {
>  template
> @@ -103,6 +103,8 @@ struct S {
>static constexpr T t = 0x8000;
>std::string s;
>void f(char c) { s += c | static_cast(t); }
> +  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: an integer is interpreted
> as a chara
> +  // CHECK-FIXES: {{^}}  void f(char c) { s += std::to_string(c |
> static_cast(t)); }
>  };
>
>  template S;
>
> diff  --git
> a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
> b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
> index 119eff67318e..8e546b44ab74 100644
> --- a/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
> +++ b/clang-tools-extra/test/clang-tidy/checkers/misc-unused-parameters.cpp
> @@ -233,7 +233,7 @@ struct a {
>  template 
>  class d {
>a e;
> -  void f() { e.b(); }
> +  void f() { e.b(0); }
>  };
>  }  // namespace
>  }  // namespace PR38055
>
> diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
> index 322b3a7fa740..a73531ad5fad 100644
> --- a/clang/lib/AST/Expr.cpp
> +++ b/clang/lib/AST/Expr.cpp
> @@ -1678,6 +1678,15 @@ MemberExpr *MemberExpr::Create(
>MemberExpr *E = new (Mem) MemberExpr(Base, IsArrow, OperatorLoc,
> MemberDecl,
> NameInfo, T, VK, OK, NOUR);
>
> +  if (FieldDecl *Field = dyn_cast(MemberDecl)) {
> +DeclContext *DC = MemberDecl->getDeclContext();
> +// dyn_cast_or_null is used to handle objC variables which do not
> +// have a declaration context.
> +CXXRecordDecl *RD = dyn_cast_or_null(DC);
> +if (RD && RD->isDependentContext() && RD->isCurrentInstantiation(DC))
> +  E->setTypeDependent(T->isDependentType());
> +  }
> +
>if (HasQualOrFound) {
>  // FIXME: Wrong. We should be looking at the member declaration we
> found.
>  if (QualifierLoc &&
> QualifierLoc.getNestedNameSpecifier()->isDependent()) {
>
> diff  --git a/clang/lib/Sema/SemaChecking.cpp
> b/clang/lib/Sema/SemaChecking.cpp
> index ed42833531d4..825e0faa3037 100644
> --- a/clang/lib/Sema/SemaChecking.cpp
> +++ b/clang/lib/Sema/SemaChecking.cpp
> @@ -14706,6 +14706,8 @@ void Sema::RefersToMemberWithReducedAlignment(
>bool AnyIsPacked = false;
>do {

[PATCH] D71111: [Sema] Improve diagnostic about addr spaces for overload candidates

2019-12-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 233424.
Anastasia added a comment.

- Allow sending address spaces into diagnostics
- Change wording of diagnostics for address spaces in overloading


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

https://reviews.llvm.org/D7

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCXX/address-space-references.cpp
  clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl

Index: clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
===
--- clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
+++ clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
@@ -7,8 +7,8 @@
 };
 
 void bar(__local C*);
-// expected-note@-1{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka '__global C *')), parameter type must be '__local C *'}}
-// expected-note@-2{{candidate function not viable: address space mismatch in 1st argument ('decltype(this)' (aka 'C *')), parameter type must be '__local C *'}}
+// expected-note@-1{{candidate function not viable: cannot pass pointer to address space '__global' as a pointer to address space '__local' in 1st argument}}
+// expected-note@-2{{candidate function not viable: cannot pass pointer to address space default as a pointer to address space '__local' in 1st argument}}
 
 __global C Glob;
 void foo(){
Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- clang/test/SemaOpenCLCXX/address-space-lambda.cl
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -12,7 +12,7 @@
   // Test lambda with default parameters
 //CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
   [&] {i++;} ();
-  __constant auto err = [&]() {}; //expected-note-re{{candidate function not viable: address space mismatch in 'this' argument ('__constant (lambda at {{.*}})'), parameter type must be 'const __generic (lambda at {{.*}})'}}
+  __constant auto err = [&]() {}; //expected-note{{candidate function not viable: 'this' object is in address space '__constant', but method expects object in address space '__generic'}}
   err();  //expected-error-re{{no matching function for call to object of type '__constant (lambda at {{.*}})'}}
   // FIXME: There is very limited addr space functionality
   // we can test when taking lambda type from the object.
Index: clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
===
--- clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
+++ clang/test/SemaOpenCL/address-spaces-conversions-cl2.0.cl
@@ -42,7 +42,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-3{{passing argument to parameter 'arg_glob' here}}
 #else
-// expected-note-re@-5{{candidate function not viable: address space mismatch in 1st argument ('__{{generic|constant}} int *'), parameter type must be '__global int *'}}
+// expected-note-re@-5{{candidate function not viable: cannot pass pointer to address space '__{{generic|constant}}' as a pointer to address space '__global' in 1st argument}}
 #endif
 #endif
 
@@ -50,7 +50,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-2{{passing argument to parameter 'arg_loc' here}}
 #else
-// expected-note-re@-4{{candidate function not viable: address space mismatch in 1st argument ('__{{global|generic|constant}} int *'), parameter type must be '__local int *'}}
+// expected-note-re@-4{{candidate function not viable: cannot pass pointer to address space '__{{global|generic|constant}}' as a pointer to address space '__local' in 1st argument}}
 #endif
 
 void f_const(__constant int *arg_const) {}
@@ -58,7 +58,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-3{{passing argument to parameter 'arg_const' here}}
 #else
-// expected-note-re@-5{{candidate function not viable: address space mismatch in 1st argument ('__{{global|generic}} int *'), parameter type must be '__constant int *'}}
+// expected-note-re@-5{{candidate function not viable: cannot pass pointer to address space '__{{global|generic}}' as a pointer to address space '__constant' in 1st argument}}
 #endif
 #endif
 
@@ -66,7 +66,7 @@
 #if !__OPENCL_CPP_VERSION__
 // expected-note@-2{{passing argument to parameter 'arg_priv' here}}
 #else
-// expected-note-re@-4{{candidate function not viable: address space mismatch in 1st argument ('__{{global|generic|constant}} int *'), parameter type must be 'int *'}}
+// expected-note-re@-4{{candidate function not viable: cannot pass pointer to address space 

[PATCH] D71322: [analyzer] CStringChecker: Fix overly eager assumption that memcmp arguments overlap.

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2b3f2071ec65: [analyzer] CStringChecker: Fix overly eager 
assumption that memcmp args overlap. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71322

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bstring.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -867,6 +867,12 @@
   fPtr();
 }
 
+int strcmp_null_argument(char *a) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return strcmp(a, b); // expected-warning{{Null pointer passed as 2nd argument to string comparison function}}
+}
+
 //===--===
 // strncmp()
 //===--===
@@ -976,6 +982,12 @@
 	clang_analyzer_eval(strncmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}}
 }
 
+int strncmp_null_argument(char *a, size_t n) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return strncmp(a, b, n); // expected-warning{{Null pointer passed as 2nd argument to string comparison function}}
+}
+
 //===--===
 // strcasecmp()
 //===--===
@@ -1067,6 +1079,12 @@
 	clang_analyzer_eval(strcasecmp("ab\0zz", "ab\0yy") == 0); // expected-warning{{TRUE}}
 }
 
+int strcasecmp_null_argument(char *a) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return strcasecmp(a, b); // expected-warning{{Null pointer passed as 2nd argument to string comparison function}}
+}
+
 //===--===
 // strncasecmp()
 //===--===
@@ -1176,6 +1194,12 @@
 	clang_analyzer_eval(strncasecmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}}
 }
 
+int strncasecmp_null_argument(char *a, size_t n) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return strncasecmp(a, b, n); // expected-warning{{Null pointer passed as 2nd argument to string comparison function}}
+}
+
 //===--===
 // strsep()
 //===--===
Index: clang/test/Analysis/bstring.c
===
--- clang/test/Analysis/bstring.c
+++ clang/test/Analysis/bstring.c
@@ -462,6 +462,12 @@
  memcmp([x*y], a, n);
 }
 
+int memcmp8(char *a, size_t n) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return memcmp(a, b, n); // expected-warning{{Null pointer passed as 2nd argument to memory comparison function}}
+}
+
 //===--===
 // bcopy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1313,9 +1313,9 @@
 ProgramStateRef StSameBuf, StNotSameBuf;
 std::tie(StSameBuf, StNotSameBuf) = state->assume(SameBuf);
 
-// If the two arguments might be the same buffer, we know the result is 0,
+// If the two arguments are the same buffer, we know the result is 0,
 // and we only need to check one size.
-if (StSameBuf) {
+if (StSameBuf && !StNotSameBuf) {
   state = StSameBuf;
   state = CheckBufferAccess(C, state, Size, Left);
   if (state) {
@@ -1323,20 +1323,19 @@
 svalBuilder.makeZeroVal(CE->getType()));
 C.addTransition(state);
   }
+  return;
 }
 
-// If the two arguments might be different buffers, we have to check the
-// size of both of them.
-if (StNotSameBuf) {
-  state = StNotSameBuf;
-  state = CheckBufferAccess(C, state, Size, Left, Right);
-  if (state) {
-// The return value is the comparison result, which we don't know.
-SVal CmpV = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx,
- C.blockCount());
-state = state->BindExpr(CE, LCtx, CmpV);
-C.addTransition(state);
-  }
+// If the two arguments might be different buffers, we have to check
+// the size of both of them.
+assert(StNotSameBuf);
+state = CheckBufferAccess(C, state, Size, Left, Right);
+if (state) {
+  // The return value is the comparison result, which we 

[PATCH] D71371: [analyzer] Do not cache out on some shared implicit AST nodes.

2019-12-11 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: NoQ, dcoughlin, Szelethus, baloghadamsoftware, 
haowei.
xazax.hun added a project: clang.
Herald added subscribers: Charusso, gamesh411, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet.

Some AST nodes that stands for implicit initialization is shared. The analyzer 
will do the same evaluation on the same nodes resulting in the same state. The 
analyzer will "cache out", i.e. it thinks that it visited an already existing 
node in the exploded graph. This is not true in this case and we lose coverage. 
This patch introduces a trick that prevents caching out.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71371

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/designated-initializer-values.c


Index: clang/test/Analysis/designated-initializer-values.c
===
--- /dev/null
+++ clang/test/Analysis/designated-initializer-values.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-std=c99 -verify %s
+
+void clang_analyzer_eval(int);
+
+void array_init() {
+  int a[5] = {[4] = 29, [2] = 15, [0] = 4};
+  clang_analyzer_eval(a[0] == 4);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[2] == 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[3] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[4] == 29); // expected-warning{{TRUE}}
+  int b[5] = {[0 ... 2] = 1, [4] = 5};
+  clang_analyzer_eval(b[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[1] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[2] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[3] == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[4] == 5); // expected-warning{{TRUE}}
+}
+
+struct point {
+  int x, y;
+};
+
+void struct_init() {
+  struct point p = {.y = 5, .x = 3};
+  clang_analyzer_eval(p.x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(p.y == 5); // expected-warning{{TRUE}}
+}
+
+void array_of_struct() {
+  struct point ptarray[3] = { [2].y = 1, [2].x = 2, [0].x = 3 };
+  clang_analyzer_eval(ptarray[0].x == 3); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[0].y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[1].x == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[1].y == 0); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[2].x == 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval(ptarray[2].y == 1); // expected-warning{{TRUE}}
+}
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -193,6 +193,11 @@
 REGISTER_TRAIT_WITH_PROGRAMSTATE(ObjectsUnderConstruction,
  ObjectsUnderConstructionMap)
 
+// The AST sometimes ends up sharing nodes for compile time constants.
+// We might end up caching out on those notes, this trait intended to
+// prevent that explicitly.
+REGISTER_MAP_WITH_PROGRAMSTATE(NoCachingOutForConsts, const Stmt *, unsigned 
long)
+
 
//===--===//
 // Engine construction and deletion.
 
//===--===//
@@ -1403,6 +1408,13 @@
 case Stmt::OMPArraySectionExprClass:
 case Stmt::TypeTraitExprClass: {
   Bldr.takeNodes(Pred);
+  if (isa(S)) {
+ProgramStateRef State = Pred->getState();
+const unsigned long *Count = State->get(0);
+State = State->set(0, Count? *Count + 1 : 0);
+Pred = Bldr.generateNode(S, Pred, State);
+assert(Pred && "We should never cache out on constants");
+  }
   ExplodedNodeSet preVisit;
   getCheckerManager().runCheckersForPreStmt(preVisit, Pred, S, *this);
   getCheckerManager().runCheckersForPostStmt(Dst, preVisit, S, *this);


Index: clang/test/Analysis/designated-initializer-values.c
===
--- /dev/null
+++ clang/test/Analysis/designated-initializer-values.c
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -std=c99 -verify %s
+
+void clang_analyzer_eval(int);
+
+void array_init() {
+  int a[5] = {[4] = 29, [2] = 15, [0] = 4};
+  clang_analyzer_eval(a[0] == 4);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[1] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[2] == 15); // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[3] == 0);  // expected-warning{{TRUE}}
+  clang_analyzer_eval(a[4] == 29); // expected-warning{{TRUE}}
+  int b[5] = {[0 ... 2] = 1, [4] = 5};
+  clang_analyzer_eval(b[0] == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(b[1] == 1); // 

[PATCH] D71356: [Tooling/Syntax] Helpers to find spelled tokens touching a location.

2019-12-11 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

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

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

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



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71356



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


[PATCH] D71321: [analyzer] CStringChecker: Warning text fixes.

2019-12-11 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG134faae04259: [analyzer] CStringChecker: Improve warning 
messages. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71321

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/bsd-string.c
  clang/test/Analysis/bstring.c
  clang/test/Analysis/cstring-ranges.c
  clang/test/Analysis/null-deref-path-notes.c
  clang/test/Analysis/null-deref-ps-region.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -97,7 +97,7 @@
 }
 
 size_t strlen_null() {
-  return strlen(0); // expected-warning{{Null pointer argument in call to string length function}}
+  return strlen(0); // expected-warning{{Null pointer passed as 1st argument to string length function}}
 }
 
 size_t strlen_fn() {
@@ -251,7 +251,7 @@
 }
 
 size_t strnlen_null() {
-  return strnlen(0, 3); // expected-warning{{Null pointer argument in call to string length function}}
+  return strnlen(0, 3); // expected-warning{{Null pointer passed as 1st argument to string length function}}
 }
 
 size_t strnlen_fn() {
@@ -322,11 +322,11 @@
 
 
 void strcpy_null_dst(char *x) {
-  strcpy(NULL, x); // expected-warning{{Null pointer argument in call to string copy function}}
+  strcpy(NULL, x); // expected-warning{{Null pointer passed as 1st argument to string copy function}}
 }
 
 void strcpy_null_src(char *x) {
-  strcpy(x, NULL); // expected-warning{{Null pointer argument in call to string copy function}}
+  strcpy(x, NULL); // expected-warning{{Null pointer passed as 2nd argument to string copy function}}
 }
 
 void strcpy_fn(char *x) {
@@ -424,15 +424,15 @@
 
 
 void strcat_null_dst(char *x) {
-  strcat(NULL, x); // expected-warning{{Null pointer argument in call to string copy function}}
+  strcat(NULL, x); // expected-warning{{Null pointer passed as 1st argument to string concatenation function}}
 }
 
 void strcat_null_src(char *x) {
-  strcat(x, NULL); // expected-warning{{Null pointer argument in call to string copy function}}
+  strcat(x, NULL); // expected-warning{{Null pointer passed as 2nd argument to string concatenation function}}
 }
 
 void strcat_fn(char *x) {
-  strcat(x, (char*)_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcat_fn', which is not a null-terminated string}}
+  strcat(x, (char*)_fn); // expected-warning{{Argument to string concatenation function is the address of the function 'strcat_fn', which is not a null-terminated string}}
 }
 
 void strcat_effects(char *y) {
@@ -523,11 +523,11 @@
 
 
 void strncpy_null_dst(char *x) {
-  strncpy(NULL, x, 5); // expected-warning{{Null pointer argument in call to string copy function}}
+  strncpy(NULL, x, 5); // expected-warning{{Null pointer passed as 1st argument to string copy function}}
 }
 
 void strncpy_null_src(char *x) {
-  strncpy(x, NULL, 5); // expected-warning{{Null pointer argument in call to string copy function}}
+  strncpy(x, NULL, 5); // expected-warning{{Null pointer passed as 2nd argument to string copy function}}
 }
 
 void strncpy_fn(char *x) {
@@ -631,15 +631,15 @@
 
 
 void strncat_null_dst(char *x) {
-  strncat(NULL, x, 4); // expected-warning{{Null pointer argument in call to string copy function}}
+  strncat(NULL, x, 4); // expected-warning{{Null pointer passed as 1st argument to string concatenation function}}
 }
 
 void strncat_null_src(char *x) {
-  strncat(x, NULL, 4); // expected-warning{{Null pointer argument in call to string copy function}}
+  strncat(x, NULL, 4); // expected-warning{{Null pointer passed as 2nd argument to string concatenation function}}
 }
 
 void strncat_fn(char *x) {
-  strncat(x, (char*)_fn, 4); // expected-warning{{Argument to string copy function is the address of the function 'strncat_fn', which is not a null-terminated string}}
+  strncat(x, (char*)_fn, 4); // expected-warning{{Argument to string concatenation function is the address of the function 'strncat_fn', which is not a null-terminated string}}
 }
 
 void strncat_effects(char *y) {
@@ -812,13 +812,13 @@
 void strcmp_null_0() {
   char *x = NULL;
   char *y = "123";
-  strcmp(x, y); // expected-warning{{Null pointer argument in call to string comparison function}}
+  strcmp(x, y); // expected-warning{{Null pointer passed as 1st argument to string comparison function}}
 }
 
 void strcmp_null_1() {
   char *x = "123";
   char *y = NULL;
-  strcmp(x, y); // expected-warning{{Null pointer argument in call to string comparison function}}
+  strcmp(x, y); // expected-warning{{Null pointer passed as 2nd argument to string comparison function}}
 }
 
 void strcmp_diff_length_0() {
@@ -921,13 +921,13 @@
 void strncmp_null_0() {
   char *x = NULL;
   char *y = "123";
-  

[PATCH] D70854: [Clang] In tests, do not always assume others permissions are set

2019-12-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I see there is no setfacl on Mac. Personally, I feel like this test doesn't 
have much value. Rafael added it long ago when we changed how we opened files 
in some way that I guess affected umask. I'm not sure we really need this 
regression test given how unportable it seems to be.


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

https://reviews.llvm.org/D70854



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


[clang] 2b3f207 - [analyzer] CStringChecker: Fix overly eager assumption that memcmp args overlap.

2019-12-11 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-11T11:22:36-08:00
New Revision: 2b3f2071ec6561c3f10e5291289c47bb3629e354

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

LOG: [analyzer] CStringChecker: Fix overly eager assumption that memcmp args 
overlap.

While analyzing code `memcmp(a, NULL, n);', where `a' has an unconstrained
symbolic value, the analyzer was emitting a warning about the *first* argument
being a null pointer, even though we'd rather have it warn about the *second*
argument.

This happens because CStringChecker first checks whether the two argument
buffers are in fact the same buffer, in order to take the fast path.
This boils down to assuming `a == NULL' to true. Then the subsequent check
for null pointer argument "discovers" that `a' is null.

Don't take the fast path unless we are *sure* that the buffers are the same.
Otherwise proceed as normal.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/test/Analysis/bstring.c
clang/test/Analysis/string.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index c05a09da3df1..4203f790e211 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1313,9 +1313,9 @@ void CStringChecker::evalMemcmp(CheckerContext , const 
CallExpr *CE) const {
 ProgramStateRef StSameBuf, StNotSameBuf;
 std::tie(StSameBuf, StNotSameBuf) = state->assume(SameBuf);
 
-// If the two arguments might be the same buffer, we know the result is 0,
+// If the two arguments are the same buffer, we know the result is 0,
 // and we only need to check one size.
-if (StSameBuf) {
+if (StSameBuf && !StNotSameBuf) {
   state = StSameBuf;
   state = CheckBufferAccess(C, state, Size, Left);
   if (state) {
@@ -1323,20 +1323,19 @@ void CStringChecker::evalMemcmp(CheckerContext , 
const CallExpr *CE) const {
 svalBuilder.makeZeroVal(CE->getType()));
 C.addTransition(state);
   }
+  return;
 }
 
-// If the two arguments might be 
diff erent buffers, we have to check the
-// size of both of them.
-if (StNotSameBuf) {
-  state = StNotSameBuf;
-  state = CheckBufferAccess(C, state, Size, Left, Right);
-  if (state) {
-// The return value is the comparison result, which we don't know.
-SVal CmpV = svalBuilder.conjureSymbolVal(nullptr, CE, LCtx,
- C.blockCount());
-state = state->BindExpr(CE, LCtx, CmpV);
-C.addTransition(state);
-  }
+// If the two arguments might be 
diff erent buffers, we have to check
+// the size of both of them.
+assert(StNotSameBuf);
+state = CheckBufferAccess(C, state, Size, Left, Right);
+if (state) {
+  // The return value is the comparison result, which we don't know.
+  SVal CmpV =
+  svalBuilder.conjureSymbolVal(nullptr, CE, LCtx, C.blockCount());
+  state = state->BindExpr(CE, LCtx, CmpV);
+  C.addTransition(state);
 }
   }
 }

diff  --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index 8d8f64cebec1..2d53402a9ad3 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -462,6 +462,12 @@ int memcmp7 (char *a, size_t x, size_t y, size_t n) {
  memcmp([x*y], a, n);
 }
 
+int memcmp8(char *a, size_t n) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return memcmp(a, b, n); // expected-warning{{Null pointer passed as 2nd 
argument to memory comparison function}}
+}
+
 //===--===
 // bcopy()
 //===--===

diff  --git a/clang/test/Analysis/string.c b/clang/test/Analysis/string.c
index d21ec11c1115..7612614bc091 100644
--- a/clang/test/Analysis/string.c
+++ b/clang/test/Analysis/string.c
@@ -867,6 +867,12 @@ void strcmp_union_function_pointer_cast(union argument a) {
   fPtr();
 }
 
+int strcmp_null_argument(char *a) {
+  char *b = 0;
+  // Do not warn about the first argument!
+  return strcmp(a, b); // expected-warning{{Null pointer passed as 2nd 
argument to string comparison function}}
+}
+
 //===--===
 // strncmp()
 //===--===
@@ -976,6 +982,12 @@ void strncmp_embedded_null () {
clang_analyzer_eval(strncmp("ab\0zz", "ab\0yy", 4) == 0); // 
expected-warning{{TRUE}}
 }
 
+int strncmp_null_argument(char 

[clang] 134faae - [analyzer] CStringChecker: Improve warning messages.

2019-12-11 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2019-12-11T11:22:36-08:00
New Revision: 134faae04259b0412a067c73069f61905fc451d7

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

LOG: [analyzer] CStringChecker: Improve warning messages.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/test/Analysis/bsd-string.c
clang/test/Analysis/bstring.c
clang/test/Analysis/cstring-ranges.c
clang/test/Analysis/null-deref-path-notes.c
clang/test/Analysis/null-deref-ps-region.c
clang/test/Analysis/string.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index f2c994b2a667..c05a09da3df1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -290,9 +290,9 @@ ProgramStateRef CStringChecker::checkNonNull(CheckerContext 
,
   SmallString<80> buf;
   llvm::raw_svector_ostream OS(buf);
   assert(CurrentFunctionDescription);
-  OS << "Null pointer argument in call to " << CurrentFunctionDescription
- << ' ' << IdxOfArg << llvm::getOrdinalSuffix(IdxOfArg)
- << " parameter";
+  OS << "Null pointer passed as " << IdxOfArg
+ << llvm::getOrdinalSuffix(IdxOfArg) << " argument to "
+ << CurrentFunctionDescription;
 
   emitNullArgBug(C, stateNull, S, OS.str());
 }
@@ -1536,7 +1536,10 @@ void CStringChecker::evalStrcpyCommon(CheckerContext , 
const CallExpr *CE,
   bool ReturnEnd, bool IsBounded,
   ConcatFnKind appendK,
   bool returnPtr) const {
-  CurrentFunctionDescription = "string copy function";
+  if (appendK == ConcatFnKind::none)
+CurrentFunctionDescription = "string copy function";
+  else
+CurrentFunctionDescription = "string concatenation function";
   ProgramStateRef state = C.getState();
   const LocationContext *LCtx = C.getLocationContext();
 

diff  --git a/clang/test/Analysis/bsd-string.c 
b/clang/test/Analysis/bsd-string.c
index d8a88836a151..3778664a8ef5 100644
--- a/clang/test/Analysis/bsd-string.c
+++ b/clang/test/Analysis/bsd-string.c
@@ -33,11 +33,11 @@ void f3() {
 }
 
 void f4() {
-  strlcpy(NULL, "abcdef", 6); // expected-warning{{Null pointer argument in 
call to string copy function}}
+  strlcpy(NULL, "abcdef", 6); // expected-warning{{Null pointer passed as 1st 
argument to string copy function}}
 }
 
 void f5() {
-  strlcat(NULL, "abcdef", 6); // expected-warning{{Null pointer argument in 
call to string copy function}}
+  strlcat(NULL, "abcdef", 6); // expected-warning{{Null pointer passed as 1st 
argument to string concatenation function}}
 }
 
 void f6() {

diff  --git a/clang/test/Analysis/bstring.c b/clang/test/Analysis/bstring.c
index beabb0f0241e..8d8f64cebec1 100644
--- a/clang/test/Analysis/bstring.c
+++ b/clang/test/Analysis/bstring.c
@@ -148,12 +148,12 @@ void memcpy9() {
 
 void memcpy10() {
   char a[4] = {0};
-  memcpy(0, a, 4); // expected-warning{{Null pointer argument in call to 
memory copy function}}
+  memcpy(0, a, 4); // expected-warning{{Null pointer passed as 1st argument to 
memory copy function}}
 }
 
 void memcpy11() {
   char a[4] = {0};
-  memcpy(a, 0, 4); // expected-warning{{Null pointer argument in call to 
memory copy function}}
+  memcpy(a, 0, 4); // expected-warning{{Null pointer passed as 2nd argument to 
memory copy function}}
 }
 
 void memcpy12() {
@@ -173,7 +173,7 @@ void memcpy_unknown_size (size_t n) {
 
 void memcpy_unknown_size_warn (size_t n) {
   char a[4];
-  void *result = memcpy(a, 0, n); // expected-warning{{Null pointer argument 
in call to memory copy function}}
+  void *result = memcpy(a, 0, n); // expected-warning{{Null pointer passed as 
2nd argument to memory copy function}}
   clang_analyzer_eval(result == a); // no-warning (above is fatal)
 }
 
@@ -268,12 +268,12 @@ void mempcpy9() {
 
 void mempcpy10() {
   char a[4] = {0};
-  mempcpy(0, a, 4); // expected-warning{{Null pointer argument in call to 
memory copy function}}
+  mempcpy(0, a, 4); // expected-warning{{Null pointer passed as 1st argument 
to memory copy function}}
 }
 
 void mempcpy11() {
   char a[4] = {0};
-  mempcpy(a, 0, 4); // expected-warning{{Null pointer argument in call to 
memory copy function}}
+  mempcpy(a, 0, 4); // expected-warning{{Null pointer passed as 2nd argument 
to memory copy function}}
 }
 
 void mempcpy12() {
@@ -327,7 +327,7 @@ void mempcpy16() {
 
 void mempcpy_unknown_size_warn (size_t n) {
   char a[4];
-  void *result = mempcpy(a, 0, n); // expected-warning{{Null pointer argument 
in call to memory copy 

[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:74
+///
+///{
+namespace types {

Extra comments?



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h:93
+} // namespace types
+///}
+

Here too.



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:174-177
+if (auto *IdentI = dyn_cast(Ident))
+  Call->moveAfter(IdentI);
+else
+  Call->moveBefore(&*Fn->getEntryBlock().getFirstInsertionPt());

Are you sure it will work correctly with late outlining?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:186-188
+  // TODO: Do we really expect these create calls to happen at an invalid
+  //   location and if so is ignoring them the right thing to do? This
+  //   mimics Clang's behavior for now.

Clang drops insert point after some code, like call of `exit()` etc. That's why 
we need to check it in the frontend, otherwise, the compiler crashes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

2019-12-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 233420.
kadircet marked 12 inline comments as done.
kadircet added a comment.

- Move code blocks out of Paragraph
- Provide a way to control vertical spacing
- Address comments around naming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248

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

Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -8,192 +8,139 @@
 #include "FormattedString.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
 namespace clangd {
+namespace markup {
 namespace {
 
-TEST(FormattedString, Basic) {
-  FormattedString S;
-  EXPECT_EQ(S.renderAsPlainText(), "");
-  EXPECT_EQ(S.renderAsMarkdown(), "");
-
-  S.appendText("foobar  ");
-  S.appendText("baz");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "foobar  baz");
-
-  S = FormattedString();
-  S.appendInlineCode("foobar");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar");
-  EXPECT_EQ(S.renderAsMarkdown(), "`foobar`");
-
-  S = FormattedString();
-  S.appendCodeBlock("foobar");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar");
-  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
-  "foobar\n"
-  "```\n");
+enum RenderKind {
+  PlainText,
+  Markdown,
+};
+std::string renderBlock(const Block , RenderKind RK) {
+  std::string R;
+  llvm::raw_string_ostream OS(R);
+  switch (RK) {
+  case PlainText:
+B.asPlainText(OS);
+break;
+  case Markdown:
+B.asMarkdown(OS);
+break;
+  }
+  return OS.str();
 }
 
-TEST(FormattedString, CodeBlocks) {
-  FormattedString S;
-  S.appendCodeBlock("foobar");
-  S.appendCodeBlock("bazqux", "javascript");
-  S.appendText("after");
-
-  std::string ExpectedText = R"(foobar
-
-bazqux
-
-after)";
-  EXPECT_EQ(S.renderAsPlainText(), ExpectedText);
-  std::string ExpectedMarkdown = R"md(```cpp
-foobar
-```
-```javascript
-bazqux
-```
-after)md";
-  EXPECT_EQ(S.renderAsMarkdown(), ExpectedMarkdown);
-
-  S = FormattedString();
-  S.appendInlineCode("foobar");
-  S.appendInlineCode("bazqux");
-  EXPECT_EQ(S.renderAsPlainText(), "foobar bazqux");
-  EXPECT_EQ(S.renderAsMarkdown(), "`foobar` `bazqux`");
-
-  S = FormattedString();
-  S.appendText("foo");
-  S.appendInlineCode("bar");
-  S.appendText("baz");
-
-  EXPECT_EQ(S.renderAsPlainText(), "foo bar baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "foo `bar` baz");
-}
+MATCHER_P(HasMarkdown, MD, "") { return renderBlock(arg, Markdown) == MD; }
+MATCHER_P(HasPlainText, PT, "") { return renderBlock(arg, PlainText) == PT; }
 
-TEST(FormattedString, Escaping) {
+TEST(Render, Escaping) {
   // Check some ASCII punctuation
-  FormattedString S;
-  S.appendText("*!`");
-  EXPECT_EQ(S.renderAsMarkdown(), "\\*\\!\\`");
+  Paragraph P;
+  P.appendText("*!`");
+  EXPECT_THAT(P, HasMarkdown("\\*\\!\\`"));
 
   // Check all ASCII punctuation.
-  S = FormattedString();
+  P = Paragraph();
   std::string Punctuation = R"txt(!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)txt";
   // Same text, with each character escaped.
   std::string EscapedPunctuation;
   EscapedPunctuation.reserve(2 * Punctuation.size());
   for (char C : Punctuation)
 EscapedPunctuation += std::string("\\") + C;
-  S.appendText(Punctuation);
-  EXPECT_EQ(S.renderAsMarkdown(), EscapedPunctuation);
+  P.appendText(Punctuation);
+  EXPECT_THAT(P, HasMarkdown(EscapedPunctuation));
 
   // In code blocks we don't need to escape ASCII punctuation.
-  S = FormattedString();
-  S.appendInlineCode("* foo !+ bar * baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "`* foo !+ bar * baz`");
-  S = FormattedString();
-  S.appendCodeBlock("#define FOO\n* foo !+ bar * baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
-  "#define FOO\n* foo !+ bar * baz\n"
-  "```\n");
+  P = Paragraph();
+  P.appendCode("* foo !+ bar * baz");
+  EXPECT_THAT(P, HasMarkdown("`* foo !+ bar * baz`"));
 
   // But we have to escape the backticks.
-  S = FormattedString();
-  S.appendInlineCode("foo`bar`baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "`foo``bar``baz`");
-
-  S = FormattedString();
-  S.appendCodeBlock("foo`bar`baz");
-  EXPECT_EQ(S.renderAsMarkdown(), "```cpp\n"
-  "foo`bar`baz\n"
-  "```\n");
+  P = Paragraph();
+  

[PATCH] D71248: [clangd] Introduce paragraph, the first part of new rendering structs

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



Comment at: clang-tools-extra/clangd/FormattedString.cpp:95
+// Concatanates whitespace blocks into a single ` `.
+std::string canonicalizeSpaces(std::string Input) {
+  // Goes over the string and preserves only a single ` ` for any whitespace

sammccall wrote:
> is this equivalent to
> ```
> SmallVector Words;
> llvm::SplitString(Input, Words);
> return llvm::join(Input, " ");
> ```
> ?
> 
> (That would trim leading/trailing whitespace, but I suspect we actually want 
> that)
yes that's exactly what we want, thanks!
not just joining them though, since we could still merge them in-place.



Comment at: clang-tools-extra/clangd/FormattedString.h:30
+  virtual std::string renderAsPlainText() const = 0;
+
+  virtual ~RenderableBlock() = default;

sammccall wrote:
> renderfortests has gone. What's the plan for testing Hover rendering? (i.e. 
> HoverInfo -> Document)
> I guess asserting the plain text and markdown might be enough...
> 
> (Did we remove *all* the tests for `present()`in D70911, and I didn't notice? 
> We should restore some based on synthetic HoverInfo)
yes we I was planning to check using the plaintext output with some "synthetic" 
hoverinfo. Currently only lit tests are checking for the behavior of present.
there's also changes to hover.cpp in this patch to preserve current output. 
happy to add some tests before moving forward, but didn't want to add any as 
they
will change drastically with the new rendering layout.



Comment at: clang-tools-extra/clangd/FormattedString.h:35
+/// Represents parts of the markup that can contain strings, like inline code,
+/// code block or plain text.
+/// Only CodeBlocks guarantees conservation of new lines within text. One must

sammccall wrote:
> A code block doesn't go in a paragraph, as it's a block itself.
> 
> "A paragraph contains a logical line of rich text. It may be wrapped for 
> display"
sending out codeblocks in a new patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71248



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


  1   2   3   >