[PATCH] D87737: Add -fprofile-update={atomic,prefer-atomic,single}

2020-09-16 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think an interesting extension (not in GCC) is `-fprofile-update=set`, a 
boolean counter like `-covermode set` in go: sometimes we don't need the 
numbers at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87737

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


[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a subscriber: hans.
sammccall added a comment.
This revision is now accepted and ready to land.

Argh, sorry. I think this might be too late to get into 11 - we're in the 
"soon=final" stage and maybe any changes at all cause logistical problems? :-(

@hans to confirm - this is a feature that was meant to be in the 11 release 
(and was implemented and tested) but the flag to enable it wasn't wired up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87710

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


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.

Thanks, this seems better than crashing.
The practical result isn't wonderful: the two are going to fight over index 
files to some extent. But this can happen with different clangd versions (that 
use different index format versions) anyway. So this is really just graceful 
recovery from a bad situation.

In D87673#2273347 , @ArcsinX wrote:

> Unsure about test for this

Agree, testing this seems hard and not that useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87673

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


[PATCH] D87745: [clangd] Config: handle Index block

2020-09-16 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
ArcsinX requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Without this patch config parser ignores `Index` block and reports warning 
"Unknown Config key Index".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87745

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -119,6 +119,16 @@
   ASSERT_THAT(Results, IsEmpty());
 }
 
+TEST(ParseYAML, Index) {
+  CapturedDiags Diags;
+  const char *YAML = R"yaml(
+Index:
+  Background: Skip
+  )yaml";
+  auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+}
+
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }


Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -119,6 +119,16 @@
   ASSERT_THAT(Results, IsEmpty());
 }
 
+TEST(ParseYAML, Index) {
+  CapturedDiags Diags;
+  const char *YAML = R"yaml(
+Index:
+  Background: Skip
+  )yaml";
+  auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+}
+
 } // namespace
 } // namespace config
 } // namespace clangd
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87745: [clangd] Config: handle Index block

2020-09-16 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX abandoned this revision.
ArcsinX added a comment.

Sorry, it's already here https://reviews.llvm.org/D87710


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87745

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


[PATCH] D86137: Add ignore-unknown-options flag to clang-format.

2020-09-16 Thread George Rimar via Phabricator via cfe-commits
grimar accepted this revision.
grimar added a comment.
This revision is now accepted and ready to land.

LGTM. It worth wainting for a second approvement and/or other comments to 
verify that people are happy with doing this for `clang-format`.




Comment at: clang/unittests/Format/FormatTest.cpp:16062
   FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int 
i;")));
   auto Style7 = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
   ASSERT_FALSE((bool)Style7);

nit: since you have `Style7b`, this perhaps should be `Style7a`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86137

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


[PATCH] D87673: [clangd] Don't use zlib when it's unavailable.

2020-09-16 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd427df6369f1: [clangd] Don't use zlib when it's 
unavailable. (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87673

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


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,12 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
-  }
+  } else
+return error("Compressed string table, but zlib is unavailable");
 
   StringTableIn Table;
   llvm::StringSaver Saver(Table.Arena);


Index: clang-tools-extra/clangd/index/Serialization.cpp
===
--- clang-tools-extra/clangd/index/Serialization.cpp
+++ clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,12 +201,13 @@
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
-  }
+  } else
+return error("Compressed string table, but zlib is unavailable");
 
   StringTableIn Table;
   llvm::StringSaver Saver(Table.Arena);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d427df6 - [clangd] Don't use zlib when it's unavailable.

2020-09-16 Thread Aleksandr Platonov via cfe-commits
Author: Aleksandr Platonov
Date: 2020-09-16T11:05:18+03:00
New Revision: d427df6369f1d229a9f498b4dc621433ada380d2

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

LOG: [clangd] Don't use zlib when it's unavailable.

Without this patch `clangd` crashes at try to load compressed string table when 
`zlib` is not available.
Example:
- Build `clangd` with MinGW (`zlib` found)
- Build index
- Build `clangd` with Visual Studio compiler (`zlib` not found)
- Try to load index

