r315276 - [ASTMatchers] Don't create a copy of a std::set when iterating over it.

2017-10-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Oct 10 00:21:34 2017
New Revision: 315276

URL: http://llvm.org/viewvc/llvm-project?rev=315276&view=rev
Log:
[ASTMatchers] Don't create a copy of a std::set when iterating over it.

This is a bit awkward because lookup returns a copy instead of a
reference. No functionality change intended.

Modified:
cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=315276&r1=315275&r2=315276&view=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Tue Oct 10 00:21:34 2017
@@ -734,7 +734,10 @@ private:
 BoundNodesTreeBuilder *Builder) {
 const Type *const CanonicalType =
   ActiveASTContext->getCanonicalType(TypeNode);
-for (const TypedefNameDecl *Alias : TypeAliases.lookup(CanonicalType)) {
+auto Aliases = TypeAliases.find(CanonicalType);
+if (Aliases == TypeAliases.end())
+  return false;
+for (const TypedefNameDecl *Alias : Aliases->second) {
   BoundNodesTreeBuilder Result(*Builder);
   if (Matcher.matches(*Alias, this, &Result)) {
 *Builder = std::move(Result);


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


[clang-tools-extra] r315277 - [clang-tidy] Use a more efficient map for the virtual near miss check.

2017-10-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Oct 10 00:21:51 2017
New Revision: 315277

URL: http://llvm.org/viewvc/llvm-project?rev=315277&view=rev
Log:
[clang-tidy] Use a more efficient map for the virtual near miss check.

DenseMap performs better here. No functionality change intended.

Modified:
clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h

Modified: clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h?rev=315277&r1=315276&r2=315277&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/VirtualNearMissCheck.h Tue Oct 10 
00:21:51 2017
@@ -11,7 +11,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_VIRTUAL_NEAR_MISS_H
 
 #include "../ClangTidy.h"
-#include 
+#include "llvm/ADT/DenseMap.h"
 
 namespace clang {
 namespace tidy {
@@ -47,12 +47,12 @@ private:
 
   /// Key: the unique ID of a method.
   /// Value: whether the method is possible to be overridden.
-  std::map PossibleMap;
+  llvm::DenseMap PossibleMap;
 
   /// Key: 
   /// Value: whether the base method is overridden by some method in the 
derived
   /// class.
-  std::map, bool>
+  llvm::DenseMap, bool>
   OverriddenMap;
 
   const unsigned EditDistanceThreshold = 1;


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


[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-10 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added a comment.

Excuse me, Ubuntu 14.04's g++-4.8.4 doesn't compile it. :(
Any idea?

  In file included from clang-tools-extra/clangd/ClangdServer.h:23:0,
   from clang-tools-extra/clangd/ClangdServer.cpp:10:
  clang-tools-extra/clangd/Function.h: In instantiation of ‘Ret 
clang::clangd::UniqueFunction::FunctionCallImpl::Call(Args ...) [with Callable = 
clang::clangd::ForwardBinder)::__lambda23,
 std::promise, std::future >; Ret = void; Args = {}]’:
  clang-tools-extra/clangd/ClangdServer.cpp:484:1:   required from here
  clang-tools-extra/clangd/Function.h:68:74: error: no match for call to 
‘(clang::clangd::ForwardBinder)::__lambda23,
 std::promise, std::future >) ()’
   Ret Call(Args... As) override { return Func(std::forward(As)...); }
^
  clang-tools-extra/clangd/Function.h:82:45: note: candidate is:
   template  struct ForwardBinder {
   ^
  clang-tools-extra/clangd/Function.h:108:8: note: template 
decltype (CallImpl(llvm::index_sequence_for(), 
(forward)(clang::clangd::ForwardBinder::operator()::Rest)...)) 
clang::clangd::ForwardBinder::operator()(RestArgs&& ...) [with 
RestArgs = {RestArgs ...}; Func = 
clang::clangd::ClangdServer::scheduleCancelRebuild(std::shared_ptr)::__lambda23;
 Args = {std::promise, std::future}]
 auto operator()(RestArgs &&... Rest)
  ^
  clang-tools-extra/clangd/Function.h:108:8: note:   template argument 
deduction/substitution failed:
  clang-tools-extra/clangd/Function.h: In substitution of ‘template decltype (CallImpl(llvm::index_sequence_for(), 
(forward)(clang::clangd::ForwardBinder::operator()::Rest)...)) 
clang::clangd::ForwardBinder::operator()(RestArgs&& ...) [with 
RestArgs = {RestArgs ...}; Func = 
clang::clangd::ClangdServer::scheduleCancelRebuild(std::shared_ptr)::__lambda23;
 Args = {std::promise, std::future}] [with RestArgs = {}]’:
  clang-tools-extra/clangd/Function.h:68:74:   required from ‘Ret 
clang::clangd::UniqueFunction::FunctionCallImpl::Call(Args ...) [with Callable = 
clang::clangd::ForwardBinder)::__lambda23,
 std::promise, std::future >; Ret = void; Args = {}]’
  clang-tools-extra/clangd/ClangdServer.cpp:484:1:   required from here
  clang-tools-extra/clangd/Function.h:110:59: error: cannot call member 
function ‘decltype 
(get<0>(this->.FuncWithArguments)((forward)((get)(this->.FuncWithArguments))..., 
(forward)(clang::clangd::ForwardBinder::CallImpl::Rest)...)) 
clang::clangd::ForwardBinder::CallImpl(llvm::integer_sequence, RestArgs&& ...) [with long unsigned int ...Indexes 
= {0ul, 1ul}; RestArgs = {}; Func = 
clang::clangd::ClangdServer::scheduleCancelRebuild(std::shared_ptr)::__lambda23;
 Args = {std::promise, std::future}; decltype 
(get<0>(this->.FuncWithArguments)((forward)((get)(this->.FuncWithArguments))..., 
(forward)(clang::clangd::ForwardBinder::CallImpl::Rest)...)) = void]’ 
without object
  std::forward(Rest)...)) {
 ^
  clang-tools-extra/clangd/Function.h: In instantiation of ‘Ret 
clang::clangd::UniqueFunction::FunctionCallImpl::Call(Args ...) [with Callable = 
clang::clangd::ForwardBinder)::__lambda23,
 std::promise, std::future >; Ret = void; Args = {}]’:
  clang-tools-extra/clangd/ClangdServer.cpp:484:1:   required from here
  clang-tools-extra/clangd/Function.h:68:74: error: return-statement with a 
value, in function returning 'void' [-fpermissive]
   Ret Call(Args... As) override { return Func(std::forward(As)...); }
^
  clang-tools-extra/clangd/Function.h: In instantiation of ‘Ret 
clang::clangd::UniqueFunction::FunctionCallImpl::Call(Args ...) [with Callable = 
clang::clangd::ForwardBinder, 
clang::clangd::Tagged 
>)::__lambda22, 
std::future > > >, std::promise >; Ret 
= void; Args = {}]’:
  clang-tools-extra/clangd/ClangdServer.cpp:484:1:   required from here
  clang-tools-extra/clangd/Function.h:68:74: error: no match for call to 
‘(clang::clangd::ForwardBinder, 
clang::clangd::Tagged 
>)::__lambda22, 
std::future > > >, std::promise >) ()’
  clang-tools-extra/clangd/Function.h:82:45: note: candidate is:
   template  struct ForwardBinder {
   ^
  clang-tools-extra/clangd/Function.h:108:8: note: template 
decltype (CallImpl(llvm::index_sequence_for(), 
(forward)(clang::clangd::ForwardBinder::operator()::Rest)...)) 
clang::clangd::ForwardBinder::operator()(RestArgs&& ...) [with 
RestArgs = {RestArgs ...}; Func = 
clang::clangd::ClangdServer::scheduleReparseAndDiags(clang::clangd::PathRef, 
clang::clangd::VersionedDraft, std::shared_ptr, 
clang::clangd::Tagged 
>)::__lambda22; Args = 
{std::future > > >, std::promise}]
 auto operator()(RestArgs &&... Rest)
  ^
  clang-tools-extra/clangd/Function.h:108:8: note:   template argument 
deduction

[PATCH] D38628: Remove unneeded typename from test

2017-10-10 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Thanks @chill , @mclow.lists and @EricWF !


https://reviews.llvm.org/D38628



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


[PATCH] D38628: Remove unneeded typename from test

2017-10-10 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315278: Remove unneeded typename from test (authored by 
rogfer01).

Changed prior to commit:
  https://reviews.llvm.org/D38628?vs=118183&id=118321#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38628

Files:
  
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
  
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp


Index: 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
===
--- 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
+++ 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
@@ -28,5 +28,5 @@
 
 int main() {
 using V = std::variant;
-typename std::variant_alternative<4, V>::type foo;  // 
expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
+std::variant_alternative<4, V>::type foo;  // expected-error@variant:* 
{{Index out of bounds in std::variant_alternative<>}}
 }
Index: 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
===
--- 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
+++ 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
@@ -18,5 +18,5 @@
 int main()
 {
 typedef std::pair T;
-typename std::tuple_element<2, T>::type foo; // expected-error@utility:* 
{{Index out of bounds in std::tuple_element>}}
+std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index 
out of bounds in std::tuple_element>}}
 }


Index: libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
===
--- libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
+++ libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
@@ -28,5 +28,5 @@
 
 int main() {
 using V = std::variant;
-typename std::variant_alternative<4, V>::type foo;  // expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
+std::variant_alternative<4, V>::type foo;  // expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
 }
Index: libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
===
--- libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
+++ libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
@@ -18,5 +18,5 @@
 int main()
 {
 typedef std::pair T;
-typename std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index out of bounds in std::tuple_element>}}
+std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index out of bounds in std::tuple_element>}}
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r315278 - Remove unneeded typename from test

2017-10-10 Thread Roger Ferrer Ibanez via cfe-commits
Author: rogfer01
Date: Tue Oct 10 00:42:19 2017
New Revision: 315278

URL: http://llvm.org/viewvc/llvm-project?rev=315278&view=rev
Log:
Remove unneeded typename from test

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


Modified:

libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp

libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp

Modified: 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp?rev=315278&r1=315277&r2=315278&view=diff
==
--- 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/tuple_element.fail.cpp
 Tue Oct 10 00:42:19 2017
@@ -18,5 +18,5 @@
 int main()
 {
 typedef std::pair T;
-typename std::tuple_element<2, T>::type foo; // expected-error@utility:* 
{{Index out of bounds in std::tuple_element>}}
+std::tuple_element<2, T>::type foo; // expected-error@utility:* {{Index 
out of bounds in std::tuple_element>}}
 }

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp?rev=315278&r1=315277&r2=315278&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.helpers/variant_alternative.fail.cpp
 Tue Oct 10 00:42:19 2017
@@ -28,5 +28,5 @@
 
 int main() {
 using V = std::variant;
-typename std::variant_alternative<4, V>::type foo;  // 
expected-error@variant:* {{Index out of bounds in std::variant_alternative<>}}
+std::variant_alternative<4, V>::type foo;  // expected-error@variant:* 
{{Index out of bounds in std::variant_alternative<>}}
 }


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


[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

2017-10-10 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

In https://reviews.llvm.org/D38675#891912, @xazax.hun wrote:

> In https://reviews.llvm.org/D38675#891750, @danielmarjamaki wrote:
>
> > > However, the checker seems to work with a low false positive rate.  (<15 
> > > on the LLVM, 6 effectively different)
> >
> > This does not sound like a low false positive rate to me. Could you 
> > describe what the false positives are? Is it possible to fix them?
>
>
> Note that the unique findings are 6. I think there are non-alpha checks with 
> more false positives.


This does not answer the important questions. What are the false positives, and 
is it possible to fix them?

In https://reviews.llvm.org/D38675#891750, @danielmarjamaki wrote:

>




>> Is it enough or should I check it on other open source projects?
> 
> you should check a number of different projects. There might be idioms/usages 
> in other projects that are not seen in LLVM.
> 
> However I don't know what other open source C++11 projects there are.
> 
> But I have a script that runs clang on various Debian projects and I can run 
> that and provide you with the results.

Something didn't go well. I started my script yesterday afternoon. It has 
checked 426 projects so far. I do not see a single MisusedMovedObject warning. 
I am thinking that my script doesn't work well in this case. A wild idea is 
that maybe my script must somehow tell scan-build to use -std=c++11.

For information here are the cppcheck results for a similar checker:
http://cppcheck.sourceforge.net/cgi-bin/daca2-search.cgi?id=accessMoved

Maybe you could pick a few of those projects and check those. That should 
exercise this checker.

Please tell me if you think some of the accessMoved warnings are false 
positives. These warnings are "inconclusive" which indicates they might not 
always be correct.


https://reviews.llvm.org/D38675



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


Re: [clang-tools-extra] r315210 - [clangd] Added move-only function helpers.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Will do, sorry about that.

On Oct 10, 2017 01:15, "Galina Kistanova"  wrote:

> Hello Ilya,
>
> This commit broke build on one of our builders:
>
> http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/16435
>
> Please have a look?
>
> Thanks
>
> Galina
>
>
> On Mon, Oct 9, 2017 at 9:26 AM, Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Mon Oct  9 09:26:26 2017
>> New Revision: 315210
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315210&view=rev
>> Log:
>> [clangd] Added move-only function helpers.
>>
>> Summary:
>> They are now used in ClangdScheduler instead of deferred std::async
>> computations.
>> The results of `std::async` are much less effective and do not provide
>> a good abstraction for similar purposes, i.e. for storing additional
>> callbacks
>> to clangd async tasks. The actual callback API will follow a bit later.
>>
>> Reviewers: klimek, bkramer, sammccall, krasimir
>>
>> Reviewed By: sammccall
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D38627
>>
>> Added:
>> clang-tools-extra/trunk/clangd/Function.h
>> 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=315210&r1=315209&r2=315210&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Oct  9 09:26:26
>> 2017
>> @@ -99,7 +99,7 @@ ClangdScheduler::ClangdScheduler(unsigne
>>for (unsigned I = 0; I < AsyncThreadsCount; ++I) {
>>  Workers.push_back(std::thread([this]() {
>>while (true) {
>> -std::future Request;
>> +UniqueFunction Request;
>>
>>  // Pick request from the queue
>>  {
>> @@ -120,7 +120,7 @@ ClangdScheduler::ClangdScheduler(unsigne
>>RequestQueue.pop_front();
>>  } // unlock Mutex
>>
>> -Request.get();
>> +Request();
>>}
>>  }));
>>}
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.h?rev=315210&r1=315209&r2=315210&view=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Oct  9 09:26:26
>> 2017
>> @@ -20,6 +20,7 @@
>>  #include "llvm/ADT/StringRef.h"
>>
>>  #include "ClangdUnit.h"
>> +#include "Function.h"
>>  #include "Protocol.h"
>>
>>  #include 
>> @@ -132,9 +133,8 @@ public:
>>
>>  {
>>std::lock_guard Lock(Mutex);
>> -  RequestQueue.push_front(std::async(std::launch::deferred,
>> - std::forward(F),
>> - std::forward(As)...));
>> +  RequestQueue.push_front(
>> +  BindWithForward(std::forward(F),
>> std::forward(As)...));
>>  }
>>  RequestCV.notify_one();
>>}
>> @@ -149,9 +149,8 @@ public:
>>
>>  {
>>std::lock_guard Lock(Mutex);
>> -  RequestQueue.push_back(std::async(std::launch::deferred,
>> -std::forward(F),
>> -std::forward(As)...));
>> +  RequestQueue.push_back(
>> +  BindWithForward(std::forward(F),
>> std::forward(As)...));
>>  }
>>  RequestCV.notify_one();
>>}
>> @@ -167,7 +166,7 @@ private:
>>bool Done = false;
>>/// A queue of requests. Elements of this vector are async
>> computations (i.e.
>>/// results of calling std::async(std::launch::deferred, ...)).
>> -  std::deque> RequestQueue;
>> +  std::deque> RequestQueue;
>>/// Condition variable to wake up worker threads.
>>std::condition_variable RequestCV;
>>  };
>>
>> Added: clang-tools-extra/trunk/clangd/Function.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/Function.h?rev=315210&view=auto
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/Function.h (added)
>> +++ clang-tools-extra/trunk/clangd/Function.h Mon Oct  9 09:26:26 2017
>> @@ -0,0 +1,136 @@
>> +//===--- Function.h - Utility callable wrappers  -*-
>> C++-*-===//
>> +//
>> +// The LLVM Compiler Infrastructure
>> +//
>> +// This file is distributed under the University of Illinois Open Source
>> +// License. See LICENSE.TXT for details.
>> +//
>> +//===--
>> ===//
>> +//
>> +// This file provides an analogue to std::function that supports move
>> semantics.
>> +//
>> +//===---

[clang-tools-extra] r315284 - [clangd] Fix compilation on gcc.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 01:40:57 2017
New Revision: 315284

URL: http://llvm.org/viewvc/llvm-project?rev=315284&view=rev
Log:
[clangd] Fix compilation on gcc.

Modified:
clang-tools-extra/trunk/clangd/Function.h

Modified: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315284&r1=315283&r2=315284&view=diff
==
--- clang-tools-extra/trunk/clangd/Function.h (original)
+++ clang-tools-extra/trunk/clangd/Function.h Tue Oct 10 01:40:57 2017
@@ -106,8 +106,8 @@ private:
 public:
   template 
   auto operator()(RestArgs &&... Rest)
-  -> decltype(CallImpl(llvm::index_sequence_for(),
-   std::forward(Rest)...)) {
+  -> decltype(this->CallImpl(llvm::index_sequence_for(),
+ std::forward(Rest)...)) {
 
 #ifndef NDEBUG
 assert(!WasCalled && "Can only call result of BindWithForward once.");


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


Re: [clang-tools-extra] r315210 - [clangd] Added move-only function helpers.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Fixed in r315284.

On Tue, Oct 10, 2017 at 10:28 AM, Ilya Biryukov 
wrote:

> Will do, sorry about that.
>
> On Oct 10, 2017 01:15, "Galina Kistanova"  wrote:
>
>> Hello Ilya,
>>
>> This commit broke build on one of our builders:
>>
>> http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-
>> test/builds/16435
>>
>> Please have a look?
>>
>> Thanks
>>
>> Galina
>>
>>
>> On Mon, Oct 9, 2017 at 9:26 AM, Ilya Biryukov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ibiryukov
>>> Date: Mon Oct  9 09:26:26 2017
>>> New Revision: 315210
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=315210&view=rev
>>> Log:
>>> [clangd] Added move-only function helpers.
>>>
>>> Summary:
>>> They are now used in ClangdScheduler instead of deferred std::async
>>> computations.
>>> The results of `std::async` are much less effective and do not provide
>>> a good abstraction for similar purposes, i.e. for storing additional
>>> callbacks
>>> to clangd async tasks. The actual callback API will follow a bit later.
>>>
>>> Reviewers: klimek, bkramer, sammccall, krasimir
>>>
>>> Reviewed By: sammccall
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D38627
>>>
>>> Added:
>>> clang-tools-extra/trunk/clangd/Function.h
>>> 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=315210&r1=315209&r2=315210&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Oct  9 09:26:26
>>> 2017
>>> @@ -99,7 +99,7 @@ ClangdScheduler::ClangdScheduler(unsigne
>>>for (unsigned I = 0; I < AsyncThreadsCount; ++I) {
>>>  Workers.push_back(std::thread([this]() {
>>>while (true) {
>>> -std::future Request;
>>> +UniqueFunction Request;
>>>
>>>  // Pick request from the queue
>>>  {
>>> @@ -120,7 +120,7 @@ ClangdScheduler::ClangdScheduler(unsigne
>>>RequestQueue.pop_front();
>>>  } // unlock Mutex
>>>
>>> -Request.get();
>>> +Request();
>>>}
>>>  }));
>>>}
>>>
>>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/ClangdServer.h?rev=315210&r1=315209&r2=315210&view=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Oct  9 09:26:26
>>> 2017
>>> @@ -20,6 +20,7 @@
>>>  #include "llvm/ADT/StringRef.h"
>>>
>>>  #include "ClangdUnit.h"
>>> +#include "Function.h"
>>>  #include "Protocol.h"
>>>
>>>  #include 
>>> @@ -132,9 +133,8 @@ public:
>>>
>>>  {
>>>std::lock_guard Lock(Mutex);
>>> -  RequestQueue.push_front(std::async(std::launch::deferred,
>>> - std::forward(F),
>>> - std::forward(As)...));
>>> +  RequestQueue.push_front(
>>> +  BindWithForward(std::forward(F),
>>> std::forward(As)...));
>>>  }
>>>  RequestCV.notify_one();
>>>}
>>> @@ -149,9 +149,8 @@ public:
>>>
>>>  {
>>>std::lock_guard Lock(Mutex);
>>> -  RequestQueue.push_back(std::async(std::launch::deferred,
>>> -std::forward(F),
>>> -std::forward(As)...));
>>> +  RequestQueue.push_back(
>>> +  BindWithForward(std::forward(F),
>>> std::forward(As)...));
>>>  }
>>>  RequestCV.notify_one();
>>>}
>>> @@ -167,7 +166,7 @@ private:
>>>bool Done = false;
>>>/// A queue of requests. Elements of this vector are async
>>> computations (i.e.
>>>/// results of calling std::async(std::launch::deferred, ...)).
>>> -  std::deque> RequestQueue;
>>> +  std::deque> RequestQueue;
>>>/// Condition variable to wake up worker threads.
>>>std::condition_variable RequestCV;
>>>  };
>>>
>>> Added: clang-tools-extra/trunk/clangd/Function.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/Function.h?rev=315210&view=auto
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/Function.h (added)
>>> +++ clang-tools-extra/trunk/clangd/Function.h Mon Oct  9 09:26:26 2017
>>> @@ -0,0 +1,136 @@
>>> +//===--- Function.h - Utility callable wrappers  -*-
>>> C++-*-===//
>>> +//
>>> +// The LLVM Compiler Infrastructure
>>> +//
>>> +// This file is distributed under the University of Illinois Open Source
>>> +// License. See LICENSE.TXT for 

r315286 - Fix small nits in clang-refactor doc.

2017-10-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct 10 02:00:56 2017
New Revision: 315286

URL: http://llvm.org/viewvc/llvm-project?rev=315286&view=rev
Log:
Fix small nits in clang-refactor doc.

Modified:
cfe/trunk/docs/RefactoringEngine.rst

Modified: cfe/trunk/docs/RefactoringEngine.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/RefactoringEngine.rst?rev=315286&r1=315285&r2=315286&view=diff
==
--- cfe/trunk/docs/RefactoringEngine.rst (original)
+++ cfe/trunk/docs/RefactoringEngine.rst Tue Oct 10 02:00:56 2017
@@ -41,7 +41,7 @@ outline of a ``local-rename`` action:
   public:
 StringRef getCommand() const override { return "local-rename"; }
 
-   StringRef getDescription() const override {
+StringRef getDescription() const override {
   return "Finds and renames symbols in code with no indexer support";
 }
 
@@ -143,7 +143,7 @@ list of action rules using the following
   Rules.push_back(
 createRefactoringActionRule(
   SourceRangeSelectionRequirement())
-  )
+  );
 
 The ``createRefactoringActionRule`` function takes in a list of refactoring
 action rule requirement values. These values describe the initiation


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


[clang-tools-extra] r315287 - Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 02:08:47 2017
New Revision: 315287

URL: http://llvm.org/viewvc/llvm-project?rev=315287&view=rev
Log:
Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"

This reverts commit r315242 and restores r315214.

To fix original failure, replaced non-portable `diff -Z` with portable
alternative: `diff -b`.

Added:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315287&r1=315286&r2=315287&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Tue Oct 10 02:08:47 
2017
@@ -37,6 +37,14 @@ void JSONOutput::log(const Twine &Messag
   Logs.flush();
 }
 
+void JSONOutput::mirrorInput(const Twine &Message) {
+  if (!InputMirror)
+return;
+
+  *InputMirror << Message;
+  InputMirror->flush();
+}
+
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
+  Out.mirrorInput(Line);
+  // Mirror '\n' that gets consumed by std::getline, but is not included in
+  // the resulting Line.
+  // Note that '\r' is part of Line, so we don't need to mirror it
+  // separately.
+  if (!In.eof())
+Out.mirrorInput("\n");
+
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message ("
-  + std::to_string(ContentLength)
-  + ") was ignored.\n");
+  "The previous value for this message (" +
+  std::to_string(ContentLength) + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
+  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only "
-+ std::to_string(In.gcount())
-+ " bytes of expected "
-+ std::to_string(ContentLength)
-+ ".\n");
+Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
+" bytes of expected " + std::to_string(ContentLength) + ".\n");
 break;
   }
 
