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

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231357.
lh123 marked 6 inline comments as done.
lh123 added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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
@@ -859,5 +859,36 @@
 "clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
 }
 
+class ExpandResponseFilesTest : public MemDBTest {
+protected:
+  void SetUp() override {
+FS = new llvm::vfs::InMemoryFileSystem;
+ASSERT_TRUE(addFile(path(StringRef("rsp1.rsp")), "-Dflag"));
+  }
+
+  bool addFile(StringRef File, StringRef Context) {
+return FS->addFile(File, 0, llvm::MemoryBuffer::getMemBufferCopy(Context));
+  }
+
+  std::string getCommand(llvm::StringRef F) {
+auto Results = expandResponseFiles(std::make_unique(Entries),
+   FS)
+   ->getCompileCommands(path(F));
+if (Results.empty()) {
+  return "none";
+}
+return llvm::join(Results[0].CommandLine, " ");
+  }
+
+  llvm::IntrusiveRefCntPtr FS;
+};
+
+TEST_F(ExpandResponseFilesTest, ExpandResponseFiles) {
+  add("foo.cpp", "clang", "@rsp1.rsp");
+  add("bar.cpp", "clang", "-Dflag");
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag");
+  EXPECT_EQ(getCommand("bar.cpp"), "clang bar.cpp -D bar.cpp -Dflag");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -168,7 +168,9 @@
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
 return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(std::move(Base)))
