[PATCH] D70684: [clangd] Shutdown cleanly on signals.

2019-11-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 231012.
sammccall added a comment.

Don't require temp file to already exist!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/Shutdown.cpp
  clang-tools-extra/clangd/Shutdown.h
  clang-tools-extra/clangd/test/exit-eof.test
  clang-tools-extra/clangd/test/exit-signal.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -11,6 +11,7 @@
 #include "Features.inc"
 #include "Path.h"
 #include "Protocol.h"
+#include "Shutdown.h"
 #include "Trace.h"
 #include "Transport.h"
 #include "index/Background.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#ifndef _WIN32
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace {
@@ -435,6 +440,7 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::SetInterruptFunction(&requestShutdown);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
@@ -531,6 +537,10 @@
   LoggingSession LoggingSession(Logger);
   // Write some initial logs before we start doing any real work.
   log("{0}", clang::getClangToolFullVersion("clangd"));
+// FIXME: abstract this better, and print PID on windows too.
+#ifndef _WIN32
+  log("PID: {0}", getpid());
+#endif
   {
 SmallString<128> CWD;
 if (auto Err = llvm::sys::fs::current_path(CWD))
@@ -683,12 +693,7 @@
   // However if a bug causes them to run forever, we want to ensure the process
   // eventually exits. As clangd isn't directly user-facing, an editor can
   // "leak" clangd processes. Crashing in this case contains the damage.
-  //
-  // This is more portable than sys::WatchDog, and yields a stack trace.
-  std::thread([] {
-std::this_thread::sleep_for(std::chrono::minutes(5));
-std::abort();
-  }).detach();
+  abortAfterTimeout(std::chrono::minutes(5));
 
   return ExitCode;
 }
Index: clang-tools-extra/clangd/test/exit-signal.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-signal.test
@@ -0,0 +1,31 @@
+# This is a fiddly signal test, we need POSIX and a real shell.
+UNSUPPORTED: win32
+REQUIRES: shell
+
+# Our goal is:
+#  1) spawn clangd
+#  2) wait for it to start up (install signal handlers)
+#  3) send SIGTERM
+#  4) wait for clangd to shut down (nonzero exit for a signal)
+#  4) verify the shutdown was clean
+
+RUN: rm -f %t.err
+ # To keep clangd running, we need to hold its input stream open.
+ # We redirect its input to a subshell that waits for it to start up.
+RUN: not clangd 2> %t.err < <( \
+   # Loop waiting for clangd to start up, so signal handlers are installed.
+   # Reading the PID line ensures this, and lets us send a signal.
+RUN:   while true; do \
+ # Relevant log line is I[timestamp] PID: 
+RUN: CLANGD_PID=$(grep -a -m 1 "PID:" %t.err | cut -d' ' -f 3); \
+RUN: [ ! -z "$CLANGD_PID" ] && break; \
+RUN:   done; \
+RUN:   kill $CLANGD_PID \
+ # Now wait for clangd to exit.
+RUN: )
+
+# Check that clangd caught the signal and shut down cleanly.
+RUN: FileCheck %s < %t.err
+CHECK: Transport error: Got signal
+CHECK: LSP finished
+
Index: clang-tools-extra/clangd/test/exit-eof.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-eof.test
@@ -0,0 +1,7 @@
+# RUN: not clangd -sync < %s 2> %t.err
+# RUN: FileCheck %s < %t.err
+#
+# No LSP messages here, just let clangd see the end-of-file
+# CHECK: Transport error:
+# (Typically "Transport error: Input/output error" but platform-dependent).
+
Index: clang-tools-extra/clangd/Shutdown.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Shutdown.h
@@ -0,0 +1,84 @@
+//===--- Shutdown.h - Unclean exit scenarios *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// LSP specifies a protocol for shutting down: a `shutdown` request followed
+// by an `exit` notification. If this protocol is followed, clangd should
+// finish outstanding work and exit with code 0.
+//
+// The way this works in the happy case:
+//  - when ClangdLSPServer gets `shutdown`, it sets a flag
+//  - when ClangdLSPServer gets `exit`, it returns false to indicate end-of

[PATCH] D70684: [clangd] Shutdown cleanly on signals.

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

Build result: fail - 60239 tests passed, 1 failed and 732 were skipped.

  failed: Clangd.Clangd/exit-signal.test

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684



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


[PATCH] D70684: [clangd] Shutdown cleanly on signals.

2019-11-26 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684



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


[clang-tools-extra] 852bafa - [clangd] Implement cross-file rename.

2019-11-26 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2019-11-26T10:04:31+01:00
New Revision: 852bafae2bb4d875e8d206168a57667f59c0f9a6

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

LOG: [clangd] Implement cross-file rename.

Summary:
This is the initial version. The cross-file rename is purely based on
the index.

It is hidden under a command-line flag, and only available for a small set
of symbols.

Reviewers: ilya-biryukov, sammccall

Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/SourceCode.h
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TUScheduler.h
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/Rename.h
clang-tools-extra/clangd/refactor/Tweak.h
clang-tools-extra/clangd/tool/ClangdMain.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp
clang-tools-extra/clangd/unittests/SyncAPI.cpp
clang-tools-extra/clangd/unittests/SyncAPI.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 4fe815818074..57ed97f7a782 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -103,13 +103,13 @@ std::vector> 
buildHighlightScopeLookupTable() {
   return LookupTable;
 }
 
-// Makes sure edits in \p E are applicable to latest file contents reported by
+// Makes sure edits in \p FE are applicable to latest file contents reported by
 // editor. If not generates an error message containing information about files
 // that needs to be saved.
-llvm::Error validateEdits(const DraftStore &DraftMgr, const Tweak::Effect &E) {
+llvm::Error validateEdits(const DraftStore &DraftMgr, const FileEdits &FE) {
   size_t InvalidFileCount = 0;
   llvm::StringRef LastInvalidFile;
-  for (const auto &It : E.ApplyEdits) {
+  for (const auto &It : FE) {
 if (auto Draft = DraftMgr.getDraft(It.first())) {
   // If the file is open in user's editor, make sure the version we
   // saw and current version are compatible as this is the text that
@@ -704,7 +704,7 @@ void ClangdLSPServer::onCommand(const ExecuteCommandParams 
&Params,
   if (R->ApplyEdits.empty())
 return Reply("Tweak applied.");
 
-  if (auto Err = validateEdits(DraftMgr, *R))
+  if (auto Err = validateEdits(DraftMgr, R->ApplyEdits))
 return Reply(std::move(Err));
 
   WorkspaceEdit WE;
@@ -758,17 +758,23 @@ void ClangdLSPServer::onRename(const RenameParams &Params,
   if (!Code)
 return Reply(llvm::make_error(
 "onRename called for non-added file", ErrorCode::InvalidParams));
-
-  Server->rename(File, Params.position, Params.newName, /*WantFormat=*/true,
- [File, Code, Params, Reply = std::move(Reply)](
- llvm::Expected> Edits) mutable {
-   if (!Edits)
- return Reply(Edits.takeError());
-
-   WorkspaceEdit WE;
-   WE.changes = {{Params.textDocument.uri.uri(), *Edits}};
-   Reply(WE);
- });
+  Server->rename(
+  File, Params.position, Params.newName,
+  /*WantFormat=*/true,
+  [File, Params, Reply = std::move(Reply),
+   this](llvm::Expected Edits) mutable {
+if (!Edits)
+  return Reply(Edits.takeError());
+if (auto Err = validateEdits(DraftMgr, *Edits))
+  return Reply(std::move(Err));
+WorkspaceEdit Result;
+Result.changes.emplace();
+for (const auto &Rep : *Edits) {
+  (*Result.changes)[URI::createFile(Rep.first()).toString()] =
+  Rep.second.asTextEdits();
+}
+Reply(Result);
+  });
 }
 
 void ClangdLSPServer::onDocumentDidClose(

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 5a9833d78b48..6c5fabdce5c3 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -119,7 +119,8 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
  : nullptr),
   GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
-  TweakFilter(Opts.TweakFilter), WorkspaceRoot(Opts.WorkspaceRoot),
+  CrossFileRename(Opts.CrossFileRename), TweakFilter(Opts.TweakFilter),
+  WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly

[clang] a2601a4 - clang-format-vs : Fix typo NUGET_EXE_DIR on README

2019-11-26 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2019-11-26T10:16:06+01:00
New Revision: a2601a4116f6024b45fc6f53777d2f6a3cd3

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

LOG: clang-format-vs : Fix typo NUGET_EXE_DIR on README

Match with the CMake variable.

Patch by empty2fill!

Differential revision: https://reviews.llvm.org/D70632

Added: 


Modified: 
clang/tools/clang-format-vs/README.txt

Removed: 




diff  --git a/clang/tools/clang-format-vs/README.txt 
b/clang/tools/clang-format-vs/README.txt
index 84e0b451f018..2cac5b9af9e3 100644
--- a/clang/tools/clang-format-vs/README.txt
+++ b/clang/tools/clang-format-vs/README.txt
@@ -10,12 +10,12 @@ the following CMake vars:
 
 - BUILD_CLANG_FORMAT_VS_PLUGIN=ON
 
-- NUGET_EXE_PATH=path/to/nuget_dir (unless nuget.exe is already available in 
PATH)
+- NUGET_EXE_DIR=path/to/nuget_dir (unless nuget.exe is already available in 
PATH)
 
 example:
   cd /d C:\code\llvm
   mkdir build & cd build
-  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_PATH=C:\nuget ..
+  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_DIR=C:\nuget ..
 
 Once LLVM.sln is generated, build the clang_format_vsix target, which will 
build
 ClangFormat.sln, the C# extension application.



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


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

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

In D70500#1758963 , @sunfish wrote:

> If people feel using -B paths, and COMPILER_PATH, are appropriate, we can use 
> `GetProgramPath` itself, though note that that still does have a PATH 
> fallback.


I'm not an expert in driver code and how it should behave, but being consistent 
with how other tools are found definitely looks much better than special-casing 
a single tool.
Unless there are reasons why `wasm-opt` should be special, why not use the 
mechanism used by all other tools?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[PATCH] D69263: [clangd] Implement cross-file rename.

2019-11-26 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG852bafae2bb4: [clangd] Implement cross-file rename. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69263

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -38,8 +38,8 @@
 llvm::Expected>
 runFindDocumentHighlights(ClangdServer &Server, PathRef File, Position Pos);
 
-llvm::Expected>
-runRename(ClangdServer &Server, PathRef File, Position Pos, StringRef NewName);
+llvm::Expected runRename(ClangdServer &Server, PathRef File,
+Position Pos, StringRef NewName);
 
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -96,10 +96,9 @@
   return std::move(*Result);
 }
 
-llvm::Expected> runRename(ClangdServer &Server,
-PathRef File, Position Pos,
-llvm::StringRef NewName) {
-  llvm::Optional>> Result;
+llvm::Expected runRename(ClangdServer &Server, PathRef File,
+Position Pos, llvm::StringRef NewName) {
+  llvm::Optional> Result;
   Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -9,8 +9,10 @@
 #include "Annotations.h"
 #include "TestFS.h"
 #include "TestTU.h"
+#include "index/Ref.h"
 #include "refactor/Rename.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -18,8 +20,45 @@
 namespace clangd {
 namespace {
 
-MATCHER_P2(RenameRange, Code, Range, "") {
-  return replacementToEdit(Code, arg).range == Range;
+using testing::Eq;
+using testing::Pair;
+using testing::UnorderedElementsAre;
+
+// Build a RefSlab from all marked ranges in the annotation. The ranges are
+// assumed to associate with the given SymbolName.
+std::unique_ptr buildRefSlab(const Annotations &Code,
+  llvm::StringRef SymbolName,
+  llvm::StringRef Path) {
+  RefSlab::Builder Builder;
+  TestTU TU;
+  TU.HeaderCode = Code.code();
+  auto Symbols = TU.headerSymbols();
+  const auto &SymbolID = findSymbol(Symbols, SymbolName).ID;
+  for (const auto &Range : Code.ranges()) {
+Ref R;
+R.Kind = RefKind::Reference;
+R.Location.Start.setLine(Range.start.line);
+R.Location.Start.setColumn(Range.start.character);
+R.Location.End.setLine(Range.end.line);
+R.Location.End.setColumn(Range.end.character);
+auto U = URI::create(Path).toString();
+R.Location.FileURI = U.c_str();
+Builder.insert(SymbolID, R);
+  }
+
+  return std::make_unique(std::move(Builder).build());
+}
+
+std::vector<
+std::pair>
+applyEdits(FileEdits FE) {
+  std::vector> Results;
+  for (auto &It : FE)
+Results.emplace_back(
+It.first().str(),
+llvm::cantFail(tooling::applyAllReplacements(
+It.getValue().InitialCode, It.getValue().Replacements)));
+  return Results;
 }
 
 // Generates an expected rename result by replacing all ranges in the given
@@ -363,11 +402,11 @@
 llvm::StringRef NewName = "abcde";
 for (const auto &RenamePos : Code.points()) {
   auto RenameResult =
-  renameWithinFile(AST, testPath(TU.Filename), RenamePos, NewName);
-  ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError() << T;
-  auto ApplyResult = llvm::cantFail(
-  tooling::applyAllReplacements(Code.code(), *RenameResult));
-  EXPECT_EQ(expectedResult(Code, NewName), ApplyResult);
+  rename({RenamePos, NewName, AST, testPath(TU.Filename)});
+  ASSERT_TRUE(bool(RenameResult)) << Renam

[PATCH] D70632: clang-format-vs : Fix typo NUGET_EXE_DIR on README

2019-11-26 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2601a4116f6: clang-format-vs : Fix typo NUGET_EXE_DIR on 
README (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70632

Files:
  clang/tools/clang-format-vs/README.txt


Index: clang/tools/clang-format-vs/README.txt
===
--- clang/tools/clang-format-vs/README.txt
+++ clang/tools/clang-format-vs/README.txt
@@ -10,12 +10,12 @@
 
 - BUILD_CLANG_FORMAT_VS_PLUGIN=ON
 
-- NUGET_EXE_PATH=path/to/nuget_dir (unless nuget.exe is already available in 
PATH)
+- NUGET_EXE_DIR=path/to/nuget_dir (unless nuget.exe is already available in 
PATH)
 
 example:
   cd /d C:\code\llvm
   mkdir build & cd build
-  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_PATH=C:\nuget ..
+  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_DIR=C:\nuget ..
 
 Once LLVM.sln is generated, build the clang_format_vsix target, which will 
build
 ClangFormat.sln, the C# extension application.


Index: clang/tools/clang-format-vs/README.txt
===
--- clang/tools/clang-format-vs/README.txt
+++ clang/tools/clang-format-vs/README.txt
@@ -10,12 +10,12 @@
 
 - BUILD_CLANG_FORMAT_VS_PLUGIN=ON
 
-- NUGET_EXE_PATH=path/to/nuget_dir (unless nuget.exe is already available in PATH)
+- NUGET_EXE_DIR=path/to/nuget_dir (unless nuget.exe is already available in PATH)
 
 example:
   cd /d C:\code\llvm
   mkdir build & cd build
-  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_PATH=C:\nuget ..
+  cmake -DBUILD_CLANG_FORMAT_VS_PLUGIN=ON -DNUGET_EXE_DIR=C:\nuget ..
 
 Once LLVM.sln is generated, build the clang_format_vsix target, which will build
 ClangFormat.sln, the C# extension application.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70684: [clangd] Shutdown cleanly on signals.

2019-11-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 231014.
sammccall added a comment.

Don't close the input stream early.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/Shutdown.cpp
  clang-tools-extra/clangd/Shutdown.h
  clang-tools-extra/clangd/test/exit-eof.test
  clang-tools-extra/clangd/test/exit-signal.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -11,6 +11,7 @@
 #include "Features.inc"
 #include "Path.h"
 #include "Protocol.h"
+#include "Shutdown.h"
 #include "Trace.h"
 #include "Transport.h"
 #include "index/Background.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#ifndef _WIN32
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace {
@@ -435,6 +440,7 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::SetInterruptFunction(&requestShutdown);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
@@ -531,6 +537,10 @@
   LoggingSession LoggingSession(Logger);
   // Write some initial logs before we start doing any real work.
   log("{0}", clang::getClangToolFullVersion("clangd"));
+// FIXME: abstract this better, and print PID on windows too.
+#ifndef _WIN32
+  log("PID: {0}", getpid());
+#endif
   {
 SmallString<128> CWD;
 if (auto Err = llvm::sys::fs::current_path(CWD))
@@ -683,12 +693,7 @@
   // However if a bug causes them to run forever, we want to ensure the process
   // eventually exits. As clangd isn't directly user-facing, an editor can
   // "leak" clangd processes. Crashing in this case contains the damage.
-  //
-  // This is more portable than sys::WatchDog, and yields a stack trace.
-  std::thread([] {
-std::this_thread::sleep_for(std::chrono::minutes(5));
-std::abort();
-  }).detach();
+  abortAfterTimeout(std::chrono::minutes(5));
 
   return ExitCode;
 }
Index: clang-tools-extra/clangd/test/exit-signal.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-signal.test
@@ -0,0 +1,32 @@
+# This is a fiddly signal test, we need POSIX and a real shell.
+UNSUPPORTED: win32
+REQUIRES: shell
+
+# Our goal is:
+#  1) spawn clangd
+#  2) wait for it to start up (install signal handlers)
+#  3) send SIGTERM
+#  4) wait for clangd to shut down (nonzero exit for a signal)
+#  4) verify the shutdown was clean
+
+RUN: rm -f %t.err
+ # To keep clangd running, we need to hold its input stream open.
+ # We redirect its input to a subshell that waits for it to start up.
+RUN: not clangd 2> %t.err < <( \
+   # Loop waiting for clangd to start up, so signal handlers are installed.
+   # Reading the PID line ensures this, and lets us send a signal.
+RUN:   while true; do \
+ # Relevant log line is I[timestamp] PID: 
+RUN: CLANGD_PID=$(grep -a -m 1 "PID:" %t.err | cut -d' ' -f 3); \
+RUN: [ ! -z "$CLANGD_PID" ] && break; \
+RUN:   done; \
+RUN:   kill $CLANGD_PID; \
+   # Now wait for clangd to stop reading (before closing its input!)
+RUN:   while not grep "LSP finished" %t.err; do :; done; \
+RUN: )
+
+# Check that clangd caught the signal and shut down cleanly.
+RUN: FileCheck %s < %t.err
+CHECK: Transport error: Got signal
+CHECK: LSP finished
+
Index: clang-tools-extra/clangd/test/exit-eof.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-eof.test
@@ -0,0 +1,7 @@
+# RUN: not clangd -sync < %s 2> %t.err
+# RUN: FileCheck %s < %t.err
+#
+# No LSP messages here, just let clangd see the end-of-file
+# CHECK: Transport error:
+# (Typically "Transport error: Input/output error" but platform-dependent).
+
Index: clang-tools-extra/clangd/Shutdown.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Shutdown.h
@@ -0,0 +1,84 @@
+//===--- Shutdown.h - Unclean exit scenarios *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// LSP specifies a protocol for shutting down: a `shutdown` request followed
+// by an `exit` notification. If this protocol is followed, clangd should
+// finish outstanding work and exit with code 0.
+//
+// The way this works in the happy case:
+//  - when ClangdLSPServer gets `shutdown`,

[PATCH] D70480: [clangd] Use expansion location when the ref is inside macros.

2019-11-26 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:280
   (Roles & static_cast(index::SymbolRole::Reference)) &&
-  SM.getFileID(SpellingLoc) == SM.getMainFileID())
+  SM.getFileID(SM.getSpellingLoc(Loc)) == SM.getMainFileID())
 ReferencedDecls.insert(ND);

hokein wrote:
> ilya-biryukov wrote:
> > hokein wrote:
> > > ilya-biryukov wrote:
> > > > We're using `getSpellingLoc` here and `getFileLoc` later. Why not use 
> > > > `getFileLoc` everywhere?
> > > > 
> > > > Having a variable (similar to the `SpellingLoc` we had before) and 
> > > > calling `getFileLoc` only once also seems preferable.
> > > > We're using getSpellingLoc here and getFileLoc later. Why not use 
> > > > getFileLoc everywhere?
> > > 
> > > There are two things in SymbolCollector:
> > > - symbols & ranking signals, we use spelling location for them, the code 
> > > is part of this, `ReferencedDecls` is used to calculate the ranking
> > > - references
> > > 
> > > this patch only targets the reference part (changing the loc here would 
> > > break many assumptions I think, and there was a failure test).
> > - What are the assumptions that it will break?
> > - What is rationale for using spelling locations for ranking and file 
> > location for references?
> > 
> > It would be nice to have this spelled out somewhere in the code, too. 
> > Currently this looks like an accidental inconsistency. Especially given 
> > that `getFileLoc` and `getSpellingLoc` are often the same.
> Added comments to clarify the difference between references and other fields. 
The comment still does not explain *why* we do this.
Why not use the same type of locations for everything?



Comment at: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp:659
+  TYPE(TYPE([[Foo]])) foo3;
+  [[CAT]](Fo, o) foo4;
+}

hokein wrote:
> ilya-biryukov wrote:
> > Previously we would not report any location at all in that case, right?
> > Not sure how common this is, hope this won't blow up our index size too 
> > much. No need to change anything now, but we should be ready to revert if 
> > needed.
> > 
> > Worth putting a comment here that AST-based XRefs behave in the same way. 
> > (And maybe adding a test there, if there isn't one already)
> Yes, I measure the memory usage before vs after, it increased ~5% memory 
> usage.
On LLVM? This doesn't look too bad, but probably worth mentioning it in the 
patch description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70480



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


[PATCH] D70684: [clangd] Shutdown cleanly on signals.

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

Build result: pass - 60240 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684



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


[PATCH] D70358: Add Cursor.get_reference_name_range to clang python binding.

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

Hi Arthur,

Sorry for the late response.
I'm not the maintainer of the Python bindings and I'm not sure who is.

Maybe ask on Discord or cfe-dev mailing list?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70358



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


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

2019-11-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Thanks! This is starting to look really good now.




Comment at: clang/lib/Driver/Job.cpp:318
 
-int Command::Execute(ArrayRef> Redirects,
- std::string *ErrMsg, bool *ExecutionFailed) const {
+int Command::PrepareExecution(SmallVectorImpl &Argv,
+  std::string *ErrMsg,

Maybe better to just return a bool for success/failure since there is not 
really a process exit code yet.

(But I'm not even sure this is worth a separate method; see comment further 
down.)



Comment at: clang/lib/Driver/Job.cpp:386
+  SmallVector Argv;
+  int R = PrepareExecution(Argv, ErrMsg, ExecutionFailed);
+  if (R)

For CC1Command, PrepareExecution doesn't do very much (since it doesn't use 
response files). Because of that, I'm not sure breaking out PrepareExecution 
into a separate method is worth it. I'd just copy the part that applies to 
CC1Command here. Then we wouldn't need to check the return value from 
PrepareExecution (it can't fail if response files aren't used), and we also 
don't need to intercept SetResponsefile -- we'd just ignore it even if it's set.



Comment at: clang/lib/Driver/Job.cpp:415
+  // We don't support set a new environment when calling into ExecuteCC1Tool()
+  assert(0 && "The CC1Command doesn't support changing the environment vars!");
+}

llvm_unreachable("msg") is usually preferred instead of assert(0 && "msg")



Comment at: clang/tools/driver/driver.cpp:313
+  llvm::cl::ResetAllOptionOccurrences();
+  StringRef Tool = argv[1] + 4;
   void *GetExecutablePathVP = (void *)(intptr_t) GetExecutablePath;

This feels a little risky to me. Do we still need to rely on argv[1], now that 
we have a nice CC1Command abstraction?


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

https://reviews.llvm.org/D69825



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


[PATCH] D70180: [AArch64][SVE] Implement floating-point conversion intrinsics

2019-11-26 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4a649ad21aa2: [AArch64][SVE] Implement floating-point 
conversion intrinsics (authored by kmclaughlin).

Changed prior to commit:
  https://reviews.llvm.org/D70180?vs=229085&id=231032#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70180

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-fp-converts.ll
  llvm/test/CodeGen/AArch64/sve2-intrinsics-fp-converts.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-fp-converts.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-fp-converts.ll
@@ -0,0 +1,84 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; FCVTLT
+;
+
+define  @fcvtlt_f32_f16( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvtlt_f32_f16:
+; CHECK: fcvtlt z0.s, p0/m, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvtlt.f32f16( %a,
+%pg,
+%b)
+  ret  %out
+}
+
+define  @fcvtlt_f64_f32( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvtlt_f64_f32:
+; CHECK: fcvtlt	z0.d, p0/m, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvtlt.f64f32( %a,
+ %pg,
+ %b)
+  ret  %out
+}
+
+;
+; FCVTNT
+;
+
+define  @fcvtnt_f16_f32( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvtnt_f16_f32:
+; CHECK: fcvtnt z0.h, p0/m, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvtnt.f16f32( %a,
+  %pg,
+  %b)
+  ret  %out
+}
+
+define  @fcvtnt_f32_f64( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvtnt_f32_f64:
+; CHECK: fcvtnt	z0.s, p0/m, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvtnt.f32f64( %a,
+%pg,
+%b)
+  ret  %out
+}
+
+;
+; FCVTX
+;
+
+define  @fcvtx_f32_f64( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvtx_f32_f64:
+; CHECK: fcvtx z0.s, p0/m, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvtx.f32f64( %a,
+   %pg,
+   %b)
+  ret  %out
+}
+
+;
+; FCVTXNT
+;
+
+define  @fcvtxnt_f32_f64( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvtxnt_f32_f64:
+; CHECK: fcvtxnt z0.s, p0/m, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvtxnt.f32f64( %a,
+ %pg,
+ %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.fcvtlt.f32f16(, , )
+declare  @llvm.aarch64.sve.fcvtlt.f64f32(, , )
+declare  @llvm.aarch64.sve.fcvtnt.f16f32(, , )
+declare  @llvm.aarch64.sve.fcvtnt.f32f64(, , )
+declare  @llvm.aarch64.sve.fcvtx.f32f64(, , )
+declare  @llvm.aarch64.sve.fcvtxnt.f32f64(, , )
Index: llvm/test/CodeGen/AArch64/sve-intrinsics-fp-converts.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-fp-converts.ll
@@ -0,0 +1,400 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; FCVT
+;
+
+define  @fcvt_f16_f32( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvt_f16_f32:
+; CHECK: fcvt z0.h, p0/m, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvt.f16f32( %a,
+ %pg,
+ %b)
+  ret  %out
+}
+
+define  @fcvt_f16_f64( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvt_f16_f64:
+; CHECK: fcvt z0.h, p0/m, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvt.f16f64( %a,
+ %pg,
+ %b)
+  ret  %out
+}
+
+define  @fcvt_f32_f16( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvt_f32_f16:
+; CHECK: fcvt z0.s, p0/m, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvt.f32f16( %a,
+  %pg,
+  %b)
+  ret  %out
+}
+
+define  @fcvt_f32_f64( %a,  %pg,  %b) {
+; CHECK-LABEL: fcvt_f32_f64:
+; CHECK: fcvt z0.s, p0/m, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcvt.f32f64( %a,
+  %pg,
+

[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

2019-11-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:891
+if (getLangOpts().OpenCL)
+  EPI.TypeQuals.addAddressSpace(LangAS::opencl_generic);
+

rjmccall wrote:
> This should probably check that there isn't already an address space, right?
EPI has just been constructed newly here or do you mean if addr space has been 
set in the constructor? That is currently not the case but might happen in the 
future perhaps.


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

https://reviews.llvm.org/D69938



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


[clang] e54c83e - [OpenCL] Add work-group and miscellaneous vector builtin functions

2019-11-26 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-11-26T10:44:49Z
New Revision: e54c83ec4dd493f2c6a483be2f6f3fc93624d10a

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

LOG: [OpenCL] Add work-group and miscellaneous vector builtin functions

Add the work-group and miscellaneous vector builtin functions from the
OpenCL C specification.

Patch by Pierre Gondois and Sven van Haastregt.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 0bd4c51a04c2..353e0c1d8c8d 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -274,14 +274,21 @@ def Event : Type<"Event", 
QualType<"OCLEventTy">>;
 def VecAndScalar: IntList<"VecAndScalar", [1, 2, 3, 4, 8, 16]>;
 def VecNoScalar : IntList<"VecNoScalar", [2, 3, 4, 8, 16]>;
 def Vec1: IntList<"Vec1", [1]>;
+def Vec2: IntList<"Vec2", [2]>;
+def Vec4: IntList<"Vec4", [4]>;
+def Vec8: IntList<"Vec8", [8]>;
+def Vec16   : IntList<"Vec16", [16]>;
 def Vec1234 : IntList<"Vec1234", [1, 2, 3, 4]>;
 
 // Type lists.
-def TLAll   : TypeList<"TLAll", [Char, UChar, Short, UShort, Int, UInt, Long, 
ULong, Float, Double, Half]>;
+def TLAll : TypeList<"TLAll", [Char,  UChar, Short,  UShort, Int,  
UInt, Long,  ULong, Float, Double, Half]>;
+def TLAllUnsigned : TypeList<"TLAllUnsigned", [UChar, UChar, UShort, UShort, 
UInt, UInt, ULong, ULong, UInt,  ULong,  UShort]>;
 def TLFloat : TypeList<"TLFloat", [Float, Double, Half]>;
 def TLSignedInts   : TypeList<"TLSignedInts", [Char, Short, Int, Long]>;
 def TLUnsignedInts : TypeList<"TLUnsignedInts", [UChar, UShort, UInt, ULong]>;
 
+def TLIntLongFloats : TypeList<"TLIntLongFloats", [Int, UInt, Long, ULong, 
Float, Double, Half]>;
+
 // All unsigned integer types twice, to facilitate unsigned return types for 
e.g.
 // uchar abs(char) and
 // uchar abs(uchar).
@@ -306,6 +313,8 @@ def SGenTypeN  : GenericType<"SGenTypeN", 
TLSignedInts, VecAndScalar
 def UGenTypeN  : GenericType<"UGenTypeN", TLUnsignedInts, 
VecAndScalar>;
 // Float
 def FGenTypeN  : GenericType<"FGenTypeN", TLFloat, VecAndScalar>;
+// (u)int, (u)long, and all floats
+def IntLongFloatGenType1   : GenericType<"IntLongFloatGenType1", 
TLIntLongFloats, Vec1>;
 
 // GenType definitions for every single base type (e.g. fp32 only).
 // Names are like: GenTypeFloatVecAndScalar.
@@ -867,6 +876,31 @@ foreach Type = [Int, UInt] in {
   }
 }
 
+//
+// OpenCL v1.1 s6.11.12, v1.2 s6.12.12, v2.0 s6.13.12 - Miscellaneous Vector 
Functions
+// --- Table 19 ---
+foreach name = ["shuffle"] in {
+  foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
+foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
+  def : Builtin,
+   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
+   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
+  Attr.Const>;
+}
+  }
+}
+foreach name = ["shuffle2"] in {
+  foreach VSize1 = [Vec2, Vec4, Vec8, Vec16] in {
+foreach VSize2 = [Vec2, Vec4, Vec8, Vec16] in {
+  def : Builtin,
+   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
+   GenericType<"TLAll" # VSize2.Name, TLAll, VSize2>,
+   GenericType<"TLAllUnsigned" # VSize1.Name, 
TLAllUnsigned, VSize1>],
+  Attr.Const>;
+}
+  }
+}
+
 //
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14: Image Read and Write 
Functions
 // OpenCL Extension v2.0 s5.1.8 and s6.1.8: Image Read and Write Functions
@@ -1020,6 +1054,27 @@ foreach aQual = ["WO", "RW"] in {
 }
 
 
+//
+// OpenCL v2.0 s6.13.15 - Work-group Functions
+// --- Table 26 ---
+let MinVersion = CL20 in {
+  foreach name = ["work_group_all", "work_group_any"] in {
+def : Builtin;
+  }
+  foreach name = ["work_group_broadcast"] in {
+def : Builtin;
+def : Builtin;
+def : Builtin;
+  }
+  foreach op = ["add", "min", "max"] in {
+foreach name = ["work_group_reduce_", "work_group_scan_exclusive_",
+"work_group_scan_inclusive_"] in {
+  def : Builtin;
+}
+  }
+}
+
+
 // OpenCL v2.0 s9.17.3: Additions to section 6.13.1: Work-Item Functions
 let MinVersion = CL20 in {
   let Extension = "cl_khr_subgroups" in {

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.

[PATCH] D70546: [ARM][MVE][Intrinsics] Add MVE VMUL intrinsics.

2019-11-26 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231035.
MarkMurrayARM added a comment.

Rebase and reupload patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70546

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vmulq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
  llvm/unittests/Target/ARM/MachineInstrTest.cpp

Index: llvm/unittests/Target/ARM/MachineInstrTest.cpp
===
--- llvm/unittests/Target/ARM/MachineInstrTest.cpp
+++ llvm/unittests/Target/ARM/MachineInstrTest.cpp
@@ -250,9 +250,9 @@
 case MVE_VMUL_qr_i8:
 case MVE_VMULf16:
 case MVE_VMULf32:
-case MVE_VMULt1i16:
-case MVE_VMULt1i8:
-case MVE_VMULt1i32:
+case MVE_VMULi16:
+case MVE_VMULi8:
+case MVE_VMULi32:
 case MVE_VMVN:
 case MVE_VMVNimmi16:
 case MVE_VMVNimmi32:
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmulq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmul.i32 q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = mul <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vmulq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vmulq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmul.f32 q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = fmul <4 x float> %b, %a
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmulq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vmulq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmult.i8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.mul.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.mul.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vmulq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vmulq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmult.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.mul.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.mul.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
===
--- llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
+++ llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
@@ -211,7 +211,7 @@
   ; CHECK:   renamable $r4 = t2ADDrr renamable $r0, renamable $r12, 14, $noreg, $noreg
   ; CHECK:   renamable $r12 = t2ADDri killed renamable $r12, 16, 14, $noreg, $noreg
   ; CHECK:   renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, $noreg
-  ; CHECK:   renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
+  ; CHECK:   renamable $q0 = MVE_VMULi8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
   ; CHECK:   MVE_VSTRBU8 killed renamable $q0, killed renamable $r4, 0, 0, killed $noreg :: (store 16 into %ir.scevgep1, align 1)
   ; CHECK:   $lr = MVE_LETP renamable $lr, %bb.2
   ; CHECK: bb.3.for.cond.cleanup:
@@ -252,7 +252,7 @@
 renamable $r4 = t2ADDrr renamable $r0, renamable $r12, 14, $noreg, $noreg
 renamable $r12 = t2ADDri killed renamable $r12, 16, 14, $noreg, $noreg
 renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, $noreg
-renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
+renamable $q0 = MVE_VMULi8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
 MVE_VPST 8, implicit $vpr

[PATCH] D70545: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics.

2019-11-26 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231034.
MarkMurrayARM added a comment.

Rebase and reupload patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70545

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

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vabdq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vabdq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.s32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>%a, <4 x i32>%b)
+  ret <4 x i32> %0
+}
+
+declare <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>, <4 x i32>)
+
+define arm_aapcs_vfpcc <4 x float> @test_vabdq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vabdq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.f32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>%a, <4 x float>%b)
+  ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>, <4 x float>)
+
+define arm_aapcs_vfpcc <16 x i8> @test_vabdq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vabdq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -1664,8 +1664,9 @@
 }
 
 
-class MVE_VABD_int size, list pattern=[]>
-  : MVE_int<"vabd", suffix, size, pattern> {
+class MVE_VABD_int size,
+ list pattern=[]>
+  : MVE_int {
 
   let Inst{28} = U;
   let Inst{25-23} = 0b110;
@@ -1676,12 +1677,35 @@
   let validForTailPredication = 1;
 }
 
-def MVE_VABDs8  : MVE_VABD_int<"s8", 0b0, 0b00>;
-def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
-def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
-def MVE_VABDu8  : MVE_VABD_int<"u8", 0b1, 0b00>;
-def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
-def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
+multiclass MVE_VABD_m {
+  def "" : MVE_VABD_int;
+
+  let Predicates = [HasMVEInt] in {
+// Unpredicated absolute difference
+def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+
+// Predicated absolute difference
+def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(i32 1), (VTI.Pred VCCR:$mask),
+(VTI.Vec MQPR:$inactive)))>;
+  }
+}
+
+multiclass MVE_VABD
+  : MVE_VABD_m<"vabd", VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
+
+defm MVE_VABDs8  : MVE_VABD;
+defm MVE_VABDs16 : MVE_VABD;
+defm MVE_VABDs32 : MVE_VABD;
+defm MVE_VABDu8  : MVE_VABD;
+defm MVE_VABDu16 : MVE_VABD;
+defm MVE_VABDu32 : MVE_VABD;
 
 class MVE_VRHADD size, list pattern=[]>
   : MVE_int<"vrhadd", 

[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-26 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231037.
MarkMurrayARM added a comment.

Rebase and reupload patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vandq.c
  clang/test/CodeGen/arm-mve-intrinsics/vbicq.c
  clang/test/CodeGen/arm-mve-intrinsics/veorq.c
  clang/test/CodeGen/arm-mve-intrinsics/vornq.c
  clang/test/CodeGen/arm-mve-intrinsics/vorrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vandq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbicq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/veorq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vornq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <16 x i8> %b, %a
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vorrq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <8 x i16> %b, %a
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vorrq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = or <4 x i32> %1, %0
+  %3 = bitcast <4 x i32> %2 to <4 x float>
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+; Function Attrs: nounwind readnone
+define arm_aapcs_vfpcc <8 x half> @test_vorrq_m_f32(<4 x float> %inactive, <4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = zext i16 %p to i32
+  %3 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %2)
+  %4 = bitcast <4 x float> %inactive to <4 x i32>
+  %5 = tail call <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32> %0, <4 x i32> %1, <4 x i1> %3, <4 x i32> %4)
+  %6 = bitcast <4 x i32> %5 to <8 x half>
+  ret <8 x half> %6
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>,

[PATCH] D70545: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics.

2019-11-26 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

This mostly LGTM: only a handful of nits.




Comment at: clang/include/clang/Basic/arm_mve.td:45
 let params = T.Usual in {
+def vabdq: Intrinsic $a, $b)>;
+}

Can you wrap this line to 80 columns, please? I've been trying to fit the rest 
of the file in that width.



Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:1669
+ list pattern=[]>
+  : MVE_int {
 

This new template parameter `iname` seems to be redundant, since I can't see 
anywhere you set it to anything other than `"vabd"`.



Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:2958
+class MVE_VABD_fp
+  : MVE_float {

Similarly here: `iname` is an unnecessary extra template parameter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70545



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


[PATCH] D70546: [ARM][MVE][Intrinsics] Add MVE VMUL intrinsics.

2019-11-26 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir:219
   ; CHECK:   renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, 
$noreg
-  ; CHECK:   renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed 
renamable $q0, 0, $noreg, undef renamable $q0
+  ; CHECK:   renamable $q0 = MVE_VMULi8 killed renamable $q1, killed renamable 
$q0, 0, $noreg, undef renamable $q0
   ; CHECK:   MVE_VSTRBU8 killed renamable $q0, killed renamable $r4, 0, 0, 
killed $noreg :: (store 16 into %ir.scevgep1, align 1)

dmgreen wrote:
> This I like
Yes, I agree that the new names of these instruction ids are better. But if 
you're changing these names as a side effect of this patch, please add text to 
the commit message calling out the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70546



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


[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-26 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: clang/include/clang/Basic/arm_mve.td:68
+def "": Intrinsic
+(bitcast $a, UVector),

I think it's worth adding a comment here explaining why this bitcasting isn't 
overcomplicating the IR in the integer case. (Because `Vector` and `UVector` 
may be different vector types at the C level – vectors of signed/unsigned ints 
of the same size – but once they're lowered to IR, they're just vectors of 
`i16` or `i32` or whatever, with no sign at all, so the bitcasts will be 
automatically elided by `IRBuilder`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547



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


[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

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



Comment at: clang/include/clang/Tooling/CompilationDatabase.h:223
 
+/// Returns a wrapped CompilationDatabase that will expand all response files 
on
+/// commandline returned by underlying database.

nit: `s/response files/rsp(response) files/`



Comment at: clang/include/clang/Tooling/CompilationDatabase.h:230
+expandResponseFiles(std::unique_ptr Base,
+llvm::cl::TokenizerCallback Tokenizer = nullptr);
+

it looks like none of the callsites are setting this parameter can we get rid 
of this one?



Comment at: clang/lib/Tooling/CompilationDatabase.cpp:402
 llvm::sys::path::append(DatabasePath, "compile_flags.txt");
-return FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);
+auto Base =
+FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);

is it really common for rsp files to show up in fixed compilation databases? 
since compile_flags.txt itself is also a file doesn't make much sense to refer 
to another one. as it can also contain text of arbitrary length.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:167
+for (auto &Cmd : Cmds) {
+  expandResponseFiles(Cmd, Tokenizer);
+}

so it looks like we already have `ExpandResponseFiles` exposed in 
`llvm/include/llvm/Support/CommandLine.h` could you make use of it in here 
instead of re-implementing it again?

I see that it has a different signature, but we can do the conversion back and 
forth in here, going from `std::string` to `char*` is cheap anyways, coming 
back is expensive though, and we can limit that to iff we have seen an argument 
starting with an `@`. So this would be something like:

```
llvm::SmallVector Argvs;
Argvs.reserve(Cmd.CommandLine.size());
bool SeenRSPFile = false;
for(auto &Argv : Cmd.CommandLine) {
  Argvs.push_back(Argv.c_str());
  SeenRSPFile |= Argv.front() == '@';
}
if(!SeenRSPFile)
  continue;

// call ExpandResponseFiles with Argvs, convert back to vector and 
assign to Cmd.CommandLine
```


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

https://reviews.llvm.org/D70222



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


[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-26 Thread liu hui via Phabricator via cfe-commits
lh123 marked an inline comment as done.
lh123 added inline comments.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:167
+for (auto &Cmd : Cmds) {
+  expandResponseFiles(Cmd, Tokenizer);
+}

kadircet wrote:
> so it looks like we already have `ExpandResponseFiles` exposed in 
> `llvm/include/llvm/Support/CommandLine.h` could you make use of it in here 
> instead of re-implementing it again?
> 
> I see that it has a different signature, but we can do the conversion back 
> and forth in here, going from `std::string` to `char*` is cheap anyways, 
> coming back is expensive though, and we can limit that to iff we have seen an 
> argument starting with an `@`. So this would be something like:
> 
> ```
> llvm::SmallVector Argvs;
> Argvs.reserve(Cmd.CommandLine.size());
> bool SeenRSPFile = false;
> for(auto &Argv : Cmd.CommandLine) {
>   Argvs.push_back(Argv.c_str());
>   SeenRSPFile |= Argv.front() == '@';
> }
> if(!SeenRSPFile)
>   continue;
> 
> // call ExpandResponseFiles with Argvs, convert back to vector 
> and assign to Cmd.CommandLine
> ```
I think it's not easy to reuse `ExpandResponseFiles` without changing code 
because it uses llvm::sys::fs::current_path to resolve relative paths.

In fact, most of the code here is copied from `CommandLine`


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

https://reviews.llvm.org/D70222



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


[clang-tools-extra] c547c22 - [NFC] ASSERT_EQ before accessing items in containers

2019-11-26 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2019-11-26T13:45:04+01:00
New Revision: c547c22f18973dceaf5b40dae1b4ad7d3dd4eab7

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

LOG: [NFC] ASSERT_EQ before accessing items in containers

As discussed offline, something different from `EXPECT_EQ` should be
used to check if the container contains enough items before accessing
them so that other tests can still be run even if the assertion fails as
opposed to having `EXPECT_EQ` failing and then aborting the run due to
the errors caused by out-of-bounds memory access.

Reviewed by: ilya-biryukov

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index cb6d61150319..28f18e73d7a8 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1874,7 +1874,10 @@ TEST(CompletionTest, CompletionTokenRange) {
 Annotations TestCode(Text);
 auto Results = completions(Server, TestCode.code(), TestCode.point());
 
-EXPECT_EQ(Results.Completions.size(), 1u);
+if (Results.Completions.size() != 1) {
+  ADD_FAILURE() << "Results.Completions.size() != 1";
+  continue;
+}
 EXPECT_THAT(Results.Completions.front().CompletionTokenRange,
 TestCode.range());
   }

diff  --git a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp 
b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
index fe7a8898c5de..3c0257849021 100644
--- a/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -709,7 +709,10 @@ void bar(X *x) {
 
   auto Parsed = TU.build();
   for (const auto &D : Parsed.getDiagnostics()) {
-EXPECT_EQ(D.Fixes.size(), 1u);
+if (D.Fixes.size() != 1) {
+  ADD_FAILURE() << "D.Fixes.size() != 1";
+  continue;
+}
 EXPECT_EQ(D.Fixes[0].Message,
   std::string("Add include \"a.h\" for symbol X"));
   }



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


[PATCH] D70528: [NFC] ASSERT_EQ before accessing items in containers

2019-11-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 231046.
kbobyrev added a comment.

Rebase on top of master.


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

https://reviews.llvm.org/D70528

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -709,7 +709,10 @@
 
   auto Parsed = TU.build();
   for (const auto &D : Parsed.getDiagnostics()) {
-EXPECT_EQ(D.Fixes.size(), 1u);
+if (D.Fixes.size() != 1) {
+  ADD_FAILURE() << "D.Fixes.size() != 1";
+  continue;
+}
 EXPECT_EQ(D.Fixes[0].Message,
   std::string("Add include \"a.h\" for symbol X"));
   }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1874,7 +1874,10 @@
 Annotations TestCode(Text);
 auto Results = completions(Server, TestCode.code(), TestCode.point());
 
-EXPECT_EQ(Results.Completions.size(), 1u);
+if (Results.Completions.size() != 1) {
+  ADD_FAILURE() << "Results.Completions.size() != 1";
+  continue;
+}
 EXPECT_THAT(Results.Completions.front().CompletionTokenRange,
 TestCode.range());
   }


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -709,7 +709,10 @@
 
   auto Parsed = TU.build();
   for (const auto &D : Parsed.getDiagnostics()) {
-EXPECT_EQ(D.Fixes.size(), 1u);
+if (D.Fixes.size() != 1) {
+  ADD_FAILURE() << "D.Fixes.size() != 1";
+  continue;
+}
 EXPECT_EQ(D.Fixes[0].Message,
   std::string("Add include \"a.h\" for symbol X"));
   }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1874,7 +1874,10 @@
 Annotations TestCode(Text);
 auto Results = completions(Server, TestCode.code(), TestCode.point());
 
-EXPECT_EQ(Results.Completions.size(), 1u);
+if (Results.Completions.size() != 1) {
+  ADD_FAILURE() << "Results.Completions.size() != 1";
+  continue;
+}
 EXPECT_THAT(Results.Completions.front().CompletionTokenRange,
 TestCode.range());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-26 Thread liu hui via Phabricator via cfe-commits
lh123 marked an inline comment as done.
lh123 added inline comments.



Comment at: clang/lib/Tooling/CompilationDatabase.cpp:402
 llvm::sys::path::append(DatabasePath, "compile_flags.txt");
-return FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);
+auto Base =
+FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);

kadircet wrote:
> is it really common for rsp files to show up in fixed compilation databases? 
> since compile_flags.txt itself is also a file doesn't make much sense to 
> refer to another one. as it can also contain text of arbitrary length.
Yes, rsp files usually only appear on the command line.


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

https://reviews.llvm.org/D70222



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


[PATCH] D70528: [NFC] ASSERT_EQ before accessing items in containers

2019-11-26 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc547c22f1897: [NFC] ASSERT_EQ before accessing items in 
containers (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70528

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -709,7 +709,10 @@
 
   auto Parsed = TU.build();
   for (const auto &D : Parsed.getDiagnostics()) {
-EXPECT_EQ(D.Fixes.size(), 1u);
+if (D.Fixes.size() != 1) {
+  ADD_FAILURE() << "D.Fixes.size() != 1";
+  continue;
+}
 EXPECT_EQ(D.Fixes[0].Message,
   std::string("Add include \"a.h\" for symbol X"));
   }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1874,7 +1874,10 @@
 Annotations TestCode(Text);
 auto Results = completions(Server, TestCode.code(), TestCode.point());
 
-EXPECT_EQ(Results.Completions.size(), 1u);
+if (Results.Completions.size() != 1) {
+  ADD_FAILURE() << "Results.Completions.size() != 1";
+  continue;
+}
 EXPECT_THAT(Results.Completions.front().CompletionTokenRange,
 TestCode.range());
   }


Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -709,7 +709,10 @@
 
   auto Parsed = TU.build();
   for (const auto &D : Parsed.getDiagnostics()) {
-EXPECT_EQ(D.Fixes.size(), 1u);
+if (D.Fixes.size() != 1) {
+  ADD_FAILURE() << "D.Fixes.size() != 1";
+  continue;
+}
 EXPECT_EQ(D.Fixes[0].Message,
   std::string("Add include \"a.h\" for symbol X"));
   }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1874,7 +1874,10 @@
 Annotations TestCode(Text);
 auto Results = completions(Server, TestCode.code(), TestCode.point());
 
-EXPECT_EQ(Results.Completions.size(), 1u);
+if (Results.Completions.size() != 1) {
+  ADD_FAILURE() << "Results.Completions.size() != 1";
+  continue;
+}
 EXPECT_THAT(Results.Completions.front().CompletionTokenRange,
 TestCode.range());
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70441: [clangd] Speed up when building rename edit.

2019-11-26 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8805316172a6: [clangd] Speed up when building rename edit. 
(authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70441

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

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -638,6 +638,33 @@
   UnorderedElementsAre(Pair(Eq(Path), Eq(expectedResult(Code, NewName);
 }
 
+TEST(CrossFileRenameTests, BuildRenameEdits) {
+  Annotations Code("[[😂]]");
+  auto LSPRange = Code.range();
+  auto Edit = buildRenameEdit(Code.code(), {LSPRange}, "abc");
+  ASSERT_TRUE(bool(Edit)) << Edit.takeError();
+  ASSERT_EQ(1UL, Edit->Replacements.size());
+  EXPECT_EQ(4UL, Edit->Replacements.begin()->getLength());
+
+  // Test invalid range.
+  LSPRange.end = {10, 0}; // out of range
+  Edit = buildRenameEdit(Code.code(), {LSPRange}, "abc");
+  EXPECT_FALSE(Edit);
+  EXPECT_THAT(llvm::toString(Edit.takeError()),
+  testing::HasSubstr("fail to convert"));
+
+  // Normal ascii characters.
+  Annotations T(R"cpp(
+[[range]]
+  [[range]]
+  [[range]]
+  )cpp");
+  Edit = buildRenameEdit(T.code(), T.ranges(), "abc");
+  ASSERT_TRUE(bool(Edit)) << Edit.takeError();
+  EXPECT_EQ(applyEdits(FileEdits{{T.code(), std::move(*Edit)}}).front().second,
+expectedResult(Code, expectedResult(T, "abc")));
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/Rename.h
===
--- clang-tools-extra/clangd/refactor/Rename.h
+++ clang-tools-extra/clangd/refactor/Rename.h
@@ -47,6 +47,13 @@
 /// in another file (per the index).
 llvm::Expected rename(const RenameInputs &RInputs);
 
+/// Generates rename edits that replaces all given occurrences with the
+/// NewName.
+/// Exposed for testing only.
+llvm::Expected buildRenameEdit(llvm::StringRef InitialCode,
+ std::vector Occurrences,
+ llvm::StringRef NewName);
+
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -20,6 +20,7 @@
 #include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FormatVariadic.h"
 
 namespace clang {
 namespace clangd {
@@ -297,34 +298,6 @@
   return AffectedFiles;
 }
 
-llvm::Expected> toRangeOffset(const clangd::Range &R,
-llvm::StringRef Code) {
-  auto StartOffset = positionToOffset(Code, R.start);
-  if (!StartOffset)
-return StartOffset.takeError();
-  auto EndOffset = positionToOffset(Code, R.end);
-  if (!EndOffset)
-return EndOffset.takeError();
-  return std::make_pair(*StartOffset, *EndOffset);
-};
-
-llvm::Expected buildRenameEdit(llvm::StringRef InitialCode,
- const std::vector &Occurrences,
- llvm::StringRef NewName) {
-  tooling::Replacements RenameEdit;
-  for (const Range &Occurrence : Occurrences) {
-// FIXME: !positionToOffset is O(N), optimize it.
-auto RangeOffset = toRangeOffset(Occurrence, InitialCode);
-if (!RangeOffset)
-  return RangeOffset.takeError();
-auto ByteLength = RangeOffset->second - RangeOffset->first;
-if (auto Err = RenameEdit.add(tooling::Replacement(
-InitialCode, RangeOffset->first, ByteLength, NewName)))
-  return std::move(Err);
-  }
-  return Edit(InitialCode, std::move(RenameEdit));
-}
-
 // Index-based rename, it renames all occurrences outside of the main file.
 //
 // The cross-file rename is purely based on the index, as we don't want to
@@ -358,7 +331,7 @@
 llvm::inconvertibleErrorCode());
 
   FileEdits Results;
-  for (const auto &FileAndOccurrences : AffectedFiles) {
+  for (auto &FileAndOccurrences : AffectedFiles) {
 llvm::StringRef FilePath = FileAndOccurrences.first();
 
 auto AffectedFileCode = GetFileContent(FilePath);
@@ -366,11 +339,14 @@
   elog("Fail to read file content: {0}", AffectedFileCode.takeError());
   continue;
 }
-
-auto RenameEdit = buildRenameEdit(*AffectedFileCode,
-  FileAndOccurrences.getValue(), NewName);
-if (!RenameEdit)
-  return RenameEdit.takeError();
+auto RenameEdit = buildRenameE

Re: [clang] 7b86188 - [Diagnostic] add a warning which warns about misleading indentation

2019-11-26 Thread Maxim Kuvyrkov via cfe-commits
Hi Tyker,

This patch generates lots of warnings on building Linux kernel, which seem to 
be false positives.

E.g.,
===
static inline bool
atomic_inc_unless_negative(atomic_t *v)
{
int c = atomic_read(v);

do {
if (unlikely(c < 0))
return false;
} while (!atomic_try_cmpxchg(v, &c, c + 1));

return true;
}
===
00:01:57 ./include/linux/atomic-fallback.h:1136:10: warning: misleading 
indentation; statement is not part of the previous 'else' 
[-Wmisleading-indentation]
00:01:57 int c = atomic_read(v);
00:01:57 ^

Tyker, would you please revert your patch (it generates multi-gig log files in 
CI builds) and investigate the problem?

Arnd, would you please help Tyker troubleshooting problems from kernel side?

Thank you,

--
Maxim Kuvyrkov
https://www.linaro.org




> On Nov 25, 2019, at 10:52 PM, via cfe-commits  
> wrote:
> 
> 
> Author: Tyker
> Date: 2019-11-25T20:46:32+01:00
> New Revision: 7b86188b50bf6e537fe98b326f258fbd23108b83
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/7b86188b50bf6e537fe98b326f258fbd23108b83
> DIFF: 
> https://github.com/llvm/llvm-project/commit/7b86188b50bf6e537fe98b326f258fbd23108b83.diff
> 
> LOG: [Diagnostic] add a warning which warns about misleading indentation
> 
> Summary: Add a warning for misleading indentation similar to GCC's 
> -Wmisleading-indentation
> 
> Reviewers: aaron.ballman, xbolva00
> 
> Reviewed By: aaron.ballman, xbolva00
> 
> Subscribers: arphaman, Ka-Ka, thakis
> 
> Differential Revision: https://reviews.llvm.org/D70638
> 
> Added: 
>clang/test/SemaCXX/warn-misleading-indentation.cpp
> 
> Modified: 
>clang/include/clang/Basic/DiagnosticGroups.td
>clang/include/clang/Basic/DiagnosticParseKinds.td
>clang/include/clang/Parse/Parser.h
>clang/lib/Parse/ParseStmt.cpp
>clang/test/Index/pragma-diag-reparse.c
>clang/test/Misc/warning-wall.c
>clang/test/Preprocessor/pragma_diagnostic_sections.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
> b/clang/include/clang/Basic/DiagnosticGroups.td
> index 5bfb3de86a47..666193e074f0 100644
> --- a/clang/include/clang/Basic/DiagnosticGroups.td
> +++ b/clang/include/clang/Basic/DiagnosticGroups.td
> @@ -693,6 +693,7 @@ def ZeroLengthArray : DiagGroup<"zero-length-array">;
> def GNUZeroLineDirective : DiagGroup<"gnu-zero-line-directive">;
> def GNUZeroVariadicMacroArguments : 
> DiagGroup<"gnu-zero-variadic-macro-arguments">;
> def Fallback : DiagGroup<"fallback">;
> +def MisleadingIndentation : DiagGroup<"misleading-indentation">;
> 
> // This covers both the deprecated case (in C++98)
> // and the extension case (in C++11 onwards).
> @@ -884,7 +885,7 @@ def Consumed   : DiagGroup<"consumed">;
> // Note that putting warnings in -Wall will not disable them by default. If a
> // warning should be active _only_ when -Wall is passed in, mark it as
> // DefaultIgnore in addition to putting it here.
> -def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
> +def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, 
> MisleadingIndentation]>;
> 
> // Warnings that should be in clang-cl /w4.
> def : DiagGroup<"CL4", [All, Extra]>;
> 
> diff  --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
> b/clang/include/clang/Basic/DiagnosticParseKinds.td
> index c94d1b99d0e8..e6aa92eddef7 100644
> --- a/clang/include/clang/Basic/DiagnosticParseKinds.td
> +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
> @@ -61,6 +61,13 @@ def warn_null_statement : Warning<
>   "remove unnecessary ';' to silence this warning">,
>   InGroup, DefaultIgnore;
> 
> +def warn_misleading_indentation : Warning<
> +  "misleading indentation; %select{statement|declaration}0 is not part of "
> +  "the previous '%select{if|else|for|while}1'">,
> +  InGroup, DefaultIgnore;
> +def note_previous_statement : Note<
> +  "previous statement is here">;
> +
> def ext_thread_before : Extension<"'__thread' before '%0'">;
> def ext_keyword_as_ident : ExtWarn<
>   "keyword '%0' will be made available as an identifier "
> 
> diff  --git a/clang/include/clang/Parse/Parser.h 
> b/clang/include/clang/Parse/Parser.h
> index ea1116ff7a23..edd31e3ff7e8 100644
> --- a/clang/include/clang/Parse/Parser.h
> +++ b/clang/include/clang/Parse/Parser.h
> @@ -2266,11 +2266,13 @@ class Parser : public CodeCompletionHandler {
> return isTypeSpecifierQualifier();
>   }
> 
> +public:
>   /// isCXXDeclarationStatement - C++-specialized function that disambiguates
>   /// between a declaration or an expression statement, when parsing function
>   /// bodies. Returns true for declaration, false for expression.
>   bool isCXXDeclarationStatement();
> 
> +private:
>   /// isCXXSimpleDeclaration - C++-specialized function that disambiguates
>   /// between a simple-declaration or an expression-statement.
>

[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-26 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231051.
lh123 added a comment.

address comments


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

https://reviews.llvm.org/D70222

Files:
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support/TargetSelect.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 namespace clang {
 namespace tooling {
@@ -859,5 +860,76 @@
 "clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
 }
 
+class ExpandResponseFilesTest : public MemDBTest {
+protected:
+  void SetUp() override {
+InnerDir = path(StringRef("inner"));
+std::error_code EC = llvm::sys::fs::create_directory(InnerDir);
+EXPECT_TRUE(!EC);
+
+llvm::sys::path::append(RspFileName1, InnerDir, "rsp1.rsp");
+std::ofstream RspFile1(RspFileName1.c_str());
+RspFile1 << "-Dflag1";
+RspFile1.close();
+
+RspFileName2 = path(StringRef("rsp2.rsp"));
+std::ofstream RspFile2(RspFileName2.c_str());
+RspFile2 << "-Dflag2 @rsp3.rsp";
+RspFile2.close();
+
+RspFileName3 = path(StringRef("rsp3.rsp"));
+std::ofstream RspFile3(RspFileName3.c_str());
+RspFile3 << "-Dflag3";
+RspFile3.close();
+
+RspFileName4 = path(StringRef("rsp4.rsp"));
+std::ofstream  RspFile4(RspFileName4.c_str());
+RspFile4 << "-Dflag4 @rsp4.rsp";
+RspFile4.close();
+
+llvm::sys::path::append(RspFileName5, InnerDir, "rsp5.rsp");
+std::ofstream RspFile5(RspFileName5.c_str());
+RspFile5 << "-Dflag5 @inner/rsp1.rsp";
+RspFile5.close();
+  }
+
+  void TearDown() override {
+llvm::sys::fs::remove(RspFileName5);
+llvm::sys::fs::remove(RspFileName4);
+llvm::sys::fs::remove(RspFileName3);
+llvm::sys::fs::remove(RspFileName2);
+llvm::sys::fs::remove(RspFileName1);
+llvm::sys::fs::remove(InnerDir);
+  }
+
+  std::string getCommand(llvm::StringRef F) {
+auto Results = expandResponseFiles(std::make_unique(Entries))
+   ->getCompileCommands(path(F));
+if (Results.empty()) {
+  return "none";
+}
+return llvm::join(Results[0].CommandLine, " ");
+  }
+
+  SmallString<128> InnerDir;
+  SmallString<128> RspFileName1;
+  SmallString<128> RspFileName2;
+  SmallString<128> RspFileName3;
+  SmallString<128> RspFileName4;
+  SmallString<128> RspFileName5;
+};
+
+TEST_F(ExpandResponseFilesTest, ExpandResponseFiles) {
+  // clang-format off
+  add("foo.cpp", "clang",
+  ("@inner/rsp1.rsp @rsp2.rsp @rsp4.rsp "
+"@" + RspFileName1 + " @inner/rsp5.rsp @rsp6.rsp")
+  .str());
+  // clang-format on
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag1 -Dflag2 "
+   "-Dflag3 -Dflag4 @rsp4.rsp -Dflag1 "
+   "-Dflag5 -Dflag1 @rsp6.rsp");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -167,8 +167,8 @@
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
-return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(std::move(Base)))
+return Base ? inferTargetAndDriverMode(inferMissingCompileCommands(
+  expandResponseFiles(std::move(Base
 : nullptr;
   }
 };
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -0,0 +1,191 @@
+//===- ExpandResponseFileCompilationDataBase.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
+
+namespace clang {
+namespace tooling 

[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-26 Thread liu hui via Phabricator via cfe-commits
lh123 marked an inline comment as done.
lh123 added inline comments.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:167
+for (auto &Cmd : Cmds) {
+  expandResponseFiles(Cmd, Tokenizer);
+}

lh123 wrote:
> kadircet wrote:
> > so it looks like we already have `ExpandResponseFiles` exposed in 
> > `llvm/include/llvm/Support/CommandLine.h` could you make use of it in here 
> > instead of re-implementing it again?
> > 
> > I see that it has a different signature, but we can do the conversion back 
> > and forth in here, going from `std::string` to `char*` is cheap anyways, 
> > coming back is expensive though, and we can limit that to iff we have seen 
> > an argument starting with an `@`. So this would be something like:
> > 
> > ```
> > llvm::SmallVector Argvs;
> > Argvs.reserve(Cmd.CommandLine.size());
> > bool SeenRSPFile = false;
> > for(auto &Argv : Cmd.CommandLine) {
> >   Argvs.push_back(Argv.c_str());
> >   SeenRSPFile |= Argv.front() == '@';
> > }
> > if(!SeenRSPFile)
> >   continue;
> > 
> > // call ExpandResponseFiles with Argvs, convert back to vector 
> > and assign to Cmd.CommandLine
> > ```
> I think it's not easy to reuse `ExpandResponseFiles` without changing code 
> because it uses llvm::sys::fs::current_path to resolve relative paths.
> 
> In fact, most of the code here is copied from `CommandLine`
But we can reuse `static bool ExpandResponseFile(StringRef FName, StringSaver 
&Saver, TokenizerCallback Tokenizer, SmallVectorImpl &NewArgv, 
bool MarkEOLs, bool RelativeNames)` if we expose it in `CommandLine.h`


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

https://reviews.llvm.org/D70222



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


[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-26 Thread liu hui via Phabricator via cfe-commits
lh123 marked an inline comment as done.
lh123 added inline comments.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:167
+for (auto &Cmd : Cmds) {
+  expandResponseFiles(Cmd, Tokenizer);
+}

lh123 wrote:
> lh123 wrote:
> > kadircet wrote:
> > > so it looks like we already have `ExpandResponseFiles` exposed in 
> > > `llvm/include/llvm/Support/CommandLine.h` could you make use of it in 
> > > here instead of re-implementing it again?
> > > 
> > > I see that it has a different signature, but we can do the conversion 
> > > back and forth in here, going from `std::string` to `char*` is cheap 
> > > anyways, coming back is expensive though, and we can limit that to iff we 
> > > have seen an argument starting with an `@`. So this would be something 
> > > like:
> > > 
> > > ```
> > > llvm::SmallVector Argvs;
> > > Argvs.reserve(Cmd.CommandLine.size());
> > > bool SeenRSPFile = false;
> > > for(auto &Argv : Cmd.CommandLine) {
> > >   Argvs.push_back(Argv.c_str());
> > >   SeenRSPFile |= Argv.front() == '@';
> > > }
> > > if(!SeenRSPFile)
> > >   continue;
> > > 
> > > // call ExpandResponseFiles with Argvs, convert back to 
> > > vector and assign to Cmd.CommandLine
> > > ```
> > I think it's not easy to reuse `ExpandResponseFiles` without changing code 
> > because it uses llvm::sys::fs::current_path to resolve relative paths.
> > 
> > In fact, most of the code here is copied from `CommandLine`
> But we can reuse `static bool ExpandResponseFile(StringRef FName, StringSaver 
> &Saver, TokenizerCallback Tokenizer, SmallVectorImpl &NewArgv, 
> bool MarkEOLs, bool RelativeNames)` if we expose it in `CommandLine.h`
`static bool ExpandResponseFile(StringRef FName, StringSaver &Saver, 
TokenizerCallback Tokenizer, SmallVectorImpl &NewArgv, bool 
MarkEOLs, bool RelativeNames)` also seems to use `llvm::sys::fs::current_path` 
to resolve relative paths.


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

https://reviews.llvm.org/D70222



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


[PATCH] D70545: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics.

2019-11-26 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231055.
MarkMurrayARM added a comment.

Respond to review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70545

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

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vabdq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vabdq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.s32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>%a, <4 x i32>%b)
+  ret <4 x i32> %0
+}
+
+declare <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>, <4 x i32>)
+
+define arm_aapcs_vfpcc <4 x float> @test_vabdq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vabdq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.f32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>%a, <4 x float>%b)
+  ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>, <4 x float>)
+
+define arm_aapcs_vfpcc <16 x i8> @test_vabdq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vabdq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -1664,7 +1664,8 @@
 }
 
 
-class MVE_VABD_int size, list pattern=[]>
+class MVE_VABD_int size,
+ list pattern=[]>
   : MVE_int<"vabd", suffix, size, pattern> {
 
   let Inst{28} = U;
@@ -1676,12 +1677,35 @@
   let validForTailPredication = 1;
 }
 
-def MVE_VABDs8  : MVE_VABD_int<"s8", 0b0, 0b00>;
-def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
-def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
-def MVE_VABDu8  : MVE_VABD_int<"u8", 0b1, 0b00>;
-def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
-def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
+multiclass MVE_VABD_m {
+  def "" : MVE_VABD_int;
+
+  let Predicates = [HasMVEInt] in {
+// Unpredicated absolute difference
+def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+
+// Predicated absolute difference
+def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(i32 1), (VTI.Pred VCCR:$mask),
+(VTI.Vec MQPR:$inactive)))>;
+  }
+}
+
+multiclass MVE_VABD
+  : MVE_VABD_m;
+
+defm MVE_VABDs8  : MVE_VABD;
+defm MVE_VABDs16 : MVE_VABD;
+defm MVE_VABDs32 : MVE_VABD;
+defm MVE_VABDu8  : MVE_VABD;
+defm MVE_VABDu16 : MVE_VABD;
+defm MVE_VABDu32 : MVE_VABD;
 
 class MVE_VRHADD size, list pattern=[]>
   : MVE_int<"vrhadd", suffix, size, pattern> {
@@ -2950,8 +2974,28 @@
   let validForTailPredication = 1;
 }
 
-def MVE_VABDf

[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-26 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231057.
MarkMurrayARM added a comment.

Respond to review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vandq.c
  clang/test/CodeGen/arm-mve-intrinsics/vbicq.c
  clang/test/CodeGen/arm-mve-intrinsics/veorq.c
  clang/test/CodeGen/arm-mve-intrinsics/vornq.c
  clang/test/CodeGen/arm-mve-intrinsics/vorrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vandq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbicq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/veorq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vornq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <16 x i8> %b, %a
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vorrq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <8 x i16> %b, %a
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vorrq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = or <4 x i32> %1, %0
+  %3 = bitcast <4 x i32> %2 to <4 x float>
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+; Function Attrs: nounwind readnone
+define arm_aapcs_vfpcc <8 x half> @test_vorrq_m_f32(<4 x float> %inactive, <4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = zext i16 %p to i32
+  %3 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %2)
+  %4 = bitcast <4 x float> %inactive to <4 x i32>
+  %5 = tail call <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32> %0, <4 x i32> %1, <4 x i1> %3, <4 x i32> %4)
+  %6 = bitcast <4 x i32> %5 to <8 x half>
+  ret <8 x half> %6
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32>, <4 x i32>, 

[PATCH] D70546: [ARM][MVE][Intrinsics] Add MVE VMUL intrinsics.

2019-11-26 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 231056.
MarkMurrayARM added a comment.

Respond to review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70546

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vmulq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
  llvm/unittests/Target/ARM/MachineInstrTest.cpp

Index: llvm/unittests/Target/ARM/MachineInstrTest.cpp
===
--- llvm/unittests/Target/ARM/MachineInstrTest.cpp
+++ llvm/unittests/Target/ARM/MachineInstrTest.cpp
@@ -250,9 +250,9 @@
 case MVE_VMUL_qr_i8:
 case MVE_VMULf16:
 case MVE_VMULf32:
-case MVE_VMULt1i16:
-case MVE_VMULt1i8:
-case MVE_VMULt1i32:
+case MVE_VMULi16:
+case MVE_VMULi8:
+case MVE_VMULi32:
 case MVE_VMVN:
 case MVE_VMVNimmi16:
 case MVE_VMVNimmi32:
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmulq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmul.i32 q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = mul <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vmulq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vmulq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmul.f32 q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = fmul <4 x float> %b, %a
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmulq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vmulq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmult.i8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.mul.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.mul.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vmulq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vmulq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmult.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.mul.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.mul.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
===
--- llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
+++ llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
@@ -211,7 +211,7 @@
   ; CHECK:   renamable $r4 = t2ADDrr renamable $r0, renamable $r12, 14, $noreg, $noreg
   ; CHECK:   renamable $r12 = t2ADDri killed renamable $r12, 16, 14, $noreg, $noreg
   ; CHECK:   renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, $noreg
-  ; CHECK:   renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
+  ; CHECK:   renamable $q0 = MVE_VMULi8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
   ; CHECK:   MVE_VSTRBU8 killed renamable $q0, killed renamable $r4, 0, 0, killed $noreg :: (store 16 into %ir.scevgep1, align 1)
   ; CHECK:   $lr = MVE_LETP renamable $lr, %bb.2
   ; CHECK: bb.3.for.cond.cleanup:
@@ -252,7 +252,7 @@
 renamable $r4 = t2ADDrr renamable $r0, renamable $r12, 14, $noreg, $noreg
 renamable $r12 = t2ADDri killed renamable $r12, 16, 14, $noreg, $noreg
 renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, $noreg
-renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
+renamable $q0 = MVE_VMULi8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
 MVE_VPST 8, implicit $vpr
 

[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-26 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

LGTM, though I spotted a couple of even tinier last-minute nits.




Comment at: clang/include/clang/Basic/arm_mve.td:68
+// Vector and UVector may be different vector types at the C level i.e.
+// vectors of ame size igned/unsigned ints. Once they're lowered
+// to IR, they're just bit vectors with no sign at all, so the

Typos: "ame" and "igned" should be "same" and "signed".



Comment at: clang/include/clang/Basic/arm_mve.td:72
+multiclass predicated_bit_op_fp {
+def "": Intrinsic

Another long line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547



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


[PATCH] D70041: register cuda language activation event and activate for .cuh files

2019-11-26 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.

sorry for the delay, looks good, one more nit.




Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:91
 { scheme: 'file', language: 'cpp' },
+// Syntax highlighting for the 'cuda' language is
+// provided by the kriegalex.vscode-cudacpp plugin.

This comment seems not correct anymore, I'd just drop it, or rephrase like 
`VSCode does not have CUDA as a supported language yet, but our extension does`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70041



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


[PATCH] D66564: [clang-tidy] new altera struct pack align check

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



Comment at: clang-tidy/altera/StructPackAlignCheck.cpp:66-68
+  // FIXME: Express this as CharUnit rather than a hardcoded 8-bits (Rshift3)i
+  // After computing the minimum size in bits, check for an existing alignment
+  // flag.

I'm not certain I understand this FIXME, is it out of date? You're getting the 
width of a char and using that rather than hard-coding already.



Comment at: clang-tidy/altera/StructPackAlignCheck.cpp:71
+  CharUnits MinByteSize =
+   //   CharUnits::fromQuantity(ceil((float)TotalBitSize / CHAR_BIT));
+  CharUnits::fromQuantity(ceil((float)TotalBitSize / CharSize));

This should probably be removed.



Comment at: clang-tidy/altera/StructPackAlignCheck.cpp:85
+  ((Struct->getMaxAlignment() / CharSize) != NewAlign.getQuantity()) &&
+//  ((Struct->getMaxAlignment() / CHAR_BIT) != NewAlign.getQuantity()) &&
+  (CurrSize != NewAlign) && !IsPacked) {

This should also probably be removed.



Comment at: clang-tidy/altera/StructPackAlignCheck.cpp:93-94
+diag(Struct->getLocation(),
+ "use \"__attribute__((packed))\" to reduce the amount of padding "
+ "applied to struct %0", DiagnosticIDs::Note)
+<< Struct;

Would it make sense to generate a fixit to add the attribute to the struct so 
long as the struct is not in a system header?



Comment at: clang-tidy/altera/StructPackAlignCheck.cpp:107
+diag(Struct->getLocation(),
+ "use \"__attribute__((aligned(%0)))\" to align struct %1 to %0 bytes",
+ DiagnosticIDs::Note)

Similar question here about the fixit.


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

https://reviews.llvm.org/D66564



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


[PATCH] D70568: [Support] Possibly use exception handler in the Crash Recovery Context in the same way as global exceptions

2019-11-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> This is a support patch for D69825 .

Thanks for breaking this out!

> It handles an exception in the same way as the global exception handler (same 
> side-effect, print call stack & cleanup), and can return the exception code.

I'm not familiar with this code, so I was struggling with the patch title: 
"Possibly use exception handler in the Crash Recovery Context in the same way 
as global exceptions".

Do I understand correctly that the main point is to get a stack trace when 
CrashRecoveryContext::RunSafely() fails, instead of just returning an error?

> It enables CrashRecoveryContext exceptions by default (instead of disabled 
> before) - however the exception handlers are lazily installed on the first 
> creation of a CrashRecoveryContext.

Why does it now need to be enabled by default?




Comment at: llvm/include/llvm/Support/CrashRecoveryContext.h:26
 /// Clients make use of this code by first calling
 /// CrashRecoveryContext::Enable(), and then executing unsafe operations via a
 /// CrashRecoveryContext object. For example:

I guess this needs an update, if it's now being enabled by default?



Comment at: llvm/include/llvm/Support/CrashRecoveryContext.h:104
+
+  /// In case of a crash, this is the crash identifier
+  int RetCode = 0;

ultra nit: period at the end would be nice :)



Comment at: llvm/include/llvm/Support/Signals.h:116
+  /// ignored and is always zero.
+  signed InvokeExceptionHandler(int &RetCode, void *ExceptionInfo);
 } // End sys namespace

Any reason not to use "int" for the return type here? "signed" is unusual as a 
type in LLVM I think.



Comment at: llvm/lib/Support/CrashRecoveryContext.cpp:82
 
+static std::atomic gCrashRecoveryEnabled{ true };
 static ManagedStatic gCrashRecoveryContextMutex;

" = true" would be more common in LLVM code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70568



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


[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

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



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:167
+for (auto &Cmd : Cmds) {
+  expandResponseFiles(Cmd, Tokenizer);
+}

lh123 wrote:
> lh123 wrote:
> > lh123 wrote:
> > > kadircet wrote:
> > > > so it looks like we already have `ExpandResponseFiles` exposed in 
> > > > `llvm/include/llvm/Support/CommandLine.h` could you make use of it in 
> > > > here instead of re-implementing it again?
> > > > 
> > > > I see that it has a different signature, but we can do the conversion 
> > > > back and forth in here, going from `std::string` to `char*` is cheap 
> > > > anyways, coming back is expensive though, and we can limit that to iff 
> > > > we have seen an argument starting with an `@`. So this would be 
> > > > something like:
> > > > 
> > > > ```
> > > > llvm::SmallVector Argvs;
> > > > Argvs.reserve(Cmd.CommandLine.size());
> > > > bool SeenRSPFile = false;
> > > > for(auto &Argv : Cmd.CommandLine) {
> > > >   Argvs.push_back(Argv.c_str());
> > > >   SeenRSPFile |= Argv.front() == '@';
> > > > }
> > > > if(!SeenRSPFile)
> > > >   continue;
> > > > 
> > > > // call ExpandResponseFiles with Argvs, convert back to 
> > > > vector and assign to Cmd.CommandLine
> > > > ```
> > > I think it's not easy to reuse `ExpandResponseFiles` without changing 
> > > code because it uses llvm::sys::fs::current_path to resolve relative 
> > > paths.
> > > 
> > > In fact, most of the code here is copied from `CommandLine`
> > But we can reuse `static bool ExpandResponseFile(StringRef FName, 
> > StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl > *> &NewArgv, bool MarkEOLs, bool RelativeNames)` if we expose it in 
> > `CommandLine.h`
> `static bool ExpandResponseFile(StringRef FName, StringSaver &Saver, 
> TokenizerCallback Tokenizer, SmallVectorImpl &NewArgv, bool 
> MarkEOLs, bool RelativeNames)` also seems to use 
> `llvm::sys::fs::current_path` to resolve relative paths.
> I think it's not easy to reuse ExpandResponseFiles without changing code 
> because it uses llvm::sys::fs::current_path to resolve relative paths.

Ah, I missed this, thanks for pointing it out.

> In fact, most of the code here is copied from CommandLine

I believe in such a scenario, the correct course of action would be to update 
`ExpandResponseFiles` in `CommandLine.h` to accept a `FileSystem &FS`, instead 
of duplicating the logic.
Namely changing the signature to:

```
bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
 llvm::vfs::FileSystem &FS, SmallVectorImpl &Argv,
 bool MarkEOLs = false, bool RelativeNames = false);
```

Then you can pass `llvm::vfs::getRealFileSystem()` to these function in 
existing call sites.
And create a FS with working directory set to `Cmd.Directory` via 
`FileSystem::setCurrentWorkingDirectory` in this specific call site you want to 
introduce.

Also to update the implementation of `ExpandResponseFiles` you would need to 
make use of `FileSystem::getCurrentWorkingDirectory()` instead of 
`llvm::sys::fs::current_path` and `FileSystem::getBufferForFile()` instead of 
`llvm::MemoryBuffer::getFile` the rest shouldn't need any changes hopefully, 
except plumbing VFS to some helpers.

Please send the signature change and call site updates in a separate patch 
though.


After that patch you can change signature for 
`std::unique_ptr 
expandResponseFiles(std::unique_ptr Base)` to accept a 
`IntrusiveRefCntPtr VFS`, which will be `getRealFileSystem` in case 
of JSONCompilationDatabase. But this will enable you to pass a 
`InMemoryFileSystem` in the unittest below.


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

https://reviews.llvm.org/D70222



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


[PATCH] D68862: [ARM] Allocatable Global Register Variables for ARM

2019-11-26 Thread Carey Williams via Phabricator via cfe-commits
carwil added a comment.

Hi @efriedma, thanks your comments. You're right, that was hasty of me. 
Apologies for that, it won't happen again.

RE: R6 
Case in point: you're right. We're definitely not handling this correctly. I'll 
revert the patch, or ask @anwel too. Once we have a fix, we'll raise another 
review.


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

https://reviews.llvm.org/D68862



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

2019-11-26 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D70605#1759614 , @rjmccall wrote:

> Is there a similar problem with reference parameters?


It doesn't seem so, patching the test as follows gives reasonable output.

  @@ -73,8 +73,10 @@ void pr43145_3(int n) {
   // Implicit conversion of derived to base.
   
   void functionWithBaseArg(class B2 *b) {}
  +void functionWithBaseArgRef(class B2 &b) {}
   
   void pr43145_4() {
 Derived d;
 functionWithBaseArg(&d);
  +  functionWithBaseArgRef(d);
   }


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

https://reviews.llvm.org/D70605



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


[clang-tools-extra] aa0e92e - [clang-tidy] Use range-for for check registration. NFC

2019-11-26 Thread Alexander Kornienko via cfe-commits

Author: Alexander Kornienko
Date: 2019-11-26T16:34:23+01:00
New Revision: aa0e92e1f7069834852c08fdd32a92258e30555c

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

LOG: [clang-tidy] Use range-for for check registration. NFC

Actually, just testing GitHub commit rights.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 91e8ebee1368..40aaf402ec0e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -314,10 +314,8 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
 IntrusiveRefCntPtr OverlayFS)
 : Context(Context), OverlayFS(OverlayFS),
   CheckFactories(new ClangTidyCheckFactories) {
-  for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
- E = ClangTidyModuleRegistry::end();
-   I != E; ++I) {
-std::unique_ptr Module(I->instantiate());
+  for (ClangTidyModuleRegistry::entry E : ClangTidyModuleRegistry::entries()) {
+std::unique_ptr Module = E.instantiate();
 Module->addCheckFactories(*CheckFactories);
   }
 }



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


[clang] a913e87 - [OPENMP]Fix PR44133: crash on lambda reductions in templates.

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

Author: Alexey Bataev
Date: 2019-11-26T10:55:54-05:00
New Revision: a913e872d6e7044ae77e55c45ab3ea5304eb7262

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

LOG: [OPENMP]Fix PR44133: crash on lambda reductions in templates.

Need to perform the instantiation of the combiner/initializer even if
the resulting type is not dependent, if the construct is defined in
templates in some cases.

Added: 
clang/test/OpenMP/declare_reduction_codegen_in_templates.cpp

Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 63777d5272b7..a2fd8a92dd61 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3067,6 +3067,17 @@ Decl 
*TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
   } else {
 SubstReductionType = D->getType();
   }
+  Expr *Combiner = D->getCombiner();
+  Expr *Init = D->getInitializer();
+  const bool CombinerRequiresInstantiation =
+  Combiner &&
+  (Combiner->isValueDependent() || Combiner->isInstantiationDependent() ||
+   Combiner->isTypeDependent() ||
+   Combiner->containsUnexpandedParameterPack());
+  const bool InitRequiresInstantiation =
+  Init &&
+  (Init->isValueDependent() || Init->isInstantiationDependent() ||
+   Init->isTypeDependent() || Init->containsUnexpandedParameterPack());
   if (SubstReductionType.isNull())
 return nullptr;
   bool IsCorrect = !SubstReductionType.isNull();
@@ -3084,11 +3095,12 @@ Decl 
*TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
   PrevDeclInScope);
   auto *NewDRD = cast(DRD.get().getSingleDecl());
   SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewDRD);
-  if (!RequiresInstantiation) {
-if (Expr *Combiner = D->getCombiner()) {
+  if (!RequiresInstantiation && !CombinerRequiresInstantiation &&
+  !InitRequiresInstantiation) {
+if (Combiner) {
   NewDRD->setCombinerData(D->getCombinerIn(), D->getCombinerOut());
   NewDRD->setCombiner(Combiner);
-  if (Expr *Init = D->getInitializer()) {
+  if (Init) {
 NewDRD->setInitializerData(D->getInitOrig(), D->getInitPriv());
 NewDRD->setInitializer(Init, D->getInitializerKind());
   }
@@ -3100,22 +3112,32 @@ Decl 
*TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(
   Expr *SubstCombiner = nullptr;
   Expr *SubstInitializer = nullptr;
   // Combiners instantiation sequence.
-  if (D->getCombiner()) {
-SemaRef.ActOnOpenMPDeclareReductionCombinerStart(
-/*S=*/nullptr, NewDRD);
-SemaRef.CurrentInstantiationScope->InstantiatedLocal(
-cast(D->getCombinerIn())->getDecl(),
-cast(NewDRD->getCombinerIn())->getDecl());
-SemaRef.CurrentInstantiationScope->InstantiatedLocal(
-cast(D->getCombinerOut())->getDecl(),
-cast(NewDRD->getCombinerOut())->getDecl());
-auto *ThisContext = dyn_cast_or_null(Owner);
-Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
- ThisContext);
-SubstCombiner = SemaRef.SubstExpr(D->getCombiner(), TemplateArgs).get();
-SemaRef.ActOnOpenMPDeclareReductionCombinerEnd(NewDRD, SubstCombiner);
-// Initializers instantiation sequence.
-if (D->getInitializer()) {
+  if (Combiner) {
+if (!CombinerRequiresInstantiation) {
+  NewDRD->setCombinerData(D->getCombinerIn(), D->getCombinerOut());
+  NewDRD->setCombiner(Combiner);
+} else {
+  SemaRef.ActOnOpenMPDeclareReductionCombinerStart(
+  /*S=*/nullptr, NewDRD);
+  SemaRef.CurrentInstantiationScope->InstantiatedLocal(
+  cast(D->getCombinerIn())->getDecl(),
+  cast(NewDRD->getCombinerIn())->getDecl());
+  SemaRef.CurrentInstantiationScope->InstantiatedLocal(
+  cast(D->getCombinerOut())->getDecl(),
+  cast(NewDRD->getCombinerOut())->getDecl());
+  auto *ThisContext = dyn_cast_or_null(Owner);
+  Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, Qualifiers(),
+   ThisContext);
+  SubstCombiner = SemaRef.SubstExpr(Combiner, TemplateArgs).get();
+  SemaRef.ActOnOpenMPDeclareReductionCombinerEnd(NewDRD, SubstCombiner);
+}
+  }
+  // Initializers instantiation sequence.
+  if (Init) {
+if (!InitRequiresInstantiation) {
+  NewDRD->setInitializerData(D->getInitOrig(), D->getInitPriv());
+  NewDRD->setInitializer(Init, D->getInitializerKind());
+} else {
   VarDecl *OmpPrivParm =
   SemaRef.ActOnOpenMPDeclareReductionInitializerStart(
   /*S=*/nullptr, NewDRD);
@@ -3126,8 +3148,7 @@ Decl 
*TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(

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

2019-11-26 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D69825#1758949 , @aganea wrote:

> Thanks for the feedback Russell!
>
> Can you possibly try again with `/MT`? (ie. `-DLLVM_USE_CRT_RELEASE=MT`)


I tried adding this to my stage 1 builds and it didn't make any significant 
difference (times in seconds):

No patch (573.879, 568.519, 567.709)
With Patch (578.253, 558.515, 562.368)

In case it makes a difference, this is from a VS2017 command prompt with Visual 
Studio 15.9.17.

> In the `abba_test.ps1` script, `ninja check-all` is only used for preparing 
> clang.exe with the patch. The A/B loop //does not// use `check-all`.

Ah, yes. Sorry, my mistake.

> I also found out that on some of our multi-socket servers, Ninja defaulted to 
> only the # threads from the first socket. If you had a 2x 18-core system, 
> Ninja would default to 38 threads (18 x 2 + 2) instead of 74 threads (2 x 18 
> x 2 + 2). This behavior seems to be random,  depending on the system. This 
> has been fixed by Ninja PR 1674 
> , I've tested all our systems 
> with this patch and they now all default to the proper # of threads.

I'm not testing on a multi-socket system so don't believe I need that patch.

> I'm doing a new round of tests, I'll get back with updated figures.

Thanks.

I ran the new version of abba_test.ps1 (just building LLVM) with small 
modifications to comment out the "Validate Ninja" step and change "check-all" 
to "all" to save time as I'm concentrating on build build speed. This means 
that I'm applying it to the same git revision as you. For 
clang_bypass_cc1.patch I used the patch I downloaded before (before spinning 
off D70568 ). Running for one hour on a six 
core machine (winver 1803, 14 ninja jobs, CFG enabled, recently rebooted) I get:

  Total iterations:  2
  
   | Min   |Mean   |   Median  | 
Max   |
 A |  00:15:13.0773389 |  00:15:13.7219710 |  00:15:13.7219710 |  
00:15:14.3666030 |
 B |  00:15:08.6134425 |  00:15:09.0363284 |  00:15:09.0363284 |  
00:15:09.4592142 |
  Diff | -00:00:04.4638964 | -00:00:04.6856426 | -00:00:04.6856426 | 
-00:00:04.9073888 |

So in this case it saved 0.5% of time. Using the previous maths, with 2378 
clang-cl jobs, this implies process creation time of 29ms. This was fairly soon 
after a reboot. Maybe I'm just lucky and none of the process creation problems 
are affecting me on this system (at this moment).


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

https://reviews.llvm.org/D69825



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


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

2019-11-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

I have some other concerns about the code itself, but after pondering this a 
little bit, I'd like to instead bring up some rather more general concerns 
about the overall approach used here -- with some suggestions. (As these 
comments are not really comments on the _code_, but on the overall strategy, 
they also apply to the gnu binutils patch for this same feature.)

Of course, echoing chandler, it would be nice to see some performance numbers, 
otherwise it's not clear how useful any of this is.

Segment-prefix padding
--

The ability to pad instructions instead of adding a multibyte-NOP in order to 
create alignment seems like a generally-useful feature, which should be usable 
in other situations where we align within a function -- assuming that there is 
indeed a measurable performance benefit vs NOP instructions. E.g. we should do 
this for basic-block alignment, as well! As such, it feels like this feature 
ought to be split out, and implemented separately from the new branch-alignment 
functionality -- in a way which is usable for any kind of alignment request.

The way I'd imagine it working is to introduce a new pair of asm directives, to 
enable and disable segment-prefix padding in a certain range of instructions 
(let's say ".enable_instr_prefix_pad", ".disable_instr_prefix_pad". Within such 
an enabled range, the assembler would prefix instructions as required in order 
to handle later nominally-nop-emitting code alignment directives (such as the 
usual '.p2align 4, 0x90') .

Branch alignment


The primary goal of this patch, restricting the placement of branch 
instructions, is a performance optimization. Similar to loop alignment, the 
desire is to increase speed, at the cost of code-size. However, the way this 
feature has been designed is a global assembler flag. I find that not ideal, 
because it cannot take into account hotness of a block/function, as for example 
loop alignment code does. Basic-block alignment of loops is explicitly opt-in 
on an block-by-block basis -- the compiler simply emits a p2align directive 
where it needs, and the assembler honors that. And so, 
MachineBlockPlacement::alignBlocks has a bunch of conditions under which it 
will avoid emitting a p2align. This seems like a good model -- the assembler 
does what it's told by the compiler (or assembly-writer). Making the 
branch-instruction-alignment work similarly seems like it would be good.

IMO it would be nicest if there could be a directive that requests to 
specially-align the next instruction. However, the fused-jcc case makes that 
quite tricky, so perhaps this ought to also be a mode which can be 
enabled/disabled on a region as well.

Enabling by default
---

Previously, I'd mentioned that it seemed likely we couldn't actually enable 
branch-alignment by default because it'll probably break people's inline-asm 
and standalone asm files. That would be solved by making everything 
controllable within the asm file. The compiler could then insert the directives 
for its own code, and disable it around inline assembly. And standalone asm 
files could remain unaffected, unless they opt in. With that, we could actually 
enable the alignment by default, for compiled output in certain cpu-tuning 
modes, if it's warranted.


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

https://reviews.llvm.org/D70157



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


[PATCH] D70203: [AST] Attach comment in `/** doc */ typedef struct A {} B` to B as well as A.

2019-11-26 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Hi @sammccall . 
Just a heads up. Looks like this might have caused: 
https://bugs.llvm.org/show_bug.cgi?id=44143 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70203



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


[clang] 87c3f4a - [OPENMP]Simplify printing of declare variant attribute, NFC.

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

Author: Alexey Bataev
Date: 2019-11-26T11:35:12-05:00
New Revision: 87c3f4a5e0bb53ca0d9799ca627e0897b10a82b3

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

LOG: [OPENMP]Simplify printing of declare variant attribute, NFC.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 5d9e5dd59596..21cf53f0a815 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3335,20 +3335,40 @@ def OMPDeclareVariant : InheritableAttr {
   }
   // TODO: add printing of real context selectors.
   OS << " match(";
+  int Used[OMP_CTX_SET_unknown] = {0};
   for (unsigned I = 0, E = ctxSelectorSets_size(); I < E; ++I) {
 auto CtxSet = static_cast(
 *std::next(ctxSelectorSets_begin(), I));
-auto Ctx = static_cast(
-*std::next(ctxSelectors_begin(), I));
-assert(CtxSet != OMP_CTX_SET_unknown && Ctx != OMP_CTX_unknown &&
-   "Unknown context selector.");
+if (Used[CtxSet])
+  continue;
+if (I > 0)
+  OS << ",";
 switch (CtxSet) {
 case OMP_CTX_SET_implementation:
   OS << "implementation={";
+  break;
+case OMP_CTX_SET_device:
+  OS << "device={";
+  break;
+case OMP_CTX_SET_unknown:
+  llvm_unreachable("Unknown context selector set.");
+}
+Used[CtxSet] = 1;
+for (unsigned K = I, EK = ctxSelectors_size(); K < EK; ++K) {
+  auto CtxSetK = static_cast(
+  *std::next(ctxSelectorSets_begin(), K));
+  if (CtxSet != CtxSetK)
+continue;
+  if (K != I)
+OS << ",";
+  auto Ctx = static_cast(
+  *std::next(ctxSelectors_begin(), K));
   switch (Ctx) {
   case OMP_CTX_vendor:
+assert(CtxSet == OMP_CTX_SET_implementation &&
+   "Expected implementation context selector set.");
 OS << "vendor(";
-printScore(OS, Policy, I);
+printScore(OS, Policy, K);
 if (implVendors_size() > 0) {
   OS << *implVendors(). begin();
   for (StringRef VendorName : llvm::drop_begin(implVendors(), 1))
@@ -3357,16 +3377,8 @@ def OMPDeclareVariant : InheritableAttr {
 OS << ")";
 break;
   case OMP_CTX_kind:
-llvm_unreachable("Unexpected context selector in implementation 
set.");
-  case OMP_CTX_unknown:
-llvm_unreachable("Unknown context selector.");
-  }
-  OS << "}";
-  break;
-case OMP_CTX_SET_device:
-  OS << "device={";
-  switch (Ctx) {
-  case OMP_CTX_kind:
+assert(CtxSet == OMP_CTX_SET_device &&
+   "Expected device context selector set.");
 OS << "kind(";
 if (deviceKinds_size() > 0) {
   OS << *deviceKinds().begin();
@@ -3375,18 +3387,11 @@ def OMPDeclareVariant : InheritableAttr {
 }
 OS << ")";
 break;
-  case OMP_CTX_vendor:
-llvm_unreachable("Unexpected context selector in device set.");
   case OMP_CTX_unknown:
 llvm_unreachable("Unknown context selector.");
   }
-  OS << "}";
-  break;
-case OMP_CTX_SET_unknown:
-  llvm_unreachable("Unknown context selector set.");
 }
-if (I != E - 1)
-  OS << ",";
+OS << "}";
   }
   OS << ")";
 }



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


[PATCH] D46027: [clang-tidy] Fix PR35824

2019-11-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 231078.
xazax.hun added a comment.
Herald added subscribers: Charusso, gamesh411.

- Use matcher.


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

https://reviews.llvm.org/D46027

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp


Index: 
clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17
+
+void fail()
+{
+  int x = 0;
+  if(x > 5); (void)x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended 
semicolon [bugprone-suspicious-semicolon]
+  // CHECK-FIXES: if(x > 5) (void)x;
+}
+
+template 
+int foo(int a) {
+if constexpr(X > 0) {
+return a;
+}
+return a + 1;
+}
+
+int main(void) {
+return foo<0>(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -20,7 +20,8 @@
 void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   stmt(anyOf(ifStmt(hasThen(nullStmt().bind("semi")),
-unless(hasElse(stmt(,
+unless(hasElse(stmt())),
+unless(isConstexpr())),
  forStmt(hasBody(nullStmt().bind("semi"))),
  cxxForRangeStmt(hasBody(nullStmt().bind("semi"))),
  whileStmt(hasBody(nullStmt().bind("semi")


Index: clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17
+
+void fail()
+{
+  int x = 0;
+  if(x > 5); (void)x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
+  // CHECK-FIXES: if(x > 5) (void)x;
+}
+
+template 
+int foo(int a) {
+if constexpr(X > 0) {
+return a;
+}
+return a + 1;
+}
+
+int main(void) {
+return foo<0>(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -20,7 +20,8 @@
 void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   stmt(anyOf(ifStmt(hasThen(nullStmt().bind("semi")),
-unless(hasElse(stmt(,
+unless(hasElse(stmt())),
+unless(isConstexpr())),
  forStmt(hasBody(nullStmt().bind("semi"))),
  cxxForRangeStmt(hasBody(nullStmt().bind("semi"))),
  whileStmt(hasBody(nullStmt().bind("semi")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70424: clang/AMDGPU: Fix default for frame-pointer attribute

2019-11-26 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added a comment.

In D70424#1759379 , @t-tye wrote:

> @scott.linder can answer about the -g question, but I would expect that the 
> CFI is capable of describing the address of the CFA regardless of whether 
> there is a frame pointer by simply knowing the constant offset from the stack 
> pointer.
>
> For AMDGPU it seems to me what we really have is an FP and we optimize away 
> the SP since the stack grows low address to high address, and S32 points to 
> the base of the frame, and not the top of the stack.


Right, with CFI we will be able to describe every case we can generate code 
for, regardless of whether we optimize out the FP.


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

https://reviews.llvm.org/D70424



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


[clang] 49a2b2a - [OPENMP]Remove tab in message, NFC.

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

Author: Alexey Bataev
Date: 2019-11-26T11:37:36-05:00
New Revision: 49a2b2a3d2c869cb10407c480fff2f832e080018

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

LOG: [OPENMP]Remove tab in message, NFC.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c19862addec9..746320fa526b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9292,7 +9292,7 @@ def ext_omp_loop_not_canonical_init : ExtWarn<
   "('var = init' or 'T var = init')">, InGroup;
 def err_omp_loop_not_canonical_cond : Error<
   "condition of OpenMP for loop must be a relational comparison "
-   "('<', '<=', '>', %select{or '>='|'>=', or '!='}0) of loop variable 
%1">;
+  "('<', '<=', '>', %select{or '>='|'>=', or '!='}0) of loop variable %1">;
 def err_omp_loop_not_canonical_incr : Error<
   "increment clause of OpenMP for loop must perform simple addition "
   "or subtraction on loop variable %0">;



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


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

2019-11-26 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D69825#1760279 , @russell.gallop 
wrote:

> So in this case it saved 0.5% of time. Using the previous maths, with 2378 
> clang-cl jobs, this implies process creation time of 29ms. This was fairly 
> soon after a reboot. Maybe I'm just lucky and none of the process creation 
> problems are affecting me on this system (at this moment).


It looks like the git apply didn't work, but the script continued so this was a 
duff experiment, please ignore. I'll try to fix this and run it again.


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

https://reviews.llvm.org/D69825



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


[PATCH] D69878: Consoldiate internal denormal flushing controls

2019-11-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1775
-if (getLangOpts().OpenCL)
-  FuncAttrs.addAttribute("denorms-are-zero",
- llvm::toStringRef(CodeGenOpts.FlushDenorm));

arsenm wrote:
> Anastasia wrote:
> > so where would `denorms-are-zero` be emitted now (in case some out of tree 
> > implementations rely on this)?
> Rely on in what sense? Do you have a concrete use of this?
Since it has been emitted before in the module potentially some LLVM 
implementations could be using that attribute?


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

https://reviews.llvm.org/D69878



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


[PATCH] D70723: [clangd] Store index::SymbolKind in HoverInfo

2019-11-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

LSP's SymbolKind has some shortcomings when it comes to C++ types,
index::SymbolKind has more detailed info like Destructor, Parameter, MACRO etc.

We are planning to make use of that information in our new Hover response, and
it would be nice to display the Symbol type in full detail, rather than some
approximation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70723

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -32,7 +32,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -49,7 +49,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "ns1::ns2::";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Documentation = "Best foo ever.";
  HI.Definition = "void foo()";
  HI.ReturnType = "void";
@@ -68,7 +68,7 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -86,7 +86,7 @@
  HI.NamespaceScope = "ns1::ns2::";
  HI.LocalScope = "Foo::foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -102,7 +102,7 @@
  HI.NamespaceScope = "ns1::(anonymous)::";
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Field;
+ HI.Kind = index::SymbolKind::Field;
  HI.Definition = "int bar";
  HI.Type = "int";
}},
@@ -114,7 +114,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "Foo foo = Foo(5)";
  HI.Type = "Foo";
}},
@@ -126,7 +126,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "vector";
- HI.Kind = SymbolKind::Class;
+ HI.Kind = index::SymbolKind::Class;
  HI.Definition = "template  class vector {}";
  HI.TemplateParameters = {
  {std::string("typename"), std::string("T"), llvm::None},
@@ -145,7 +145,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "Foo";
- HI.Kind = SymbolKind::Class;
+ HI.Kind = index::SymbolKind::Class;
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
@@ -175,7 +175,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Definition =
  R"cpp(template  class C, typename = char, int = 0,
   bool Q = false, class... Ts>
@@ -204,7 +204,7 @@
[](HoverInfo &HI) {
  HI.NamespaceScope = "";
  HI.Name = "foo";
- HI.Kind = SymbolKind::Function;
+ HI.Kind = index::SymbolKind::Function;
  HI.Definition = "Foo foo(int, bool T = false)";
  HI.ReturnType = "Foo";
  HI.Type = "Foo (int, bool)";
@@ -225,7 +225,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "c";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Variable;
  HI.Definition = "auto *c = &b";
  HI.Type = "class (lambda) **";
  HI.ReturnType = "bool";
@@ -246,7 +246,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Parameter;
  HI.Definition = "decltype(lamb) &bar";
  HI.Type = "decltype(lamb) &";
  HI.ReturnType = "bool";
@@ -267,7 +267,7 @@
  HI.NamespaceScope = "";
  HI.LocalScope = "foo::";
  HI.Name = "bar";
- HI.Kind = SymbolKind::Variable;
+ HI.Kind = index::SymbolKind::Parameter;
  HI.Definition = "decltype(lamb) bar";
 

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

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

In D69825#1760373 , @russell.gallop 
wrote:

> It looks like the git apply didn't work, but the script continued so this was 
> a duff experiment, please ignore. I'll try to fix this and run it again.


Thanks Russell! Can you try running the script overnight? It'll give a better 
result and we'll see the error bar.

In D69825#1760279 , @russell.gallop 
wrote:

> Maybe I'm just lucky and none of the process creation problems are affecting 
> me on this system (at this moment).


I'm running tests on 6 differents Windows systems (both desktops and servers), 
with different OS revisions, and they all behave differently. With this patch, 
some see better improvements than others. I'll post the results once I have a 
better picture.


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

https://reviews.llvm.org/D69825



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


[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

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

- Handle cases where the number of args/params mismatch.


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

https://reviews.llvm.org/D70470

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/test/Analysis/fuchsia_handle.cpp

Index: clang/test/Analysis/fuchsia_handle.cpp
===
--- /dev/null
+++ clang/test/Analysis/fuchsia_handle.cpp
@@ -0,0 +1,139 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -verify %s
+
+typedef __typeof__(sizeof(int)) size_t;
+typedef int zx_status_t;
+typedef __typeof__(sizeof(int)) zx_handle_t;
+typedef unsigned int uint32_t;
+#define NULL ((void *)0)
+
+#if defined(__clang__)
+#define ZX_HANDLE_ACQUIRE  __attribute__((acquire_handle))
+#define ZX_HANDLE_RELEASE  __attribute__((release_handle))
+#define ZX_HANDLE_USE  __attribute__((use_handle))
+#else
+#define ZX_HANDLE_ACQUIRE
+#define ZX_HANDLE_RELEASE
+#define ZX_HANDLE_USE
+#endif
+
+zx_status_t zx_channel_create(
+uint32_t options,
+ZX_HANDLE_ACQUIRE zx_handle_t* out0,
+zx_handle_t* out1 ZX_HANDLE_ACQUIRE);
+
+zx_status_t zx_handle_close(
+zx_handle_t handle ZX_HANDLE_RELEASE);
+
+void escape1(zx_handle_t *in);
+void escape2(zx_handle_t in);
+
+void use1(const zx_handle_t *in ZX_HANDLE_USE);
+void use2(zx_handle_t in ZX_HANDLE_USE);
+
+void moreArgs(zx_handle_t, int, ...);
+void lessArgs(zx_handle_t, int a = 5);
+
+// To test if argument indexes are OK for operator calls.
+struct MyType {
+  ZX_HANDLE_ACQUIRE
+  zx_handle_t operator+(zx_handle_t replace ZX_HANDLE_RELEASE);
+};
+
+void checkNoCrash01() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  moreArgs(sa, 1, 2, 3, 4, 5);
+  lessArgs(sa);
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+}
+
+void checkNoLeak01() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+}
+
+void checkNoLeak02() {
+  zx_handle_t ay[2];
+  zx_channel_create(0, &ay[0], &ay[1]);
+  zx_handle_close(ay[0]);
+  zx_handle_close(ay[1]);
+}
+
+void checkNoLeak03() {
+  zx_handle_t ay[2];
+  zx_channel_create(0, &ay[0], &ay[1]);
+  for (int i = 0; i < 2; i++)
+zx_handle_close(ay[i]);
+}
+
+zx_handle_t checkNoLeak04() {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  zx_handle_close(sa);
+  return sb; // no warning
+}
+
+zx_handle_t checkNoLeak05(zx_handle_t *out1) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  *out1 = sa;
+  return sb; // no warning
+}
+
+void checkNoLeak06() {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, &sa, &sb))
+return;
+  zx_handle_close(sa);
+  zx_handle_close(sb);
+} 
+
+void checkNoLeak07(int tag) {
+  zx_handle_t sa, sb;
+  if (zx_channel_create(0, &sa, &sb) < 0)
+return;
+  escape1(&sa);
+  escape2(sb);
+}
+
+void checkLeak01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  use1(&sa);
+  if (tag)
+zx_handle_close(sa);
+  use2(sb); // expected-warning {{Potential leak of handle}}
+  zx_handle_close(sb);
+}
+
+void checkDoubleRelease01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  if (tag)
+zx_handle_close(sa);
+  zx_handle_close(sa); // expected-warning {{Releasing a previously released handle}}
+  zx_handle_close(sb);
+}
+
+void checkUseAfterFree01(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  if (tag) {
+zx_handle_close(sa);
+use1(&sa); // expected-warning {{Using a previously released handle}}
+  }
+  zx_handle_close(sb);
+  use2(sb); // expected-warning {{Using a previously released handle}}
+}
+
+void checkMemberOperatorIndices() {
+  zx_handle_t sa, sb, sc;
+  zx_channel_create(0, &sa, &sb);
+  zx_handle_close(sb);
+  MyType t;
+  sc = t + sa;
+  zx_handle_close(sc);
+}
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- /dev/null
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -0,0 +1,462 @@
+//=== FuchsiaHandleChecker.cpp - Find handle leaks/double closes -*- C++ -*--=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This checker checks if the handle of Fuchsia is properly used according to
+// following rules.
+//   - If a handle is acquired, it should be released before execution
+//ends.
+//   - If a handle is released, it should 

[PATCH] D70726: [OpenMP50] Add parallel master construct

2019-11-26 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, jfb, arphaman, guansong, jholewinski.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70726

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/nesting_of_regions.cpp
  clang/test/OpenMP/parallel_master_ast_print.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_copyin_messages.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_master_firstprivate_messages.cpp
  clang/test/OpenMP/parallel_master_if_messages.cpp
  clang/test/OpenMP/parallel_master_message.cpp
  clang/test/OpenMP/parallel_master_num_threads_messages.cpp
  clang/test/OpenMP/parallel_master_private_messages.cpp
  clang/test/OpenMP/parallel_master_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_master_reduction_messages.cpp
  clang/test/OpenMP/parallel_master_shared_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -610,6 +610,9 @@
   case Stmt::OMPParallelForSimdDirectiveClass:
 K = CXCursor_OMPParallelForSimdDirective;
 break;
+  case Stmt::OMPParallelMasterDirectiveClass:
+K = CXCursor_OMPParallelMasterDirective;
+break;
   case Stmt::OMPParallelSectionsDirectiveClass:
 K = CXCursor_OMPParallelSectionsDirective;
 break;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2030,6 +2030,7 @@
   void VisitOMPCriticalDirective(const OMPCriticalDirective *D);
   void VisitOMPParallelForDirective(const OMPParallelForDirective *D);
   void VisitOMPParallelForSimdDirective(const OMPParallelForSimdDirective *D);
+  void VisitOMPParallelMasterDirective(const OMPParallelMasterDirective *D);
   void VisitOMPParallelSectionsDirective(const OMPParallelSectionsDirective *D);
   void VisitOMPTaskDirective(const OMPTaskDirective *D);
   void VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *D);
@@ -2811,6 +2812,11 @@
   VisitOMPLoopDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPParallelMasterDirective(
+const OMPParallelMasterDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPParallelSectionsDirective(
 const OMPParallelSectionsDirective *D) {
   VisitOMPExecutableDirective(D);
@@ -5453,6 +5459,8 @@
 return cxstring::createRef("OMPParallelForDirective");
   case CXCursor_OMPParallelForSimdDirective:
 return cxstring::createRef("OMPParallelForSimdDirective");
+  case CXCursor_OMPParallelMasterDirective:
+return cxstring::createRef("OMPParallelMasterDirective");
   case CXCursor_OMPParallelSectionsDirective:
 return cxstring::createRef("OMPParallelSectionsDirective");
   case CXCursor_OMPTaskDirective:
Index: clang/test/OpenMP/parallel_master_shared_messages.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_master_shared_messages.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wuninitialized
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wuninitialized
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+extern S1 a;
+class S2 {
+  mutable int a;
+
+public:
+  S2() : a(0) {}
+  S2(S2 &s2) : a(s2.a) {}
+};
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+
+public:
+  S3() : a(0) {}
+  S3(S3 &s3) : a(s3.a) {}
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 &s4);
+
+public:
+  S4(int v) : a(v) {}
+};
+class S5 {
+  int a;
+  S5() : a(0) {}
+  S5(const S5 &s5) : a(s5.a) {}
+
+public:
+  S5(int v) : a(v) {}
+};
+
+S3 h;
+#pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
+
+namespace A {
+doub

[PATCH] D70723: [clangd] Store index::SymbolKind in HoverInfo

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

Build result: pass - 60291 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70723



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


[PATCH] D55484: ComputeLineNumbers: delete SSE2 vectorization

2019-11-26 Thread Shi Yan via Phabricator via cfe-commits
shi-yan added a comment.
Herald added a project: LLVM.

I'm hitting a crash by this code,

getting:

  exception thrown: RuntimeError: unreachable,RuntimeError: unreachable
  at ComputeLineNumbers(clang::DiagnosticsEngine&, 
clang::SrcMgr::ContentCache*, llvm::BumpPtrAllocatorImpl&, clang::SourceManager const&, bool&) (wasm-function[21781]:719)
  at clang::SourceManager::getLineNumber(clang::FileID, unsigned int, 
bool*) const (wasm-function[21780]:187)
  at clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) 
const (wasm-function[21779]:733)
  at clang::Preprocessor::HandlePragmaSystemHeader(clang::Token&) 
(wasm-function[21284]:297)
  at (anonymous 
namespace)::PragmaSystemHeaderHandler::HandlePragma(clang::Preprocessor&, 
clang::PragmaIntroducer, clang::Token&) (wasm-function[21317]:5)
  at clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, 
clang::PragmaIntroducer, clang::Token&) (wasm-function[21278]:565)
  at clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, 
clang::PragmaIntroducer, clang::Token&) (wasm-function[21278]:565)
  at clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) 
(wasm-function[21279]:142)
  at clang::Preprocessor::HandleDirective(clang::Token&) 
(wasm-function[21157]:1721)
  at clang::Lexer::LexTokenInternal(clang::Token&, bool) 
(wasm-function[20897]:14349)

The reason seems to be that the code appears to expect the Buf is zero ended, 
but it doesn't seem to be the case. The last character of the Buf was actually 
\n


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55484



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


[PATCH] D70725: [analyzer] Add path notes to FuchsiaHandleCheck

2019-11-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: NoQ, haowei.
xazax.hun added a project: clang.
Herald added subscribers: Charusso, gamesh411, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware.
xazax.hun added a reviewer: Szelethus.
xazax.hun added a parent revision: D70470: [analyzer] Add FuchsiaHandleCheck to 
catch handle leaks, use after frees and double frees.

I also added a missing const to a BugReporter API.

There are some TODOs for potential future updates if we want richer notes 
during reporting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70725

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/test/Analysis/fuchsia_handle.cpp

Index: clang/test/Analysis/fuchsia_handle.cpp
===
--- clang/test/Analysis/fuchsia_handle.cpp
+++ clang/test/Analysis/fuchsia_handle.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,fuchsia.HandleChecker -analyzer-output=text \
+// RUN: -verify %s
 
 typedef __typeof__(sizeof(int)) size_t;
 typedef int zx_status_t;
@@ -102,31 +103,73 @@
 void checkLeak01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated here}}
   use1(&sa);
-  if (tag)
+  if (tag) // expected-note {{Assuming 'tag' is 0}}
 zx_handle_close(sa);
+  // expected-note@-2 {{Taking false branch}}
   use2(sb); // expected-warning {{Potential leak of handle}}
+  // expected-note@-1 {{Potential leak of handle}}
   zx_handle_close(sb);
 }
 
+void checkReportLeakOnOnePath(int tag) {
+  zx_handle_t sa, sb;
+  zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated here}}
+  zx_handle_close(sb);
+  switch(tag) { // expected-note {{Control jumps to the 'default' case at line}} 
+case 0:
+  use2(sa);
+  return;
+case 1:
+  use2(sa);
+  return;
+case 2:
+  use2(sa);
+  return;
+case 3:
+  use2(sa);
+  return;
+case 4:
+  use2(sa);
+  return;
+default:
+  use2(sa);
+  return; // expected-warning {{Potential leak of handle}}
+  // expected-note@-1 {{Potential leak of handle}}
+  }
+}
+
 void checkDoubleRelease01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, &sa, &sb);
-  if (tag)
-zx_handle_close(sa);
+  // expected-note@-1 {{Handle allocated here}}
+  if (tag) // expected-note {{Assuming 'tag' is not equal to 0}}
+zx_handle_close(sa); // expected-note {{Handle released here}}
+  // expected-note@-2 {{Taking true branch}}
   zx_handle_close(sa); // expected-warning {{Releasing a previously released handle}}
+  // expected-note@-1 {{Releasing a previously released handle}}
   zx_handle_close(sb);
 }
 
 void checkUseAfterFree01(int tag) {
   zx_handle_t sa, sb;
   zx_channel_create(0, &sa, &sb);
+  // expected-note@-1 {{Handle allocated here}}
+  // expected-note@-2 {{Handle allocated here}}
+  // expected-note@+2 {{Taking true branch}}
+  // expected-note@+1 {{Taking false branch}}
   if (tag) {
-zx_handle_close(sa);
+// expected-note@-1 {{Assuming 'tag' is not equal to 0}}
+zx_handle_close(sa); // expected-note {{Handle released here}}
 use1(&sa); // expected-warning {{Using a previously released handle}}
+// expected-note@-1 {{Using a previously released handle}}
   }
-  zx_handle_close(sb);
+  // expected-note@-6 {{Assuming 'tag' is 0}}
+  zx_handle_close(sb); // expected-note {{Handle released here}}
   use2(sb); // expected-warning {{Using a previously released handle}}
+  // expected-note@-1 {{Using a previously released handle}}
 }
 
 void checkMemberOperatorIndices() {
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -163,6 +163,28 @@
   LLVM_DUMP_METHOD void dump() const { dump(llvm::errs()); }
 };
 
+class HandleBugVisitor : public BugReporterVisitor {
+private:
+  SymbolRef HandleSym;
+
+  static void *getTag() {
+static int Tag = 0;
+return &Tag;
+  }
+
+public:
+  HandleBugVisitor(SymbolRef HandleSym) : HandleSym(HandleSym) {}
+
+  void Profile(llvm::FoldingSetNodeID &ID) const override {
+ID.AddPointer(HandleSym);
+ID.AddPointer(getTag());
+  }
+
+  PathDiagnosticPieceRef VisitNode(const ExplodedNode *N,
+   BugReporterContext &BRC,
+   PathSensitiveBugReport &BR) override;
+};
+
 class FuchsiaHandleChecker
 : public Checker {
@@ -204,6 +226,71 @@
 
 REGISTER_MAP_WITH_PROGRAMSTATE(HStateMap, SymbolRef, HandleState)
 
+PathDiagnosticPieceRef HandleBugVisitor::VisitNode(const

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-11-26 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 231092.
serge-sans-paille added a comment.

Handle all @Meinersbur comment, rebuild on github with extra flags pending.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt
  clang/tools/driver/cc1_main.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/docs/WritingAnLLVMPass.rst
  llvm/examples/Bye/Bye.cpp
  llvm/examples/Bye/CMakeLists.txt
  llvm/examples/CMakeLists.txt
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/test/Feature/load_extension.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/opt-O0-pipeline.ll
  llvm/test/Other/opt-O2-pipeline.ll
  llvm/test/Other/opt-O3-pipeline.ll
  llvm/test/Other/opt-Os-pipeline.ll
  llvm/test/lit.cfg.py
  llvm/test/lit.site.cfg.py.in
  llvm/tools/CMakeLists.txt
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/bugpoint/bugpoint.cpp
  llvm/tools/opt/CMakeLists.txt
  llvm/tools/opt/NewPMDriver.cpp
  llvm/tools/opt/opt.cpp
  llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
  polly/include/polly/RegisterPasses.h
  polly/lib/CMakeLists.txt
  polly/lib/Plugin/Polly.cpp
  polly/lib/Polly.cpp
  polly/lib/Support/RegisterPasses.cpp
  polly/test/Unit/lit.site.cfg.in
  polly/test/lit.site.cfg.in
  polly/test/update_check.py

Index: polly/test/update_check.py
===
--- polly/test/update_check.py
+++ polly/test/update_check.py
@@ -15,7 +15,7 @@
 polly_lib_dir = '''@POLLY_LIB_DIR@'''
 shlibext = '''@LLVM_SHLIBEXT@'''
 llvm_tools_dir = '''@LLVM_TOOLS_DIR@'''
-link_polly_into_tools = not '''@LINK_POLLY_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','link_polly_into_tools-notfound'}
+llvm_polly_link_into_tools = not '''@LLVM_POLLY_LINK_INTO_TOOLS@'''.lower() in {'','0','n','no','off','false','notfound','llvm_polly_link_into_tools-notfound'}
 
 runre = re.compile(r'\s*\;\s*RUN\s*\:(?P.*)')
 filecheckre = re.compile(r'\s*(?P.*)\|\s*(?PFileCheck\s[^|]*)')
@@ -298,7 +298,7 @@
 toolarg = toolarg.replace('%s', filename)
 toolarg = toolarg.replace('%S', os.path.dirname(filename))
 if toolarg == '%loadPolly':
-if not link_polly_into_tools:
+if not llvm_polly_link_into_tools:
 newtool += ['-load',os.path.join(polly_lib_dir,'LLVMPolly' + shlibext)]
 newtool.append('-polly-process-unprofitable')
 newtool.append('-polly-remarks-minimal')
Index: polly/test/lit.site.cfg.in
===
--- polly/test/lit.site.cfg.in
+++ polly/test/lit.site.cfg.in
@@ -8,7 +8,7 @@
 config.polly_lib_dir = "@POLLY_LIB_DIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.targets_to_build = "@TARGETS_TO_BUILD@"
 config.extra_paths = "@POLLY_TEST_EXTRA_PATHS@".split(";")
 
@@ -36,14 +36,14 @@
 # directories.
 config.excludes = ['Inputs']
 
-if config.link_polly_into_tools == '' or \
-   config.link_polly_into_tools.lower() == '0' or \
-   config.link_polly_into_tools.lower() == 'n' or \
-   config.link_polly_into_tools.lower() == 'no' or \
-   config.link_polly_into_tools.lower() == 'off' or \
-   config.link_polly_into_tools.lower() == 'false' or \
-   config.link_polly_into_tools.lower() == 'notfound' or \
-   config.link_polly_into_tools.lower() == 'link_polly_into_tools-notfound':
+if config.llvm_polly_link_into_tools == '' or \
+   config.llvm_polly_link_into_tools.lower() == '0' or \
+   config.llvm_polly_link_into_tools.lower() == 'n' or \
+   config.llvm_polly_link_into_tools.lower() == 'no' or \
+   config.llvm_polly_link_into_tools.lower() == 'off' or \
+   config.llvm_polly_link_into_tools.lower() == 'false' or \
+   config.llvm_polly_link_into_tools.lower() == 'notfound' or \
+   config.llvm_polly_link_into_tools.lower() == 'llvm_polly_link_into_tools-notfound':
 config.substitutions.append(('%loadPolly', '-load '
  + config.polly_lib_dir + '/LLVMPolly@LLVM_SHLIBEXT@'
  + ' -load-pass-plugin '
Index: polly/test/Unit/lit.site.cfg.in
===
--- polly/test/Unit/lit.site.cfg.in
+++ polly/test/Unit/lit.site.cfg.in
@@ -13,7 +13,7 @@
 config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.enable_gpgpu_codegen = "@GPU_CODEGEN@"
-config.link_polly_into_tools = "@LINK_POLLY_INTO_TOOLS@"
+config.llvm_polly_link_into_tools = "@LLVM_POLLY_LINK_INTO_TOOLS@"
 config.has_unittests = @POLLY_GTEST_AVAIL@
 
 # Support s

[PATCH] D70727: [clangd] Keep go-to-definition working at the end of an identifier (fixes #194)

2019-11-26 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70727

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,6 +450,17 @@
   +^+x;
 }
   )cpp",
+
+  R"cpp(// End of identifier (definition)
+void [[func]]^() {}
+  )cpp",
+
+  R"cpp(// End of identifier (reference)
+void [[func]]() {}
+void test() {
+  func^();
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -129,11 +129,8 @@
   return Merged.CanonicalDeclaration;
 }
 
-std::vector getDeclAtPosition(ParsedAST &AST, SourceLocation Pos,
-DeclRelationSet Relations) {
-  FileID FID;
-  unsigned Offset;
-  std::tie(FID, Offset) = AST.getSourceManager().getDecomposedSpellingLoc(Pos);
+std::vector getDeclAtOffset(ParsedAST &AST, unsigned Offset,
+  DeclRelationSet Relations) {
   SelectionTree Selection(AST.getASTContext(), AST.getTokens(), Offset);
   std::vector Result;
   if (const SelectionTree::Node *N = Selection.commonAncestor()) {
@@ -143,6 +140,22 @@
   return Result;
 }
 
+std::vector getDeclAtPosition(ParsedAST &AST, SourceLocation Pos,
+DeclRelationSet Relations) {
+  FileID FID;
+  unsigned Offset;
+  std::tie(FID, Offset) = AST.getSourceManager().getDecomposedSpellingLoc(Pos);
+  std::vector Result = getDeclAtOffset(AST, Offset, Relations);
+  // If no declaration was found at this offset, try the previous offset.
+  // This compensates for the fact that SelectionTree interprets an offset
+  // as applying to the character after rather than the character before,
+  // allowing go-to-definition to work at the end of an identifier.
+  if (Result.empty() && Offset > 0) {
+Result = getDeclAtOffset(AST, Offset - 1, Relations);
+  }
+  return Result;
+}
+
 llvm::Optional makeLocation(ASTContext &AST, SourceLocation TokLoc,
   llvm::StringRef TUPath) {
   const SourceManager &SourceMgr = AST.getSourceManager();


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -450,6 +450,17 @@
   +^+x;
 }
   )cpp",
+
+  R"cpp(// End of identifier (definition)
+void [[func]]^() {}
+  )cpp",
+
+  R"cpp(// End of identifier (reference)
+void [[func]]() {}
+void test() {
+  func^();
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -129,11 +129,8 @@
   return Merged.CanonicalDeclaration;
 }
 
-std::vector getDeclAtPosition(ParsedAST &AST, SourceLocation Pos,
-DeclRelationSet Relations) {
-  FileID FID;
-  unsigned Offset;
-  std::tie(FID, Offset) = AST.getSourceManager().getDecomposedSpellingLoc(Pos);
+std::vector getDeclAtOffset(ParsedAST &AST, unsigned Offset,
+  DeclRelationSet Relations) {
   SelectionTree Selection(AST.getASTContext(), AST.getTokens(), Offset);
   std::vector Result;
   if (const SelectionTree::Node *N = Selection.commonAncestor()) {
@@ -143,6 +140,22 @@
   return Result;
 }
 
+std::vector getDeclAtPosition(ParsedAST &AST, SourceLocation Pos,
+DeclRelationSet Relations) {
+  FileID FID;
+  unsigned Offset;
+  std::tie(FID, Offset) = AST.getSourceManager().getDecomposedSpellingLoc(Pos);
+  std::vector Result = getDeclAtOffset(AST, Offset, Relations);
+  // If no declaration was found at this offset, try the previous offset.
+  // This compensates for the fact that SelectionTree interprets an offset
+  // as applying to the character after rather than the character before,
+  // allowing go-to-definition to work at the end of an identifier.
+  if (Result.empty() && Offset > 0) {
+Result = getDeclAtOffset(AST, Offset - 1, Relations);
+  }
+  return Result;
+}
+
 llvm::Optional makeLocation(ASTContext &A

[PATCH] D70726: [OpenMP50] Add parallel master construct

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

Missing check for prohibited nesting of the barrier and worksharing directvies 
in the master regions. Plus, definitely no tests for this.




Comment at: clang/include/clang/AST/StmtOpenMP.h:1857
+  /// true if current directive has inner cancel directive.
+  bool HasCancel;
+

Why do we need this if cancel in `parallel master` is not supported?



Comment at: clang/include/clang/Sema/Sema.h:9564
+  StmtResult ActOnOpenMPParallelMasterDirective(ArrayRef Clauses,
+  Stmt *AStmt,
+  SourceLocation StartLoc,

Not formatted



Comment at: clang/lib/AST/StmtOpenMP.cpp:335-349
-OMPSectionsDirective *OMPSectionsDirective::Create(
-const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
-ArrayRef Clauses, Stmt *AssociatedStmt, bool HasCancel) {
-  unsigned Size =
-  llvm::alignTo(sizeof(OMPSectionsDirective), alignof(OMPClause *));
-  void *Mem =
-  C.Allocate(Size + sizeof(OMPClause *) * Clauses.size() + sizeof(Stmt *));

Why moved to a different place?



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2872-2879
+void CodeGenFunction::EmitMaster(const OMPExecutableDirective &S) {
   auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
 Action.Enter(CGF);
 CGF.EmitStmt(S.getInnermostCapturedStmt()->getCapturedStmt());
   };
-  OMPLexicalScope Scope(*this, S, OMPD_unknown);
   CGM.getOpenMPRuntime().emitMasterRegion(*this, CodeGen, S.getBeginLoc());
 }

Make it static local, not a member function



Comment at: clang/lib/Sema/SemaOpenMP.cpp:10677
   break;
+case OMPD_parallel_master:
 case OMPD_parallel_master_taskloop:

`parallel master` is very similar to just `parallel` rather than with `parallel 
master taskloop` when it comes to the analysis of the clauses.



Comment at: clang/test/OpenMP/parallel_master_codegen.cpp:16-25
+// CHECK-LABEL: parallel_master
+void parallel_master() {
+#pragma omp parallel master
+  // CHECK-NOT: __kmpc_global_thread_num
+  // CHECK: call i32 @__kmpc_master({{.+}})
+  // CHECK: invoke void {{.*}}foo{{.*}}()
+  // CHECK-NOT: __kmpc_global_thread_num

Check that the region was outlined. Plus, codegen for some of the clauses are 
required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70726



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


[PATCH] D70728: [clang][IFS] Adding support for new clang interface stubs decl types.

2019-11-26 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added a reviewer: compnerd.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Adding support for NamespaceAliasDecl UnresolvedUsingTypenameDecl 
CXXDeductionGuideDecl ConstructorUsingShadowDecl


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70728

Files:
  clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
  clang/test/InterfaceStubs/constructor-using-shadow.cpp
  clang/test/InterfaceStubs/cxxdeduction-guide.cpp
  clang/test/InterfaceStubs/namespace-alias.cpp
  clang/test/InterfaceStubs/unresolved-using-typename.cpp


Index: clang/test/InterfaceStubs/unresolved-using-typename.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/unresolved-using-typename.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+
+// UnresolvedUsingTypenameDecl
+template class C1 { using ReprType = unsigned; };
+template class C2 : public C1 { using typename C1::Repr; };
Index: clang/test/InterfaceStubs/namespace-alias.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/namespace-alias.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+
+// NamespaceAliasDecl
+namespace NS { }
+namespace B = NS;
Index: clang/test/InterfaceStubs/cxxdeduction-guide.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/cxxdeduction-guide.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs -std=c++17 %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+
+// CXXDeductionGuideDecl
+template struct A { A(); A(T); };
+A() -> A;
Index: clang/test/InterfaceStubs/constructor-using-shadow.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/constructor-using-shadow.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+
+ // ConstructorUsingShadowDecl
+struct Base { Base(int); };
+struct Derived : public Base { using Base::Base; };
Index: clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
===
--- clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
+++ clang/lib/Frontend/InterfaceStubFunctionsConsumer.cpp
@@ -195,6 +195,10 @@
 case Decl::Kind::TemplateTemplateParm:
 case Decl::Kind::ClassTemplatePartialSpecialization:
 case Decl::Kind::IndirectField:
+case Decl::Kind::ConstructorUsingShadow:
+case Decl::Kind::CXXDeductionGuide:
+case Decl::Kind::NamespaceAlias:
+case Decl::Kind::UnresolvedUsingTypename:
   return true;
 case Decl::Kind::Var: {
   // Bail on any VarDecl that either has no named symbol.


Index: clang/test/InterfaceStubs/unresolved-using-typename.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/unresolved-using-typename.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+
+// UnresolvedUsingTypenameDecl
+template class C1 { using ReprType = unsigned; };
+template class C2 : public C1 { using typename C1::Repr; };
Index: clang/test/InterfaceStubs/namespace-alias.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/namespace-alias.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1
+// CHECK-NEXT: IfsVersion: 1.0
+// CHECK-NEXT: Triple:
+// CHECK-NEXT: ObjectFileFormat: ELF
+// CHECK-NEXT: Symbols:
+// CHECK-NEXT: ...
+
+// NamespaceAliasDecl
+namespace NS { }
+namespace B = NS;
Index: clang/test/InterfaceStubs/cxxdeduction-guide.cpp
===
--- /dev/null
+++ clang/test/InterfaceStubs/cxxdeduction-guide.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -o - -emit-interface-stubs -std=c++17 %s | FileCheck %s
+
+// CHECK:  --- !experimental-ifs-v1

[PATCH] D70727: [clangd] Keep go-to-definition working at the end of an identifier (fixes #194)

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

By the way, may I get permissions to assign issues to myself (and make other 
such metadata changes to issues) on github?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70727



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

2019-11-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Great.  Could you add that to the test, then, just to make sure we don't 
regress it?


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

https://reviews.llvm.org/D70605



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


[PATCH] D70729: Workaround for EvalInfo ctor for MSVC 2017

2019-11-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, hliao.

Current EvalInfo ctor causes EnableNewConstInterp to be true even though
it is supposed to be false on MSVC 2017. This is because a virtual function
getLangOpts() is called in member initializer lists, whereas on MSVC
member ctors are called before function virtual function pointers are
initialized.

https://docs.microsoft.com/en-us/cpp/cpp/constructors-cpp?view=vs-2019#order_of_construction

  

This patch fixes that.


https://reviews.llvm.org/D70729

Files:
  clang/lib/AST/ExprConstant.cpp


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -921,10 +921,10 @@
 EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
 : Ctx(const_cast(C)), EvalStatus(S), 
CurrentCall(nullptr),
   CallStackDepth(0), NextCallIndex(1),
-  StepsLeft(getLangOpts().ConstexprStepLimit),
-  ForceNewConstInterp(getLangOpts().ForceNewConstInterp),
+  StepsLeft(C.getLangOpts().ConstexprStepLimit),
+  ForceNewConstInterp(C.getLangOpts().ForceNewConstInterp),
   EnableNewConstInterp(ForceNewConstInterp ||
-   getLangOpts().EnableNewConstInterp),
+   C.getLangOpts().EnableNewConstInterp),
   BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
   EvaluatingDecl((const ValueDecl *)nullptr),
   EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),


Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -921,10 +921,10 @@
 EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
 : Ctx(const_cast(C)), EvalStatus(S), CurrentCall(nullptr),
   CallStackDepth(0), NextCallIndex(1),
-  StepsLeft(getLangOpts().ConstexprStepLimit),
-  ForceNewConstInterp(getLangOpts().ForceNewConstInterp),
+  StepsLeft(C.getLangOpts().ConstexprStepLimit),
+  ForceNewConstInterp(C.getLangOpts().ForceNewConstInterp),
   EnableNewConstInterp(ForceNewConstInterp ||
-   getLangOpts().EnableNewConstInterp),
+   C.getLangOpts().EnableNewConstInterp),
   BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
   EvaluatingDecl((const ValueDecl *)nullptr),
   EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

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



Comment at: clang/lib/Sema/SemaLambda.cpp:891
+if (getLangOpts().OpenCL)
+  EPI.TypeQuals.addAddressSpace(LangAS::opencl_generic);
+

Anastasia wrote:
> rjmccall wrote:
> > This should probably check that there isn't already an address space, right?
> EPI has just been constructed newly here or do you mean if addr space has 
> been set in the constructor? That is currently not the case but might happen 
> in the future perhaps.
Oh, sorry, I see now that this is the place where we synthesize a signature.  
This is fine, nevermind.

Actually, could you go ahead and extract out some sort of 
`getDefaultCXXMethodAddrSpace()` function on Sema that you can use consistently 
here and in the other places?


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

https://reviews.llvm.org/D69938



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


[PATCH] D70568: [Support] Possibly use exception handler in the Crash Recovery Context in the same way as global exceptions

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

In D70568#1760185 , @hans wrote:

> Do I understand correctly that the main point is to get a stack trace when 
> CrashRecoveryContext::RunSafely() fails, instead of just returning an error?


Correct. Otherwise, when running with D69825 , 
the callstack was not displayed anymore when a crash occurred in clang-cl. This 
side-effect is that it also calls the cleanup, thus the change in 
`clang/test/Modules/signal.m` (the temp files are properly deleted in the case 
of a crash).

>> It enables CrashRecoveryContext exceptions by default (instead of disabled 
>> before) - however the exception handlers are lazily installed on the first 
>> creation of a CrashRecoveryContext.
> 
> Why does it now need to be enabled by default?

I used to call `CrashRecoveryContext::Enable()` in `CC1Command`, just before 
calling the CC1 callback. And to be consistent, call 
`CrashRecoveryContext::Disable()` after the CC1 callback.
But then, if we're running several compilations in parallel, it gets 
complicated, we can't just toggle it on/off all the time - it would need a 
refcount as the comment in `CrashRecoveryContext::Enable()` says.
I thought it'd be easier to just have it always enabled, as the signal handlers 
won't be installed before usage? Do you prefer that, or the refcounting?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70568



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


[PATCH] D70729: Workaround for EvalInfo ctor for MSVC 2017

2019-11-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 231101.
yaxunl added a comment.

add a test


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

https://reviews.llvm.org/D70729

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/Sema/eval-info.c


Index: clang/test/Sema/eval-info.c
===
--- /dev/null
+++ clang/test/Sema/eval-info.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-windows-msvc -verify
+
+// expected-no-diagnostics
+
+// Make sure the new constant interpolator is not enabled unintentionally
+// to cause assertion.
+typedef enum x {
+  a = 1,
+} x;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -921,10 +921,10 @@
 EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
 : Ctx(const_cast(C)), EvalStatus(S), 
CurrentCall(nullptr),
   CallStackDepth(0), NextCallIndex(1),
-  StepsLeft(getLangOpts().ConstexprStepLimit),
-  ForceNewConstInterp(getLangOpts().ForceNewConstInterp),
+  StepsLeft(C.getLangOpts().ConstexprStepLimit),
+  ForceNewConstInterp(C.getLangOpts().ForceNewConstInterp),
   EnableNewConstInterp(ForceNewConstInterp ||
-   getLangOpts().EnableNewConstInterp),
+   C.getLangOpts().EnableNewConstInterp),
   BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
   EvaluatingDecl((const ValueDecl *)nullptr),
   EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),


Index: clang/test/Sema/eval-info.c
===
--- /dev/null
+++ clang/test/Sema/eval-info.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-windows-msvc -verify
+
+// expected-no-diagnostics
+
+// Make sure the new constant interpolator is not enabled unintentionally
+// to cause assertion.
+typedef enum x {
+  a = 1,
+} x;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -921,10 +921,10 @@
 EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
 : Ctx(const_cast(C)), EvalStatus(S), CurrentCall(nullptr),
   CallStackDepth(0), NextCallIndex(1),
-  StepsLeft(getLangOpts().ConstexprStepLimit),
-  ForceNewConstInterp(getLangOpts().ForceNewConstInterp),
+  StepsLeft(C.getLangOpts().ConstexprStepLimit),
+  ForceNewConstInterp(C.getLangOpts().ForceNewConstInterp),
   EnableNewConstInterp(ForceNewConstInterp ||
-   getLangOpts().EnableNewConstInterp),
+   C.getLangOpts().EnableNewConstInterp),
   BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
   EvaluatingDecl((const ValueDecl *)nullptr),
   EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55484: ComputeLineNumbers: delete SSE2 vectorization

2019-11-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D55484#1760432 , @shi-yan wrote:

> I'm hitting a crash by this code,
>
> getting:
>
>   exception thrown: RuntimeError: unreachable,RuntimeError: unreachable
>   at ComputeLineNumbers(clang::DiagnosticsEngine&, 
> clang::SrcMgr::ContentCache*, 
> llvm::BumpPtrAllocatorImpl&, 
> clang::SourceManager const&, bool&) (wasm-function[21781]:719)
>   at clang::SourceManager::getLineNumber(clang::FileID, unsigned int, 
> bool*) const (wasm-function[21780]:187)
>   at clang::SourceManager::getPresumedLoc(clang::SourceLocation, bool) 
> const (wasm-function[21779]:733)
>   at clang::Preprocessor::HandlePragmaSystemHeader(clang::Token&) 
> (wasm-function[21284]:297)
>   at (anonymous 
> namespace)::PragmaSystemHeaderHandler::HandlePragma(clang::Preprocessor&, 
> clang::PragmaIntroducer, clang::Token&) (wasm-function[21317]:5)
>   at clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, 
> clang::PragmaIntroducer, clang::Token&) (wasm-function[21278]:565)
>   at clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, 
> clang::PragmaIntroducer, clang::Token&) (wasm-function[21278]:565)
>   at clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) 
> (wasm-function[21279]:142)
>   at clang::Preprocessor::HandleDirective(clang::Token&) 
> (wasm-function[21157]:1721)
>   at clang::Lexer::LexTokenInternal(clang::Token&, bool) 
> (wasm-function[20897]:14349)
>  
>
>
> The reason seems to be that the code appears to expect the Buf is zero ended, 
> but it doesn't seem to be the case. The last character of the Buf was 
> actually \n


ComputeLineNumbers assumes that the buffer has a NUL terminator 
(`RequiresNullTerminator` in lib/Support/MemoryBuffer.cpp). The function has 
the assumption both before and after the change (I don't think this patch 
should be blamed...). That said, a detailed reproducible instruction will be 
useful, though I think the mostly likely problem is that your code does not set 
`RequiresNullTerminator` when calling one of the MemoryBuffer creation routines.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55484



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


[PATCH] D70675: [AIX] Disable clang python binding tests

2019-11-26 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu 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/D70675/new/

https://reviews.llvm.org/D70675



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


[PATCH] D70729: Workaround for EvalInfo ctor for MSVC 2017

2019-11-26 Thread Michael Liao via Phabricator via cfe-commits
hliao accepted this revision.
hliao added a comment.
This revision is now accepted and ready to land.

LGTM, anyway calling a virtual function inside the constructor is not 
encouraged.


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

https://reviews.llvm.org/D70729



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


[PATCH] D70687: [WebAssembly] Add an llvm-lto path for compiler-rt.

2019-11-26 Thread Dan Gohman via Phabricator via cfe-commits
sunfish abandoned this revision.
sunfish added a comment.

I've done some more experimenting with this, and it turns out not to work very 
well, because calls to these functions get generated after LTO runs, so I'll 
abandon this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70687



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


[PATCH] D70675: [AIX] Disable clang python binding tests

2019-11-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

Agreed. LGTM as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70675



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


[PATCH] D70470: [analyzer] Add FuchsiaHandleCheck to catch handle leaks, use after frees and double frees

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

Ok, now I have some real world experience with the results of the check.
The false positive ratio for double free and use after free seems to be quite 
good but the handle leak part is almost unusable at this point. The main 
problem is somewhat anticipated, we are not doing a great job notifying the 
checkers about escaped non-pointer symbols. The question is, what should we do 
about this? Should the `PointerEscape` callback be renamed? Currently, the list 
of symbols will also contain non-pointer symbols, so in some cases that 
callback does solve the escaping issue for integers. But it is not consistent. 
So I see two ways forward:

1. Have a separate SymbolEscape callback.
2. Rename PointerEscape, and fix it to be triggered for all kinds of pointers.

I feel like the 2. is a better solution. Of course, that change might have a 
performance impact as well.

Any thoughts?


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

https://reviews.llvm.org/D70470



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


[PATCH] D70739: [OPENMP50]Add device/isa context selector support.

2019-11-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added a subscriber: guansong.
Herald added a project: clang.

Added basic support for device/isa context selector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70739

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/OpenMP/declare_variant_ast_print.c
  clang/test/OpenMP/declare_variant_ast_print.cpp
  clang/test/OpenMP/declare_variant_device_isa_codegen.cpp
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp

Index: clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 | FileCheck %s --implicit-check-not='ret i32 {{1|81|84}}'
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -fopenmp-version=50 | FileCheck %s --implicit-check-not='ret i32 {{1|81|84}}'
+// expected-no-diagnostics
+
+// CHECK-NOT: ret i32 {{1|81|84}}
+// CHECK-DAG: define {{.*}}i32 @_Z3barv()
+// CHECK-DAG: define {{.*}}i32 @_ZN16SpecSpecialFuncs6MethodEv(%struct.SpecSpecialFuncs* %{{.+}})
+// CHECK-DAG: define {{.*}}i32 @_ZN12SpecialFuncs6MethodEv(%struct.SpecialFuncs* %{{.+}})
+// CHECK-DAG: define linkonce_odr {{.*}}i32 @_ZN16SpecSpecialFuncs6methodEv(%struct.SpecSpecialFuncs* %{{.+}})
+// CHECK-DAG: define linkonce_odr {{.*}}i32 @_ZN12SpecialFuncs6methodEv(%struct.SpecialFuncs* %{{.+}})
+// CHECK-DAG: define {{.*}}i32 @_Z5prio_v()
+// CHECK-DAG: define internal i32 @_ZL6prio1_v()
+// CHECK-DAG: define {{.*}}i32 @_Z4callv()
+// CHECK-DAG: define internal i32 @_ZL9stat_usedv()
+// CHECK-DAG: define {{.*}}i32 @fn_linkage()
+// CHECK-DAG: define {{.*}}i32 @_Z11fn_linkage1v()
+
+// CHECK-DAG: ret i32 2
+// CHECK-DAG: ret i32 3
+// CHECK-DAG: ret i32 4
+// CHECK-DAG: ret i32 5
+// CHECK-DAG: ret i32 6
+// CHECK-DAG: ret i32 7
+// CHECK-DAG: ret i32 82
+// CHECK-DAG: ret i32 83
+// CHECK-DAG: ret i32 85
+// CHECK-DAG: ret i32 86
+// CHECK-DAG: ret i32 87
+
+// Outputs for function members
+// CHECK-DAG: ret i32 6
+// CHECK-DAG: ret i32 7
+// CHECK-NOT: ret i32 {{1|81|84}}
+
+#ifndef HEADER
+#define HEADER
+
+int foo() { return 2; }
+int bazzz();
+int test();
+static int stat_unused_();
+static int stat_used_();
+
+#pragma omp declare target
+
+#pragma omp declare variant(foo) match(device = {isa("nvptx64")})
+int bar() { return 1; }
+
+#pragma omp declare variant(bazzz) match(device = {isa("nvptx64")})
+int baz() { return 1; }
+
+#pragma omp declare variant(test) match(device = {isa("nvptx64")})
+int call() { return 1; }
+
+#pragma omp declare variant(stat_unused_) match(device = {isa("nvptx64")})
+static int stat_unused() { return 1; }
+
+#pragma omp declare variant(stat_used_) match(device = {isa("nvptx64")})
+static int stat_used() { return 1; }
+
+#pragma omp end declare target
+
+int main() {
+  int res;
+#pragma omp target map(from \
+   : res)
+  res = bar() + baz() + call();
+  return res;
+}
+
+int test() { return 3; }
+static int stat_unused_() { return 4; }
+static int stat_used_() { return 5; }
+
+#pragma omp declare target
+
+struct SpecialFuncs {
+  void vd() {}
+  SpecialFuncs();
+  ~SpecialFuncs();
+
+  int method_() { return 6; }
+#pragma omp declare variant(SpecialFuncs::method_) \
+match(device = {isa("nvptx64")})
+  int method() { return 1; }
+#pragma omp declare variant(SpecialFuncs::method_) \
+match(device = {isa("nvptx64")})
+  int Method();
+} s;
+
+int SpecialFuncs::Method() { return 1; }
+
+struct SpecSpecialFuncs {
+  void vd() {}
+  SpecSpecialFuncs();
+  ~SpecSpecialFuncs();
+
+  int method_();
+#pragma omp declare variant(SpecSpecialFuncs::method_) \
+match(device = {isa("nvptx64")})
+  int method() { return

[PATCH] D70740: [clangd] Find reference to template parameter in 'sizeof...' expression

2019-11-26 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70740

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -625,6 +625,13 @@
 $InactiveCode[[]]  #else
   int $Variable[[Active2]];
   #endif
+)cpp",
+  // Argument to 'sizeof...'
+  R"cpp(
+  template 
+  struct $Class[[TupleSize]] {
+static const int $StaticField[[size]] = 
sizeof...($TemplateParameter[[Elements]]);
+  };
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -491,6 +491,13 @@
   llvm::SmallVector(
   E->decls().begin(), E->decls().end())});
 }
+
+void VisitSizeOfPackExpr(const SizeOfPackExpr *E) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  E->getPackLoc(),
+  /*IsDecl=*/false,
+  {E->getPack()}});
+}
   };
 
   Visitor V;


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -625,6 +625,13 @@
 $InactiveCode[[]]  #else
   int $Variable[[Active2]];
   #endif
+)cpp",
+  // Argument to 'sizeof...'
+  R"cpp(
+  template 
+  struct $Class[[TupleSize]] {
+static const int $StaticField[[size]] = sizeof...($TemplateParameter[[Elements]]);
+  };
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -491,6 +491,13 @@
   llvm::SmallVector(
   E->decls().begin(), E->decls().end())});
 }
+
+void VisitSizeOfPackExpr(const SizeOfPackExpr *E) {
+  Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+  E->getPackLoc(),
+  /*IsDecl=*/false,
+  {E->getPack()}});
+}
   };
 
   Visitor V;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a38fc61 - [AIX] Disable clang python binding tests

2019-11-26 Thread David Tenty via cfe-commits

Author: David Tenty
Date: 2019-11-26T15:30:38-05:00
New Revision: a38fc61648797a10629ed160779b5df6b8d577e7

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

LOG: [AIX] Disable clang python binding tests

Summary:
The Python ctypes FFI interface is broken on AIX, it cannot properly pass
structures containing  arrays ( https://bugs.python.org/issue38628). So
disable the clang python binding tests on AIX till this is resolved.

Reviewers: stevewan, jasonliu, hubert.reinterpretcast, mgorny

Reviewed By: jasonliu, hubert.reinterpretcast

Subscribers: mgorny, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/bindings/python/tests/CMakeLists.txt

Removed: 




diff  --git a/clang/bindings/python/tests/CMakeLists.txt 
b/clang/bindings/python/tests/CMakeLists.txt
index 3f5ac957f81d..626256af9c1b 100644
--- a/clang/bindings/python/tests/CMakeLists.txt
+++ b/clang/bindings/python/tests/CMakeLists.txt
@@ -32,6 +32,11 @@ if(WIN32)
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
+# The Python FFI interface is broken on AIX: 
https://bugs.python.org/issue38628.
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:



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


[PATCH] D70740: [clangd] Find reference to template parameter in 'sizeof...' expression

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70740



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


[PATCH] D70675: [AIX] Disable clang python binding tests

2019-11-26 Thread David Tenty via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa38fc6164879: [AIX] Disable clang python binding tests 
(authored by daltenty).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70675

Files:
  clang/bindings/python/tests/CMakeLists.txt


Index: clang/bindings/python/tests/CMakeLists.txt
===
--- clang/bindings/python/tests/CMakeLists.txt
+++ clang/bindings/python/tests/CMakeLists.txt
@@ -32,6 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
+# The Python FFI interface is broken on AIX: 
https://bugs.python.org/issue38628.
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:


Index: clang/bindings/python/tests/CMakeLists.txt
===
--- clang/bindings/python/tests/CMakeLists.txt
+++ clang/bindings/python/tests/CMakeLists.txt
@@ -32,6 +32,11 @@
   set(RUN_PYTHON_TESTS FALSE)
 endif()
 
+# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+  set(RUN_PYTHON_TESTS FALSE)
+endif()
+
 # AArch64, Hexagon, and Sparc have known test failures that need to be
 # addressed.
 # SystemZ has broken Python/FFI interface:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70203: [AST] Attach comment in `/** doc */ typedef struct A {} B` to B as well as A.

2019-11-26 Thread Chris Hamilton via Phabricator via cfe-commits
chrish_ericsson_atx added a comment.

In D70203#1760299 , @bjope wrote:

> Hi @sammccall . 
>  Just a heads up. Looks like this might have caused: 
> https://bugs.llvm.org/show_bug.cgi?id=44143 .


Yes indeed.  I locally reverted commit a433e714 
 and it 
resolved my issue.  It's odd, though.  The unittest Sam added is nearly 
identical with the reproducer I posted.  Only obvious difference I see at first 
blush is that my reproducer uses the same identifier for the struct name and 
the typedef name, whereas Sam's unittest uses a unique identifier for each.  
Semantically, there is no difference, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70203



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Dan McGregor via Phabricator via cfe-commits
dankm added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2019-11-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1033-1035
+  bool IsCausedByImmediateInvocation() const {
+return ConstantExprBits.IsCausedByImmediateInvocation;
+  }

I'd remove the "CausedBy" here -- the `ConstantExpr` is our representation of 
the immediate invocation.

Also, please start this function name with a lowercase `i` for local 
consistency.



Comment at: clang/include/clang/Sema/Sema.h:1027
 
+  using IICandidate = llvm::PointerIntPair;
+

`II` doesn't mean anything to a reader here; please expand the abbreviation.



Comment at: clang/include/clang/Sema/Sema.h:5438-5439
 
+  /// Wrap the expression in a ConstantExpr if it is a potention immediate
+  /// invocation
+  ExprResult CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl);

potention -> potential
Missing period at end of sentence.



Comment at: clang/lib/AST/ExprConstant.cpp:2012-2013
 
+  if (auto *VD = LVal.getLValueBase().dyn_cast())
+if (auto *FD = dyn_cast(VD))
+  if (FD->isConsteval()) {

Please add braces to these `if` statements (their controlled statement is too 
long to omit the braces). As a general rule: if an inner construct needs 
braces, put braces on the outer constructs too.



Comment at: clang/lib/AST/ExprConstant.cpp:13618
+  if (InPlace) {
+LValue LVal;
+if (!::EvaluateInPlace(Result.Val, Info, LVal, this) ||

This isn't sufficient: the evaluation process can refer back to the object 
under construction (eg, via `this`), and we need an lvalue that actually names 
the result in order for this to work.

I think you'll need to do something like creating a suitable object (perhaps a 
`LifetimeExtendedTemporaryDecl`) in the caller to represent the result of the 
immediate invocation, and passing that into here.



Comment at: clang/lib/Sema/Sema.cpp:164
   isConstantEvaluatedOverride = false;
+  RebuildingImmediateInvocation = false;
 

Consider using a default member initializer instead.



Comment at: clang/lib/Sema/SemaDecl.cpp:8835-8836
+  // specifier.
+  if (ConstexprKind == CSK_consteval)
+if (CXXMethodDecl *MD = dyn_cast(NewFD))
+  if (MD->getOverloadedOperator() == OO_New ||

Please add braces here.



Comment at: clang/lib/Sema/SemaDecl.cpp:8836
+  if (ConstexprKind == CSK_consteval)
+if (CXXMethodDecl *MD = dyn_cast(NewFD))
+  if (MD->getOverloadedOperator() == OO_New ||

This rule also applies to non-member allocator functions. (Don't check for a 
`CXXMethodDecl` here.)



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:11188-11189
 
+  ConstexprSpecKind ConstexprKind = DetermineSpecialMemberConstexprKind(
+  Constexpr, ClassDecl->hasDefaultedConstevalDefaultCtor());
+

Tyker wrote:
> rsmith wrote:
> > I don't think this is necessary: implicit special members are never 
> > `consteval`. (We use `DeclareImplicitDefaultConstructor` when there is no 
> > user-declared default constructor, in which case there can't possibly be a 
> > defaulted consteval default constructor.) I don't think you need any of the 
> > `DetermineSpecialMemberConstexprKind` machinery, nor the tracking of 
> > `DefaultedSpecialMemberIsConsteval` in `CXXRecordDecl`.
> all the code you mention is to fixe an issue i saw while working on consteval.
> the AST of
> ```
> struct A {
> consteval A() = default;
> consteval A(int) { }
> };
> ```
> is
> ```
> TranslationUnitDecl
> `-CXXRecordDecl  line:1:8 struct A definition
>   |-DefinitionData pass_in_registers empty standard_layout trivially_copyable 
> trivial literal has_user_declared_ctor has_constexpr_non_copy_move_ctor 
> can_const_default_init
>   | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr
>   | |-CopyConstructor simple trivial has_const_param needs_implicit 
> implicit_has_const_param
>   | |-MoveConstructor exists simple trivial needs_implicit
>   | |-CopyAssignment trivial has_const_param needs_implicit 
> implicit_has_const_param
>   | |-MoveAssignment exists simple trivial needs_implicit
>   | `-Destructor simple irrelevant trivial needs_implicit
>   |-CXXRecordDecl  col:8 implicit referenced struct A
>   |-CXXConstructorDecl  col:15 constexpr A 'void ()' 
> default trivial noexcept-unevaluated 0x55585ae25160
>   `-CXXConstructorDecl  col:15 consteval A 'void (int)'
> |-ParmVarDecl  col:20 'int'
> `-CompoundStmt 
> ```
> [[ https://godbolt.org/z/oRx0Ss | godbolt ]]
> notice that `A::A()` is marked as constexpr instead of consteval.
> and `A::A(int)` is marked correctly.
> 
> this is because consteval defaulted special members are not marked as 
> consteval.
> those code changes are intended to fix that. with this patch both constructor 
> are marked as co

[PATCH] D70746: [clangd] Highlighting dependent types in more contexts

2019-11-26 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70746

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -630,7 +630,24 @@
   R"cpp(
   template 
   struct $Class[[TupleSize]] {
-static const int $StaticField[[size]] = 
sizeof...($TemplateParameter[[Elements]]);
+static const int $StaticField[[size]] =
+sizeof...($TemplateParameter[[Elements]]);
+  };
+)cpp",
+  // More dependent types
+  R"cpp(
+  template 
+  struct $Class[[Waldo]] {
+using $Typedef[[Location1]] = typename $TemplateParameter[[T]]
+::$DependentType[[Resolver]]::$DependentType[[Location]];
+using $Typedef[[Location2]] = typename $TemplateParameter[[T]]
+::template $DependentType[[Resolver]]<$TemplateParameter[[T]]>
+::$DependentType[[Location]];
+using $Typedef[[Location3]] = typename $TemplateParameter[[T]]
+::$DependentType[[Resolver]]
+::template $DependentType[[Location]]<$TemplateParameter[[T]]>;
+static const int $StaticField[[Value]] = $TemplateParameter[[T]]
+::$DependentType[[Resolver]]::$DependentName[[Value]];
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -250,16 +250,44 @@
 
   bool VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
 H.addToken(E->getNameInfo().getLoc(), HighlightingKind::DependentName);
+visitDependentTypesInQualifier(E->getQualifierLoc());
 return true;
   }
 
   bool VisitDependentNameTypeLoc(DependentNameTypeLoc L) {
 H.addToken(L.getNameLoc(), HighlightingKind::DependentType);
+visitDependentTypesInQualifier(L.getQualifierLoc());
+return true;
+  }
+
+  // This is similar to DependentNameTypeLoc, but used for
+  // template-ids where the template-name itself is dependent.
+  bool VisitDependentTemplateSpecializationTypeLoc(
+  DependentTemplateSpecializationTypeLoc L) {
+H.addToken(L.getTemplateNameLoc(), HighlightingKind::DependentType);
+visitDependentTypesInQualifier(L.getQualifierLoc());
 return true;
   }
 
 private:
   HighlightingsBuilder &H;
+
+  // findExplicitReferences will walk nested-name-specifiers and
+  // find anything that can be resolved to a Decl. However, non-leaf
+  // components of nested-name-specifiers which are dependent names
+  // (kind "Identifier") cannot be resolved to a decl and also do
+  // not have a Visit() method called on them directly, so we
+  // walk the nested-name-specifiers of relevant node types
+  // (e.g. DependentScopeDeclRefExpr) here to catch them.
+  void visitDependentTypesInQualifier(NestedNameSpecifierLoc Q) {
+NestedNameSpecifier *NNS = Q.getNestedNameSpecifier();
+if (!NNS)
+  return;
+if (NNS->getKind() == NestedNameSpecifier::Identifier) {
+  H.addToken(Q.getLocalBeginLoc(), HighlightingKind::DependentType);
+}
+visitDependentTypesInQualifier(Q.getPrefix());
+  }
 };
 
 // Encode binary data into base64.


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -630,7 +630,24 @@
   R"cpp(
   template 
   struct $Class[[TupleSize]] {
-static const int $StaticField[[size]] = sizeof...($TemplateParameter[[Elements]]);
+static const int $StaticField[[size]] =
+sizeof...($TemplateParameter[[Elements]]);
+  };
+)cpp",
+  // More dependent types
+  R"cpp(
+  template 
+  struct $Class[[Waldo]] {
+using $Typedef[[Location1]] = typename $TemplateParameter[[T]]
+::$DependentType[[Resolver]]::$DependentType[[Location]];
+using $Typedef[[Location2]] = typename $TemplateParameter[[T]]
+::template $DependentType[[Resolver]]<$TemplateParameter[[T]]>
+::$DependentType[[Location]];
+using $Typedef[[Location3]] = typename $TemplateParameter[[T]]
+::$DependentType[[Resolver]]
+::template $DependentType[[Location]]<$TemplateParameter[[T]]>;
+static const int $StaticFi

[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D49466#1760765 , @dankm wrote:

> Ping?


The tests need fixing... I can commit it. Now that we've migrated to the llvm 
monorepo, the git commit message can retain the author info properly...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[PATCH] D70747: [Fuchsia] Don't fail for unknown architectures

2019-11-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: leonardchan.
Herald added subscribers: cfe-commits, s.egerton, simoncook.
Herald added a project: clang.

When selecting the set of default sanitizers, don't fail for unknown
architectures. This may be the case e.g. with x86_64-unknown-fuchsia
-m32 target that's used to build the bootloader.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70747

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -351,10 +351,9 @@
   case llvm::Triple::x86_64:
 Res |= SanitizerKind::SafeStack;
 break;
-  case llvm::Triple::riscv64:
-break;
   default:
-llvm_unreachable("invalid architecture");
+// TODO: Enable SafeStack on RISC-V once tested.
+break;
   }
   return Res;
 }


Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -351,10 +351,9 @@
   case llvm::Triple::x86_64:
 Res |= SanitizerKind::SafeStack;
 break;
-  case llvm::Triple::riscv64:
-break;
   default:
-llvm_unreachable("invalid architecture");
+// TODO: Enable SafeStack on RISC-V once tested.
+break;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 231140.
MaskRay added a comment.

Add back remapDIPath that was unintentionally deleted by D69213 
, caught by a test.

Small adjustment of the code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/Driver/debug-prefix-map.S
  clang/test/Driver/debug-prefix-map.c
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test.h
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1230,7 +1230,9 @@
 TEST(Support, ReplacePathPrefix) {
   SmallString<64> Path1("/foo");
   SmallString<64> Path2("/old/foo");
+  SmallString<64> Path3("/oldnew/foo");
   SmallString<64> OldPrefix("/old");
+  SmallString<64> OldPrefixSep("/old/");
   SmallString<64> NewPrefix("/new");
   SmallString<64> NewPrefix2("/longernew");
   SmallString<64> EmptyPrefix("");
@@ -1250,6 +1252,33 @@
   Path = Path2;
   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
   EXPECT_EQ(Path, "/foo");
+  Path = Path2;
+  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
+  EXPECT_EQ(Path, "foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
+  EXPECT_EQ(Path, "/newnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path1;
+  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/foo");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new");
+  Path = OldPrefixSep;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
+  EXPECT_EQ(Path, "/old");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/new");
 }
 
 TEST_F(FileSystemTest, OpenFileForRead) {
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -496,27 +496,50 @@
   path.append(ext.begin(), ext.end());
 }
 
-void replace_path_prefix(SmallVectorImpl &Path,
+bool replace_path_prefix(SmallVectorImpl &Path,
  const StringRef &OldPrefix, const StringRef &NewPrefix,
- Style style) {
+ Style style, bool strict) {
   if (OldPrefix.empty() && NewPrefix.empty())
-return;
+return false;
 
   StringRef OrigPath(Path.begin(), Path.size());
-  if (!OrigPath.startswith(OldPrefix))
-return;
+  StringRef OldPrefixDir;
+
+  if (!strict && OldPrefix.size() > OrigPath.size())
+return false;
+
+  // Ensure OldPrefixDir does not have a trailing separator.
+  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
+OldPrefixDir = parent_path(OldPrefix, style);
+  else
+OldPrefixDir = OldPrefix;
+
+  if (!OrigPath.startswith(OldPrefixDir))
+return false;
+
+  if (OrigPath.size() > OldPrefixDir.size())
+if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
+  return false;
 
   // If prefixes have the same size we can simply copy the new one over.
-  if (OldPrefix.size() == NewPrefix.size()) {
+  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
 llvm::copy(NewPrefix, Path.begin());
-return;
+return true;
   }
 
-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
+  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
   SmallString<256> NewPath;
   path::append(NewPath, style, NewPrefix);
-  path::append(NewPath, style, RelPath);
+  if (!RelPath.empty()) {
+if (!is_separator(RelPath[0], style) || !strict)
+  path::append(NewPath, style, RelPath);
+else
+  path::append(NewPath, style, relative_path(RelPath, style));
+  }
+
   Path.swap(NewPath);
+
+  return true;
 }
 
 void native(const Twine &path, SmallVectorImpl &result, Style style) {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h

[PATCH] D70693: [scan-build-py] Set of small fixes

2019-11-26 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/tools/scan-build-py/libscanbuild/clang.py:47
 cmd.insert(1, '-###')
+cmd.append('-fno-color-diagnostics')
 

Alternative would be to set `TERM=dumb` environment variable which disables 
color support as well, but this also works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70693



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


[PATCH] D70748: [clang test] Do not assume default target

2019-11-26 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre created this revision.
thopre added a reviewer: thegameg.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang test Driver/darwin-opt-record.c assumes the default target is
x86_64 by its uses of the -arch x86_64 and -arch x86_64h and thus fail
on systems where it is not the case. Adding a target
x86_64-apple-darwin10 reveals another problem: the driver refuses 2
-arch for an assembly output so this commit also changes the output to
be an object file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70748

Files:
  clang/test/Driver/darwin-opt-record.c


Index: clang/test/Driver/darwin-opt-record.c
===
--- clang/test/Driver/darwin-opt-record.c
+++ clang/test/Driver/darwin-opt-record.c
@@ -1,6 +1,6 @@
 // REQUIRES: system-darwin
 
-// RUN: %clang -### -S -o FOO -fsave-optimization-record -arch x86_64 -arch 
x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
+// RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MULTIPLE-ARCH
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"


Index: clang/test/Driver/darwin-opt-record.c
===
--- clang/test/Driver/darwin-opt-record.c
+++ clang/test/Driver/darwin-opt-record.c
@@ -1,6 +1,6 @@
 // REQUIRES: system-darwin
 
-// RUN: %clang -### -S -o FOO -fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
+// RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO -fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6c92cdf - Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via cfe-commits

Author: Dan McGregor
Date: 2019-11-26T15:17:49-08:00
New Revision: 6c92cdff72251a7d13ab3958b04fba72dfcaebb1

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

LOG: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

GCC 8 implements -fmacro-prefix-map. Like -fdebug-prefix-map, it replaces a 
string prefix for the __FILE__ macro.
-ffile-prefix-map is the union of -fdebug-prefix-map and -fmacro-prefix-map

Reviewed By: rnk, Lekensteyn, maskray

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

Added: 
clang/test/Preprocessor/file_test.c
clang/test/Preprocessor/file_test.h

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/include/clang/Lex/PreprocessorOptions.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/FreeBSD.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/CodeGen/debug-prefix-map.c
clang/test/Driver/debug-prefix-map.S
clang/test/Driver/debug-prefix-map.c
llvm/include/llvm/Support/Path.h
llvm/lib/Support/Path.cpp
llvm/unittests/Support/Path.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 0e309909030e..b4904bb9d2dc 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -143,8 +143,8 @@ def err_drv_missing_arg_mtp : Error<
   "missing argument to '%0'">;
 def err_drv_invalid_libcxx_deployment : Error<
   "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
-def err_drv_invalid_argument_to_fdebug_prefix_map : Error<
-  "invalid argument '%0' to -fdebug-prefix-map">;
+def err_drv_invalid_argument_to_option : Error<
+  "invalid argument '%0' to -%1">;
 def err_drv_malformed_sanitizer_blacklist : Error<
   "malformed sanitizer blacklist: '%0'">;
 def err_drv_duplicate_config : Error<

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1f0fc97b14e2..2d501c09c762 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1964,6 +1964,12 @@ def fdebug_prefix_map_EQ
   : Joined<["-"], "fdebug-prefix-map=">, Group,
 Flags<[CC1Option,CC1AsOption]>,
 HelpText<"remap file source paths in debug info">;
+def ffile_prefix_map_EQ
+  : Joined<["-"], "ffile-prefix-map=">, Group, Flags<[CC1Option]>,
+HelpText<"remap file source paths in debug info and predefined 
preprocessor macros">;
+def fmacro_prefix_map_EQ
+  : Joined<["-"], "fmacro-prefix-map=">, Group, 
Flags<[CC1Option]>,
+HelpText<"remap file source paths in predefined preprocessor macros">;
 def fforce_dwarf_frame : Flag<["-"], "fforce-dwarf-frame">, Group, 
Flags<[CC1Option]>,
 HelpText<"Always emit a debug frame section">;
 def fno_force_dwarf_frame : Flag<["-"], "fno-force-dwarf-frame">, 
Group, Flags<[CC1Option]>,

diff  --git a/clang/include/clang/Lex/PreprocessorOptions.h 
b/clang/include/clang/Lex/PreprocessorOptions.h
index 344afa894172..abffbd03c3b4 100644
--- a/clang/include/clang/Lex/PreprocessorOptions.h
+++ b/clang/include/clang/Lex/PreprocessorOptions.h
@@ -13,6 +13,8 @@
 #include "clang/Lex/PreprocessorExcludedConditionalDirectiveSkipMapping.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -173,6 +175,9 @@ class PreprocessorOptions {
   /// build it again.
   std::shared_ptr FailedModules;
 
+  /// A prefix map for __FILE__ and __BASE_FILE__.
+  std::map> MacroPrefixMap;
+
   /// Contains the currently active skipped range mappings for skipping 
excluded
   /// conditional directives.
   ///

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index db5893a7b51f..282a8e44d386 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -476,10 +476,12 @@ CGDebugInfo::createFile(StringRef FileName,
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
+  SmallString<256> p = Path;
   for (const auto &Entry : DebugPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (llvm::sys::path::replace_path_prefix(
+p, Entry.first, Entry.second, llvm::sys::path::Style::native, 
true))
+  break;
+  return p.str();
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {

diff  --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 13e9c7a38fcc..8e7

[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 231142.
MaskRay added a comment.

Minimize diff in Options.td
Properly rebase remapDIPath on top of D69213 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/Driver/debug-prefix-map.S
  clang/test/Driver/debug-prefix-map.c
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test.h
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1230,7 +1230,9 @@
 TEST(Support, ReplacePathPrefix) {
   SmallString<64> Path1("/foo");
   SmallString<64> Path2("/old/foo");
+  SmallString<64> Path3("/oldnew/foo");
   SmallString<64> OldPrefix("/old");
+  SmallString<64> OldPrefixSep("/old/");
   SmallString<64> NewPrefix("/new");
   SmallString<64> NewPrefix2("/longernew");
   SmallString<64> EmptyPrefix("");
@@ -1250,6 +1252,33 @@
   Path = Path2;
   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
   EXPECT_EQ(Path, "/foo");
+  Path = Path2;
+  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
+  EXPECT_EQ(Path, "foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
+  EXPECT_EQ(Path, "/newnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path1;
+  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/foo");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new");
+  Path = OldPrefixSep;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
+  EXPECT_EQ(Path, "/old");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/new");
 }
 
 TEST_F(FileSystemTest, OpenFileForRead) {
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -496,27 +496,50 @@
   path.append(ext.begin(), ext.end());
 }
 
-void replace_path_prefix(SmallVectorImpl &Path,
+bool replace_path_prefix(SmallVectorImpl &Path,
  const StringRef &OldPrefix, const StringRef &NewPrefix,
- Style style) {
+ Style style, bool strict) {
   if (OldPrefix.empty() && NewPrefix.empty())
-return;
+return false;
 
   StringRef OrigPath(Path.begin(), Path.size());
-  if (!OrigPath.startswith(OldPrefix))
-return;
+  StringRef OldPrefixDir;
+
+  if (!strict && OldPrefix.size() > OrigPath.size())
+return false;
+
+  // Ensure OldPrefixDir does not have a trailing separator.
+  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
+OldPrefixDir = parent_path(OldPrefix, style);
+  else
+OldPrefixDir = OldPrefix;
+
+  if (!OrigPath.startswith(OldPrefixDir))
+return false;
+
+  if (OrigPath.size() > OldPrefixDir.size())
+if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
+  return false;
 
   // If prefixes have the same size we can simply copy the new one over.
-  if (OldPrefix.size() == NewPrefix.size()) {
+  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
 llvm::copy(NewPrefix, Path.begin());
-return;
+return true;
   }
 
-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
+  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
   SmallString<256> NewPath;
   path::append(NewPath, style, NewPrefix);
-  path::append(NewPath, style, RelPath);
+  if (!RelPath.empty()) {
+if (!is_separator(RelPath[0], style) || !strict)
+  path::append(NewPath, style, RelPath);
+else
+  path::append(NewPath, style, relative_path(RelPath, style));
+  }
+
   Path.swap(NewPath);
+
+  return true;
 }
 
 void native(const Twine &path, SmallVectorImpl &result, Style style) {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ 

[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c92cdff7225: Initial implementation of -fmacro-prefix-map 
and -ffile-prefix-map (authored by dankm, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/PreprocessorOptions.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/Driver/debug-prefix-map.S
  clang/test/Driver/debug-prefix-map.c
  clang/test/Preprocessor/file_test.c
  clang/test/Preprocessor/file_test.h
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1230,7 +1230,9 @@
 TEST(Support, ReplacePathPrefix) {
   SmallString<64> Path1("/foo");
   SmallString<64> Path2("/old/foo");
+  SmallString<64> Path3("/oldnew/foo");
   SmallString<64> OldPrefix("/old");
+  SmallString<64> OldPrefixSep("/old/");
   SmallString<64> NewPrefix("/new");
   SmallString<64> NewPrefix2("/longernew");
   SmallString<64> EmptyPrefix("");
@@ -1250,6 +1252,33 @@
   Path = Path2;
   path::replace_path_prefix(Path, OldPrefix, EmptyPrefix);
   EXPECT_EQ(Path, "/foo");
+  Path = Path2;
+  path::replace_path_prefix(Path, OldPrefix, EmptyPrefix, true);
+  EXPECT_EQ(Path, "foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, false);
+  EXPECT_EQ(Path, "/newnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path3;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/oldnew/foo");
+  Path = Path1;
+  path::replace_path_prefix(Path, EmptyPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/foo");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new");
+  Path = OldPrefixSep;
+  path::replace_path_prefix(Path, OldPrefix, NewPrefix);
+  EXPECT_EQ(Path, "/new/");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, false);
+  EXPECT_EQ(Path, "/old");
+  Path = OldPrefix;
+  path::replace_path_prefix(Path, OldPrefixSep, NewPrefix, true);
+  EXPECT_EQ(Path, "/new");
 }
 
 TEST_F(FileSystemTest, OpenFileForRead) {
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -496,27 +496,50 @@
   path.append(ext.begin(), ext.end());
 }
 
-void replace_path_prefix(SmallVectorImpl &Path,
+bool replace_path_prefix(SmallVectorImpl &Path,
  const StringRef &OldPrefix, const StringRef &NewPrefix,
- Style style) {
+ Style style, bool strict) {
   if (OldPrefix.empty() && NewPrefix.empty())
-return;
+return false;
 
   StringRef OrigPath(Path.begin(), Path.size());
-  if (!OrigPath.startswith(OldPrefix))
-return;
+  StringRef OldPrefixDir;
+
+  if (!strict && OldPrefix.size() > OrigPath.size())
+return false;
+
+  // Ensure OldPrefixDir does not have a trailing separator.
+  if (!OldPrefix.empty() && is_separator(OldPrefix.back()))
+OldPrefixDir = parent_path(OldPrefix, style);
+  else
+OldPrefixDir = OldPrefix;
+
+  if (!OrigPath.startswith(OldPrefixDir))
+return false;
+
+  if (OrigPath.size() > OldPrefixDir.size())
+if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict)
+  return false;
 
   // If prefixes have the same size we can simply copy the new one over.
-  if (OldPrefix.size() == NewPrefix.size()) {
+  if (OldPrefixDir.size() == NewPrefix.size() && !strict) {
 llvm::copy(NewPrefix, Path.begin());
-return;
+return true;
   }
 
-  StringRef RelPath = OrigPath.substr(OldPrefix.size());
+  StringRef RelPath = OrigPath.substr(OldPrefixDir.size());
   SmallString<256> NewPath;
   path::append(NewPath, style, NewPrefix);
-  path::append(NewPath, style, RelPath);
+  if (!RelPath.empty()) {
+if (!is_separator(RelPath[0], style) || !strict)
+  path::append(NewPath, style, RelPath);
+else
+  path::append(NewPath, style, relative_path(RelPath, style));
+  }
+
   Path.swap(NewPath);
+
+  return true;
 }
 
 void native(const Twine &path, SmallVectorImpl &result, Style style) {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
++

[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Dan McGregor via Phabricator via cfe-commits
dankm added a comment.

In D49466#1760860 , @MaskRay wrote:

> Add back remapDIPath that was unintentionally deleted by D69213 
> , caught by a test.
>
> Small adjustment of the code


Right. Can't believe I missed that. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[clang] 3bb24bf - Fix tests on Windows after D49466

2019-11-26 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2019-11-26T16:15:39-08:00
New Revision: 3bb24bf25767ef5bbcef958b484e7a06d8689204

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

LOG: Fix tests on Windows after D49466

It is tricky to use replace_path_prefix correctly on Windows which uses
backslashes as native path separators. Switch back to the old approach
(startswith is not ideal) to appease build bots for now.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/CodeGen/debug-prefix-map.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 282a8e44d386..db5893a7b51f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -476,12 +476,10 @@ CGDebugInfo::createFile(StringRef FileName,
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
-  SmallString<256> p = Path;
   for (const auto &Entry : DebugPrefixMap)
-if (llvm::sys::path::replace_path_prefix(
-p, Entry.first, Entry.second, llvm::sys::path::Style::native, 
true))
-  break;
-  return p.str();
+if (Path.startswith(Entry.first))
+  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
+  return Path.str();
 }
 
 unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) {

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index 3b53d07cc4a9..cf8bb2fbab99 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1456,10 +1456,10 @@ static void remapMacroPath(
 const std::map>
 &MacroPrefixMap) {
   for (const auto &Entry : MacroPrefixMap)
-if (llvm::sys::path::replace_path_prefix(Path, Entry.first, Entry.second,
- llvm::sys::path::Style::native,
- true))
+if (Path.startswith(Entry.first)) {
+  Path = (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
   break;
+}
 }
 
 /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded

diff  --git a/clang/test/CodeGen/debug-prefix-map.c 
b/clang/test/CodeGen/debug-prefix-map.c
index abebc9a15106..5366e19447ae 100644
--- a/clang/test/CodeGen/debug-prefix-map.c
+++ b/clang/test/CodeGen/debug-prefix-map.c
@@ -19,21 +19,21 @@ void test_rewrite_includes() {
 }
 
 // CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}"
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}",
 // On POSIX systems "Dir" should actually be empty, but on Windows we
 // can't recognize "/UNLIKELY_PATH" as being an absolute path.
 // CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
-// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{[/\\]}}Inputs/stdio.h",
+// CHECK-NO-MAIN-FILE-NAME: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}Inputs/stdio.h",
 // CHECK-NO-MAIN-FILE-NAME-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NO-MAIN-FILE-NAME-NOT: !DIFile(filename:
 
-// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{[/\\]}}{{.*}}"
-// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{[/\\]}}{{.*}}Inputs/stdio.h",
+// CHECK-EVIL: !DIFile(filename: "/UNLIKELY_PATH=empty{{/|}}{{.*}}"
+// CHECK-EVIL: !DIFile(filename: 
"/UNLIKELY_PATH=empty{{/|}}{{.*}}Inputs/stdio.h",
 // CHECK-EVIL-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-EVIL-NOT: !DIFile(filename:
 
-// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}"
-// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{[/\\]}}{{.*}}Inputs/stdio.h",
+// CHECK: !DIFile(filename: "/UNLIKELY_PATH/empty{{/|}}{{.*}}"
+// CHECK: !DIFile(filename: 
"/UNLIKELY_PATH/empty{{/|}}{{.*}}Inputs/stdio.h",
 // CHECK-SAME:directory: "{{()|(.*:.*)}}")
 // CHECK-NOT: !DIFile(filename:
 



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


[PATCH] D70755: [LifetimeAnalysis] Fix PR44150

2019-11-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun created this revision.
xazax.hun added reviewers: gribozavr, mgehre.
xazax.hun added a project: clang.
Herald added subscribers: Szelethus, Charusso, gamesh411, dkrupp, rnkovacs.

We really wanted to avoid special handling of references but it looks like this 
is inevitable.

The main difference is the following, if you copy a gsl::Pointer, like an 
iterator, the result will dangle if and only if the original instance would 
dangle as well. Basically the copy just propagates the points-to set. But this 
is not the case for references.  If we create an object from a reference it is 
often more similar to a dereference operation, or an LValueToRValue cast. This 
patch attempts to address this difference.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70755

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -450,3 +450,8 @@
 MyIntPointer handleDerivedToBaseCast2(MyOwnerIntPointer ptr) {
   return ptr; // expected-warning {{address of stack memory associated with parameter 'ptr' returned}}
 }
+
+std::vector::iterator noFalsePositiveWithVectorOfPointers() {
+  std::vector::iterator> iters;
+  return iters.at(0);
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6653,6 +6653,7 @@
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslReferenceInit,
 GslPointerInit
   } Kind;
   Expr *E;
@@ -6783,12 +6784,24 @@
 
 static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
 LocalVisitor Visit) {
-  auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
+  auto VisitPointerArg = [&](const Decl *D, Expr *Arg, bool Value) {
 // We are not interested in the temporary base objects of gsl Pointers:
 //   Temp().ptr; // Here ptr might not dangle.
 if (isa(Arg->IgnoreImpCasts()))
   return;
-Path.push_back({IndirectLocalPathEntry::GslPointerInit, Arg, D});
+// Once we initialized a value with a reference, it can no longer dangle.
+if (!Value) {
+  for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
+if (It->Kind == IndirectLocalPathEntry::GslReferenceInit)
+  continue;
+if (It->Kind == IndirectLocalPathEntry::GslPointerInit)
+  return;
+break;
+  }
+}
+Path.push_back({Value ? IndirectLocalPathEntry::GslPointerInit
+  : IndirectLocalPathEntry::GslReferenceInit,
+Arg, D});
 if (Arg->isGLValue())
   visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding,
 Visit,
@@ -6802,18 +6815,21 @@
   if (auto *MCE = dyn_cast(Call)) {
 const auto *MD = cast_or_null(MCE->getDirectCallee());
 if (MD && shouldTrackImplicitObjectArg(MD))
-  VisitPointerArg(MD, MCE->getImplicitObjectArgument());
+  VisitPointerArg(MD, MCE->getImplicitObjectArgument(),
+  !MD->getReturnType()->isReferenceType());
 return;
   } else if (auto *OCE = dyn_cast(Call)) {
 FunctionDecl *Callee = OCE->getDirectCallee();
 if (Callee && Callee->isCXXInstanceMember() &&
 shouldTrackImplicitObjectArg(cast(Callee)))
-  VisitPointerArg(Callee, OCE->getArg(0));
+  VisitPointerArg(Callee, OCE->getArg(0),
+  !Callee->getReturnType()->isReferenceType());
 return;
   } else if (auto *CE = dyn_cast(Call)) {
 FunctionDecl *Callee = CE->getDirectCallee();
 if (Callee && shouldTrackFirstArgument(Callee))
-  VisitPointerArg(Callee, CE->getArg(0));
+  VisitPointerArg(Callee, CE->getArg(0),
+  !Callee->getReturnType()->isReferenceType());
 return;
   }
 
@@ -6821,7 +6837,7 @@
 const auto *Ctor = CCE->getConstructor();
 const CXXRecordDecl *RD = Ctor->getParent();
 if (CCE->getNumArgs() > 0 && RD->hasAttr())
-  VisitPointerArg(Ctor->getParamDecl(0), CCE->getArgs()[0]);
+  VisitPointerArg(Ctor->getParamDecl(0), CCE->getArgs()[0], true);
   }
 }
 
@@ -7288,6 +7304,7 @@
 case IndirectLocalPathEntry::AddressOf:
 case IndirectLocalPathEntry::LValToRVal:
 case IndirectLocalPathEntry::LifetimeBoundCall:
+case IndirectLocalPathEntry::GslReferenceInit:
 case IndirectLocalPathEntry::GslPointerInit:
   // These exist primarily to mark the path as not permitting or
   // supporting lifetime extension.
@@ -7310,7 +7327,8 @@
   continue;
 if (It->Kind == IndirectLocalPathEntry::AddressOf)
   continue;
-return It->Kind == IndirectLocalPathEntry::GslPointerInit;
+return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
+ 

[clang] 7ddc628 - [Preprocessor] Fix backslash tests on Windows after D49466

2019-11-26 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2019-11-26T17:27:58-08:00
New Revision: 7ddc6287a08ef758d66acb20d006c9ab0c579fcc

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

LOG: [Preprocessor] Fix backslash tests on Windows after D49466

See 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/29442/steps/test-check-all/logs/stdio

Added: 


Modified: 
clang/test/Preprocessor/file_test.c

Removed: 




diff  --git a/clang/test/Preprocessor/file_test.c 
b/clang/test/Preprocessor/file_test.c
index bdc5f1df6599..09ae48f48e09 100644
--- a/clang/test/Preprocessor/file_test.c
+++ b/clang/test/Preprocessor/file_test.c
@@ -6,14 +6,14 @@
 filename: __FILE__
 #include "file_test.h"
 
-// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
-// CHECK: filename: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.h"
-// CHECK: basefile: "/UNLIKELY_PATH/empty{{[/\\]}}file_test.c"
+// CHECK: filename: "/UNLIKELY_PATH/empty{{/|}}file_test.c"
+// CHECK: filename: "/UNLIKELY_PATH/empty{{/|}}file_test.h"
+// CHECK: basefile: "/UNLIKELY_PATH/empty{{/|}}file_test.c"
 // CHECK-NOT: filename:
 
-// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
-// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.h"
-// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty{{[/\\]}}file_test.c"
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{/|}}file_test.c"
+// CHECK-EVIL: filename: "/UNLIKELY_PATH=empty{{/|}}file_test.h"
+// CHECK-EVIL: basefile: "/UNLIKELY_PATH=empty{{/|}}file_test.c"
 // CHECK-EVIL-NOT: filename:
 
 // CHECK-REMOVE: filename: "file_test.c"



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

There's still one failing test on Windows after the fix attempt: 
http://45.33.8.238/win/3052/step_6.txt

Please take a look and revert if it's not an easy fix. (And please watch bots 
after committing stuff.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[clang] ded2490 - Workaround for EvalInfo ctor for MSVC 2017

2019-11-26 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2019-11-26T21:43:29-05:00
New Revision: ded249049429a26d3748926c04bd7169f0170714

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

LOG: Workaround for EvalInfo ctor for MSVC 2017

Current EvalInfo ctor causes EnableNewConstInterp to be true even though
it is supposed to be false on MSVC 2017. This is because a virtual function
getLangOpts() is called in member initializer lists, whereas on MSVC
member ctors are called before function virtual function pointers are
initialized.

This patch fixes that.

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

Added: 
clang/test/Sema/eval-info.c

Modified: 
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 79659261388b..eec9bbdaef80 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -921,10 +921,10 @@ namespace {
 EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode)
 : Ctx(const_cast(C)), EvalStatus(S), 
CurrentCall(nullptr),
   CallStackDepth(0), NextCallIndex(1),
-  StepsLeft(getLangOpts().ConstexprStepLimit),
-  ForceNewConstInterp(getLangOpts().ForceNewConstInterp),
+  StepsLeft(C.getLangOpts().ConstexprStepLimit),
+  ForceNewConstInterp(C.getLangOpts().ForceNewConstInterp),
   EnableNewConstInterp(ForceNewConstInterp ||
-   getLangOpts().EnableNewConstInterp),
+   C.getLangOpts().EnableNewConstInterp),
   BottomFrame(*this, SourceLocation(), nullptr, nullptr, nullptr),
   EvaluatingDecl((const ValueDecl *)nullptr),
   EvaluatingDeclValue(nullptr), HasActiveDiagnostic(false),

diff  --git a/clang/test/Sema/eval-info.c b/clang/test/Sema/eval-info.c
new file mode 100644
index ..7f4de4b90820
--- /dev/null
+++ b/clang/test/Sema/eval-info.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-windows-msvc -verify
+
+// expected-no-diagnostics
+
+// Make sure the new constant interpolator is not enabled unintentionally
+// to cause assertion.
+typedef enum x {
+  a = 1,
+} x;



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


  1   2   >