@@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log( "Warning: Missing Content-Length header, or message has zero "
-   "length.\n" );
+  Out.log("Warning: Missing Content-Length header, or message has zero "
+  "length.\n");
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315287&r1=315286&r2=315287&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Tue Oct 10 02:08:47 2017
@@ -24,8 +24,9 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs)
-  : Outs(Outs), Logs(Logs) {}
+  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,
+ llvm::raw_ostream *InputMirror = nullptr)
+  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine &Message);
@@ -33,9 +34,15 @@ public:
   /// Write to the logging stream.
   void log(const Twine &Message) override;
 
+  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
+  /// null.
+  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
+  void mirrorInput(const Twine &Message);
+
 private:
   llvm::raw_ostream &Outs;
   llvm::raw_ostream &Logs;
+  llvm::raw_ostream *InputMirror;
 
   std::mutex StreamMutex;
 };

Modified: clang-tools-extra/trunk/clan

[PATCH] D38627: [clangd] Added move-only function helpers.

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

In https://reviews.llvm.org/D38627#892773, @chapuni wrote:

> Excuse me, Ubuntu 14.04's g++-4.8.4 doesn't compile it. :(
>  Any idea?


Sorry about that. Fixed in https://reviews.llvm.org/rL315284.
clang and gcc (at least version 4.8) behave differently here, so I didn't catch 
it before submitting.


Repository:
  rL LLVM

https://reviews.llvm.org/D38627



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


[PATCH] D36955: [libclang] Visit attributes for function and class templates

2017-10-10 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn updated this revision to Diff 118330.
jklaehn added a comment.

Added `c-index-test`-based test.


https://reviews.llvm.org/D36955

Files:
  bindings/python/tests/cindex/test_cursor.py
  test/Index/annotate-attribute.cpp
  tools/libclang/CIndex.cpp


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -907,16 +907,18 @@
   if (VisitTemplateParameters(D->getTemplateParameters()))
 return true;
   
-  return VisitFunctionDecl(D->getTemplatedDecl());
+  auto* FD = D->getTemplatedDecl();
+  return VisitAttributes(FD) || VisitFunctionDecl(FD);
 }
 
 bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   // FIXME: Visit the "outer" template parameter lists on the TagDecl
   // before visiting these template parameters.
   if (VisitTemplateParameters(D->getTemplateParameters()))
 return true;
   
-  return VisitCXXRecordDecl(D->getTemplatedDecl());
+  auto* CD = D->getTemplatedDecl();
+  return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
 }
 
 bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) 
{
Index: test/Index/annotate-attribute.cpp
===
--- test/Index/annotate-attribute.cpp
+++ test/Index/annotate-attribute.cpp
@@ -16,6 +16,12 @@
   void methodWithoutAttribute();
 };
 
+template 
+class __attribute__((annotate("works"))) TemplateTest {};
+
+template 
+int templateFunction(T value) __attribute__((annotate("works")));
+
 // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
 // CHECK-NEXT: CXXAccessSpecifier=:4:1 (Definition) Extent=[4:1 - 4:8]
 // CHECK-NEXT: CXXMethod=aMethod:5:51 Extent=[5:3 - 5:60]
@@ -31,3 +37,9 @@
 // CHECK-NEXT: CompoundStmt= Extent=[12:23 - 12:25]
 // CHECK-NEXT: CXXAccessSpecifier=:14:1 (Definition) Extent=[14:1 - 14:11]
 // CHECK-NEXT: CXXMethod=methodWithoutAttribute:16:8 Extent=[16:3 - 16:32]
+// CHECK: ClassTemplate=TemplateTest:20:42 (Definition) Extent=[19:1 - 20:57]
+// CHECK-NEXT: TemplateTypeParameter=T:19:20 (Definition) Extent=[19:11 - 
19:21] [access=public]
+// CHECK-NEXT: attribute(annotate)=works Extent=[20:22 - 20:39]
+// CHECK: FunctionTemplate=templateFunction:23:5 Extent=[22:1 - 23:65]
+// CHECK-NEXT: TemplateTypeParameter=T:22:20 (Definition) Extent=[22:11 - 
22:21] [access=public]
+// CHECK-NEXT: attribute(annotate)=works Extent=[23:46 - 23:63]
Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -377,6 +377,26 @@
 else:
 assert False, "Couldn't find annotation"
 
+def test_annotation_template():
+annotation = '__attribute__ ((annotate("annotation")))'
+for source, kind in [
+('int foo (T value) %s;', CursorKind.FUNCTION_TEMPLATE),
+('class %s foo {};', CursorKind.CLASS_TEMPLATE),
+]:
+source = 'template ' + (source % annotation)
+tu = get_tu(source, lang="cpp")
+
+foo = get_cursor(tu, 'foo')
+assert foo is not None
+assert foo.kind == kind
+
+for c in foo.get_children():
+if c.kind == CursorKind.ANNOTATE_ATTR:
+assert c.displayname == "annotation"
+break
+else:
+assert False, "Couldn't find annotation for {}".format(kind)
+
 def test_result_type():
 tu = get_tu('int foo();')
 foo = get_cursor(tu, 'foo')


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -907,16 +907,18 @@
   if (VisitTemplateParameters(D->getTemplateParameters()))
 return true;
   
-  return VisitFunctionDecl(D->getTemplatedDecl());
+  auto* FD = D->getTemplatedDecl();
+  return VisitAttributes(FD) || VisitFunctionDecl(FD);
 }
 
 bool CursorVisitor::VisitClassTemplateDecl(ClassTemplateDecl *D) {
   // FIXME: Visit the "outer" template parameter lists on the TagDecl
   // before visiting these template parameters.
   if (VisitTemplateParameters(D->getTemplateParameters()))
 return true;
   
-  return VisitCXXRecordDecl(D->getTemplatedDecl());
+  auto* CD = D->getTemplatedDecl();
+  return VisitAttributes(CD) || VisitCXXRecordDecl(CD);
 }
 
 bool CursorVisitor::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
Index: test/Index/annotate-attribute.cpp
===
--- test/Index/annotate-attribute.cpp
+++ test/Index/annotate-attribute.cpp
@@ -16,6 +16,12 @@
   void methodWithoutAttribute();
 };
 
+template 
+class __attribute__((annotate("works"))) TemplateTest {};
+
+template 
+int templateFunction(T value) __attribute__((annotate("works")));
+
 // CHECK: ClassDecl=Test:3:7 (Definition) Extent=[3:1 - 17:2]
 // CHECK-NEXT: CXXAccessSpecifier=:4:1 