+  inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base),
+  llvm::vfs::createPhysicalFileSystem().get(
 : nullptr;
   }
 };
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -0,0 +1,93 @@
+//===- 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 {
+namespace {
+
+class ExpandResponseFilesDatabase : public CompilationDatabase {
+public:
+  ExpandResponseFilesDatabase(
+  std::unique_ptr Base,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::IntrusiveRefCntPtr FS)
+  : Base(std::move(Base)), Tokenizer(Tokenizer), FS(std::move(FS)) {
+assert(this->Base != nullptr);
+assert(this->Tokenizer != nullptr);
+assert(this->FS != nullptr);
+  }
+
+  std::vector getAllFiles() const override {
+return Base->getAllFiles();
+  }
+
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
+return expand(Base->getCompileCommands(FilePath));
+  }
+
+  std::vector getAllCompileCommands() const override {
+return expand(Base->getAllCompileCommands());
+  }
+
+private:
+  std::vector expand(std::vector Cmds) const {
+for (auto  : Cmds) {
+  // FIXME: we should rather propagate the current directory into
+  // ExpandResponseFiles as well in addition to FS and someone can take a
+  // look at it later on.
+  if (std::error_code EC = FS->setCurrentWorkingDirectory(Cmd.Directory)) {
+llvm::consumeError(llvm::errorCodeToError(EC));
+continue;
+  }
+  bool SeenRSPFile = false;
+  llvm::SmallVector Argv;
+  Argv.reserve(Cmd.CommandLine.size());
+  for (auto  : Cmd.CommandLine) {
+Argv.push_back(Arg.c_str());
+SeenRSPFile |= Arg.front() == 

[PATCH] D70799: [OpenMP] Lower taskyield using OpenMP IR Builder

2019-11-27 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 created this revision.
rogfer01 added reviewers: jdoerfert, kiranchandramohan.
Herald added subscribers: llvm-commits, cfe-commits, guansong, hiraditya.
Herald added projects: clang, LLVM.
rogfer01 added a parent revision: D69922: [OpenMP] Use the OpenMP-IR-Builder.

This is similar to D69828 .

Special codegen for enclosing untied tasks is still done in clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70799

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/taskyield_codegen.cpp
  llvm/include/llvm/Frontend/OpenMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMPKinds.def
  llvm/lib/Frontend/OpenMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMPIRBuilder.cpp
@@ -272,3 +272,20 @@
 return;
   emitTaskwaitImpl(Loc);
 }
+
+void OpenMPIRBuilder::emitTaskyieldImpl(const LocationDescription ) {
+  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
+  Constant *SrcLocStr = getOrCreateSrcLocStr(Loc);
+  Value *Ident = getOrCreateIdent(SrcLocStr);
+  Constant *I32Null = ConstantInt::getNullValue(Int32);
+  Value *Args[] = {Ident, getOrCreateThreadID(Ident), I32Null};
+
+  Builder.CreateCall(getOrCreateRuntimeFunction(OMPRTL___kmpc_omp_taskyield),
+ Args);
+}
+
+void OpenMPIRBuilder::CreateTaskyield(const LocationDescription ) {
+  if (!updateToLocation(Loc))
+return;
+  emitTaskyieldImpl(Loc);
+}
Index: llvm/include/llvm/Frontend/OpenMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMPKinds.def
@@ -168,6 +168,7 @@
 __OMP_RTL(__kmpc_fork_call, true, Void, IdentPtr, Int32, ParallelTaskPtr)
 __OMP_RTL(omp_get_thread_num, false, Int32, )
 __OMP_RTL(__kmpc_omp_taskwait, false, Int32, IdentPtr, Int32)
+__OMP_RTL(__kmpc_omp_taskyield, false, Int32, IdentPtr, Int32, Int32)
 
 #undef __OMP_RTL
 #undef OMP_RTL
Index: llvm/include/llvm/Frontend/OpenMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMPIRBuilder.h
@@ -78,6 +78,11 @@
   /// \param Loc The location where the taskwait directive was encountered.
   void CreateTaskwait(const LocationDescription& Loc);
 
+  /// Generator for '#omp taskyield'
+  ///
+  /// \param Loc The location where the taskyield directive was encountered.
+  void CreateTaskyield(const LocationDescription& Loc);
+
   ///}
 
 private:
@@ -122,6 +127,11 @@
   /// \param Loc The location at which the request originated and is fulfilled.
   void emitTaskwaitImpl(const LocationDescription );
 
+  /// Generate a taskyield runtime call.
+  ///
+  /// \param Loc The location at which the request originated and is fulfilled.
+  void emitTaskyieldImpl(const LocationDescription );
+
   /// Return the current thread ID.
   ///
   /// \param Ident The ident (ident_t*) describing the query origin.
Index: clang/test/OpenMP/taskyield_codegen.cpp
===
--- clang/test/OpenMP/taskyield_codegen.cpp
+++ clang/test/OpenMP/taskyield_codegen.cpp
@@ -1,6 +1,10 @@
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3247,11 +3247,18 @@
 SourceLocation Loc) {
   if (!CGF.HaveInsertPoint())
 return;
-  // Build call __kmpc_omp_taskyield(loc, thread_id, 0);
-  llvm::Value *Args[] = {
-  emitUpdateLocation(CGF, Loc), getThreadID(CGF, Loc),
-  llvm::ConstantInt::get(CGM.IntTy, /*V=*/0, /*isSigned=*/true)};
-  CGF.EmitRuntimeCall(createRuntimeFunction(OMPRTL__kmpc_omp_taskyield), Args);
+  

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

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

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1046,11 +1047,19 @@
 static bool ExpandResponseFile(StringRef FName, StringSaver ,
TokenizerCallback Tokenizer,
SmallVectorImpl ,
-   bool MarkEOLs, bool RelativeNames) {
-  ErrorOr> MemBufOrErr =
-  MemoryBuffer::getFile(FName);
-  if (!MemBufOrErr)
+   bool MarkEOLs, bool RelativeNames,
+   llvm::vfs::FileSystem ) {
+  llvm::ErrorOr CurrDirOrErr = FS.getCurrentWorkingDirectory();
+  if (!CurrDirOrErr) {
+llvm::consumeError(llvm::errorCodeToError(CurrDirOrErr.getError()));
 return false;
+  }
+  llvm::ErrorOr> MemBufOrErr =
+  FS.getBufferForFile(FName);
+  if (!MemBufOrErr) {
+llvm::consumeError(llvm::errorCodeToError(MemBufOrErr.getError()));
+return false;
+  }
   MemoryBuffer  = *MemBufOrErr.get();
   StringRef Str(MemBuf.getBufferStart(), MemBuf.getBufferSize());
 
@@ -1084,9 +1093,7 @@
 SmallString<128> ResponseFile;
 ResponseFile.append(1, '@');
 if (llvm::sys::path::is_relative(FName)) {
-  SmallString<128> curr_dir;
-  llvm::sys::fs::current_path(curr_dir);
-  ResponseFile.append(curr_dir.str());
+  ResponseFile.append(CurrDirOrErr.get());
 }
 llvm::sys::path::append(
 ResponseFile, llvm::sys::path::parent_path(FName), FileName);
@@ -1101,8 +1108,8 @@
 /// Expand response files on a command line recursively using the given
 /// StringSaver and tokenization strategy.
 bool cl::ExpandResponseFiles(StringSaver , TokenizerCallback Tokenizer,
- SmallVectorImpl ,
- bool MarkEOLs, bool RelativeNames) {
+ SmallVectorImpl , bool MarkEOLs,
+ bool RelativeNames, llvm::vfs::FileSystem ) {
   bool AllExpanded = true;
   struct ResponseFileRecord {
 const char *File;
@@ -1139,8 +1146,18 @@
 }
 
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord ) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, ](const ResponseFileRecord ) {
+  llvm::ErrorOr LHS = FS.status(FName);
+  if (!LHS) {
+llvm::consumeError(llvm::errorCodeToError(LHS.getError()));
+return false;
+  }
+  llvm::ErrorOr RHS = FS.status(RFile.File);
+  if (!RHS) {
+llvm::consumeError(llvm::errorCodeToError(RHS.getError()));
+return false;
+  }
+  return LHS->equivalent(*RHS);
 };
 
 // Check for recursive response files.
@@ -1156,7 +1173,7 @@
 // contents.  Nested response files are expanded in subsequent iterations.
 SmallVector ExpandedArgv;
 if (!ExpandResponseFile(FName, Saver, Tokenizer, ExpandedArgv, MarkEOLs,
-RelativeNames)) {
+RelativeNames, FS)) {
   // We couldn't read this file, so we leave it in the argument stream and
   // move on.
   AllExpanded = false;
@@ -1187,7 +1204,8 @@
 bool cl::readConfigFile(StringRef CfgFile, StringSaver ,
 SmallVectorImpl ) {
   if (!ExpandResponseFile(CfgFile, Saver, cl::tokenizeConfigFile, Argv,
-  /*MarkEOLs*/ false, /*RelativeNames*/ true))
+  /*MarkEOLs*/ false, /*RelativeNames*/ true,
+  *llvm::vfs::getRealFileSystem()))
 return false;
   return ExpandResponseFiles(Saver, cl::tokenizeConfigFile, Argv,
  /*MarkEOLs*/ false, /*RelativeNames*/ true);
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1964,10 +1965,13 @@
 /// with nullptrs in the Argv vector.
 /// \param [in] RelativeNames true if names of nested response files must be
 /// 

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

2019-11-27 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMPKinds.def:165
+
+__OMP_RTL(__kmpc_barrier, false, Void, IdentPtr, Int32)
+__OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32)

As we migrate, we will end with a significant number of interfaces here.

@jdoerfert what do you think about adding a comment with their C prototype 
before each one like we do in `clang/lib/CodeGen/CGOpenMPRuntime.cpp`?

Something like this

```lang=cpp
// void __kmpc_barrier(ident_t *loc, kmp_int32 global_tid);
__OMP_RTL(__kmpc_barrier, false, Void, IdentPtr, Int32)
// kmp_int32 __kmpc_cancel_barrier(ident_t *loc, kmp_int32
// global_tid)
__OMP_RTL(__kmpc_cancel_barrier, false, Int32, IdentPtr, Int32)
...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231349.
lh123 marked 3 inline comments as done.
lh123 added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1046,9 +1047,15 @@
 static bool ExpandResponseFile(StringRef FName, StringSaver ,
TokenizerCallback Tokenizer,
SmallVectorImpl ,
-   bool MarkEOLs, bool RelativeNames) {
+   bool MarkEOLs, bool RelativeNames,
+   llvm::vfs::FileSystem ) {
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir) {
+llvm::consumeError(errorCodeToError(CurrDir.getError()));
+return false;
+  }
   ErrorOr> MemBufOrErr =
-  MemoryBuffer::getFile(FName);
+  FS.getBufferForFile(FName);
   if (!MemBufOrErr)
 return false;
   MemoryBuffer  = *MemBufOrErr.get();
@@ -1084,9 +1091,7 @@
 SmallString<128> ResponseFile;
 ResponseFile.append(1, '@');
 if (llvm::sys::path::is_relative(FName)) {
-  SmallString<128> curr_dir;
-  llvm::sys::fs::current_path(curr_dir);
-  ResponseFile.append(curr_dir.str());
+  ResponseFile.append(CurrDir.get());
 }
 llvm::sys::path::append(
 ResponseFile, llvm::sys::path::parent_path(FName), FileName);
@@ -1101,8 +1106,8 @@
 /// Expand response files on a command line recursively using the given
 /// StringSaver and tokenization strategy.
 bool cl::ExpandResponseFiles(StringSaver , TokenizerCallback Tokenizer,
- SmallVectorImpl ,
- bool MarkEOLs, bool RelativeNames) {
+ SmallVectorImpl , bool MarkEOLs,
+ bool RelativeNames, llvm::vfs::FileSystem ) {
   bool AllExpanded = true;
   struct ResponseFileRecord {
 const char *File;
@@ -1139,8 +1144,18 @@
 }
 
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord ) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, ](const ResponseFileRecord ) {
+  llvm::ErrorOr LHS = FS.status(FName);
+  if (!LHS) {
+llvm::consumeError(errorCodeToError(LHS.getError()));
+return false;
+  }
+  llvm::ErrorOr RHS = FS.status(RFile.File);
+  if (!RHS) {
+llvm::consumeError(errorCodeToError(RHS.getError()));
+return false;
+  }
+  return LHS->equivalent(*RHS);
 };
 
 // Check for recursive response files.
@@ -1156,7 +1171,7 @@
 // contents.  Nested response files are expanded in subsequent iterations.
 SmallVector ExpandedArgv;
 if (!ExpandResponseFile(FName, Saver, Tokenizer, ExpandedArgv, MarkEOLs,
-RelativeNames)) {
+RelativeNames, FS)) {
   // We couldn't read this file, so we leave it in the argument stream and
   // move on.
   AllExpanded = false;
@@ -1187,7 +1202,8 @@
 bool cl::readConfigFile(StringRef CfgFile, StringSaver ,
 SmallVectorImpl ) {
   if (!ExpandResponseFile(CfgFile, Saver, cl::tokenizeConfigFile, Argv,
-  /*MarkEOLs*/ false, /*RelativeNames*/ true))
+  /*MarkEOLs*/ false, /*RelativeNames*/ true,
+  *llvm::vfs::getRealFileSystem()))
 return false;
   return ExpandResponseFiles(Saver, cl::tokenizeConfigFile, Argv,
  /*MarkEOLs*/ false, /*RelativeNames*/ true);
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1964,10 +1965,13 @@
 /// with nullptrs in the Argv vector.
 /// \param [in] RelativeNames true if names of nested response files must be
 /// resolved relative to including file.
+/// \param [in] FS File system used for all file access when running the tool.
 /// \return true if all @files were expanded successfully or there were none.
-bool 

[PATCH] D69498: IR: Invert convergent attribute handling

2019-11-27 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Talked with Matt at the last social, they thought I was strongly opposed to 
this: I am not, and I told them I would clarify here:

I don't buy the argument of "frontend projects have consistently run into 
problems related to this", I think this is not a good justification for this 
change. But this change seems like it can be motivated without this argument.
I also have been trying to help brainstorming alternatives just to see if we 
could get something that would fit what Matt is looking to achieve while 
getting past @rjmccall concerns, not because I am against this change.


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

https://reviews.llvm.org/D69498



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


[PATCH] D70694: Use InitLLVM in clang-tidy

2019-11-27 Thread Rui Ueyama via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa7acba29c19a: Use InitLLVM in clang-tidy (authored by ruiu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70694

Files:
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp


Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -18,6 +18,7 @@
 #include "../ClangTidyForceLinker.h"
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -327,7 +328,7 @@
 }
 
 static int clangTidyMain(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
   CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
 cl::ZeroOrMore);
   llvm::IntrusiveRefCntPtr BaseFS(


Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -18,6 +18,7 @@
 #include "../ClangTidyForceLinker.h"
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -327,7 +328,7 @@
 }
 
 static int clangTidyMain(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
   CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
 cl::ZeroOrMore);
   llvm::IntrusiveRefCntPtr BaseFS(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] a7acba2 - Use InitLLVM in clang-tidy

2019-11-27 Thread Rui Ueyama via cfe-commits

Author: Rui Ueyama
Date: 2019-11-28T13:50:35+09:00
New Revision: a7acba29c19ac67c77ed282ec9432602ae21268d

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

LOG: Use InitLLVM in clang-tidy

Update clang-tidy to use InitLLVM, like several other llvm tools that
were previously updated. On Windows, this allows clang-tidy to operate
on arguments containing characters which cannot be represented in the
system's ANSI code page such as filenames with Unicode characters.

Fixes bugzilla bug 43751.

Patch by Tristan Labelle.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index df83de856238..ad6182def20d 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -18,6 +18,7 @@
 #include "../ClangTidyForceLinker.h"
 #include "../GlobList.h"
 #include "clang/Tooling/CommonOptionsParser.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
@@ -327,7 +328,7 @@ getVfsFromFile(const std::string ,
 }
 
 static int clangTidyMain(int argc, const char **argv) {
-  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::InitLLVM X(argc, argv);
   CommonOptionsParser OptionsParser(argc, argv, ClangTidyCategory,
 cl::ZeroOrMore);
   llvm::IntrusiveRefCntPtr BaseFS(



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


[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2019-11-27 Thread Valentin Churavy via Phabricator via cfe-commits
vchuravy updated this revision to Diff 231343.
vchuravy marked 6 inline comments as done.
vchuravy added a comment.

- add test for passing anyref through a function
- fix wrong name for funcref
- fixes and formatting
- fix error message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035

Files:
  lld/wasm/WriterUtils.cpp
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
  llvm/test/CodeGen/WebAssembly/anyref.ll
  llvm/test/CodeGen/WebAssembly/reg-argument.mir
  llvm/test/CodeGen/WebAssembly/reg-copy.mir

Index: llvm/test/CodeGen/WebAssembly/reg-copy.mir
===
--- llvm/test/CodeGen/WebAssembly/reg-copy.mir
+++ llvm/test/CodeGen/WebAssembly/reg-copy.mir
@@ -66,3 +66,14 @@
 %0:exnref = COPY %1:exnref
 RETURN implicit-def $arguments
 ...
+---
+name: copy_anyref
+# CHECK-LABEL: copy_anyref
+body: |
+  ; CHECK-LABEL: bb.0
+  ; CHECK-NEXT: %0:anyref = COPY_ANYREF %1:anyref
+  ; CHECK-NEXT: RETURN
+  bb.0:
+%0:anyref = COPY %1:anyref
+RETURN implicit-def $arguments
+...
Index: llvm/test/CodeGen/WebAssembly/reg-argument.mir
===
--- llvm/test/CodeGen/WebAssembly/reg-argument.mir
+++ llvm/test/CodeGen/WebAssembly/reg-argument.mir
@@ -57,3 +57,14 @@
 %1:exnref = ARGUMENT_exnref 0, implicit $arguments
 RETURN implicit-def $arguments
 ...
+---
+name: argument_anyref
+# CHECK-LABEL: argument_anyref
+body: |
+  ; CHECK-LABEL: bb.0:
+  ; CHECK-NEXT: %1:anyref = ARGUMENT_anyref 0
+  bb.0:
+%0:i32 = CONST_I32 0, implicit-def $arguments
+%1:anyref = ARGUMENT_anyref 0, implicit $arguments
+RETURN implicit-def $arguments
+...
Index: llvm/test/CodeGen/WebAssembly/anyref.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/anyref.ll
@@ -0,0 +1,29 @@
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+reference-types | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+declare i8 addrspace(256)* @test(i8 addrspace(256)*) 
+
+
+; CHECK-LABEL: call_test:
+; CHECK: .functype   call_test (anyref) -> (anyref)
+define i8 addrspace(256)* @call_test(i8 addrspace(256)*) {
+; CHECK: anyref.call $push0=, test, $0
+  %a = call i8 addrspace(256)* @test(i8 addrspace(256)* %0) 
+  ret i8 addrspace(256)* %a
+}
+
+; TODO: nullref?
+; define i8 addrspace(256)* @null_test() {
+;   ret i8 addrspace(256)* null
+; }
+
+; TODO: Loading a anyref from a pointer
+; @glob = external global i8 addrspace(256)*, align 4
+; define i8 addrspace(256)* @global_test() {
+;   %a = load i8 addrspace(256)*, i8 addrspace(256)** @glob
+;   ret i8 addrspace(256)* %a
+; }
+
+; CHECK: .functype   test (anyref) -> (anyref)
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
@@ -77,6 +77,8 @@
 CopyOpcode = WebAssembly::COPY_V128;
   else if (RC == ::EXNREFRegClass)
 CopyOpcode = WebAssembly::COPY_EXNREF;
+  else if (RC == ::ANYREFRegClass)
+CopyOpcode = WebAssembly::COPY_ANYREF;
   else
 llvm_unreachable("Unexpected register class");
 
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrCall.td
@@ -143,6 +143,9 @@
 def : Pat<(exnref (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))),
   (CALL_exnref tglobaladdr:$callee)>,
   Requires<[HasExceptionHandling]>;
+def : Pat<(anyref (WebAssemblycall1 (WebAssemblywrapper tglobaladdr:$callee))),
+  (CALL_anyref tglobaladdr:$callee)>,
+  Requires<[HasReferenceTypes]>;
 def : Pat<(WebAssemblycall0 (WebAssemblywrapper tglobaladdr:$callee)),
   (CALL_VOID tglobaladdr:$callee)>;
 def : Pat<(WebAssemblyretcall (WebAssemblywrapper tglobaladdr:$callee)),
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -1118,7 +1118,7 @@
  "Unexpected target flags on generic GlobalAddressSDNode");
   if (GA->getAddressSpace() != 0 &&
   GA->getAddressSpace() != 

[PATCH] D66035: [WebAssembly] WIP: Add support for reference types

2019-11-27 Thread Valentin Churavy via Phabricator via cfe-commits
vchuravy marked 4 inline comments as done.
vchuravy added a comment.

Rebased onto current master and added an initial test. (I will start adding 
more as I start integrating this with the rest of the toolchain)




Comment at: llvm/lib/Object/WasmObjectFile.cpp:998
+if (Tables.back().ElemType != wasm::WASM_TYPE_FUNCREF &&
+// TODO: Only allow anyref here when reference-types is enabled?
+Tables.back().ElemType != wasm::WASM_TYPE_ANYREF) {

aheejin wrote:
> Why should we only allow anyref?
Not sure what Keno meant by this comment, but it might be to check that 
`reference-types` is enabled before allowing it as a element type.



Comment at: llvm/lib/Target/WebAssembly/WebAssembly.h:88
+  MAX_CUSTOM_ADDRESS = 255,
+  ANYREF_ADDRESS = 256, // Address space for anyref
+};

tlively wrote:
> I assume other reference types will get their own address spaces so we can 
> differentiate them in IR. Would it then make sense to put the table itself in 
> another address space? We should also think about how best to partition the 
> address space space looking forward to when we will have multiple memories, 
> multiple tables, and multiple function references or reference type imports.
Yes. `funcref` should get its own address space but I am not sure about its 
usage yet.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h:54
+  MVT::getIntegerVT(DL.getPointerSizeInBits(AS));
+  }
+

aheejin wrote:
> How are we gonna represent other reference types, such as `funcref` or 
> `exnref`?
The question is which of these types need representing. As far as I can tell 
`exnref` and is produced by LLVM already and `funcref` is primarily used for 
function tables in modules and isn't necessarily a frontend facing time. Albeit 
nothing in the spec says that it couldn't be. 

If funcref would need a frontend facing representation it would need a new AS.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:113
+TT.isArch64Bit() ? 
"e-m:e-p:64:64-i64:64-n32:64-S128-ni:1"
+ : 
"e-m:e-p:32:32-i64:64-n32:64-S128-ni:1",
 TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),

aheejin wrote:
> Is this gonna support existing .ll files with the previous data layout?
I don't see why it shouldn't without activating `-mattr=+reference-types` new 
.ll files won't compile,
but old one should.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66035



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


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

2019-11-27 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I'd very much like this to land soon. It's the prereq for a lot of other 
patches and the code looks good.

It's tricky to test the infra before the users are landed so the unit test is 
particularly appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[PATCH] D70411: [analyzer] CERT: StrChecker: 31.c

2019-11-27 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 2 inline comments as done.
Charusso added a comment.

The false positive suppression by going backwards on the bug-path of stored 
reports was a very simple concept, which turned out to be a useless one. The 
rough idea was that to invalidate every report in a path, and every other 
report would be left because they are reachable from a different path and they 
are valid errors. So that:

  void test_wonky_null_termination(const char *src) {
char dest[128];
strcpy(dest, src);
dest[sizeof(dest) - 1] = '\0';
do_something(dest); // no-warning
  }

The above example null-terminates the string on every path, so we remove the 
report, and:

  void test_may_not_every_path_null_terminated(const char *src) {
char dest[128];
strcpy(dest, src);
if (strlen(src) > sizeof(dest)) {
  dest[sizeof(dest) - 1] = '\0';
}
do_something(dest);
// expected-warning@-1 {{'dest' is not null-terminated}}
  }

We say that the above example has a path where we cannot invalidate the report. 
Invalidating one single control-flow path I think should be safe and keeps 
every other report like the above examples. In general there is no such simple 
case exist because we check for the destination array being null so we 
encounter a state-split whatever we do. Also may it was a bad idea to rewrite 
the `BugReporter` for a simple checker.

This null-termination-by-hand made false positives because even the buffer 
could overflow, we stop up the flow, so the Vasa will not sink. I wanted to 
emit reports on problematic function calls, but changing the main logic to emit 
an error on the string-reading made the null-termination store-able. So that we 
could drop this backward path-traversing logic, that is why I have not answered 
yet. However, if we still want to emit an error on function-calls, and every of 
them, we need to be able to chain the calls to the same region, which made by 
the reports in the previous revisions. Also may we would use this 
report-storing idea later.




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:801
+  Dependencies<[StrCheckerBase]>,
+  Documentation;
+

In my mind the documentation is the CERT rule's page. Is it okay?



Comment at: clang/test/Analysis/cert/str31-c-fp-suppression.cpp:15
+
+void do_something(char *destfer);
+

Facepalm.


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

https://reviews.llvm.org/D70411



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


[PATCH] D70411: [analyzer] CERT: StrChecker: 31.c

2019-11-27 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 231341.
Charusso added a comment.

- Do not emit a report on re-binding a not null-terminated string, it may will 
be properly terminated (test added).
- Added a test for the necessity of `SValVisitor` in this checker.
- Some refactor.


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

https://reviews.llvm.org/D70411

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/BugReporter/CommonBugCategories.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSizeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymExpr.h
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/lib/StaticAnalyzer/Core/CommonBugCategories.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-fp-suppression.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,security.cert.str.31.c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator
+
+#include "../Inputs/system-header-simulator.h"
+
+#define EOF -1
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+void do_something(char *buffer);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+do_something(buf);
+// expected-warning@-1 {{'buf' is not null-terminated}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+do_something(buff);
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+
+  do_something(buf);
+  // expected-warning@-1 {{'buf' is not null-terminated}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+
+  do_something(buff);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  if (fscanf(stdin, "%s", buf)) {
+do_something(buf);
+// expected-warning@-1 {{'buf' is not null-terminated}}
+  }
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  if (fscanf(stdin, "%1023s", buff)) {
+do_something(buff);
+  }
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+
+  do_something(prog_name);
+  // expected-warning@-1 {{'prog_name' is not null-terminated}}
+
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+
+do_something(buff);
+// expected-warning@-1 {{'buff' is not null-terminated}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  do_something(prog_name2);
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+do_something(buff2);
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following is from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n - 1); ++i) {
+

[clang] 789a7aa - Properly disambiguate between array declarators and array subscript expressions.

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

Author: Richard Smith
Date: 2019-11-27T17:54:26-08:00
New Revision: 789a7aa37d0cca70d6e48908ce3e8bb4e761e266

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

LOG: Properly disambiguate between array declarators and array subscript 
expressions.

Added: 


Modified: 
clang/lib/Parse/ParseTentative.cpp
clang/test/Parser/cxx-ambig-decl-expr.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseTentative.cpp 
b/clang/lib/Parse/ParseTentative.cpp
index e2e16ca63d1e..9cc41328c469 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -2066,9 +2066,21 @@ Parser::TPResult Parser::TryParseFunctionDeclarator() {
 ///
 Parser::TPResult Parser::TryParseBracketDeclarator() {
   ConsumeBracket();
-  if (!SkipUntil(tok::r_square, StopAtSemi))
+
+  // A constant-expression cannot begin with a '{', but the
+  // expr-or-braced-init-list of a postfix-expression can.
+  if (Tok.is(tok::l_brace))
+return TPResult::False;
+
+  if (!SkipUntil(tok::r_square, tok::comma, StopAtSemi | StopBeforeMatch))
 return TPResult::Error;
 
+  // If we hit a comma before the ']', this is not a constant-expression,
+  // but might still be the expr-or-braced-init-list of a postfix-expression.
+  if (Tok.isNot(tok::r_square))
+return TPResult::False;
+
+  ConsumeBracket();
   return TPResult::Ambiguous;
 }
 

diff  --git a/clang/test/Parser/cxx-ambig-decl-expr.cpp 
b/clang/test/Parser/cxx-ambig-decl-expr.cpp
index 6507eafb74cd..02857e21f7c3 100644
--- a/clang/test/Parser/cxx-ambig-decl-expr.cpp
+++ b/clang/test/Parser/cxx-ambig-decl-expr.cpp
@@ -17,3 +17,25 @@ auto (*q)() -> int(*)(unknown); // expected-error {{unknown 
type name 'unknown'}
 auto (*r)() -> int(*)(unknown + 1); // expected-error {{undeclared identifier 
'unknown'}}
 
 int f(unknown const x); // expected-error {{unknown type name 'unknown'}}
+
+// Disambiguating an array declarator from an array subscripting.
+void arr() {
+  int x[] = {1}; // expected-note 2{{previous}}
+
+  // This is array indexing not an array declarator because a comma expression
+  // is not syntactically a constant-expression.
+  int(x[1,1]); // expected-warning 2{{unused}}
+
+  // This is array indexing not an array declaration because a braced-init-list
+  // is not syntactically a constant-expression.
+  int(x[{0}]); // expected-error {{array subscript is not an integer}}
+  struct A {
+struct Q { int n; };
+int operator[](Q);
+  } a;
+  int(a[{0}]); // expected-warning {{unused}}
+
+  // These are array declarations.
+  int(x[(1,1)]); // expected-error {{redefinition}}
+  int(x[true ? 1,1 : 1]); // expected-error {{redefinition}}
+}



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


[PATCH] D46234: Mark if a null statement is the result of constexpr folding

2019-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D46234#1762104 , @xazax.hun wrote:

> Just a note for anyone willing to pick this up, PR32203 is also related.


Further note: the right approach here would likely be to add a `DiscardedStmt` 
class deriving from `Stmt` that represents a discarded arm of an `if 
constexpr`, rather than modeling this as a `NullStmt`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D46234



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


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

I think this was commited too soon. You should receive LGTM from clang 
maintainer(s).

In D70302#1747372 , @nickie wrote:

> LGTM, for all that it's worth.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302



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


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes added a comment.

Committed as 1ac700cdef787383ad49a0e37d9894491ef19480 
 - this 
should be a safe fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302



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


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1ac700cdef78: [CodeGen] Fix clang crash on aggregate 
initialization of array of labels (authored by johannes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1ac700c - [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via cfe-commits

Author: Johannes Altmanninger
Date: 2019-11-28T00:59:25+01:00
New Revision: 1ac700cdef787383ad49a0e37d9894491ef19480

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

LOG: [CodeGen] Fix clang crash on aggregate initialization of array of labels

Summary: Fix PR43700

The ConstantEmitter in AggExprEmitter::EmitArrayInit was initialized
with the CodeGenFunction set to null, which caused the crash.
Also simplify another call, and make the CGF member a const pointer
since it is public but only assigned in the constructor.

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/CodeGen/label-array-aggregate-init.c

Modified: 
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/ConstantEmitter.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 7e69f63fe135..ecb5253c07ec 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, 
llvm::ArrayType *AType,
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index d727e326a27a..750b5503c08f 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@ class ScalarExprEmitter
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {

diff  --git a/clang/lib/CodeGen/ConstantEmitter.h 
b/clang/lib/CodeGen/ConstantEmitter.h
index 59a19730f4eb..121acbac4fa9 100644
--- a/clang/lib/CodeGen/ConstantEmitter.h
+++ b/clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@ namespace CodeGen {
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;

diff  --git a/clang/test/CodeGen/label-array-aggregate-init.c 
b/clang/test/CodeGen/label-array-aggregate-init.c
new file mode 100644
index ..6821fd355ec1
--- /dev/null
+++ b/clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}



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


[PATCH] D70302: [CodeGen] Fix clang crash on aggregate initialization of array of labels

2019-11-27 Thread Johannes Altmanninger via Phabricator via cfe-commits
johannes updated this revision to Diff 231330.
johannes edited the summary of this revision.
johannes added a comment.

update commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70302

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/test/CodeGen/label-array-aggregate-init.c


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, 
CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(


Index: clang/test/CodeGen/label-array-aggregate-init.c
===
--- /dev/null
+++ clang/test/CodeGen/label-array-aggregate-init.c
@@ -0,0 +1,6 @@
+// RUN: %clang -cc1 -emit-llvm %s -o /dev/null
+
+int main() {
+L:
+  (void)(void *[]){ &, 0, 0 };
+}
Index: clang/lib/CodeGen/ConstantEmitter.h
===
--- clang/lib/CodeGen/ConstantEmitter.h
+++ clang/lib/CodeGen/ConstantEmitter.h
@@ -23,7 +23,7 @@
 class ConstantEmitter {
 public:
   CodeGenModule 
-  CodeGenFunction *CGF;
+  CodeGenFunction *const CGF;
 
 private:
   bool Abstract = false;
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -644,8 +644,8 @@
 auto  = CGF.getContext();
 APValue Evaluated =
 SLE->EvaluateInContext(Ctx, CGF.CurSourceLocExprScope.getDefaultExpr());
-return ConstantEmitter(CGF.CGM, )
-.emitAbstract(SLE->getLocation(), Evaluated, SLE->getType());
+return ConstantEmitter(CGF).emitAbstract(SLE->getLocation(), Evaluated,
+ SLE->getType());
   }
 
   Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -493,7 +493,7 @@
   if (NumInitElements * elementSize.getQuantity() > 16 &&
   elementType.isTriviallyCopyableType(CGF.getContext())) {
 CodeGen::CodeGenModule  = CGF.CGM;
-ConstantEmitter Emitter(CGM);
+ConstantEmitter Emitter(CGF);
 LangAS AS = ArrayQTy.getAddressSpace();
 if (llvm::Constant *C = Emitter.tryEmitForInitializer(E, AS, ArrayQTy)) {
   auto GV = new llvm::GlobalVariable(
___
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-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:9320
   using OMPCtxSelectorData =
-  OpenMPCtxSelectorData, ExprResult>;
+  OpenMPCtxSelectorData, ExprResult>;
 

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > I would like to avoid the Any type here and I hope we can if we don't 
> > > > > allow "strings". See also my last comment.
> > > > The only possible solution I see here is to convert kind/vendor strings 
> > > > into exprs and store all data as `Expr *`
> > > Should we define a struct to be used as variant here maybe? If we only 
> > > have <5 different types we might not want to go to Any or Expr directly.
> > What is the difference between using Any and a struct?
> Any is generic (anything).
> Having a variant (std::variant or self build struct with 2 constructors) 
> specifies what the components can be.
> 
It is not quite so. Anyway, I'm going to switch to Expr* since it is the only 
possible way to represent traits as identifiers/string literals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



___
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-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:9320
   using OMPCtxSelectorData =
-  OpenMPCtxSelectorData, ExprResult>;
+  OpenMPCtxSelectorData, ExprResult>;
 

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > I would like to avoid the Any type here and I hope we can if we don't 
> > > > allow "strings". See also my last comment.
> > > The only possible solution I see here is to convert kind/vendor strings 
> > > into exprs and store all data as `Expr *`
> > Should we define a struct to be used as variant here maybe? If we only have 
> > <5 different types we might not want to go to Any or Expr directly.
> What is the difference between using Any and a struct?
Any is generic (anything).
Having a variant (std::variant or self build struct with 2 constructors) 
specifies what the components can be.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

The attribute bits LGTM aside from a wording nit with the diagnostic; I have no 
opinion on the CodeGen question.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10080
+  "template parameter of a function template with the 'sycl_kernel' attribute"
+  " can't be a non-type template parameter">, InGroup;
+def warn_sycl_kernel_num_of_function_params : Warning<

`can't` -> `cannot`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70253: [AArch64][SVE2] Implement remaining SVE2 floating-point intrinsics

2019-11-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:898
+ llvm_i32_ty],
+[IntrNoMem]>;
+

