Re: r289787 - Re-commit r289252 and r289285, and fix PR31374

2016-12-15 Thread Nico Weber via cfe-commits
Thanks! The test now also includes a regression test for PR31374, yes?

On Thu, Dec 15, 2016 at 3:09 AM, Yaxun Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yaxunl
> Date: Thu Dec 15 02:09:08 2016
> New Revision: 289787
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289787=rev
> Log:
> Re-commit r289252 and r289285, and fix PR31374
>
> Added:
> cfe/trunk/test/CodeGenOpenCL/amdgpu-nullptr.cl
> Modified:
> cfe/trunk/include/clang/AST/APValue.h
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/lib/AST/APValue.cpp
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/CodeGen/CGDecl.cpp
> cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.h
> cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
> cfe/trunk/lib/CodeGen/CodeGenTypes.h
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> cfe/trunk/lib/CodeGen/TargetInfo.h
>
> Modified: cfe/trunk/include/clang/AST/APValue.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/APValue.h?rev=289787=289786=289787=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/APValue.h (original)
> +++ cfe/trunk/include/clang/AST/APValue.h Thu Dec 15 02:09:08 2016
> @@ -135,14 +135,15 @@ public:
>}
>APValue(const APValue );
>APValue(APValue &) : Kind(Uninitialized) { swap(RHS); }
> -  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned
> CallIndex)
> +  APValue(LValueBase B, const CharUnits , NoLValuePath N, unsigned
> CallIndex,
> +  bool IsNullPtr = false)
>: Kind(Uninitialized) {
> -MakeLValue(); setLValue(B, O, N, CallIndex);
> +MakeLValue(); setLValue(B, O, N, CallIndex, IsNullPtr);
>}
>APValue(LValueBase B, const CharUnits , ArrayRef
> Path,
> -  bool OnePastTheEnd, unsigned CallIndex)
> +  bool OnePastTheEnd, unsigned CallIndex, bool IsNullPtr = false)
>: Kind(Uninitialized) {
> -MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex);
> +MakeLValue(); setLValue(B, O, Path, OnePastTheEnd, CallIndex,
> IsNullPtr);
>}
>APValue(UninitArray, unsigned InitElts, unsigned Size) :
> Kind(Uninitialized) {
>  MakeArray(InitElts, Size);
> @@ -254,6 +255,7 @@ public:
>bool hasLValuePath() const;
>ArrayRef getLValuePath() const;
>unsigned getLValueCallIndex() const;
> +  bool isNullPointer() const;
>
>APValue (unsigned I) {
>  assert(isVector() && "Invalid accessor");
> @@ -374,10 +376,10 @@ public:
>  ((ComplexAPFloat *)(char *)Data.buffer)->Imag = std::move(I);
>}
>void setLValue(LValueBase B, const CharUnits , NoLValuePath,
> - unsigned CallIndex);
> + unsigned CallIndex, bool IsNullPtr);
>void setLValue(LValueBase B, const CharUnits ,
>   ArrayRef Path, bool OnePastTheEnd,
> - unsigned CallIndex);
> + unsigned CallIndex, bool IsNullPtr);
>void setUnion(const FieldDecl *Field, const APValue ) {
>  assert(isUnion() && "Invalid accessor");
>  ((UnionData*)(char*)Data.buffer)->Field = Field;
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/ASTContext.h?rev=289787=289786=289787=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Thu Dec 15 02:09:08 2016
> @@ -2299,6 +2299,10 @@ public:
>return (*AddrSpaceMap)[AS - LangAS::Offset];
>}
>
> +  /// Get target-dependent integer value for null pointer which is used
> for
> +  /// constant folding.
> +  uint64_t getTargetNullPointerValue(QualType QT) const;
> +
>bool addressSpaceMapManglingFor(unsigned AS) const {
>  return AddrSpaceMapMangling ||
> AS < LangAS::Offset ||
>
> Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/TargetInfo.h?rev=289787=289786=289787=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
> +++ cfe/trunk/include/clang/Basic/TargetInfo.h Thu Dec 15 02:09:08 2016
> @@ -42,6 +42,7 @@ class DiagnosticsEngine;
>  class LangOptions;
>  class CodeGenOptions;
>  class MacroBuilder;
> +class QualType;
>  class SourceLocation;
>  class SourceManager;
>
> @@ -300,6 +301,12 @@ public:
>  return PointerWidth;
>}
>
> +  /// \brief Get integer value for null pointer.
> +  /// \param AddrSpace address space of pointee in source language.
> +  virtual 

[PATCH] D27821: [OpenMP] support is_device_ptr clause with 'target parallel' pragma

2016-12-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D27821



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


[PATCH] D27818: [OpenMP] Sema and parsing for 'target teams' pragma

2016-12-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D27818



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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
On Fri, Dec 16, 2016 at 12:45 AM, Akira Hatanaka 
wrote:

> It looks like it failed again. I’m still looking.
>

Well, the bot needs to run once with my change in. In that run, the .ll
file is still around and the tests will still fail, but the .cpp test will
remove it. On the first build _after_ my fix, it should cycle green.


>
> On Dec 15, 2016, at 9:14 PM, Nico Weber  wrote:
>
> I gave this a shot in 289924. Please check that's the right thing.
>
> On Fri, Dec 16, 2016 at 12:09 AM, Nico Weber  wrote:
>
>> On Fri, Dec 16, 2016 at 12:08 AM, Nico Weber  wrote:
>>
>>> I think the problem was that you didn't pipe the output to /dev/null or
>>> -, and so a .ll file got created which now confuses the bots.
>>>
>>> I suggest:
>>> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look
>>> through magic lit vars to find one that expands to the right thing)
>>>
>>
>> I think you want `rm -f %S/default-expr-arguments-3.ll`
>>
>>
>>> 2. If the intent for this is to be a -verify check, add that back
>>> 3. If not, remove expected-no-diagnostics
>>> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck,
>>> add CHECK lines
>>> 5. If it isn't FileCheck either, what does this test?
>>>
>>> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber 
>>> wrote:
>>>
 Are you aware that this is still failing on all the bots? (
 http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493
 eg)

 On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: ahatanak
> Date: Thu Dec 15 22:18:53 2016
> New Revision: 289919
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
> Log:
> Remove "-disable-llvm-optzns -verify" from the RUN line.
>
> Modified:
> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>
> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTempl
> ate/default-expr-arguments-3.cpp?rev=289919=289918=289
> 919=diff
> 
> ==
> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> (original)
> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec
> 15 22:18:53 2016
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify
> %s
> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>  // expected-no-diagnostics
>
>  namespace PR28795 {
>
>
> ___
> 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Akira Hatanaka via cfe-commits
Your commit seemed to have fixed the bot. Thanks!

I’m going to wait until all the other bots are green again and then fix the 
test case later.

> On Dec 15, 2016, at 9:45 PM, Akira Hatanaka via cfe-commits 
>  wrote:
> 
> It looks like it failed again. I’m still looking.
> 
>> On Dec 15, 2016, at 9:14 PM, Nico Weber > > wrote:
>> 
>> I gave this a shot in 289924. Please check that's the right thing.
>> 
>> On Fri, Dec 16, 2016 at 12:09 AM, Nico Weber > > wrote:
>> On Fri, Dec 16, 2016 at 12:08 AM, Nico Weber > > wrote:
>> I think the problem was that you didn't pipe the output to /dev/null or -, 
>> and so a .ll file got created which now confuses the bots.
>> 
>> I suggest:
>> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through 
>> magic lit vars to find one that expands to the right thing)
>> 
>> I think you want `rm -f %S/default-expr-arguments-3.ll`
>>  
>> 2. If the intent for this is to be a -verify check, add that back
>> 3. If not, remove expected-no-diagnostics
>> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add 
>> CHECK lines
>> 5. If it isn't FileCheck either, what does this test?
>> 
>> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber > > wrote:
>> Are you aware that this is still failing on all the bots? 
>> (http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493 
>>  eg)
>> 
>> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits 
>> > wrote:
>> Author: ahatanak
>> Date: Thu Dec 15 22:18:53 2016
>> New Revision: 289919
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev 
>> 
>> Log:
>> Remove "-disable-llvm-optzns -verify" from the RUN line.
>> 
>> Modified:
>> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>> 
>> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289919=289918=289919=diff
>>  
>> 
>> ==
>> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
>> 22:18:53 2016
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
>> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>>  // expected-no-diagnostics
>> 
>>  namespace PR28795 {
>> 
>> 
>> ___
>> 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

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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Akira Hatanaka via cfe-commits
It looks like it failed again. I’m still looking.

> On Dec 15, 2016, at 9:14 PM, Nico Weber  wrote:
> 
> I gave this a shot in 289924. Please check that's the right thing.
> 
> On Fri, Dec 16, 2016 at 12:09 AM, Nico Weber  > wrote:
> On Fri, Dec 16, 2016 at 12:08 AM, Nico Weber  > wrote:
> I think the problem was that you didn't pipe the output to /dev/null or -, 
> and so a .ll file got created which now confuses the bots.
> 
> I suggest:
> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through 
> magic lit vars to find one that expands to the right thing)
> 
> I think you want `rm -f %S/default-expr-arguments-3.ll`
>  
> 2. If the intent for this is to be a -verify check, add that back
> 3. If not, remove expected-no-diagnostics
> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add 
> CHECK lines
> 5. If it isn't FileCheck either, what does this test?
> 
> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  > wrote:
> Are you aware that this is still failing on all the bots? 
> (http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493 
>  eg)
> 
> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits 
> > wrote:
> Author: ahatanak
> Date: Thu Dec 15 22:18:53 2016
> New Revision: 289919
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev 
> 
> Log:
> Remove "-disable-llvm-optzns -verify" from the RUN line.
> 
> Modified:
> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> 
> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289919=289918=289919=diff
>  
> 
> ==
> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
> 22:18:53 2016
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>  // expected-no-diagnostics
> 
>  namespace PR28795 {
> 
> 
> ___
> 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
On Fri, Dec 16, 2016 at 12:21 AM, Akira Hatanaka 
wrote:

>
> On Dec 15, 2016, at 9:18 PM, Nico Weber  wrote:
>
> On Fri, Dec 16, 2016 at 12:14 AM, Akira Hatanaka 
> wrote:
>
>>
>> On Dec 15, 2016, at 9:08 PM, Nico Weber  wrote:
>>
>> I think the problem was that you didn't pipe the output to /dev/null or
>> -, and so a .ll file got created which now confuses the bots.
>>
>> I suggest:
>> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through
>> magic lit vars to find one that expands to the right thing)
>> 2. If the intent for this is to be a -verify check, add that back
>> 3. If not, remove expected-no-diagnostics
>> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add
>> CHECK lines
>> 5. If it isn't FileCheck either, what does this test?
>>
>>
>> I intended to do IRGen because that was where it was crashing.
>>
>
> Then the test should probably be somewhere in test/CodeGenCXX and
> FileCheck that the generated IR looks mostly correct :-)
>
>
>
> Yes, I think the test should FileCheck the IR. The bugs I fixed are in
> Sema, however the crash occurs in IRGen. In that case, should the test go
> to CodeGen* or Sema*? I see several tests in SemaTemplate are generating IR
> (using -emit-llvm).
>

Hm, I guess it's fine to keep it here then. (I find this surprising,
though.)


>
>
>> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  wrote:
>>
>>> Are you aware that this is still failing on all the bots? (
>>> http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493
>>> eg)
>>>
>>> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ahatanak
 Date: Thu Dec 15 22:18:53 2016
 New Revision: 289919

 URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
 Log:
 Remove "-disable-llvm-optzns -verify" from the RUN line.

 Modified:
 cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp

 Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
 SemaTemplate/default-expr-arguments-3.cpp?rev=289919=
 289918=289919=diff
 
 ==
 --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
 +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec
 15 22:18:53 2016
 @@ -1,4 +1,4 @@
 -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify
 %s
 +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
  // expected-no-diagnostics

  namespace PR28795 {


 ___
 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Akira Hatanaka via cfe-commits

> On Dec 15, 2016, at 9:18 PM, Nico Weber  wrote:
> 
> On Fri, Dec 16, 2016 at 12:14 AM, Akira Hatanaka  > wrote:
> 
>> On Dec 15, 2016, at 9:08 PM, Nico Weber > > wrote:
>> 
>> I think the problem was that you didn't pipe the output to /dev/null or -, 
>> and so a .ll file got created which now confuses the bots.
>> 
>> I suggest:
>> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through 
>> magic lit vars to find one that expands to the right thing)
>> 2. If the intent for this is to be a -verify check, add that back
>> 3. If not, remove expected-no-diagnostics
>> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add 
>> CHECK lines
>> 5. If it isn't FileCheck either, what does this test?
>> 
> 
> I intended to do IRGen because that was where it was crashing.
> 
> Then the test should probably be somewhere in test/CodeGenCXX and FileCheck 
> that the generated IR looks mostly correct :-)
>  

Yes, I think the test should FileCheck the IR. The bugs I fixed are in Sema, 
however the crash occurs in IRGen. In that case, should the test go to CodeGen* 
or Sema*? I see several tests in SemaTemplate are generating IR (using 
-emit-llvm).

> 
>> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber > > wrote:
>> Are you aware that this is still failing on all the bots? 
>> (http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493 
>>  eg)
>> 
>> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits 
>> > wrote:
>> Author: ahatanak
>> Date: Thu Dec 15 22:18:53 2016
>> New Revision: 289919
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev 
>> 
>> Log:
>> Remove "-disable-llvm-optzns -verify" from the RUN line.
>> 
>> Modified:
>> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>> 
>> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289919=289918=289919=diff
>>  
>> 
>> ==
>> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
>> 22:18:53 2016
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
>> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>>  // expected-no-diagnostics
>> 
>>  namespace PR28795 {
>> 
>> 
>> ___
>> 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
On Fri, Dec 16, 2016 at 12:14 AM, Akira Hatanaka 
wrote:

>
> On Dec 15, 2016, at 9:08 PM, Nico Weber  wrote:
>
> I think the problem was that you didn't pipe the output to /dev/null or -,
> and so a .ll file got created which now confuses the bots.
>
> I suggest:
> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through
> magic lit vars to find one that expands to the right thing)
> 2. If the intent for this is to be a -verify check, add that back
> 3. If not, remove expected-no-diagnostics
> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add
> CHECK lines
> 5. If it isn't FileCheck either, what does this test?
>
>
> I intended to do IRGen because that was where it was crashing.
>

Then the test should probably be somewhere in test/CodeGenCXX and FileCheck
that the generated IR looks mostly correct :-)


>
> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  wrote:
>
>> Are you aware that this is still failing on all the bots? (
>> http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493
>> eg)
>>
>> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ahatanak
>>> Date: Thu Dec 15 22:18:53 2016
>>> New Revision: 289919
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
>>> Log:
>>> Remove "-disable-llvm-optzns -verify" from the RUN line.
>>>
>>> Modified:
>>> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>>>
>>> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTempl
>>> ate/default-expr-arguments-3.cpp?rev=289919=289918=289
>>> 919=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
>>> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15
>>> 22:18:53 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
>>> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>>>  // expected-no-diagnostics
>>>
>>>  namespace PR28795 {
>>>
>>>
>>> ___
>>> 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Akira Hatanaka via cfe-commits

> On Dec 15, 2016, at 9:08 PM, Nico Weber  wrote:
> 
> I think the problem was that you didn't pipe the output to /dev/null or -, 
> and so a .ll file got created which now confuses the bots.
> 
> I suggest:
> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through 
> magic lit vars to find one that expands to the right thing)
> 2. If the intent for this is to be a -verify check, add that back
> 3. If not, remove expected-no-diagnostics
> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add 
> CHECK lines
> 5. If it isn't FileCheck either, what does this test?
> 

I intended to do IRGen because that was where it was crashing.

> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  > wrote:
> Are you aware that this is still failing on all the bots? 
> (http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493 
>  eg)
> 
> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits 
> > wrote:
> Author: ahatanak
> Date: Thu Dec 15 22:18:53 2016
> New Revision: 289919
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev 
> 
> Log:
> Remove "-disable-llvm-optzns -verify" from the RUN line.
> 
> Modified:
> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> 
> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289919=289918=289919=diff
>  
> 
> ==
> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
> 22:18:53 2016
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>  // expected-no-diagnostics
> 
>  namespace PR28795 {
> 
> 
> ___
> 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


r289924 - attempt to fix bots after r289914/r289919

2016-12-15 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Dec 15 23:03:44 2016
New Revision: 289924

URL: http://llvm.org/viewvc/llvm-project?rev=289924=rev
Log:
attempt to fix bots after r289914/r289919

Modified:
cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp

Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289924=289923=289924=diff
==
--- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
23:03:44 2016
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
+// FIXME: Remove the next line after a bit; this test used to
+// write a .ll file and that confuses the bots. The next line
+// cleans that up.
+// RUN: rm -f %S/default-expr-arguments-3.ll
+// RUN: %clang_cc1 -std=c++14 -verify %s
 // expected-no-diagnostics
 
 namespace PR28795 {


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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
I gave this a shot in 289924. Please check that's the right thing.

On Fri, Dec 16, 2016 at 12:09 AM, Nico Weber  wrote:

> On Fri, Dec 16, 2016 at 12:08 AM, Nico Weber  wrote:
>
>> I think the problem was that you didn't pipe the output to /dev/null or
>> -, and so a .ll file got created which now confuses the bots.
>>
>> I suggest:
>> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through
>> magic lit vars to find one that expands to the right thing)
>>
>
> I think you want `rm -f %S/default-expr-arguments-3.ll`
>
>
>> 2. If the intent for this is to be a -verify check, add that back
>> 3. If not, remove expected-no-diagnostics
>> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add
>> CHECK lines
>> 5. If it isn't FileCheck either, what does this test?
>>
>> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  wrote:
>>
>>> Are you aware that this is still failing on all the bots? (
>>> http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493
>>> eg)
>>>
>>> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ahatanak
 Date: Thu Dec 15 22:18:53 2016
 New Revision: 289919

 URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
 Log:
 Remove "-disable-llvm-optzns -verify" from the RUN line.

 Modified:
 cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp

 Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTempl
 ate/default-expr-arguments-3.cpp?rev=289919=289918=289
 919=diff
 
 ==
 --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
 +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec
 15 22:18:53 2016
 @@ -1,4 +1,4 @@
 -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify
 %s
 +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
  // expected-no-diagnostics

  namespace PR28795 {


 ___
 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
On Fri, Dec 16, 2016 at 12:08 AM, Nico Weber  wrote:

> I think the problem was that you didn't pipe the output to /dev/null or -,
> and so a .ll file got created which now confuses the bots.
>
> I suggest:
> 1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through
> magic lit vars to find one that expands to the right thing)
>

I think you want `rm -f %S/default-expr-arguments-3.ll`


> 2. If the intent for this is to be a -verify check, add that back
> 3. If not, remove expected-no-diagnostics
> 4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add
> CHECK lines
> 5. If it isn't FileCheck either, what does this test?
>
> On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  wrote:
>
>> Are you aware that this is still failing on all the bots? (
>> http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493
>> eg)
>>
>> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ahatanak
>>> Date: Thu Dec 15 22:18:53 2016
>>> New Revision: 289919
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
>>> Log:
>>> Remove "-disable-llvm-optzns -verify" from the RUN line.
>>>
>>> Modified:
>>> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>>>
>>> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTempl
>>> ate/default-expr-arguments-3.cpp?rev=289919=289918=289
>>> 919=diff
>>> 
>>> ==
>>> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
>>> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15
>>> 22:18:53 2016
>>> @@ -1,4 +1,4 @@
>>> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
>>> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>>>  // expected-no-diagnostics
>>>
>>>  namespace PR28795 {
>>>
>>>
>>> ___
>>> 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
I think the problem was that you didn't pipe the output to /dev/null or -,
and so a .ll file got created which now confuses the bots.

I suggest:
1. Add `// RUN: rm -f right_path.ll` at the top for a while (look through
magic lit vars to find one that expands to the right thing)
2. If the intent for this is to be a -verify check, add that back
3. If not, remove expected-no-diagnostics
4. If not, is this a FileCheck test? If so, pipe output to FileCheck, add
CHECK lines
5. If it isn't FileCheck either, what does this test?

On Fri, Dec 16, 2016 at 12:05 AM, Nico Weber  wrote:

> Are you aware that this is still failing on all the bots? (
> http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493
> eg)
>
> On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ahatanak
>> Date: Thu Dec 15 22:18:53 2016
>> New Revision: 289919
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
>> Log:
>> Remove "-disable-llvm-optzns -verify" from the RUN line.
>>
>> Modified:
>> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>>
>> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTempl
>> ate/default-expr-arguments-3.cpp?rev=289919=289918=289919=diff
>> 
>> ==
>> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
>> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15
>> 22:18:53 2016
>> @@ -1,4 +1,4 @@
>> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
>> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>>  // expected-no-diagnostics
>>
>>  namespace PR28795 {
>>
>>
>> ___
>> 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


Re: r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Nico Weber via cfe-commits
Are you aware that this is still failing on all the bots? (
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/493 eg)

On Thu, Dec 15, 2016 at 11:18 PM, Akira Hatanaka via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ahatanak
> Date: Thu Dec 15 22:18:53 2016
> New Revision: 289919
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
> Log:
> Remove "-disable-llvm-optzns -verify" from the RUN line.
>
> Modified:
> cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
>
> Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> SemaTemplate/default-expr-arguments-3.cpp?rev=289919=
> 289918=289919=diff
> 
> ==
> --- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
> +++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15
> 22:18:53 2016
> @@ -1,4 +1,4 @@
> -// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
> +// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
>  // expected-no-diagnostics
>
>  namespace PR28795 {
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27440: clang-format-vsix: fail when clang-format outputs to stderr

2016-12-15 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

Hi @djasper, just curious about your opinion on this change, and on the 
conversation following it, specifically regarding whether clang-format should 
really use the fallback style when failing to parse a .clang-format file. 
Thanks!


https://reviews.llvm.org/D27440



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


r289921 - Update for LLVM global variable debug info API change.

2016-12-15 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec 15 22:26:15 2016
New Revision: 289921

URL: http://llvm.org/viewvc/llvm-project?rev=289921=rev
Log:
Update for LLVM global variable debug info API change.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c
cfe/trunk/test/CodeGen/2010-08-10-DbgConstant.c
cfe/trunk/test/CodeGen/debug-info-atomic.c
cfe/trunk/test/CodeGen/debug-info-global-constant.c
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
cfe/trunk/test/CodeGen/debug-info-static.c
cfe/trunk/test/CodeGenCXX/debug-info-global.cpp
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/debug-info.cpp
cfe/trunk/test/CodeGenCXX/inline-dllexport-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289921=289920=289921=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 15 22:26:15 2016
@@ -2855,7 +2855,7 @@ CGDebugInfo::getGlobalVariableForwardDec
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
   DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
-  !VD->isExternallyVisible(), nullptr, nullptr, Align);
+  !VD->isExternallyVisible(), nullptr, Align);
   FwdDeclReplaceMap.emplace_back(
   std::piecewise_construct,
   std::make_tuple(cast(VD->getCanonicalDecl())),
@@ -2873,8 +2873,12 @@ llvm::DINode *CGDebugInfo::getDeclaratio
getOrCreateFile(TD->getLocation()));
   auto I = DeclCache.find(D->getCanonicalDecl());
 
-  if (I != DeclCache.end())
-return dyn_cast_or_null(I->second);
+  if (I != DeclCache.end()) {
+auto N = I->second;
+if (auto *GVE = dyn_cast_or_null(N))
+  return GVE->getVariable();
+return dyn_cast_or_null(N);
+  }
 
   // No definition for now. Emit a forward definition that might be
   // merged with a potential upcoming definition.
@@ -3650,10 +3654,10 @@ CGDebugInfo::getOrCreateStaticDataMember
   return CreateRecordStaticField(D, Ctxt, cast(DC));
 }
 
-llvm::DIGlobalVariable *CGDebugInfo::CollectAnonRecordDecls(
+llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
 const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
 StringRef LinkageName, llvm::GlobalVariable *Var, llvm::DIScope *DContext) 
{
-  llvm::DIGlobalVariable *GV = nullptr;
+  llvm::DIGlobalVariableExpression *GVE = nullptr;
 
   for (const auto *Field : RD->fields()) {
 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -3662,16 +3666,17 @@ llvm::DIGlobalVariable *CGDebugInfo::Col
 // Ignore unnamed fields, but recurse into anonymous records.
 if (FieldName.empty()) {
   if (const auto *RT = dyn_cast(Field->getType()))
-GV = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
+GVE = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
 Var, DContext);
   continue;
 }
 // Use VarDecl's Tag, Scope and Line number.
-GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit,
-   LineNo, FieldTy, 
Var->hasLocalLinkage());
-Var->addDebugInfo(GV);
+GVE = DBuilder.createGlobalVariableExpression(
+DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
+Var->hasLocalLinkage());
+Var->addDebugInfo(GVE);
   }
