[PATCH] D37554: [libclang] Allow crash recovery with LIBCLANG_NOTHREADS

2017-09-20 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping 2


https://reviews.llvm.org/D37554



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


r313729 - Implement C++ [basic.link]p8.

2017-09-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Sep 20 00:22:00 2017
New Revision: 313729

URL: http://llvm.org/viewvc/llvm-project?rev=313729&view=rev
Log:
Implement C++ [basic.link]p8.

If a function or variable has a type with no linkage (and is not extern "C"),
any use of it requires a definition within the same translation unit; the idea
is that it is not possible to define the entity elsewhere, so any such use is
necessarily an error.

There is an exception, though: some types formally have no linkage but
nonetheless can be referenced from other translation units (for example, this
happens to anonymous structures defined within inline functions). For entities
with those types, we suppress the diagnostic except under -pedantic.

Added:
cfe/trunk/test/CXX/basic/basic.link/p8.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Sema/SemaInternal.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Analysis/malloc.mm
cfe/trunk/test/Analysis/reference.cpp
cfe/trunk/test/CodeGenCXX/debug-info-method.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-cxx11.cpp
cfe/trunk/test/CodeGenCXX/mangle.cpp
cfe/trunk/test/PCH/cxx11-lambdas.mm
cfe/trunk/test/SemaCXX/warn-unreachable.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=313729&r1=313728&r2=313729&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 20 00:22:00 
2017
@@ -4707,6 +4707,14 @@ def note_deleted_assign_field : Note<
 def warn_undefined_internal : Warning<
   "%select{function|variable}0 %q1 has internal linkage but is not defined">,
   InGroup>;
+def err_undefined_internal_type : Error<
+  "%select{function|variable}0 %q1 is used but not defined in this "
+  "translation unit, and cannot be defined in any other translation unit "
+  "because its type does not have linkage">;
+def ext_undefined_internal_type : Extension<
+  "ISO C++ requires a definition in this translation unit for "
+  "%select{function|variable}0 %q1 because its type does not have linkage">,
+  InGroup>;
 def warn_undefined_inline : Warning<"inline function %q0 is not defined">,
   InGroup>;
 def err_undefined_inline_var : Error<"inline variable %q0 is not defined">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=313729&r1=313728&r2=313729&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Wed Sep 20 00:22:00 2017
@@ -1086,6 +1086,11 @@ public:
   /// definition in this translation unit.
   llvm::MapVector UndefinedButUsed;
 
+  /// Determine if VD, which must be a variable or function, is an external
+  /// symbol that nonetheless can't be referenced from outside this translation
+  /// unit because its type has no linkage and it's not extern "C".
+  bool isExternalWithNoLinkageType(ValueDecl *VD);
+
   /// Obtain a sorted list of functions that are undefined but ODR-used.
   void getUndefinedButUsed(
   SmallVectorImpl > &Undefined);

Modified: cfe/trunk/include/clang/Sema/SemaInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/SemaInternal.h?rev=313729&r1=313728&r2=313729&view=diff
==
--- cfe/trunk/include/clang/Sema/SemaInternal.h (original)
+++ cfe/trunk/include/clang/Sema/SemaInternal.h Wed Sep 20 00:22:00 2017
@@ -73,7 +73,8 @@ inline void MarkVarDeclODRUsed(VarDecl *
   // Keep track of used but undefined variables.
   // FIXME: We shouldn't suppress this warning for static data members.
   if (Var->hasDefinition(SemaRef.Context) == VarDecl::DeclarationOnly &&
-  (!Var->isExternallyVisible() || Var->isInline()) &&
+  (!Var->isExternallyVisible() || Var->isInline() ||
+   SemaRef.isExternalWithNoLinkageType(Var)) &&
   !(Var->isStaticDataMember() && Var->hasInit())) {
 SourceLocation &old = SemaRef.UndefinedButUsed[Var->getCanonicalDecl()];
 if (old.isInvalid())

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=313729&r1=313728&r2=313729&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Sep 20 00:22:00 2017
@@ -721,8 +721,7 @@ LinkageComputer::getLVForNamespaceScopeD
 // because of this, but unique-external linkage suits us.
 if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var

[PATCH] D37972: [clangd] Introduced Logger interface.

2017-09-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313730: [clangd] Introduced Logger interface. (authored by 
ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D37972

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  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/ClangdUnitStore.cpp
  clang-tools-extra/trunk/clangd/ClangdUnitStore.h
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
  clang-tools-extra/trunk/clangd/Logger.cpp
  clang-tools-extra/trunk/clangd/Logger.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -8,6 +8,7 @@
 //===--===//
 
 #include "ClangdServer.h"
+#include "Logger.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Config/config.h"
 #include "llvm/ADT/SmallVector.h"
@@ -302,7 +303,8 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false);
+/*SnippetCompletions=*/false,
+EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
   FileWithContents.second;
@@ -365,7 +367,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -410,7 +412,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -457,7 +459,8 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = "int a;";
@@ -490,7 +493,8 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
 
   // Just a random gcc version string
   SmallString<8> Version("4.9.3");
@@ -538,7 +542,8 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false);
+  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
 
@@ -597,7 +602,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false);
+  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
   const auto SourceContents = R"cpp(
@@ -745,7 +750,8 @@
   {
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false);
+/*SnippetCompletions=*/false,
+EmptyLogger::getInstance());
 
 // Prepare some random distributions for 

[clang-tools-extra] r313730 - [clangd] Introduced Logger interface.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 00:24:15 2017
New Revision: 313730

URL: http://llvm.org/viewvc/llvm-project?rev=313730&view=rev
Log:
[clangd] Introduced Logger interface.

Summary: This fixes a bunch of logging-related FIXMEs.

Reviewers: bkramer, krasimir, malaperle

Reviewed By: malaperle

Subscribers: malaperle, klimek, cfe-commits, mgorny

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

Added:
clang-tools-extra/trunk/clangd/Logger.cpp
clang-tools-extra/trunk/clangd/Logger.h
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
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/ClangdUnitStore.cpp
clang-tools-extra/trunk/clangd/ClangdUnitStore.h
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=313730&r1=313729&r2=313730&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Wed Sep 20 00:24:15 2017
@@ -10,6 +10,7 @@ add_clang_library(clangDaemon
   DraftStore.cpp
   GlobalCompilationDatabase.cpp
   JSONRPCDispatcher.cpp
+  Logger.cpp
   Protocol.cpp
   ProtocolHandlers.cpp
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=313730&r1=313729&r2=313730&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Sep 20 00:24:15 2017
@@ -223,9 +223,9 @@ void ClangdLSPServer::LSPProtocolCallbac
 ClangdLSPServer::ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount,
  bool SnippetCompletions,
  llvm::Optional ResourceDir)
-: Out(Out), DiagConsumer(*this),
+: Out(Out), CDB(/*Logger=*/Out), DiagConsumer(*this),
   Server(CDB, DiagConsumer, FSProvider, AsyncThreadsCount,
- SnippetCompletions, ResourceDir) {}
+ SnippetCompletions, /*Logger=*/Out, ResourceDir) {}
 
 void ClangdLSPServer::run(std::istream &In) {
   assert(!IsDone && "Run was called before");

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=313730&r1=313729&r2=313730&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 00:24:15 2017
@@ -145,8 +145,10 @@ ClangdServer::ClangdServer(GlobalCompila
DiagnosticsConsumer &DiagConsumer,
FileSystemProvider &FSProvider,
unsigned AsyncThreadsCount, bool SnippetCompletions,
+   clangd::Logger &Logger,
llvm::Optional ResourceDir)
-: CDB(CDB), DiagConsumer(DiagConsumer), FSProvider(FSProvider),
+: Logger(Logger), CDB(CDB), DiagConsumer(DiagConsumer),
+  FSProvider(FSProvider),
   ResourceDir(ResourceDir ? ResourceDir->str() : getStandardResourceDir()),
   PCHs(std::make_shared()),
   WorkScheduler(AsyncThreadsCount), SnippetCompletions(SnippetCompletions) 
{
@@ -157,7 +159,7 @@ std::future ClangdServer::addDocum
 
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
   std::shared_ptr Resources =
-  Units.getOrCreateFile(File, ResourceDir, CDB, PCHs, TaggedFS.Value);
+  Units.getOrCreateFile(File, ResourceDir, CDB, PCHs, TaggedFS.Value, 
Logger);
   return scheduleReparseAndDiags(File, VersionedDraft{Version, Contents.str()},
  std::move(Resources), std::move(TaggedFS));
 }
@@ -175,7 +177,7 @@ std::future ClangdServer::forceRep
 
   auto TaggedFS = FSProvider.getTaggedFileSystem(File);
   auto Recreated = Units.recreateFileIfCompileCommandChanged(
-  File, ResourceDir, CDB, PCHs, TaggedFS.Value);
+  File, ResourceDir, CDB, PCHs, TaggedFS.Value, Logger);
 
   // Note that std::future from this cleanup action is ignored.
   scheduleCancelRebuild(std::move(Recreated.RemovedFile));
@@ -210,7 +212,7 @@ ClangdServer::codeComplete(PathRef File,
   std::v

[PATCH] D36150: [clangd] LSP extension to switch between source/header file

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

In https://reviews.llvm.org/D36150#875623, @Nebiroth wrote:

> In https://reviews.llvm.org/D36150#867971, @ilya-biryukov wrote:
>
> > Overall looks good, but still needs at least a few tests.
>
>
> I have a test for this commit that uses included source and header files, 
> would that be okay to do or should I generate files dynamically? If so, how 
> can I accomplish this?


You are right, unfortunately we don't have a good story for multi-file tests 
yet.
Let's add a unit-test for the implementation in `ClangdServer`. This can be 
easily done by using `MockFSProvider`. You may find some examples in 
`clang-tools-extra/unittest/clangd/ClangdTests.cpp`


https://reviews.llvm.org/D36150



___
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-09-20 Thread Francois Ferrand via Phabricator via cfe-commits
Typz added a comment.

This cannot be implemented where we currently call breakProtrudingToken(), 
since this function starts by 'creating' the BreakableToken and dealing with 
meany corner cases: so this should be done before in any case.
But the code at the end of breakProtrudingToken() is actually very similar to 
what you propose.

I can refactor the code to have two functions reflowProtrudingToken() and 
getExcessPenalty(), though that will add some significant redundancy: the 
problem is that even if we don't actually reflow, we still need (I think?) to 
handle whitespace replacement and update the state (to set Column, 
Stack.back().LastSpace, and Stack[i].BreakBeforeParameter, and call 
updateNextToken() ...). And therefore getExcessPenalty() should probably not 
just compute the penalty, it should also update the state and handle whitespace 
replacement...


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] D31140: [LLVMbugs] [Bug 18710] Only generate .ARM.exidx and .ARM.extab when needed in EHABI

2017-09-20 Thread Christian Bruel via Phabricator via cfe-commits
chrib added a comment.

oops yes of course. I forgot some bits while switching from testing the arch to 
testing the platform.

indeed --target=arm-none-linux-gnueabihf lost its unwind info in c++. 
Surprisingly not caught by the llvm tests, will add some.

thanks


https://reviews.llvm.org/D31140



___
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-09-20 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

In https://reviews.llvm.org/D33589#876196, @Typz wrote:

> This cannot be implemented where we currently call breakProtrudingToken(), 
> since this function starts by 'creating' the BreakableToken and dealing with 
> meany corner cases: so this should be done before in any case.
>  But the code at the end of breakProtrudingToken() is actually very similar 
> to what you propose.
>
> I can refactor the code to have two functions reflowProtrudingToken() and 
> getExcessPenalty(), though that will add some significant redundancy: the 
> problem is that even if we don't actually reflow, we still need (I think?) to 
> handle whitespace replacement and update the state (to set Column, 
> Stack.back().LastSpace, and Stack[i].BreakBeforeParameter, and call 
> updateNextToken() ...). And therefore getExcessPenalty() should probably not 
> just compute the penalty, it should also update the state and handle 
> whitespace replacement...


My question is: if CanBreak is false, we currently don't call 
breakProtrudingToken. So either we do something very wrong in that case (which 
might be true, but I'd like to understand why) or we should be able  to just 
calculate the penalty by not breaking anything and go on.


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] D38048: [clangd] Add textDocument/signatureHelp

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov requested changes to this revision.
ilya-biryukov added a comment.
This revision now requires changes to proceed.

Thanks for the patch. Overall looks good, just a few comments.
Could you also add some tests?




Comment at: clangd/ClangdServer.h:243
+  /// Provide signature help for \p File at \p Pos. If \p OverridenContents is
+  /// not None, they will used only for code completion, i.e. no diagnostics
+  /// update will be scheduled and a draft for \p File will not be updated. If

Mentions "code completion" in the comment.



Comment at: clangd/ClangdUnit.cpp:536
+SigHelp.signatures.reserve(NumCandidates);
+// TODO(rwols): How can we determine the "active overload candidate"?
+SigHelp.activeSignature = 0;

Code in clangd uses `FIXME` instead of `TODO`.



Comment at: clangd/ClangdUnit.cpp:589
+  }
+  case CodeCompletionString::CK_Optional:
+  case CodeCompletionString::CK_VerticalSpace:

Ignoring `CK_Optional` chunks leads to weird results. They represent parameters 
that have default arguments. For example,
```
int foo(int a, int b = 10, int c = 20);

int test() {
  foo(10, 20, 30); // signatureHelp shows foo(int a) here, which is confusing.
}
```