kmclaughlin wrote:
> sdesmalen wrote:
> > I'd expect the `llvm_i32_ty` to be an immediate for these instructions, 
> > right? If so you'll need to add `ImmArg`  to the list of properties.
> > 
> Thanks for taking a look at this :) I tried your suggestion of adding 
> ImmAr to the list of properties here but had some problems with it (i.e. 
> Cannot select: intrinsic %llvm.aarch64.sve.fmlalb.lane). I don't think this 
> is too much of an issue here as we have additional checks on the immediate 
> with VectorIndexH32b, which ensures the immediate is in the correct range.
The point of immarg markings isn't to assist the backend; it's to ensure IR 
optimizations don't break your intrinsic calls.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70253



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


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

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



Comment at: clang/include/clang/Basic/Attr.td:3445
+  let Spellings = [Clang<"acquire_handle">];
+  let Subjects = SubjectList<[Function, ParmVar], ErrorDiag>;
+  let Documentation = [AcquireHandleDocs];

xazax.hun wrote:
> xazax.hun wrote:
> > aaron.ballman wrote:
> > > xazax.hun wrote:
> > > > aaron.ballman wrote:
> > > > > What about function-like interfaces such as lambdas, blocks, or other 
> > > > > callable objects that are not a `FunctionDecl`?
> > > > Good point!
> > > This get you partway there -- `FunctionLike` allows functions and 
> > > function pointers, but I don't think it allows lambdas or blocks. You 
> > > should add some test cases for all of these (including function pointers) 
> > > to verify you're able to mark the entities you want and get the behavior 
> > > you're after.
> > > 
> > > For instance, on function pointers and lambdas, this may impact the 
> > > function *type* which is a good design question to be thinking about. 
> > > What should happen with code like:
> > > ```
> > > [[clang::acquire_handle]] void int open(const char *);
> > > int (*fp)(const char *) = open;
> > > ```
> > > If the attribute is a type attribute as opposed to a declaration 
> > > attribute, then you can think about diagnostics in these sort of cases. 
> > > However, if it is a type attribute, there is more work involved in 
> > > hooking it up to the type system.
> > > 
> > > FWIW, this attribute smells like it should be a type attribute rather 
> > > than a declaration attribute because I can imagine wanting to use this 
> > > with function pointers and not losing the analysis capabilities (esp for 
> > > things like callback functions).
> > I see your point. I have, however, some concerns making this part of the 
> > type system. I think it would be great to let the users add the annotations 
> > gradually without any diagnostic. For example:
> > 
> > ```
> > void my_function_with_callback( int (*callback)(int 
> > __attribute__((handle_use)) );
> > 
> > ...
> > 
> > my_function_with_callback(already_annotated);
> > my_function_with_callback(not_yet_annotated); // Do we intend to give a 
> > diagnostics here?
> > ```
> > 
> > What do you think?
> After some digging it looks like I cannot apply any attributes to lambdas. 
> For example, you cannot even add `[[noreturn]]` to a lambda, because the 
> language only supports type attributes in that position.
> After some digging it looks like I cannot apply any attributes to lambdas.

That's what got me thinking about making this a type attribute instead. It 
would be a shame for you to not be able to mark lambdas.

> I have, however, some concerns making this part of the type system.

Understandable -- type attributes are not much fun. ;-) I think your concern is 
justified, but you have the control to allow or disallow whatever you'd like in 
terms of the semantics of the type attribute. Personally, I would want that use 
case to give a diagnostic because that use may close the handle, for instance. 
Or it could be creating/releasing a handle instead of just using one, etc.