-  return GV;
+  return GVE;
 }
 
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
@@ -3684,7 +3689,8 @@ void CGDebugInfo::EmitGlobalVariable(llv
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
   if (Cached != DeclCache.end())
-return Var->addDebugInfo(cast(Cached->second));
+return Var->addDebugInfo(
+cast(Cached->second));
 
   // Create global variable debug descriptor.
   llvm::DIFile *Unit = nullptr;
@@ -3696,7 +3702,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
 
   // Attempt to store one global variable for the declaration - even if we
   // emit a lot of fields.
-  llvm::DIGlobalVariable *GV = nullptr;
+  llvm::DIGlobalVariableExpression *GVE = nullptr;
 
   // If this is an anonymous union then we'll want to emit a global
   // variable for each member of the anonymous union so that it's possible
@@ -3705,16 +3711,16 @@ void CGDebugInfo::EmitGlobalVariable(llv
 const RecordDecl *RD = T->castAs()->getDecl();
 assert(RD->isAnonymousStructOrUnion() &&
"unnamed non-anonymous struct or union?");
-GV = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext);

r289919 - Remove "-disable-llvm-optzns -verify" from the RUN line.

2016-12-15 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Dec 15 22:18:53 2016
New Revision: 289919

URL: http://llvm.org/viewvc/llvm-project?rev=289919=rev
Log:
Remove "-disable-llvm-optzns -verify" from the RUN line.

Modified:
cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp

Modified: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289919=289918=289919=diff
==
--- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (original)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
22:18:53 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
+// RUN: %clang_cc1 -std=c++14 -emit-llvm -o - %s
 // expected-no-diagnostics
 
 namespace PR28795 {


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


r289914 - [Sema] Fix handling of enumerators used as default arguments of lambda

2016-12-15 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Dec 15 21:19:41 2016
New Revision: 289914

URL: http://llvm.org/viewvc/llvm-project?rev=289914=rev
Log:
[Sema] Fix handling of enumerators used as default arguments of lambda
expressions in a function or class template.

This patch makes the following changes:

- Create a DependentScopeDeclRefExpr for the default argument instead of
  a CXXDependentScopeMemberExpr.
- Pass CombineWithOuterScope=true so that the outer scope in which the
  enum is declared is searched for the instantiation of the enum. 

This is the first part of https://reviews.llvm.org/D23096. Fixes PR28795

rdar://problem/27535319

Added:
cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=289914=289913=289914=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu Dec 15 21:19:41 2016
@@ -429,7 +429,12 @@ Sema::ActOnDependentIdExpression(const C
   bool MightBeCxx11UnevalField =
   getLangOpts().CPlusPlus11 && isUnevaluatedContext();
 
-  if (!MightBeCxx11UnevalField && !isAddressOfOperand &&
+  // Check if the nested name specifier is an enum type.
+  bool IsEnum = false;
+  if (NestedNameSpecifier *NNS = SS.getScopeRep())
+IsEnum = dyn_cast_or_null(NNS->getAsType());
+
+  if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
   isa(DC) && cast(DC)->isInstance()) {
 QualType ThisType = cast(DC)->getThisType(Context);
 

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=289914=289913=289914=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Dec 15 21:19:41 2016
@@ -1687,7 +1687,7 @@ ParmVarDecl *Sema::SubstParmVarDecl(Parm
   // Instantiate default arguments for methods of local classes (DR1484)
   // and non-defining declarations.
   Sema::ContextRAII SavedContext(*this, OwningFunc);
-  LocalInstantiationScope Local(*this);
+  LocalInstantiationScope Local(*this, true);
   ExprResult NewArg = SubstExpr(Arg, TemplateArgs);
   if (NewArg.isUsable()) {
 // It would be nice if we still had this.

Added: cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp?rev=289914=auto
==
--- cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp (added)
+++ cfe/trunk/test/SemaTemplate/default-expr-arguments-3.cpp Thu Dec 15 
21:19:41 2016
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++14 -emit-llvm -disable-llvm-optzns -verify %s
+// expected-no-diagnostics
+
+namespace PR28795 {
+  template
+  void func() {
+enum class foo { a, b };
+auto bar = [](foo f = foo::a) { return f; };
+bar();
+  }
+
+  void foo() {
+func();
+  }
+}
+
+// Template struct case:
+template  struct class2 {
+  void bar() {
+enum class foo { a, b };
+[](foo f = foo::a) { return f; }();
+  }
+};
+
+template struct class2;
+
+template
+void f1() {
+  enum class foo { a, b };
+  struct S {
+int g1(foo n = foo::a);
+  };
+}
+
+template void f1();


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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It may be good idea to create LLVM check which will suggest to use STLExtras.h 
wrappers instead of STL algorithms.


https://reviews.llvm.org/D27806



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


[PATCH] D27187: [clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop

2016-12-15 Thread Felix Berger via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
flx marked an inline comment as done.
Closed by commit rL289912: [clang-tidy] Do not move parameter if only 
DeclRefExpr occurs inside of a loop (authored by flx).

Changed prior to commit:
  https://reviews.llvm.org/D27187?vs=81693=81706#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27187

Files:
  clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -47,6 +47,17 @@
   return !Matches.empty();
 }
 
+bool hasLoopStmtAncestor(const DeclRefExpr , const Stmt ,
+ ASTContext ) {
+  auto Matches =
+  match(findAll(declRefExpr(
+equalsNode(),
+unless(hasAncestor(stmt(anyOf(forStmt(), cxxForRangeStmt(),
+  whileStmt(), doStmt())),
+Stmt, Context);
+  return Matches.empty();
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -105,6 +116,8 @@
   if (!IsConstQualified) {
 auto CanonicalType = Param->getType().getCanonicalType();
 if (AllDeclRefExprs.size() == 1 &&
+!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
+ *Result.Context) &&
 ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
   utils::decl_ref_expr::isCopyConstructorArgument(
   **AllDeclRefExprs.begin(), *Function->getBody(),
Index: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -225,6 +225,15 @@
   // CHECK-FIXES: F = std::move(E);
 }
 
+// The argument could be moved but is not since copy statement is inside a 
loop.
+void PositiveNoMoveInsideLoop(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveNoMoveInsideLoop(const ExpensiveMovableType& E) 
{
+  for (;;) {
+auto F = E;
+  }
+}
+
 void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
   // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied
   // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const 
ExpensiveToCopyType& T) {


Index: clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -47,6 +47,17 @@
   return !Matches.empty();
 }
 
+bool hasLoopStmtAncestor(const DeclRefExpr , const Stmt ,
+ ASTContext ) {
+  auto Matches =
+  match(findAll(declRefExpr(
+equalsNode(),
+unless(hasAncestor(stmt(anyOf(forStmt(), cxxForRangeStmt(),
+  whileStmt(), doStmt())),
+Stmt, Context);
+  return Matches.empty();
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -105,6 +116,8 @@
   if (!IsConstQualified) {
 auto CanonicalType = Param->getType().getCanonicalType();
 if (AllDeclRefExprs.size() == 1 &&
+!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
+ *Result.Context) &&
 ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
   utils::decl_ref_expr::isCopyConstructorArgument(
   **AllDeclRefExprs.begin(), *Function->getBody(),
Index: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -225,6 +225,15 @@
   // CHECK-FIXES: F = std::move(E);
 }
 
+// The argument could be moved but is not since copy statement is inside a loop.
+void PositiveNoMoveInsideLoop(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveNoMoveInsideLoop(const ExpensiveMovableType& E) {
+  for (;;) {
+auto F = E;
+  }
+}
+
 void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
   // CHECK-MESSAGES: [[@LINE-1]]:63: 

[PATCH] D27187: [clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop

2016-12-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

Thanks, this is fine to commit.


https://reviews.llvm.org/D27187



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


[clang-tools-extra] r289912 - [clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop

2016-12-15 Thread Felix Berger via cfe-commits
Author: flx
Date: Thu Dec 15 20:47:56 2016
New Revision: 289912

URL: http://llvm.org/viewvc/llvm-project?rev=289912=rev
Log:
[clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop

Summary: This fixes a bug where the performance-unnecessary-value-param check 
suggests a fix to move the parameter inside of a loop which could be invoked 
multiple times.

Reviewers: sbenza, aaron.ballman, alexfh

Subscribers: JDevlieghere, cfe-commits

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

Modified:

clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp?rev=289912=289911=289912=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
Thu Dec 15 20:47:56 2016
@@ -47,6 +47,17 @@ bool isReferencedOutsideOfCallExpr(const
   return !Matches.empty();
 }
 
+bool hasLoopStmtAncestor(const DeclRefExpr , const Stmt ,
+ ASTContext ) {
+  auto Matches =
+  match(findAll(declRefExpr(
+equalsNode(),
+unless(hasAncestor(stmt(anyOf(forStmt(), cxxForRangeStmt(),
+  whileStmt(), doStmt())),
+Stmt, Context);
+  return Matches.empty();
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -105,6 +116,8 @@ void UnnecessaryValueParamCheck::check(c
   if (!IsConstQualified) {
 auto CanonicalType = Param->getType().getCanonicalType();
 if (AllDeclRefExprs.size() == 1 &&
+!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
+ *Result.Context) &&
 ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
   utils::decl_ref_expr::isCopyConstructorArgument(
   **AllDeclRefExprs.begin(), *Function->getBody(),

Modified: 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp?rev=289912=289911=289912=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param.cpp 
Thu Dec 15 20:47:56 2016
@@ -225,6 +225,15 @@ void PositiveMoveOnCopyAssignment(Expens
   // CHECK-FIXES: F = std::move(E);
 }
 
+// The argument could be moved but is not since copy statement is inside a 
loop.
+void PositiveNoMoveInsideLoop(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveNoMoveInsideLoop(const ExpensiveMovableType& E) 
{
+  for (;;) {
+auto F = E;
+  }
+}
+
 void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
   // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied
   // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const 
ExpensiveToCopyType& T) {


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


[PATCH] D27501: clang-format-vsix: add command to format document

2016-12-15 Thread Antonio Maiorano via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289910: clang-format-vsix: add command to format document 
(authored by amaiorano).

Changed prior to commit:
  https://reviews.llvm.org/D27501?vs=80533=81701#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27501

Files:
  cfe/trunk/tools/clang-format-vs/.gitignore
  cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.vsct
  cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  cfe/trunk/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
  cfe/trunk/tools/clang-format-vs/README.txt

Index: cfe/trunk/tools/clang-format-vs/README.txt
===
--- cfe/trunk/tools/clang-format-vs/README.txt
+++ cfe/trunk/tools/clang-format-vs/README.txt
@@ -25,3 +25,27 @@
 ClangFormat/source.extension.vsixmanifest. Once the plug-in has been built with
 CMake once, it can be built manually from the ClangFormat.sln solution in Visual
 Studio.
+
+===
+ Debugging
+===
+
+Once you've built the clang_format_vsix project from LLVM.sln at least once,
+open ClangFormat.sln in Visual Studio, then:
+
+- Make sure the "Debug" target is selected
+- Open the ClangFormat project properties
+- Select the Debug tab
+- Set "Start external program:" to where your devenv.exe is installed. Typically
+  it's "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe"
+- Set "Command line arguments" to: /rootsuffix Exp
+- You can now set breakpoints if you like
+- Press F5 to build and run with debugger
+
+If all goes well, a new instance of Visual Studio will be launched in a special
+mode where it uses the experimental hive instead of the normal configuration hive.
+By default, when you build a VSIX project in Visual Studio, it auto-registers the
+extension in the experimental hive, allowing you to test it. In the new Visual Studio
+instance, open or create a C++ solution, and you should now see the Clang Format
+entries in the Tool menu. You can test it out, and any breakpoints you set will be
+hit where you can debug as usual.
Index: cfe/trunk/tools/clang-format-vs/.gitignore
===
--- cfe/trunk/tools/clang-format-vs/.gitignore
+++ cfe/trunk/tools/clang-format-vs/.gitignore
@@ -1,5 +1,6 @@
 # Visual Studio files
 .vs/
+*.user
 /packages/
 /ClangFormat/obj/
 /ClangFormat/bin/
Index: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -180,41 +180,86 @@
 var commandService = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
 if (commandService != null)
 {
-var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormat);
-var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
-commandService.AddCommand(menuItem);
+{
+var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatSelection);
+var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+commandService.AddCommand(menuItem);
+}
+
+{
+var menuCommandID = new CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormatDocument);
+var menuItem = new MenuCommand(MenuItemCallback, menuCommandID);
+commandService.AddCommand(menuItem);
+}
 }
 }
 #endregion
 
 private void MenuItemCallback(object sender, EventArgs args)
 {
+var mc = sender as System.ComponentModel.Design.MenuCommand;
+if (mc == null)
+return;
+
+switch (mc.CommandID.ID)
+{
+case (int)PkgCmdIDList.cmdidClangFormatSelection:
+FormatSelection();
+break;
+
+case (int)PkgCmdIDList.cmdidClangFormatDocument:
+FormatDocument();
+break;
+}
+}
+
+/// 
+/// Runs clang-format on the current selection
+/// 
+private void FormatSelection()
+{
 IWpfTextView view = GetCurrentView();
 if (view == null)
 // We're not in a text view.
 return;
 string text = view.TextBuffer.CurrentSnapshot.GetText();
 int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
 int end = view.Selection.End.Position.GetContainingLine().End.Position;
 int length = end - start;
+
 // 

r289910 - clang-format-vsix: add command to format document

2016-12-15 Thread Antonio Maiorano via cfe-commits
Author: amaiorano
Date: Thu Dec 15 19:51:43 2016
New Revision: 289910

URL: http://llvm.org/viewvc/llvm-project?rev=289910=rev
Log:
clang-format-vsix: add command to format document

Bound to Ctrl+R, Ctrl+D by default. Also added section on how to debug the 
extension to the Readme.

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

Modified:
cfe/trunk/tools/clang-format-vs/.gitignore
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.vsct
cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
cfe/trunk/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
cfe/trunk/tools/clang-format-vs/README.txt

Modified: cfe/trunk/tools/clang-format-vs/.gitignore
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/.gitignore?rev=289910=289909=289910=diff
==
--- cfe/trunk/tools/clang-format-vs/.gitignore (original)
+++ cfe/trunk/tools/clang-format-vs/.gitignore Thu Dec 15 19:51:43 2016
@@ -1,5 +1,6 @@
 # Visual Studio files
 .vs/
+*.user
 /packages/
 /ClangFormat/obj/
 /ClangFormat/bin/

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.vsct
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.vsct?rev=289910=289909=289910=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.vsct (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormat.vsct Thu Dec 15 
19:51:43 2016
@@ -61,15 +61,21 @@
   DynamicVisibility
   If you do not want an image next to your command, remove the Icon 
node /> -->
 
-  
+  
 
 
 
-  ClangFormat
+  Clang Format Selection
 
   
 
-
+  
+
+
+
+  Clang Format Document
+
+  
 
 

@@ -88,7 +94,8 @@
 
 
   
-
+
+
   
 
 
@@ -101,7 +108,8 @@
 
 
   
-  
+  
+  
 
 
 

Modified: cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs?rev=289910=289909=289910=diff
==
--- cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs (original)
+++ cfe/trunk/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs Thu Dec 
15 19:51:43 2016
@@ -180,15 +180,44 @@ namespace LLVM.ClangFormat
 var commandService = GetService(typeof(IMenuCommandService)) as 
OleMenuCommandService;
 if (commandService != null)
 {
-var menuCommandID = new 
CommandID(GuidList.guidClangFormatCmdSet, (int)PkgCmdIDList.cmdidClangFormat);
-var menuItem = new MenuCommand(MenuItemCallback, 
menuCommandID);
-commandService.AddCommand(menuItem);
+{
+var menuCommandID = new 
CommandID(GuidList.guidClangFormatCmdSet, 
(int)PkgCmdIDList.cmdidClangFormatSelection);
+var menuItem = new MenuCommand(MenuItemCallback, 
menuCommandID);
+commandService.AddCommand(menuItem);
+}
+
+{
+var menuCommandID = new 
CommandID(GuidList.guidClangFormatCmdSet, 
(int)PkgCmdIDList.cmdidClangFormatDocument);
+var menuItem = new MenuCommand(MenuItemCallback, 
menuCommandID);
+commandService.AddCommand(menuItem);
+}
 }
 }
 #endregion
 
 private void MenuItemCallback(object sender, EventArgs args)
 {
+var mc = sender as System.ComponentModel.Design.MenuCommand;
+if (mc == null)
+return;
+
+switch (mc.CommandID.ID)
+{
+case (int)PkgCmdIDList.cmdidClangFormatSelection:
+FormatSelection();
+break;
+
+case (int)PkgCmdIDList.cmdidClangFormatDocument:
+FormatDocument();
+break;
+}
+}
+
+/// 
+/// Runs clang-format on the current selection
+/// 
+private void FormatSelection()
+{
 IWpfTextView view = GetCurrentView();
 if (view == null)
 // We're not in a text view.
@@ -197,24 +226,40 @@ namespace LLVM.ClangFormat
 int start = 
view.Selection.Start.Position.GetContainingLine().Start.Position;
 int end = 
view.Selection.End.Position.GetContainingLine().End.Position;
 int length = end - start;
+
 // clang-format doesn't support formatting a range that starts at 
the end
 // of the file.
 if (start >= text.Length && text.Length > 0)
 start = 

[PATCH] D27837: Add fix-it notes to the nullability consistency warning

2016-12-15 Thread Jordan Rose via Phabricator via cfe-commits
jordan_rose created this revision.
jordan_rose added a reviewer: doug.gregor.
jordan_rose added a subscriber: cfe-commits.
jordan_rose set the repository for this revision to rL LLVM.

This is especially important for arrays, since no one knows the proper syntax 
for putting qualifiers in arrays.

  nullability.h:3:26: warning: array parameter is missing a nullability type 
specifier (_Nonnull, _Nullable, or _Null_unspecified)
  void arrayParameter(int x[]);
   ^
  nullability.h:3:26: note: insert '_Nullable' if the array parameter may be 
null
  void arrayParameter(int x[]);
   ^
_Nullable
  nullability.h:3:26: note: insert '_Nonnull' if the array parameter should 
never be null
  void arrayParameter(int x[]);
   ^
_Nonnull

rdar://problem/29524992


Repository:
  rL LLVM

https://reviews.llvm.org/D27837

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaType.cpp
  test/FixIt/Inputs/nullability.h
  test/FixIt/nullability.mm
  test/SemaObjCXX/Inputs/nullability-consistency-1.h
  test/SemaObjCXX/Inputs/nullability-consistency-2.h
  test/SemaObjCXX/Inputs/nullability-consistency-3.h
  test/SemaObjCXX/Inputs/nullability-consistency-4.h
  test/SemaObjCXX/Inputs/nullability-consistency-5.h
  test/SemaObjCXX/Inputs/nullability-consistency-6.h
  test/SemaObjCXX/Inputs/nullability-consistency-7.h
  test/SemaObjCXX/Inputs/nullability-consistency-8.h
  test/SemaObjCXX/Inputs/nullability-consistency-arrays.h
  
test/SemaObjCXX/Inputs/nullability-consistency-system/nullability-consistency-system.h
  test/SemaObjCXX/Inputs/nullability-pragmas-1.h

Index: test/SemaObjCXX/Inputs/nullability-pragmas-1.h
===
--- test/SemaObjCXX/Inputs/nullability-pragmas-1.h
+++ test/SemaObjCXX/Inputs/nullability-pragmas-1.h
@@ -9,6 +9,8 @@
 struct X { };
 
 void f1(int *x); // expected-warning{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
 
 typedef struct __attribute__((objc_bridge(NSError))) __CFError *CFErrorRef;
 typedef NSError *NSErrorPtr;
@@ -39,15 +41,29 @@
 A * _Null_unspecified f16(void);
 void f17(CFErrorRef *error); // expected-note{{no known conversion from 'A * _Nonnull' to 'CFErrorRef  _Nullable * _Nullable' (aka '__CFError **') for 1st argument}}
 void f18(A **); // expected-warning 2{{pointer is missing a nullability type specifier}}
+// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
 void f19(CFErrorRefPtr error); // expected-warning{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the pointer should never be null}}
 
 void g1(int (^)(int, int));
 void g2(int (^ *bp)(int, int)); // expected-warning{{block pointer is missing a nullability type specifier}}
-// expected-warning@-1{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
+// expected-warning@-3{{pointer is missing a nullability type specifier}}
+// expected-note@-4{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
 void g3(block_ptr *bp); // expected-warning{{block pointer is missing a nullability type specifier}}
-// expected-warning@-1{{pointer is missing a nullability type specifier}}
+// expected-note@-1{{insert '_Nullable' if the block pointer may be null}}
+// expected-note@-2{{insert '_Nonnull' if the block pointer should never be null}}
+// expected-warning@-3{{pointer is missing a nullability type specifier}}
+// expected-note@-4{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-5{{insert '_Nonnull' if the pointer should never be null}}
 void g4(int (*fp)(int, int));
 void g5(int (**fp)(int, int)); // expected-warning 2{{pointer is missing a nullability type specifier}}
+// expected-note@-1 2 {{insert '_Nullable' if the pointer may be null}}
+// expected-note@-2 2 {{insert '_Nonnull' if the pointer should never be null}}
 
 @interface A(Pragmas1)
 + (instancetype)aWithA:(A *)a;
@@ -57,17 +73,23 @@
 - (void)method4:(NSErrorPtr *)error; // expected-note{{passing argument to parameter 'error' here}}
 - (void)method5:(NSErrorPtrPtr)error;
 // expected-warning@-1{{pointer is missing a nullability type specifier}}
+// expected-note@-2{{insert '_Nullable' if the pointer may be null}}
+// expected-note@-3{{insert '_Nonnull' if the pointer should never be null}}
 
 @property A *aProp;
 @property NSError **anError; // expected-warning 2{{pointer 

[PATCH] D27438: clang-format-vsix: add a date stamp to the VSIX version number to ensure upgradability

2016-12-15 Thread Antonio Maiorano via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289909: clang-format-vsix: add a date stamp to the VSIX 
version number to ensure… (authored by amaiorano).

Changed prior to commit:
  https://reviews.llvm.org/D27438?vs=80527=81696#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27438

Files:
  cfe/trunk/tools/clang-format-vs/CMakeLists.txt


Index: cfe/trunk/tools/clang-format-vs/CMakeLists.txt
===
--- cfe/trunk/tools/clang-format-vs/CMakeLists.txt
+++ cfe/trunk/tools/clang-format-vs/CMakeLists.txt
@@ -11,8 +11,11 @@
   "${CLANG_SOURCE_DIR}/LICENSE.TXT"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
 
+  # Build number added to Clang version to ensure that new VSIX can be upgraded
+  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
+
   if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
   endif()
 
   configure_file("source.extension.vsixmanifest.in"


Index: cfe/trunk/tools/clang-format-vs/CMakeLists.txt
===
--- cfe/trunk/tools/clang-format-vs/CMakeLists.txt
+++ cfe/trunk/tools/clang-format-vs/CMakeLists.txt
@@ -11,8 +11,11 @@
   "${CLANG_SOURCE_DIR}/LICENSE.TXT"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
 
+  # Build number added to Clang version to ensure that new VSIX can be upgraded
+  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
+
   if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+set(CLANG_FORMAT_VS_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
   endif()
 
   configure_file("source.extension.vsixmanifest.in"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289909 - clang-format-vsix: add a date stamp to the VSIX version number to ensure upgradability

2016-12-15 Thread Antonio Maiorano via cfe-commits
Author: amaiorano
Date: Thu Dec 15 19:37:01 2016
New Revision: 289909

URL: http://llvm.org/viewvc/llvm-project?rev=289909=rev
Log:
clang-format-vsix: add a date stamp to the VSIX version number to ensure 
upgradability

Presently, the version number of the VSIX matches the LLVM version number. 
However, as this number doesn't change often, it means that as we release new 
versions of this VSIX, it will have the same version number, which means users 
must first uninstall the old version before installing the new one. With this 
change, we generate a 4th part to the version number that is a date stamp 
(year, month, day); for example: 4.0.0.161203.

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

Modified:
cfe/trunk/tools/clang-format-vs/CMakeLists.txt

Modified: cfe/trunk/tools/clang-format-vs/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format-vs/CMakeLists.txt?rev=289909=289908=289909=diff
==
--- cfe/trunk/tools/clang-format-vs/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-format-vs/CMakeLists.txt Thu Dec 15 19:37:01 2016
@@ -11,8 +11,11 @@ if (BUILD_CLANG_FORMAT_VS_PLUGIN)
   "${CLANG_SOURCE_DIR}/LICENSE.TXT"
   "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/license.txt")
 
+  # Build number added to Clang version to ensure that new VSIX can be upgraded
+  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
+
   if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
+set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
   endif()
 
   configure_file("source.extension.vsixmanifest.in"


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


[PATCH] D27187: [clang-tidy] Do not move parameter if only DeclRefExpr occurs inside of a loop

2016-12-15 Thread Felix Berger via Phabricator via cfe-commits
flx updated this revision to Diff 81693.

https://reviews.llvm.org/D27187

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -225,6 +225,15 @@
   // CHECK-FIXES: F = std::move(E);
 }
 
+// The argument could be moved but is not since copy statement is inside a 
loop.
+void PositiveNoMoveInsideLoop(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveNoMoveInsideLoop(const ExpensiveMovableType& E) 
{
+  for (;;) {
+auto F = E;
+  }
+}
+
 void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
   // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied
   // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const 
ExpensiveToCopyType& T) {
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -47,6 +47,17 @@
   return !Matches.empty();
 }
 
+bool hasLoopStmtAncestor(const DeclRefExpr , const Stmt ,
+ ASTContext ) {
+  auto Matches =
+  match(findAll(declRefExpr(
+equalsNode(),
+unless(hasAncestor(stmt(anyOf(forStmt(), cxxForRangeStmt(),
+  whileStmt(), doStmt())),
+Stmt, Context);
+  return Matches.empty();
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -105,6 +116,8 @@
   if (!IsConstQualified) {
 auto CanonicalType = Param->getType().getCanonicalType();
 if (AllDeclRefExprs.size() == 1 &&
+!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
+ *Result.Context) &&
 ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
   utils::decl_ref_expr::isCopyConstructorArgument(
   **AllDeclRefExprs.begin(), *Function->getBody(),


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -225,6 +225,15 @@
   // CHECK-FIXES: F = std::move(E);
 }
 
+// The argument could be moved but is not since copy statement is inside a loop.
+void PositiveNoMoveInsideLoop(ExpensiveMovableType E) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the parameter 'E' is copied
+  // CHECK-FIXES: void PositiveNoMoveInsideLoop(const ExpensiveMovableType& E) {
+  for (;;) {
+auto F = E;
+  }
+}
+
 void PositiveConstRefNotMoveConstructible(ExpensiveToCopyType T) {
   // CHECK-MESSAGES: [[@LINE-1]]:63: warning: the parameter 'T' is copied
   // CHECK-FIXES: void PositiveConstRefNotMoveConstructible(const ExpensiveToCopyType& T) {
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -47,6 +47,17 @@
   return !Matches.empty();
 }
 
+bool hasLoopStmtAncestor(const DeclRefExpr , const Stmt ,
+ ASTContext ) {
+  auto Matches =
+  match(findAll(declRefExpr(
+equalsNode(),
+unless(hasAncestor(stmt(anyOf(forStmt(), cxxForRangeStmt(),
+  whileStmt(), doStmt())),
+Stmt, Context);
+  return Matches.empty();
+}
+
 } // namespace
 
 UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
@@ -105,6 +116,8 @@
   if (!IsConstQualified) {
 auto CanonicalType = Param->getType().getCanonicalType();
 if (AllDeclRefExprs.size() == 1 &&
+!hasLoopStmtAncestor(**AllDeclRefExprs.begin(), *Function->getBody(),
+ *Result.Context) &&
 ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
   utils::decl_ref_expr::isCopyConstructorArgument(
   **AllDeclRefExprs.begin(), *Function->getBody(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289908 - Revert "Update for LLVM global variable debug info API change."

2016-12-15 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec 15 19:01:40 2016
New Revision: 289908

URL: http://llvm.org/viewvc/llvm-project?rev=289908=rev
Log:
Revert "Update for LLVM global variable debug info API change."

This reverts commit 289901 while investigating bot breakage.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c
cfe/trunk/test/CodeGen/2010-08-10-DbgConstant.c
cfe/trunk/test/CodeGen/debug-info-atomic.c
cfe/trunk/test/CodeGen/debug-info-global-constant.c
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
cfe/trunk/test/CodeGen/debug-info-static.c
cfe/trunk/test/CodeGenCXX/debug-info-global.cpp
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/debug-info.cpp
cfe/trunk/test/CodeGenCXX/inline-dllexport-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289908=289907=289908=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 15 19:01:40 2016
@@ -2855,7 +2855,7 @@ CGDebugInfo::getGlobalVariableForwardDec
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
   DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
-  !VD->isExternallyVisible(), nullptr, Align);
+  !VD->isExternallyVisible(), nullptr, nullptr, Align);
   FwdDeclReplaceMap.emplace_back(
   std::piecewise_construct,
   std::make_tuple(cast(VD->getCanonicalDecl())),
@@ -2873,12 +2873,8 @@ llvm::DINode *CGDebugInfo::getDeclaratio
getOrCreateFile(TD->getLocation()));
   auto I = DeclCache.find(D->getCanonicalDecl());
 
-  if (I != DeclCache.end()) {
-auto N = I->second;
-if (auto *GVE = dyn_cast_or_null(N))
-  return GVE->getVariable();
-return dyn_cast_or_null(N);
-  }
+  if (I != DeclCache.end())
+return dyn_cast_or_null(I->second);
 
   // No definition for now. Emit a forward definition that might be
   // merged with a potential upcoming definition.
@@ -3654,10 +3650,10 @@ CGDebugInfo::getOrCreateStaticDataMember
   return CreateRecordStaticField(D, Ctxt, cast(DC));
 }
 
-llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
+llvm::DIGlobalVariable *CGDebugInfo::CollectAnonRecordDecls(
 const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
 StringRef LinkageName, llvm::GlobalVariable *Var, llvm::DIScope *DContext) 
{
-  llvm::DIGlobalVariableExpression *GVE = nullptr;
+  llvm::DIGlobalVariable *GV = nullptr;
 
   for (const auto *Field : RD->fields()) {
 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -3666,17 +3662,16 @@ llvm::DIGlobalVariableExpression *CGDebu
 // Ignore unnamed fields, but recurse into anonymous records.
 if (FieldName.empty()) {
   if (const auto *RT = dyn_cast(Field->getType()))
-GVE = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
+GV = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
 Var, DContext);
   continue;
 }
 // Use VarDecl's Tag, Scope and Line number.
-GVE = DBuilder.createGlobalVariableExpression(
-DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
-Var->hasLocalLinkage());
-Var->addDebugInfo(GVE);
+GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit,
+   LineNo, FieldTy, 
Var->hasLocalLinkage());
+Var->addDebugInfo(GV);
   }
-  return GVE;
+  return GV;
 }
 
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
@@ -3689,8 +3684,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
   if (Cached != DeclCache.end())
-return Var->addDebugInfo(
-cast(Cached->second));
+return Var->addDebugInfo(cast(Cached->second));
 
   // Create global variable debug descriptor.
   llvm::DIFile *Unit = nullptr;
@@ -3702,7 +3696,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
 
   // Attempt to store one global variable for the declaration - even if we
   // emit a lot of fields.
-  llvm::DIGlobalVariableExpression *GVE = nullptr;
+  llvm::DIGlobalVariable *GV = nullptr;
 
   // If this is an anonymous union then we'll want to emit a global
   // variable for each member of the anonymous union so that it's possible
@@ -3711,16 +3705,16 @@ void CGDebugInfo::EmitGlobalVariable(llv
 const RecordDecl *RD = T->castAs()->getDecl();
 assert(RD->isAnonymousStructOrUnion() &&
"unnamed non-anonymous struct or union?");
-GVE 

r289905 - [c++1z] P0195R2: Allow multiple using-declarators in a single using-declaration.

2016-12-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 15 18:58:48 2016
New Revision: 289905

URL: http://llvm.org/viewvc/llvm-project?rev=289905=rev
Log:
[c++1z] P0195R2: Allow multiple using-declarators in a single using-declaration.

Added:
cfe/trunk/test/Parser/cxx1z-using-declaration.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Parse/ParseTemplate.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Parser/cxx0x-decl.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=289905=289904=289905=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Thu Dec 15 18:58:48 
2016
@@ -741,6 +741,15 @@ def err_alias_declaration_not_identifier
 def err_alias_declaration_specialization : Error<
   "%select{partial specialization|explicit specialization|explicit 
instantiation}0 of alias templates is not permitted">;
 
+// C++1z using-declaration pack expansions
+def ext_multi_using_declaration : ExtWarn<
+  "use of multiple declarators in a single using declaration is "
+  "a C++1z extension">, InGroup;
+def warn_cxx1z_compat_multi_using_declaration : Warning<
+  "use of multiple declarators in a single using declaration is "
+  "incompatible with C++ standards before C++1z">,
+  InGroup, DefaultIgnore;
+
 // C++11 override control
 def ext_override_control_keyword : ExtWarn<
   "'%0' keyword is a C++11 extension">, InGroup;

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=289905=289904=289905=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Dec 15 18:58:48 2016
@@ -1261,6 +1261,11 @@ private:
 ParsedAttributesWithRange(AttributeFactory )
   : ParsedAttributes(factory) {}
 
+void clear() {
+  ParsedAttributes::clear();
+  Range = SourceRange();
+}
+
 SourceRange Range;
   };
 
@@ -2418,21 +2423,41 @@ private:
BalancedDelimiterTracker );
   Decl *ParseLinkage(ParsingDeclSpec , unsigned Context);
   Decl *ParseExportDeclaration();
-  Decl *ParseUsingDirectiveOrDeclaration(unsigned Context,
- const ParsedTemplateInfo 
,
- SourceLocation ,
- ParsedAttributesWithRange ,
- Decl **OwnedType = nullptr);
+  DeclGroupPtrTy ParseUsingDirectiveOrDeclaration(
+  unsigned Context, const ParsedTemplateInfo ,
+  SourceLocation , ParsedAttributesWithRange );
   Decl *ParseUsingDirective(unsigned Context,
 SourceLocation UsingLoc,
 SourceLocation ,
 ParsedAttributes );
-  Decl *ParseUsingDeclaration(unsigned Context,
-  const ParsedTemplateInfo ,
-  SourceLocation UsingLoc,
-  SourceLocation ,
-  AccessSpecifier AS = AS_none,
-  Decl **OwnedType = nullptr);
+
+  struct UsingDeclarator {
+SourceLocation TypenameLoc;
+CXXScopeSpec SS;
+SourceLocation TemplateKWLoc;
+UnqualifiedId Name;
+
+void clear() {
+  TypenameLoc = TemplateKWLoc = SourceLocation();
+  SS.clear();
+  Name.clear();
+}
+  };
+
+  bool ParseUsingDeclarator(unsigned Context, UsingDeclarator );
+  DeclGroupPtrTy ParseUsingDeclaration(unsigned Context,
+   const ParsedTemplateInfo ,
+   SourceLocation UsingLoc,
+   SourceLocation ,
+   AccessSpecifier AS = AS_none);
+  Decl *ParseAliasTemplate(const ParsedTemplateInfo ,
+   SourceLocation , AccessSpecifier AS,
+   ParsedAttributesWithRange );
+  Decl *ParseAliasDeclarationAfterDeclarator(
+  const ParsedTemplateInfo , SourceLocation UsingLoc,
+  UsingDeclarator , SourceLocation , AccessSpecifier AS,
+  ParsedAttributes , Decl **OwnedType = nullptr);
+
   Decl *ParseStaticAssertDeclaration(SourceLocation );
   Decl *ParseNamespaceAlias(SourceLocation NamespaceLoc,
 SourceLocation AliasLoc, IdentifierInfo *Alias,

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 

[PATCH] D27813: [clang-tidy] fix missing anchor for MPI Module

2016-12-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

LG, thank you!


https://reviews.llvm.org/D27813



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


r289901 - Update for LLVM global variable debug info API change.

2016-12-15 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Dec 15 18:35:42 2016
New Revision: 289901

URL: http://llvm.org/viewvc/llvm-project?rev=289901=rev
Log:
Update for LLVM global variable debug info API change.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGen/2009-10-20-GlobalDebug.c
cfe/trunk/test/CodeGen/2010-08-10-DbgConstant.c
cfe/trunk/test/CodeGen/debug-info-atomic.c
cfe/trunk/test/CodeGen/debug-info-global-constant.c
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
cfe/trunk/test/CodeGen/debug-info-static.c
cfe/trunk/test/CodeGenCXX/debug-info-global.cpp
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template-member.cpp
cfe/trunk/test/CodeGenCXX/debug-info-template.cpp
cfe/trunk/test/CodeGenCXX/debug-info.cpp
cfe/trunk/test/CodeGenCXX/inline-dllexport-member.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289901=289900=289901=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec 15 18:35:42 2016
@@ -2855,7 +2855,7 @@ CGDebugInfo::getGlobalVariableForwardDec
   auto Align = getDeclAlignIfRequired(VD, CGM.getContext());
   auto *GV = DBuilder.createTempGlobalVariableFwdDecl(
   DContext, Name, LinkageName, Unit, Line, getOrCreateType(T, Unit),
-  !VD->isExternallyVisible(), nullptr, nullptr, Align);
+  !VD->isExternallyVisible(), nullptr, Align);
   FwdDeclReplaceMap.emplace_back(
   std::piecewise_construct,
   std::make_tuple(cast(VD->getCanonicalDecl())),
@@ -2873,8 +2873,12 @@ llvm::DINode *CGDebugInfo::getDeclaratio
getOrCreateFile(TD->getLocation()));
   auto I = DeclCache.find(D->getCanonicalDecl());
 
-  if (I != DeclCache.end())
-return dyn_cast_or_null(I->second);
+  if (I != DeclCache.end()) {
+auto N = I->second;
+if (auto *GVE = dyn_cast_or_null(N))
+  return GVE->getVariable();
+return dyn_cast_or_null(N);
+  }
 
   // No definition for now. Emit a forward definition that might be
   // merged with a potential upcoming definition.
@@ -3650,10 +3654,10 @@ CGDebugInfo::getOrCreateStaticDataMember
   return CreateRecordStaticField(D, Ctxt, cast(DC));
 }
 
-llvm::DIGlobalVariable *CGDebugInfo::CollectAnonRecordDecls(
+llvm::DIGlobalVariableExpression *CGDebugInfo::CollectAnonRecordDecls(
 const RecordDecl *RD, llvm::DIFile *Unit, unsigned LineNo,
 StringRef LinkageName, llvm::GlobalVariable *Var, llvm::DIScope *DContext) 
{
-  llvm::DIGlobalVariable *GV = nullptr;
+  llvm::DIGlobalVariableExpression *GVE = nullptr;
 
   for (const auto *Field : RD->fields()) {
 llvm::DIType *FieldTy = getOrCreateType(Field->getType(), Unit);
@@ -3662,16 +3666,17 @@ llvm::DIGlobalVariable *CGDebugInfo::Col
 // Ignore unnamed fields, but recurse into anonymous records.
 if (FieldName.empty()) {
   if (const auto *RT = dyn_cast(Field->getType()))
-GV = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
+GVE = CollectAnonRecordDecls(RT->getDecl(), Unit, LineNo, LinkageName,
 Var, DContext);
   continue;
 }
 // Use VarDecl's Tag, Scope and Line number.
-GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit,
-   LineNo, FieldTy, 
Var->hasLocalLinkage());
-Var->addDebugInfo(GV);
+GVE = DBuilder.createGlobalVariableExpression(
+DContext, FieldName, LinkageName, Unit, LineNo, FieldTy,
+Var->hasLocalLinkage());
+Var->addDebugInfo(GVE);
   }
-  return GV;
+  return GVE;
 }
 
 void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,
@@ -3684,7 +3689,8 @@ void CGDebugInfo::EmitGlobalVariable(llv
   // it to the llvm::GlobalVariable.
   auto Cached = DeclCache.find(D->getCanonicalDecl());
   if (Cached != DeclCache.end())
-return Var->addDebugInfo(cast(Cached->second));
+return Var->addDebugInfo(
+cast(Cached->second));
 
   // Create global variable debug descriptor.
   llvm::DIFile *Unit = nullptr;
@@ -3696,7 +3702,7 @@ void CGDebugInfo::EmitGlobalVariable(llv
 
   // Attempt to store one global variable for the declaration - even if we
   // emit a lot of fields.
-  llvm::DIGlobalVariable *GV = nullptr;
+  llvm::DIGlobalVariableExpression *GVE = nullptr;
 
   // If this is an anonymous union then we'll want to emit a global
   // variable for each member of the anonymous union so that it's possible
@@ -3705,16 +3711,16 @@ void CGDebugInfo::EmitGlobalVariable(llv
 const RecordDecl *RD = T->castAs()->getDecl();
 assert(RD->isAnonymousStructOrUnion() &&
"unnamed non-anonymous struct or union?");
-GV = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext);

[PATCH] D27263: Address of bitfield in anonymous struct doesn't error.

2016-12-15 Thread Jacob Young via Phabricator via cfe-commits
jacobly added a comment.

rsmith, is this ready to be commited?


https://reviews.llvm.org/D27263



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


r289897 - Fix typo in error messages. NFC.

2016-12-15 Thread Kelvin Li via cfe-commits
Author: kli
Date: Thu Dec 15 18:15:54 2016
New Revision: 289897

URL: http://llvm.org/viewvc/llvm-project?rev=289897=rev
Log:
Fix typo in error messages. NFC.

Modified:
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp?rev=289897=289896=289897=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp 
(original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_loop_messages.cpp 
Thu Dec 15 18:15:54 2016
@@ -659,12 +659,12 @@ void test_loop_eh() {
 try { // expected-error {{'try' statement cannot be used in OpenMP simd 
region}}
   for (int j = 0; j < 10; ++j) {
 if (a[i] > b[j])
-  throw a[i]; // expected-error {{throw' statement cannot be used in 
OpenMP simd region}}
+  throw a[i]; // expected-error {{'throw' statement cannot be used in 
OpenMP simd region}}
   }
-  throw a[i]; // expected-error {{throw' statement cannot be used in 
OpenMP simd region}}
+  throw a[i]; // expected-error {{'throw' statement cannot be used in 
OpenMP simd region}}
 } catch (float f) {
   if (f > 0.1)
-throw a[i]; // expected-error {{throw' statement cannot be used in 
OpenMP simd region}}
+throw a[i]; // expected-error {{'throw' statement cannot be used in 
OpenMP simd region}}
   return; // expected-error {{cannot return from OpenMP region}}
 }
 switch (i) {
@@ -676,7 +676,7 @@ void test_loop_eh() {
 }
 for (int j = 0; j < 10; j++) {
   if (c[i] > 10)
-throw c[i]; // expected-error {{throw' statement cannot be used in 
OpenMP simd region}}
+throw c[i]; // expected-error {{'throw' statement cannot be used in 
OpenMP simd region}}
 }
   }
   if (c[9] > 10)


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


[PATCH] D27832: Add -plugin-opt=sample-profile for thinLTO build.

2016-12-15 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Is this covered by a driver test usually?


https://reviews.llvm.org/D27832



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


[PATCH] D27832: Add -plugin-opt=sample-profile for thinLTO build.

2016-12-15 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh created this revision.
danielcdh added reviewers: tejohnson, mehdi_amini, davidxl.
danielcdh added a subscriber: cfe-commits.

ThinLTO needs to pass down the sample profile file path to linker.


https://reviews.llvm.org/D27832

Files:
  lib/Driver/Tools.cpp


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2206,6 +2206,14 @@
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef fname = A->getValue();
+if (!llvm::sys::fs::exists(fname))
+  D.Diag(diag::err_drv_no_such_file) << fname;
+else
+  
CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + 
fname));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step


Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2206,6 +2206,14 @@
UseSeparateSections)) {
 CmdArgs.push_back("-plugin-opt=-data-sections");
   }
+
+  if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {
+StringRef fname = A->getValue();
+if (!llvm::sys::fs::exists(fname))
+  D.Diag(diag::err_drv_no_such_file) << fname;
+else
+  CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=sample-profile=") + fname));
+  }
 }
 
 /// This is a helper function for validating the optional refinement step
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)

2016-12-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: test/CodeGen/debug-info-file-checksum.c:1
+// RUN: %clang -emit-llvm -S -g -gcodeview -x c %s.source -o - | FileCheck %s
+

Instead of %s.source, you can do %S/Inputs/debug-info-file-checksum.c.



Comment at: test/CodeGen/debug-info-file-checksum.c.source:1
+int foo(int x) {
+  return x+1;

This can live in test/CodeGen/Inputs/debug-info-file-checksum.c


https://reviews.llvm.org/D27641



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


r289890 - [sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT when building compiler-rt from clang/runtime/CMakeLists.txt

2016-12-15 Thread Kuba Mracek via cfe-commits
Author: kuba.brecka
Date: Thu Dec 15 17:20:54 2016
New Revision: 289890

URL: http://llvm.org/viewvc/llvm-project?rev=289890=rev
Log:
[sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET and CMAKE_OSX_SYSROOT when 
building compiler-rt from clang/runtime/CMakeLists.txt

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


Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=289890=289889=289890=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Thu Dec 15 17:20:54 2016
@@ -78,6 +78,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
+   -DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
${COMPILER_RT_PASSTHROUGH_VARIABLES}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build


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


[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2016-12-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Huh, I'm surprised this has a runtime component, I missed that. I thought this 
would be a statically-checked thing. But having this does seem useful :-)

I'm also surprised that this compiles down to Gestalt – Gestalt is deprecated 
in newer SDKs, and in Chromium we invested some time to move off of it when 
recently bumping our min SDK target. So it seems strange the compiler would add 
a dependency to it. (We've also observed that Gestalt is pretty heavy-weight at 
least in macOS 10.6 in that it can spawn threads).

Things we've done instead, in various contexts:

- `uname()` 
(https://cs.chromium.org/chromium/src/base/mac/mac_util.mm?q=MacOSXMinorVersion=package:chromium=C=365)
- -[NSProcessInfo operatingSystemVersion] if it's available (it's documented 
available in 10.10+, but actually exists from 10.9.2+) (rhs on 
https://codereview.chromium.org/1842213002/diff/40001/base/sys_info_mac.mm)
- `sysctl()` 
https://github.com/google/google-toolbox-for-mac/blob/master/Foundation/GTMServiceManagement.c#L63
 That's what's recommended but might need 10.8


https://reviews.llvm.org/D27827



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


[PATCH] D27726: [analyzer] Refer to macro names in diagnostics for macros representing a literal

2016-12-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289884: [analyzer] Refer to macro names in diagnostics for 
macros representing a literal (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D27726?vs=81277=81669#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27726

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
  cfe/trunk/test/Analysis/Inputs/system-header-simulator.h
  cfe/trunk/test/Analysis/diagnostics/macros.cpp
  cfe/trunk/test/Analysis/diagnostics/macros.m

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
@@ -245,6 +245,7 @@
   const ExplodedNode *N);
 
   bool patternMatch(const Expr *Ex,
+const Expr *ParentEx,
 raw_ostream ,
 BugReporterContext ,
 BugReport ,
Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator.h
@@ -102,3 +102,11 @@
 void _exit(int status) __attribute__ ((__noreturn__));
 void _Exit(int status) __attribute__ ((__noreturn__));
 
+#define UINT32_MAX4294967295U
+#define INT64_MIN(-INT64_MAX-1)
+#define __DBL_MAX__ 1.7976931348623157e+308
+#define DBL_MAX __DBL_MAX__
+#ifndef NULL
+#define __DARWIN_NULL 0
+#define NULL __DARWIN_NULL
+#endif
\ No newline at end of file
Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
@@ -17,7 +17,11 @@
 typedef unsigned short unichar;
 typedef UInt16 UniChar;
 
-#define NULL ((void *)0)
+#ifndef NULL
+#define __DARWIN_NULL ((void *)0)
+#define NULL __DARWIN_NULL
+#endif
+
 #define nil ((id)0)
 
 enum {
@@ -54,6 +58,7 @@
 - (oneway void)release;
 - (id)autorelease;
 - (id)init;
+@property (readonly, copy) NSString *description;
 @end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
 @end  @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
 @end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
Index: cfe/trunk/test/Analysis/diagnostics/macros.cpp
===
--- cfe/trunk/test/Analysis/diagnostics/macros.cpp
+++ cfe/trunk/test/Analysis/diagnostics/macros.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=core,osx -analyzer-output=text -verify %s
+
+#include "../Inputs/system-header-simulator.h"
+#include "../Inputs/system-header-simulator-cxx.h"
+
+void testIntMacro(unsigned int i) {
+  if (i == UINT32_MAX) { // expected-note {{Assuming 'i' is equal to UINT32_MAX}}
+ // expected-note@-1 {{Taking true branch}}
+char *p = NULL; // expected-note {{'p' initialized to a null pointer value}}
+*p = 7;  // expected-warning {{Dereference of null pointer (loaded from variable 'p')}}
+ // expected-note@-1 {{Dereference of null pointer (loaded from variable 'p')}}
+  }
+}
+
+void testNULLMacro(int *p) {
+  if (p == NULL) { // expected-note {{Assuming 'p' is equal to NULL}}
+   // expected-note@-1 {{Taking true branch}}
+*p = 7;  // expected-warning {{Dereference of null pointer (loaded from variable 'p')}}
+ // expected-note@-1 {{Dereference of null pointer (loaded from variable 'p')}}
+  }
+}
+
+void testnullptrMacro(int *p) {
+  if (p == nullptr) { // expected-note {{Assuming pointer value is null}}
+  // expected-note@-1 {{Taking true branch}}
+*p = 7;  // expected-warning {{Dereference of null pointer (loaded from variable 'p')}}
+ // expected-note@-1 {{Dereference of null pointer (loaded from variable 'p')}}
+  }
+}
+
+// There are no path notes on the comparison to float types.
+void testDoubleMacro(double d) {
+  if (d == DBL_MAX) { // expected-note {{Taking true branch}}
+
+char *p = NULL; // expected-note {{'p' initialized to a null pointer value}}
+*p = 7; // expected-warning {{Dereference of null pointer (loaded from variable 'p')}}
+// expected-note@-1 {{Dereference of null pointer (loaded from variable 'p')}}
+  }
+}
+
+void testboolMacro(bool b, int *p) {
+  p = nullptr;  // expected-note {{Null pointer value stored to 'p'}}
+  if (b == 

[PATCH] D27600: [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289885: [analyzer] Refine the diagnostics in the nullability 
checker to differentiate… (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D27600?vs=80925=81671#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27600

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  cfe/trunk/test/Analysis/nullability-no-arc.mm
  cfe/trunk/test/Analysis/nullability.mm
  cfe/trunk/test/Analysis/nullability_nullonly.mm

Index: cfe/trunk/test/Analysis/nullability-no-arc.mm
===
--- cfe/trunk/test/Analysis/nullability-no-arc.mm
+++ cfe/trunk/test/Analysis/nullability-no-arc.mm
@@ -17,20 +17,20 @@
 @interface TestObject : NSObject
 @end
 
-TestObject * _Nonnull returnsNilObjCInstanceIndirectly() {
-  TestObject *local = 0;
-  return local; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+TestObject *_Nonnull returnsNilObjCInstanceIndirectly() {
+  TestObject *local = nil;
+  return local; // expected-warning {{nil returned from a function that is expected to return a non-null value}}
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceIndirectlyWithSupressingCast() {
-  TestObject *local = 0;
+  TestObject *local = nil;
   return (TestObject * _Nonnull)local; // no-warning
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceDirectly() {
   // The first warning is from Sema. The second is from the static analyzer.
   return nil; // expected-warning {{null returned from function that requires a non-null return value}}
-  // expected-warning@-1 {{Null is returned from a function that is expected to return a non-null value}}
+  // expected-warning@-1 {{nil returned from a function that is expected to return a non-null value}}
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceDirectlyWithSuppressingCast() {
@@ -43,7 +43,7 @@
 }
 
 void testObjCNonARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{Null is assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}
 }
 
 @interface ClassWithInitializers : NSObject
Index: cfe/trunk/test/Analysis/nullability.mm
===
--- cfe/trunk/test/Analysis/nullability.mm
+++ cfe/trunk/test/Analysis/nullability.mm
@@ -75,7 +75,7 @@
   }
   Dummy a;
   Dummy *_Nonnull nonnull = 
-  nonnull = q; // expected-warning {{Null is assigned to a pointer which is expected to have non-null value}}
+  nonnull = q; // expected-warning {{Null assigned to a pointer which is expected to have non-null value}}
   q = 
   takesNullable(q);
   takesNonnull(q);
@@ -107,7 +107,7 @@
 
 Dummy *_Nonnull testNullReturn() {
   Dummy *p = 0;
-  return p; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return p; // expected-warning {{Null returned from a function that is expected to return a non-null value}}
 }
 
 void testObjCMessageResultNullability() {
@@ -229,7 +229,7 @@
 Dummy * _Nonnull testIndirectCastNilToNonnullAndReturn() {
   Dummy *p = (Dummy * _Nonnull)0;
   // FIXME: Ideally the cast above would suppress this warning.
-  return p; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return p; // expected-warning {{Null returned from a function that is expected to return a non-null value}}
 }
 
 void testInvalidPropagation() {
Index: cfe/trunk/test/Analysis/nullability_nullonly.mm
===
--- cfe/trunk/test/Analysis/nullability_nullonly.mm
+++ cfe/trunk/test/Analysis/nullability_nullonly.mm
@@ -24,7 +24,7 @@
 
 Dummy *_Nonnull testNullReturn() {
   Dummy *p = 0;
-  return p; // expected-warning {{Null is returned from a function that is expected to return a non-null value}}
+  return p; // expected-warning {{Null returned from a function that is expected to return a non-null value}}
 }
 
 void onlyReportFirstPreconditionViolationOnPath() {
@@ -100,24 +100,24 @@
 }
 
 void testObjCARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{Null is assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning {{nil assigned to a pointer which is expected to have non-null value}}
 }
 
 // Under ARC, returned expressions of ObjC objects types are are implicitly
 // cast to _Nonnull when the functions return type is _Nonnull, so make
 // sure this doesn't implicit cast doesn't suppress a legitimate warning.
 TestObject * _Nonnull returnsNilObjCInstanceIndirectly() {
-  

r289887 - [asan][docs] Fix the documentation to use clang++ for the C++ example

2016-12-15 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Dec 15 16:55:21 2016
New Revision: 289887

URL: http://llvm.org/viewvc/llvm-project?rev=289887=rev
Log:
[asan][docs] Fix the documentation to use clang++ for the C++ example

After Darwin has been updated not to link in stdc++ on Darwin this actually
started to break.

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

Modified:
cfe/trunk/docs/AddressSanitizer.rst

Modified: cfe/trunk/docs/AddressSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/AddressSanitizer.rst?rev=289887=289886=289887=diff
==
--- cfe/trunk/docs/AddressSanitizer.rst (original)
+++ cfe/trunk/docs/AddressSanitizer.rst Thu Dec 15 16:55:21 2016
@@ -49,16 +49,16 @@ you may need to disable inlining (just u
 }
 
 # Compile and link
-% clang -O1 -g -fsanitize=address -fno-omit-frame-pointer 
example_UseAfterFree.cc
+% clang++ -O1 -g -fsanitize=address -fno-omit-frame-pointer 
example_UseAfterFree.cc
 
 or:
 
 .. code-block:: console
 
 # Compile
-% clang -O1 -g -fsanitize=address -fno-omit-frame-pointer -c 
example_UseAfterFree.cc
+% clang++ -O1 -g -fsanitize=address -fno-omit-frame-pointer -c 
example_UseAfterFree.cc
 # Link
-% clang -g -fsanitize=address example_UseAfterFree.o
+% clang++ -g -fsanitize=address example_UseAfterFree.o
 
 If a bug is detected, the program will print an error message to stderr and
 exit with a non-zero exit code. AddressSanitizer exits on the first detected 
error.


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


[PATCH] D27599: [analyzer] Teach the analyzer that pointers can escape into __cxa_demangle

2016-12-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289886: [analyzer] Teach the analyzer that pointers can 
escape into __cxa_demangle (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D27599?vs=80842=81672#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27599

Files:
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
  cfe/trunk/test/Analysis/malloc.cpp


Index: cfe/trunk/test/Analysis/malloc.cpp
===
--- cfe/trunk/test/Analysis/malloc.cpp
+++ cfe/trunk/test/Analysis/malloc.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -w -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete
 -analyzer-store=region -verify %s
 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -w -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete
 -analyzer-store=region -verify %s
 
+#include "Inputs/system-header-simulator-cxx.h"
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void free(void *);
@@ -125,3 +127,15 @@
 p->m(); // no-crash // no-warning
   }
 }
+
+// Allow __cxa_demangle to escape.
+char* test_cxa_demangle(const char* sym) {
+  size_t funcnamesize = 256;
+  char* funcname = (char*)malloc(funcnamesize);
+  int status;
+  char* ret = abi::__cxa_demangle(sym, funcname, , );
+  if (status == 0) {
+funcname = ret;
+  }
+  return funcname; // no-warning
+}
Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -240,3 +240,12 @@
 void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
 void operator delete (void* ptr, void*) throw() {};
 void operator delete[] (void* ptr, void*) throw() {};
+
+namespace __cxxabiv1 {
+extern "C" {
+extern char *__cxa_demangle(const char *mangled_name,
+char *output_buffer,
+size_t *length,
+int *status);
+}}
+namespace abi = __cxxabiv1;
Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -382,6 +382,11 @@
   if (II->isStr("funopen"))
 return true;
 
+  // - __cxa_demangle - can reallocate memory and can return the pointer to
+  // the input buffer.
+  if (II->isStr("__cxa_demangle"))
+return true;
+
   StringRef FName = II->getName();
 
   // - CoreFoundation functions that end with "NoCopy" can free a passed-in


Index: cfe/trunk/test/Analysis/malloc.cpp
===
--- cfe/trunk/test/Analysis/malloc.cpp
+++ cfe/trunk/test/Analysis/malloc.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -w -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete -analyzer-store=region -verify %s
 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -w -analyze -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete -analyzer-store=region -verify %s
 
+#include "Inputs/system-header-simulator-cxx.h"
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void free(void *);
@@ -125,3 +127,15 @@
 p->m(); // no-crash // no-warning
   }
 }
+
+// Allow __cxa_demangle to escape.
+char* test_cxa_demangle(const char* sym) {
+  size_t funcnamesize = 256;
+  char* funcname = (char*)malloc(funcnamesize);
+  int status;
+  char* ret = abi::__cxa_demangle(sym, funcname, , );
+  if (status == 0) {
+funcname = ret;
+  }
+  return funcname; // no-warning
+}
Index: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
===
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
@@ -240,3 +240,12 @@
 void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
 void operator delete (void* ptr, void*) throw() {};
 void operator delete[] (void* ptr, void*) throw() {};
+
+namespace __cxxabiv1 {
+extern "C" {
+extern char *__cxa_demangle(const char *mangled_name,
+char *output_buffer,
+size_t *length,
+int *status);
+}}
+namespace abi = __cxxabiv1;
Index: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -382,6 +382,11 @@
   if 

r289886 - [analyzer] Teach the analyzer that pointers can escape into __cxa_demangle

2016-12-15 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Dec 15 16:55:18 2016
New Revision: 289886

URL: http://llvm.org/viewvc/llvm-project?rev=289886=rev
Log:
[analyzer] Teach the analyzer that pointers can escape into __cxa_demangle

This fixes a reported false positive in the malloc checker.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
cfe/trunk/test/Analysis/malloc.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp?rev=289886=289885=289886=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp Thu Dec 15 16:55:18 2016
@@ -382,6 +382,11 @@ bool AnyFunctionCall::argumentsMayEscape
   if (II->isStr("funopen"))
 return true;
 
+  // - __cxa_demangle - can reallocate memory and can return the pointer to
+  // the input buffer.
+  if (II->isStr("__cxa_demangle"))
+return true;
+
   StringRef FName = II->getName();
 
   // - CoreFoundation functions that end with "NoCopy" can free a passed-in

Modified: cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h?rev=289886=289885=289886=diff
==
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h (original)
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator-cxx.h Thu Dec 15 
16:55:18 2016
@@ -240,3 +240,12 @@ void* operator new (std::size_t size, vo
 void* operator new[] (std::size_t size, void* ptr) throw() { return ptr; };
 void operator delete (void* ptr, void*) throw() {};
 void operator delete[] (void* ptr, void*) throw() {};
+
+namespace __cxxabiv1 {
+extern "C" {
+extern char *__cxa_demangle(const char *mangled_name,
+char *output_buffer,
+size_t *length,
+int *status);
+}}
+namespace abi = __cxxabiv1;

Modified: cfe/trunk/test/Analysis/malloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc.cpp?rev=289886=289885=289886=diff
==
--- cfe/trunk/test/Analysis/malloc.cpp (original)
+++ cfe/trunk/test/Analysis/malloc.cpp Thu Dec 15 16:55:18 2016
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -w -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete
 -analyzer-store=region -verify %s
 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -w -analyze 
-analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,cplusplus.NewDelete
 -analyzer-store=region -verify %s
 
+#include "Inputs/system-header-simulator-cxx.h"
+
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void free(void *);
@@ -125,3 +127,15 @@ namespace PR31226 {
 p->m(); // no-crash // no-warning
   }
 }
+
+// Allow __cxa_demangle to escape.
+char* test_cxa_demangle(const char* sym) {
+  size_t funcnamesize = 256;
+  char* funcname = (char*)malloc(funcnamesize);
+  int status;
+  char* ret = abi::__cxa_demangle(sym, funcname, , );
+  if (status == 0) {
+funcname = ret;
+  }
+  return funcname; // no-warning
+}


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


r289885 - [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-15 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Dec 15 16:55:15 2016
New Revision: 289885

URL: http://llvm.org/viewvc/llvm-project?rev=289885=rev
Log:
[analyzer] Refine the diagnostics in the nullability checker to differentiate 
between nil and null

This is a big deal for ObjC, where nullability annotations are extensively
used. I've also changed "Null" -> "null" and removed "is" as this is the
pattern that Sema is using.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability-no-arc.mm
cfe/trunk/test/Analysis/nullability.mm
cfe/trunk/test/Analysis/nullability_nullonly.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=289885=289884=289885=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Thu Dec 15 
16:55:15 2016
@@ -610,9 +610,9 @@ void NullabilityChecker::checkPreStmt(co
 
 SmallString<256> SBuf;
 llvm::raw_svector_ostream OS(SBuf);
-OS << "Null is returned from a " << C.getDeclDescription(D) <<
+OS << (RetExpr->getType()->isObjCObjectPointerType() ? "nil" : "Null");
+OS << " returned from a " << C.getDeclDescription(D) <<
   " that is expected to return a non-null value";
-
 reportBugIfInvariantHolds(OS.str(),
   ErrorKind::NilReturnedToNonnull, N, nullptr, C,
   RetExpr);
@@ -707,9 +707,11 @@ void NullabilityChecker::checkPreCall(co
   ExplodedNode *N = C.generateErrorNode(State);
   if (!N)
 return;
+
   SmallString<256> SBuf;
   llvm::raw_svector_ostream OS(SBuf);
-  OS << "Null passed to a callee that requires a non-null " << ParamIdx
+  OS << (Param->getType()->isObjCObjectPointerType() ? "nil" : "Null");
+  OS << " passed to a callee that requires a non-null " << ParamIdx
  << llvm::getOrdinalSuffix(ParamIdx) << " parameter";
   reportBugIfInvariantHolds(OS.str(), ErrorKind::NilPassedToNonnull, N,
 nullptr, C,
@@ -1128,8 +1130,11 @@ void NullabilityChecker::checkBind(SVal
 if (ValueExpr)
   ValueStmt = ValueExpr;
 
-reportBugIfInvariantHolds("Null is assigned to a pointer which is "
-  "expected to have non-null value",
+SmallString<256> SBuf;
+llvm::raw_svector_ostream OS(SBuf);
+OS << (LocType->isObjCObjectPointerType() ? "nil" : "Null");
+OS << " assigned to a pointer which is expected to have non-null value";
+reportBugIfInvariantHolds(OS.str(),
   ErrorKind::NilAssignedToNonnull, N, nullptr, C,
   ValueStmt);
 return;

Modified: cfe/trunk/test/Analysis/nullability-no-arc.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability-no-arc.mm?rev=289885=289884=289885=diff
==
--- cfe/trunk/test/Analysis/nullability-no-arc.mm (original)
+++ cfe/trunk/test/Analysis/nullability-no-arc.mm Thu Dec 15 16:55:15 2016
@@ -17,20 +17,20 @@ NSObject
 @interface TestObject : NSObject
 @end
 
-TestObject * _Nonnull returnsNilObjCInstanceIndirectly() {
-  TestObject *local = 0;
-  return local; // expected-warning {{Null is returned from a function that is 
expected to return a non-null value}}
+TestObject *_Nonnull returnsNilObjCInstanceIndirectly() {
+  TestObject *local = nil;
+  return local; // expected-warning {{nil returned from a function that is 
expected to return a non-null value}}
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceIndirectlyWithSupressingCast() {
-  TestObject *local = 0;
+  TestObject *local = nil;
   return (TestObject * _Nonnull)local; // no-warning
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceDirectly() {
   // The first warning is from Sema. The second is from the static analyzer.
   return nil; // expected-warning {{null returned from function that requires 
a non-null return value}}
-  // expected-warning@-1 {{Null is returned from a function that 
is expected to return a non-null value}}
+  // expected-warning@-1 {{nil returned from a function that is 
expected to return a non-null value}}
 }
 
 TestObject * _Nonnull returnsNilObjCInstanceDirectlyWithSuppressingCast() {
@@ -43,7 +43,7 @@ void testObjCNonARCNoInitialization(Test
 }
 
 void testObjCNonARCExplicitZeroInitialization() {
-  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{Null is assigned to a pointer which is expected to have non-null value}}
+  TestObject * _Nonnull explicitlyZeroInitialized = nil; // expected-warning 
{{nil assigned to a pointer which is expected to have 

r289884 - [analyzer] Refer to macro names in diagnostics for macros representing a literal

2016-12-15 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Dec 15 16:55:11 2016
New Revision: 289884

URL: http://llvm.org/viewvc/llvm-project?rev=289884=rev
Log:
[analyzer] Refer to macro names in diagnostics for macros representing a literal

When a macro expending to a literal is used in a comparison, use the macro name
in the diagnostic rather than the literal. This improves readability of path
notes.

Added tests for various macro literals that could occur. Only BOOl, Int, and
NULL tests have changed behavior with this patch.

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

Added:
cfe/trunk/test/Analysis/diagnostics/macros.cpp
cfe/trunk/test/Analysis/diagnostics/macros.m
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-objc.h
cfe/trunk/test/Analysis/Inputs/system-header-simulator.h

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h?rev=289884=289883=289884=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitor.h 
Thu Dec 15 16:55:11 2016
@@ -245,6 +245,7 @@ public:
   const ExplodedNode *N);
 
   bool patternMatch(const Expr *Ex,
+const Expr *ParentEx,
 raw_ostream ,
 BugReporterContext ,
 BugReport ,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=289884=289883=289884=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Thu Dec 15 
16:55:11 2016
@@ -15,6 +15,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/Analysis/CFGStmtMap.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
@@ -1372,7 +1373,9 @@ ConditionBRVisitor::VisitTrueTest(const
   return Event;
 }
 
-bool ConditionBRVisitor::patternMatch(const Expr *Ex, raw_ostream ,
+bool ConditionBRVisitor::patternMatch(const Expr *Ex,
+  const Expr *ParentEx,
+  raw_ostream ,
   BugReporterContext ,
   BugReport ,
   const ExplodedNode *N,
@@ -1380,6 +1383,47 @@ bool ConditionBRVisitor::patternMatch(co
   const Expr *OriginalExpr = Ex;
   Ex = Ex->IgnoreParenCasts();
 
+  // Use heuristics to determine if Ex is a macro expending to a literal and
+  // if so, use the macro's name.
+  SourceLocation LocStart = Ex->getLocStart();
+  SourceLocation LocEnd = Ex->getLocEnd();
+  if (LocStart.isMacroID() && LocEnd.isMacroID() &&
+  (isa(Ex) ||
+   isa(Ex) ||
+   isa(Ex) ||
+   isa(Ex) ||
+   isa(Ex))) {
+
+StringRef StartName = Lexer::getImmediateMacroNameForDiagnostics(LocStart,
+  BRC.getSourceManager(), BRC.getASTContext().getLangOpts());
+StringRef EndName = Lexer::getImmediateMacroNameForDiagnostics(LocEnd,
+  BRC.getSourceManager(), BRC.getASTContext().getLangOpts());
+bool beginAndEndAreTheSameMacro = StartName.equals(EndName);
+
+bool partOfParentMacro = false;
+if (ParentEx->getLocStart().isMacroID()) {
+  StringRef PName = Lexer::getImmediateMacroNameForDiagnostics(
+ParentEx->getLocStart(), BRC.getSourceManager(),
+BRC.getASTContext().getLangOpts());
+  partOfParentMacro = PName.equals(StartName);
+}
+
+if (beginAndEndAreTheSameMacro && !partOfParentMacro ) {
+  // Get the location of the macro name as written by the caller.
+  SourceLocation Loc = LocStart;
+  while (LocStart.isMacroID()) {
+Loc = LocStart;
+LocStart = BRC.getSourceManager().getImmediateMacroCallerLoc(LocStart);
+  }
+  StringRef MacroName = Lexer::getImmediateMacroNameForDiagnostics(
+Loc, BRC.getSourceManager(), BRC.getASTContext().getLangOpts());
+
+  // Return the macro name.
+  Out << MacroName;
+  return false;
+}
+  }
+
   if (const DeclRefExpr *DR = dyn_cast(Ex)) {
 const bool quotes = isa(DR->getDecl());
 if (quotes) {
@@ -1440,10 +1484,10 @@ ConditionBRVisitor::VisitTrueTest(const
   SmallString<128> LhsString, RhsString;
   {
 

[PATCH] D27740: [analyzer] Include type name in Retain Count Checker diagnostics

2016-12-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289883: [analyzer] Include type name in Retain Count Checker 
diagnostics (authored by zaks).

Changed prior to commit:
  https://reviews.llvm.org/D27740?vs=81482=81668#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27740

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/test/Analysis/edges-new.mm
  cfe/trunk/test/Analysis/inlining/path-notes.m
  cfe/trunk/test/Analysis/objc-arc.m
  cfe/trunk/test/Analysis/plist-output-alternate.m
  cfe/trunk/test/Analysis/retain-release-arc.m
  cfe/trunk/test/Analysis/retain-release-path-notes-gc.m
  cfe/trunk/test/Analysis/retain-release-path-notes.m

Index: cfe/trunk/test/Analysis/retain-release-path-notes.m
===
--- cfe/trunk/test/Analysis/retain-release-path-notes.m
+++ cfe/trunk/test/Analysis/retain-release-path-notes.m
@@ -44,12 +44,12 @@
 
 
 void creationViaAlloc () {
-  id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id leaked = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void creationViaCFCreate () {
-  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
@@ -68,25 +68,25 @@
 }
 
 void acquisitionViaCFFunction () {
-  CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count}}
+  CFTypeRef leaked = CFGetSomething(); // expected-note{{Call to function 'CFGetSomething' returns a Core Foundation object of type CFTypeRef with a +0 retain count}}
   CFRetain(leaked); // expected-note{{Reference count incremented. The object now has a +1 retain count}}
   return; // expected-warning{{leak}} expected-note{{Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1}}
 }
 
 void explicitDealloc () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object dealloc]; // expected-note{{Object released by directly sending the '-dealloc' message}}
   [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
 }
 
 void implicitDealloc () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object release]; // expected-note{{Object released}}
   [object class]; // expected-warning{{Reference-counted object is used after it is released}} // expected-note{{Reference-counted object is used after it is released}}
 }
 
 void overAutorelease () {
-  id object = [[NSObject alloc] init]; // expected-note{{Method returns an Objective-C object with a +1 retain count}}
+  id object = [[NSObject alloc] init]; // expected-note{{Method returns an instance of NSObject with a +1 retain count}}
   [object autorelease]; // expected-note{{Object autoreleased}}
   [object autorelease]; // expected-note{{Object autoreleased}} 
   return; // expected-warning{{Object autoreleased too many times}} expected-note{{Object was autoreleased 2 times but the object has a +1 retain count}} 
@@ -99,19 +99,19 @@
 }
 
 void makeCollectableIgnored () {
-  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count}}
+  CFTypeRef leaked = CFCreateSomething(); // expected-note{{Call to function 'CFCreateSomething' returns a Core Foundation object of type CFTypeRef with a +1 retain count}}
   CFMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument}}
   NSMakeCollectable(leaked); // expected-note{{When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument}}
   return; // expected-warning{{leak}} 

r289883 - [analyzer] Include type name in Retain Count Checker diagnostics

2016-12-15 Thread Anna Zaks via cfe-commits
Author: zaks
Date: Thu Dec 15 16:55:03 2016
New Revision: 289883

URL: http://llvm.org/viewvc/llvm-project?rev=289883=rev
Log:
[analyzer] Include type name in Retain Count Checker diagnostics

The more detailed diagnostic will make identifying which object the
diagnostics refer to easier.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/edges-new.mm
cfe/trunk/test/Analysis/inlining/path-notes.m
cfe/trunk/test/Analysis/objc-arc.m
cfe/trunk/test/Analysis/plist-output-alternate.m
cfe/trunk/test/Analysis/retain-release-arc.m
cfe/trunk/test/Analysis/retain-release-path-notes-gc.m
cfe/trunk/test/Analysis/retain-release-path-notes.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=289883=289882=289883=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Thu Dec 15 
16:55:03 2016
@@ -1990,11 +1990,23 @@ PathDiagnosticPiece *CFRefReportVisitor:
   }
 
   if (CurrV.getObjKind() == RetEffect::CF) {
-os << " returns a Core Foundation object with a ";
+if (Sym->getType().isNull()) {
+  os << " returns a Core Foundation object with a ";
+} else {
+  os << " returns a Core Foundation object of type "
+ << Sym->getType().getAsString() << " with a ";
+}
   }
   else {
 assert (CurrV.getObjKind() == RetEffect::ObjC);
-os << " returns an Objective-C object with a ";
+QualType T = Sym->getType();
+if (T.isNull() || !isa(T)) {
+  os << " returns an Objective-C object with a ";
+} else {
+  const ObjCObjectPointerType *PT = cast(T);
+  os << " returns an instance of "
+ << PT->getPointeeType().getAsString() << " with a ";
+}
   }
 
   if (CurrV.isOwned()) {

Modified: cfe/trunk/test/Analysis/edges-new.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/edges-new.mm?rev=289883=289882=289883=diff
==
--- cfe/trunk/test/Analysis/edges-new.mm (original)
+++ cfe/trunk/test/Analysis/edges-new.mm Thu Dec 15 16:55:03 2016
@@ -2438,9 +2438,9 @@ namespace rdar14960554 {
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Call to function CFNumberCreate 
returns a Core Foundation object with a +1 retain count
+// CHECK-NEXT:  Call to function CFNumberCreate 
returns a Core Foundation object of type CFNumberRef with a +1 retain 
count
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Call to function CFNumberCreate 
returns a Core Foundation object with a +1 retain count
+// CHECK-NEXT:  Call to function CFNumberCreate 
returns a Core Foundation object of type CFNumberRef with a +1 retain 
count
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
@@ -11355,9 +11355,9 @@ namespace rdar14960554 {
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Method returns an Objective-C object with a +1 
retain count
+// CHECK-NEXT:  Method returns an instance of RDar10797980 with a 
+1 retain count
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Method returns an Objective-C object with a +1 
retain count
+// CHECK-NEXT:  Method returns an instance of RDar10797980 with a 
+1 retain count
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol
@@ -20325,9 +20325,9 @@ namespace rdar14960554 {
 // CHECK-NEXT:  
 // CHECK-NEXT:  depth0
 // CHECK-NEXT:  extended_message
-// CHECK-NEXT:  Method returns an Objective-C object with a +1 
retain count
+// CHECK-NEXT:  Method returns an instance of NSObject with a +1 
retain count
 // CHECK-NEXT:  message
-// CHECK-NEXT:  Method returns an Objective-C object with a +1 
retain count
+// CHECK-NEXT:  Method returns an instance of NSObject with a +1 
retain count
 // CHECK-NEXT: 
 // CHECK-NEXT: 
 // CHECK-NEXT:  kindcontrol

Modified: cfe/trunk/test/Analysis/inlining/path-notes.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/inlining/path-notes.m?rev=289883=289882=289883=diff
==
--- cfe/trunk/test/Analysis/inlining/path-notes.m (original)
+++ cfe/trunk/test/Analysis/inlining/path-notes.m Thu Dec 15 16:55:03 2016
@@ -160,7 +160,7 @@ id testAutoreleaseTakesEffectInDispatch(
   dispatch_once(, ^{});
 
   id x = NSObject alloc] init] autorelease] autorelease];
-  // expected-note@-1 {{Method returns an Objective-C object 

[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D27815#624322, @Eugene.Zelenko wrote:

> There are many other checks or compiler warnings which could be classified as 
> obvious bugs.


Sure, but unfortunatelly they won't be able to become warning because of false 
positive rate. 
In the example I mentioned this code could be totally valid.


https://reviews.llvm.org/D27815



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


[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

There are many other checks or compiler warnings which could be classified as 
obvious bugs.


https://reviews.llvm.org/D27815



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


[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D27815#624294, @Eugene.Zelenko wrote:

> I'm not sure that this is good name for module.
>
> Singe reason for this is check for STL algorithms, may be //stl// module is 
> more correct destination?


The reason for this module is that I want to make a bunch of clang-tidy checks 
that are designed to help programmer find a bug in the recently written code. 
These check probably won't find any bugs in projects, because with example of 
the first check, either:
a) the code is dead
b) code is correct because we use 2 references to the same vector

in any other case the app would crash, so it only make sense to run this check 
while programming and looking for the bugs.

Other example of the check I want to write:

  for (int i = 0; i < n; i++) {
 for (int j = 0; i < n; j++) {


These are kinds of bugs that with 99% chances will be found during development, 
so the goal is to reduce programmer time ti find these kind of bugs.


https://reviews.llvm.org/D27815



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


[PATCH] D27180: Testbed and skeleton of a new expression parser

2016-12-15 Thread Sean Callanan via Phabricator via cfe-commits
spyffe updated this revision to Diff 81661.
spyffe marked 2 inline comments as done.
spyffe added a comment.
Herald added a subscriber: jgosnell.

Applied Vassil and Vedant's comments.  I will commit this soon.


Repository:
  rL LLVM

https://reviews.llvm.org/D27180

Files:
  test/Import/clang-flags/Inputs/S.c
  test/Import/clang-flags/test.c
  test/Import/empty-struct/Inputs/S.c
  test/Import/empty-struct/test.c
  test/Import/error-in-expression/Inputs/S.c
  test/Import/error-in-expression/test.c
  test/Import/error-in-import/Inputs/S.c
  test/Import/error-in-import/test.c
  test/Import/missing-import/test.c
  tools/CMakeLists.txt
  tools/clang-import-test/CMakeLists.txt
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -0,0 +1,319 @@
+//===-- import-test.cpp - ASTImporter/ExternalASTSource testbed ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTImporter.h"
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
+#include "clang/CodeGen/ModuleBuilder.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Parse/ParseAST.h"
+
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Signals.h"
+
+#include 
+#include 
+
+using namespace clang;
+
+static llvm::cl::opt Expression(
+"expression", llvm::cl::Required,
+llvm::cl::desc("Path to a file containing the expression to parse"));
+
+static llvm::cl::list
+Imports("import", llvm::cl::ZeroOrMore,
+llvm::cl::desc("Path to a file containing declarations to import"));
+
+static llvm::cl::list
+ClangArgs("Xcc", llvm::cl::ZeroOrMore,
+  llvm::cl::desc("Argument to pass to the CompilerInvocation"),
+  llvm::cl::CommaSeparated);
+
+namespace init_convenience {
+class TestDiagnosticConsumer : public DiagnosticConsumer {
+private:
+  std::unique_ptr Passthrough;
+  const LangOptions *LangOpts = nullptr;
+
+public:
+  TestDiagnosticConsumer()
+  : Passthrough(llvm::make_unique()) {}
+
+  virtual void BeginSourceFile(const LangOptions ,
+   const Preprocessor *PP = nullptr) override {
+this->LangOpts = 
+return Passthrough->BeginSourceFile(LangOpts, PP);
+  }
+
+  virtual void EndSourceFile() override {
+this->LangOpts = nullptr;
+Passthrough->EndSourceFile();
+  }
+
+  virtual bool IncludeInDiagnosticCounts() const override {
+return Passthrough->IncludeInDiagnosticCounts();
+  }
+
+private:
+  static void PrintSourceForLocation(const SourceLocation ,
+ SourceManager ) {
+const char *LocData = SM.getCharacterData(Loc, /*Invalid=*/nullptr);
+unsigned LocColumn =
+SM.getSpellingColumnNumber(Loc, /*Invalid=*/nullptr) - 1;
+FileID FID = SM.getFileID(Loc);
+llvm::MemoryBuffer *Buffer = SM.getBuffer(FID, Loc, /*Invalid=*/nullptr);
+
+assert(LocData >= Buffer->getBufferStart() &&
+   LocData < Buffer->getBufferEnd());
+
+const char *LineBegin = LocData - LocColumn;
+
+assert(LineBegin >= Buffer->getBufferStart());
+
+const char *LineEnd = nullptr;
+
+for (LineEnd = LineBegin; *LineEnd != '\n' && *LineEnd != '\r' &&
+  LineEnd < Buffer->getBufferEnd();
+ ++LineEnd)
+  ;
+
+llvm::StringRef LineString(LineBegin, LineEnd - LineBegin);
+
+llvm::errs() << LineString << '\n';
+std::string Space(LocColumn, ' ');
+llvm::errs() << Space.c_str() << '\n';
+  }
+
+  virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic ) override {
+if (Info.hasSourceManager() && LangOpts) {
+  SourceManager  = Info.getSourceManager();
+
+  if (Info.getLocation().isValid()) {
+Info.getLocation().print(llvm::errs(), SM);
+llvm::errs() << ": ";
+  }
+
+  SmallString<16> DiagText;
+  Info.FormatDiagnostic(DiagText);
+  llvm::errs() << DiagText << '\n';
+
+  if (Info.getLocation().isValid()) {
+PrintSourceForLocation(Info.getLocation(), SM);
+  }
+
+  for (const CharSourceRange  : Info.getRanges()) {
+bool Invalid = true;
+StringRef Ref = 

[PATCH] D27815: [clang-tidy] Add obvious module for obvious bugs

2016-12-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I'm not sure that this is good name for module.

Singe reason for this is check for STL algorithms, may be //stl// module is 
more correct destination?


https://reviews.llvm.org/D27815



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


Re: [libcxx] r286789 - Add check-cxx-abilist target when supported.

2016-12-15 Thread Justin Bogner via cfe-commits
Yep, the copy-libcxx-headers-into-build-tree logic is so that they end
up somewhere where a just built clang will find them relative to itself
(it looks for something like ../include/c++/v1). It's purely a
convenience so you don't need to call `ninja install` to use a clang
that refers to headers that match your checked out libc++.

Chris Bieneman via cfe-commits  writes:
> (+Bogner, I think he originally added this)
>
> My understanding is that we only did this copy step if you are
> building with a clang that isn't installed so that the non-installed
> clang could find these headers.
>
> I'm pretty sure compiler-rt finds libcxx via the sources, not the
> build directory.
>
> I'll put together a fix later today.
>
> -Chris
>
>> On Dec 14, 2016, at 11:49 PM, Eric Fiselier  wrote:
>> 
>>  
>> Eric, this part of this change seems wrong to me. It causes the
>> headers to be installed into the libcxx build directory instead of
>> the LLVM one. If you build using the LLVM runtimes directory this
>> puts the headers in the wrong place for clang to find them.
>> 
>> Is there a reason you're copying them into the libcxx binary dir? I
>> generally don't think the headers are needed there.
>> 
>> 
>> If it seems wrong for building in the LLVM runtimes directory then
>> it probably is. I don't think there is a good reason why we need to
>> copy the headers into the build directory, although we should double
>> check compiler-rt uses the headers from the source directory.
>> 
>> If you know how to fix this feel free to commit a patch. If not I'll
>> look into this more on Friday.
>> 
>> @Dan, @Jonathan: Do you guys use, or see a need for, this behavior?
>> 
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25475: [analyzer] Add a new SVal to support pointer-to-member operations.

2016-12-15 Thread Devin Coughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289873: [analyzer] Add a new SVal to support 
pointer-to-member operations. (authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D25475?vs=81598=81655#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25475

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
  cfe/trunk/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  cfe/trunk/test/Analysis/pointer-to-member.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -479,6 +479,22 @@
 return X.isValid() ? svalBuilder.evalComplement(X.castAs()) : X;
   }
 
+  ProgramStateRef handleLValueBitCast(ProgramStateRef state, const Expr *Ex,
+  const LocationContext *LCtx, QualType T,
+  QualType ExTy, const CastExpr *CastE,
+  StmtNodeBuilder ,
+  ExplodedNode *Pred);
+
+  ProgramStateRef handleLVectorSplat(ProgramStateRef state,
+ const LocationContext *LCtx,
+ const CastExpr *CastE,
+ StmtNodeBuilder ,
+ ExplodedNode *Pred);
+
+  void handleUOExtension(ExplodedNodeSet::iterator I,
+ const UnaryOperator* U,
+ StmtNodeBuilder );
+
 public:
 
   SVal evalBinOp(ProgramStateRef state, BinaryOperator::Opcode op,
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
@@ -66,6 +66,7 @@
   NONLOC_SVAL(LazyCompoundVal, NonLoc)
   NONLOC_SVAL(LocAsInteger, NonLoc)
   NONLOC_SVAL(SymbolVal, NonLoc)
+  NONLOC_SVAL(PointerToMember, NonLoc)
 
 #undef NONLOC_SVAL
 #undef LOC_SVAL
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -204,6 +204,8 @@
const LocationContext *LCtx,
unsigned count);
 
+  DefinedSVal getMemberPointer(const DeclaratorDecl *DD);
+
   DefinedSVal getFunctionPointer(const FunctionDecl *func);
   
   DefinedSVal getBlockPointer(const BlockDecl *block, CanQualType locTy,
@@ -226,6 +228,14 @@
 BasicVals.getLazyCompoundValData(store, region));
   }
 
+  NonLoc makePointerToMember(const DeclaratorDecl *DD) {
+return nonloc::PointerToMember(DD);
+  }
+
+  NonLoc makePointerToMember(const PointerToMemberData *PTMD) {
+return nonloc::PointerToMember(PTMD);
+  }
+
   NonLoc makeZeroArrayIndex() {
 return nonloc::ConcreteInt(BasicVals.getValue(0, ArrayIndexTy));
   }
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -59,6 +59,29 @@
   void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, store, region); }
 };
 
+class PointerToMemberData: public llvm::FoldingSetNode {
+  const DeclaratorDecl *D;
+  llvm::ImmutableList L;
+
+public:
+  PointerToMemberData(const DeclaratorDecl *D,
+  llvm::ImmutableList L)
+: D(D), L(L) {}
+
+  typedef llvm::ImmutableList::iterator iterator;
+  iterator begin() const { return L.begin(); }
+  iterator end() const { return L.end(); }
+
+  static void Profile(llvm::FoldingSetNodeID& ID, const DeclaratorDecl *D,
+  llvm::ImmutableList L);
+
+  void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, D, L); }
+  const DeclaratorDecl *getDeclaratorDecl() const {return D;}
+  

r289873 - [analyzer] Add a new SVal to support pointer-to-member operations.

2016-12-15 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Thu Dec 15 15:27:06 2016
New Revision: 289873

URL: http://llvm.org/viewvc/llvm-project?rev=289873=rev
Log:
[analyzer] Add a new SVal to support pointer-to-member operations.

Add a new type of NonLoc SVal for C++ pointer-to-member operations. This SVal
supports both pointers to member functions and pointers to member data.

A patch by Kirill Romanenkov!

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.def
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
cfe/trunk/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineC.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SValBuilder.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SVals.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
cfe/trunk/test/Analysis/pointer-to-member.cpp

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h?rev=289873=289872=289873=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
Thu Dec 15 15:27:06 2016
@@ -59,6 +59,29 @@ public:
   void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, store, region); }
 };
 
+class PointerToMemberData: public llvm::FoldingSetNode {
+  const DeclaratorDecl *D;
+  llvm::ImmutableList L;
+
+public:
+  PointerToMemberData(const DeclaratorDecl *D,
+  llvm::ImmutableList L)
+: D(D), L(L) {}
+
+  typedef llvm::ImmutableList::iterator iterator;
+  iterator begin() const { return L.begin(); }
+  iterator end() const { return L.end(); }
+
+  static void Profile(llvm::FoldingSetNodeID& ID, const DeclaratorDecl *D,
+  llvm::ImmutableList L);
+
+  void Profile(llvm::FoldingSetNodeID& ID) { Profile(ID, D, L); }
+  const DeclaratorDecl *getDeclaratorDecl() const {return D;}
+  llvm::ImmutableList getCXXBaseList() const {
+return L;
+  }
+};
+
 class BasicValueFactory {
   typedef llvm::FoldingSet
   APSIntSetTy;
@@ -71,8 +94,10 @@ class BasicValueFactory {
   void *PersistentSValPairs;
 
   llvm::ImmutableList::Factory SValListFactory;
+  llvm::ImmutableList::Factory CXXBaseListFactory;
   llvm::FoldingSet  CompoundValDataSet;
   llvm::FoldingSet LazyCompoundValDataSet;
+  llvm::FoldingSet PointerToMemberDataSet;
 
   // This is private because external clients should use the factory
   // method that takes a QualType.
@@ -81,7 +106,8 @@ class BasicValueFactory {
 public:
   BasicValueFactory(ASTContext , llvm::BumpPtrAllocator )
 : Ctx(ctx), BPAlloc(Alloc), PersistentSVals(nullptr),
-  PersistentSValPairs(nullptr), SValListFactory(Alloc) {}
+  PersistentSValPairs(nullptr), SValListFactory(Alloc),
+  CXXBaseListFactory(Alloc) {}
 
   ~BasicValueFactory();
 
@@ -172,14 +198,32 @@ public:
   const LazyCompoundValData *getLazyCompoundValData(const StoreRef ,
 const TypedValueRegion *region);
 
+  const PointerToMemberData *getPointerToMemberData(
+  const DeclaratorDecl *DD,
+  llvm::ImmutableList L);
+
   llvm::ImmutableList getEmptySValList() {
 return SValListFactory.getEmptyList();
   }
 
-  llvm::ImmutableList consVals(SVal X, llvm::ImmutableList L) {
+  llvm::ImmutableList prependSVal(SVal X, llvm::ImmutableList L) {
 return SValListFactory.add(X, L);
   }
 
+  llvm::ImmutableList getEmptyCXXBaseList() {
+return CXXBaseListFactory.getEmptyList();
+  }
+
+  llvm::ImmutableList prependCXXBase(
+  const CXXBaseSpecifier *CBS,
+  llvm::ImmutableList L) {
+return CXXBaseListFactory.add(CBS, L);
+  }
+
+  const clang::ento::PointerToMemberData *accumCXXBase(
+  llvm::iterator_range PathRange,
+  const nonloc::PointerToMember );
+
   const llvm::APSInt* evalAPSInt(BinaryOperator::Opcode Op,
  const llvm::APSInt& V1,
  const llvm::APSInt& V2);

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=289873=289872=289873=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 

[PATCH] D27827: [ObjC] CodeGen support for @available on macOS

2016-12-15 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: manmanren, dexonsmith, rjmccall, thakis.
erik.pilkington added a subscriber: cfe-commits.

This patch adds CodeGen support for `@available` on macos. This is done by 
compiling @available predicates into calls to `clang.is_os_version_at_least`. 
This function first populates 3 global variables which hold the major, minor 
and subminor with the operating system version, using core services' 
`Gestalt()` 
(https://developer.apple.com/reference/coreservices/1471624-gestalt?language=objc),
 and grand central dispatch's `dispatch_once_f` to make sure that this is only 
done once. After that, it compares the version that was passed to it with the 
host's OS version.

Unfortunately, `Gestalt()` is only available on macOS. In a follow-up patch, we 
can add support for other platforms. I think that the best way of doing that is 
to depend on Objective-C's `NSProcessInfo`. I'm not super familiar with this 
part of the compiler, and in particular I'm unsure of whether we should be 
directly calling into library functions like `Gestalt` and `dispatch_once_f`, 
so please tear this patch apart!

This patch is part of a feature that I proposed last summer here:
http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html

Thanks,
Erik


https://reviews.llvm.org/D27827

Files:
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.h
  test/CodeGenObjC/availability-check.m
  test/CodeGenObjC/availability-check2.m

Index: test/CodeGenObjC/availability-check2.m
===
--- test/CodeGenObjC/availability-check2.m
+++ test/CodeGenObjC/availability-check2.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s
+
+// Test that we behave correctly if the user already imported the libraries we
+// depend on to implement @available.
+
+// CHECK: @clang.os_version_major = linkonce_odr global i32 0
+// CHECK: @clang.os_version_minor = linkonce_odr global i32 0
+// CHECK: @clang.os_version_subminor = linkonce_odr global i32 0
+// CHECK: @clang.os_version_check_dispatch_once_counter = linkonce_odr global i64 0
+
+short Gestalt(int, int *);
+void dispatch_once_f(long long *, char *, void (*)(char *));
+
+void actually_emit() {
+  (void)Gestalt;
+  (void)dispatch_once_f;
+}
+
+// CHECK: declare signext i16 @Gestalt(i32, i32*)
+// CHECK: declare void @dispatch_once_f(i64*, i8*, void (i8*)*)
+
+void use_at_available() {
+  if (@available(macos 10.12, *))
+;
+  // CHECK: call i1 @clang.is_os_version_at_least(i32 10, i32 12, i32 0)
+}
+
+// CHECK-NOT: declare signext i16 @Gestalt(i32, i32*)
+// CHECK-NOT: declare void @dispatch_once_f(i64*, i8*, void (i8*)*)
+
+// CHECK: define linkonce_odr void @clang.populate_os_version(i8*)
+// CHECK: define linkonce_odr i1 @clang.is_os_version_at_least(i32, i32, i32)
Index: test/CodeGenObjC/availability-check.m
===
--- test/CodeGenObjC/availability-check.m
+++ test/CodeGenObjC/availability-check.m
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -xc -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK:  @clang.os_version_major = linkonce_odr global i32 0
+// CHECK:  @clang.os_version_minor = linkonce_odr global i32 0
+// CHECK:  @clang.os_version_subminor = linkonce_odr global i32 0
+// CHECK:  @clang.os_version_check_dispatch_once_counter = linkonce_odr global i64 0
+
+void use_at_available() {
+  if (__builtin_available(macos 10.12, *))
+;
+  // CHECK: call i1 @clang.is_os_version_at_least(i32 10, i32 12, i32 0)
+
+  // Test that we constant fold the check if our OS version is older than our
+  // deployment target:
+  if (__builtin_available(macos 10.11, *))
+;
+  // CHECK-NOT: call i1 @clang.is_os_version_at_least
+  // CHECK: br i1 true
+}
+
+// CHECK:  define linkonce_odr void @clang.populate_os_version(i8*) {
+// CHECK-NEXT:   call i16 @Gestalt(i32 1937339185, i32* @clang.os_version_major)
+// CHECK-NEXT:   call i16 @Gestalt(i32 1937339186, i32* @clang.os_version_minor)
+// CHECK-NEXT:   call i16 @Gestalt(i32 1937339187, i32* @clang.os_version_subminor)
+// CHECK-NEXT:   ret void
+// CHECK-NEXT: }
+
+// CHECK: declare signext i16 @Gestalt(i32, i32*)
+// CHECK: declare void @dispatch_once_f(i64*, i8*, void (i8*)*)
+
+// CHECK:  define linkonce_odr i1 @clang.is_os_version_at_least(i32, i32, i32) {
+// CHECK:call void @dispatch_once_f(i64* @clang.os_version_check_dispatch_once_counter, i8* null, void (i8*)* @clang.populate_os_version)
+// entry:
+// CHECK:[[T0:%.*]] = load i32, i32* @clang.os_version_major, align 4
+// CHECK-NEXT:   [[T1:%.*]] = icmp slt i32 %0, [[T0]]
+// CHECK-NEXT:   br i1 [[T1]],
+// major_cmp:
+// CHECK:

[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

2016-12-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin updated the summary for this revision.
dcoughlin updated this revision to Diff 81651.
dcoughlin marked an inline comment as done.
dcoughlin added a comment.

Update to address Aleksei's comments.


https://reviews.llvm.org/D27773

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/Driver/Tools.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/GTestChecker.cpp
  test/Analysis/gtest.cpp
  test/Driver/analyzer-target-enabled-checkers.cpp

Index: test/Driver/analyzer-target-enabled-checkers.cpp
===
--- test/Driver/analyzer-target-enabled-checkers.cpp
+++ test/Driver/analyzer-target-enabled-checkers.cpp
@@ -4,6 +4,7 @@
 // RUN: %clang -### -target x86_64-apple-darwin10 --analyze %s 2>&1 | FileCheck --check-prefix=CHECK-DARWIN %s
 
 // CHECK-DARWIN: "-analyzer-checker=core"
+// CHECK-DARWIN-SAME: "-analyzer-checker=apiModeling"
 // CHECK-DARWIN-SAME: "-analyzer-checker=unix"
 // CHECK-DARWIN-SAME: "-analyzer-checker=osx"
 // CHECK-DARWIN-SAME: "-analyzer-checker=deadcode"
@@ -21,6 +22,7 @@
 // RUN: %clang -### -target x86_64-unknown-linux --analyze %s 2>&1 | FileCheck --check-prefix=CHECK-LINUX %s
 
 // CHECK-LINUX: "-analyzer-checker=core"
+// CHECK-LINUX-SAME: "-analyzer-checker=apiModeling"
 // CHECK-LINUX-SAME: "-analyzer-checker=unix"
 // CHECK-LINUX-NOT:  "-analyzer-checker=osx"
 // CHECK-LINUX-SAME: "-analyzer-checker=deadcode"
@@ -38,6 +40,7 @@
 // RUN: %clang -### -target x86_64-windows --analyze %s 2>&1 | FileCheck --check-prefix=CHECK-WINDOWS %s
 
 // CHECK-WINDOWS: "-analyzer-checker=core"
+// CHECK-WINDOWS-SAME: "-analyzer-checker=apiModeling"
 // CHECK-WINDOWS-SAME: "-analyzer-checker=unix.API"
 // CHECK-WINDOWS-SAME: "-analyzer-checker=unix.Malloc"
 // CHECK-WINDOWS-SAME: "-analyzer-checker=unix.MallocSizeof"
Index: test/Analysis/gtest.cpp
===
--- /dev/null
+++ test/Analysis/gtest.cpp
@@ -0,0 +1,142 @@
+//RUN: %clang_cc1 -cc1 -std=c++11 -analyze  -analyzer-checker=core,apiModeling.google.GTest -analyzer-eagerly-assume %s -verify
+//RUN: %clang_cc1 -cc1 -std=c++11 -analyze  -analyzer-checker=core,apiModeling.google.GTest -analyzer-eagerly-assume -DGTEST_VERSION_1_8_AND_LATER=1 %s -verify
+
+// expected-no-diagnostics
+
+namespace std {
+  class string {
+public:
+~string();
+const char *c_str();
+  };
+}
+
+namespace testing {
+
+class Message { };
+class TestPartResult {
+ public:
+  enum Type {
+kSuccess,
+kNonFatalFailure,
+kFatalFailure
+  };
+};
+
+namespace internal {
+
+class AssertHelper {
+ public:
+  AssertHelper(TestPartResult::Type type, const char* file, int line,
+   const char* message);
+  ~AssertHelper();
+  void operator=(const Message& message) const;
+};
+
+
+template 
+struct AddReference { typedef T& type; };
+template 
+struct AddReference { typedef T& type; };
+template 
+class ImplicitlyConvertible {
+ private:
+  static typename AddReference::type MakeFrom();
+  static char Helper(To);
+  static char ((...))[2];
+ public:
+  static const bool value =
+  sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;
+};
+template 
+const bool ImplicitlyConvertible::value;
+template struct EnableIf;
+template<> struct EnableIf { typedef void type; };
+
+} // end internal
+
+
+class AssertionResult {
+public:
+
+  // The implementation for the copy constructor is not exposed in the
+  // interface.
+  AssertionResult(const AssertionResult& other);
+
+#if defined(GTEST_VERSION_1_8_AND_LATER)
+  template 
+  explicit AssertionResult(
+  const T& success,
+  typename internal::EnableIf<
+  !internal::ImplicitlyConvertible::value>::type*
+  /*enabler*/ = 0)
+  : success_(success) {}
+#else
+  explicit AssertionResult(bool success) : success_(success) {}
+#endif
+
+  operator bool() const { return success_; }
+
+  // The actual AssertionResult does not have an explicit destructor, but
+  // it does have a non-trivial member veriable, so we add a destructor here
+  // to force temporary cleanups.
+  ~AssertionResult();
+private:
+
+  bool success_;
+};
+
+namespace internal {
+std::string GetBoolAssertionFailureMessage(
+const AssertionResult& assertion_result,
+const char* expression_text,
+const char* actual_predicate_value,
+const char* expected_predicate_value);
+} // end internal
+
+} // end testing
+
+#define GTEST_MESSAGE_AT_(file, line, message, result_type) \
+  ::testing::internal::AssertHelper(result_type, file, line, message) \
+= ::testing::Message()
+
+#define GTEST_MESSAGE_(message, result_type) \
+  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)
+
+#define GTEST_FATAL_FAILURE_(message) \
+  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)
+
+#define GTEST_NONFATAL_FAILURE_(message) \
+  GTEST_MESSAGE_(message, 

[PATCH] D27773: [analyzer] Add checker modeling gtest APIs.

2016-12-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin marked 2 inline comments as done.
dcoughlin added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:30
+//
+// The gtest unit testing API provides macros for assertions that that expand
+// into an if statement that calls a series of constructors and returns

a.sidorin wrote:
> "that that"
Thanks!



Comment at: lib/StaticAnalyzer/Checkers/GTestChecker.cpp:182
+
+  SVal ThisSuccess = getAssertionResultSuccessFieldValue(AssertResultClassDecl,
+ ThisVal, State);

a.sidorin wrote:
> Shouldn't we just bind OtherSuccess to our field?
Unfortunately since this is a PostCall, the result of the constructor has 
already entered value land. It is a LazyCompoundValue with a reference to a 
previous store. Even if we look through the lazy compound value to get at the 
memory region, binding it in the current store will have no effect on the 
returned value.

We could perform the bind and load the result value again -- but then we'd have 
to replace the result value in the environment, which is not compositional with 
respect to other checkers' PostCalls, since they may have done their own thing 
with the old value.


https://reviews.llvm.org/D27773



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


[PATCH] D27163: Introduce -f[no-]strict-return flag that controls code generation for C++'s undefined behaviour return optimisation

2016-12-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CodeGenFunction.cpp:1078
+  QualType T = FD->getReturnType();
+  if (T.isTriviallyCopyableType(Context)) {
+// Avoid the optimization for functions that return trivially copyable

arphaman wrote:
> Quuxplusone wrote:
> > Peanut-gallery question: Does `isTriviallyCopyableType` also check that the 
> > type is trivially destructible and/or default-constructible? Do those 
> > things matter?
> Yes for trivially destructible, since it calls 
> `CXXRecordDecl::isTriviallyCopyable()` which checks. No for trivially 
> default-constructible, I fixed that. 
> 
> I think that for us it doesn't really matter that much, since we're mostly 
> worried about C code compiled in C++ mode.
The right condition is just hasTrivialDestructor().  The goal of 
-fno-strict-return is to not treat falling off the end of a function as 
undefined behavior in itself: it might still be a *problem* if users don't 
ignore the result, but we shouldn't escalate to UB in the callee because they 
legitimately might ignore the result.  The argument for having an exception 
around non-trivial types is that callers never *really* ignore the result when 
there's a non-trivial destructor.  Calling a destructor on storage that doesn't 
have a valid object of that type constructed there is already definitely U.B. 
in the caller, so it's fine to also treat it as U.B. on the callee side.  That 
reasoning is entirely based on the behavior of the destructor, though, not any 
of the copy/move constructors, and definitely not the presence or absence of a 
trivial default constructor.

In practice, all of these things tend to vary together, of course, except that 
sometimes trivial types do have non-trivial default constructors.  We should 
not treat that as a UB case.


Repository:
  rL LLVM

https://reviews.llvm.org/D27163



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


[PATCH] D27784: Add a class ASTRecordReader which wraps an ASTReader, a RecordData, and ModuleFile.

2016-12-15 Thread David L. Jones via Phabricator via cfe-commits
dlj added a comment.




https://reviews.llvm.org/D27784



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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-15 Thread Piotr Padlewski via cfe-commits
I think that the feature I mentioned is right thing to put in this check,
however you don't have to implement it right now, just leave FIXIT comment

2016-12-15 20:55 GMT+01:00 Mads Ravn :

> Hi Piotr,
>
> That is a good point. Because it is not always -1 or 1 that determines
> lexicographical higher or lower.
>
> However, I don't think that is in the scope of this check. This check
> checks for string comparison (equality or inequality). Adding a match for
> if the user is using the compare function semantically wrong might make the
> check too ambiguous. Since str.compare(str) == 0 will check for equality
> and str.compare(str) != 0 will check for inequality. But str.compare(str)
> == 1 will check whether one string is lexicographically smaller than the
> other (and == -1 also). What do you think?
>
> Best regards,
> Mads Ravn
>
> On Thu, Dec 15, 2016 at 8:17 PM Piotr Padlewski via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> Prazek added a comment.
>>
>> Good job.
>> I think it is resonable to warn in cases like:
>>
>>   if (str.compare(str2) == 1)
>>
>> or even
>>
>>   if(str.compare(str2) == -1)
>>
>> Sometimes people check for 1 or -1 instead of > 0 and < 0. If I remember
>> corectly PVS studio found some bugs like this.
>>
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.cpp:27
>> +   hasName("::std::basic_string"),
>> +  hasArgument(0, declRefExpr()), callee(memberExpr()));
>> +
>> 
>> malcolm.parsons wrote:
>> > I don't think you need to check what the first argument is.
>> +1, just check if you are calling function with 1 argument.
>> you can still use hasArgument(0, expr().bind("str2")) to bind argument
>>
>>
>> 
>> Comment at: clang-tidy/misc/StringCompareCheck.cpp:25
>> +return;
>> +  const auto strCompare = cxxMemberCallExpr(
>> +  callee(cxxMethodDecl(hasName("compare"),
>> 
>> Start with upper case
>>
>>
>> https://reviews.llvm.org/D27210
>>
>>
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27641: DebugInfo: Added support for Checksum debug info feature (Clang part)

2016-12-15 Thread Amjad Aboud via Phabricator via cfe-commits
aaboud added a subscriber: bwyma.
aaboud updated this revision to Diff 81640.
aaboud added a comment.

Moved getChecksum from SourceManager to CGDebugInfo.
Also, now checksum is emitted only for CodeView.


https://reviews.llvm.org/D27641

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGen/debug-info-file-checksum.c
  test/CodeGen/debug-info-file-checksum.c.source

Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -442,6 +442,10 @@
   /// Remap a given path with the current debug prefix map
   std::string remapDIPath(StringRef) const;
 
+  /// Get the file checksum debug info for input file ID.
+  llvm::DIFile::ChecksumKind getChecksum(FileID FID,
+ SmallString<32> ) const;
+
   /// Get the file debug info descriptor for the input location.
   llvm::DIFile *getOrCreateFile(SourceLocation Loc);
 
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -41,6 +41,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MD5.h"
 #include "llvm/Support/Path.h"
 using namespace clang;
 using namespace clang::CodeGen;
@@ -320,19 +321,46 @@
   return StringRef();
 }
 
+llvm::DIFile::ChecksumKind
+CGDebugInfo::getChecksum(FileID FID, SmallString<32> ) const {
+  Checksum.clear();
+
+  if (!CGM.getCodeGenOpts().EmitCodeView)
+return llvm::DIFile::CSK_None;
+
+  SourceManager  = CGM.getContext().getSourceManager();
+  bool Invalid;
+  llvm::MemoryBuffer *MemBuffer = SM.getBuffer(FID, );
+  if (Invalid)
+return llvm::DIFile::CSK_None;
+
+  llvm::MD5 Hash;
+  llvm::MD5::MD5Result Result;
+
+  Hash.update(MemBuffer->getBuffer());
+  Hash.final(Result);
+
+  Hash.stringifyResult(Result, Checksum);
+  return llvm::DIFile::CSK_MD5;
+}
+
 llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
   if (!Loc.isValid())
 // If Location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()));
+   remapDIPath(TheCU->getDirectory()),
+   TheCU->getFile()->getChecksumKind(),
+   TheCU->getFile()->getChecksum());
 
   SourceManager  = CGM.getContext().getSourceManager();
   PresumedLoc PLoc = SM.getPresumedLoc(Loc);
 
   if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
 // If the location is not valid then use main input file.
 return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
-   remapDIPath(TheCU->getDirectory()));
+   remapDIPath(TheCU->getDirectory()),
+   TheCU->getFile()->getChecksumKind(),
+   TheCU->getFile()->getChecksum());
 
   // Cache the results.
   const char *fname = PLoc.getFilename();
@@ -344,16 +372,22 @@
   return cast(V);
   }
 
+  SmallString<32> Checksum;
+  llvm::DIFile::ChecksumKind CSKind = getChecksum(SM.getFileID(Loc), Checksum);
+
   llvm::DIFile *F = DBuilder.createFile(remapDIPath(PLoc.getFilename()),
-remapDIPath(getCurrentDirname()));
+remapDIPath(getCurrentDirname()),
+CSKind, Checksum);
 
   DIFileCache[fname].reset(F);
   return F;
 }
 
 llvm::DIFile *CGDebugInfo::getOrCreateMainFile() {
   return DBuilder.createFile(remapDIPath(TheCU->getFilename()),
- remapDIPath(TheCU->getDirectory()));
+ remapDIPath(TheCU->getDirectory()),
+ TheCU->getFile()->getChecksumKind(),
+ TheCU->getFile()->getChecksum());
 }
 
 std::string CGDebugInfo::remapDIPath(StringRef Path) const {
@@ -396,6 +430,8 @@
 }
 
 void CGDebugInfo::CreateCompileUnit() {
+   SmallString<32> Checksum;
+  llvm::DIFile::ChecksumKind CSKind = llvm::DIFile::CSK_None;
 
   // Should we be asking the SourceManager for the main file name, instead of
   // accepting it as an argument? This just causes the main file name to
@@ -422,6 +458,7 @@
   llvm::sys::path::append(MainFileDirSS, MainFileName);
   MainFileName = MainFileDirSS.str();
 }
+CSKind = getChecksum(SM.getMainFileID(), Checksum);
   }
 
   llvm::dwarf::SourceLanguage LangTag;
@@ -467,7 +504,8 @@
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
   LangTag, DBuilder.createFile(remapDIPath(MainFileName),
-remapDIPath(getCurrentDirname())),
+   remapDIPath(getCurrentDirname()), CSKind,
+   

[PATCH] D27812: [test] Extend llvm_shlib_dir fix to unittests

2016-12-15 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289865: [test] Extend llvm_shlib_dir fix to unittests 
(authored by mgorny).

Changed prior to commit:
  https://reviews.llvm.org/D27812?vs=81587=81635#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27812

Files:
  cfe/trunk/test/Unit/lit.cfg


Index: cfe/trunk/test/Unit/lit.cfg
===
--- cfe/trunk/test/Unit/lit.cfg
+++ cfe/trunk/test/Unit/lit.cfg
@@ -94,15 +94,16 @@
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath


Index: cfe/trunk/test/Unit/lit.cfg
===
--- cfe/trunk/test/Unit/lit.cfg
+++ cfe/trunk/test/Unit/lit.cfg
@@ -94,15 +94,16 @@
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289865 - [test] Extend llvm_shlib_dir fix to unittests

2016-12-15 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Thu Dec 15 14:31:08 2016
New Revision: 289865

URL: http://llvm.org/viewvc/llvm-project?rev=289865=rev
Log:
[test] Extend llvm_shlib_dir fix to unittests

Extend the fix from rL286952 to unittests. The fix added clang built
library directories (via llvm_shlib_dir) to LD_LIBRARY_PATH.
The previous logic has used llvm_libs_dir only which points to installed
LLVM when doing stand-alone builds.

The patch also removes the redundant win32 code that is no longer
necessary now that shlibdir is used unconditionally.

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

Modified:
cfe/trunk/test/Unit/lit.cfg

Modified: cfe/trunk/test/Unit/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Unit/lit.cfg?rev=289865=289864=289865=diff
==
--- cfe/trunk/test/Unit/lit.cfg (original)
+++ cfe/trunk/test/Unit/lit.cfg Thu Dec 15 14:31:08 2016
@@ -94,15 +94,16 @@ elif platform.system() == 'Darwin':
 elif platform.system() == 'Windows':
 shlibpath_var = 'PATH'
 
+# in stand-alone builds, shlibdir is clang's build tree
+# while llvm_libs_dir is installed LLVM (and possibly older clang)
+llvm_shlib_dir = getattr(config, 'shlibdir', None)
+if not llvm_shlib_dir:
+lit_config.fatal('No shlibdir set!')
 # Point the dynamic loader at dynamic libraries in 'lib'.
 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
 if not llvm_libs_dir:
 lit_config.fatal('No LLVM libs dir set!')
-shlibpath = os.path.pathsep.join((llvm_libs_dir,
+shlibpath = os.path.pathsep.join((llvm_shlib_dir, llvm_libs_dir,
  config.environment.get(shlibpath_var,'')))
 
-# Win32 seeks DLLs along %PATH%.
-if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
-shlibpath = os.path.pathsep.join((config.shlibdir, shlibpath))
-
 config.environment[shlibpath_var] = shlibpath


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


Re: [PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-15 Thread Mads Ravn via cfe-commits
Hi Piotr,

That is a good point. Because it is not always -1 or 1 that determines
lexicographical higher or lower.

However, I don't think that is in the scope of this check. This check
checks for string comparison (equality or inequality). Adding a match for
if the user is using the compare function semantically wrong might make the
check too ambiguous. Since str.compare(str) == 0 will check for equality
and str.compare(str) != 0 will check for inequality. But str.compare(str)
== 1 will check whether one string is lexicographically smaller than the
other (and == -1 also). What do you think?

Best regards,
Mads Ravn

On Thu, Dec 15, 2016 at 8:17 PM Piotr Padlewski via Phabricator <
revi...@reviews.llvm.org> wrote:

> Prazek added a comment.
>
> Good job.
> I think it is resonable to warn in cases like:
>
>   if (str.compare(str2) == 1)
>
> or even
>
>   if(str.compare(str2) == -1)
>
> Sometimes people check for 1 or -1 instead of > 0 and < 0. If I remember
> corectly PVS studio found some bugs like this.
>
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:27
> +   hasName("::std::basic_string"),
> +  hasArgument(0, declRefExpr()), callee(memberExpr()));
> +
> 
> malcolm.parsons wrote:
> > I don't think you need to check what the first argument is.
> +1, just check if you are calling function with 1 argument.
> you can still use hasArgument(0, expr().bind("str2")) to bind argument
>
>
> 
> Comment at: clang-tidy/misc/StringCompareCheck.cpp:25
> +return;
> +  const auto strCompare = cxxMemberCallExpr(
> +  callee(cxxMethodDecl(hasName("compare"),
> 
> Start with upper case
>
>
> https://reviews.llvm.org/D27210
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27784: Add a class ASTRecordReader which wraps an ASTReader, a RecordData, and ModuleFile.

2016-12-15 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Serialization/ASTReader.cpp:5870-5876
+TL.setWrittenTypeSpec(
+static_cast(Reader.getRecordData()[Idx++]));
+TL.setWrittenSignSpec(
+static_cast(Reader.getRecordData()[Idx++]));
+TL.setWrittenWidthSpec(
+static_cast(Reader.getRecordData()[Idx++]));
+TL.setModeAttr(Reader.getRecordData()[Idx++]);

Can you remove the `.getRecordData()` here and use 
`ASTRecordReader::operator[]` instead?


https://reviews.llvm.org/D27784



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


[PATCH] D27821: [OpenMP] support is_device_ptr clause with 'target parallel' pragma

2016-12-15 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: ABataev, hfinkel, carlo.bertolli, sfantao, 
arpith-jacob, mikerice.
kkwli0 added a subscriber: cfe-commits.

This patch is to add support of the 'is_device_ptr' clause in the 'target 
parallel' pragma.


https://reviews.llvm.org/D27821

Files:
  include/clang/Basic/OpenMPKinds.def
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_parallel_is_device_ptr_ast_print.cpp
  test/OpenMP/target_parallel_is_device_ptr_messages.cpp

Index: test/OpenMP/target_parallel_is_device_ptr_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_is_device_ptr_messages.cpp
@@ -0,0 +1,268 @@
+// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
+struct ST {
+  int *a;
+};
+typedef int arr[10];
+typedef ST STarr[10];
+struct SA {
+  const int d = 5;
+  const int da[5] = { 0 };
+  ST e;
+  ST g[10];
+  STarr  = g;
+  int i;
+  int  = i;
+  int *k = 
+  int * = k;
+  int aa[10];
+  arr  = aa;
+  void func(int arg) {
+#pragma omp target parallel is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
+{}
+#pragma omp target parallel is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+{}
+#pragma omp target parallel is_device_ptr() // expected-error {{expected expression}}
+{}
+#pragma omp target parallel is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+{}
+#pragma omp target parallel is_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+{}
+#pragma omp target parallel is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+{}
+#pragma omp target parallel is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+{}
+#pragma omp target parallel is_device_ptr(k) // OK
+{}
+#pragma omp target parallel is_device_ptr(z) // OK
+{}
+#pragma omp target parallel is_device_ptr(aa) // OK
+{}
+#pragma omp target parallel is_device_ptr(raa) // OK
+{}
+#pragma omp target parallel is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+{}
+#pragma omp target parallel is_device_ptr(g) // OK
+{}
+#pragma omp target parallel is_device_ptr(rg) // OK
+{}
+#pragma omp target parallel is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+{}
+#pragma omp target parallel is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+{}
+#pragma omp target parallel is_device_ptr(da) // OK
+{}
+  return;
+ }
+};
+struct SB {
+  unsigned A;
+  unsigned B;
+  float Arr[100];
+  float *Ptr;
+  float *foo() {
+return [0];
+  }
+};
+
+struct SC {
+  unsigned A : 2;
+  unsigned B : 3;
+  unsigned C;
+  unsigned D;
+  float Arr[100];
+  SB S;
+  SB ArrS[100];
+  SB *PtrS;
+  SB *
+  float *Ptr;
+
+  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
+};
+
+union SD {
+  unsigned A;
+  float B;
+};
+
+struct S1;
+extern S1 a;
+class S2 {
+  mutable int a;
+public:
+  S2():a(0) { }
+  S2(S2 ):a(s2.a) { }
+  static float S2s;
+  static const float S2sc;
+};
+const float S2::S2sc = 0;
+const S2 b;
+const S2 ba[5];
+class S3 {
+  int a;
+public:
+  S3():a(0) { }
+  S3(S3 ):a(s3.a) { }
+};
+const S3 c;
+const S3 ca[5];
+extern const int f;
+class S4 {
+  int a;
+  S4();
+  S4(const S4 );
+public:
+  S4(int v):a(v) { }
+};
+class S5 {
+  int a;
+  S5():a(0) {}
+  S5(const S5 ):a(s5.a) { }
+public:
+  S5(int v):a(v) { }
+};
+
+S3 h;
+#pragma omp threadprivate(h)
+
+typedef struct {
+  int a;
+} S6;
+
+template 
+T tmain(T argc) {
+  const T d = 5;
+  const T da[5] = { 0 };
+  S4 e(4);
+  S5 g(5);
+  S6 h[10];
+  auto  = h;
+  T i;
+  T  = i;
+  T *k = 
+  T * = k;
+  T aa[10];
+  auto  = aa;
+  S6 *ps;
+#pragma omp target parallel is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
+  {}
+#pragma omp target parallel is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
+  {}
+#pragma omp target parallel is_device_ptr() // expected-error {{expected expression}}
+  {}
+#pragma omp target parallel is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
+  {}
+#pragma omp target parallel is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
+  {}
+#pragma omp target parallel 

[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: docs/clang-tidy/checks/list.rst:68
misc-inefficient-algorithm
+   misc-invalid-range
misc-macro-parentheses

malcolm.parsons wrote:
> Prazek wrote:
> > malcolm.parsons wrote:
> > > misc.
> > > add_new_check.py can fix it.
> > How? I added new check with this script, but unfortunatelly rename_check 
> > doesn't move check from module to module, so I have to make all the changes 
> > by hand.
> add_new_check.py --update-docs
Didn't know about it, cool


https://reviews.llvm.org/D27806



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


[PATCH] D27812: [test] Extend llvm_shlib_dir fix to unittests

2016-12-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

Looks reasonable to me.


https://reviews.llvm.org/D27812



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: docs/clang-tidy/checks/list.rst:68
misc-inefficient-algorithm
+   misc-invalid-range
misc-macro-parentheses

Prazek wrote:
> malcolm.parsons wrote:
> > misc.
> > add_new_check.py can fix it.
> How? I added new check with this script, but unfortunatelly rename_check 
> doesn't move check from module to module, so I have to make all the changes 
> by hand.
add_new_check.py --update-docs


https://reviews.llvm.org/D27806



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


[PATCH] D27600: [analyzer] Refine the diagnostics in the nullability checker to differentiate between nil and null

2016-12-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good.

While you are here, you might consider changing: the checkBind() diagnostic to 
match the other diagnostics:

"Null assigned to a pointer which is expected to have non-null value" --> "Null 
assigned to a pointer which is expected to have *a* non-null value"


https://reviews.llvm.org/D27600



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


[PATCH] D27740: [analyzer] Include type name in Retain Count Checker diagnostics

2016-12-15 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D27740



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


[PATCH] D27796: Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments"

2016-12-15 Thread Mehdi AMINI via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289850: Fix printf specifier handling: invalid specifier 
should not be marked as… (authored by mehdi_amini).

Changed prior to commit:
  https://reviews.llvm.org/D27796?vs=81532=81621#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27796

Files:
  cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
  cfe/trunk/test/CodeGen/builtins.c
  cfe/trunk/test/Sema/format-strings.c
  cfe/trunk/test/SemaObjC/format-strings-objc.m


Index: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
===
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
@@ -211,6 +211,8 @@
 return false;
   case PercentArg:
 return false;
+  case InvalidSpecifier:
+return false;
   default:
 return true;
 }
Index: cfe/trunk/test/Sema/format-strings.c
===
--- cfe/trunk/test/Sema/format-strings.c
+++ cfe/trunk/test/Sema/format-strings.c
@@ -156,10 +156,10 @@
 
 void check_invalid_specifier(FILE* fp, char *buf)
 {
-  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion 
specifier 'b'}}
+  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion 
specifier 'b'}} expected-warning {{data argument not used by format string}}
   fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}}
   sprintf(buf,"%ld%d%d", 1, 2, 3); // expected-warning{{format specifies 
type 'long' but the argument has type 'int'}}
-  snprintf(buf, 2, "%ld%;%d", 1, 2, 3); // expected-warning{{format 
specifies type 'long' but the argument has type 'int'}} expected-warning 
{{invalid conversion specifier ';'}}
+  snprintf(buf, 2, "%ld%;%d", 1, 2, 3); // expected-warning{{format 
specifies type 'long' but the argument has type 'int'}} expected-warning 
{{invalid conversion specifier ';'}} expected-warning {{data argument not used 
by format string}}
 }
 
 void check_null_char_string(char* b)
@@ -251,7 +251,7 @@
   printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
   printf("%d%d\n", x); // expected-warning{{more '%' conversions than data 
arguments}}
   printf("%d\n", x, x); // expected-warning{{data argument not used by format 
string}}
-  printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 
'W'}}
+  printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 
'W'}}  expected-warning {{data argument not used by format string}}
   printf("%"); // expected-warning{{incomplete format specifier}}
   printf("%.d", x); // no-warning
   printf("%.", x);  // expected-warning{{incomplete format specifier}}
@@ -270,7 +270,7 @@
   printf("%.0Lf", (long double) 1.0); // no-warning
   printf("%c\n", "x"); // expected-warning{{format specifies type 'int' but 
the argument has type 'char *'}}
   printf("%c\n", 1.23); // expected-warning{{format specifies type 'int' but 
the argument has type 'double'}}
-  printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid 
conversion specifier '!'}}
+  printf("Format %d, is %! %f", 1, 4.4); // expected-warning{{invalid 
conversion specifier '!'}}
 }
 
 typedef unsigned char uint8_t;
Index: cfe/trunk/test/SemaObjC/format-strings-objc.m
===
--- cfe/trunk/test/SemaObjC/format-strings-objc.m
+++ cfe/trunk/test/SemaObjC/format-strings-objc.m
@@ -47,7 +47,7 @@
 
 void check_nslog(unsigned k) {
   NSLog(@"%d%%", k); // no-warning
-  NSLog(@"%s%lb%d", "unix", 10,20); // expected-warning {{invalid conversion 
specifier 'b'}}
+  NSLog(@"%s%lb%d", "unix", 10, 20); // expected-warning {{invalid conversion 
specifier 'b'}} expected-warning {{data argument not used by format string}}
 }
 
 // Check type validation