Reviewed By: sammccall, adamcz

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Serialization.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Serialization.cpp 
b/clang-tools-extra/clangd/index/Serialization.cpp
index c099a30c4d34..e7f65f087b1c 100644
--- a/clang-tools-extra/clangd/index/Serialization.cpp
+++ b/clang-tools-extra/clangd/index/Serialization.cpp
@@ -201,12 +201,13 @@ llvm::Expected 
readStringTable(llvm::StringRef Data) {
   llvm::SmallString<1> UncompressedStorage;
   if (UncompressedSize == 0) // No compression
 Uncompressed = R.rest();
-  else {
+  else if (llvm::zlib::isAvailable()) {
 if (llvm::Error E = llvm::zlib::uncompress(R.rest(), UncompressedStorage,
UncompressedSize))
   return std::move(E);
 Uncompressed = UncompressedStorage;
-  }
+  } else
+return error("Compressed string table, but zlib is unavailable");
 
   StringTableIn Table;
   llvm::StringSaver Saver(Table.Arena);



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


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 292130.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

Address another round of comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -12,15 +12,25 @@
 #include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Shutdown.h"
+#include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -63,15 +73,10 @@
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
-std::unique_ptr openIndex(llvm::StringRef Index) {
-  return loadIndex(Index, /*UseIndex=*/true);
-}
-
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
-  : Index(std::move(Index)) {
+  RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
+  : Index(Index) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -91,7 +96,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const clangd::Symbol &Item) {
+Index.lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -124,7 +129,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
+bool HasMore = Index.fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -155,7 +160,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
+bool HasMore = Index.refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Ref to protobuf: {0}",
@@ -188,7 +193,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->relations(
+Index.relations(
 *Req, [&](const SymbolID &Subject, const clangd::Symbol &Object) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Subject, Object);
   if (!SerializedItem) {
@@ -210,22 +215,56 @@
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
+  clangd::SymbolIndex &Index;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,
+   llvm::IntrusiveRefCntPtr &FS) {
+  auto Status = FS->status(IndexPath);
+  // Current index is different from the one before: no reload is needed.
+  if (!Status || (Status->getLastModificationTime() ==
+  LastStatus.getLastModificationTime() &&
+  Status->getSize() == LastStatus.getSize()))
+return;
+  vlog("Found different index version: existing index was modified at {0}, new "
+   "index was modified at {1}. Attempting to reload.",
+   LastStatus.getLastModificationTime(), Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {
+elog("Failed to load new index. Old index will be served.");
+return;
+  }
+  Index.reset(std::move(NewIndex));
+  log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
+  Status->getLastModificationTime(), Status->getSize());
+  LastStatus = *Status;
+}
+
+void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress

[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:234
+   LastStatus.getLastModificationTime(), 
Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {

kadircet wrote:
> i think we should update `LastStatus` here, as we are going to fail loading 
> the index unless the file changes. so there's no need to retry loading the 
> index if the file hasn't changed.
Sorry, the comment is off, it belongs to the `if` statement above. Here, the 
index file is already different and there is an attempt to reload it. If it 
succeeds, new index replaces the old one and `LastStatus` is updated.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:342
+  HotReloadThread.join();
 }

kadircet wrote:
> nit: `return 0;` ?
No need for that in C++.

https://en.cppreference.com/w/cpp/language/main_function

> 4) The body of the main function does not need to contain the return 
> statement: if control reaches the end of main without encountering a return 
> statement, the effect is that of executing `return 0;`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

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


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 292131.
kbobyrev added a comment.

Update comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -12,15 +12,25 @@
 #include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Shutdown.h"
+#include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -63,15 +73,10 @@
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
-std::unique_ptr openIndex(llvm::StringRef Index) {
-  return loadIndex(Index, /*UseIndex=*/true);
-}
-
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
-  : Index(std::move(Index)) {
+  RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
+  : Index(Index) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -91,7 +96,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const clangd::Symbol &Item) {
+Index.lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -124,7 +129,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
+bool HasMore = Index.fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -155,7 +160,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
+bool HasMore = Index.refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Ref to protobuf: {0}",
@@ -188,7 +193,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->relations(
+Index.relations(
 *Req, [&](const SymbolID &Subject, const clangd::Symbol &Object) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Subject, Object);
   if (!SerializedItem) {
@@ -210,22 +215,56 @@
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
+  clangd::SymbolIndex &Index;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,
+   llvm::IntrusiveRefCntPtr &FS) {
+  auto Status = FS->status(IndexPath);
+  // Requested file is same as loaded index: no reload is needed.
+  if (!Status || (Status->getLastModificationTime() ==
+  LastStatus.getLastModificationTime() &&
+  Status->getSize() == LastStatus.getSize()))
+return;
+  vlog("Found different index version: existing index was modified at {0}, new "
+   "index was modified at {1}. Attempting to reload.",
+   LastStatus.getLastModificationTime(), Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {
+elog("Failed to load new index. Old index will be served.");
+return;
+  }
+  Index.reset(std::move(NewIndex));
+  log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
+  Status->getLastModificationTime(), Status->getSize());
+  LastStatus = *Status;
+}
+
+void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
+  llvm::StringRef IndexPath) {
+  RemoteIndexSe

[PATCH] D87686: [clang-tidy] Improve documentation on Clangd integration

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for doing this! (Agree with Haojian's comments too)




Comment at: clang-tools-extra/docs/clang-tidy/Integrations.rst:10
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using Clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors

nit: lowercase C for clangd


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87686

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


[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

We should check if the mangling matches GCC (or if it depends on -std), if we 
can.




Comment at: clang/lib/AST/Type.cpp:3429
toTypeDependence(E->getDependence()) |
-   (E->isInstantiationDependent() ? TypeDependence::Dependent
-  : TypeDependence::None) |
+   (E->isTypeDependent() ? TypeDependence::Dependent
+ : TypeDependence::None) |

isn't this redudant with toDependence(E->getDependence)?



Comment at: clang/test/SemaCXX/invalid-template-base-specifier.cpp:16
+struct Crash2 : decltype(Alias()) { // expected-note {{in instantiation of 
template type alias 'Alias' requested here}} \
+  expected-error {{base specifier must 
name a class}}
   Crash2(){};

nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87349

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


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

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



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:234
+   LastStatus.getLastModificationTime(), 
Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {

kbobyrev wrote:
> kadircet wrote:
> > i think we should update `LastStatus` here, as we are going to fail loading 
> > the index unless the file changes. so there's no need to retry loading the 
> > index if the file hasn't changed.
> Sorry, the comment is off, it belongs to the `if` statement above. Here, the 
> index file is already different and there is an attempt to reload it. If it 
> succeeds, new index replaces the old one and `LastStatus` is updated.
right and what I am saying is, even if we fail to load the the index we should 
still update the `LastStatus` to prevent redundant retries for a broken index 
file. e.g:

- For some reason a malformed index file is written with mod. time X and size Y.
- Hot reload logic picks it up, the file exists and everything is fine.
- When we try to read the index, we notice it is malformed or for whatever 
reason, deserialization fails.
- Now we exit without updating the `LastStatus`, hence in the next update all 
of this will happen again even though index loading is going to fail again (as 
malformed index is still the same).

We could prevent that redundant loads (and failure logs) by caching the 
`LastStatus` as soon as the file exists.

Does that make sense now?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:342
+  HotReloadThread.join();
 }

kbobyrev wrote:
> kadircet wrote:
> > nit: `return 0;` ?
> No need for that in C++.
> 
> https://en.cppreference.com/w/cpp/language/main_function
> 
> > 4) The body of the main function does not need to contain the return 
> > statement: if control reaches the end of main without encountering a return 
> > statement, the effect is that of executing `return 0;`
right, hence the `nit`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

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


[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-09-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

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


[PATCH] D87749: [SyntaxTree][Synthesis] Implement `deepCopy`

2020-09-16 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
eduucaldas added a reviewer: gribozavr2.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87749

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp

Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -137,6 +137,50 @@
   )txt"));
 }
 
+TEST_P(SynthesisTest, Copy_Synthesized) {
+  buildTree("", GetParam());
+
+  auto *LeafContinue = createLeaf(*Arena, tok::kw_continue);
+  auto *LeafSemiColon = createLeaf(*Arena, tok::semi);
+  auto *StatementContinue = createTree(*Arena,
+   {{LeafContinue, NodeRole::LiteralToken},
+{LeafSemiColon, NodeRole::Unknown}},
+   NodeKind::ContinueStatement);
+
+  auto *Copy = deepCopy(*Arena, StatementContinue);
+  EXPECT_TRUE(
+  treeDumpEqual(Copy, StatementContinue->dump(Arena->getSourceManager(;
+  // FIXME: Test that copy is independent of original, once the Mutations API is
+  // more developed.
+}
+
+TEST_P(SynthesisTest, Copy_Original) {
+  auto *OriginalTree = buildTree("int a;", GetParam());
+
+  auto *Copy = deepCopy(*Arena, OriginalTree);
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+TranslationUnit Detached synthesized
+`-SimpleDeclaration synthesized
+  |-'int' synthesized
+  |-SimpleDeclarator Declarator synthesized
+  | `-'a' synthesized
+  `-';' synthesized
+  )txt"));
+}
+
+TEST_P(SynthesisTest, Copy_Child) {
+  auto *OriginalTree = buildTree("int a;", GetParam());
+
+  auto *Copy = deepCopy(*Arena, OriginalTree->getFirstChild());
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+SimpleDeclaration Detached synthesized
+|-'int' synthesized
+|-SimpleDeclarator Declarator synthesized
+| `-'a' synthesized
+`-';' synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Statement_EmptyStatement) {
   buildTree("", GetParam());
 
Index: clang/lib/Tooling/Syntax/Synthesis.cpp
===
--- clang/lib/Tooling/Syntax/Synthesis.cpp
+++ clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -66,6 +66,27 @@
   return T;
 }
 
+static syntax::Leaf *copyLeaf(syntax::Arena &A, const syntax::Leaf *L) {
+  auto *Leaf = new (A.getAllocator()) syntax::Leaf(L->getToken());
+  if (L->canModify())
+syntax::FactoryImpl::setCanModify(Leaf);
+
+  return Leaf;
+}
+
+syntax::Node *clang::syntax::deepCopy(syntax::Arena &A, const Node *N) {
+  if (const auto *L = dyn_cast(N)) {
+return copyLeaf(A, L);
+  }
+
+  const auto *T = cast(N);
+  auto Children = std::vector>();
+  for (const auto *C = T->getFirstChild(); C; C = C->getNextSibling()) {
+Children.push_back({deepCopy(A, C), C->getRole()});
+  }
+  return clang::syntax::createTree(A, Children, N->getKind());
+}
+
 syntax::EmptyStatement *clang::syntax::createEmptyStatement(syntax::Arena &A) {
   auto *S = new (A.getAllocator()) syntax::EmptyStatement;
   FactoryImpl::setCanModify(S);
Index: clang/include/clang/Tooling/Syntax/BuildTree.h
===
--- clang/include/clang/Tooling/Syntax/BuildTree.h
+++ clang/include/clang/Tooling/Syntax/BuildTree.h
@@ -40,6 +40,13 @@
std::vector> Children,
syntax::NodeKind K);
 
+/// Deep copies `N`.
+///
+/// The copy is detached, i.e. `Parent == NextSibling == nullptr` and
+/// `Role == Detached`.
+/// The copy is synthesized, i.e. `Original == false`.
+syntax::Node *deepCopy(syntax::Arena &A, const syntax::Node *N);
+
 // Synthesis of Syntax Nodes
 clang::syntax::EmptyStatement *createEmptyStatement(clang::syntax::Arena &A);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 292144.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Save last status to prevent redundant updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -12,15 +12,25 @@
 #include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Shutdown.h"
+#include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -63,15 +73,10 @@
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
-std::unique_ptr openIndex(llvm::StringRef Index) {
-  return loadIndex(Index, /*UseIndex=*/true);
-}
-
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
-  : Index(std::move(Index)) {
+  RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
+  : Index(Index) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -91,7 +96,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const clangd::Symbol &Item) {
+Index.lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -124,7 +129,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
+bool HasMore = Index.fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -155,7 +160,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
+bool HasMore = Index.refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Ref to protobuf: {0}",
@@ -188,7 +193,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->relations(
+Index.relations(
 *Req, [&](const SymbolID &Subject, const clangd::Symbol &Object) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Subject, Object);
   if (!SerializedItem) {
@@ -210,22 +215,56 @@
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
+  clangd::SymbolIndex &Index;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,
+   llvm::IntrusiveRefCntPtr &FS) {
+  auto Status = FS->status(IndexPath);
+  // Requested file is same as loaded index: no reload is needed.
+  if (!Status || (Status->getLastModificationTime() ==
+  LastStatus.getLastModificationTime() &&
+  Status->getSize() == LastStatus.getSize()))
+return;
+  vlog("Found different index version: existing index was modified at {0}, new "
+   "index was modified at {1}. Attempting to reload.",
+   LastStatus.getLastModificationTime(), Status->getLastModificationTime());
+  LastStatus = *Status;
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {
+elog("Failed to load new index. Old index will be served.");
+return;
+  }
+  Index.reset(std::move(NewIndex));
+  log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
+  Status->getLastModificationTime(), Status->getSize());
+}
+
+void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAdd

[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:234
+   LastStatus.getLastModificationTime(), 
Status->getLastModificationTime());
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {

kadircet wrote:
> kbobyrev wrote:
> > kadircet wrote:
> > > i think we should update `LastStatus` here, as we are going to fail 
> > > loading the index unless the file changes. so there's no need to retry 
> > > loading the index if the file hasn't changed.
> > Sorry, the comment is off, it belongs to the `if` statement above. Here, 
> > the index file is already different and there is an attempt to reload it. 
> > If it succeeds, new index replaces the old one and `LastStatus` is updated.
> right and what I am saying is, even if we fail to load the the index we 
> should still update the `LastStatus` to prevent redundant retries for a 
> broken index file. e.g:
> 
> - For some reason a malformed index file is written with mod. time X and size 
> Y.
> - Hot reload logic picks it up, the file exists and everything is fine.
> - When we try to read the index, we notice it is malformed or for whatever 
> reason, deserialization fails.
> - Now we exit without updating the `LastStatus`, hence in the next update all 
> of this will happen again even though index loading is going to fail again 
> (as malformed index is still the same).
> 
> We could prevent that redundant loads (and failure logs) by caching the 
> `LastStatus` as soon as the file exists.
> 
> Does that make sense now?
Ahh, I see now, makes sense. Thanks for the explanation!



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:342
+  HotReloadThread.join();
 }

kadircet wrote:
> kbobyrev wrote:
> > kadircet wrote:
> > > nit: `return 0;` ?
> > No need for that in C++.
> > 
> > https://en.cppreference.com/w/cpp/language/main_function
> > 
> > > 4) The body of the main function does not need to contain the return 
> > > statement: if control reaches the end of main without encountering a 
> > > return statement, the effect is that of executing `return 0;`
> right, hence the `nit`
Hm, why do you think it is better then? I'm not sure if adding no-op lines of 
code will increase readability/clarity.

I'm curious now, is there any reason you prefer explicit `return 0;`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

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


[PATCH] D87749: [SyntaxTree][Synthesis] Implement `deepCopy`

2020-09-16 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 292145.
eduucaldas added a comment.

Remove extraneous qualifiers in `createTree`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87749

Files:
  clang/include/clang/Tooling/Syntax/BuildTree.h
  clang/lib/Tooling/Syntax/Synthesis.cpp
  clang/unittests/Tooling/Syntax/SynthesisTest.cpp

Index: clang/unittests/Tooling/Syntax/SynthesisTest.cpp
===
--- clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -137,6 +137,50 @@
   )txt"));
 }
 
+TEST_P(SynthesisTest, Copy_Synthesized) {
+  buildTree("", GetParam());
+
+  auto *LeafContinue = createLeaf(*Arena, tok::kw_continue);
+  auto *LeafSemiColon = createLeaf(*Arena, tok::semi);
+  auto *StatementContinue = createTree(*Arena,
+   {{LeafContinue, NodeRole::LiteralToken},
+{LeafSemiColon, NodeRole::Unknown}},
+   NodeKind::ContinueStatement);
+
+  auto *Copy = deepCopy(*Arena, StatementContinue);
+  EXPECT_TRUE(
+  treeDumpEqual(Copy, StatementContinue->dump(Arena->getSourceManager(;
+  // FIXME: Test that copy is independent of original, once the Mutations API is
+  // more developed.
+}
+
+TEST_P(SynthesisTest, Copy_Original) {
+  auto *OriginalTree = buildTree("int a;", GetParam());
+
+  auto *Copy = deepCopy(*Arena, OriginalTree);
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+TranslationUnit Detached synthesized
+`-SimpleDeclaration synthesized
+  |-'int' synthesized
+  |-SimpleDeclarator Declarator synthesized
+  | `-'a' synthesized
+  `-';' synthesized
+  )txt"));
+}
+
+TEST_P(SynthesisTest, Copy_Child) {
+  auto *OriginalTree = buildTree("int a;", GetParam());
+
+  auto *Copy = deepCopy(*Arena, OriginalTree->getFirstChild());
+  EXPECT_TRUE(treeDumpEqual(Copy, R"txt(
+SimpleDeclaration Detached synthesized
+|-'int' synthesized
+|-SimpleDeclarator Declarator synthesized
+| `-'a' synthesized
+`-';' synthesized
+  )txt"));
+}
+
 TEST_P(SynthesisTest, Statement_EmptyStatement) {
   buildTree("", GetParam());
 
Index: clang/lib/Tooling/Syntax/Synthesis.cpp
===
--- clang/lib/Tooling/Syntax/Synthesis.cpp
+++ clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -66,6 +66,27 @@
   return T;
 }
 
+static syntax::Leaf *copyLeaf(syntax::Arena &A, const syntax::Leaf *L) {
+  auto *Leaf = new (A.getAllocator()) syntax::Leaf(L->getToken());
+  if (L->canModify())
+syntax::FactoryImpl::setCanModify(Leaf);
+
+  return Leaf;
+}
+
+syntax::Node *clang::syntax::deepCopy(syntax::Arena &A, const Node *N) {
+  if (const auto *L = dyn_cast(N)) {
+return copyLeaf(A, L);
+  }
+
+  const auto *T = cast(N);
+  auto Children = std::vector>();
+  for (const auto *C = T->getFirstChild(); C; C = C->getNextSibling()) {
+Children.push_back({deepCopy(A, C), C->getRole()});
+  }
+  return createTree(A, Children, N->getKind());
+}
+
 syntax::EmptyStatement *clang::syntax::createEmptyStatement(syntax::Arena &A) {
   auto *S = new (A.getAllocator()) syntax::EmptyStatement;
   FactoryImpl::setCanModify(S);
Index: clang/include/clang/Tooling/Syntax/BuildTree.h
===
--- clang/include/clang/Tooling/Syntax/BuildTree.h
+++ clang/include/clang/Tooling/Syntax/BuildTree.h
@@ -40,6 +40,13 @@
std::vector> Children,
syntax::NodeKind K);
 
+/// Deep copies `N`.
+///
+/// The copy is detached, i.e. `Parent == NextSibling == nullptr` and
+/// `Role == Detached`.
+/// The copy is synthesized, i.e. `Original == false`.
+syntax::Node *deepCopy(syntax::Arena &A, const syntax::Node *N);
+
 // Synthesis of Syntax Nodes
 clang::syntax::EmptyStatement *createEmptyStatement(clang::syntax::Arena &A);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!




Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:342
+  HotReloadThread.join();
 }

kbobyrev wrote:
> kadircet wrote:
> > kbobyrev wrote:
> > > kadircet wrote:
> > > > nit: `return 0;` ?
> > > No need for that in C++.
> > > 
> > > https://en.cppreference.com/w/cpp/language/main_function
> > > 
> > > > 4) The body of the main function does not need to contain the return 
> > > > statement: if control reaches the end of main without encountering a 
> > > > return statement, the effect is that of executing `return 0;`
> > right, hence the `nit`
> Hm, why do you think it is better then? I'm not sure if adding no-op lines of 
> code will increase readability/clarity.
> 
> I'm curious now, is there any reason you prefer explicit `return 0;`?
I suppose, mostly aesthetics and being used to it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

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


[PATCH] D87686: [clang-tidy] Improve documentation on Clangd integration

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 292149.
kbobyrev marked 3 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87686

Files:
  clang-tools-extra/docs/clang-tidy/Integrations.rst


Index: clang-tools-extra/docs/clang-tidy/Integrations.rst
===
--- clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -2,12 +2,17 @@
 Clang-tidy IDE/Editor Integrations
 ==
 
-.. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _clangd: http://clangd.llvm.org/
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
+.. _more: https://langserver.org/#implementations-client
 
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors
+through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
+
+The following table shows the most well-known :program:`clang-tidy`
+integrations in detail.
 
 
+--++-+--+-+--+
 |  |Feature

   |
@@ -17,8 +22,8 @@
 |A.L.E. for Vim| \+\|  
 \-\   |   \-\| \-\ 
|   \+\|
 
+--++-+--+-+--+
 |Clang Power Tools for Visual Studio   | \-\|  
 \+\   |   \-\| \+\ 
|   \-\|
-+--++-+--+-+--+
-|Clangd| \+\|  
 \-\   |   \-\| \-\ 
|   \-\|
++-++-+--+-+--+
+|Clangd| \+\|  
 \-\   |   \-\| \+\ 
|   \-\|
 
+--++-+--+-+--+
 |CLion IDE | \+\|  
 \+\   |   \+\| \+\ 
|   \+\|
 
+--++-+--+-+--+


Index: clang-tools-extra/docs/clang-tidy/Integrations.rst
===
--- clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -2,12 +2,17 @@
 Clang-tidy IDE/Editor Integrations
 ==
 
-.. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _clangd: http://clangd.llvm.org/
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
+.. _more: https://langserver.org/#implementations-client
 
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors
+through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
+
+The following table shows the most well-known

[clang-tools-extra] 3a0a2a6 - [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via cfe-commits
Author: Kirill Bobyrev
Date: 2020-09-16T11:12:14+02:00
New Revision: 3a0a2a6347f5a79ebfba2cc2b763dd02001d9baa

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

LOG: [clangd] Implement hot index reloading for clangd-index-server

This patch adds a mechanism to load new versions of index into
clangd-index-server using SwapIndex and FileStatus information about last
modification time without downtime.

Reviewed By: kadircet

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/server/Server.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/server/Server.cpp 
b/clang-tools-extra/clangd/index/remote/server/Server.cpp
index e9838cce85e3..d8cf54249662 100644
--- a/clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ b/clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -12,15 +12,25 @@
 #include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Shutdown.h"
+#include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -63,15 +73,10 @@ llvm::cl::opt ServerAddress(
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 
0.0.0.0:50051"));
 
-std::unique_ptr openIndex(llvm::StringRef Index) {
-  return loadIndex(Index, /*UseIndex=*/true);
-}
-
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
-  : Index(std::move(Index)) {
+  RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
+  : Index(Index) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -91,7 +96,7 @@ class RemoteIndexServer final : public SymbolIndex::Service {
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const clangd::Symbol &Item) {
+Index.lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -124,7 +129,7 @@ class RemoteIndexServer final : public SymbolIndex::Service 
{
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
+bool HasMore = Index.fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -155,7 +160,7 @@ class RemoteIndexServer final : public SymbolIndex::Service 
{
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
+bool HasMore = Index.refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Ref to protobuf: {0}",
@@ -188,7 +193,7 @@ class RemoteIndexServer final : public SymbolIndex::Service 
{
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->relations(
+Index.relations(
 *Req, [&](const SymbolID &Subject, const clangd::Symbol &Object) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Subject, 
Object);
   if (!SerializedItem) {
@@ -210,22 +215,56 @@ class RemoteIndexServer final : public 
SymbolIndex::Service {
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
+  clangd::SymbolIndex &Index;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,
+   llvm::IntrusiveRefCntPtr &FS) {
+  auto Status = FS->status(IndexPath);
+  // Requested file is same as loaded index: no reload is needed.
+  if (!Status || (Status->getLastModi

[PATCH] D87450: [clangd] Implement hot index reloading for clangd-index-server

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a0a2a6347f5: [clangd] Implement hot index reloading for 
clangd-index-server (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87450

Files:
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -12,15 +12,25 @@
 #include "index/Symbol.h"
 #include "index/remote/marshalling/Marshalling.h"
 #include "support/Logger.h"
+#include "support/Shutdown.h"
+#include "support/ThreadsafeFS.h"
 #include "support/Trace.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Chrono.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Signals.h"
+#include "llvm/Support/VirtualFileSystem.h"
 
+#include 
 #include 
 #include 
+#include 
+#include 
 
 #include "Index.grpc.pb.h"
 
@@ -63,15 +73,10 @@
 "server-address", llvm::cl::init("0.0.0.0:50051"),
 llvm::cl::desc("Address of the invoked server. Defaults to 0.0.0.0:50051"));
 
-std::unique_ptr openIndex(llvm::StringRef Index) {
-  return loadIndex(Index, /*UseIndex=*/true);
-}
-
 class RemoteIndexServer final : public SymbolIndex::Service {
 public:
-  RemoteIndexServer(std::unique_ptr Index,
-llvm::StringRef IndexRoot)
-  : Index(std::move(Index)) {
+  RemoteIndexServer(clangd::SymbolIndex &Index, llvm::StringRef IndexRoot)
+  : Index(Index) {
 llvm::SmallString<256> NativePath = IndexRoot;
 llvm::sys::path::native(NativePath);
 ProtobufMarshaller = std::unique_ptr(new Marshaller(
@@ -91,7 +96,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->lookup(*Req, [&](const clangd::Symbol &Item) {
+Index.lookup(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -124,7 +129,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
+bool HasMore = Index.fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Symbol to protobuf: {0}",
@@ -155,7 +160,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
+bool HasMore = Index.refs(*Req, [&](const clangd::Ref &Item) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
   if (!SerializedItem) {
 elog("Unable to convert Ref to protobuf: {0}",
@@ -188,7 +193,7 @@
 }
 unsigned Sent = 0;
 unsigned FailedToSend = 0;
-Index->relations(
+Index.relations(
 *Req, [&](const SymbolID &Subject, const clangd::Symbol &Object) {
   auto SerializedItem = ProtobufMarshaller->toProtobuf(Subject, Object);
   if (!SerializedItem) {
@@ -210,22 +215,56 @@
 return grpc::Status::OK;
   }
 
-  std::unique_ptr Index;
   std::unique_ptr ProtobufMarshaller;
+  clangd::SymbolIndex &Index;
 };
 
-void runServer(std::unique_ptr Index,
-   const std::string &ServerAddress) {
-  RemoteIndexServer Service(std::move(Index), IndexRoot);
+// Detect changes in \p IndexPath file and load new versions of the index
+// whenever they become available.
+void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
+   llvm::vfs::Status &LastStatus,
+   llvm::IntrusiveRefCntPtr &FS) {
+  auto Status = FS->status(IndexPath);
+  // Requested file is same as loaded index: no reload is needed.
+  if (!Status || (Status->getLastModificationTime() ==
+  LastStatus.getLastModificationTime() &&
+  Status->getSize() == LastStatus.getSize()))
+return;
+  vlog("Found different index version: existing index was modified at {0}, new "
+   "index was modified at {1}. Attempting to reload.",
+   LastStatus.getLastModificationTime(), Status->getLastModificationTime());
+  LastStatus = *Status;
+  std::unique_ptr NewIndex = loadIndex(IndexPath);
+  if (!NewIndex) {
+elog("Failed to load new index. Old index will be served.");
+return;
+  }
+  Index.reset(std::move(NewIndex));
+  log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
+  Status->getLastModificationTime(), Status->getSize

[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 292151.
baloghadamsoftware added a comment.

`std::size_t` defined correctly in the tests.


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

https://reviews.llvm.org/D87683

Files:
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,14 @@
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+namespace std {
+typedef decltype(sizeof(void*)) size_t;
+}
+
+void* operator new(std::size_t, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is 
applied to the result of operator new() instead of its size-like argument
+}
Index: 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,14 @@
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+namespace std {
+typedef decltype(sizeof(void*)) size_t;
+}
+
+void* operator new(std::size_t, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+}
Index: clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D87710#2275933 , @sammccall wrote:

> Argh, sorry. I think this might be too late to get into 11 - we're in the 
> "soon=final" stage and maybe any changes at all cause logistical problems? :-(
>
> @hans to confirm - this is a feature that was meant to be in the 11 release 
> (and was implemented and tested) but the flag to enable it wasn't wired up.

Okay, I'll cherry-pick it once it lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87710

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


[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

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



Comment at: clang/lib/AST/ASTContext.cpp:8522
+  return VT->getElementType().getCanonicalType() ==
+ getBuiltinVectorTypeInfo(BT).ElementType;
   }

efriedma wrote:
> c-rhodes wrote:
> > efriedma wrote:
> > > We allow casting SVE fixed-width vectors only if the element type is 
> > > identical, but we allow casting to GNU fixed-width vectors if the vector 
> > > width is the same?  That seems sort of loose; could allow weird casts, 
> > > particularly when bool vectors are involved.
> > > We allow casting SVE fixed-width vectors only if the element type is 
> > > identical, but we allow casting to GNU fixed-width vectors if the vector 
> > > width is the same? That seems sort of loose; could allow weird casts, 
> > > particularly when bool vectors are involved.
> > 
> > Fixed-length SVE vectors are created with the attribute and the vector 
> > width must match `-msve-vector-bits`, which should guarantee consistent 
> > vector widths for a given input. This is checking the vector width is the 
> > same and the element type matches when casting between GNU and SVE vectors, 
> > although since neither of those types are created by the attribute it's 
> > necessary to check the vector width to validate `__ARM_FEATURE_SVE_BITS==N`.
> > 
> > Predicates are treated differently in the ACLE and it doesn't mention 
> > supporting casts between GNU bool vectors and SVE VLS/VLA predicates. I'm 
> > also not sure the GNU vector_size extension is defined for bool elements 
> > yet, but I did notice Simon Moll is working on this (D81083).
> I think you need to check both the size and the element type here?
> I think you need to check both the size and the element type here?

Compare the size of a scalable and fixed-length vector?


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

https://reviews.llvm.org/D87607

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


[PATCH] D87686: [clang-tidy] Improve documentation on Clangd integration

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

thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87686

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


[clang-tools-extra] a909a84 - [clang-tidy] Improve documentation on Clangd integration

2020-09-16 Thread Kirill Bobyrev via cfe-commits
Author: Kirill Bobyrev
Date: 2020-09-16T12:10:00+02:00
New Revision: a909a84ef2d9220242512b8be1206ee3d9b3d8b9

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

LOG: [clang-tidy] Improve documentation on Clangd integration

The integration is already complete; this patch updates information as well as
suggests using Clang-Tidy via Clangd integration that is vastly available
in most editors through LSP client plugins.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/Integrations.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/Integrations.rst 
b/clang-tools-extra/docs/clang-tidy/Integrations.rst
index bdd012aec89e..94851631fe1f 100644
--- a/clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ b/clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -2,12 +2,17 @@
 Clang-tidy IDE/Editor Integrations
 ==
 
-.. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _clangd: http://clangd.llvm.org/
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
+.. _more: https://langserver.org/#implementations-client
 
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors
+through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
+
+The following table shows the most well-known :program:`clang-tidy`
+integrations in detail.
 
 
+--++-+--+-+--+
 |  |Feature

   |
@@ -17,8 +22,8 @@ well-known :program:`clang-tidy` integrations in detail.
 |A.L.E. for Vim| \+\|  
 \-\   |   \-\| \-\ 
|   \+\|
 
+--++-+--+-+--+
 |Clang Power Tools for Visual Studio   | \-\|  
 \+\   |   \-\| \+\ 
|   \-\|
-+--++-+--+-+--+
-|Clangd| \+\|  
 \-\   |   \-\| \-\ 
|   \-\|
++-++-+--+-+--+
+|Clangd| \+\|  
 \-\   |   \-\| \+\ 
|   \-\|
 
+--++-+--+-+--+
 |CLion IDE | \+\|  
 \+\   |   \+\| \+\ 
|   \+\|
 
+--++-+--+-+--+



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


[PATCH] D87686: [clang-tidy] Improve documentation on Clangd integration

2020-09-16 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa909a84ef2d9: [clang-tidy] Improve documentation on Clangd 
integration (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87686

Files:
  clang-tools-extra/docs/clang-tidy/Integrations.rst


Index: clang-tools-extra/docs/clang-tidy/Integrations.rst
===
--- clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -2,12 +2,17 @@
 Clang-tidy IDE/Editor Integrations
 ==
 
-.. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _clangd: http://clangd.llvm.org/
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
+.. _more: https://langserver.org/#implementations-client
 
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors
+through plugins (Vim, Emacs, Visual Studio Code, Sublime Text and more_).
+
+The following table shows the most well-known :program:`clang-tidy`
+integrations in detail.
 
 
+--++-+--+-+--+
 |  |Feature

   |
@@ -17,8 +22,8 @@
 |A.L.E. for Vim| \+\|  
 \-\   |   \-\| \-\ 
|   \+\|
 
+--++-+--+-+--+
 |Clang Power Tools for Visual Studio   | \-\|  
 \+\   |   \-\| \+\ 
|   \-\|
-+--++-+--+-+--+
-|Clangd| \+\|  
 \-\   |   \-\| \-\ 
|   \-\|
++-++-+--+-+--+
+|Clangd| \+\|  
 \-\   |   \-\| \+\ 
|   \-\|
 
+--++-+--+-+--+
 |CLion IDE | \+\|  
 \+\   |   \+\| \+\ 
|   \+\|
 
+--++-+--+-+--+


Index: clang-tools-extra/docs/clang-tidy/Integrations.rst
===
--- clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -2,12 +2,17 @@
 Clang-tidy IDE/Editor Integrations
 ==
 
-.. _Clangd: https://clang.llvm.org/extra/clangd.html
+.. _clangd: http://clangd.llvm.org/
+.. _is available: https://clangd.llvm.org/installation.html#editor-plugins
+.. _more: https://langserver.org/#implementations-client
 
 Apart from being a standalone tool, :program:`clang-tidy` is integrated into
-various IDEs, code analyzers, and editors. Besides, it is currently being
-integrated into Clangd_. The following table shows the most
-well-known :program:`clang-tidy` integrations in detail.
+various IDEs, code analyzers, and editors. We recommend using clangd_ which
+integrates :program:`clang-tidy` and `is available`_ in most major editors
+through plugins (Vim

[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

2020-09-16 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 292162.
c-rhodes added a comment.

Address comments


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

https://reviews.llvm.org/D87607

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -1,14 +1,26 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
 // expected-no-diagnostics
 
+#include 
+
 #define N __ARM_FEATURE_SVE_BITS
 
 typedef __SVInt8_t svint8_t;
 typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+typedef int8_t gnu_int8_t __attribute__((vector_size(N / 8)));
 
 template struct S { T var; };
 
 S s;
 
+// Test implicit casts between VLA and VLS vectors
 svint8_t to_svint8_t(fixed_int8_t x) { return x; }
 fixed_int8_t from_svint8_t(svint8_t x) { return x; }
+
+// Test implicit casts between GNU and VLA vectors
+svint8_t to_svint8_t__from_gnu_int8_t(gnu_int8_t x) { return x; }
+gnu_int8_t from_svint8_t__to_gnu_int8_t(svint8_t x) { return x; }
+
+// Test implicit casts between GNU and VLS vectors
+fixed_int8_t to_fixed_int8_t__from_gnu_int8_t(gnu_int8_t x) { return x; }
+gnu_int8_t from_fixed_int8_t__to_gnu_int8_t(fixed_int8_t x) { return x; }
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=128 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=256 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=128 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=256 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -ffreestanding -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
+
+#include 
 
 #define N __ARM_FEATURE_SVE_BITS
 
+typedef __fp16 float16_t;
+typedef float float32_t;
+typedef double float64_t;
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
 typedef __SVInt32_t svint32_t;
@@ -19,6 +24,7 @@
 typedef __SVFloat64_t svfloat64_t;
 
 #if defined(__ARM_FEATURE_SVE_BF16)
+typedef __bf16 bfloat16_t;
 typedef __SVBFloat16_t svbfloat16_t;
 #endif
 
@@ -43,6 +49,23 @@
 
 typedef svbool_t fixed_bool_t __attribute__((arm_sve_vector_bits(N)));
 
+// GNU vector types
+typedef int8_t gnu_int8_t __attribute__((vector_size(N / 8)));
+typedef int16_t gnu_int16_t __attribute__((vector_size(N / 8)));
+typedef int32_t gnu_int32_t __attribute__((vector_size(N / 8)));
+typedef int64_t gnu_int64_t __attribute__((vector_size(N / 8)));
+
+typedef uint8_t gnu_uint8_t __attribute__((vector_size(N / 8)));
+typedef uint16_t gnu_uint16_t __attribute__((vector_size(N / 8)));
+typedef uint32_t gnu_uint32_t __attribute__((vector_size(N / 8)));
+typedef uint64_t gnu_uint64_t __attribute__((vector_size(N / 8)));
+
+typedef float16_t gnu_float16_t 

[PATCH] D87607: [clang][aarch64] Support implicit casts between GNU and SVE vectors

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



Comment at: clang/test/Sema/attr-arm-sve-vector-bits.c:237
+// Test implicit conversion between SVE and GNU vector is invalid when
+// __ARM_FEATURE_SVE_BITS != N
+#if defined(__ARM_FEATURE_SVE_BITS) && __ARM_FEATURE_SVE_BITS == 512

efriedma wrote:
> This test isn't checking what it says it is; int4 and svint64_t have 
> different element types.
> This test isn't checking what it says it is; int4 and svint64_t have 
> different element types.

Good spot! Fixed


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

https://reviews.llvm.org/D87607

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


[PATCH] D81272: [clang-tidy] New check `bugprone-redundant-branch-condition`

2020-09-16 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Thanks for this checker. FYI, it found (at least) 3 defects in Firefox code:
https://hg.mozilla.org/mozilla-central/rev/651e68f628d0

https://bugzilla.mozilla.org/show_bug.cgi?id=1664747
(unlikely that it was causing any actual bugs in the product)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81272

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


[clang-tools-extra] 3e5a4ef - Fix table formatting after D87686

2020-09-16 Thread Kirill Bobyrev via cfe-commits
Author: Kirill Bobyrev
Date: 2020-09-16T12:27:59+02:00
New Revision: 3e5a4ef51a1d0def10525b2059f5cdab0cb0ae8d

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

LOG: Fix table formatting after D87686

Added: 


Modified: 
clang-tools-extra/docs/clang-tidy/Integrations.rst

Removed: 




diff  --git a/clang-tools-extra/docs/clang-tidy/Integrations.rst 
b/clang-tools-extra/docs/clang-tidy/Integrations.rst
index 94851631fe1f6..c81a00deb68ad 100644
--- a/clang-tools-extra/docs/clang-tidy/Integrations.rst
+++ b/clang-tools-extra/docs/clang-tidy/Integrations.rst
@@ -22,7 +22,7 @@ integrations in detail.
 |A.L.E. for Vim| \+\|  
 \-\   |   \-\| \-\ 
|   \+\|
 
+--++-+--+-+--+
 |Clang Power Tools for Visual Studio   | \-\|  
 \+\   |   \-\| \+\ 
|   \-\|
-+-++-+--+-+--+
++--++-+--+-+--+
 |Clangd| \+\|  
 \-\   |   \-\| \+\ 
|   \-\|
 
+--++-+--+-+--+
 |CLion IDE | \+\|  
 \+\   |   \+\| \+\ 
|   \+\|



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


[PATCH] D87527: [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`

2020-09-16 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 292170.
baloghadamsoftware added a comment.

Checker `modernize-use-equals-delete` adjusted.


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

https://reviews.llvm.org/D87527

Files:
  clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1454,10 +1454,49 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+}
+
+TEST(HasBody, FindsBodyOfFunctions) {
   EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
   EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
-  EXPECT_TRUE(matches("void f(); void f() {}",
-  functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(); void f() {}",
+  functionDecl(hasBody(compoundStmt())).bind("func"),
+  std::make_unique>("func", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { void f(); }; void C::f() {}",
+  cxxMethodDecl(hasBody(compoundStmt())).bind("met"),
+  std::make_unique>("met", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { C(); }; C::C() {}",
+  cxxConstructorDecl(hasBody(compoundStmt())).bind("ctr"),
+  std::make_unique>("ctr", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { ~C(); }; C::~C() {}",
+  cxxDestructorDecl(hasBody(compoundStmt())).bind("dtr"),
+  std::make_unique>("dtr", 1)));
+}
+
+TEST(HasAnyBody, FindsAnyBodyOfFunctions) {
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasAnyBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();",
+ functionDecl(hasAnyBody(compoundStmt();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(); void f() {}",
+  functionDecl(hasAnyBody(compoundStmt())).bind("func"),
+  std::make_unique>("func", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { void f(); }; void C::f() {}",
+  cxxMethodDecl(hasAnyBody(compoundStmt())).bind("met"),
+  std::make_unique>("met", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { C(); }; C::C() {}",
+  cxxConstructorDecl(hasAnyBody(compoundStmt())).bind("ctr"),
+  std::make_unique>("ctr", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { ~C(); }; C::~C() {}",
+  cxxDestructorDecl(hasAnyBody(compoundStmt())).bind("dtr"),
+  std::make_unique>("dtr", 2)));
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1835,18 +1835,18 @@
   DynTypedNode Node;
 };
 
+template  struct GetBodyMatcher {
+  static const Stmt *get(const Ty &Node) { return Node.getBody(); }
+};
+
 template 
-struct GetBodyMatcher {
+struct GetBodyMatcher::value>::type> {
   static const Stmt *get(const Ty &Node) {
-return Node.getBody();
+return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
   }
 };
 
-template <>
-inline const Stmt *GetBodyMatcher::get(const FunctionDecl &Node) {
-  return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
-}
-
 template 
 struct HasSizeMatcher {
   static bool hasSize(const Ty &Node, unsigned int N) {
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4769,7 +4769,9 @@
 }
 
 /// Matches a 'for', 'while', 'do while' statement or a function
-/// definition that has a given body.
+/// definition that has a given body. Note that in case of functions
+/// this matcher only matches the definition itself and not the other
+/// declarations of the same function.
 ///
 /// Given
 /// \code
@@ -4779,6 +4781,18 @@
 ///   matches 'for (;;) {}'
 /// with compoundStmt()
 ///   matching '{}'
+///
+/// Given
+/// \code
+///   void f();
+///   void f() {}
+/// \endcode
+/// hasBody(functionDecl())
+///   matches 'void f() {}'
+/// with compoundStmt()
+///   matching '{}'
+///   but does not match 'void f();'
+
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
@@ -4790,6 +

[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

2020-09-16 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 292153.
ro added a comment.

- Rely on `stackAlignment` default for 32-bit Solaris/x86
- Handle Solaris in `llvm/test/CodeGen/X86/stack-align2.ll`

Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

Files:
  compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
  llvm/lib/Target/X86/X86Subtarget.cpp
  llvm/test/CodeGen/X86/stack-align2.ll


Index: llvm/test/CodeGen/X86/stack-align2.ll
===
--- llvm/test/CodeGen/X86/stack-align2.ll
+++ llvm/test/CodeGen/X86/stack-align2.ll
@@ -2,10 +2,12 @@
 ; RUN: llc < %s -mcpu=generic -mtriple=i386-kfreebsd | FileCheck %s 
-check-prefix=KFREEBSD-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=i386-netbsd | FileCheck %s 
-check-prefix=NETBSD-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=i686-apple-darwin8 | FileCheck %s 
-check-prefix=DARWIN-I386
+; RUN: llc < %s -mcpu=generic -mtriple=i386-pc-solaris2.11 | FileCheck %s 
-check-prefix=SOLARIS-I386
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux | FileCheck %s 
-check-prefix=LINUX-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-kfreebsd | FileCheck %s 
-check-prefix=KFREEBSD-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-netbsd | FileCheck %s 
-check-prefix=NETBSD-X86_64
 ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-apple-darwin8 | FileCheck %s 
-check-prefix=DARWIN-X86_64
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-pc-solaris2.11 | FileCheck %s 
-check-prefix=SOLARIS-X86_64
 
 define i32 @test() nounwind {
 entry:
@@ -15,7 +17,8 @@
 ; LINUX-I386: subl $12, %esp
 ; KFREEBSD-I386:  subl $12, %esp
 ; DARWIN-I386:subl $12, %esp
-; NETBSD-I386-NOT: subl{{.*}}, %esp
+; NETBSD-I386-NOT:  subl   {{.*}}, %esp
+; SOLARIS-I386-NOT: subl   {{.*}}, %esp
 
 ; LINUX-X86_64:  pushq %{{.*}}
 ; LINUX-X86_64-NOT:  subq  {{.*}}, %rsp
@@ -23,6 +26,8 @@
 ; DARWIN-X86_64-NOT: subq  {{.*}}, %rsp
 ; NETBSD-X86_64: pushq %{{.*}}
 ; NETBSD-X86_64-NOT: subq  {{.*}}, %rsp
+; SOLARIS-X86_64: pushq %{{.*}}
+; SOLARIS-X86_64-NOT: subq {{.*}}, %rsp
 ; KFREEBSD-X86_64: pushq %{{.*}}
 ; KFREEBSD-X86_64-NOT: subq{{.*}}, %rsp
 }
Index: llvm/lib/Target/X86/X86Subtarget.cpp
===
--- llvm/lib/Target/X86/X86Subtarget.cpp
+++ llvm/lib/Target/X86/X86Subtarget.cpp
@@ -258,12 +258,13 @@
 report_fatal_error("64-bit code requested on a subtarget that doesn't "
"support it!");
 
-  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and Solaris (both
-  // 32 and 64 bit) and for all 64-bit targets.
+  // Stack alignment is 16 bytes on Darwin, Linux, kFreeBSD and for all
+  // 64-bit targets.  On Solaris (32-bit), stack alignment is 4 bytes
+  // following the i386 psABI, while on Illumos it is always 16 bytes.
   if (StackAlignOverride)
 stackAlignment = *StackAlignOverride;
-  else if (isTargetDarwin() || isTargetLinux() || isTargetSolaris() ||
-   isTargetKFreeBSD() || In64BitMode)
+  else if (isTargetDarwin() || isTargetLinux() || isTargetKFreeBSD() ||
+   In64BitMode)
 stackAlignment = Align(16);
 
   // Consume the vector width attribute or apply any target specific limit.
Index: compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp
@@ -162,7 +162,7 @@
   case 'm':
 // CHECK-MEMBER: vptr.cpp:[[@LINE+6]]:15: runtime error: member access 
within address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
 // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']]
-// CHECK-MEMBER-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
+// CHECK-MEMBER-NEXT: {{^  ?.. .. .. ..  ?.. .. .. ..  ?.. .. .. ..  ?}}
 // CHECK-MEMBER-NEXT: {{^  \^~~()? *$}}
 // CHECK-MEMBER-NEXT: {{^  vptr for}} [[DYN_TYPE]]
 // CHECK-Linux-MEMBER: #0 {{.*}}access_p{{.*}}vptr.cpp:[[@LINE+1]]
@@ -178,7 +178,7 @@
   case 'f':
 // CHECK-MEMFUN: vptr.cpp:[[@LINE+6]]:15: runtime error: member call on 
address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
 // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type [[DYN_TYPE:'S'|'U']]
-// CHECK-MEMFUN-NEXT: {{^ .. .. .. ..  .. .. .. .. .. .. .. ..  }}
+// CHECK-MEMFUN-NEXT: {{^  ?.. .. .. ..  ?.. .. .. ..  ?.. .. .. ..  ?}}
 // CHECK-MEMFUN-NEXT: {{^  \^~~()? *$}}
 // CHECK-MEMFUN-NEXT: {{^  vptr for}} [[DYN_TYPE]]
 // TODO: Add check for stacktrace here.
@@ -196,7 +196,7 @@
   case 'c':
 // CHECK-DOWNCAST: vptr.cpp:[[@LINE+6]]:11: runtime error: downcas

[PATCH] D87615: [X86] Fix stack alignment on 32-bit Solaris/x86

2020-09-16 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D87615#2275045 , @efriedma wrote:

> Also, it would be nice to have some regression test coverage; add a Solaris 
> RUN line to llvm/test/CodeGen/X86/stack-align2.ll ?

Sure, done in the updated patch.  I'd checked that if `FAIL`s with `llc 
-mtriple=i386-pc-solaris2.11 --stack-alignment=16`




Comment at: llvm/lib/Target/X86/X86Subtarget.cpp:270
+  else if (isTargetSolaris() && !In64BitMode)
+stackAlignment = Align(4);
 

efriedma wrote:
> stackAlignment is initialized to 4 in the header, so `stackAlignment = 
> Align(4)` here is a no-op.
Ah, I missed that.  Fixed in the updated patch.  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87615

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


[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-16 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7029e5d4ca20: [clangd] Actually parse Index section of the 
YAML file. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87710

Files:
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp


Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -47,16 +47,21 @@
   Add: |
 b
 az
+---
+Index:
+  Background: Skip
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  ASSERT_EQ(Results.size(), 2u);
-  EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
-  EXPECT_THAT(Results.front().CompileFlags.Add,
-  ElementsAre(Val("foo"), Val("bar")));
+  ASSERT_EQ(Results.size(), 3u);
+  EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
+  EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), 
Val("bar")));
+
+  EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(Val("b\naz\n")));
 
-  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+  ASSERT_TRUE(Results[2].Index.Background);
+  EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }


Index: clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -47,16 +47,21 @@
   Add: |
 b
 az
+---
+Index:
+  Background: Skip
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  ASSERT_EQ(Results.size(), 2u);
-  EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
-  EXPECT_THAT(Results.front().CompileFlags.Add,
-  ElementsAre(Val("foo"), Val("bar")));
+  ASSERT_EQ(Results.size(), 3u);
+  EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
+  EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), Val("bar")));
+
+  EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(Val("b\naz\n")));
 
-  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+  ASSERT_TRUE(Results[2].Index.Background);
+  EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
 }
 
 TEST(ParseYAML, Locations) {
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 7029e5d - [clangd] Actually parse Index section of the YAML file.

2020-09-16 Thread Adam Czachorowski via cfe-commits
Author: Adam Czachorowski
Date: 2020-09-16T13:11:02+02:00
New Revision: 7029e5d4ca20d20982da8efe89de27acd8d7d75b

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

LOG: [clangd] Actually parse Index section of the YAML file.

This fixes a bug in dbf486c0de92c76df77c1a1f815cf16533ecbb3a, which
introduced the Index section of the config, but did not register the
parse method, so it didn't work in a YAML file (but did in a test).

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

Added: 


Modified: 
clang-tools-extra/clangd/ConfigYAML.cpp
clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 16639f6649c2..9988fe376648 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@ class Parser {
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }

diff  --git a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp 
b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
index a9526ce2367c..27b1c0cfc56d 100644
--- a/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
+++ b/clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
@@ -47,16 +47,21 @@ CompileFlags: { Add: [foo, bar] }
   Add: |
 b
 az
+---
+Index:
+  Background: Skip
   )yaml";
   auto Results = Fragment::parseYAML(YAML, "config.yaml", Diags.callback());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
-  ASSERT_EQ(Results.size(), 2u);
-  EXPECT_FALSE(Results.front().If.HasUnrecognizedCondition);
-  EXPECT_THAT(Results.front().If.PathMatch, ElementsAre(Val("abc")));
-  EXPECT_THAT(Results.front().CompileFlags.Add,
-  ElementsAre(Val("foo"), Val("bar")));
+  ASSERT_EQ(Results.size(), 3u);
+  EXPECT_FALSE(Results[0].If.HasUnrecognizedCondition);
+  EXPECT_THAT(Results[0].If.PathMatch, ElementsAre(Val("abc")));
+  EXPECT_THAT(Results[0].CompileFlags.Add, ElementsAre(Val("foo"), 
Val("bar")));
+
+  EXPECT_THAT(Results[1].CompileFlags.Add, ElementsAre(Val("b\naz\n")));
 
-  EXPECT_THAT(Results.back().CompileFlags.Add, ElementsAre(Val("b\naz\n")));
+  ASSERT_TRUE(Results[2].Index.Background);
+  EXPECT_EQ("Skip", *Results[2].Index.Background.getValue());
 }
 
 TEST(ParseYAML, Locations) {



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


[PATCH] D87587: [clang-format][PR47290] Make one-line namespaces resistant to FixNamespaceComments, update documentation

2020-09-16 Thread Krystian Kuzniarek via Phabricator via cfe-commits
kuzkry added a comment.

Thanks @MyDeveloperDay, I appreciate your input in this review. You're a good 
reviewer. :)
Also, I think you've made some good points there and I'm going to turn this 
review into "non-breaking the world" one. I'll be back in a few days with a new 
diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87587

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


[clang-tools-extra] 779a2a2 - [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-16 Thread Adam Balogh via cfe-commits
Author: Adam Balogh
Date: 2020-09-16T13:16:44+02:00
New Revision: 779a2a2edcea89ad5f5bf99eeac90516542159d9

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

LOG: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

Placement new operators on non-object types cause crash in
`bugprone-misplaced-pointer-arithmetic-in-alloc`. This patch fixes this
issue.

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

Added: 


Modified: 

clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
index 2a6a0ae53a4f3..6208cb5cfc9dc 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@ void MisplacedPointerArithmeticInAllocCheck::check(
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
index 42250da2610df..00d12891cde88 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,14 @@ void bad_new_array(int n, int m) {
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+namespace std {
+typedef decltype(sizeof(void*)) size_t;
+}
+
+void* operator new(std::size_t, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is 
applied to the result of operator new() instead of its size-like argument
+}



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


[PATCH] D87683: [clang-tidy] Crash fix for bugprone-misplaced-pointer-arithmetic-in-alloc

2020-09-16 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG779a2a2edcea: [clang-tidy] Crash fix for 
bugprone-misplaced-pointer-arithmetic-in-alloc (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87683

Files:
  
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,14 @@
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+namespace std {
+typedef decltype(sizeof(void*)) size_t;
+}
+
+void* operator new(std::size_t, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is 
applied to the result of operator new() instead of its size-like argument
+}
Index: 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ 
clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-misplaced-pointer-arithmetic-in-alloc.cpp
@@ -51,3 +51,14 @@
   // CHECK-FIXES: p = new char[n - m] + 10;
   // FIXME: should be p = new char[n - m + 10];
 }
+
+namespace std {
+typedef decltype(sizeof(void*)) size_t;
+}
+
+void* operator new(std::size_t, void*);
+
+void placement_new_ptr(void *buf, C *old) {
+  C **p = new (buf) C*(old) + 1;
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: arithmetic operation is applied to the result of operator new() instead of its size-like argument
+}
Index: clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp
@@ -77,9 +77,9 @@
   CallName = "operator new[]";
 } else {
   const auto *CtrE = New->getConstructExpr();
-  if (!CtrE->getArg(CtrE->getNumArgs() - 1)
-   ->getType()
-   ->isIntegralOrEnumerationType())
+  if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
+ ->getType()
+ ->isIntegralOrEnumerationType())
 return;
   CallName = "operator new";
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] dbd45b2 - [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`

2020-09-16 Thread Adam Balogh via cfe-commits
Author: Adam Balogh
Date: 2020-09-16T13:16:51+02:00
New Revision: dbd45b2db8e0c396fa20d4c72734c4f31f54af96

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

LOG: [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`

//AST Matcher// `hasBody` is a polymorphic matcher that behaves
differently for loop statements and function declarations. The main
difference is the for functions declarations it does not only call
`FunctionDecl::getBody()` but first checks whether the declaration in
question is that specific declaration which has the body by calling
`FunctionDecl::doesThisDeclarationHaveABody()`. This is achieved by
specialization of the template `GetBodyMatcher`. Unfortunately template
specializations do not catch the descendants of the class for which the
template is specialized. Therefore it does not work correcly for the
descendants of `FunctionDecl`, such as `CXXMethodDecl`,
`CXXConstructorDecl`, `CXXDestructorDecl` etc. This patch fixes this
issue by using a template metaprogram.

The patch also introduces a new matcher `hasAnyBody` which matches
declarations which have a body present in the AST but not necessarily
belonging to that particular declaration.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
index ea4bf91b0d438..7d5ae89551731 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
@@ -36,12 +36,12 @@ void UseEqualsDeleteCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(
   cxxMethodDecl(
   PrivateSpecialFn,
-  unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
+  unless(anyOf(hasAnyBody(stmt()), isDefaulted(), isDeleted(),
ast_matchers::isTemplateInstantiation(),
// Ensure that all methods except private special member
// functions are defined.
hasParent(cxxRecordDecl(hasMethod(unless(
-   anyOf(PrivateSpecialFn, hasBody(stmt()), isPure(),
+   anyOf(PrivateSpecialFn, hasAnyBody(stmt()), 
isPure(),
  isDefaulted(), isDeleted()
   .bind(SpecialFunction),
   this);

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index e670459fe8a2f..bd89906eadb0f 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4879,7 +4879,9 @@ AST_MATCHER_P(ArraySubscriptExpr, hasBase,
 }
 
 /// Matches a 'for', 'while', 'do while' statement or a function
-/// definition that has a given body.
+/// definition that has a given body. Note that in case of functions
+/// this matcher only matches the definition itself and not the other
+/// declarations of the same function.
 ///
 /// Given
 /// \code
@@ -4889,6 +4891,18 @@ AST_MATCHER_P(ArraySubscriptExpr, hasBase,
 ///   matches 'for (;;) {}'
 /// with compoundStmt()
 ///   matching '{}'
+///
+/// Given
+/// \code
+///   void f();
+///   void f() {}
+/// \endcode
+/// hasBody(functionDecl())
+///   matches 'void f() {}'
+/// with compoundStmt()
+///   matching '{}'
+///   but does not match 'void f();'
+
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt,
   WhileStmt,
@@ -4900,6 +4914,30 @@ AST_POLYMORPHIC_MATCHER_P(hasBody,
   InnerMatcher.matches(*Statement, Finder, Builder));
 }
 
+/// Matches a function declaration that has a given body present in the AST.
+/// Note that this matcher matches all the declarations of a function whose
+/// body is present in the AST.
+///
+/// Given
+/// \code
+///   void f();
+///   void f() {}
+///   void g();
+/// \endcode
+/// hasAnyBody(functionDecl())
+///   matches both 'void f();'
+///   and 'void f() {}'
+/// with compoundStmt()
+///   matching '{}'
+///   but does not match 'void g();'
+AST_MATCHER_P(FunctionDecl, hasAnyBody,
+  internal::Matcher, InnerMatcher) {
+  const Stmt *const Statement = Node.getBody();
+  return (Statement != nullptr &&
+  InnerMatcher.matches(*Statement, Finder, Builder));
+}
+
+
 /// Matches compound statements where at least one substatement mat

[PATCH] D87527: [ASTMatchers] Fix `hasBody` for the descendants of `FunctionDecl`

2020-09-16 Thread Balogh , Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdbd45b2db8e0: [ASTMatchers] Fix `hasBody` for the 
descendants of `FunctionDecl` (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87527

Files:
  clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1612,10 +1612,49 @@
   doStmt(hasBody(compoundStmt();
   EXPECT_TRUE(matches("void f() { int p[2]; for (auto x : p) {} }",
   cxxForRangeStmt(hasBody(compoundStmt();
+}
+
+TEST(HasBody, FindsBodyOfFunctions) {
   EXPECT_TRUE(matches("void f() {}", functionDecl(hasBody(compoundStmt();
   EXPECT_TRUE(notMatches("void f();", functionDecl(hasBody(compoundStmt();
-  EXPECT_TRUE(matches("void f(); void f() {}",
-  functionDecl(hasBody(compoundStmt();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(); void f() {}",
+  functionDecl(hasBody(compoundStmt())).bind("func"),
+  std::make_unique>("func", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { void f(); }; void C::f() {}",
+  cxxMethodDecl(hasBody(compoundStmt())).bind("met"),
+  std::make_unique>("met", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { C(); }; C::C() {}",
+  cxxConstructorDecl(hasBody(compoundStmt())).bind("ctr"),
+  std::make_unique>("ctr", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { ~C(); }; C::~C() {}",
+  cxxDestructorDecl(hasBody(compoundStmt())).bind("dtr"),
+  std::make_unique>("dtr", 1)));
+}
+
+TEST(HasAnyBody, FindsAnyBodyOfFunctions) {
+  EXPECT_TRUE(matches("void f() {}", functionDecl(hasAnyBody(compoundStmt();
+  EXPECT_TRUE(notMatches("void f();",
+ functionDecl(hasAnyBody(compoundStmt();
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "void f(); void f() {}",
+  functionDecl(hasAnyBody(compoundStmt())).bind("func"),
+  std::make_unique>("func", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { void f(); }; void C::f() {}",
+  cxxMethodDecl(hasAnyBody(compoundStmt())).bind("met"),
+  std::make_unique>("met", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { C(); }; C::C() {}",
+  cxxConstructorDecl(hasAnyBody(compoundStmt())).bind("ctr"),
+  std::make_unique>("ctr", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  "class C { ~C(); }; C::~C() {}",
+  cxxDestructorDecl(hasAnyBody(compoundStmt())).bind("dtr"),
+  std::make_unique>("dtr", 2)));
 }
 
 TEST(HasAnySubstatement, MatchesForTopLevelCompoundStatement) {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1835,18 +1835,18 @@
   DynTypedNode Node;
 };
 
+template  struct GetBodyMatcher {
+  static const Stmt *get(const Ty &Node) { return Node.getBody(); }
+};
+
 template 
-struct GetBodyMatcher {
+struct GetBodyMatcher::value>::type> {
   static const Stmt *get(const Ty &Node) {
-return Node.getBody();
+return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
   }
 };
 
-template <>
-inline const Stmt *GetBodyMatcher::get(const FunctionDecl &Node) {
-  return Node.doesThisDeclarationHaveABody() ? Node.getBody() : nullptr;
-}
-
 template 
 struct HasSizeMatcher {
   static bool hasSize(const Ty &Node, unsigned int N) {
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4879,7 +4879,9 @@
 }
 
 /// Matches a 'for', 'while', 'do while' statement or a function
-/// definition that has a given body.
+/// definition that has a given body. Note that in case of functions
+/// this matcher only matches the definition itself and not the other
+/// declarations of the same function.
 ///
 /// Given
 /// \code
@@ -4889,6 +4891,18 @@
 ///   matches 'for (;;) {}'
 /// with compoundStmt()
 ///   matching '{}'
+///
+/// Given
+/// \code
+///   void f();
+///   void f() {}
+/// \endcode
+/// hasBody(functionDecl())
+///   matches 'void f() {}'
+/// with compoundStmt()
+///   matching '{}'
+///   but does not match 'void f();'
+
 AST_POLYMORPHIC_MATCHER_P(hasBody,
   AST_POLYMORPHIC_SUPPORTED_T

[clang] aa1e15d - TokenAnnotator.cpp - remove useless pointer null test. NFCI.

2020-09-16 Thread Simon Pilgrim via cfe-commits
Author: Simon Pilgrim
Date: 2020-09-16T12:30:24+01:00
New Revision: aa1e15dda9e5941611f2183ba34087c2d02beb1a

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

LOG: TokenAnnotator.cpp - remove useless pointer null test. NFCI.

We dereference the Left pointer throughout the parseParens() function apart 
from this single case - just add an non-null assertion and drop the check.

Fixes clang static analayzer null dereference warning.

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 841f0b41e9a7f..2fa3b28f3a390 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -198,8 +198,8 @@ class AnnotatingParser {
 if (!CurrentToken)
   return false;
 FormatToken *Left = CurrentToken->Previous;
-FormatToken *PrevNonComment =
-Left ? Left->getPreviousNonComment() : nullptr;
+assert(Left && "Unknown previous token");
+FormatToken *PrevNonComment = Left->getPreviousNonComment();
 Left->ParentBracket = Contexts.back().ContextKind;
 ScopedContextCreator ContextCreator(*this, tok::l_paren, 1);
 



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


[clang] 439f574 - [AST] ASTReader::ReadModuleMapFileBlock - assert non-null Module. NFCI.

2020-09-16 Thread Simon Pilgrim via cfe-commits
Author: Simon Pilgrim
Date: 2020-09-16T12:30:24+01:00
New Revision: 439f5749d978acfa69f1a2d20c797c3fc0d97989

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

LOG: [AST] ASTReader::ReadModuleMapFileBlock - assert non-null Module. NFCI.

At this stage the Module* shouldn't be null - add an assert to fix a clang 
static analyzer warning.

Added: 


Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 6f5fa67117c09..f02c43f337674 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -3950,7 +3950,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, 
ModuleFile &F,
   return OutOfDate;
 }
 
-assert(M->Name == F.ModuleName && "found module with 
diff erent name");
+assert(M && M->Name == F.ModuleName && "found module with 
diff erent name");
 
 // Check the primary module map file.
 auto StoredModMap = FileMgr.getFile(F.ModuleMapPath);



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


[clang] 4abb5cd - CGBlocks.cpp - assert non-null CGF pointer. NFCI.

2020-09-16 Thread Simon Pilgrim via cfe-commits
Author: Simon Pilgrim
Date: 2020-09-16T12:30:24+01:00
New Revision: 4abb5cd83902f1351db473c720ee0b95ebdcb338

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

LOG: CGBlocks.cpp - assert non-null CGF pointer. NFCI.

Fixes static analyzer warning.

Added: 


Modified: 
clang/lib/CodeGen/CGBlocks.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index ac5559a93d9cc..ee0c14641803b 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -580,7 +580,7 @@ static void computeBlockInfo(CodeGenModule &CGM, 
CodeGenFunction *CGF,
 
   // Since a __block variable cannot be captured by lambdas, its type and
   // the capture field type should always match.
-  assert(getCaptureFieldType(*CGF, CI) == variable->getType() &&
+  assert(CGF && getCaptureFieldType(*CGF, CI) == variable->getType() &&
  "capture type 
diff ers from the variable type");
   layout.push_back(BlockLayoutChunk(align, CGM.getPointerSize(),
 Qualifiers::OCL_None, &CI,



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


[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Ugh, the hole goes deeper, because the Itanium ABI unambiguously follows the 
C++11 (instantiation-dependent) behavior.
Definitely need Richard's input here as I'm fairly sure this will break things 
as-is.




Comment at: clang/test/CodeGenCXX/mangle-exprs.cpp:215
 
 namespace test5 {
   template  void a(decltype(noexcept(T( {}

Amusingly, both GCC and MSVC reject this valid code.

GCC says: "sorry, unimplemented: mangling noexcept_expr"

MSVC says: "'void test5::a(bool)': no function template defined that matches 
forced instantiation"
MSVC seems to require the expression to be exactly the same as that in the 
template declaration in order to compile (even when that's not possible)...



Comment at: clang/test/CodeGenCXX/mangle.cpp:805
 
-  // CHECK-LABEL: define weak_odr void 
@_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
+  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvm
   template void f(decltype(sizeof(1)));

GCC mangles this as `_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE`, so we're 
breaking compat here :-\

And in fact we're just incorrect. 
https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling:

> If the operand expression of decltype is not instantiation-dependent then the 
> resulting type is encoded directly.

Here, instantiation-dependent *is* explicitly defined as "type-dependent or 
value-dependent or ...". And therefore these cases must not be "encoded 
directly", including the motivating case (decltype(N) where N is a typed 
constant whose initializer is value-dependent).

We could consider not two but *three* types of decltypetypes:
 - decltype(type-dependent), which is sugar for a canonical 
DependentDeclTypeType
 - decltype(instantiation-but-not-type-dependent), which is still sugar for a 
concrete canonical type (per C++17) but mangles using the expr (per cxxabi)
 - decltype(non-dependent), which is sugar for a concrete canonical type and 
mangles directly

This only works if it's OK for mangling to depend on non-canonical type details 
- I don't know whether this is the case. @rsmith - any hints here?



Comment at: clang/test/SemaTemplate/dependent-expr.cpp:132
   }
-  template void f(); // expected-note {{instantiation of}}
+  template void f();
 

Took me a while to understand this, I think this is an improvement as we now 
diagnose when we see the template rather than when we see the instantiation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87349

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


[clang] f5c7102 - Update dead links to Itanium and ARM ABIs. NFC

2020-09-16 Thread Sam McCall via cfe-commits
Author: Sam McCall
Date: 2020-09-16T13:42:01+02:00
New Revision: f5c7102dbc7223e98ce5c0f02b343ed92062987c

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

LOG: Update dead links to Itanium and ARM ABIs. NFC

Added: 


Modified: 
clang/lib/CodeGen/ItaniumCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 3b752d306055..69825a036a1e 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -9,11 +9,11 @@
 // This provides C++ code generation targeting the Itanium C++ ABI.  The class
 // in this file generates structures that follow the Itanium C++ ABI, which is
 // documented at:
-//  http://www.codesourcery.com/public/cxx-abi/abi.html
-//  http://www.codesourcery.com/public/cxx-abi/abi-eh.html
+//  https://itanium-cxx-abi.github.io/cxx-abi/abi.html
+//  https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
 //
 // It also supports the closely-related ARM ABI, documented at:
-// 
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0041c/IHI0041C_cppabi.pdf
+// https://developer.arm.com/documentation/ihi0041/g/
 //
 
//===--===//
 



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


[clang] 0a0abc0 - [Sema] isOpenMPCapturedDecl - assert we locate CapturedRegionScopeInfo. NFCI.

2020-09-16 Thread Simon Pilgrim via cfe-commits
Author: Simon Pilgrim
Date: 2020-09-16T12:42:35+01:00
New Revision: 0a0abc0ede0ff8015e30aae89a3f89c7dc5b3f0f

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

LOG: [Sema] isOpenMPCapturedDecl - assert we locate CapturedRegionScopeInfo. 
NFCI.

Fixes clang static analayzer null dereference warning.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1aeb52a213f6..336f26422914 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2194,6 +2194,7 @@ VarDecl *Sema::isOpenMPCapturedDecl(ValueDecl *D, bool 
CheckScopeInfo,
 break;
   }
   }
+  assert(CSI && "Failed to find CapturedRegionScopeInfo");
   SmallVector Regions;
   getOpenMPCaptureRegions(Regions,
   DSAStack->getDirective(CSI->OpenMPLevel));



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


[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-09-16 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 292188.
usaxena95 marked 8 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83814

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/for-review-only/CompletionModel.cpp
  clang-tools-extra/clangd/for-review-only/CompletionModel.h
  clang-tools-extra/clangd/for-review-only/DecisionForestRuntimeTest.cpp
  clang-tools-extra/clangd/for-review-only/DecisionForestRuntimeTest.h
  clang-tools-extra/clangd/quality/CompletionModel.cmake
  clang-tools-extra/clangd/quality/CompletionModelCodegen.py
  clang-tools-extra/clangd/quality/README.md
  clang-tools-extra/clangd/quality/model/features.json
  clang-tools-extra/clangd/quality/model/forest.json
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
  clang-tools-extra/clangd/unittests/decision_forest_model/CategoricalFeature.h
  clang-tools-extra/clangd/unittests/decision_forest_model/features.json
  clang-tools-extra/clangd/unittests/decision_forest_model/forest.json

Index: clang-tools-extra/clangd/unittests/decision_forest_model/forest.json
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/decision_forest_model/forest.json
@@ -0,0 +1,52 @@
+[
+{
+"operation": "if_greater",
+"feature": "ANumber",
+"threshold": 200.0,
+"then": {
+"operation": "if_greater",
+"feature": "AFloat",
+"threshold": -1,
+"then": {
+"operation": "boost",
+"score": 10.0
+},
+"else": {
+"operation": "boost",
+"score": -20.0
+}
+},
+"else": {
+"operation": "if_member",
+"feature": "ACategorical",
+"set": [
+"A",
+"C"
+],
+"then": {
+"operation": "boost",
+"score": 3.0
+},
+"else": {
+"operation": "boost",
+"score": -4.0
+}
+}
+},
+{
+"operation": "if_member",
+"feature": "ACategorical",
+"set": [
+"A",
+"B"
+],
+"then": {
+"operation": "boost",
+"score": 5.0
+},
+"else": {
+"operation": "boost",
+"score": -6.0
+}
+}
+]
\ No newline at end of file
Index: clang-tools-extra/clangd/unittests/decision_forest_model/features.json
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/decision_forest_model/features.json
@@ -0,0 +1,16 @@
+[
+{
+"name": "ANumber",
+"type": "NUMBER"
+},
+{
+"name": "AFloat",
+"type": "NUMBER"
+},
+{
+"name": "ACategorical",
+"type": "ENUM",
+"enum": "ns1::ns2::TestEnum",
+"header": "decision_forest_model/CategoricalFeature.h"
+}
+]
\ No newline at end of file
Index: clang-tools-extra/clangd/unittests/decision_forest_model/CategoricalFeature.h
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/decision_forest_model/CategoricalFeature.h
@@ -0,0 +1,5 @@
+namespace ns1 {
+namespace ns2 {
+enum TestEnum { A, B, C, D };
+} // namespace ns2
+} // namespace ns1
Index: clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/DecisionForestTests.cpp
@@ -0,0 +1,29 @@
+#include "DecisionForestRuntimeTest.h"
+#include "decision_forest_model/CategoricalFeature.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+TEST(DecisionForestRuntime, Evaluate) {
+  using Example = ::ns1::ns2::test::Example;
+  using Cat = ::ns1::ns2::TestEnum;
+  using ::ns1::ns2::test::Evaluate;
+
+  Example E;
+  E.setANumber(200); // True
+  E.setAFloat(0);// True: +10.0
+  E.setACategorical(Cat::A); // True: +5.0
+  EXPECT_EQ(Evaluate(E), 15.0);
+
+  E.setANumber(200); // True
+  E.setAFloat(-2.5); // False: -20.0
+  E.setACategorical(Cat::B); // True: +5.0
+  EXPECT_EQ(Evaluate(E), -15.0);
+
+  E.setANumber(100); // False
+  E.setACategorical(Cat::C); // True: +3.0, False: -6.0
+  EXPECT_EQ(Evaluate(E), -3.0);
+}
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools

[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-09-16 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:39
+'''Returns the header guard for the generated header.'''
+return "GENERATED_DECISION_FOREST_MODEL_{}_H".format(filename.upper())
+

adamcz wrote:
> Why GENERATED_DECISON_FOREST_MODEL instead of output_dir, to be consistent 
> with header guards for other files? Doesn't matter much for generated code, 
> but if someone opens this in vim they'll see warnings.
The output_dir is the absolute path and not a project relative path.
I tried to stick with a special prefix for header guard as done in other 
Generated headers (e.g. protos)

If someone opens this in vim, there would many other warnings that they would 
see like "unused_label" ;)
I don't think that would be a concern since it would be opened for inspection 
and not for editing.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:177
+
+code += "  friend float Evaluate(const {}&);\n".format(cpp_class.name)
+code += "};\n"

adamcz wrote:
> Is there a reason to make this a friend free-function instead of static 
> method on the Example class? The problem is that you now end up with 
> clang::clangd::Evaluate, so if we every re-use this code gen for another 
> model we'll have a name collision.
The class name ("Example" currently) would be different for a different model 
and therefore there would be another overload for `Evaluate(const 
AnotherClass&)` even if the namespaces are same (`clang::clangd`).



Comment at: clang-tools-extra/clangd/unittests/model/CategoricalFeature.h:1
+namespace ns1 {
+namespace ns2 {

adamcz wrote:
> Can we rename this directory? quality/model makes some sense (although it 
> would be better to include something about code completion there), but 
> unittests/model is not very descriptive - what model?
> 
> How about unittests/decision_forest_model/ or something like that? Or go with 
> the Input/TEST_NAME pattern.
You are right "quality" wasn't indicative of code completion here but we 
decided to be consistent with the current naming. The current heuristics for 
the ranking are in Quality.h and Quality.cpp ;-)

changed the dir name in unittests.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83814

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


[PATCH] D87352: Fix typo

2020-09-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: arichardson.
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:778
 
-  For example: __capability.
-

So this is an example of where someone has changed the .rst and not the 
Format.h! @arichardson 

I recommend keeping Format.h and rst in lock step.


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

https://reviews.llvm.org/D87352

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


[PATCH] D87291: [clang-format][regression][PR47461] ifdef causes catch to be seen as a function

2020-09-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

ping


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

https://reviews.llvm.org/D87291

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


[PATCH] D87352: Fix typo

2020-09-16 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dd9c709ef1b: [clang-format] [NFC] Fix spelling mistake in 
the documentation (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87352

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -758,10 +758,14 @@
  int b) {
}
 
+
+
 **AttributeMacros** (``std::vector``)
   A vector of strings that should be interpreted as attributes/qualifiers
   instead of identifiers. This can be useful for language extensions or
-  static analyzer annotations:
+  static analyzer annotations.
+
+  For example:
 
   .. code-block:: c++
 
@@ -775,8 +779,6 @@
 
 AttributeMacros: ['__capability', '__output', '__ununsed']
 
-  For example: __capability.
-
 **BinPackArguments** (``bool``)
   If ``false``, a function call's arguments will either be all on the
   same line or will have one line each.
@@ -2246,7 +2248,7 @@
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 


Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -758,10 +758,14 @@
  int b) {
}
 
+
+
 **AttributeMacros** (``std::vector``)
   A vector of strings that should be interpreted as attributes/qualifiers
   instead of identifiers. This can be useful for language extensions or
-  static analyzer annotations:
+  static analyzer annotations.
+
+  For example:
 
   .. code-block:: c++
 
@@ -775,8 +779,6 @@
 
 AttributeMacros: ['__capability', '__output', '__ununsed']
 
-  For example: __capability.
-
 **BinPackArguments** (``bool``)
   If ``false``, a function call's arguments will either be all on the
   same line or will have one line each.
@@ -2246,7 +2248,7 @@
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4dd9c70 - [clang-format] [NFC] Fix spelling mistake in the documentation

2020-09-16 Thread via cfe-commits
Author: mydeveloperday
Date: 2020-09-16T13:46:34+01:00
New Revision: 4dd9c709ef1b59f0ec8e71100c624ec946b95fe2

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

LOG: [clang-format] [NFC] Fix spelling mistake in the documentation

Ensure ClangFormatStyleOptions.rst can be regenerated from Format.h

Patch By: YangZhihui

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 72a25032151f..20e829135b33 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -758,10 +758,14 @@ the configuration (without a prefix: ``Auto``).
  int b) {
}
 
+
+
 **AttributeMacros** (``std::vector``)
   A vector of strings that should be interpreted as attributes/qualifiers
   instead of identifiers. This can be useful for language extensions or
-  static analyzer annotations:
+  static analyzer annotations.
+
+  For example:
 
   .. code-block:: c++
 
@@ -775,8 +779,6 @@ the configuration (without a prefix: ``Auto``).
 
 AttributeMacros: ['__capability', '__output', '__ununsed']
 
-  For example: __capability.
-
 **BinPackArguments** (``bool``)
   If ``false``, a function call's arguments will either be all on the
   same line or will have one line each.
@@ -2246,7 +2248,7 @@ the configuration (without a prefix: ``Auto``).
 
 **ObjCBreakBeforeNestedBlockParam** (``bool``)
   Break parameters list into lines when there is nested block
-  parameters in a fuction call.
+  parameters in a function call.
 
   .. code-block:: c++
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6bb828d60071..c6c182b7bdce 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1860,7 +1860,7 @@ struct FormatStyle {
   bool ObjCSpaceAfterProperty;
 
   /// Break parameters list into lines when there is nested block
-  /// parameters in a fuction call.
+  /// parameters in a function call.
   /// \code
   ///   false:
   ///- (void)_aMethod



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


[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-16 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Pushed to 11.x as 4a26e3b33798424dc5a4843f7b29a617bef81656 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87710

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


[PATCH] D87745: [clangd] Config: handle Index block

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for catching this! Lucky coincidence it was spotted twice just before 
rc3!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87745

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


[PATCH] D87710: [clangd] Actually parse Index section of the YAML file.

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks Hans!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87710

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


[PATCH] D85762: [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-09-16 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4341c6618dec: [OPENMP]Do not allow threadprivates as base 
for array-like reduction. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85762

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_reduction_messages.cpp


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15120,6 +15120,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using


Index: clang/test/OpenMP/parallel_reduction_messages.cpp
===
--- clang/test/OpenMP/parallel_reduction_messages.cpp
+++ clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error {{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain' requested here}} expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -15120,6 +15120,17 @@
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4341c66 - [OPENMP]Do not allow threadprivates as base for array-like reduction.

2020-09-16 Thread Alexey Bataev via cfe-commits
Author: Alexey Bataev
Date: 2020-09-16T09:30:32-04:00
New Revision: 4341c6618decb4014a167bc83aeeed49ab49b34f

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

LOG: [OPENMP]Do not allow threadprivates as base for array-like reduction.

The base must be shared between the threads, threadprivates are not
allowed to be bases for array-like reductions.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_reduction_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 336f26422914..1a0470a9606d 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -15120,6 +15120,17 @@ static bool actOnOMPReductionKindClause(
   continue;
 }
   }
+} else {
+  // Threadprivates cannot be shared between threads, so dignose if the 
base
+  // is a threadprivate variable.
+  DSAStackTy::DSAVarData DVar = Stack->getTopDSA(D, /*FromParent=*/false);
+  if (DVar.CKind == OMPC_threadprivate) {
+S.Diag(ELoc, diag::err_omp_wrong_dsa)
+<< getOpenMPClauseName(DVar.CKind)
+<< getOpenMPClauseName(OMPC_reduction);
+reportOriginalDsa(S, Stack, D, DVar);
+continue;
+  }
 }
 
 // Try to find 'declare reduction' corresponding construct before using

diff  --git a/clang/test/OpenMP/parallel_reduction_messages.cpp 
b/clang/test/OpenMP/parallel_reduction_messages.cpp
index b464bf5b9643..12b34a4de07b 100644
--- a/clang/test/OpenMP/parallel_reduction_messages.cpp
+++ b/clang/test/OpenMP/parallel_reduction_messages.cpp
@@ -92,6 +92,8 @@ class S6 { // expected-note 3 {{candidate function (the 
implicit copy assignment
 
 S3 h, k;
 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or 
thread local}}
+int *gptr;
+#pragma omp threadprivate(gptr) // expected-note {{defined as threadprivate or 
thread local}}
 
 template// expected-note {{declared here}}
 T tmain(T argc) {
@@ -277,6 +279,8 @@ int main(int argc, char **argv) {
   m++;
 #pragma omp parallel reduction(task, + : m) // omp45-error 2 {{expected 
expression}} omp45-warning {{missing ':' after reduction identifier - ignoring}}
   m++;
+#pragma omp parallel reduction(+:gptr[:argc]) // expected-error 
{{threadprivate or thread local variable cannot be reduction}}
+  ;
 
   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of 
function template specialization 'tmain' requested here}} expected-note 
{{in instantiation of function template specialization 'tmain' requested 
here}}
 }



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


[PATCH] D87352: Fix typo

2020-09-16 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:778
 
-  For example: __capability.
-

MyDeveloperDay wrote:
> So this is an example of where someone has changed the .rst and not the 
> Format.h! @arichardson 
> 
> I recommend keeping Format.h and rst in lock step.
Ah I was not aware of that script, I just did both manually but must have 
adjusted one later. Sorry!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87352

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


[PATCH] D87349: [clang] adapt c++17 behavior for dependent decltype-specifiers

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



Comment at: clang/test/CodeGenCXX/mangle.cpp:805
 
-  // CHECK-LABEL: define weak_odr void 
@_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE
+  // CHECK-LABEL: define weak_odr void @_ZN6test341fIiEEvm
   template void f(decltype(sizeof(1)));

sammccall wrote:
> GCC mangles this as `_ZN6test341fIiEEvDTstDTplcvT__EcvS1__EEE`, so we're 
> breaking compat here :-\
> 
> And in fact we're just incorrect. 
> https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling:
> 
> > If the operand expression of decltype is not instantiation-dependent then 
> > the resulting type is encoded directly.
> 
> Here, instantiation-dependent *is* explicitly defined as "type-dependent or 
> value-dependent or ...". And therefore these cases must not be "encoded 
> directly", including the motivating case (decltype(N) where N is a typed 
> constant whose initializer is value-dependent).
> 
> We could consider not two but *three* types of decltypetypes:
>  - decltype(type-dependent), which is sugar for a canonical 
> DependentDeclTypeType
>  - decltype(instantiation-but-not-type-dependent), which is still sugar for a 
> concrete canonical type (per C++17) but mangles using the expr (per cxxabi)
>  - decltype(non-dependent), which is sugar for a concrete canonical type and 
> mangles directly
> 
> This only works if it's OK for mangling to depend on non-canonical type 
> details - I don't know whether this is the case. @rsmith - any hints here?
Hmm, my naive reading of the mangle code matches what I described.

The big comment in ItaniumMangle talks about related issues: 
https://github.com/llvm/llvm-project/blob/24238f09edb98b0f460aa41139874ae5d4e5cd8d/clang/lib/AST/ItaniumMangle.cpp#L2541-L2572

I don't really understand what's going on here, sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87349

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


[PATCH] D86790: [FE] Use preferred alignment instead of ABI alignment for complete object when applicable

2020-09-16 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 292207.
Xiangling_L added a comment.

Use default argument;


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

https://reviews.llvm.org/D86790

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/CodeGen/aix-alignment.c
  clang/test/CodeGenCXX/aix-alignment.cpp

Index: clang/test/CodeGenCXX/aix-alignment.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-alignment.cpp
@@ -0,0 +1,30 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix \
+// RUN: -emit-llvm -o - -x c++ %s | \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX32
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix \
+// RUN: -emit-llvm -o - %s -x c++| \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX64
+
+struct B {
+  double d;
+  ~B() {}
+};
+
+// AIX32: %call = call noalias nonnull i8* @_Znam(i32 8)
+// AIX64: %call = call noalias nonnull i8* @_Znam(i64 8)
+B *allocBp() { return new B[0]; }
+
+typedef struct D {
+  double d;
+  int i;
+
+  ~D(){};
+} D;
+
+// AIX: define void @_Z3foo1D(%struct.D* noalias sret align 4 %agg.result, %struct.D* %x)
+// AIX:   %1 = bitcast %struct.D* %agg.result to i8*
+// AIX:   %2 = bitcast %struct.D* %x to i8*
+// AIX32  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %1, i8* align 4 %2, i32 16, i1 false)
+// AIX64: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %1, i8* align 4 %2, i64 16, i1 false)
+D foo(D x) { return x; }
Index: clang/test/CodeGen/aix-alignment.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-alignment.c
@@ -0,0 +1,41 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX32
+// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=AIX,AIX64
+
+// AIX: @d = global double 0.00e+00, align 8
+double d;
+
+typedef struct {
+  double d;
+  int i;
+} StructDouble;
+
+// AIX: @d1 = global %struct.StructDouble zeroinitializer, align 8
+StructDouble d1;
+
+// AIX: double @retDouble(double %x)
+// AIX: %x.addr = alloca double, align 8
+// AIX: store double %x, double* %x.addr, align 8
+// AIX: load double, double* %x.addr, align 8
+// AIX: ret double %0
+double retDouble(double x) { return x; }
+
+// AIX32: define void @bar(%struct.StructDouble* noalias sret align 4 %agg.result, %struct.StructDouble* byval(%struct.StructDouble) align 4 %x)
+// AIX64: define void @bar(%struct.StructDouble* noalias sret align 4 %agg.result, %struct.StructDouble* byval(%struct.StructDouble) align 8 %x)
+// AIX: %0 = bitcast %struct.StructDouble* %agg.result to i8*
+// AIX: %1 = bitcast %struct.StructDouble* %x to i8*
+// AIX32:   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %0, i8* align 4 %1, i32 16, i1 false)
+// AIX64:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %0, i8* align 8 %1, i64 16, i1 false)
+StructDouble bar(StructDouble x) { return x; }
+
+// AIX:   define void @foo(double* %out, double* %in)
+// AIX32:   %0 = load double*, double** %in.addr, align 4
+// AIX64:   %0 = load double*, double** %in.addr, align 8
+// AIX: %1 = load double, double* %0, align 4
+// AIX: %mul = fmul double %1, 2.00e+00
+// AIX32:   %2 = load double*, double** %out.addr, align 4
+// AIX64:   %2 = load double*, double** %out.addr, align 8
+// AIX: store double %mul, double* %2, align 4
+void foo(double *out, double *in) { *out = *in * 2; }
Index: clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
@@ -248,8 +248,8 @@
   FieldInfo RetVal;
   RetVal.Field = FD;
   auto &Ctx = FD->getASTContext();
-  std::tie(RetVal.Size, RetVal.Align) =
-  Ctx.getTypeInfoInChars(FD->getType());
+  std::tie(RetVal.Size, RetVal.Align) = Ctx.getTypeInfoInChars(
+  FD->getType(), true /* NeedsPreferredAlignment */);
   assert(llvm::isPowerOf2_64(RetVal.Align.getQuantity()));
   if (auto Max = FD->getMaxAlignment())
 RetVal.Align = std::max(Ctx.toCharUnitsFromBits(Max), RetVal.Align);
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -349,7 +349,8 @@
 ///
 /// \param IsIndirect - Values of this type are passed indirectly.
 /// \param ValueInfo - The size and alignment of this type, generally
-///   computed with getContext().getTypeInfoInChars(ValueTy).
+///   computed wi

[PATCH] D87729: [PowerPC] Implement the 128-bit Vector Divide Extended Builtins in Clang/LLVM

2020-09-16 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

In D87729#2275667 , @Conanap wrote:

> Looks like there's some unit test failures; could you double check?

We discussed offline; I've tested this again afterwards and looked into 
failures. Unit tests failures are not a result of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87729

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


[PATCH] D87761: [clang][codegen] Skip adding default function attributes on intrinsics.

2020-09-16 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: rjmccall, tra, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
hliao requested review of this revision.

- After loading builtin bitcode for linking, skip adding default function 
attributes on LLVM intrinsics as their attributes are well-defined and 
retrieved directly from internal definitions. Adding extra attributes on 
intrinsics results in inconsistent result when `-save-temps` is present. Also, 
that makes few optimizations conservative.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87761

Files:
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGenCUDA/Inputs/device-lib-code.ll
  clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip


Index: clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
===
--- /dev/null
+++ clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
@@ -0,0 +1,18 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa 
-emit-llvm-bc -disable-llvm-passes -o %t.bc %S/Inputs/device-lib-code.ll
+// RUN: %clang_cc1 -x hip -fcuda-is-device -triple amdgcn-amd-amdhsa 
-mlink-builtin-bitcode %t.bc -emit-llvm -disable-llvm-passes -o - %s | 
FileCheck %s
+
+#include "Inputs/cuda.h"
+
+extern "C" __device__ float __ocml_fma_f32(float x, float y, float z);
+
+__device__ float foo(float x) {
+  return __ocml_fma_f32(x, x, x);
+}
+
+// CHECK: {{^}}define{{.*}} @__ocml_fma_f32{{.*}} [[ATTR1:#[0-9]+]]
+// CHECK: {{^}}declare{{.*}} @llvm.fma.f32{{.*}} [[ATTR2:#[0-9]+]]
+// CHECK: attributes [[ATTR1]] = { convergent
+// CHECK: attributes [[ATTR2]] = {
+// CHECK-NOT: convergent
+// CHECK: }
Index: clang/test/CodeGenCUDA/Inputs/device-lib-code.ll
===
--- /dev/null
+++ clang/test/CodeGenCUDA/Inputs/device-lib-code.ll
@@ -0,0 +1,5 @@
+define linkonce_odr protected float @__ocml_fma_f32(float %0, float %1, float 
%2) local_unnamed_addr {
+  %4 = tail call float @llvm.fma.f32(float %0, float %1, float %2)
+  ret float %4
+}
+declare float @llvm.fma.f32(float, float, float)
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -245,8 +245,13 @@
 bool LinkInModules() {
   for (auto &LM : LinkModules) {
 if (LM.PropagateAttrs)
-  for (Function &F : *LM.Module)
+  for (Function &F : *LM.Module) {
+// Skip intrinsics. Keep consistent with how intrinsics are created
+// in LLVM IR.
+if (F.isIntrinsic())
+  continue;
 Gen->CGM().addDefaultFunctionDefinitionAttributes(F);
+  }
 
 CurLinkModule = LM.Module.get();
 


Index: clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
===
--- /dev/null
+++ clang/test/CodeGenCUDA/dft-func-attr-skip-intrinsic.hip
@@ -0,0 +1,18 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc -disable-llvm-passes -o %t.bc %S/Inputs/device-lib-code.ll
+// RUN: %clang_cc1 -x hip -fcuda-is-device -triple amdgcn-amd-amdhsa -mlink-builtin-bitcode %t.bc -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+
+#include "Inputs/cuda.h"
+
+extern "C" __device__ float __ocml_fma_f32(float x, float y, float z);
+
+__device__ float foo(float x) {
+  return __ocml_fma_f32(x, x, x);
+}
+
+// CHECK: {{^}}define{{.*}} @__ocml_fma_f32{{.*}} [[ATTR1:#[0-9]+]]
+// CHECK: {{^}}declare{{.*}} @llvm.fma.f32{{.*}} [[ATTR2:#[0-9]+]]
+// CHECK: attributes [[ATTR1]] = { convergent
+// CHECK: attributes [[ATTR2]] = {
+// CHECK-NOT: convergent
+// CHECK: }
Index: clang/test/CodeGenCUDA/Inputs/device-lib-code.ll
===
--- /dev/null
+++ clang/test/CodeGenCUDA/Inputs/device-lib-code.ll
@@ -0,0 +1,5 @@
+define linkonce_odr protected float @__ocml_fma_f32(float %0, float %1, float %2) local_unnamed_addr {
+  %4 = tail call float @llvm.fma.f32(float %0, float %1, float %2)
+  ret float %4
+}
+declare float @llvm.fma.f32(float, float, float)
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -245,8 +245,13 @@
 bool LinkInModules() {
   for (auto &LM : LinkModules) {
 if (LM.PropagateAttrs)
-  for (Function &F : *LM.Module)
+  for (Function &F : *LM.Module) {
+// Skip intrinsics. Keep consistent with how intrinsics are created
+// in LLVM IR.
+if (F.isIntrinsic())
+  continue;
 Gen->CGM().addDefaultFunctionDefinitionAttributes(F);
+  }
 
 CurL

[PATCH] D87587: [clang-format][PR47290] Make one-line namespaces resistant to FixNamespaceComments, update documentation

2020-09-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D87587#2276462 , @kuzkry wrote:

> Thanks @MyDeveloperDay, I appreciate your input in this review. You're a good 
> reviewer. :)
> Also, I think you've made some good points there and I'm going to turn this 
> review into "non-breaking the world" one. I'll be back in a few days with a 
> new diff.

Thank you for considering that, I'm pretty sure I for one will be happy to 
approve it in its new form. I think this has merits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87587

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


[PATCH] D87624: [SystemZ][z/OS] Set default wchar_t type for zOS

2020-09-16 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng accepted this revision.
fanbo-meng added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87624

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


[PATCH] D83814: [clangd] Add Random Forest runtime for code completion.

2020-09-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Just some naming and doc nits. This looks really solid now, nice job!

In D83814#2261458 , @jkorous wrote:

> Hi @usaxena95 and @sammccall,
>
> I am wondering about couple high-level things.
>
> Do you guys intend to open-source also the training part of the model 
> pipeline or publish a model trained on generic-enough training set so it 
> could be reasonably used on "any" codebase?

@adamcz and I were talking about this too... I think it's important we do as 
much of this as possible. I was the one not finding time to do it though, and I 
think Adam may do better :-)

- the existing training stuff is using internal tech, but AFAIK it's nothing 
LightGBM can't do (it trains on a single machine). So we should be able to 
open-source the training setup and actually use that.
- training data generation is harder to open, because it involves sampling a 
large diverse body of code and parsing lots of it. The core code that embeds 
clangd and extracts completion candidates should be very doable, so one could 
run over LLVM on one machine. The framework to run at a larger scale is coupled 
to internal infra though, and we're currently training on both public and 
non-public code.




Comment at: clang-tools-extra/clangd/quality/CompletionModel.cmake:10
+
+  set(model_json ${model}/forest.json)
+  set(model_features ${model}/features.json)

these vars are used only once, I'd suggest inlining them for readability



Comment at: clang-tools-extra/clangd/quality/CompletionModel.cmake:13
+  
+  set(output_dir ${CMAKE_BINARY_DIR}/generated/decision_forest)
+  set(header_file ${output_dir}/${filename}.h)

/generated/decision_forest seems redundant considering ${CMAKE_BINARY_DIR} is 
already the generated-files tree for the directory of the calling CMakeLists.

Can't we just use ${CMAKE_BINARY_DIR} directly and avoid the 
DECISION_FOREST_OUTPUT_DIR variable?



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:150
+# Class definition.
+code += f"class {cpp_class.name} {{\n"
+code += "public:\n"

you can use triple-quoted f-strings, which I think would be more readable than 
blocks of "code +="

```
code += f"""class {cpp_class.name} {{
public:
  {"\n   ".join(setters)}

private:
  {"\n  ".join(class_members)}
"""
```

etc

may even do the whole thing in one go.



Comment at: clang-tools-extra/clangd/quality/CompletionModelCodegen.py:217
+
+code = "\n".join(f'#include <{h}>' for h in angled_include) + "\n\n"
+code += "\n".join(f'#include "{h}"' for h in quoted_include) + "\n\n"

again, making this one big triple-quoted f-string may be nicer, up to you



Comment at: clang-tools-extra/clangd/quality/README.md:4
+## Decision Forest
+A **decision forest** is a collection of many decision trees. A **decision 
tree** is a full binary tree where every non-leaf node has exactly **2** 
children. 
+

The second half of this sentence simply restates the first.

Maybe we can combine this with the second paragraph: "A decision tree is a full 
binary tree that provides a quality prediction for an input (code completion 
item). Internal nodes represent a binary decision based on the input data, and 
leaf nodes represent a prediction."



Comment at: clang-tools-extra/clangd/quality/README.md:8
+
+At every non-leaf node, we evaluate the condition present in the node.  The 
condition refers to exactly one **feature**. It uses the value of this 
attribute from the code completion item to evaluate the condition.
+Based on the condition, we move to its true child or the false child.

Nit: I think it's worth separating out defining features vs conditions.

e.g.
"An input (code completion candidate) is characterized as a set of 
**features**, such as the type of symbol or the number of existing references

At every non-leaf node, we evaluate the condition to decide whether to go left 
or right. The condition compares one feature of the input against a constant. 
It is either:
...".



Comment at: clang-tools-extra/clangd/quality/README.md:16
+A leaf node only contains the value **score**.
+Once we know the set of leaves (one from each decision tree), we add the 
**score** values from each of the leaves to get the final relevance score.
+

nit: rather than alternating between describing traversing all trees and one 
tree, I'd just say "To compute an overall quality score, we traverse each tree 
in this way and add up the scores".



Comment at: clang-tools-extra/clangd/quality/README.md:26
+  "name": "a_numerical_feature",
+  "type": "NUMBER"
+}

This is a little prone to confusion with C++ type.

Consider "kind" instead?



Comment at: clang-tools-extra/clangd/qual

[PATCH] D87624: [SystemZ][z/OS] Set default wchar_t type for zOS

2020-09-16 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87624

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


[clang] f054617 - [ASTMatchers] Add missing definition for decompositionDecl

2020-09-16 Thread Benjamin Kramer via cfe-commits
Author: Benjamin Kramer
Date: 2020-09-16T17:32:29+02:00
New Revision: f0546173fa4bdde03ecb21a174fcaa8a6490adbd

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

LOG: [ASTMatchers] Add missing definition for decompositionDecl

Otherwise we'd get a linker error whenever decompositionDecl is ODR
used.

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchersInternal.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 6b17bd0cda0b..4e4e43b2a94a 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -710,6 +710,7 @@ const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
 const internal::VariadicDynCastAllOfMatcher
 typeAliasTemplateDecl;
 const internal::VariadicAllOfMatcher decl;
+const internal::VariadicAllOfMatcher decompositionDecl;
 const internal::VariadicDynCastAllOfMatcher
 linkageSpecDecl;
 const internal::VariadicDynCastAllOfMatcher namedDecl;



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


[PATCH] D87451: add new clang option -mignore-xcoff-visibility

2020-09-16 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2310
 
+.. option:: -mignore-xcoff-visibility
+

We should move this option to where all the other -m options resides.



Comment at: clang/docs/ClangCommandLineReference.rst:2312
+
+Ignore all the visibility pragmas and attributes in source code for aix xcoff.
+





Comment at: clang/include/clang/Basic/LangOptions.def:300
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
+BENIGN_LANGOPT(IgnoreXCOFFVisibility, 1, 0, "All the visibility pragmas and 
attributes that are specified in the source are ignored in aix.")
 ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,

nit: AIX XCOFF target



Comment at: clang/include/clang/Driver/Options.td:1939
 def dA : Flag<["-"], "dA">, Alias;
+def mignore_xcoff_visibility : Flag<["-"], "mignore-xcoff-visibility">, 
Group,
+  HelpText<"Ignore all the visibility pragmas and attributes in source code">,

We should move this option to where the m groups belong.



Comment at: clang/lib/AST/Decl.cpp:1487
+ ? CK.forLinkageOnly()
+ : CK);
 }

Question: When I look for `visibility` in CodeGen, I could find some of the 
visibility settings there that does not depend on the query of existing 
visibility settings. For example, some of the vtable generation, which means we 
could still get visibility settings out from IR in some situation?
Does those visibility settings in the CodeGen matters?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2768
   // The type-visibility mode defaults to the value-visibility mode.
   if (Arg *typeVisOpt = Args.getLastArg(OPT_ftype_visibility)) {
 Opts.setTypeVisibilityMode(parseVisibility(typeVisOpt, Args, Diags));

Question: how should -mignore-xcoff-visiblity interact with -ftype-visibility?



Comment at: clang/test/Driver/ignore-xcoff-visibility.cpp:24
+// RUN: FileCheck -check-prefix=ERROR %s
+
+__attribute__((visibility("hidden"))) void foo_h(int *p) {

I don't feel like this test belongs in the Driver directory. 
There is driver test needed, which is to pass in `-###` and specify 
-mignore-xcoff-visibility to see if it gets passed by the driver.
But the majority of what this test tests seems belong to CodeGen directory.



Comment at: clang/test/Driver/ignore-xcoff-visibility.cpp:62
+#pragma GCC visibility pop
+
+// IGNOREVISIBILITY:@b = global i32 0

Do we also want to test attribute visibility on a type?
For example:
```
class __attribute__((__visibility__("hidden"))) TestClass {
   int foo();
   int bar();
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87451

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


[PATCH] D87163: [DSE] Switch to MemorySSA-backed DSE by default.

2020-09-16 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

In D87163#2275896 , @asbirlea wrote:

> I checked in a fix in https://reviews.llvm.org/rGfc8200633122, but I haven't 
> yet verified it addresses all the failures reported.

Thanks, I've confirmed that this fixes our tests in their original form (not 
reduced).

Our day-to-day testing of LLVM trunk is limited though, maybe one-tenth of our 
full suite. Since this code has some risks, I could start a full run to throw 
more testing at it. But that takes more machine capacity and human effort to 
remove flaky failures, so I'd prefer to wait until the odds are good that there 
won't be further changes. Let me know when you think it's ready.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87163

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


[PATCH] D87534: Sema: introduce `__attribute__((__swift_name__))`

2020-09-16 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked 8 inline comments as done.
compnerd added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4289
+if (Inline->getName() != Name && !Inline->isImplicit()) {
+  Diag(Inline->getLocation(), diag::warn_attribute_ignored) << Inline;
+  Diag(CI.getLoc(), diag::note_conflicting_attribute);

aaron.ballman wrote:
> I think it would be more helpful if the diagnostic said why the attribute is 
> being ignored (because the arguments don't match).
Does the note below not accomplish that?



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5804-5805
+if (const auto *Method = dyn_cast(D)) {
+  ParamCount = Method->getSelector().getNumArgs();
+  Params = Method->parameters().slice(0, ParamCount);
+} else {

aaron.ballman wrote:
> Do you have to worry about functions with `...` variadic parameters and how 
> those impact counts (for either ObjC or regular methods)?
No, they are currently not auto-imported AFAIK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87534

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 292237.
fanbo-meng added a comment.
Herald added a reviewer: aaron.ballman.

get platform name from triple instead of hardcoding, and convert its spelling


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

https://reviews.llvm.org/D87611

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/Lexer/aligned-allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,12 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DZOS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DZOS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -62,40 +65,40 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
+// expected-error-re@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation function 

[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/Targets/OSTargets.h:773-774
 }
+
+this->PlatformName = llvm::Triple::getOSTypeName(Triple.getOS());;
   }

There is an extra semi-colon.


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

https://reviews.llvm.org/D87611

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 292240.
fanbo-meng set the repository for this revision to rG LLVM Github Monorepo.
fanbo-meng added a comment.

fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/Lexer/aligned-allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,12 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DZOS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DZOS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -62,40 +65,40 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
+// expected-error-re@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation fun

[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7216
+  "aligned %select{allocation|deallocation}0 function of type '%1' is "
+  "%select{only|not}4 available on %2 %select{%3 or newer|}4">;
 def note_silence_aligned_allocation_unavailable : Note<

Can something be done about the trailing space?



Comment at: clang/test/SemaCXX/unavailable_aligned_allocation.cpp:158
+#elif defined(ZOS)
+// expected-error@-18 {{aligned deallocation function of type 'void (void *, 
enum std::align_val_t) noexcept' is not available on z/OS}}}
+// expected-note@-19 {{if you supply your own aligned allocation functions}}

Try to use the regex form to check against trailing whitespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne commandeered this revision.
ldionne added a reviewer: EricWF.
ldionne added a comment.
Herald added subscribers: dexonsmith, jkorous.

I did some work on trying to reproduce this a while ago but never got to 
reproducing it on macOS.


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

https://reviews.llvm.org/D31413

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


[PATCH] D87774: [flang] Introduce DiagnosticConsumer classes in libflangFrontend

2020-09-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added subscribers: cfe-commits, dang, mgorny.
Herald added a reviewer: DavidTruby.
Herald added a reviewer: sscalpone.
Herald added a project: clang.
awarzynski requested review of this revision.

Currently Flang uses TextDiagnostic, TextDiagnosticPrinter &
TestDiagnosticBuffer from Clang (more specifically, from
libclangFrontend). This patch introduces simplified versions of these
classes in Flang (i.e. it removes the depdendency on libclangFrontend).

Note that currently, Flang needs these diagnostics classes only for the
compiler driver diagnostics. This is unlike in Clang in which similar
diagnostic classes are used for (among others) Lexing/Parsing/Sema
diagnostics. For this reason the implementations introduced here are
rather basic.

This patch also enhances how the diagnostics are printed. In particular,
this is what you'd get _before_ (no text formatting):

  $ bin/flang-new
  error: no input files

This is what you get _after_ (in terminals that support it,
the text is formatted - bold + red):

  $ bin/flang-new
  flang-new: error: no input files

Tests are updated accordingly and options related to enabling/disabling
color diagnostics are flagged as supported by Flang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87774

Files:
  clang/include/clang/Driver/Options.td
  clang/tools/driver/driver.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/include/flang/Frontend/TextDiagnostic.h
  flang/include/flang/Frontend/TextDiagnosticBuffer.h
  flang/include/flang/Frontend/TextDiagnosticPrinter.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/TextDiagnostic.cpp
  flang/lib/Frontend/TextDiagnosticBuffer.cpp
  flang/lib/Frontend/TextDiagnosticPrinter.cpp
  flang/test/Flang-Driver/driver-error-cc1.c
  flang/test/Flang-Driver/driver-error-cc1.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/driver-version.f90
  flang/test/Flang-Driver/missing-input.f90
  flang/tools/flang-driver/driver.cpp
  flang/tools/flang-driver/fc1_main.cpp
  flang/unittests/Frontend/CompilerInstanceTest.cpp

Index: flang/unittests/Frontend/CompilerInstanceTest.cpp
===
--- flang/unittests/Frontend/CompilerInstanceTest.cpp
+++ flang/unittests/Frontend/CompilerInstanceTest.cpp
@@ -9,9 +9,9 @@
 #include "flang/Frontend/CompilerInstance.h"
 #include "gtest/gtest.h"
 #include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Driver/Options.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include 
@@ -24,7 +24,7 @@
   // 1. Set-up a basic DiagnosticConsumer
   std::string diagnosticOutput;
   llvm::raw_string_ostream diagnosticsOS(diagnosticOutput);
-  auto diagPrinter = std::make_unique(
+  auto diagPrinter = std::make_unique(
   diagnosticsOS, new clang::DiagnosticOptions());
 
   // 2. Create a CompilerInstance (to manage a DiagnosticEngine)
Index: flang/tools/flang-driver/fc1_main.cpp
===
--- flang/tools/flang-driver/fc1_main.cpp
+++ flang/tools/flang-driver/fc1_main.cpp
@@ -14,9 +14,9 @@
 
 #include "flang/Frontend/CompilerInstance.h"
 #include "flang/Frontend/CompilerInvocation.h"
+#include "flang/Frontend/TextDiagnosticBuffer.h"
 #include "flang/FrontendTool/Utils.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
@@ -34,18 +34,23 @@
   if (!flang->HasDiagnostics())
 return 1;
 
+  // We will buffer diagnostics from argument parsing so that we can output
+  // them using a well formed diagnostic object.
+  Fortran::TextDiagnosticBuffer *diagsBuffer =
+  new Fortran::TextDiagnosticBuffer;
+
   // Create CompilerInvocation - use a dedicated instance of DiagnosticsEngine
   // for parsing the arguments
   llvm::IntrusiveRefCntPtr diagID(
   new clang::DiagnosticIDs());
   llvm::IntrusiveRefCntPtr diagOpts =
   new clang::DiagnosticOptions();
-  clang::TextDiagnosticBuffer *diagsBuffer = new clang::TextDiagnosticBuffer;
   clang::DiagnosticsEngine diags(diagID, &*diagOpts, diagsBuffer);
   bool success =
   CompilerInvocation::CreateFromArgs(flang->GetInvocation(), argv, diags);
 
   diagsBuffer->FlushDiagnostics(flang->getDiagnostics());
+
   if (!success)
 return 1;
 
Index: flang/tools/flang-driver/driver.cpp
===
--- flang/tools/flang-driver/driver.cpp
+++ flang/tools/flang-driver/driver.cpp
@@ -11,17 +11,21 @@
 //
 //===--===//
 #include "clang/Driver/Driver.h"
+#include "

[PATCH] D87775: [clangd] Add option for disabling AddUsing tweak on some namespaces.

2020-09-16 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
adamcz added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

For style guides forbid "using" declarations for namespaces like "std".
With this new config option, AddUsing can be selectively disabled on
those.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87775

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "Annotations.h"
+#include "Config.h"
 #include "SourceCode.h"
 #include "TestFS.h"
 #include "TestTU.h"
@@ -2471,8 +2472,14 @@
 
 TWEAK_TEST(AddUsing);
 TEST_F(AddUsingTest, Prepare) {
+  Config Cfg;
+  Cfg.Style.FullyQualifiedNamespaces.push_back("ban");
+  WithContextValue WithConfig(Config::Key, std::move(Cfg));
+
   const std::string Header = R"cpp(
 #define NS(name) one::two::name
+namespace ban { void foo() {} }
+namespace banana { void foo() {} }
 namespace one {
 void oo() {}
 template class tt {};
@@ -2506,6 +2513,10 @@
   // Test that we don't crash or misbehave on unnamed DeclRefExpr.
   EXPECT_UNAVAILABLE(Header +
  "void fun() { one::two::cc() ^| one::two::cc(); }");
+  // Do not offer code action when operating on a banned namespace.
+  EXPECT_UNAVAILABLE(Header + "void fun() { ban::fo^o(); }");
+  EXPECT_UNAVAILABLE(Header + "void fun() { ::ban::fo^o(); }");
+  EXPECT_AVAILABLE(Header + "void fun() { banana::fo^o(); }");
 
   // Check that we do not trigger in header files.
   FileName = "test.h";
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "AST.h"
+#include "Config.h"
 #include "FindTarget.h"
 #include "refactor/Tweak.h"
 #include "support/Logger.h"
@@ -190,6 +191,29 @@
   return Out;
 }
 
+bool isNamespaceForbidden(const Tweak::Selection &Inputs,
+  const NestedNameSpecifier &Namespace) {
+  std::string Buf;
+  llvm::raw_string_ostream NamespaceStream(Buf);
+  Namespace.print(NamespaceStream,
+  Inputs.AST->getASTContext().getPrintingPolicy());
+  NamespaceStream << "::";
+  StringRef NamespaceStr = NamespaceStream.str();
+  NamespaceStr.consume_front("::");
+
+  for (StringRef Banned : Config::current().Style.FullyQualifiedNamespaces) {
+// We want to match regardless of leading ::, so we remove it from both
+// NamespaceStr and Banned. We append it at the end of both to make sure
+// that we do not prefix-match ::foo to ::foobar.
+Banned.consume_front("::");
+Banned.consume_back("::");
+if (NamespaceStr.startswith(Banned.str() + "::"))
+  return true;
+  }
+
+  return false;
+}
+
 bool AddUsing::prepare(const Selection &Inputs) {
   auto &SM = Inputs.AST->getSourceManager();
 
@@ -248,6 +272,9 @@
 return false;
   }
 
+  if (isNamespaceForbidden(Inputs, *QualifierToRemove.getNestedNameSpecifier()))
+return false;
+
   // Macros are difficult. We only want to offer code action when what's spelled
   // under the cursor is a namespace qualifier. If it's a macro that expands to
   // a qualifier, user would not know what code action will actually change.
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -38,6 +38,7 @@
 DictParser Dict("Config", this);
 Dict.handle("If", [&](Node &N) { parse(F.If, N); });
 Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
+Dict.handle("Style", [&](Node &N) { parse(F.Style, N); });
 Dict.parse(N);
 return !(N.failed() || HadError);
   }
@@ -71,6 +72,15 @@
 Dict.parse(N);
   }
 
+  void parse(Fragment::StyleBlock &F, Node &N) {
+DictParser Dict("Style", this);
+Dict.handle("FullyQualifiedNamespaces", [&](Node &N) {
+  if (auto Values = scalarValues(N))
+F.FullyQualifiedNamespaces = std::move(*Values);
+});
+Dict.parse(N);
+  }
+
   void parse(Fragment::IndexBlock &F, Node &N) {
 DictParser Dict("Index", this);
 Dict.handle("Bac

[PATCH] D80791: [AArch64] Generate .note.gnu.property based on module flags.

2020-09-16 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 292250.
danielkiss added a comment.

Rebased top of D85649 .


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

https://reviews.llvm.org/D80791

Files:
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-0.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-1.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-2.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-3.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
  llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll

Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-8.ll
+++ /dev/null
@@ -1,21 +0,0 @@
-; RUN: llc -mtriple=aarch64-linux %s   -o - | \
-; RUN:   FileCheck %s --check-prefix=ASM
-; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - | \
-; RUN:   llvm-readelf --notes - | FileCheck %s --check-prefix=OBJ
-
-define dso_local i32 @f() #0 {
-entry:
-  %r = tail call i32 @g()
-  ret i32 %r
-}
-
-declare dso_local i32 @g()
-
-attributes #0 = { "branch-target-enforcement"="true" }
-
-; Declarations don't prevent setting BTI
-; ASM:	.word	3221225472
-; ASM-NEXT:	.word	4
-; ASM-NEXT:	.word	1
-
-; OBJ: Properties: aarch64 feature: BTI
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-7.ll
+++ /dev/null
@@ -1,23 +0,0 @@
-; RUN: llc -mtriple=aarch64-linux %s   -o - 2>&1 | \
-; RUN:   FileCheck %s --check-prefix=ASM
-; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o -  |  \
-; RUN:   llvm-readelf -S - | FileCheck %s --check-prefix=OBJ
-
-define dso_local i32 @f() #0 {
-entry:
-  ret i32 0
-}
-
-define dso_local i32 @g() #1 {
-entry:
-  ret i32 0
-}
-
-attributes #0 = { "sign-return-address"="non-leaf" }
-
-attributes #1 = { "branch-target-enforcement"="true" }
-
-; No common attribute, no note section
-; ASM: warning: not setting BTI in feature flags
-; ASM-NOT: .note.gnu.property
-; OBJ-NOT: .note.gnu.property
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-6.ll
+++ /dev/null
@@ -1,22 +0,0 @@
-; RUN: llc -mtriple=aarch64-linux %s   -o - | \
-; RUN:   FileCheck %s --check-prefix=ASM
-; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - |  \
-; RUN:   llvm-readelf -S - | FileCheck %s --check-prefix=OBJ
-
-define dso_local i32 @f() #0 {
-entry:
-  ret i32 0
-}
-
-define dso_local i32 @g() #1 {
-entry:
-  ret i32 0
-}
-
-attributes #0 = { "sign-return-address"="non-leaf" }
-
-attributes #1 = { "sign-return-address"="none" }
-
-; No common attribute, no note section
-; ASM-NOT: .note.gnu.property
-; OBJ-NOT: .note.gnu.property
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-5.ll
+++ /dev/null
@@ -1,26 +0,0 @@
-; RUN: llc -mtriple=aarch64-linux %s   -o - 2>&1 | \
-; RUN:   FileCheck %s --check-prefix=ASM
-; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o -  |  \
-; RUN:   llvm-readelf --notes - | FileCheck %s --check-prefix=OBJ
-
-define dso_local i32 @f() #0 {
-entry:
-  ret i32 0
-}
-
-define dso_local i32 @g() #1 {
-entry:
-  ret i32 0
-}
-
-attributes #0 = { "branch-target-enforcement"="true" "sign-return-address"="non-leaf" }
-
-attributes #1 = { "sign-return-address"="all" }
-
-; Only the common atttribute (PAC)
-; ASM: warning: not setting BTI in feature flags
-; ASM:	.word	3221225472
-; ASM-NEXT:	.word	4
-; ASM-NEXT:	.word	2
-
-; OBJ: Properties: aarch64 feature: PAC
Index: llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
===
--- llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
+++ llvm/test/CodeGen/AArch64/note-gnu-property-pac-bti-4.ll
@@ -1,7 +1,5 @@
 ; RUN: llc -mtriple=aarch64-linux %s   -o - | \
 ; RUN:   FileCheck %s --check-prefix=ASM
-; RUN: llc -mtriple=aarch64-linux %s -filetype=obj -o - |  \
-; RUN:   llvm-readelf --notes - | FileCheck %s --check-prefix=OBJ
 
 define dso_local i32 @f() #0 {
 entry:
@@ -17,9 +15,5 @@
 
 attributes #1 = { "branch-target-enforcement"="true" }
 
-; Only the common atttribute (BTI)
-; ASM:	.word	3221225472
-; ASM-NEXT:	.word	4
-; ASM-NEXT:	.word	1
-
-; OBJ: Properties: aarch64 feature: BTI
+; Note is not emited if module has no properties
+; ASM-NOT: .note

[PATCH] D87534: Sema: introduce `__attribute__((__swift_name__))`

2020-09-16 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd updated this revision to Diff 292253.
compnerd marked an inline comment as done.
compnerd added a comment.

Address feedback from @aaron.ballman


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87534

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaObjC/attr-swift_name.m

Index: clang/test/SemaObjC/attr-swift_name.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-swift_name.m
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fobjc-arc %s
+
+#define SWIFT_NAME(name) __attribute__((__swift_name__(name)))
+
+typedef struct {
+  float x, y, z;
+} Point3D;
+
+__attribute__((__swift_name__("PType")))
+@protocol P
+@end
+
+__attribute__((__swift_name__("IClass")))
+@interface I
+- (instancetype)init SWIFT_NAME("init()");
+- (instancetype)initWithValue:(int)value SWIFT_NAME("iWithValue(_:)");
+
++ (void)refresh SWIFT_NAME("refresh()");
+
+- (instancetype)i SWIFT_NAME("i()");
+
+- (I *)iWithValue:(int)value SWIFT_NAME("i(value:)");
+- (I *)iWithValue:(int)value value:(int)value2 SWIFT_NAME("i(value:extra:)");
+- (I *)iWithValueConvertingValue:(int)value value:(int)value2 SWIFT_NAME("i(_:extra:)");
+
++ (I *)iWithOtheValue:(int)value SWIFT_NAME("init");
+// expected-warning@-1 {{parameter of '__swift_name__' attribute must be a Swift function name string}}
+
++ (I *)iWithAnotherValue:(int)value SWIFT_NAME("i()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
++ (I *)iWithYetAnotherValue:(int)value SWIFT_NAME("i(value:extra:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 1; got 2}}
+
++ (I *)iAndReturnErrorCode:(int *)errorCode SWIFT_NAME("i()"); // no-warning
++ (I *)iWithValue:(int)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(value:)"); // no-warning
+
++ (I *)iFromErrorCode:(const int *)errorCode SWIFT_NAME("i()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
++ (I *)iWithPointerA:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i()"); // no-warning
++ (I *)iWithPointerB:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(pointer:)"); // no-warning
++ (I *)iWithPointerC:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(pointer:errorCode:)"); // no-warning
+
++ (I *)iWithOtherI:(I *)other SWIFT_NAME("i()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
++ (instancetype)specialI SWIFT_NAME("init(options:)");
++ (instancetype)specialJ SWIFT_NAME("init(options:extra:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 0; got 2)}}
++ (instancetype)specialK SWIFT_NAME("init(_:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 0; got 1)}}
++ (instancetype)specialL SWIFT_NAME("i(options:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 0; got 1)}}
+
++ (instancetype)trailingParen SWIFT_NAME("foo(");
+// expected-warning@-1 {{parameter of '__swift_name__' attribute must be a Swift function name string}}
++ (instancetype)trailingColon SWIFT_NAME("foo:");
+// expected-warning@-1 {{parameter of '__swift_name__' attribute must be a Swift function name string}}
++ (instancetype)initialIgnore:(int)value SWIFT_NAME("_(value:)");
+// expected-warning@-1 {{'__swift_name__' attribute has invalid identifier for base name}}
++ (instancetype)middleOmitted:(int)value SWIFT_NAME("i(:)");
+// expected-warning@-1 {{'__swift_name__' attribute has invalid identifier for parameter name}}
+
+@property(strong) id someProp SWIFT_NAME("prop");
+@end
+
+enum SWIFT_NAME("E") E {
+  value1,
+  value2,
+  value3 SWIFT_NAME("three"),
+  value4 SWIFT_NAME("four()"), // expected-warning {{'__swift_name__' attribute has invalid identifier for base name}}
+};
+
+struct SWIFT_NAME("TStruct") SStruct {
+  int i, j, k SWIFT_NAME("kay");
+};
+
+int i SWIFT_NAME("g_i");
+
+void f0(int i) SWIFT_NAME("f_0");
+// expected-warning@-1 {{parameter of '__swift_name__' attribute must be a Swift function name string}}
+
+void f1(int i) SWIFT_NAME("f_1()");
+// expected-warning@-1 {{too few parameters in '__swift_name__' attribute (expected 1; got 0)}}
+
+void f2(int i) SWIFT_NAME("f_2(a:b:)");
+// expected-warning@-1 {{too many parameters in '__swift_name__' attribute (expected 1; got 2)}}
+
+void f3(int x, int y) SWIFT_NAME("fWithX(_:y:)");
+void f4(int x, int *error) SWIFT_NAME("fWithX(_:)");
+
+typedef int int_t SWIFT_NAME("IntType");
+
+struct Point3D createPoint3D(float x, float y, float z) SWI

[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 292254.
ldionne added a comment.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Added a test. I can't reproduce the issue, so I don't know whether the test is 
useful or not. Please help with that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

Files:
  libcxx/src/iostream.cpp
  
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.init_priority.sh.cpp


Index: 
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.init_priority.sh.cpp
===
--- /dev/null
+++ 
libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.init_priority.sh.cpp
@@ -0,0 +1,33 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// XFAIL: libcpp-has-no-stdout
+
+// Make sure that the iostreams are initialized before everything else.
+// This has been an issue when statically linking libc++ in some contexts.
+// See https://llvm.org/PR28954 for details.
+
+// RUN: %{build}
+// RUN: %{run} > %t.out
+// RUN: grep -e 'SHOULD BE PRINTED' %t.out
+
+#include 
+#include "test_macros.h"
+
+
+struct Foo {
+Foo() {
+std::cout << "SHOULD BE PRINTED" << std::endl;
+}
+};
+
+Foo foo;
+
+int main(int, char**) {
+return 0;
+}
Index: libcxx/src/iostream.cpp
===
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,7 @@
 #endif
 ;
 
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams 
__attribute__((init_priority(101)));
 
 // On Windows the TLS storage for locales needs to be initialized before we 
create
 // the standard streams, otherwise it may not be alive during program 
termination


Index: libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.init_priority.sh.cpp
===
--- /dev/null
+++ libcxx/test/std/input.output/iostream.objects/narrow.stream.objects/cout.init_priority.sh.cpp
@@ -0,0 +1,33 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// XFAIL: libcpp-has-no-stdout
+
+// Make sure that the iostreams are initialized before everything else.
+// This has been an issue when statically linking libc++ in some contexts.
+// See https://llvm.org/PR28954 for details.
+
+// RUN: %{build}
+// RUN: %{run} > %t.out
+// RUN: grep -e 'SHOULD BE PRINTED' %t.out
+
+#include 
+#include "test_macros.h"
+
+
+struct Foo {
+Foo() {
+std::cout << "SHOULD BE PRINTED" << std::endl;
+}
+};
+
+Foo foo;
+
+int main(int, char**) {
+return 0;
+}
Index: libcxx/src/iostream.cpp
===
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,7 @@
 #endif
 ;
 
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101)));
 
 // On Windows the TLS storage for locales needs to be initialized before we create
 // the standard streams, otherwise it may not be alive during program termination
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 accepted this revision.
sbc100 added a comment.

I'd love to see this land so we can drop our downstream patch in emscripten and 
also fix the outstanding wasi-sdk issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Might even be worth backporting such as simple but useful fix to the 11 release?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


[clang] 4cff1b4 - Do not apply calling conventions to MSVC entry points

2020-09-16 Thread Elizabeth Andrews via cfe-commits
Author: Elizabeth Andrews
Date: 2020-09-16T09:39:37-07:00
New Revision: 4cff1b40dacf6a5489b09657d94ea4757b8cd3b0

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

LOG: Do not apply calling conventions to MSVC entry points

Fix link error for MSVC entry points when calling conventions
are specified. MSVC entry points should have default calling
convention.

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenCXX/default_calling_conv.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 4ede2f9192f4..3e0d284bdf71 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -11095,6 +11095,11 @@ void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) {
 if (FD->getName() != "DllMain")
   FD->setHasImplicitReturnZero(true);
 
+  if (FT->getCallConv() != CC_C) {
+FT = Context.adjustFunctionType(FT, 
FT->getExtInfo().withCallingConv(CC_C));
+FD->setType(QualType(FT, 0));
+  }
+
   if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
 FD->setInvalidDecl();

diff  --git a/clang/test/CodeGenCXX/default_calling_conv.cpp 
b/clang/test/CodeGenCXX/default_calling_conv.cpp
index b5b0f47ceb98..16b623c30197 100644
--- a/clang/test/CodeGenCXX/default_calling_conv.cpp
+++ b/clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -1,10 +1,14 @@
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=FASTCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i486-unknown-linux-gnu 
-fdefault-calling-conv=stdcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=STDCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | 
FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
-
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl 
-emit-llvm -o - %s -DMAIN | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=FASTCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i486-unknown-linux-gnu 
-fdefault-calling-conv=stdcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=STDCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s 
-DMAIN | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWMAIN | FileCheck %s  
--check-prefix=WMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWINMAIN | FileCheck %s  
--check-prefix=WINMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWWINMAIN | FileCheck %s  
--check-prefix=WWINMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DDLLMAIN | FileCheck %s  
--check-prefix=DLLMAIN
+//
 // CDECL: define void @_Z5test1v
 // FASTCALL: define x86_fastcallcc void @_Z5test1v
 // STDCALL: define x86_stdcallcc void @_Z5test1v
@@ -46,7 +50,37 @@ void test() {
   a.test_member();
 }
 
+#ifdef MAIN
 // ALL: define i32 @main
 int main() {
   return 1;
 }
+#endif // main
+
+#ifdef WMAIN
+// WMAIN: define dso_local i32 @wmain
+int wmain() {
+  return 1;
+}
+#endif // wmain
+
+#ifdef WINMAIN
+// WINMAIN: define dso_local i32 @WinMain
+int WinMain() {
+  return 1;
+}
+#endif // WinMain
+
+#ifdef WWINMAIN
+// WWINMAIN: define dso_local i32 @wWinMain
+int wWinMain() {
+  return 1;
+}
+#endif // wWinMain
+
+#ifdef DLLMAIN
+// DLLMAIN: defin

[PATCH] D87701: Do not apply calling conventions to MSVC entry points

2020-09-16 Thread Elizabeth Andrews via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cff1b40dacf: Do not apply calling conventions to MSVC entry 
points (authored by eandrews).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87701

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/default_calling_conv.cpp


Index: clang/test/CodeGenCXX/default_calling_conv.cpp
===
--- clang/test/CodeGenCXX/default_calling_conv.cpp
+++ clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -1,10 +1,14 @@
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=FASTCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i486-unknown-linux-gnu 
-fdefault-calling-conv=stdcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=STDCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | 
FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
-// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
-
+// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl 
-emit-llvm -o - %s -DMAIN | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=FASTCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i486-unknown-linux-gnu 
-fdefault-calling-conv=stdcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=STDCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s 
-DMAIN | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=VECTORCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i986-unknown-linux-gnu 
-fdefault-calling-conv=regcall -emit-llvm -o - %s -DMAIN | FileCheck %s 
--check-prefix=REGCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWMAIN | FileCheck %s  
--check-prefix=WMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWINMAIN | FileCheck %s  
--check-prefix=WINMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DWWINMAIN | FileCheck %s  
--check-prefix=WWINMAIN
+// RUN: %clang_cc1 -triple i386-pc-win32  -target-feature +sse4.2 
-fdefault-calling-conv=fastcall -emit-llvm -o - %s -DDLLMAIN | FileCheck %s  
--check-prefix=DLLMAIN
+//
 // CDECL: define void @_Z5test1v
 // FASTCALL: define x86_fastcallcc void @_Z5test1v
 // STDCALL: define x86_stdcallcc void @_Z5test1v
@@ -46,7 +50,37 @@
   a.test_member();
 }
 
+#ifdef MAIN
 // ALL: define i32 @main
 int main() {
   return 1;
 }
+#endif // main
+
+#ifdef WMAIN
+// WMAIN: define dso_local i32 @wmain
+int wmain() {
+  return 1;
+}
+#endif // wmain
+
+#ifdef WINMAIN
+// WINMAIN: define dso_local i32 @WinMain
+int WinMain() {
+  return 1;
+}
+#endif // WinMain
+
+#ifdef WWINMAIN
+// WWINMAIN: define dso_local i32 @wWinMain
+int wWinMain() {
+  return 1;
+}
+#endif // wWinMain
+
+#ifdef DLLMAIN
+// DLLMAIN: define dso_local i32 @DllMain
+int DllMain() {
+  return 1;
+}
+#endif // DllMain
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11095,6 +11095,11 @@
 if (FD->getName() != "DllMain")
   FD->setHasImplicitReturnZero(true);
 
+  if (FT->getCallConv() != CC_C) {
+FT = Context.adjustFunctionType(FT, 
FT->getExtInfo().withCallingConv(CC_C));
+FD->setType(QualType(FT, 0));
+  }
+
   if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
 FD->setInvalidDecl();


Index: clang/test/CodeGenCXX/default_calling_conv.cpp
===
--- clang/test/CodeGenCXX/default_calling_conv.cpp
+++ clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -1,10 +1,14 @@
-// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl -emit-llvm -o - %s | FileCheck %

[PATCH] D87701: Do not apply calling conventions to MSVC entry points

2020-09-16 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

In D87701#2274860 , @rnk wrote:

> lgtm, thanks.

Thanks for taking a look!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87701

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7216
+  "aligned %select{allocation|deallocation}0 function of type '%1' is "
+  "%select{only|not}4 available on %2 %select{%3 or newer|}4">;
 def note_silence_aligned_allocation_unavailable : Note<

hubert.reinterpretcast wrote:
> Can something be done about the trailing space?
Thanks for catching that Hubert, I'll fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Evgeny Astigeevich via Phabricator via cfe-commits
eastig added a comment.

In D31413#2277070 , @ldionne wrote:

> Added a test. I can't reproduce the issue, so I don't know whether the test 
> is useful or not. Please help with that!

There are tests in https://reviews.llvm.org/D12689 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng updated this revision to Diff 292259.
fanbo-meng added a comment.

remove trailing whitespace from diagnostic


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

https://reviews.llvm.org/D87611

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/Lexer/aligned-allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp

Index: clang/test/SemaCXX/unavailable_aligned_allocation.cpp
===
--- clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,12 +1,15 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DIOS %s
 // RUN: %clang_cc1 -triple arm64-apple-ios10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DTVOS %s
 // RUN: %clang_cc1 -triple arm64-apple-tvos10.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DWATCHOS %s
 // RUN: %clang_cc1 -triple armv7k-apple-watchos3.0.0 -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-alloc-unavailable -std=c++1z -verify -DZOS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -std=c++1z -verify -DNO_ERRORS %s
+// RUN: %clang_cc1 -triple s390x-none-zos -fexceptions -faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DZOS %s
 
 namespace std {
   typedef decltype(sizeof(0)) size_t;
@@ -62,40 +65,40 @@
 #ifdef NO_ERRORS
 // expected-no-diagnostics
 #else
-// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-17 {{if you supply your own aligned allocation functions}}
-// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-19 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on}}
+// expected-error-re@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}}
 // expected-note@-21 {{if you supply your own aligned allocation functions}}
-// expected-error@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-23 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on}}
+// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
 // expected-note@-25 {{if you supply your own aligned allocation functions}}
 
-// expected-error@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is only available on}}
+// expected-error-re@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}}
 // expected-note@-27 {{if you supply your own aligned allocation functions}}
-// expected-error@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' 

[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D31413#2277118 , @eastig wrote:

> In D31413#2277070 , @ldionne wrote:
>
>> Added a test. I can't reproduce the issue, so I don't know whether the test 
>> is useful or not. Please help with that!
>
> There are tests in https://reviews.llvm.org/D12689 .

Oh, nice, I missed that. I'll borrow those if you don't mind. Can you close 
https://reviews.llvm.org/D12689 and leave a trace to this review? I'm trying to 
de-tangle things here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


[PATCH] D87611: [SystemZ][z/OS] Set aligned allocation unavailable by default for z/OS

2020-09-16 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM; thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87611

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


[PATCH] D87761: [clang][codegen] Skip adding default function attributes on intrinsics.

2020-09-16 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Seems reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87761

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 292261.
ldionne added a comment.

Add tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

Files:
  libcxx/src/iostream.cpp
  libcxx/test/std/input.output/iostream.objects/init.pass.cpp

Index: libcxx/test/std/input.output/iostream.objects/init.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/input.output/iostream.objects/init.pass.cpp
@@ -0,0 +1,88 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-stdin, libcpp-has-no-stdout
+
+// Make sure that the iostreams are initialized before everything else.
+// This has been an issue when statically linking libc++ in some contexts.
+// See https://llvm.org/PR28954 for details.
+//
+// This test works by checking that 'std::{cin/cout,cerr}' is the same in a
+// static object constructor and in the main function. It dumps the memory of
+// each stream in the static object constructor and compares it with the memory
+// in the main function.
+//
+// The assumption is that if there are no uses of the stream object (such as
+// construction), then its memory must be the same. In the case where the test
+// "fails" and we are actually accessing an uninitialized object when we perform
+// the memcpy, the behavior is technically undefined (so the test could still
+// pass).
+
+#include 
+#include 
+#include 
+
+struct Checker {
+char *cerr_mem_dump;
+char *cin_mem_dump;
+char *cout_mem_dump;
+char *clog_mem_dump;
+
+char *wcerr_mem_dump;
+char *wcin_mem_dump;
+char *wcout_mem_dump;
+char *wclog_mem_dump;
+
+Checker()
+: cerr_mem_dump(new char[sizeof(std::cerr)])
+, cin_mem_dump(new char[sizeof(std::cin)])
+, cout_mem_dump(new char[sizeof(std::cout)])
+, clog_mem_dump(new char[sizeof(std::clog)])
+
+, wcerr_mem_dump(new char[sizeof(std::wcerr)])
+, wcin_mem_dump(new char[sizeof(std::wcin)])
+, wcout_mem_dump(new char[sizeof(std::wcout)])
+, wclog_mem_dump(new char[sizeof(std::wclog)])
+ {
+std::memcpy(cerr_mem_dump, (char*)&std::cerr, sizeof(std::cerr));
+std::memcpy(cin_mem_dump, (char*)&std::cin, sizeof(std::cin));
+std::memcpy(cout_mem_dump, (char*)&std::cout, sizeof(std::cout));
+std::memcpy(clog_mem_dump, (char*)&std::clog, sizeof(std::clog));
+
+std::memcpy(wcerr_mem_dump, (char*)&std::wcerr, sizeof(std::wcerr));
+std::memcpy(wcin_mem_dump, (char*)&std::wcin, sizeof(std::wcin));
+std::memcpy(wcout_mem_dump, (char*)&std::wcout, sizeof(std::wcout));
+std::memcpy(wclog_mem_dump, (char*)&std::wclog, sizeof(std::wclog));
+}
+
+~Checker() {
+delete[] cerr_mem_dump;
+delete[] cin_mem_dump;
+delete[] cout_mem_dump;
+delete[] clog_mem_dump;
+
+delete[] wcerr_mem_dump;
+delete[] wcin_mem_dump;
+delete[] wcout_mem_dump;
+delete[] wclog_mem_dump;
+}
+};
+
+static Checker check;
+
+int main() {
+assert(std::memcmp(check.cerr_mem_dump, (char const*)&std::cerr, sizeof(std::cerr)) == 0);
+assert(std::memcmp(check.cin_mem_dump, (char const*)&std::cin, sizeof(std::cin)) == 0);
+assert(std::memcmp(check.cout_mem_dump, (char const*)&std::cout, sizeof(std::cout)) == 0);
+assert(std::memcmp(check.clog_mem_dump, (char const*)&std::clog, sizeof(std::clog)) == 0);
+
+assert(std::memcmp(check.wcerr_mem_dump, (char const*)&std::wcerr, sizeof(std::wcerr)) == 0);
+assert(std::memcmp(check.wcin_mem_dump, (char const*)&std::wcin, sizeof(std::wcin)) == 0);
+assert(std::memcmp(check.wcout_mem_dump, (char const*)&std::wcout, sizeof(std::wcout)) == 0);
+assert(std::memcmp(check.wclog_mem_dump, (char const*)&std::wclog, sizeof(std::wclog)) == 0);
+}
Index: libcxx/src/iostream.cpp
===
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,7 @@
 #endif
 ;
 
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101)));
 
 // On Windows the TLS storage for locales needs to be initialized before we create
 // the standard streams, otherwise it may not be alive during program termination
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: libcxx/test/std/input.output/iostream.objects/init.pass.cpp:15
+//
+// This test works by checking that 'std::{cin/cout,cerr}' is the same in a
+// static object constructor and in the main function. It dumps the memory of

I'll fix that typo when committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39faf428164a: [libc++] Ensure streams are initialized early 
(authored by ldionne).

Changed prior to commit:
  https://reviews.llvm.org/D31413?vs=292261&id=292262#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

Files:
  libcxx/src/iostream.cpp
  libcxx/test/std/input.output/iostream.objects/init.pass.cpp

Index: libcxx/test/std/input.output/iostream.objects/init.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/input.output/iostream.objects/init.pass.cpp
@@ -0,0 +1,88 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: libcpp-has-no-stdin, libcpp-has-no-stdout
+
+// Make sure that the iostreams are initialized before everything else.
+// This has been an issue when statically linking libc++ in some contexts.
+// See https://llvm.org/PR28954 for details.
+//
+// This test works by checking that std::{cin,cout,cerr} is the same in a
+// static object constructor and in the main function. It dumps the memory of
+// each stream in the static object constructor and compares it with the memory
+// in the main function.
+//
+// The assumption is that if there are no uses of the stream object (such as
+// construction), then its memory must be the same. In the case where the test
+// "fails" and we are actually accessing an uninitialized object when we perform
+// the memcpy, the behavior is technically undefined (so the test could still
+// pass).
+
+#include 
+#include 
+#include 
+
+struct Checker {
+char *cerr_mem_dump;
+char *cin_mem_dump;
+char *cout_mem_dump;
+char *clog_mem_dump;
+
+char *wcerr_mem_dump;
+char *wcin_mem_dump;
+char *wcout_mem_dump;
+char *wclog_mem_dump;
+
+Checker()
+: cerr_mem_dump(new char[sizeof(std::cerr)])
+, cin_mem_dump(new char[sizeof(std::cin)])
+, cout_mem_dump(new char[sizeof(std::cout)])
+, clog_mem_dump(new char[sizeof(std::clog)])
+
+, wcerr_mem_dump(new char[sizeof(std::wcerr)])
+, wcin_mem_dump(new char[sizeof(std::wcin)])
+, wcout_mem_dump(new char[sizeof(std::wcout)])
+, wclog_mem_dump(new char[sizeof(std::wclog)])
+ {
+std::memcpy(cerr_mem_dump, (char*)&std::cerr, sizeof(std::cerr));
+std::memcpy(cin_mem_dump, (char*)&std::cin, sizeof(std::cin));
+std::memcpy(cout_mem_dump, (char*)&std::cout, sizeof(std::cout));
+std::memcpy(clog_mem_dump, (char*)&std::clog, sizeof(std::clog));
+
+std::memcpy(wcerr_mem_dump, (char*)&std::wcerr, sizeof(std::wcerr));
+std::memcpy(wcin_mem_dump, (char*)&std::wcin, sizeof(std::wcin));
+std::memcpy(wcout_mem_dump, (char*)&std::wcout, sizeof(std::wcout));
+std::memcpy(wclog_mem_dump, (char*)&std::wclog, sizeof(std::wclog));
+}
+
+~Checker() {
+delete[] cerr_mem_dump;
+delete[] cin_mem_dump;
+delete[] cout_mem_dump;
+delete[] clog_mem_dump;
+
+delete[] wcerr_mem_dump;
+delete[] wcin_mem_dump;
+delete[] wcout_mem_dump;
+delete[] wclog_mem_dump;
+}
+};
+
+static Checker check;
+
+int main() {
+assert(std::memcmp(check.cerr_mem_dump, (char const*)&std::cerr, sizeof(std::cerr)) == 0);
+assert(std::memcmp(check.cin_mem_dump, (char const*)&std::cin, sizeof(std::cin)) == 0);
+assert(std::memcmp(check.cout_mem_dump, (char const*)&std::cout, sizeof(std::cout)) == 0);
+assert(std::memcmp(check.clog_mem_dump, (char const*)&std::clog, sizeof(std::clog)) == 0);
+
+assert(std::memcmp(check.wcerr_mem_dump, (char const*)&std::wcerr, sizeof(std::wcerr)) == 0);
+assert(std::memcmp(check.wcin_mem_dump, (char const*)&std::wcin, sizeof(std::wcin)) == 0);
+assert(std::memcmp(check.wcout_mem_dump, (char const*)&std::wcout, sizeof(std::wcout)) == 0);
+assert(std::memcmp(check.wclog_mem_dump, (char const*)&std::wclog, sizeof(std::wclog)) == 0);
+}
Index: libcxx/src/iostream.cpp
===
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,7 @@
 #endif
 ;
 
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams;
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101)));
 
 // On Windows the TLS storage for locales needs to be initialized before we create
 // the standard streams,

[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Evgeny Astigeevich via Phabricator via cfe-commits
eastig added a comment.

In D31413#2277133 , @ldionne wrote:

> In D31413#2277118 , @eastig wrote:
>
>> In D31413#2277070 , @ldionne wrote:
>>
>>> Added a test. I can't reproduce the issue, so I don't know whether the test 
>>> is useful or not. Please help with that!
>>
>> There are tests in https://reviews.llvm.org/D12689 .
>
> Oh, nice, I missed that. I'll borrow those if you don't mind. Can you close 
> https://reviews.llvm.org/D12689 and leave a trace to this review? I'm trying 
> to de-tangle things here.

I don't mind.
Just to check,  in PR28954 it is mentioned the solution based on 
'init_priority' works for Linux. What about other platforms?
The idea was to fall back to the conservative method if the attribute is not 
supported by a compiler. Maybe, as an option a warning can be issued.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


[PATCH] D31413: [libc++] Use __attribute__((init_priority(101))) to ensure streams get initialized early

2020-09-16 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: hans.
ldionne added a comment.

@hans Is there still time to cherry-pick this to the 11 release?

In D31413#2277198 , @eastig wrote:

> I don't mind.
> Just to check,  in PR28954 it is mentioned the solution based on 
> 'init_priority' works for Linux. What about other platforms?
> The idea was to fall back to the conservative method if the attribute is not 
> supported by a compiler. Maybe, as an option a warning can be issued.

Eric Fiselier said the attribute worked on all compilers we support, including 
clang-cl. So as long as you compile the library with a supported compiler, my 
understanding is that it should work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31413

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


  1   2   3   >