For instance, one idea (and it may not be a good one) is that you could 
diagnose any implicit conversion between the function pointer types, but still 
allow explicit conversion between them. This gives users a transition path -- 
they can explicitly add the type cast in the places they've not yet got the 
annotations added yet. They could even use a macro to perform the cast, giving 
them a handy marker of what code still needs to be fixed.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6524
+  if (auto *PVD = dyn_cast(D)) {
+if (PVD->getType()->isIntegerType()) {
+  S.Diag(AL.getLoc(), diag::err_attribute_output_parameter)

xazax.hun wrote:
> aaron.ballman wrote:
> > I'm skeptical of this. I think a better check is if the type is a pointer 
> > or reference -- was there a reason you didn't go with that approach?
> The reason why I do not want to restrict this to pointers and references is 
> that the users might have a custom wrapper type to deal with handles that 
> might be passed by value. Or the user might pass an iterator by value which 
> points to a handle.  These are not extremely likely, but I did not want to 
> diagnose those cases. What do you think?
I guess I was envisioning the value type being the issue, but I suppose you 
could have some sort of reference-counted object where the copy is not 
problematic. But this is still a bit of a strange constraint -- it disallows 
putting it on an integer parameter type, but not, say a float or a `const char 
*`?

Have you considered requiring the handle type to be annotated itself, so that 
you can verify the parameter is actually a handle as opposed to a mistake?


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

https://reviews.llvm.org/D70469



___

[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2019-11-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/altera/IdDependentBackwardBranchCheck.cpp:115
+IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
+  if (const MemberExpr *MemberExpression = dyn_cast(Expression)) {
+const FieldDecl *CheckField =

May be comments were shifted with code, but here const auto * could be used, 
because type is spelled in dyn_cast<>.



Comment at: clang-tidy/altera/IdDependentBackwardBranchCheck.cpp:116
+  if (const MemberExpr *MemberExpression = dyn_cast(Expression)) {
+const FieldDecl *CheckField =
+dyn_cast(MemberExpression->getMemberDecl());

May be comments were shifted with code, but here const auto * could be used, 
because type is spelled in dyn_cast<>.



Comment at: clang-tidy/altera/IdDependentBackwardBranchCheck.cpp:124
+  }
+  for (const Stmt *Child : Expression->children()) {
+if (const Expr *ChildExpression = dyn_cast(Child)) {

May be comments were shifted with code, but here const auto * could be used, 
because type is iterator.



Comment at: clang-tidy/altera/IdDependentBackwardBranchCheck.cpp:125
+  for (const Stmt *Child : Expression->children()) {
+if (const Expr *ChildExpression = dyn_cast(Child)) {
+  IdDependencyRecord *Result = hasIdDepField(ChildExpression);

May be comments were shifted with code, but here const auto * could be used, 
because type is spelled in dyn_cast<>.



Comment at: clang-tidy/altera/IdDependentBackwardBranchCheck.cpp:165
+  if (RefExpr) {
+const auto RefVar = dyn_cast(RefExpr->getDecl());
+// If variable isn't ID-dependent, but RefVar is.

const auto *. Same in other dyn_cast<>.


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

https://reviews.llvm.org/D70094



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


[PATCH] D70764: build: reduce CMake handling for zlib

2019-11-27 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@labath I think you are misunderstanding the patch.  This is not autoselecting 
the dependencies.  It is simply doing that based on an existing option that we 
have - `LLVM_ENABLE_ZLIB`.  We could always search for zlib and override the 
results with `LLVM_ENABLE_ZLIB` as well.  The current build will continue to 
just work - zlib is used only for the compressed debug sections (which requires 
the user to opt-in).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70764



___
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-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:9320
   using OMPCtxSelectorData =
-  OpenMPCtxSelectorData, ExprResult>;
+  OpenMPCtxSelectorData, ExprResult>;
 

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > I would like to avoid the Any type here and I hope we can if we don't 
> > > allow "strings". See also my last comment.
> > The only possible solution I see here is to convert kind/vendor strings 
> > into exprs and store all data as `Expr *`
> Should we define a struct to be used as variant here maybe? If we only have 
> <5 different types we might not want to go to Any or Expr directly.
What is the difference between using Any and a struct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



___
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-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:9320
   using OMPCtxSelectorData =
-  OpenMPCtxSelectorData, ExprResult>;
+  OpenMPCtxSelectorData, ExprResult>;
 

ABataev wrote:
> jdoerfert wrote:
> > I would like to avoid the Any type here and I hope we can if we don't allow 
> > "strings". See also my last comment.
> The only possible solution I see here is to convert kind/vendor strings into 
> exprs and store all data as `Expr *`
Should we define a struct to be used as variant here maybe? If we only have <5 
different types we might not want to go to Any or Expr directly.



Comment at: clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp:48
+
+#pragma omp declare variant(foo) match(device = {isa("nvptx64")})
+int bar() { return 1; }

ABataev wrote:
> jdoerfert wrote:
> > I'm not sure we want these to be strings. I would have assumed 
> > `isa(nvptx64)`, similar to `vendor(arm)`, or `kind(host)` and `kind(gpu)`
> Here is the message from Joachim Protze:
> ```
> vendor and kind are special, because we define the kind-name and 
> vendor-name in the context definition side document. (We could change 
> that to "kind-name" or define kind-name as any of "cpu", "gpu", "fpga" ???)
> 
> For the others, according to the syntax diagram in the OpenMP Context 
> section, the content of the () can only be string or const-int-exp.
> 
> - Joachim
> ```
> That's why we need to represent them as strings, this is per OpenMP standard.
While you say it, I wanted to mention that we moved the discussion on the 
openmp-lang list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2019-11-27 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 231309.
ffrankies added a comment.

Implemented changes requested by @Eugene.Zelenko

Also changed for loop in `hasIdDepVar` and `hasIdDepField` to range-based for 
loops, and updated the license information in IdDependentBackwardBranchCheck.cpp


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

https://reviews.llvm.org/D70094

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/altera/AlteraTidyModule.cpp
  clang-tidy/altera/CMakeLists.txt
  clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
  clang-tidy/altera/IdDependentBackwardBranchCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp

Index: test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===
--- /dev/null
+++ test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -0,0 +1,83 @@
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+
+typedef struct ExampleStruct {
+  int IDDepField;
+} ExampleStruct;
+
+void error() {
+  //  Assignments 
+  int ThreadID = get_local_id(0); 
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: assignment of ID-dependent variable ThreadID [altera-id-dependent-backward-branch]
+
+  ExampleStruct Example;
+  Example.IDDepField = get_local_id(0);
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: assignment of ID-dependent field IDDepField [altera-id-dependent-backward-branch]
+
+  //  Inferred Assignments 
+  int ThreadID2 = ThreadID * get_local_size(0);
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: inferred assignment of ID-dependent value from ID-dependent variable ThreadID [altera-id-dependent-backward-branch]
+  
+  int ThreadID3 = Example.IDDepField;  // OK: not used in any loops
+
+  ExampleStruct UnusedStruct = {
+ThreadID * 2  // OK: not used in any loops
+  };
+
+  //  Conditional Expressions 
+  int accumulator = 0;
+  for (int i = 0; i < get_local_id(0); i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  int j = 0;
+  while (j < get_local_id(0)) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < get_local_id(0));
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+  
+  for (int i = 0; i < ThreadID2; i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to variable reference to 'ThreadID2' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < ThreadID) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < ThreadID);
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+  
+  for (int i = 0; i < Example.IDDepField; i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < Example.IDDepField) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < Example.IDDepField);
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+}
+
+void success() {
+  int accumulator = 0;
+
+  for (int i = 0; i < 1000; i++) {
+if (i < get_local_id(0)) {
+  accumulator++;
+}
+  }
+}
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -59,6 +59,7 @@
 == =
 

[PATCH] D70071: [ConstExprPreter] Removed the flag forcing the use of the interpreter

2019-11-27 Thread Nandor Licker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf584f04dab69: [ConstExprPreter] Removed the flag forcing the 
use of the interpreter (authored by nand).

Changed prior to commit:
  https://reviews.llvm.org/D70071?vs=230791=231310#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70071

Files:
  clang/docs/ConstantInterpreter.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Context.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/AST/Interp/cond.cpp

Index: clang/test/AST/Interp/cond.cpp
===
--- clang/test/AST/Interp/cond.cpp
+++ clang/test/AST/Interp/cond.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fforce-experimental-new-constant-interpreter %s -verify
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -fexperimental-new-constant-interpreter %s -verify
 // RUN: %clang_cc1 -std=c++17 -fsyntax-only %s -verify
 // expected-no-diagnostics
 
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2854,8 +2854,6 @@
   getLastArgIntValue(Args, OPT_fconstexpr_steps, 1048576, Diags);
   Opts.EnableNewConstInterp =
   Args.hasArg(OPT_fexperimental_new_constant_interpreter);
-  Opts.ForceNewConstInterp =
-  Args.hasArg(OPT_fforce_experimental_new_constant_interpreter);
   Opts.BracketDepth = getLastArgIntValue(Args, OPT_fbracket_depth, 256, Diags);
   Opts.DelayedTemplateParsing = Args.hasArg(OPT_fdelayed_template_parsing);
   Opts.NumLargeByValueCopy =
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4503,9 +4503,6 @@
   if (Args.hasArg(options::OPT_fexperimental_new_constant_interpreter))
 CmdArgs.push_back("-fexperimental-new-constant-interpreter");
 
-  if (Args.hasArg(options::OPT_fforce_experimental_new_constant_interpreter))
-CmdArgs.push_back("-fforce-experimental-new-constant-interpreter");
-
   if (Arg *A = Args.getLastArg(options::OPT_fbracket_depth_EQ)) {
 CmdArgs.push_back("-fbracket-depth");
 CmdArgs.push_back(A->getValue());
Index: clang/lib/AST/Interp/Context.h
===
--- clang/lib/AST/Interp/Context.h
+++ clang/lib/AST/Interp/Context.h
@@ -34,16 +34,6 @@
 class State;
 enum PrimType : unsigned;
 
-/// Wrapper around interpreter termination results.
-enum class InterpResult {
-  /// Interpreter successfully computed a value.
-  Success,
-  /// Interpreter encountered an error and quit.
-  Fail,
-  /// Interpreter encountered an unimplemented feature, AST fallback.
-  Bail,
-};
-
 /// Holds all information required to evaluate constexpr code in a module.
 class Context {
 public:
@@ -54,15 +44,13 @@
   ~Context();
 
   /// Checks if a function is a potential constant expression.
-  InterpResult isPotentialConstantExpr(State ,
-   const FunctionDecl *FnDecl);
+  bool isPotentialConstantExpr(State , const FunctionDecl *FnDecl);
 
   /// Evaluates a toplevel expression as an rvalue.
-  InterpResult evaluateAsRValue(State , const Expr *E, APValue );
+  bool evaluateAsRValue(State , const Expr *E, APValue );
 
   /// Evaluates a toplevel initializer.
-  InterpResult evaluateAsInitializer(State , const VarDecl *VD,
- APValue );
+  bool evaluateAsInitializer(State , const VarDecl *VD, APValue );
 
   /// Returns the AST context.
   ASTContext () const { return Ctx; }
@@ -78,16 +66,14 @@
 
 private:
   /// Runs a function.
-  InterpResult Run(State , Function *Func, APValue );
+  bool Run(State , Function *Func, APValue );
 
   /// Checks a result fromt the interpreter.
-  InterpResult Check(State , llvm::Expected &);
+  bool Check(State , llvm::Expected &);
 
 private:
   /// Current compilation context.
   ASTContext 
-  /// Flag to indicate if the use of the interpreter is mandatory.
-  bool ForceInterp;
   /// Interpreter stack, shared across invocations.
   InterpStack Stk;
   /// Constexpr program.
Index: clang/lib/AST/Interp/Context.cpp
===
--- clang/lib/AST/Interp/Context.cpp
+++ clang/lib/AST/Interp/Context.cpp
@@ -21,44 +21,37 @@
 using namespace clang;
 using namespace clang::interp;
 
-Context::Context(ASTContext )
-: Ctx(Ctx), ForceInterp(getLangOpts().ForceNewConstInterp),
-  P(new Program(*this)) {}
+Context::Context(ASTContext ) : Ctx(Ctx), P(new Program(*this)) {}
 
 

[clang] f584f04 - [ConstExprPreter] Removed the flag forcing the use of the interpreter

2019-11-27 Thread Nandor Licker via cfe-commits

Author: Nandor Licker
Date: 2019-11-27T20:07:19Z
New Revision: f584f04dab69ab15c8942753a145f0c6e7693bcc

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

LOG: [ConstExprPreter] Removed the flag forcing the use of the interpreter

Summary:
Removed the ```-fforce-experimental-new-constant-interpreter flag```, leaving
only the ```-fexperimental-new-constant-interpreter``` one. The interpreter
now always emits an error on an unsupported feature.

Allowing the interpreter to bail out would require a mapping from APValue to
interpreter memory, which will not be necessary in the final version. It is
more sensible to always emit an error if the interpreter fails.

Reviewers: jfb, Bigcheese, rsmith, dexonsmith

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/ConstantInterpreter.rst
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Interp/Context.cpp
clang/lib/AST/Interp/Context.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/AST/Interp/cond.cpp

Removed: 




diff  --git a/clang/docs/ConstantInterpreter.rst 
b/clang/docs/ConstantInterpreter.rst
index d4fb8f6f34aa..a86161c8fa01 100644
--- a/clang/docs/ConstantInterpreter.rst
+++ b/clang/docs/ConstantInterpreter.rst
@@ -10,8 +10,7 @@ Introduction
 
 The constexpr interpreter aims to replace the existing tree evaluator in 
clang, improving performance on constructs which are executed inefficiently by 
the evaluator. The interpreter is activated using the following flags:
 
-* ``-fexperimental-new-constant-interpreter`` enables the interpreter, falling 
back to the evaluator for unsupported features
-* ``-fforce-experimental-new-constant-interpreter`` forces the use of the 
interpreter, bailing out if an unsupported feature is encountered
+* ``-fexperimental-new-constant-interpreter`` enables the interpreter, 
emitting an error if an unsupported feature is encountered
 
 Bytecode Compilation
 

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 82bf379af909..68d6ee1dce42 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -297,8 +297,6 @@ BENIGN_LANGOPT(ConstexprStepLimit, 32, 1048576,
"maximum constexpr evaluation steps")
 BENIGN_LANGOPT(EnableNewConstInterp, 1, 0,
"enable the experimental new constant interpreter")
-BENIGN_LANGOPT(ForceNewConstInterp, 1, 0,
-   "force the use of the experimental new constant interpreter")
 BENIGN_LANGOPT(BracketDepth, 32, 256,
"maximum bracket nesting depth")
 BENIGN_LANGOPT(NumLargeByValueCopy, 32, 0,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2d501c09c762..daba98a39dab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -850,8 +850,6 @@ def fconstexpr_depth_EQ : Joined<["-"], 
"fconstexpr-depth=">, Group;
 def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group;
 def fexperimental_new_constant_interpreter : Flag<["-"], 
"fexperimental-new-constant-interpreter">, Group,
   HelpText<"Enable the experimental new constant interpreter">, 
Flags<[CC1Option]>;
-def fforce_experimental_new_constant_interpreter : Flag<["-"], 
"fforce-experimental-new-constant-interpreter">, Group,
-  HelpText<"Force the use of the experimental new constant interpreter, 
failing on missing features">, Flags<[CC1Option]>;
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index eec9bbdaef80..df80cb4f9440 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -763,11 +763,8 @@ namespace {
 /// we will evaluate.
 unsigned StepsLeft;
 
-/// Force the use of the experimental new constant interpreter, bailing out
-/// with an error if a feature is not supported.
-bool ForceNewConstInterp;
-
-/// Enable the experimental new constant interpreter.
+/// Enable the experimental new constant interpreter. If an expression is
+/// not supported by the interpreter, an error is triggered.
 bool EnableNewConstInterp;
 
 /// BottomFrame - The frame in which evaluation started. This must be
@@ -922,9 +919,7 @@ namespace {
 : Ctx(const_cast(C)), EvalStatus(S), 

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

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:3445
+  let Spellings = [Clang<"acquire_handle">];
+  let Subjects = SubjectList<[Function, ParmVar], ErrorDiag>;
+  let Documentation = [AcquireHandleDocs];

aaron.ballman wrote:
> xazax.hun wrote:
> > aaron.ballman wrote:
> > > What about function-like interfaces such as lambdas, blocks, or other 
> > > callable objects that are not a `FunctionDecl`?
> > Good point!
> This get you partway there -- `FunctionLike` allows functions and function 
> pointers, but I don't think it allows lambdas or blocks. You should add some 
> test cases for all of these (including function pointers) to verify you're 
> able to mark the entities you want and get the behavior you're after.
> 
> For instance, on function pointers and lambdas, this may impact the function 
> *type* which is a good design question to be thinking about. What should 
> happen with code like:
> ```
> [[clang::acquire_handle]] void int open(const char *);
> int (*fp)(const char *) = open;
> ```
> If the attribute is a type attribute as opposed to a declaration attribute, 
> then you can think about diagnostics in these sort of cases. However, if it 
> is a type attribute, there is more work involved in hooking it up to the type 
> system.
> 
> FWIW, this attribute smells like it should be a type attribute rather than a 
> declaration attribute because I can imagine wanting to use this with function 
> pointers and not losing the analysis capabilities (esp for things like 
> callback functions).
I see your point. I have, however, some concerns making this part of the type 
system. I think it would be great to let the users add the annotations 
gradually without any diagnostic. For example:

```
void my_function_with_callback( int (*callback)(int __attribute__((handle_use)) 
);

...

my_function_with_callback(already_annotated);
my_function_with_callback(not_yet_annotated); // Do we intend to give a 
diagnostics here?
```

What do you think?



Comment at: clang/include/clang/Basic/Attr.td:3445
+  let Spellings = [Clang<"acquire_handle">];
+  let Subjects = SubjectList<[Function, ParmVar], ErrorDiag>;
+  let Documentation = [AcquireHandleDocs];

xazax.hun wrote:
> aaron.ballman wrote:
> > xazax.hun wrote:
> > > aaron.ballman wrote:
> > > > What about function-like interfaces such as lambdas, blocks, or other 
> > > > callable objects that are not a `FunctionDecl`?
> > > Good point!
> > This get you partway there -- `FunctionLike` allows functions and function 
> > pointers, but I don't think it allows lambdas or blocks. You should add 
> > some test cases for all of these (including function pointers) to verify 
> > you're able to mark the entities you want and get the behavior you're after.
> > 
> > For instance, on function pointers and lambdas, this may impact the 
> > function *type* which is a good design question to be thinking about. What 
> > should happen with code like:
> > ```
> > [[clang::acquire_handle]] void int open(const char *);
> > int (*fp)(const char *) = open;
> > ```
> > If the attribute is a type attribute as opposed to a declaration attribute, 
> > then you can think about diagnostics in these sort of cases. However, if it 
> > is a type attribute, there is more work involved in hooking it up to the 
> > type system.
> > 
> > FWIW, this attribute smells like it should be a type attribute rather than 
> > a declaration attribute because I can imagine wanting to use this with 
> > function pointers and not losing the analysis capabilities (esp for things 
> > like callback functions).
> I see your point. I have, however, some concerns making this part of the type 
> system. I think it would be great to let the users add the annotations 
> gradually without any diagnostic. For example:
> 
> ```
> void my_function_with_callback( int (*callback)(int 
> __attribute__((handle_use)) );
> 
> ...
> 
> my_function_with_callback(already_annotated);
> my_function_with_callback(not_yet_annotated); // Do we intend to give a 
> diagnostics here?
> ```
> 
> What do you think?
After some digging it looks like I cannot apply any attributes to lambdas. For 
example, you cannot even add `[[noreturn]]` to a lambda, because the language 
only supports type attributes in that position.


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

https://reviews.llvm.org/D70469



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


[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-11-27 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM, but it might be good to wait with committing until next week, so people 
in the US have a chance to take a look as well.




Comment at: clang/lib/Driver/ToolChains/Arch/AArch64.cpp:143
 MtuneLowerCase = llvm::sys::getHostCPUName();
-  if (MtuneLowerCase == "cyclone") {
+  if (MtuneLowerCase == "cyclone" || MtuneLowerCase.find("apple") == 0) {
 Features.push_back("+zcm");

It might be slightly more obvious to use MtuneLowerCAse.StartsWith("apple")


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

https://reviews.llvm.org/D70779



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


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

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 231307.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Address review comments.


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

https://reviews.llvm.org/D70469

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-handles.cpp

Index: clang/test/Sema/attr-handles.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-handles.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1  -fsyntax-only -verify %s
+
+void f(int *a __attribute__((acquire_handle)));
+void (*fp)(int handle [[clang::use_handle]]);
+auto lambda = [](int handle [[clang::use_handle]]){};
+void g(int a __attribute__((acquire_handle))); // expected-error {{attribute only applies to output parameters}}
+void h(int *a __attribute__((acquire_handle(1; // expected-error {{'acquire_handle' attribute takes no arguments}}
+__attribute__((release_handle)) int i(); // expected-warning {{'release_handle' attribute only applies to parameters}}
+__attribute__((use_handle)) int j(); // expected-warning {{'use_handle' attribute only applies to parameters}}
+int a __attribute__((acquire_handle)); // expected-warning {{'acquire_handle' attribute only applies to functions, function pointers, and parameters}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -9,6 +9,7 @@
 // CHECK-NEXT: AMDGPUWavesPerEU (SubjectMatchRule_function)
 // CHECK-NEXT: AVRSignal (SubjectMatchRule_function)
 // CHECK-NEXT: AbiTag (SubjectMatchRule_record_not_is_union, SubjectMatchRule_variable, SubjectMatchRule_function, SubjectMatchRule_namespace)
+// CHECK-NEXT: AcquireHandle (SubjectMatchRule_hasType_functionType, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: Alias (SubjectMatchRule_function, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: AlignValue (SubjectMatchRule_variable, SubjectMatchRule_type_alias)
 // CHECK-NEXT: AllocSize (SubjectMatchRule_function)
@@ -128,6 +129,7 @@
 // CHECK-NEXT: ParamTypestate (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: PassObjectSize (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: Pointer (SubjectMatchRule_record_not_is_union)
+// CHECK-NEXT: ReleaseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: RenderScriptKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ReqdWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: Restrict (SubjectMatchRule_function)
@@ -145,6 +147,7 @@
 // CHECK-NEXT: Target (SubjectMatchRule_function)
 // CHECK-NEXT: TestTypestate (SubjectMatchRule_function_is_member)
 // CHECK-NEXT: TrivialABI (SubjectMatchRule_record)
+// CHECK-NEXT: UseHandle (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: VecReturn (SubjectMatchRule_record)
 // CHECK-NEXT: VecTypeHint (SubjectMatchRule_function)
 // CHECK-NEXT: WarnUnused (SubjectMatchRule_record)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6540,6 +6540,18 @@
   handleSimpleAttribute(S, D, AL);
 }
 
+static void handeAcquireHandleAttr(Sema , Decl *D, const ParsedAttr ) {
+  // Warn if the parameter is definitely not an output parameter.
+  if (const auto *PVD = dyn_cast(D)) {
+if (PVD->getType()->isIntegerType()) {
+  S.Diag(AL.getLoc(), diag::err_attribute_output_parameter)
+  << AL.getRange();
+  return;
+}
+  }
+  handleSimpleAttribute(S, D, AL);
+}
+
 //===--===//
 // Top Level Sema Entry Points
 //===--===//
@@ -7311,6 +7323,16 @@
   case ParsedAttr::AT_ArmMveAlias:
 handleArmMveAliasAttr(S, D, AL);
 break;
+
+  case ParsedAttr::AT_AcquireHandle:
+handeAcquireHandleAttr(S, D, AL);
+break;
+  case ParsedAttr::AT_ReleaseHandle:
+handleSimpleAttribute(S, D, AL);
+break;
+  case ParsedAttr::AT_UseHandle:
+handleSimpleAttribute(S, D, AL);
+break;
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3101,6 +3101,8 @@
 def err_cconv_incomplete_param_type : Error<
   "parameter %0 must have a complete type to use function %1 with the %2 "
   "calling convention">;
+def err_attribute_output_parameter : Error<
+  "attribute only applies to output parameters">;
 
 

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

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:6524
+  if (auto *PVD = dyn_cast(D)) {
+if (PVD->getType()->isIntegerType()) {
+  S.Diag(AL.getLoc(), diag::err_attribute_output_parameter)

aaron.ballman wrote:
> I'm skeptical of this. I think a better check is if the type is a pointer or 
> reference -- was there a reason you didn't go with that approach?
The reason why I do not want to restrict this to pointers and references is 
that the users might have a custom wrapper type to deal with handles that might 
be passed by value. Or the user might pass an iterator by value which points to 
a handle.  These are not extremely likely, but I did not want to diagnose those 
cases. What do you think?


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

https://reviews.llvm.org/D70469



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


[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

2019-11-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D65591#1625744 , @aaron.ballman 
wrote:

> In D65591#1625228 , @ilya-biryukov 
> wrote:
>
> > We can also assume they're cheap, use the visitor-based implementation and 
> > later switch if this turn out to be a problem.
> >  I think we should prefer the approach that guarantees the compiler is not 
> > getting slow ever rather than chase the slowness later.
>
>
> The problem is: those bits are not infinite and we only have a handful left 
> until bumping the allocation size; is this use case critical enough to use 
> one of those bits?


In the abstract, improving error recovery and toolability are among the more 
important things we could do, and it certainly seems worth spending a bit on 
every `Expr` on this to me, if there's no better alternative. (That is: I think 
this approach is OK if we don't find something better.)

It's not obvious to me whether recomputing this information by AST traversal 
would be fast enough: *if* we want to perform the "does this contain errors?" 
check from contexts we encounter frequently (eg, when deciding whether to 
produce warnings, whether we should skip certain semantic actions, and 
similar), we can't do that if it requires a traversal.

In D65591#1626969 , @aaron.ballman 
wrote:

> In D65591#1626638 , @ilya-biryukov 
> wrote:
>
> > Alternatively, we could keep an equivalent of `set InvalidExprs` in 
> > `ASTContext`. Gives the same computational complexity, but has a higher 
> > constant overhead factor.
> >  Does that look reasonable?
>
>
> Yup, that is also very reasonable.


I think this will be very expensive from a maintenance (and potentially 
performance) perspective: every constructor for every expression node will need 
to check whether its subexpressions are in the set, and if so, add themselves 
to the set.

As a variant on this, we could build a `map` to track whether each 
expression is known to contain errors, or known to not contain errors, populate 
it lazily when queried, and shortcut the whole mechanism if we've never created 
an error node. That still seems a little expensive, but at least we'd only pay 
the cost for invalid programs. If we could produce a dense numbering of 
`Expr`s, this'd suddenly seem pretty good, though, and we know that `Expr`s are 
allocated on the `ASTContext`'s bump allocator, so maybe there's something we 
can do there...

Another option is to represent "contains an error" with a specific `Type`. 
This'd mean we'd not preserve type information in less-common cases such as:  
`f( T(some-erroneous-expression) )`, and wouldn't be able to diagnose if 
there's no function `f` that takes a `T`, but I think that's an acceptable 
loss. The downside is that we would need logic to create representations with 
the appropriate "contains an error" type throughout `Sema` -- everywhere where 
we create nodes with dependent types, plus some additional cases like cast 
expressions that are never type-dependent (but can contain errors).

Here's my current thinking:

- Using dependence to model "contains errors" is a mistake. We should stop 
doing that.
- We therefore need a different type to indicate "couldn't determine the type 
of this because it contains errors", and should add a new builtin type for that.
- In cases like `int( thing-containing-errors )`, it's probably completely fine 
that we can't determine whether the expression contains errors, and we 
shouldn't provide an interface to ask that question. (The current flag bit 
doesn't help with that anyway, since the errors could be nested indirectly, say 
inside a lambda, and we don't propagate the flag through that.)

So my proposal would be: stop trying to track whether expressions contain 
errors. Instead, add a builtin type to indicate whether the type of an 
expression couldn't be determined due to an error, and propagate that in the 
same way we propagate type-dependence. Would that address the use cases here?

> I'm not certain there are real problems there, but I am wondering whether 
> something like a BMI should include serialized error AST nodes or not. Would 
> a consumer of the module expect that? I suppose it could if we wanted it to.

We already do preserve invalid AST through AST files if we're asked to do so; 
this isn't new. (For example, the `Invalid` flag on `Decl`s is preserved.) This 
is important for some tooling scenarios: you want to be able to produce and use 
a precompiled preamble even if it contains errors.

> Ah, drat, I was hoping we had at least one test that already did this, but I 
> don't see one.

Maybe we should introduce a `__builtin_dump(expr)` function that dumps its 
operand at the point where semantic analysis is first done? That'd be useful 
for other things too (`#pragma clang __debug dump X` is a little unwieldy).


Repository:
  rG LLVM Github 

[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D70791#1762155 , @rnk wrote:

> My version of cl.exe claims to have version 19.23.28107 and my headers are in 
> Tools/MSVC/14.23.28105/include, and I see that this is fixed in xtr1common. 
> is_integral_v and the helpers are defined with implicit template 
> instantiations. There are no fully specialized template definitions in that 
> header. So, my hope is that this problem will go away as users run the VS 
> updater. Although, for buildbots and users such as myself who rarely start 
> the IDE, that may take longer than we'd like.


Ah, I see!  I have no idea what that version is unfortunately... 14.23 is just 
16.3 I think, but no idea which of the _10_ sub releases that is 
(https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes).  
My tester claims to have a completely up to date version, but I'll have them 
check.


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

https://reviews.llvm.org/D70791



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


[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

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

My version of cl.exe claims to have version 19.23.28107 and my headers are in 
Tools/MSVC/14.23.28105/include, and I see that this is fixed in xtr1common. 
is_integral_v and the helpers are defined with implicit template 
instantiations. There are no fully specialized template definitions in that 
header. So, my hope is that this problem will go away as users run the VS 
updater. Although, for buildbots and users such as myself who rarely start the 
IDE, that may take longer than we'd like.


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

https://reviews.llvm.org/D70791



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


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

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

So after investigating the effects of this patch, the result is the following:

Verbose mode (`-v`) that also prints findings to the command line will no 
longer be colored after the patch. If we do not want this regression there are 
two easy ways around it:

1. Make the parsing of error more forgiving
2. Make two `-###` invocation, one for parsing the potential error and the 
other for actually getting the arguments.

Any preferences?


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] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2019-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D69746#1756448 , @gribozavr2 wrote:

> The only way I know people apply fixits is with the help of IDEs.


This depends on the infrastructure available. Talking specifically about 
clang-tidy in our environment, I know of at least three other modes that are 
being frequently used:

- in a code review tool (allows to apply manually selected fixes one-by-one);
- in a code browsing tool (allows to apply manually selected fixes or all fixes 
of a certain category - e.g. from performance-related checks - to a file or 
directory);
- a script that applies pre-generated fixes to a set of files or all repository.

> I am also skeptical that people want to apply *all* fixits. Usually people 
> want to pick a few specific ones, or all fixits of a certain kind; but not 
> everything.

While "all fixits" may be not particularly useful, "apply all fixes enabled for 
my project" is a reasonable function when the project is generally kept in a 
clean shape.


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

https://reviews.llvm.org/D69746



___
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-27 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c5e860535d8: [clang-tidy] Fix PR35824 (authored by 
xazax.hun).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D46027?vs=231078=231301#toc

Repository:
  rG LLVM Github Monorepo

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,31 @@
+// 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;
+}
+
+template 
+int foo2(int a) {
+// FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
+// for details.
+if constexpr(X > 0);
+return a;
+return a + 1;
+}
+
+int main(void) {
+foo2<0>(1);
+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,31 @@
+// 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;
+}
+
+template 
+int foo2(int a) {
+// FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
+// for details.
+if constexpr(X > 0);
+return a;
+return a + 1;
+}
+
+int main(void) {
+foo2<0>(1);
+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] D46234: Mark if a null statement is the result of constexpr folding

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.
Herald added subscribers: Charusso, gamesh411, Szelethus.
Herald added a project: clang.

Just a note for anyone willing to pick this up, PR32203 is also related.


Repository:
  rC Clang

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

https://reviews.llvm.org/D46234



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


[clang-tools-extra] 5c5e860 - [clang-tidy] Fix PR35824

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

Author: Gabor Horvath
Date: 2019-11-27T11:07:16-08:00
New Revision: 5c5e860535d8924a3d6eb950bb8a4945df01e9b7

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

LOG: [clang-tidy] Fix PR35824

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

Added: 

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

Modified: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
index d94731beba94..9b34f5ab55a7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -20,7 +20,8 @@ namespace bugprone {
 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")

diff  --git 
a/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp 
b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
new file mode 100644
index ..c18dd7bd1e93
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
@@ -0,0 +1,31 @@
+// 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;
+}
+
+template 
+int foo2(int a) {
+// FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
+// for details.
+if constexpr(X > 0);
+return a;
+return a + 1;
+}
+
+int main(void) {
+foo2<0>(1);
+return foo<0>(1);
+}



___
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-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:4108
+  NewToType = Context.getPointerType(NewToType);
+}
+

Hmm, sorry, just noticed this.  Could you write this so that it preserves the 
original kind of pointer of `ToType`?  I think it has to be a `PointerType`, 
`BlockPointerType,` or `ObjCObjectPointerType`.  It doesn't look like there's 
an existing utility for that.


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] D60455: [SYCL] Implement SYCL device code outlining

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



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

bader wrote:
> ABataev wrote:
> > bader wrote:
> > > ABataev wrote:
> > > > Need to check if the decl must be emitted at all.
> > > Let me check that I get it right. You suggest adding `if 
> > > (MustBeEmitted(Global))`, right?
> > > ```
> > >   if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
> > > MustBeEmitted(Global)) {
> > > ...
> > > addDeferredDeclToEmit(GD);
> > > return;
> > >   }
> > > ```
> > Yes
> Okay. Making this change requires additional adjustments in the patch and I 
> have a few options.
> In this patch we do not add any logic forcing compiler to emit SYCL kernel. 
> This logic is supposed to be added by follow-up patch (currently under SYCL 
> working group review here https://github.com/intel/llvm/pull/249), which add 
> code emitting "externally visible" OpenCL kernel calling function object 
> passed to SYCL kernel function.
> 
> I can:
> 1) Temporally remove CodeGen test and add updated version back with the 
> follow-up patch
> 2) Do change making SYCL kernels "externally visible" and revert this change 
> with the follow-up patch (this is kind of current logic which emits SYCL 
> kernels unconditionally)
> 3) Merge two patches and submit them together, but I assume it will 
> significantly increase the size of the patch.
Probably, better would be to split the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



___
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-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:892
+if (AS != LangAS::Default)
+  EPI.TypeQuals.addAddressSpace(getDefaultCXXMethodAddrSpace());
+

This should just be `AS`.

Could you go ahead and change the other, existing places that should use this 
method?


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] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D70791#1762081 , @rnk wrote:

> I thought we agreed to remove the workaround that we had for this and just 
> declare that the old MSVC STL release was buggy and users should update:
>  https://bugs.llvm.org/show_bug.cgi?id=42027
>  It's a point release that preserves ABI compatibility, so there's less 
> motivation for us to add a compat hack.
>
> In general, we should seriously think about sunsetting some MS compat hacks 
> that aren't needed for new SDK/STL versions to save on clang maintenance 
> costs. The complexity they add is surprisingly expensive. For example, 
> -fdelayed-template-parsing is a recurring source of compat issues in 
> clang-tools-extra (see the commit logs), and I would like to revive D66394 
>  to get it disabled by default soon. 
> (+@thakis)


Ah!  I KNEW I had seen this bug before.  I searched the bug database for a 
while for it.

I agree with sunsetting MS compat hacks as well, though I think we would need 
to support at least the most recentish versions.  My test team tells me that 
this failure isn't fixed until the (yet to be released) 16.4 version of the 
MSVC, so at the moment we don't compile the 'current' version without 
-std=c++17.  I don't see why r363191 was reverted, though I believe that this 
is both a less intrusive change, and is heavily specialized to only deal with 
this one case so hopefully it would not get reverted for the same reason.


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

https://reviews.llvm.org/D70791



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


[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: thakis.
rnk added a comment.

I thought we agreed to remove the workaround that we had for this and just 
declare that the old MSVC STL release was buggy and users should update:
https://bugs.llvm.org/show_bug.cgi?id=42027
It's a point release that preserves ABI compatibility, so there's less 
motivation for us to add a compat hack.

In general, we should seriously think about sunsetting some MS compat hacks 
that aren't needed for new SDK/STL versions to save on clang maintenance costs. 
The complexity they add is surprisingly expensive. For example, 
-fdelayed-template-parsing is a recurring source of compat issues in 
clang-tools-extra (see the commit logs), and I would like to revive D66394 
 to get it disabled by default soon. (+@thakis)


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

https://reviews.llvm.org/D70791



___
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-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

> This approach will also introduce false negatives.

Could you add a test showing this with a FIXME comment?

> A better approach would be to check if the null statement is the result of 
> folding an if constexpr.
>  The current AST API does not expose this information.
>  A better fix might require AST patches on the clang side.
>  The fix is proposed here: https://reviews.llvm.org/D46234



> Richard suggested to replace null stmts with nulls, but I have no time to 
> deal with all the fallouts for now. If someone is willing to pick that up 
> feel free to, but until then it might be a good idea to land this quick fix.

Could you add a FIXME comment to this effect?

Otherwise LG.


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

https://reviews.llvm.org/D46027



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


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

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added inline comments.



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

phosek wrote:
> Alternative would be to set `TERM=dumb` environment variable which disables 
> color support as well, but this also works.
Thanks! I'd love to have another solution, but it looks like the command line 
takes precedence over the environment variables and if `-fcolor-diagnostics` is 
specified in the command line it will always turn the colors on. 


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] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D49466#1761156 , @MaskRay wrote:

> The ugly path separator pattern `{{(/|)}}` appears in 60+ tests. Can we 
> teach clang and other tools to
>
> 1. accept both `/` and `\` input


In general they do, AFAIK, although it's not feasible in cases where `/` is the 
character that introduces an option, which is common on standard Windows 
utilities.

> 2. but only output `/`
> 
>   on Windows?

This is often actually incorrect for Windows.

> We can probably remove llvm::sys::path::Style::{windows,posix,native} from 
> include/llvm/Support/Path.h and only keep the posix form.

It's highly unlikely that will be correct for all cases, and certainly will not 
match users' expectations.  Debug info, for example, will want normal Windows 
syntax file paths with `\`.


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] D70253: [AArch64][SVE2] Implement remaining SVE2 floating-point intrinsics

2019-11-27 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:898
+ llvm_i32_ty],
+[IntrNoMem]>;
+

sdesmalen wrote:
> I'd expect the `llvm_i32_ty` to be an immediate for these instructions, 
> right? If so you'll need to add `ImmArg`  to the list of properties.
> 
Thanks for taking a look at this :) I tried your suggestion of adding ImmAr 
to the list of properties here but had some problems with it (i.e. Cannot 
select: intrinsic %llvm.aarch64.sve.fmlalb.lane). I don't think this is too 
much of an issue here as we have additional checks on the immediate with 
VectorIndexH32b, which ensures the immediate is in the correct range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70253



___
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-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Thanks!

Updated context for this patch:
A superior fix would be to follow through with the approach suggested by 
Richard in  https://reviews.llvm.org/D46234 . However, since I do not have time 
to finish that and there are people complaining in the PR, I think it is better 
to land this.


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

https://reviews.llvm.org/D46027



___
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-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth added a comment.
This revision is now accepted and ready to land.

Maybe a short notice in the release notes wouldn't hurt. Otherwise LGTM

*EDIT*: Aaron commented as well. Plz let him react before committing :)


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

https://reviews.llvm.org/D46027



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


[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rnk, rjmccall, majnemer.

MSVC's type_trait header for the 16.3.* release in pre-c++17 mode
exposes explicitly specialized constexpr variables for _Is_integral,
is_void_v, and _Is_floating_point as not-inline (since that isn't
available in pre-C++17). The result is duplicate-symbols in any
program that includes  more than once.

This patch works around this issue by making fairly specific cases (in
the system header, in MSVC mode, and in pre-c++17 mode) be weak_odr
linkage rather than External linkage.


https://reviews.llvm.org/D70791

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
  clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp


Index: clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -std=c++14 -o - %s 
-isystem%S/Inputs | FileCheck %s
+#include 
+
+// CHECK: @"??$_Is_integral@_N@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$_Is_floating_point@M@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$is_void_v@X@@3_NB" = weak_odr dso_local constant
+
Index: clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
===
--- /dev/null
+++ clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
@@ -0,0 +1,17 @@
+template 
+constexpr bool _Is_integral = false;
+
+template <>
+constexpr bool _Is_integral = true;
+
+template 
+constexpr bool _Is_floating_point = false;
+
+template <>
+constexpr bool _Is_floating_point = true;
+
+template 
+constexpr bool is_void_v = false;
+
+template <>
+constexpr bool is_void_v = true;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9860,6 +9860,19 @@
   return L;
 }
 
+// The MSVC type_traits header defines a handful of type-trait constexpr
+// variables as non-inline in pre-C++17 mode which causes duplicate symbols.
+// In C++17 cases, they mark these as 'inline', which avoids this issue.
+// This fixup alters the linkage to be odr for this case.
+static bool isMSVCPreCxx17TypeTrait(const ASTContext ,
+const VarDecl *VD) {
+  assert(VD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+ "Only valid for explicit specializations");
+  return VD->isConstexpr() && !VD->isInline() &&
+ !Context.getLangOpts().CPlusPlus17 &&
+ Context.getSourceManager().isInSystemHeader(VD->getLocation());
+}
+
 GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) const {
   return adjustGVALinkageForExternalDefinitionKind(*this, FD,
adjustGVALinkageForAttributes(*this, FD,
@@ -9926,7 +9939,8 @@
 
   case TSK_ExplicitSpecialization:
 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-   VD->isStaticDataMember()
+   (VD->isStaticDataMember() ||
+isMSVCPreCxx17TypeTrait(Context, VD))
? GVA_StrongODR
: StrongLinkage;
 


Index: clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -std=c++14 -o - %s -isystem%S/Inputs | FileCheck %s
+#include 
+
+// CHECK: @"??$_Is_integral@_N@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$_Is_floating_point@M@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$is_void_v@X@@3_NB" = weak_odr dso_local constant
+
Index: clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
===
--- /dev/null
+++ clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
@@ -0,0 +1,17 @@
+template 
+constexpr bool _Is_integral = false;
+
+template <>
+constexpr bool _Is_integral = true;
+
+template 
+constexpr bool _Is_floating_point = false;
+
+template <>
+constexpr bool _Is_floating_point = true;
+
+template 
+constexpr bool is_void_v = false;
+
+template <>
+constexpr bool is_void_v = true;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9860,6 +9860,19 @@
   return L;
 }
 
+// The MSVC type_traits header defines a handful of type-trait constexpr
+// variables as non-inline in pre-C++17 mode which causes duplicate symbols.
+// In C++17 cases, they mark these as 'inline', which avoids this issue.
+// This fixup alters the linkage to be odr for this case.
+static bool isMSVCPreCxx17TypeTrait(const ASTContext ,
+const 

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

2019-11-27 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 231285.
svenvh added a comment.

Added test for references too.


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

https://reviews.llvm.org/D70605

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 ) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr();
+  functionWithBaseArgRef(d);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,21 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4120,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, , CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, , CCK)
  .get();
 break;
   }


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 ) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr();
+  functionWithBaseArgRef(d);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,21 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4120,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, , CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, , CCK)
  .get();
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

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



Comment at: llvm/lib/Support/CommandLine.cpp:1053
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;

this comment has moved into a irrelevant line and wasn't addressed, so 
re-stating it here:

```
it is sad that, ExpandResponseFile returns a bool, but that's a battle for 
another day.

unfortunately, it is not enough return false in this case you need to consume 
the error with llvm::consumeError before exiting the scope.
```



Comment at: llvm/lib/Support/CommandLine.cpp:1148
+  llvm::ErrorOr RHS = FS.status(RFile.File);
+  if (!LHS || !RHS) {
+return false;

again you need to `consumeError`s before returning. I would first get `LHS`, 
consume and bail out if it was an error, then do the same for `RHS` and only 
after that return `equivalent`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



___
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-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:28
+  llvm::IntrusiveRefCntPtr FS)
+  : Base(std::move(Base)), Tokenizer(Tokenizer), FS(FS) {
+assert(this->Base != nullptr);

nit: `FS(std::move(FS))`



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:49
+  std::vector expand(std::vector Cmds) const {
+llvm::ErrorOr PreWorkingDirectory =
+FS->getCurrentWorkingDirectory();

no need to restore/save, `ExpandResponseFilesDatabase` should have a FS that's 
not shared with others.

it is iffy anyway, because if initial working directory is faulty, we'll mutate 
it to the working directory of the last compile command.
or even if it wasn't faulty, someone could delete the directory before we can 
restore, or someone can change it while we are in the middle of 
`ExpandResponseFile` calls.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:61
+continue;
+  if (FS->setCurrentWorkingDirectory(Cmd.Directory))
+continue;

maybe make this check at the beginning of the for loop?

could you also leave a fixme saying that we should rather propagate the current 
directory into `ExpandResponseFiles` as well in addition to `FS` and someone 
can take a look at it later on.
That would be more principled than relying on `ExpandResponseFilesDatabase` 
having its own non-shared copy of `FS`.



Comment at: clang/lib/Tooling/JSONCompilationDatabase.cpp:172
+  inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem(
 : nullptr;

let's change this one to `llvm::vfs::createPhysicalFileSystem` to make sure we 
are passing a non-shared FS. Unfortunately, `getRealFileSystem` is shared with 
the whole process.



Comment at: clang/unittests/Tooling/CompilationDatabaseTest.cpp:910
+TEST_F(ExpandResponseFilesTest, ExpandResponseFiles) {
+  // clang-format off
+  add("foo.cpp", "clang",

nit: instead of clang-format off maybe provide command as a raw string literal?



Comment at: clang/unittests/Tooling/CompilationDatabaseTest.cpp:912
+  add("foo.cpp", "clang",
+  ("@inner/rsp1.rsp @rsp2.rsp @rsp4.rsp "
+"@" + RspFileName1 + " @inner/rsp5.rsp @rsp6.rsp")

this test is checking the functionality of `ExpandFileCommands` helper, which 
is already tested in `llvm/unittests/Support/CommandLineTest.cpp`

it should be enough to have two simple tests:
- with a compile command that refers to a simple rsp file, and making sure it 
was expanded.
- with a regular compile command, making sure it stays the same.


Repository:
  rG LLVM Github Monorepo

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] D70755: [LifetimeAnalysis] Fix PR44150

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbcd0798c47ca: [LifetimeAnalysis] Fix PR44150 (authored by 
xazax.hun).

Repository:
  rG LLVM Github Monorepo

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

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 , 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);
   }
 }
 
@@ -7287,6 +7303,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.
@@ -7309,7 +7326,8 @@
   continue;
 if (It->Kind == IndirectLocalPathEntry::AddressOf)
   continue;
-return It->Kind == IndirectLocalPathEntry::GslPointerInit;
+return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
+   It->Kind == IndirectLocalPathEntry::GslReferenceInit;
   }
   return false;
 }
@@ -7532,6 +7550,7 @@
 
   case IndirectLocalPathEntry::LifetimeBoundCall:
   case IndirectLocalPathEntry::GslPointerInit:
+  case IndirectLocalPathEntry::GslReferenceInit:
 // FIXME: Consider adding a note for these.
 break;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bader via Phabricator via cfe-commits
bader marked an inline comment as done.
bader added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

ABataev wrote:
> bader wrote:
> > ABataev wrote:
> > > Need to check if the decl must be emitted at all.
> > Let me check that I get it right. You suggest adding `if 
> > (MustBeEmitted(Global))`, right?
> > ```
> >   if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
> > MustBeEmitted(Global)) {
> > ...
> > addDeferredDeclToEmit(GD);
> > return;
> >   }
> > ```
> Yes
Okay. Making this change requires additional adjustments in the patch and I 
have a few options.
In this patch we do not add any logic forcing compiler to emit SYCL kernel. 
This logic is supposed to be added by follow-up patch (currently under SYCL 
working group review here https://github.com/intel/llvm/pull/249), which add 
code emitting "externally visible" OpenCL kernel calling function object passed 
to SYCL kernel function.

I can:
1) Temporally remove CodeGen test and add updated version back with the 
follow-up patch
2) Do change making SYCL kernels "externally visible" and revert this change 
with the follow-up patch (this is kind of current logic which emits SYCL 
kernels unconditionally)
3) Merge two patches and submit them together, but I assume it will 
significantly increase the size of the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[clang] bcd0798 - [LifetimeAnalysis] Fix PR44150

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

Author: Gabor Horvath
Date: 2019-11-27T09:15:14-08:00
New Revision: bcd0798c47ca865f95226859893016a17402441e

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

LOG: [LifetimeAnalysis] Fix PR44150

References need somewhat special treatment. While copying a gsl::Pointer
will propagate the points-to set, creating an object from a reference
often behaves more like a dereference operation.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 80d7cfed711a..7421754d95ca 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6653,6 +6653,7 @@ struct IndirectLocalPathEntry {
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslReferenceInit,
 GslPointerInit
   } Kind;
   Expr *E;
@@ -6783,12 +6784,24 @@ static bool shouldTrackFirstArgument(const FunctionDecl 
*FD) {
 
 static void handleGslAnnotatedTypes(IndirectLocalPath , 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 @@ static void handleGslAnnotatedTypes(IndirectLocalPath 
, Expr *Call,
   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 @@ static void handleGslAnnotatedTypes(IndirectLocalPath 
, Expr *Call,
 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);
   }
 }
 
@@ -7287,6 +7303,7 @@ static SourceRange nextPathEntryRange(const 
IndirectLocalPath , unsigned I,
 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.
@@ -7309,7 +7326,8 @@ static bool 
pathOnlyInitializesGslPointer(IndirectLocalPath ) {
   continue;
 if (It->Kind == IndirectLocalPathEntry::AddressOf)
   continue;
-return It->Kind == IndirectLocalPathEntry::GslPointerInit;
+return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
+   It->Kind == IndirectLocalPathEntry::GslReferenceInit;
   }
   return false;
 }
@@ -7532,6 +7550,7 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity ,
 
   case IndirectLocalPathEntry::LifetimeBoundCall:
   case 

[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

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

Build result: pass - 60223 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/D70787/new/

https://reviews.llvm.org/D70787



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


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

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

Build result: pass - 60223 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/D70787/new/

https://reviews.llvm.org/D70787



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


[PATCH] D70788: [Syntax] A tool to dump syntax tree and token buffer

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

Build result: pass - 60223 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/D70788/new/

https://reviews.llvm.org/D70788



___
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-27 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa048bf87fb65: [ARM][MVE][Intrinsics] Add MVE 
VAND/VORR/VORN/VEOR/VBIC intrinsics. Add unit… (authored by MarkMurrayARM).

Changed prior to commit:
  https://reviews.llvm.org/D70547?vs=231057=231272#toc

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 

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

2019-11-27 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8a8dbe9c458: [ARM][MVE][Intrinsics] Add MVE VMUL 
intrinsics. Remove annoying t1 from VMUL*… (authored by 
MarkMurrayARM).

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 

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

2019-11-27 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4bba07b87ce: [ARM][MVE][Intrinsics] Add MVE VABD 
intrinsics. Add unit tests. (authored by MarkMurrayARM).

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, 

[PATCH] D70765: LTOVisibility.rst: fix up syntax in example

2019-11-27 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc 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/D70765/new/

https://reviews.llvm.org/D70765



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


[clang] f4bba07 - [ARM][MVE][Intrinsics] Add MVE VABD intrinsics. Add unit tests.

2019-11-27 Thread Mark Murray via cfe-commits

Author: Mark Murray
Date: 2019-11-27T16:52:04Z
New Revision: f4bba07b87ce7ad60d908d2fe02abe88d2d48fa4

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

LOG: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics. Add unit tests.

Summary: Add MVE VABD intrinsics. Add unit tests.

Reviewers: simon_tatham, ostannard, dmgreen

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

Tags: #clang, #llvm

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

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

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

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index d8d199f464d9..0d827485ae40 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -28,6 +28,7 @@ foreach n = [ 2, 4 ] in {
   "Intrinsic::arm_mve_vld"#n#"q":$IRIntr)>;
 }
 
+
 let params = T.Int in {
 def vaddq: Intrinsic;
 def vsubq: Intrinsic;
@@ -41,6 +42,14 @@ def vsubqf: Intrinsic,
 }
 
 let params = T.Usual in {
+def vabdq: Intrinsic $a, $b)>;
+}
+
+let params = T.Usual in {
+def vabdq_m: Intrinsic<
+Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
+(IRInt<"abd_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
 def vaddq_m: Intrinsic<
 Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
 (IRInt<"add_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vabdq.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
new file mode 100644
index ..a416bfb773e6
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
@@ -0,0 +1,95 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vabdq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.arm.mve.vabd.v16i8(<16 x 
i8> [[A:%.*]], <16 x i8> [[B:%.*]])
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vabdq_s8(int8x16_t a, int8x16_t b)
+{
+#ifdef POLYMORPHIC
+return vabdq(a, b);
+#else /* POLYMORPHIC */
+return vabdq_s8(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x 
i32> [[A:%.*]], <4 x i32> [[B:%.*]])
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vabdq_u32(uint32x4_t a, uint32x4_t b)
+{
+#ifdef POLYMORPHIC
+return vabdq(a, b);
+#else /* POLYMORPHIC */
+return vabdq_u32(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.arm.mve.vabd.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[B:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vabdq_f32(float16x8_t a, float16x8_t b)
+{
+#ifdef POLYMORPHIC
+return vabdq(a, b);
+#else /* POLYMORPHIC */
+return vabdq_f16(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_m_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <8 x i16> 
@llvm.arm.mve.abd.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> 
[[B:%.*]], <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+uint16x8_t test_vabdq_m_u16(uint16x8_t inactive, uint16x8_t a, uint16x8_t b, 
mve_pred16_t p)
+{
+#ifdef POLYMORPHIC
+return vabdq_m(inactive, a, b, p);
+#else /* POLYMORPHIC */
+return vabdq_m_u16(inactive, a, b, p);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_m_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <16 x i8> 
@llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> 
[[B:%.*]], <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
+// CHECK-NEXT:ret <16 x i8> 

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

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

Build result: pass - 60340 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/D70739/new/

https://reviews.llvm.org/D70739



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


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 231269.
ilya-biryukov added a comment.

- Remove obsolete FIXME
- Fix a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70787

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

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -130,7 +130,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-|-TopLevelDeclaration
+|-SimpleDeclaration
 | |-int
 | |-main
 | |-(
@@ -138,7 +138,7 @@
 | `-CompoundStatement
 |   |-{
 |   `-}
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-foo
   |-(
@@ -157,7 +157,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-main
   |-(
@@ -202,7 +202,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -224,7 +224,7 @@
   {"void test() { int a = 10; }",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -232,16 +232,18 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-=
-| |-10
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-=
+| | `-UnknownExpression
+| |   `-10
 | `-;
 `-}
 )txt"},
   {"void test() { ; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -263,7 +265,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -299,7 +301,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -329,7 +331,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-test
   |-(
@@ -352,7 +354,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -360,18 +362,21 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-[
-| |-3
-| |-]
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-[
+| | |-UnknownExpression
+| | | `-3
+| | `-]
 | `-;
 |-RangeBasedForStatement
 | |-for
 | |-(
-| |-int
-| |-x
-| |-:
+| |-SimpleDeclaration
+| | |-int
+| | |-x
+| | `-:
 | |-UnknownExpression
 | | `-a
 | |-)
@@ -384,7 +389,7 @@
   // counterpart.
   {"void main() { foo: return 100; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-main
   |-(
@@ -411,7 +416,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -444,7 +449,35 @@
 |   | `-)
 |   `-;
 `-}
-)txt"}};
+)txt"},
+  // Multiple declarators group into a single SimpleDeclaration.
+  {R"cpp(
+  int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"},
+  {R"cpp(
+typedef int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-typedef
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"}};
 
   for (const auto  : Cases) {
 auto *Root = buildTree(T.first);
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -16,8 +16,6 @@
 return OS << "Leaf";
   case NodeKind::TranslationUnit:
 return OS << "TranslationUnit";
-  case NodeKind::TopLevelDeclaration:
-return OS << "TopLevelDeclaration";
   case NodeKind::UnknownExpression:
 return OS << "UnknownExpression";
   case NodeKind::UnknownStatement:
@@ -50,6 +48,10 @@
 return OS << "ExpressionStatement";
   case NodeKind::CompoundStatement:
 return OS << "CompoundStatement";
+  case NodeKind::UnknownDeclaration:
+return OS << "UnknownDeclaration";
+  case NodeKind::SimpleDeclaration:
+return OS << "SimpleDeclaration";
   }
   llvm_unreachable("unknown node kind");
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include 

[PATCH] D70788: [Syntax] A tool to dump syntax tree and token buffer

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
ilya-biryukov added a comment.
ilya-biryukov planned changes to this revision.

Would want to add some tests before landing this. But this is tool is generally 
useful to experiment with syntax trees, so posting it early (so that it doesn't 
get lost)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70788

Files:
  clang/tools/CMakeLists.txt
  clang/tools/clang-syntax/CMakeLists.txt
  clang/tools/clang-syntax/SyntaxMain.cpp

Index: clang/tools/clang-syntax/SyntaxMain.cpp
===
--- /dev/null
+++ clang/tools/clang-syntax/SyntaxMain.cpp
@@ -0,0 +1,81 @@
+//===- SyntaxMain.cpp -*- 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
+//
+//===--===//
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Tooling/Execution.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace clang;
+
+namespace {
+llvm::cl::opt DumpTokens("dump-tokens",
+   llvm::cl::desc("dump the preprocessed tokens"),
+   llvm::cl::init(false));
+llvm::cl::opt DumpTree("dump-tree",
+ llvm::cl::desc("dump the syntax tree"),
+ llvm::cl::init(false));
+
+class BuildSyntaxTree : public ASTFrontendAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance ,
+ StringRef InFile) override {
+class Consumer : public ASTConsumer {
+public:
+  Consumer(CompilerInstance ) : Collector(CI.getPreprocessor()) {}
+
+  void HandleTranslationUnit(ASTContext ) override {
+syntax::Arena A(AST.getSourceManager(), AST.getLangOpts(),
+std::move(Collector).consume());
+auto *TU = syntax::buildSyntaxTree(A, *AST.getTranslationUnitDecl());
+if (DumpTokens)
+  llvm::outs() << A.tokenBuffer().dumpForTests();
+if (DumpTree)
+  llvm::outs() << TU->dump(A);
+  }
+
+private:
+  syntax::TokenCollector Collector;
+};
+return std::make_unique(CI);
+  }
+};
+
+class Factory : public tooling::FrontendActionFactory {
+  std::unique_ptr create() override {
+return std::make_unique();
+  }
+};
+
+} // namespace
+
+int main(int argc, const char **argv) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
+  argc, argv, llvm::cl::GeneralCategory,
+  "Build syntax trees for the specified files");
+  if (!Executor) {
+llvm::errs() << llvm::toString(Executor.takeError()) << "\n";
+return 1;
+  }
+  if (!DumpTokens && !DumpTree) {
+llvm::errs()
+<< "Please specify at least one of -dump-tree or -dump-tokens\n";
+return 1;
+  }
+  // Collect symbols found in each translation unit, merging as we go.
+  auto Err = Executor->get()->execute(std::make_unique());
+  if (Err)
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return 0;
+}
Index: clang/tools/clang-syntax/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/clang-syntax/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS Support)
+
+add_clang_tool(clang-syntax
+  SyntaxMain.cpp
+  )
+
+target_link_libraries(clang-syntax
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangLex
+  clangTooling
+  clangToolingCore
+  clangToolingSyntax
+)
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -18,6 +18,7 @@
 if(UNIX)
   add_clang_subdirectory(clang-shlib)
 endif()
+add_clang_subdirectory(clang-syntax)
 
 if(CLANG_ENABLE_ARCMT)
   add_clang_subdirectory(arcmt-test)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70788: [Syntax] A tool to dump syntax tree and token buffer

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

Would want to add some tests before landing this. But this is tool is generally 
useful to experiment with syntax trees, so posting it early (so that it doesn't 
get lost)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70788



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


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: gribozavr2.
Herald added a project: clang.

Also remove the temporary TopLevelDeclaration node and add
UnknownDeclaration to represent other unknown nodes.

See the follow-up change for building more top-level declarations.
Adding declarators is also pretty involved and will be done in the
follow-up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70787

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

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -130,7 +130,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-|-TopLevelDeclaration
+|-SimpleDeclaration
 | |-int
 | |-main
 | |-(
@@ -138,7 +138,7 @@
 | `-CompoundStatement
 |   |-{
 |   `-}
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-foo
   |-(
@@ -157,7 +157,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-main
   |-(
@@ -202,7 +202,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -224,7 +224,7 @@
   {"void test() { int a = 10; }",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -232,16 +232,18 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-=
-| |-10
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-=
+| | `-UnknownExpression
+| |   `-10
 | `-;
 `-}
 )txt"},
   {"void test() { ; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -263,7 +265,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -299,7 +301,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -329,7 +331,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-test
   |-(
@@ -352,7 +354,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -360,18 +362,21 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-[
-| |-3
-| |-]
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-[
+| | |-UnknownExpression
+| | | `-3
+| | `-]
 | `-;
 |-RangeBasedForStatement
 | |-for
 | |-(
-| |-int
-| |-x
-| |-:
+| |-SimpleDeclaration
+| | |-int
+| | |-x
+| | `-:
 | |-UnknownExpression
 | | `-a
 | |-)
@@ -384,7 +389,7 @@
   // counterpart.
   {"void main() { foo: return 100; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-main
   |-(
@@ -411,7 +416,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -444,7 +449,35 @@
 |   | `-)
 |   `-;
 `-}
-)txt"}};
+)txt"},
+  // Multiple declarators group into a single SimpleDeclaration.
+  {R"cpp(
+  int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"},
+  {R"cpp(
+typedef int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-typedef
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"}};
 
   for (const auto  : Cases) {
 auto *Root = buildTree(T.first);
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -16,8 +16,6 @@
 return OS << "Leaf";
   case NodeKind::TranslationUnit:
 return OS << "TranslationUnit";
-  case NodeKind::TopLevelDeclaration:
-return OS << "TopLevelDeclaration";
   case NodeKind::UnknownExpression:
 return OS << "UnknownExpression";
   case NodeKind::UnknownStatement:
@@ -50,6 +48,10 @@
 return OS << "ExpressionStatement";
   case NodeKind::CompoundStatement:
 return OS << "CompoundStatement";
+  case NodeKind::UnknownDeclaration:
+return OS << "UnknownDeclaration";
+  case NodeKind::SimpleDeclaration:
+return OS << "SimpleDeclaration";
   }
   llvm_unreachable("unknown node kind");
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 

[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2019-11-27 Thread Marco Hinz via Phabricator via cfe-commits
mhinz added a comment.

I applied the fix to all toolchains now, but I'm unsure how to write a test for 
it. Neither could I find tests for similar options like `-DDEFAULT_SYSROOT`.

My use case: I want to build a clang that has the same search path as the clang 
shipped with macOS.

  $ /usr/bin/clang -E -xc -v /dev/null
  [snip]
  #include <...> search starts here:
   /usr/local/include
   
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
   
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
 (framework directory)
  End of search list.
  [snip]

For this, I need to pass this to cmake:

  
-DC_INCLUDE_DIRS="/usr/local/include:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
  -DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)"


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

https://reviews.llvm.org/D69221



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


[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2019-11-27 Thread Marco Hinz via Phabricator via cfe-commits
mhinz updated this revision to Diff 231266.
mhinz added a comment.
Herald added subscribers: aheejin, jgravelle-google, sbc100, dschuff.

Apply fix to all toolchains.


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

https://reviews.llvm.org/D69221

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -674,7 +674,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -149,7 +149,7 @@
 CIncludeDirs.split(Dirs, ":");
 for (StringRef Dir : Dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(Dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -286,7 +286,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1896,7 +1896,7 @@
 CIncludeDirs.split(dirs, ":");
 for (llvm::StringRef dir : dirs) {
   llvm::StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? llvm::StringRef(Sysroot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : llvm::StringRef(Sysroot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
   } else {


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: 

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

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 2 inline comments as done.
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:9320
   using OMPCtxSelectorData =
-  OpenMPCtxSelectorData, ExprResult>;
+  OpenMPCtxSelectorData, ExprResult>;
 

jdoerfert wrote:
> I would like to avoid the Any type here and I hope we can if we don't allow 
> "strings". See also my last comment.
The only possible solution I see here is to convert kind/vendor strings into 
exprs and store all data as `Expr *`



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:11147
+llvm::Triple CustomTriple(Name);
+if (CGM.getTarget().getTriple().getArch() != CustomTriple.getArch())
+  return false;

jdoerfert wrote:
> should we normalize the names here? at least `.lower` might be useful.
Done + added check for possibly used vendor/os/env


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



___
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-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 231265.
ABataev added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

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 1; }
+#pragma omp declare 

[PATCH] D60455: [SYCL] Implement SYCL device code outlining

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



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

bader wrote:
> ABataev wrote:
> > Need to check if the decl must be emitted at all.
> Let me check that I get it right. You suggest adding `if 
> (MustBeEmitted(Global))`, right?
> ```
>   if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
> MustBeEmitted(Global)) {
> ...
> addDeferredDeclToEmit(GD);
> return;
>   }
> ```
Yes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70773: [clangd] Handle the missing call expr in targetDecl.

2019-11-27 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG939544add98e: [clangd] Handle the missing call expr in 
targetDecl. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70773

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


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@
   RelSet Flags;
   Visitor(TargetFinder , RelSet Flags) : Outer(Outer), Flags(Flags) 
{}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@
   RelSet Flags;
   Visitor(TargetFinder , RelSet Flags) : Outer(Outer), Flags(Flags) {}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bader via Phabricator via cfe-commits
bader marked an inline comment as done.
bader added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

ABataev wrote:
> Need to check if the decl must be emitted at all.
Let me check that I get it right. You suggest adding `if 
(MustBeEmitted(Global))`, right?
```
  if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
MustBeEmitted(Global)) {
...
addDeferredDeclToEmit(GD);
return;
  }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[clang-tools-extra] 939544a - [clangd] Handle the missing call expr in targetDecl.

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

Author: Haojian Wu
Date: 2019-11-27T16:22:20+01:00
New Revision: 939544add98ee6463d6abd6c28fa6c9ac4b6e104

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

LOG: [clangd] Handle the missing call expr in targetDecl.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index c536cbf75e5c..3e55a6a9cdc6 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@ struct TargetFinder {
   RelSet Flags;
   Visitor(TargetFinder , RelSet Flags) : Outer(Outer), Flags(Flags) 
{}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f6e5fe723ec7..620eb3d6d3d6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@ TEST_F(TargetDeclTest, Exprs) {
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

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

Build result: pass - 60338 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/D70769/new/

https://reviews.llvm.org/D70769



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


[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, the patch looks good! please also update the patch description.




Comment at: clang-tools-extra/clangd/Selection.cpp:63
+  // Claims whichever expanded tokens in SourceRange are not yet claimed.
+  // Writes contiguous claimed subranges to Result, and returns true if any.
+  llvm::SmallVector, 4> erase(llvm::ArrayRef Claim) {

nit: this comment seems not reflect to the code now.



Comment at: clang-tools-extra/clangd/Selection.cpp:126
+
+// Nodes start start with NoTokens, and then use this function to aggregate
+// the selectedness as more tokens are found.

nit: remove the redundant start.



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:468
+  // Unfortunately, this makes the common ancestor the CallExpr...
+  // FIXME: hack around this by picking one?
+  EXPECT_EQ("CallExpr", T.commonAncestor()->kind());

I think cases like below are broken:

```
#define greater(x, y) x > y? x : y
#define abs(x) x > 0 ? x : -x
```

 Selecting the first element for a macro arg seems good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512



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


[clang] f59614d - [OPENMP50]Add if clause in parallel for simd directive.

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

Author: Alexey Bataev
Date: 2019-11-27T09:56:25-05:00
New Revision: f59614d906b5428f3687a44ee018df5840b301dd

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

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

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 59178fb671fb..2773efcf3dae 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4538,6 +4538,8 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 Res = ActOnOpenMPParallelForSimdDirective(
 ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
 AllowedNameModifiers.push_back(OMPD_parallel);
+if (LangOpts.OpenMP >= 50)
+  AllowedNameModifiers.push_back(OMPD_simd);
 break;
   case OMPD_parallel_sections:
 Res = ActOnOpenMPParallelSectionsDirective(ClausesWithImplicit, AStmt,
@@ -10677,11 +10679,14 @@ static OpenMPDirectiveKind 
getOpenMPCaptureRegionForClause(
   if (NameModifier == OMPD_unknown || NameModifier == OMPD_taskloop)
 CaptureRegion = OMPD_parallel;
   break;
+case OMPD_parallel_for_simd:
+  if (NameModifier == OMPD_unknown || NameModifier == OMPD_simd)
+CaptureRegion = OMPD_parallel;
+  break;
 case OMPD_cancel:
 case OMPD_parallel:
 case OMPD_parallel_sections:
 case OMPD_parallel_for:
-case OMPD_parallel_for_simd:
 case OMPD_target:
 case OMPD_target_simd:
 case OMPD_target_teams:

diff  --git a/clang/test/OpenMP/parallel_for_simd_codegen.cpp 
b/clang/test/OpenMP/parallel_for_simd_codegen.cpp
index 9585bf293695..01f2b4c42a24 100644
--- a/clang/test/OpenMP/parallel_for_simd_codegen.cpp
+++ b/clang/test/OpenMP/parallel_for_simd_codegen.cpp
@@ -1,14 +1,24 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 
--check-prefix=OMP45 --check-prefix=CHECK
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TERM_DEBUG
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck %s --check-prefix=OMP50 --check-prefix=CHECK
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-version=50 -fexceptions -fcxx-exceptions 
-debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s 
--check-prefix=TERM_DEBUG
+
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50  -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50  -x c++ -std=c++11 
-triple x86_64-unknown-unknown -fexceptions 

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

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

Added `getDefaultCXXMethodAddrSpace` helper to Sema


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

https://reviews.llvm.org/D69938

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/address-space-lambda.cl


Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -0,0 +1,25 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'int (int) const __generic'
+auto glambda = [](auto a) { return a; };
+
+__kernel void foo() {
+  int i;
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
+  auto  llambda = [&]() {i++;};
+  llambda();
+  glambda(1);
+  // Test lambda with default parameters
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
+  [&] {i++;} ();
+  __constant auto err = [&]() {}; //expected-note-re{{candidate function not 
viable: address space mismatch in 'this' argument ('__constant (lambda at 
{{.*}})'), parameter type must be 'const __generic (lambda at {{.*}})'}}
+  err();  //expected-error-re{{no matching function 
for call to object of type '__constant (lambda at {{.*}})'}}
+  // FIXME: There is very limited addr space functionality
+  // we can test when taking lambda type from the object.
+  // The limitation is due to addr spaces being added to all
+  // objects in OpenCL. Once we add metaprogramming utility
+  // for removing address spaces from a type we can enhance
+  // testing here.
+  (*(__constant decltype(llambda) *)nullptr)(); //expected-error{{multiple 
address spaces specified for type}}
+  (*(decltype(llambda) *)nullptr)();
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4916,7 +4916,9 @@
   .getScopeRep()
   ->getKind() == NestedNameSpecifier::TypeSpec) ||
  state.getDeclarator().getContext() ==
- DeclaratorContext::MemberContext;
+ DeclaratorContext::MemberContext ||
+ state.getDeclarator().getContext() ==
+ DeclaratorContext::LambdaExprContext;
 };
 
 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -887,6 +887,10 @@
 /*IsVariadic=*/false, /*IsCXXMethod=*/true));
 EPI.HasTrailingReturn = true;
 EPI.TypeQuals.addConst();
+LangAS AS = getDefaultCXXMethodAddrSpace();
+if (AS != LangAS::Default)
+  EPI.TypeQuals.addAddressSpace(getDefaultCXXMethodAddrSpace());
+
 // C++1y [expr.prim.lambda]:
 //   The lambda return type is 'auto', which is replaced by the
 //   trailing-return type if provided and/or deduced from 'return'
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1279,6 +1279,12 @@
   return nullptr;
 }
 
+LangAS Sema::getDefaultCXXMethodAddrSpace() const {
+  if (getLangOpts().OpenCL)
+return LangAS::opencl_generic;
+  return LangAS::Default;
+}
+
 void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
   // FIXME: It doesn't make sense to me that DiagID is an incoming argument 
here
   // and yet we also use the current diag ID on the DiagnosticsEngine. This has
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3724,6 +3724,9 @@
   /// Add the given method to the list of globally-known methods.
   void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
 
+  /// Returns default addr space for method qualifiers.
+  LangAS getDefaultCXXMethodAddrSpace() const;
+
 private:
   /// AddMethodToGlobalPool - Add an instance or factory method to the global
   /// pool. See descriptoin of AddInstanceMethodToGlobalPool.


Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -0,0 +1,25 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'int (int) const __generic'
+auto glambda = [](auto a) { return a; };
+
+__kernel void foo() {
+  int i;
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const 

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 marked 3 inline comments as done.
lh123 added inline comments.



Comment at: llvm/include/llvm/Support/CommandLine.h:47
+class FileSystem;
+IntrusiveRefCntPtr getRealFileSystem();
+

kadircet wrote:
> now that we are also pulling the the function, I think it is OK to include 
> the header instead.
Yes, we need to include `VirtualFileSystem.h`, `IntrusiveRefCntPtr` needs to 
know the complete definition of `FileSystem`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231242.
lh123 marked an inline comment as done.
lh123 added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1046,9 +1047,13 @@
 static bool ExpandResponseFile(StringRef FName, StringSaver ,
TokenizerCallback Tokenizer,
SmallVectorImpl ,
-   bool MarkEOLs, bool RelativeNames) {
+   bool MarkEOLs, bool RelativeNames,
+   llvm::vfs::FileSystem ) {
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;
   ErrorOr> MemBufOrErr =
-  MemoryBuffer::getFile(FName);
+  FS.getBufferForFile(FName);
   if (!MemBufOrErr)
 return false;
   MemoryBuffer  = *MemBufOrErr.get();
@@ -1084,9 +1089,7 @@
 SmallString<128> ResponseFile;
 ResponseFile.append(1, '@');
 if (llvm::sys::path::is_relative(FName)) {
-  SmallString<128> curr_dir;
-  llvm::sys::fs::current_path(curr_dir);
-  ResponseFile.append(curr_dir.str());
+  ResponseFile.append(CurrDir.get());
 }
 llvm::sys::path::append(
 ResponseFile, llvm::sys::path::parent_path(FName), FileName);
@@ -1101,8 +1104,8 @@
 /// Expand response files on a command line recursively using the given
 /// StringSaver and tokenization strategy.
 bool cl::ExpandResponseFiles(StringSaver , TokenizerCallback Tokenizer,
- SmallVectorImpl ,
- bool MarkEOLs, bool RelativeNames) {
+ SmallVectorImpl , bool MarkEOLs,
+ bool RelativeNames, llvm::vfs::FileSystem ) {
   bool AllExpanded = true;
   struct ResponseFileRecord {
 const char *File;
@@ -1139,8 +1142,13 @@
 }
 
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord ) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, ](const ResponseFileRecord ) {
+  llvm::ErrorOr LHS = FS.status(FName);
+  llvm::ErrorOr RHS = FS.status(RFile.File);
+  if (!LHS || !RHS) {
+return false;
+  }
+  return LHS->equivalent(*RHS);
 };
 
 // Check for recursive response files.
@@ -1156,7 +1164,7 @@
 // contents.  Nested response files are expanded in subsequent iterations.
 SmallVector ExpandedArgv;
 if (!ExpandResponseFile(FName, Saver, Tokenizer, ExpandedArgv, MarkEOLs,
-RelativeNames)) {
+RelativeNames, FS)) {
   // We couldn't read this file, so we leave it in the argument stream and
   // move on.
   AllExpanded = false;
@@ -1187,7 +1195,8 @@
 bool cl::readConfigFile(StringRef CfgFile, StringSaver ,
 SmallVectorImpl ) {
   if (!ExpandResponseFile(CfgFile, Saver, cl::tokenizeConfigFile, Argv,
-  /*MarkEOLs*/ false, /*RelativeNames*/ true))
+  /*MarkEOLs*/ false, /*RelativeNames*/ true,
+  *llvm::vfs::getRealFileSystem()))
 return false;
   return ExpandResponseFiles(Saver, cl::tokenizeConfigFile, Argv,
  /*MarkEOLs*/ false, /*RelativeNames*/ true);
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1964,10 +1965,13 @@
 /// with nullptrs in the Argv vector.
 /// \param [in] RelativeNames true if names of nested response files must be
 /// resolved relative to including file.
+/// \param [in] FS File system used for all file access when running the tool.
 /// \return true if all @files were expanded successfully or there were none.
-bool ExpandResponseFiles(StringSaver , TokenizerCallback Tokenizer,
- SmallVectorImpl ,
- bool MarkEOLs = false, bool RelativeNames = false);
+bool ExpandResponseFiles(
+StringSaver , 

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

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp:48
+
+#pragma omp declare variant(foo) match(device = {isa("nvptx64")})
+int bar() { return 1; }

jdoerfert wrote:
> I'm not sure we want these to be strings. I would have assumed 
> `isa(nvptx64)`, similar to `vendor(arm)`, or `kind(host)` and `kind(gpu)`
Here is the message from Joachim Protze:
```
vendor and kind are special, because we define the kind-name and 
vendor-name in the context definition side document. (We could change 
that to "kind-name" or define kind-name as any of "cpu", "gpu", "fpga" ???)

For the others, according to the syntax diagram in the OpenMP Context 
section, the content of the () can only be string or const-int-exp.

- Joachim
```
That's why we need to represent them as strings, this is per OpenMP standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

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



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

Need to check if the decl must be emitted at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



___
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-27 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

In D70500#1759831 , @ilya-biryukov 
wrote:

> 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?


@dschuff also suggested this approach offline, so it sounds like the way to go. 
I've now submitted https://reviews.llvm.org/D70780 which implements this.


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] D70780: [WebAssembly] Find wasm-opt with GetProgramPath

2019-11-27 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
sunfish added reviewers: dschuff, ilya-biryukov.
Herald added subscribers: cfe-commits, aheejin, jgravelle-google, sbc100.
Herald added a project: clang.

Instead of just searching for wasm-opt in PATH, use `GetProgramPath`, which 
checks the `COMPILER_PATH` environment variable, `-B` paths, and `PATH.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70780

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


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -92,10 +92,10 @@
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
 
-  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-if (llvm::ErrorOr WasmOptPath =
-   llvm::sys::findProgramByName("wasm-opt")) {
+auto WasmOptPath = getToolChain().GetProgramPath("wasm-opt");
+if (WasmOptPath != "wasm-opt") {
   StringRef OOpt = "s";
   if (A->getOption().matches(options::OPT_O4) ||
   A->getOption().matches(options::OPT_Ofast))
@@ -106,7 +106,7 @@
 OOpt = A->getValue();
 
   if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+const char *WasmOpt = Args.MakeArgString(WasmOptPath);
 ArgStringList CmdArgs;
 CmdArgs.push_back(Output.getFilename());
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -92,10 +92,10 @@
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
 
-  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-if (llvm::ErrorOr WasmOptPath =
-   llvm::sys::findProgramByName("wasm-opt")) {
+auto WasmOptPath = getToolChain().GetProgramPath("wasm-opt");
+if (WasmOptPath != "wasm-opt") {
   StringRef OOpt = "s";
   if (A->getOption().matches(options::OPT_O4) ||
   A->getOption().matches(options::OPT_Ofast))
@@ -106,7 +106,7 @@
 OOpt = A->getValue();
 
   if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+const char *WasmOpt = Args.MakeArgString(WasmOptPath);
 ArgStringList CmdArgs;
 CmdArgs.push_back(Output.getFilename());
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri reopened this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Temporarily reverted in rG62098354ab1c6c0dd2cecc8ac526d411bfe8aa20 - the 
assertion does not hold, need to remove it likely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539



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


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

2019-11-27 Thread Alouest via Phabricator via cfe-commits
Alouest added a comment.

Greetings,

I stumbled upon a bug while toying with your example Bye.cpp. I modified your 
pass to make a ModulePass and while it works with

  /build/bin/opt -goodbye -wave-goodbye test.ll

It's making clang crash with the command

  /build/bin/clang test.c

I've included the pass, the error logs and some files to reproduce the bug 
(hello2.bc is supposed to be placed in the directory where you start your 
code). 
It seems that the bug is coming from StringMap.cpp, it looks like NumBuckets is 
not always initialized when accessed, raising a SegFault.
In my example, this function is called by Module::getFunction (StringRef).

I'm a beginner in LLVM so I might just be doing dumb things.

F10889373: test-df7efc.c 

F10889372: Bye.cpp 

F10889371: test.c 

F10889370: test-df7efc.sh 

F10889369: hello2.bc 

F10889368: test.ll 

F10889367: log 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 231237.
lebedev.ri added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/catch-implicit-conversions-incdec-basics.c
  
clang/test/CodeGen/catch-implicit-integer-arithmetic-value-change-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-conversions-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
  clang/test/CodeGen/catch-implicit-integer-truncations-incdec-basics.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec-basics.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  clang/test/CodeGen/catch-implicit-unsigned-integer-truncations-incdec-basics.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-conversion-incdec.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-sign-change-incdec.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c

Index: compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c
@@ -0,0 +1,122 @@
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+
+void test_unsigned() {
+  unsigned char x;
+
+  x = 0;
+  x++;
+  x = 0;
+  ++x;
+
+  x = 0;
+  x--;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned char' changed the value to 255 (8-bit, unsigned)
+  x = 0;
+  --x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned char' changed the value to 255 (8-bit, unsigned)
+
+  x = 1;
+  x++;
+  x = 1;
+  ++x;
+
+  x = 1;
+  x--;
+  x = 1;
+  --x;
+
+  x = 254;
+  x++;
+  x = 254;
+  ++x;
+
+  x = 254;
+  x--;
+  x = 254;
+  --x;
+
+  x = 255;
+  x++;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned)
+  x = 255;
+  ++x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned)
+
+  x = 255;
+  x--;
+  x = 255;
+  --x;
+}
+
+void test_signed() {
+  signed char x;
+
+  x = -128;
+  x++;
+  x = -128;
+  ++x;
+
+  x = -128;
+  x--;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value -129 (32-bit, signed) to type 'signed char' changed the value to 127 (8-bit, signed)
+  x = -128;
+  --x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value -129 (32-bit, signed) to type 'signed char' changed the value to 127 (8-bit, signed)
+
+  x = -1;
+  x++;
+  x = -1;
+  ++x;
+
+  x = -1;
+  x--;
+  x = -1;
+  --x;
+
+  x = 0;
+  x++;
+  x = 0;
+  ++x;
+
+  x = 0;
+  x--;
+  x = 0;
+  --x;
+
+  x = 1;
+  x++;
+  x = 1;
+  ++x;
+
+  x = 1;
+  x--;
+  x = 1;
+  --x;
+
+  x = 127;
+  

[clang] cbfa237 - Revert "[clang][CodeGen] Implicit Conversion Sanitizer: handle increment/decrement (PR44054)"

2019-11-27 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2019-11-27T17:05:21+03:00
New Revision: cbfa237892e55b7129a1178c9b03f26683d643af

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

LOG: Revert "[clang][CodeGen] Implicit Conversion Sanitizer: handle 
increment/decrement (PR44054)"

The asssertion that was added does not hold,
breaks on test-suite/MultiSource/Applications/SPASS/analyze.c
Will reduce the testcase and revisit.

This reverts commit 9872ea4ed1de4c49300430e4f1f4dfc110a79ab9, 
870f3542d3e0d06d208442bdca6482866b59171b.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 
clang/test/CodeGen/catch-implicit-conversions-incdec-basics.c

clang/test/CodeGen/catch-implicit-integer-arithmetic-value-change-incdec-basics.c
clang/test/CodeGen/catch-implicit-integer-conversions-incdec-basics.c
clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec-basics.c
clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
clang/test/CodeGen/catch-implicit-integer-truncations-incdec-basics.c
clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec-basics.c
clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c

clang/test/CodeGen/catch-implicit-unsigned-integer-truncations-incdec-basics.c

compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-conversion-incdec.c

compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-sign-change-incdec.c

compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 37a8f30e0bc9..4ac300deb589 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -78,10 +78,6 @@ Non-comprehensive list of changes in this release
   been extended to detect these cases, so that code relying on them can be
   detected and fixed.
 
-* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
-  learned to sanitize pre/post increment/decrement of types with bit width
-  smaller than ``int``.
-
 - For X86 target, -march=skylake-avx512, -march=icelake-client,
   -march=icelake-server, -march=cascadelake, -march=cooperlake will default to
   not using 512-bit zmm registers in vectorized code unless 512-bit intrinsics

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 953ced9168c5..822976640643 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2419,39 +2419,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const 
UnaryOperator *E, LValue LV,
 
   // Most common case by far: integer increment.
   } else if (type->isIntegerType()) {
-assert((!type->isPromotableIntegerType() ||
-(type->isSignedIntegerOrEnumerationType() ||
- CGF.getContext()
- .getPromotedIntegerType(type)
- ->isSignedIntegerOrEnumerationType())) &&
-   "The following check expects that if we do promotion, at least one "
-   "of the types (either base or promoted) will be signed.");
-if (CGF.SanOpts.hasOneOf(
-SanitizerKind::ImplicitIntegerArithmeticValueChange) &&
-type->isPromotableIntegerType()) {
-  // While `x += 1` (for `x` with width less than int) is modeled as
-  // promotion+arithmetics+demotion, and we can catch lossy demotion with
-  // ease; inc/dec with width less than int can't overflow because of
-  // promotion rules, so we omit promotion+demotion, which means that we 
can
-  // not catch lossy "demotion". Because we still want to catch these cases
-  // when the sanitizer is enabled, we perform the promotion, then perform
-  // the increment/decrement in the wider type, and finally
-  // perform the demotion. This will catch lossy demotions.
-
-  QualType promotedType = CGF.getContext().getPromotedIntegerType(type);
-  assert(promotedType != type && "Shouldn't promote to the same type.");
-  value = EmitScalarConversion(value, type, promotedType, E->getExprLoc());
-  Value *amt = llvm::ConstantInt::get(value->getType(), amount, true);
-  value = Builder.CreateAdd(value, amt, isInc ? "inc" : "dec");
-  // Do pass non-default ScalarConversionOpts so that sanitizer check is
-  // emitted.
-  value = EmitScalarConversion(value, promotedType, type, E->getExprLoc(),
-   ScalarConversionOpts(CGF.SanOpts));
-
-  // Note that signed integer inc/dec with width less than int can't
-  // overflow because of promotion rules; we're just eliding a few steps
-  // here.
-} else if (E->canOverflow() && type->isSignedIntegerOrEnumerationType()) {
+// Note that 

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

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

Build result: FAILURE - 
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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] D70769: [Support] add vfs support for ExpandResponseFiles

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



Comment at: llvm/include/llvm/Support/CommandLine.h:47
+class FileSystem;
+IntrusiveRefCntPtr getRealFileSystem();
+

now that we are also pulling the the function, I think it is OK to include the 
header instead.



Comment at: llvm/lib/Support/CommandLine.cpp:1073
 
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)

you can move this to the beginning of the function, to exit immediately, 
without checking for anything else.



Comment at: llvm/lib/Support/CommandLine.cpp:1074
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;

it is sad that, ExpandResponseFile returns a bool, but that's a battle for 
another day.

unfortunately, it is not enough return false in this case you need to consume 
the error with `llvm::consumeError` before exiting the scope.



Comment at: llvm/lib/Support/CommandLine.cpp:1146
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord ) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, ](const ResponseFileRecord ) {
+  SmallVector LHSPath;

there are `FileSystem::status` and `Status::equivalent` functions to implement 
`llvm::sys::fs:equivalent` behaviour


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

Aside from one nit, this looks okay to me. I'd like someone else to look at it 
though too. I'm not at all familiar with the file system stuff to be confident 
to say everything there is good.




Comment at: llvm/lib/Support/CommandLine.cpp:1148
+  SmallVector RHSPath;
+  if (FS.getRealPath(FName, LHSPath) || FS.getRealPath(RFile.File, 
RHSPath)) {
+return false;

Has this been clang-formatted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


  1   2   >