Index: cfe/trunk/test/CodeGen/builtins.c
===
--- cfe/trunk/test/CodeGen/builtins.c
+++ cfe/trunk/test/CodeGen/builtins.c
@@ -538,6 +538,34 @@
   __builtin_os_log_format(buf, "Hello %*.*s World", precision, width, data);
 }
 
+// CHECK-LABEL: define void @test_builtin_os_log_invalid
+// CHECK: (i8* [[BUF:%.*]], i32 [[DATA:%.*]])
+void test_builtin_os_log_invalid(void *buf, int data) {
+  volatile int len;
+  // CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
+  // CHECK: store i32 [[DATA]], i32* [[DATA_ADDR:%.*]]
+
+  // CHECK: store volatile i32 8,
+  len = __builtin_os_log_format_buffer_size("invalid specifier %: %d even a 
trailing one%", data);
+
+  // CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
+  // CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
+  // CHECK: store i8 0, i8* [[SUMMARY]]
+  // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
+  // CHECK: store i8 1, i8* [[NUM_ARGS]]
+
+  // CHECK: 

Re: [libcxx] r286789 - Add check-cxx-abilist target when supported.

2016-12-15 Thread Chris Bieneman via cfe-commits
(+Bogner, I think he originally added this)

My understanding is that we only did this copy step if you are building with a 
clang that isn't installed so that the non-installed clang could find these 
headers.

I'm pretty sure compiler-rt finds libcxx via the sources, not the build 
directory.

I'll put together a fix later today.

-Chris

> On Dec 14, 2016, at 11:49 PM, Eric Fiselier  wrote:
> 
>  
> Eric, this part of this change seems wrong to me. It causes the headers to be 
> installed into the libcxx build directory instead of the LLVM one. If you 
> build using the LLVM runtimes directory this puts the headers in the wrong 
> place for clang to find them.
> 
> Is there a reason you're copying them into the libcxx binary dir? I generally 
> don't think the headers are needed there.
> 
> 
> If it seems wrong for building in the LLVM runtimes directory then it 
> probably is. I don't think there is a good reason why we need to copy the 
> headers into the build directory, although we should double check compiler-rt 
> uses the headers from the source directory.
> 
> If you know how to fix this feel free to commit a patch. If not I'll look 
> into this more on Friday.
> 
> @Dan, @Jonathan: Do you guys use, or see a need for, this behavior?
> 

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


r289850 - Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments"

2016-12-15 Thread Mehdi Amini via cfe-commits
Author: mehdi_amini
Date: Thu Dec 15 12:54:00 2016
New Revision: 289850

URL: http://llvm.org/viewvc/llvm-project?rev=289850=rev
Log:
Fix printf specifier handling: invalid specifier should not be marked as 
"consuming data arguments"

Reviewers: rsmith, bruno, dexonsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
cfe/trunk/test/CodeGen/builtins.c
cfe/trunk/test/Sema/format-strings.c
cfe/trunk/test/SemaObjC/format-strings-objc.m

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=289850=289849=289850=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Thu Dec 15 
12:54:00 2016
@@ -211,6 +211,8 @@ public:
 return false;
   case PercentArg:
 return false;
+  case InvalidSpecifier:
+return false;
   default:
 return true;
 }

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=289850=289849=289850=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Thu Dec 15 12:54:00 2016
@@ -538,6 +538,34 @@ void test_builtin_os_log_precision_width
   __builtin_os_log_format(buf, "Hello %*.*s World", precision, width, data);
 }
 
