[PATCH] D33440: clang-format: better handle statement macros

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D33440



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D32478



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


Re: [PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Manuel Klimek via cfe-commits
On Thu, Nov 9, 2017 at 4:02 AM Richard Smith - zygoloid via Phabricator <
revi...@reviews.llvm.org> wrote:

> rsmith added a comment.
>
> I'm not entirely sure what's happening with this and
> https://reviews.llvm.org/D38818, but the direction looks good to me, and
> I left a couple of comments on the other review thread.
>

This patch had some of my comments addressed :(
(around how the interface is structured)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 122206.
sammccall added a comment.

Add test verifying that working directory is compile_flags's parent.


https://reviews.llvm.org/D39799

Files:
  docs/JSONCompilationDatabase.rst
  include/clang/Tooling/CompilationDatabase.h
  lib/Tooling/CompilationDatabase.cpp
  test/Tooling/Inputs/fixed-header.h
  test/Tooling/fixed-database.cpp

Index: test/Tooling/fixed-database.cpp
===
--- /dev/null
+++ test/Tooling/fixed-database.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/Src
+// RUN: cp "%s" "%t/Src/test.cpp"
+// RUN: mkdir -p %t/Include
+// RUN: cp "%S/Inputs/fixed-header.h" "%t/Include/"
+// -I flag is relative to %t (where compile_flags is), not Src/.
+// RUN: echo '-IInclude/' >> %t/compile_flags.txt
+// RUN: echo "-Dklazz=class" >> %t/compile_flags.txt
+// RUN: echo '-std=c++11' >> %t/compile_flags.txt
+// RUN: clang-check "%t/Src/test.cpp" 2>&1
+// RUN: not clang-check "%s" 2>&1 | FileCheck "%s" -check-prefix=NODB
+
+// NODB: unknown type name 'klazz'
+klazz F{};
+
+// NODB: 'fixed-header.h' file not found
+#include "fixed-header.h"
+static_assert(SECRET_SYMBOL == 1, "");
Index: test/Tooling/Inputs/fixed-header.h
===
--- /dev/null
+++ test/Tooling/Inputs/fixed-header.h
@@ -0,0 +1 @@
+#define SECRET_SYMBOL 1
Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -26,6 +26,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -302,8 +303,22 @@
   std::vector StrippedArgs;
   if (!stripPositionalArgs(CommandLine, StrippedArgs, ErrorMsg))
 return nullptr;
-  return std::unique_ptr(
-  new FixedCompilationDatabase(Directory, StrippedArgs));
+  return llvm::make_unique(Directory, StrippedArgs);
+}
+
+std::unique_ptr
+FixedCompilationDatabase::loadFromFile(StringRef Path, std::string ) {
+  ErrorMsg.clear();
+  llvm::ErrorOr File =
+  llvm::MemoryBuffer::getFile(Path);
+  if (std::error_code Result = File.getError()) {
+ErrorMsg = "Error while opening fixed database: " + Result.message();
+return nullptr;
+  }
+  std::vector Args{llvm::line_iterator(**File),
+llvm::line_iterator()};
+  return llvm::make_unique(
+  llvm::sys::path::parent_path(Path), std::move(Args));
 }
 
 FixedCompilationDatabase::
@@ -334,6 +349,22 @@
   return std::vector();
 }
 
+namespace {
+
+class FixedCompilationDatabasePlugin : public CompilationDatabasePlugin {
+  std::unique_ptr
+  loadFromDirectory(StringRef Directory, std::string ) override {
+SmallString<1024> DatabasePath(Directory);
+llvm::sys::path::append(DatabasePath, "compile_flags.txt");
+return FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);
+  }
+};
+
+static CompilationDatabasePluginRegistry::Add
+X("fixed-compilation-database", "Reads plain-text flags file");
+
+} // namespace
+
 namespace clang {
 namespace tooling {
 
Index: include/clang/Tooling/CompilationDatabase.h
===
--- include/clang/Tooling/CompilationDatabase.h
+++ include/clang/Tooling/CompilationDatabase.h
@@ -182,6 +182,11 @@
   int , const char *const *Argv, std::string ,
   Twine Directory = ".");
 
+  /// Reads flags from the given file, one-per line.
+  /// Returns nullptr and sets ErrorMessage if we can't read the file.
+  static std::unique_ptr
+  loadFromFile(StringRef Path, std::string );
+
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
   FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
Index: docs/JSONCompilationDatabase.rst
===
--- docs/JSONCompilationDatabase.rst
+++ docs/JSONCompilationDatabase.rst
@@ -91,3 +91,9 @@
 the top of the build directory. Clang tools are pointed to the top of
 the build directory to detect the file and use the compilation database
 to parse C++ code in the source tree.
+
+Alternatives
+
+For simple projects, Clang tools also recognize a compile_flags.txt file.
+This should contain one flag per line. The same flags will be used to compile
+any file.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33440: clang-format: better handle statement macros

2017-11-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Out of curiosity, will this be able to fix the two situations that you get for 
python extension?
There, you usually have a PyObject_HEAD with out semicolon in a struct and than 
a PyObject_HEAD_INIT(..) in a braced init list. More info:
http://starship.python.net/crew/mwh/toext/node20.html




Comment at: lib/Format/FormatTokenLexer.cpp:642
   tok::pp_define) &&
-std::find(ForEachMacros.begin(), ForEachMacros.end(),
-  FormatTok->Tok.getIdentifierInfo()) != ForEachMacros.end()) {
-  FormatTok->Type = TT_ForEachMacro;
+(it = std::find(Macros.begin(), Macros.end(),
+FormatTok->Tok.getIdentifierInfo())) != Macros.end()) {

Typz wrote:
> djasper wrote:
> > This does a binary search. Why aren't you implementing it with a hashtable?
> It was already done this way, so I did not change it to avoid any impact on 
> performance.
> But I can change it if you prefer.
Thanks. This is much better than it was before.



Comment at: lib/Format/FormatTokenLexer.cpp:630
   if (Style.isCpp()) {
+decltype(Macros)::iterator it;
 if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() &&

Just do:

  auto it = Macros.find(FormatTok->Tok.getIdentifierInfo());
  ..

I know that this means that we might do the hash look up when we wouldn't need 
to (when we are actually in a #define), but I think clarity here is more 
important than the tiny performance benefit.



Comment at: lib/Format/FormatTokenLexer.h:25
 #include "llvm/Support/Regex.h"
+#include 
 

Use ".



Comment at: lib/Format/UnwrappedLineParser.cpp:1254
 
+  if (Style.isCpp() && FormatTok->is(TT_StatementMacro)) {
+nextToken();

This contains the exact same code (I think). Can you pull it out into a 
function?


https://reviews.llvm.org/D33440



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


[PATCH] D33589: clang-format: consider not splitting tokens in optimization

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping ?


https://reviews.llvm.org/D33589



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-11-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D32478#806757, @Typz wrote:

> I renamed the option to `AlignAfterOperator`, is it acceptable now?
>  (I also thought of `UnindentOperator`, but I think it is better to keep the 
> notion of alignment)
>
> Note that this style is used in multiple open-source projects: Skia 
> , parts of QtCreator 
>  code base 
> (e.g. in multiple plugins: clang, cpptools, android...), the OpenEXR 
>  library...


Sorry for the long response time. I don't see this style rule expressed 
explicitly in the Skia or QtCreator style guides - is this something that just 
happens to be done sometimes in the code bases? I have problems understanding 
the rules from the discussion (as well as the code / test tbh), is there a 
really concise way to give me the core of the idea?


https://reviews.llvm.org/D32478



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


[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.

lg




Comment at: lib/Tooling/CompilationDatabase.cpp:312
+FixedCompilationDatabase::loadFromFile(StringRef Path, std::string ) {
+  ErrorMsg.clear();
+  llvm::ErrorOr File =

sammccall wrote:
> klimek wrote:
> > I assume we can't use ErrorOr as return value?
> Again this mirrors JSONCompilationDatabase. (And also 
> CompilationDatabasePlugin, which is harder to change)
> Change this one, change both, or leave as-is?
I think we want to add a FIXME to change the interface.


https://reviews.llvm.org/D39799



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


[PATCH] D39834: [ClangDriver] -foptimization-record-file= should imply -fsave-optimization-record

2017-11-09 Thread Dmitry Venikov via Phabricator via cfe-commits
Quolyk created this revision.
Herald added a subscriber: ilya-biryukov.

This is my first attempt to contribute to llvm. I'm trying to implement this 
https://bugs.llvm.org/show_bug.cgi?id=33670. I'm struggling with writing tests 
for this patch. I will be very thankful if somebody guides me trough writing 
tests for such thing. Thanks a lot.


https://reviews.llvm.org/D39834

Files:
  lib/Driver/ToolChains/Clang.cpp


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4376,6 +4376,11 @@
   llvm::sys::path::replace_extension(F, "opt.yaml");
   CmdArgs.push_back(Args.MakeArgString(F));
 }
+  } else {
+if (const Arg *A = 
Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
+  CmdArgs.push_back("-opt-record-file");
+  CmdArgs.push_back(A->getValue());
+}
   }
 
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,


Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4376,6 +4376,11 @@
   llvm::sys::path::replace_extension(F, "opt.yaml");
   CmdArgs.push_back(Args.MakeArgString(F));
 }
+  } else {
+if (const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ)) {
+  CmdArgs.push_back("-opt-record-file");
+  CmdArgs.push_back(A->getValue());
+}
   }
 
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317777 - [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Nov  9 02:37:39 2017
New Revision: 31

URL: http://llvm.org/viewvc/llvm-project?rev=31=rev
Log:
[Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

Summary:
This is an alternative to JSONCompilationDatabase for simple projects that
don't use a build system such as CMake.
(You can also drop one in ~, to make your tools use e.g. C++11 by default)

There's no facility for varying flags per-source-file or per-machine.
Possibly this could be accommodated backwards-compatibly using cpp, but even if
not the simplicity seems worthwhile for the cases that are addressed.

Tested with clangd, works great! (requires clangd restart)

Reviewers: klimek

Subscribers: ilya-biryukov, cfe-commits

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

Added:
cfe/trunk/test/Tooling/Inputs/fixed-header.h
cfe/trunk/test/Tooling/fixed-database.cpp
Modified:
cfe/trunk/docs/JSONCompilationDatabase.rst
cfe/trunk/include/clang/Tooling/CompilationDatabase.h
cfe/trunk/lib/Tooling/CompilationDatabase.cpp

Modified: cfe/trunk/docs/JSONCompilationDatabase.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/JSONCompilationDatabase.rst?rev=31=317776=31=diff
==
--- cfe/trunk/docs/JSONCompilationDatabase.rst (original)
+++ cfe/trunk/docs/JSONCompilationDatabase.rst Thu Nov  9 02:37:39 2017
@@ -91,3 +91,9 @@ The convention is to name the file compi
 the top of the build directory. Clang tools are pointed to the top of
 the build directory to detect the file and use the compilation database
 to parse C++ code in the source tree.
+
+Alternatives
+
+For simple projects, Clang tools also recognize a compile_flags.txt file.
+This should contain one flag per line. The same flags will be used to compile
+any file.

Modified: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/CompilationDatabase.h?rev=31=317776=31=diff
==
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h (original)
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h Thu Nov  9 02:37:39 
2017
@@ -182,6 +182,11 @@ public:
   int , const char *const *Argv, std::string ,
   Twine Directory = ".");
 
+  /// Reads flags from the given file, one-per line.
+  /// Returns nullptr and sets ErrorMessage if we can't read the file.
+  static std::unique_ptr
+  loadFromFile(StringRef Path, std::string );
+
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
   FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);

Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=31=317776=31=diff
==
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Thu Nov  9 02:37:39 2017
@@ -10,6 +10,9 @@
 //  This file contains implementations of the CompilationDatabase base class
 //  and the FixedCompilationDatabase.
 //
+//  FIXME: Various functions that take a string  should be 
upgraded
+//  to Expected.
+//
 
//===--===//
 
 #include "clang/Tooling/CompilationDatabase.h"
@@ -26,6 +29,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -302,8 +306,22 @@ FixedCompilationDatabase::loadFromComman
   std::vector StrippedArgs;
   if (!stripPositionalArgs(CommandLine, StrippedArgs, ErrorMsg))
 return nullptr;
-  return std::unique_ptr(
-  new FixedCompilationDatabase(Directory, StrippedArgs));
+  return llvm::make_unique(Directory, StrippedArgs);
+}
+
+std::unique_ptr
+FixedCompilationDatabase::loadFromFile(StringRef Path, std::string ) {
+  ErrorMsg.clear();
+  llvm::ErrorOr File =
+  llvm::MemoryBuffer::getFile(Path);
+  if (std::error_code Result = File.getError()) {
+ErrorMsg = "Error while opening fixed database: " + Result.message();
+return nullptr;
+  }
+  std::vector Args{llvm::line_iterator(**File),
+llvm::line_iterator()};
+  return llvm::make_unique(
+  llvm::sys::path::parent_path(Path), std::move(Args));
 }
 
 FixedCompilationDatabase::
@@ -334,6 +352,22 @@ FixedCompilationDatabase::getAllCompileC
   return std::vector();
 }
 