[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-10-10 Thread Johann Klähn via Phabricator via cfe-commits
jklaehn updated this revision to Diff 118333.
jklaehn added a comment.

Use user-defined function for test of `AvailabilityKind.DEPRECATED`.


https://reviews.llvm.org/D36973

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py

Index: bindings/python/tests/cindex/test_cursor.py
===
--- bindings/python/tests/cindex/test_cursor.py
+++ bindings/python/tests/cindex/test_cursor.py
@@ -1,6 +1,7 @@
 import ctypes
 import gc
 
+from clang.cindex import AvailabilityKind
 from clang.cindex import CursorKind
 from clang.cindex import TemplateArgumentKind
 from clang.cindex import TranslationUnit
@@ -385,6 +386,30 @@
 t = foo.result_type
 assert t.kind == TypeKind.INT
 
+def test_availability():
+tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')
+
+# AvailabilityKind.AVAILABLE
+cursor = get_cursor(tu, 'A')
+assert cursor.kind == CursorKind.CLASS_DECL
+assert cursor.availability == AvailabilityKind.AVAILABLE
+
+# AvailabilityKind.NOT_AVAILABLE
+cursors = get_cursors(tu, 'A')
+for c in cursors:
+if c.kind == CursorKind.CONSTRUCTOR:
+assert c.availability == AvailabilityKind.NOT_AVAILABLE
+break
+else:
+assert False, "Could not find cursor for deleted constructor"
+
+# AvailabilityKind.DEPRECATED
+tu = get_tu('void test() __attribute__((deprecated));', lang='cpp')
+cursor = get_cursor(tu, 'test')
+assert cursor.availability == AvailabilityKind.DEPRECATED
+
+# AvailabilityKind.NOT_ACCESSIBLE is only used in the code completion results
+
 def test_get_tokens():
 """Ensure we can map cursors back to tokens."""
 tu = get_tu('int foo(int i);')
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1572,6 +1572,16 @@
 
 return StorageClass.from_id(self._storage_class)
 
+@property
+def availability(self):
+"""
+Retrieves the availability of the entity pointed at by the cursor.
+"""
+if not hasattr(self, '_availability'):
+self._availability = conf.lib.clang_getCursorAvailability(self)
+
+return AvailabilityKind.from_id(self._availability)
+
 @property
 def access_specifier(self):
 """
@@ -1909,6 +1919,24 @@
 StorageClass.AUTO = StorageClass(6)
 StorageClass.REGISTER = StorageClass(7)
 
+### Availability Kinds ###
+
+class AvailabilityKind(BaseEnumeration):
+"""
+Describes the availability of an entity.
+"""
+
+# The unique kind objects, indexed by id.
+_kinds = []
+_name_map = None
+
+def __repr__(self):
+return 'AvailabilityKind.%s' % (self.name,)
+
+AvailabilityKind.AVAILABLE = AvailabilityKind(0)
+AvailabilityKind.DEPRECATED = AvailabilityKind(1)
+AvailabilityKind.NOT_AVAILABLE = AvailabilityKind(2)
+AvailabilityKind.NOT_ACCESSIBLE = AvailabilityKind(3)
 
 ### C++ access specifiers ###
 
@@ -3440,6 +3468,10 @@
[TranslationUnit, SourceLocation],
Cursor),
 
+  ("clang_getCursorAvailability",
+   [Cursor],
+   c_int),
+
   ("clang_getCursorDefinition",
[Cursor],
Cursor,
@@ -4055,6 +4087,7 @@
 register_enumerations()
 
 __all__ = [
+'AvailabilityKind',
 'Config',
 'CodeCompletionResults',
 'CompilationDatabase',
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34030: Fix the postorder visting of the ClassTemplateSpecializationDecl nodes in the RecursiveASTVisitor.

2017-10-10 Thread Peter Siket via Phabricator via cfe-commits
MontyKutyi added a comment.

Ping.


https://reviews.llvm.org/D34030



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


Re: [clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Sorry about that, `diff -b` seems to work. Restored commit and changed to
`diff -b` in r315287.
Thanks for spotting and reverting this.

On Mon, Oct 9, 2017 at 8:45 PM, Bruno Cardoso Lopes  wrote:

> Hi,
>
> On Mon, Oct 9, 2017 at 9:58 AM, Ilya Biryukov via cfe-commits
>  wrote:
> > Author: ibiryukov
> > Date: Mon Oct  9 09:58:16 2017
> > New Revision: 315214
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=315214&view=rev
> > Log:
> > [clangd] Added a command-line arg to mirror clangd input into a file.
> >
> > Summary: The arg is useful for debugging and creating test cases.
> >
> > Reviewers: bkramer, krasimir
> >
> > Reviewed By: bkramer
> >
> > Subscribers: klimek, cfe-commits
> >
> > Differential Revision: https://reviews.llvm.org/D37970
> >
> > Added:
> > clang-tools-extra/trunk/test/clangd/input-mirror.test
> > Modified:
> > clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> > clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> > clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
> >
> > Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/
> JSONRPCDispatcher.cpp?rev=315214&r1=315213&r2=315214&view=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> > +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9
> 09:58:16 2017
> > @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine &Messag
> >Logs.flush();
> >  }
> >
> > +void JSONOutput::mirrorInput(const Twine &Message) {
> > +  if (!InputMirror)
> > +return;
> > +
> > +  *InputMirror << Message;
> > +  InputMirror->flush();
> > +}
> > +
> >  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef
> ID) {
> >Output.log("Method ignored.\n");
> >// Return that this method is unsupported.
> > @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
> >  continue;
> >}
> >
> > +  Out.mirrorInput(Line);
> > +  // Mirror '\n' that gets consumed by std::getline, but is not
> included in
> > +  // the resulting Line.
> > +  // Note that '\r' is part of Line, so we don't need to mirror it
> > +  // separately.
> > +  if (!In.eof())
> > +Out.mirrorInput("\n");
> > +
> >llvm::StringRef LineRef(Line);
> >
> >// We allow YAML-style comments in headers. Technically this
> isn't part
> > @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
> >if (LineRef.consume_front("Content-Length: ")) {
> >  if (ContentLength != 0) {
> >Out.log("Warning: Duplicate Content-Length header received. "
> > -  "The previous value for this message ("
> > -  + std::to_string(ContentLength)
> > -  + ") was ignored.\n");
> > +  "The previous value for this message (" +
> > +  std::to_string(ContentLength) + ") was ignored.\n");
> >  }
> >
> >  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> > @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
> >// parser.
> >std::vector JSON(ContentLength + 1, '\0');
> >In.read(JSON.data(), ContentLength);
> > +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
> >
> >// If the stream is aborted before we read ContentLength bytes, In
> >// will have eofbit and failbit set.
> >if (!In) {
> > -Out.log("Input was aborted. Read only "
> > -+ std::to_string(In.gcount())
> > -+ " bytes of expected "
> > -+ std::to_string(ContentLength)
> > -+ ".\n");
> > +Out.log("Input was aborted. Read only " +
> std::to_string(In.gcount()) +
> > +" bytes of expected " + std::to_string(ContentLength) +
> ".\n");
> >  break;
> >}
> >
> > @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
> >if (IsDone)
> >  break;
> >  } else {
> > -  Out.log( "Warning: Missing Content-Length header, or message has
> zero "
> > -   "length.\n" );
> > +  Out.log("Warning: Missing Content-Length header, or message has
> zero "
> > +  "length.\n");
> >  }
> >}
> >  }
> >
> > Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> > URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/
> JSONRPCDispatcher.h?rev=315214&r1=315213&r2=315214&view=diff
> > 
> ==
> > --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> > +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9
> 09:58:16 2017
> > @@ -24,8 +24,9 @@ namespace clangd {
> >  /// them.
> >  class JSONOutput : public Logger {
> >  public:
> > -  JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostrea

[PATCH] D38717: Patch to Bugzilla 31373

2017-10-10 Thread Erik Viktorsson via Phabricator via cfe-commits
erikv created this revision.

Committing a patch to Bugzilla 31373
A novice programmer so hopefully it complies with the coding policy.

I had to disable an assert in lib/CodeGen/CGExpr.cpp since it requires that all 
expressions are marked as Used or referenced, which is not possible if we want 
the ShouldDiagnoseUnusedDecl to return true (thus trigger the 
warn_unused_variable  warning).

The reason I removed the assert statement is because it causes five tests to 
fail. These test are the following:

•   clang -cc1 -triple i386-unknown-unknown -mllvm -inline-threshold=1024 
-O3 -emit-llvm temp-order.cpp
•   clang -cc1 -debug-info-kind=limited -std=c++11 -emit-llvm 
debug-info-scope.cpp
•   clang -cc1 -std=c++1z -triple x86_64-apple-macosx10.7.0 -emit-llvm 
cxx1z-init-statement.cpp
•   clang -cc1 -triple x86_64-apple-darwin10 -emit-llvm condition.cpp
•   clang -cc1 -emit-llvm cxx-condition.cpp

/E


https://reviews.llvm.org/D38717

Files:
  lib/CodeGen/CGExpr.cpp
  lib/Sema/SemaExprCXX.cpp


Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3362,7 +3362,10 @@
   /*enclosing*/ false, ConditionVar->getLocation(),
   ConditionVar->getType().getNonReferenceType(), VK_LValue);
 
-  MarkDeclRefReferenced(cast(Condition.get()));
+  // Check whether this declaration is a definition.
+  // If yes, dont mark it as used/referenced
+  if (!ConditionVar->isLocalVarDecl())
+MarkDeclRefReferenced(cast(Condition.get()));
 
   switch (CK) {
   case ConditionKind::Boolean:
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2352,9 +2352,9 @@
   // FIXME: We should be able to assert this for FunctionDecls as well!
   // FIXME: We should be able to assert this for all DeclRefExprs, not just
   // those with a valid source location.
-  assert((ND->isUsed(false) || !isa(ND) ||
-  !E->getLocation().isValid()) &&
- "Should not use decl without marking it used!");
+  // assert((ND->isUsed(false) || !isa(ND) ||
+  // !E->getLocation().isValid()) &&
+  //"Should not use decl without marking it used!");
 
   if (ND->hasAttr()) {
 const auto *VD = cast(ND);


Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3362,7 +3362,10 @@
   /*enclosing*/ false, ConditionVar->getLocation(),
   ConditionVar->getType().getNonReferenceType(), VK_LValue);
 
-  MarkDeclRefReferenced(cast(Condition.get()));
+  // Check whether this declaration is a definition.
+  // If yes, dont mark it as used/referenced
+  if (!ConditionVar->isLocalVarDecl())
+MarkDeclRefReferenced(cast(Condition.get()));
 
   switch (CK) {
   case ConditionKind::Boolean:
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2352,9 +2352,9 @@
   // FIXME: We should be able to assert this for FunctionDecls as well!
   // FIXME: We should be able to assert this for all DeclRefExprs, not just
   // those with a valid source location.
-  assert((ND->isUsed(false) || !isa(ND) ||
-  !E->getLocation().isValid()) &&
- "Should not use decl without marking it used!");
+  // assert((ND->isUsed(false) || !isa(ND) ||
+  // !E->getLocation().isValid()) &&
+  //"Should not use decl without marking it used!");
 
   if (ND->hasAttr()) {
 const auto *VD = cast(ND);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38695: [CodeGen] Do not construct complete LValue base info in trivial cases

2017-10-10 Thread Ivan A. Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315289: [CodeGen] Do not construct complete LValue base info 
in trivial cases (authored by kosarev).

Changed prior to commit:
  https://reviews.llvm.org/D38695?vs=118234&id=118335#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38695

Files:
  cfe/trunk/lib/CodeGen/CGBlocks.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
  cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h

Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -162,7 +162,7 @@
   const Expr *Rhs = ALE->getElement(i);
   LValue LV = MakeAddrLValue(
   Builder.CreateConstArrayGEP(Objects, i, getPointerSize()),
-  ElementType, LValueBaseInfo(AlignmentSource::Decl, false));
+  ElementType, AlignmentSource::Decl);
 
   llvm::Value *value = EmitScalarExpr(Rhs);
   EmitStoreThroughLValue(RValue::get(value), LV, true);
@@ -174,15 +174,15 @@
   const Expr *Key = DLE->getKeyValueElement(i).Key;
   LValue KeyLV = MakeAddrLValue(
   Builder.CreateConstArrayGEP(Keys, i, getPointerSize()),
-  ElementType, LValueBaseInfo(AlignmentSource::Decl, false));
+  ElementType, AlignmentSource::Decl);
   llvm::Value *keyValue = EmitScalarExpr(Key);
   EmitStoreThroughLValue(RValue::get(keyValue), KeyLV, /*isInit=*/true);
 
   // Emit the value and store it to the appropriate array slot.
   const Expr *Value = DLE->getKeyValueElement(i).Value;
   LValue ValueLV = MakeAddrLValue(
   Builder.CreateConstArrayGEP(Objects, i, getPointerSize()),
-  ElementType, LValueBaseInfo(AlignmentSource::Decl, false));
+  ElementType, AlignmentSource::Decl);
   llvm::Value *valueValue = EmitScalarExpr(Value);
   EmitStoreThroughLValue(RValue::get(valueValue), ValueLV, /*isInit=*/true);
   if (TrackNeededObjects) {
Index: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
@@ -392,15 +392,14 @@
   continue;
 }
 
-LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
-LValue ArgLVal =
-CGF.MakeAddrLValue(LocalAddr, Args[Cnt]->getType(), BaseInfo);
+LValue ArgLVal = CGF.MakeAddrLValue(LocalAddr, Args[Cnt]->getType(),
+AlignmentSource::Decl);
 if (FD->hasCapturedVLAType()) {
   if (FO.UIntPtrCastRequired) {
 ArgLVal = CGF.MakeAddrLValue(castValueFromUintptr(CGF, FD->getType(),
   Args[Cnt]->getName(),
   ArgLVal),
- FD->getType(), BaseInfo);
+ FD->getType(), AlignmentSource::Decl);
   }
   auto *ExprArg =
   CGF.EmitLoadOfLValue(ArgLVal, SourceLocation()).getScalarVal();
@@ -497,22 +496,23 @@
   llvm::Function *WrapperF =
   emitOutlinedFunctionPrologue(WrapperCGF, Args, LocalAddrs, VLASizes,
WrapperCGF.CXXThisValue, WrapperFO);
-  LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
   llvm::SmallVector CallArgs;
   for (const auto *Arg : Args) {
 llvm::Value *CallArg;
 auto I = LocalAddrs.find(Arg);
 if (I != LocalAddrs.end()) {
   LValue LV =
-  WrapperCGF.MakeAddrLValue(I->second.second, Arg->getType(), BaseInfo);
+  WrapperCGF.MakeAddrLValue(I->second.second, Arg->getType(),
+AlignmentSource::Decl);
   CallArg = WrapperCGF.EmitLoadOfScalar(LV, SourceLocation());
 } else {
   auto EI = VLASizes.find(Arg);
   if (EI != VLASizes.end())
 CallArg = EI->second.second;
   else {
 LValue LV = WrapperCGF.MakeAddrLValue(WrapperCGF.GetAddrOfLocalVar(Arg),
-  Arg->getType(), BaseInfo);
+  Arg->getType(),
+  AlignmentSource::Decl);
 CallArg = WrapperCGF.EmitLoadOfScalar(LV, SourceLocation());
   }
 }
Index: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1131,7 +1131,7 @@
 CodeGenFunction &CGF) {
   return CGF.MakeAddrLValue(CGF.GetAddrOfLocalVar(getThreadIDVariable()),
 getThreadIDVariable()->getType(),
-LValueBaseInfo(AlignmentSource::Decl, false));
+AlignmentSource::Decl);
 }
 
 CGOpenMPRuntim

r315289 - [CodeGen] Do not construct complete LValue base info in trivial cases

2017-10-10 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Tue Oct 10 02:39:32 2017
New Revision: 315289

URL: http://llvm.org/viewvc/llvm-project?rev=315289&view=rev
Log:
[CodeGen] Do not construct complete LValue base info in trivial cases

Besides obvious code simplification, avoiding explicit creation
of LValueBaseInfo objects makes it easier to make TBAA
information to be part of such objects.

This is part of D38126 reworked to be a separate patch to
simplify review.

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

Modified:
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGBlocks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBlocks.cpp?rev=315289&r1=315288&r2=315289&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBlocks.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBlocks.cpp Tue Oct 10 02:39:32 2017
@@ -986,9 +986,8 @@ llvm::Value *CodeGenFunction::EmitBlockL
   // FIXME: Pass a specific location for the expr init so that the store is
   // attributed to a reasonable location - otherwise it may be attributed 
to
   // locations of subexpressions in the initialization.
-  LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
   EmitExprAsInit(&l2r, &BlockFieldPseudoVar,
- MakeAddrLValue(blockField, type, BaseInfo),
+ MakeAddrLValue(blockField, type, AlignmentSource::Decl),
  /*captured by init*/ false);
 }
 

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=315289&r1=315288&r2=315289&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 10 02:39:32 2017
@@ -412,14 +412,12 @@ EmitMaterializeTemporaryExpr(const Mater
   // dynamic initialization or a cleanup and we can just return the address
   // of the temporary.
   if (Var->hasInitializer())
-return MakeAddrLValue(Object, M->getType(),
-  LValueBaseInfo(AlignmentSource::Decl, false));
+return MakeAddrLValue(Object, M->getType(), AlignmentSource::Decl);
 
   Var->setInitializer(CGM.EmitNullConstant(E->getType()));
 }
 LValue RefTempDst = MakeAddrLValue(Object, M->getType(),
-   LValueBaseInfo(AlignmentSource::Decl,
-  false));
+   AlignmentSource::Decl);
 
 switch (getEvaluationKind(E->getType())) {
 default: llvm_unreachable("expected scalar or aggregate expression");
@@ -506,8 +504,7 @@ EmitMaterializeTemporaryExpr(const Mater
   break;
 
 case SubobjectAdjustment::FieldAdjustment: {
-  LValue LV = MakeAddrLValue(Object, E->getType(),
- LValueBaseInfo(AlignmentSource::Decl, false));
+  LValue LV = MakeAddrLValue(Object, E->getType(), AlignmentSource::Decl);
   LV = EmitLValueForField(LV, Adjustment.Field);
   assert(LV.isSimple() &&
  "materialized temporary field is not a simple lvalue");
@@ -524,8 +521,7 @@ EmitMaterializeTemporaryExpr(const Mater
 }
   }
 
-  return MakeAddrLValue(Object, M->getType(),
-LValueBaseInfo(AlignmentSource::Decl, false));
+  return MakeAddrLValue(Object, M->getType(), AlignmentSource::Decl);
 }
 
 RValue
@@ -2148,8 +2144,7 @@ static LValue EmitThreadPrivateVarDeclLV
 llvm::Type *RealVarTy, SourceLocation Loc) {
   Addr = CGF.CGM.getOpenMPRuntime().getAddrOfThreadPrivate(CGF, VD, Addr, Loc);
   Addr = CGF.Builder.CreateElementBitCast(Addr, RealVarTy);
-  LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
-  return CGF.MakeAddrLValue(Addr, T, BaseInfo);
+  return CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
 }
 
 Address CodeGenFunction::EmitLoadOfReference(Address Addr,
@@ -2206,8 +2201,7 @@ static LValue EmitGlobalVarDeclLValue(Co
   if (auto RefTy = VD->getType()->getAs()) {
 LV = CGF.EmitLoadOfReferenceLValue(Addr, RefTy);
   } else {
-LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
-LV = CGF.MakeAddrLValue(Addr, T, BaseInfo);
+LV = CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
   }
   setObjCGCLValueClass(CGF.getContext(), E, LV);
   return LV;
@@ -2241,8 +2235,8 @@ static LValue EmitFunctionDeclLValue(Cod
  const Expr *E, const FunctionDecl *FD) {
   llvm::Value *V = EmitFunctionDeclPointer(CGF.CGM, FD);
   CharUnits Alignment = CGF.getContext().getDeclAlign(FD);
-  LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
-  return CGF.MakeAddrLValue(V, E->getType(), Alignment, 

r315290 - [clang-refactor] Fix clang-tidy misc-move-const-arg warning.

2017-10-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct 10 02:48:38 2017
New Revision: 315290

URL: http://llvm.org/viewvc/llvm-project?rev=315290&view=rev
Log:
[clang-refactor] Fix clang-tidy misc-move-const-arg warning.

NFC

Modified:
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=315290&r1=315289&r2=315290&view=diff
==
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Tue Oct 10 02:48:38 2017
@@ -226,12 +226,12 @@ public:
   ActionWrapper(TUCallbackType Callback) : Callback(Callback) {}
 
   std::unique_ptr newASTConsumer() {
-return llvm::make_unique(std::move(Callback));
+return llvm::make_unique(Callback);
   }
 };
 
 ClangTool Tool(DB, Sources);
-ActionWrapper ToolAction(std::move(Callback));
+ActionWrapper ToolAction(Callback);
 std::unique_ptr Factory =
 tooling::newFrontendActionFactory(&ToolAction);
 return Tool.run(Factory.get());


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


[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

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

Last time i was running on WebKit; i already lost my results, so i'd try to 
reproduce the results on the fixed checker and follow up. Apart from 
https://reviews.llvm.org/D31538, i've seen a few cases where a method was safe 
to be called on a moved-from object (which led me to believe that we'd need to 
be safer here), and a few weird cases where a moved-from object was 
accidentally copied implicitly, which seemed to be a non-issue.

You'd need to update the checker name in the test run line.


https://reviews.llvm.org/D38675



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


[PATCH] D38718: Patch to Bugzilla 20951

2017-10-10 Thread Erik Viktorsson via Phabricator via cfe-commits
erikv created this revision.

Submitting a patch to Bugzilla 20951.

Simply replaced the function call IgnoreImpCasts to IgnoreParenImpCasts which 
seems to more appropriate.
I also had to modify a test cast in test/Sema/conditional-expr.c

/E


https://reviews.llvm.org/D38718

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/conditional-expr.c


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9933,7 +9933,7 @@
 IsInAnyMacroBody(SM, Range.getBegin()))
   return;
   }
-  E = E->IgnoreImpCasts();
+  E = E->IgnoreParenImpCasts();
 
   const bool IsCompare = NullKind != Expr::NPCK_NotNull;
 
Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -79,9 +79,9 @@
   (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning 
{{pointer type mismatch}} expected-warning {{expression result unused}}
 }
 
-int Postgresql() {
-  char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+int Postgresql(char *x) {
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), 
(unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional 
expressions with only one void side}}
 }
 
 #define nil ((void*) 0)


Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9933,7 +9933,7 @@
 IsInAnyMacroBody(SM, Range.getBegin()))
   return;
   }
-  E = E->IgnoreImpCasts();
+  E = E->IgnoreParenImpCasts();
 
   const bool IsCompare = NullKind != Expr::NPCK_NotNull;
 
Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -79,9 +79,9 @@
   (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
 }
 
-int Postgresql() {
-  char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+int Postgresql(char *x) {
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
 }
 
 #define nil ((void*) 0)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38718: Patch to Bugzilla 20951

2017-10-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/Sema/conditional-expr.c:84
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), 
(unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional 
expressions with only one void side}}
 }

Please don't just remove previous tests.
E.g. does the old test no longer warns?



https://reviews.llvm.org/D38718



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


r315296 - [analyzer] Implement pointer arithmetic on constants

2017-10-10 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Oct 10 04:01:49 2017
New Revision: 315296

URL: http://llvm.org/viewvc/llvm-project?rev=315296&view=rev
Log:
[analyzer] Implement pointer arithmetic on constants

Patch by: Rafael Stahl!

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

Added:
cfe/trunk/test/Analysis/pointer-arithmetic.c
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp?rev=315296&r1=315295&r2=315296&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp Tue Oct 10 04:01:49 
2017
@@ -922,6 +922,10 @@ SVal SimpleSValBuilder::evalBinOpLN(Prog
   if (rhs.isZeroConstant())
 return lhs;
 
+  // Perserve the null pointer so that it can be found by the DerefChecker.
+  if (lhs.isZeroConstant())
+return lhs;
+
   // We are dealing with pointer arithmetic.
 
   // Handle pointer arithmetic on constant values.
@@ -937,6 +941,8 @@ SVal SimpleSValBuilder::evalBinOpLN(Prog
 
   // Offset the increment by the pointer size.
   llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
+  QualType pointeeType = resultTy->getPointeeType();
+  Multiplicand = 
getContext().getTypeSizeInChars(pointeeType).getQuantity();
   rightI *= Multiplicand;
 
   // Compute the adjusted pointer.

Added: cfe/trunk/test/Analysis/pointer-arithmetic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/pointer-arithmetic.c?rev=315296&view=auto
==
--- cfe/trunk/test/Analysis/pointer-arithmetic.c (added)
+++ cfe/trunk/test/Analysis/pointer-arithmetic.c Tue Oct 10 04:01:49 2017
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  // This is a special case where pointer arithmetic is not calculated to
+  // preserve useful warnings on dereferences of null pointers.
+  int *p = 0;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}


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


[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315296: [analyzer] Implement pointer arithmetic on constants 
(authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D37478?vs=118182&id=118342#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37478

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/pointer-arithmetic.c


Index: cfe/trunk/test/Analysis/pointer-arithmetic.c
===
--- cfe/trunk/test/Analysis/pointer-arithmetic.c
+++ cfe/trunk/test/Analysis/pointer-arithmetic.c
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  // This is a special case where pointer arithmetic is not calculated to
+  // preserve useful warnings on dereferences of null pointers.
+  int *p = 0;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -922,6 +922,10 @@
   if (rhs.isZeroConstant())
 return lhs;
 
+  // Perserve the null pointer so that it can be found by the DerefChecker.
+  if (lhs.isZeroConstant())
+return lhs;
+
   // We are dealing with pointer arithmetic.
 
   // Handle pointer arithmetic on constant values.
@@ -937,6 +941,8 @@
 
   // Offset the increment by the pointer size.
   llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
+  QualType pointeeType = resultTy->getPointeeType();
+  Multiplicand = 
getContext().getTypeSizeInChars(pointeeType).getQuantity();
   rightI *= Multiplicand;
 
   // Compute the adjusted pointer.


Index: cfe/trunk/test/Analysis/pointer-arithmetic.c
===
--- cfe/trunk/test/Analysis/pointer-arithmetic.c
+++ cfe/trunk/test/Analysis/pointer-arithmetic.c
@@ -0,0 +1,30 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+int test1() {
+  int *p = (int *)sizeof(int);
+  p -= 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test2() {
+  int *p = (int *)sizeof(int);
+  p -= 2;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test3() {
+  int *p = (int *)sizeof(int);
+  p++;
+  p--;
+  p--;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
+
+int test4() {
+  // This is a special case where pointer arithmetic is not calculated to
+  // preserve useful warnings on dereferences of null pointers.
+  int *p = 0;
+  p += 1;
+  return *p; // expected-warning {{Dereference of null pointer}}
+}
Index: cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -922,6 +922,10 @@
   if (rhs.isZeroConstant())
 return lhs;
 
+  // Perserve the null pointer so that it can be found by the DerefChecker.
+  if (lhs.isZeroConstant())
+return lhs;
+
   // We are dealing with pointer arithmetic.
 
   // Handle pointer arithmetic on constant values.
@@ -937,6 +941,8 @@
 
   // Offset the increment by the pointer size.
   llvm::APSInt Multiplicand(rightI.getBitWidth(), /* isUnsigned */ true);
+  QualType pointeeType = resultTy->getPointeeType();
+  Multiplicand = getContext().getTypeSizeInChars(pointeeType).getQuantity();
   rightI *= Multiplicand;
 
   // Compute the adjusted pointer.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38718: Patch to Bugzilla 20951

2017-10-10 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a reviewer: danielmarjamaki.
danielmarjamaki added a comment.

I think a test for -Wtautological-pointer-compare should be added that shows 
that the bug is fixed.




Comment at: test/Sema/conditional-expr.c:84
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), 
(unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional 
expressions with only one void side}}
 }

lebedev.ri wrote:
> Please don't just remove previous tests.
> E.g. does the old test no longer warns?
> 
no test is removed. The expected-warning is unchanged.

the problem with the test was that this comparison is always true:
```
(&x) != ((void *)0)
```
the address of x is never 0!

Fixing https://bugs.llvm.org/show_bug.cgi?id=20951 means Clang will warn:
```
warning: comparison of address of 'x' not equal to a null pointer is always 
true [-Wtautological-pointer-compare]
```

We changed the test so the -Wtautological-pointer-compare is not reported... 
but the original warning is still reported.



https://reviews.llvm.org/D38718



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


[PATCH] D38720: [clangd] Report proper kinds for 'Keyword' and 'Snippet' completion items.

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

https://reviews.llvm.org/D38720

Files:
  clangd/ClangdUnit.cpp
  test/clangd/completion-items-kinds.test


Index: test/clangd/completion-items-kinds.test
===
--- /dev/null
+++ test/clangd/completion-items-kinds.test
@@ -0,0 +1,37 @@
+# RUN: clangd -enable-snippets -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 220
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define
 MACRO X\nint variable;\nstruct Struct {};\n int function();\nint X = "}}}
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":7}}}
+Content-Length: 58
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+#
+# Keyword
+# CHECK-DAG: 
{"label":"int","kind":14,"sortText":"50int","filterText":"int","insertText":"int","insertTextFormat":1}
+#
+# Code pattern
+# CHECK-DAG: 
{"label":"static_cast(expression)","kind":15,"sortText":"40static_cast","filterText":"static_cast","insertText":"static_cast<${1:type}>(${2:expression})","insertTextFormat":2}
+#
+# Struct
+# CHECK-DAG: 
{"label":"Struct","kind":7,"sortText":"50Struct","filterText":"Struct","insertText":"Struct","insertTextFormat":1}
+#
+# Macro
+# CHECK-DAG: 
{"label":"MACRO","kind":1,"sortText":"70MACRO","filterText":"MACRO","insertText":"MACRO","insertTextFormat":1}
+#
+# Variable
+# CHECK-DAG: 
{"label":"variable","kind":6,"detail":"int","sortText":"12variable","filterText":"variable","insertText":"variable","insertTextFormat":1}
+#
+# Function
+# CHECK-DAG: 
{"label":"function()","kind":3,"detail":"int","sortText":"12function","filterText":"function","insertText":"function()","insertTextFormat":1}
+#
+#
+# CHECK: ]}
+
+{"jsonrpc":"2.0","id":3,"method":"shutdown","params":null}
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -268,8 +268,8 @@
 
 namespace {
 
-CompletionItemKind getKind(CXCursorKind K) {
-  switch (K) {
+CompletionItemKind getKindOfDecl(CXCursorKind CursorKind) {
+  switch (CursorKind) {
   case CXCursor_MacroInstantiation:
   case CXCursor_MacroDefinition:
 return CompletionItemKind::Text;
@@ -311,6 +311,22 @@
   }
 }
 
+CompletionItemKind getKind(CodeCompletionResult::ResultKind ResKind,
+   CXCursorKind CursorKind) {
+  switch (ResKind) {
+  case CodeCompletionResult::RK_Declaration:
+return getKindOfDecl(CursorKind);
+  case CodeCompletionResult::RK_Keyword:
+return CompletionItemKind::Keyword;
+  case CodeCompletionResult::RK_Macro:
+return CompletionItemKind::Text; // unfortunately, there's no 'Macro'
+ // completion items in LSP.
+  case CodeCompletionResult::RK_Pattern:
+return CompletionItemKind::Snippet;
+  }
+  llvm_unreachable("Unhandled CodeCompletionResult::ResultKind.");
+}
+
 std::string escapeSnippet(const llvm::StringRef Text) {
   std::string Result;
   Result.reserve(Text.size()); // Assume '$', '}' and '\\' are rare.
@@ -395,7 +411,7 @@
 ProcessChunks(CCS, Item);
 
 // Fill in the kind field of the CompletionItem.
-Item.kind = getKind(Result.CursorKind);
+Item.kind = getKind(Result.Kind, Result.CursorKind);
 
 FillSortText(CCS, Item);
 


Index: test/clangd/completion-items-kinds.test
===
--- /dev/null
+++ test/clangd/completion-items-kinds.test
@@ -0,0 +1,37 @@
+# RUN: clangd -enable-snippets -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 220
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO X\nint variable;\nstruct Struct {};\n int function();\nint X = "}}}
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":7}}}
+Content-Length: 58
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+#
+# Keyword
+# CHECK-DAG: {"label":"int","kind":14,"sortText":"50int","filterText":"int","insertText":"int","insertTextFormat":1}
+#
+# Code pattern
+# CHECK-DAG: {"label":"static_cast(expression)","kind":15,"sortText":"40static_cast","filterText":"static_cast","insertText":"static_cast<${1:type}>(${2:expression})","insert

[PATCH] D38718: [Sema] No -Wtautological-pointer-compare warning on variables within parentheses

2017-10-10 Thread Erik Viktorsson via Phabricator via cfe-commits
erikv updated this revision to Diff 118347.
erikv added a comment.

Added new test


Repository:
  rL LLVM

https://reviews.llvm.org/D38718

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/conditional-expr.c
  test/Sema/warn-tautological-compare.c


Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -79,9 +79,9 @@
   (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning 
{{pointer type mismatch}} expected-warning {{expression result unused}}
 }
 
-int Postgresql() {
-  char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 
0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids 
conditional expressions with only one void side}}
+int Postgresql(char *x) {
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), 
(unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional 
expressions with only one void side}}
 }
 
 #define nil ((void*) 0)
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9933,7 +9933,7 @@
 IsInAnyMacroBody(SM, Range.getBegin()))
   return;
   }
-  E = E->IgnoreImpCasts();
+  E = E->IgnoreParenImpCasts();
 
   const bool IsCompare = NullKind != Expr::NPCK_NotNull;
 
Index: test/Sema/warn-tautological-compare.c
===
--- test/Sema/warn-tautological-compare.c
+++ test/Sema/warn-tautological-compare.c
@@ -93,3 +93,11 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test_parentesens(short arg) {
+  if (0 ==
+  (&arg)) { // expected-warning {{comparison of address of 'arg' equal to 
a null pointer is always false}}
+  } else if (0 ==
+&arg) { // expected-warning {{comparison of address of 'arg' equal 
to a null pointer is always false}}
+  }
+}


Index: test/Sema/conditional-expr.c
===
--- test/Sema/conditional-expr.c
+++ test/Sema/conditional-expr.c
@@ -79,9 +79,9 @@
   (test0 ? (test0 ? adr2 : adr2) : nonconst_int); // expected-warning {{pointer type mismatch}} expected-warning {{expression result unused}}
 }
 
-int Postgresql() {
-  char x;
-  return &x) != ((void *) 0)) ? (*(&x) = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
+int Postgresql(char *x) {
+  //char x;
+  return (((x != ((void *) 0)) ? (*x = ((char) 1)) : (void) ((void *) 0)), (unsigned long) ((void *) 0)); // expected-warning {{C99 forbids conditional expressions with only one void side}}
 }
 
 #define nil ((void*) 0)
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -9933,7 +9933,7 @@
 IsInAnyMacroBody(SM, Range.getBegin()))
   return;
   }
-  E = E->IgnoreImpCasts();
+  E = E->IgnoreParenImpCasts();
 
   const bool IsCompare = NullKind != Expr::NPCK_NotNull;
 
Index: test/Sema/warn-tautological-compare.c
===
--- test/Sema/warn-tautological-compare.c
+++ test/Sema/warn-tautological-compare.c
@@ -93,3 +93,11 @@
   x = array ? 1 : 0; // expected-warning {{address of array}}
   x = &x ? 1 : 0;// expected-warning {{address of 'x'}}
 }
+
+void test_parentesens(short arg) {
+  if (0 ==
+  (&arg)) { // expected-warning {{comparison of address of 'arg' equal to a null pointer is always false}}
+  } else if (0 ==
+	 &arg) { // expected-warning {{comparison of address of 'arg' equal to a null pointer is always false}}
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38171: Implement clang-tidy check aliases.

2017-10-10 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Let's also summarize what do we have now and what do we want.

> I also think this sounds good, though I'm not quite sure it can be done in 
> this patch. Anyway, we should definitely specify what we expect from 
> first-class citizen checks. Please correct & extend the list:
> 
> - can be enabled or disabled through a unique name

This is addressed by the current pathc.

> - can have config options

Do you know warnings that have config options? Does this make sense for this 
featre?

> - can have aliases

Does that make sense to be able to add aliases to warning aliases? I

> - inherits ClangTidyCheck

I think this is just technical and this does not really affect the users.

In https://reviews.llvm.org/D38171#878808, @alexfh wrote:

> 1. Make `clang-diagnostic-*` checks first-class citizens and take full 
> control of all diagnostics, i.e. disable all Clang diagnostics by default, 
> and enable the ones that correspond to the enabled clang-diagnostic checks.


I think this might be a good idea in general. @leanil could you address this 
point in this patch?

> 2. Make aliases first-class citizens (there was a proposal as well, but we 
> didn't arrive to a consensus at that time). That would include the ability to 
> configure an alias name for any check including clang-diagnostic- and 
> clang-analyzer- checks.

I am not sure that this makes sense, see my points above.

> 3. Use aliases to map clang-diagnostic- checks to check names under cert-, 
> hicpp-, etc.

I agree.


https://reviews.llvm.org/D38171



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


[PATCH] D38718: [Sema] No -Wtautological-pointer-compare warning on variables within parentheses

2017-10-10 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

LGTM! However I would like to see a review from somebody else also.

There are a number of diagnostics that might be affected. The 
Sema::DiagnoseAlwaysNonNullPointer diagnoses these:

diag::warn_this_null_compare
diag::warn_this_bool_conversion
diag::warn_address_of_reference_null_compare
diag::warn_address_of_reference_bool_conversion
diag::warn_nonnull_expr_compare
diag::warn_cast_nonnull_to_bool
diag::warn_null_pointer_compare   <-- I think this is the one bug 20951 is about
diag::warn_impcast_pointer_to_bool

It seems to me that it is an improvement for all these warnings to skip the 
parentheses. However there is a danger that parentheses should hide some 
warnings to make it possible for users to hide unwanted warnings. But if that 
was the design decision then some regression test should complain when we skip 
the parentheses.


Repository:
  rL LLVM

https://reviews.llvm.org/D38718



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


r315298 - [analyzer] PthreadLockChecker: Add printState() method for self-debugging.

2017-10-10 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Oct 10 04:49:09 2017
New Revision: 315298

URL: http://llvm.org/viewvc/llvm-project?rev=315298&view=rev
Log:
[analyzer] PthreadLockChecker: Add printState() method for self-debugging.

This method injects additional information into program state dumps,
describing states of mutexes tracked by the checker.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp?rev=315298&r1=315297&r2=315298&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp Tue Oct 10 
04:49:09 2017
@@ -81,6 +81,8 @@ class PthreadLockChecker
 public:
   void checkPostStmt(const CallExpr *CE, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const override;
 
   void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock,
bool isTryLock, enum LockingSemantics semantics) const;
@@ -184,6 +186,39 @@ ProgramStateRef PthreadLockChecker::reso
   return state;
 }
 
+void PthreadLockChecker::printState(raw_ostream &Out, ProgramStateRef State,
+const char *NL, const char *Sep) const {
+  LockMapTy LM = State->get();
+  if (!LM.isEmpty()) {
+Out << Sep << "Mutex states:" << NL;
+for (auto I : LM) {
+  I.first->dumpToStream(Out);
+  if (I.second.isLocked())
+Out << ": locked";
+  else if (I.second.isUnlocked())
+Out << ": unlocked";
+  else if (I.second.isDestroyed())
+Out << ": destroyed";
+  else if (I.second.isUntouchedAndPossiblyDestroyed())
+Out << ": not tracked, possibly destroyed";
+  else if (I.second.isUnlockedAndPossiblyDestroyed())
+Out << ": unlocked, possibly destroyed";
+  Out << NL;
+}
+  }
+
+  LockSetTy LS = State->get();
+  if (!LS.isEmpty()) {
+Out << Sep << "Mutex lock order:" << NL;
+for (auto I: LS) {
+  I->dumpToStream(Out);
+  Out << NL;
+}
+  }
+
+  // TODO: Dump destroyed mutex symbols?
+}
+
 void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE,
  SVal lock, bool isTryLock,
  enum LockingSemantics semantics) const {


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


[PATCH] D37805: [analyzer] PthreadLock: add printState().

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315298: [analyzer] PthreadLockChecker: Add printState() 
method for self-debugging. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D37805?vs=115028&id=118349#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37805

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -81,6 +81,8 @@
 public:
   void checkPostStmt(const CallExpr *CE, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const override;
 
   void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock,
bool isTryLock, enum LockingSemantics semantics) const;
@@ -184,6 +186,39 @@
   return state;
 }
 
+void PthreadLockChecker::printState(raw_ostream &Out, ProgramStateRef State,
+const char *NL, const char *Sep) const {
+  LockMapTy LM = State->get();
+  if (!LM.isEmpty()) {
+Out << Sep << "Mutex states:" << NL;
+for (auto I : LM) {
+  I.first->dumpToStream(Out);
+  if (I.second.isLocked())
+Out << ": locked";
+  else if (I.second.isUnlocked())
+Out << ": unlocked";
+  else if (I.second.isDestroyed())
+Out << ": destroyed";
+  else if (I.second.isUntouchedAndPossiblyDestroyed())
+Out << ": not tracked, possibly destroyed";
+  else if (I.second.isUnlockedAndPossiblyDestroyed())
+Out << ": unlocked, possibly destroyed";
+  Out << NL;
+}
+  }
+
+  LockSetTy LS = State->get();
+  if (!LS.isEmpty()) {
+Out << Sep << "Mutex lock order:" << NL;
+for (auto I: LS) {
+  I->dumpToStream(Out);
+  Out << NL;
+}
+  }
+
+  // TODO: Dump destroyed mutex symbols?
+}
+
 void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE,
  SVal lock, bool isTryLock,
  enum LockingSemantics semantics) const {


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp
@@ -81,6 +81,8 @@
 public:
   void checkPostStmt(const CallExpr *CE, CheckerContext &C) const;
   void checkDeadSymbols(SymbolReaper &SymReaper, CheckerContext &C) const;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const override;
 
   void AcquireLock(CheckerContext &C, const CallExpr *CE, SVal lock,
bool isTryLock, enum LockingSemantics semantics) const;
@@ -184,6 +186,39 @@
   return state;
 }
 
+void PthreadLockChecker::printState(raw_ostream &Out, ProgramStateRef State,
+const char *NL, const char *Sep) const {
+  LockMapTy LM = State->get();
+  if (!LM.isEmpty()) {
+Out << Sep << "Mutex states:" << NL;
+for (auto I : LM) {
+  I.first->dumpToStream(Out);
+  if (I.second.isLocked())
+Out << ": locked";
+  else if (I.second.isUnlocked())
+Out << ": unlocked";
+  else if (I.second.isDestroyed())
+Out << ": destroyed";
+  else if (I.second.isUntouchedAndPossiblyDestroyed())
+Out << ": not tracked, possibly destroyed";
+  else if (I.second.isUnlockedAndPossiblyDestroyed())
+Out << ": unlocked, possibly destroyed";
+  Out << NL;
+}
+  }
+
+  LockSetTy LS = State->get();
+  if (!LS.isEmpty()) {
+Out << Sep << "Mutex lock order:" << NL;
+for (auto I: LS) {
+  I->dumpToStream(Out);
+  Out << NL;
+}
+  }
+
+  // TODO: Dump destroyed mutex symbols?
+}
+
 void PthreadLockChecker::AcquireLock(CheckerContext &C, const CallExpr *CE,
  SVal lock, bool isTryLock,
  enum LockingSemantics semantics) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315300 - [analyzer] MisusedMovedObject: Add printState() method for self-debugging.

2017-10-10 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Oct 10 04:50:45 2017
New Revision: 315300

URL: http://llvm.org/viewvc/llvm-project?rev=315300&view=rev
Log:
[analyzer] MisusedMovedObject: Add printState() method for self-debugging.

This method injects additional information into program state dumps,
describing which objects have been moved from.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp?rev=315300&r1=315299&r2=315300&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp Tue Oct 
10 04:50:45 2017
@@ -56,6 +56,8 @@ public:
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const override;
 
 private:
   class MovedBugVisitor : public BugReporterVisitorImpl {
@@ -476,6 +478,25 @@ ProgramStateRef MisusedMovedObjectChecke
   return State;
 }
 
+void MisusedMovedObjectChecker::printState(raw_ostream &Out,
+   ProgramStateRef State,
+   const char *NL,
+   const char *Sep) const {
+
+  TrackedRegionMapTy RS = State->get();
+
+  if (!RS.isEmpty()) {
+Out << Sep << "Moved-from objects :" << NL;
+for (auto I: RS) {
+  I.first->dumpToStream(Out);
+  if (I.second.isMoved())
+Out << ": moved";
+  else
+Out << ": moved and reported";
+  Out << NL;
+}
+  }
+}
 void ento::registerMisusedMovedObjectChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }


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


[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315300: [analyzer] MisusedMovedObject: Add printState() 
method for self-debugging. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D31541?vs=93661&id=118350#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31541

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
@@ -56,6 +56,8 @@
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const override;
 
 private:
   class MovedBugVisitor : public BugReporterVisitorImpl {
@@ -476,6 +478,25 @@
   return State;
 }
 
+void MisusedMovedObjectChecker::printState(raw_ostream &Out,
+   ProgramStateRef State,
+   const char *NL,
+   const char *Sep) const {
+
+  TrackedRegionMapTy RS = State->get();
+
+  if (!RS.isEmpty()) {
+Out << Sep << "Moved-from objects :" << NL;
+for (auto I: RS) {
+  I.first->dumpToStream(Out);
+  if (I.second.isMoved())
+Out << ": moved";
+  else
+Out << ": moved and reported";
+  Out << NL;
+}
+  }
+}
 void ento::registerMisusedMovedObjectChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
@@ -56,6 +56,8 @@
  ArrayRef ExplicitRegions,
  ArrayRef Regions,
  const LocationContext *LCtx, const CallEvent *Call) const;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const char *Sep) const override;
 
 private:
   class MovedBugVisitor : public BugReporterVisitorImpl {
@@ -476,6 +478,25 @@
   return State;
 }
 
+void MisusedMovedObjectChecker::printState(raw_ostream &Out,
+   ProgramStateRef State,
+   const char *NL,
+   const char *Sep) const {
+
+  TrackedRegionMapTy RS = State->get();
+
+  if (!RS.isEmpty()) {
+Out << Sep << "Moved-from objects :" << NL;
+for (auto I: RS) {
+  I.first->dumpToStream(Out);
+  if (I.second.isMoved())
+Out << ": moved";
+  else
+Out << ": moved and reported";
+  Out << NL;
+}
+  }
+}
 void ento::registerMisusedMovedObjectChecker(CheckerManager &mgr) {
   mgr.registerChecker();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315301 - [analyzer] MisusedMovedObject: Fix state-resetting a base-class sub-object.

2017-10-10 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Oct 10 04:55:56 2017
New Revision: 315301

URL: http://llvm.org/viewvc/llvm-project?rev=315301&view=rev
Log:
[analyzer] MisusedMovedObject: Fix state-resetting a base-class sub-object.

If a method is resetting the state of an object that was moved from, it should
be safe to use this object again. However if the method was defined in a parent
class, but used in a child class, the reset didn't happen from the checker's
perspective.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
cfe/trunk/test/Analysis/MisusedMovedObject.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp?rev=315301&r1=315300&r2=315301&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp 
(original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp Tue Oct 
10 04:55:56 2017
@@ -416,7 +416,14 @@ void MisusedMovedObjectChecker::checkPre
 return;
 
   if (isStateResetMethod(MethodDecl)) {
-State = State->remove(ThisRegion);
+// A state reset method resets the whole object, not only sub-object
+// of a parent class in which it is defined.
+const MemRegion *WholeObjectRegion = ThisRegion;
+while (const CXXBaseObjectRegion *BR =
+   dyn_cast(WholeObjectRegion))
+  WholeObjectRegion = BR->getSuperRegion();
+
+State = State->remove(WholeObjectRegion);
 C.addTransition(State);
 return;
   }

Modified: cfe/trunk/test/Analysis/MisusedMovedObject.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MisusedMovedObject.cpp?rev=315301&r1=315300&r2=315301&view=diff
==
--- cfe/trunk/test/Analysis/MisusedMovedObject.cpp (original)
+++ cfe/trunk/test/Analysis/MisusedMovedObject.cpp Tue Oct 10 04:55:56 2017
@@ -617,3 +617,11 @@ void subRegionMoveTest() {
 a.b.foo();   // no-warning
   }
 }
+
+class C: public A {};
+void resetSuperClass() {
+  C c;
+  C c1 = std::move(c);
+  c.clear();
+  C c2 = c; // no-warning
+}


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


[PATCH] D31538: [analyzer] MisusedMovedObjectChecker: Fix a false positive on state-resetting a base-class sub-object.

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315301: [analyzer] MisusedMovedObject: Fix state-resetting a 
base-class sub-object. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D31538?vs=93652&id=118351#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31538

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
  cfe/trunk/test/Analysis/MisusedMovedObject.cpp


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
@@ -416,7 +416,14 @@
 return;
 
   if (isStateResetMethod(MethodDecl)) {
-State = State->remove(ThisRegion);
+// A state reset method resets the whole object, not only sub-object
+// of a parent class in which it is defined.
+const MemRegion *WholeObjectRegion = ThisRegion;
+while (const CXXBaseObjectRegion *BR =
+   dyn_cast(WholeObjectRegion))
+  WholeObjectRegion = BR->getSuperRegion();
+
+State = State->remove(WholeObjectRegion);
 C.addTransition(State);
 return;
   }
Index: cfe/trunk/test/Analysis/MisusedMovedObject.cpp
===
--- cfe/trunk/test/Analysis/MisusedMovedObject.cpp
+++ cfe/trunk/test/Analysis/MisusedMovedObject.cpp
@@ -617,3 +617,11 @@
 a.b.foo();   // no-warning
   }
 }
+
+class C: public A {};
+void resetSuperClass() {
+  C c;
+  C c1 = std::move(c);
+  c.clear();
+  C c2 = c; // no-warning
+}


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp
@@ -416,7 +416,14 @@
 return;
 
   if (isStateResetMethod(MethodDecl)) {
-State = State->remove(ThisRegion);
+// A state reset method resets the whole object, not only sub-object
+// of a parent class in which it is defined.
+const MemRegion *WholeObjectRegion = ThisRegion;
+while (const CXXBaseObjectRegion *BR =
+   dyn_cast(WholeObjectRegion))
+  WholeObjectRegion = BR->getSuperRegion();
+
+State = State->remove(WholeObjectRegion);
 C.addTransition(State);
 return;
   }
Index: cfe/trunk/test/Analysis/MisusedMovedObject.cpp
===
--- cfe/trunk/test/Analysis/MisusedMovedObject.cpp
+++ cfe/trunk/test/Analysis/MisusedMovedObject.cpp
@@ -617,3 +617,11 @@
 a.b.foo();   // no-warning
   }
 }
+
+class C: public A {};
+void resetSuperClass() {
+  C c;
+  C c1 = std::move(c);
+  c.clear();
+  C c2 = c; // no-warning
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36471: [StaticAnalyzer] Try to calculate arithmetic result when operand has a range of possible values

2017-10-10 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D36471



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


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Eric Liu via cfe-commits
Hi Richard,

This is breaking the boostrap stage in the internal integration. I'm seeing
"unsupported: typedef changes linkage of anonymous type, but linkage was
already computed" error for many `struct`s defined with typedef. I'm not
sure if it is user code or clang that needs fixing; however, as there are
likely many more struct definitions that would cause the same failure, I'll
revert this commit as well as r315256, which depends on this. Sorry about
that.

I'll also send you the repros separately.

Regards,
Eric

On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Oct  9 16:42:09 2017
> New Revision: 315251
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315251&view=rev
> Log:
> [Modules TS] Module ownership semantics for redeclarations.
>
> When declaring an entity in the "purview" of a module, it's never a
> redeclaration of an entity in the purview of a default module or in no
> module
> ("in the global module"). Don't consider those other declarations as
> possible
> redeclaration targets if they're not visible, and reject any cases where we
> pick a prior visible declaration that violates this rule.
>
> Added:
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Lookup.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclBase.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExprMember.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251&r1=315250&r2=315251&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
> @@ -339,6 +339,12 @@ public:
>  return clang::isExternallyVisible(getLinkageInternal());
>}
>
> +  /// Determine whether this declaration can be redeclared in a
> +  /// different translation unit.
> +  bool isExternallyDeclarable() const {
> +return isExternallyVisible() && !getOwningModuleForLinkage();
> +  }
> +
>/// \brief Determines the visibility of this entity.
>Visibility getVisibility() const {
>  return getLinkageAndVisibility().getVisibility();
> @@ -379,10 +385,6 @@ public:
>  return hasCachedLinkage();
>}
>
> -  /// Get the module that owns this declaration for linkage purposes.
> -  /// There only ever is such a module under the C++ Modules TS.
> -  Module *getOwningModuleForLinkage() const;
> -
>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>/// the underlying named decl.
>NamedDecl *getUnderlyingDecl() {
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251&r1=315250&r2=315251&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
> @@ -738,6 +738,10 @@ public:
>  return isFromASTFile() ? getImportedOwningModule() :
> getLocalOwningModule();
>}
>
> +  /// Get the module that owns this declaration for linkage purposes.
> +  /// There only ever is such a module under the C++ Modules TS.
> +  Module *getOwningModuleForLinkage() const;
> +
>/// \brief Determine whether this declaration might be hidden from name
>/// lookup. Note that the declaration might be visible even if this
> returns
>/// \c false, if the owning module is visible within the query context.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315251&r1=315250&r2=315251&view=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct  9
> 16:42:09 2017
> @@ -4801,6 +4801,9 @@ def err_thread_non_thread : Error<
>  def err_thread_thread_differe

[PATCH] D38723: [clang-rename] Don't add prefix qualifiers to the declaration and definition of the renamed symbol.

2017-10-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D38723

Files:
  lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  unittests/Rename/RenameClassTest.cpp

Index: unittests/Rename/RenameClassTest.cpp
===
--- unittests/Rename/RenameClassTest.cpp
+++ unittests/Rename/RenameClassTest.cpp
@@ -469,8 +469,6 @@
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being added to the class definition and
-// constructor.
 TEST_F(ClangRenameTest, RenameClassWithNamespaceWithInlineMembers) {
   std::string Before = R"(
   namespace ns {
@@ -488,9 +486,9 @@
 )";
   std::string Expected = R"(
   namespace ns {
-  class ns::New {
+  class New {
public:
-ns::New() {}
+New() {}
 ~New() {}
 
 New* next() { return next_; }
@@ -504,8 +502,6 @@
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being added to the class definition and
-// constructor.
 TEST_F(ClangRenameTest, RenameClassWithNamespaceWithOutOfInlineMembers) {
   std::string Before = R"(
   namespace ns {
@@ -527,32 +523,32 @@
 )";
   std::string Expected = R"(
   namespace ns {
-  class ns::New {
+  class New {
public:
-ns::New();
+New();
 ~New();
 
 New* next();
 
private:
 New* next_;
   };
 
-  New::ns::New() {}
+  New::New() {}
   New::~New() {}
   New* New::next() { return next_; }
   }  // namespace ns
 )";
   std::string After = runClangRenameOnCode(Before, "ns::Old", "ns::New");
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being added to the definition.
 TEST_F(ClangRenameTest, RenameClassInInheritedConstructor) {
   // `using Base::Base;` will generate an implicit constructor containing usage
   // of `::ns::Old` which should not be matched.
   std::string Before = R"(
   namespace ns {
+  class Old;
   class Old {
 int x;
   };
@@ -574,7 +570,8 @@
   })";
   std::string Expected = R"(
   namespace ns {
-  class ns::New {
+  class New;
+  class New {
 int x;
   };
   class Base {
@@ -615,7 +612,7 @@
   )";
   std::string Expected = R"(
   namespace ns {
-  class ::new_ns::New {
+  class New {
   };
   } // namespace ns
   struct S {
@@ -632,7 +629,6 @@
   CompareSnippets(Expected, After);
 }
 
-// FIXME: no prefix qualifiers being adding to the definition.
 TEST_F(ClangRenameTest, ReferencesInLambdaFunctionParameters) {
   std::string Before = R"(
   template 
@@ -669,7 +665,7 @@
   };
 
   namespace ns {
-  class ::new_ns::New {};
+  class New {};
   void f() {
 function func;
   }
Index: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -160,13 +160,13 @@
 const Decl *Context;
 // The nested name being replaced (can be nullptr).
 const NestedNameSpecifier *Specifier;
+// Determine whether the prefix qualifiers of the NewName are known to be
+// ignored.
+// For example, if it is true and NewName is "a::b::foo", then the symbol
+// will be renamed to "foo".
+bool IgnorePrefixQualifers;
   };
 
-  // FIXME: Currently, prefix qualifiers will be added to the renamed symbol
-  // definition (e.g. "class Foo {};" => "class b::Bar {};" when renaming
-  // "a::Foo" to "b::Bar").
-  // For renaming declarations/definitions, prefix qualifiers should be filtered
-  // out.
   bool VisitNamedDecl(const NamedDecl *Decl) {
 // UsingDecl has been handled in other place.
 if (llvm::isa(Decl))
@@ -180,8 +180,12 @@
   return true;
 
 if (isInUSRSet(Decl)) {
-  RenameInfo Info = {Decl->getLocation(), Decl->getLocation(), nullptr,
- nullptr, nullptr};
+  RenameInfo Info = {Decl->getLocation(),
+ Decl->getLocation(),
+ /*FromDecl=*/nullptr,
+ /*Context=*/nullptr,
+ /*Specifier=*/nullptr,
+ /*IgnorePrefixQualifers=*/true};
   RenameInfos.push_back(Info);
 }
 return true;
@@ -191,8 +195,11 @@
 const NamedDecl *Decl = Expr->getFoundDecl();
 if (isInUSRSet(Decl)) {
   RenameInfo Info = {Expr->getSourceRange().getBegin(),
- Expr->getSourceRange().getEnd(), Decl,
- getClosestAncestorDecl(*Expr), Expr->getQualifier()};
+ Expr->getSourceRange().getEnd(),
+ Decl,
+ getClosestAncestorDecl(*Expr),
+ Expr->getQualifier(),
+ /*IgnorePrefixQualifers=*/false};
   RenameIn

Re: r315256 - [Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module.

2017-10-10 Thread Eric Liu via cfe-commits
I am reverting this commit as it depends on r315251. See r315251 thread for
reason.

On Tue, Oct 10, 2017 at 2:49 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Oct  9 17:49:38 2017
> New Revision: 315256
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315256&view=rev
> Log:
> [Modules TS] Avoid computing the linkage of the enclosing DeclContext for
> a declaration in the global module.
>
> This works around a language issue where adding a typedef name for linkage
> purposes changes the linkage of an already-defined class after it becomes
> complete.
>
> Added:
> cfe/trunk/test/Modules/anon-linkage.cpp
> Modified:
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Decl.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315256&r1=315255&r2=315256&view=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 17:49:38 2017
> @@ -740,7 +740,10 @@ public:
>
>/// Get the module that owns this declaration for linkage purposes.
>/// There only ever is such a module under the C++ Modules TS.
> -  Module *getOwningModuleForLinkage() const;
> +  ///
> +  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
> +  /// all declarations in a global module fragment are unowned.
> +  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
>
>/// \brief Determine whether this declaration might be hidden from name
>/// lookup. Note that the declaration might be visible even if this
> returns
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=315256&r1=315255&r2=315256&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct  9 17:49:38 2017
> @@ -3051,8 +3051,11 @@ public:
>
>RedeclarationKind forRedeclarationInCurContext() {
>  // A declaration with an owning module for linkage can never link
> against
> -// anything that is not visible.
> -if (cast(CurContext)->getOwningModuleForLinkage())
> +// anything that is not visible. We don't need to check linkage here;
> if
> +// the context has internal linkage, redeclaration lookup won't find
> things
> +// from other TUs, and we can't safely compute linkage yet in general.
> +if (cast(CurContext)
> +->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
>return ForVisibleRedeclaration;
>  return ForExternalRedeclaration;
>}
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=315256&r1=315255&r2=315256&view=diff
>
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Mon Oct  9 17:49:38 2017
> @@ -1395,7 +1395,7 @@ LinkageInfo LinkageComputer::getDeclLink
>  :
> NamedDecl::VisibilityForValue));
>  }
>
> -Module *Decl::getOwningModuleForLinkage() const {
> +Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
>Module *M = getOwningModule();
>if (!M)
>  return nullptr;
> @@ -1413,6 +1413,8 @@ Module *Decl::getOwningModuleForLinkage(
>  // for linkage purposes. But internal linkage declarations in the
> global
>  // module fragment of a particular module are owned by that module for
>  // linkage purposes.
> +if (IgnoreLinkage)
> +  return nullptr;
>  bool InternalLinkage;
>  if (auto *ND = dyn_cast(this))
>InternalLinkage = !ND->hasExternalFormalLinkage();
>
> Added: cfe/trunk/test/Modules/anon-linkage.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/anon-linkage.cpp?rev=315256&view=auto
>
> ==
> --- cfe/trunk/test/Modules/anon-linkage.cpp (added)
> +++ cfe/trunk/test/Modules/anon-linkage.cpp Mon Oct  9 17:49:38 2017
> @@ -0,0 +1,12 @@
> +// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s
> +
> +typedef struct {
> +  int c;
> +  union {
> +int n;
> +char c[4];
> +  } v;
> +} mbstate;
> +
> +export module M;
> +export using ::mbstate;
>
>
> ___
> 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


r315308 - Revert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module."

2017-10-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Oct 10 06:00:18 2017
New Revision: 315308

URL: http://llvm.org/viewvc/llvm-project?rev=315308&view=rev
Log:
Revert "[Modules TS] Avoid computing the linkage of the enclosing DeclContext 
for a declaration in the global module."

This reverts commit r315256. See the original commit thread for reason.

Removed:
cfe/trunk/test/Modules/anon-linkage.cpp
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315308&r1=315307&r2=315308&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Oct 10 06:00:18 2017
@@ -740,10 +740,7 @@ public:
 
   /// Get the module that owns this declaration for linkage purposes.
   /// There only ever is such a module under the C++ Modules TS.
-  ///
-  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
-  /// all declarations in a global module fragment are unowned.
-  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
+  Module *getOwningModuleForLinkage() const;
 
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=315308&r1=315307&r2=315308&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Oct 10 06:00:18 2017
@@ -3051,11 +3051,8 @@ public:
 
   RedeclarationKind forRedeclarationInCurContext() {
 // A declaration with an owning module for linkage can never link against
-// anything that is not visible. We don't need to check linkage here; if
-// the context has internal linkage, redeclaration lookup won't find things
-// from other TUs, and we can't safely compute linkage yet in general.
-if (cast(CurContext)
-->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
+// anything that is not visible.
+if (cast(CurContext)->getOwningModuleForLinkage())
   return ForVisibleRedeclaration;
 return ForExternalRedeclaration;
   }

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=315308&r1=315307&r2=315308&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Tue Oct 10 06:00:18 2017
@@ -1395,7 +1395,7 @@ LinkageInfo LinkageComputer::getDeclLink
 : NamedDecl::VisibilityForValue));
 }
 
-Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
+Module *Decl::getOwningModuleForLinkage() const {
   Module *M = getOwningModule();
   if (!M)
 return nullptr;
@@ -1413,8 +1413,6 @@ Module *Decl::getOwningModuleForLinkage(
 // for linkage purposes. But internal linkage declarations in the global
 // module fragment of a particular module are owned by that module for
 // linkage purposes.
-if (IgnoreLinkage)
-  return nullptr;
 bool InternalLinkage;
 if (auto *ND = dyn_cast(this))
   InternalLinkage = !ND->hasExternalFormalLinkage();

Removed: cfe/trunk/test/Modules/anon-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/anon-linkage.cpp?rev=315307&view=auto
==
--- cfe/trunk/test/Modules/anon-linkage.cpp (original)
+++ cfe/trunk/test/Modules/anon-linkage.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s
-
-typedef struct {
-  int c;
-  union {
-int n;
-char c[4];
-  } v;
-} mbstate;
-
-export module M;
-export using ::mbstate;


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


[PATCH] D38683: [X86][AVX512] lowering broadcastm intrinsic - clang part

2017-10-10 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: test/CodeGen/avx512cdintrin.c:106
+  // CHECK: insertelement <16 x i32> %{{.*}}, i32 %{{.*}}
+  return _mm512_broadcastmw_epi32(_mm512_cmpeq_epi32_mask ( a, b)); 
 }

Any reason why you can't use the actual insertion indices instead of regexps?


https://reviews.llvm.org/D38683



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


r315309 - Revert "[Modules TS] Module ownership semantics for redeclarations."

2017-10-10 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Oct 10 06:09:40 2017
New Revision: 315309

URL: http://llvm.org/viewvc/llvm-project?rev=315309&view=rev
Log:
Revert "[Modules TS] Module ownership semantics for redeclarations."

This reverts commit r315251. See the original commit thread for reason.

Removed:
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315309&r1=315308&r2=315309&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue Oct 10 06:09:40 2017
@@ -339,12 +339,6 @@ public:
 return clang::isExternallyVisible(getLinkageInternal());
   }
 
-  /// Determine whether this declaration can be redeclared in a
-  /// different translation unit.
-  bool isExternallyDeclarable() const {
-return isExternallyVisible() && !getOwningModuleForLinkage();
-  }
-
   /// \brief Determines the visibility of this entity.
   Visibility getVisibility() const {
 return getLinkageAndVisibility().getVisibility();
@@ -385,6 +379,10 @@ public:
 return hasCachedLinkage();
   }
 
+  /// Get the module that owns this declaration for linkage purposes.
+  /// There only ever is such a module under the C++ Modules TS.
+  Module *getOwningModuleForLinkage() const;
+
   /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
   /// the underlying named decl.
   NamedDecl *getUnderlyingDecl() {

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315309&r1=315308&r2=315309&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Tue Oct 10 06:09:40 2017
@@ -738,10 +738,6 @@ public:
 return isFromASTFile() ? getImportedOwningModule() : 
getLocalOwningModule();
   }
 
-  /// Get the module that owns this declaration for linkage purposes.
-  /// There only ever is such a module under the C++ Modules TS.
-  Module *getOwningModuleForLinkage() const;
-
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns
   /// \c false, if the owning module is visible within the query context.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315309&r1=315308&r2=315309&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct 10 06:09:40 
2017
@@ -4801,9 +4801,6 @@ def err_thread_non_thread : Error<
 def err_thread_thread_different_kind : Error<
   "thread-local declaration of %0 with %select{static|dynamic}1 initialization 
"
   "follows declaration with %select{dynamic|static}1 initialization">;
-def err_mismatched_owning_module : Error<
-  "declaration of %0 in %select{the global module|module %2}1 follows "
-  "declaration in %select{the global module|module %4}3">;
 def err_redefinition_different_type : Error<
   "redefinition of %0 with a different type%diff{: $ vs $|}1,2">;
 def err_redefinition_different_kind : Error<

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=315309&r1=315308&r2=315309&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Tue Oct 10 06:09:40 2017
@@ -139,7 +139,6 @@ public:
   LookupKind(LookupKind),
   IDNS(0),
   Redecl(Redecl != Sema::NotForRedeclaration),
-  ExternalRedecl(Redecl == Sema::ForExternalRedeclaration),
   HideTags(true),
   Diagnose(Redecl == Sema::NotForRedeclarati

Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread NAKAMURA Takumi via cfe-commits
FYI, I tweaked the tree in rL315283. Shall we restore it?

On Tue, Oct 10, 2017 at 9:41 PM Eric Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> This is breaking the boostrap stage in the internal integration. I'm
> seeing "unsupported: typedef changes linkage of anonymous type, but
> linkage was already computed" error for many `struct`s defined with
> typedef. I'm not sure if it is user code or clang that needs fixing;
> however, as there are likely many more struct definitions that would cause
> the same failure, I'll revert this commit as well as r315256, which depends
> on this. Sorry about that.
>
> I'll also send you the repros separately.
>
> Regards,
> Eric
>
> On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Oct  9 16:42:09 2017
>> New Revision: 315251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315251&view=rev
>> Log:
>> [Modules TS] Module ownership semantics for redeclarations.
>>
>> When declaring an entity in the "purview" of a module, it's never a
>> redeclaration of an entity in the purview of a default module or in no
>> module
>> ("in the global module"). Don't consider those other declarations as
>> possible
>> redeclaration targets if they're not visible, and reject any cases where
>> we
>> pick a prior visible declaration that violates this rule.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/test/SemaCXX/modules-ts.cppm
>>
>> Modified: cfe/trunk/include/clang/AST/Decl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251&r1=315250&r2=315251&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
>> @@ -339,6 +339,12 @@ public:
>>  return clang::isExternallyVisible(getLinkageInternal());
>>}
>>
>> +  /// Determine whether this declaration can be redeclared in a
>> +  /// different translation unit.
>> +  bool isExternallyDeclarable() const {
>> +return isExternallyVisible() && !getOwningModuleForLinkage();
>> +  }
>> +
>>/// \brief Determines the visibility of this entity.
>>Visibility getVisibility() const {
>>  return getLinkageAndVisibility().getVisibility();
>> @@ -379,10 +385,6 @@ public:
>>  return hasCachedLinkage();
>>}
>>
>> -  /// Get the module that owns this declaration for linkage purposes.
>> -  /// There only ever is such a module under the C++ Modules TS.
>> -  Module *getOwningModuleForLinkage() const;
>> -
>>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>>/// the underlying named decl.
>>NamedDecl *getUnderlyingDecl() {
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251&r1=315250&r2=315251&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
>> @@ -738,6 +738,10 @@ public:
>>  return isFromASTFile() ? getImportedOwningModule() :
>> getLocalOwningModule();
>>}
>>
>> +  /// Get the module that owns this declaration for linkage purposes.
>> +  /// There only ever is such a module under the C++ Modules TS.
>> +  Module *getOwningModuleForLinkage() const;
>> +
>>/// \brief Determine whether this declaration might be hidden from name
>>/// lookup. Note that the declaration might be visible even if this
>> returns
>>/// \c false, if the owning module is visible within the query context.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315251&r1=315250&r2=315251&view=diff
>>
>> =

[PATCH] D38452: Mark test as a long-test

2017-10-10 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Friendly ping :)


https://reviews.llvm.org/D38452



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


[PATCH] D38723: [clang-rename] Don't add prefix qualifiers to the declaration and definition of the renamed symbol.

2017-10-10 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with nits.




Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:163
 const NestedNameSpecifier *Specifier;
+// Determine whether the prefix qualifiers of the NewName are known to be
+// ignored.

s/are known to/should be/ ?



Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:166
+// For example, if it is true and NewName is "a::b::foo", then the symbol
+// will be renamed to "foo".
+bool IgnorePrefixQualifers;

maybe "... for both symbol references and symbol definitions", just for clarity?



Comment at: lib/Tooling/Refactoring/Rename/USRLocFinder.cpp:443
+  size_t LastColonPos = NewName.find_last_of(':');
+  if (LastColonPos != std::string::npos) {
+ReplacedName = NewName.substr(LastColonPos + 1);

nit: no braces


https://reviews.llvm.org/D38723



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


r315314 - Fix a (slightly weird) 'comma operator within array index expression' warning on VS builds. NFCI.

2017-10-10 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Oct 10 06:56:17 2017
New Revision: 315314

URL: http://llvm.org/viewvc/llvm-project?rev=315314&view=rev
Log:
Fix a (slightly weird) 'comma operator within array index expression' warning 
on VS builds. NFCI.

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=315314&r1=315313&r2=315314&view=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Oct 10 06:56:17 2017
@@ -5728,7 +5728,8 @@ void ASTReader::ReadPragmaDiagnosticMapp
 
   // Preserve the property that the imaginary root file describes the
   // current state.
-  auto &T = Diag.DiagStatesByLoc.Files[FileID()].StateTransitions;
+  FileID NullFile;
+  auto &T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
   if (T.empty())
 T.push_back({CurState, 0});
   else


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


r315315 - [OPENMP] Add default codegen|tests for 'target parallel for[ simd]'

2017-10-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Oct 10 07:14:43 2017
New Revision: 315315

URL: http://llvm.org/viewvc/llvm-project?rev=315315&view=rev
Log:
[OPENMP] Add default codegen|tests for 'target parallel for[ simd]'
constructs.

Added default codegen for 'target parallel for' construct + tests for
default codegen of 'target parallel for[ simd]' constructs.

Added:
cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_codegen.cpp
Modified:
cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp

Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=315315&r1=315314&r2=315315&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Oct 10 07:14:43 2017
@@ -4126,7 +4126,14 @@ void CodeGenFunction::EmitOMPTargetParal
 
 void CodeGenFunction::EmitOMPTargetParallelForDirective(
 const OMPTargetParallelForDirective &S) {
-  // TODO: codegen for target parallel for.
+  OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
+  CGM.getOpenMPRuntime().emitInlinedDirective(
+  *this, OMPD_target_parallel_for,
+  [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+OMPLoopScope PreInitScope(CGF, S);
+CGF.EmitStmt(
+cast(S.getAssociatedStmt())->getCapturedStmt());
+  });
 }
 
 /// Emit a helper variable and return corresponding lvalue.

Added: cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp?rev=315315&view=auto
==
--- cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp (added)
+++ cfe/trunk/test/OpenMP/target_parallel_for_codegen.cpp Tue Oct 10 07:14:43 
2017
@@ -0,0 +1,232 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TERM_DEBUG
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+long long get_val() { return 0; }
+double *g_ptr;
+
+// CHECK-LABEL: define {{.*void}} @{{.*}}simple{{.*}}(float* {{.+}}, float* 
{{.+}}, float* {{.+}}, float* {{.+}})
+void simple(float *a, float *b, float *c, float *d) {
+  // CHECK: store i32 3, i32* %
+  // CHECK: icmp slt i32 %{{.+}}, 32
+  // CHECK: fmul float
+  // CHECK: fmul float
+  // CHECK: add nsw i32 %{{.+}}, 5
+  #pragma omp target parallel for device((int)*a)
+  for (int i = 3; i < 32; i += 5) {
+a[i] = b[i] * c[i] * d[i];
+  }
+
+  // CHECK: call i{{.+}} @{{.+}}get_val{{.+}}()
+  // CHECK: store i32 10, i32* %
+  // CHECK: icmp sgt i32 %{{.+}}, 1
+  // CHECK: fadd float %{{.+}}, 1.00e+00
+  // CHECK: add nsw {{.+}} %{{.+}}, 3
+  // CHECK: add nsw i32 %{{.+}}, -1
+  long long k = get_val();
+  #pragma omp target parallel for linear(k : 3) schedule(dynamic)
+  for (int i = 10; i > 1; i--) {
+a[k]++;
+k = k + 3;
+  }
+
+  // CHECK: store i32 12, i32* %
+  // CHECK: store i{{.+}} 2000, i{{.+}}* %
+  // CHECK: icmp uge i{{.+}} %{{.+}}, 600
+  // CHECK: store double 0.00e+00,
+  // CHECK: fadd float %{{.+}}, 1.00e+00
+  // CHECK: sub i{{.+}} %{{.+}}, 400
+  int lin = 12;
+  #pragma omp target parallel for linear(lin : get_val()), linear(g_ptr)
+  for (unsigned long long it = 2000; it >= 600; it-=400) {
+*g_ptr++ = 0.0;
+a[it + lin]++;
+  }
+
+  // CHECK: store i{{.+}} 6, i{{.+}}* %
+  // CHECK: icmp sle i{{.+}} %{{.+}}, 20
+  // CHECK: sub nsw i{{.+}} %{{.+}}, -4
+  #pragma omp target parallel for
+  for (short it = 6; it <= 20; it-=-4) {
+  }
+
+  // CHECK: store i8 122, i8* %
+  // CHECK: icmp sge i32 %{{.+}}, 97
+  // CHECK: add nsw i32 %{{.+}}, -1
+  #pragma omp target parallel for
+  for (unsigned char it = 'z'; it >= 'a'; it+=-1) {
+  }
+
+  // CHECK: store i32 100, i32* %
+  // CHECK: icmp ult i32 %{{.+}}, 10
+  // CHECK: add i32 %{{.+}}, 10
+  #pragma omp target parallel for
+  for (unsigned i=100; i<10; i+=10) {
+  }
+
+  int A;
+  {
+  A = -1;
+  // CHECK: store i{{.+}} -10, i{{.+}}* %
+  // CHECK: icmp slt i{{.+}} %{{.+}}, 10
+  // CHECK: add nsw i{{.+}} %{{.+}}, 3
+  #pragma omp target parallel for lastprivate(A)
+  for (long long i = -10; i < 10; i += 3) {
+A = i;
+  }
+  }
+  int R;
+  {
+  R = -1;
+  // CHECK: store i{{.+}} -10, i{{.+}}* %
+  // CHECK: icmp slt i{{.+}} %{{.+}

[PATCH] D38731: [clangd] Allow to pass code completion opts to ClangdServer.

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

https://reviews.llvm.org/D38731

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

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -135,6 +135,33 @@
 namespace clangd {
 namespace {
 
+struct StringWithPos {
+  std::string Text;
+  clangd::Position MarkerPos;
+};
+
+/// Returns location of "{mark}" substring in \p Text and removes it from \p
+/// Text. Note that \p Text must contain exactly one occurence of "{mark}".
+///
+/// Marker name can be configured using \p MarkerName parameter.
+StringWithPos parseTextMarker(StringRef Text, StringRef MarkerName = "mark") {
+  SmallString<16> Marker;
+  Twine("{" + MarkerName + "}").toVector(/*ref*/ Marker);
+
+  std::size_t MarkerOffset = Text.find(Marker);
+  assert(MarkerOffset != StringRef::npos && "{mark} wasn't found in Text.");
+
+  std::string WithoutMarker;
+  WithoutMarker += Text.take_front(MarkerOffset);
+  WithoutMarker += Text.drop_front(MarkerOffset + Marker.size());
+  assert(StringRef(WithoutMarker).find(Marker) == StringRef::npos &&
+ "There were multiple occurences of {mark} inside Text");
+
+  clangd::Position MarkerPos =
+  clangd::offsetToPosition(WithoutMarker, MarkerOffset);
+  return {std::move(WithoutMarker), MarkerPos};
+}
+
 // Don't wait for async ops in clangd test more than that to avoid blocking
 // indefinitely in case of bugs.
 static const std::chrono::seconds DefaultFutureTimeout =
@@ -305,7 +332,7 @@
 ErrorCheckingDiagConsumer DiagConsumer;
 MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-/*SnippetCompletions=*/false,
+clangd::CodeCompleteOptions(),
 EmptyLogger::getInstance());
 for (const auto &FileWithContents : ExtraFiles)
   FS.Files[getVirtualTestFilePath(FileWithContents.first)] =
@@ -369,7 +396,8 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
+  clangd::CodeCompleteOptions(),
+  EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -414,7 +442,8 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
 
   ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
-  /*SnippetCompletions=*/false, EmptyLogger::getInstance());
+  clangd::CodeCompleteOptions(),
+  EmptyLogger::getInstance());
 
   const auto SourceContents = R"cpp(
 #include "foo.h"
@@ -461,7 +490,7 @@
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   auto FooCpp = getVirtualTestFilePath("foo.cpp");
@@ -495,7 +524,7 @@
   "-stdlib=libstdc++"});
   // Run ClangdServer synchronously.
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
 
   // Just a random gcc version string
@@ -544,7 +573,7 @@
   ErrorCheckingDiagConsumer DiagConsumer;
   MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
   ClangdServer Server(CDB, DiagConsumer, FS,
-  /*AsyncThreadsCount=*/0, /*SnippetCompletions=*/false,
+  /*AsyncThreadsCount=*/0, clangd::CodeCompleteOptions(),
   EmptyLogger::getInstance());
   // No need to sync reparses, because reparses are performed on the calling
   // thread to true.
@@ -589,22 +618,32 @@
 
 class ClangdCompletionTest : public ClangdVFSTest {
 protected:
-  bool ContainsItem(std::vector const &Items, StringRef Name) {
+  template 
+  bool ContainsItemPred(std::vector const &Items,
+Predicate Pred) {
 for (const auto &Item : Items) {
-  if (Item.insertText == Name)
+  if (Pred(Item))
 return true;
 }
 return false;
   }
+
+  bool ContainsItem(std::vector const &Items, StringRef Name) {
+return ContainsItemPred(Items, [Name](clangd::CompletionItem Item) {
+  return Item.insertText == Name;
+});
+return false;
+  }
 };
 
 TEST_F(ClangdCompl

[clang-tools-extra] r315317 - [clangd] clang-format the source code. NFC.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 07:21:04 2017
New Revision: 315317

URL: http://llvm.org/viewvc/llvm-project?rev=315317&view=rev
Log:
[clangd] clang-format the source code. NFC.

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=315317&r1=315316&r2=315317&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Tue Oct 10 
07:21:04 2017
@@ -40,7 +40,7 @@ tooling::CompileCommand getDefaultCompil
 DirectoryBasedGlobalCompilationDatabase::
 DirectoryBasedGlobalCompilationDatabase(
 clangd::Logger &Logger, llvm::Optional CompileCommandsDir)
-: Logger(Logger), CompileCommandsDir(std::move(CompileCommandsDir)) {}
+: Logger(Logger), CompileCommandsDir(std::move(CompileCommandsDir)) {}
 
 std::vector
 DirectoryBasedGlobalCompilationDatabase::getCompileCommands(PathRef File) {

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=315317&r1=315316&r2=315317&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Tue Oct 10 07:21:04 2017
@@ -182,7 +182,8 @@ std::string Location::unparse(const Loca
 }
 
 llvm::Optional
-TextDocumentItem::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
&Logger) {
+TextDocumentItem::parse(llvm::yaml::MappingNode *Params,
+clangd::Logger &Logger) {
   TextDocumentItem Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -552,7 +553,8 @@ TextDocumentContentChangeEvent::parse(ll
 }
 
 llvm::Optional
-FormattingOptions::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
&Logger) {
+FormattingOptions::parse(llvm::yaml::MappingNode *Params,
+ clangd::Logger &Logger) {
   FormattingOptions Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -767,7 +769,8 @@ llvm::Optional Diagnostic::p
 }
 
 llvm::Optional
-CodeActionContext::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
&Logger) {
+CodeActionContext::parse(llvm::yaml::MappingNode *Params,
+ clangd::Logger &Logger) {
   CodeActionContext Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());
@@ -800,7 +803,8 @@ CodeActionContext::parse(llvm::yaml::Map
 }
 
 llvm::Optional
-CodeActionParams::parse(llvm::yaml::MappingNode *Params, clangd::Logger 
&Logger) {
+CodeActionParams::parse(llvm::yaml::MappingNode *Params,
+clangd::Logger &Logger) {
   CodeActionParams Result;
   for (auto &NextKeyValue : *Params) {
 auto *KeyString = dyn_cast(NextKeyValue.getKey());

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp?rev=315317&r1=315316&r2=315317&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp Tue Oct 10 07:21:04 2017
@@ -265,8 +265,8 @@ private:
 } // namespace
 
 void clangd::registerCallbackHandlers(JSONRPCDispatcher &Dispatcher,
- JSONOutput &Out,
- ProtocolCallbacks &Callbacks) {
+  JSONOutput &Out,
+  ProtocolCallbacks &Callbacks) {
   Dispatcher.registerHandler(
   "initialize", llvm::make_unique(Out, Callbacks));
   Dispatcher.registerHandler(


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


[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Michael Ferguson via Phabricator via cfe-commits
mppf added a comment.

Since I don't have commit access, could somebody commit this for me please? 
Thanks.


https://reviews.llvm.org/D38473



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


[PATCH] D38733: [CodeGen] Generate TBAA info along with LValue base info

2017-10-10 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

This patch enables explicit generation of TBAA information in all cases where 
LValue base info is propagated or constructed in non-trivial ways. Eventually, 
we will consider each of these cases to make sure the TBAA information is 
correct and not too conservative. For now, we just fall back to generating TBAA 
info from the access type.

This patch should not bring in any functional changes.

This is part of https://reviews.llvm.org/D38126 reworked to be a separate patch 
to simplify review.


Repository:
  rL LLVM

https://reviews.llvm.org/D38733

Files:
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1917,9 +1917,9 @@
 CGM.getTBAAAccessInfo(T));
   }
 
-  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo) {
-return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
-CGM.getTBAAAccessInfo(T));
+  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo,
+TBAAAccessInfo TBAAInfo) {
+return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
@@ -1930,25 +1930,28 @@
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-LValueBaseInfo BaseInfo) {
+LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
-BaseInfo, CGM.getTBAAAccessInfo(T));
+BaseInfo, TBAAInfo);
   }
 
   LValue MakeNaturalAlignPointeeAddrLValue(llvm::Value *V, QualType T);
   LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T);
   CharUnits getNaturalTypeAlignment(QualType T,
 LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr,
 bool forPointeeType = false);
   CharUnits getNaturalPointeeTypeAlignment(QualType T,
LValueBaseInfo *BaseInfo = nullptr);
 
   Address EmitLoadOfReference(Address Ref, const ReferenceType *RefTy,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfReferenceLValue(Address Ref, const ReferenceType *RefTy);
 
   Address EmitLoadOfPointer(Address Ptr, const PointerType *PtrTy,
-LValueBaseInfo *BaseInfo = nullptr);
+LValueBaseInfo *BaseInfo = nullptr,
+TBAAAccessInfo *TBAAInfo = nullptr);
   LValue EmitLoadOfPointerLValue(Address Ptr, const PointerType *PtrTy);
 
   /// CreateTempAlloca - This creates an alloca and inserts it into the entry
@@ -3327,7 +3330,8 @@
   Address EmitCXXMemberDataPointerAddress(const Expr *E, Address base,
   llvm::Value *memberPtr,
   const MemberPointerType *memberPtrType,
-  LValueBaseInfo *BaseInfo = nullptr);
+  LValueBaseInfo *BaseInfo = nullptr,
+  TBAAAccessInfo *TBAAInfo = nullptr);
   RValue EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
   ReturnValueSlot ReturnValue);
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -120,12 +120,17 @@
 CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T,
 LValueBaseInfo *BaseInfo) {
   return getNaturalTypeAlignment(T->getPointeeType(), BaseInfo,
- /*forPointee*/ true);
+ /* TBAAInfo= */ nullptr,
+ /* forPointeeType= */ true);
 }
 
 CharUnits CodeGenFunction::getNaturalTypeAlignment(QualType T,
LValueBaseInfo *BaseInfo,
+   TBAAAccessInfo *TBAAInfo,
bool forPointeeType) {
+  if (TBAAInfo)
+*TBAAInfo = CGM.getTBAAAccessInfo(T);
+
   // Honor alignment typedef attributes even on incomplete types.
   // We also honor them straight for C++ class types, even as pointees;
   // there's an expre

[PATCH] D38737: [X86] test/testn intrinsics lowering to IR. clang side

2017-10-10 Thread Uriel Korach via Phabricator via cfe-commits
uriel.k created this revision.

Changed Header files of the intrinsics fro lowering test and testn intrinsics 
to IR code.
Removed test and testn builtins from clang

this is the clang side, the llvm side revision is D38736 
.


https://reviews.llvm.org/D38737

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx512bwintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vlbwintrin.h
  lib/Headers/avx512vlintrin.h
  test/CodeGen/avx512bw-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vlbw-builtins.c

Index: test/CodeGen/avx512vlbw-builtins.c
===
--- test/CodeGen/avx512vlbw-builtins.c
+++ test/CodeGen/avx512vlbw-builtins.c
@@ -2481,97 +2481,121 @@
 }
 __mmask16 test_mm_test_epi8_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i8> %{{.*}}, %{{.*}}
   return _mm_test_epi8_mask(__A, __B); 
 }
 
 __mmask16 test_mm_mask_test_epi8_mask(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
   return _mm_mask_test_epi8_mask(__U, __A, __B); 
 }
 
 __mmask32 test_mm256_test_epi8_mask(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <32 x i8> %{{.*}}, %{{.*}}
   return _mm256_test_epi8_mask(__A, __B); 
 }
 
 __mmask32 test_mm256_mask_test_epi8_mask(__mmask32 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_test_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <32 x i1> %{{.*}}, %{{.*}}
   return _mm256_mask_test_epi8_mask(__U, __A, __B); 
 }
 
 __mmask8 test_mm_test_epi16_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <8 x i16> %{{.*}}, %{{.*}}
   return _mm_test_epi16_mask(__A, __B); 
 }
 
 __mmask8 test_mm_mask_test_epi16_mask(__mmask8 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <8 x i16> %{{.*}}, %{{.*}}
+  // CHECK: and <8 x i1> %{{.*}}, %{{.*}}
   return _mm_mask_test_epi16_mask(__U, __A, __B); 
 }
 
 __mmask16 test_mm256_test_epi16_mask(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i16> %{{.*}}, %{{.*}}
   return _mm256_test_epi16_mask(__A, __B); 
 }
 
 __mmask16 test_mm256_mask_test_epi16_mask(__mmask16 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_test_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestm.w.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp ne <16 x i16> %{{.*}}, %{{.*}}
+  // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
   return _mm256_mask_test_epi16_mask(__U, __A, __B); 
 }
 
 __mmask16 test_mm_testn_epi8_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <16 x i8> %{{.*}}, %{{.*}}
   return _mm_testn_epi8_mask(__A, __B); 
 }
 
 __mmask16 test_mm_mask_testn_epi8_mask(__mmask16 __U, __m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_mask_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.128
+  // CHECK: and <2 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <16 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <16 x i1> %{{.*}}, %{{.*}}
   return _mm_mask_testn_epi8_mask(__U, __A, __B); 
 }
 
 __mmask32 test_mm256_testn_epi8_mask(__m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <32 x i8> %{{.*}}, %{{.*}}
   return _mm256_testn_epi8_mask(__A, __B); 
 }
 
 __mmask32 test_mm256_mask_testn_epi8_mask(__mmask32 __U, __m256i __A, __m256i __B) {
   // CHECK-LABEL: @test_mm256_mask_testn_epi8_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.b.256
+  // CHECK: and <4 x i64> %{{.*}}, %{{.*}}
+  // CHECK: icmp eq <32 x i8> %{{.*}}, %{{.*}}
+  // CHECK: and <32 x i1> %{{.*}}, %{{.*}}
   return _mm256_mask_testn_epi8_mask(__U, __A, __B); 
 }
 
 __mmask8 test_mm_testn_epi16_mask(__m128i __A, __m128i __B) {
   // CHECK-LABEL: @test_mm_testn_epi16_mask
-  // CHECK: @llvm.x86.avx512.ptestnm.w.128
+  // CHECK: and <2 x i64> %{{.*}}, %{

[PATCH] D38728: [analyzer] Use the signature of the primary template for issue hash calculation

2017-10-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: lib/StaticAnalyzer/Core/IssueHash.cpp:39
+  // primary template.
+  if (const FunctionDecl *InstantiatedFrom =
+  Target->getInstantiatedFromMemberFunction())

Could we use here FunctionDecl::getPrimaryTemplate() ? That seems more general, 
it handles both specializations and instantiations.



Comment at: test/Analysis/bug_hash_test.cpp:61
 
-// CHECK: diagnostics
+template 
+T f(T i) {

We could add a few more test cases:
- a function template in class template
- specializations vs instantiations
- the combination of the above two (?)




Comment at: test/Analysis/bug_hash_test.cpp:1363
 // CHECK-NEXT:  
+// CHECK-NEXT:  
+// CHECK-NEXT:   path

I am not sure if this is possible, but could we add unit test just for the 
`GetSignature` function? Instead of these huge plist files?

I am thinking something like this:
https://github.com/martong/friend-stats/blob/ed0c69ea3669c933204c799f59b85cd7b2507c34/ut/FriendFunctionsTest.cpp#L31


Repository:
  rL LLVM

https://reviews.llvm.org/D38728



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


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Hans Wennborg via cfe-commits
Thanks for reverting.

We saw build failures in Chromium too. E.g. from
https://build.chromium.org/p/chromium.clang/builders/ToTLinux/builds/134:

In file included from
../../third_party/breakpad/breakpad/src/common/linux/symbol_upload.cc:34:
../../third_party/breakpad/breakpad/src/common/linux/symbol_upload.h:51:3:
error: unsupported: typedef changes linkage of anonymous type, but
linkage was already computed
} Options;
  ^
../../third_party/breakpad/breakpad/src/common/linux/symbol_upload.h:44:15:
note: use a tag name here to establish linkage prior to definition
typedef struct {
  ^
   Options


On Tue, Oct 10, 2017 at 5:41 AM, Eric Liu via cfe-commits
 wrote:
> Hi Richard,
>
> This is breaking the boostrap stage in the internal integration. I'm seeing
> "unsupported: typedef changes linkage of anonymous type, but linkage was
> already computed" error for many `struct`s defined with typedef. I'm not
> sure if it is user code or clang that needs fixing; however, as there are
> likely many more struct definitions that would cause the same failure, I'll
> revert this commit as well as r315256, which depends on this. Sorry about
> that.
>
> I'll also send you the repros separately.
>
> Regards,
> Eric
>
> On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits
>  wrote:
>>
>> Author: rsmith
>> Date: Mon Oct  9 16:42:09 2017
>> New Revision: 315251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315251&view=rev
>> Log:
>> [Modules TS] Module ownership semantics for redeclarations.
>>
>> When declaring an entity in the "purview" of a module, it's never a
>> redeclaration of an entity in the purview of a default module or in no
>> module
>> ("in the global module"). Don't consider those other declarations as
>> possible
>> redeclaration targets if they're not visible, and reject any cases where
>> we
>> pick a prior visible declaration that violates this rule.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/test/SemaCXX/modules-ts.cppm
>>
>> Modified: cfe/trunk/include/clang/AST/Decl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251&r1=315250&r2=315251&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
>> @@ -339,6 +339,12 @@ public:
>>  return clang::isExternallyVisible(getLinkageInternal());
>>}
>>
>> +  /// Determine whether this declaration can be redeclared in a
>> +  /// different translation unit.
>> +  bool isExternallyDeclarable() const {
>> +return isExternallyVisible() && !getOwningModuleForLinkage();
>> +  }
>> +
>>/// \brief Determines the visibility of this entity.
>>Visibility getVisibility() const {
>>  return getLinkageAndVisibility().getVisibility();
>> @@ -379,10 +385,6 @@ public:
>>  return hasCachedLinkage();
>>}
>>
>> -  /// Get the module that owns this declaration for linkage purposes.
>> -  /// There only ever is such a module under the C++ Modules TS.
>> -  Module *getOwningModuleForLinkage() const;
>> -
>>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>>/// the underlying named decl.
>>NamedDecl *getUnderlyingDecl() {
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251&r1=315250&r2=315251&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
>> @@ -738,6 +738,10 @@ public:
>>  return isFromASTFile() ? getImportedOwningModule() :
>> getLocalOwningModule();
>>}
>>
>> +  /// Get the module that owns this declaration for linkage purposes.
>> +  /// There only ever is such a module under the C++ Modules TS.
>> +  Module *getOwningModuleForLi

Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Richard Smith via cfe-commits
On 10 Oct 2017 05:41, "Eric Liu via cfe-commits" 
wrote:

Hi Richard,

This is breaking the boostrap stage in the internal integration. I'm seeing
"unsupported: typedef changes linkage of anonymous type, but linkage was
already computed" error for many `struct`s defined with typedef. I'm not
sure if it is user code or clang that needs fixing; however, as there are
likely many more struct definitions that would cause the same failure, I'll
revert this commit as well as r315256, which depends on this. Sorry about
that.


r315256 should have fixed those errors. Did it not?

I'll also send you the repros separately.

Regards,
Eric

On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Oct  9 16:42:09 2017
> New Revision: 315251
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315251&view=rev
> Log:
> [Modules TS] Module ownership semantics for redeclarations.
>
> When declaring an entity in the "purview" of a module, it's never a
> redeclaration of an entity in the purview of a default module or in no
> module
> ("in the global module"). Don't consider those other declarations as
> possible
> redeclaration targets if they're not visible, and reject any cases where we
> pick a prior visible declaration that violates this rule.
>
> Added:
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-
> vs-module.cpp
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-
> vs-global.cpp
> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-
> vs-module.cpp
> Modified:
> cfe/trunk/include/clang/AST/Decl.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Lookup.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/DeclBase.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
> cfe/trunk/lib/Sema/SemaExprMember.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/Decl.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Decl.h?rev=315251&r1=315250&r2=315251&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Decl.h (original)
> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
> @@ -339,6 +339,12 @@ public:
>  return clang::isExternallyVisible(getLinkageInternal());
>}
>
> +  /// Determine whether this declaration can be redeclared in a
> +  /// different translation unit.
> +  bool isExternallyDeclarable() const {
> +return isExternallyVisible() && !getOwningModuleForLinkage();
> +  }
> +
>/// \brief Determines the visibility of this entity.
>Visibility getVisibility() const {
>  return getLinkageAndVisibility().getVisibility();
> @@ -379,10 +385,6 @@ public:
>  return hasCachedLinkage();
>}
>
> -  /// Get the module that owns this declaration for linkage purposes.
> -  /// There only ever is such a module under the C++ Modules TS.
> -  Module *getOwningModuleForLinkage() const;
> -
>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>/// the underlying named decl.
>NamedDecl *getUnderlyingDecl() {
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclBase.h?rev=315251&r1=315250&r2=315251&view=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
> @@ -738,6 +738,10 @@ public:
>  return isFromASTFile() ? getImportedOwningModule() :
> getLocalOwningModule();
>}
>
> +  /// Get the module that owns this declaration for linkage purposes.
> +  /// There only ever is such a module under the C++ Modules TS.
> +  Module *getOwningModuleForLinkage() const;
> +
>/// \brief Determine whether this declaration might be hidden from name
>/// lookup. Note that the declaration might be visible even if this
> returns
>/// \c false, if the owning module is visible within the query context.
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=315251&r1=315250&r2=315251&view=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/Diagnost

[clang-tools-extra] r315324 - [clangd] Added missing #includes to Function.h

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 09:12:50 2017
New Revision: 315324

URL: http://llvm.org/viewvc/llvm-project?rev=315324&view=rev
Log:
[clangd] Added missing #includes to Function.h

Modified:
clang-tools-extra/trunk/clangd/Function.h

Modified: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315324&r1=315323&r2=315324&view=diff
==
--- clang-tools-extra/trunk/clangd/Function.h (original)
+++ clang-tools-extra/trunk/clangd/Function.h Tue Oct 10 09:12:50 2017
@@ -14,6 +14,9 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
 
+#include "llvm/ADT/STLExtras.h"
+#include 
+#include 
 #include 
 #include 
 #include 


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


[clang-tools-extra] r315323 - [clangd] Added forgotten return in UniqueFunction.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 09:12:47 2017
New Revision: 315323

URL: http://llvm.org/viewvc/llvm-project?rev=315323&view=rev
Log:
[clangd] Added forgotten return in UniqueFunction.

This hasn't bitten us because we only used functions returning
'void'.

Modified:
clang-tools-extra/trunk/clangd/Function.h

Modified: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315323&r1=315322&r2=315323&view=diff
==
--- clang-tools-extra/trunk/clangd/Function.h (original)
+++ clang-tools-extra/trunk/clangd/Function.h Tue Oct 10 09:12:47 2017
@@ -46,7 +46,7 @@ public:
 
   Ret operator()(Args... As) {
 assert(CallablePtr);
-CallablePtr->Call(std::forward(As)...);
+return CallablePtr->Call(std::forward(As)...);
   }
 
 private:


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


Re: r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-10 Thread Eric Liu via cfe-commits
No :( I tried reverting only r315256 but still got the errors.

On Tue, Oct 10, 2017 at 6:10 PM Richard Smith  wrote:

> On 10 Oct 2017 05:41, "Eric Liu via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
> Hi Richard,
>
> This is breaking the boostrap stage in the internal integration. I'm
> seeing "unsupported: typedef changes linkage of anonymous type, but
> linkage was already computed" error for many `struct`s defined with
> typedef. I'm not sure if it is user code or clang that needs fixing;
> however, as there are likely many more struct definitions that would cause
> the same failure, I'll revert this commit as well as r315256, which depends
> on this. Sorry about that.
>
>
> r315256 should have fixed those errors. Did it not?
>
> I'll also send you the repros separately.
>
> Regards,
> Eric
>
> On Tue, Oct 10, 2017 at 1:42 AM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Mon Oct  9 16:42:09 2017
>> New Revision: 315251
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315251&view=rev
>> Log:
>> [Modules TS] Module ownership semantics for redeclarations.
>>
>> When declaring an entity in the "purview" of a module, it's never a
>> redeclaration of an entity in the purview of a default module or in no
>> module
>> ("in the global module"). Don't consider those other declarations as
>> possible
>> redeclaration targets if they're not visible, and reject any cases where
>> we
>> pick a prior visible declaration that violates this rule.
>>
>> Added:
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
>>
>> cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Decl.h
>> cfe/trunk/include/clang/AST/DeclBase.h
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Sema/Lookup.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/AST/Decl.cpp
>> cfe/trunk/lib/AST/DeclBase.cpp
>> cfe/trunk/lib/AST/DeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDecl.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>> cfe/trunk/lib/Sema/SemaExprMember.cpp
>> cfe/trunk/lib/Sema/SemaLookup.cpp
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaTemplate.cpp
>> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
>> cfe/trunk/test/SemaCXX/modules-ts.cppm
>>
>> Modified: cfe/trunk/include/clang/AST/Decl.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251&r1=315250&r2=315251&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Decl.h (original)
>> +++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
>> @@ -339,6 +339,12 @@ public:
>>  return clang::isExternallyVisible(getLinkageInternal());
>>}
>>
>> +  /// Determine whether this declaration can be redeclared in a
>> +  /// different translation unit.
>> +  bool isExternallyDeclarable() const {
>> +return isExternallyVisible() && !getOwningModuleForLinkage();
>> +  }
>> +
>>/// \brief Determines the visibility of this entity.
>>Visibility getVisibility() const {
>>  return getLinkageAndVisibility().getVisibility();
>> @@ -379,10 +385,6 @@ public:
>>  return hasCachedLinkage();
>>}
>>
>> -  /// Get the module that owns this declaration for linkage purposes.
>> -  /// There only ever is such a module under the C++ Modules TS.
>> -  Module *getOwningModuleForLinkage() const;
>> -
>>/// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
>>/// the underlying named decl.
>>NamedDecl *getUnderlyingDecl() {
>>
>> Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251&r1=315250&r2=315251&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
>> @@ -738,6 +738,10 @@ public:
>>  return isFromASTFile() ? getImportedOwningModule() :
>> getLocalOwningModule();
>>}
>>
>> +  /// Get the module that owns this declaration for linkage purposes.
>> +  /// There only ever is such a module under the C++ Modules TS.
>> +  Module *getOwningModuleForLinkage() const;
>> +
>>/// \brief Determine whether this declaration might be hidden from name
>>/// lookup. Note that the declaration might be visible even if this
>> returns
>>/// \c false, if the owning module is visible within the query context.
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clan

[clang-tools-extra] r315325 - [clangd] Use UniqueFunction for deferred computations.

2017-10-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Oct 10 09:12:54 2017
New Revision: 315325

URL: http://llvm.org/viewvc/llvm-project?rev=315325&view=rev
Log:
[clangd] Use UniqueFunction for deferred computations.

Previsouly, `std::future` that were results of
`std::async(std::launch::deferred, ...` were used.

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

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=315325&r1=315324&r2=315325&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Oct 10 09:12:54 2017
@@ -413,8 +413,9 @@ std::future ClangdServer::schedule
 Tagged> TaggedFS) {
 
   assert(Contents.Draft && "Draft must have contents");
-  std::future>> DeferredRebuild =
-  Resources->deferRebuild(*Contents.Draft, TaggedFS.Value);
+  UniqueFunction>()>
+  DeferredRebuild =
+  Resources->deferRebuild(*Contents.Draft, TaggedFS.Value);
   std::promise DonePromise;
   std::future DoneFuture = DonePromise.get_future();
 
@@ -423,7 +424,7 @@ std::future ClangdServer::schedule
   VFSTag Tag = TaggedFS.Tag;
   auto ReparseAndPublishDiags =
   [this, FileStr, Version,
-   Tag](std::future>>
+   Tag](UniqueFunction>()>
 DeferredRebuild,
 std::promise DonePromise) -> void {
 FulfillPromiseGuard Guard(DonePromise);
@@ -432,7 +433,7 @@ std::future ClangdServer::schedule
 if (CurrentVersion != Version)
   return; // This request is outdated
 
-auto Diags = DeferredRebuild.get();
+auto Diags = DeferredRebuild();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
 
@@ -467,11 +468,11 @@ ClangdServer::scheduleCancelRebuild(std:
 return DoneFuture;
   }
 
-  std::future DeferredCancel = Resources->deferCancelRebuild();
+  UniqueFunction DeferredCancel = Resources->deferCancelRebuild();
   auto CancelReparses = [Resources](std::promise DonePromise,
-std::future DeferredCancel) {
+UniqueFunction DeferredCancel) {
 FulfillPromiseGuard Guard(DonePromise);
-DeferredCancel.get();
+DeferredCancel();
   };
   WorkScheduler.addToFront(std::move(CancelReparses), std::move(DonePromise),
std::move(DeferredCancel));

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=315325&r1=315324&r2=315325&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Oct 10 09:12:54 2017
@@ -1121,9 +1121,9 @@ CppFile::CppFile(PathRef FileName, tooli
   ASTFuture = ASTPromise.get_future();
 }
 
-void CppFile::cancelRebuild() { deferCancelRebuild().get(); }
+void CppFile::cancelRebuild() { deferCancelRebuild()(); }
 
-std::future CppFile::deferCancelRebuild() {
+UniqueFunction CppFile::deferCancelRebuild() {
   std::unique_lock Lock(Mutex);
   // Cancel an ongoing rebuild, if any, and wait for it to finish.
   unsigned RequestRebuildCounter = ++this->RebuildCounter;
@@ -1143,7 +1143,7 @@ std::future CppFile::deferCancelRe
   RebuildCond.notify_all();
 
   std::shared_ptr That = shared_from_this();
-  return std::async(std::launch::deferred, [That, RequestRebuildCounter]() {
+  return [That, RequestRebuildCounter]() {
 std::unique_lock Lock(That->Mutex);
 CppFile *This = &*That;
 This->RebuildCond.wait(Lock, [This, RequestRebuildCounter]() {
@@ -1158,16 +1158,16 @@ std::future CppFile::deferCancelRe
 // Set empty results for Promises.
 That->PreamblePromise.set_value(nullptr);
 That->ASTPromise.set_value(std::make_shared(llvm::None));
-  });
+  };
 }
 
 llvm::Optional>
 CppFile::rebuild(StringRef NewContents,
  IntrusiveRefCntPtr VFS) {
-  return deferRebuild(NewContents, std::move(VFS)).get();
+  return deferRebuild(NewContents, std::move(VFS))();
 }
 
-std::future>>
+UniqueFunction>()>
 CppFile::deferRebuild(StringRef NewContents,
   IntrusiveRefCntPtr VFS) {
   std::shared_ptr OldPreamble;
@@ -1315,7 +1315,7 @@ CppFile::deferRebuild(StringRef NewConte
 return Diagnostics;
   };
 
-  return std::async(std::launch::deferred, FinishRebuild, NewContents.str());
+  return BindWithForward(FinishRebuild, NewContents.str());
 }
 
 std::shared_future>

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=315325&r1=315324&r2=315325&view=diff
=

[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-10 Thread John Baldwin via Phabricator via cfe-commits
bsdjhb added a comment.

I keep running into issues trying to cross-build LLVM (it keeps wanting to use 
/usr/bin/cc or host libraries even though cross-compiling is enabled).  I 
wonder if the failures you saw Simon might be due to 
https://bugs.llvm.org/show_bug.cgi?id=33858?  Could you try applying the patch 
from https://reviews.llvm.org/D37484 along with this patchset to see if it 
fixes the test failures for you?


https://reviews.llvm.org/D38110



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


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:144
+  if (auto *I = dyn_cast(V)) {
+// If the block literal is emitted as an instruction, it is an alloca
+// and the block invoke function is stored to GEP of this alloca.

yaxunl wrote:
> Anastasia wrote:
> > Why do we need to replace original block calls with the kernels? I think in 
> > case of calling a block we could use the original block function and only 
> > for enqueue use the kernel that would call the block function inside. The 
> > pointer to the kernel wrapper could be passed as an additional parameter to 
> > `enqueue_kernel` calls. We won't need to iterate through all IR then.
> `CGF.EmitScalarExpr(Block)` returns the block literal structure which 
> contains the size/align/invoke_function/captures. The block invoke function 
> is stored to the struct by a `StoreInst`. To create the wrapper kernel, we 
> need to get the block invoke function, therefore we have to iterate through 
> IR.
> 
> Since we need to find the store instruction any way, it is simpler to just 
> replace the stored function with the kernel and pass the block literal 
> struct, instead of passing the kernel separately.
So we cann't get the invoke function from the block literal structure passed 
into the kernel wrapper directly knowing its offset? Iterating through IR adds 
extra time and also I am not sure how reliable this is wrt different corner 
cases of IR.



Comment at: lib/CodeGen/TargetInfo.cpp:8949
+  Builder.restoreIP(IP);
+  return F;
+}

yaxunl wrote:
> Anastasia wrote:
> > Wondering if we should add the kernel metadata (w/o args) since it was used 
> > for long time to indicate the kernel.
> Currently (before this change), clang already does not generate kernel 
> metadata if there is no vec_type_hint, work_group_size_hint, 
> reqd_work_group_size. Remember last time we made the change to use function 
> metadata to represent these attributes. Whether a function is a kernel can be 
> determined by its calling convention.
Ok, let's leave it for now. We can always add it in on request. 



Comment at: test/CodeGenOpenCL/cl20-device-side-enqueue.cl:297
+// COMMON: define internal spir_kernel void [[INVG5]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})
+// COMMON: define internal spir_kernel void [[INVG6]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}}, i8 addrspace(3)*{{.*}}, i8 addrspace(3)*{{.*}})
+// COMMON: define internal spir_kernel void [[INVG7]](i8 addrspace(4)*{{.*}}, 
i8 addrspace(3)*{{.*}})

Perhaps we could check the body of this one too since it has a different 
prototype.


https://reviews.llvm.org/D38134



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


[PATCH] D38567: [config] Warn when POSIX_C_SOURCE breaks threading support on Darwin

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



Comment at: include/__threading_support:26
 
+#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && 
(__MAC_OS_X_VERSION_MIN_REQUIRED < 101300)) \
+|| (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && 
(__IPHONE_OS_VERSION_MIN_REQUIRED < 11)) \

Please add a brief comment that describes why the check and the warning are 
needed.


https://reviews.llvm.org/D38567



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


r315330 - For dllexport class templates, export specializations of member functions (PR34849) (take 2)

2017-10-10 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Tue Oct 10 09:53:25 2017
New Revision: 315330

URL: http://llvm.org/viewvc/llvm-project?rev=315330&view=rev
Log:
For dllexport class templates, export specializations of member functions 
(PR34849) (take 2)

This is a re-commit of r315025, but making sure to only apply this to
specializations of class template member functions; i.e. not when the function
itself is a template.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCXX/dllexport.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=315330&r1=315329&r2=315330&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Oct 10 09:53:25 2017
@@ -6041,6 +6041,22 @@ static void checkDLLAttributeRedeclarati
diag::warn_dllimport_dropped_from_inline_function)
 << NewDecl << OldImportAttr;
   }
+
+  // A specialization of a class template member function is processed here
+  // since it's a redeclaration. If the parent class is dllexport, the
+  // specialization inherits that attribute. This doesn't happen automatically
+  // since the parent class isn't instantiated until later.
+  if (const CXXMethodDecl *MD = dyn_cast(NewDecl)) {
+if (MD->getTemplatedKind() == FunctionDecl::TK_MemberSpecialization &&
+!NewImportAttr && !NewExportAttr) {
+  if (const DLLExportAttr *ParentExportAttr =
+  MD->getParent()->getAttr()) {
+DLLExportAttr *NewAttr = ParentExportAttr->clone(S.Context);
+NewAttr->setInherited(true);
+NewDecl->addAttr(NewAttr);
+  }
+}
+  }
 }
 
 /// Given that we are within the definition of the given function,

Modified: cfe/trunk/test/CodeGenCXX/dllexport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllexport.cpp?rev=315330&r1=315329&r2=315330&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllexport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllexport.cpp Tue Oct 10 09:53:25 2017
@@ -831,6 +831,21 @@ template  struct ExplicitIns
 template struct __declspec(dllexport) __declspec(dllimport) 
ExplicitInstantiationTwoAttributes;
 // M32-DAG: define weak_odr dllexport x86_thiscallcc void 
@"\01?f@?$ExplicitInstantiationTwoAttributes@H@@QAEXXZ"
 
+namespace pr34849 {
+// Specializations of exported class template member functions get exported.
+template  struct __declspec(dllexport) ExportedClassTemplate { void 
foo(); };
+template<> void ExportedClassTemplate::foo() {}
+template struct ExportedClassTemplate;
+// M32-DAG: define dllexport x86_thiscallcc void 
@"\01?foo@?$ExportedClassTemplate@H@pr34849@@QAEXXZ"
+
+// Specializations of exported class member template functions do not get 
exported.
+struct __declspec(dllexport) ExportedClass { template  void bar() ; 
};
+template<> void ExportedClass::bar() {}
+// M32-DAG: define x86_thiscallcc void 
@"\01??$bar@H@ExportedClass@pr34849@@QAEXXZ"
+template  struct __declspec(dllexport) ExportedClassTemplate2 { 
template  void baz(); };
+template<> template<> void ExportedClassTemplate2::baz() {}
+// M32-DAG: define x86_thiscallcc void 
@"\01??$baz@H@?$ExportedClassTemplate2@H@pr34849@@QAEXXZ"
+}
 
 
//===--===//
 // Classes with template base classes


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


[PATCH] D38742: [CUDA] Added __hmma_m16n16k16_* builtins to support mma instructions in sm_70

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

https://reviews.llvm.org/D38742

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-nvptx-sm_70.cu

Index: clang/test/CodeGen/builtins-nvptx-sm_70.cu
===
--- /dev/null
+++ clang/test/CodeGen/builtins-nvptx-sm_70.cu
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -target-cpu sm_70 \
+// RUN:-fcuda-is-device -target-feature +ptx60 \
+// RUN:-S -emit-llvm -o - -x cuda %s \
+// RUN:   | FileCheck -check-prefix=CHECK %s
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -target-cpu sm_60 \
+// RUN:   -fcuda-is-device -S -o /dev/null -x cuda -verify %s
+
+#if !defined(CUDA_VERSION)
+#define __device__ __attribute__((device))
+#define __global__ __attribute__((global))
+#define __shared__ __attribute__((shared))
+#define __constant__ __attribute__((constant))
+
+typedef unsigned long long uint64_t;
+#endif
+// We have to keep all builtins that depend on particular target feature in the
+// same function, because the codegen will stop after the very first function
+// that encounters an error, so -verify will not be able to find errors in
+// subsequent functions.
+
+// CHECK-LABEL: nvvm_wmma
+__device__ void nvvm_wmma(int *src, int *dst,
+  float *fsrc, float *fdst,
+  int ldm) {
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.a.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_a' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_a(dst, src+1, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.b.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_b' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_b(dst, src+2, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.load.c.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_ld_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_ld_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f16' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f16(dst, src, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.row.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.store.d.sync.col.m16n16k16.stride.f32
+  // expected-error@+1 {{'__hmma_m16n16k16_st_c_f32' needs target feature ptx60}}
+  __hmma_m16n16k16_st_c_f32(fdst, fsrc, ldm, 1);
+
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.row.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 0, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 0);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.row.col.m16n16k16.f16.f16.satfinite
+  // expected-error@+1 {{'__hmma_m16n16k16_mma_f16f16' needs target feature ptx60}}
+  __hmma_m16n16k16_mma_f16f16(dst, src, src, src, 1, 1);
+  // CHECK: call {{.*}} @llvm.nvvm.wmma.mma.sync.col.row.m16n16k16.f16.f16
+  // expected-error@+1 {{'__hmma

[PATCH] D35082: [OpenCL] Add LangAS::opencl_private to represent private address space in AST

2017-10-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> (*) I know that you aren't considering OpenCL C++ yet, but often these 
> representation/model questions are easier to answer when thinking about C++ 
> instead of C because type differences are so much more directly important in 
> C++.  In OpenCL C++, I assume it will be important to distinguish between 
>  and <__private int> as template arguments.  That tells us straight up 
> that __private needs to be represented differently from a lack of qualifier.  
> Note that the result, where certain type representations (e.g. an unqualified 
> int*) become basically meaningless and should never be constructed by Sema, 
> is already precedented in Clang: ObjC ARC does the same thing to unqualified 
> ObjC pointer types, like id*.

It's pretty complicated in OpenCL as `int` and `private int` won't be 
different, but  `int*` and `private int*` would be different only in OpenCL2.0. 
The rules are pretty convoluted and I have summarized them in the table 
earlier: https://reviews.llvm.org/D35082#inline-327303. The issue is that there 
is not anything like this in other languages and therefore we have this issue 
trying to fit this concept with something similar but not exactly the same. I 
thought you and Sam decided to use implicit AS flag to make printing messages 
consistent with the original source code. I am fine with this approach, 
however, I would prefer to just keep no AS qualifier in the default AS mode 
instead of deducing it during parcing in `processTypeAttrs`, and only to add 
the AS to the IR at the end of the CodeGen phase. I think it would be a lot 
easier to understand. However, as Sam has pointed out a lot of code in Sema has 
been written assuming the deduction of AS and is using AS qualifiers explicitly 
and therefore it seems like it would be a bigger change to go for. At the same 
type we have refactored the deduction of default AS now in the parcing phase 
and it looks a lot better than I thought it would be. So I don't mind if we 
continue this way.


https://reviews.llvm.org/D35082



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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

I would prefer to merge the new test with test/SemaOpenCL/func.cl, but 
otherwise LGTM! Thanks!


https://reviews.llvm.org/D33681



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


[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-10 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot added a comment.

In https://reviews.llvm.org/D38656#892740, @nemanjai wrote:

> In https://reviews.llvm.org/D38656#892072, @Carrot wrote:
>
> > I worked on a similar bug as 31161, and then found this one, it should be 
> > same as in comment7.
> >  What is the current status of the work on that bug?
>
>
> No one has had time to finalize a fix to it. Please go ahead with this patch. 
> If this patch indeed fixes the bug, please close it.


This patch fixes the second part of bug 31161 described in comment7. I will 
check it in soon.
For the first part of the bug, I will retest your patch in comment1, plus 
incorrect handling of type long in our case, and then send it out.


https://reviews.llvm.org/D38656



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


[PATCH] D38567: [config] Warn when POSIX_C_SOURCE breaks threading support on Darwin

2017-10-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk abandoned this revision.
vsk added a comment.

For those following along, Alex worked out that this doesn't affect apple-clang 
802. We took a closer look and found that the build break just affects 
clang-900, and was introduced in this r290889. The fix (r293167) didn't make it 
into clang-900. Adding a warning here wouldn't be the right solution, since it 
would be better to just cherry pick r293167.


https://reviews.llvm.org/D38567



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


r315336 - [clang-fuzzer] Allow building without coverage instrumentation.

2017-10-10 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Tue Oct 10 10:41:43 2017
New Revision: 315336

URL: http://llvm.org/viewvc/llvm-project?rev=315336&view=rev
Log:
[clang-fuzzer] Allow building without coverage instrumentation.

Summary:
Compile with DummyClangFuzzer.cpp as entry point rather than
libFuzzer's main when coverage instrumentation is missing.

https://llvm.org/pr34314

Reviewers: kcc, bogner, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, mgorny

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

Added:
cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315336&r1=315335&r2=315336&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue Oct 10 10:41:43 2017
@@ -1,60 +1,65 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
-  set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(DUMMY_MAIN DummyClangFuzzer.cpp)
+if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  unset(DUMMY_MAIN)
+endif()
+
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  DummyClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  )
+
+if(CLANG_ENABLE_PROTO_FUZZER)
+  # Create protobuf .h and .cc files, and put them in a library for use by
+  # clang-proto-fuzzer components.
+  find_package(Protobuf REQUIRED)
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+  include_directories(${PROTOBUF_INCLUDE_DIRS})
+  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
+  add_clang_library(clangCXXProto
+${PROTO_SRCS}
+${PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
 
-  if(CLANG_ENABLE_PROTO_FUZZER)
-# Create protobuf .h and .cc files, and put them in a library for use by
-# clang-proto-fuzzer components.
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  ${PROTO_SRCS}
-  )
-add_clang_library(clangCXXProto
-  ${PROTO_SRCS}
-  ${PROTO_HDRS}
-
-  LINK_LIBS
-  ${PROTOBUF_LIBRARIES}
-  )
-
-# Build and include libprotobuf-mutator
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-# Build the protobuf->C++ translation library and driver.
-add_clang_subdirectory(proto-to-cxx)
-
-# Build the protobuf fuzzer
-add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
-target_link_libraries(clang-proto-fuzzer
-  ${ProtobufMutator_LIBRARIES}
-  clangCXXProto
-  clangHandleCXX
-  clangProtoToCXX
-  )
-  else()
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
-  endif()
-
-  add_clang_subdirectory(handle-cxx)
-
-  add_clang_executable(clang-fuzzer
-EXCLUDE_FROM_ALL
-ClangFuzzer.cpp
+  # Build and include libprotobuf-mutator
+  include(ProtobufMutator)
+  include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+  # Build the protobuf->C++ translation library and driver.
+  add_clang_subdirectory(proto-to-cxx)
+
+  # Build the protobuf fuzzer
+  add_clang_executable(clang-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-fuzzer
+  target_link_libraries(clang-proto-fuzzer
+${ProtobufMutator_LIBRARIES}
+clangCXXProto
 clangHandleCXX
+clangProtoToCXX
 )
 endif()
+
+add_clang_subdirectory(handle-cxx)
+
+add_clang_executable(clang-fuzzer
+  EXCLUDE_FROM_ALL
+  ${DUMMY_MAIN}
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangHandleCXX
+  )

Modified: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=315336&r1=315335&r2=315336&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp (o

[PATCH] D38642: [clang-fuzzer] Allow building without coverage instrumentation.

2017-10-10 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315336: [clang-fuzzer] Allow building without coverage 
instrumentation. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38642?vs=118097&id=118420#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38642

Files:
  cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
  cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
  cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp

Index: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
===
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
@@ -1,60 +1,65 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
-  set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
+set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
+set(DUMMY_MAIN DummyClangFuzzer.cpp)
+if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  unset(DUMMY_MAIN)
+endif()
+
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  DummyClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  )
+
+if(CLANG_ENABLE_PROTO_FUZZER)
+  # Create protobuf .h and .cc files, and put them in a library for use by
+  # clang-proto-fuzzer components.
+  find_package(Protobuf REQUIRED)
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+  include_directories(${PROTOBUF_INCLUDE_DIRS})
+  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
+  add_clang_library(clangCXXProto
+${PROTO_SRCS}
+${PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
 
-  if(CLANG_ENABLE_PROTO_FUZZER)
-# Create protobuf .h and .cc files, and put them in a library for use by
-# clang-proto-fuzzer components.
-find_package(Protobuf REQUIRED)
-add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-include_directories(${PROTOBUF_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  ${PROTO_SRCS}
-  )
-add_clang_library(clangCXXProto
-  ${PROTO_SRCS}
-  ${PROTO_HDRS}
-
-  LINK_LIBS
-  ${PROTOBUF_LIBRARIES}
-  )
-
-# Build and include libprotobuf-mutator
-include(ProtobufMutator)
-include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-# Build the protobuf->C++ translation library and driver.
-add_clang_subdirectory(proto-to-cxx)
-
-# Build the protobuf fuzzer
-add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
-target_link_libraries(clang-proto-fuzzer
-  ${ProtobufMutator_LIBRARIES}
-  clangCXXProto
-  clangHandleCXX
-  clangProtoToCXX
-  )
-  else()
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
-  endif()
-
-  add_clang_subdirectory(handle-cxx)
-
-  add_clang_executable(clang-fuzzer
-EXCLUDE_FROM_ALL
-ClangFuzzer.cpp
+  # Build and include libprotobuf-mutator
+  include(ProtobufMutator)
+  include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+  # Build the protobuf->C++ translation library and driver.
+  add_clang_subdirectory(proto-to-cxx)
+
+  # Build the protobuf fuzzer
+  add_clang_executable(clang-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-fuzzer
+  target_link_libraries(clang-proto-fuzzer
+${ProtobufMutator_LIBRARIES}
+clangCXXProto
 clangHandleCXX
+clangProtoToCXX
 )
 endif()
+
+add_clang_subdirectory(handle-cxx)
+
+add_clang_executable(clang-fuzzer
+  EXCLUDE_FROM_ALL
+  ${DUMMY_MAIN}
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangHandleCXX
+  )
Index: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
+++ cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
@@ -17,6 +17,8 @@
 
 using namespace clang_fuzzer;
 
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; }
+
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
   std::string s((const char *)data, size);
   HandleCXX(s, {"-O2"});
Index: cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
===
--- cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
+++ cfe/trunk/tools

[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks.


https://reviews.llvm.org/D33681



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


r315338 - [lit] Add host_cxx to lit config

2017-10-10 Thread Francis Ricci via cfe-commits
Author: fjricci
Date: Tue Oct 10 10:53:45 2017
New Revision: 315338

URL: http://llvm.org/viewvc/llvm-project?rev=315338&view=rev
Log:
[lit] Add host_cxx to lit config

Summary: This is required to get the clang version for sanitized builds.

Reviewers: zturner

Subscribers: llvm-commits

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

Modified:
cfe/trunk/test/lit.site.cfg.py.in

Modified: cfe/trunk/test/lit.site.cfg.py.in
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.site.cfg.py.in?rev=315338&r1=315337&r2=315338&view=diff
==
--- cfe/trunk/test/lit.site.cfg.py.in (original)
+++ cfe/trunk/test/lit.site.cfg.py.in Tue Oct 10 10:53:45 2017
@@ -14,6 +14,7 @@ config.clang_src_dir = "@CLANG_SOURCE_DI
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
+config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @HAVE_LIBZ@
 config.clang_arcmt = @CLANG_ENABLE_ARCMT@


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


r315339 - [clang-fuzzer] Build proto-to-cxx with fuzzer-no-link.

2017-10-10 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Tue Oct 10 10:59:37 2017
New Revision: 315339

URL: http://llvm.org/viewvc/llvm-project?rev=315339&view=rev
Log:
[clang-fuzzer] Build proto-to-cxx with fuzzer-no-link.

Makes it possible to build with any sanitizer or none at all.

Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315339&r1=315338&r2=315339&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue Oct 10 10:59:37 2017
@@ -3,6 +3,7 @@ set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
 set(DUMMY_MAIN DummyClangFuzzer.cpp)
 if(LLVM_USE_SANITIZE_COVERAGE)
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+  set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
   unset(DUMMY_MAIN)
 endif()
 


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


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

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



Comment at: test/CodeCompletion/qualifiers-as-written.cpp:29
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar 
c#>, <#ns::baz d#>
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz 
c#>
+}

Sorry, I see the issue now. However, I don't think that we'd like to change the 
signature for a function like this, as we'd still prefer to show `func 
(foo::type, ns::bar, ns::baz);` on this line.

In Xcode we actually avoid the problem with `std::vector<>`s that you've 
pointed out entirely by using `value_type`. I'll check what our solution does.

Btw, maybe using things like `value_type` is completely wrong (with or without 
the qualifier)? If we have `std::vector` shouldn't we rather show 
`push_back(int _Value)`, rather than the `value_type`? Perhaps this kind of 
change should be discussed with a wider community somehow to find out what's 
best for all users.


https://reviews.llvm.org/D38538



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


[libclc] r315341 - Make image builtins r600/llvm-3.9 only

2017-10-10 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Oct 10 11:10:21 2017
New Revision: 315341

URL: http://llvm.org/viewvc/llvm-project?rev=315341&view=rev
Log:
Make image builtins r600/llvm-3.9 only

The implementation uses r600 sepcific intrinsics
LLVM-4 switched to _ro_t and _rw_t image types
Portions of the code can be moved back as more targets/llvm versions add image 
support

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Added:
libclc/trunk/r600/lib/SOURCES_3.9
  - copied, changed from r315235, libclc/trunk/amdgpu/lib/SOURCES
libclc/trunk/r600/lib/image/get_image_attributes_impl.ll
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll
libclc/trunk/r600/lib/image/get_image_channel_data_type.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_channel_data_type.cl
libclc/trunk/r600/lib/image/get_image_channel_order.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_channel_order.cl
libclc/trunk/r600/lib/image/get_image_depth.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_depth.cl
libclc/trunk/r600/lib/image/get_image_dim.cl
  - copied, changed from r315235, 
libclc/trunk/generic/lib/image/get_image_dim.cl
libclc/trunk/r600/lib/image/get_image_height.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_height.cl
libclc/trunk/r600/lib/image/get_image_width.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/get_image_width.cl
libclc/trunk/r600/lib/image/read_image_impl.ll
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_image_impl.ll
libclc/trunk/r600/lib/image/read_imagef.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_imagef.cl
libclc/trunk/r600/lib/image/read_imagei.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_imagei.cl
libclc/trunk/r600/lib/image/read_imageui.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/read_imageui.cl
libclc/trunk/r600/lib/image/write_image_impl.ll
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_image_impl.ll
libclc/trunk/r600/lib/image/write_imagef.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_imagef.cl
libclc/trunk/r600/lib/image/write_imagei.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_imagei.cl
libclc/trunk/r600/lib/image/write_imageui.cl
  - copied, changed from r315235, 
libclc/trunk/amdgpu/lib/image/write_imageui.cl
Removed:
libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll
libclc/trunk/amdgpu/lib/image/get_image_channel_data_type.cl
libclc/trunk/amdgpu/lib/image/get_image_channel_order.cl
libclc/trunk/amdgpu/lib/image/get_image_depth.cl
libclc/trunk/amdgpu/lib/image/get_image_height.cl
libclc/trunk/amdgpu/lib/image/get_image_width.cl
libclc/trunk/amdgpu/lib/image/read_image_impl.ll
libclc/trunk/amdgpu/lib/image/read_imagef.cl
libclc/trunk/amdgpu/lib/image/read_imagei.cl
libclc/trunk/amdgpu/lib/image/read_imageui.cl
libclc/trunk/amdgpu/lib/image/write_image_impl.ll
libclc/trunk/amdgpu/lib/image/write_imagef.cl
libclc/trunk/amdgpu/lib/image/write_imagei.cl
libclc/trunk/amdgpu/lib/image/write_imageui.cl
libclc/trunk/generic/lib/image/get_image_dim.cl
Modified:
libclc/trunk/amdgpu/lib/SOURCES
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/amdgpu/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/SOURCES?rev=315341&r1=315340&r2=315341&view=diff
==
--- libclc/trunk/amdgpu/lib/SOURCES (original)
+++ libclc/trunk/amdgpu/lib/SOURCES Tue Oct 10 11:10:21 2017
@@ -1,16 +1,2 @@
 math/nextafter.cl
 math/sqrt.cl
-image/get_image_width.cl
-image/get_image_height.cl
-image/get_image_depth.cl
-image/get_image_channel_data_type.cl
-image/get_image_channel_order.cl
-image/get_image_attributes_impl.ll
-image/read_imagef.cl
-image/read_imagei.cl
-image/read_imageui.cl
-image/read_image_impl.ll
-image/write_imagef.cl
-image/write_imagei.cl
-image/write_imageui.cl
-image/write_image_impl.ll

Removed: libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll?rev=315340&view=auto
==
--- libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll (original)
+++ libclc/trunk/amdgpu/lib/image/get_image_attributes_impl.ll (removed)
@@ -1,87 +0,0 @@
-%opencl.image2d_t = type opaque
-%opencl.image3d_t = type opaque
-
-declare i32 @llvm.OpenCL.image.get.resource.id.2d(
-  %opencl.image2d_t addrspace(1)*) nounwind readnone
-declare i32 @llvm.OpenCL.image.get.resource.id.3d(
-  %opencl.image3d_t addrspace(1)*)

[libclc] r315343 - travis: enable checks of nvptx libraries

2017-10-10 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Oct 10 11:10:25 2017
New Revision: 315343

URL: http://llvm.org/viewvc/llvm-project?rev=315343&view=rev
Log:
travis: enable checks of nvptx libraries

Reviewer: Jeroen Ketema
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=315343&r1=315342&r2=315343&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Tue Oct 10 11:10:25 2017
@@ -13,7 +13,7 @@ matrix:
 - LABEL="make gcc LLVM-3.9"
 - LLVM_VERSION=3.9
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
   sources:
@@ -28,7 +28,7 @@ matrix:
 - LABEL="make gcc LLVM-4.0"
 - LLVM_VERSION=4.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
   sources:
@@ -43,7 +43,7 @@ matrix:
 - LABEL="make gcc LLVM-5.0"
 - LLVM_VERSION=5.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
-- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc nvptx--nvidiacl.bc 
nvptx64--nvidiacl.bc"
   addons:
 apt:
   sources:


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


[libclc] r315342 - travis: Enable external function call checks on llvm-{4, 5}

2017-10-10 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Tue Oct 10 11:10:24 2017
New Revision: 315342

URL: http://llvm.org/viewvc/llvm-project?rev=315342&view=rev
Log:
travis: Enable external function call checks on llvm-{4,5}

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/.travis.yml

Modified: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=315342&r1=315341&r2=315342&view=diff
==
--- libclc/trunk/.travis.yml (original)
+++ libclc/trunk/.travis.yml Tue Oct 10 11:10:24 2017
@@ -28,6 +28,7 @@ matrix:
 - LABEL="make gcc LLVM-4.0"
 - LLVM_VERSION=4.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
   addons:
 apt:
   sources:
@@ -42,6 +43,7 @@ matrix:
 - LABEL="make gcc LLVM-5.0"
 - LLVM_VERSION=5.0
 - LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+- CHECK_FILES="barts-r600--.bc cayman-r600--.bc cedar-r600--.bc 
cypress-r600--.bc tahiti-amdgcn--.bc amdgcn--amdhsa.bc"
   addons:
 apt:
   sources:


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


[PATCH] D38134: [OpenCL] Emit enqueued block as kernel

2017-10-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: lib/CodeGen/CGOpenCLRuntime.cpp:144
+  if (auto *I = dyn_cast(V)) {
+// If the block literal is emitted as an instruction, it is an alloca
+// and the block invoke function is stored to GEP of this alloca.

Anastasia wrote:
> yaxunl wrote:
> > Anastasia wrote:
> > > Why do we need to replace original block calls with the kernels? I think 
> > > in case of calling a block we could use the original block function and 
> > > only for enqueue use the kernel that would call the block function 
> > > inside. The pointer to the kernel wrapper could be passed as an 
> > > additional parameter to `enqueue_kernel` calls. We won't need to iterate 
> > > through all IR then.
> > `CGF.EmitScalarExpr(Block)` returns the block literal structure which 
> > contains the size/align/invoke_function/captures. The block invoke function 
> > is stored to the struct by a `StoreInst`. To create the wrapper kernel, we 
> > need to get the block invoke function, therefore we have to iterate through 
> > IR.
> > 
> > Since we need to find the store instruction any way, it is simpler to just 
> > replace the stored function with the kernel and pass the block literal 
> > struct, instead of passing the kernel separately.
> So we cann't get the invoke function from the block literal structure passed 
> into the kernel wrapper directly knowing its offset? Iterating through IR 
> adds extra time and also I am not sure how reliable this is wrt different 
> corner cases of IR.
Unfortunately the invoke function is not returned directly. Instead, it is 
buried in an LLVM value. And to extract the invoke function from the LLVM value 
we have to wade through a bunch of LLVM IRs.

There is one way to get the invoke function directly instead of going through 
IRs, but we need to change the functions for generating code for the blocks a 
little bit so that they return the block invoke function.


https://reviews.llvm.org/D38134



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


[PATCH] D33681: [OpenCL] Allow function declaration with empty argument list.

2017-10-10 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 118437.
bader added a comment.

Applied comments.


https://reviews.llvm.org/D33681

Files:
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/func.cl
  test/SemaOpenCL/invalid-pipes-cl2.0.cl


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only 
pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global 
reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global 
write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error 
{{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: test/SemaOpenCL/func.cl
===
--- test/SemaOpenCL/func.cl
+++ test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple 
spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid 
prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus
+&& !LangOpts.OpenCL) {
 // Simple void foo(), where the incoming T is the result type.
 T = Context.getFunctionNoProtoType(T, EI);
   } else {
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -5989,7 +5989,8 @@
 else if (RequiresArg)
   Diag(Tok, diag::err_argument_required_after_attribute);
 
-HasProto = ParamInfo.size() || getLangOpts().CPlusPlus;
+HasProto = ParamInfo.size() || getLangOpts().CPlusPlus
+|| getLangOpts().OpenCL;
 
 // If we have the closing ')', eat it.
 Tracker.consumeClose();


Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -3,7 +3,7 @@
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int ()' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
Index: test/SemaOpenCL/func.cl
===
--- test/SemaOpenCL/func.cl
+++ test/SemaOpenCL/func.cl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
 
 // Variadic functions
 void vararg_f(int, ...);// expected-error {{invalid prototype, variadic arguments are not allowed in OpenCL}}
@@ -16,6 +16,9 @@
 //Function pointer
 void foo(void*);
 
+// Expect no diagnostics for an empty parameter list.
+void bar();
+
 void bar()
 {
   // declaring a function pointer is an error
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4460,7 +4460,8 @@
 
   FunctionType::ExtInfo EI(getCCForDeclaratorChunk(S, D, FTI, chunkIndex));
 
-  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus) {
+  if (!FTI.NumParams && !FTI.isVariadic && !LangOpts.CPlusPlus

[PATCH] D38755: Fixed crash during indexing default template template param

2017-10-10 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.

fix + testcase


https://reviews.llvm.org/D38755

Files:
  lib/Index/IndexDecl.cpp
  test/Index/index-template-template-param.cpp


Index: test/Index/index-template-template-param.cpp
===
--- /dev/null
+++ test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }


Index: test/Index/index-template-template-param.cpp
===
--- /dev/null
+++ test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |
Index: lib/Index/IndexDecl.cpp
===
--- lib/Index/IndexDecl.cpp
+++ lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

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



Comment at: test/CodeCompletion/qualifiers-as-written.cpp:29
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo a#>, <#bar b#>, <#ns::bar 
c#>, <#ns::baz d#>
+  // CHECK-2: COMPLETION: func : [#int#]func(<#foo::type a#>, <#bar b#>, <#baz 
c#>
+}

arphaman wrote:
> Sorry, I see the issue now. However, I don't think that we'd like to change 
> the signature for a function like this, as we'd still prefer to show `func 
> (foo::type, ns::bar, ns::baz);` on this line.
> 
> In Xcode we actually avoid the problem with `std::vector<>`s that you've 
> pointed out entirely by using `value_type`. I'll check what our solution does.
> 
> Btw, maybe using things like `value_type` is completely wrong (with or 
> without the qualifier)? If we have `std::vector` shouldn't we rather 
> show `push_back(int _Value)`, rather than the `value_type`? Perhaps this kind 
> of change should be discussed with a wider community somehow to find out 
> what's best for all users.
Using `int _Value` may be good in case of `vector`, but it would probably 
loose typedefs, i.e. `vector` would still have `int`, which may be 
undesirable.
Also, for `vector>`, the type inside `push_back` would probably end 
up being `vector>`. 


As for the current vs new behavior, I can totally see why you want to see more 
context in completion items. 

I would argue that the current code does not do a great job there, as it only 
adds qualifiers to unqualified references. But the context may be missing for 
qualified references as well.
For example, in the following code:
```
  template >
  struct vector {
typedef T value_type;

typename value_type::some_type foo();
value_type bar()
  };
```

Completion item for `vector::bar` will have return type `vector>::value_type`. However, completion item for `vector>::foo` will have return type `value_type::some_type` (note 
that no `vector>` qualifier was added).

I would also question the intent of the current implementation. The following 
line suggest that adding those qualifers was not intended in the first place:
```
  Policy.SuppressUnwrittenScope = true;
```
But that's just a wild guess, I may be completely wrong.


That being said, I don't think there is one right preference, different people 
may prefer different options. We can surely discuss that in a wider community, 
though.

Would you be open to adding an option for that in completion and keeping the 
current behavior as a default?




https://reviews.llvm.org/D38538



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


[PATCH] D38110: [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.

2017-10-10 Thread Simon Dardis via Phabricator via cfe-commits
sdardis added a comment.

Thanks for the pointer to that patch, I'll take a look tomorrow.




Comment at: src/UnwindRegistersRestore.S:492
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32
+

Needs checking for soft-float.



Comment at: src/UnwindRegistersRestore.S:543
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64
+

Needs checking for soft-float.



Comment at: src/UnwindRegistersSave.S:90
 
+#elif defined(__mips__) && _MIPS_SIM == _ABIO32
+

Needs checking for soft-float.



Comment at: src/UnwindRegistersSave.S:125
+
+#elif defined(__mips__) && _MIPS_SIM == _ABI64
+

Needs checking for soft-float.


https://reviews.llvm.org/D38110



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


r315355 - Revert "[clang-fuzzer] Allow building without coverage instrumentation."

2017-10-10 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Tue Oct 10 13:13:13 2017
New Revision: 315355

URL: http://llvm.org/viewvc/llvm-project?rev=315355&view=rev
Log:
Revert "[clang-fuzzer] Allow building without coverage instrumentation."

This reverts r315336 due to build breakage with gcc.
http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/2173

Removed:
cfe/trunk/tools/clang-fuzzer/DummyClangFuzzer.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=315355&r1=315354&r2=315355&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Tue Oct 10 13:13:13 2017
@@ -1,66 +1,60 @@
-set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzMutate)
-set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
-set(DUMMY_MAIN DummyClangFuzzer.cpp)
-if(LLVM_USE_SANITIZE_COVERAGE)
+if( LLVM_USE_SANITIZE_COVERAGE )
+  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
+  set(CXX_FLAGS_NOFUZZ "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-  set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
-  unset(DUMMY_MAIN)
-endif()
-
-# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
-# executables from this directory.
-set(LLVM_OPTIONAL_SOURCES
-  ClangFuzzer.cpp
-  DummyClangFuzzer.cpp
-  ExampleClangProtoFuzzer.cpp
-  )
-
-if(CLANG_ENABLE_PROTO_FUZZER)
-  # Create protobuf .h and .cc files, and put them in a library for use by
-  # clang-proto-fuzzer components.
-  find_package(Protobuf REQUIRED)
-  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
-  include_directories(${PROTOBUF_INCLUDE_DIRS})
-  include_directories(${CMAKE_CURRENT_BINARY_DIR})
-  protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
-  set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
-  add_clang_library(clangCXXProto
-${PROTO_SRCS}
-${PROTO_HDRS}
-
-LINK_LIBS
-${PROTOBUF_LIBRARIES}
-)
 
-  # Build and include libprotobuf-mutator
-  include(ProtobufMutator)
-  include_directories(${ProtobufMutator_INCLUDE_DIRS})
-
-  # Build the protobuf->C++ translation library and driver.
-  add_clang_subdirectory(proto-to-cxx)
-
-  # Build the protobuf fuzzer
-  add_clang_executable(clang-proto-fuzzer
-${DUMMY_MAIN}
-ExampleClangProtoFuzzer.cpp
+  if(CLANG_ENABLE_PROTO_FUZZER)
+# Create protobuf .h and .cc files, and put them in a library for use by
+# clang-proto-fuzzer components.
+find_package(Protobuf REQUIRED)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES
+  ClangFuzzer.cpp
+  ExampleClangProtoFuzzer.cpp
+  ${PROTO_SRCS}
+  )
+add_clang_library(clangCXXProto
+  ${PROTO_SRCS}
+  ${PROTO_HDRS}
+
+  LINK_LIBS
+  ${PROTOBUF_LIBRARIES}
+  )
+
+# Build and include libprotobuf-mutator
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+# Build the protobuf->C++ translation library and driver.
+add_clang_subdirectory(proto-to-cxx)
+
+# Build the protobuf fuzzer
+add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
+target_link_libraries(clang-proto-fuzzer
+  ${ProtobufMutator_LIBRARIES}
+  clangCXXProto
+  clangHandleCXX
+  clangProtoToCXX
+  )
+  else()
+# Hack to bypass LLVM's cmake sources check and allow multiple libraries 
and
+# executables from this directory.
+set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
+  endif()
+
+  add_clang_subdirectory(handle-cxx)
+
+  add_clang_executable(clang-fuzzer
+EXCLUDE_FROM_ALL
+ClangFuzzer.cpp
 )
 
-  target_link_libraries(clang-proto-fuzzer
-${ProtobufMutator_LIBRARIES}
-clangCXXProto
+  target_link_libraries(clang-fuzzer
 clangHandleCXX
-clangProtoToCXX
 )
 endif()
-
-add_clang_subdirectory(handle-cxx)
-
-add_clang_executable(clang-fuzzer
-  EXCLUDE_FROM_ALL
-  ${DUMMY_MAIN}
-  ClangFuzzer.cpp
-  )
-
-target_link_libraries(clang-fuzzer
-  clangHandleCXX
-  )

Modified: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=315355&r1=315354&r2=315355&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp Tue Oct 10 13:13

[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-10 Thread Guozhi Wei via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315358: [CGExprScalar] In EmitCompare trunc the result if it 
has different type as E… (authored by Carrot).

Changed prior to commit:
  https://reviews.llvm.org/D38656?vs=118236&id=118464#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38656

Files:
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/test/CodeGen/ppc-vector-compare.cc


Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc
===
--- cfe/trunk/test/CodeGen/ppc-vector-compare.cc
+++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, 
E->getType(),
   E->getExprLoc());
 }


Index: cfe/trunk/test/CodeGen/ppc-vector-compare.cc
===
--- cfe/trunk/test/CodeGen/ppc-vector-compare.cc
+++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
===
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(),
   E->getExprLoc());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38402: [clang-refactor] Apply source replacements

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 118471.
arphaman marked 6 inline comments as done.
arphaman added a comment.

Address review comments


Repository:
  rL LLVM

https://reviews.llvm.org/D38402

Files:
  include/clang/Frontend/CommandLineSourceLoc.h
  test/Refactor/tool-apply-replacements.cpp
  test/Refactor/tool-selection-option.c
  tools/clang-refactor/ClangRefactor.cpp

Index: tools/clang-refactor/ClangRefactor.cpp
===
--- tools/clang-refactor/ClangRefactor.cpp
+++ tools/clang-refactor/ClangRefactor.cpp
@@ -14,6 +14,7 @@
 //===--===//
 
 #include "TestSupport.h"
+#include "clang/Frontend/CommandLineSourceLoc.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
@@ -54,7 +55,7 @@
 
   /// Prints any additional state associated with the selection argument to
   /// the given output stream.
-  virtual void print(raw_ostream &OS) = 0;
+  virtual void print(raw_ostream &OS) {}
 
   /// Returns a replacement refactoring result consumer (if any) that should
   /// consume the results of a refactoring operation.
@@ -99,6 +100,41 @@
   TestSelectionRangesInFile TestSelections;
 };
 
+/// Stores the parsed -selection=filename:line:column[-line:column] option.
+class SourceRangeSelectionArgument final : public SourceSelectionArgument {
+public:
+  SourceRangeSelectionArgument(ParsedSourceRange Range)
+  : Range(std::move(Range)) {}
+
+  bool forAllRanges(const SourceManager &SM,
+llvm::function_ref Callback) override {
+const FileEntry *FE = SM.getFileManager().getFile(Range.FileName);
+FileID FID = FE ? SM.translateFile(FE) : FileID();
+if (!FE || FID.isInvalid()) {
+  llvm::errs() << "error: -selection=" << Range.FileName
+   << ":... : given file is not in the target TU\n";
+  return true;
+}
+
+SourceLocation Start = SM.getMacroArgExpandedLocation(
+SM.translateLineCol(FID, Range.Begin.first, Range.Begin.second));
+SourceLocation End = SM.getMacroArgExpandedLocation(
+SM.translateLineCol(FID, Range.End.first, Range.End.second));
+if (Start.isInvalid() || End.isInvalid()) {
+  llvm::errs() << "error: -selection=" << Range.FileName << ':'
+   << Range.Begin.first << ':' << Range.Begin.second << '-'
+   << Range.End.first << ':' << Range.End.second
+   << " : invalid source location\n";
+  return true;
+}
+Callback(SourceRange(Start, End));
+return false;
+  }
+
+private:
+  ParsedSourceRange Range;
+};
+
 std::unique_ptr
 SourceSelectionArgument::fromString(StringRef Value) {
   if (Value.startswith("test:")) {
@@ -110,10 +146,12 @@
 return llvm::make_unique(
 std::move(*ParsedTestSelection));
   }
-  // FIXME: Support true selection ranges.
+  Optional Range = ParsedSourceRange::fromString(Value);
+  if (Range)
+return llvm::make_unique(std::move(*Range));
   llvm::errs() << "error: '-selection' option must be specified using "
   ":: or "
-  "::-: format";
+  "::-: format\n";
   return nullptr;
 }
 
@@ -268,11 +306,18 @@
 
 class ClangRefactorConsumer : public RefactoringResultConsumer {
 public:
-  void handleError(llvm::Error Err) {
+  void handleError(llvm::Error Err) override {
 llvm::errs() << llvm::toString(std::move(Err)) << "\n";
   }
 
-  // FIXME: Consume atomic changes and apply them to files.
+  void handle(AtomicChanges Changes) override {
+SourceChanges.insert(SourceChanges.begin(), Changes.begin(), Changes.end());
+  }
+
+  const AtomicChanges &getSourceChanges() const { return SourceChanges; }
+
+private:
+  AtomicChanges SourceChanges;
 };
 
 class ClangRefactorTool {
@@ -352,6 +397,39 @@
 }
   }
 
+  bool applySourceChanges(const AtomicChanges &Replacements) {
+std::set Files;
+for (const auto &Change : Replacements)
+  Files.insert(Change.getFilePath());
+// FIXME: Add automatic formatting support as well.
+tooling::ApplyChangesSpec Spec;
+// FIXME: We should probably cleanup the result by default as well.
+Spec.Cleanup = false;
+for (const auto &File : Files) {
+  llvm::ErrorOr> BufferErr =
+  llvm::MemoryBuffer::getFile(File);
+  if (!BufferErr) {
+llvm::errs() << "error: failed to open " << File << " for rewriting\n";
+return true;
+  }
+  auto Result = tooling::applyAtomicChanges(File, (*BufferErr)->getBuffer(),
+Replacements, Spec);
+  if (!Result) {
+llvm::errs() << toString(Result.takeError());
+return true;
+  }
+
+  std::error_code EC;
+  llvm::raw_fd_ostream OS(File, EC, llvm::sys::fs::F_Text);
+  if (EC) {
+llvm::errs() << EC.message() << "\n";
+return true;
+  }
+ 

[PATCH] D38402: [clang-refactor] Apply source replacements

2017-10-10 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D38402



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


[PATCH] D38755: Fixed crash during indexing default template template param

2017-10-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


https://reviews.llvm.org/D38755



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


r315358 - [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-10 Thread Guozhi Wei via cfe-commits
Author: carrot
Date: Tue Oct 10 13:31:27 2017
New Revision: 315358

URL: http://llvm.org/viewvc/llvm-project?rev=315358&view=rev
Log:
[CGExprScalar] In EmitCompare trunc the result if it has different type as 
E->getType()

Usually compare expression should return i1 type, so EmitScalarConversion is 
called before return

return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), 
E->getExprLoc());

But when ppc intrinsic is called to compare vectors, the ppc intrinsic can 
return i32 even E->getType() is BoolTy, in this case EmitScalarConversion does 
nothing, an i32 type result is returned and causes crash later.

This patch detects this case and truncates the result before return.

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


Added:
cfe/trunk/test/CodeGen/ppc-vector-compare.cc
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=315358&r1=315357&r2=315358&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Oct 10 13:31:27 2017
@@ -3214,6 +3214,16 @@ Value *ScalarExprEmitter::EmitCompare(co
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, 
E->getType(),
   E->getExprLoc());
 }

Added: cfe/trunk/test/CodeGen/ppc-vector-compare.cc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ppc-vector-compare.cc?rev=315358&view=auto
==
--- cfe/trunk/test/CodeGen/ppc-vector-compare.cc (added)
+++ cfe/trunk/test/CodeGen/ppc-vector-compare.cc Tue Oct 10 13:31:27 2017
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+


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


r315366 - Add test for regression caused by reverted patch r315251.

2017-10-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct 10 14:07:44 2017
New Revision: 315366

URL: http://llvm.org/viewvc/llvm-project?rev=315366&view=rev
Log:
Add test for regression caused by reverted patch r315251.

Modified:
cfe/trunk/test/SemaCXX/linkage2.cpp

Modified: cfe/trunk/test/SemaCXX/linkage2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/linkage2.cpp?rev=315366&r1=315365&r2=315366&view=diff
==
--- cfe/trunk/test/SemaCXX/linkage2.cpp (original)
+++ cfe/trunk/test/SemaCXX/linkage2.cpp Tue Oct 10 14:07:44 2017
@@ -218,3 +218,34 @@ namespace PR18964 {
   unsigned &*foo; //expected-error{{'foo' declared as a pointer to a reference 
of type}}
   extern struct {} *foo; // don't assert
 }
+
+namespace typedef_name_for_linkage {
+  template struct Use {};
+
+  struct A { A(); A(const A&); ~A(); };
+
+  typedef struct {
+A a;
+  } B;
+
+  struct C {
+typedef struct {
+  A a;
+} D;
+  };
+
+  typedef struct {
+void f() { static int n; struct Inner {};}
+  } E;
+
+  // FIXME: Ideally this would be accepted in all modes. In C++98, we trigger a
+  // linkage calculation to drive the "internal linkage type as template
+  // argument" warning.
+  typedef struct {
+void f() { struct Inner {}; Use ui; }
+  } F;
+#if __cplusplus < 201103L
+  // expected-error@-2 {{unsupported: typedef changes linkage of anonymous 
type, but linkage was already computed}}
+  // expected-note@-5 {{use a tag name here}}
+#endif
+}


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


r315367 - Fix indexer crash for default template template parameter value

2017-10-10 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Tue Oct 10 14:09:49 2017
New Revision: 315367

URL: http://llvm.org/viewvc/llvm-project?rev=315367&view=rev
Log:
Fix indexer crash for default template template parameter value

rdar://33058798

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

Added:
cfe/trunk/test/Index/index-template-template-param.cpp
Modified:
cfe/trunk/lib/Index/IndexDecl.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=315367&r1=315366&r2=315367&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Tue Oct 10 14:09:49 2017
@@ -666,7 +666,6 @@ public:
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@ public:
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }

Added: cfe/trunk/test/Index/index-template-template-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-template-template-param.cpp?rev=315367&view=auto
==
--- cfe/trunk/test/Index/index-template-template-param.cpp (added)
+++ cfe/trunk/test/Index/index-template-template-param.cpp Tue Oct 10 14:09:49 
2017
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |


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


[PATCH] D38755: Fixed crash during indexing default template template param

2017-10-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315367: Fix indexer crash for default template template 
parameter value (authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38755?vs=118451&id=118476#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38755

Files:
  cfe/trunk/lib/Index/IndexDecl.cpp
  cfe/trunk/test/Index/index-template-template-param.cpp


Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }
Index: cfe/trunk/test/Index/index-template-template-param.cpp
===
--- cfe/trunk/test/Index/index-template-template-param.cpp
+++ cfe/trunk/test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |


Index: cfe/trunk/lib/Index/IndexDecl.cpp
===
--- cfe/trunk/lib/Index/IndexDecl.cpp
+++ cfe/trunk/lib/Index/IndexDecl.cpp
@@ -666,7 +666,6 @@
   }
 
   bool VisitTemplateDecl(const TemplateDecl *D) {
-// FIXME: Template parameters.
 
 // Index the default values for the template parameters.
 const NamedDecl *Parent = D->getTemplatedDecl();
@@ -683,7 +682,7 @@
 } else if (const auto *TTPD = dyn_cast(TP)) {
   if (TTPD->hasDefaultArgument())
 handleTemplateArgumentLoc(TTPD->getDefaultArgument(), Parent,
-  /*DC=*/nullptr);
+  TP->getLexicalDeclContext());
 }
   }
 }
Index: cfe/trunk/test/Index/index-template-template-param.cpp
===
--- cfe/trunk/test/Index/index-template-template-param.cpp
+++ cfe/trunk/test/Index/index-template-template-param.cpp
@@ -0,0 +1,7 @@
+// RUN: c-index-test -index-file %s -x objective-c++ | FileCheck %s
+
+template  class Template1 {};
+
+template  class TMPL = Template1> class Template2;
+
+// CHECK: [indexEntityReference]: kind: c++-class-template | name: Template1 |
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D36973: [libclang] Add support for querying cursor availability

2017-10-10 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a comment.
This revision is now accepted and ready to land.

LGTM

Would you like me to commit this for you?


https://reviews.llvm.org/D36973



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


[PATCH] D36955: [libclang] Visit attributes for function and class templates

2017-10-10 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe accepted this revision.
jbcoe added a comment.
This revision is now accepted and ready to land.

LGTM

Would you like me to commit this for you?


https://reviews.llvm.org/D36955



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


[PATCH] D38473: Include getting generated struct offsets in CodegenABITypes

2017-10-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

@rjmccall Do you have any more comments?


https://reviews.llvm.org/D38473



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


[PATCH] D38425: [clangd] Document highlights for clangd

2017-10-10 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 118482.
Nebiroth added a comment.

Rebased on master.


https://reviews.llvm.org/D38425

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  test/clangd/documenthighlight.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -5,18 +5,21 @@
 Content-Length: 143
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 535
+# CHECK: Content-Length: 580
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
 # CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-# CHECK:   "definitionProvider": true
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
 # CHECK: }}}
 #
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
+
+
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -5,16 +5,17 @@
 Content-Length: 142
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":"","rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
-# CHECK: Content-Length: 535
+# CHECK: Content-Length: 580
 # CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
 # CHECK:   "textDocumentSync": 1,
 # CHECK:   "documentFormattingProvider": true,
 # CHECK:   "documentRangeFormattingProvider": true,
 # CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
 # CHECK:   "codeActionProvider": true,
 # CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
 # CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
-# CHECK:   "definitionProvider": true
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
 # CHECK: }}}
 #
 Content-Length: 44
Index: test/clangd/documenthighlight.test
===
--- /dev/null
+++ test/clangd/documenthighlight.test
@@ -0,0 +1,42 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+# CHECK: Content-Length: 580
+# CHECK: {"jsonrpc":"2.0","id":0,"result":{"capabilities":{
+# CHECK:   "textDocumentSync": 1,
+# CHECK:   "documentFormattingProvider": true,
+# CHECK:   "documentRangeFormattingProvider": true,
+# CHECK:   "documentOnTypeFormattingProvider": {"firstTriggerCharacter":"}","moreTriggerCharacter":[]},
+# CHECK:   "codeActionProvider": true,
+# CHECK:   "completionProvider": {"resolveProvider": false, "triggerCharacters": [".",">",":"]},
+# CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},
+# CHECK:   "definitionProvider": true,
+# CHECK:   "documentHighlightProvider": true
+# CHECK: }}}
+#
+
+Content-Length: 455
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};\nstruct Foo {\nint xasd;\n};\n}\nint main() {\nint bonjour;\nbonjour = 2;\nns1::Foo bar = { xasd : 1};\nbar.xasd = 3;\nns1::MyClass* Params;\nParams->anotherOperation();}\n"}}}
+
+Content-Length: 156
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":2}}}
+# Go to local variable
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[{"range": {"start": {"line": 16, "character": 4}, "end": {"line": 16, "character": 12}}, "kind": 1},{"range": {"start": {"line": 17, "character": 0}, "end": {"line": 17, "character": 7}}, "kind": 1}]}
+
+Content-Length: 157
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":18,"charact

[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added a comment.

I assume std::type_info::operator== also needs to be adjusted to compare string 
names? It looks like libc++'s version of the function does string comparisons 
for ARM64 iOS, but only on some classes (e.g. public(?) ones). Look for the 
_LIBCPP_HAS_NONUNIQUE_TYPEINFO and _LIBCPP_NONUNIQUE_RTTI_BIT flags. I wonder 
if ARM64 iOS also sets _LIBCXX_DYNAMIC_FALLBACK for libc++abi.

I noticed that Clang on GNU/Linux is treating two classes defined in separate 
anonymous namespaces as equal for std::type_info::operator== and dynamic_cast, 
which I *think* is a Clang bug. G++ marks the typeinfo names with an asterisk 
to disable the string comparisons. I'd expect that enabling 
_LIBCXX_DYNAMIC_FALLBACK would introduce the same bug into the Android 
toolchain.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-10 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added a comment.

Here's the Clang bug I filed: https://bugs.llvm.org/show_bug.cgi?id=34907


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38764: [Analyzer] Assume const string-like globals are non-null

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

https://reviews.llvm.org/D38764

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
  test/Analysis/nonnil-string-constants.mm

Index: test/Analysis/nonnil-string-constants.mm
===
--- /dev/null
+++ test/Analysis/nonnil-string-constants.mm
@@ -0,0 +1,80 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// Nullability of const string-like globals.
+void clang_analyzer_eval(bool);
+
+@class NSString;
+typedef const struct __CFString *CFStringRef;
+
+// Global NSString* is non-null.
+extern NSString *const StringConstGlobal;
+void stringConstGlobal() {
+  clang_analyzer_eval(StringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// The logic does not apply to local variables though.
+extern NSString *stringGetter();
+void stringConstLocal() {
+  NSString *const local = stringGetter();
+  clang_analyzer_eval(local); // expected-warning{{UNKNOWN}}
+}
+
+// Global const CFStringRef's are also assumed to be non-null.
+extern const CFStringRef CFStringConstGlobal;
+void cfStringCheckGlobal() {
+  clang_analyzer_eval(CFStringConstGlobal); // expected-warning{{TRUE}}
+}
+
+// But only "const" ones.
+extern CFStringRef CFStringNonConstGlobal;
+void cfStringCheckMutableGlobal() {
+  clang_analyzer_eval(CFStringNonConstGlobal); // expected-warning{{UNKNOWN}}
+}
+
+// Const char* is also assumed to be non-null.
+extern const char *const ConstCharStarConst;
+void constCharStarCheckGlobal() {
+  clang_analyzer_eval(ConstCharStarConst); // expected-warning{{TRUE}}
+}
+
+// For char* we do not require a pointer itself to be immutable.
+extern const char *CharStarConst;
+void charStarCheckGlobal() {
+  clang_analyzer_eval(CharStarConst); // expected-warning{{TRUE}}
+}
+
+// But the pointed data should be.
+extern char *CharStar;
+void charStartCheckMutableGlobal() {
+  clang_analyzer_eval(CharStar); // expected-warning{{UNKNOWN}}
+}
+
+// Type definitions should also work across typedefs, for pointers:
+typedef const char *str;
+extern str globalStr;
+void charStarCheckTypedef() {
+  clang_analyzer_eval(globalStr); // expected-warning{{TRUE}}
+}
+
+// And for types.
+typedef NSString *const NStr;
+extern NStr globalNSString;
+void NSStringCheckTypedef() {
+  clang_analyzer_eval(globalNSString); // expected-warning{{TRUE}}
+}
+
+// Note that constness could be either inside
+// the var declaration, or in a typedef.
+typedef NSString *NStr2;
+extern const NStr2 globalNSString2;
+void NSStringCheckConstTypedef() {
+  clang_analyzer_eval(globalNSString2); // expected-warning{{TRUE}}
+}
+
+// Nested typedefs should work as well.
+typedef const CFStringRef str1;
+typedef str1 str2;
+extern str2 globalStr2;
+void testNestedTypedefs() {
+  clang_analyzer_eval(globalStr2); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/NonnilStringConstantsChecker.cpp
@@ -0,0 +1,120 @@
+
+//
+// This checker ensures that const string globals are assumed to be non-null.
+//
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+
+class NonnilStringConstantsChecker : public Checker {
+  mutable IdentifierInfo *NSStringII;
+  mutable IdentifierInfo *CFStringRefII;
+
+public:
+  NonnilStringConstantsChecker(AnalyzerOptions &AO) {}
+
+  void checkLocation(SVal l, bool isLoad, const Stmt *S,
+ CheckerContext &C) const;
+
+private:
+  /// Lazily initialize cache for required identifier informations.
+  void initIdentifierInfo(ASTContext &Ctx) const;
+  bool typeIsConstString(QualType type, bool isConstQualified) const;
+  bool isGlobalConstString(SVal val) const;
+};
+
+} // namespace
+
+void NonnilStringConstantsChecker::checkLocation(SVal location, bool isLoad,
+ const Stmt *S,
+ CheckerContext &C) const {
+  initIdentifierInfo(C.getASTContext());
+  if (!isLoad)
+return;
+
+  ProgramStateRef State = C.getState();
+  SVal V = UnknownVal();
+  if (location.isValid()) {
+V = State->getSVal(location.castAs());
+  }
+
+  if (isGlobalConstString(location)) {
+Optional Constr = V.getAs();
+
+if (Constr) {
+
+  // Assume that the variable is non-null.
+  ProgramStateRef OutputState = State->assume(*Constr, true);
+  C.addT

  1   2   >