+// CHECK-LABEL: define void @test_builtin_os_log_invalid
+// CHECK: (i8* [[BUF:%.*]], i32 [[DATA:%.*]])
+void test_builtin_os_log_invalid(void *buf, int data) {
+  volatile int len;
+  // CHECK: store i8* [[BUF]], i8** [[BUF_ADDR:%.*]], align 8
+  // CHECK: store i32 [[DATA]], i32* [[DATA_ADDR:%.*]]
+
+  // CHECK: store volatile i32 8,
+  len = __builtin_os_log_format_buffer_size("invalid specifier %: %d even a 
trailing one%", data);
+
+  // CHECK: [[BUF2:%.*]] = load i8*, i8** [[BUF_ADDR]]
+  // CHECK: [[SUMMARY:%.*]] = getelementptr i8, i8* [[BUF2]], i64 0
+  // CHECK: store i8 0, i8* [[SUMMARY]]
+  // CHECK: [[NUM_ARGS:%.*]] = getelementptr i8, i8* [[BUF2]], i64 1
+  // CHECK: store i8 1, i8* [[NUM_ARGS]]
+
+  // CHECK: [[ARG1_DESC:%.*]] = getelementptr i8, i8* [[BUF2]], i64 2
+  // CHECK: store i8 0, i8* [[ARG1_DESC]]
+  // CHECK: [[ARG1_SIZE:%.*]] = getelementptr i8, i8* [[BUF2]], i64 3
+  // CHECK: store i8 4, i8* [[ARG1_SIZE]]
+  // CHECK: [[ARG1:%.*]] = getelementptr i8, i8* [[BUF2]], i64 4
+  // CHECK: [[ARG1_INT:%.*]] = bitcast i8* [[ARG1]] to i32*
+  // CHECK: [[ARG1_VAL:%.*]] = load i32, i32* [[DATA_ADDR]]
+  // CHECK: store i32 [[ARG1_VAL]], i32* [[ARG1_INT]]
+
+  __builtin_os_log_format(buf, "invalid specifier %: %d even a trailing one%", 
data);
+}
+
 // CHECK-LABEL: define void @test_builtin_os_log_percent
 // CHECK: (i8* [[BUF:%.*]], i8* [[DATA1:%.*]], i8* [[DATA2:%.*]])
 // Check that the %% which does not consume any argument is correctly handled

Modified: cfe/trunk/test/Sema/format-strings.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=289850=289849=289850=diff
==
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Thu Dec 15 12:54:00 2016
@@ -156,10 +156,10 @@ void check_writeback_specifier()
 
 void check_invalid_specifier(FILE* fp, char *buf)
 {
-  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion 
specifier 'b'}}
+  printf("%s%lb%d","unix",10,20); // expected-warning {{invalid conversion 
specifier 'b'}} expected-warning {{data argument not used by format string}}
   fprintf(fp,"%%%l"); // expected-warning {{incomplete format specifier}}
   sprintf(buf,"%ld%d%d", 1, 2, 3); // expected-warning{{format specifies 