Comment at: clangd/ClangdUnit.cpp:691
+  std::shared_ptr PCHs) {
+  std::vector ArgStrs;
+  for (const auto &S : Command.CommandLine)

Most of this function is almost identical to `clangd::codeComplete`. They only 
differ in some of the `CodeCompleteOpts` flags and `CodeCompletionConsumer`s 
they use, right?

Maybe extract a helper function that runs code completion and reuse it for both 
`clangd::codeComplete`and `clangd::signatureHelp`?


https://reviews.llvm.org/D38048



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


[PATCH] D37954: Try to shorten system header paths when using -MD depfiles

2017-09-20 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Well, the background for the use of the option in NetBSD is related to inducted 
differences in reproducable builds. From that perspective, it is even worth to 
sometimes shorten the dependency and sometimes not.


https://reviews.llvm.org/D37954



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


[PATCH] D37978: [analyzer] Fix an assertion fail in VirtualCallChecker

2017-09-20 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Actually, after looking at the getBestDynamicClassType() implementation, I'm 
pretty sure it does all things IgnoreImpCasts() used to do that are relevant to 
the use case. So the patch seems to be trivially correct. Other reviewers' 
comments (if any) can be addressed post-commit. Thanks again for the fix!


Repository:
  rL LLVM

https://reviews.llvm.org/D37978



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


[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Alberto Magni via Phabricator via cfe-commits
alberto_magni added a comment.

Hi all,
this change is causing busybox to fail to compile.
The faulty enum is here:
https://git.busybox.net/busybox/tree/include/libbb.h#n639
The nested union is inside a sizeof statement.

Something like this:

  enum {
A = sizeof(union {
  int x;
  int y;
})
  };

I this behavior expected ? Do you suggest to patch busybox ?

Many Thanks


Repository:
  rL LLVM

https://reviews.llvm.org/D37089



___
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-09-20 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

I think instead of introducing more and more special cases of macros we might 
want to handle, we should instead allow specifying macro productions globally.


https://reviews.llvm.org/D37813



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


r313742 - Fix clang-format's detection of structured bindings.

2017-09-20 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Wed Sep 20 02:29:37 2017
New Revision: 313742

URL: http://llvm.org/viewvc/llvm-project?rev=313742&view=rev
Log:
Fix clang-format's detection of structured bindings.

Correctly determine when [ is part of a structured binding instead of a
lambda.

To be able to reuse the implementation already available, this patch also:
- sets the Previous link of FormatTokens in the UnwrappedLineParser
- moves the isCppStructuredBinding function into FormatToken

Before:
  auto const const &&[x, y] { A *i };

After:
  auto const const && [x, y]{A * i};

Fixing formatting of the type of the structured binding is still missing.

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=313742&r1=313741&r2=313742&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Wed Sep 20 02:29:37 2017
@@ -472,6 +472,19 @@ struct FormatToken {
   Style.Language == FormatStyle::LK_TextProto));
   }
 
+  /// \brief Returns whether the token is the left square bracket of a C++
+  /// structured binding declaration.
+  bool isCppStructuredBinding(const FormatStyle &Style) const {
+if (!Style.isCpp() || isNot(tok::l_square))
+  return false;
+const FormatToken* T = this;
+do {
+  T = T->getPreviousNonComment();
+} while (T && T->isOneOf(tok::kw_const, tok::kw_volatile, tok::amp,
+ tok::ampamp));
+return T && T->is(tok::kw_auto);
+  }
+
   /// \brief Same as opensBlockOrBlockTypeList, but for the closing token.
   bool closesBlockOrBlockTypeList(const FormatStyle &Style) const {
 if (is(TT_TemplateString) && closesScope())

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=313742&r1=313741&r2=313742&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Sep 20 02:29:37 2017
@@ -310,16 +310,6 @@ private:
 return false;
   }
 
-  bool isCppStructuredBinding(const FormatToken *Tok) {
-if (!Style.isCpp() || !Tok->is(tok::l_square))
-  return false;
-do {
-  Tok = Tok->getPreviousNonComment();
-} while (Tok && Tok->isOneOf(tok::kw_const, tok::kw_volatile, tok::amp,
- tok::ampamp));
-return Tok && Tok->is(tok::kw_auto);
-  }
-
   bool parseSquare() {
 if (!CurrentToken)
   return false;
@@ -354,7 +344,7 @@ private:
 
 unsigned BindingIncrease = 1;
 if (Left->is(TT_Unknown)) {
-  if (isCppStructuredBinding(Left)) {
+  if (Left->isCppStructuredBinding(Style)) {
 Left->Type = TT_StructuredBindingLSquare;
   } else if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=313742&r1=313741&r2=313742&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Sep 20 02:29:37 2017
@@ -356,7 +356,7 @@ void UnwrappedLineParser::calculateBrace
   // definitions, too.
   unsigned StoredPosition = Tokens->getPosition();
   FormatToken *Tok = FormatTok;
-  const FormatToken *PrevTok = getPreviousToken();
+  const FormatToken *PrevTok =  Tok->Previous;
   // Keep a stack of positions of lbrace tokens. We will
   // update information about whether an lbrace starts a
   // braced init list or a different block during the loop.
@@ -1100,7 +1100,7 @@ void UnwrappedLineParser::parseStructura
 break;
   }
   do {
-const FormatToken *Previous = getPreviousToken();
+const FormatToken *Previous = FormatTok->Previous;
 switch (FormatTok->Tok.getKind()) {
 case tok::at:
   nextToken();
@@ -1356,10 +1356,11 @@ bool UnwrappedLineParser::tryToParseLamb
 }
 
 bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
-  const FormatToken* Previous = getPreviousToken();
+  const FormatToken* Previous = FormatTok->Previous;
   if (Previous &&
   (Previous->isOneOf(tok::identifier, tok::kw_operator, tok::kw_new,
  tok::kw_delete) ||
+   FormatTok->isCppStructuredBinding(Style) ||
Previous->closesScope() || Previous->isSimpleTypeSpecifier())) {
 nextToken();
 return false;
@@ -2232,6 +2233,8 @@ void UnwrappedLineParser::addUnwrappedLi
 std::make_move_iterator(Preproces

[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

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

1. Can you rebase after r313742? I fixed detection of structured bindings in 
the UnwrappedLineParser, that might affect this patch
2. Isn't LLVM style the reverse? That is, shouldn't that be

  LLVM style:

  auto &&[a, b] = ...

  Pointer/Ref-to-type-style:

  auto&& [a, b] = ...

(and I just notice that I didn't fully clang-format my last patch, argh!)


https://reviews.llvm.org/D35743



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


r313744 - clang-format clang-format.

2017-09-20 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Wed Sep 20 02:51:03 2017
New Revision: 313744

URL: http://llvm.org/viewvc/llvm-project?rev=313744&view=rev
Log:
clang-format clang-format.

Modified:
cfe/trunk/lib/Format/BreakableToken.cpp
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/FormatToken.cpp
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/lib/Format/SortJavaScriptImports.cpp
cfe/trunk/lib/Format/TokenAnalyzer.cpp
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.h
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/lib/Format/UnwrappedLineParser.h
cfe/trunk/lib/Format/WhitespaceManager.cpp

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=313744&r1=313743&r2=313744&view=diff
==
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Sep 20 02:51:03 2017
@@ -41,8 +41,8 @@ static bool IsBlank(char C) {
 }
 
 static StringRef getLineCommentIndentPrefix(StringRef Comment) {
-  static const char *const KnownPrefixes[] = {
-  "///<", "//!<", "///", "//", "//!"};
+  static const char *const KnownPrefixes[] = {"///<", "//!<", "///", "//",
+  "//!"};
   StringRef LongestPrefix;
   for (StringRef KnownPrefix : KnownPrefixes) {
 if (Comment.startswith(KnownPrefix)) {
@@ -225,8 +225,7 @@ void BreakableStringLiteral::insertBreak
 }
 
 BreakableComment::BreakableComment(const FormatToken &Token,
-   unsigned StartColumn,
-   bool InPPDirective,
+   unsigned StartColumn, bool InPPDirective,
encoding::Encoding Encoding,
const FormatStyle &Style)
 : BreakableToken(Token, InPPDirective, Encoding, Style),
@@ -309,7 +308,7 @@ static bool mayReflowContent(StringRef C
   // Lines starting with '@' commonly have special meaning.
   // Lines starting with '-', '-#', '+' or '*' are bulleted/numbered lists.
   static const SmallVector kSpecialMeaningPrefixes = {
-  "@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* " };
+  "@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "};
   bool hasSpecialMeaningPrefix = false;
   for (StringRef Prefix : kSpecialMeaningPrefixes) {
 if (Content.startswith(Prefix)) {
@@ -322,8 +321,8 @@ static bool mayReflowContent(StringRef C
   // To avoid issues if a line starts with a number which is actually the end
   // of a previous line, we only consider numbers with up to 2 digits.
   static llvm::Regex kNumberedListRegexp = llvm::Regex("^[1-9][0-9]?\\. ");
-  hasSpecialMeaningPrefix = hasSpecialMeaningPrefix ||
-kNumberedListRegexp.match(Content);
+  hasSpecialMeaningPrefix =
+  hasSpecialMeaningPrefix || kNumberedListRegexp.match(Content);
 
   // Simple heuristic for what to reflow: content should contain at least two
   // characters and either the first or second character must be
@@ -385,8 +384,7 @@ BreakableBlockComment::BreakableBlockCom
 // If the last line is empty, the closing "*/" will have a star.
 if (i + 1 == e && Content[i].empty())
   break;
-if (!Content[i].empty() && i + 1 != e &&
-Decoration.startswith(Content[i]))
+if (!Content[i].empty() && i + 1 != e && Decoration.startswith(Content[i]))
   continue;
 while (!Content[i].startswith(Decoration))
   Decoration = Decoration.substr(0, Decoration.size() - 1);
@@ -428,8 +426,7 @@ BreakableBlockComment::BreakableBlockCom
   IndentAtLineBreak =
   std::min(IndentAtLineBreak, std::max(0, ContentColumn[i]));
   }
-  IndentAtLineBreak =
-  std::max(IndentAtLineBreak, Decoration.size());
+  IndentAtLineBreak = std::max(IndentAtLineBreak, Decoration.size());
 
   // Detect a multiline jsdoc comment and set DelimitersOnNewline in that case.
   if (Style.Language == FormatStyle::LK_JavaScript ||
@@ -441,8 +438,11 @@ BreakableBlockComment::BreakableBlockCom
   // Detect a long single-line comment, like:
   // /** long long long */
   // Below, '2' is the width of '*/'.
-  unsigned EndColumn = ContentColumn[0] + encoding::columnWidthWithTabs(
-  Lines[0], ContentColumn[0], Style.TabWidth, Encoding) + 2;
+  unsigned EndColumn =
+  ContentColumn[0] +
+  encoding::columnWidthWithTabs(Lines[0], ContentColumn[0],
+Style.TabWidth, Encoding) +
+  2;
   DelimitersOnNewline = EndColumn > Style.ColumnLimit;
 }
   }
@@ -559,27 +559,24 @@ BreakableToken::Split BreakableBlockComm
   return Result;
 }
 
-unsigned BreakableBlockC

[PATCH] D37629: [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313745: [Sema] Move some stuff into 
-Wtautological-unsigned-enum-zero-compare (authored by lebedevri).

Changed prior to commit:
  https://reviews.llvm.org/D37629?vs=115903&id=115977#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37629

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/Sema/compare.c
  cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5914,19 +5914,26 @@
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
+def warn_lunsigned_always_true_comparison : Warning<
+  "comparison of unsigned expression %0 is always %select{false|true}1">,
+  InGroup;
+def warn_runsigned_always_true_comparison : Warning<
+  "comparison of %0 unsigned expression is always %select{false|true}1">,
+  InGroup;
+def warn_lunsigned_enum_always_true_comparison : Warning<
+  "comparison of unsigned enum expression %0 is always %select{false|true}1">,
+  InGroup;
+def warn_runsigned_enum_always_true_comparison : Warning<
+  "comparison of %0 unsigned enum expression is always %select{false|true}1">,
+  InGroup;
+
 def warn_mixed_sign_comparison : Warning<
   "comparison of integers of different signs: %0 and %1">,
   InGroup, DefaultIgnore;
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned%select{| enum}2 expression %0 is always %1">,
-  InGroup;
 def warn_out_of_range_compare : Warning<
   "comparison of %select{constant %0|true|false}1 with " 
   "%select{expression of type %2|boolean expression}3 is always "
   "%select{false|true}4">, InGroup;
-def warn_runsigned_always_true_comparison : Warning<
-  "comparison of %0 unsigned%select{| enum}2 expression is always %1">,
-  InGroup;
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -429,12 +429,14 @@
 def StringPlusChar : DiagGroup<"string-plus-char">;
 def StrncatSize : DiagGroup<"strncat-size">;
 def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
+def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
 [TautologicalUnsignedZeroCompare,
+ TautologicalUnsignedEnumZeroCompare,
  TautologicalOutOfRangeCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,
Index: cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
===
--- cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
+++ cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare -verify %s
+
+int main() {
+  enum A { A_foo, A_bar };
+  enum A a;
+
+#ifdef TEST
+  if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0 <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0 > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 is always false}}
+return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 0 is always true}}
+return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum expression is always true}}
+return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression is always false}}
+return 0;
+#else
+  

r313745 - [Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

2017-09-20 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Sep 20 02:54:47 2017
New Revision: 313745

URL: http://llvm.org/viewvc/llvm-project?rev=313745&view=rev
Log:
[Sema] Move some stuff into -Wtautological-unsigned-enum-zero-compare

Recommit. Original commit was reverted because buildbots broke.
The error was only reproducible in the build with assertions.
The problem was that the diagnostic expected true/false as
bool, while it was provided as string "true"/"false".

Summary:
As requested by Sam McCall:
> Enums (not new I guess). Typical case: if (enum < 0 || enum > MAX)
> The warning strongly suggests that the enum < 0 check has no effect
> (for enums with nonnegative ranges).
> Clang doesn't seem to optimize such checks out though, and they seem
> likely to catch bugs in some cases. Yes, only if there's UB elsewhere,
> but I assume not optimizing out these checks indicates a deliberate
> decision to stay somewhat compatible with a technically-incorrect
> mental model.
> If this is the case, should we move these to a
> -Wtautological-compare-enum subcategory?

Reviewers: rjmccall, rsmith, aaron.ballman, sammccall, bkramer, djasper

Reviewed By: aaron.ballman

Subscribers: jroelofs, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/compare.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=313745&r1=313744&r2=313745&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Sep 20 02:54:47 2017
@@ -429,12 +429,14 @@ def StringPlusInt : DiagGroup<"string-pl
 def StringPlusChar : DiagGroup<"string-plus-char">;
 def StrncatSize : DiagGroup<"strncat-size">;
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
+def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
 def TautologicalUndefinedCompare : DiagGroup<"tautological-undefined-compare">;
 def TautologicalCompare : DiagGroup<"tautological-compare",
 [TautologicalUnsignedZeroCompare,
+ TautologicalUnsignedEnumZeroCompare,
  TautologicalOutOfRangeCompare,
  TautologicalPointerCompare,
  TautologicalOverlapCompare,

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=313745&r1=313744&r2=313745&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Sep 20 02:54:47 
2017
@@ -5914,19 +5914,26 @@ def note_typecheck_assign_const : Note<
   "member function %q1 is declared const here|"
   "%select{|nested }1data member %2 declared const here}0">;
 
+def warn_lunsigned_always_true_comparison : Warning<
+  "comparison of unsigned expression %0 is always %select{false|true}1">,
+  InGroup;
+def warn_runsigned_always_true_comparison : Warning<
+  "comparison of %0 unsigned expression is always %select{false|true}1">,
+  InGroup;
+def warn_lunsigned_enum_always_true_comparison : Warning<
+  "comparison of unsigned enum expression %0 is always %select{false|true}1">,
+  InGroup;
+def warn_runsigned_enum_always_true_comparison : Warning<
+  "comparison of %0 unsigned enum expression is always %select{false|true}1">,
+  InGroup;
+
 def warn_mixed_sign_comparison : Warning<
   "comparison of integers of different signs: %0 and %1">,
   InGroup, DefaultIgnore;
-def warn_lunsigned_always_true_comparison : Warning<
-  "comparison of unsigned%select{| enum}2 expression %0 is always %1">,
-  InGroup;
 def warn_out_of_range_compare : Warning<
   "comparison of %select{constant %0|true|false}1 with " 
   "%select{expression of type %2|boolean expression}3 is always "
   "%select{false|true}4">, InGroup;
-def warn_runsigned_always_true_comparison : Warning<
-  "comparison of %0 unsigned%select{| enum}2 expression is always %1">,
-  InGroup;
 def warn_comparison_of_mixed_enum_types : Warning<
   "comparison of two values with different enumeration types"
   "%diff{ ($ and $)|}0,1">,

Modified: cfe/t

r313747 - [Sema] CheckTautologicalComparisonWithZero(): always complain about enums

2017-09-20 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Sep 20 03:15:27 2017
New Revision: 313747

URL: http://llvm.org/viewvc/llvm-project?rev=313747&view=rev
Log:
[Sema] CheckTautologicalComparisonWithZero(): always complain about enums

Hopefully fixes test-clang-msc-x64-on-i686-linux-RA build.

The underlying problem is that the enum is signed there.
Yet still, it is invalid for it to contain negative values,
so the comparison is always tautological in this case.

No differential, but related to https://reviews.llvm.org/D37629

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=313747&r1=313746&r2=313747&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 20 03:15:27 2017
@@ -8592,22 +8592,26 @@ bool CheckTautologicalComparisonWithZero
 
   bool Match = true;
 
-  if (Op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
+  if (Op == BO_LT && IsZero(S, RHS) &&
+  (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison
 : diag::warn_lunsigned_always_true_comparison)
 << "< 0" << false << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
+  } else if (Op == BO_GE && IsZero(S, RHS) &&
+ (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison
 : diag::warn_lunsigned_always_true_comparison)
 << ">= 0" << true << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
+  } else if (Op == BO_GT && IsZero(S, LHS) &&
+ (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison
 : diag::warn_runsigned_always_true_comparison)
 << "0 >" << false << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
+  } else if (Op == BO_LE && IsZero(S, LHS) &&
+ (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison
 : diag::warn_runsigned_always_true_comparison)


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


[PATCH] D38075: Fix PR34668 - P0704R1 implementation is too permissive

2017-09-20 Thread Tim Song via Phabricator via cfe-commits
tcanens created this revision.
tcanens added a project: clang.

https://bugs.llvm.org/show_bug.cgi?id=34668

Pretty straightforward.


Repository:
  rL LLVM

https://reviews.llvm.org/D38075

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp


Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -3,12 +3,15 @@
 struct X {
   void ref() & {}
   void cref() const& {}
+  void cvref() const volatile& {}
 };
 
 void test() {
   X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' 
with an expression of type 'X'}}
   X{}.cref(); // expected-no-error
+  X{}.cvref(); // expected-error{{cannot initialize object parameter of type 
'const volatile X' with an expression of type 'X'}}
 
   (X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 
'void (X::*)() {{.*}}&' can only be called on an lvalue}}
   (X{}.*&X::cref)(); // expected-no-error
+  (X{}.*&X::cvref)(); // expected-error-re{{pointer-to-member function type 
'void (X::*)() {{.*}}&' can only be called on an lvalue}}
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5183,7 +5183,7 @@
 case RQ_LValue:
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 
'const'.
-if (Proto->isConst())
+if (Proto->isConst() && !Proto->isVolatile())
   Diag(Loc, getLangOpts().CPlusPlus2a
 ? 
diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
 : diag::ext_pointer_to_const_ref_member_on_rvalue);


Index: test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
===
--- test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
+++ test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
@@ -3,12 +3,15 @@
 struct X {
   void ref() & {}
   void cref() const& {}
+  void cvref() const volatile& {}
 };
 
 void test() {
   X{}.ref(); // expected-error{{cannot initialize object parameter of type 'X' with an expression of type 'X'}}
   X{}.cref(); // expected-no-error
+  X{}.cvref(); // expected-error{{cannot initialize object parameter of type 'const volatile X' with an expression of type 'X'}}
 
   (X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
   (X{}.*&X::cref)(); // expected-no-error
+  (X{}.*&X::cvref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
 }
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -5183,7 +5183,7 @@
 case RQ_LValue:
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 'const'.
-if (Proto->isConst())
+if (Proto->isConst() && !Proto->isVolatile())
   Diag(Loc, getLangOpts().CPlusPlus2a
 ? diag::warn_cxx17_compat_pointer_to_const_ref_member_on_rvalue
 : diag::ext_pointer_to_const_ref_member_on_rvalue);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r312750 - [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

2017-09-20 Thread Roman Lebedev via cfe-commits
On Sat, Sep 9, 2017 at 12:56 AM, Aaron Ballman  wrote:
> On Fri, Sep 8, 2017 at 5:49 PM, Hans Wennborg via cfe-commits
>  wrote:
>> On Fri, Sep 8, 2017 at 2:26 PM, Friedman, Eli  
>> wrote:
>>> On 9/8/2017 2:18 PM, Hans Wennborg via cfe-commits wrote:

 On Fri, Sep 8, 2017 at 2:09 PM, Roman Lebedev 
 wrote:
>
>
> Interesting. My first thought was to explicitly specify enum as signed:
>
> enum MediaDeviceType : signed int {
> MEDIA_DEVICE_TYPE_AUDIO_INPUT = 0,
> MEDIA_DEVICE_TYPE_VIDEO_INPUT,
> MEDIA_DEVICE_TYPE_AUDIO_OUTPUT,
> NUM_MEDIA_DEVICE_TYPES,
> };
>
> inline bool IsValidMediaDeviceType(MediaDeviceType type) {
> return type >= 0U && type < NUM_MEDIA_DEVICE_TYPES;
> }
>
> But it still seem to warn, and *that* sounds like a bug.
> Please open a new bugreport.

 I'm reporting it here :-)

> As for different default signedness, i'm not sure what is there to do.
> Does
> not sound like a problem for this diagnostic to intentionally avoid to
> be honest.

 I think it is a problem for this warning. If a user sees the warning
 and removes the "type >= 0" check, thinking that it was unnecessary
 because the compiler told them so, they have now introduced a bug in
 the code.
>>>
>>>
>>> Even if you declare the enum type as signed, it still isn't allowed to
>>> contain a negative number; that's undefined behavior.  You can check for
>>> this using ubsan's -fsanitize=enum.
>>
>> Is it? I thought if you define it as signed, it falls under "For an
>> enumeration whose underlying type is fixed, the values of the
>> enumeration are the values of the underlying type." (c++11 7.2p7)
>>
>> My standards-fu is weak though, so I could be wrong.
>
> The enum values can be signed because of the fixed type, but the
> comparison was enum_val <= 0U, so I believe the usual arithmetic
> conversions will convert the enum value to an *unsigned* value, making
> this a tautological comparison. If the value was 0, then I think the
> comparison would not be tautological because there would be no
> conversion needed.

Once i re-committed D37629, test-clang-msc-x64-on-i686-linux-RA build
broke with that exact problem - the expected diagnostic about enum
was not emitted. So i fixed it up in r313747, so now such diagnostic
about tautological comparison of 0 and enum is properly emitted
regardless of the sign of the enum type.

>> But I think you're right about the case when the underlying type is
>> not specified. Even if it happens to be 'int' on Windows, negative
>> values aren't allowed (unless there are negative enumerators). That
>> doesn't mean it won't happen though, and lots of code isn't UB-clean
>> :-/
>
> Yes, but if the *optimizer* were ever clever enough to realize the
> value cannot be negative, then your code still has a pretty serious
> problem in the face of that same UB.
>
> ~Aaron

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


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: clangd/ClangdServer.cpp:321-324
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.

Why is this a FIXME? Do we intend to use a different mechanism? 2^64 versions 
of a file seem to be a lot?



Comment at: unittests/clangd/ClangdTests.cpp:912
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));

Why not hand in a signal to wait for?


https://reviews.llvm.org/D38032



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


[clang-tools-extra] r313749 - [clangd] Run clang-format on ClangdUnit.cpp. NFC.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 03:46:58 2017
New Revision: 313749

URL: http://llvm.org/viewvc/llvm-project?rev=313749&view=rev
Log:
[clangd] Run clang-format on ClangdUnit.cpp. NFC.

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=313749&r1=313748&r2=313749&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Sep 20 03:46:58 2017
@@ -9,6 +9,7 @@
 
 #include "ClangdUnit.h"
 
+#include "Logger.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/FrontendActions.h"
@@ -26,7 +27,6 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/Format.h"
-#include "Logger.h"
 
 #include 
 #include 
@@ -894,7 +894,8 @@ PreambleData::PreambleData(PrecompiledPr
 
 std::shared_ptr
 CppFile::Create(PathRef FileName, tooling::CompileCommand Command,
-std::shared_ptr PCHs, clangd::Logger 
&Logger) {
+std::shared_ptr PCHs,
+clangd::Logger &Logger) {
   return std::shared_ptr(
   new CppFile(FileName, std::move(Command), std::move(PCHs), Logger));
 }


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


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.cpp:321-324
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.

klimek wrote:
> Why is this a FIXME? Do we intend to use a different mechanism? 2^64 versions 
> of a file seem to be a lot?
I think we can get rid of it after refactoring threading. But we should 
definitely be fine with 2^64 versions.



Comment at: unittests/clangd/ClangdTests.cpp:912
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));

klimek wrote:
> Why not hand in a signal to wait for?
The signal should be fired on a second call to `onDiagnosticsReady`, but the 
second call won't happen before the fist one returns.
Is there some other way to fire the signal that I'm missing?


https://reviews.llvm.org/D38032



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


[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

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

https://reviews.llvm.org/D38077

Files:
  clangd/ClangdUnit.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-priorities.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test

Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -31,7 +31,7 @@
 # Test message with Content-Type before Content-Length
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 
 X-Test: Testing
@@ -50,7 +50,7 @@
 # Test message with duplicate Content-Length headers
 #
 # CHECK: {"jsonrpc":"2.0","id":3,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
 
@@ -69,7 +69,7 @@
 # Test message with Content-Type before Content-Length
 #
 # CHECK: {"jsonrpc":"2.0","id":5,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 
 Content-Length: 1024
Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -16,25 +16,25 @@
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"35bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"35ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"34operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"34~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"35f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind"

[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG




Comment at: clangd/ClangdServer.h:287
+  std::mutex DiagnosticsMutex;
+  llvm::StringMap ReportedDiagnosticVersions;
 };

Comment what it maps from.



Comment at: unittests/clangd/ClangdTests.cpp:912
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));

ilya-biryukov wrote:
> klimek wrote:
> > Why not hand in a signal to wait for?
> The signal should be fired on a second call to `onDiagnosticsReady`, but the 
> second call won't happen before the fist one returns.
> Is there some other way to fire the signal that I'm missing?
Thinking a bit more about it, I can't find a better way.


https://reviews.llvm.org/D38032



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


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 115985.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Added a comment to version map.
- Fixed compilation after rebase.


https://reviews.llvm.org/D38032

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -898,5 +899,67 @@
   }
 }
 
+TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
+  class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
+  public:
+NoConcurrentAccessDiagConsumer(std::promise StartSecondReparse)
+: StartSecondReparse(std::move(StartSecondReparse)) {}
+
+void onDiagnosticsReady(
+PathRef File,
+Tagged> Diagnostics) override {
+
+  std::unique_lock Lock(Mutex, std::try_to_lock_t());
+  ASSERT_TRUE(Lock.owns_lock())
+  << "Detected concurrent onDiagnosticsReady calls for the same file.";
+  if (FirstRequest) {
+FirstRequest = false;
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));
+  }
+}
+
+  private:
+std::mutex Mutex;
+bool FirstRequest = true;
+std::promise StartSecondReparse;
+  };
+
+  const auto SourceContentsWithoutErrors = R"cpp(
+int a;
+int b;
+int c;
+int d;
+)cpp";
+
+  const auto SourceContentsWithErrors = R"cpp(
+int a = x;
+int b;
+int c;
+int d;
+)cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  llvm::StringMap FileContents;
+  FileContents[FooCpp] = "";
+  ConstantFSProvider FS(buildTestFS(FileContents));
+
+  std::promise StartSecondReparsePromise;
+  std::future StartSecondReparse = StartSecondReparsePromise.get_future();
+
+  NoConcurrentAccessDiagConsumer DiagConsumer(
+  std::move(StartSecondReparsePromise));
+
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  ClangdServer Server(CDB, DiagConsumer, FS, 4, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
+  Server.addDocument(FooCpp, SourceContentsWithErrors);
+  StartSecondReparse.wait();
+
+  auto Future = Server.addDocument(FooCpp, SourceContentsWithoutErrors);
+  Future.wait();
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/DraftStore.h
===
--- clangd/DraftStore.h
+++ clangd/DraftStore.h
@@ -13,15 +13,16 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
-/// Using 'unsigned' here to avoid undefined behaviour on overflow.
-typedef unsigned DocVersion;
+/// Using unsigned int type here to avoid undefined behaviour on overflow.
+typedef uint64_t DocVersion;
 
 /// Document draft with a version of this draft.
 struct VersionedDraft {
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -284,6 +284,13 @@
   // ClangdServer
   ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
+
+  /// Used to serialize diagnostic callbacks.
+  /// FIXME(ibiryukov): get rid of an extra map and put all version counters
+  /// into CppFile.
+  std::mutex DiagnosticsMutex;
+  /// Maps from a filename to the latest version of reported diagnostics.
+  llvm::StringMap ReportedDiagnosticVersions;
 };
 
 } // namespace clangd
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -315,6 +315,19 @@
 auto Diags = DeferredRebuild.get();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
+
+// We need to serialize access to resulting diagnostics to avoid calling
+// `onDiagnosticsReady` in the wrong order.
+std::lock_guard DiagsLock(DiagnosticsMutex);
+DocVersion &LastReportedDiagsVersion = ReportedDiagnosticVersions[FileStr];
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.
+if (Version < LastReportedDiagsVersion)
+  return;
+LastReportedDiagsVersion = Version;
+
 DiagConsumer.onDiagnosticsReady(FileStr,
 make_tagged(std::move(*Diags), Tag));
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

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

Thanks for the review!


https://reviews.llvm.org/D38032



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


[clang-tools-extra] r313752 - [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests

2017-09-20 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Sep 20 05:16:35 2017
New Revision: 313752

URL: http://llvm.org/viewvc/llvm-project?rev=313752&view=rev
Log:
[clang-tidy] Fix linkage-related compiler errors in clang-tidy tests

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp?rev=313752&r1=313751&r2=313752&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp Wed 
Sep 20 05:16:35 2017
@@ -43,19 +43,23 @@ template  struct
 
 template > struct multiset : set {};
 
-template  FwIt find(FwIt, FwIt, const K &);
+template 
+FwIt find(FwIt, FwIt end, const K &) { return end; }
 
 template 
-FwIt find(FwIt, FwIt, const K &, Cmp);
+FwIt find(FwIt, FwIt end, const K &, Cmp) { return end; }
 
-template  FwIt find_if(FwIt, FwIt, Pred);
+template 
+FwIt find_if(FwIt, FwIt end, Pred) { return end; }
 
-template  FwIt count(FwIt, FwIt, const K &);
+template 
+unsigned count(FwIt, FwIt, const K &) { return 0; }
 
-template  FwIt lower_bound(FwIt, FwIt, const K &);
+template 
+FwIt lower_bound(FwIt, FwIt end, const K &) { return end; }
 
 template 
-FwIt lower_bound(FwIt, FwIt, const K &, Ord);
+FwIt lower_bound(FwIt, FwIt end, const K &, Ord) { return end; }
 }
 
 #define FIND_IN_SET(x) find(x.begin(), x.end(), 10)

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp?rev=313752&r1=313751&r2=313752&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp Wed Sep 20 
05:16:35 2017
@@ -10,7 +10,9 @@ template  struct remove_re
 template  struct remove_reference<_Tp &&> { typedef _Tp type; };
 
 template 
-constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t);
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
 
 } // namespace std
 


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


Re: r313747 - [Sema] CheckTautologicalComparisonWithZero(): always complain about enums

2017-09-20 Thread Aaron Ballman via cfe-commits
On Wed, Sep 20, 2017 at 6:15 AM, Roman Lebedev via cfe-commits
 wrote:
> Author: lebedevri
> Date: Wed Sep 20 03:15:27 2017
> New Revision: 313747
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313747&view=rev
> Log:
> [Sema] CheckTautologicalComparisonWithZero(): always complain about enums
>
> Hopefully fixes test-clang-msc-x64-on-i686-linux-RA build.
>
> The underlying problem is that the enum is signed there.
> Yet still, it is invalid for it to contain negative values,
> so the comparison is always tautological in this case.

Why is it invalid for the comparand to contain a negative value when
the enum type is signed?

~Aaron

>
> No differential, but related to https://reviews.llvm.org/D37629
>
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=313747&r1=313746&r2=313747&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 20 03:15:27 2017
> @@ -8592,22 +8592,26 @@ bool CheckTautologicalComparisonWithZero
>
>bool Match = true;
>
> -  if (Op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
> +  if (Op == BO_LT && IsZero(S, RHS) &&
> +  (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(LHS) ? 
> diag::warn_lunsigned_enum_always_true_comparison
>  : diag::warn_lunsigned_always_true_comparison)
>  << "< 0" << false << LHS->getSourceRange() << RHS->getSourceRange();
> -  } else if (Op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, 
> RHS)) {
> +  } else if (Op == BO_GE && IsZero(S, RHS) &&
> + (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(LHS) ? 
> diag::warn_lunsigned_enum_always_true_comparison
>  : diag::warn_lunsigned_always_true_comparison)
>  << ">= 0" << true << LHS->getSourceRange() << RHS->getSourceRange();
> -  } else if (Op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, 
> LHS)) {
> +  } else if (Op == BO_GT && IsZero(S, LHS) &&
> + (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(RHS) ? 
> diag::warn_runsigned_enum_always_true_comparison
>  : diag::warn_runsigned_always_true_comparison)
>  << "0 >" << false << LHS->getSourceRange() << RHS->getSourceRange();
> -  } else if (Op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, 
> LHS)) {
> +  } else if (Op == BO_LE && IsZero(S, LHS) &&
> + (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(RHS) ? 
> diag::warn_runsigned_enum_always_true_comparison
>  : diag::warn_runsigned_always_true_comparison)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13811: [clang-format] AllowShortFunctionsOnASingleLine: true/Empty didn't work with BreakBeforeBraces: Linux/Allman.

2017-09-20 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius abandoned this revision.
curdeius added a comment.

This was fixed by https://reviews.llvm.org/rL312904 and other commits.


https://reviews.llvm.org/D13811



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


[clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 05:58:55 2017
New Revision: 313754

URL: http://llvm.org/viewvc/llvm-project?rev=313754&view=rev
Log:
[clangd] Serialize onDiagnosticsReady callbacks for the same file.

Summary:
Calls to onDiagnosticsReady were done concurrently before. This sometimes
led to older versions of diagnostics being reported to the user after
the newer versions.

Reviewers: klimek, bkramer, krasimir

Reviewed By: klimek

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/DraftStore.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=313754&r1=313753&r2=313754&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55 2017
@@ -315,6 +315,19 @@ std::future ClangdServer::schedule
 auto Diags = DeferredRebuild.get();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
+
+// We need to serialize access to resulting diagnostics to avoid calling
+// `onDiagnosticsReady` in the wrong order.
+std::lock_guard DiagsLock(DiagnosticsMutex);
+DocVersion &LastReportedDiagsVersion = ReportedDiagnosticVersions[FileStr];
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.
+if (Version < LastReportedDiagsVersion)
+  return;
+LastReportedDiagsVersion = Version;
+
 DiagConsumer.onDiagnosticsReady(FileStr,
 make_tagged(std::move(*Diags), Tag));
   };

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=313754&r1=313753&r2=313754&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55 2017
@@ -284,6 +284,13 @@ private:
   // ClangdServer
   ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
+
+  /// Used to serialize diagnostic callbacks.
+  /// FIXME(ibiryukov): get rid of an extra map and put all version counters
+  /// into CppFile.
+  std::mutex DiagnosticsMutex;
+  /// Maps from a filename to the latest version of reported diagnostics.
+  llvm::StringMap ReportedDiagnosticVersions;
 };
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/DraftStore.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/DraftStore.h?rev=313754&r1=313753&r2=313754&view=diff
==
--- clang-tools-extra/trunk/clangd/DraftStore.h (original)
+++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
@@ -13,6 +13,7 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 #include 
 #include 
@@ -20,8 +21,8 @@
 namespace clang {
 namespace clangd {
 
-/// Using 'unsigned' here to avoid undefined behaviour on overflow.
-typedef unsigned DocVersion;
+/// Using unsigned int type here to avoid undefined behaviour on overflow.
+typedef uint64_t DocVersion;
 
 /// Document draft with a version of this draft.
 struct VersionedDraft {

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=313754&r1=313753&r2=313754&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Wed Sep 20 
05:58:55 2017
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -898,5 +899,67 @@ int d;
   }
 }
 
+TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
+  class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
+  public:
+NoConcurrentAccessDiagConsumer(std::promise StartSecondReparse)
+: StartSecondReparse(std::move(StartSecondReparse)) {}
+
+void onDiagnosticsReady(
+PathRef File,
+Tagged> Diagnostics) override {
+
+  std::unique_lock Lock(Mutex, std::try_to_lock_t());
+  ASSERT_TRUE(Lock.owns_lock())
+  << "Detected concurrent onDiagnosticsReady calls for the same file.";
+  if (FirstRequest) {
+FirstRequest = false;
+ 

[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313754: [clangd] Serialize onDiagnosticsReady callbacks for 
the same file. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38032

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/DraftStore.h
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -898,5 +899,67 @@
   }
 }
 
+TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
+  class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
+  public:
+NoConcurrentAccessDiagConsumer(std::promise StartSecondReparse)
+: StartSecondReparse(std::move(StartSecondReparse)) {}
+
+void onDiagnosticsReady(
+PathRef File,
+Tagged> Diagnostics) override {
+
+  std::unique_lock Lock(Mutex, std::try_to_lock_t());
+  ASSERT_TRUE(Lock.owns_lock())
+  << "Detected concurrent onDiagnosticsReady calls for the same file.";
+  if (FirstRequest) {
+FirstRequest = false;
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));
+  }
+}
+
+  private:
+std::mutex Mutex;
+bool FirstRequest = true;
+std::promise StartSecondReparse;
+  };
+
+  const auto SourceContentsWithoutErrors = R"cpp(
+int a;
+int b;
+int c;
+int d;
+)cpp";
+
+  const auto SourceContentsWithErrors = R"cpp(
+int a = x;
+int b;
+int c;
+int d;
+)cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  llvm::StringMap FileContents;
+  FileContents[FooCpp] = "";
+  ConstantFSProvider FS(buildTestFS(FileContents));
+
+  std::promise StartSecondReparsePromise;
+  std::future StartSecondReparse = StartSecondReparsePromise.get_future();
+
+  NoConcurrentAccessDiagConsumer DiagConsumer(
+  std::move(StartSecondReparsePromise));
+
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  ClangdServer Server(CDB, DiagConsumer, FS, 4, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
+  Server.addDocument(FooCpp, SourceContentsWithErrors);
+  StartSecondReparse.wait();
+
+  auto Future = Server.addDocument(FooCpp, SourceContentsWithoutErrors);
+  Future.wait();
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -284,6 +284,13 @@
   // ClangdServer
   ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
+
+  /// Used to serialize diagnostic callbacks.
+  /// FIXME(ibiryukov): get rid of an extra map and put all version counters
+  /// into CppFile.
+  std::mutex DiagnosticsMutex;
+  /// Maps from a filename to the latest version of reported diagnostics.
+  llvm::StringMap ReportedDiagnosticVersions;
 };
 
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/DraftStore.h
===
--- clang-tools-extra/trunk/clangd/DraftStore.h
+++ clang-tools-extra/trunk/clangd/DraftStore.h
@@ -13,15 +13,16 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
-/// Using 'unsigned' here to avoid undefined behaviour on overflow.
-typedef unsigned DocVersion;
+/// Using unsigned int type here to avoid undefined behaviour on overflow.
+typedef uint64_t DocVersion;
 
 /// Document draft with a version of this draft.
 struct VersionedDraft {
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -315,6 +315,19 @@
 auto Diags = DeferredRebuild.get();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
+
+// We need to serialize access to resulting diagnostics to avoid calling
+// `onDiagnosticsReady` in the wrong order.
+std::lock_guard DiagsLock(DiagnosticsMutex);
+DocVersion &LastReportedDiagsVersion = ReportedDiagnosticVersions[FileStr];
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.
+   

Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-09-20 Thread Alex L via cfe-commits
On 16 August 2017 at 02:49, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Aug 15 18:49:53 2017
> New Revision: 310983
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310983&view=rev
> Log:
> PR19668, PR23034: Fix handling of move constructors and deleted copy
> constructors when deciding whether classes should be passed indirectly.
>
> This fixes ABI differences between Clang and GCC:
>
>  * Previously, Clang ignored the move constructor when making this
>determination. It now takes the move constructor into account, per
>https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
>seem recent, but the ABI change was agreed on the Itanium C++ ABI
>list a long time ago).
>
>  * Previously, Clang's behavior when the copy constructor was deleted
>was unstable -- depending on whether the lazy declaration of the
>copy constructor had been triggered, you might get different behavior.
>We now eagerly declare the copy constructor whenever its deletedness
>is unclear, and ignore deleted copy/move constructors when looking for
>a trivial such constructor.
>
> This also fixes an ABI difference between Clang and MSVC:
>
>  * If the copy constructor would be implicitly deleted (but has not been
>lazily declared yet), for instance because the class has an rvalue
>reference member, we would pass it directly. We now pass such a class
>indirectly, matching MSVC.
>
> Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
> Schmidt, which was based on a patch by Reid Kleckner!
>
> This is a re-commit of r310401, which was reverted in r310464 due to ARM
> failures (which should now be fixed).
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/CodeGen/CGCXXABI.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=310983&r1=310982&r2=310983&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017
> @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if a defaulted corresponding
> special
>  /// member can't be fully analyzed without performing overload
> resolution.
>  /// @{
> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveAssignment : 1;
>  unsigned NeedOverloadResolutionForDestructor : 1;
> @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if an implicit defaulted
> corresponding
>  /// special member would be defined as deleted.
>  /// @{
> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>  unsigned DefaultedMoveConstructorIsDeleted : 1;
>  unsigned DefaultedMoveAssignmentIsDeleted : 1;
>  unsigned DefaultedDestructorIsDeleted : 1;
> @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl
>  /// constructor.
>  unsigned HasDefaultedDefaultConstructor : 1;
>
> +/// \brief True if this class can be passed in a
> non-address-preserving
> +/// fashion (such as in registers) according to the C++ language
> rules.
> +/// This does not imply anything about how the ABI in use will
> actually
> +/// pass an object of this class.
> +unsigned CanPassInRegisters : 1;
> +
>  /// \brief True if a defaulted default constructor for this class
> would
>  /// be constexpr.
>  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
> @@ -810,18 +818,50 @@ public:
>  return data().FirstFriend.isValid();
>}
>
> +  /// \brief \c true if a defaulted copy constructor for this class would
> be
> +  /// deleted.
> +  bool defaultedCopyConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForCopyConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
> +   "this property has not yet been computed by Sema");
> +return data().DefaultedCopyConstructorIsDeleted;
> +  }
> +
> +  /// \brief \c true if a defaulted move constructor for this class would
> be
> +  /// deleted.
> +  bool defaultedMoveConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForMoveConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
> +   "

r313756 - Replace r313747, don't always warn on enums, rework testcases.

2017-09-20 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Sep 20 06:50:01 2017
New Revision: 313756

URL: http://llvm.org/viewvc/llvm-project?rev=313756&view=rev
Log:
Replace r313747, don't always warn on enums, rework testcases.

As Aaron Ballman has pointed out, that is not really correct.
So the key problem there is the invalidity of the testcase.

Revert r313747, and rework testcase in such a way, so these
details (platform-specific default enum sigdness) are
accounted for.

Also, add a C++-specific testcase.

Added:
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=313756&r1=313755&r2=313756&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 20 06:50:01 2017
@@ -8592,26 +8592,22 @@ bool CheckTautologicalComparisonWithZero
 
   bool Match = true;
 
-  if (Op == BO_LT && IsZero(S, RHS) &&
-  (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
+  if (Op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison
 : diag::warn_lunsigned_always_true_comparison)
 << "< 0" << false << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_GE && IsZero(S, RHS) &&
- (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
+  } else if (Op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison
 : diag::warn_lunsigned_always_true_comparison)
 << ">= 0" << true << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_GT && IsZero(S, LHS) &&
- (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
+  } else if (Op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison
 : diag::warn_runsigned_always_true_comparison)
 << "0 >" << false << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_LE && IsZero(S, LHS) &&
- (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
+  } else if (Op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison
 : diag::warn_runsigned_always_true_comparison)

Modified: cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c?rev=313756&r1=313755&r2=313756&view=diff
==
--- cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c (original)
+++ cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c Wed Sep 20 
06:50:01 2017
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare 
-verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DALL_WARN 
-verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGN_WARN -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only 
-Wno-tautological-unsigned-enum-zero-compare -verify %s
+
+// Okay, this is where it gets complicated.
+// Then default enum sigdness is target-specific.
+// On windows, it is signed by default. We do not want to warn in that case.
 
 int main() {
   enum A { A_foo, A_bar };
   enum A a;
 
-#ifdef TEST
+#ifdef ALL_WARN
   if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 
is always false}}
 return 0;
   if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 
0 is always true}}
@@ -16,6 +21,23 @@ int main() {
 return 0;
   if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 
is always false}}
 return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 
0 is always true}}
+return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum 
expression is always true}}
+return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression 
is always false}}
+return 0;
+#elif defined(SIGN_WARN)
+  if (a < 0) // ok
+return 0;
+  if (a >= 0) // ok
+return 0;
+  if (0 <= a) // ok
+return 0;
+  if (0 > a) // ok
+return 0;
+  if (a < 0U) // expected-warning {{comparison

[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

This is how you could add a test in `NamespaceEndCommentsFixerTest.cpp`:

  TEST_F(NamespaceEndCommentsFixerTest, FixesNamespaceCommentsInAllmanStyle) {
FormatStyle AllmanStyle = getLLVMStyle();
AllmanStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
EXPECT_EQ("namespace a\n"
  "{\n"
  "void f();\n"
  "void g();\n"
  "}// namespace a\n",
  fixNamespaceEndComments("namespace a\n"
  "{\n"
  "void f();\n"
  "void g();\n"
  "}\n",
  AllmanStyle));
  }


https://reviews.llvm.org/D37904



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


[PATCH] D38081: Set completion priority of destructors and operators to CCP_Unlikely.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added a subscriber: eraman.

It will move destructors and operators to the end of completion list.
Destructors and operators are currently very high on the completion
list, as they have the same priority as member functions. However,
they are clearly not something users usually choose in completion
lists.


https://reviews.llvm.org/D38081

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-access-checks.cpp
  test/Index/complete-cxx-inline-methods.cpp
  test/Index/complete-qualified.cpp
  test/Index/complete-with-annotations.cpp

Index: test/Index/complete-with-annotations.cpp
===
--- test/Index/complete-with-annotations.cpp
+++ test/Index/complete-with-annotations.cpp
@@ -17,7 +17,7 @@
 // CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("three", "two", "one")
 // CHECK: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) ("some annotation")
 // CHECK: FieldDecl:{ResultType int}{TypedText member2} (35) ("another annotation", "some annotation")
-// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (34)
+// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (79)
 // CHECK: ClassDecl:{TypedText X}{Text ::} (75)
-// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (34)
+// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (79)
 
Index: test/Index/complete-qualified.cpp
===
--- test/Index/complete-qualified.cpp
+++ test/Index/complete-qualified.cpp
@@ -17,4 +17,4 @@
 // CHECK-CC1: FieldDecl:{ResultType C}{TypedText c} (35)
 // CHECK-CC1: ClassDecl:{TypedText Foo} (35)
 // CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )}
-// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35)
+// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (80)
Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -25,11 +25,11 @@
 
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
-// CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
+// CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
-// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (34)
+// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (79)
 // CHECK-NEXT: Completion contexts:
 // CHECK-NEXT: Dot member access
 // CHECK-NEXT: Container Kind: StructDecl
Index: test/Index/complete-access-checks.cpp
===
--- test/Index/complete-access-checks.cpp
+++ test/Index/complete-access-checks.cpp
@@ -41,22 +41,22 @@
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible)
-// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (34)
-// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (36)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (79)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (81)
 // CHECK-SUPER-ACCESS: StructDecl:{TypedText X}{Text ::} (77)
 // CHECK-SUPER-ACCESS: StructDecl:{TypedText Y}{Text ::} (75)
-// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (36)
-// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (34)
+// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (81)
+// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (79)
 
 // CHECK-ACCESS: CXXMethod:{ResultType void}{T

[PATCH] D37263: [clang-format] Ignore case when sorting using-declarations

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 115998.
krasimir added a comment.

- Stable sort using declarations


https://reviews.llvm.org/D37263

Files:
  lib/Format/UsingDeclarationsSorter.cpp
  unittests/Format/UsingDeclarationsSorterTest.cpp

Index: unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- unittests/Format/UsingDeclarationsSorterTest.cpp
+++ unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -86,6 +86,77 @@
   "using a, b;"));
 }
 
+TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+  EXPECT_EQ("using A;\n"
+"using a;",
+sortUsingDeclarations("using A;\n"
+  "using a;"));
+  EXPECT_EQ("using a;\n"
+"using A;",
+sortUsingDeclarations("using a;\n"
+  "using A;"));
+  EXPECT_EQ("using a;\n"
+"using B;",
+sortUsingDeclarations("using B;\n"
+  "using a;"));
+  EXPECT_EQ("using _;\n"
+"using a;",
+sortUsingDeclarations("using a;\n"
+  "using _;"));
+  EXPECT_EQ("using a::_;\n"
+"using a::a;",
+sortUsingDeclarations("using a::a;\n"
+  "using a::_;"));
+
+  EXPECT_EQ("using ::testing::_;\n"
+"using ::testing::Aardvark;\n"
+"using ::testing::apple::Honeycrisp;\n"
+"using ::testing::Xylophone;\n"
+"using ::testing::zebra::Stripes;",
+sortUsingDeclarations("using ::testing::Aardvark;\n"
+  "using ::testing::Xylophone;\n"
+  "using ::testing::_;\n"
+  "using ::testing::apple::Honeycrisp;\n"
+  "using ::testing::zebra::Stripes;"));
+}
+
+TEST_F(UsingDeclarationsSorterTest, SortsStably) {
+  EXPECT_EQ("using a;\n"
+"using a;\n"
+"using A;\n"
+"using a;\n"
+"using A;\n"
+"using a;\n"
+"using A;\n"
+"using a;\n"
+"using B;\n"
+"using b;\n"
+"using b;\n"
+"using B;\n"
+"using b;\n"
+"using b;\n"
+"using b;\n"
+"using B;\n"
+"using b;",
+sortUsingDeclarations("using a;\n"
+  "using B;\n"
+  "using a;\n"
+  "using b;\n"
+  "using A;\n"
+  "using a;\n"
+  "using b;\n"
+  "using B;\n"
+  "using b;\n"
+  "using A;\n"
+  "using a;\n"
+  "using b;\n"
+  "using b;\n"
+  "using B;\n"
+  "using b;\n"
+  "using A;\n"
+  "using a;"));
+}
+
 TEST_F(UsingDeclarationsSorterTest, SortsMultipleTopLevelDeclarations) {
   EXPECT_EQ("using a;\n"
 "using b;\n"
Index: lib/Format/UsingDeclarationsSorter.cpp
===
--- lib/Format/UsingDeclarationsSorter.cpp
+++ lib/Format/UsingDeclarationsSorter.cpp
@@ -34,7 +34,7 @@
   : Line(Line), Label(Label) {}
 
   bool operator<(const UsingDeclaration &Other) const {
-return Label < Other.Label;
+return StringRef(Label).compare_lower(Other.Label) < 0;
   }
 };
 
@@ -78,7 +78,8 @@
 const SourceManager &SourceMgr, tooling::Replacements *Fixes) {
   SmallVector SortedUsingDeclarations(
   UsingDeclarations->begin(), UsingDeclarations->end());
-  std::sort(SortedUsingDeclarations.begin(), SortedUsingDeclarations.end());
+  std::stable_sort(SortedUsingDeclarations.begin(),
+   SortedUsingDeclarations.end());
   for (size_t I = 0, E = UsingDeclarations->size(); I < E; ++I) {
 if ((*UsingDeclarations)[I].Line == SortedUsingDeclarations[I].Line)
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Makes sense.


https://reviews.llvm.org/D38077



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


[PATCH] D38081: Set completion priority of destructors and operators to CCP_Unlikely.

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

+1! I totally agree with this!


https://reviews.llvm.org/D38081



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


[PATCH] D38083: [clangd] Skip informative qualifier chunks.

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

Completion results look much nicer without them.
Informative qualifiers are stored for every method from a base class, even when
calling those methods does not require any qualifiers. For example,

  struct Foo { int foo(); };
  struct Bar : Foo { };
  void test() { Bar(). // Completion item label was 'Foo::foo' before,
   // but inserted text was simply 'foo'.
   // We now simply show 'foo' in completion item label.

They effectively cluttered the completion list without providing much value.


https://reviews.llvm.org/D38083

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


Index: test/clangd/completion-qualifiers.test
===
--- /dev/null
+++ test/clangd/completion-qualifiers.test
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class
 Foo {\n  public:\nint foo() const;\nint bar() const;\n};\n\nclass Bar 
: public Foo {\n  int foo() const;\n};\n\nvoid test() {\n  Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHEKC-DAG: {"label":"foo() 
const","kind":2,"detail":"int","sortText":"00035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHEKC-DAG: {"label":"bar() 
const","kind":2,"detail":"int","sortText":"00037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHEKC-DAG: {"label":"Foo::foo() 
const","kind":2,"detail":"int","sortText":"00037foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -383,6 +383,11 @@
 
 }; // CompletionItemsCollector
 
+bool isInformativeQualifierChunk(CodeCompletionString::Chunk const &Chunk) {
+  return Chunk.Kind == CodeCompletionString::CK_Informative &&
+ StringRef(Chunk.Text).endswith("::");
+}
+
 class PlainTextCompletionItemsCollector final
 : public CompletionItemsCollector {
 
@@ -395,6 +400,11 @@
   void ProcessChunks(const CodeCompletionString &CCS,
  CompletionItem &Item) const override {
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // There's always exactly one CK_TypedText chunk.
@@ -427,6 +437,11 @@
  CompletionItem &Item) const override {
 unsigned ArgCount = 0;
 for (const auto &Chunk : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // The piece of text that the user is expected to type to match


Index: test/clangd/completion-qualifiers.test
===
--- /dev/null
+++ test/clangd/completion-qualifiers.test
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class Foo {\n  public:\nint foo() const;\nint bar() const;\n};\n\nclass Bar : public Foo {\n  int foo() const;\n};\n\nvoid test() {\n  Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHEKC-DAG: {"label":"foo() const","kind":2,"detail":"int","sortText":"00035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHEKC-DAG: {"label":"bar() const","kind":2,"detail":"int","sortText":"00037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHEKC-DAG: {"label":"Foo::foo() const","kind":2,"detail":"int","sortText":"00037foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutd

[clang-tools-extra] r313759 - [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 08:09:14 2017
New Revision: 313759

URL: http://llvm.org/viewvc/llvm-project?rev=313759&view=rev
Log:
[clangd] Put inacessible items to the end of completion list.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clangd/completion-priorities.test
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/test/clangd/authority-less-uri.test
clang-tools-extra/trunk/test/clangd/completion-snippet.test
clang-tools-extra/trunk/test/clangd/completion.test
clang-tools-extra/trunk/test/clangd/protocol.test

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=313759&r1=313758&r2=313759&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Sep 20 08:09:14 2017
@@ -368,13 +368,39 @@ private:
 }
   }
 
-  void FillSortText(const CodeCompletionString &CCS,
-CompletionItem &Item) const {
+  static int GetSortPriority(const CodeCompletionString &CCS) {
+int Score = CCS.getPriority();
 // Fill in the sortText of the CompletionItem.
-assert(CCS.getPriority() < 9 && "Expecting code completion result "
-"priority to have at most 5-digits");
+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;
+}
+
+return Score;
+  }
+
+  static void FillSortText(const CodeCompletionString &CCS,
+   CompletionItem &Item) {
+int Priority = GetSortPriority(CCS);
+// Fill in the sortText of the CompletionItem.
+assert(Priority <= 99 &&
+   "Expecting sort priority to have at most 6-digits");
 llvm::raw_string_ostream(Item.sortText)
-<< llvm::format("%05d%s", CCS.getPriority(), Item.filterText.c_str());
+<< llvm::format("%06d%s", Priority, Item.filterText.c_str());
   }
 
   std::vector &Items;

Modified: clang-tools-extra/trunk/test/clangd/authority-less-uri.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/authority-less-uri.test?rev=313759&r1=313758&r2=313759&view=diff
==
--- clang-tools-extra/trunk/test/clangd/authority-less-uri.test (original)
+++ clang-tools-extra/trunk/test/clangd/authority-less-uri.test Wed Sep 20 
08:09:14 2017
@@ -16,7 +16,7 @@ Content-Length: 146
 # Test authority-less URI
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 
 Content-Length: 172
@@ -25,7 +25,7 @@ Content-Length: 172
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 44
 

Added: clang-tools-extra/trunk/test/clangd/completion-priorities.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion-priorities.test?rev=313759&view=auto
==
--- clang-tools-extra/trunk/test/clangd/completion-priorities.test (added)
+++ clang-tools-extra/trunk/test/clangd/completion-priorities.test Wed Sep 20 
08:09:14 2017
@@ -0,0 +1,36 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+
+Content-Length: 127
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 312
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class
 Foo {\npublic:\n  void pub();\n\nprotected:\n  void prot();\n\nprivate:\n  
void priv();\n};\

[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313759: [clangd] Put inacessible items to the end of 
completion list. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38077

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/test/clangd/authority-less-uri.test
  clang-tools-extra/trunk/test/clangd/completion-priorities.test
  clang-tools-extra/trunk/test/clangd/completion-snippet.test
  clang-tools-extra/trunk/test/clangd/completion.test
  clang-tools-extra/trunk/test/clangd/protocol.test

Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -368,13 +368,39 @@
 }
   }
 
-  void FillSortText(const CodeCompletionString &CCS,
-CompletionItem &Item) const {
+  static int GetSortPriority(const CodeCompletionString &CCS) {
+int Score = CCS.getPriority();
 // Fill in the sortText of the CompletionItem.
-assert(CCS.getPriority() < 9 && "Expecting code completion result "
-"priority to have at most 5-digits");
+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;
+}
+
+return Score;
+  }
+
+  static void FillSortText(const CodeCompletionString &CCS,
+   CompletionItem &Item) {
+int Priority = GetSortPriority(CCS);
+// Fill in the sortText of the CompletionItem.
+assert(Priority <= 99 &&
+   "Expecting sort priority to have at most 6-digits");
 llvm::raw_string_ostream(Item.sortText)
-<< llvm::format("%05d%s", CCS.getPriority(), Item.filterText.c_str());
+<< llvm::format("%06d%s", Priority, Item.filterText.c_str());
   }
 
   std::vector &Items;
Index: clang-tools-extra/trunk/test/clangd/completion-priorities.test
===
--- clang-tools-extra/trunk/test/clangd/completion-priorities.test
+++ clang-tools-extra/trunk/test/clangd/completion-priorities.test
@@ -0,0 +1,36 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+
+Content-Length: 127
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 312
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class Foo {\npublic:\n  void pub();\n\nprotected:\n  void prot();\n\nprivate:\n  void priv();\n};\n\nvoid Foo::pub() {\n  this->\n}\n\nvoid test() {\n  Foo f;\n  f.\n}"}}}
+
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":12,"character":8}}}
+# The order of results returned by codeComplete seems to be
+# nondeterministic, so we check regardless of order.
+#
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHECK-DAG: {"label":"pub()","kind":2,"detail":"void","sortText":"34pub","filterText":"pub","insertText":"pub","insertTextFormat":1}
+# CHECK-DAG: {"label":"prot()","kind":2,"detail":"void","sortText":"34prot","filterText":"prot","insertText":"prot","insertTextFormat":1}
+# CHECK-DAG: {"label":"priv()","kind":2,"detail":"void","sortText":"34priv","filterText":"priv","insertText":"priv","insertTextFormat":1}
+# CHECK: ]}
+
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":4}}}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":[
+# CHECK-DAG: {"label":"pub()","kind":2,"detail":"void","sortText":"34pub","filterText":"pub","insertText":"pub","insertTextFormat":1}
+# CHECK-DAG: {"label":"prot()","kind":2,"detail":"void","sortText":"200034prot","filterText":"prot","insertText":"prot","insertTextFormat":1}
+# CHECK-DAG: {"label":"priv()","kind":2,"detail":"void","sortText":"200034priv","filterText":"priv","insertText":"priv","insertTextFormat":1}
+# CHECK: ]}
+
+Content-Length: 58
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown","params":null}
Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/t

[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

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

Thanks for quick review!


https://reviews.llvm.org/D38077



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


[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-20 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

That's precisely what I've written, but, as I'd said before, such tests pass 
already without any modification in `NamespaceEndCommentsFixer`.


https://reviews.llvm.org/D37904



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


r313760 - Put target deduced from executable name at the start of argument list

2017-09-20 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed Sep 20 08:22:27 2017
New Revision: 313760

URL: http://llvm.org/viewvc/llvm-project?rev=313760&view=rev
Log:
Put target deduced from executable name at the start of argument list

When clang is called as 'target-clang', put deduced target option at
the start of argument list so that option '--target=' specified in command
line could override it.

This change fixes PR34671.

Added:
cfe/trunk/test/Driver/target-override.c
Modified:
cfe/trunk/tools/driver/driver.cpp

Added: cfe/trunk/test/Driver/target-override.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/target-override.c?rev=313760&view=auto
==
--- cfe/trunk/test/Driver/target-override.c (added)
+++ cfe/trunk/test/Driver/target-override.c Wed Sep 20 08:22:27 2017
@@ -0,0 +1,16 @@
+// REQUIRES: shell
+// REQUIRES: x86-registered-target
+
+// RUN: mkdir -p %T/testbin
+// RUN: [ ! -s %T/testbin/i386-clang ] || rm %T/testbin/i386-clang
+// RUN: ln -s %clang %T/testbin/i386-clang
+
+// Check if invocation of "foo-clang" adds option "-target foo".
+//
+// RUN: %T/testbin/i386-clang -c -no-canonical-prefixes %s -### 2>&1 | 
FileCheck -check-prefix CHECK-TG1 %s
+// CHECK-TG1: Target: i386
+
+// Check if invocation of "foo-clang -target bar" overrides option "-target 
foo".
+//
+// RUN: %T/testbin/i386-clang -c -no-canonical-prefixes -target x86_64 %s -### 
2>&1 | FileCheck -check-prefix CHECK-TG2 %s
+// CHECK-TG2: Target: x86_64

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=313760&r1=313759&r2=313760&view=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Wed Sep 20 08:22:27 2017
@@ -209,16 +209,23 @@ extern int cc1as_main(ArrayRef &ArgVector,
 std::set &SavedStrings) {
+  // Put target and mode arguments at the start of argument list so that
+  // arguments specified in command line could override them. Avoid putting
+  // them at index 0, as an option like '-cc1' must remain the first.
+  auto InsertionPoint = ArgVector.begin();
+  if (InsertionPoint != ArgVector.end())
+++InsertionPoint;
+
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(ArgVector.end(),
+ArgVector.insert(InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(ArgVector.end(), std::begin(arr), std::end(arr));
+ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
   }
 }
 


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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

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



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:24
+withInitializer(cxxConstructExpr(unless(hasDescendant(implicitCastExpr(
+.bind("cruct-expr")));
+

You pick a more readable name than `cruct-expr`, like `construct-expr`?



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:37
+
+  // We match here because we want one warning (and FixIt) for every ctor.
+  const auto Matches = match(

Wouldn't registering this matcher achieve the same goal instead of needing to 
re-match?



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:59
+  // We want to write in the FixIt the template arguments too.
+  if (const auto *Decl = dyn_cast(
+  Init->getBaseClass()->getAsCXXRecordDecl())) {

Please pick a name other than `Decl`, since that's a type name.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:80
+
+  auto &SM = Result.Context->getSourceManager();
+  SourceLocation StartLoc = Ctor->getLocation();

Please do not use `auto` here.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:95
+  if (Tok.is(tok::l_brace))
+FixItMsg += ": ";
+  FixItMsg += FixItInitList;

Space before the colon?



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:104
+
+  diag(Tok.getLocation(),
+   "calling an inherited constructor other than the copy constructor")

Insteaad of having to re-lex the physical source, can the AST should be 
modified to carry the information you need if it doesn't already have it? For 
instance, you can tell there is not initializer list by looking at 
`CXXConstructorDecl::getNumCtorInitializers()`.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:27
+   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]
+   // CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) 
{};
+};

Don't we want the ctor-inits to be in the same order as the bases are specified?


https://reviews.llvm.org/D33722



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


[libcxx] r313763 - Make libcxx tests work when llvm sources are not present.

2017-09-20 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Sep 20 09:01:50 2017
New Revision: 313763

URL: http://llvm.org/viewvc/llvm-project?rev=313763&view=rev
Log:
Make libcxx tests work when llvm sources are not present.

Despite a strong CMake warning that this is an unsupported
libcxx build configuration, some bots still rely on being
able to check out lit and libcxx independently with no
LLVM sources, and then run lit against libcxx.

A previous patch broke that workflow, so this is making it work
again.  Unfortunately, it breaks generation of the llvm-lit
script for libcxx, but we will just have to live with that until
a solution is found that allows libcxx to make more use of
llvm build pieces.  libcxx can still run tests by using the
ninja check target, or by running lit.py directly against the
build tree or source tree.

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

Modified:
libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake

Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=313763&r1=313762&r2=313763&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Wed Sep 20 09:01:50 
2017
@@ -111,14 +111,17 @@ macro(configure_out_of_tree_llvm)
   # the configurator should write the script into.
   set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
 
-  # Required LIT Configuration 
-  # Define the default arguments to use with 'lit', and an option for the user
-  # to override.
-  set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
-  if (MSVC OR XCODE)
-set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+  if (LLVM_INCLUDE_TESTS)
+# Required LIT Configuration 

+# Define the default arguments to use with 'lit', and an option for the 
user
+# to override.
+set(LLVM_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
+set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
+if (MSVC OR XCODE)
+  set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+endif()
+set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for 
lit")
   endif()
-  set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for 
lit")
 
   # Required doc configuration
   if (LLVM_ENABLE_SPHINX)


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


[PATCH] D37913: [OpenMP] Enable the existing nocudalib flag for OpenMP offloading toolchain.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

One small nit. LGTM otherwise.




Comment at: test/Driver/openmp-offload-gpu.c:133
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target -march=sm_60 -nocudalib -fopenmp-relocatable-target -save-temps 
-no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s

Please split this RUN line further.


Repository:
  rL LLVM

https://reviews.llvm.org/D37913



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


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: test/OpenMP/target_map_codegen.cpp:4845
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+

tra wrote:
> Please break the line to make it easier to read.
Better, but the line still wraps.  I'd split it again somewhere between 
-emit-llvm and -fopenmp.
BTW, you have -fopenmp specified twice. Is that intentional?


Repository:
  rL LLVM

https://reviews.llvm.org/D38040



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


[libclc] r313773 - Add travis CI configuration file

2017-09-20 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Sep 20 10:28:58 2017
New Revision: 313773

URL: http://llvm.org/viewvc/llvm-project?rev=313773&view=rev
Log:
Add travis CI configuration file

Signed-off-by: Jan Vesely 

Added:
libclc/trunk/.travis.yml

Added: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=313773&view=auto
==
--- libclc/trunk/.travis.yml (added)
+++ libclc/trunk/.travis.yml Wed Sep 20 10:28:58 2017
@@ -0,0 +1,42 @@
+language: cpp
+
+sudo: false
+dist: trusty
+
+cache:
+  apt: true
+
+
+matrix:
+  include:
+- env:
+- LABEL="make gcc LLVM-4.0"
+- LLVM_VERSION=4.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-4.0
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-4.0-dev
+- clang-4.0
+- env:
+- LABEL="make gcc LLVM-5.0"
+- LLVM_VERSION=5.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-5.0
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-5.0-dev
+- clang-5.0
+
+script:
+  - $PYTHON ./configure.py --with-llvm-config=$LLVM_CONFIG 
--with-cxx-compiler=$CXX && make -j4


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


[libcxx] r313776 - Fix a bit of UB in __independent_bits_engine. Fixes PR#34663

2017-09-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Sep 20 10:34:11 2017
New Revision: 313776

URL: http://llvm.org/viewvc/llvm-project?rev=313776&view=rev
Log:
Fix a bit of UB in __independent_bits_engine. Fixes PR#34663

Modified:
libcxx/trunk/include/algorithm

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=313776&r1=313775&r2=313776&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Sep 20 10:34:11 2017
@@ -3013,6 +3013,7 @@ template
 _UIntType
 __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
 {
+const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0_; ++__k)
 {
@@ -3021,7 +3022,7 @@ __independent_bits_engine<_Engine, _UInt
 {
 __u = __e_() - _Engine::min();
 } while (__u >= __y0_);
-if (__w0_ < _WDt)
+if (__w0_ < _WRt)
 _Sp <<= __w0_;
 else
 _Sp = 0;
@@ -3034,7 +3035,7 @@ __independent_bits_engine<_Engine, _UInt
 {
 __u = __e_() - _Engine::min();
 } while (__u >= __y1_);
-if (__w0_ < _WDt - 1)
+if (__w0_ < _WRt - 1)
 _Sp <<= __w0_ + 1;
 else
 _Sp = 0;


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


Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-20 Thread Galina Kistanova via cfe-commits
Thanks for looking.
It seems  your commit exposed some other issue. Now, unfortunately, it has
stopped being reproducible.
Thanks for looking anyway.

A good bug will show itself sooner or later.

Thanks

Galina


On Mon, Sep 18, 2017 at 3:49 PM, Douglas Gregor  wrote:

>
> On Sep 18, 2017, at 3:11 PM, Richard Smith  wrote:
>
> On 18 September 2017 at 14:34, Douglas Gregor via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> On Sep 18, 2017, at 1:45 PM, Galina Kistanova 
>> wrote:
>>
>> Hello Douglas,
>>
>> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-ubuntu-fast/builds/17506
>>
>> Are you about to commit the fix, or shall I revert that commit to give
>> you more time?
>>
>>
>> I’m unable to reproduce this issue, and it’s weirdly not hitting the
>> other bots.
>>
>> Is anyone able to reproduce this? The stack trace is… insufficient… to
>> figure out what’s going on.
>>
>
> I think that bot might be the only one with a target whose default C++
> language mode is C++11.
>
>
> Hmm. It’s not the C++ RUN lines that are failing, though; it’s the default
> (Objective-C) one.
>
> - Doug
>
>
>
>> - Doug
>>
>>
>> Thanks
>>
>> Galina
>>
>> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: dgregor
>>> Date: Thu Sep 14 16:38:44 2017
>>> New Revision: 313316
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=313316&view=rev
>>> Log:
>>> [Module map] Introduce a private module re-export directive.
>>>
>>> Introduce a new "export_as" directive for top-level modules, which
>>> indicates that the current module is a "private" module whose symbols
>>> will eventually be exported through the named "public" module. This is
>>> in support of a common pattern in the Darwin ecosystem where a single
>>> public framework is constructed of several private frameworks, with
>>> (currently) header duplication and some support from the linker.
>>>
>>> Addresses rdar://problem/34438420.
>>>
>>> Added:
>>> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
>>> cfe/trunk/test/Modules/export_as_test.c
>>> Modified:
>>> cfe/trunk/docs/Modules.rst
>>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> cfe/trunk/include/clang/Basic/Module.h
>>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>> cfe/trunk/lib/Basic/Module.cpp
>>> cfe/trunk/lib/Lex/ModuleMap.cpp
>>> cfe/trunk/lib/Serialization/ASTReader.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>>
>>> Modified: cfe/trunk/docs/Modules.rst
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.r
>>> st?rev=313316&r1=313315&r2=313316&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/docs/Modules.rst (original)
>>> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
>>> @@ -323,11 +323,12 @@ Module map files use a simplified form o
>>>
>>>  .. parsed-literal::
>>>
>>> -  ``config_macros`` ``export`` ``private``
>>> +  ``config_macros`` ``export_as``  ``private``
>>>``conflict``  ``framework``  ``requires``
>>>``exclude``   ``header`` ``textual``
>>>``explicit``  ``link``   ``umbrella``
>>>``extern````module`` ``use``
>>> +  ``export``
>>>
>>>  Module map file
>>>  ---
>>> @@ -387,6 +388,7 @@ Modules can have a number of different k
>>>  *umbrella-dir-declaration*
>>>  *submodule-declaration*
>>>  *export-declaration*
>>> +*export-as-declaration*
>>>  *use-declaration*
>>>  *link-declaration*
>>>  *config-macros-declaration*
>>> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>>>compatibility for programs that rely on transitive inclusion (i.e.,
>>>all of them).
>>>
>>> +Re-export Declaration
>>> +~~
>>> +An *export-as-declaration* specifies that the current module is a
>>> private
>>> +module whose interface will be re-exported by the named public module.
>>> +
>>> +.. parsed-literal::
>>> +
>>> +  *export-as-declaration*:
>>> +``export_as`` *identifier*
>>> +
>>> +The *export-as-declaration* names the public module that the current
>>> +(private) module will be re-exported through. Only top-level modules
>>> +can be re-exported, and any given module may only be re-exported
>>> +through a single public module.
>>> +
>>> +**Example:** In the following example, the (private) module
>>> +``MyFrameworkCore`` will be re-exported via the public module
>>> +``MyFramework``:
>>> +
>>> +.. parsed-literal::
>>> +
>>> +  module MyFrameworkCore {
>>> +export_as MyFramework
>>> +  }
>>> +
>>>  Use declaration
>>>  ~~~
>>>  A *use-declaration* specifies another module that the current top-level
>>> module
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Ba

r313784 - Remove offset size check in nullptr arithmetic handling

2017-09-20 Thread Andrew Kaylor via cfe-commits
Author: akaylor
Date: Wed Sep 20 11:06:44 2017
New Revision: 313784

URL: http://llvm.org/viewvc/llvm-project?rev=313784&view=rev
Log:
Remove offset size check in nullptr arithmetic handling

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


Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CodeGen/nullptr-arithmetic.c
cfe/trunk/test/Sema/pointer-addition.c
cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=313784&r1=313783&r2=313784&view=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Sep 20 11:06:44 2017
@@ -1837,17 +1837,14 @@ bool BinaryOperator::isNullPointerArithm
 
   // Check that we have one pointer and one integer operand.
   Expr *PExp;
-  Expr *IExp;
   if (LHS->getType()->isPointerType()) {
 if (!RHS->getType()->isIntegerType())
   return false;
 PExp = LHS;
-IExp = RHS;
   } else if (RHS->getType()->isPointerType()) {
 if (!LHS->getType()->isIntegerType())
   return false;
 PExp = RHS;
-IExp = LHS;
   } else {
 return false;
   }
@@ -1862,10 +1859,6 @@ bool BinaryOperator::isNullPointerArithm
   if (!PTy || !PTy->getPointeeType()->isCharType())
 return false;
 
-  // Check that the integer type is pointer-sized.
-  if (Ctx.getTypeSize(IExp->getType()) != Ctx.getTypeSize(PExp->getType()))
-return false;
-
   return true;
 }
 InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc,

Modified: cfe/trunk/test/CodeGen/nullptr-arithmetic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nullptr-arithmetic.c?rev=313784&r1=313783&r2=313784&view=diff
==
--- cfe/trunk/test/CodeGen/nullptr-arithmetic.c (original)
+++ cfe/trunk/test/CodeGen/nullptr-arithmetic.c Wed Sep 20 11:06:44 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -S %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -S %s -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s
+// RUN: %clang_cc1 -S %s -emit-llvm -triple x86_64-unknown-unknown -o - | 
FileCheck %s
 
 #include 
 
@@ -32,3 +34,14 @@ int8_t* test3(intptr_t n) {
 // CHECK-LABEL: test3
 // CHECK: getelementptr
 // CHECK-NOT: inttoptr
+
+// This checks the case where the offset isn't pointer-sized.
+// The front end will implicitly cast the offset to an integer, so we need to
+// make sure that doesn't cause problems on targets where integers and pointers
+// are not the same size.
+int8_t *test4(int8_t b) {
+  return NULLPTRI8 + b;
+}
+// CHECK-LABEL: test4
+// CHECK: inttoptr
+// CHECK-NOT: getelementptr

Modified: cfe/trunk/test/Sema/pointer-addition.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pointer-addition.c?rev=313784&r1=313783&r2=313784&view=diff
==
--- cfe/trunk/test/Sema/pointer-addition.c (original)
+++ cfe/trunk/test/Sema/pointer-addition.c Wed Sep 20 11:06:44 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify 
-pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify 
-pedantic -Wextra -std=c11
 
 #include 
 

Modified: cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp?rev=313784&r1=313783&r2=313784&view=diff
==
--- cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp (original)
+++ cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp Wed Sep 20 11:06:44 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c++11
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify 
-pedantic -Wextra -std=c++11
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify 
-pedantic -Wextra -std=c++11
 
 #include 
 


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


[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for following up, Alberto. I haven't expected such a use case. It is 
possible to achieve the same with `LSA_SIZEOF_SA = sizeof(((len_and_sockaddr 
*)0)->u)` but I don't like it and don't want to force developers using such 
approach.

For solving this problem I think to restrict error only to C++ and to allow 
tags inside enums for C. Alberto, what do you think, will it work for you? And 
from implementation perspective allowing tags in enums for C should be safe 
because things go haywire for C++ while checking access rules and C doesn't 
have access rules.


Repository:
  rL LLVM

https://reviews.llvm.org/D37089



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


Re: [PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Aaron Ballman via cfe-commits
On Wed, Sep 20, 2017 at 2:17 PM, Volodymyr Sapsai via Phabricator via
cfe-commits  wrote:
> vsapsai added a comment.
>
> Thanks for following up, Alberto. I haven't expected such a use case. It is 
> possible to achieve the same with `LSA_SIZEOF_SA = sizeof(((len_and_sockaddr 
> *)0)->u)` but I don't like it and don't want to force developers using such 
> approach.
>
> For solving this problem I think to restrict error only to C++ and to allow 
> tags inside enums for C. Alberto, what do you think, will it work for you? 
> And from implementation perspective allowing tags in enums for C should be 
> safe because things go haywire for C++ while checking access rules and C 
> doesn't have access rules.

That construct is well-formed C code, but isn't in C++ (C++ restricts
the places where you can define a new type compared to what C allows).

~Aaron

>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D37089
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: hiraditya, sanjoy, jholewinski.

https://reviews.llvm.org/D38090

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/shfl-sync.ll

Index: llvm/test/CodeGen/NVPTX/shfl-sync.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/shfl-sync.ll
@@ -0,0 +1,94 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 | FileCheck %s
+
+declare i32 @llvm.nvvm.shfl.sync.down.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.down.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.up.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.up.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.bfly.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.idx.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.idx.f32(float, i32, i32, i32)
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rrr
+define i32 @shfl.sync.rrr(i32 %mask, i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.irr
+define i32 @shfl.sync.irr(i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rri
+define i32 @shfl.sync.rri(i32 %mask, i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 1, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 1)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iri
+define i32 @shfl.sync.iri(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 2, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rir
+define i32 @shfl.sync.rir(i32 %mask, i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iir
+define i32 @shfl.sync.iir(i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rii
+define i32 @shfl.sync.rii(i32 %mask, i32 %a) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, 2, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iii
+define i32 @shfl.sync.iii(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, 3, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 3)
+  ret i32 %val
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -113,6 +113,76 @@
 
 } // isConvergent = 1
 
+multiclass SHFL_SYNC {
+  // The last two parameters to shfl can be regs or imms.  ptxas is smart
+  // enough to inline constant registers, so strictly speaking we don't need to
+  // handle immediates here.  But

Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Alex L via cfe-commits
This commit causes the formatting.test to fail on macOS with an uncaught
exception:

libc++abi.dylib: terminating with uncaught exception of type
std::__1::system_error: mutex lock failed: Invalid argument
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/35642/

I'm still looking into it. It doesn't look like the sanitizers are
reporting anything suspicious. Do you by any chance know what went wrong?
If it will turn out to be a macOS only thing it might make sense to XFAIL
formatting.test until the issue is resolved.

Thanks,
Alex

On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Wed Sep 20 05:58:55 2017
> New Revision: 313754
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313754&view=rev
> Log:
> [clangd] Serialize onDiagnosticsReady callbacks for the same file.
>
> Summary:
> Calls to onDiagnosticsReady were done concurrently before. This sometimes
> led to older versions of diagnostics being reported to the user after
> the newer versions.
>
> Reviewers: klimek, bkramer, krasimir
>
> Reviewed By: klimek
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D38032
>
> Modified:
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.h
> clang-tools-extra/trunk/clangd/DraftStore.h
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.cpp?rev=313754&r1=313753&r2=313754&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55
> 2017
> @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
>  auto Diags = DeferredRebuild.get();
>  if (!Diags)
>return; // A new reparse was requested before this one completed.
> +
> +// We need to serialize access to resulting diagnostics to avoid
> calling
> +// `onDiagnosticsReady` in the wrong order.
> +std::lock_guard DiagsLock(DiagnosticsMutex);
> +DocVersion &LastReportedDiagsVersion = ReportedDiagnosticVersions[
> FileStr];
> +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
> +// implementation diagnostics will not be reported after version
> counters'
> +// overflow. This should not happen in practice, since DocVersion is a
> +// 64-bit unsigned integer.
> +if (Version < LastReportedDiagsVersion)
> +  return;
> +LastReportedDiagsVersion = Version;
> +
>  DiagConsumer.onDiagnosticsReady(FileStr,
>  make_tagged(std::move(*Diags), Tag));
>};
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.h?rev=313754&r1=313753&r2=313754&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55 2017
> @@ -284,6 +284,13 @@ private:
>// ClangdServer
>ClangdScheduler WorkScheduler;
>bool SnippetCompletions;
> +
> +  /// Used to serialize diagnostic callbacks.
> +  /// FIXME(ibiryukov): get rid of an extra map and put all version
> counters
> +  /// into CppFile.
> +  std::mutex DiagnosticsMutex;
> +  /// Maps from a filename to the latest version of reported diagnostics.
> +  llvm::StringMap ReportedDiagnosticVersions;
>  };
>
>  } // namespace clangd
>
> Modified: clang-tools-extra/trunk/clangd/DraftStore.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/DraftStore.h?rev=313754&r1=313753&r2=313754&view=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
> +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
> @@ -13,6 +13,7 @@
>  #include "Path.h"
>  #include "clang/Basic/LLVM.h"
>  #include "llvm/ADT/StringMap.h"
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -20,8 +21,8 @@
>  namespace clang {
>  namespace clangd {
>
> -/// Using 'unsigned' here to avoid undefined behaviour on overflow.
> -typedef unsigned DocVersion;
> +/// Using unsigned int type here to avoid undefined behaviour on overflow.
> +typedef uint64_t DocVersion;
>
>  /// Document draft with a version of this draft.
>  struct VersionedDraft {
>
> Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/unittests/clangd/ClangdTests.cpp?rev=313754&r1=
> 313753&r2=313754&view=diff
> 
> ==
> --- clang-tools-extra/tru

[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-09-20 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 116038.
Nebiroth added a comment.

Added unit test.


https://reviews.llvm.org/D36150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -892,5 +892,83 @@
   }
 }
 
+TEST_F(ClangdVFSTest, CheckSourceHeaderSwitch) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*SnippetCompletions=*/false);
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+  )cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  auto FooH = getVirtualTestFilePath("foo.h");
+  auto invalid = getVirtualTestFilePath("main.cpp");
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = "int a;";   
+  FS.Files[invalid] = "int main() { \n return 0; \n }";
+
+  llvm::Optional pathResult = Server.switchSourceHeader(FooCpp);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), FooH);
+
+  pathResult = Server.switchSourceHeader(FooH);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), FooCpp);
+
+  SourceContents = R"c(
+  #include "foo.HH"
+  int b = a;
+  )c";
+
+  // Test with header file in capital letters and different extension, source file with different extension
+  auto FooC = getVirtualTestFilePath("bar.c");
+  auto FooHH = getVirtualTestFilePath("bar.HH");
+
+  FS.Files[FooC] = SourceContents; 
+  FS.Files[FooHH] = "int a;";
+
+  pathResult = Server.switchSourceHeader(FooC);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), FooHH);
+
+  // Test with both capital letters
+  auto Foo2C = getVirtualTestFilePath("foo2.C");
+  auto Foo2HH = getVirtualTestFilePath("foo2.HH");
+  FS.Files[Foo2C] = SourceContents;
+  FS.Files[Foo2HH] = "int a;"; 
+
+  pathResult = Server.switchSourceHeader(Foo2C);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), Foo2HH);
+
+  // Test with source file as capital letter and .hxx header file
+  auto Foo3C = getVirtualTestFilePath("foo3.C");
+  auto Foo3HXX = getVirtualTestFilePath("foo3.hxx");
+
+  SourceContents = R"c(
+  #include "foo3.hxx"
+  int b = a;
+  )c";
+
+  FS.Files[Foo3C] = SourceContents;
+  FS.Files[Foo3HXX] = "int a;"; 
+
+  pathResult = Server.switchSourceHeader(Foo3C);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), Foo3HXX);
+  
+
+  // Test if asking for a corresponding file that doesn't exist returns an empty string.
+  pathResult = Server.switchSourceHeader(invalid);
+  EXPECT_FALSE(pathResult.hasValue());
+
+} 
+
 } // namespace clangd
 } // namespace clang
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -48,6 +48,8 @@
 JSONOutput &Out) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput &Out) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput &Out) = 0;  
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher, JSONOutput &Out,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,22 @@
   ProtocolCallbacks &Callbacks;
 };
 
+struct SwitchSourceHeaderHandler : Handler {
+  SwitchSourceHeaderHandler(JSONOutput &Output, ProtocolCallbacks &Callbacks)
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentIdentifier::parse(Params);
+if (!TDPP)
+  return;
+
+Callbacks.onSwitchSourceHeader(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks &Callbacks;
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher &Dispatcher,
@@ -240,4 +256,7 @@
   Dispatcher.registerHandler(
   "textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -241,6 +241,10 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged> findDefinitions(PathRef File, Position Pos);
 
+  /// Helper function tha

[PATCH] D37482: run-clang-tidy: Use check_call instead of check_output

2017-09-20 Thread Kevin Funk via Phabricator via cfe-commits
kfunk added a comment.

Bump? This is a trivial one


https://reviews.llvm.org/D37482



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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-09-20 Thread DIVYA SHANMUGHAN via Phabricator via cfe-commits
DIVYA added a comment.

ping


https://reviews.llvm.org/D36423



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


[libcxx] r313789 - Mark the __eval methods on independent_bits_engine (and __independent_bits_engine) as const, since they make no changes to the object. NFC.

2017-09-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Sep 20 11:32:08 2017
New Revision: 313789

URL: http://llvm.org/viewvc/llvm-project?rev=313789&view=rev
Log:
Mark the __eval methods on independent_bits_engine (and 
__independent_bits_engine) as const, since they make no changes to the object. 
NFC.

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/random

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=313789&r1=313788&r2=313789&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Sep 20 11:32:08 2017
@@ -2962,8 +2962,8 @@ public:
 result_type operator()() {return __eval(integral_constant());}
 
 private:
-result_type __eval(false_type);
-result_type __eval(true_type);
+result_type __eval(false_type) const;
+result_type __eval(true_type)  const;
 };
 
 template
@@ -3004,14 +3004,14 @@ __independent_bits_engine<_Engine, _UInt
 template
 inline
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
+__independent_bits_engine<_Engine, _UIntType>::__eval(false_type) const
 {
 return static_cast(__e_() & __mask0_);
 }
 
 template
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
+__independent_bits_engine<_Engine, _UIntType>::__eval(true_type) const
 {
 const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=313789&r1=313788&r2=313789&view=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Wed Sep 20 11:32:08 2017
@@ -3124,8 +3124,8 @@ public:
 
 private:
 _LIBCPP_INLINE_VISIBILITY
-result_type __eval(false_type);
-result_type __eval(true_type);
+result_type __eval(false_type) const;
+result_type __eval(true_type) const;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3151,14 +3151,14 @@ private:
 template
 inline
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) const
 {
 return static_cast(__e_() & __mask0);
 }
 
 template
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type)
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) const
 {
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0; ++__k)


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


[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_intrinsics.h:161
+#endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ 
>=
+   // 300)
+

Nit, better linebreaking in the comment?



Comment at: llvm/include/llvm/IR/IntrinsicsNVVM.td:3744
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, 
llvm_i32_ty],
+[IntrNoMem], "llvm.nvvm.shfl.sync.down.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_down_i32">;

IntrConvergent?


https://reviews.llvm.org/D38090



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


[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-20 Thread Cameron via Phabricator via cfe-commits
cameron314 updated this revision to Diff 116043.
cameron314 added a comment.

Final diff. Test passes!


https://reviews.llvm.org/D37491

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  include/clang/Lex/Lexer.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PrecompiledPreamble.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  unittests/Frontend/PCHPreambleTest.cpp

Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -153,4 +153,48 @@
   ASSERT_EQ(initialCounts[2], GetFileReadCount(Header2));
 }
 
+TEST_F(PCHPreambleTest, ParseWithBom) {
+  std::string Header = "//./header.h";
+  std::string Main = "//./main.cpp";
+  AddFile(Header, "int random() { return 4; }");
+  AddFile(Main,
+"\xef\xbb\xbf"
+"#include \"//./header.h\"\n"
+"int main() { return random() -2; }");
+
+  std::unique_ptr AST(ParseAST(Main));
+  ASSERT_TRUE(AST.get());
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  unsigned HeaderReadCount = GetFileReadCount(Header);
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+  
+  // Check preamble PCH was really reused
+  ASSERT_EQ(HeaderReadCount, GetFileReadCount(Header));
+
+  // Remove BOM
+  RemapFile(Main,
+"#include \"//./header.h\"\n"
+"int main() { return random() -2; }");
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  ASSERT_LE(HeaderReadCount, GetFileReadCount(Header));
+  HeaderReadCount = GetFileReadCount(Header);
+
+  // Add BOM back
+  RemapFile(Main,
+"\xef\xbb\xbf"
+"#include \"//./header.h\"\n"
+"int main() { return random() -2; }");
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  ASSERT_LE(HeaderReadCount, GetFileReadCount(Header));
+}
+
 } // anonymous namespace
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -516,9 +516,9 @@
 // If we've been asked to skip bytes in the main file (e.g., as part of a
 // precompiled preamble), do so now.
 if (SkipMainFilePreamble.first > 0)
-  CurLexer->SkipBytes(SkipMainFilePreamble.first, 
-  SkipMainFilePreamble.second);
-
+  CurLexer->SetByteOffset(SkipMainFilePreamble.first,
+  SkipMainFilePreamble.second);
+
 // Tell the header info that the main file was entered.  If the file is later
 // #imported, it won't be re-entered.
 if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -552,9 +552,9 @@
 
 } // end anonymous namespace
 
-std::pair Lexer::ComputePreamble(StringRef Buffer,
- const LangOptions &LangOpts,
- unsigned MaxLines) {
+PreambleBounds Lexer::ComputePreamble(StringRef Buffer,
+  const LangOptions &LangOpts,
+  unsigned MaxLines) {
   // Create a lexer starting at the beginning of the file. Note that we use a
   // "fake" file source location at offset 1 so that the lexer will track our
   // position within the file.
@@ -688,7 +688,7 @@
   else
 End = TheTok.getLocation();
 
-  return std::make_pair(End.getRawEncoding() - StartLoc.getRawEncoding(),
+  return PreambleBounds(End.getRawEncoding() - FileLoc.getRawEncoding(),
 TheTok.isAtStartOfLine());
 }
 
@@ -1394,9 +1394,9 @@
 // Helper methods for lexing.
 //===--===//
 
-/// \brief Routine that indiscriminately skips bytes in the source file.
-void Lexer::SkipBytes(unsigned Bytes, bool StartOfLine) {
-  BufferPtr += Bytes;
+/// \brief Routine that indiscriminately sets the offset into the source file.
+void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
+  BufferPtr = BufferStart + Offset;
   if (BufferPtr > BufferEnd)
 BufferPtr = BufferEnd;
   // FIXME: What exactly does the StartOfLine bit mean?  There are two
Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -195,8 +195,7 @@
 PreambleBounds clang::ComputePreambleBounds(const LangOptions &LangOpts,
 llvm::MemoryBuffer *Buffer,
 unsigned MaxLines) {
-  auto Pre = Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
-  return PreambleBounds(Pre.first, Pre.second);
+  re

[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 116047.
tra added a comment.

Addressed Justin's comments.


https://reviews.llvm.org/D38090

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/shfl-sync.ll

Index: llvm/test/CodeGen/NVPTX/shfl-sync.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/shfl-sync.ll
@@ -0,0 +1,94 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 | FileCheck %s
+
+declare i32 @llvm.nvvm.shfl.sync.down.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.down.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.up.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.up.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.bfly.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.idx.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.idx.f32(float, i32, i32, i32)
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rrr
+define i32 @shfl.sync.rrr(i32 %mask, i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.irr
+define i32 @shfl.sync.irr(i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rri
+define i32 @shfl.sync.rri(i32 %mask, i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 1, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 1)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iri
+define i32 @shfl.sync.iri(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 2, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rir
+define i32 @shfl.sync.rir(i32 %mask, i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iir
+define i32 @shfl.sync.iir(i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rii
+define i32 @shfl.sync.rii(i32 %mask, i32 %a) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, 2, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iii
+define i32 @shfl.sync.iii(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, 3, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 3)
+  ret i32 %val
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -111,9 +111,81 @@
 defm INT_SHFL_IDX_I32 : SHFL;
 defm INT_SHFL_IDX_F32 : SHFL;
 
+multiclass SHFL_SYNC {
+  // Threadmask and the last two parameters to shfl.sync can be regs or imms.
+  // ptxas is smart enough to inline constant registers, so stri

[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

__interface types are allowed in MSVC to have "property" data members 
(marked with declspec property).  This patch alters Sema to allow property
data members.


https://reviews.llvm.org/D38092

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/ms-interface.cpp

Index: test/SemaCXX/ms-interface.cpp
===
--- test/SemaCXX/ms-interface.cpp
+++ test/SemaCXX/ms-interface.cpp
@@ -77,3 +77,32 @@
 
 class C2 : I6 {
 };
+
+
+// MSVC makes a special case in that an interface is allowed to have a data
+// member if it is a property.
+__interface HasProp {
+  __declspec(property(get = Get, put = Put)) int data;
+  int Get(void);
+  void Put(int);
+};
+
+struct __declspec(uuid("---C000-0046"))
+IUnknown {
+  void foo();
+  __declspec(property(get = Get, put = Put), deprecated) int data;
+  int Get(void);
+  void Put(int);
+};
+
+struct IFaceStruct : IUnknown {
+  __declspec(property(get = Get2, put = Put2), deprecated) int data2;
+  int Get2(void);
+  void Put2(int);
+};
+
+__interface IFaceInheritsStruct : IFaceStruct {};
+static_assert(!__is_interface_class(HasProp), "oops");
+static_assert(!__is_interface_class(IUnknown), "oops");
+static_assert(!__is_interface_class(IFaceStruct), "oops");
+static_assert(!__is_interface_class(IFaceInheritsStruct), "oops");
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -143,7 +143,7 @@
 if (Lambda->capture_begin() == Lambda->capture_end())
   return false;
 
-return S->Diag(Lambda->getLocStart(), 
+return S->Diag(Lambda->getLocStart(),
diag::err_lambda_capture_default_arg);
   }
 }
@@ -276,18 +276,18 @@
   // Okay: add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
-  // We have already instantiated this parameter; provide each of the 
+  // We have already instantiated this parameter; provide each of the
   // instantiations with the uninstantiated default argument.
   UnparsedDefaultArgInstantiationsMap::iterator InstPos
 = UnparsedDefaultArgInstantiations.find(Param);
   if (InstPos != UnparsedDefaultArgInstantiations.end()) {
 for (unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
   InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
-
+
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-  
+
   return false;
 }
 
@@ -524,8 +524,8 @@
   Invalid = false;
 }
   }
-  
-  // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+
+  // FIXME: If we knew where the '=' was, we could easily provide a fix-it
   // hint here. Alternatively, we could walk the type-source information
   // for NewParam to find the last source location in the type... but it
   // isn't worth the effort right now. This is the kind of test case that
@@ -535,7 +535,7 @@
   //   void g(int (*fp)(int) = &f);
   Diag(NewParam->getLocation(), DiagDefaultParamID)
 << NewParam->getDefaultArgRange();
-  
+
   // Look for the function declaration where the default argument was
   // actually written, which may be a declaration prior to Old.
   for (auto Older = PrevForDefaultArgs;
@@ -581,36 +581,36 @@
 //   or a definition for one of the following explicit specializations:
 // - the explicit specialization of a function template;
 // - the explicit specialization of a member function template;
-// - the explicit specialization of a member function of a class 
+// - the explicit specialization of a member function of a class
 //   template where the class template specialization to which the
-//   member function specialization belongs is implicitly 
+//   member function specialization belongs is implicitly
 //   instantiated.
 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
   << (New->getTemplateSpecializationKind() ==TSK_ExplicitSpecialization)
   << New->getDeclName()
   << NewParam->getDefaultArgRange();
   } else if (New->getDeclContext()->isDependentContext()) {
 // C++ [dcl.fct.default]p6 (DR217):
-//   Default arguments for a member function of a class template shall 
-//   be specified on the initial declaration of the member function 
+//   Default arguments for a member function of a class template shall
+//   be specified on the initial declaration of the member function
 //   within the class template.
 //
-// Reading the tea leaves a bit in DR217 and its reference to DR205 
-// leads me to the conclusion that one cannot add default function 
-// arguments for an out-of-line definition of a 

[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:2871
+  InvalidDecl =
+  (DS.getStorageClassSpec() == DeclSpec::SCS_typedef || MSPropertyAttr)
+  ? 0

Note: Clang format did this craziness... I'm open to whatever format you guys 
would prefer.


https://reviews.llvm.org/D38092



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


r313796 - [PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-20 Thread Cameron Desrochers via cfe-commits
Author: cameron314
Date: Wed Sep 20 12:03:37 2017
New Revision: 313796

URL: http://llvm.org/viewvc/llvm-project?rev=313796&view=rev
Log:
[PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating 
BOM presence)

This patch fixes broken preamble-skipping when the preamble region includes a 
byte order mark (BOM). Previously, parsing would fail if preamble PCH 
generation was enabled and a BOM was present.

This also fixes preamble invalidation when a BOM appears or disappears. This 
may seem to be an obscure edge case, but it happens regularly with IDEs that 
pass buffer overrides that never (or always) have a BOM, yet the underlying 
file from the initial parse that generated a PCH might (or might not) have a 
BOM.

I've included a test case for these scenarios.

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

Modified:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp

Modified: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h?rev=313796&r1=313795&r2=313796&view=diff
==
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h (original)
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h Wed Sep 20 12:03:37 
2017
@@ -36,21 +36,6 @@ class CompilerInvocation;
 class DeclGroupRef;
 class PCHContainerOperations;
 
-/// A size of the preamble and a flag required by
-/// PreprocessorOptions::PrecompiledPreambleBytes.
-struct PreambleBounds {
-  PreambleBounds(unsigned Size, bool PreambleEndsAtStartOfLine)
-  : Size(Size), PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
-
-  /// \brief Size of the preamble in bytes.
-  unsigned Size;
-  /// \brief Whether the preamble ends at the start of a new line.
-  ///
-  /// Used to inform the lexer as to whether it's starting at the beginning of
-  /// a line after skipping the preamble.
-  bool PreambleEndsAtStartOfLine;
-};
-
 /// \brief Runs lexer to compute suggested preamble bounds.
 PreambleBounds ComputePreambleBounds(const LangOptions &LangOpts,
  llvm::MemoryBuffer *Buffer,

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=313796&r1=313795&r2=313796&view=diff
==
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Wed Sep 20 12:03:37 2017
@@ -39,6 +39,23 @@ enum ConflictMarkerKind {
   CMK_Perforce
 };
 
+/// Describes the bounds (start, size) of the preamble and a flag required by
+/// PreprocessorOptions::PrecompiledPreambleBytes.
+/// The preamble includes the BOM, if any.
+struct PreambleBounds {
+  PreambleBounds(unsigned Size, bool PreambleEndsAtStartOfLine)
+: Size(Size),
+  PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
+
+  /// \brief Size of the preamble in bytes.
+  unsigned Size;
+  /// \brief Whether the preamble ends at the start of a new line.
+  ///
+  /// Used to inform the lexer as to whether it's starting at the beginning of
+  /// a line after skipping the preamble.
+  bool PreambleEndsAtStartOfLine;
+};
+
 /// Lexer - This provides a simple interface that turns a text buffer into a
 /// stream of tokens.  This provides no support for file reading or buffering,
 /// or buffering/seeking of tokens, only forward lexing is supported.  It 
relies
@@ -443,11 +460,11 @@ public:
   /// to fewer than this number of lines.
   ///
   /// \returns The offset into the file where the preamble ends and the rest
-  /// of the file begins along with a boolean value indicating whether 
+  /// of the file begins along with a boolean value indicating whether
   /// the preamble ends at the beginning of a new line.
-  static std::pair ComputePreamble(StringRef Buffer,
-   const LangOptions &LangOpts,
-   unsigned MaxLines = 0);
+  static PreambleBounds ComputePreamble(StringRef Buffer,
+const LangOptions &LangOpts,
+unsigned MaxLines = 0);
 
   /// \brief Checks that the given token is the first token that occurs after
   /// the given location (this excludes comments and whitespace). Returns the
@@ -618,7 +635,7 @@ private:
   
//======//
   // Other lexer functions.
 
-  void SkipBytes(unsigned Bytes, bool StartOfLine);
+  void SetByteOf

[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-20 Thread Cameron via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313796: [PCH] Fixed preamble breaking with BOM presence (and 
particularly, fluctuating… (authored by cameron314).

Changed prior to commit:
  https://reviews.llvm.org/D37491?vs=116043&id=116049#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37491

Files:
  cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
  cfe/trunk/include/clang/Lex/Lexer.h
  cfe/trunk/include/clang/Lex/PreprocessorOptions.h
  cfe/trunk/lib/Frontend/FrontendActions.cpp
  cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/lib/Lex/Preprocessor.cpp
  cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp

Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -516,9 +516,9 @@
 // If we've been asked to skip bytes in the main file (e.g., as part of a
 // precompiled preamble), do so now.
 if (SkipMainFilePreamble.first > 0)
-  CurLexer->SkipBytes(SkipMainFilePreamble.first, 
-  SkipMainFilePreamble.second);
-
+  CurLexer->SetByteOffset(SkipMainFilePreamble.first,
+  SkipMainFilePreamble.second);
+
 // Tell the header info that the main file was entered.  If the file is later
 // #imported, it won't be re-entered.
 if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -552,9 +552,9 @@
 
 } // end anonymous namespace
 
-std::pair Lexer::ComputePreamble(StringRef Buffer,
- const LangOptions &LangOpts,
- unsigned MaxLines) {
+PreambleBounds Lexer::ComputePreamble(StringRef Buffer,
+  const LangOptions &LangOpts,
+  unsigned MaxLines) {
   // Create a lexer starting at the beginning of the file. Note that we use a
   // "fake" file source location at offset 1 so that the lexer will track our
   // position within the file.
@@ -688,7 +688,7 @@
   else
 End = TheTok.getLocation();
 
-  return std::make_pair(End.getRawEncoding() - StartLoc.getRawEncoding(),
+  return PreambleBounds(End.getRawEncoding() - FileLoc.getRawEncoding(),
 TheTok.isAtStartOfLine());
 }
 
@@ -1394,9 +1394,9 @@
 // Helper methods for lexing.
 //===--===//
 
-/// \brief Routine that indiscriminately skips bytes in the source file.
-void Lexer::SkipBytes(unsigned Bytes, bool StartOfLine) {
-  BufferPtr += Bytes;
+/// \brief Routine that indiscriminately sets the offset into the source file.
+void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
+  BufferPtr = BufferStart + Offset;
   if (BufferPtr > BufferEnd)
 BufferPtr = BufferEnd;
   // FIXME: What exactly does the StartOfLine bit mean?  There are two
Index: cfe/trunk/lib/Frontend/FrontendActions.cpp
===
--- cfe/trunk/lib/Frontend/FrontendActions.cpp
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp
@@ -591,7 +591,7 @@
   auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
   if (Buffer) {
 unsigned Preamble =
-Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).first;
+Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size;
 llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
   }
 }
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -195,8 +195,7 @@
 PreambleBounds clang::ComputePreambleBounds(const LangOptions &LangOpts,
 llvm::MemoryBuffer *Buffer,
 unsigned MaxLines) {
-  auto Pre = Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
-  return PreambleBounds(Pre.first, Pre.second);
+  return Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
 }
 
 llvm::ErrorOr PrecompiledPreamble::Build(
Index: cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
===
--- cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
+++ cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
@@ -153,4 +153,48 @@
   ASSERT_EQ(initialCounts[2], GetFileReadCount(Header2));
 }
 
+TEST_F(PCHPreambleTest, ParseWithBom) {
+  std::string Header = "//./header.h";
+  std::string Main = "//./main.cpp";
+  AddFile(Header, "int random() { return 4; }");
+  AddFile(Main,
+"\xef\xbb

[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:957
 
-return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+return Builder.CreatePointerBitCastOrAddrSpaceCast(
+Addr, ConvertType(E->getType()));

Anastasia wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > Better assert that only CK_AddressSpaceConversion allows different addr 
> > > spaces in target type.
> > It seems for consistency then we would have to assert for both different 
> > ASes in non-`addrspacecast` case and equivalent ASes in the other case.
> > 
> > As condition becomes complicated then, I could as well split into either 
> > creating `bitcast` or `addrspacecast` explicitly at a cost of one simple 
> > check in the return statement but that would be in release build too. 
> Sam, do you prefer an assert that will check both things or a runtime check 
> that would make sure to build the right IR node here?
splitting into bitcast and addrspacecast seems better.


https://reviews.llvm.org/D37804



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


[PATCH] D38075: Fix PR34668 - P0704R1 implementation is too permissive

2017-09-20 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

Thanks! That was an oversight on my part, sorry.




Comment at: lib/Sema/SemaExprCXX.cpp:5185
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst() && !Proto->isVolatile())

I think you should update the comment to something like "also 'const', but not 
if they're 'volatile'."


https://reviews.llvm.org/D38075



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


Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via cfe-commits
I think I know what's wrong. I've already seen those failures. std::mutex
gets destroyed before threads waiting on it are joined.
Will submit a fix shortly.

On Wed, Sep 20, 2017 at 8:22 PM, Alex L  wrote:

> This commit causes the formatting.test to fail on macOS with an uncaught
> exception:
>
> libc++abi.dylib: terminating with uncaught exception of type
> std::__1::system_error: mutex lock failed: Invalid argument
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/35642/
>
> I'm still looking into it. It doesn't look like the sanitizers are
> reporting anything suspicious. Do you by any chance know what went wrong?
> If it will turn out to be a macOS only thing it might make sense to XFAIL
> formatting.test until the issue is resolved.
>
> Thanks,
> Alex
>
> On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Wed Sep 20 05:58:55 2017
>> New Revision: 313754
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=313754&view=rev
>> Log:
>> [clangd] Serialize onDiagnosticsReady callbacks for the same file.
>>
>> Summary:
>> Calls to onDiagnosticsReady were done concurrently before. This sometimes
>> led to older versions of diagnostics being reported to the user after
>> the newer versions.
>>
>> Reviewers: klimek, bkramer, krasimir
>>
>> Reviewed By: klimek
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D38032
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> clang-tools-extra/trunk/clangd/ClangdServer.h
>> clang-tools-extra/trunk/clangd/DraftStore.h
>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.cpp?rev=313754&r1=313753&r2=313754&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55
>> 2017
>> @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
>>  auto Diags = DeferredRebuild.get();
>>  if (!Diags)
>>return; // A new reparse was requested before this one completed.
>> +
>> +// We need to serialize access to resulting diagnostics to avoid
>> calling
>> +// `onDiagnosticsReady` in the wrong order.
>> +std::lock_guard DiagsLock(DiagnosticsMutex);
>> +DocVersion &LastReportedDiagsVersion = ReportedDiagnosticVersions[Fil
>> eStr];
>> +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
>> +// implementation diagnostics will not be reported after version
>> counters'
>> +// overflow. This should not happen in practice, since DocVersion is
>> a
>> +// 64-bit unsigned integer.
>> +if (Version < LastReportedDiagsVersion)
>> +  return;
>> +LastReportedDiagsVersion = Version;
>> +
>>  DiagConsumer.onDiagnosticsReady(FileStr,
>>  make_tagged(std::move(*Diags),
>> Tag));
>>};
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.h?rev=313754&r1=313753&r2=313754&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55
>> 2017
>> @@ -284,6 +284,13 @@ private:
>>// ClangdServer
>>ClangdScheduler WorkScheduler;
>>bool SnippetCompletions;
>> +
>> +  /// Used to serialize diagnostic callbacks.
>> +  /// FIXME(ibiryukov): get rid of an extra map and put all version
>> counters
>> +  /// into CppFile.
>> +  std::mutex DiagnosticsMutex;
>> +  /// Maps from a filename to the latest version of reported diagnostics.
>> +  llvm::StringMap ReportedDiagnosticVersions;
>>  };
>>
>>  } // namespace clangd
>>
>> Modified: clang-tools-extra/trunk/clangd/DraftStore.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/DraftStore.h?rev=313754&r1=313753&r2=313754&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
>> +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
>> @@ -13,6 +13,7 @@
>>  #include "Path.h"
>>  #include "clang/Basic/LLVM.h"
>>  #include "llvm/ADT/StringMap.h"
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -20,8 +21,8 @@
>>  namespace clang {
>>  namespace clangd {
>>
>> -/// Using 'unsigned' here to avoid undefined behaviour on overflow.
>> -typedef unsigned DocVersion;
>> +/// Using unsigned int type here to avoid undefined behaviour on
>> overflow.
>> +typedef uint64_t DocVersion;
>>
>>  /// Document draft with a version of this draft.

[clang-tools-extra] r313801 - [clangd] Fixed crash on MacOS.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 12:32:06 2017
New Revision: 313801

URL: http://llvm.org/viewvc/llvm-project?rev=313801&view=rev
Log:
[clangd] Fixed crash on MacOS.

Caused by invalid order of members in ClangdServer.
DiagnosticsMutex was used after destruction.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=313801&r1=313800&r2=313801&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 12:32:06 2017
@@ -151,7 +151,7 @@ ClangdServer::ClangdServer(GlobalCompila
   FSProvider(FSProvider),
   ResourceDir(ResourceDir ? ResourceDir->str() : getStandardResourceDir()),
   PCHs(std::make_shared()),
-  WorkScheduler(AsyncThreadsCount), SnippetCompletions(SnippetCompletions) 
{
+  SnippetCompletions(SnippetCompletions), WorkScheduler(AsyncThreadsCount) 
{
 }
 
 std::future ClangdServer::addDocument(PathRef File, StringRef Contents) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=313801&r1=313800&r2=313801&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 12:32:06 2017
@@ -279,18 +279,17 @@ private:
   CppFileCollection Units;
   std::string ResourceDir;
   std::shared_ptr PCHs;
-  // WorkScheduler has to be the last member, because its destructor has to be
-  // called before all other members to stop the worker thread that references
-  // ClangdServer
-  ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
-
   /// Used to serialize diagnostic callbacks.
   /// FIXME(ibiryukov): get rid of an extra map and put all version counters
   /// into CppFile.
   std::mutex DiagnosticsMutex;
   /// Maps from a filename to the latest version of reported diagnostics.
   llvm::StringMap ReportedDiagnosticVersions;
+  // WorkScheduler has to be the last member, because its destructor has to be
+  // called before all other members to stop the worker thread that references
+  // ClangdServer
+  ClangdScheduler WorkScheduler;
 };
 
 } // namespace clangd


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


[PATCH] D38083: [clangd] Skip informative qualifier chunks.

2017-09-20 Thread Raoul Wols via Phabricator via cfe-commits
rwols added inline comments.



Comment at: test/clangd/completion-qualifiers.test:12
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHEKC-DAG: {"label":"foo() 
const","kind":2,"detail":"int","sortText":"00035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHEKC-DAG: {"label":"bar() 
const","kind":2,"detail":"int","sortText":"00037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}

CHECK-DAG typo?


https://reviews.llvm.org/D38083



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


Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Fixed by r313801.
Sorry for all the trouble.

On Wed, Sep 20, 2017 at 9:22 PM, Ilya Biryukov  wrote:

> I think I know what's wrong. I've already seen those failures. std::mutex
> gets destroyed before threads waiting on it are joined.
> Will submit a fix shortly.
>
> On Wed, Sep 20, 2017 at 8:22 PM, Alex L  wrote:
>
>> This commit causes the formatting.test to fail on macOS with an uncaught
>> exception:
>>
>> libc++abi.dylib: terminating with uncaught exception of type
>> std::__1::system_error: mutex lock failed: Invalid argument
>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/35642/
>>
>> I'm still looking into it. It doesn't look like the sanitizers are
>> reporting anything suspicious. Do you by any chance know what went wrong?
>> If it will turn out to be a macOS only thing it might make sense to XFAIL
>> formatting.test until the issue is resolved.
>>
>> Thanks,
>> Alex
>>
>> On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ibiryukov
>>> Date: Wed Sep 20 05:58:55 2017
>>> New Revision: 313754
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=313754&view=rev
>>> Log:
>>> [clangd] Serialize onDiagnosticsReady callbacks for the same file.
>>>
>>> Summary:
>>> Calls to onDiagnosticsReady were done concurrently before. This sometimes
>>> led to older versions of diagnostics being reported to the user after
>>> the newer versions.
>>>
>>> Reviewers: klimek, bkramer, krasimir
>>>
>>> Reviewed By: klimek
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D38032
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> clang-tools-extra/trunk/clangd/ClangdServer.h
>>> clang-tools-extra/trunk/clangd/DraftStore.h
>>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>>
>>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/ClangdServer.cpp?rev=313754&r1=313753&r2=313754&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55
>>> 2017
>>> @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
>>>  auto Diags = DeferredRebuild.get();
>>>  if (!Diags)
>>>return; // A new reparse was requested before this one completed.
>>> +
>>> +// We need to serialize access to resulting diagnostics to avoid
>>> calling
>>> +// `onDiagnosticsReady` in the wrong order.
>>> +std::lock_guard DiagsLock(DiagnosticsMutex);
>>> +DocVersion &LastReportedDiagsVersion =
>>> ReportedDiagnosticVersions[FileStr];
>>> +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
>>> +// implementation diagnostics will not be reported after version
>>> counters'
>>> +// overflow. This should not happen in practice, since DocVersion
>>> is a
>>> +// 64-bit unsigned integer.
>>> +if (Version < LastReportedDiagsVersion)
>>> +  return;
>>> +LastReportedDiagsVersion = Version;
>>> +
>>>  DiagConsumer.onDiagnosticsReady(FileStr,
>>>  make_tagged(std::move(*Diags),
>>> Tag));
>>>};
>>>
>>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/ClangdServer.h?rev=313754&r1=313753&r2=313754&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55
>>> 2017
>>> @@ -284,6 +284,13 @@ private:
>>>// ClangdServer
>>>ClangdScheduler WorkScheduler;
>>>bool SnippetCompletions;
>>> +
>>> +  /// Used to serialize diagnostic callbacks.
>>> +  /// FIXME(ibiryukov): get rid of an extra map and put all version
>>> counters
>>> +  /// into CppFile.
>>> +  std::mutex DiagnosticsMutex;
>>> +  /// Maps from a filename to the latest version of reported
>>> diagnostics.
>>> +  llvm::StringMap ReportedDiagnosticVersions;
>>>  };
>>>
>>>  } // namespace clangd
>>>
>>> Modified: clang-tools-extra/trunk/clangd/DraftStore.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/DraftStore.h?rev=313754&r1=313753&r2=313754&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
>>> +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
>>> @@ -13,6 +13,7 @@
>>>  #include "Path.h"
>>>  #include "clang/Basic/LLVM.h"
>>>  #include "llvm/ADT/StringMap.h"
>>> +#include 
>>>  #include 
>>>  #include 
>>>  #include 
>>> @@ -20,8 +21,8 @@
>>>  namespace clang {
>>>  namespace clangd {
>>>
>>> -/// Using 'unsigned' here to avoi

r313802 - Fixed unused variable warning introduced in r313796 causing build failure

2017-09-20 Thread Cameron Desrochers via cfe-commits
Author: cameron314
Date: Wed Sep 20 12:37:37 2017
New Revision: 313802

URL: http://llvm.org/viewvc/llvm-project?rev=313802&view=rev
Log:
Fixed unused variable warning introduced in r313796 causing build failure

Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=313802&r1=313801&r2=313802&view=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Sep 20 12:37:37 2017
@@ -564,9 +564,6 @@ PreambleBounds Lexer::ComputePreamble(St
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
 
-  // StartLoc will differ from FileLoc if there is a BOM that was skipped.
-  SourceLocation StartLoc = TheLexer.getSourceLocation();
-
   bool InPreprocessorDirective = false;
   Token TheTok;
   SourceLocation ActiveCommentLoc;


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


[libcxx] r313803 - Revert 313789 because gcc doesn't like it

2017-09-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Sep 20 12:38:43 2017
New Revision: 313803

URL: http://llvm.org/viewvc/llvm-project?rev=313803&view=rev
Log:
Revert 313789 because gcc doesn't like it

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/random

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=313803&r1=313802&r2=313803&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Sep 20 12:38:43 2017
@@ -2962,8 +2962,8 @@ public:
 result_type operator()() {return __eval(integral_constant());}
 
 private:
-result_type __eval(false_type) const;
-result_type __eval(true_type)  const;
+result_type __eval(false_type);
+result_type __eval(true_type);
 };
 
 template
@@ -3004,14 +3004,14 @@ __independent_bits_engine<_Engine, _UInt
 template
 inline
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(false_type) const
+__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
 {
 return static_cast(__e_() & __mask0_);
 }
 
 template
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(true_type) const
+__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
 {
 const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=313803&r1=313802&r2=313803&view=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Wed Sep 20 12:38:43 2017
@@ -3124,8 +3124,8 @@ public:
 
 private:
 _LIBCPP_INLINE_VISIBILITY
-result_type __eval(false_type) const;
-result_type __eval(true_type) const;
+result_type __eval(false_type);
+result_type __eval(true_type);
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3151,14 +3151,14 @@ private:
 template
 inline
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) const
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
 {
 return static_cast(__e_() & __mask0);
 }
 
 template
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) const
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type)
 {
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0; ++__k)


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


[PATCH] D37881: [Sema] Prevent InstantiateClass from checking unrelated exception specs.

2017-09-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 116056.
vsapsai added a comment.

- Rename SavePendingDelayedStateRAII to SavePendingParsedClassStateRAII.


https://reviews.llvm.org/D37881

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/crash-unparsed-exception.cpp
  clang/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: clang/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- clang/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ clang/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -87,3 +87,30 @@
 A<1> m_target;
   };
 }
+
+// rdar://problem/34167492
+// Template B is instantiated during checking if defaulted A copy constructor
+// is constexpr. For this we check if S copy constructor is constexpr. And
+// for this we check S constructor template with default argument that mentions
+// template B. In  turn, template instantiation triggers checking defaulted
+// members exception spec. The problem is that it checks defaulted members not
+// for instantiated class only, but all defaulted members so far. In this case
+// we try to check exception spec for A default constructor which requires
+// initializer for the field _a. But initializers are added after constexpr
+// check so we reject the code because cannot find _a initializer.
+namespace rdar34167492 {
+  template  struct B { using type = bool; };
+
+  template  struct S {
+S() noexcept;
+
+template ::type = true>
+S(const S&) noexcept;
+  };
+
+  class A {
+A() noexcept = default;
+A(const A&) noexcept = default;
+S _a{};
+  };
+}
Index: clang/test/SemaTemplate/crash-unparsed-exception.cpp
===
--- clang/test/SemaTemplate/crash-unparsed-exception.cpp
+++ clang/test/SemaTemplate/crash-unparsed-exception.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -fcxx-exceptions -fexceptions %s
+// expected-no-diagnostics
 
 struct A {
   virtual ~A();
@@ -11,7 +12,7 @@
 ~D() throw();
   };
   struct E : A {
-D d; //expected-error{{exception specification is not available until end of class definition}}
+D d;
   };
-  B b; //expected-note{{in instantiation of template class 'B' requested here}}
+  B b;
 };
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2026,12 +2026,11 @@
   bool MergeWithParentScope = !Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
-  // All dllexported classes created during instantiation should be fully
-  // emitted after instantiation completes. We may not be ready to emit any
-  // delayed classes already on the stack, so save them away and put them back
-  // later.
-  decltype(DelayedDllExportClasses) ExportedClasses;
-  std::swap(ExportedClasses, DelayedDllExportClasses);
+  // Some class state isn't processed immediately but delayed till class
+  // instantiation completes. We may not be ready to handle any delayed state
+  // already on the stack as it might correspond to a different class, so save
+  // it now and put it back later.
+  SavePendingParsedClassStateRAII SavedPendingParsedClassState(*this);
 
   // Pull attributes from the pattern onto the instantiation.
   InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
@@ -2118,9 +2117,6 @@
   // default arg exprs for default constructors if necessary now.
   ActOnFinishCXXNonNestedClass(Instantiation);
 
-  // Put back the delayed exported classes that we moved out of the way.
-  std::swap(ExportedClasses, DelayedDllExportClasses);
-
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
   for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10490,6 +10490,36 @@
   SmallVector DelayedDllExportClasses;
 
 private:
+  class SavePendingParsedClassStateRAII {
+  public:
+SavePendingParsedClassStateRAII(Sema &S) : S(S) { swapSavedState(); }
+
+~SavePendingParsedClassStateRAII() {
+  assert(S.DelayedExceptionSpecChecks.empty() &&
+ "there shouldn't be any pending delayed exception spec checks");
+  assert(S.DelayedDefaultedMemberExceptionSpecs.empty() &&
+ "there shouldn't be any pending delayed defaulted member "
+ "exception specs");
+  assert(S.DelayedDllExportClasses.empty() &&
+ "there shouldn't be any pending delayed DLL export classes");
+  swapSavedState();
+}
+
+  private:
+Sema &S;
+decltype(DelayedExceptionSpecChecks) SavedExceptionSpecChecks;
+decltype(Delay

[PATCH] D38075: Fix PR34668 - P0704R1 implementation is too permissive

2017-09-20 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:5185
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst() && !Proto->isVolatile())

Rakete wrote:
> I think you should update the comment to something like "also 'const', but 
> not if they're 'volatile'."
"if their cv-qualifier-seq is (exactly) 'const'", maybe?


https://reviews.llvm.org/D38075



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


r313805 - [OPENMP] Support for re-declarations when checking captured variables.

2017-09-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Sep 20 13:11:31 2017
New Revision: 313805

URL: http://llvm.org/viewvc/llvm-project?rev=313805&view=rev
Log:
[OPENMP] Support for re-declarations when checking captured variables.

Need to check for variables re-declarations when checking that the
variable was already captured in the captured region.

Modified:
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=313805&r1=313804&r2=313805&view=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Wed Sep 20 13:11:31 2017
@@ -1114,11 +1114,7 @@ bool CapturedStmt::capturesVariable(cons
   for (const auto &I : captures()) {
 if (!I.capturesVariable() && !I.capturesVariableByCopy())
   continue;
-
-// This does not handle variable redeclarations. This should be
-// extended to capture variables with redeclarations, for example
-// a thread-private variable in OpenMP.
-if (I.getCapturedVar() == Var)
+if (I.getCapturedVar()->getCanonicalDecl() == Var->getCanonicalDecl())
   return true;
   }
 

Modified: cfe/trunk/test/OpenMP/target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen.cpp?rev=313805&r1=313804&r2=313805&view=diff
==
--- cfe/trunk/test/OpenMP/target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen.cpp Wed Sep 20 13:11:31 2017
@@ -79,6 +79,9 @@ struct TT{
   ty Y;
 };
 
+int global;
+extern int global;
+
 // CHECK: define {{.*}}[[FOO:@.+]](
 int foo(int n) {
   int a = 0;
@@ -109,7 +112,7 @@ int foo(int n) {
   // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}})
   #pragma omp target if(0)
   {
-a += 1;
+global += 1;
   }
 
   // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, 
i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds 
([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr 
inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))


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


[PATCH] D35796: [analyzer] Delete with non-virtual destructor check

2017-09-20 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 116060.
rnkovacs added a comment.

- Accidentally left-in comment removed.
- Checker file clang-formatted.


https://reviews.llvm.org/D35796

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  test/Analysis/DeleteWithNonVirtualDtor.cpp

Index: test/Analysis/DeleteWithNonVirtualDtor.cpp
===
--- /dev/null
+++ test/Analysis/DeleteWithNonVirtualDtor.cpp
@@ -0,0 +1,187 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.DeleteWithNonVirtualDtor -std=c++11 -verify -analyzer-output=text %s
+
+struct Virtual {
+  virtual ~Virtual() {}
+};
+
+struct VDerived : public Virtual {};
+
+struct NonVirtual {
+  ~NonVirtual() {}
+};
+
+struct NVDerived : public NonVirtual {};
+struct NVDoubleDerived : public NVDerived {};
+
+struct Base {
+  virtual void destroy() = 0;
+};
+
+class PrivateDtor final : public Base {
+public:
+  void destroy() { delete this; }
+private:
+  ~PrivateDtor() {}
+};
+
+struct ImplicitNV {
+  virtual void f();
+};
+
+struct ImplicitNVDerived : public ImplicitNV {};
+
+NVDerived *get();
+
+NonVirtual *create() {
+  NonVirtual *x = new NVDerived(); // expected-note{{Conversion from derived to base happened here}}
+  return x;
+}
+
+void sink(NonVirtual *x) {
+  delete x; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void sinkCast(NonVirtual *y) {
+  delete reinterpret_cast(y);
+}
+
+void sinkParamCast(NVDerived *z) {
+  delete z;
+}
+
+void singleDerived() {
+  NonVirtual *sd;
+  sd = new NVDerived(); // expected-note{{Conversion from derived to base happened here}}
+  delete sd; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void singleDerivedArr() {
+  NonVirtual *sda = new NVDerived[5]; // expected-note{{Conversion from derived to base happened here}}
+  delete[] sda; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void doubleDerived() {
+  NonVirtual *dd = new NVDoubleDerived(); // expected-note{{Conversion from derived to base happened here}}
+  delete (dd); // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void assignThroughFunction() {
+  NonVirtual *atf = get(); // expected-note{{Conversion from derived to base happened here}}
+  delete atf; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void assignThroughFunction2() {
+  NonVirtual *atf2;
+  atf2 = get(); // expected-note{{Conversion from derived to base happened here}}
+  delete atf2; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void createThroughFunction() {
+  NonVirtual *ctf = create(); // expected-note{{Calling 'create'}}
+  // expected-note@-1{{Returning from 'create'}}
+  delete ctf; // expected-warning {{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void deleteThroughFunction() {
+  NonVirtual *dtf = new NVDerived(); // expected-note{{Conversion from derived to base happened here}}
+  sink(dtf); // expected-note{{Calling 'sink'}}
+}
+
+void singleCastCStyle() {
+  NVDerived *sccs = new NVDerived();
+  NonVirtual *sccs2 = (NonVirtual*)sccs; // expected-note{{Conversion from derived to base happened here}}
+  delete sccs2; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void doubleCastCStyle() {
+  NonVirtual *dccs = new NVDerived();
+  NVDerived *dccs2 = (NVDerived*)dccs;
+  dccs = (NonVirtual*)dccs2; // expected-note{{Conversion from derived to base happened here}}
+  delete dccs; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void singleCast() {
+  NVDerived *sc = new NVDerived();
+  NonVirtual *sc2 = reinterpret_cast(sc); // expected-note{{Conversion from derived to base happened here}}
+  delete sc2; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphi

Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Alex L via cfe-commits
Perfect, thanks!

On 20 September 2017 at 20:33, Ilya Biryukov  wrote:

> Fixed by r313801.
> Sorry for all the trouble.
>
> On Wed, Sep 20, 2017 at 9:22 PM, Ilya Biryukov 
> wrote:
>
>> I think I know what's wrong. I've already seen those failures. std::mutex
>> gets destroyed before threads waiting on it are joined.
>> Will submit a fix shortly.
>>
>> On Wed, Sep 20, 2017 at 8:22 PM, Alex L  wrote:
>>
>>> This commit causes the formatting.test to fail on macOS with an uncaught
>>> exception:
>>>
>>> libc++abi.dylib: terminating with uncaught exception of type
>>> std::__1::system_error: mutex lock failed: Invalid argument
>>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA
>>> _check/35642/
>>>
>>> I'm still looking into it. It doesn't look like the sanitizers are
>>> reporting anything suspicious. Do you by any chance know what went wrong?
>>> If it will turn out to be a macOS only thing it might make sense to
>>> XFAIL formatting.test until the issue is resolved.
>>>
>>> Thanks,
>>> Alex
>>>
>>> On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ibiryukov
 Date: Wed Sep 20 05:58:55 2017
 New Revision: 313754

 URL: http://llvm.org/viewvc/llvm-project?rev=313754&view=rev
 Log:
 [clangd] Serialize onDiagnosticsReady callbacks for the same file.

 Summary:
 Calls to onDiagnosticsReady were done concurrently before. This
 sometimes
 led to older versions of diagnostics being reported to the user after
 the newer versions.

 Reviewers: klimek, bkramer, krasimir

 Reviewed By: klimek

 Subscribers: cfe-commits

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

 Modified:
 clang-tools-extra/trunk/clangd/ClangdServer.cpp
 clang-tools-extra/trunk/clangd/ClangdServer.h
 clang-tools-extra/trunk/clangd/DraftStore.h
 clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

 Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clangd/ClangdServer.cpp?rev=313754&r1=313753&r2=313754&view=diff
 
 ==
 --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
 +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20
 05:58:55 2017
 @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
  auto Diags = DeferredRebuild.get();
  if (!Diags)
return; // A new reparse was requested before this one completed.
 +
 +// We need to serialize access to resulting diagnostics to avoid
 calling
 +// `onDiagnosticsReady` in the wrong order.
 +std::lock_guard DiagsLock(DiagnosticsMutex);
 +DocVersion &LastReportedDiagsVersion =
 ReportedDiagnosticVersions[FileStr];
 +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
 +// implementation diagnostics will not be reported after version
 counters'
 +// overflow. This should not happen in practice, since DocVersion
 is a
 +// 64-bit unsigned integer.
 +if (Version < LastReportedDiagsVersion)
 +  return;
 +LastReportedDiagsVersion = Version;
 +
  DiagConsumer.onDiagnosticsReady(FileStr,
  make_tagged(std::move(*Diags),
 Tag));
};

 Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clangd/ClangdServer.h?rev=313754&r1=313753&r2=313754&view=diff
 
 ==
 --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
 +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55
 2017
 @@ -284,6 +284,13 @@ private:
// ClangdServer
ClangdScheduler WorkScheduler;
bool SnippetCompletions;
 +
 +  /// Used to serialize diagnostic callbacks.
 +  /// FIXME(ibiryukov): get rid of an extra map and put all version
 counters
 +  /// into CppFile.
 +  std::mutex DiagnosticsMutex;
 +  /// Maps from a filename to the latest version of reported
 diagnostics.
 +  llvm::StringMap ReportedDiagnosticVersions;
  };

  } // namespace clangd

 Modified: clang-tools-extra/trunk/clangd/DraftStore.h
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clangd/DraftStore.h?rev=313754&r1=313753&r2=313754&view=diff
 
 ==
 --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
 +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55
 2017
 @@ -13,6 +13,7 @@
  #include "Path.h"
  #include "clang/Basic

[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Alberto Magni via Phabricator via cfe-commits
alberto_magni added a comment.

Yes, restricting the error to C++ would work. Many thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D37089



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


[libclc] r313810 - Implement cl_khr_int64_base_atomics builtins

2017-09-20 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Sep 20 13:42:14 2017
New Revision: 313810

URL: http://llvm.org/viewvc/llvm-project?rev=313810&view=rev
Log:
Implement cl_khr_int64_base_atomics builtins

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Added:
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h?rev=313810&view=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h Wed 
Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_add(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile global unsigned long 
*p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_add(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile local unsigned long 
*p, unsigned long val);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h?rev=313810&view=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h 
Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp, 
long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile global unsigned 
long *p, unsigned long cmp, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp, 
long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile local unsigned 
long *p, unsigned long cmp, unsigned long val);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h?rev=313810&view=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h Wed 
Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile global long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile global unsigned long 
*p);
+_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile local long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile local unsigned long 
*p);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h?rev=313810&view=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h Wed 
Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile global long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile global unsigned long 
*p);
+_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile local long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile local unsigned long 
*p);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h?rev=313810&view=auto
==
--- libclc/trunk/generic/incl

[libclc] r313811 - Implement cl_khr_int64_extended_atomics builtins

2017-09-20 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Sep 20 13:42:19 2017
New Revision: 313811

URL: http://llvm.org/viewvc/llvm-project?rev=313811&view=rev
Log:
Implement cl_khr_int64_extended_atomics builtins

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Added:
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl
Modified:
libclc/trunk/amdgcn/lib/SOURCES
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/amdgcn/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=313811&r1=313810&r2=313811&view=diff
==
--- libclc/trunk/amdgcn/lib/SOURCES (original)
+++ libclc/trunk/amdgcn/lib/SOURCES Wed Sep 20 13:42:19 2017
@@ -1,3 +1,4 @@
+cl_khr_int64_extended_atomics/minmax_helpers.ll
 math/ldexp.cl
 mem_fence/fence.cl
 mem_fence/waitcnt.ll

Added: libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll?rev=313811&view=auto
==
--- libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll 
(added)
+++ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll Wed 
Sep 20 13:42:19 2017
@@ -0,0 +1,47 @@
+define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umin_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_min_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umin_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_max_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umax_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_max_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umax_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}

Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h?rev=313811&view=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h 
Wed Sep 20 13:42:19 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_and(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_and(volatile global unsigned long 
*p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_and(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_and(volatile local unsigned long 
*p, unsigned long val);

Added: lib

[PATCH] D38060: Remove offset size check in nullptr arithmetic handling

2017-09-20 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor closed this revision.
andrew.w.kaylor added a comment.

This was committed as r313784.  I put the wrong differential revision number in 
the comment for that check-in.


https://reviews.llvm.org/D38060



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


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Needs testcase.




Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

I don't think we need to mess with MaxAtomicPromoteWidth?

Probably more intuitive to check "if (hasFeature" rather than "if (!hasFeature".

Adding a dedicated hook for this seems a bit overkill, but I don't have a 
better suggestion.


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 116072.
morehouse added a comment.

- Add test case.
- Use SanitizerScope.


https://reviews.llvm.org/D38063

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction &I = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast(&I);
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope(&CGF);
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction &I = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast(&I);
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction &CGF, llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope(&CGF);
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r313820 - [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Sep 20 14:23:07 2017
New Revision: 313820

URL: http://llvm.org/viewvc/llvm-project?rev=313820&view=rev
Log:
[NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

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

Added:
cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=313820&r1=313819&r2=313820&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Sep 20 14:23:07 2017
@@ -390,6 +390,15 @@ BUILTIN(__nvvm_shfl_bfly_f32, "ffii", ""
 BUILTIN(__nvvm_shfl_idx_i32, "", "")
 BUILTIN(__nvvm_shfl_idx_f32, "ffii", "")
 
+TARGET_BUILTIN(__nvvm_shfl_sync_down_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_down_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_up_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_up_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_bfly_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_bfly_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_idx_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_idx_f32, "fUifii", "", "ptx60")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=313820&r1=313819&r2=313820&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Wed Sep 20 14:23:07 2017
@@ -507,11 +507,17 @@ void CudaToolChain::addClangTargetOption
   CC1Args.push_back("-mlink-cuda-bitcode");
   CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
 
-  // Libdevice in CUDA-7.0 requires PTX version that's more recent
-  // than LLVM defaults to. Use PTX4.2 which is the PTX version that
-  // came with CUDA-7.0.
-  CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+  if (CudaInstallation.version() >= CudaVersion::CUDA_90) {
+// CUDA-9 uses new instructions that are only available in PTX6.0
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+ptx60");
+  } else {
+// Libdevice in CUDA-7.0 requires PTX version that's more recent
+// than LLVM defaults to. Use PTX4.2 which is the PTX version that
+// came with CUDA-7.0.
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+ptx42");
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=313820&r1=313819&r2=313820&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Wed Sep 20 14:23:07 2017
@@ -92,6 +92,74 @@ __MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
+// __shfl_sync_* variants available in CUDA-9
+#if CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
+#pragma push_macro("__MAKE_SYNC_SHUFFLES")
+#define __MAKE_SYNC_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic,   
\
+ __Mask)   
\
+  inline __device__ int __FnName(unsigned int __mask, int __val, int __offset, 
\
+ int __width = warpSize) { 
\
+return __IntIntrinsic(__mask, __val, __offset, 
\
+  ((warpSize - __width) << 8) | (__Mask)); 
\
+  }
\
+  inline __device__ float __FnName(unsigned int __mask, float __val,   
\
+   int __offset, int __width = warpSize) { 
\
+return __FloatIntrinsic(__mask, __val, __offset,   
\
+((warpSize - __width) << 8) | (__Mask));   
\
+  }
\
+  inline __device__ unsigned int __FnName(unsigned int __mask, 
\
+  unsigned int __val, int __offset,
\
+  int __width = warpSize) {
\
+return static_cast(  

[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313820: [NVPTX] Implemented shfl.sync instruction and 
supporting intrinsics/builtins. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38090?vs=116047&id=116073#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38090

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
  cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
  cfe/trunk/test/CodeGen/builtins-nvptx.c
  llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
  llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll

Index: llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
+++ llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
@@ -3736,4 +3736,48 @@
   Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
 [IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.idx.f32">,
   GCCBuiltin<"__nvvm_shfl_idx_f32">;
+
+// Synchronizing shfl variants available in CUDA-9.
+// On sm_70 these don't have to be convergent, so we may eventually want to
+// implement non-convergent variant of this intrinsic.
+
+// shfl.sync.down.b32 dest, threadmask, val, offset , mask_and_clamp
+def int_nvvm_shfl_sync_down_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.down.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_down_i32">;
+def int_nvvm_shfl_sync_down_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.down.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_down_f32">;
+
+// shfl.sync.up.b32 dest, threadmask, val, offset, mask_and_clamp
+def int_nvvm_shfl_sync_up_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.up.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_up_i32">;
+def int_nvvm_shfl_sync_up_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.up.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_up_f32">;
+
+// shfl.sync.bfly.b32 dest, threadmask, val, offset, mask_and_clamp
+def int_nvvm_shfl_sync_bfly_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.bfly.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_bfly_i32">;
+def int_nvvm_shfl_sync_bfly_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.bfly.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_bfly_f32">;
+
+// shfl.sync.idx.b32 dest, threadmask, val, lane, mask_and_clamp
+def int_nvvm_shfl_sync_idx_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.idx.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_idx_i32">;
+def int_nvvm_shfl_sync_idx_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.idx.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_idx_f32">;
 }
Index: llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll
===
--- llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll
+++ llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll
@@ -0,0 +1,94 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 | FileCheck %s
+
+declare i32 @llvm.nvvm.shfl.sync.down.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.down.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.up.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.up.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.bfly.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.idx.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.idx.f32(float, i32, i32, i32)
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rrr
+define i32 @shfl.sync.rrr(i32 %mask, i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.irr
+define i32 @shfl.sync.irr(i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param

[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-09-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added a project: clang.

Currently, clang only diagnoses completely out-of-range comparisons (e.g. 
`char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons 
with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

I don't really like this code, but given the previous feedback in 
https://reviews.llvm.org/D37629,
i decided to do it in the most simple way possible for now, and change it given 
on review feedback.

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565


Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -102,6 +102,7 @@
   return 1;
 
 short s = value();
+
 if (s == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
 return 0;
 if (s != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
@@ -128,6 +129,112 @@
 if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
 return 0;
 
+if (s == 32767)
+return 0;
+if (s != 32767)
+return 0;
+if (s < 32767)
+return 0;
+if (s <= 32767) // expected-warning {{comparison 'short' <= 32767 is always true}}
+return 0;
+if (s > 32767) // expected-warning {{comparison 'short' > 32767 is always false}}
+return 0;
+if (s >= 32767)
+return 0;
+
+if (32767 == s)
+return 0;
+if (32767 != s)
+return 0;
+if (32767 < s) // expected-warning {{comparison 32767 < 'short' is always false}}
+return 0;
+if (32767 <= s)
+return 0;
+if (32767 > s)
+return 0;
+if (32767 >= s) // expected-warning {{comparison 32767 >= 'short' is always true}}
+return 0;
+
+// FIXME: assumes two's complement
+if (s == -32768)
+return 0;
+if (s != -32768)
+return 0;
+if (s < -32768) // expected-warning {{comparison 'short' < -32768 is always false}}
+return 0;
+if (s <= -32768)
+return 0;
+if (s > -32768)
+return 0;
+if (s >= -32768) // expected-warning {{comparison 'short' >= -32768 is always true}}
+return 0;
+
+if (-32768 == s)
+return 0;
+if (-32768 != s)
+return 0;
+if (-32768 < s)
+return 0;
+if (-32768 <= s) // expected-warning {{comparison -32768 <= 'short' is always true}}
+return 0;
+if (-32768 > s) // expected-warning {{comparison -32768 > 'short' is always false}}
+return 0;
+if (-32768 >= s)
+return 0;
+
+if (s == 32767UL)
+return 0;
+if (s != 32767UL)
+return 0;
+if (s < 32767UL)
+return 0;
+if (s <= 32767UL) // expected-warning {{comparison 'short' <= 32767 is always true}}
+return 0;
+if (s > 32767UL) // expected-warning {{comparison 'short' > 32767 is always false}}
+return 0;
+if (s >= 32767UL)
+return 0;
+
+if (32767UL == s)
+return 0;
+if (32767UL != s)
+return 0;
+if (32767UL < s) // expected-warning {{comparison 32767 < 'short' is always false}}
+return 0;
+if (32767UL <= s)
+return 0;
+if (32767UL > s)
+return 0;
+if (32767UL >= s) // expected-warning {{comparison 32767 >= 'short' is always true}}
+return 0;
+
+// FIXME: assumes two's complement
+if (s == -32768L)
+return 0;
+if (s != -32768L)
+return 0;
+if (s < -32768L) // expected-warning {{comparison 'short' < -32768 is always false}}
+return 0;
+if (s <= -32768L)
+return 0;
+if (s > -32768L)
+return 0;
+if (s >= -32768L) // expected-warning {{comparison 'short' >= -32768 is always true}}
+return 0;
+
+if (-32768L == s)
+return 0;
+if (-32768L != s)
+return 0;
+if (-32768L < s)
+return 0;
+if (-32768L <= s) // expected-warning {{comparison -32768 <= 'short' is always true}}
+return 0;
+if (-32768L > s) // expected-warning {{comparison -32768 > 'short' is always false}}
+return 0;
+if (-32768L >= s)
+return 0;
+
 long l = value();
 if (l == 0x1234567812345678L)
 return 0;
@@ -208,6 +315,60 @@
 if (0xUL >= un)
 return 0;
 
+unsigned short us = value();
+
+if (us ==

[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Wei Mi via Phabricator via cfe-commits
wmi added inline comments.



Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

efriedma wrote:
> I don't think we need to mess with MaxAtomicPromoteWidth?
> 
> Probably more intuitive to check "if (hasFeature" rather than "if 
> (!hasFeature".
> 
> Adding a dedicated hook for this seems a bit overkill, but I don't have a 
> better suggestion.
If 128 bits inline atomic is not supported, what is the point to promote atomic 
type to 128 bits?


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/Sema/SemaDeclCXX.cpp:2871
+  InvalidDecl =
+  (DS.getStorageClassSpec() == DeclSpec::SCS_typedef || MSPropertyAttr)
+  ? 0

erichkeane wrote:
> Note: Clang format did this craziness... I'm open to whatever format you guys 
> would prefer.
Maybe this would be better expressed in an if /else if chain like:
  if (!isFunc && (DS.getStorageClassSpec() == SCS_typedef || MSPropertyAttr))
InvalidDecl = 0;
  else if (!isFunc)
InvalidDecl = 1;
...


https://reviews.llvm.org/D38092



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


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

wmi wrote:
> efriedma wrote:
> > I don't think we need to mess with MaxAtomicPromoteWidth?
> > 
> > Probably more intuitive to check "if (hasFeature" rather than "if 
> > (!hasFeature".
> > 
> > Adding a dedicated hook for this seems a bit overkill, but I don't have a 
> > better suggestion.
> If 128 bits inline atomic is not supported, what is the point to promote 
> atomic type to 128 bits?
MaxAtomicPromoteWidth affects the ABI, so it can't vary based on the target CPU.


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


Re: [clang-tools-extra] r313752 - [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests

2017-09-20 Thread Richard Smith via cfe-commits
Thank you!

On 20 September 2017 at 05:16, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Wed Sep 20 05:16:35 2017
> New Revision: 313752
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313752&view=rev
> Log:
> [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
> clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-
> algorithm.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/misc-inefficient-algorithm.cpp?rev=
> 313752&r1=313751&r2=313752&view=diff
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
> Wed Sep 20 05:16:35 2017
> @@ -43,19 +43,23 @@ template  struct
>
>  template > struct multiset : set Cmp> {};
>
> -template  FwIt find(FwIt, FwIt, const K &);
> +template 
> +FwIt find(FwIt, FwIt end, const K &) { return end; }
>
>  template 
> -FwIt find(FwIt, FwIt, const K &, Cmp);
> +FwIt find(FwIt, FwIt end, const K &, Cmp) { return end; }
>
> -template  FwIt find_if(FwIt, FwIt, Pred);
> +template 
> +FwIt find_if(FwIt, FwIt end, Pred) { return end; }
>
> -template  FwIt count(FwIt, FwIt, const K &);
> +template 
> +unsigned count(FwIt, FwIt, const K &) { return 0; }
>
> -template  FwIt lower_bound(FwIt, FwIt, const K
> &);
> +template 
> +FwIt lower_bound(FwIt, FwIt end, const K &) { return end; }
>
>  template 
> -FwIt lower_bound(FwIt, FwIt, const K &, Ord);
> +FwIt lower_bound(FwIt, FwIt end, const K &, Ord) { return end; }
>  }
>
>  #define FIND_IN_SET(x) find(x.begin(), x.end(), 10)
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/misc-move-const-arg.cpp?rev=313752&
> r1=313751&r2=313752&view=diff
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp Wed
> Sep 20 05:16:35 2017
> @@ -10,7 +10,9 @@ template  struct remove_re
>  template  struct remove_reference<_Tp &&> { typedef _Tp
> type; };
>
>  template 
> -constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t);
> +constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
> +  return static_cast::type &&>(__t);
> +}
>
>  } // namespace std
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

Please also add a tiny LLVM test that call instructions with nosanitize 
metadata are not instrumented.


https://reviews.llvm.org/D38063



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


r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Sep 20 15:17:55 2017
New Revision: 313827

URL: http://llvm.org/viewvc/llvm-project?rev=313827&view=rev
Log:
Give external linkage and mangling to lambdas inside inline variables and 
variable templates.

This implements the proposed approach in 
https://github.com/itanium-cxx-abi/cxx-abi/issues/33

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Linkage.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CodeGenCXX/mangle-lambdas.cpp
cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=313827&r1=313826&r2=313827&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Sep 20 15:17:55 2017
@@ -676,10 +676,10 @@ LinkageComputer::getLVForNamespaceScopeD
 if (!LV.isVisibilityExplicit()) {
   // Use global type/value visibility as appropriate.
   Visibility globalVisibility;
-  if (computation == LVForValue) {
+  if ((computation & ~IgnoreTypeLinkageBit) == LVForValue) {
 globalVisibility = Context.getLangOpts().getValueVisibilityMode();
   } else {
-assert(computation == LVForType);
+assert((computation & ~IgnoreTypeLinkageBit) == LVForType);
 globalVisibility = Context.getLangOpts().getTypeVisibilityMode();
   }
   LV.mergeVisibility(globalVisibility, /*explicit*/ false);
@@ -719,7 +719,8 @@ LinkageComputer::getLVForNamespaceScopeD
 //
 // Note that we don't want to make the variable non-external
 // because of this, but unique-external linkage suits us.
-if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var)) {
+if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var) &&
+!(computation & IgnoreTypeLinkageBit)) {
   LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
   if (!isExternallyVisible(TypeLV.getLinkage()))
 return LinkageInfo::uniqueExternal();
@@ -759,8 +760,8 @@ LinkageComputer::getLVForNamespaceScopeD
 // unique-external linkage, it's not legally usable from outside
 // this translation unit.  However, we should use the C linkage
 // rules instead for extern "C" declarations.
-if (Context.getLangOpts().CPlusPlus &&
-!Function->isInExternCContext()) {
+if (Context.getLangOpts().CPlusPlus && !Function->isInExternCContext() &&
+!(computation & IgnoreTypeLinkageBit)) {
   // Only look at the type-as-written. If this function has an auto-deduced
   // return type, we can't compute the linkage of that type because it 
could
   // require looking at the linkage of this function, and we don't need 
this
@@ -1122,8 +1123,18 @@ LinkageInfo LinkageComputer::getLVForClo
   // calculation determines the lambda has external linkage, it should be
   // downgraded to VisibleNoLinkage.
   if (ContextDecl) {
+auto *VD = dyn_cast(ContextDecl);
 if (isa(ContextDecl))
   DC = ContextDecl->getDeclContext()->getRedeclContext();
+else if (VD && VD->getType()->getContainedDeducedType())
+  // If the declaration has a deduced type, we need to skip querying the
+  // linkage and visibility of that type, because it might involve this
+  // closure type. The only effect of this is that we might give a lambda
+  // VisibleNoLinkage rather than NoLinkage when we don't strictly need to,
+  // which is benign.
+  return computeLVForDecl(
+  cast(ContextDecl),
+  LVComputationKind(computation | IgnoreTypeLinkageBit));
 else
   return getLVForDecl(cast(ContextDecl), computation);
   }

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=313827&r1=313826&r2=313827&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Sep 20 15:17:55 2017
@@ -1691,10 +1691,16 @@ void CXXNameMangler::mangleLambda(const
   // to emit that last part of the prefix here.
   if (Decl *Context = Lambda->getLambdaContextDecl()) {
 if ((isa(Context) || isa(Context)) &&
-Context->getDeclContext()->isRecord()) {
+!isa(Context)) {
+  // FIXME: 'inline auto [a, b] = []{ return ... };' does not get a
+  // reasonable mangling here.
   if (const IdentifierInfo *Name
 = cast(Context)->getIdentifier()) {
 mangleSourceName(Name);
+const TemplateArgumentList *TemplateArgs = nullptr;
+if (const TemplateDecl *TD =
+isTemplate(cast(Context), Temp

[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-20 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 116092.
chh edited the summary of this revision.

https://reviews.llvm.org/D35743

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11579,24 +11579,58 @@
   EXPECT_EQ("auto const volatile [a, b] = f();",
 format("auto  const   volatile[a, b] = f();"));
   EXPECT_EQ("auto [a, b, c] = f();", format("auto   [  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto & [a, b, c] = f();",
+  EXPECT_EQ("auto &[a, b, c] = f();",
 format("auto   &[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto && [a, b, c] = f();",
+  EXPECT_EQ("auto &&[a, b, c] = f();",
 format("auto   &&[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto const & [a, b] = f();", format("auto  const&[a, b] = f();"));
-  EXPECT_EQ("auto const volatile && [a, b] = f();",
+  EXPECT_EQ("auto const &[a, b] = f();", format("auto  const&[a, b] = f();"));
+  EXPECT_EQ("auto const volatile &&[a, b] = f();",
 format("auto  const  volatile  &&[a, b] = f();"));
-  EXPECT_EQ("auto && [a, b] = f();", format("auto  &&[a, b] = f();"));
+  EXPECT_EQ("auto const &&[a, b] = f();", format("auto  const   &&  [a, b] = f();"));
+  EXPECT_EQ("const auto &[a, b] = f();", format("const  auto  &  [a, b] = f();"));
+  EXPECT_EQ("const auto volatile &&[a, b] = f();",
+format("const  auto   volatile  &&[a, b] = f();"));
+  EXPECT_EQ("volatile const auto &&[a, b] = f();",
+format("volatile  const  auto   &&[a, b] = f();"));
+  EXPECT_EQ("const auto &&[a, b] = f();", format("const  auto  &&  [a, b] = f();"));
 
   // Make sure we don't mistake structured bindings for lambdas.
   verifyFormat("auto [a, b]{A * i};");
   verifyFormat("auto const [a, b]{A * i};");
-  verifyFormat("auto const && [a, b]{A * i};");
+  verifyFormat("auto const& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const&& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &&[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const &&x1 = y1;", getGoogleStyle());
+  verifyFormat("auto const &&x2 = y1;", getLLVMStyle());
+  verifyFormat("auto const &x1 = y2;", getGoogleStyle());
+  verifyFormat("auto const &x2 = y2;", getLLVMStyle());
+  verifyFormat("auto const &x1 = y2;", getGoogleStyle());
+  verifyFormat("auto const *x1, *x2;", getGoogleStyle());
+  verifyFormat("auto const *x3, *x4;", getLLVMStyle());
+
+  EXPECT_EQ("for (const auto &&[a, b] : some_range) {\n}",
+format("for (const auto   &&   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto &[a, b] : some_range) {\n}",
+format("for (const auto   &   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto [a, b] : some_range) {\n}",
+format("for (const auto[a, b] : some_range) {\n}"));
+  EXPECT_EQ("auto [x, y](expr);", format("auto[x,y]  (expr);"));
+  EXPECT_EQ("auto &[x, y](expr);", format("auto  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto &&[x, y](expr);", format("auto  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto const &[x, y](expr);", format("auto  const  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto const &&[x, y](expr);", format("auto  const  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto [x, y]{expr};", format("auto[x,y] {expr};"));
+  EXPECT_EQ("auto const &[x, y]{expr};", format("auto  const  &  [x,y]  {expr};"));
+  EXPECT_EQ("auto const &&[x, y]{expr};", format("auto  const  &&  [x,y]  {expr};"));
 
   format::FormatStyle Spaces = format::getLLVMStyle();
   Spaces.SpacesInSquareBrackets = true;
   verifyFormat("auto [ a, b ] = f();", Spaces);
-  verifyFormat("auto && [ a, b ] = f();", Spaces);
+  verifyFormat("auto &&[ a, b ] = f();", Spaces);
+  verifyFormat("auto &[ a, b ] = f();", Spaces);
+  verifyFormat("auto const &&[ a, b ] = f();", Spaces);
+  verifyFormat("auto const &[ a, b ] = f();", Spaces);
 }
 
 } // end namespace
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -342,10 +342,10 @@
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->is(TT_Unknown)) {
-  if (Left->isCppStructuredBinding(Style)) {
-Left->Type = TT_StructuredBindingLSquare;
-  } else if (StartsObjCMethodExpr) {
+if (Left->isCppStructuredBinding(Style)) {
+  Left->Type = TT_StructuredBindingLSquare;
+} else if (Left->is(TT_Unknown)) {
+  if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;
   } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
  Contexts.back().ContextKind == tok::l_brace &&
@@ -2513,6 +2513,14 @@
   TT_TemplateOpener));
   if ((Left.is(TT_TemplateOpener)) != (Right.is(T

r313828 - [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Sep 20 15:28:24 2017
New Revision: 313828

URL: http://llvm.org/viewvc/llvm-project?rev=313828&view=rev
Log:
[MS Compat]Allow __interfaces to have properties.

__interface types are allowed in MSVC to have "property" data members
(marked with declspec property). This patch alters Sema to allow property
data members.

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


Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/ms-interface.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=313828&r1=313827&r2=313828&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Sep 20 15:28:24 2017
@@ -143,7 +143,7 @@ namespace {
 if (Lambda->capture_begin() == Lambda->capture_end())
   return false;
 
-return S->Diag(Lambda->getLocStart(), 
+return S->Diag(Lambda->getLocStart(),
diag::err_lambda_capture_default_arg);
   }
 }
@@ -276,18 +276,18 @@ Sema::SetParamDefaultArgument(ParmVarDec
   // Okay: add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
-  // We have already instantiated this parameter; provide each of the 
+  // We have already instantiated this parameter; provide each of the
   // instantiations with the uninstantiated default argument.
   UnparsedDefaultArgInstantiationsMap::iterator InstPos
 = UnparsedDefaultArgInstantiations.find(Param);
   if (InstPos != UnparsedDefaultArgInstantiations.end()) {
 for (unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
   InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
-
+
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-  
+
   return false;
 }
 
@@ -524,8 +524,8 @@ bool Sema::MergeCXXFunctionDecl(Function
   Invalid = false;
 }
   }
-  
-  // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+
+  // FIXME: If we knew where the '=' was, we could easily provide a fix-it
   // hint here. Alternatively, we could walk the type-source information
   // for NewParam to find the last source location in the type... but it
   // isn't worth the effort right now. This is the kind of test case that
@@ -535,7 +535,7 @@ bool Sema::MergeCXXFunctionDecl(Function
   //   void g(int (*fp)(int) = &f);
   Diag(NewParam->getLocation(), DiagDefaultParamID)
 << NewParam->getDefaultArgRange();
-  
+
   // Look for the function declaration where the default argument was
   // actually written, which may be a declaration prior to Old.
   for (auto Older = PrevForDefaultArgs;
@@ -581,9 +581,9 @@ bool Sema::MergeCXXFunctionDecl(Function
 //   or a definition for one of the following explicit specializations:
 // - the explicit specialization of a function template;
 // - the explicit specialization of a member function template;
-// - the explicit specialization of a member function of a class 
+// - the explicit specialization of a member function of a class
 //   template where the class template specialization to which the
-//   member function specialization belongs is implicitly 
+//   member function specialization belongs is implicitly
 //   instantiated.
 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
   << (New->getTemplateSpecializationKind() 
==TSK_ExplicitSpecialization)
@@ -591,16 +591,16 @@ bool Sema::MergeCXXFunctionDecl(Function
   << NewParam->getDefaultArgRange();
   } else if (New->getDeclContext()->isDependentContext()) {
 // C++ [dcl.fct.default]p6 (DR217):
-//   Default arguments for a member function of a class template shall 
-//   be specified on the initial declaration of the member function 
+//   Default arguments for a member function of a class template shall
+//   be specified on the initial declaration of the member function
 //   within the class template.
 //
-// Reading the tea leaves a bit in DR217 and its reference to DR205 
-// leads me to the conclusion that one cannot add default function 
-// arguments for an out-of-line definition of a member function of a 
+// Reading the tea leaves a bit in DR217 and its reference to DR205
+// leads me to the conclusion that one cannot add default function
+// arguments for an out-of-line definition of a member function of a
 // dependent type.
 int WhichKind = 2;
-if (CXXRecordDecl *Record 
+if (CXXRecordDecl *Record
   = dyn_cast(New->getDeclContext())) {
   if (Record->getDescribedClassTemplate())
  

[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313828: [MS Compat]Allow __interfaces to have properties. 
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38092?vs=116046&id=116097#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38092

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/ms-interface.cpp

Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -143,7 +143,7 @@
 if (Lambda->capture_begin() == Lambda->capture_end())
   return false;
 
-return S->Diag(Lambda->getLocStart(), 
+return S->Diag(Lambda->getLocStart(),
diag::err_lambda_capture_default_arg);
   }
 }
@@ -276,18 +276,18 @@
   // Okay: add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
-  // We have already instantiated this parameter; provide each of the 
+  // We have already instantiated this parameter; provide each of the
   // instantiations with the uninstantiated default argument.
   UnparsedDefaultArgInstantiationsMap::iterator InstPos
 = UnparsedDefaultArgInstantiations.find(Param);
   if (InstPos != UnparsedDefaultArgInstantiations.end()) {
 for (unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
   InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
-
+
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-  
+
   return false;
 }
 
@@ -524,8 +524,8 @@
   Invalid = false;
 }
   }
-  
-  // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+
+  // FIXME: If we knew where the '=' was, we could easily provide a fix-it
   // hint here. Alternatively, we could walk the type-source information
   // for NewParam to find the last source location in the type... but it
   // isn't worth the effort right now. This is the kind of test case that
@@ -535,7 +535,7 @@
   //   void g(int (*fp)(int) = &f);
   Diag(NewParam->getLocation(), DiagDefaultParamID)
 << NewParam->getDefaultArgRange();
-  
+
   // Look for the function declaration where the default argument was
   // actually written, which may be a declaration prior to Old.
   for (auto Older = PrevForDefaultArgs;
@@ -581,36 +581,36 @@
 //   or a definition for one of the following explicit specializations:
 // - the explicit specialization of a function template;
 // - the explicit specialization of a member function template;
-// - the explicit specialization of a member function of a class 
+// - the explicit specialization of a member function of a class
 //   template where the class template specialization to which the
-//   member function specialization belongs is implicitly 
+//   member function specialization belongs is implicitly
 //   instantiated.
 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
   << (New->getTemplateSpecializationKind() ==TSK_ExplicitSpecialization)
   << New->getDeclName()
   << NewParam->getDefaultArgRange();
   } else if (New->getDeclContext()->isDependentContext()) {
 // C++ [dcl.fct.default]p6 (DR217):
-//   Default arguments for a member function of a class template shall 
-//   be specified on the initial declaration of the member function 
+//   Default arguments for a member function of a class template shall
+//   be specified on the initial declaration of the member function
 //   within the class template.
 //
-// Reading the tea leaves a bit in DR217 and its reference to DR205 
-// leads me to the conclusion that one cannot add default function 
-// arguments for an out-of-line definition of a member function of a 
+// Reading the tea leaves a bit in DR217 and its reference to DR205
+// leads me to the conclusion that one cannot add default function
+// arguments for an out-of-line definition of a member function of a
 // dependent type.
 int WhichKind = 2;
-if (CXXRecordDecl *Record 
+if (CXXRecordDecl *Record
   = dyn_cast(New->getDeclContext())) {
   if (Record->getDescribedClassTemplate())
 WhichKind = 0;
   else if (isa(Record))
 WhichKind = 1;
   else
 WhichKind = 2;
 }
-
-Diag(NewParam->getLocation(), 
+
+Diag(NewParam->getLocation(),
  diag::err_param_default_argument_member_template_redecl)
   << WhichKind
   << NewParam->getDefaultArgRange();
@@ -2148,7 +2148,7 @@
 return nullptr;
   }
 
-  if (EllipsisLoc.isValid() && 
+  if (Ellips

  1   2   >