+namespace {
+
+class FixedCompilationDatabasePlugin : public CompilationDatabasePlugin {
+  std::unique_ptr
+  loadFromDirectory(StringRef Directory, std::string ) override {
+SmallString<1024> 

[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL31: [Tooling] Use FixedCompilationDatabase when 
`compile_flags.txt` is found. (authored by sammccall).

Repository:
  rL LLVM

https://reviews.llvm.org/D39799

Files:
  cfe/trunk/docs/JSONCompilationDatabase.rst
  cfe/trunk/include/clang/Tooling/CompilationDatabase.h
  cfe/trunk/lib/Tooling/CompilationDatabase.cpp
  cfe/trunk/test/Tooling/Inputs/fixed-header.h
  cfe/trunk/test/Tooling/fixed-database.cpp

Index: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp
@@ -10,6 +10,9 @@
 //  This file contains implementations of the CompilationDatabase base class
 //  and the FixedCompilationDatabase.
 //
+//  FIXME: Various functions that take a string  should be upgraded
+//  to Expected.
+//
 //===--===//
 
 #include "clang/Tooling/CompilationDatabase.h"
@@ -26,6 +29,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -302,8 +306,22 @@
   std::vector StrippedArgs;
   if (!stripPositionalArgs(CommandLine, StrippedArgs, ErrorMsg))
 return nullptr;
-  return std::unique_ptr(
-  new FixedCompilationDatabase(Directory, StrippedArgs));
+  return llvm::make_unique(Directory, StrippedArgs);
+}
+
+std::unique_ptr
+FixedCompilationDatabase::loadFromFile(StringRef Path, std::string ) {
+  ErrorMsg.clear();
+  llvm::ErrorOr File =
+  llvm::MemoryBuffer::getFile(Path);
+  if (std::error_code Result = File.getError()) {
+ErrorMsg = "Error while opening fixed database: " + Result.message();
+return nullptr;
+  }
+  std::vector Args{llvm::line_iterator(**File),
+llvm::line_iterator()};
+  return llvm::make_unique(
+  llvm::sys::path::parent_path(Path), std::move(Args));
 }
 
 FixedCompilationDatabase::
@@ -334,6 +352,22 @@
   return std::vector();
 }
 
+namespace {
+
+class FixedCompilationDatabasePlugin : public CompilationDatabasePlugin {
+  std::unique_ptr
+  loadFromDirectory(StringRef Directory, std::string ) override {
+SmallString<1024> DatabasePath(Directory);
+llvm::sys::path::append(DatabasePath, "compile_flags.txt");
+return FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);
+  }
+};
+
+static CompilationDatabasePluginRegistry::Add
+X("fixed-compilation-database", "Reads plain-text flags file");
+
+} // namespace
+
 namespace clang {
 namespace tooling {
 
Index: cfe/trunk/docs/JSONCompilationDatabase.rst
===
--- cfe/trunk/docs/JSONCompilationDatabase.rst
+++ cfe/trunk/docs/JSONCompilationDatabase.rst
@@ -91,3 +91,9 @@
 the top of the build directory. Clang tools are pointed to the top of
 the build directory to detect the file and use the compilation database
 to parse C++ code in the source tree.
+
+Alternatives
+
+For simple projects, Clang tools also recognize a compile_flags.txt file.
+This should contain one flag per line. The same flags will be used to compile
+any file.
Index: cfe/trunk/include/clang/Tooling/CompilationDatabase.h
===
--- cfe/trunk/include/clang/Tooling/CompilationDatabase.h
+++ cfe/trunk/include/clang/Tooling/CompilationDatabase.h
@@ -182,6 +182,11 @@
   int , const char *const *Argv, std::string ,
   Twine Directory = ".");
 
+  /// Reads flags from the given file, one-per line.
+  /// Returns nullptr and sets ErrorMessage if we can't read the file.
+  static std::unique_ptr
+  loadFromFile(StringRef Path, std::string );
+
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
   FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
Index: cfe/trunk/test/Tooling/fixed-database.cpp
===
--- cfe/trunk/test/Tooling/fixed-database.cpp
+++ cfe/trunk/test/Tooling/fixed-database.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/Src
+// RUN: cp "%s" "%t/Src/test.cpp"
+// RUN: mkdir -p %t/Include
+// RUN: cp "%S/Inputs/fixed-header.h" "%t/Include/"
+// -I flag is relative to %t (where compile_flags is), not Src/.
+// RUN: echo '-IInclude/' >> %t/compile_flags.txt
+// RUN: echo "-Dklazz=class" >> %t/compile_flags.txt
+// RUN: echo '-std=c++11' >> %t/compile_flags.txt
+// RUN: clang-check "%t/Src/test.cpp" 2>&1
+// RUN: not clang-check "%s" 2>&1 | FileCheck "%s" -check-prefix=NODB
+
+// NODB: unknown type name 'klazz'
+klazz F{};
+
+// NODB: 'fixed-header.h' file not found
+#include "fixed-header.h"
+static_assert(SECRET_SYMBOL == 

[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D39799#919508, @ilya-biryukov wrote:

> In https://reviews.llvm.org/D39799#919494, @sammccall wrote:
>
> > e.g. IIUC, things like `#include "sibling.h"` won't look for the h file 
> > next to the cc file?
>
>
> Actually, this should work as quoted includes are always searched relative to 
> the current file before looking in the include paths. No matter what the WD 
> is.


Right, thanks :-)

>> Ideally yes... i'm not sure this is so easy with the registry mechanism 
>> though :-(
>>  They'd have to be present at the same level, so I'm not sure this is a huge 
>> deal.
> 
> Yeah, looks like this would require unifying `FixedCompilationDatabase` and 
> `JSONCompilationDatabase`. This doesn't seem too crazy, though. "A class that 
> handles reading compilation arguments from the filesystem." seems like a 
> valid entity to me.

It's doable, but then you're fighting the infrastructure here. The same 
ambiguity can exist between any pair of CompilationDatabasePlugins (try dumping 
a compile_commands.json in a google source tree). If we want to make this an 
error or have well-defined priority, that should be handled by 
autoDetectFromDirectory I think.

(Happy to do that if you think it's important - personally I'm not convinced it 
will be an issue in practice)


https://reviews.llvm.org/D39799



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Next time, please remember to add `cfe-commits` to the subscriber.




Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:14
+
+#include 
+

Do we need this header?



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:25
+/// we will do best effort to generate a fix, however, if the
+/// case can not be solved with a simple fix (e.g. remove prefix or change 
first
+/// character), we will leave the fix to the user.

I might miss some background context. 

The fix of the check seems to me that it does more things it should. It removes 
all the non-alphabetical prefix characters, I'd be conservative of the fix here 
(just fix the case "CamelCase", and only give a warning for other cases).



Comment at: docs/clang-tidy/checks/objc-property-declaration.rst:7
+Finds property declarations in Objective-C files that do not follow the pattern
+of property names in Google's Objective-C Style Guide. The property name should
+be in the format of Lower Camel Case.

Google style? but the link you provided is Apple.



Comment at: docs/clang-tidy/checks/objc-property-declaration.rst:27
+The corresponding style rule: 
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757
\ No newline at end of file


nit: add a newline.


https://reviews.llvm.org/D39829



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


[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added a comment.

In https://reviews.llvm.org/D39114#914098, @kubamracek wrote:

> Hi and sorry for replying so late! All of the changes LGTM with a few nits.


All good, thanks for having a look!

>> Assembly for Darwin x86_64 and how we avoid the ELF'isms (do we need to 
>> implement darwin-specific assembly for MachO?)
> 
> This should be actually easily solvable by `#include`'ing 
> sanitizer_common/sanitizer_asm.h and then using the macros from there 
> (perhaps introducing some new macros or generalizing the existing ones). Take 
> a look at what was done in lib/tsan/rtl/tsan_rtl_amd64.S. Names of symbols 
> should use a macro like `ASM_SYMBOL` which will add an underscore on macOS. 
> `.type` directives should use `ASM_TYPE_FUNCTION`. And so on. It should be 
> possible to reuse almost all of the assembly instructions unchanged. I think 
> I have an ugly old patch for this somewhere, I can send it to you if you want.

Thanks for the hints, that was easy enough!

>> Syscalls, testing, etc. -- whether we need to do anything special here for 
>> making it work on macOS.
> 
> We should try to move most of the tests in the Linux directory to a common 
> tests directory. I don't see anything particularly Linux-y there.

Agreed. Let me make a few of those changes.

> Regarding syscalls, I'm not sure I understand the problem. Is XRay doing any 
> syscall interception or something like that?

Nope, just calling mmap and mprotect -- which should just be available on 
macOS. :)




Comment at: compiler-rt/lib/xray/CMakeLists.txt:82
+  add_compiler_rt_runtime(clang_rt.xray
+STATIC
+OS osx

kubamracek wrote:
> `STATIC` is okay for now, but we have much better experience with dynamic 
> libraries for runtimes. Is there some reason to use a static library?
Let me try with a `SHARED` build, and report back.



Comment at: compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc:12
+// RUN:FileCheck %s --check-prefix ALWAYSINSTR
+// REQUIRES: x86_64-linux
+// REQUIRES: built-in-llvm-tree

kubamracek wrote:
> Should this `REQUIRES` be here?
> 
> Similarly, in all the tests in the `Linux/` directory, we should change 
> `REQUIRES: x86_64-linux` to just `REQUIRES: x86_64`.
Not anymore, let me change that next.


https://reviews.llvm.org/D39114



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


[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 122210.
dberris marked an inline comment as done.
dberris added a comment.

- fixup: Use ASM macros for darwin assembly
- fixup: support weak symbols for Darwin linkage


https://reviews.llvm.org/D39114

Files:
  clang/lib/Driver/XRayArgs.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/xray/CMakeLists.txt
  compiler-rt/lib/xray/tests/CMakeLists.txt
  compiler-rt/lib/xray/weak_symbols.txt
  compiler-rt/lib/xray/xray_init.cc
  compiler-rt/lib/xray/xray_trampoline_x86_64.S
  compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
  compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
  compiler-rt/test/xray/TestCases/Linux/lit.local.cfg
  compiler-rt/test/xray/lit.cfg

Index: compiler-rt/test/xray/lit.cfg
===
--- compiler-rt/test/xray/lit.cfg
+++ compiler-rt/test/xray/lit.cfg
@@ -40,7 +40,7 @@
 # Default test suffixes.
 config.suffixes = ['.c', '.cc', '.cpp']
 
-if config.host_os not in ['Linux']:
+if config.host_os not in ['Linux', 'Darwin']:
   config.unsupported = True
 elif '64' not in config.host_arch:
   if 'arm' in config.host_arch:
Index: compiler-rt/test/xray/TestCases/Linux/lit.local.cfg
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Linux/lit.local.cfg
@@ -0,0 +1,9 @@
+def getRoot(config):
+  if not config.parent:
+return config
+  return getRoot(config.parent)
+
+root = getRoot(config)
+
+if root.host_os not in ['Linux']:
+  config.unsupported = True
Index: compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
@@ -0,0 +1,9 @@
+def getRoot(config):
+  if not config.parent:
+return config
+  return getRoot(config.parent)
+
+root = getRoot(config)
+
+if root.host_os not in ['Darwin']:
+  config.unsupported = True
Index: compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
@@ -0,0 +1,23 @@
+// Test that the always/never instrument lists apply.
+// RUN: echo "fun:main" > %tmp-always.txt
+// RUN: echo "fun:__xray*" > %tmp-never.txt
+// RUN: %clangxx_xray \
+// RUN: -fxray-never-instrument=%tmp-never.txt \
+// RUN: -fxray-always-instrument=%tmp-always.txt \
+// RUN: %s -o %t
+// RUN: %llvm_xray extract -symbolize %t | \
+// RUN:FileCheck %s --check-prefix NOINSTR
+// RUN: %llvm_xray extract -symbolize %t | \
+// RUN:FileCheck %s --check-prefix ALWAYSINSTR
+// REQUIRES: x86_64-linux
+// REQUIRES: built-in-llvm-tree
+
+// NOINSTR-NOT: {{.*__xray_NeverInstrumented.*}}
+int __xray_NeverInstrumented() {
+  return 0;
+}
+
+// ALWAYSINSTR: {{.*function-name:.*main.*}}
+int main(int argc, char *argv[]) {
+  return __xray_NeverInstrumented();
+}
Index: compiler-rt/lib/xray/xray_trampoline_x86_64.S
===
--- compiler-rt/lib/xray/xray_trampoline_x86_64.S
+++ compiler-rt/lib/xray/xray_trampoline_x86_64.S
@@ -14,10 +14,11 @@
 //===--===//
 
 #include "../builtins/assembly.h"
+#include "../sanitizer_common/sanitizer_asm.h"
 
 .macro SAVE_REGISTERS
 	subq $192, %rsp
-	.cfi_def_cfa_offset 200
+	CFI_DEF_CFA_OFFSET(200)
 	// At this point, the stack pointer should be aligned to an 8-byte boundary,
 	// because any call instructions that come after this will add another 8
 	// bytes and therefore align it to 16-bytes.
@@ -57,20 +58,23 @@
 	movq	8(%rsp), %r8
 	movq	0(%rsp), %r9
 	addq	$192, %rsp
-	.cfi_def_cfa_offset 8
+	CFI_DEF_CFA_OFFSET(8)
 .endm
 
-	.text
+#if !defined(__APPLE__)
+	.section .text
+#else
+	.section __TEXT,__text
+#endif
 	.file "xray_trampoline_x86.S"
 
 //===--===//
 
 	.globl __xray_FunctionEntry
 	.align 16, 0x90
-	.type __xray_FunctionEntry,@function
-
+	ASM_TYPE_FUNCTION(__xray_FunctionEntry)
 __xray_FunctionEntry:
-	.cfi_startproc
+	CFI_STARTPROC
 	SAVE_REGISTERS
 
 	// This load has to be atomic, it's concurrent with __xray_patch().
@@ -86,22 +90,21 @@
 .Ltmp0:
 	RESTORE_REGISTERS
 	retq
-.Ltmp1:
-	.size __xray_FunctionEntry, .Ltmp1-__xray_FunctionEntry
-	.cfi_endproc
+	ASM_SIZE(__xray_FunctionEntry)
+	CFI_ENDPROC
 
 //===--===//
 
 	.globl __xray_FunctionExit
 	.align 16, 0x90
-	.type __xray_FunctionExit,@function
+	ASM_TYPE_FUNCTION(__xray_FunctionExit)
 __xray_FunctionExit:
-	.cfi_startproc
+	CFI_STARTPROC
 	// Save the important registers first. Since we're assuming that this
 	// function is only jumped into, we only preserve the registers for
 	// returning.
 	subq	$56, %rsp
-	.cfi_def_cfa_offset 64
+	

[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> Sorry for the long response time. I don't see this style rule expressed 
> explicitly in the Skia or QtCreator style guides - is this something that 
> just happens to be done sometimes in the code bases?

This is present in code base. Those project's style guides are not precise 
enough, and do not document the behavior for this case.

> I have problems understanding the rules from the discussion (as well as the 
> code / test tbh), is there a really concise way to give me the core of the 
> idea?

The case I am trying to address is to really keep the _operands_ aligned after 
an assignment or `return`, in case line is wrapped *before* the operator.

  int a = b
+ c;
  return a
   + b;

while the current behavior with `Style.AlignOperands = true; 
BreakBeforeBinaryOperators = true` is to align the wrapped operator with the 
previous line's operand:

  int a = b
  + c;
  return a
 + b;

In the discussion, it appeared that this behavior is not a error (with respect 
to the name), but an expected behavior for most coding rules: hence the 
introduction of a third AlignOperands mode ("AlignAfterOperator"), to handle 
this new case.

From there the code actually got a bit more complex to support various corner 
cases (e.g. operators with different number of characters, wrapperd first line, 
do not unindent more than the enclosing brace...)


https://reviews.llvm.org/D32478



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


[PATCH] D37813: clang-format: better handle namespace macros

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

ping?


https://reviews.llvm.org/D37813



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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a subscriber: klimek.
ilya-biryukov added a comment.

I personally think they're useful to have anyway, and they don't add much noise 
when they're at the end of completions list.
I sometimes want to complete an item I know is there and then fix 
accessibility. Do you think they add too much noise?

I think I'm almost alone in this camp, though. (I remember @klimek saying he 
thinks they're sometimes useful too, but I may be mistaken)


https://reviews.llvm.org/D39836



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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

This is probably one of the things that I'd like to be configurable.

In https://reviews.llvm.org/D39836#920313, @sammccall wrote:

> - they bulk up tests and debugging output


I'd argue that the more you put into tests, the more potential errors you'll 
see. E.g. if we're not showing private members, we might miss some presentation 
issues that only those exhibit. And you can always leave them out in tests in 
case you only want to test the public ones (though that's not a good idea, 
probably).
As for debugging, I don't LSP is any good as a debugging format anyway, we 
probably want some different form of output.

> - they complicate the scoring scheme - we *never* want them to appear above a 
> legal completion, so a 1-dimensional score needs special handling as here.

We could always use a 2-dimensional score `(accessible, sort_score)`. I'd love 
to have some editor support to grey-out some items (not only inaccessible, 
deprecated items could have been somehow signalled in completion UI as well), 
probably requires some changes to LSP too and not a priority, though.

> - compute: we spend time scoring them, computing their strings, writing them 
> over the wire, and then the client has to process them

I don't think it matters much, given that there aren't many items that are 
inaccessible compared to the total number of completion items when it's slow 
(they are all class members, but the biggest portion of items come from 
namespaces). And after-dot completion is usually fast (and when it's slow it's 
because reparse is slow, not because we take too much time to process the 
items).

That being said, I don't think there's a chance I'll argue my way through this. 
Let's turn them off and see if someone (besides me) complains. LGTM.


https://reviews.llvm.org/D39836



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


[PATCH] D39505: [OpenMP] Show error if VLAs are not supported

2017-11-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/TargetInfo.h:944
+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+

ABataev wrote:
> ABataev wrote:
> > Hahnfeld wrote:
> > > rjmccall wrote:
> > > > Hahnfeld wrote:
> > > > > rjmccall wrote:
> > > > > > Hahnfeld wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > The way you've written this makes it sound like "does the 
> > > > > > > > target support VLAs?", but the actual semantic checks treat it 
> > > > > > > > as "do OpenMP devices on this target support VLAs?"  Maybe 
> > > > > > > > there should be a more specific way to query things about 
> > > > > > > > OpenMP devices instead of setting a global flag for the target?
> > > > > > > Actually, the NVPTX and SPIR targets never support VLAs. So I 
> > > > > > > felt like it would be more correct to make this a global property 
> > > > > > > of the target.
> > > > > > > 
> > > > > > > The difference is that the other programming models (OpenCL and 
> > > > > > > CUDA) error out immediatelyand regardless of the target because 
> > > > > > > this limitation is reflected in the standards that disallow VLAs 
> > > > > > > (see SemaType.cpp). For OpenMP we might have target devices that 
> > > > > > > support VLA so we shouldn't error out for those.
> > > > > > If you want to make it a global property of the target, that's 
> > > > > > fine, but then I don't understand why your diagnostic only fires 
> > > > > > when (S.isInOpenMPDeclareTargetContext() || 
> > > > > > S.isInOpenMPTargetExecutionDirective()).
> > > > > That is because of how OpenMP offloading works and how it is 
> > > > > implemented in Clang. Consider the following snippet from the added 
> > > > > test case:
> > > > > ```lang=c
> > > > > int vla[arg];
> > > > > 
> > > > > #pragma omp target map(vla[0:arg])
> > > > > {
> > > > >// more code here...
> > > > > }
> > > > > ```
> > > > > 
> > > > > Clang will take the following steps to compile this into a working 
> > > > > binary for a GPU:
> > > > > 1. Parse and (semantically) analyze the code as-is for the host and 
> > > > > produce LLVM Bitcode.
> > > > > 2. Parse and analyze again the code as-is and generate code for the 
> > > > > offloading target, the GPU in this case.
> > > > > 3. Take LLVM Bitcode from 1., generate host binary and embed target 
> > > > > binary from 3.
> > > > > 
> > > > > `OpenMPIsDevice` will be true for 2., but the complete source code is 
> > > > > analyzed. So to not throw errors for the host code, we have to make 
> > > > > sure that we are actually generating code for the target device. This 
> > > > > is either in a `target` directive or in a `declare target` region.
> > > > > Note that this is quite similar to what CUDA does, only they have 
> > > > > `CUDADiagIfDeviceCode` for this logic. If you want me to add 
> > > > > something of that kind for OpenMP target devices, I'm fine with that. 
> > > > > However for the given case, it's a bit different because this error 
> > > > > should only be thrown for target devices that don't support VLAs...
> > > > I see.  So the entire translation unit is re-parsed and re-Sema'ed from 
> > > > scratch for the target?  Which means you need to avoid generating 
> > > > errors about things in the outer translation unit that aren't part of 
> > > > the target directive that you actually want to compile.  I would've 
> > > > expected there to be some existing mechanism for that, to be honest, as 
> > > > opposed to explicitly trying to suppress target-specific diagnostics 
> > > > one by one.
> > > Yes, that is my understanding. For errors, we don't need to take anything 
> > > special as the first `cc1` invocation will exit with a non-zero status so 
> > > that the driver stops the compilation. For warnings, there seems to be no 
> > > mechanism in place as I see them duplicated, even in code that is not 
> > > generate for the target device (verified with an unused variable).
> > > 
> > > @ABataev @gtbercea Do I miss something here?
> > I'm not aware of any.
> John, target-specific checks require some special flags (like LangOpts.Cuda) 
> that are not set when we re-compile the code for OpenMP devices. That's why 
> errors are not emitted for the non-target code. But also because of that, we 
> need some special OpenMP checks for target-specific code inside the target 
> regions. For example, code in lib/Sema/SemaType.cpp, lines 2184, 2185 (see 
> this file in this patch) checks for Cuda compilation and prohibits using of 
> VLAs in Cuda mode. We also should prohibit using of VLAs in target code for 
> NVPTX devices or other devices that do not support VLAs in OpenMP mode.
I think it would be cleaner here, and better for our OpenMP support overall, if 
we found a more general way to suppress unwanted diagnostics in the second 
invocation for code outside of the target directive.  This check (and 

[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D39799#920195, @sammccall wrote:

> It's doable, but then you're fighting the infrastructure here. The same 
> ambiguity can exist between any pair of CompilationDatabasePlugins (try 
> dumping a compile_commands.json in a google source tree). If we want to make 
> this an error or have well-defined priority, that should be handled by 
> autoDetectFromDirectory I think.
>
> (Happy to do that if you think it's important - personally I'm not convinced 
> it will be an issue in practice)


Yeah, I'm not sure if that's an issue either. Let's see whether anyone will be 
using both `compile_flags.txt` and `compile_commands.json` in the first place. 
We can always do it later.
Oh, and LGTM from my side!


https://reviews.llvm.org/D39799



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


[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 122211.
sammccall added a comment.

Add fixme to upgrade out-param APIs.


https://reviews.llvm.org/D39799

Files:
  docs/JSONCompilationDatabase.rst
  include/clang/Tooling/CompilationDatabase.h
  lib/Tooling/CompilationDatabase.cpp
  test/Tooling/Inputs/fixed-header.h
  test/Tooling/fixed-database.cpp

Index: test/Tooling/fixed-database.cpp
===
--- /dev/null
+++ test/Tooling/fixed-database.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/Src
+// RUN: cp "%s" "%t/Src/test.cpp"
+// RUN: mkdir -p %t/Include
+// RUN: cp "%S/Inputs/fixed-header.h" "%t/Include/"
+// -I flag is relative to %t (where compile_flags is), not Src/.
+// RUN: echo '-IInclude/' >> %t/compile_flags.txt
+// RUN: echo "-Dklazz=class" >> %t/compile_flags.txt
+// RUN: echo '-std=c++11' >> %t/compile_flags.txt
+// RUN: clang-check "%t/Src/test.cpp" 2>&1
+// RUN: not clang-check "%s" 2>&1 | FileCheck "%s" -check-prefix=NODB
+
+// NODB: unknown type name 'klazz'
+klazz F{};
+
+// NODB: 'fixed-header.h' file not found
+#include "fixed-header.h"
+static_assert(SECRET_SYMBOL == 1, "");
Index: test/Tooling/Inputs/fixed-header.h
===
--- /dev/null
+++ test/Tooling/Inputs/fixed-header.h
@@ -0,0 +1 @@
+#define SECRET_SYMBOL 1
Index: lib/Tooling/CompilationDatabase.cpp
===
--- lib/Tooling/CompilationDatabase.cpp
+++ lib/Tooling/CompilationDatabase.cpp
@@ -10,6 +10,9 @@
 //  This file contains implementations of the CompilationDatabase base class
 //  and the FixedCompilationDatabase.
 //
+//  FIXME: Various functions that take a string  should be upgraded
+//  to Expected.
+//
 //===--===//
 
 #include "clang/Tooling/CompilationDatabase.h"
@@ -26,6 +29,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/LineIterator.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -302,8 +306,22 @@
   std::vector StrippedArgs;
   if (!stripPositionalArgs(CommandLine, StrippedArgs, ErrorMsg))
 return nullptr;
-  return std::unique_ptr(
-  new FixedCompilationDatabase(Directory, StrippedArgs));
+  return llvm::make_unique(Directory, StrippedArgs);
+}
+
+std::unique_ptr
+FixedCompilationDatabase::loadFromFile(StringRef Path, std::string ) {
+  ErrorMsg.clear();
+  llvm::ErrorOr File =
+  llvm::MemoryBuffer::getFile(Path);
+  if (std::error_code Result = File.getError()) {
+ErrorMsg = "Error while opening fixed database: " + Result.message();
+return nullptr;
+  }
+  std::vector Args{llvm::line_iterator(**File),
+llvm::line_iterator()};
+  return llvm::make_unique(
+  llvm::sys::path::parent_path(Path), std::move(Args));
 }
 
 FixedCompilationDatabase::
@@ -334,6 +352,22 @@
   return std::vector();
 }
 
+namespace {
+
+class FixedCompilationDatabasePlugin : public CompilationDatabasePlugin {
+  std::unique_ptr
+  loadFromDirectory(StringRef Directory, std::string ) override {
+SmallString<1024> DatabasePath(Directory);
+llvm::sys::path::append(DatabasePath, "compile_flags.txt");
+return FixedCompilationDatabase::loadFromFile(DatabasePath, ErrorMessage);
+  }
+};
+
+static CompilationDatabasePluginRegistry::Add
+X("fixed-compilation-database", "Reads plain-text flags file");
+
+} // namespace
+
 namespace clang {
 namespace tooling {
 
Index: include/clang/Tooling/CompilationDatabase.h
===
--- include/clang/Tooling/CompilationDatabase.h
+++ include/clang/Tooling/CompilationDatabase.h
@@ -182,6 +182,11 @@
   int , const char *const *Argv, std::string ,
   Twine Directory = ".");
 
+  /// Reads flags from the given file, one-per line.
+  /// Returns nullptr and sets ErrorMessage if we can't read the file.
+  static std::unique_ptr
+  loadFromFile(StringRef Path, std::string );
+
   /// \brief Constructs a compilation data base from a specified directory
   /// and command line.
   FixedCompilationDatabase(Twine Directory, ArrayRef CommandLine);
Index: docs/JSONCompilationDatabase.rst
===
--- docs/JSONCompilationDatabase.rst
+++ docs/JSONCompilationDatabase.rst
@@ -91,3 +91,9 @@
 the top of the build directory. Clang tools are pointed to the top of
 the build directory to detect the file and use the compilation database
 to parse C++ code in the source tree.
+
+Alternatives
+
+For simple projects, Clang tools also recognize a compile_flags.txt file.
+This should contain one flag per line. The same flags will be used to compile
+any file.
___
cfe-commits mailing list

[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

(There must be some reason why https://reviews.llvm.org/D38077 didn't just do 
this, but I don't get it!)


https://reviews.llvm.org/D39836

Files:
  clangd/ClangdUnit.cpp
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test

Index: test/clangd/completion-qualifiers.test
===
--- test/clangd/completion-qualifiers.test
+++ test/clangd/completion-qualifiers.test
@@ -11,7 +11,7 @@
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": [
-# Eligible const functions are at the top of the list.
+# Eligible functions are at the top of the list.
 # CHECK-NEXT:{
 # CHECK-NEXT:  "detail": "int",
 # CHECK-NEXT:  "filterText": "bar",
@@ -30,17 +30,9 @@
 # CHECK-NEXT:  "label": "Foo::foo() const",
 # CHECK-NEXT:  "sortText": "37foo"
 # CHECK-NEXT:},
-# Ineligible non-const function is at the bottom of the list.
-# CHECK-NEXT:{
-#  CHECK:  "detail": "int",
-#  CHECK:  "filterText": "foo",
-# CHECK-NEXT:  "insertText": "foo",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "foo() const",
-# CHECK-NEXT:  "sortText": "200035foo"
-# CHECK-NEXT:}
-# CHECK-NEXT:  ]
+# Ineligible private functions are not present.
+#  CHECK-NOT:  "label": "foo() const",
+#  CHECK:  ]
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":4,"method":"shutdown"}
Index: test/clangd/completion-priorities.test
===
--- test/clangd/completion-priorities.test
+++ test/clangd/completion-priorities.test
@@ -57,27 +57,10 @@
 # CHECK-NEXT:  "kind": 2,
 # CHECK-NEXT:  "label": "pub()",
 # CHECK-NEXT:  "sortText": "34pub"
-# CHECK-NEXT:},
-# priv() and prot() are at the end of the list
-# CHECK-NEXT:{
-#  CHECK:  "detail": "void",
-#  CHECK:  "filterText": "priv",
-# CHECK-NEXT:  "insertText": "priv",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "priv()",
-# CHECK-NEXT:  "sortText": "200034priv"
-# CHECK-NEXT:},
-# CHECK-NEXT:{
-# CHECK-NEXT:  "detail": "void",
-# CHECK-NEXT:  "filterText": "prot",
-# CHECK-NEXT:  "insertText": "prot",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 2,
-# CHECK-NEXT:  "label": "prot()",
-# CHECK-NEXT:  "sortText": "200034prot"
 # CHECK-NEXT:}
-# CHECK-NEXT:  ]
+#  CHECK-NOT:  "label": "priv()",
+#  CHECK-NOT:  "label": "prot()",
+#  CHECK:  ]
 Content-Length: 58
 
 {"jsonrpc":"2.0","id":4,"method":"shutdown","params":null}
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -383,6 +383,9 @@
 Items.reserve(NumResults);
 for (unsigned I = 0; I < NumResults; ++I) {
   auto  = Results[I];
+  if (Result.Availability == CXAvailability_NotAvailable ||
+  Result.Availability == CXAvailability_NotAccessible)
+continue;
   const auto *CCS = Result.CreateCodeCompletionString(
   S, Context, *Allocator, CCTUInfo,
   CodeCompleteOpts.IncludeBriefComments);
@@ -428,23 +431,8 @@
 // Fill in the sortText of the CompletionItem.
 assert(Score <= 9 && "Expecting code completion result "
  "priority to have at most 5-digits");
-
-const int Penalty = 10;
-switch (static_cast(CCS.getAvailability())) {
-case CXAvailability_Available:
-  // No penalty.
-  break;
-case CXAvailability_Deprecated:
-  Score += Penalty;
-  break;
-case CXAvailability_NotAccessible:
-  Score += 2 * Penalty;
-  break;
-case CXAvailability_NotAvailable:
-  Score += 3 * Penalty;
-  break;
-}
-
+if (CCS.getAvailability() == CXAvailability_Deprecated)
+  Score += 10;
 return Score;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39831: [Driver] Make the use of relax relocations a per target option

2017-11-09 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

The support for relax relocations is dependent on the linker and
different toolchains within the same compiler can be using different
linkers some of which may or may not support relax relocations.

  

Give toolchains the option to control whether they want to use relax
relocations in addition to the existing (global) build system option.


Repository:
  rL LLVM

https://reviews.llvm.org/D39831

Files:
  cmake/caches/Fuchsia-stage2.cmake
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Fuchsia.h


Index: lib/Driver/ToolChains/Fuchsia.h
===
--- lib/Driver/ToolChains/Fuchsia.h
+++ lib/Driver/ToolChains/Fuchsia.h
@@ -43,6 +43,7 @@
   bool HasNativeLLVMSupport() const override { return true; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
+  bool useRelaxRelocations() const override { return true; };
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1885,7 +1885,7 @@
   // arg after parsing the '-I' arg.
   bool TakeNextArg = false;
 
-  bool UseRelaxRelocations = ENABLE_X86_RELAX_RELOCATIONS;
+  bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
   const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -90,6 +90,10 @@
   IsIntegratedAssemblerDefault());
 }
 
+bool ToolChain::useRelaxRelocations() const {
+  return ENABLE_X86_RELAX_RELOCATIONS;
+}
+
 const SanitizerArgs& ToolChain::getSanitizerArgs() const {
   if (!SanitizerArguments.get())
 SanitizerArguments.reset(new SanitizerArgs(*this, Args));
Index: include/clang/Driver/ToolChain.h
===
--- include/clang/Driver/ToolChain.h
+++ include/clang/Driver/ToolChain.h
@@ -310,6 +310,9 @@
   /// mixed dispatch method be used?
   virtual bool UseObjCMixedDispatch() const { return false; }
 
+  /// \brief Check whether to enable x86 relax relocations by default.
+  virtual bool useRelaxRelocations() const;
+
   /// GetDefaultStackProtectorLevel - Get the default stack protector level for
   /// this tool chain (0=off, 1=on, 2=strong, 3=all).
   virtual unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const {
Index: cmake/caches/Fuchsia-stage2.cmake
===
--- cmake/caches/Fuchsia-stage2.cmake
+++ cmake/caches/Fuchsia-stage2.cmake
@@ -18,13 +18,6 @@
   set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 endif()
 
-# This is a "Does your linker support it?" option that only applies
-# to x86-64 ELF targets.  All Fuchsia target linkers do support it.
-# For x86-64 Linux, it's supported by LLD and by GNU linkers since
-# binutils 2.27, so one can hope that all Linux hosts in use handle it.
-# Ideally this would be settable as a per-target option.
-set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
-
 if(APPLE)
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()


Index: lib/Driver/ToolChains/Fuchsia.h
===
--- lib/Driver/ToolChains/Fuchsia.h
+++ lib/Driver/ToolChains/Fuchsia.h
@@ -43,6 +43,7 @@
   bool HasNativeLLVMSupport() const override { return true; }
   bool IsIntegratedAssemblerDefault() const override { return true; }
   bool IsMathErrnoDefault() const override { return false; }
+  bool useRelaxRelocations() const override { return true; };
   RuntimeLibType GetDefaultRuntimeLibType() const override {
 return ToolChain::RLT_CompilerRT;
   }
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1885,7 +1885,7 @@
   // arg after parsing the '-I' arg.
   bool TakeNextArg = false;
 
-  bool UseRelaxRelocations = ENABLE_X86_RELAX_RELOCATIONS;
+  bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations();
   const char *MipsTargetFeature = nullptr;
   for (const Arg *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) {
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -90,6 +90,10 @@
   IsIntegratedAssemblerDefault());
 }
 
+bool ToolChain::useRelaxRelocations() const {

r317776 - Fix a bug with the use of __builtin_bzero in a conditional expression.

2017-11-09 Thread John McCall via cfe-commits
Author: rjmccall
Date: Thu Nov  9 01:32:32 2017
New Revision: 317776

URL: http://llvm.org/viewvc/llvm-project?rev=317776=rev
Log:
Fix a bug with the use of __builtin_bzero in a conditional expression.

Patch by Bharathi Seshadri!

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=317776=317775=317776=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Nov  9 01:32:32 2017
@@ -1431,7 +1431,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
 EmitNonNullArgCheck(RValue::get(Dest.getPointer()), 
E->getArg(0)->getType(),
 E->getArg(0)->getExprLoc(), FD, 0);
 Builder.CreateMemSet(Dest, Builder.getInt8(0), SizeVal, false);
-return RValue::get(Dest.getPointer());
+return RValue::get(nullptr);
   }
   case Builtin::BImemcpy:
   case Builtin::BI__builtin_memcpy: {

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=317776=317775=317776=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Thu Nov  9 01:32:32 2017
@@ -176,6 +176,19 @@ void bar() {
 }
 // CHECK: }
 
+// CHECK-LABEL: define void @test_conditional_bzero
+void test_conditional_bzero() {
+  char dst[20];
+  int _sz = 20, len = 20;
+  return (_sz
+  ? ((_sz >= len)
+  ? __builtin_bzero(dst, len)
+  : foo())
+  : __builtin_bzero(dst, len));
+  // CHECK: call void @llvm.memset
+  // CHECK: call void @llvm.memset
+  // CHECK-NOT: phi
+}
 
 // CHECK-LABEL: define void @test_float_builtins
 void test_float_builtins(float F, double D, long double LD) {


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


[clang-tools-extra] r317780 - [clangd] Add rename support.

2017-11-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Nov  9 03:30:04 2017
New Revision: 317780

URL: http://llvm.org/viewvc/llvm-project?rev=317780=rev
Log:
[clangd] Add rename support.

Summary:
Make clangd handle "textDocument/rename" request. The rename
functionality comes from the "local-rename" sub-tool of clang-refactor.

Currently clangd only supports local rename (only symbol occurrences in
the main file will be renamed).

Reviewers: sammccall, ilya-biryukov

Reviewed By: sammccall

Subscribers: cfe-commits, ioeric, arphaman, mgorny

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

Added:
clang-tools-extra/trunk/test/clangd/rename.test
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h
clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
clang-tools-extra/trunk/test/clangd/initialize-params.test

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=317780=317779=317780=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Thu Nov  9 03:30:04 2017
@@ -27,6 +27,7 @@ add_clang_library(clangDaemon
   clangSerialization
   clangTooling
   clangToolingCore
+  clangToolingRefactor
   ${LLVM_PTHREAD_LIB}
   )
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=317780=317779=317780=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Nov  9 03:30:04 2017
@@ -57,6 +57,7 @@ void ClangdLSPServer::onInitialize(Ctx C
  {"triggerCharacters", {"(", ","}},
  }},
 {"definitionProvider", true},
+{"renameProvider", true},
 {"executeCommandProvider",
  json::obj{
  {"commands", 
{ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},
@@ -127,6 +128,22 @@ void ClangdLSPServer::onCommand(Ctx C, E
   }
 }
 
+void ClangdLSPServer::onRename(Ctx C, RenameParams ) {
+  auto File = Params.textDocument.uri.file;
+  auto Replacements = Server.rename(File, Params.position, Params.newName);
+  if (!Replacements) {
+C.replyError(
+ErrorCode::InternalError,
+llvm::toString(Replacements.takeError()));
+return;
+  }
+  std::string Code = Server.getDocument(File);
+  std::vector Edits = replacementsToEdits(Code, *Replacements);
+  WorkspaceEdit WE;
+  WE.changes = {{llvm::yaml::escape(Params.textDocument.uri.uri), Edits}};
+  C.reply(WorkspaceEdit::unparse(WE));
+}
+
 void ClangdLSPServer::onDocumentDidClose(Ctx C,
  DidCloseTextDocumentParams ) {
   Server.removeDocument(Params.textDocument.uri.file);

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=317780=317779=317780=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Thu Nov  9 03:30:04 2017
@@ -70,6 +70,7 @@ private:
   void onSwitchSourceHeader(Ctx C, TextDocumentIdentifier ) override;
   void onFileEvent(Ctx C, DidChangeWatchedFilesParams ) override;
   void onCommand(Ctx C, ExecuteCommandParams ) override;
+  void onRename(Ctx C, RenameParams ) override;
 
   std::vector
   getFixIts(StringRef File, const clangd::Diagnostic );

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=317780=317779=317780=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Nov  9 03:30:04 2017
@@ -9,6 +9,8 @@
 
 #include "ClangdServer.h"
 #include "clang/Format/Format.h"
+#include "clang/Tooling/Refactoring/RefactoringResultConsumer.h"
+#include "clang/Tooling/Refactoring/Rename/RenamingAction.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/CompilationDatabase.h"
@@ -51,6 

[PATCH] D39676: [clangd] Add rename support.

2017-11-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rL317780: [clangd] Add rename support. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D39676?vs=122074=12#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39676

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
  clang-tools-extra/trunk/clangd/ProtocolHandlers.h
  clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
  clang-tools-extra/trunk/test/clangd/initialize-params.test
  clang-tools-extra/trunk/test/clangd/rename.test

Index: clang-tools-extra/trunk/test/clangd/rename.test
===
--- clang-tools-extra/trunk/test/clangd/rename.test
+++ clang-tools-extra/trunk/test/clangd/rename.test
@@ -0,0 +1,50 @@
+# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 150
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///foo.cpp","languageId":"cpp","version":1,"text":"int foo;"}}}
+
+Content-Length: 159
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/rename","params":{"textDocument":{"uri":"file:///foo.cpp"},"position":{"line":0,"character":5},"newName":"bar"}}
+#  CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"changes": {
+# CHECK-NEXT:  "file:///foo.cpp": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "newText": "bar",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 7
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 4
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+# CHECK-NEXT:}
+# CHECK-NEXT:  ]
+# CHECK-NEXT:}
+# CHECK-NEXT:  }
+Content-Length: 159
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/rename","params":{"textDocument":{"uri":"file:///foo.cpp"},"position":{"line":0,"character":2},"newName":"bar"}}
+#  CHECK:  "error": {
+# CHECK-NEXT:"code": -32603,
+# CHECK-NEXT:"message": "clang diagnostic"
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "id": 2,
+# CHECK-NEXT:  "jsonrpc": "2.0"
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+Content-Length: 33
+
+{"jsonrpc":"2.0":"method":"exit"}
Index: clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
===
--- clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
+++ clang-tools-extra/trunk/test/clangd/initialize-params-invalid.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  "(",
Index: clang-tools-extra/trunk/test/clangd/initialize-params.test
===
--- clang-tools-extra/trunk/test/clangd/initialize-params.test
+++ clang-tools-extra/trunk/test/clangd/initialize-params.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
 # CHECK-NEXT:  "(",
Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -57,6 +57,7 @@
  {"triggerCharacters", {"(", ","}},
  }},
 {"definitionProvider", true},
+{"renameProvider", true},
 {"executeCommandProvider",
  json::obj{
  {"commands", {ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND}},
@@ -127,6 +128,22 @@
   }
 }
 
+void ClangdLSPServer::onRename(Ctx C, RenameParams ) {
+  auto File = Params.textDocument.uri.file;
+  auto Replacements = Server.rename(File, Params.position, Params.newName);
+  if (!Replacements) {
+   

[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D39836#920313, @sammccall wrote:

> In https://reviews.llvm.org/D39836#920306, @ilya-biryukov wrote:
>
> > I personally think they're useful to have anyway, and they don't add much 
> > noise when they're at the end of completions list.
> >  I sometimes want to complete an item I know is there and then fix 
> > accessibility. Do you think they add too much noise?
>
>
> For me the noise definitely outweighs the value, e.g. when I'm trying to see 
> all the available functions. There are costs beyond noise:
>
> - they bulk up tests and debugging output
> - they complicate the scoring scheme - we *never* want them to appear above a 
> legal completion, so a 1-dimensional score needs special handling as here.
> - compute: we spend time scoring them, computing their strings, writing them 
> over the wire, and then the client has to process them


I do think they are useful to me, but I don't know what the percentages of 
folks who want them vs. not are, and whether people have actually tried 
multiple schemes.
I think it's more likely that we get bug reports to put them in if we don't 
show them than the other way round, so I think taking them out is a good way to 
get that feedback :)


https://reviews.llvm.org/D39836



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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-11-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D32478#920275, @Typz wrote:

> > Sorry for the long response time. I don't see this style rule expressed 
> > explicitly in the Skia or QtCreator style guides - is this something that 
> > just happens to be done sometimes in the code bases?
>
> This is present in code base. Those project's style guides are not precise 
> enough, and do not document the behavior for this case.
>
> > I have problems understanding the rules from the discussion (as well as the 
> > code / test tbh), is there a really concise way to give me the core of the 
> > idea?
>
> The case I am trying to address is to really keep the _operands_ aligned 
> after an assignment or `return`, in case line is wrapped *before* the 
> operator.
>
>   int a = b
> + c;
>   return a
>+ b;
>   
>
> while the current behavior with `Style.AlignOperands = true; 
> BreakBeforeBinaryOperators = true` is to align the wrapped operator with the 
> previous line's operand:
>
>   int a = b
>   + c;
>   return a
>  + b;
>   
>
> In the discussion, it appeared that this behavior is not a error (with 
> respect to the name), but an expected behavior for most coding rules: hence 
> the introduction of a third AlignOperands mode ("AlignAfterOperator"), to 
> handle this new case.
>
> From there the code actually got a bit more complex to support various corner 
> cases (e.g. operators with different number of characters, wrapperd first 
> line, do not unindent more than the enclosing brace...)


Checking out skia and looking at wrapped '+', I see various different formats, 
and random sampling I've found none so far that would fit your proposed rule. 
Unless I'm missing something, I'd agree with Daniel; this is not a rule that's 
widely used, and I'd say reformatting a code base to the clang-formatted 
variant will not regress readability.


https://reviews.llvm.org/D32478



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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D39836#920306, @ilya-biryukov wrote:

> I personally think they're useful to have anyway, and they don't add much 
> noise when they're at the end of completions list.
>  I sometimes want to complete an item I know is there and then fix 
> accessibility. Do you think they add too much noise?


For me the noise definitely outweighs the value, e.g. when I'm trying to see 
all the available functions. There are costs beyond noise:

- they bulk up tests and debugging output
- they complicate the scoring scheme - we *never* want them to appear above a 
legal completion, so a 1-dimensional score needs special handling as here.
- compute: we spend time scoring them, computing their strings, writing them 
over the wire, and then the client has to process them


https://reviews.llvm.org/D39836



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


[PATCH] D33440: clang-format: better handle statement macros

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

In https://reviews.llvm.org/D33440#920205, @djasper wrote:

> Out of curiosity, will this be able to fix the two situations that you get 
> for python extension?
>  There, you usually have a PyObject_HEAD with out semicolon in a struct and 
> than a PyObject_HEAD_INIT(..) in a braced init list. More info:
>  http://starship.python.net/crew/mwh/toext/node20.html


`PyObject_HEAD` is defined (by defaut) as:

  Py_ssize_t ob_refcnt;
  PyTypeObject *ob_type;

so declaring it as a statement macro should allow clang-format to process it 
correctly. (though this is a variable-like macro, so I need to check if this 
case is supported)

`PyObject_HEAD_INIT` ends with a comma, which is not supported yet. We would 
need to add another kind of macro to support that case.


https://reviews.llvm.org/D33440



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


[PATCH] D39050: Add index-while-building support to Clang

2017-11-09 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D39050#900830, @arphaman wrote:

> I think this patch should be split into a number of smaller patches to help 
> the review process.
>
> Things like `tools/IndexStore`, `DirectoryWatcher` and other components that 
> are not directly needed right now should definitely be in their own patches.
>  It would be nice to find some way to split the implementation into multiple 
> patches as well.


+1.

This is a lot of work (but great work!) for one patch. Smaller/incremental 
patches help reviewers understand and (hopefully) capture potential improvement 
of the design. I would really appreciate it if you could further split the 
patch.

Some comments/ideas:

- The lack of tests is a bit concerning.
- I think the implementation of the index output logic (e.g. `IndexUnitWriter` 
and bit format file) can be abstracted away (and split into separate patches) 
so that you can unit-test the action with a custom/mock unit writer; this would 
also make the action reusable with (potentially) other storage formats.
- I would suggest that you start with a patch that implement the index action 
and just enough components so that you could test the action.

Thanks!


https://reviews.llvm.org/D39050



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


[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D39843

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -235,7 +235,7 @@
   // NOTE: we use Buffer.get() when adding remapped files, so we have to make
   // sure it will be released if no error is emitted.
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, Buffer.get());
+Preamble->AddImplicitPreamble(*CI, /*ref*/ VFS, Buffer.get());
   } else {
 CI->getPreprocessorOpts().addRemappedFile(
 CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get());
@@ -1301,7 +1301,7 @@
   CppFilePreambleCallbacks SerializedDeclsCollector;
   auto BuiltPreamble = PrecompiledPreamble::Build(
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
-  SerializedDeclsCollector);
+  /*StoreInMemory=*/true, SerializedDeclsCollector);
 
   if (BuiltPreamble) {
 return std::make_shared(


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -235,7 +235,7 @@
   // NOTE: we use Buffer.get() when adding remapped files, so we have to make
   // sure it will be released if no error is emitted.
   if (Preamble) {
-Preamble->AddImplicitPreamble(*CI, Buffer.get());
+Preamble->AddImplicitPreamble(*CI, /*ref*/ VFS, Buffer.get());
   } else {
 CI->getPreprocessorOpts().addRemappedFile(
 CI->getFrontendOpts().Inputs[0].getFile(), Buffer.get());
@@ -1301,7 +1301,7 @@
   CppFilePreambleCallbacks SerializedDeclsCollector;
   auto BuiltPreamble = PrecompiledPreamble::Build(
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
-  SerializedDeclsCollector);
+  /*StoreInMemory=*/true, SerializedDeclsCollector);
 
   if (BuiltPreamble) {
 return std::make_shared(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

After looking at the numbers, I think we should make this configurable. I'll 
update this change accordingly. Not sure what should be the default, though. 
I'm currently erring on the side of "in-memory by default".

Current implementation eats almost twice as much memory, which quickly adds up 
(tried comparing with earlier builds on `ClangdUnit.cpp`).
Even without proper benchmarks, it's clear that if we run out of memory (and we 
easily could if run on a machine with, say, 8GB of RAM) on-disk preambles are 
an easy way out of trouble.


https://reviews.llvm.org/D39843



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


[PATCH] D39838: [clang] [python] [tests] Update priority values in code completion test

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM.

Can we run those tests as part of `check-all` cmake target or setup a buildbot 
that runs those? Seems surprising it went unnoticed for so long.


Repository:
  rL LLVM

https://reviews.llvm.org/D39838



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


[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

These preambles are built by ASTUnit and clangd. Previously, preambles
were always stored on disk.

In-memory preambles are routed back to the compiler as virtual files in
a custom VFS.

Interface of ASTUnit does not allow to use in-memory preambles, as
ASTUnit::CodeComplete receives FileManager as a parameter, so we can't
change VFS used by the compiler inside the CodeComplete method.

A follow-up commit will update clangd in clang-tools-extra to use
in-memory preambles.

Proper variant-like storage for Preambles.

Final fixes and adjustments.


https://reviews.llvm.org/D39842

Files:
  include/clang/Frontend/FrontendActions.h
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PrecompiledPreamble.cpp

Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -28,12 +28,42 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 
+#include 
+
 using namespace clang;
 
 namespace {
 
+StringRef getInMemoryPreamblePath() {
+  // Note that the lambda is called inline to initialize the variable.
+  static auto PreambleName = []() {
+SmallString<64> Path;
+llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/true,
+   /*ref*/ Path);
+llvm::sys::path::append(Path, "___clang_inmemory_preamble___");
+return Path;
+  }();
+  return PreambleName;
+}
+
+IntrusiveRefCntPtr
+createVFSOverlayForPreamblePCH(StringRef PCHFilename,
+   std::unique_ptr PCHBuffer,
+   IntrusiveRefCntPtr VFS) {
+  // We want only the PCH file from the real filesystem to be available,
+  // so we create an in-memory VFS with just that and overlay it on top.
+  IntrusiveRefCntPtr PCHFS(
+  new vfs::InMemoryFileSystem());
+  PCHFS->addFile(PCHFilename, 0, std::move(PCHBuffer));
+  IntrusiveRefCntPtr Overlay(
+  new vfs::OverlayFileSystem(VFS));
+  Overlay->pushOverlay(PCHFS);
+  return Overlay;
+}
+
 /// Keeps a track of files to be deleted in destructor.
 class TemporaryFiles {
 public:
@@ -101,8 +131,9 @@
 
 class PrecompilePreambleAction : public ASTFrontendAction {
 public:
-  PrecompilePreambleAction(PreambleCallbacks )
-  : Callbacks(Callbacks) {}
+  PrecompilePreambleAction(std::string *InMemStorage,
+   PreambleCallbacks )
+  : InMemStorage(InMemStorage), Callbacks(Callbacks) {}
 
   std::unique_ptr CreateASTConsumer(CompilerInstance ,
  StringRef InFile) override;
@@ -123,6 +154,7 @@
   friend class PrecompilePreambleConsumer;
 
   bool HasEmittedPreamblePCH = false;
+  std::string *InMemStorage;
   PreambleCallbacks 
 };
 
@@ -164,13 +196,19 @@
 
 std::unique_ptr
 PrecompilePreambleAction::CreateASTConsumer(CompilerInstance ,
-
 StringRef InFile) {
   std::string Sysroot;
-  std::string OutputFile;
-  std::unique_ptr OS =
-  GeneratePCHAction::ComputeASTConsumerArguments(CI, InFile, Sysroot,
- OutputFile);
+  if (!GeneratePCHAction::ComputeASTConsumerArguments(CI, /*ref*/ Sysroot))
+return nullptr;
+
+  std::unique_ptr OS;
+  std::unique_ptr Storage;
+  if (InMemStorage) {
+OS = llvm::make_unique(*InMemStorage);
+  } else {
+std::string OutputFile;
+OS = GeneratePCHAction::CreateOutputFile(CI, InFile, /*ref*/ OutputFile);
+  }
   if (!OS)
 return nullptr;
 
@@ -202,7 +240,7 @@
 const CompilerInvocation ,
 const llvm::MemoryBuffer *MainFileBuffer, PreambleBounds Bounds,
 DiagnosticsEngine , IntrusiveRefCntPtr VFS,
-std::shared_ptr PCHContainerOps,
+std::shared_ptr PCHContainerOps, bool StoreInMemory,
 PreambleCallbacks ) {
   assert(VFS && "VFS is null");
 
@@ -214,12 +252,19 @@
   PreprocessorOptions  =
   PreambleInvocation->getPreprocessorOpts();
 
-  // Create a temporary file for the precompiled preamble. In rare
-  // circumstances, this can fail.
-  llvm::ErrorOr PreamblePCHFile =
-  PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile();
-  if (!PreamblePCHFile)
-return BuildPreambleError::CouldntCreateTempFile;
+  llvm::Optional TempFile;
+  if (!StoreInMemory) {
+// Create a temporary file for the precompiled preamble. In rare
+// circumstances, this can fail.
+llvm::ErrorOr PreamblePCHFile =
+PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile();
+if (!PreamblePCHFile)
+  return BuildPreambleError::CouldntCreateTempFile;
+TempFile = std::move(*PreamblePCHFile);
+  }
+
+  PCHStorage Storage = StoreInMemory ? PCHStorage(InMemoryPreamble())
+   

r317793 - [clang-format] Apply a clang-tidy suggestion, NFC

2017-11-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Nov  9 07:12:17 2017
New Revision: 317793

URL: http://llvm.org/viewvc/llvm-project?rev=317793=rev
Log:
[clang-format] Apply a clang-tidy suggestion, NFC

Modified:
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=317793=317792=317793=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Nov  9 07:12:17 2017
@@ -466,7 +466,7 @@ template <> struct DocumentListTraits= Seq.size()) {
   assert(Index == Seq.size());
   FormatStyle Template;
-  if (Seq.size() > 0 && Seq[0].Language == FormatStyle::LK_None) {
+  if (!Seq.empty() && Seq[0].Language == FormatStyle::LK_None) {
 Template = Seq[0];
   } else {
 Template = *((const FormatStyle *)IO.getContext());


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


[PATCH] D32478: [clang-format] Fix AlignOperands when BreakBeforeBinaryOperators is set

2017-11-09 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

> Unless I'm missing something, I'd agree with Daniel; this is not a rule 
> that's widely used, and I'd say reformatting a code base to the 
> clang-formatted variant will not regress readability.

Unfortunately coding rules are not just about readability, but also about 
consistency at entreprise scale, thus as a general rule we should not change 
the established rules in an organizatoin.
There is history in rules, we have code which already uses these rules, so for 
consistency we must stick to the old rules (even if we would not necessarily 
choose the same rules if we were to start from scratch).


https://reviews.llvm.org/D32478



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


r317783 - [clang-format] Fix argument name comment, NFC

2017-11-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Nov  9 05:19:14 2017
New Revision: 317783

URL: http://llvm.org/viewvc/llvm-project?rev=317783=rev
Log:
[clang-format] Fix argument name comment, NFC

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=317783=317782=317783=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Nov  9 05:19:14 2017
@@ -1324,7 +1324,7 @@ unsigned ContinuationIndenter::reformatR
   std::pair Fixes = internal::reformat(
   RawStringStyle, RawText, {tooling::Range(0, RawText.size())},
   FirstStartColumn, NextStartColumn, LastStartColumn, "",
-  /*FormattingAttemptStatus=*/nullptr);
+  /*Status=*/nullptr);
 
   auto NewCode = applyAllReplacements(RawText, Fixes.first);
   tooling::Replacements NoFixes;


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


[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 19.
dberris added a comment.

- fixup: Use ASM macros for darwin assembly
- fixup: support weak symbols for Darwin linkage
- fixup: qualify symbols, use macros, limit weak symbols
- fixup: move test cases from Linux up one directory
- fixup: make clang link the needed runtime bits in osx
- fixup: update tests to run on x86_64 on both Darwin and Linux


https://reviews.llvm.org/D39114

Files:
  clang/include/clang/Driver/XRayArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/XRayArgs.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/xray/CMakeLists.txt
  compiler-rt/lib/xray/tests/CMakeLists.txt
  compiler-rt/lib/xray/weak_symbols.txt
  compiler-rt/lib/xray/xray_init.cc
  compiler-rt/lib/xray/xray_trampoline_x86_64.S
  compiler-rt/test/xray/TestCases/Darwin/always-never-instrument.cc
  compiler-rt/test/xray/TestCases/Darwin/lit.local.cfg
  compiler-rt/test/xray/TestCases/Linux/always-never-instrument.cc
  compiler-rt/test/xray/TestCases/Linux/arg1-arg0-logging.cc
  compiler-rt/test/xray/TestCases/Linux/arg1-logger.cc
  compiler-rt/test/xray/TestCases/Linux/arg1-logging-implicit-this.cc
  compiler-rt/test/xray/TestCases/Linux/argv0-log-file-name.cc
  compiler-rt/test/xray/TestCases/Linux/coverage-sample.cc
  compiler-rt/test/xray/TestCases/Linux/custom-event-handler-alignment.cc
  compiler-rt/test/xray/TestCases/Linux/custom-event-logging.cc
  compiler-rt/test/xray/TestCases/Linux/fdr-mode.cc
  compiler-rt/test/xray/TestCases/Linux/fdr-single-thread.cc
  compiler-rt/test/xray/TestCases/Linux/fdr-thread-order.cc
  compiler-rt/test/xray/TestCases/Linux/fixedsize-logging.cc
  compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc
  compiler-rt/test/xray/TestCases/Linux/optional-inmemory-log.cc
  compiler-rt/test/xray/TestCases/Linux/patching-unpatching.cc
  compiler-rt/test/xray/TestCases/Linux/pic_test.cc
  compiler-rt/test/xray/TestCases/Linux/quiet-start.cc
  compiler-rt/test/xray/TestCases/always-never-instrument.cc
  compiler-rt/test/xray/TestCases/arg1-arg0-logging.cc
  compiler-rt/test/xray/TestCases/arg1-logger.cc
  compiler-rt/test/xray/TestCases/arg1-logging-implicit-this.cc
  compiler-rt/test/xray/TestCases/argv0-log-file-name.cc
  compiler-rt/test/xray/TestCases/coverage-sample.cc
  compiler-rt/test/xray/TestCases/custom-event-handler-alignment.cc
  compiler-rt/test/xray/TestCases/custom-event-logging.cc
  compiler-rt/test/xray/TestCases/fdr-mode.cc
  compiler-rt/test/xray/TestCases/fdr-single-thread.cc
  compiler-rt/test/xray/TestCases/fdr-thread-order.cc
  compiler-rt/test/xray/TestCases/fixedsize-logging.cc
  compiler-rt/test/xray/TestCases/func-id-utils.cc
  compiler-rt/test/xray/TestCases/lit.local.cfg
  compiler-rt/test/xray/TestCases/optional-inmemory-log.cc
  compiler-rt/test/xray/TestCases/patching-unpatching.cc
  compiler-rt/test/xray/TestCases/pic_test.cc
  compiler-rt/test/xray/TestCases/quiet-start.cc
  compiler-rt/test/xray/lit.cfg

Index: compiler-rt/test/xray/lit.cfg
===
--- compiler-rt/test/xray/lit.cfg
+++ compiler-rt/test/xray/lit.cfg
@@ -40,7 +40,7 @@
 # Default test suffixes.
 config.suffixes = ['.c', '.cc', '.cpp']
 
-if config.host_os not in ['Linux']:
+if config.host_os not in ['Linux', 'Darwin']:
   config.unsupported = True
 elif '64' not in config.host_arch:
   if 'arm' in config.host_arch:
Index: compiler-rt/test/xray/TestCases/quiet-start.cc
===
--- compiler-rt/test/xray/TestCases/quiet-start.cc
+++ compiler-rt/test/xray/TestCases/quiet-start.cc
@@ -9,8 +9,8 @@
 // RUN: XRAY_OPTIONS="" %run %t 2>&1 | FileCheck %s --check-prefix DEFAULT
 //
 // FIXME: Understand how to make this work on other platforms
+// REQUIRES: x86_64
 // REQUIRES: built-in-llvm-tree
-// REQUIRES: x86_64-linux
 #include 
 
 using namespace std;
Index: compiler-rt/test/xray/TestCases/Linux/pic_test.cc
===
--- /dev/null
+++ compiler-rt/test/xray/TestCases/Linux/pic_test.cc
@@ -1,36 +0,0 @@
-// Test to check if we handle pic code properly.
-
-// RUN: %clangxx_xray -fxray-instrument -std=c++11 -ffunction-sections \
-// RUN: -fdata-sections -fpic -fpie -Wl,--gc-sections %s -o %t
-// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_logfile_base=pic-test-logging-" %run %t 2>&1 | FileCheck %s
-// After all that, clean up the output xray log.
-//
-// RUN: rm pic-test-logging-*
-
-// UNSUPPORTED: target-is-mips64,target-is-mips64el
-
-#include 
-
-[[clang::xray_always_instrument]]
-unsigned short foo (unsigned b);
-
-[[clang::xray_always_instrument]]
-unsigned short bar (unsigned short a)
-{
-  printf("bar() is always instrumented!\n");
-  return foo(a);
-}
-
-unsigned short foo (unsigned b)
-{
-  printf("foo() is always instrumented!\n");
-  return b + b + 5;
-}
-
-int main ()
-{
-  // CHECK: XRay: Log file in 'pic-test-logging-{{.*}}'
-  

[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris added subscribers: pelikan, echristo.
dberris added a comment.

Got some good progress on finally being able to make this work... here's the 
current state:

- When linking the final binary, the XRay runtime can't seem to find the 
`__{start,stop}_xray_{fn_idx,instr_map}` symbols. I've marked them weak, but 
they seem to either not be resolved when statically linking the binary. The 
dynamic lib version of the XRay runtime isn't quite ready yet, but I'm willing 
to try some things there.

- There are also missing symbols from the sanitizer_common library that's 
linked to from the `libclang_rt.xray_osx.a` produced by the compiler-rt XRay 
build configuration.

For example, when we're building some of the tests, I see errors like:

  
  FAIL: XRay-x86_64-darwin :: TestCases/func-id-utils.cc (18 of 18)
   TEST 'XRay-x86_64-darwin :: TestCases/func-id-utils.cc' 
FAILED 
  Script:
  --
  /Users/dberris/Source/llvm-project-build/./bin/clang --driver-mode=g++ 
-fxray-instrument -arch x86_64 -stdlib=libc++ -mmacosx-version-min=10.9 
-isysroot /Applications/Xcode.
  
app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk 
 -std=c++11 
/Users/dberris/Source/llvm-project/compiler-rt/test/xray/TestCases/func-id-utils.
  cc -o 
/Users/dberris/Source/llvm-project-build/projects/compiler-rt/test/xray/X86_64DarwinConfig/TestCases/Output/func-id-utils.cc.tmp
  XRAY_OPTIONS="patch_premain=false xray_naive_log=false"  
/Users/dberris/Source/llvm-project-build/projects/compiler-rt/test/xray/X86_64DarwinConfig/TestCases/Output/func-id-
  utils.cc.tmp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  Undefined symbols for architecture x86_64:
"___sanitizer_symbolize_code", referenced from:
__sanitizer::Symbolizer::PlatformInit() in 
libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
__sanitizer::InternalSymbolizer::SymbolizePC(unsigned long, 
__sanitizer::SymbolizedStack*) in 
libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
"___sanitizer_symbolize_data", referenced from:
__sanitizer::Symbolizer::PlatformInit() in 
libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
__sanitizer::InternalSymbolizer::SymbolizeData(unsigned long, 
__sanitizer::DataInfo*) in 
libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
"___sanitizer_symbolize_demangle", referenced from:
__sanitizer::InternalSymbolizer::Demangle(char const*) in 
libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
"___sanitizer_symbolize_flush", referenced from:
__sanitizer::InternalSymbolizer::Flush() in 
libclang_rt.xray_osx.a(sanitizer_symbolizer_posix_libcdep.cc.o)
"___start_xray_fn_idx", referenced from:
___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
"___start_xray_instr_map", referenced from:
___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
"___stop_xray_fn_idx", referenced from:
___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
"___stop_xray_instr_map", referenced from:
___xray_init in libclang_rt.xray_osx.a(xray_init.cc.o)
  ld: symbol(s) not found for architecture x86_64
  clang-6.0: error: linker command failed with exit code 1 (use -v to see 
invocation)
  
  --

Any further hints/thoughts on this would be great, @kubamracek (cc @pelikan and 
@echristo)


https://reviews.llvm.org/D39114



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


[PATCH] D39786: [clang-format] Sort using declarations by splitting on '::'

2017-11-09 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D39786



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


r317784 - [clang-format] Fix a clang-tidy finding, NFC

2017-11-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Nov  9 05:22:03 2017
New Revision: 317784

URL: http://llvm.org/viewvc/llvm-project?rev=317784=rev
Log:
[clang-format] Fix a clang-tidy finding, NFC

Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=317784=317783=317784=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Nov  9 05:22:03 2017
@@ -2179,7 +2179,7 @@ void UnwrappedLineParser::parseJavaScrip
   while (!eof()) {
 if (FormatTok->is(tok::semi))
   return;
-if (Line->Tokens.size() == 0) {
+if (Line->Tokens.empty()) {
   // Common issue: Automatic Semicolon Insertion wrapped the line, so the
   // import statement should terminate.
   return;


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


[PATCH] D39838: [clang] [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.

The priority for destructors and operators was reduced in 
https://reviews.llvm.org/rL314019.
Adjust the values used in the test appropriately to fix the test
failure.


Repository:
  rL LLVM

https://reviews.llvm.org/D39838

Files:
  bindings/python/tests/cindex/test_code_completion.py


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -68,8 +68,8 @@
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: 
Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: 
Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || 
Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)


Index: bindings/python/tests/cindex/test_code_completion.py
===
--- bindings/python/tests/cindex/test_code_completion.py
+++ bindings/python/tests/cindex/test_code_completion.py
@@ -68,8 +68,8 @@
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38639: [clangd] #include statements support for Open definition

2017-11-09 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

I'm not sure it's better to use the InclusionDirective callback for this. We 
need to get the includes in two places: in the preamble and non-preamble. In 
the preamble we use the callback, have to store some temporary stuff because we 
don't have a SourceManager in InclusionDirective, then in finish we use the 
SourceManager to convert everything. In the non-preamble, we cannot use the 
callback so we use the SourceManager to go through the includes. Therefore, we 
have to maintain two different ways of getting the inclusion map. Without using 
the InclusionDirective callback, we use the SourceManager in both cases and can 
use the same code to iterate through inclusions, just on two different 
SourceManagers at different moments. We also don't need to make another patch 
to modify the PreambleCallbacks. I also double this is much slower but I think 
this simplifies the code nicely.
What do you think?


https://reviews.llvm.org/D38639



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


[PATCH] D39806: [clang-format] Support python-style comments in text protos

2017-11-09 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added inline comments.



Comment at: lib/Format/BreakableToken.cpp:48
+  static const SmallVector KnownTextProtoPrefixes{"//", "#"};
+  const SmallVectorImpl  =
+  (Style.Language == FormatStyle::LK_TextProto) ? KnownTextProtoPrefixes

These should stay arrays. You can use ArrayRef to get a convenient reference to 
them.


https://reviews.llvm.org/D39806



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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

I would prefer to make this behaviour configurable.


https://reviews.llvm.org/D39836



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


r317800 - [VirtualFileSystem] InMemoryFileSystem::addFile(): Type and Perms

2017-11-09 Thread Ben Hamilton via cfe-commits
Author: benhamilton
Date: Thu Nov  9 08:01:16 2017
New Revision: 317800

URL: http://llvm.org/viewvc/llvm-project?rev=317800=rev
Log:
[VirtualFileSystem] InMemoryFileSystem::addFile(): Type and Perms

Summary:
This implements a FIXME in InMemoryFileSystem::addFile(), allowing
clients to specify User, Group, Type, and/or Perms when creating a
file in an in-memory filesystem.

New tests included. Ran tests with:

% ninja BasicTests && ./tools/clang/unittests/Basic/BasicTests

Fixes PR#35172 (https://bugs.llvm.org/show_bug.cgi?id=35172)

Reviewers: bkramer, hokein

Reviewed By: bkramer, hokein

Subscribers: alexfh

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

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=317800=317799=317800=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Thu Nov  9 08:01:16 2017
@@ -320,15 +320,25 @@ public:
   ~InMemoryFileSystem() override;
 
   /// Add a buffer to the VFS with a path. The VFS owns the buffer.
+  /// If present, User, Group, Type and Perms apply to the newly-created file.
   /// \return true if the file was successfully added, false if the file 
already
   /// exists in the file system with different contents.
   bool addFile(const Twine , time_t ModificationTime,
-   std::unique_ptr Buffer);
+   std::unique_ptr Buffer,
+   Optional User = None, Optional Group = None,
+   Optional Type = None,
+   Optional Perms = None);
   /// Add a buffer to the VFS with a path. The VFS does not own the buffer.
+  /// If present, User, Group, Type and Perms apply to the newly-created file.
   /// \return true if the file was successfully added, false if the file 
already
   /// exists in the file system with different contents.
   bool addFileNoOwn(const Twine , time_t ModificationTime,
-llvm::MemoryBuffer *Buffer);
+llvm::MemoryBuffer *Buffer,
+Optional User = None,
+Optional Group = None,
+Optional Type = None,
+Optional Perms = None);
+
   std::string toString() const;
   /// Return true if this file system normalizes . and .. in paths.
   bool useNormalizedPaths() const { return UseNormalizedPaths; }

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=317800=317799=317800=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Nov  9 08:01:16 2017
@@ -493,7 +493,11 @@ std::string InMemoryFileSystem::toString
 }
 
 bool InMemoryFileSystem::addFile(const Twine , time_t ModificationTime,
- std::unique_ptr Buffer) {
+ std::unique_ptr Buffer,
+ Optional User,
+ Optional Group,
+ Optional Type,
+ Optional Perms) {
   SmallString<128> Path;
   P.toVector(Path);
 
@@ -509,7 +513,14 @@ bool InMemoryFileSystem::addFile(const T
 return false;
 
   detail::InMemoryDirectory *Dir = Root.get();
-  auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
+  auto I = llvm::sys::path::begin(Path), E = sys::path::end(Path);
+  const auto ResolvedUser = User.getValueOr(0);
+  const auto ResolvedGroup = Group.getValueOr(0);
+  const auto ResolvedType = Type.getValueOr(sys::fs::file_type::regular_file);
+  const auto ResolvedPerms = Perms.getValueOr(sys::fs::all_all);
+  // Any intermediate directories we create should be accessible by
+  // the owner, even if Perms says otherwise for the final path.
+  const auto NewDirectoryPerms = ResolvedPerms | sys::fs::owner_all;
   while (true) {
 StringRef Name = *I;
 detail::InMemoryNode *Node = Dir->getChild(Name);
@@ -517,24 +528,21 @@ bool InMemoryFileSystem::addFile(const T
 if (!Node) {
   if (I == E) {
 // End of the path, create a new file.
-// FIXME: expose the status details in the interface.
 Status Stat(P.str(), getNextVirtualUniqueID(),
-llvm::sys::toTimePoint(ModificationTime), 0, 0,
-Buffer->getBufferSize(),
-llvm::sys::fs::file_type::regular_file,
-llvm::sys::fs::all_all);
+llvm::sys::toTimePoint(ModificationTime), ResolvedUser,
+ResolvedGroup, 

[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

So I probably should have started from the other end, here :-)

I'd really like to make the completion retrieval and ranking more flexible. In 
particular

- incorporating results from other sources (indexes: both in-memory and 
external services).
- combining more quality signals like usage count and fuzzy-match-strength in a 
non-lexicographic-sort way

The biggest difficulty in *supporting* unusable functions is maintaining the 
invariant that all unusable functions are ranked lower than usable ones - all 
code that deals with ranking has to deal with this special case, e.g. by making 
score a tuple instead of a single number.

If the current approach of "give them a penalty" is enough, knowing that in the 
future it may lead to e.g. a very widely used but inaccessible protected 
function being ranked highly, then that seems fine to me too. A wider 
configuration space means testing is more work, but happy to live with it. What 
do you think?

(With my user-hat on, configurable is fine, though I do strongly feel they 
should be off by default, and it seems unlikely many users will change the 
defaults.)


https://reviews.llvm.org/D39836



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


[PATCH] D39786: [clang-format] Sort using declarations by splitting on '::'

2017-11-09 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317794: [clang-format] Sort using declarations by splitting 
on '::' (authored by krasimir).

Repository:
  rL LLVM

https://reviews.llvm.org/D39786

Files:
  cfe/trunk/docs/ClangFormatStyleOptions.rst
  cfe/trunk/docs/tools/dump_format_style.py
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
  cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp

Index: cfe/trunk/docs/ClangFormatStyleOptions.rst
===
--- cfe/trunk/docs/ClangFormatStyleOptions.rst
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst
@@ -266,13 +266,9 @@
 
   .. code-block:: c++
 
-true:
-int a; // My comment a
-int b = 2; // comment  b
-
-false:
-int a; // My comment a
-int b = 2; // comment about b
+true:   false:
+int a; // My comment a  vs. int a; // My comment a
+int b = 2; // comment  bint b = 2; // comment about b
 
 **AllowAllParametersOfDeclarationOnNextLine** (``bool``)
   If the function declaration doesn't fit on a line,
@@ -1541,6 +1537,26 @@
 
 
 
+**RawStringFormats** (``std::vector``)
+  Raw string delimiters denoting that the raw string contents are
+  code in a particular language and can be reformatted.
+
+  A raw string with a matching delimiter will be reformatted assuming the
+  specified language based on a predefined style given by 'BasedOnStyle'.
+  If 'BasedOnStyle' is not found, the formatting is based on llvm style.
+
+  To configure this in the .clang-format file, use:
+
+  .. code-block:: yaml
+
+RawStringFormats:
+  - Delimiter: 'pb'
+Language:  TextProto
+BasedOnStyle: llvm
+  - Delimiter: 'proto'
+Language:  TextProto
+BasedOnStyle: google
+
 **ReflowComments** (``bool``)
   If ``true``, clang-format will attempt to re-flow comments.
 
@@ -1573,6 +1589,13 @@
  false: true:
  using std::cout;   vs. using std::cin;
  using std::cin;using std::cout;
+  The order of using declarations is defined as follows:
+  Split the strings by "::" and discard any initial empty strings. The last
+  element of each list is a non-namespace name; all others are namespace
+  names. Sort the lists of names lexicographically, where the sort order of
+  individual names is that all non-namespace names come before all namespace
+  names, and within those groups, names are in case-insensitive
+  lexicographic order.
 
 **SpaceAfterCStyleCast** (``bool``)
   If ``true``, a space is inserted after C style casts.
Index: cfe/trunk/docs/tools/dump_format_style.py
===
--- cfe/trunk/docs/tools/dump_format_style.py
+++ cfe/trunk/docs/tools/dump_format_style.py
@@ -177,7 +177,8 @@
   for option in options:
 if not option.type in ['bool', 'unsigned', 'int', 'std::string',
'std::vector',
-   'std::vector']:
+   'std::vector',
+   'std::vector']:
   if enums.has_key(option.type):
 option.enum = enums[option.type]
   elif nested_structs.has_key(option.type):
Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -1390,6 +1390,13 @@
   ///using std::cout;   vs. using std::cin;
   ///using std::cin;using std::cout;
   /// \endcode
+  /// The order of using declarations is defined as follows:
+  /// Split the strings by "::" and discard any initial empty strings. The last
+  /// element of each list is a non-namespace name; all others are namespace
+  /// names. Sort the lists of names lexicographically, where the sort order of
+  /// individual names is that all non-namespace names come before all namespace
+  /// names, and within those groups, names are in case-insensitive
+  /// lexicographic order.
   bool SortUsingDeclarations;
 
   /// \brief If ``true``, a space is inserted after C style casts.
Index: cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
===
--- cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
+++ cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
@@ -26,34 +26,54 @@
 
 namespace {
 
+// The order of using declaration is defined as follows:
+// Split the strings by "::" and discard any initial empty strings. The last
+// element of each list is a non-namespace name; all others are namespace
+// names. Sort the lists of names lexicographically, where the sort order of
+// individual names is that all non-namespace names come before all namespace
+// names, and within those 

[PATCH] D39843: [clangd] Use in-memory preambles in clangd.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Heh, I was just going to ask :-)

As a very first step, can we make this configurable but off-by-default? That 
will address the pressing diskless-servers need.

In a typical workstation scenario, disk is plentiful (if slow) and RAM is 
scarce - very likely we're running browser + editor (VSCode is another browser 
really) + clangd + build system, and clangd is likely the least important of 
these...
So if we're going to increase mem usage by a significant amount I think we want 
to measure it carefully first.


https://reviews.llvm.org/D39843



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: docs/clang-tidy/checks/objc-property-declaration.rst:7
+Finds property declarations in Objective-C files that do not follow the pattern
+of property names in Google's Objective-C Style Guide. The property name should
+be in the format of Lower Camel Case.

hokein wrote:
> Google style? but the link you provided is Apple.
Google's Objective-C style guide is a list of additions on top of Apple's 
Objective-C style guide.

Property naming standards are defined in Apple's style guide, and not changed 
by Google's.


https://reviews.llvm.org/D39829



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


r317813 - [OPENMP] Codegen for `#pragma omp target parallel for simd`.

2017-11-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov  9 09:32:15 2017
New Revision: 317813

URL: http://llvm.org/viewvc/llvm-project?rev=317813=rev
Log:
[OPENMP] Codegen for `#pragma omp target parallel for simd`.

Added codegen for `#pragma omp target parallel for simd` and clauses.

Added:
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen_registration.cpp

cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen_registration_naming.cpp
Modified:
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Nov  9 09:32:15 2017
@@ -793,7 +793,7 @@ bool clang::isOpenMPParallelDirective(Op
 
 bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
   return DKind == OMPD_target || DKind == OMPD_target_parallel ||
- DKind == OMPD_target_parallel_for || 
+ DKind == OMPD_target_parallel_for ||
  DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
  DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
  DKind == OMPD_target_teams_distribute_parallel_for ||
@@ -909,7 +909,6 @@ void clang::getOpenMPCaptureRegions(
   case OMPD_atomic:
   case OMPD_target_data:
   case OMPD_target:
-  case OMPD_target_parallel_for_simd:
   case OMPD_target_simd:
   case OMPD_task:
   case OMPD_taskloop:
@@ -927,6 +926,7 @@ void clang::getOpenMPCaptureRegions(
 break;
   case OMPD_target_parallel:
   case OMPD_target_parallel_for:
+  case OMPD_target_parallel_for_simd:
 CaptureRegions.push_back(OMPD_target);
 CaptureRegions.push_back(OMPD_parallel);
 break;

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Thu Nov  9 09:32:15 2017
@@ -7125,6 +7125,10 @@ void CGOpenMPRuntime::scanForTargetRegio
   CodeGenFunction::EmitOMPTargetParallelForDeviceFunction(
   CGM, ParentName, cast(*S));
   break;
+case Stmt::OMPTargetParallelForSimdDirectiveClass:
+  CodeGenFunction::EmitOMPTargetParallelForSimdDeviceFunction(
+  CGM, ParentName, cast(*S));
+  break;
 default:
   llvm_unreachable("Unknown target directive for OpenMP device codegen.");
 }

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Thu Nov  9 09:32:15 2017
@@ -277,6 +277,7 @@ getExecutionModeForDirective(CodeGenModu
 return CGOpenMPRuntimeNVPTX::ExecutionMode::Generic;
   case OMPD_target_parallel:
   case OMPD_target_parallel_for:
+  case OMPD_target_parallel_for_simd:
 return CGOpenMPRuntimeNVPTX::ExecutionMode::Spmd;
   default:
 llvm_unreachable("Unsupported directive on NVPTX device.");

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=317813=317812=317813=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Nov  9 09:32:15 2017
@@ -2027,18 +2027,6 @@ void CodeGenFunction::EmitOMPDistributeS
   });
 }
 
-void CodeGenFunction::EmitOMPTargetParallelForSimdDirective(
-const OMPTargetParallelForSimdDirective ) {
-  OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
-  CGM.getOpenMPRuntime().emitInlinedDirective(
-  *this, OMPD_target_parallel_for_simd,
-  [](CodeGenFunction , PrePostActionTy &) {
-OMPLoopScope PreInitScope(CGF, S);
-CGF.EmitStmt(
-cast(S.getAssociatedStmt())->getCapturedStmt());
-  });
-}
-
 void CodeGenFunction::EmitOMPTargetSimdDirective(
 const OMPTargetSimdDirective ) {
   OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
@@ -4169,6 +4157,44 @@ void CodeGenFunction::EmitOMPTargetParal
   };
   emitCommonOMPTargetDirective(*this, S, CodeGen);
 }
+
+static void
+emitTargetParallelForSimdRegion(CodeGenFunction ,
+const 

r317794 - [clang-format] Sort using declarations by splitting on '::'

2017-11-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Nov  9 07:41:23 2017
New Revision: 317794

URL: http://llvm.org/viewvc/llvm-project?rev=317794=rev
Log:
[clang-format] Sort using declarations by splitting on '::'

Summary: This patch improves using declarations sorting.

Reviewers: bkramer

Reviewed By: bkramer

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/docs/tools/dump_format_style.py
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/UsingDeclarationsSorter.cpp
cfe/trunk/unittests/Format/UsingDeclarationsSorterTest.cpp

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=317794=317793=317794=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Nov  9 07:41:23 2017
@@ -266,13 +266,9 @@ the configuration (without a prefix: ``A
 
   .. code-block:: c++
 
-true:
-int a; // My comment a
-int b = 2; // comment  b
-
-false:
-int a; // My comment a
-int b = 2; // comment about b
+true:   false:
+int a; // My comment a  vs. int a; // My comment a
+int b = 2; // comment  bint b = 2; // comment about b
 
 **AllowAllParametersOfDeclarationOnNextLine** (``bool``)
   If the function declaration doesn't fit on a line,
@@ -1541,6 +1537,26 @@ the configuration (without a prefix: ``A
 
 
 
+**RawStringFormats** (``std::vector``)
+  Raw string delimiters denoting that the raw string contents are
+  code in a particular language and can be reformatted.
+
+  A raw string with a matching delimiter will be reformatted assuming the
+  specified language based on a predefined style given by 'BasedOnStyle'.
+  If 'BasedOnStyle' is not found, the formatting is based on llvm style.
+
+  To configure this in the .clang-format file, use:
+
+  .. code-block:: yaml
+
+RawStringFormats:
+  - Delimiter: 'pb'
+Language:  TextProto
+BasedOnStyle: llvm
+  - Delimiter: 'proto'
+Language:  TextProto
+BasedOnStyle: google
+
 **ReflowComments** (``bool``)
   If ``true``, clang-format will attempt to re-flow comments.
 
@@ -1573,6 +1589,13 @@ the configuration (without a prefix: ``A
  false: true:
  using std::cout;   vs. using std::cin;
  using std::cin;using std::cout;
+  The order of using declarations is defined as follows:
+  Split the strings by "::" and discard any initial empty strings. The last
+  element of each list is a non-namespace name; all others are namespace
+  names. Sort the lists of names lexicographically, where the sort order of
+  individual names is that all non-namespace names come before all namespace
+  names, and within those groups, names are in case-insensitive
+  lexicographic order.
 
 **SpaceAfterCStyleCast** (``bool``)
   If ``true``, a space is inserted after C style casts.

Modified: cfe/trunk/docs/tools/dump_format_style.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/tools/dump_format_style.py?rev=317794=317793=317794=diff
==
--- cfe/trunk/docs/tools/dump_format_style.py (original)
+++ cfe/trunk/docs/tools/dump_format_style.py Thu Nov  9 07:41:23 2017
@@ -177,7 +177,8 @@ def read_options(header):
   for option in options:
 if not option.type in ['bool', 'unsigned', 'int', 'std::string',
'std::vector',
-   'std::vector']:
+   'std::vector',
+   'std::vector']:
   if enums.has_key(option.type):
 option.enum = enums[option.type]
   elif nested_structs.has_key(option.type):

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=317794=317793=317794=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Nov  9 07:41:23 2017
@@ -1390,6 +1390,13 @@ struct FormatStyle {
   ///using std::cout;   vs. using std::cin;
   ///using std::cin;using std::cout;
   /// \endcode
+  /// The order of using declarations is defined as follows:
+  /// Split the strings by "::" and discard any initial empty strings. The last
+  /// element of each list is a non-namespace name; all others are namespace
+  /// names. Sort the lists of names lexicographically, where the sort order of
+  /// individual names is that all non-namespace names come before all 
namespace
+  /// names, and within those groups, names 

r317799 - [clang-format] Keep Sphinx happy after r317794

2017-11-09 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Thu Nov  9 07:54:59 2017
New Revision: 317799

URL: http://llvm.org/viewvc/llvm-project?rev=317799=rev
Log:
[clang-format] Keep Sphinx happy after r317794

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

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=317799=317798=317799=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Thu Nov  9 07:54:59 2017
@@ -1584,11 +1584,6 @@ the configuration (without a prefix: ``A
 **SortUsingDeclarations** (``bool``)
   If ``true``, clang-format will sort using declarations.
 
-  .. code-block:: c++
-
- false: true:
- using std::cout;   vs. using std::cin;
- using std::cin;using std::cout;
   The order of using declarations is defined as follows:
   Split the strings by "::" and discard any initial empty strings. The last
   element of each list is a non-namespace name; all others are namespace
@@ -1597,6 +1592,12 @@ the configuration (without a prefix: ``A
   names, and within those groups, names are in case-insensitive
   lexicographic order.
 
+  .. code-block:: c++
+
+ false: true:
+ using std::cout;   vs. using std::cin;
+ using std::cin;using std::cout;
+
 **SpaceAfterCStyleCast** (``bool``)
   If ``true``, a space is inserted after C style casts.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=317799=317798=317799=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Nov  9 07:54:59 2017
@@ -1385,11 +1385,7 @@ struct FormatStyle {
   bool SortIncludes;
 
   /// \brief If ``true``, clang-format will sort using declarations.
-  /// \code
-  ///false: true:
-  ///using std::cout;   vs. using std::cin;
-  ///using std::cin;using std::cout;
-  /// \endcode
+  ///
   /// The order of using declarations is defined as follows:
   /// Split the strings by "::" and discard any initial empty strings. The last
   /// element of each list is a non-namespace name; all others are namespace
@@ -1397,6 +1393,11 @@ struct FormatStyle {
   /// individual names is that all non-namespace names come before all 
namespace
   /// names, and within those groups, names are in case-insensitive
   /// lexicographic order.
+  /// \code
+  ///false: true:
+  ///using std::cout;   vs. using std::cin;
+  ///using std::cin;using std::cout;
+  /// \endcode
   bool SortUsingDeclarations;
 
   /// \brief If ``true``, a space is inserted after C style casts.


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


[PATCH] D39842: Allow to store precompiled preambles in memory.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm really happy you've made this work! I don't understand it enough to do a 
meaningful review (keen to learn if you have time for a walkthrough when back 
in the office).


https://reviews.llvm.org/D39842



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


[PATCH] D38639: [clangd] #include statements support for Open definition

2017-11-09 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D38639#920487, @ilya-biryukov wrote:

> I think we should never iterate through `SourceManager`, as it's much easier 
> to get wrong than using the callbacks. I agree that all that fiddling with 
> callbacks is unfortunate, but it's well worth the fact that it'd be much 
> easier to tell that the implementation is correct by simply looking at the 
> implementation and not knowing how `SourceManager` works. `PPCallbacks` is a 
> much more direct API that was designed to handle our purposes.
>
> Note that we don't need to use `SourceManager` to find non-preamble includes, 
> we should implement proper `PPCallbacks` and use them when building the AST.


Sounds good!


https://reviews.llvm.org/D38639



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


[PATCH] D39800: [analyzer] pr34404: Fix a crash on pointers to members in nested anonymous structures.

2017-11-09 Thread Kirill Romanenkov via Phabricator via cfe-commits
kromanenkov added a comment.

@NoQ  Do we need to change a `DeclaratorDecl` field in PointerToMember SVal to 
something more common, like `ValueDecl`, to support `IndirectFieldDecl` as well?


https://reviews.llvm.org/D39800



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


[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

> When linking the final binary, the XRay runtime can't seem to find the 
> `__{start,stop}_xray_{fn_idx,instr_map}` symbols. I've marked them weak, but 
> they seem to either not be resolved when statically linking the binary. The 
> dynamic lib version of the XRay runtime isn't quite ready yet, but I'm 
> willing to try some things there.
>  There are also missing symbols from the sanitizer_common library that's 
> linked to from the `libclang_rt.xray_osx.a` produced by the compiler-rt XRay 
> build configuration.
>  Any further hints/thoughts on this would be great, @kubamracek (cc @pelikan 
> and @echristo)

This is one of the reasons why a dynamic shared library works better. Using a 
dynamic library should solve this. What are the problems with that?


https://reviews.llvm.org/D39114



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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added inline comments.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:25
+/// we will do best effort to generate a fix, however, if the
+/// case can not be solved with a simple fix (e.g. remove prefix or change 
first
+/// character), we will leave the fix to the user.

hokein wrote:
> I might miss some background context. 
> 
> The fix of the check seems to me that it does more things it should. It 
> removes all the non-alphabetical prefix characters, I'd be conservative of 
> the fix here (just fix the case "CamelCase", and only give a warning for 
> other cases).
I agree, removing a prefix is not a good idea. Warning is fine.

We could probably also change `snake_case` variables to `CamelCase` 
automatically. Not sure if it's worth doing in this review, but @Wizard can 
file a bug to follow up and add a TODO comment here mentioning the bug.


https://reviews.llvm.org/D39829



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


r317811 - [OPENMP] Treat '#pragma omp target parallel for simd' as simd directive.

2017-11-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Thu Nov  9 09:01:35 2017
New Revision: 317811

URL: http://llvm.org/viewvc/llvm-project?rev=317811=rev
Log:
[OPENMP] Treat '#pragma omp target parallel for simd' as simd directive.

`#pragma omp target parallel for simd` mistakenly was not treated as a
simd directive, fixed this problem.

Modified:
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_lastprivate_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_loop_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_misc_messages.c
cfe/trunk/test/OpenMP/target_parallel_for_simd_ordered_messages.cpp

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=317811=317810=317811=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Thu Nov  9 09:01:35 2017
@@ -829,7 +829,8 @@ bool clang::isOpenMPSimdDirective(OpenMP
  DKind == OMPD_teams_distribute_simd ||
  DKind == OMPD_teams_distribute_parallel_for_simd ||
  DKind == OMPD_target_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_simd;
+ DKind == OMPD_target_teams_distribute_simd ||
+ DKind == OMPD_target_parallel_for_simd;
 }
 
 bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {

Modified: cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp?rev=317811=317810=317811=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp (original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_ast_print.cpp Thu Nov  9 
09:01:35 2017
@@ -77,14 +77,14 @@ T tmain(T argc, T *argv) {
 a = 2;
 // CHECK-NEXT: for (T i = 0; i < 2; ++i)
 // CHECK-NEXT: a = 2;
-#pragma omp target parallel for simd private(argc, b), firstprivate(c, d), 
lastprivate(d, f) collapse(N) schedule(static, N) ordered(N) if (parallel 
:argc) num_threads(N) default(shared) shared(e) reduction(+ : h)
+#pragma omp target parallel for simd private(argc, b), firstprivate(c, d), 
lastprivate(d, f) collapse(N) schedule(static, N) ordered if (parallel :argc) 
num_threads(N) default(shared) shared(e) reduction(+ : h)
   for (int i = 0; i < 2; ++i)
 for (int j = 0; j < 2; ++j)
   for (int j = 0; j < 2; ++j)
 for (int j = 0; j < 2; ++j)
   for (int j = 0; j < 2; ++j)
 foo();
-  // CHECK-NEXT: #pragma omp target parallel for simd private(argc,b) 
firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered(N) 
if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h)
+  // CHECK-NEXT: #pragma omp target parallel for simd private(argc,b) 
firstprivate(c,d) lastprivate(d,f) collapse(N) schedule(static, N) ordered 
if(parallel: argc) num_threads(N) default(shared) shared(e) reduction(+: h)
   // CHECK-NEXT: for (int i = 0; i < 2; ++i)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)
   // CHECK-NEXT: for (int j = 0; j < 2; ++j)

Modified: 
cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp?rev=317811=317810=317811=diff
==
--- cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/target_parallel_for_simd_firstprivate_messages.cpp 
Thu Nov  9 09:01:35 2017
@@ -125,11 +125,11 @@ int foomain(int argc, char **argv) {
 foo();
 #pragma omp parallel private(i)
 #pragma omp target parallel for simd firstprivate(i) // expected-note 
{{defined as firstprivate}}
-  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may not be 
firstprivate, predetermined as private}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may not be 
firstprivate, predetermined as linear}}
 foo();
 #pragma omp parallel reduction(+ : i)
 #pragma omp target parallel for simd firstprivate(i) // expected-note 
{{defined as firstprivate}}
-  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may not be 
firstprivate, predetermined as private}}
+  for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in 
the associated loop of 'omp target parallel for simd' directive may 

[PATCH] D39114: [XRay] Initial XRay in Darwin Support

2017-11-09 Thread Kuba (Brecka) Mracek via Phabricator via cfe-commits
kubamracek added a comment.

Thanks for working on this! Can we split the patch and land parts that are 
LGTM? It's getting a bit crowded here. I think the ASM changes should be a 
separate patch, and the test changes as well, probably.


https://reviews.llvm.org/D39114



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


[libcxx] r317816 - Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

2017-11-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Nov  9 09:54:49 2017
New Revision: 317816

URL: http://llvm.org/viewvc/llvm-project?rev=317816=rev
Log:
Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

The commit r300140 changed the implementation of compressed_pair, but didn't add
_LIBCPP_INLINE_VISIBILITY to the constructors and get members of the
compressed_pair_elem class. This patch adds the visibility annotation.

I didn't find a way to test this change with libc++ regression tests.

rdar://35352579

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

Modified:
libcxx/trunk/include/memory

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=317816=317815=317816=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Thu Nov  9 09:54:49 2017
@@ -2040,11 +2040,12 @@ struct __compressed_pair_elem {
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@ struct __compressed_pair_elem {
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@ struct __compressed_pair_elem<_Tp, _Idx,
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@ struct __compressed_pair_elem<_Tp, _Idx,
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 


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


[PATCH] D39751: [libc++] Add _LIBCPP_INLINE_VISIBILITY to __compressed_pair_elem members

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317816: Add _LIBCPP_INLINE_VISIBILITY to 
__compressed_pair_elem members (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D39751?vs=121939=122261#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39751

Files:
  libcxx/trunk/include/memory


Index: libcxx/trunk/include/memory
===
--- libcxx/trunk/include/memory
+++ libcxx/trunk/include/memory
@@ -2040,11 +2040,12 @@
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 


Index: libcxx/trunk/include/memory
===
--- libcxx/trunk/include/memory
+++ libcxx/trunk/include/memory
@@ -2040,11 +2040,12 @@
   typedef const _Tp& const_reference;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() : __value_() {}
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_(_VSTD::forward<_Up>(__u)){};
@@ -2055,11 +2056,13 @@
  __tuple_indices<_Indexes...>)
   : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return __value_; }
 
 private:
@@ -2074,11 +2077,12 @@
   typedef _Tp __value_type;
 
 #ifndef _LIBCPP_CXX03_LANG
-  constexpr __compressed_pair_elem() = default;
+  _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default;
 
   template ::type>::value
   >::type>
+  _LIBCPP_INLINE_VISIBILITY
   constexpr explicit
   __compressed_pair_elem(_Up&& __u)
   : __value_type(_VSTD::forward<_Up>(__u)){};
@@ -2089,12 +2093,14 @@
  __tuple_indices<_Indexes...>)
   : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {}
 #else
-  __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {}
+  _LIBCPP_INLINE_VISIBILITY
   __compressed_pair_elem(_ParamT __p)
   : __value_type(std::forward<_ParamT>(__p)) {}
 #endif
 
-  reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; }
+  _LIBCPP_INLINE_VISIBILITY
   const_reference __get() const _NOEXCEPT { return *this; }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2017-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 122268.
ABataev added a comment.

Update status.


https://reviews.llvm.org/D39457

Files:
  docs/OpenMPSupport.rst
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.5 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework 
is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full 
codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target simd: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp target teams: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams distribute [simd]: :partial:`Partial`.  No full codegen 
support.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No full 
codegen support.
+
+* #pragma omp teams distribute parallel for [simd]: :partial:`Partial`.  No 
full codegen support.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task`-based directives.
+


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.5 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target 

[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a subscriber: cfe-commits.
kzhuravl added a reviewer: aaron.ballman.
kzhuravl added a comment.

Hi Alex, can you rebase on top of trunk (I think you brought in some extra 
changes from hcc branch) and upload a full diff?




Comment at: include/clang/Basic/Attr.td:1328
+  ExprArgument<"Max", 1>,
   StringArgument<"ISA", 1>];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];

Not in trunk.



Comment at: include/clang/Basic/Attr.td:1339
+  ExprArgument<"Max", 1>,
   StringArgument<"ISA", 1>];
   let Documentation = [AMDGPUWavesPerEUDocs];

Not in trunk.



Comment at: include/clang/Basic/Attr.td:1361-1370
+def AMDGPUMaxWorkGroupDim : InheritableAttr {
   let Spellings = [CXX11<"","hc_max_workgroup_dim", 201511>];
-  let Args = [IntArgument<"X">,
-  IntArgument<"Y", 1>,
-  IntArgument<"Z", 1>,
+  let Args = [ExprArgument<"X">,
+  ExprArgument<"Y">,
+  ExprArgument<"Z">,
   StringArgument<"ISA", 1>];
   let Subjects = SubjectList<[Function], ErrorDiag>;

Not in trunk.


https://reviews.llvm.org/D39857



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


[PATCH] D39852: [clangd] Support returning a limited number of completion results.

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.

All results are scored, we only process CodeCompletionStrings for the winners.
We now return CompletionList rather than CompletionItem[] (both are valid).
sortText is now based on CodeCompletionResult::orderedName (mostly the same).

This is the first clangd-only completion option, so plumbing changed.
It requires a small clangd patch (exposing CodeCompletionResult::orderedName).

(This can't usefully be enabled yet: we don't support server-side filtering)


https://reviews.llvm.org/D39852

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/authority-less-uri.test
  test/clangd/completion-items-kinds.test
  test/clangd/completion-priorities.test
  test/clangd/completion-qualifiers.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -619,16 +619,15 @@
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
   template 
-  bool ContainsItemPred(std::vector const ,
-Predicate Pred) {
-for (const auto  : Items) {
+  bool ContainsItemPred(CompletionList const , Predicate Pred) {
+for (const auto  : Items.items) {
   if (Pred(Item))
 return true;
 }
 return false;
   }
 
-  bool ContainsItem(std::vector const , StringRef Name) {
+  bool ContainsItem(CompletionList const , StringRef Name) {
 return ContainsItemPred(Items, [Name](clangd::CompletionItem Item) {
   return Item.insertText == Name;
 });
@@ -694,6 +693,44 @@
   }
 }
 
+TEST_F(ClangdCompletionTest, Limit) {
+  MockFSProvider FS;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  CDB.ExtraClangFlags.push_back("-xc++");
+  ErrorCheckingDiagConsumer DiagConsumer;
+  clangd::CodeCompleteOptions Opts;
+  Opts.Limit = 2;
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  Opts, EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  FS.Files[FooCpp] = "";
+  FS.ExpectedFile = FooCpp;
+  StringWithPos Completion = parseTextMarker(R"cpp(
+struct ClassWithMembers {
+  int AAA();
+  int BBB();
+  int CCC();
+}
+int main() { ClassWithMembers().{complete} }
+  )cpp",
+ "complete");
+  Server.addDocument(FooCpp, Completion.Text);
+
+  /// For after-dot completion we must always get consistent results.
+  auto Results = Server
+ .codeComplete(FooCpp, Completion.MarkerPos,
+   StringRef(Completion.Text))
+ .get()
+ .Value;
+
+  EXPECT_TRUE(Results.isIncomplete);
+  EXPECT_EQ(Opts.Limit, Results.items.size());
+  EXPECT_TRUE(ContainsItem(Results, "AAA"));
+  EXPECT_TRUE(ContainsItem(Results, "BBB"));
+  EXPECT_FALSE(ContainsItem(Results, "CCC"));
+}
+
 TEST_F(ClangdCompletionTest, CompletionOptions) {
   MockFSProvider FS;
   ErrorCheckingDiagConsumer DiagConsumer;
Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -31,14 +31,17 @@
 #
 #  CHECK:  "id": 1,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:"sortText": "75fake"
+#  CHECK:]
+# CHECK-NEXT:  }
 
 X-Test: Testing
 Content-Type: application/vscode-jsonrpc; charset-utf-8
@@ -57,14 +60,17 @@
 #
 #  CHECK:  "id": 3,
 # CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": [
-#  CHECK:  "filterText": "fake",
-# CHECK-NEXT:  "insertText": "fake",
-# CHECK-NEXT:  "insertTextFormat": 1,
-# CHECK-NEXT:  "kind": 7,
-# CHECK-NEXT:  "label": "fake::",
-# CHECK-NEXT:  "sortText": "75fake"
-#  CHECK:  ]
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"isIncomplete": false,
+# CHECK-NEXT:"items": [
+#  CHECK:"filterText": "fake",
+# CHECK-NEXT:"insertText": "fake",
+# CHECK-NEXT:"insertTextFormat": 1,
+# CHECK-NEXT:"kind": 7,
+# CHECK-NEXT:"label": "fake::",
+# CHECK-NEXT:

[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2017-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 122273.
ABataev added a comment.

Fixed version of OpenMP standard


https://reviews.llvm.org/D39457

Files:
  docs/OpenMPSupport.rst
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework 
is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full 
codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* #pragma omp target simd: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp target teams: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams distribute [simd]: :partial:`Partial`.  No full codegen 
support.
+
+* #pragma omp target teams distribute [simd]: :partial:`Partial`.  No full 
codegen support.
+
+* #pragma omp teams distribute parallel for [simd]: :partial:`Partial`.  No 
full codegen support.
+
+* #pragma omp target teams distribute parallel for [simd]: :partial:`Partial`. 
 No full codegen support.
+
+Clang does not support any constructs/updates from upcoming OpenMP 5.0 except 
for `reduction`-based clauses in the `task`-based directives.
+


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -39,6 +39,7 @@
SourceBasedCodeCoverage
Modules
MSVCCompatibility
+   OpenMPSupport
ThinLTO
CommandGuide/index
FAQ
Index: docs/OpenMPSupport.rst
===
--- /dev/null
+++ docs/OpenMPSupport.rst
@@ -0,0 +1,70 @@
+.. raw:: html
+
+  
+.none { background-color: #FF }
+.partial { background-color: #99 }
+.good { background-color: #CCFF99 }
+  
+
+.. role:: none
+.. role:: partial
+.. role:: good
+
+==
+OpenMP Support
+==
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.
+
+Standalone directives
+=
+
+* #pragma omp [for] simd: :good:`Complete`.
+
+* #pragma omp declare simd: :partial:`Partial`.  We support parsing/semantic
+  analysis + generation of special attributes for X86 target, but still
+  missing the LLVM pass for vectorization.
+
+* #pragma omp taskloop [simd]: :good:`Complete`.
+
+* #pragma omp target [enter|exit] data: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target update: :good:`Mostly complete`.  Some rework is
+  required for better stability.
+
+* #pragma omp target: :partial:`Partial`.  No support for the `reduction`,
+  `nowait` and `depend` clauses.
+
+* #pragma omp declare target: :partial:`Partial`.  No full codegen support.
+
+* #pragma omp teams: :good:`Complete`.
+
+* #pragma omp distribute [simd]: :good:`Complete`.
+
+* #pragma omp distribute parallel for [simd]: :partial:`Partial`. No full codegen support.
+
+Combined directives
+===
+
+* #pragma omp parallel for simd: :good:`Complete`.
+
+* #pragma omp target parallel: :good:`Complete`.
+
+* #pragma omp target parallel for [simd]: :good:`Complete`.
+
+* 

r317820 - [analyzer] assume bitwise arithmetic axioms

2017-11-09 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Nov  9 11:06:22 2017
New Revision: 317820

URL: http://llvm.org/viewvc/llvm-project?rev=317820=rev
Log:
[analyzer] assume bitwise arithmetic axioms

Patches the solver to assume that bitwise OR of an unsigned value with a
constant always produces a value larger-or-equal than the constant, and
bitwise AND with a constant always produces a value less-or-equal than
the constant.

This patch is especially useful in the context of using bitwise
arithmetic for error code encoding: the analyzer would be able to state
that the error code produced using a bitwise OR is non-zero.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
cfe/trunk/test/Analysis/constant-folding.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp?rev=317820=317819=317820=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Thu Nov  9 
11:06:22 2017
@@ -460,6 +460,53 @@ RangeConstraintManager::removeDeadBindin
   return Changed ? State->set(CR) : State;
 }
 
+/// Return a range set subtracting zero from \p Domain.
+static RangeSet assumeNonZero(
+BasicValueFactory ,
+RangeSet::Factory ,
+SymbolRef Sym,
+RangeSet Domain) {
+  APSIntType IntType = BV.getAPSIntType(Sym->getType());
+  return Domain.Intersect(BV, F, ++IntType.getZeroValue(),
+  --IntType.getZeroValue());
+}
+
+/// \brief Apply implicit constraints for bitwise OR- and AND-.
+/// For unsigned types, bitwise OR with a constant always returns
+/// a value greater-or-equal than the constant, and bitwise AND
+/// returns a value less-or-equal then the constant.
+///
+/// Pattern matches the expression \p Sym against those rule,
+/// and applies the required constraints.
+/// \p Input Previously established expression range set
+static RangeSet applyBitwiseConstraints(
+BasicValueFactory ,
+RangeSet::Factory ,
+RangeSet Input,
+const SymIntExpr* SIE) {
+  QualType T = SIE->getType();
+  bool IsUnsigned = T->isUnsignedIntegerType();
+  const llvm::APSInt  = SIE->getRHS();
+  const llvm::APSInt  = BV.getAPSIntType(T).getZeroValue();
+  BinaryOperator::Opcode Operator = SIE->getOpcode();
+
+  // For unsigned types, the output of bitwise-or is bigger-or-equal than RHS.
+  if (Operator == BO_Or && IsUnsigned)
+return Input.Intersect(BV, F, RHS, BV.getMaxValue(T));
+
+  // Bitwise-or with a non-zero constant is always non-zero.
+  if (Operator == BO_Or && RHS != Zero)
+return assumeNonZero(BV, F, SIE, Input);
+
+  // For unsigned types, or positive RHS,
+  // bitwise-and output is always smaller-or-equal than RHS (assuming two's
+  // complement representation of signed types).
+  if (Operator == BO_And && (IsUnsigned || RHS >= Zero))
+return Input.Intersect(BV, F, BV.getMinValue(T), RHS);
+
+  return Input;
+}
+
 RangeSet RangeConstraintManager::getRange(ProgramStateRef State,
   SymbolRef Sym) {
   if (ConstraintRangeTy::data_type *V = State->get(Sym))
@@ -472,12 +519,13 @@ RangeSet RangeConstraintManager::getRang
 
   RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T));
 
-  // Special case: references are known to be non-zero.
-  if (T->isReferenceType()) {
-APSIntType IntType = BV.getAPSIntType(T);
-Result = Result.Intersect(BV, F, ++IntType.getZeroValue(),
-  --IntType.getZeroValue());
-  }
+  // References are known to be non-zero.
+  if (T->isReferenceType())
+return assumeNonZero(BV, F, Sym, Result);
+
+  // Known constraints on ranges of bitwise expressions.
+  if (const SymIntExpr* SIE = dyn_cast(Sym))
+return applyBitwiseConstraints(BV, F, Result, SIE);
 
   return Result;
 }

Modified: cfe/trunk/test/Analysis/constant-folding.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/constant-folding.c?rev=317820=317819=317820=diff
==
--- cfe/trunk/test/Analysis/constant-folding.c (original)
+++ cfe/trunk/test/Analysis/constant-folding.c Thu Nov  9 11:06:22 2017
@@ -76,3 +76,42 @@ void testMixedTypeComparisons (char a, u
   clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
   clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
 }
+
+void testBitwiseRules(unsigned int a, int b) {
+  clang_analyzer_eval((a | 1) >= 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | -1) >= -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 2) >= 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 5) >= 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 10) >= 10); // expected-warning{{TRUE}}
+
+  // Argument order should not 

[PATCH] D39707: [analyzer] assume bitwise arithmetic axioms

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317820: [analyzer] assume bitwise arithmetic axioms 
(authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D39707?vs=122170=122278#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39707

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  cfe/trunk/test/Analysis/constant-folding.c

Index: cfe/trunk/test/Analysis/constant-folding.c
===
--- cfe/trunk/test/Analysis/constant-folding.c
+++ cfe/trunk/test/Analysis/constant-folding.c
@@ -76,3 +76,42 @@
   clang_analyzer_eval(b >= a); // expected-warning{{TRUE}}
   clang_analyzer_eval(a != b); // expected-warning{{TRUE}}
 }
+
+void testBitwiseRules(unsigned int a, int b) {
+  clang_analyzer_eval((a | 1) >= 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | -1) >= -1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 2) >= 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 5) >= 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a | 10) >= 10); // expected-warning{{TRUE}}
+
+  // Argument order should not influence this
+  clang_analyzer_eval((1 | a) >= 1); // expected-warning{{TRUE}}
+
+  clang_analyzer_eval((a & 1) <= 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & 2) <= 2); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & 5) <= 5); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & 10) <= 10); // expected-warning{{TRUE}}
+  clang_analyzer_eval((a & -10) <= 10); // expected-warning{{UNKNOWN}}
+
+  // Again, check for different argument order.
+  clang_analyzer_eval((1 & a) <= 1); // expected-warning{{TRUE}}
+
+  unsigned int c = a;
+  c |= 1;
+  clang_analyzer_eval((c | 0) == 0); // expected-warning{{FALSE}}
+
+  // Rules don't apply to signed typed, as the values might be negative.
+  clang_analyzer_eval((b | 1) > 0); // expected-warning{{UNKNOWN}}
+
+  // Even for signed values, bitwise OR with a non-zero is always non-zero.
+  clang_analyzer_eval((b | 1) == 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((b | -2) == 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((b | 10) == 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval((b | 0) == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval((b | -2) >= 0); // expected-warning{{UNKNOWN}}
+
+  // Check that dynamically computed constants also work.
+  int constant = 1 << 3;
+  unsigned int d = a | constant;
+  clang_analyzer_eval(constant > 0); // expected-warning{{TRUE}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -460,6 +460,53 @@
   return Changed ? State->set(CR) : State;
 }
 
+/// Return a range set subtracting zero from \p Domain.
+static RangeSet assumeNonZero(
+BasicValueFactory ,
+RangeSet::Factory ,
+SymbolRef Sym,
+RangeSet Domain) {
+  APSIntType IntType = BV.getAPSIntType(Sym->getType());
+  return Domain.Intersect(BV, F, ++IntType.getZeroValue(),
+  --IntType.getZeroValue());
+}
+
+/// \brief Apply implicit constraints for bitwise OR- and AND-.
+/// For unsigned types, bitwise OR with a constant always returns
+/// a value greater-or-equal than the constant, and bitwise AND
+/// returns a value less-or-equal then the constant.
+///
+/// Pattern matches the expression \p Sym against those rule,
+/// and applies the required constraints.
+/// \p Input Previously established expression range set
+static RangeSet applyBitwiseConstraints(
+BasicValueFactory ,
+RangeSet::Factory ,
+RangeSet Input,
+const SymIntExpr* SIE) {
+  QualType T = SIE->getType();
+  bool IsUnsigned = T->isUnsignedIntegerType();
+  const llvm::APSInt  = SIE->getRHS();
+  const llvm::APSInt  = BV.getAPSIntType(T).getZeroValue();
+  BinaryOperator::Opcode Operator = SIE->getOpcode();
+
+  // For unsigned types, the output of bitwise-or is bigger-or-equal than RHS.
+  if (Operator == BO_Or && IsUnsigned)
+return Input.Intersect(BV, F, RHS, BV.getMaxValue(T));
+
+  // Bitwise-or with a non-zero constant is always non-zero.
+  if (Operator == BO_Or && RHS != Zero)
+return assumeNonZero(BV, F, SIE, Input);
+
+  // For unsigned types, or positive RHS,
+  // bitwise-and output is always smaller-or-equal than RHS (assuming two's
+  // complement representation of signed types).
+  if (Operator == BO_And && (IsUnsigned || RHS >= Zero))
+return Input.Intersect(BV, F, BV.getMinValue(T), RHS);
+
+  return Input;
+}
+
 RangeSet RangeConstraintManager::getRange(ProgramStateRef State,
   SymbolRef Sym) {
   if (ConstraintRangeTy::data_type *V = State->get(Sym))
@@ -472,12 +519,13 @@
 
   RangeSet Result(F, BV.getMinValue(T), BV.getMaxValue(T));
 
-  

[PATCH] D39799: [Tooling] Use FixedCompilationDatabase when `compile_flags.txt` is found.

2017-11-09 Thread JVApen via Phabricator via cfe-commits
JVApen added a comment.

How does this new file know if it should handle it's flags as  it does in 
clang.exe or clang-cl.exe?


Repository:
  rL LLVM

https://reviews.llvm.org/D39799



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/Attr.td:1329
   StringArgument<"ISA", 1>];
   let Documentation = [AMDGPUFlatWorkGroupSizeDocs];
   let Subjects = SubjectList<[Function], ErrorDiag, "ExpectedKernelFunction">;

Please ensure that the attribute documentation properly reflects the changes 
you've made here. At the very least, I would expect the docs to mention that 
these can now be in dependent contexts. 

The same applies for the other attributes.



Comment at: include/clang/Basic/Attr.td:1368
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
+  let TemplateDependent = 1;

Since you're changing the definition of the attribute, it would also be nice to 
add some documentation to AttrDocs.td for this.



Comment at: lib/CodeGen/TargetInfo.cpp:7665-7666
 
+namespace
+{
+  inline

This should be a static function rather than in an inline namespace.



Comment at: lib/CodeGen/TargetInfo.cpp:7671
+llvm::APSInt r{32, 0};
+if (E) E->EvaluateAsInt(r, Ctx);
+

If there is no expression given, why should this return an `APSInt` for 0? This 
seems more like something you would assert.



Comment at: lib/Sema/SemaDeclAttr.cpp:5583-5584
 
+namespace
+{
+  inline

static function instead, please.



Comment at: lib/Sema/SemaDeclAttr.cpp:5586
+  inline
+  bool checkAllAreIntegral(const AttributeList , Sema ) {
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {

We usually put the `Sema` object first in the parameter list in this file, 
don't we?



Comment at: lib/Sema/SemaDeclAttr.cpp:5587-5588
+  bool checkAllAreIntegral(const AttributeList , Sema ) {
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+  auto e = Attr.getArgAsExpr(i);
+  if (e && !e->getType()->isIntegralOrEnumerationType()) {

These variables should not be lower-case per our usual coding conventions.



Comment at: lib/Sema/SemaDeclAttr.cpp:5588
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+  auto e = Attr.getArgAsExpr(i);
+  if (e && !e->getType()->isIntegralOrEnumerationType()) {

Please spell the type out explicitly.


https://reviews.llvm.org/D39857



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


[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun.

This is the issue breaking the postgresql bot, purely by chance exposed through 
taint checker, somehow appearing after https://reviews.llvm.org/D38358 got 
committed.

The backstory is that the taint checker requests `SVal` for the value of the 
pointer, and analyzer has a "fast path" in the getter to return a constant when 
we know that the value is constant.
Unfortunately, the getter requires a cast to get signedness correctly, and for 
the pointer `void *` the cast crashes.

This is more of a band-aid patch, as I am not sure what could be done here 
"correctly", but it should be applied in any case to avoid the crash.

@dcoughlin faster review here would be appreciated to get the bot back to green.


https://reviews.llvm.org/D39862

Files:
  lib/StaticAnalyzer/Core/ProgramState.cpp
  test/Analysis/taint-tester.c


Index: test/Analysis/taint-tester.c
===
--- test/Analysis/taint-tester.c
+++ test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()


Index: test/Analysis/taint-tester.c
===
--- test/Analysis/taint-tester.c
+++ test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39739: [HCC] Add flag to Import Weak Functions in Function Importer

2017-11-09 Thread Aaron En Ye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 122271.
ashi1 added subscribers: scchan, yaxunl, ashi1.
ashi1 added a comment.
Herald added a subscriber: eraman.

I've added the lit tests for this change, and also showing full context.

My lit test import_weak_type.ll follows similar format to import_opaque_type.ll.


Repository:
  rL LLVM

https://reviews.llvm.org/D39739

Files:
  include/llvm/Transforms/Utils/FunctionImportUtils.h
  lib/Transforms/IPO/FunctionImport.cpp
  lib/Transforms/Utils/FunctionImportUtils.cpp
  test/ThinLTO/X86/Inputs/import_weak_type.ll
  test/ThinLTO/X86/import_weak_type.ll


Index: test/ThinLTO/X86/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/import_weak_type.ll
@@ -0,0 +1,19 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: opt -module-summary %p/Inputs/import_weak_type.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Check that we import correctly the imported weak type to replace declaration 
here
+; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t3.bc 
-force-import-weak -o - | llvm-dis -o - | FileCheck %s
+; CHECK: define weak void @foo()
+
+
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target triple = "amdgcn--amdhsa-hcc"
+
+declare extern_weak void @foo()
+define weak_odr amdgpu_kernel void @main() {
+call void @foo()
+  ret void
+}
+
Index: test/ThinLTO/X86/Inputs/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/Inputs/import_weak_type.ll
@@ -0,0 +1,7 @@
+target datalayout = 
"e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
+target triple = "amdgcn--amdhsa-hcc"
+
+define weak void @foo() {
+  ret void
+}
+
Index: lib/Transforms/Utils/FunctionImportUtils.cpp
===
--- lib/Transforms/Utils/FunctionImportUtils.cpp
+++ lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -151,7 +151,8 @@
 // program semantics, since the linker will pick the first weak_any
 // definition and importing would change the order they are seen by the
 // linker. The module linking caller needs to enforce this.
-assert(!doImportAsDefinition(SGV));
+if(!ForceImportWeakFlag)
+  assert(!doImportAsDefinition(SGV));
 // If imported as a declaration, it becomes external_weak.
 return SGV->getLinkage();
 
Index: lib/Transforms/IPO/FunctionImport.cpp
===
--- lib/Transforms/IPO/FunctionImport.cpp
+++ lib/Transforms/IPO/FunctionImport.cpp
@@ -102,6 +102,12 @@
 static cl::opt ComputeDead("compute-dead", cl::init(true), cl::Hidden,
  cl::desc("Compute dead symbols"));
 
+bool llvm::ForceImportWeakFlag;
+static cl::opt
+ForceImportWeak("force-import-weak", cl::Hidden,
+cl::desc("Allow weak functions to be imported"),
+cl::location(ForceImportWeakFlag), cl::init(false));
+
 static cl::opt EnableImportMetadata(
 "enable-import-metadata", cl::init(
 #if !defined(NDEBUG)
@@ -169,7 +175,7 @@
 // filtered out.
 if (GVSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind)
   return false;
-if (GlobalValue::isInterposableLinkage(GVSummary->linkage()))
+if (!ForceImportWeakFlag && 
GlobalValue::isInterposableLinkage(GVSummary->linkage()))
   // There is no point in importing these, we can't inline them
   return false;
 if (isa(GVSummary))
Index: include/llvm/Transforms/Utils/FunctionImportUtils.h
===
--- include/llvm/Transforms/Utils/FunctionImportUtils.h
+++ include/llvm/Transforms/Utils/FunctionImportUtils.h
@@ -21,6 +21,9 @@
 namespace llvm {
 class Module;
 
+// Set to true depending on option -force-import-weak
+extern bool ForceImportWeakFlag;
+
 /// Class to handle necessary GlobalValue changes required by ThinLTO
 /// function importing, including linkage changes and any necessary renaming.
 class FunctionImportGlobalProcessing {


Index: test/ThinLTO/X86/import_weak_type.ll
===
--- /dev/null
+++ test/ThinLTO/X86/import_weak_type.ll
@@ -0,0 +1,19 @@
+; Do setup work for all below tests: generate bitcode and combined index
+; RUN: opt -module-summary %s -o %t.bc
+; RUN: opt -module-summary %p/Inputs/import_weak_type.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
+
+; Check that we import correctly the imported weak type to replace declaration here
+; 

[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

2017-11-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.

[OpenMP] diagnose assign to firstprivate const

Clang does not diagnose assignments to const variables declared
firstprivate.  Furthermore, codegen is broken such that, at run time,
such assignments simply have no effect.  For example, the following
prints 0 not 1:

int main() {

  const int i = 0;
  #pragma omp parallel firstprivate(i)
  { i=1; printf("%d\n", i); }
  return 0;

}

This commit makes these assignments a compile error, which is
consistent with other OpenMP compilers I've tried (pgcc 17.4-0, gcc 
6.3.0).


https://reviews.llvm.org/D39859

Files:
  lib/Sema/SemaExpr.cpp
  test/OpenMP/parallel_firstprivate_messages.cpp


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,7 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not 
refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}}
+d = 5; // expected-error {{cannot assign to variable 'd' with 
const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected 
variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool hasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (hasConst)
+DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,7 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool hasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (hasConst)
+DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39838: [clang] [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317828: [python] [tests] Update priority values in code 
completion test (authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D39838?vs=17=122304#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39838

Files:
  cfe/trunk/bindings/python/tests/cindex/test_code_completion.py


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -68,8 +68,8 @@
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: 
Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: 
Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || 
Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)


Index: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
===
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
@@ -68,8 +68,8 @@
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | {'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39706: [refactor][extract] Initial implementation of variable captures

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 122270.
arphaman marked 5 inline comments as done.
arphaman added a comment.

Address review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D39706

Files:
  lib/Tooling/Refactoring/CMakeLists.txt
  lib/Tooling/Refactoring/Extract/CaptureVariables.cpp
  lib/Tooling/Refactoring/Extract/CaptureVariables.h
  lib/Tooling/Refactoring/Extract/Extract.cpp
  test/Refactor/Extract/CaptureSimpleVariables.cpp
  test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
  test/Refactor/Extract/ExtractionSemicolonPolicy.m

Index: test/Refactor/Extract/ExtractionSemicolonPolicy.m
===
--- test/Refactor/Extract/ExtractionSemicolonPolicy.m
+++ test/Refactor/Extract/ExtractionSemicolonPolicy.m
@@ -10,7 +10,7 @@
   }
 }
 // CHECK: 1 'astmt' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(NSArray *array) {
 // CHECK-NEXT: for (id i in array) {
 // CHECK-NEXT: int x = 0;
 // CHECK-NEXT: }{{$}}
@@ -23,7 +23,7 @@
   }
 }
 // CHECK: 1 'bstmt' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(id lock) {
 // CHECK-NEXT: @synchronized(lock) {
 // CHECK-NEXT: int x = 0;
 // CHECK-NEXT: }{{$}}
Index: test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
===
--- test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
+++ test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
@@ -6,41 +6,41 @@
   /*range adeclstmt=->+0:59*/int area = r.width * r.height;
 }
 // CHECK: 1 'adeclstmt' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(const Rectangle ) {
 // CHECK-NEXT: int area = r.width * r.height;{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatement(const Rectangle ) {
-// CHECK-NEXT:   /*range adeclstmt=->+0:59*/extracted();{{$}}
+// CHECK-NEXT:   /*range adeclstmt=->+0:59*/extracted(r);{{$}}
 // CHECK-NEXT: }
 
 void extractStatementNoSemiIf(const Rectangle ) {
   /*range bextractif=->+2:4*/if (r.width) {
 int x = r.height;
   }
 }
 // CHECK: 1 'bextractif' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(const Rectangle ) {
 // CHECK-NEXT: if (r.width) {
 // CHECK-NEXT: int x = r.height;
 // CHECK-NEXT: }{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatementNoSemiIf(const Rectangle ) {
-// CHECK-NEXT:   /*range bextractif=->+2:4*/extracted();{{$}}
+// CHECK-NEXT:   /*range bextractif=->+2:4*/extracted(r);{{$}}
 // CHECK-NEXT: }
 
 void extractStatementDontExtraneousSemi(const Rectangle ) {
   /*range cextractif=->+2:4*/if (r.width) {
 int x = r.height;
   } ;
 } //^ This semicolon shouldn't be extracted.
 // CHECK: 1 'cextractif' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(const Rectangle ) {
 // CHECK-NEXT: if (r.width) {
 // CHECK-NEXT: int x = r.height;
 // CHECK-NEXT: }{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatementDontExtraneousSemi(const Rectangle ) {
-// CHECK-NEXT: extracted(); ;{{$}}
+// CHECK-NEXT: extracted(r); ;{{$}}
 // CHECK-NEXT: }
 
 void extractStatementNotSemiSwitch() {
@@ -102,12 +102,12 @@
   }
 }
 // CHECK: 1 'gextract' results:
-// CHECK:  static void extracted() {
+// CHECK:  static void extracted(XS xs) {
 // CHECK-NEXT: for (int i : xs) {
 // CHECK-NEXT: }{{$}}
 // CHECK-NEXT: }{{[[:space:]].*}}
 // CHECK-NEXT: void extractStatementNotSemiRangedFor(XS xs) {
-// CHECK-NEXT: extracted();{{$}}
+// CHECK-NEXT: extracted(xs);{{$}}
 // CHECK-NEXT: }
 
 void extractStatementNotSemiRangedTryCatch() {
Index: test/Refactor/Extract/CaptureSimpleVariables.cpp
===
--- /dev/null
+++ test/Refactor/Extract/CaptureSimpleVariables.cpp
@@ -0,0 +1,40 @@
+// RUN: clang-refactor extract -selection=test:%s %s -- 2>&1 | grep -v CHECK | FileCheck %s
+
+void captureStaticVars() {
+  static int x;
+  /*range astaticvar=->+0:39*/int y = x;
+  x += 1;
+}
+// CHECK: 1 'astaticvar' results:
+// CHECK:  static void extracted(int x) {
+// CHECK-NEXT: int y = x;{{$}}
+// CHECK-NEXT: }{{[[:space:]].*}}
+// CHECK-NEXT: void captureStaticVars() {
+// CHECK-NEXT: static int x;
+// CHECK-NEXT: extracted(x);{{$}}
+
+typedef struct {
+  int width, height;
+} Rectangle;
+
+void basicTypes(int i, float f, char c, const int *ip, float *fp, const Rectangle *structPointer) {
+  /*range basictypes=->+0:73*/basicTypes(i, f, c, ip, fp, structPointer);
+}
+// CHECK: 1 'basictypes' results:
+// CHECK:  static void extracted(char c, float f, float *fp, int i, const int *ip, const Rectangle *structPointer) {
+// CHECK-NEXT: basicTypes(i, f, c, ip, fp, structPointer);{{$}}
+// CHECK-NEXT: }{{[[:space:]].*}}
+// CHECK-NEXT: void basicTypes(int i, float f, char c, const int *ip, float *fp, const Rectangle *structPointer) {
+// CHECK-NEXT: 

[PATCH] D39706: [refactor][extract] Initial implementation of variable captures

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Tooling/Refactoring/Extract/CaptureVariables.cpp:36
+  return true;
+// FIXME: Capture 'self'.
+if (!VD->isLocalVarDeclOrParm())

ioeric wrote:
> and `this`?
This is a different kind of expression that won't be handled in this method, 
and there's a fixit for 'this' further down already.



Comment at: lib/Tooling/Refactoring/Extract/CaptureVariables.h:36
+  explicit CapturedExtractedEntity(const VarDecl *VD)
+  : Kind(CapturedVarDecl), VD(VD) {}
+

ioeric wrote:
> Maybe a `FIXME` here for `Kind`?
I think this constructor will always set the same kind.


Repository:
  rL LLVM

https://reviews.llvm.org/D39706



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


[PATCH] D39707: [analyzer] assume bitwise arithmetic axioms

2017-11-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

This looks good to me. It is very clean! But please add a comment in the places 
where you are assuming a two's complement value representation for signed 
integers.


https://reviews.llvm.org/D39707



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


[PATCH] D39838: [clang] [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In https://reviews.llvm.org/D39838#920399, @ilya-biryukov wrote:

> LGTM.
>
> Can we run those tests as part of `check-all` cmake target or setup a 
> buildbot that runs those? Seems surprising it went unnoticed for so long.


I was thinking of that but I think it'd be nice to find someone who knows them 
better. I know they're loading `libclang.so` dynamically somehow, and I'm not 
really sure how to make sure that they're going to test the right library. On 
Gentoo we run the tests after installing clang to the system.


Repository:
  rL LLVM

https://reviews.llvm.org/D39838



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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-09 Thread Reimar Döffinger via cfe-commits
Hello!

On Wed, Nov 08, 2017 at 12:36:00PM -0800, Volodymyr Sapsai wrote:
> Thanks for the patch, Reimar. Can you please add tests to ensure this 
> functionality doesn’t regress? As null character is required by the standard 
> (27.7.2.3p21), a good starting point seems to be
> test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size.pass.cpp
> test/std/input.output/iostream.format/input.streams/istream.unformatted/getline_pointer_size_chart.pass.cpp

New patch attached, though I went the lazy way of just adding one case.
Not sure that's "good enough" - in principle I think it should be.
More tricky would be to add a test for the _LIBCPP_NO_EXCEPTIONS case,
is there any code testing that at all?

> And what about free function std::getline that takes a stream and a string? 
> The standard (21.4.8.9p7) specifies 
[...]
> 
> Technically, string is not a character array of non-zero size. But according 
> to the spirit of the standard, I would expect string to be empty after 
> reading into it from a stream that reached EOF. What do you think?

Starting with the useful answer instead of what I think:

I'd try what other implementations do and align with that.
At least libstdc++ does not clear the string, so tentatively
I'd suggest not changing behaviour, for simple interoperability.
Testing at least Microsoft C++ in addition might be a good idea
though...
Test code:

#include 
#include 
#include 

int main()
{
std::istringstream in;
std::string dummy;
in >> dummy;
char test[20] = "oldstring";
in.getline(test, sizeof(test));
std::cout << "std::istream::getline result: " << test << std::endl;
dummy = "oldstring";
std::getline(in, dummy);
std::cout << "std::getline result: " << dummy << std::endl;
return test[0];
}


As to what I really think, for anyone who isn't tired of unfair rants
(anyone else please just skip):

I don't really care much about that case, because at least unlike
not 0-terminating a char buffer it is not in the "things you never EVER
do" list.
But this rather needs to be put to the standard authors and it needs to be
clarified.
Along with the suggestion to not only spend time on new features but
also on improving the spec quality.
Large parts of the spec read like when a second-semester maths student
tries to write a proof: the language lacks the precision to actually
write a solid proof, and excessive verbosity is used to try to make
up for it (to no effect besides annoying the reader).
The lack of specified pre- and post-conditions (specified formally
or in natural language) for at least parts easy to specify in such a way
to allow at least partial formal verification or proof of correctness
isn't exactly state-of-the-art either.

Kind regards,
Reimar Döffinger

> > On Oct 4, 2017, at 12:07, Reimar Döffinger via cfe-commits 
> >  wrote:
> > 
> > If the sentinel failed (e.g. due to having reached
> > EOF before) or an exception was caught it failed to
> > do that.
> > The C++14 standard says:
> > "In any case, if n is greater than zero, it then stores
> > a null character (using charT()) into the next
> > successive location of the array."
> > Other implementations like libstdc++ do 0-terminate and
> > not doing so may lead security issues in applications.
> > ---
> > include/istream | 6 --
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/istream b/include/istream
> > index 0b8e05d95..5c73df38f 100644
> > --- a/include/istream
> > +++ b/include/istream
> > @@ -1069,16 +1069,18 @@ basic_istream<_CharT, _Traits>::getline(char_type* 
> > __s, streamsize __n, char_typ
> > this->rdbuf()->sbumpc();
> > ++__gc_;
> > }
> > -if (__n > 0)
> > -*__s = char_type();
> > if (__gc_ == 0)
> >__err |= ios_base::failbit;
> > this->setstate(__err);
> > }
> > +if (__n > 0)
> > +*__s = char_type();
> > #ifndef _LIBCPP_NO_EXCEPTIONS
> > }
> > catch (...)
> > {
> > +if (__n > 0)
> > +*__s = char_type();
> > this->__set_badbit_and_consider_rethrow();
> > }
> > #endif  // _LIBCPP_NO_EXCEPTIONS
> > -- 
> > 2.14.2
> > 
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 
>From 67ecbad84c70a611cb933b90bb10a10e5f32d4a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= 
Date: Thu, 7 Sep 2017 08:42:10 +0200
Subject: [PATCH] Ensure std::istream::getline always 0-terminates string.

If the sentinel failed (e.g. due to having reached
EOF before) or an exception was caught it failed to
do that.
The C++14 standard says:
"In any case, if n is greater than zero, it then stores
a null character (using charT()) into the next
successive location 

r317828 - [python] [tests] Update priority values in code completion test

2017-11-09 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Nov  9 12:17:41 2017
New Revision: 317828

URL: http://llvm.org/viewvc/llvm-project?rev=317828=rev
Log:
[python] [tests] Update priority values in code completion test

The priority for destructors and operators was reduced in r314019.
Adjust the values used in the test appropriately to fix the test
failure.

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

Modified:
cfe/trunk/bindings/python/tests/cindex/test_code_completion.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_code_completion.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_code_completion.py?rev=317828=317827=317828=diff
==
--- cfe/trunk/bindings/python/tests/cindex/test_code_completion.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_code_completion.py Thu Nov  9 
12:17:41 2017
@@ -68,8 +68,8 @@ void f(P x, Q y) {
 cr = tu.codeComplete('fake.cpp', 13, 5, unsaved_files=files)
 expected = [
 "{'P', TypedText} | {'::', Text} || Priority: 75 || Availability: 
Available || Brief comment: None",
-"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 34 || Availability: 
Available || Brief comment: None",
+"{'P &', ResultType} | {'operator=', TypedText} | {'(', LeftParen} | 
{'const P &', Placeholder} | {')', RightParen} || Priority: 79 || Availability: 
Available || Brief comment: None",
 "{'int', ResultType} | {'member', TypedText} || Priority: 35 || 
Availability: NotAccessible || Brief comment: None",
-"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 34 || Availability: Available || Brief comment: None"
+"{'void', ResultType} | {'~P', TypedText} | {'(', LeftParen} | {')', 
RightParen} || Priority: 79 || Availability: Available || Brief comment: None"
 ]
 check_completion_results(cr, expected)


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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In https://reviews.llvm.org/D39836#920587, @sammccall wrote:

> So I probably should have started from the other end, here :-)
>
> I'd really like to make the completion retrieval and ranking more flexible. 
> In particular
>
> - incorporating results from other sources (indexes: both in-memory and 
> external services).
> - combining more quality signals like usage count and fuzzy-match-strength in 
> a non-lexicographic-sort way The biggest difficulty in *supporting* unusable 
> functions is maintaining the invariant that all unusable functions are ranked 
> lower than usable ones - all code that deals with ranking has to deal with 
> this special case, e.g. by making score a tuple instead of a single number.


That sounds good to me. Please keep in mind that not all clients might want to 
take advantage of these things as they might have their own fuzz-match logic 
and external result injection.

> If the current approach of "give them a penalty" is enough, knowing that in 
> the future it may lead to e.g. a very widely used but inaccessible protected 
> function being ranked highly, then that seems fine to me too. A wider 
> configuration space means testing is more work, but happy to live with it. 
> What do you think?
> 
> (With my user-hat on, configurable is fine, though I do strongly feel they 
> should be off by default, and it seems unlikely many users will change the 
> defaults.)

I'd be ok with off by default, as long as it's possible to turn it on :)


https://reviews.llvm.org/D39836



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


[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

2017-11-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Sema/SemaExpr.cpp:14356
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool hasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();

`hasConst` must start from capital letter `HasConst`.



Comment at: lib/Sema/SemaExpr.cpp:14360
+  if (hasConst)
+DeclRefType = QualType(DeclRefType.getTypePtr(), Qualifiers::Const);
+}

Better to make it this way:
```
DeclRefType.addConst();
```



Comment at: test/OpenMP/parallel_firstprivate_messages.cpp:75
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}}
+d = 5; // expected-error {{cannot assign to variable 'd' with 
const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected 
variable name}}

Please, add a separate directive with this assignment


https://reviews.llvm.org/D39859



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


[PATCH] D39738: [clangd] Sort completion results.

2017-11-09 Thread Francisco Lopes da Silva via Phabricator via cfe-commits
francisco.lopes added a comment.

Sorting got hardcoded? libclang has it optional. If hardcoded it becomes a 
performance problem, since some clients may wish to order it themselves with 
private heuristics.


Repository:
  rL LLVM

https://reviews.llvm.org/D39738



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 122323.
AlexVlx marked 7 inline comments as done.

https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,33 @@
   }
 }
 
+static bool checkAllAreIntegral(Sema , const AttributeList ) {
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);
+if (E && !E->getType()->isIntegralOrEnumerationType()) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+<< getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+<< E->getSourceRange();
+
+  return false;
+}
+  }
+
+  return true;
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema , Decl *D,
   const AttributeList ) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5510,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema , Decl *D,
const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
-Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+MaxExpr = Attr.getArgAsExpr(1);
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5547,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
+ AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7661,6 +7661,16 @@
 };
 }
 
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+{
+  assert(E);
+
+  llvm::APSInt Tmp{32, 0};
+  E->EvaluateAsInt(Tmp, Ctx);
+
+  return Tmp;
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ,
 ForDefinition_t IsForDefinition) const {
@@ -7676,8 +7686,11 @@
 FD->getAttr() : nullptr;
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+

[PATCH] D38818: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 marked an inline comment as done.
sabel83 added a comment.

The last update of the patch also contains the changes to this pull request 
based on comments from https://reviews.llvm.org/D5767.


https://reviews.llvm.org/D38818



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


[PATCH] D39859: [OpenMP] diagnose assign to firstprivate const

2017-11-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 122329.
jdenny added a comment.

Hi Alexey.  Thanks for your comments.  This update should address them all.


https://reviews.llvm.org/D39859

Files:
  lib/Sema/SemaExpr.cpp
  test/OpenMP/parallel_firstprivate_messages.cpp


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,8 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not 
refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}}
+  #pragma omp parallel firstprivate (d)
+d = 5; // expected-error {{cannot assign to variable 'd' with 
const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected 
variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool HasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (HasConst)
+DeclRefType.addConst();
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 


Index: test/OpenMP/parallel_firstprivate_messages.cpp
===
--- test/OpenMP/parallel_firstprivate_messages.cpp
+++ test/OpenMP/parallel_firstprivate_messages.cpp
@@ -56,7 +56,7 @@
 }
 
 int main(int argc, char **argv) {
-  const int d = 5;
+  const int d = 5; // expected-note {{variable 'd' declared const here}}
   const int da[5] = { 0 };
   S4 e(4);
   S5 g(5);
@@ -72,6 +72,8 @@
   #pragma omp parallel firstprivate (argc)
   #pragma omp parallel firstprivate (S1) // expected-error {{'S1' does not refer to a value}}
   #pragma omp parallel firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
+  #pragma omp parallel firstprivate (d)
+d = 5; // expected-error {{cannot assign to variable 'd' with const-qualified type}}
   #pragma omp parallel firstprivate (argv[1]) // expected-error {{expected variable name}}
   #pragma omp parallel firstprivate(ba)
   #pragma omp parallel firstprivate(ca)
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -14352,8 +14352,13 @@
   bool ByRef = true;
   // Using an LValue reference type is consistent with Lambdas (see below).
   if (S.getLangOpts().OpenMP && RSI->CapRegionKind == CR_OpenMP) {
-if (S.IsOpenMPCapturedDecl(Var))
+if (S.IsOpenMPCapturedDecl(Var)) {
+  bool HasConst = DeclRefType.isConstQualified();
   DeclRefType = DeclRefType.getUnqualifiedType();
+  // Don't lose diagnostics about assignments to const.
+  if (HasConst)
+DeclRefType.addConst();
+}
 ByRef = S.IsOpenMPCapturedByRef(Var, RSI->OpenMPLevel);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 122318.

https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,36 @@
   }
 }
 
+namespace
+{
+  bool checkAllAreIntegral(const AttributeList , Sema ) {
+for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+  auto e = Attr.getArgAsExpr(i);
+  if (e && !e->getType()->isIntegralOrEnumerationType()) {
+S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+  << getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+  << e->getSourceRange();
+
+return false;
+  }
+}
+
+return true;
+  }
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema , Decl *D,
   const AttributeList ) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5513,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema , Decl *D,
const AttributeList ) {
+  if (!checkAllAreIntegral(Attr, S))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
-Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+MaxExpr = Attr.getArgAsExpr(1);
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5550,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(Attr, S))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(Attr, S))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
+ AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7661,6 +7661,18 @@
 };
 }
 
+namespace
+{
+  inline
+  llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+  {
+llvm::APSInt r{32, 0};
+if (E) E->EvaluateAsInt(r, Ctx);
+
+return r;
+  }
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ,
 ForDefinition_t IsForDefinition) const {
@@ -7676,8 +7688,11 @@
 FD->getAttr() : nullptr;
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+

[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This seems reasonable to me. Please commit it. @NoQ can do a post-commit review 
and fix it up if he would rather address the issue differently.


https://reviews.llvm.org/D39862



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


[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'm curious if the crash would turn into an assertion failure during 
`getRawSVal()` after https://reviews.llvm.org/D38801 is committed.

The problem with this checker producing void symbols is known since 
https://reviews.llvm.org/D26837. If this problem is fixed on the checker side 
(it probably should be - the checker , we can probably put stronger asserts 
onto types suitable for symbols.




Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:265
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {

If a type is an integral or enumeration type or a Loc type, then it is 
definitely not null.


https://reviews.llvm.org/D39862



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx marked an inline comment as done.
AlexVlx added a comment.

In https://reviews.llvm.org/D39857#920814, @kzhuravl wrote:

> Hi Alex, can you rebase on top of trunk (I think you brought in some extra 
> changes from hcc branch) and upload a full diff?


Hello Konstantine - apologies about that, hopefully it's correct now. Thank you.


https://reviews.llvm.org/D39857



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


[PATCH] D39857: [AMDGPU] Late parsed / dependent arguments for AMDGPU kernel attributes

2017-11-09 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx updated this revision to Diff 122327.

https://reviews.llvm.org/D39857

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/TargetInfo.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5469,16 +5469,33 @@
   }
 }
 
+static bool checkAllAreIntegral(Sema , const AttributeList ) {
+  for (auto i = 0u; i != Attr.getNumArgs(); ++i) {
+Expr* E = Attr.getArgAsExpr(i);
+if (E && !E->getType()->isIntegralOrEnumerationType()) {
+  S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
+<< getAttrName(Attr) << i << AANT_ArgumentIntegerConstant
+<< E->getSourceRange();
+
+  return false;
+}
+  }
+
+  return true;
+}
+
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema , Decl *D,
   const AttributeList ) {
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
   Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (MaxExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MaxExpr, Max))
 return;
 
   if (Min == 0 && Max != 0) {
@@ -5493,21 +5510,28 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
- Attr.getAttributeSpellingListIndex()));
+ AMDGPUFlatWorkGroupSizeAttr(
+   Attr.getLoc(), S.Context, MinExpr, MaxExpr,
+   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema , Decl *D,
const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t Min = 0;
   Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  if (MinExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, MinExpr, Min))
 return;
 
   uint32_t Max = 0;
+  Expr *MaxExpr = MinExpr;
   if (Attr.getNumArgs() == 2) {
-Expr *MaxExpr = Attr.getArgAsExpr(1);
-if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+MaxExpr = Attr.getArgAsExpr(1);
+if (MaxExpr->isEvaluatable(S.Context) &&
+!checkUInt32Argument(S, Attr, MaxExpr, Max))
   return;
   }
 
@@ -5523,31 +5547,39 @@
   }
 
   D->addAttr(::new (S.Context)
- AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
+ AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, MinExpr, MaxExpr,
   Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumSGPR = 0;
   Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  if (NumSGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
+ AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema , Decl *D,
 const AttributeList ) {
+  if (!checkAllAreIntegral(S, Attr))
+return;
+
   uint32_t NumVGPR = 0;
   Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  if (NumVGPRExpr->isEvaluatable(S.Context) &&
+  !checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
 return;
 
   D->addAttr(::new (S.Context)
- AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
+ AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPRExpr,
Attr.getAttributeSpellingListIndex()));
 }
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -7661,6 +7661,16 @@
 };
 }
 
+static llvm::APSInt getConstexprInt(const Expr *E, const ASTContext& Ctx)
+{
+  assert(E);
+
+  llvm::APSInt Tmp{32, 0};
+  E->EvaluateAsInt(Tmp, Ctx);
+
+  return Tmp;
+}
+
 void AMDGPUTargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ,
 ForDefinition_t IsForDefinition) const {
@@ -7676,8 +7686,11 @@
 FD->getAttr() : nullptr;
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {
-unsigned Min = FlatWGS ? FlatWGS->getMin() : 0;
-unsigned Max = FlatWGS ? FlatWGS->getMax() : 0;
+llvm::APSInt KMin 

[PATCH] D39862: [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317839: [analyzer] do not crash when trying to convert an 
APSInt to an unexpected type (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D39862?vs=122306=122328#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39862

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
  cfe/trunk/test/Analysis/taint-tester.c


Index: cfe/trunk/test/Analysis/taint-tester.c
===
--- cfe/trunk/test/Analysis/taint-tester.c
+++ cfe/trunk/test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()


Index: cfe/trunk/test/Analysis/taint-tester.c
===
--- cfe/trunk/test/Analysis/taint-tester.c
+++ cfe/trunk/test/Analysis/taint-tester.c
@@ -189,3 +189,10 @@
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -260,7 +260,9 @@
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r317839 - [analyzer] do not crash when trying to convert an APSInt to an unexpected type

2017-11-09 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Nov  9 13:49:38 2017
New Revision: 317839

URL: http://llvm.org/viewvc/llvm-project?rev=317839=rev
Log:
[analyzer] do not crash when trying to convert an APSInt to an unexpected type

This is the issue breaking the postgresql bot, purely by chance exposed
through taint checker, somehow appearing after
https://reviews.llvm.org/D38358 got committed.

The backstory is that the taint checker requests SVal for the value of
the pointer, and analyzer has a "fast path" in the getter to return a
constant when we know that the value is constant.
Unfortunately, the getter requires a cast to get signedness correctly,
and for the pointer `void *` the cast crashes.

This is more of a band-aid patch, as I am not sure what could be done
here "correctly", but it should be applied in any case to avoid the
crash.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/test/Analysis/taint-tester.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=317839=317838=317839=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Thu Nov  9 13:49:38 2017
@@ -260,7 +260,9 @@ SVal ProgramState::getSVal(Loc location,
   // be a constant value, use that value instead to lessen the burden
   // on later analysis stages (so we have less symbolic values to reason
   // about).
-  if (!T.isNull()) {
+  // We only go into this branch if we can convert the APSInt value we have
+  // to the type of T, which is not always the case (e.g. for void).
+  if (!T.isNull() && (T->isIntegralOrEnumerationType() || Loc::isLocType(T))) {
 if (SymbolRef sym = V.getAsSymbol()) {
   if (const llvm::APSInt *Int = getStateManager()
 .getConstraintManager()

Modified: cfe/trunk/test/Analysis/taint-tester.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/taint-tester.c?rev=317839=317838=317839=diff
==
--- cfe/trunk/test/Analysis/taint-tester.c (original)
+++ cfe/trunk/test/Analysis/taint-tester.c Thu Nov  9 13:49:38 2017
@@ -189,3 +189,10 @@ void atoiTest() {
 
 }
 
+char *pointer1;
+void *pointer2;
+void noCrashTest() {
+  if (!*pointer1) {
+__builtin___memcpy_chk(pointer2, pointer1, 0, 0); // no-crash
+  }
+}


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


[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Yan Zhang via Phabricator via cfe-commits
Wizard updated this revision to Diff 122319.
Wizard marked 6 inline comments as done.
Wizard added a comment.

address comments


https://reviews.llvm.org/D39829

Files:
  clang-tidy/objc/CMakeLists.txt
  clang-tidy/objc/ObjCTidyModule.cpp
  clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tidy/objc/PropertyDeclarationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/objc-property-declaration.rst
  test/clang-tidy/objc-property-declaration.m

Index: test/clang-tidy/objc-property-declaration.m
===
--- /dev/null
+++ test/clang-tidy/objc-property-declaration.m
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s objc-property-declaration %t
+
+@interface Foo
+@property(assign, nonatomic) int NotCamelCase;
+// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property 'NotCamelCase' is not in proper format according to property naming convention [objc-property-declaration]
+// CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
+@property(assign, nonatomic) int camelCase;
+// CHECK-MESSAGES-NOT: :[[@LINE-1]]:34: warning: property 'camelCase' is not in proper format according to property naming convention [objc-property-declaration]
+@end
Index: docs/clang-tidy/checks/objc-property-declaration.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/objc-property-declaration.rst
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - objc-property-declaration
+
+objc-property-declaration
+=
+
+Finds property declarations in Objective-C files that do not follow the pattern
+of property names in Apple's programming guide. The property name should be
+in the format of Lower Camel Case.
+
+For code:
+
+.. code-block:: objc
+
+@property(nonatomic, assign) int LowerCamelCase;
+
+The fix will be:
+
+.. code-block:: objc
+
+@property(nonatomic, assign) int lowerCamelCase;
+
+The check will do best effort to give a fix, however, in some cases it is
+difficult to give a proper fix since the property name could be complicated.
+Users will need to come up with a proper name by their own.
+
+The corresponding style rule: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingIvarsAndTypes.html#//apple_ref/doc/uid/20001284-1001757
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -173,15 +173,16 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   objc-forbidden-subclassing
+   objc-property-declaration
performance-faster-string-find
performance-for-range-copy
performance-implicit-conversion-in-loop
performance-inefficient-string-concatenation
performance-inefficient-vector-operation
performance-type-promotion-in-math-fn
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
-   objc-forbidden-subclassing
readability-avoid-const-params-in-decls
readability-braces-around-statements
readability-container-size-empty
Index: docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
===
--- docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
+++ docs/clang-tidy/checks/google-objc-global-variable-declaration.rst
@@ -3,7 +3,7 @@
 google-objc-global-variable-declaration
 ===
 
-Finds global variable declarations in Objective-C files that are not follow the pattern
+Finds global variable declarations in Objective-C files that do not follow the pattern
 of variable names in Google's Objective-C Style Guide.
 
 The corresponding style guide rule:
@@ -16,26 +16,31 @@
 For code:
 
 .. code-block:: objc
+
   static NSString* myString = @"hello";
 
 The fix will be:
 
 .. code-block:: objc
+
   static NSString* gMyString = @"hello";
 
 Another example of constant:
 
 .. code-block:: objc
+
   static NSString* const myConstString = @"hello";
 
 The fix will be:
 
 .. code-block:: objc
+
   static NSString* const kMyConstString = @"hello";
 
 However for code that prefixed with non-alphabetical characters like:
 
 .. code-block:: objc
+
   static NSString* __anotherString = @"world";
 
 The check will give a warning message but will not be able to suggest a fix. The user
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `objc-property-declaration
+  `_ check
+
+  FIXME: add release notes.
+
 - New `google-objc-global-variable-declaration
   

[PATCH] D39829: add new check for property declaration

2017-11-09 Thread Yan Zhang via Phabricator via cfe-commits
Wizard added inline comments.



Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:25
+/// we will do best effort to generate a fix, however, if the
+/// case can not be solved with a simple fix (e.g. remove prefix or change 
first
+/// character), we will leave the fix to the user.

benhamilton wrote:
> hokein wrote:
> > I might miss some background context. 
> > 
> > The fix of the check seems to me that it does more things it should. It 
> > removes all the non-alphabetical prefix characters, I'd be conservative of 
> > the fix here (just fix the case "CamelCase", and only give a warning for 
> > other cases).
> I agree, removing a prefix is not a good idea. Warning is fine.
> 
> We could probably also change `snake_case` variables to `CamelCase` 
> automatically. Not sure if it's worth doing in this review, but @Wizard can 
> file a bug to follow up and add a TODO comment here mentioning the bug.
Will do


https://reviews.llvm.org/D39829



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


[PATCH] D39836: [clangd] Drop impossible completions (unavailable or inaccessible)

2017-11-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In https://reviews.llvm.org/D39836#920977, @arphaman wrote:

> In https://reviews.llvm.org/D39836#920587, @sammccall wrote:
>
> > So I probably should have started from the other end, here :-)
> >
> > I'd really like to make the completion retrieval and ranking more flexible. 
> > In particular
> >
> > - incorporating results from other sources (indexes: both in-memory and 
> > external services).
> > - combining more quality signals like usage count and fuzzy-match-strength 
> > in a non-lexicographic-sort way The biggest difficulty in *supporting* 
> > unusable functions is maintaining the invariant that all unusable functions 
> > are ranked lower than usable ones - all code that deals with ranking has to 
> > deal with this special case, e.g. by making score a tuple instead of a 
> > single number.
>
>
> That sounds good to me. Please keep in mind that not all clients might want 
> to take advantage of these things as they might have their own fuzz-match 
> logic


Yup! My understanding of the protocol is clients will generally trigger 
completion after the dot, and then filter client-side *unless* the result set 
is incomplete.
So fuzzy-match filtering/scoring would only be triggered if we limit the number 
of results (proposed as optional in https://reviews.llvm.org/D39852) or if 
completion is explicitly triggered mid-identifier (maybe we should allow 
turning this off too).

> and external result injection.

Absolutely. To be concrete, i'm thinking about three overlaid:

1. a static generated index that clangd consumes (e.g. generated by 
index-while-building and located on disk, or a hosted index of google's 
monorepo)
2. a dynamically generated index of symbols in files that clangd has seen. 
(Likely to be dirty with respect to 1)
3. context-sensitive completion results as today

1 would definitely be optional.
2 isn't really external... we might want to handle global symbols with 2 and 
not 3 as now, but that's an implementation detail.

>> If the current approach of "give them a penalty" is enough, knowing that in 
>> the future it may lead to e.g. a very widely used but inaccessible protected 
>> function being ranked highly, then that seems fine to me too. A wider 
>> configuration space means testing is more work, but happy to live with it. 
>> What do you think?
>> 
>> (With my user-hat on, configurable is fine, though I do strongly feel they 
>> should be off by default, and it seems unlikely many users will change the 
>> defaults.)
> 
> I'd be ok with off by default, as long as it's possible to turn it on :)

Sure, I'll update the patch.

For these things that are (I assume) more "user preference" than project- or 
integration-specific, I wonder whether command-line flags are the right thing. 
Configuration in `~/.clangd` is a can of worms, but might be the right thing in 
the long-run.


https://reviews.llvm.org/D39836



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


[PATCH] D38818: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 marked an inline comment as done.
sabel83 added a comment.

I have moved the tests into their own directory in the last update.




Comment at: tools/CMakeLists.txt:37
 add_clang_subdirectory(libclang)
+add_subdirectory(templight)

rsmith wrote:
> Did you mean to include this in this patch? There's no such directory added 
> here. (Should this be an `add_llvm_external_project`, to pick up some 
> external project if it's checked out here?)
It is a reference to a utility based on this patch. The utility has not been 
finished yet, so I have removed that line.


https://reviews.llvm.org/D38818



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


[PATCH] D5767: Template Instantiation Observer + a few other templight-related changes

2017-11-09 Thread Ábel Sinkovics via Phabricator via cfe-commits
sabel83 added a comment.

In https://reviews.llvm.org/D5767#920085, @rsmith wrote:

> I'm not entirely sure what's happening with this and 
> https://reviews.llvm.org/D38818, but the direction looks good to me, and I 
> left a couple of comments on the other review thread.


This was the original pull request. I created https://reviews.llvm.org/D38818 
when I didn't know how to update this one (it was originally created by Mikael, 
not me). I have updated https://reviews.llvm.org/D38818 and this one as well 
based on the comments, so both pull requests have the same code now (and I'll 
cancel the one that does not get merged).


https://reviews.llvm.org/D5767



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


  1   2   >