type 'long' but the argument has type 'int'}}
-  snprintf(buf, 2, "%ld%;%d", 1, 2, 3); // expected-warning{{format 
specifies type 'long' but the argument has type 'int'}} expected-warning 
{{invalid conversion specifier ';'}}
+  snprintf(buf, 2, "%ld%;%d", 1, 2, 3); // expected-warning{{format 
specifies type 'long' but the argument has type 'int'}} expected-warning 
{{invalid conversion specifier ';'}} expected-warning {{data argument not used 
by format string}}
 }
 
 void check_null_char_string(char* b)
@@ -251,7 +251,7 @@ void test10(int x, float f, int i, long
   printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}}
   printf("%d%d\n", x); // expected-warning{{more '%' conversions than data 
arguments}}
   printf("%d\n", x, x); // expected-warning{{data argument not used by format 
string}}
-  printf("%W%d\n", x, x); // expected-warning{{invalid conversion specifier 
'W'}}
+  printf("%W%d\n", x, x); // 

[PATCH] D27796: Fix printf specifier handling: invalid specifier should not be marked as "consuming data arguments"

2016-12-15 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno accepted this revision.
bruno added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D27796



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


Re: [clang-tools-extra] r289656 - modernize-use-auto NFC fixes

2016-12-15 Thread Piotr Padlewski via cfe-commits
Sure, I am planning to do so. I just wanted to firstly make all auto's and
the change was small enough that I though you would not mind pushing it
without review.
BTW the same thing in clang needs review: https://reviews.llvm.org/D27767

2016-12-15 17:08 GMT+01:00 Alexander Kornienko :

> For most loop changes here applying modernize-loop-convert would be better
> ;)
>
> On Wed, Dec 14, 2016 at 4:29 PM, Piotr Padlewski via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: prazek
>> Date: Wed Dec 14 09:29:23 2016
>> New Revision: 289656
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=289656=rev
>> Log:
>> modernize-use-auto NFC fixes
>>
>> Modified:
>> clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
>> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling
>> /ApplyReplacements.cpp
>> clang-tools-extra/trunk/clang-query/Query.cpp
>> clang-tools-extra/trunk/clang-query/QueryParser.cpp
>> clang-tools-extra/trunk/clang-query/tool/ClangQuery.cpp
>> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProType
>> MemberInitCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/Special
>> MemberFunctionsCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/google/ExplicitConstructo
>> rCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/google/NonConstReferences.cpp
>> clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/misc/ArgumentCommentCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/misc/MoveForwardingRefere
>> nceCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMac
>> roCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByR
>> eferenceCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/UseNullptrCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolC
>> astCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/readability/NamespaceComm
>> entCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/readability/RedundantDecl
>> arationCheck.cpp
>> clang-tools-extra/trunk/clang-tidy/readability/RedundantSmar
>> tptrGetCheck.cpp
>> clang-tools-extra/trunk/include-fixer/find-all-symbols/
>> FindAllSymbols.cpp
>> clang-tools-extra/trunk/modularize/CoverageChecker.cpp
>> clang-tools-extra/trunk/modularize/Modularize.cpp
>> clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
>> clang-tools-extra/trunk/modularize/ModuleAssistant.cpp
>> clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
>> clang-tools-extra/trunk/pp-trace/PPTrace.cpp
>> clang-tools-extra/trunk/unittests/clang-tidy/ClangTidyDiagno
>> sticConsumerTest.cpp
>> clang-tools-extra/trunk/unittests/clang-tidy/NamespaceAliaserTest.cpp
>> clang-tools-extra/trunk/unittests/clang-tidy/UsingInserterTest.cpp
>>
>> Modified: clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> change-namespace/ChangeNamespace.cpp?rev=289656=289655&
>> r2=289656=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp
>> (original)
>> +++ clang-tools-extra/trunk/change-namespace/ChangeNamespace.cpp Wed Dec
>> 14 09:29:23 2016
>> @@ -709,7 +709,7 @@ void ChangeNamespaceTool::fixTypeLoc(
>>return;
>>}
>>
>> -  const Decl *DeclCtx = Result.Nodes.getNodeAs("dc");
>> +  const auto *DeclCtx = Result.Nodes.getNodeAs("dc");
>>assert(DeclCtx && "Empty decl context.");
>>replaceQualifiedSymbolInDeclContext(Result,
>> DeclCtx->getDeclContext(), Start,
>>End, FromDecl);
>>
>> Modified: clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling
>> /ApplyReplacements.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp?
>> rev=289656=289655=289656=diff
>> 
>> ==
>> --- 
>> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
>> (original)
>> +++ 
>> clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
>> Wed Dec 14 09:29:23 2016
>> @@ -124,9 +124,7 @@ static void reportConflict(
>>  bool applyAllReplacements(const std::vector
>> ,
>>Rewriter ) {
>>bool Result = true;
>> -  for (std::vector::const_iterator I =
>> Replaces.begin(),
>> - E =
>> Replaces.end();
>> -   I != E; ++I) {
>> +  for (auto I = Replaces.begin(), E = Replaces.end(); I != E; ++I) {
>>  if (I->isApplicable()) {
>>Result = I->apply(Rewrite) && Result;
>>  } 

[PATCH] D27788: [CUDA] Add --ptxas-path= flag.

2016-12-15 Thread Justin Lebar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289847: [CUDA] Add --ptxas-path= flag. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D27788?vs=81501=81620#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27788

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/Tools.cpp
  cfe/trunk/test/Driver/cuda-ptxas-path.cu


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -425,6 +425,8 @@
 def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
+def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
+  HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,
   Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero 
in CUDA device mode.">;
 def fno_cuda_flush_denormals_to_zero : Flag<["-"], 
"fno-cuda-flush-denormals-to-zero">;
Index: cfe/trunk/test/Driver/cuda-ptxas-path.cu
===
--- cfe/trunk/test/Driver/cuda-ptxas-path.cu
+++ cfe/trunk/test/Driver/cuda-ptxas-path.cu
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### --target=i386-unknown-linux \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   --ptxas-path=/some/path/to/ptxas %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK-NOT: "ptxas"
+// CHECK: "/some/path/to/ptxas"
+// CHECK-SAME: "--gpu-name" "sm_20"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -12105,7 +12105,11 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
+  const char *Exec;
+  if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
+Exec = A->getValue();
+  else
+Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -425,6 +425,8 @@
 def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
+def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
+  HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], "fcuda-flush-denormals-to-zero">,
   Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero in CUDA device mode.">;
 def fno_cuda_flush_denormals_to_zero : Flag<["-"], "fno-cuda-flush-denormals-to-zero">;
Index: cfe/trunk/test/Driver/cuda-ptxas-path.cu
===
--- cfe/trunk/test/Driver/cuda-ptxas-path.cu
+++ cfe/trunk/test/Driver/cuda-ptxas-path.cu
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### --target=i386-unknown-linux \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   --ptxas-path=/some/path/to/ptxas %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK-NOT: "ptxas"
+// CHECK: "/some/path/to/ptxas"
+// CHECK-SAME: "--gpu-name" "sm_20"
Index: cfe/trunk/lib/Driver/Tools.cpp
===
--- cfe/trunk/lib/Driver/Tools.cpp
+++ cfe/trunk/lib/Driver/Tools.cpp
@@ -12105,7 +12105,11 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
+  const char *Exec;
+  if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
+Exec = A->getValue();
+  else
+Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289847 - [CUDA] Add --ptxas-path= flag.

2016-12-15 Thread Justin Lebar via cfe-commits
Author: jlebar
Date: Thu Dec 15 12:44:57 2016
New Revision: 289847

URL: http://llvm.org/viewvc/llvm-project?rev=289847=rev
Log:
[CUDA] Add --ptxas-path= flag.

Summary:
This lets you build with one CUDA installation but use ptxas from
another install.

This is useful e.g. if you want to avoid bugs in an old ptxas without
actually upgrading wholesale to a newer CUDA version.

Reviewers: tra

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/Driver/cuda-ptxas-path.cu
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=289847=289846=289847=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Dec 15 12:44:57 2016
@@ -425,6 +425,8 @@ def no_cuda_version_check : Flag<["--"],
 def no_cuda_noopt_device_debug : Flag<["--"], "no-cuda-noopt-device-debug">;
 def cuda_path_EQ : Joined<["--"], "cuda-path=">, Group,
   HelpText<"CUDA installation path">;
+def ptxas_path_EQ : Joined<["--"], "ptxas-path=">, Group,
+  HelpText<"Path to ptxas (used for compiling CUDA code)">;
 def fcuda_flush_denormals_to_zero : Flag<["-"], 
"fcuda-flush-denormals-to-zero">,
   Flags<[CC1Option]>, HelpText<"Flush denormal floating point values to zero 
in CUDA device mode.">;
 def fno_cuda_flush_denormals_to_zero : Flag<["-"], 
"fno-cuda-flush-denormals-to-zero">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=289847=289846=289847=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec 15 12:44:57 2016
@@ -12105,7 +12105,11 @@ void NVPTX::Assembler::ConstructJob(Comp
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
-  const char *Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
+  const char *Exec;
+  if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
+Exec = A->getValue();
+  else
+Exec = Args.MakeArgString(TC.GetProgramPath("ptxas"));
   C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 

Added: cfe/trunk/test/Driver/cuda-ptxas-path.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-ptxas-path.cu?rev=289847=auto
==
--- cfe/trunk/test/Driver/cuda-ptxas-path.cu (added)
+++ cfe/trunk/test/Driver/cuda-ptxas-path.cu Thu Dec 15 12:44:57 2016
@@ -0,0 +1,12 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+
+// RUN: %clang -### --target=i386-unknown-linux \
+// RUN:   --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda \
+// RUN:   --ptxas-path=/some/path/to/ptxas %s 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK-NOT: "ptxas"
+// CHECK: "/some/path/to/ptxas"
+// CHECK-SAME: "--gpu-name" "sm_20"


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


[PATCH] D27813: [clang-tidy] fix missing anchor for MPI Module

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D27813#623978, @Alexander_Droste wrote:

> Thanks for adding!


I also forgot about that one once. It is simple bugfix so I guess I need small 
LGTM to push it


https://reviews.llvm.org/D27813



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


[PATCH] D27794: Make some diagnostic tests C++11 clean

2016-12-15 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a reviewer: ABataev.
probinson added a comment.

+abataev for OpenMP.


https://reviews.llvm.org/D27794



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Also please review https://reviews.llvm.org/D27815 to make it happen


https://reviews.llvm.org/D27806



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


[PATCH] D27813: [clang-tidy] fix missing anchor for MPI Module

2016-12-15 Thread Alexander Droste via Phabricator via cfe-commits
Alexander_Droste added a comment.

Thanks for adding!


https://reviews.llvm.org/D27813



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 81617.
Prazek marked an inline comment as done.
Prazek added a comment.

- Small fixes


https://reviews.llvm.org/D27806

Files:
  clang-tidy/obvious/CMakeLists.txt
  clang-tidy/obvious/InvalidRangeCheck.cpp
  clang-tidy/obvious/InvalidRangeCheck.h
  clang-tidy/obvious/ObviousTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/obvious-invalid-range.rst
  test/clang-tidy/obvious-invalid-range.cpp

Index: test/clang-tidy/obvious-invalid-range.cpp
===
--- /dev/null
+++ test/clang-tidy/obvious-invalid-range.cpp
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s obvious-invalid-range %t
+
+namespace std {
+
+template 
+OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result) {
+  return result;
+}
+
+template 
+OutputIterator move(InputIterator first, InputIterator last, OutputIterator result) {
+  return result;
+}
+
+template 
+T move(T &&) { return T(); }
+
+template 
+void fill(InputIterator first, InputIterator last, const Val ) {
+}
+
+template 
+class vector {
+public:
+  T *begin();
+  T *end();
+};
+}
+
+void test_copy() {
+  std::vector v, v2;
+  std::copy(v.begin(), v2.end(), v2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: call to algorithm with begin and end from different objects [obvious-invalid-range]
+
+  std::copy(v.begin(), v.end(), v2.begin());
+}
+
+void test_move() {
+  std::vector v;
+  auto  = v;
+  std::move(v.begin(), v2.end(), v2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: call to algorithm with begin and end from different objects
+
+  std::move(v.begin(), v.end(), v2.begin());
+  std::move(v.begin());
+  test_copy();
+}
Index: docs/clang-tidy/checks/obvious-invalid-range.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/obvious-invalid-range.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - obvious-invalid-range
+
+obvious-invalid-range
+=
+
+This check finds invalid calls to algorithms with obviously invalid range of
+iterators like:
+
+.. code-block:: c++
+std::fill(v.begin(), v2.end(), it);
+
+It checks if first and second argument of call is method call to ``begin()``
+and ``end()``, but on different objects (having different name).
+
+By default it looks for all algorithms from . This can be
+changed by using ``AlgorithmNames`` option, where empty list means that any
+function name will be accepted.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -118,6 +118,7 @@
modernize-use-using
mpi-buffer-deref
mpi-type-mismatch
+   obvious-invalid-range
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -114,6 +114,15 @@
 
   Flags MPI function calls with a buffer type and MPI data type mismatch.
 
+- New obvious module with checks for obvious bugs that probably won't be found
+  in working code, but can be found while looking for an obvious bug in broken
+  code.
+- New `obvious-invalid-range
+  `_ check
+
+  Warns if algorithm is used with ``.begin()`` and ``.end()`` from different
+  container.
+
 - New `performance-inefficient-string-concatenation
   `_ check
 
Index: clang-tidy/obvious/ObviousTidyModule.cpp
===
--- clang-tidy/obvious/ObviousTidyModule.cpp
+++ clang-tidy/obvious/ObviousTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 
+#include "InvalidRangeCheck.h"
 using namespace clang::ast_matchers;
 
 namespace clang {
@@ -20,7 +21,7 @@
 class ObviousModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
-// Add obvious checks here.
+CheckFactories.registerCheck("obvious-invalid-range");
   }
 };
 
Index: clang-tidy/obvious/InvalidRangeCheck.h
===
--- /dev/null
+++ clang-tidy/obvious/InvalidRangeCheck.h
@@ -0,0 +1,40 @@
+//===--- InvalidRangeCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBVIOUS_INVALID_RANGE_H
+#define 

[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tidy/misc/InvalidRangeCheck.cpp:78
+void InvalidRangeCheck::check(const MatchFinder::MatchResult ) {
+
+  const auto *FirstArg = Result.Nodes.getNodeAs("first_arg");

Please remove empty line.



Comment at: docs/ReleaseNotes.rst:88
+  Warns if algorithm is used with ``.begin()`` and ``.end()`` from different
+  variables.
+

Probably container will be better word. Same for documentation.



Comment at: test/clang-tidy/misc-invalid-range.cpp:28
+};
+}
+

Please add closing namespace comment and empty line bfore.


https://reviews.llvm.org/D27806



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: docs/clang-tidy/checks/list.rst:68
misc-inefficient-algorithm
+   misc-invalid-range
misc-macro-parentheses

malcolm.parsons wrote:
> misc.
> add_new_check.py can fix it.
How? I added new check with this script, but unfortunatelly rename_check 
doesn't move check from module to module, so I have to make all the changes by 
hand.


https://reviews.llvm.org/D27806



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


[PATCH] D24487: [Clang] Fix some Clang-tidy modernize-use-bool-literals and Include What You Use warnings in AST; other minor fixes

2016-12-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: lib/ASTMatchers/Dynamic/Parser.cpp:617
 
-}  // namespace dynamic
-}  // namespace ast_matchers
-}  // namespace clang
+} // end namespace dynamic
+} // end namespace ast_matchers

Prazek wrote:
> I think check should not warn in these cases.
I think it's reasonable to unify such comments. Three different styles are too 
much for one project :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D24487



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


r289839 - [Driver] Bump default x86 cpu to Penryn when targeting macosx10.12+.

2016-12-15 Thread Ahmed Bougacha via cfe-commits
Author: ab
Date: Thu Dec 15 12:14:27 2016
New Revision: 289839

URL: http://llvm.org/viewvc/llvm-project?rev=289839=rev
Log:
[Driver] Bump default x86 cpu to Penryn when targeting macosx10.12+.

10.12 dropped support for all pre-Penryn Macs.

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/clang-translation.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=289839=289838=289839=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Dec 15 12:14:27 2016
@@ -2015,6 +2015,11 @@ static const char *getX86TargetCPU(const
   if (Triple.isOSDarwin()) {
 if (Triple.getArchName() == "x86_64h")
   return "core-avx2";
+// macosx10.12 drops support for all pre-Penryn Macs.
+// Simulators can still run on 10.11 though, like Xcode.
+if (Triple.isMacOSX() && !Triple.isOSVersionLT(10, 12))
+  return "penryn";
+// The oldest x86_64 Macs have core2/Merom; the oldest x86 Macs have Yonah.
 return Is64Bit ? "core2" : "yonah";
   }
 

Modified: cfe/trunk/test/Driver/clang-translation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=289839=289838=289839=diff
==
--- cfe/trunk/test/Driver/clang-translation.c (original)
+++ cfe/trunk/test/Driver/clang-translation.c Thu Dec 15 12:14:27 2016
@@ -11,19 +11,36 @@
 // I386: "hidden"
 // I386: "-o"
 // I386: clang-translation
+
 // RUN: %clang -target i386-apple-darwin9 -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=YONAH %s
+// RUN: %clang -target i386-apple-macosx10.11 -### -S %s -o %t.s 2>&1 | \
+// RUN: FileCheck -check-prefix=YONAH %s
 // YONAH: "-target-cpu"
 // YONAH: "yonah"
+
 // RUN: %clang -target x86_64-apple-darwin9 -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=CORE2 %s
+// RUN: %clang -target x86_64-apple-macosx10.11 -### -S %s -o %t.s 2>&1 | \
+// RUN: FileCheck -check-prefix=CORE2 %s
 // CORE2: "-target-cpu"
 // CORE2: "core2"
+
 // RUN: %clang -target x86_64h-apple-darwin -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=AVX2 %s
+// RUN: %clang -target x86_64h-apple-macosx10.12 -### -S %s -o %t.s 2>&1 | \
+// RUN: FileCheck -check-prefix=AVX2 %s
 // AVX2: "-target-cpu"
 // AVX2: "core-avx2"
 
+// RUN: %clang -target i386-apple-macosx10.12 -### -S %s -o %t.s 2>&1 | \
+// RUN: FileCheck -check-prefix=PENRYN %s
+// RUN: %clang -target x86_64-apple-macosx10.12 -### -S %s -o %t.s 2>&1 | \
+// RUN: FileCheck -check-prefix=PENRYN %s
+// PENRYN: "-target-cpu"
+// PENRYN: "penryn"
+
+
 // RUN: %clang -target x86_64-apple-darwin10 -### -S %s -arch armv7 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMV7_DEFAULT %s
 // ARMV7_DEFAULT: clang


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


[PATCH] D27753: [analyzer] alpha.security.DirtyScalar Checker

2016-12-15 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

> Did you checked if same warnings may be emitted by another checkers? For 
> example, 
>  ArrayBoundChecker may warn if index is tainted.

I second that. The GenericTaintChecker also reports uses of tainted values. It 
is not clear that we should add a new separate checker instead of adding the 
missing cases to the existing checkers.

Thank you!
Anna.


https://reviews.llvm.org/D27753



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


[PATCH] D27210: [clang-tidy] misc-string-compare. Adding a new check to clang-tidy

2016-12-15 Thread Mads Ravn via Phabricator via cfe-commits
madsravn updated this revision to Diff 81610.
madsravn added a comment.

Updated the matcher to find suggested occurences.


https://reviews.llvm.org/D27210

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringCompareCheck.cpp
  clang-tidy/misc/StringCompareCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-compare.rst
  test/clang-tidy/misc-string-compare.cpp

Index: test/clang-tidy/misc-string-compare.cpp
===
--- test/clang-tidy/misc-string-compare.cpp
+++ test/clang-tidy/misc-string-compare.cpp
@@ -0,0 +1,111 @@
+// RUN: %check_clang_tidy %s misc-string-compare %t -- -- -std=c++11
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+class basic_string {
+public:
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  int compare(const basic_string ) const;
+  int compare(const C *) const;
+  int compare(int, int, const basic_string ) const;
+  bool empty();
+};
+bool operator==(const basic_string , const basic_string );
+bool operator!=(const basic_string , const basic_string );
+bool operator==(const basic_string , const char *);
+typedef basic_string string;
+}
+
+void func(bool b);
+
+std::string comp() {
+  std::string str("a", 1);
+  return str;
+}
+
+void Test() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+
+  if (str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings; use the string equality operator instead [misc-string-compare]
+  if (!str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:8: warning: do not use 'compare' to test equality of strings; use the string equality operator instead [misc-string-compare]
+  if (str1.compare(str2) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str1 == str2) {
+  if (str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str1 != str2) {
+  if (str1.compare("foo") == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str1 == "foo") {
+  if (0 == str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str2 == str1) {
+  if (0 != str1.compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str2 != str1) {
+  func(str1.compare(str2));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: do not use 'compare' to test equality of strings;
+  if (str2.empty() || str1.compare(str2) != 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:23: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str2.empty() || str1 != str2) {
+  std::string *str3 = 
+  if (str3->compare(str2)) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  if (str3->compare(str2) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (*str3 == str2) {
+  if (str2.compare(*str3) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str2 == *str3) {
+  if (comp().compare(str1) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (comp() == str1) {
+  if (str1.compare(comp()) == 0) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+  // CHECK-FIXES: if (str1 == comp()) {
+  if (str1.compare(comp())) {
+  }
+  // CHECK-MESSAGES: [[@LINE-2]]:7: warning: do not use 'compare' to test equality of strings;
+}
+
+void Valid() {
+  std::string str1("a", 1);
+  std::string str2("b", 1);
+  if (str1 == str2) {
+  }
+  if (str1 != str2) {
+  }
+  if (str1.compare(str2) == 1) {
+  }
+  if (str1.compare(str2) == str1.compare(str2)) {
+  }
+  if (0 == 0) {
+  }
+  if (1 == str1.compare(str2)) {
+  }
+  if (str1.compare(str2) > 0) {
+  }
+  if (str1.compare(1, 3, str2)) {
+  }
+}
Index: docs/clang-tidy/checks/misc-string-compare.rst
===
--- docs/clang-tidy/checks/misc-string-compare.rst
+++ docs/clang-tidy/checks/misc-string-compare.rst
@@ -0,0 +1,54 @@
+.. title:: clang-tidy - misc-string-compare
+
+misc-string-compare
+===
+
+Finds string comparisons using the compare method.
+
+A common mistake is to use the string's ``compare`` method instead of using the 
+equality or inequality operators. The compare method is intended 

[PATCH] D25435: Add -femit-accurate-debug-info to emit more debug info for sample pgo profile collection

2016-12-15 Thread Dehao Chen via Phabricator via cfe-commits
danielcdh updated this revision to Diff 81609.
danielcdh added a comment.

update option name


https://reviews.llvm.org/D25435

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/clang_f_opts.c


Index: test/Driver/clang_f_opts.c
===
--- test/Driver/clang_f_opts.c
+++ test/Driver/clang_f_opts.c
@@ -469,3 +469,8 @@
 // CHECK-WCHAR2: -fshort-wchar
 // CHECK-WCHAR2-NOT: -fno-short-wchar
 // DELIMITERS: {{^ *"}}
+
+// RUN: %clang -### -S -fno-debug-info-for-profiling 
-fdebug-info-for-profiling %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-DEBUG %s
+// RUN: %clang -### -S -fdebug-info-for-profiling 
-fno-debug-info-for-profiling %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-PROFILE-DEBUG %s
+// CHECK-PROFILE-DEBUG: -fdebug-info-for-profiling
+// CHECK-NO-PROFILE-DEBUG-NOT: -fdebug-info-for-profiling
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -538,6 +538,8 @@
   Opts.DisableIntegratedAS = Args.hasArg(OPT_fno_integrated_as);
   Opts.Autolink = !Args.hasArg(OPT_fno_autolink);
   Opts.SampleProfileFile = Args.getLastArgValue(OPT_fprofile_sample_use_EQ);
+  Opts.DebugInfoForProfiling = Args.hasFlag(
+  OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
 
   setPGOInstrumentor(Opts, Args, Diags);
   Opts.InstrProfileOutput =
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5565,6 +5565,10 @@
   A->render(Args, CmdArgs);
   }
 
+  if (Args.hasFlag(options::OPT_fdebug_info_for_profiling,
+   options::OPT_fno_debug_info_for_profiling, false))
+CmdArgs.push_back("-fdebug-info-for-profiling");
+
   // -fbuiltin is default unless -mkernel is used.
   bool UseBuiltins =
   Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2741,9 +2741,10 @@
   }
   // No need to replicate the linkage name if it isn't different from the
   // subprogram name, no need to have it at all unless coverage is enabled or
-  // debug is set to more than just line tables.
+  // debug is set to more than just line tables or extra debug info is needed.
   if (LinkageName == Name || (!CGM.getCodeGenOpts().EmitGcovArcs &&
   !CGM.getCodeGenOpts().EmitGcovNotes &&
+  !CGM.getCodeGenOpts().DebugInfoForProfiling &&
   DebugKind <= 
codegenoptions::DebugLineTablesOnly))
 LinkageName = StringRef();
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -575,6 +575,7 @@
   Options.DisableIntegratedAS = CodeGenOpts.DisableIntegratedAS;
   Options.CompressDebugSections = CodeGenOpts.CompressDebugSections;
   Options.RelaxELFRelocations = CodeGenOpts.RelaxELFRelocations;
+  Options.DebugInfoForProfiling = CodeGenOpts.DebugInfoForProfiling;
 
   // Set EABI version.
   Options.EABIVersion = llvm::StringSwitch(TargetOpts.EABIVersion)
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -255,6 +255,9 @@
 /// Whether copy relocations support is available when building as PIE.
 CODEGENOPT(PIECopyRelocations, 1, 0)
 
+/// Whether emit extra debug info for sample pgo profile collection.
+CODEGENOPT(DebugInfoForProfiling, 1, 0)
+
 #undef CODEGENOPT
 #undef ENUM_CODEGENOPT
 #undef VALUE_CODEGENOPT
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -514,6 +514,12 @@
 HelpText<"Enable sample-based profile guided optimizations">;
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
+def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">, 
Group,
+Flags<[CC1Option]>,
+HelpText<"Emit extra debug info to make sample profile more accurate.">;
+def fno_debug_info_for_profiling : Flag<["-"], 
"fno-debug-info-for-profiling">, Group,
+Flags<[DriverOption]>,
+HelpText<"Do not emit extra debug info for sample profiler.">;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
 Group, Flags<[CoreOption]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw file (overriden by 

r289836 - Fix typo in comment. NFC.

2016-12-15 Thread Kelvin Li via cfe-commits
Author: kli
Date: Thu Dec 15 11:55:32 2016
New Revision: 289836

URL: http://llvm.org/viewvc/llvm-project?rev=289836=rev
Log:
Fix typo in comment.  NFC.

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=289836=289835=289836=diff
==
--- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Thu Dec 15 11:55:32 2016
@@ -3439,7 +3439,7 @@ static void emitCommonOMPTeamsDirective(
 }
 
 void CodeGenFunction::EmitOMPTeamsDirective(const OMPTeamsDirective ) {
-  // Emit parallel region as a standalone region.
+  // Emit teams region as a standalone region.
   auto & = [](CodeGenFunction , PrePostActionTy &) {
 OMPPrivateScope PrivateScope(CGF);
 (void)CGF.EmitOMPFirstprivateClause(S, PrivateScope);


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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: docs/clang-tidy/checks/list.rst:68
misc-inefficient-algorithm
+   misc-invalid-range
misc-macro-parentheses

misc.
add_new_check.py can fix it.


https://reviews.llvm.org/D27806



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


[PATCH] D27163: Introduce -f[no-]strict-return flag that controls code generation for C++'s undefined behaviour return optimisation

2016-12-15 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

(Wait a little in case @Quuxplusone still has comments.)


Repository:
  rL LLVM

https://reviews.llvm.org/D27163



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added inline comments.



Comment at: test/clang-tidy/misc-invalid-range.cpp:41
+  auto  = v;
+  std::move(v.begin(), v2.end(), v2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: call to algorithm with begin 
and end from different objects [misc-invalid-range]

malcolm.parsons wrote:
> They're the same object...
Yep, but this type of code stinks, so it is probably a bug


https://reviews.llvm.org/D27806



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


[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 81606.
Prazek added a comment.

- Small fixes


https://reviews.llvm.org/D27806

Files:
  clang-tidy/obvious/CMakeLists.txt
  clang-tidy/obvious/InvalidRangeCheck.cpp
  clang-tidy/obvious/InvalidRangeCheck.h
  clang-tidy/obvious/ObviousTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/obvious-invalid-range.rst
  test/clang-tidy/obvious-invalid-range.cpp

Index: test/clang-tidy/obvious-invalid-range.cpp
===
--- /dev/null
+++ test/clang-tidy/obvious-invalid-range.cpp
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s obvious-invalid-range %t
+
+namespace std {
+
+template 
+OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result) {
+  return result;
+}
+
+template 
+OutputIterator move(InputIterator first, InputIterator last, OutputIterator result) {
+  return result;
+}
+
+template 
+T move(T &&) { return T(); }
+
+template 
+void fill(InputIterator first, InputIterator last, const Val ) {
+}
+
+template 
+class vector {
+public:
+  T *begin();
+  T *end();
+};
+}
+
+void test_copy() {
+  std::vector v, v2;
+  std::copy(v.begin(), v2.end(), v2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: call to algorithm with begin and end from different objects [obvious-invalid-range]
+
+  std::copy(v.begin(), v.end(), v2.begin());
+}
+
+void test_move() {
+  std::vector v;
+  auto  = v;
+  std::move(v.begin(), v2.end(), v2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: call to algorithm with begin and end from different objects
+
+  std::move(v.begin(), v.end(), v2.begin());
+  std::move(v.begin());
+  test_copy();
+}
Index: docs/clang-tidy/checks/obvious-invalid-range.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/obvious-invalid-range.rst
@@ -0,0 +1,17 @@
+.. title:: clang-tidy - obvious-invalid-range
+
+obvious-invalid-range
+=
+
+This check finds invalid calls to algorithms with obviously invalid range of
+iterators like:
+
+.. code-block:: c++
+std::fill(v.begin(), v2.end(), it);
+
+It checks if first and second argument of call is call to ``begin()``
+and ``end()``, but on different objects (having different name).
+
+By default it looks for all algorithms from . This can be
+changed by using ``AlgorithmNames`` option, where empty list means that any
+function name will be accepted.
\ No newline at end of file
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -65,6 +65,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-invalid-range
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -114,6 +114,15 @@
 
   Flags MPI function calls with a buffer type and MPI data type mismatch.
 
+- New obvious module with checks for obvious bugs that probably won't be found
+  in working code, but can be found while looking for an obvious bug in broken
+  code.
+- New `obvious-invalid-range
+  `_ check
+
+  Warns if algorithm is used with ``.begin()`` and ``.end()`` from different
+  variables.
+
 - New `performance-inefficient-string-concatenation
   `_ check
 
Index: clang-tidy/obvious/ObviousTidyModule.cpp
===
--- clang-tidy/obvious/ObviousTidyModule.cpp
+++ clang-tidy/obvious/ObviousTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 
+#include "InvalidRangeCheck.h"
 using namespace clang::ast_matchers;
 
 namespace clang {
@@ -20,7 +21,7 @@
 class ObviousModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories ) override {
-// Add obvious checks here.
+CheckFactories.registerCheck("obvious-invalid-range");
   }
 };
 
Index: clang-tidy/obvious/InvalidRangeCheck.h
===
--- /dev/null
+++ clang-tidy/obvious/InvalidRangeCheck.h
@@ -0,0 +1,40 @@
+//===--- InvalidRangeCheck.h - clang-tidy*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBVIOUS_INVALID_RANGE_H
+#define 

[PATCH] D27806: [clang-tidy] Add obvious-invalid-range

2016-12-15 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: test/clang-tidy/misc-invalid-range.cpp:41
+  auto  = v;
+  std::move(v.begin(), v2.end(), v2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: call to algorithm with begin 
and end from different objects [misc-invalid-range]

They're the same object...


https://reviews.llvm.org/D27806



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


[PATCH] D27621: [clang-tidy] check to find declarations declaring more than one name

2016-12-15 Thread Firat Kasmis via Phabricator via cfe-commits
firolino updated this revision to Diff 81605.
firolino added a comment.

Added fix and test case for `const int * const`.


https://reviews.llvm.org/D27621

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OneNamePerDeclarationCheck.cpp
  clang-tidy/readability/OneNamePerDeclarationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-one-name-per-declaration.rst
  test/clang-tidy/readability-one-name-per-declaration-complex.cpp
  test/clang-tidy/readability-one-name-per-declaration-modern.cpp
  test/clang-tidy/readability-one-name-per-declaration-simple.cpp

Index: test/clang-tidy/readability-one-name-per-declaration-simple.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-one-name-per-declaration-simple.cpp
@@ -0,0 +1,142 @@
+// RUN: %check_clang_tidy %s readability-one-name-per-declaration %t
+
+int cantTouchA, cantTouchB;
+
+void simple() 
+{
+int dontTouchC;
+
+long empty;
+long long1 = 11, *long2 = , * long3 = 
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long1 = 11;
+// CHECK-FIXES: {{^}}long *long2 = 
+// CHECK-FIXES: {{^}}long * long3 = 
+
+long ** lint1, lint2 = 0, * lint3, **linn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long ** lint1;
+// CHECK-FIXES: {{^}}long lint2 = 0;
+// CHECK-FIXES: {{^}}long * lint3;
+// CHECK-FIXES: {{^}}long **linn;
+
+	long int* lint4, *lint5,  lint6;
+	// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+	// CHECK-FIXES: {{^	}}long int* lint4;
+	// CHECK-FIXES: {{^	}}long int *lint5;
+	// CHECK-FIXES: {{^	}}long int lint6;
+
+/* *& */ int /* *& */ ** /* *& */ pp,*xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}/* *& */ int /* *& */ ** /* *& */ pp;
+// CHECK-FIXES: {{^}}int *xx;
+
+unsigned int uint1 = 0,uint2 = 44u, uint3, uint4=4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}unsigned int uint1 = 0;
+// CHECK-FIXES: {{^}}unsigned int uint2 = 44u;
+// CHECK-FIXES: {{^}}unsigned int uint3;
+// CHECK-FIXES: {{^}}unsigned int uint4=4;
+
+const int * const cpc = , simple = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int * const cpc = 
+// CHECK-FIXES: {{^}}const int simple = 0;
+
+double darray1[] = {}, darray2[] = {1,	2},dv1 = 3,dv2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}double darray1[] = {};
+// CHECK-FIXES: {{^}}double darray2[] = {1,	2};
+// CHECK-FIXES: {{^}}double dv1 = 3;
+// CHECK-FIXES: {{^}}double dv2;
+
+int notransform[] =   {
+  1,
+  2
+  };
+
+const int cx = 1, cy = 2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}const int cx = 1;
+// CHECK-FIXES: {{^}}const int cy = 2;
+
+volatile int vx, vy;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}volatile int vx;
+// CHECK-FIXES: {{^}}volatile int vy;
+
+signed char sc1 = 'h', sc2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}signed char sc1 = 'h';
+// CHECK-FIXES: {{^}}signed char sc2;
+
+long long ll1, ll2, ***ft;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: declaration statement can be split up into single line declarations [readability-one-name-per-declaration]
+// CHECK-FIXES: {{^}}long long ll1;
+// CHECK-FIXES: {{^}}long long ll2;
+  

  1   2   >