r289181 - [Headers] Add #include_next for tgmath.h on Darwin

2016-12-08 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec  8 21:30:46 2016
New Revision: 289181

URL: http://llvm.org/viewvc/llvm-project?rev=289181=rev
Log:
[Headers] Add #include_next for tgmath.h on Darwin

Allow darwin to provide additional definitions and implementation
specifc values for tgmath.h on Apple platforms.

rdar://problem/19019845

Added:
cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h
cfe/trunk/test/Headers/tgmath-darwin.c
Modified:
cfe/trunk/lib/Headers/tgmath.h

Modified: cfe/trunk/lib/Headers/tgmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/tgmath.h?rev=289181=289180=289181=diff
==
--- cfe/trunk/lib/Headers/tgmath.h (original)
+++ cfe/trunk/lib/Headers/tgmath.h Thu Dec  8 21:30:46 2016
@@ -25,6 +25,14 @@
 #ifndef __TGMATH_H
 #define __TGMATH_H
 
+/*
+ * Allow additional definitions and implementation-defined values on Apple
+ * platforms.
+ */
+#if defined(__APPLE__) && __STDC_HOSTED__ && __has_include_next()
+#  include_next 
+#else
+
 /* C99 7.22 Type-generic math . */
 #include 
 
@@ -1371,4 +1379,5 @@ static long double
 #undef _TG_ATTRS
 
 #endif /* __cplusplus */
+#endif /* __has_include_next */
 #endif /* __TGMATH_H */

Added: cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h?rev=289181=auto
==
--- cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h (added)
+++ cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h Thu Dec  8 21:30:46 2016
@@ -0,0 +1,4 @@
+#ifndef SYS_TGMATH_H
+#define SYS_TGMATH_H
+
+#endif /* SYS_TGMATH_H */

Added: cfe/trunk/test/Headers/tgmath-darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/tgmath-darwin.c?rev=289181=auto
==
--- cfe/trunk/test/Headers/tgmath-darwin.c (added)
+++ cfe/trunk/test/Headers/tgmath-darwin.c Thu Dec  8 21:30:46 2016
@@ -0,0 +1,12 @@
+// REQUIRES: system-darwin
+// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only -std=c11 -isysroot 
%S/Inputs %s
+#include 
+
+// Test the #include_next on tgmath.h works on Darwin.
+#ifndef SYS_TGMATH_H
+  #error "SYS_TGMATH_H not defined"
+#endif
+
+#ifndef __TGMATH_H
+  #error "__TGMATH_H not defined"
+#endif


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


Re: r288866 - [c++17] P0135R1: Guaranteed copy elision.

2016-12-08 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Dec-08, at 19:29, Richard Smith  wrote:
> 
> On 8 Dec 2016 7:17 pm, "Duncan P. N. Exon Smith via cfe-commits" 
>  wrote:
> +Eric, Marshall
> 
> I haven't looked, but: from the test name, "copy.fail.cpp", I suspect there 
> is a bug/incompatibility in the test.  It likely relies on the compiler 
> trying (and failing) to copy something in a context where r288866 guarantees 
> that there is no copy.
> 
> Was this not fixed by "[libcxx] r289033 - Avoid C++17 guaranteed copy elision 
> when testing for non-copyability"?

Yes, the bot is green now:
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/2728/

> 
> > On 2016-Dec-08, at 18:00, Adrian Prantl  wrote:
> >
> > Hi Richard,
> >
> > at this point this is more a heads-up than anything actionable, but I 
> > wanted to let you know that I bisected this bot failure 
> > (http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/2721/consoleFull#10584592348254eaf0-7326-4999-85b0-388101f2d404)
> >  of std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp 
> > down to this commit.
> >
> > I will follow up once I have a better understanding what is going on there.
> >
> > -- adrian
> >
> >> On Dec 6, 2016, at 3:52 PM, Richard Smith via cfe-commits 
> >>  wrote:
> >>
> >> Author: rsmith
> >> Date: Tue Dec  6 17:52:28 2016
> >> New Revision: 288866
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=288866=rev
> >> Log:
> >> [c++17] P0135R1: Guaranteed copy elision.
> >>
> >> When an object of class type is initialized from a prvalue of the same type
> >> (ignoring cv qualifications), use the prvalue to initialize the object 
> >> directly
> >> instead of inserting a redundant elidable call to a copy constructor.
> >>
> >> Added:
> >>   cfe/trunk/test/CodeGenCXX/cxx1z-copy-omission.cpp
> >>   cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
> >> Modified:
> >>   cfe/trunk/include/clang/AST/Expr.h
> >>   cfe/trunk/lib/AST/Expr.cpp
> >>   cfe/trunk/lib/AST/ExprConstant.cpp
> >>   cfe/trunk/lib/CodeGen/CGExpr.cpp
> >>   cfe/trunk/lib/CodeGen/CGExprAgg.cpp
> >>   cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> >>   cfe/trunk/lib/Sema/SemaExprCXX.cpp
> >>   cfe/trunk/lib/Sema/SemaInit.cpp
> >>   cfe/trunk/lib/Sema/SemaOverload.cpp
> >>   cfe/trunk/test/CXX/drs/dr0xx.cpp
> >>   cfe/trunk/test/CXX/drs/dr10xx.cpp
> >>   cfe/trunk/test/CXX/drs/dr1xx.cpp
> >>   cfe/trunk/test/CXX/drs/dr4xx.cpp
> >>   cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
> >>   cfe/trunk/www/cxx_dr_status.html
> >>   cfe/trunk/www/cxx_status.html
> >>
> >> Modified: cfe/trunk/include/clang/AST/Expr.h
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=288866=288865=288866=diff
> >> ==
> >> --- cfe/trunk/include/clang/AST/Expr.h (original)
> >> +++ cfe/trunk/include/clang/AST/Expr.h Tue Dec  6 17:52:28 2016
> >> @@ -3786,7 +3786,7 @@ public:
> >>
> >>  /// \brief Build an empty initializer list.
> >>  explicit InitListExpr(EmptyShell Empty)
> >> -: Expr(InitListExprClass, Empty) { }
> >> +: Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
> >>
> >>  unsigned getNumInits() const { return InitExprs.size(); }
> >>
> >> @@ -3894,6 +3894,11 @@ public:
> >>  // literal or an @encode?
> >>  bool isStringLiteralInit() const;
> >>
> >> +  /// Is this a transparent initializer list (that is, an InitListExpr 
> >> that is
> >> +  /// purely syntactic, and whose semantics are that of the sole contained
> >> +  /// initializer)?
> >> +  bool isTransparent() const;
> >> +
> >>  SourceLocation getLBraceLoc() const { return LBraceLoc; }
> >>  void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
> >>  SourceLocation getRBraceLoc() const { return RBraceLoc; }
> >>
> >> Modified: cfe/trunk/lib/AST/Expr.cpp
> >> URL: 
> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=288866=288865=288866=diff
> >> ==
> >> --- cfe/trunk/lib/AST/Expr.cpp (original)
> >> +++ cfe/trunk/lib/AST/Expr.cpp Tue Dec  6 17:52:28 2016
> >> @@ -1864,6 +1864,24 @@ bool InitListExpr::isStringLiteralInit()
> >>  return isa(Init) || isa(Init);
> >> }
> >>
> >> +bool InitListExpr::isTransparent() const {
> >> +  assert(isSemanticForm() && "syntactic form never semantically 
> >> transparent");
> >> +
> >> +  // A glvalue InitListExpr is always just sugar.
> >> +  if (isGLValue()) {
> >> +assert(getNumInits() == 1 && "multiple inits in glvalue init list");
> >> +return true;
> >> +  }
> >> +
> >> +  // Otherwise, we're sugar if and only if we have exactly one 
> >> initializer that
> >> +  // is of the same type.
> >> +  if (getNumInits() != 1 || !getInit(0))
> >> +return false;
> >> +
> >> +  return getType().getCanonicalType() ==
> >> + 

Re: r288866 - [c++17] P0135R1: Guaranteed copy elision.

2016-12-08 Thread Duncan P. N. Exon Smith via cfe-commits
Hmm, never mind.  The test seems to preclude copy elision if I'm looking in the 
right place:

std::streambuf ();

int main()
{
std::streambuf sb = get(); // expected-error
}


> On 2016-Dec-08, at 19:17, Duncan P. N. Exon Smith via cfe-commits 
>  wrote:
> 
> +Eric, Marshall
> 
> I haven't looked, but: from the test name, "copy.fail.cpp", I suspect there 
> is a bug/incompatibility in the test.  It likely relies on the compiler 
> trying (and failing) to copy something in a context where r288866 guarantees 
> that there is no copy.
> 
>> On 2016-Dec-08, at 18:00, Adrian Prantl  wrote:
>> 
>> Hi Richard,
>> 
>> at this point this is more a heads-up than anything actionable, but I wanted 
>> to let you know that I bisected this bot failure 
>> (http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/2721/consoleFull#10584592348254eaf0-7326-4999-85b0-388101f2d404)
>>  of std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp 
>> down to this commit.
>> 
>> I will follow up once I have a better understanding what is going on there.
>> 
>> -- adrian
>> 
>>> On Dec 6, 2016, at 3:52 PM, Richard Smith via cfe-commits 
>>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Tue Dec  6 17:52:28 2016
>>> New Revision: 288866
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=288866=rev
>>> Log:
>>> [c++17] P0135R1: Guaranteed copy elision.
>>> 
>>> When an object of class type is initialized from a prvalue of the same type
>>> (ignoring cv qualifications), use the prvalue to initialize the object 
>>> directly
>>> instead of inserting a redundant elidable call to a copy constructor.
>>> 
>>> Added:
>>>  cfe/trunk/test/CodeGenCXX/cxx1z-copy-omission.cpp
>>>  cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
>>> Modified:
>>>  cfe/trunk/include/clang/AST/Expr.h
>>>  cfe/trunk/lib/AST/Expr.cpp
>>>  cfe/trunk/lib/AST/ExprConstant.cpp
>>>  cfe/trunk/lib/CodeGen/CGExpr.cpp
>>>  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>>>  cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>>  cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>>  cfe/trunk/lib/Sema/SemaInit.cpp
>>>  cfe/trunk/lib/Sema/SemaOverload.cpp
>>>  cfe/trunk/test/CXX/drs/dr0xx.cpp
>>>  cfe/trunk/test/CXX/drs/dr10xx.cpp
>>>  cfe/trunk/test/CXX/drs/dr1xx.cpp
>>>  cfe/trunk/test/CXX/drs/dr4xx.cpp
>>>  cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
>>>  cfe/trunk/www/cxx_dr_status.html
>>>  cfe/trunk/www/cxx_status.html
>>> 
>>> Modified: cfe/trunk/include/clang/AST/Expr.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=288866=288865=288866=diff
>>> ==
>>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>>> +++ cfe/trunk/include/clang/AST/Expr.h Tue Dec  6 17:52:28 2016
>>> @@ -3786,7 +3786,7 @@ public:
>>> 
>>> /// \brief Build an empty initializer list.
>>> explicit InitListExpr(EmptyShell Empty)
>>> -: Expr(InitListExprClass, Empty) { }
>>> +: Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
>>> 
>>> unsigned getNumInits() const { return InitExprs.size(); }
>>> 
>>> @@ -3894,6 +3894,11 @@ public:
>>> // literal or an @encode?
>>> bool isStringLiteralInit() const;
>>> 
>>> +  /// Is this a transparent initializer list (that is, an InitListExpr 
>>> that is
>>> +  /// purely syntactic, and whose semantics are that of the sole contained
>>> +  /// initializer)?
>>> +  bool isTransparent() const;
>>> +
>>> SourceLocation getLBraceLoc() const { return LBraceLoc; }
>>> void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
>>> SourceLocation getRBraceLoc() const { return RBraceLoc; }
>>> 
>>> Modified: cfe/trunk/lib/AST/Expr.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=288866=288865=288866=diff
>>> ==
>>> --- cfe/trunk/lib/AST/Expr.cpp (original)
>>> +++ cfe/trunk/lib/AST/Expr.cpp Tue Dec  6 17:52:28 2016
>>> @@ -1864,6 +1864,24 @@ bool InitListExpr::isStringLiteralInit()
>>> return isa(Init) || isa(Init);
>>> }
>>> 
>>> +bool InitListExpr::isTransparent() const {
>>> +  assert(isSemanticForm() && "syntactic form never semantically 
>>> transparent");
>>> +
>>> +  // A glvalue InitListExpr is always just sugar.
>>> +  if (isGLValue()) {
>>> +assert(getNumInits() == 1 && "multiple inits in glvalue init list");
>>> +return true;
>>> +  }
>>> +
>>> +  // Otherwise, we're sugar if and only if we have exactly one initializer 
>>> that
>>> +  // is of the same type.
>>> +  if (getNumInits() != 1 || !getInit(0))
>>> +return false;
>>> +
>>> +  return getType().getCanonicalType() ==
>>> + getInit(0)->getType().getCanonicalType();
>>> +}
>>> +
>>> SourceLocation InitListExpr::getLocStart() const {
>>> if (InitListExpr *SyntacticForm = getSyntacticForm())
>>>   return SyntacticForm->getLocStart();
>>> @@ -2246,12 +2264,15 @@ bool 

Re: r288866 - [c++17] P0135R1: Guaranteed copy elision.

2016-12-08 Thread Richard Smith via cfe-commits
On 8 Dec 2016 7:17 pm, "Duncan P. N. Exon Smith via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

+Eric, Marshall

I haven't looked, but: from the test name, "copy.fail.cpp", I suspect there
is a bug/incompatibility in the test.  It likely relies on the compiler
trying (and failing) to copy something in a context where r288866
guarantees that there is no copy.


Was this not fixed by "[libcxx] r289033 - Avoid C++17 guaranteed copy
elision when testing for non-copyability"?

> On 2016-Dec-08, at 18:00, Adrian Prantl  wrote:
>
> Hi Richard,
>
> at this point this is more a heads-up than anything actionable, but I
wanted to let you know that I bisected this bot failure (
http://lab.llvm.org:8080/green/job/clang-stage2-cmake-
RgSan_check/2721/consoleFull#10584592348254eaf0-7326-4999-85b0-388101f2d404)
of std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
down to this commit.
>
> I will follow up once I have a better understanding what is going on
there.
>
> -- adrian
>
>> On Dec 6, 2016, at 3:52 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:
>>
>> Author: rsmith
>> Date: Tue Dec  6 17:52:28 2016
>> New Revision: 288866
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=288866=rev
>> Log:
>> [c++17] P0135R1: Guaranteed copy elision.
>>
>> When an object of class type is initialized from a prvalue of the same
type
>> (ignoring cv qualifications), use the prvalue to initialize the object
directly
>> instead of inserting a redundant elidable call to a copy constructor.
>>
>> Added:
>>   cfe/trunk/test/CodeGenCXX/cxx1z-copy-omission.cpp
>>   cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
>> Modified:
>>   cfe/trunk/include/clang/AST/Expr.h
>>   cfe/trunk/lib/AST/Expr.cpp
>>   cfe/trunk/lib/AST/ExprConstant.cpp
>>   cfe/trunk/lib/CodeGen/CGExpr.cpp
>>   cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>>   cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>   cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>   cfe/trunk/lib/Sema/SemaInit.cpp
>>   cfe/trunk/lib/Sema/SemaOverload.cpp
>>   cfe/trunk/test/CXX/drs/dr0xx.cpp
>>   cfe/trunk/test/CXX/drs/dr10xx.cpp
>>   cfe/trunk/test/CXX/drs/dr1xx.cpp
>>   cfe/trunk/test/CXX/drs/dr4xx.cpp
>>   cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
>>   cfe/trunk/www/cxx_dr_status.html
>>   cfe/trunk/www/cxx_status.html
>>
>> Modified: cfe/trunk/include/clang/AST/Expr.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
clang/AST/Expr.h?rev=288866=288865=288866=diff
>> 
==
>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>> +++ cfe/trunk/include/clang/AST/Expr.h Tue Dec  6 17:52:28 2016
>> @@ -3786,7 +3786,7 @@ public:
>>
>>  /// \brief Build an empty initializer list.
>>  explicit InitListExpr(EmptyShell Empty)
>> -: Expr(InitListExprClass, Empty) { }
>> +: Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
>>
>>  unsigned getNumInits() const { return InitExprs.size(); }
>>
>> @@ -3894,6 +3894,11 @@ public:
>>  // literal or an @encode?
>>  bool isStringLiteralInit() const;
>>
>> +  /// Is this a transparent initializer list (that is, an InitListExpr
that is
>> +  /// purely syntactic, and whose semantics are that of the sole
contained
>> +  /// initializer)?
>> +  bool isTransparent() const;
>> +
>>  SourceLocation getLBraceLoc() const { return LBraceLoc; }
>>  void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
>>  SourceLocation getRBraceLoc() const { return RBraceLoc; }
>>
>> Modified: cfe/trunk/lib/AST/Expr.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
Expr.cpp?rev=288866=288865=288866=diff
>> 
==
>> --- cfe/trunk/lib/AST/Expr.cpp (original)
>> +++ cfe/trunk/lib/AST/Expr.cpp Tue Dec  6 17:52:28 2016
>> @@ -1864,6 +1864,24 @@ bool InitListExpr::isStringLiteralInit()
>>  return isa(Init) || isa(Init);
>> }
>>
>> +bool InitListExpr::isTransparent() const {
>> +  assert(isSemanticForm() && "syntactic form never semantically
transparent");
>> +
>> +  // A glvalue InitListExpr is always just sugar.
>> +  if (isGLValue()) {
>> +assert(getNumInits() == 1 && "multiple inits in glvalue init list");
>> +return true;
>> +  }
>> +
>> +  // Otherwise, we're sugar if and only if we have exactly one
initializer that
>> +  // is of the same type.
>> +  if (getNumInits() != 1 || !getInit(0))
>> +return false;
>> +
>> +  return getType().getCanonicalType() ==
>> + getInit(0)->getType().getCanonicalType();
>> +}
>> +
>> SourceLocation InitListExpr::getLocStart() const {
>>  if (InitListExpr *SyntacticForm = getSyntacticForm())
>>return SyntacticForm->getLocStart();
>> @@ -2246,12 +2264,15 @@ bool Expr::isUnusedResultAWarning(const
>>// effects (e.g. a placement new with an uninitialized POD).
>>  case CXXDeleteExprClass:
>>return false;
>> +  case MaterializeTemporaryExprClass:
>> +return 

[libcxx] r289178 - fix misspelling in .clang-format

2016-12-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec  8 21:18:45 2016
New Revision: 289178

URL: http://llvm.org/viewvc/llvm-project?rev=289178=rev
Log:
fix misspelling in .clang-format

Modified:
libcxx/trunk/.clang-format

Modified: libcxx/trunk/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/.clang-format?rev=289178=289177=289178=diff
==
--- libcxx/trunk/.clang-format (original)
+++ libcxx/trunk/.clang-format Thu Dec  8 21:18:45 2016
@@ -7,5 +7,5 @@ AlwaysBreakTemplateDeclarations: true
 
 # Disable formatting options which may break tests.
 SortIncludes: false
-ReflowCommends: false
+ReflowComments: false
 ---


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


[libcxx] r289177 - Turn off header sorting and comment formatting

2016-12-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec  8 21:17:25 2016
New Revision: 289177

URL: http://llvm.org/viewvc/llvm-project?rev=289177=rev
Log:
Turn off header sorting and comment formatting

Modified:
libcxx/trunk/.clang-format

Modified: libcxx/trunk/.clang-format
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/.clang-format?rev=289177=289176=289177=diff
==
--- libcxx/trunk/.clang-format (original)
+++ libcxx/trunk/.clang-format Thu Dec  8 21:17:25 2016
@@ -4,4 +4,8 @@ BasedOnStyle: LLVM
 Language: Cpp
 
 AlwaysBreakTemplateDeclarations: true
+
+# Disable formatting options which may break tests.
+SortIncludes: false
+ReflowCommends: false
 ---


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


r289176 - [CrashReproducer] Provide a clean dir path for -fmodules-cache-path

2016-12-08 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec  8 21:11:48 2016
New Revision: 289176

URL: http://llvm.org/viewvc/llvm-project?rev=289176=rev
Log:
[CrashReproducer] Provide a clean dir path for -fmodules-cache-path

The most common workflow with module reproducers involves deleting the
module cache before running the script. This happens because leftovers
from the crash are present in the cache and could trigger unrelated and
confusing errors, misleading from the initial reproduction intent.
Change this to point to a clean path but leave the leftovers untouched.

rdar://problem/28655070

Modified:
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
cfe/trunk/test/Modules/crash-vfs-relative-incdir.m
cfe/trunk/test/Modules/crash-vfs-relative-overlay.m
cfe/trunk/test/Modules/crash-vfs-run-reproducer.m

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=289176=289175=289176=diff
==
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Thu Dec  8 21:11:48 2016
@@ -267,11 +267,14 @@ void Command::Print(raw_ostream , con
 OS << ' ';
 printArg(OS, CrashInfo->VFSPath.str(), Quote);
 
-// Insert -fmodules-cache-path and use the relative module directory
-// .cache/vfs/modules where we already dumped the modules.
+// The leftover modules from the crash are stored in
+//  .cache/vfs/modules
+// Leave it untouched for pcm inspection and provide a clean/empty dir
+// path to contain the future generated module cache:
+//  .cache/vfs/repro-modules
 SmallString<128> RelModCacheDir = llvm::sys::path::parent_path(
 llvm::sys::path::parent_path(CrashInfo->VFSPath));
-llvm::sys::path::append(RelModCacheDir, "modules");
+llvm::sys::path::append(RelModCacheDir, "repro-modules");
 
 std::string ModCachePath = "-fmodules-cache-path=";
 ModCachePath.append(RelModCacheDir.c_str());

Modified: cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m?rev=289176=289175=289176=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m Thu Dec  8 
21:11:48 2016
@@ -37,7 +37,7 @@
 // CHECKSH-NOT: "-fmodules-cache-path="
 // CHECKSH: "crash-vfs-{{[^ ]*}}.m"
 // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
-// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
+// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules"
 
 // CHECKYAML: 'type': 'directory',
 // CHECKYAML: 'name': "",

Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=289176=289175=289176=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m Thu Dec  8 
21:11:48 2016
@@ -38,7 +38,7 @@
 // CHECKSH-NOT: "-fmodules-cache-path="
 // CHECKSH: "crash-vfs-{{[^ ]*}}.m"
 // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
-// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
+// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules"
 
 // CHECKYAML: 'case-sensitive':
 // CHECKYAML-NEXT: 'use-external-names': 'false',

Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m?rev=289176=289175=289176=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m Thu Dec  8 
21:11:48 2016
@@ -39,7 +39,7 @@
 // CHECKSH-NOT: "-fmodules-cache-path="
 // CHECKSH: "crash-vfs-{{[^ ]*}}.m"
 // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
-// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
+// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/repro-modules"
 
 // CHECKYAML: 'type': 'directory',
 // CHECKYAML: 'name': "",

Modified: cfe/trunk/test/Modules/crash-vfs-path-traversal.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-traversal.m?rev=289176=289175=289176=diff
==
--- 

Re: r288866 - [c++17] P0135R1: Guaranteed copy elision.

2016-12-08 Thread Duncan P. N. Exon Smith via cfe-commits
+Eric, Marshall

I haven't looked, but: from the test name, "copy.fail.cpp", I suspect there is 
a bug/incompatibility in the test.  It likely relies on the compiler trying 
(and failing) to copy something in a context where r288866 guarantees that 
there is no copy.

> On 2016-Dec-08, at 18:00, Adrian Prantl  wrote:
> 
> Hi Richard,
> 
> at this point this is more a heads-up than anything actionable, but I wanted 
> to let you know that I bisected this bot failure 
> (http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/2721/consoleFull#10584592348254eaf0-7326-4999-85b0-388101f2d404)
>  of std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp 
> down to this commit.
> 
> I will follow up once I have a better understanding what is going on there.
> 
> -- adrian
> 
>> On Dec 6, 2016, at 3:52 PM, Richard Smith via cfe-commits 
>>  wrote:
>> 
>> Author: rsmith
>> Date: Tue Dec  6 17:52:28 2016
>> New Revision: 288866
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=288866=rev
>> Log:
>> [c++17] P0135R1: Guaranteed copy elision.
>> 
>> When an object of class type is initialized from a prvalue of the same type
>> (ignoring cv qualifications), use the prvalue to initialize the object 
>> directly
>> instead of inserting a redundant elidable call to a copy constructor.
>> 
>> Added:
>>   cfe/trunk/test/CodeGenCXX/cxx1z-copy-omission.cpp
>>   cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
>> Modified:
>>   cfe/trunk/include/clang/AST/Expr.h
>>   cfe/trunk/lib/AST/Expr.cpp
>>   cfe/trunk/lib/AST/ExprConstant.cpp
>>   cfe/trunk/lib/CodeGen/CGExpr.cpp
>>   cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>>   cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>   cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>   cfe/trunk/lib/Sema/SemaInit.cpp
>>   cfe/trunk/lib/Sema/SemaOverload.cpp
>>   cfe/trunk/test/CXX/drs/dr0xx.cpp
>>   cfe/trunk/test/CXX/drs/dr10xx.cpp
>>   cfe/trunk/test/CXX/drs/dr1xx.cpp
>>   cfe/trunk/test/CXX/drs/dr4xx.cpp
>>   cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
>>   cfe/trunk/www/cxx_dr_status.html
>>   cfe/trunk/www/cxx_status.html
>> 
>> Modified: cfe/trunk/include/clang/AST/Expr.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=288866=288865=288866=diff
>> ==
>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>> +++ cfe/trunk/include/clang/AST/Expr.h Tue Dec  6 17:52:28 2016
>> @@ -3786,7 +3786,7 @@ public:
>> 
>>  /// \brief Build an empty initializer list.
>>  explicit InitListExpr(EmptyShell Empty)
>> -: Expr(InitListExprClass, Empty) { }
>> +: Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
>> 
>>  unsigned getNumInits() const { return InitExprs.size(); }
>> 
>> @@ -3894,6 +3894,11 @@ public:
>>  // literal or an @encode?
>>  bool isStringLiteralInit() const;
>> 
>> +  /// Is this a transparent initializer list (that is, an InitListExpr that 
>> is
>> +  /// purely syntactic, and whose semantics are that of the sole contained
>> +  /// initializer)?
>> +  bool isTransparent() const;
>> +
>>  SourceLocation getLBraceLoc() const { return LBraceLoc; }
>>  void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
>>  SourceLocation getRBraceLoc() const { return RBraceLoc; }
>> 
>> Modified: cfe/trunk/lib/AST/Expr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=288866=288865=288866=diff
>> ==
>> --- cfe/trunk/lib/AST/Expr.cpp (original)
>> +++ cfe/trunk/lib/AST/Expr.cpp Tue Dec  6 17:52:28 2016
>> @@ -1864,6 +1864,24 @@ bool InitListExpr::isStringLiteralInit()
>>  return isa(Init) || isa(Init);
>> }
>> 
>> +bool InitListExpr::isTransparent() const {
>> +  assert(isSemanticForm() && "syntactic form never semantically 
>> transparent");
>> +
>> +  // A glvalue InitListExpr is always just sugar.
>> +  if (isGLValue()) {
>> +assert(getNumInits() == 1 && "multiple inits in glvalue init list");
>> +return true;
>> +  }
>> +
>> +  // Otherwise, we're sugar if and only if we have exactly one initializer 
>> that
>> +  // is of the same type.
>> +  if (getNumInits() != 1 || !getInit(0))
>> +return false;
>> +
>> +  return getType().getCanonicalType() ==
>> + getInit(0)->getType().getCanonicalType();
>> +}
>> +
>> SourceLocation InitListExpr::getLocStart() const {
>>  if (InitListExpr *SyntacticForm = getSyntacticForm())
>>return SyntacticForm->getLocStart();
>> @@ -2246,12 +2264,15 @@ bool Expr::isUnusedResultAWarning(const
>>// effects (e.g. a placement new with an uninitialized POD).
>>  case CXXDeleteExprClass:
>>return false;
>> +  case MaterializeTemporaryExprClass:
>> +return cast(this)->GetTemporaryExpr()
>> +   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
>>  case CXXBindTemporaryExprClass:
>> -return (cast(this)
>> -

r289174 - [CrashReproducer] Rewrite relative include paths

2016-12-08 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec  8 20:22:47 2016
New Revision: 289174

URL: http://llvm.org/viewvc/llvm-project?rev=289174=rev
Log:
[CrashReproducer] Rewrite relative include paths

When -fmodules is on, the reproducer invocation currently leave paths
for include-like flags as is. If the path is relative, the reproducer
doesn't know how to access that file during reproduction time because
the VFS cannot reason about relative paths.

Expand relative paths to absolute ones when creating the reproducer
command line. This allows, for example, the reproducer to work for
crashes while building clang with modules; this wasn't possible before
because building clang requires using relative inc dir from within the
build directory.

rdar://problem/28655070

Added:
cfe/trunk/test/Modules/crash-vfs-relative-incdir.m
Modified:
cfe/trunk/lib/Driver/Job.cpp

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=289174=289173=289174=diff
==
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Thu Dec  8 20:22:47 2016
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
@@ -38,46 +39,59 @@ Command::Command(const Action , c
   InputFilenames.push_back(II.getFilename());
 }
 
-static int skipArgs(const char *Flag, bool HaveCrashVFS) {
+/// @brief Check if the compiler flag in question should be skipped when
+/// emitting a reproducer. Also track how many arguments it has and if the
+/// option is some kind of include path.
+static bool skipArgs(const char *Flag, bool HaveCrashVFS, int ,
+ bool ) {
+  SkipNum = 2;
   // These flags are all of the form -Flag  and are treated as two
   // arguments.  Therefore, we need to skip the flag and the next argument.
-  bool Res = llvm::StringSwitch(Flag)
+  bool ShouldSkip = llvm::StringSwitch(Flag)
 .Cases("-MF", "-MT", "-MQ", "-serialize-diagnostic-file", true)
 .Cases("-o", "-coverage-file", "-dependency-file", true)
-.Cases("-fdebug-compilation-dir", "-idirafter", true)
-.Cases("-include", "-include-pch", "-internal-isystem", true)
-.Cases("-internal-externc-isystem", "-iprefix", "-iwithprefix", true)
-.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
+.Cases("-fdebug-compilation-dir", "-include-pch", true)
 .Cases("-dwarf-debug-flags", "-ivfsoverlay", true)
-.Cases("-header-include-file", "-diagnostic-log-file", true)
-// Some include flags shouldn't be skipped if we have a crash VFS
-.Cases("-isysroot", "-I", "-F", "-resource-dir", !HaveCrashVFS)
+.Case("-diagnostic-log-file", true)
 .Default(false);
+  if (ShouldSkip)
+return true;
 
-  // Match found.
-  if (Res)
-return 2;
+  // Some include flags shouldn't be skipped if we have a crash VFS
+  IsInclude = llvm::StringSwitch(Flag)
+.Cases("-include", "-header-include-file", true)
+.Cases("-idirafter", "-internal-isystem", "-iwithprefix", true)
+.Cases("-internal-externc-isystem", "-iprefix", true)
+.Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
+.Cases("-isysroot", "-I", "-F", "-resource-dir", true)
+.Case("-iframework", true)
+.Default(false);
+  if (IsInclude)
+return HaveCrashVFS ? false : true;
 
   // The remaining flags are treated as a single argument.
 
   // These flags are all of the form -Flag and have no second argument.
-  Res = llvm::StringSwitch(Flag)
+  ShouldSkip = llvm::StringSwitch(Flag)
 .Cases("-M", "-MM", "-MG", "-MP", "-MD", true)
 .Case("-MMD", true)
 .Default(false);
 
   // Match found.
-  if (Res)
-return 1;
+  SkipNum = 1;
+  if (ShouldSkip)
+return true;
 
   // These flags are treated as a single argument (e.g., -F).
   StringRef FlagRef(Flag);
-  if ((!HaveCrashVFS &&
-   (FlagRef.startswith("-F") || FlagRef.startswith("-I"))) ||
-  FlagRef.startswith("-fmodules-cache-path="))
-return 1;
+  IsInclude = FlagRef.startswith("-F") || FlagRef.startswith("-I");
+  if (IsInclude)
+return HaveCrashVFS ? false : true;
+  if (FlagRef.startswith("-fmodules-cache-path="))
+return true;
 
-  return 0;
+  SkipNum = 0;
+  return false;
 }
 
 void Command::printArg(raw_ostream , StringRef Arg, bool Quote) {
@@ -153,6 +167,45 @@ void Command::buildArgvForResponseFile(
   }
 }
 
+/// @brief Rewrite relative include-like flag paths to absolute ones.
+static void
+rewriteIncludes(const llvm::ArrayRef , size_t Idx,
+size_t NumArgs,
+llvm::SmallVectorImpl> ) {
+  using namespace llvm;
+  using namespace sys;
+  auto getAbsPath = [](StringRef InInc, SmallVectorImpl ) -> bool 
{
+if (path::is_absolute(InInc)) // Nothing to 

Re: [PATCH] D27545: Don't assert when redefining a built-in macro in a PCH, PR29119

2016-12-08 Thread Nico Weber via cfe-commits
(I replied to comments about 1h ago, looks like phab is not in the mood for
sending a mail for that for some reason. I did use the "Leap into action"
submit button.)

On Wed, Dec 7, 2016 at 9:19 PM, Richard Smith via Phabricator <
revi...@reviews.llvm.org> wrote:

> rsmith added inline comments.
>
>
> 
> Comment at: lib/Lex/PPMacroExpansion.cpp:110-112
> +// FIXME: shouldIgnoreMacro() in ASTWriter also stops at macros from
> the
> +// predefines buffer in module builds. Do we need to splice to those
> here
> +// too?
> 
> If I remember correctly, we shouldn't need to; we run this step before we
> start lexing the predefines buffer. However, that does mean that macros on
> the command line will *override* macros from the PCH, which seems like it's
> probably the wrong behavior...
>
>
> https://reviews.llvm.org/D27545
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r288866 - [c++17] P0135R1: Guaranteed copy elision.

2016-12-08 Thread Adrian Prantl via cfe-commits
Hi Richard,

at this point this is more a heads-up than anything actionable, but I wanted to 
let you know that I bisected this bot failure 
(http://lab.llvm.org:8080/green/job/clang-stage2-cmake-RgSan_check/2721/consoleFull#10584592348254eaf0-7326-4999-85b0-388101f2d404)
 of std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp down 
to this commit.

I will follow up once I have a better understanding what is going on there.

-- adrian

> On Dec 6, 2016, at 3:52 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Tue Dec  6 17:52:28 2016
> New Revision: 288866
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=288866=rev
> Log:
> [c++17] P0135R1: Guaranteed copy elision.
> 
> When an object of class type is initialized from a prvalue of the same type
> (ignoring cv qualifications), use the prvalue to initialize the object 
> directly
> instead of inserting a redundant elidable call to a copy constructor.
> 
> Added:
>cfe/trunk/test/CodeGenCXX/cxx1z-copy-omission.cpp
>cfe/trunk/test/SemaCXX/cxx1z-copy-omission.cpp
> Modified:
>cfe/trunk/include/clang/AST/Expr.h
>cfe/trunk/lib/AST/Expr.cpp
>cfe/trunk/lib/AST/ExprConstant.cpp
>cfe/trunk/lib/CodeGen/CGExpr.cpp
>cfe/trunk/lib/CodeGen/CGExprAgg.cpp
>cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>cfe/trunk/lib/Sema/SemaExprCXX.cpp
>cfe/trunk/lib/Sema/SemaInit.cpp
>cfe/trunk/lib/Sema/SemaOverload.cpp
>cfe/trunk/test/CXX/drs/dr0xx.cpp
>cfe/trunk/test/CXX/drs/dr10xx.cpp
>cfe/trunk/test/CXX/drs/dr1xx.cpp
>cfe/trunk/test/CXX/drs/dr4xx.cpp
>cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
>cfe/trunk/www/cxx_dr_status.html
>cfe/trunk/www/cxx_status.html
> 
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=288866=288865=288866=diff
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Tue Dec  6 17:52:28 2016
> @@ -3786,7 +3786,7 @@ public:
> 
>   /// \brief Build an empty initializer list.
>   explicit InitListExpr(EmptyShell Empty)
> -: Expr(InitListExprClass, Empty) { }
> +: Expr(InitListExprClass, Empty), AltForm(nullptr, true) { }
> 
>   unsigned getNumInits() const { return InitExprs.size(); }
> 
> @@ -3894,6 +3894,11 @@ public:
>   // literal or an @encode?
>   bool isStringLiteralInit() const;
> 
> +  /// Is this a transparent initializer list (that is, an InitListExpr that 
> is
> +  /// purely syntactic, and whose semantics are that of the sole contained
> +  /// initializer)?
> +  bool isTransparent() const;
> +
>   SourceLocation getLBraceLoc() const { return LBraceLoc; }
>   void setLBraceLoc(SourceLocation Loc) { LBraceLoc = Loc; }
>   SourceLocation getRBraceLoc() const { return RBraceLoc; }
> 
> Modified: cfe/trunk/lib/AST/Expr.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=288866=288865=288866=diff
> ==
> --- cfe/trunk/lib/AST/Expr.cpp (original)
> +++ cfe/trunk/lib/AST/Expr.cpp Tue Dec  6 17:52:28 2016
> @@ -1864,6 +1864,24 @@ bool InitListExpr::isStringLiteralInit()
>   return isa(Init) || isa(Init);
> }
> 
> +bool InitListExpr::isTransparent() const {
> +  assert(isSemanticForm() && "syntactic form never semantically 
> transparent");
> +
> +  // A glvalue InitListExpr is always just sugar.
> +  if (isGLValue()) {
> +assert(getNumInits() == 1 && "multiple inits in glvalue init list");
> +return true;
> +  }
> +
> +  // Otherwise, we're sugar if and only if we have exactly one initializer 
> that
> +  // is of the same type.
> +  if (getNumInits() != 1 || !getInit(0))
> +return false;
> +
> +  return getType().getCanonicalType() ==
> + getInit(0)->getType().getCanonicalType();
> +}
> +
> SourceLocation InitListExpr::getLocStart() const {
>   if (InitListExpr *SyntacticForm = getSyntacticForm())
> return SyntacticForm->getLocStart();
> @@ -2246,12 +2264,15 @@ bool Expr::isUnusedResultAWarning(const
> // effects (e.g. a placement new with an uninitialized POD).
>   case CXXDeleteExprClass:
> return false;
> +  case MaterializeTemporaryExprClass:
> +return cast(this)->GetTemporaryExpr()
> +   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
>   case CXXBindTemporaryExprClass:
> -return (cast(this)
> -->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx));
> +return cast(this)->getSubExpr()
> +   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
>   case ExprWithCleanupsClass:
> -return (cast(this)
> -->getSubExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx));
> +return cast(this)->getSubExpr()
> +   ->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx);
>   }
> }
> 
> 
> Modified: 

r289167 - Specify -std=gnu++98 on some Rewriter tests. NFC.

2016-12-08 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Dec  8 19:20:40 2016
New Revision: 289167

URL: http://llvm.org/viewvc/llvm-project?rev=289167=rev
Log:
Specify -std=gnu++98 on some Rewriter tests. NFC.

Rewriter tests rewrite Objective-C++ to C++, and then compile the
result.  The rewritten result sometimes doesn't work with C++11.  As
we want to allow Clang's default dialect to become C++11, we need to
make sure the tests will still pass.

Modified:
cfe/trunk/test/Rewriter/modern-write-bf-abi.mm
cfe/trunk/test/Rewriter/objc-modern-property-bitfield.m
cfe/trunk/test/Rewriter/property-dot-syntax.mm
cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm
cfe/trunk/test/Rewriter/rewrite-block-pointer.mm
cfe/trunk/test/Rewriter/rewrite-byref-in-nested-blocks.mm
cfe/trunk/test/Rewriter/rewrite-byref-vars.mm
cfe/trunk/test/Rewriter/rewrite-cast-ivar-modern-access.mm
cfe/trunk/test/Rewriter/rewrite-elaborated-type.mm
cfe/trunk/test/Rewriter/rewrite-foreach-in-block.mm
cfe/trunk/test/Rewriter/rewrite-foreach-protocol-id.m
cfe/trunk/test/Rewriter/rewrite-forward-class.m
cfe/trunk/test/Rewriter/rewrite-forward-class.mm
cfe/trunk/test/Rewriter/rewrite-ivar-use.m
cfe/trunk/test/Rewriter/rewrite-modern-atautoreleasepool.mm
cfe/trunk/test/Rewriter/rewrite-modern-block-ivar-call.mm
cfe/trunk/test/Rewriter/rewrite-modern-class.mm
cfe/trunk/test/Rewriter/rewrite-modern-default-property-synthesis.mm
cfe/trunk/test/Rewriter/rewrite-modern-extern-c-func-decl.mm
cfe/trunk/test/Rewriter/rewrite-modern-ivar-use.mm
cfe/trunk/test/Rewriter/rewrite-modern-ivars-2.mm
cfe/trunk/test/Rewriter/rewrite-modern-ivars.mm
cfe/trunk/test/Rewriter/rewrite-modern-nested-ivar.mm
cfe/trunk/test/Rewriter/rewrite-modern-throw.m
cfe/trunk/test/Rewriter/rewrite-nested-blocks-1.mm
cfe/trunk/test/Rewriter/rewrite-nested-blocks.mm
cfe/trunk/test/Rewriter/rewrite-nested-ivar.mm
cfe/trunk/test/Rewriter/rewrite-property-attributes.mm
cfe/trunk/test/Rewriter/rewrite-property-set-cfstring.mm
cfe/trunk/test/Rewriter/rewrite-protocol-property.mm
cfe/trunk/test/Rewriter/rewrite-user-defined-accessors.mm
cfe/trunk/test/Rewriter/rewrite-vararg.m

Modified: cfe/trunk/test/Rewriter/modern-write-bf-abi.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/modern-write-bf-abi.mm?rev=289167=289166=289167=diff
==
--- cfe/trunk/test/Rewriter/modern-write-bf-abi.mm (original)
+++ cfe/trunk/test/Rewriter/modern-write-bf-abi.mm Thu Dec  8 19:20:40 2016
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions 
-rewrite-objc %s -o %t-modern-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" 
-D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -Wno-address-of-temporary 
-D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
 // rdar://13138459
 
 // -Did="void*" -DSEL="void *" -DClass="void*"

Modified: cfe/trunk/test/Rewriter/objc-modern-property-bitfield.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/objc-modern-property-bitfield.m?rev=289167=289166=289167=diff
==
--- cfe/trunk/test/Rewriter/objc-modern-property-bitfield.m (original)
+++ cfe/trunk/test/Rewriter/objc-modern-property-bitfield.m Thu Dec  8 19:20:40 
2016
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions 
-rewrite-objc %s -o %t-modern-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" 
-D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -Wno-address-of-temporary 
-D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp
 // rdar://13138459
 
 void *sel_registerName(const char *);

Modified: cfe/trunk/test/Rewriter/property-dot-syntax.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/property-dot-syntax.mm?rev=289167=289166=289167=diff
==
--- cfe/trunk/test/Rewriter/property-dot-syntax.mm (original)
+++ cfe/trunk/test/Rewriter/property-dot-syntax.mm Thu Dec  8 19:20:40 2016
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions 
-rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp
-// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary 
-D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp
+// RUN: %clang_cc1 -fsyntax-only -std=gnu++98 -fblocks 
-Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" 
%t-rw.cpp
 // rdar:// 8520727
 
 void *sel_registerName(const char *);

Modified: cfe/trunk/test/Rewriter/rewrite-block-literal-1.mm
URL: 

r289160 - [AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

2016-12-08 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Thu Dec  8 18:11:53 2016
New Revision: 289160

URL: http://llvm.org/viewvc/llvm-project?rev=289160=rev
Log:
[AST, ASTMatchers, Basic] Fix some Clang-tidy modernize and Include What You 
Use warnings; other minor fixes (NFC).

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/Registry.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/include/clang/Basic/FileManager.h
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/include/clang/Basic/SourceManager.h
cfe/trunk/include/clang/Basic/VirtualFileSystem.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=289160=289159=289160=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Dec  8 18:11:53 2016
@@ -19,73 +19,107 @@
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CommentCommandTraits.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RawCommentList.h"
+#include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
+#include "clang/Basic/Linkage.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/PartialDiagnostic.h"
 #include "clang/Basic/SanitizerBlacklist.h"
-#include "clang/Basic/VersionTuple.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/TinyPtrVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/AlignOf.h"
 #include "llvm/Support/Allocator.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include 
+#include 
+#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 namespace llvm {
-  struct fltSemantics;
-}
+
+struct fltSemantics;
+
+} // end namespace llvm
 
 namespace clang {
-  class FileManager;
-  class AtomicExpr;
-  class ASTRecordLayout;
-  class BlockExpr;
-  class CharUnits;
-  class DiagnosticsEngine;
-  class Expr;
-  class ASTMutationListener;
-  class IdentifierTable;
-  class MaterializeTemporaryExpr;
-  class SelectorTable;
-  class TargetInfo;
-  class CXXABI;
-  class MangleNumberingContext;
-  // Decls
-  class MangleContext;
-  class ObjCIvarDecl;
-  class ObjCPropertyDecl;
-  class UnresolvedSetIterator;
-  class UsingDecl;
-  class UsingShadowDecl;
-  class VTableContextBase;
-
-  namespace Builtin { class Context; }
-  enum BuiltinTemplateKind : int;
-
-  namespace comments {
-class FullComment;
-  }
-
-  struct TypeInfo {
-uint64_t Width;
-unsigned Align;
-bool AlignIsRequired : 1;
-TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {}
-TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
-: Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
-  };
+
+class ASTMutationListener;
+class ASTRecordLayout;
+class AtomicExpr;
+class BlockExpr;
+class CharUnits;
+class CXXABI;
+class DiagnosticsEngine;
+class Expr;
+class MangleNumberingContext;
+class MaterializeTemporaryExpr;
+class TargetInfo;
+// Decls
+class MangleContext;
+class ObjCIvarDecl;
+class ObjCPropertyDecl;
+class UnresolvedSetIterator;
+class UsingDecl;
+class UsingShadowDecl;
+class VTableContextBase;
+
+namespace Builtin {
+
+  class Context;
+
+} // end namespace Builtin
+
+enum BuiltinTemplateKind : int;
+
+namespace comments {
+
+  class FullComment;
+
+} // end namespace comments
+
+struct TypeInfo {
+  uint64_t Width;
+  unsigned Align;
+  bool AlignIsRequired : 1;
+
+  TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {}
+  TypeInfo(uint64_t Width, unsigned Align, bool AlignIsRequired)
+  : Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
+};
 
 /// \brief Holds long-lived AST nodes (such as types and decls) that can be
 /// referred to throughout the semantic analysis of a file.
@@ -331,7 +365,6 @@ public:
   

r289159 - [DOXYGEN] Improved doxygen comments for xmmintrin.h intrinsics.

2016-12-08 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Dec  8 17:58:39 2016
New Revision: 289159

URL: http://llvm.org/viewvc/llvm-project?rev=289159=rev
Log:
[DOXYGEN] Improved doxygen comments for xmmintrin.h intrinsics.

Tagged parameter names with \a doxygen command to display parameters in italics.
Formatted comments to fit into 80 chars.




Modified:
cfe/trunk/lib/Headers/xmmintrin.h

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=289159=289158=289159=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Thu Dec  8 17:58:39 2016
@@ -1560,7 +1560,7 @@ _mm_cvtss_f32(__m128 __a)
   return __a[0];
 }
 
-/// \brief Loads two packed float values from the address __p into the
+/// \brief Loads two packed float values from the address \a __p into the
 /// high-order bits of a 128-bit vector of [4 x float]. The low-order bits
 /// are copied from the low-order bits of the first operand.
 ///
@@ -1587,9 +1587,9 @@ _mm_loadh_pi(__m128 __a, const __m64 *__
   return __builtin_shufflevector(__a, __bb, 0, 1, 4, 5);
 }
 
-/// \brief Loads two packed float values from the address __p into the 
low-order
-///bits of a 128-bit vector of [4 x float]. The high-order bits are copied
-///from the high-order bits of the first operand.
+/// \brief Loads two packed float values from the address \a __p into the
+///low-order bits of a 128-bit vector of [4 x float]. The high-order bits
+///are copied from the high-order bits of the first operand.
 ///
 /// \headerfile 
 ///
@@ -1965,7 +1965,7 @@ _mm_store_ps(float *__p, __m128 __a)
 ///A pointer to a 128-bit memory location.
 /// \param __a
 ///A 128-bit vector of [4 x float] whose lower 32 bits are stored to each
-///of the four contiguous elements pointed by __p.
+///of the four contiguous elements pointed by \a __p.
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_store1_ps(float *__p, __m128 __a)
 {
@@ -1985,7 +1985,7 @@ _mm_store1_ps(float *__p, __m128 __a)
 ///A pointer to a 128-bit memory location.
 /// \param __a
 ///A 128-bit vector of [4 x float] whose lower 32 bits are stored to each
-///of the four contiguous elements pointed by __p.
+///of the four contiguous elements pointed by \a __p.
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_store_ps1(float *__p, __m128 __a)
 {
@@ -2114,9 +2114,9 @@ void _mm_sfence(void);
 ///
 /// This intrinsic corresponds to the \c VPEXTRW / PEXTRW instruction.
 ///
-/// \param __a
+/// \param a
 ///A 64-bit vector of [4 x i16].
-/// \param __n
+/// \param n
 ///An immediate integer operand that determines which bits are extracted:
 ///0: Bits [15:0] are copied to the destination.
 ///1: Bits [31:16] are copied to the destination.
@@ -2128,7 +2128,7 @@ void _mm_sfence(void);
 
 /// \brief Copies data from the 64-bit vector of [4 x i16] to the destination,
 ///and inserts the lower 16-bits of an integer operand at the 16-bit offset
-///specified by the immediate operand __n.
+///specified by the immediate operand \a n.
 ///
 /// \headerfile 
 ///
@@ -2138,12 +2138,12 @@ void _mm_sfence(void);
 ///
 /// This intrinsic corresponds to the \c VPINSRW / PINSRW instruction.
 ///
-/// \param __a
+/// \param a
 ///A 64-bit vector of [4 x i16].
-/// \param __d
+/// \param d
 ///An integer. The lower 16-bit value from this operand is written to the
-///destination at the offset specified by operand __n.
-/// \param __n
+///destination at the offset specified by operand \a n.
+/// \param n
 ///An immediate integer operant that determines which the bits to be used
 ///in the destination.
 ///0: Bits [15:0] are copied to the destination.
@@ -2151,7 +2151,7 @@ void _mm_sfence(void);
 ///2: Bits [47:32] are copied to the destination.
 ///3: Bits [63:48] are copied to the destination.
 ///The remaining bits in the destination are copied from the corresponding
-///bits in operand __a.
+///bits in operand \a a.
 /// \returns A 64-bit integer vector containing the copied packed data from the
 ///operands.
 #define _mm_insert_pi16(a, d, n) __extension__ ({ \
@@ -2285,17 +2285,17 @@ _mm_mulhi_pu16(__m64 __a, __m64 __b)
 ///A 64-bit integer vector containing the values to be shuffled.
 /// \param n
 ///An immediate value containing an 8-bit value specifying which elements 
to
-///copy from a. The destinations within the 64-bit destination are assigned
-///values as follows:
+///copy from \a a. The destinations within the 64-bit destination are
+///assigned values as follows:
 ///Bits [1:0] are used to assign values to bits [15:0] in the destination.
 ///Bits [3:2] are used to assign values to bits [31:16] in the destination.
 ///Bits [5:4] are used to assign values to bits [47:32] in the destination.
 ///Bits [7:6] 

[libcxx] r289158 - Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.

2016-12-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec  8 17:57:08 2016
New Revision: 289158

URL: http://llvm.org/viewvc/llvm-project?rev=289158=rev
Log:
Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.

This patch removes libc++'s tuple extension which allowed it to be
constructed from fewer initializers than elements; with the remaining
elements being default constructed. However the implicit version of
this extension breaks conforming code. For example:

int fun(std::string);
int fun(std::tuple);
int x = fun("hello"); // ambigious

Because existing code may already depend on this extension it can be re-enabled
by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION.

Note that the explicit version of this extension is still supported,
although it's somewhat less useful than the implicit one.

Added:
libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/

libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/disable_reduced_arity_initialization_extension.pass.cpp

libcxx/trunk/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/enable_reduced_arity_initialization_extension.pass.cpp
Modified:
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/tuple

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=289158=289157=289158=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Thu Dec  8 17:57:08 2016
@@ -155,3 +155,30 @@ thread safety annotations.
   Defining this macro and then building libc++ with hidden visibility gives a
   build of libc++ which does not export any symbols, which can be useful when
   building statically for inclusion into another library.
+
+**_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**:
+  This macro is used to re-enable an extension in `std::tuple` which allowed
+  it to be implicitly constructed from fewer initializers than contained
+  elements. Elements without an initializer are default constructed. For 
example:
+
+  .. code-block:: cpp
+
+std::tuple foo() {
+  return {"hello world", 42}; // default constructs error_code
+}
+
+
+  Since libc++ 4.0 this extension has been disabled by default. This macro
+  may be defined to re-enable it in order to support existing code that depends
+  on the extension. New use of this extension should be discouraged.
+  See `PR 27374 `_ for more information.
+
+  Note: The "reduced-arity-initialization" extension is still offered but only
+  for explicit conversions. Example:
+
+  .. code-block:: cpp
+
+auto foo() {
+  using Tup = std::tuple;
+  return Tup{"hello world", 42}; // explicit constructor called. OK.
+}

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=289158=289157=289158=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Thu Dec  8 17:57:08 2016
@@ -477,6 +477,12 @@ class _LIBCPP_TYPE_VIS_ONLY tuple
 
 base base_;
 
+#if defined(_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION)
+static constexpr bool _EnableImplicitReducedArityExtension = true;
+#else
+static constexpr bool _EnableImplicitReducedArityExtension = false;
+#endif
+
 template 
 struct _PackExpandsToThisTuple : false_type {};
 
@@ -703,11 +709,17 @@ public:
) {}
 
 template ::value,
   typename enable_if
   <
  _CheckArgsConstructor<
- sizeof...(_Up) <= sizeof...(_Tp)
- && !_PackExpandsToThisTuple<_Up...>::value
+ sizeof...(_Up) == sizeof...(_Tp)
+ && !_PackIsTuple
+ >::template __enable_implicit<_Up...>() ||
+_CheckArgsConstructor<
+_EnableImplicitReducedArityExtension
+&& sizeof...(_Up) < sizeof...(_Tp)
+&& !_PackIsTuple
  >::template __enable_implicit<_Up...>(),
  bool
   >::type = false
@@ -735,7 +747,12 @@ public:
  _CheckArgsConstructor<
  sizeof...(_Up) <= sizeof...(_Tp)
  && !_PackExpandsToThisTuple<_Up...>::value
- >::template __enable_explicit<_Up...>(),
+ >::template __enable_explicit<_Up...>() ||
+ _CheckArgsConstructor<
+

r289154 - [DOXYGEN] Improved doxygen comments.

2016-12-08 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Dec  8 17:32:07 2016
New Revision: 289154

URL: http://llvm.org/viewvc/llvm-project?rev=289154=rev
Log:
[DOXYGEN] Improved doxygen comments.

Improved doxygen comments for fxsrintrin.h and mmintrin.h intrinsics by 
taagging parameter names with \a doxygen command to display parameters in 
italics.

Formatted comments to fit into 80 chars.



Modified:
cfe/trunk/lib/Headers/fxsrintrin.h
cfe/trunk/lib/Headers/mmintrin.h

Modified: cfe/trunk/lib/Headers/fxsrintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/fxsrintrin.h?rev=289154=289153=289154=diff
==
--- cfe/trunk/lib/Headers/fxsrintrin.h (original)
+++ cfe/trunk/lib/Headers/fxsrintrin.h Thu Dec  8 17:32:07 2016
@@ -31,7 +31,7 @@
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__,  
__target__("fxsr")))
 
 /// \brief Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte
-///memory region pointed to by the input parameter __p.
+///memory region pointed to by the input parameter \a __p.
 ///
 /// \headerfile 
 ///
@@ -47,9 +47,9 @@ _fxsave(void *__p)
 }
 
 /// \brief Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
-///memory region pointed to by the input parameter __p. The contents of 
this
-///memory region should have been written to by a previous _fxsave or
-///_fxsave64 intrinsic.
+///memory region pointed to by the input parameter \a __p. The contents of
+///this memory region should have been written to by a previous \c _fxsave
+///or \c _fxsave64 intrinsic.
 ///
 /// \headerfile 
 ///
@@ -66,7 +66,7 @@ _fxrstor(void *__p)
 
 #ifdef __x86_64__
 /// \brief Saves the XMM, MMX, MXCSR and x87 FPU registers into a 512-byte
-///memory region pointed to by the input parameter__p.
+///memory region pointed to by the input parameter \a __p.
 ///
 /// \headerfile 
 ///
@@ -82,9 +82,9 @@ _fxsave64(void *__p)
 }
 
 /// \brief Restores the XMM, MMX, MXCSR and x87 FPU registers from the 512-byte
-///memory region pointed to by the input parameter __p. The contents of 
this
-///memory region should have been written to by a previous _fxsave or
-///_fxsave64 intrinsic.
+///memory region pointed to by the input parameter \a __p. The contents of
+///this memory region should have been written to by a previous \c _fxsave
+///or \c _fxsave64 intrinsic.
 ///
 /// \headerfile 
 ///

Modified: cfe/trunk/lib/Headers/mmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/mmintrin.h?rev=289154=289153=289154=diff
==
--- cfe/trunk/lib/Headers/mmintrin.h (original)
+++ cfe/trunk/lib/Headers/mmintrin.h Thu Dec  8 17:32:07 2016
@@ -734,7 +734,8 @@ _mm_mullo_pi16(__m64 __m1, __m64 __m2)
 /// \param __count
 ///A 64-bit integer vector interpreted as a single 64-bit integer.
 /// \returns A 64-bit integer vector of [4 x i16] containing the left-shifted
-///values. If __count is greater or equal to 16, the result is set to all 
0.
+///values. If \a __count is greater or equal to 16, the result is set to 
all
+///0.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _mm_sll_pi16(__m64 __m, __m64 __count)
 {
@@ -755,7 +756,8 @@ _mm_sll_pi16(__m64 __m, __m64 __count)
 /// \param __count
 ///A 32-bit integer value.
 /// \returns A 64-bit integer vector of [4 x i16] containing the left-shifted
-///values. If __count is greater or equal to 16, the result is set to all 
0.
+///values. If \a __count is greater or equal to 16, the result is set to 
all
+///0.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _mm_slli_pi16(__m64 __m, int __count)
 {
@@ -777,7 +779,8 @@ _mm_slli_pi16(__m64 __m, int __count)
 /// \param __count
 ///A 64-bit integer vector interpreted as a single 64-bit integer.
 /// \returns A 64-bit integer vector of [2 x i32] containing the left-shifted
-///values. If __count is greater or equal to 32, the result is set to all 
0.
+///values. If \a __count is greater or equal to 32, the result is set to 
all
+///0.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _mm_sll_pi32(__m64 __m, __m64 __count)
 {
@@ -798,7 +801,8 @@ _mm_sll_pi32(__m64 __m, __m64 __count)
 /// \param __count
 ///A 32-bit integer value.
 /// \returns A 64-bit integer vector of [2 x i32] containing the left-shifted
-///values. If __count is greater or equal to 32, the result is set to all 
0.
+///values. If \a __count is greater or equal to 32, the result is set to 
all
+///0.
 static __inline__ __m64 __DEFAULT_FN_ATTRS
 _mm_slli_pi32(__m64 __m, int __count)
 {
@@ -818,7 +822,7 @@ _mm_slli_pi32(__m64 __m, int __count)
 /// \param __count
 ///A 64-bit integer vector interpreted as a single 64-bit integer.
 /// \returns A 64-bit integer vector containing the left-shifted value. If
-/// __count is greater or 

[PATCH] D21453: Add support for attribute "overallocated"

2016-12-08 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/Decl.h:3250
+  /// This is true if this struct ends with an array marked 'flexible_array'.
+  bool HasFlexibleArrayAttr : 1;
+

rsmith wrote:
> How is this different from `HasFlexibleArrayMember`? Do we really need both?
As I commented below, we don't need both if we are going to treat an array with 
flexible_array attribute like other existing flexible arrays.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2173
+def err_flexible_array_nested : Error<
+  "struct with a member marked 'flexible_array' cannot be nested">;
 def err_aligned_attribute_argument_not_int : Error<

rsmith wrote:
> I don't think it's very clear what "nested" means here. I assume you mean 
> that a struct with a `flexible_array` member can't be used as the type of a 
> field. If so, why not? C allows that for other kinds of flexible array 
> members.
Yes, that's what I meant. I disallowed using struct with a flexible_array 
member to be used as a field in another struct just because the use case I had 
in mind didn't need that (see the link below). We don't need to restrict its 
usage if we are going to handle it like other existing flexible array members.

http://lists.llvm.org/pipermail/cfe-dev/2016-February/047561.html



Comment at: lib/AST/ExprConstant.cpp:5200
+} else
   Result.Designator.setInvalid();
 return true;

rsmith wrote:
> Should we also set `HasFlexibleArrayAttr` on *real* flexible array members 
> (which will be fields with `IncompleteArrayType`) rather than invalidating 
> the designator?
I'm assuming you are also suggesting we call Result.addArray on "real" flexible 
arrays too?


https://reviews.llvm.org/D21453



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


[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-12-08 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Any thoughts on this @rsmith ?


https://reviews.llvm.org/D26267



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


r289144 - [sanitizers] lsan+sancov doesn't need ubsanrt (multi def error)

2016-12-08 Thread Mike Aizatsky via cfe-commits
Author: aizatsky
Date: Thu Dec  8 16:25:01 2016
New Revision: 289144

URL: http://llvm.org/viewvc/llvm-project?rev=289144=rev
Log:
[sanitizers] lsan+sancov doesn't need ubsanrt (multi def error)

Reviewers: eugenis

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

Modified:
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=289144=289143=289144=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Thu Dec  8 16:25:01 2016
@@ -165,7 +165,8 @@ bool SanitizerArgs::needsUbsanRt() const
   return ((Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) ||
   CoverageFeatures) &&
  !Sanitizers.has(Address) && !Sanitizers.has(Memory) &&
- !Sanitizers.has(Thread) && !Sanitizers.has(DataFlow) && !CfiCrossDso;
+ !Sanitizers.has(Thread) && !Sanitizers.has(DataFlow) && 
+ !Sanitizers.has(Leak) && !CfiCrossDso;
 }
 
 bool SanitizerArgs::needsCfiRt() const {

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=289144=289143=289144=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Thu Dec  8 16:25:01 2016
@@ -289,10 +289,24 @@
 //
 // CHECK-LSAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-LSAN-LINUX-NOT: "-lc"
+// CHECK-LSAN-LINUX-NOT: libclang_rt.ubsan
 // CHECK-LSAN-LINUX: libclang_rt.lsan-x86_64.a"
 // CHECK-LSAN-LINUX: "-lpthread"
 // CHECK-LSAN-LINUX: "-ldl"
 
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN:  -target x86_64-unknown-linux -fsanitize=leak -fsanitize-coverage=func 
\
+// RUN:  --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LSAN-COV-LINUX %s
+//
+// CHECK-LSAN-COV-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LSAN-COV-LINUX-NOT: "-lc"
+// CHECK-LSAN-COV-LINUX-NOT: libclang_rt.ubsan
+// CHECK-LSAV-COV-LINUX: libclang_rt.lsan-x86_64.a"
+// CHECK-LSAN-COV-LINUX-NOT: libclang_rt.ubsan
+// CHECK-LSAN-COV-LINUX: "-lpthread"
+// CHECK-LSAN-COV-LINUX: "-ldl"
+
 // RUN: %clang -fsanitize=leak,address %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \


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


[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-08 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D27166#617621, @Prazek wrote:.

> Does it work for cases like?


Yes; `replaceExpr()` checks that the variable has the same unqualified type as 
the initializer and the same canonical type as other variables in the 
declaration.


https://reviews.llvm.org/D27166



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


[PATCH] D27279: Store decls in prototypes on the declarator instead of in the AST

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



Comment at: include/clang/Sema/DeclSpec.h:1240
+/// in the prototype. These are generally tag types or enumerators.
+unsigned NumDeclsInPrototype : 8;
+

rnk wrote:
> rsmith wrote:
> > It seems plausible that generated code could have more than 256 such 
> > declarations. This class has a pointer, a set of bit-fields, 12 
> > `unsigned`s, and another pointer, so we could give this a full 32 bits 
> > without increasing the size of the class. Alternatively we could share the 
> > storage with `NumExceptions`, since this can only be non-zero in C and that 
> > can only be non-zero in C++.
> I did it as a union with the EH machinery initially, but it changes our 
> behavior on this test case:
>   void f(struct Foo {} o) {} // error in C++
>   struct Foo {}; // follow on error for redefining type Foo
> 
> We actually have test cases for this at 
> clang/test/SemaCXX/type-definition-in-specifier.cpp. I don't think it's 
> important to preserve that exact behavior, though, so performance may be more 
> important. I just did it this way to avoid premature optimization.
As discussed offline, I updated the C++ test case and made this stuff not take 
up any space in C++ mode.



Comment at: test/Misc/ast-dump-decl.c:109-110
 // CHECK:  FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
-// CHECK-NEXT:   EnumDecl
-// CHECK-NEXT: EnumConstantDecl{{.*}} e
 // CHECK-NEXT:   ParmVarDecl{{.*}} x

rnk wrote:
> rsmith wrote:
> > Why is this not here any more? Looks like SemaDecl.cpp:8255 should have 
> > added it to this `DeclContext`. It'd be nice for `-ast-dump` to still dump 
> > these declarations somewhere.
> I changed things to dump non-parameter decls in the function now, but we only 
> move NamedDecls into the function DeclContext, so the output is a little 
> different. Think it matters?
I reverted my change to the dumper. Without more work, it's hard to know what 
decls came from the function prototype and which come from the function body. 
Filtering our parameters isn't enough. Think it's OK as is?


https://reviews.llvm.org/D27279



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


[PATCH] D27279: Store decls in prototypes on the declarator instead of in the AST

2016-12-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk updated this revision to Diff 80827.
rnk marked an inline comment as done.
rnk added a comment.

- Reuse EH specifier storage in C
- Revert dumper change


https://reviews.llvm.org/D27279

Files:
  include/clang/AST/Decl.h
  include/clang/Sema/DeclSpec.h
  include/clang/Sema/Sema.h
  lib/AST/ASTDumper.cpp
  lib/AST/Decl.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  test/Misc/ast-dump-decl.c
  test/PCH/decl-in-prototype.c
  test/Sema/decl-in-prototype.c
  test/SemaCXX/type-definition-in-specifier.cpp

Index: test/SemaCXX/type-definition-in-specifier.cpp
===
--- test/SemaCXX/type-definition-in-specifier.cpp
+++ test/SemaCXX/type-definition-in-specifier.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fexceptions -fcxx-exceptions -verify %s
 
 struct S0;
 struct S1;
@@ -30,7 +30,7 @@
 
 void pr19018_1 (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}}
 void pr19018_1a (enum e19018_1 {qq} x); // expected-error{{cannot be defined in a parameter type}}
-e19018_1 x2;  // expected-error{{unknown type name 'e19018_1'}}
+e19018_1 x2;
 
 void pr19018_2 (enum {qq} x); // expected-error{{cannot be defined in a parameter type}}
 void pr19018_3 (struct s19018_2 {int qq;} x); // expected-error{{cannot be defined in a parameter type}}
@@ -53,14 +53,19 @@
 
 struct s19018b {
   void func1 (enum en_2 {qq} x); // expected-error{{cannot be defined in a parameter type}}
-  en_2 x1;  // expected-error{{unknown type name 'en_2'}}
+  en_2 x1;
   void func2 (enum en_3 {qq} x); // expected-error{{cannot be defined in a parameter type}}
-  enum en_3 x2; // expected-error{{ISO C++ forbids forward references to 'enum' types}} \
-// expected-error{{field has incomplete type 'enum en_3'}} \
-// expected-note{{forward declaration of 'en_3'}}
+  enum en_3 x2;
 };
 
 struct pr18963 {
-  short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}}
-  long foo5 (float foo6 = foo4);  // expected-error{{use of undeclared identifier 'foo4'}}
+  short bar5 (struct foo4 {} bar2); // expected-error{{'foo4' cannot be defined in a parameter type}} \
+// expected-note{{declared here}}
+
+  long foo5 (float foo6 = foo4);  // expected-error{{'foo4' does not refer to a value}}
 };
+
+// expected-error@+2 {{cannot be defined in a parameter type}}
+// expected-note@+1 {{previous definition is here}}
+void func_with_eh_and_type(struct type_in_eh {} o) throw(int) {}
+struct type_in_eh {}; // expected-error {{redefinition of 'type_in_eh'}}
Index: test/Sema/decl-in-prototype.c
===
--- test/Sema/decl-in-prototype.c
+++ test/Sema/decl-in-prototype.c
@@ -1,13 +1,19 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
+#define SA(n, c) int arr##n[(c) ? 1 : -1] = {}
+
 const int AA = 5;
 
 int f1(enum {AA,BB} E) { // expected-warning {{will not be visible outside of this function}}
-return BB;
+  SA(1, AA == 0);
+  SA(2, BB == 1);
+  return BB;
 }
 
 int f2(enum {AA=7,BB} E) { // expected-warning {{will not be visible outside of this function}}
-return AA;
+  SA(1, AA == 7);
+  SA(2, BB == 8);
+  return AA;
 }
 
 struct a {
@@ -38,3 +44,11 @@
 
 // Only warn once, even if we create two declarations.
 void f(struct q *, struct __attribute__((aligned(4))) q *); // expected-warning {{will not be visible outside}}
+
+// This enum inside the function pointer parameter shouldn't leak into the
+// function.
+enum { BB = 0 };
+void enum_in_fun_in_fun(void (*fp)(enum { AA, BB } e)) { // expected-warning {{will not be visible}}
+  SA(1, AA == 5);
+  SA(2, BB == 0);
+}
Index: test/PCH/decl-in-prototype.c
===
--- /dev/null
+++ test/PCH/decl-in-prototype.c
@@ -0,0 +1,27 @@
+// Test that we serialize the enum decl in the function prototype somehow.
+// These decls aren't serialized quite the same way as parameters.
+
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -emit-llvm -o - %s | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define i32 @main()
+// CHECK:   ret i32 1
+
+#ifndef HEADER
+#define HEADER
+
+static inline __attribute__((always_inline)) f(enum { x, y } p) {
+  return y;
+}
+
+#else
+
+int main() {
+  return f(0);
+}
+
+#endif
Index: test/Misc/ast-dump-decl.c
===
--- test/Misc/ast-dump-decl.c
+++ test/Misc/ast-dump-decl.c
@@ -106,12 +106,16 @@
   return x;
 }
 // CHECK:  FunctionDecl{{.*}} TestFunctionDecl 'int (int, enum {{.*}})'
-// CHECK-NEXT:   EnumDecl

r289116 - [DOXYGEN] Improved doxygen comments for emmintrin.h intrinsics.

2016-12-08 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Dec  8 16:10:51 2016
New Revision: 289116

URL: http://llvm.org/viewvc/llvm-project?rev=289116=rev
Log:
[DOXYGEN] Improved doxygen comments for emmintrin.h intrinsics.

Tagged parameter names with \a doxygen command to display parameters in italics.
Formatted comments to fit into 80 chars.



Modified:
cfe/trunk/lib/Headers/emmintrin.h

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=289116=289115=289116=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Thu Dec  8 16:10:51 2016
@@ -232,8 +232,8 @@ _mm_div_pd(__m128d __a, __m128d __b)
 ///A 128-bit vector of [2 x double] containing one of the operands. The
 ///square root is calculated using the lower 64 bits of this operand.
 /// \returns A 128-bit vector of [2 x double] whose lower 64 bits contain the
-///square root of the lower 64 bits of operand __b, and whose upper 64 bits
-///are copied from the upper 64 bits of operand __a.
+///square root of the lower 64 bits of operand \a __b, and whose upper 64
+///bits are copied from the upper 64 bits of operand \a __a.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_sqrt_sd(__m128d __a, __m128d __b)
 {
@@ -674,12 +674,12 @@ _mm_cmpnge_pd(__m128d __a, __m128d __b)
 ///
 /// \param __a
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __b.
+///compared to the lower double-precision value of \a __b.
 /// \param __b
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __a.
+///compared to the lower double-precision value of \a __a.
 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
-///results. The upper 64 bits are copied from the upper 64 bits of __a.
+///results. The upper 64 bits are copied from the upper 64 bits of \a __a.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_cmpeq_sd(__m128d __a, __m128d __b)
 {
@@ -698,12 +698,12 @@ _mm_cmpeq_sd(__m128d __a, __m128d __b)
 ///
 /// \param __a
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __b.
+///compared to the lower double-precision value of \a __b.
 /// \param __b
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __a.
+///compared to the lower double-precision value of \a __a.
 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
-///results. The upper 64 bits are copied from the upper 64 bits of __a.
+///results. The upper 64 bits are copied from the upper 64 bits of \a __a.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_cmplt_sd(__m128d __a, __m128d __b)
 {
@@ -722,12 +722,12 @@ _mm_cmplt_sd(__m128d __a, __m128d __b)
 ///
 /// \param __a
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __b.
+///compared to the lower double-precision value of \a __b.
 /// \param __b
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __a.
+///compared to the lower double-precision value of \a __a.
 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
-///results. The upper 64 bits are copied from the upper 64 bits of __a.
+///results. The upper 64 bits are copied from the upper 64 bits of \a __a.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_cmple_sd(__m128d __a, __m128d __b)
 {
@@ -746,12 +746,12 @@ _mm_cmple_sd(__m128d __a, __m128d __b)
 ///
 /// \param __a
 /// A 128-bit vector of [2 x double]. The lower double-precision value is
-/// compared to the lower double-precision value of __b.
+/// compared to the lower double-precision value of \a __b.
 /// \param __b
 /// A 128-bit vector of [2 x double]. The lower double-precision value is
-/// compared to the lower double-precision value of __a.
+/// compared to the lower double-precision value of \a __a.
 /// \returns A 128-bit vector. The lower 64 bits contains the comparison
-/// results. The upper 64 bits are copied from the upper 64 bits of __a.
+/// results. The upper 64 bits are copied from the upper 64 bits of \a __a.
 static __inline__ __m128d __DEFAULT_FN_ATTRS
 _mm_cmpgt_sd(__m128d __a, __m128d __b)
 {
@@ -771,12 +771,12 @@ _mm_cmpgt_sd(__m128d __a, __m128d __b)
 ///
 /// \param __a
 ///A 128-bit vector of [2 x double]. The lower double-precision value is
-///compared to the lower double-precision value of __b.
+///compared to the lower double-precision value of \a __b.
 /// \param __b
 ///A 128-bit 

[libcxx] r289109 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:38:32 2016
New Revision: 289109

URL: http://llvm.org/viewvc/llvm-project?rev=289109=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 5/7.

Instead of storing double in double and then truncating to int, store int in 
long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.

Fixes D27542.

Modified:

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp?rev=289109=289108=289109=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
 Thu Dec  8 15:38:32 2016
@@ -23,9 +23,9 @@
 int main()
 {
 {
-typedef std::pair T0;
-typedef std::tuple T1;
-T0 t0(2.5, 'a');
+typedef std::pair T0;
+typedef std::tuple T1;
+T0 t0(2, 'a');
 T1 t1;
 t1 = t0;
 assert(std::get<0>(t1) == 2);

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp?rev=289109=289108=289109=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
 Thu Dec  8 15:38:32 2016
@@ -36,26 +36,26 @@ struct D
 int main()
 {
 {
-typedef std::tuple T0;
-typedef std::tuple T1;
-T0 t0(2.5);
+typedef std::tuple T0;
+typedef std::tuple T1;
+T0 t0(2);
 T1 t1;
 t1 = t0;
 assert(std::get<0>(t1) == 2);
 }
 {
-typedef std::tuple T0;
-typedef std::tuple T1;
-T0 t0(2.5, 'a');
+typedef std::tuple T0;
+typedef std::tuple T1;
+T0 t0(2, 'a');
 T1 t1;
 t1 = t0;
 assert(std::get<0>(t1) == 2);
 assert(std::get<1>(t1) == int('a'));
 }
 {
-typedef std::tuple T0;
-typedef std::tuple T1;
-T0 t0(2.5, 'a', D(3));
+typedef std::tuple T0;
+typedef std::tuple T1;
+T0 t0(2, 'a', D(3));
 T1 t1;
 t1 = t0;
 assert(std::get<0>(t1) == 2);
@@ -65,10 +65,10 @@ int main()
 {
 D d(3);
 D d2(2);
-typedef std::tuple T0;
-typedef std::tuple T1;
-T0 t0(2.5, 'a', d2);
-T1 t1(1.5, 'b', d);
+typedef std::tuple T0;
+typedef std::tuple T1;
+T0 t0(2, 'a', d2);
+T1 t1(1, 'b', d);
 t1 = t0;
 assert(std::get<0>(t1) == 2);
 assert(std::get<1>(t1) == int('a'));

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp?rev=289109=289108=289109=diff

[PATCH] D27166: [clang-tidy] Enhance modernize-use-auto to templated function casts

2016-12-08 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a reviewer: staronj.
Prazek added a comment.

gosh, I found it too late. Jakub started to work on the same problem and he 
have made initial check for it.
One of the problems he got was multideclarations.
Does it work for cases like?

  long a = lexical_cast(z), b = lexical_cast(y);

Other test:

  Base *p = dyn_cast(b);


https://reviews.llvm.org/D27166



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


[libcxx] r289108 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:38:23 2016
New Revision: 289108

URL: http://llvm.org/viewvc/llvm-project?rev=289108=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 4/7.

Change char to long and remove some char casts. This preserves test coverage 
for tuple's
heterogeneous comparisons, while avoiding int-to-char truncation warnings.

Fixes D27541.

Modified:
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp?rev=289108=289107=289108=diff
==
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp 
(original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp Thu 
Dec  8 15:38:23 2016
@@ -51,95 +51,95 @@ int main()
 }
 {
 typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T2;
 const T1 t1(1, 2);
-const T2 t2(1, char(2));
+const T2 t2(1, 2);
 assert(t1 == t2);
 assert(!(t1 != t2));
 }
 {
 typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T2;
 const T1 t1(1, 2);
-const T2 t2(1, char(3));
+const T2 t2(1, 3);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
 typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T2;
 const T1 t1(1, 2);
-const T2 t2(1.1, char(2));
+const T2 t2(1.1, 2);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
 typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T2;
 const T1 t1(1, 2);
-const T2 t2(1.1, char(3));
+const T2 t2(1.1, 3);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1, 2, 3);
 assert(t1 == t2);
 assert(!(t1 != t2));
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1.1, 2, 3);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1, 3, 3);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1, 2, 4);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1, 3, 2);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1.1, 2, 2);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1.1, 3, 3);
 assert(!(t1 == t2));
 assert(t1 != t2);
 }
 {
-typedef std::tuple T1;
-typedef std::tuple T2;
+typedef std::tuple T1;
+typedef std::tuple T2;
 const T1 t1(1, 2, 3);
 const T2 t2(1.1, 3, 2);
 assert(!(t1 == t2));
@@ -147,8 

[libcxx] r289107 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:38:14 2016
New Revision: 289107

URL: http://llvm.org/viewvc/llvm-project?rev=289107=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 3/7.

Add static_cast when constructing pair from (Something, 
int).

Fixes D27540.

Modified:

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp

libcxx/trunk/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_non_const.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pair.astuple/get_rv.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_const_pair_U_V.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/assign_rv_pair_U_V.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/const_pair_U_V_cxx03.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/copy_ctor.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/move_ctor.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp
libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/comparison.pass.cpp

libcxx/trunk/test/std/utilities/utility/pairs/pairs.spec/non_member_swap.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp?rev=289107=289106=289107=diff
==
--- 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp
 Thu Dec  8 15:38:14 2016
@@ -37,22 +37,22 @@ int main()
 typedef std::pair P;
 C c;
 C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5, 3));
+R r = c.insert(e, P(3.5, static_cast(3)));
 assert(c.size() == 1);
 assert(r->first == 3.5);
 assert(r->second == 3);
 
-r = c.insert(c.end(), P(3.5, 4));
+r = c.insert(c.end(), P(3.5, static_cast(4)));
 assert(c.size() == 1);
 assert(r->first == 3.5);
 assert(r->second == 3);
 
-r = c.insert(c.end(), P(4.5, 4));
+r = c.insert(c.end(), P(4.5, static_cast(4)));
 assert(c.size() == 2);
 assert(r->first == 4.5);
 assert(r->second == 4);
 
-r = c.insert(c.end(), P(5.5, 4));
+r = c.insert(c.end(), P(5.5, static_cast(4)));
 assert(c.size() == 3);
 assert(r->first == 5.5);
 assert(r->second == 4);
@@ -90,22 +90,22 @@ int main()
 typedef std::pair P;
 C c;
 C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5, 3));
+R r = c.insert(e, P(3.5, static_cast(3)));
 assert(c.size() == 1);
 assert(r->first == 3.5);
 assert(r->second == 3);
 
-r = c.insert(c.end(), P(3.5, 4));
+r = c.insert(c.end(), P(3.5, static_cast(4)));
 assert(c.size() == 1);
 assert(r->first == 3.5);
 assert(r->second == 3);
 
-r = c.insert(c.end(), P(4.5, 4));
+r = c.insert(c.end(), P(4.5, static_cast(4)));
 assert(c.size() == 2);
 assert(r->first == 4.5);
 assert(r->second == 4);
 
-r = c.insert(c.end(), P(5.5, 4));
+r = c.insert(c.end(), P(5.5, static_cast(4)));
 assert(c.size() == 3);
 assert(r->first == 5.5);
 assert(r->second == 4);

Modified: 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp?rev=289107=289106=289107=diff
==
--- 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp
 Thu Dec  8 15:38:14 2016
@@ -32,25 +32,25 @@ int main()
 typedef std::pair R;
 typedef std::pair P;
 C c;
-R r = c.insert(P(3.5, 3));
+R r = c.insert(P(3.5, 

[libcxx] r289111 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 7/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:38:57 2016
New Revision: 289111

URL: http://llvm.org/viewvc/llvm-project?rev=289111=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 7/7.

test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
Add static_cast because basic_istream::get() returns int_type (N4606 
27.7.2.3 [istream.unformatted]/4).

test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
Add static_cast because toupper() returns int (C11 7.4.2.2/1).

test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
This test is intentionally writing doubles to ostream_iterator.
It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing 
for MSVC.

test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
Given `extern float zero;`, the expression `1./zero` has type double, which 
emits a truncation warning
when being passed to test() taking float. The fix is to say `1.f/zero` 
which has type float.

test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
These tests were constructing std::complex(x, 0), emitting truncation 
warnings when x is long long.
Saying static_cast(x) avoids this.

test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
This was using `int s` to construct and seed a linear_congruential_engine, where T is
unsigned short/unsigned int/unsigned long/unsigned long long. That emits a 
truncation warning in the
unsigned short case. Because the range [0, 20) is tiny and we aren't doing 
anything else with the index,
we can just iterate with `T s`.

test/std/re/re.traits/value.pass.cpp
regex_traits::value()'s first parameter is wchar_t (N4606 28.7 
[re.traits]/13). This loop is
using int to iterate through ['g', 0x), emitting a truncation warning from 
int to wchar_t
(which is 16-bit for some of us). Because the bound is exclusive, we can just 
iterate with wchar_t.

test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
This test is a little strange. It's trying to verify that basic_string's (InIt, 
InIt) range constructor
isn't confused by "N copies of C" when N and C have the same integral type. To 
do this, it was
testing (100, 65), but that eventually emits truncation warnings from int to 
char. There's a simple way
to avoid this - passing (static_cast(100), static_cast(65)) also 
exercises the disambiguation.
(And 100 is representable even when char has a signed range.)

test/std/strings/string.view/string.view.hash/string_view.pass.cpp
Add static_cast because `'0' + i` has type int.

test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
What's more horrible than nested bind()? pow() overloads! This operator()(T a, 
T b) was assuming that
std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 
26.9.1 [cmath.syn]/2
says that pow(int, int) returns double, so this was truncating double to int.
Adding static_cast silences this.

test/std/utilities/function.objects/unord.hash/integral.pass.cpp
This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` 
but that's truncating
when T is short. (And super truncating when T is bool.) Adding static_cast 
silences this.

test/std/utilities/utility/exchange/exchange.pass.cpp
First, this was exchanging 67.2 into an int, but that's inherently truncating.
Changing this to static_cast(67) avoids the truncation while preserving 
the
"what if T and U are different" test coverage.
Second, this was exchanging {} with the explicit type float into an int, and 
that's also
inherently truncating. Specifying short is just as good.

test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
Add static_cast. Note that this affects template argument deduction for 
make_pair(),
better fulfilling the test's intent. For example, this was saying
`typedef std::pair P1; P1 p1 = std::make_pair(3, 4);` but that was 
asking
make_pair() to return pair, which was then being converted to 
pair.
(pair's converting constructors are tested elsewhere.)
Now, std::make_pair(3, static_cast(4)) actually returns pair.
(There's still a conversion from pair to 
pair.)

Fixes D27544.

Modified:

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp

libcxx/trunk/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp

libcxx/trunk/test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp

[libcxx] r289110 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 6/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:38:44 2016
New Revision: 289110

URL: http://llvm.org/viewvc/llvm-project?rev=289110=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 6/7.

test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
(Affects 64-bit architectures.) Include  so we can take/return 
std::ptrdiff_t
(instead of int) in random_shuffle()'s RNG. (C++14 D.12 
[depr.alg.random.shuffle]/2 says that
difference_type is used, and we're shuffling a plain array.)

test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
(Affects 64-bit architectures.) Include  because we're already using 
iterator_traits.
Then, store the result of subtracting two RanIts as difference_type instead of 
long
(which truncates on LLP64 architectures like MSVC x64).

test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
(Affects 64-bit architectures.) Include  so we can store the result of
subtracting two pointers as std::ptrdiff_t (instead of int).

test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
(Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case 
here,
where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). 
Implementations can
have 64-bit pos_type (to handle large files) even when they have 32-bit size_t.

Fixes D27543.

Modified:

libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp

libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp

libcxx/trunk/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp

Modified: 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp?rev=289110=289109=289110=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
 Thu Dec  8 15:38:44 2016
@@ -17,12 +17,13 @@
 
 #include 
 #include 
+#include 
 
 #include "test_macros.h"
 
 struct gen
 {
-int operator()(int n)
+std::ptrdiff_t operator()(std::ptrdiff_t n)
 {
 return n-1;
 }

Modified: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp?rev=289110=289109=289110=diff
==
--- libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp 
(original)
+++ libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp 
Thu Dec  8 15:38:44 2016
@@ -16,6 +16,7 @@
 //   sort(Iter first, Iter last);
 
 #include 
+#include 
 #include 
 
 template 
@@ -23,9 +24,11 @@ void
 test_sort_helper(RI f, RI l)
 {
 typedef typename std::iterator_traits::value_type value_type;
+typedef typename std::iterator_traits::difference_type difference_type;
+
 if (f != l)
 {
-long len = l - f;
+difference_type len = l - f;
 value_type* save(new value_type[len]);
 do
 {

Modified: 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp?rev=289110=289109=289110=diff
==
--- 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
 Thu Dec  8 15:38:44 2016
@@ -16,6 +16,7 @@
 //   stable_sort(Iter first, Iter last);
 
 #include 
+#include 
 #include 
 
 template 
@@ -23,9 +24,11 @@ void
 test_sort_helper(RI f, RI l)
 {
 typedef typename std::iterator_traits::value_type value_type;
+typedef typename std::iterator_traits::difference_type difference_type;
+
 if (f != l)
 {
-long len = l - f;
+difference_type len = l - f;
 value_type* 

[libcxx] r289106 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 2/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:38:01 2016
New Revision: 289106

URL: http://llvm.org/viewvc/llvm-project?rev=289106=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 2/7.

These tests for some guy's transparent operator functors were needlessly 
truncating their
double results to int. Preserving the doubleness makes compilers happier. I'm 
following
existing practice by adding an "// exact in binary" comment when the result 
isn't a whole number.
(The changes from 6 to 6.0 and so forth are stylistic, not critical.)

Fixes D27539.

Modified:

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp

libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp?rev=289106=289105=289106=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/divides.pass.cpp
 Thu Dec  8 15:38:01 2016
@@ -35,7 +35,7 @@ int main()
 constexpr int foo = std::divides () (3, 2);
 static_assert ( foo == 1, "" );
 
-constexpr int bar = std::divides<> () (3.0, 2);
-static_assert ( bar == 1, "" );
+constexpr double bar = std::divides<> () (3.0, 2);
+static_assert ( bar == 1.5, "" ); // exact in binary
 #endif
 }

Modified: 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp?rev=289106=289105=289106=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/minus.pass.cpp
 Thu Dec  8 15:38:01 2016
@@ -35,7 +35,7 @@ int main()
 constexpr int foo = std::minus () (3, 2);
 static_assert ( foo == 1, "" );
 
-constexpr int bar = std::minus<> () (3.0, 2);
-static_assert ( bar == 1, "" );
+constexpr double bar = std::minus<> () (3.0, 2);
+static_assert ( bar == 1.0, "" );
 #endif
 }

Modified: 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp?rev=289106=289105=289106=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/multiplies.pass.cpp
 Thu Dec  8 15:38:01 2016
@@ -35,7 +35,7 @@ int main()
 constexpr int foo = std::multiplies () (3, 2);
 static_assert ( foo == 6, "" );
 
-constexpr int bar = std::multiplies<> () (3.0, 2);
-static_assert ( bar == 6, "" );
+constexpr double bar = std::multiplies<> () (3.0, 2);
+static_assert ( bar == 6.0, "" );
 #endif
 }

Modified: 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp?rev=289106=289105=289106=diff
==
--- 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
 Thu Dec  8 15:38:01 2016
@@ -34,7 +34,7 @@ int main()
 constexpr int foo = std::negate () (3);
 static_assert ( foo == -3, "" );
 
-constexpr int bar = std::negate<> () (3.0);
-static_assert ( bar == -3, "" );
+constexpr double bar = std::negate<> () (3.0);
+static_assert ( bar == -3.0, "" );
 #endif
 }

Modified: 
libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/plus.pass.cpp?rev=289106=289105=289106=diff
==
--- 

[libcxx] r289105 - [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 1/7.

2016-12-08 Thread Stephan T. Lavavej via cfe-commits
Author: stl_msft
Date: Thu Dec  8 15:37:47 2016
New Revision: 289105

URL: http://llvm.org/viewvc/llvm-project?rev=289105=rev
Log:
[libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible 
loss of data", part 1/7.

Given `std::basic_streambuf::int_type __c`, `std::basic_string 
str_`,
and having checked `__c != std::basic_streambuf::traits_type::eof()` 
(substituting typedefs
for clarity), the line `str_.push_back(__c);` is safe according to humans, but 
truncates according
to compilers. `str_.push_back(static_cast(__c));` avoids that problem.

Fixes D27538.

Modified:

libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/input.streams/istream.unformatted/get_streambuf_chart.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/bool.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/double.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/float.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/int.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_double.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/long_long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/short.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_int.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_long_long.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/unsigned_short.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/char_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/signed_char_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.character/unsigned_char_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/basic_ios.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ios_base.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/ostream.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters/streambuf.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.manip/endl.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.manip/ends.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.rvalue/CharT_pointer.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.unformatted/put.pass.cpp

libcxx/trunk/test/std/input.output/iostream.format/output.streams/ostream.unformatted/write.pass.cpp

Modified: 
libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp?rev=289105=289104=289105=diff
==
--- 
libcxx/trunk/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp 
(original)
+++ 

[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

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



Comment at: lib/CodeGen/CGExprScalar.cpp:1532
+  return llvm::ConstantInt::get(ConvertType(DestTy),
+  CGF.getContext().getTargetNullPtrValue(E->getType()));
 assert(!DestTy->isBooleanType() && "bool should use PointerToBool");

yaxunl wrote:
> rjmccall wrote:
> > yaxunl wrote:
> > > rjmccall wrote:
> > > > yaxunl wrote:
> > > > > rjmccall wrote:
> > > > > > Why is this necessary?  ptrtoint on the recursively-emitted null 
> > > > > > pointer should do this automatically.
> > > > > Since the target knows the value in the null pointers, it can fold a 
> > > > > null pointer to integer literal directly.
> > > > > 
> > > > > The above code does that, e.g.
> > > > > 
> > > > > ```
> > > > > void test_cast_null_pointer_to_sizet_calee(size_t arg_private,
> > > > >size_t arg_local,
> > > > >size_t arg_global,
> > > > >size_t arg_constant,
> > > > >size_t arg_generic);
> > > > > 
> > > > > // CHECK-LABEL: test_cast_null_pointer_to_sizet
> > > > > // CHECK: call void @test_cast_null_pointer_to_sizet_calee(i64 -1, 
> > > > > i64 -1, i64 0, i64 0, i64 0)
> > > > > void test_cast_null_pointer_to_sizet(void) {
> > > > >   test_cast_null_pointer_to_sizet_calee((size_t)((private char*)0),
> > > > > (size_t)((local char*)0),
> > > > > (size_t)((global char*)0),
> > > > > (size_t)((constant char*)0),
> > > > > (size_t)((generic char*)0));
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > Without the above code, we only get ptrtoint instructions.
> > > > Oh, does the constant folder not know how to fold ptrtoint(inttoptr(X)) 
> > > > -> X?  I guess that's probably LLVM's nominal target-independence 
> > > > rearing its head.
> > > > 
> > > > Is getting a slightly LLVM constant actually important here?  I would 
> > > > prefer to avoid this complexity (and unnecessary recursive walk) if 
> > > > possible.
> > > Since it's target dependent, it won't be constant folded by the target 
> > > agnostic passes until very late in the backend, which may lose 
> > > optimization opportunities. I think it's better folded by FE like other 
> > > constants.
> > Are you sure?  All of my attempts to produce these constants in LLVM seem 
> > to get instantly folded, even without a target set in the IR:
> >   i32 ptrtoint (i8* inttoptr (i32 -1 to i8*) to i32)
> >   i64 ptrtoint (i8* inttoptr (i64 -1 to i8*) to i64)
> > This folding literally occurs within ConstantExpr::getPtrToInt, without any 
> > passes running, and it seems to happen regardless of the pointer having an 
> > addrspace.
> > 
> > I suspect that the problem is that you additionally have an addrspacecast 
> > constant in place, which almost certainly does block the constant folder.  
> > The right fix for that is to ensure that your target's implementation of 
> > performAddrSpaceCast makes an effort to peephole casts of Constants.
> In amdgpu target, null pointer in addr space 0 is represented as 
> `addrspacecast int addrspace(4)* null to int*` instead of `inttoptr i32 -1 to 
> i8*`. As addrspacecast is opaque to target-independent LLVM passes, they 
> don't know how to fold it. Only the backend knows how to fold it.
> 
> This could be a general situation, i.e., the non-zero null pointer is 
> represented in some target specific form which LLVM does not know how to fold.
LLVM has deeply-baked-in assumptions that null is a zero bit pattern.  It is 
really, really not a good idea to assume that LLVM will never make any 
assumptions about the behavior of addrspacecasts in its target-independent code.

Also, it is almost certainly possible to validly produce that constant with the 
expectation that it will have value 0, and thus you special-case lowering in 
the backend would be a miscompile.

I understand that you probably got into this situation by trying to give null a 
non-zero representation in the backend and then slowly realized that you needed 
frontend changes to avoid miscompiles.  That is totally understandable.  Please 
understand that what are you actually doing now with this patch is 
fundamentally changing where you lower null pointers, so that it's now only the 
frontend which knows about the representation of null pointers, and the backend 
just treats ConstantPointerNull as a special way of spelling the valid, 
semantically non-null zero representation of a pointer.


https://reviews.llvm.org/D26196



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


[PATCH] D27589: [DebugInfo] Relax test case for long double constants.

2016-12-08 Thread David Gross via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289103: [DebugInfo] Relax test case for long double 
constants. (authored by dgross).

Changed prior to commit:
  https://reviews.llvm.org/D27589?vs=80815=80817#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27589

Files:
  cfe/trunk/test/CodeGen/debug-info-static-const-fp.c


Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
===
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
@@ -24,4 +24,8 @@
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
 
-// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// Temporarily removing this check -- for some targets (such as
+// "--target=hexagon-unknown-elf"), long double does not exceed 64
+// bits, and so we actually do get the constant value (expr) emitted.
+//
+// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)


Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
===
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
@@ -24,4 +24,8 @@
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value)
 
-// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
+// Temporarily removing this check -- for some targets (such as
+// "--target=hexagon-unknown-elf"), long double does not exceed 64
+// bits, and so we actually do get the constant value (expr) emitted.
+//
+// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289103 - [DebugInfo] Relax test case for long double constants.

2016-12-08 Thread David Gross via cfe-commits
Author: dgross
Date: Thu Dec  8 15:15:17 2016
New Revision: 289103

URL: http://llvm.org/viewvc/llvm-project?rev=289103=rev
Log:
[DebugInfo] Relax test case for long double constants.

Summary:
D27549 (partial fix for PR26619) emits a constant value in the debug
metadata for a floating-point static const that does not exceed 64
bits in size.  The regression test accompanying that fix assumes that
a long double exceeds 64 bits in size and hence does not get a
constant value in the debug metadata.  However, for some targets --
such as "--target=hexagon-unknown-elf" -- a long double does not
exceed 64 bits in size, and hence the test fails.

As a temporary fix, modify the regression test to no longer inspect
the debug metadata for a long double.

Reviewers: cfe-commits, probinson

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

Modified:
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c

Modified: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=289103=289102=289103=diff
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Thu Dec  8 15:15:17 2016
@@ -24,4 +24,8 @@ int main() {
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
 
-// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// Temporarily removing this check -- for some targets (such as
+// "--target=hexagon-unknown-elf"), long double does not exceed 64
+// bits, and so we actually do get the constant value (expr) emitted.
+//
+// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)


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


[PATCH] D27589: [DebugInfo] Relax test case for long double constants.

2016-12-08 Thread David Gross via Phabricator via cfe-commits
dgross created this revision.
dgross added reviewers: cfe-commits, probinson.

https://reviews.llvm.org/D27549 (partial fix for PR26619) emits a constant 
value in the debug
metadata for a floating-point static const that does not exceed 64
bits in size.  The regression test accompanying that fix assumes that
a long double exceeds 64 bits in size and hence does not get a
constant value in the debug metadata.  However, for some targets --
such as "--target=hexagon-unknown-elf" -- a long double does not
exceed 64 bits in size, and hence the test fails.

As a temporary fix, modify the regression test to no longer inspect
the debug metadata for a long double.


https://reviews.llvm.org/D27589

Files:
  test/CodeGen/debug-info-static-const-fp.c


Index: test/CodeGen/debug-info-static-const-fp.c
===
--- test/CodeGen/debug-info-static-const-fp.c
+++ test/CodeGen/debug-info-static-const-fp.c
@@ -24,4 +24,8 @@
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
 
-// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
+// Temporarily removing this check -- for some targets (such as
+// "--target=hexagon-unknown-elf"), long double does not exceed 64
+// bits, and so we actually do get the constant value (expr) emitted.
+//
+// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)


Index: test/CodeGen/debug-info-static-const-fp.c
===
--- test/CodeGen/debug-info-static-const-fp.c
+++ test/CodeGen/debug-info-static-const-fp.c
@@ -24,4 +24,8 @@
 // CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]]
 // CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value)
 
-// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
+// Temporarily removing this check -- for some targets (such as
+// "--target=hexagon-unknown-elf"), long double does not exceed 64
+// bits, and so we actually do get the constant value (expr) emitted.
+//
+// DO-NOT-CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 80811.
NoQ added a comment.

Don't yell at read-only properties (no -copy is performed).
Single-quote 'copy' in the error messages.


https://reviews.llvm.org/D27535

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
  test/Analysis/ObjCPropertiesSyntaxChecks.m

Index: test/Analysis/ObjCPropertiesSyntaxChecks.m
===
--- /dev/null
+++ test/Analysis/ObjCPropertiesSyntaxChecks.m
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=osx.ObjCProperty %s -verify
+
+#include "Inputs/system-header-simulator-objc.h"
+
+@interface I : NSObject {
+  NSMutableString *_mutableExplicitStr;
+  NSMutableString *_trulyMutableStr;
+  NSMutableString *_trulyMutableExplicitStr;
+}
+@property(copy) NSString *str; // no-warning
+@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@property(copy) NSMutableString *mutableExplicitStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
+@property(copy, readonly) NSMutableString *mutableReadonlyStr; // no-warning
+@property(copy) NSMutableString *trulyMutableStr; // no-warning
+@property(copy) NSMutableString *trulyMutableExplicitStr; // no-warning
+@property(copy) NSMutableString *trulyMutableStrWithSynthesizedStorage; // no-warning
+@end
+
+@implementation I
+@synthesize mutableExplicitStr = _mutableExplicitStr;
+- (NSMutableString *)trulyMutableStr {
+  return _trulyMutableStr;
+}
+- (void)setTrulyMutableStr: (NSMutableString *) S {
+  _trulyMutableStr = [S mutableCopy];
+}
+@dynamic trulyMutableExplicitStr;
+- (NSMutableString *)trulyMutableExplicitStr {
+  return _trulyMutableExplicitStr;
+}
+- (void)setTrulyMutableExplicitStr: (NSMutableString *) S {
+  _trulyMutableExplicitStr = [S mutableCopy];
+}
+@synthesize trulyMutableStrWithSynthesizedStorage;
+- (NSMutableString *)trulyMutableStrWithSynthesizedStorage {
+  return trulyMutableStrWithSynthesizedStorage;
+}
+- (void)setTrulyMutableStrWithSynthesizedStorage: (NSMutableString *) S {
+  trulyMutableStrWithSynthesizedStorage = [S mutableCopy];
+}
+@end
+
+// If we do not see the implementation then we do not want to warn,
+// because we may miss a user-defined setter that works correctly.
+@interface IWithoutImpl : NSObject {}
+@property(copy) NSMutableString *mutableStr; // no-warning
+@end
Index: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
@@ -0,0 +1,76 @@
+//==- ObjCPropertyChecker.cpp - Check ObjC properties *- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker finds issues with Objective-C properties.
+//  Currently finds only one kind of issue:
+//  - Find synthesized properties with copy attribute of mutable NS collection
+//types. Calling -copy on such collections produces an immutable copy,
+//which contradicts the type of the property.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ObjCPropertyChecker
+: public Checker {
+  void checkCopyMutable(const ObjCPropertyDecl *D, BugReporter ) const;
+
+public:
+  void checkASTDecl(const ObjCPropertyDecl *D, AnalysisManager ,
+BugReporter ) const;
+};
+} // end anonymous namespace.
+
+void ObjCPropertyChecker::checkASTDecl(const ObjCPropertyDecl *D,
+   AnalysisManager ,
+   BugReporter ) const {
+  checkCopyMutable(D, BR);
+}
+
+void ObjCPropertyChecker::checkCopyMutable(const ObjCPropertyDecl *D,
+   BugReporter ) const {
+  if (D->isReadOnly() || D->getSetterKind() != ObjCPropertyDecl::Copy)
+return;
+
+  QualType T = D->getType();
+  if (!T->isObjCObjectPointerType())
+return;
+
+  const std::string (T->getPointeeType().getCanonicalType()
+ .getUnqualifiedType()
+ .getAsString());
+  if (!StringRef(PropTypeName).startswith("NSMutable"))
+return;
+
+  const ObjCInterfaceDecl *IntD = cast(D->getDeclContext());
+
+  const 

[PATCH] D26626: [libcxx] [test] Fix an improper assumption about Null Forward Iterators.

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

I could mark these assertions as libcxx-specific, but I tend to believe that 
they should be removed outright (even if the natural implementation of a list 
without debug checks provides this behavior).


https://reviews.llvm.org/D26626



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


[PATCH] D27541: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7.

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

Responded to https://reviews.llvm.org/D27540. tuple is affected just like pair.


https://reviews.llvm.org/D27541



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


[PATCH] D27544: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 7/7.

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT updated the summary for this revision.
STL_MSFT updated this revision to Diff 80810.
STL_MSFT marked an inline comment as done.
STL_MSFT added a comment.

Changed test/std/re/re.traits/value.pass.cpp to iterate with wchar_t as 
requested.


https://reviews.llvm.org/D27544

Files:
  
test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
  
test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
  
test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
  
test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
  test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
  test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
  test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
  test/std/re/re.traits/value.pass.cpp
  test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
  test/std/strings/string.view/string.view.hash/string_view.pass.cpp
  
test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
  test/std/utilities/function.objects/unord.hash/integral.pass.cpp
  test/std/utilities/utility/exchange/exchange.pass.cpp
  test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp

Index: test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
===
--- test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
+++ test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
@@ -21,29 +21,29 @@
 {
 {
 typedef std::pair P1;
-P1 p1 = std::make_pair(3, 4);
+P1 p1 = std::make_pair(3, static_cast(4));
 assert(p1.first == 3);
 assert(p1.second == 4);
 }
 
 #if TEST_STD_VER >= 11
 {
 typedef std::pair P1;
-P1 p1 = std::make_pair(std::unique_ptr(new int(3)), 4);
+P1 p1 = std::make_pair(std::unique_ptr(new int(3)), static_cast(4));
 assert(*p1.first == 3);
 assert(p1.second == 4);
 }
 {
 typedef std::pair P1;
-P1 p1 = std::make_pair(nullptr, 4);
+P1 p1 = std::make_pair(nullptr, static_cast(4));
 assert(p1.first == nullptr);
 assert(p1.second == 4);
 }
 #endif
 #if TEST_STD_VER >= 14
 {
 typedef std::pair P1;
-constexpr P1 p1 = std::make_pair(3, 4);
+constexpr P1 p1 = std::make_pair(3, static_cast(4));
 static_assert(p1.first == 3, "");
 static_assert(p1.second == 4, "");
 }
Index: test/std/utilities/utility/exchange/exchange.pass.cpp
===
--- test/std/utilities/utility/exchange/exchange.pass.cpp
+++ test/std/utilities/utility/exchange/exchange.pass.cpp
@@ -22,10 +22,10 @@
 int v = 12;
 assert ( std::exchange ( v, 23 ) == 12 );
 assert ( v == 23 );
-assert ( std::exchange ( v, 67.2 ) == 23 );
+assert ( std::exchange ( v, static_cast(67) ) == 23 );
 assert ( v == 67 );
 
-assert ((std::exchange ( v, {} )) == 67 );
+assert ((std::exchange ( v, {} )) == 67 );
 assert ( v == 0 );
 
 }
Index: test/std/utilities/function.objects/unord.hash/integral.pass.cpp
===
--- test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -35,7 +35,7 @@
 
 for (int i = 0; i <= 5; ++i)
 {
-T t(i);
+T t(static_cast(i));
 if (sizeof(T) <= sizeof(std::size_t))
 {
 const std::size_t result = h(t);
Index: test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
===
--- test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
+++ test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
@@ -28,7 +28,7 @@
   T
   operator()(T a, T b)
   {
-return std::pow(a, b);
+return static_cast(std::pow(a, b));
   }
 };
 
Index: test/std/strings/string.view/string.view.hash/string_view.pass.cpp
===
--- test/std/strings/string.view/string.view.hash/string_view.pass.cpp
+++ test/std/strings/string.view/string.view.hash/string_view.pass.cpp
@@ -38,7 +38,7 @@
 char_type g1 [ 10 ];
 char_type g2 [ 10 ];
 for ( int i = 0; i < 10; ++i )
-g1[i] = g2[9-i] = '0' + i;
+g1[i] = g2[9-i] = static_cast('0' + i);
 T s1(g1, 10);
 T s2(g2, 10);
 assert(h(s1) != h(s2));
Index: test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
===
--- 

[PATCH] D27544: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 7/7.

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT marked an inline comment as done.
STL_MSFT added inline comments.



Comment at: test/std/re/re.traits/value.pass.cpp:119
 }
 for (int c = 'g'; c < 0x; ++c)
 {

EricWF wrote:
> Can't we just make `c` a `wchar_t` like above?
Yes (because the bound is exclusive). It would be problematic for signed 16-bit 
wchar_t, but I don't think anyone's crazy enough to have that (MSVC is always 
unsigned 16-bit). I'll make this change.


https://reviews.llvm.org/D27544



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


[PATCH] D27540: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

2016-12-08 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Huh. Thanks for the analysis. LGTM.


https://reviews.llvm.org/D27540



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


[PATCH] D27540: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

I checked, and Clang 3.8.0 behaves identically to C1XX in the pair scenario. 
Here's the test case:

  #include 
  
  template  struct Pair {
  A a;
  B b;
  
  template  Pair(X&& x, Y&& y) : 
a(std::forward(x)), b(std::forward(y)) { }
  };
  
  int main() {
  Pair p(11, 22);
  return p.a == 11 && p.b == 22 ? 0 : 1;
  }

With `-Wconversion`, this emits:

  prog.cc:7:62: warning: implicit conversion loses integer precision: 'int' to 
'short' [-Wconversion]
  template  Pair(X&& x, Y&& y) : 
a(std::forward(x)), b(std::forward(y)) { }
  
~^~
  prog.cc:11:24: note: in instantiation of function template specialization 
'Pair::Pair' requested here
  Pair p(11, 22);
 ^
  prog.cc:7:85: warning: implicit conversion loses integer precision: 'int' to 
'short' [-Wconversion]
  template  Pair(X&& x, Y&& y) : 
a(std::forward(x)), b(std::forward(y)) { }

 ~^~

So, if you were compiling your tests with `-Wconversion` and not suppressing 
warnings in "system headers", you'd see this in libc++ too.


https://reviews.llvm.org/D27540



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


[PATCH] D27540: [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

I can't possibly defend C1XX's behavior in your foo() scenario - but the pair 
scenarios being fixed here are different. pair's constructor from (X&&, 
Y&&) is perfect forwarding, so while the compiler can see that literals are 
being passed to (int&&, int&&), when it instantiates the constructor's 
definition, it just sees short being constructed from a perfectly-forwarded 
int, and warns about truncation there. C1XX doesn't attempt to "see through" 
the function call and notice that the arguments were literals. Its behavior is 
arguably desirable because the instantiation happens once per TU, and yet there 
may be other calls that are passing runtime-valued ints.

I chose static_cast here because it was non-invasive, although ugly. 
There's a more invasive but prettier possibility - change the shorts to longs 
so that widening instead of truncation happens. I could do that if you want.


https://reviews.llvm.org/D27540



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


[PATCH] D27549: [DebugInfo] Add support for __fp16, float, and double constants.

2016-12-08 Thread David Gross via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289094: [DebugInfo] Add support for __fp16, float, and 
double constants. (authored by dgross).

Changed prior to commit:
  https://reviews.llvm.org/D27549?vs=80683=80806#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27549

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/test/CodeGen/debug-info-static-const-fp.c


Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
===
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
@@ -0,0 +1,27 @@
+// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
+
+// Per PR26619, check that for referenced static const of floating-point type,
+// we emit its constant value in debug info.  NOTE that PR26619 is not yet 
fixed for long double.
+
+static const __fp16 hVal = 29/13.0f;//2.2307692307692307692
 (2.23046875)
+
+static const float fVal = -147/17.0f;   //   -8.6470588235294117647
 (-8.64705849)
+
+static const double dVal = 19637/7.0;   // 2805.2857142857142857   
 (2805.2857142857142)
+
+static const long double ldVal = 3/1234567.0L;  //
2.4300017739012949479e-06 ()
+
+int main() {
+  return hVal + fVal + dVal + ldVal;
+}
+
+// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[HEXPR:[0-9]+]]
+// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[FEXPR:[0-9]+]]
+// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, 
DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
+// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3760,6 +3760,9 @@
   if (Init.isInt())
 InitExpr =
 DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
+  else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64)
+InitExpr = DBuilder.createConstantValueExpression(
+Init.getFloat().bitcastToAPInt().getZExtValue());
   GV.reset(DBuilder.createGlobalVariable(
   DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
   true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),


Index: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
===
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
@@ -0,0 +1,27 @@
+// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
+
+// Per PR26619, check that for referenced static const of floating-point type,
+// we emit its constant value in debug info.  NOTE that PR26619 is not yet fixed for long double.
+
+static const __fp16 hVal = 29/13.0f;//2.2307692307692307692 (2.23046875)
+
+static const float fVal = -147/17.0f;   //   -8.6470588235294117647 (-8.64705849)
+
+static const double dVal = 19637/7.0;   // 2805.2857142857142857(2805.2857142857142)
+
+static const long double ldVal = 3/1234567.0L;  //2.4300017739012949479e-06 ()
+
+int main() {
+  return hVal + fVal + dVal + ldVal;
+}
+
+// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[HEXPR:[0-9]+]]
+// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[FEXPR:[0-9]+]]
+// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: true, expr: ![[DEXPR:[0-9]+]]
+// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true)
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -3760,6 +3760,9 @@
   if (Init.isInt())
 InitExpr =
 DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
+  else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64)
+InitExpr = DBuilder.createConstantValueExpression(
+Init.getFloat().bitcastToAPInt().getZExtValue());
   GV.reset(DBuilder.createGlobalVariable(
   DContext, Name, 

[PATCH] D26196: Add support for non-zero null pointer for C and OpenCL

2016-12-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated the summary for this revision.
yaxunl updated this revision to Diff 80804.
yaxunl marked an inline comment as done.
yaxunl added a comment.

Revised by John's comments.

Added source QualType parameter to performAddrSpaceCast.
Changed linkage of tentative definition of global var with non-zero initializer 
to weak linkage since common linkage requires zero initializer.


https://reviews.llvm.org/D26196

Files:
  include/clang/AST/APValue.h
  include/clang/AST/ASTContext.h
  include/clang/Basic/TargetInfo.h
  lib/AST/APValue.cpp
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/CodeGenTypes.h
  lib/CodeGen/TargetInfo.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCL/amdgpu-nullptr.cl

Index: test/CodeGenOpenCL/amdgpu-nullptr.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/amdgpu-nullptr.cl
@@ -0,0 +1,534 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O0 -cl-std=CL2.0 -include opencl-c.h -triple amdgcn -emit-llvm -o - | FileCheck --check-prefix=NOOPT %s
+
+typedef struct {
+  private char *p1;
+  local char *p2;
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy1;
+
+typedef struct {
+  constant char *p3;
+  global char *p4;
+  generic char *p5;
+} StructTy2;
+
+// LLVM requests global variable with common linkage to be initialized with zeroinitializer, therefore use -fno-common
+// to suppress common linkage for tentative definition.
+
+// Test 0 as initializer.
+
+// CHECK: @private_p = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p = 0;
+
+// CHECK: @local_p = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p = 0;
+
+// CHECK: @global_p = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p = 0;
+
+// CHECK: @constant_p = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p = 0;
+
+// CHECK: @generic_p = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p = 0;
+
+// Test NULL as initializer.
+
+// CHECK: @private_p_NULL = local_unnamed_addr addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+private char *private_p_NULL = NULL;
+
+// CHECK: @local_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(3)* addrspacecast (i8 addrspace(4)* null to i8 addrspace(3)*), align 4
+local char *local_p_NULL = NULL;
+
+// CHECK: @global_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(1)* null, align 4
+global char *global_p_NULL = NULL;
+
+// CHECK: @constant_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(2)* null, align 4
+constant char *constant_p_NULL = NULL;
+
+// CHECK: @generic_p_NULL = local_unnamed_addr addrspace(1) global i8 addrspace(4)* null, align 4
+generic char *generic_p_NULL = NULL;
+
+// Test constant folding of null pointer.
+// A null pointer should be folded to a null pointer in the target address space.
+
+// CHECK: @fold_generic = local_unnamed_addr addrspace(1) global i32 addrspace(4)* null, align 4
+generic int *fold_generic = (global int*)(generic float*)(private char*)0;
+
+// CHECK: @fold_priv = local_unnamed_addr addrspace(1) global i16* addrspacecast (i16 addrspace(4)* null to i16*), align 4
+private short *fold_priv = (private short*)(generic int*)(global void*)0;
+
+// CHECK: @fold_priv_arith = local_unnamed_addr addrspace(1) global i8* inttoptr (i32 9 to i8*), align 4
+private char *fold_priv_arith = (private char*)0 + 10;
+
+// CHECK: @fold_int = local_unnamed_addr addrspace(1) global i32 13, align 4
+int fold_int = (int)(private void*)(generic char*)(global int*)0 + 14;
+
+// CHECK: @fold_int2 = local_unnamed_addr addrspace(1) global i32 12, align 4
+int fold_int2 = (int) ((private void*)0 + 13);
+
+// CHECK: @fold_int3 = local_unnamed_addr addrspace(1) global i32 -1, align 4
+int fold_int3 = (int) ((private int*)0);
+
+// CHECK: @fold_int4 = local_unnamed_addr addrspace(1) global i32 7, align 4
+int fold_int4 = (int) &((private int*)0)[2];
+
+// CHECK: @fold_int5 = local_unnamed_addr addrspace(1) global i32 3, align 4
+int fold_int5 = (int) &((private StructTy1*)0)->p2;
+
+// Test static variable initialization.
+
+// NOOPT: @test_static_var.sp1 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp2 = internal addrspace(1) global i8* addrspacecast (i8 addrspace(4)* null to i8*), align 4
+// NOOPT: @test_static_var.sp3 = internal addrspace(1) 

r289094 - [DebugInfo] Add support for __fp16, float, and double constants.

2016-12-08 Thread David Gross via cfe-commits
Author: dgross
Date: Thu Dec  8 14:02:46 2016
New Revision: 289094

URL: http://llvm.org/viewvc/llvm-project?rev=289094=rev
Log:
[DebugInfo] Add support for __fp16, float, and double constants.

Summary:
Partial fix for PR26619.

Prior to this change, a DIGlobalVariable corresponding to a static
const was marked with an expression corresponding to its constant
value only if it is of integral type.  With this change, we now do the
same if it is of __fp16, float, or double type (that is,
floating-point types that do not exceed 64 bits in size, and hence are
supported easily by the existing LLVM machinery for creating constant
expressions in debug info).

Reviewers: llvm-commits

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

Added:
cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=289094=289093=289094=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Dec  8 14:02:46 2016
@@ -3760,6 +3760,9 @@ void CGDebugInfo::EmitGlobalVariable(con
   if (Init.isInt())
 InitExpr =
 DBuilder.createConstantValueExpression(Init.getInt().getExtValue());
+  else if (Init.isFloat() && CGM.getContext().getTypeSize(VD->getType()) <= 64)
+InitExpr = DBuilder.createConstantValueExpression(
+Init.getFloat().bitcastToAPInt().getZExtValue());
   GV.reset(DBuilder.createGlobalVariable(
   DContext, Name, StringRef(), Unit, getLineNumber(VD->getLocation()), Ty,
   true, InitExpr, getOrCreateStaticDataMemberDeclarationOrNull(VarD),

Added: cfe/trunk/test/CodeGen/debug-info-static-const-fp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-static-const-fp.c?rev=289094=auto
==
--- cfe/trunk/test/CodeGen/debug-info-static-const-fp.c (added)
+++ cfe/trunk/test/CodeGen/debug-info-static-const-fp.c Thu Dec  8 14:02:46 2016
@@ -0,0 +1,27 @@
+// RUN: %clang -emit-llvm -O0 -S -g %s -o - | FileCheck %s
+
+// Per PR26619, check that for referenced static const of floating-point type,
+// we emit its constant value in debug info.  NOTE that PR26619 is not yet 
fixed for long double.
+
+static const __fp16 hVal = 29/13.0f;//2.2307692307692307692
 (2.23046875)
+
+static const float fVal = -147/17.0f;   //   -8.6470588235294117647
 (-8.64705849)
+
+static const double dVal = 19637/7.0;   // 2805.2857142857142857   
 (2805.2857142857142)
+
+static const long double ldVal = 3/1234567.0L;  //
2.4300017739012949479e-06 ()
+
+int main() {
+  return hVal + fVal + dVal + ldVal;
+}
+
+// CHECK: !DIGlobalVariable(name: "hVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[HEXPR:[0-9]+]]
+// CHECK: ![[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "fVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[FEXPR:[0-9]+]]
+// CHECK: ![[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, 
DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "dVal", {{.*}}, isLocal: true, isDefinition: 
true, expr: ![[DEXPR:[0-9]+]]
+// CHECK: ![[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, 
DW_OP_stack_value)
+
+// CHECK: !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, 
isDefinition: true)


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


[PATCH] D27555: [libcxx] [test] Fix MSVC warning C6001 "Using uninitialized memory".

2016-12-08 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

It was debatable to me whether this was actually a compiler bug, but I suppose 
that it can see size()'s definition and should be able to notice that the 
elements aren't accessed. I've filed VSO#300037 "Bogus warning C6001 "Using 
uninitialized memory" for array::size()".

I'd still like to have this workaround upstreamed; I've made a note to myself 
to revert it when the compiler bug is fixed. (We're locking down for VS 2017 
RTM, so that may not happen quickly, but fortunately only this one simple test 
is affected.)


https://reviews.llvm.org/D27555



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


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-08 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26750#617316, @Eugene.Zelenko wrote:

> How does check handle bit fields?


There is no warning for bit fields.
I don't think the C++17 bit field initializer proposal has been accepted yet.

> Will be also good idea to add test case for bit fields.

There is a test:

  struct NegativeBitField
  {
NegativeBitField() : i(6) {}
int i : 5;
  };


https://reviews.llvm.org/D26750



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


[PATCH] D25845: [CUDA] Ignore implicit target attributes during function template instantiation.

2016-12-08 Thread Artem Belevich via Phabricator via cfe-commits
tra marked an inline comment as done.
tra added inline comments.



Comment at: lib/Sema/SemaTemplate.cpp:7048
   // target attributes into account, we perform target match check
   // here and reject candidates that have different target.
   if (LangOpts.CUDA &&

jlebar wrote:
> tra wrote:
> > jlebar wrote:
> > > Missing some articles:
> > > 
> > >   Target attributes are part of the cuda function signature, so the 
> > > deduced template's cuda target must match XXX [1].  Given that regular 
> > > template deduction [2] does not take target attributes into account, we 
> > > reject candidates here that have a different target.
> > > 
> > > [1] I am not sure what XXX should be.  The deduced template's cuda target 
> > > must match what, exactly?
> > > 
> > > [2] What is "regular template deduction"?
> > [1] it must match the target of its template.
> > [2] "C++ template deduction"
> > Rephrased the comment based on  IRL conversation w/ jlebar@.
> It's not showing a rephrased comment above; maybe you forgot to commit before 
> arc diff?
Argh. I've apparently deleted corrected version after I've showed it to you. 
:-/ Fixed now.



https://reviews.llvm.org/D25845



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


[PATCH] D25845: [CUDA] Ignore implicit target attributes during function template instantiation.

2016-12-08 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 80783.
tra marked 3 inline comments as done.
tra added a comment.

Fixed comments.


https://reviews.llvm.org/D25845

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCUDA/function-template-overload.cu

Index: test/SemaCUDA/function-template-overload.cu
===
--- test/SemaCUDA/function-template-overload.cu
+++ test/SemaCUDA/function-template-overload.cu
@@ -31,7 +31,8 @@
 template  <> __host__ HType overload_h_d(long a); // OK. instantiates H
 
 
-// Can't overload HD template with H or D template, though functions are OK.
+// Can't overload HD template with H or D template, though
+// non-template functions are OK.
 template  __host__ __device__ HDType overload_hd(T a) { return HDType(); }
 // expected-note@-1 {{previous declaration is here}}
 // expected-note@-2 2 {{candidate template ignored: could not match 'HDType' against 'HType'}}
@@ -56,24 +57,54 @@
 template  __host__ __device__ HDType overload_h_d2(T a) { return HDType(); }
 template  __device__ DType overload_h_d2(T1 a) { T1 x; T2 y; return DType(); }
 
+// constexpr functions are implicitly HD, but explicit
+// instantiation/specialization must use target attributes as written.
+template  constexpr T overload_ce_implicit_hd(T a) { return a+1; }
+// expected-note@-1 3 {{candidate template ignored: target attributes do not match}}
+
+// These will not match the template.
+template __host__ __device__ int overload_ce_implicit_hd(int a);
+// expected-error@-1 {{explicit instantiation of 'overload_ce_implicit_hd' does not refer to a function template, variable template, member function, member class, or static data member}}
+template <> __host__ __device__ long overload_ce_implicit_hd(long a);
+// expected-error@-1 {{no function template matches function template specialization 'overload_ce_implicit_hd'}}
+template <> __host__ __device__ constexpr long overload_ce_implicit_hd(long a);
+// expected-error@-1 {{no function template matches function template specialization 'overload_ce_implicit_hd'}}
+
+// These should work, because template matching ignores the implicit
+// HD attributes the compiler gives to constexpr functions/templates,
+// so 'overload_ce_implicit_hd' template will match __host__ functions
+// only.
+template __host__ int overload_ce_implicit_hd(int a);
+template <> __host__ long overload_ce_implicit_hd(long a);
+
+template float overload_ce_implicit_hd(float a);
+template <> float* overload_ce_implicit_hd(float *a);
+template <> constexpr double overload_ce_implicit_hd(double a) { return a + 3.0; };
+
 __host__ void hf() {
   overload_hd(13);
+  overload_ce_implicit_hd('h');// Implicitly instantiated
+  overload_ce_implicit_hd(1.0f);   // Explicitly instantiated
+  overload_ce_implicit_hd(2.0);// Explicitly specialized
 
   HType h = overload_h_d(10);
   HType h2i = overload_h_d2(11);
   HType h2ii = overload_h_d2(12);
 
   // These should be implicitly instantiated from __host__ template returning HType.
-  DType d = overload_h_d(20); // expected-error {{no viable conversion from 'HType' to 'DType'}}
-  DType d2i = overload_h_d2(21); // expected-error {{no viable conversion from 'HType' to 'DType'}}
+  DType d = overload_h_d(20);  // expected-error {{no viable conversion from 'HType' to 'DType'}}
+  DType d2i = overload_h_d2(21);  // expected-error {{no viable conversion from 'HType' to 'DType'}}
   DType d2ii = overload_h_d2(22); // expected-error {{no viable conversion from 'HType' to 'DType'}}
 }
 __device__ void df() {
   overload_hd(23);
+  overload_ce_implicit_hd('d');// Implicitly instantiated
+  overload_ce_implicit_hd(1.0f);   // Explicitly instantiated
+  overload_ce_implicit_hd(2.0);// Explicitly specialized
 
   // These should be implicitly instantiated from __device__ template returning DType.
-  HType h = overload_h_d(10); // expected-error {{no viable conversion from 'DType' to 'HType'}}
-  HType h2i = overload_h_d2(11); // expected-error {{no viable conversion from 'DType' to 'HType'}}
+  HType h = overload_h_d(10);  // expected-error {{no viable conversion from 'DType' to 'HType'}}
+  HType h2i = overload_h_d2(11);  // expected-error {{no viable conversion from 'DType' to 'HType'}}
   HType h2ii = overload_h_d2(12); // expected-error {{no viable conversion from 'DType' to 'HType'}}
 
   DType d = overload_h_d(20);
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -7043,13 +7043,15 @@
 continue;
   }
 
-  // Target attributes are part of function signature during cuda
-  // compilation, so deduced template must also have matching CUDA
-  // target. Given that regular template deduction does not take
-  // target attributes into account, we perform 

[PATCH] D27580: [modules] Add optional out-param to ASTReader::ReadAST for imported submodules.

2016-12-08 Thread Doug Gregor via Phabricator via cfe-commits
doug.gregor accepted this revision.
doug.gregor added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D27580



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


[PATCH] D27580: [modules] Add optional out-param to ASTReader::ReadAST for imported submodules.

2016-12-08 Thread Graydon Hoare via Phabricator via cfe-commits
graydon created this revision.
graydon added reviewers: doug.gregor, manmanren, rsmith.
graydon added a subscriber: cfe-commits.

The Swift frontend is acquiring the ability to load non-module PCH files 
containing
bridging definitions from C/ObjC. As part of this work, it needs to know which 
submodules
were imported by a PCH in order to wrap them in local Swift modules. This 
information
is collected by ASTReader::ReadAST in a local vector, but is currently kept 
private.

The change here is just to make the type of the vector elements public, and 
provide
an optional out-parameter to the ReadAST method to provide the vector's 
contents to
a caller after a successful read.


https://reviews.llvm.org/D27580

Files:
  include/clang/Serialization/ASTReader.h
  lib/Serialization/ASTReader.cpp


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3578,7 +3578,8 @@
 ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
 ModuleKind Type,
 SourceLocation ImportLoc,
-unsigned ClientLoadCapabilities) {
+unsigned ClientLoadCapabilities,
+SmallVectorImpl 
*Imported) {
   llvm::SaveAndRestore
 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
 
@@ -3744,6 +3745,10 @@
   }
   UnresolvedModuleRefs.clear();
 
+  if (Imported)
+Imported->append(ImportedModules.begin(),
+ ImportedModules.end());
+
   // FIXME: How do we load the 'use'd modules? They may not be submodules.
   // Might be unnecessary as use declarations are only used to build the
   // module itself.
Index: include/clang/Serialization/ASTReader.h
===
--- include/clang/Serialization/ASTReader.h
+++ include/clang/Serialization/ASTReader.h
@@ -821,14 +821,16 @@
   // \brief A list of late parsed template function data.
   SmallVector LateParsedTemplates;
 
+public:
   struct ImportedSubmodule {
 serialization::SubmoduleID ID;
 SourceLocation ImportLoc;
 
 ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
   : ID(ID), ImportLoc(ImportLoc) {}
   };
 
+private:
   /// \brief A list of modules that were imported by precompiled headers or
   /// any other non-module AST file.
   SmallVector ImportedModules;
@@ -1404,9 +1406,13 @@
   /// \param ClientLoadCapabilities The set of client load-failure
   /// capabilities, represented as a bitset of the enumerators of
   /// LoadFailureCapabilities.
+  ///
+  /// \param Imported optional out-parameter to append the list of modules
+  /// that were imported by precompiled headers or any other non-module AST 
file
   ASTReadResult ReadAST(StringRef FileName, ModuleKind Type,
 SourceLocation ImportLoc,
-unsigned ClientLoadCapabilities);
+unsigned ClientLoadCapabilities,
+SmallVectorImpl *Imported = 
nullptr);
 
   /// \brief Make the entities in the given module and any of its 
(non-explicit)
   /// submodules visible to name lookup.


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -3578,7 +3578,8 @@
 ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
 ModuleKind Type,
 SourceLocation ImportLoc,
-unsigned ClientLoadCapabilities) {
+unsigned ClientLoadCapabilities,
+SmallVectorImpl *Imported) {
   llvm::SaveAndRestore
 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
 
@@ -3744,6 +3745,10 @@
   }
   UnresolvedModuleRefs.clear();
 
+  if (Imported)
+Imported->append(ImportedModules.begin(),
+ ImportedModules.end());
+
   // FIXME: How do we load the 'use'd modules? They may not be submodules.
   // Might be unnecessary as use declarations are only used to build the
   // module itself.
Index: include/clang/Serialization/ASTReader.h
===
--- include/clang/Serialization/ASTReader.h
+++ include/clang/Serialization/ASTReader.h
@@ -821,14 +821,16 @@
   // \brief A list of late parsed template function data.
   SmallVector LateParsedTemplates;
 
+public:
   struct ImportedSubmodule {
 serialization::SubmoduleID ID;
 SourceLocation ImportLoc;
 
 ImportedSubmodule(serialization::SubmoduleID ID, SourceLocation ImportLoc)
   : ID(ID), 

[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

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

How does check handle bit fields? I encountered problem on next code in 
ASTContext.h:

struct TypeInfo {

  uint64_t Width;
  unsigned Align;
  bool AlignIsRequired : 1;
  
  TypeInfo() : Width(0), Align(0), AlignIsRequired(false) {}

};

Will be also good idea to add test case for bit fields.


https://reviews.llvm.org/D26750



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


[PATCH] D25845: [CUDA] Ignore implicit target attributes during function template instantiation.

2016-12-08 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Sema/SemaDecl.cpp:8415
+// specialization inherits its target attributes from its template
+// in CheckFunctionTemplateSpecialization() call below.
+if (getLangOpts().CUDA & !isFunctionTemplateSpecialization)

"the Foo() call below", or "in Foo() below".  (I guess "Foo()" is like a proper 
name. :)



Comment at: lib/Sema/SemaTemplate.cpp:7048
   // target attributes into account, we perform target match check
   // here and reject candidates that have different target.
   if (LangOpts.CUDA &&

tra wrote:
> jlebar wrote:
> > Missing some articles:
> > 
> >   Target attributes are part of the cuda function signature, so the deduced 
> > template's cuda target must match XXX [1].  Given that regular template 
> > deduction [2] does not take target attributes into account, we reject 
> > candidates here that have a different target.
> > 
> > [1] I am not sure what XXX should be.  The deduced template's cuda target 
> > must match what, exactly?
> > 
> > [2] What is "regular template deduction"?
> [1] it must match the target of its template.
> [2] "C++ template deduction"
> Rephrased the comment based on  IRL conversation w/ jlebar@.
It's not showing a rephrased comment above; maybe you forgot to commit before 
arc diff?



Comment at: test/SemaCUDA/function-template-overload.cu:73
+
+// These should work, because template matching ignores implicit HD
+// attributes compiler gives to constexpr functions/templates so

"the implicit HD attributes the compiler gives"  :)



Comment at: test/SemaCUDA/function-template-overload.cu:74
+// These should work, because template matching ignores implicit HD
+// attributes compiler gives to constexpr functions/templates so
+// 'overload_ce_implicit_hd' template will match __host__ functions

comma before "so" (conjunction joining independent clauses)


https://reviews.llvm.org/D25845



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


r289083 - [DOXYGEN] Improved doxygen comments.

2016-12-08 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Thu Dec  8 11:57:23 2016
New Revision: 289083

URL: http://llvm.org/viewvc/llvm-project?rev=289083=rev
Log:
[DOXYGEN] Improved doxygen comments.

Improved doxygen comments for __wmmintrin_pclmul.h and ammintrin.h intrinsics 
by taagging parameter names with \a doxygen command to display parameters in 
italics.

Formatted comments to fit into 80 chars.




Modified:
cfe/trunk/lib/Headers/__wmmintrin_pclmul.h
cfe/trunk/lib/Headers/ammintrin.h

Modified: cfe/trunk/lib/Headers/__wmmintrin_pclmul.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_pclmul.h?rev=289083=289082=289083=diff
==
--- cfe/trunk/lib/Headers/__wmmintrin_pclmul.h (original)
+++ cfe/trunk/lib/Headers/__wmmintrin_pclmul.h Thu Dec  8 11:57:23 2016
@@ -43,12 +43,12 @@
 /// \param __I
 ///An immediate value specifying which 64-bit values to select from the
 ///operands.
-///Bit 0 is used to select a value from operand __X,
-///and bit 4 is used to select a value from operand __Y:
-///Bit[0]=0 indicates that bits[63:0] of operand __X are used.
-///Bit[0]=1 indicates that bits[127:64] of operand __X are used.
-///Bit[4]=0 indicates that bits[63:0] of operand __Y are used.
-///Bit[4]=1 indicates that bits[127:64] of operand __Y are used.
+///Bit 0 is used to select a value from operand \a __X, and bit 4 is used
+///to select a value from operand \a __Y:
+///Bit[0]=0 indicates that bits[63:0] of operand \a __X are used.
+///Bit[0]=1 indicates that bits[127:64] of operand \a __X are used.
+///Bit[4]=0 indicates that bits[63:0] of operand \a __Y are used.
+///Bit[4]=1 indicates that bits[127:64] of operand \a __Y are used.
 /// \returns The 128-bit integer vector containing the result of the carry-less
 ///multiplication of the selected 64-bit values.
 #define _mm_clmulepi64_si128(__X, __Y, __I) \

Modified: cfe/trunk/lib/Headers/ammintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/ammintrin.h?rev=289083=289082=289083=diff
==
--- cfe/trunk/lib/Headers/ammintrin.h (original)
+++ cfe/trunk/lib/Headers/ammintrin.h Thu Dec  8 11:57:23 2016
@@ -30,7 +30,7 @@
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("sse4a")))
 
 /// \brief Extracts the specified bits from the lower 64 bits of the 128-bit
-///integer vector operand at the index idx and of the length len.
+///integer vector operand at the index \a idx and of the length \a len.
 ///
 /// \headerfile 
 ///
@@ -49,8 +49,8 @@
 ///Bits [5:0] specify the index of the least significant bit; the other
 ///bits are ignored. If the sum of the index and length is greater than 64,
 ///the result is undefined. If the length and index are both zero, bits
-///[63:0] of parameter x are extracted. If the length is zero but the index
-///is non-zero, the result is undefined.
+///[63:0] of parameter \a x are extracted. If the length is zero but the
+///index is non-zero, the result is undefined.
 /// \returns A 128-bit integer vector whose lower 64 bits contain the bits
 ///extracted from the source operand.
 #define _mm_extracti_si64(x, len, idx) \
@@ -58,7 +58,8 @@
   (char)(len), (char)(idx)))
 
 /// \brief Extracts the specified bits from the lower 64 bits of the 128-bit
-///integer vector operand at the index and of the length specified by __y.
+///integer vector operand at the index and of the length specified by
+///\a __y.
 ///
 /// \headerfile 
 ///
@@ -71,8 +72,8 @@
 ///length at [5:0]; all other bits are ignored. If bits [5:0] are zero, the
 ///length is interpreted as 64. If the sum of the index and length is
 ///greater than 64, the result is undefined. If the length and index are
-///both zero, bits [63:0] of parameter __x are extracted. If the length is
-///zero but the index is non-zero, the result is undefined.
+///both zero, bits [63:0] of parameter \a __x are extracted. If the length
+///is zero but the index is non-zero, the result is undefined.
 /// \returns A 128-bit vector whose lower 64 bits contain the bits extracted
 ///from the source operand.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
@@ -81,9 +82,9 @@ _mm_extract_si64(__m128i __x, __m128i __
   return (__m128i)__builtin_ia32_extrq((__v2di)__x, (__v16qi)__y);
 }
 
-/// \brief Inserts bits of a specified length from the source integer vector y
-///into the lower 64 bits of the destination integer vector x at the index
-///idx and of the length len.
+/// \brief Inserts bits of a specified length from the source integer vector
+///\a y into the lower 64 bits of the destination integer vector \a x at
+///the index \a idx and of the length \a len.
 ///
 /// \headerfile 
 ///
@@ -96,11 

[PATCH] D27488: Fixing test to work when the compiler defaults to a different c++ standard version.

2016-12-08 Thread Douglas Yung via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289075: Fixing test to work when the compiler defaults to a 
different C++ standard… (authored by dyung).

Changed prior to commit:
  https://reviews.llvm.org/D27488?vs=80496=80776#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27488

Files:
  cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp


Index: cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
===
--- cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
+++ cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -50,9 +55,12 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 
for loops after '#pragma omp teams distribute simd', but found only 1}}
 
-// expected-error@+4 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
-// expected-error@+3 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+// expected-error@+7 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
+// expected-error@+6 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+// expected-error@+5 2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), 
collapse (-5)
   for (int i = ST; i < N; i++)
@@ -62,7 +70,11 @@
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
 
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+#if __cplusplus <= 199711L
+  // expected-error@+5 2 {{expression is not an integral constant expression}}
+#else
+  // expected-error@+3 2 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++)
@@ -110,14 +122,20 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for 
loops after '#pragma omp teams distribute simd', but found only 1}}
 
+#if __cplusplus >= 201103L
+  // expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(1) > 0 ? 1 : 2) // 
expected-error {{expression is not an integral constant expression}}
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+4 {{expression is not an integral constant expression}}
-// expected-error@+3 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
-// expected-error@+2 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+// expected-error@+7 {{expression is not an integral constant expression}}
+// expected-error@+6 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
+// expected-error@+5 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+#if __cplusplus >= 201103L
+// expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), 
collapse (-5) 
   for (int i = 4; i < 12; i++)
@@ -128,7 +146,11 @@
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+  // expected-error@+5 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#else
+  // expected-error@+3 {{expression is not an integral constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = 4; i < 12; i++)


Index: cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
===
--- cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
+++ 

r289075 - Fixing test to work when the compiler defaults to a different C++ standard version.

2016-12-08 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Thu Dec  8 11:27:20 2016
New Revision: 289075

URL: http://llvm.org/viewvc/llvm-project?rev=289075=rev
Log:
Fixing test to work when the compiler defaults to a different C++ standard 
version.

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


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

Modified: cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp?rev=289075=289074=289075=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/teams_distribute_simd_collapse_messages.cpp Thu Dec  
8 11:27:20 2016
@@ -1,8 +1,13 @@
 // RUN: %clang_cc1 -verify -fopenmp %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
+// RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s
 
 void foo() {
 }
 
+#if __cplusplus >= 201103L
+// expected-note@+2 4 {{declared here}}
+#endif
 bool foobool(int argc) {
   return argc;
 }
@@ -50,9 +55,12 @@ T tmain(T argc, S **argv) { //expected-n
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST]; // expected-error 2 {{expected 2 
for loops after '#pragma omp teams distribute simd', but found only 1}}
 
-// expected-error@+4 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
-// expected-error@+3 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+// expected-error@+7 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
+// expected-error@+6 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+// expected-error@+5 2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+// expected-note@+3 2 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), 
collapse (-5)
   for (int i = ST; i < N; i++)
@@ -62,7 +70,11 @@ T tmain(T argc, S **argv) { //expected-n
   for (int i = ST; i < N; i++)
 argv[0][i] = argv[0][i] - argv[0][i-ST];
 
-// expected-error@+2 2 {{expression is not an integral constant expression}}
+#if __cplusplus <= 199711L
+  // expected-error@+5 2 {{expression is not an integral constant expression}}
+#else
+  // expected-error@+3 2 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++)
@@ -110,14 +122,20 @@ int main(int argc, char **argv) {
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4]; // expected-error {{expected 4 for 
loops after '#pragma omp teams distribute simd', but found only 1}}
 
+#if __cplusplus >= 201103L
+  // expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(1) > 0 ? 1 : 2) // 
expected-error {{expression is not an integral constant expression}}
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+4 {{expression is not an integral constant expression}}
-// expected-error@+3 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
-// expected-error@+2 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+// expected-error@+7 {{expression is not an integral constant expression}}
+// expected-error@+6 2 {{directive '#pragma omp teams distribute simd' cannot 
contain more than one 'collapse' clause}}
+// expected-error@+5 2 {{argument to 'collapse' clause must be a strictly 
positive integer value}}
+#if __cplusplus >= 201103L
+// expected-note@+3 {{non-constexpr function 'foobool' cannot be used in a 
constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (foobool(argc)), collapse (true), 
collapse (-5) 
   for (int i = 4; i < 12; i++)
@@ -128,7 +146,11 @@ int main(int argc, char **argv) {
   for (int i = 4; i < 12; i++)
 argv[0][i] = argv[0][i] - argv[0][i-4];
 
-// expected-error@+2 {{expression is not an integral constant expression}}
+#if __cplusplus >= 201103L
+  // expected-error@+5 {{integral constant expression must have integral or 
unscoped enumeration type, not 'char *'}}
+#else
+  // expected-error@+3 {{expression is not an integral constant expression}}
+#endif
 #pragma omp target
 #pragma omp teams distribute simd collapse (argv[1]=2) // expected-error 
{{expected ')'}} expected-note {{to match this '('}}
   for 

[PATCH] D27206: [libcxx] Test support for the externally threaded libcxxabi variant

2016-12-08 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Abandoning (replaced with 
https://reviews.llvm.org/D27575/https://reviews.llvm.org/D27576).


https://reviews.llvm.org/D27206



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-08 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:721
+
+static bool inTopLevelNamespace(const Decl *D, IdentifierInfo *II) {
+  const auto *ND = dyn_cast(D->getDeclContext());

zaks.anna wrote:
> Would isInStdNamespace() from BugReporterVisitor.cpp be useful here? It would 
> be fine to add this API to the CheckerContext or some other place accessible 
> from here and the BugReporter.
Is there a reason not to use isInStdNamespace() instead of the 
inTopLevelNamespace()? We can add the API to Checker Context.


https://reviews.llvm.org/D25660



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


[PATCH] D27576: [libcxx] libc++ changes necessary for the externally threaded libcxxabi variant

2016-12-08 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists.
rmaprath added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

This patch adds support for https://reviews.llvm.org/D27575. A couple of new 
threading API calls has been introduced (libc++abi requires these).

I've also done a few minor cleanups/renames here.


https://reviews.llvm.org/D27576

Files:
  CMakeLists.txt
  include/__threading_support
  lib/CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in

Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -28,7 +28,7 @@
 config.use_libatomic= "@LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB@"
 
 config.libcxxabi_shared = "@LIBCXXABI_ENABLE_SHARED@"
-config.libcxx_external_thread_api  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
+config.cxx_ext_threads  = "@LIBCXX_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
 config.loaded_site_config = True
Index: test/libcxx/test/config.py
===
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -573,10 +573,6 @@
 self.cxx.link_flags += [abs_path]
 else:
 self.cxx.link_flags += ['-lc++']
-# This needs to come after -lc++ as we want its unresolved thread-api symbols
-# to be picked up from this one.
-if self.get_lit_bool('libcxx_external_thread_api', default=False):
-self.cxx.link_flags += ['-lc++external_threads']
 
 def configure_link_flags_abi_library(self):
 cxx_abi = self.get_lit_conf('cxx_abi', 'libcxxabi')
@@ -605,6 +601,8 @@
 'C++ ABI setting %s unsupported for tests' % cxx_abi)
 
 def configure_extra_library_flags(self):
+if self.get_lit_bool('cxx_ext_threads', default=False):
+self.cxx.link_flags += ['-lcxx_external_threads']
 self.target_info.add_cxx_link_flags(self.cxx.link_flags)
 
 def configure_color_diagnostics(self):
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -56,17 +56,19 @@
   @ONLY)
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-  set(experimental_dep cxx_experimental)
+  set(LIBCXX_TEST_DEPS cxx_experimental)
+else()
+  set(LIBCXX_TEST_DEPS "")
 endif()
 
 if (LIBCXX_HAS_EXTERNAL_THREAD_API)
-  set(external_threads_dep cxx_external_threads)
+  list(APPEND LIBCXX_TEST_DEPS cxx_external_threads)
 endif()
 
 add_lit_testsuite(check-cxx
   "Running libcxx tests"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS cxx ${experimental_dep} ${external_threads_dep})
+  DEPENDS cxx ${LIBCXX_TEST_DEPS})
 
 add_custom_target(check-libcxx DEPENDS check-cxx)
 
Index: lib/CMakeLists.txt
===
--- lib/CMakeLists.txt
+++ lib/CMakeLists.txt
@@ -257,7 +257,7 @@
 PROPERTIES
   LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
   COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
-  OUTPUT_NAME   "c++external_threads"
+  OUTPUT_NAME   "cxx_external_threads"
   )
 endif()
 
Index: include/__threading_support
===
--- include/__threading_support
+++ include/__threading_support
@@ -71,7 +71,20 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
 
+// Execute once
+typedef pthread_once_t __libcpp_exec_once_flag;
+#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
+
+_LIBCPP_THREAD_ABI_VISIBILITY
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void));
+
 // Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+_LIBCPP_THREAD_ABI_VISIBILITY
+mach_port_t __libcpp_thread_get_port();
+#endif
+
 typedef pthread_t __libcpp_thread_id;
 _LIBCPP_THREAD_ABI_VISIBILITY
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2);
@@ -100,7 +113,7 @@
 _LIBCPP_THREAD_ABI_VISIBILITY
 void* __libcpp_tls_get(__libcpp_tls_key __key);
 _LIBCPP_THREAD_ABI_VISIBILITY
-void __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
+int __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
 
 #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_LIBCPP_BUILDING_EXTERNAL_THREADS)
 
@@ -176,6 +189,19 @@
 return pthread_cond_destroy(__cv);
 }
 
+// Execute once
+int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
+  void (*init_routine)(void)) {
+  return pthread_once(flag, init_routine);
+}
+
+// Thread id
+#if defined(__APPLE__) && !defined(__arm__)
+mach_port_t __libcpp_thread_get_port() {
+return pthread_mach_thread_np(pthread_self());
+}
+#endif
+
 // Returns non-zero if the thread ids are equal, otherwise 0
 bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2)
 {
@@ -230,9 +256,9 @@
 return 

[PATCH] D27204: [libcxxabi] Introduce an externally threaded libc++abi variant

2016-12-08 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath abandoned this revision.
rmaprath added a comment.

Abandoning as this has been replaced with https://reviews.llvm.org/D27575.


https://reviews.llvm.org/D27204



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


[PATCH] D27575: [libcxxabi] Introduce an externally threaded libc++abi variant (take-2)

2016-12-08 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath created this revision.
rmaprath added reviewers: EricWF, mclow.lists.
rmaprath added a subscriber: cfe-commits.
Herald added a subscriber: mgorny.

This is a replacement for https://reviews.llvm.org/D27204. Re-worked so that we 
use the threading API of `libcxx` instead of creating a whole new API for 
`libcxxabi`.


https://reviews.llvm.org/D27575

Files:
  CMakeLists.txt
  src/config.h
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/cxa_thread_atexit.cpp
  src/fallback_malloc.cpp
  src/threading_support.h
  test/CMakeLists.txt
  test/libcxxabi/test/config.py
  test/lit.site.cfg.in
  test/test_exception_storage.pass.cpp
  test/test_fallback_malloc.pass.cpp

Index: test/test_fallback_malloc.pass.cpp
===
--- test/test_fallback_malloc.pass.cpp
+++ test/test_fallback_malloc.pass.cpp
@@ -10,7 +10,7 @@
 #include 
 #include 
 
-#include "../src/threading_support.h"
+#include <__threading_support>
 
 typedef std::deque container;
 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -12,7 +12,7 @@
 #include 
 #include 
 #include 
-#include "../src/threading_support.h"
+#include <__threading_support>
 #include 
 
 #include "../src/cxa_exception.hpp"
@@ -39,7 +39,7 @@
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 #define NUMTHREADS  10
 size_t thread_globals [ NUMTHREADS ] = { 0 };
-__libcxxabi_thread_t   threads[ NUMTHREADS ];
+std::__libcpp_thread_t   threads[ NUMTHREADS ];
 #endif
 
 int main ( int argc, char *argv [] ) {
@@ -48,9 +48,9 @@
 #ifndef _LIBCXXABI_HAS_NO_THREADS
 //  Make the threads, let them run, and wait for them to finish
 for ( int i = 0; i < NUMTHREADS; ++i )
-__libcxxabi_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
+std::__libcpp_thread_create ( threads + i, thread_code, (void *) (thread_globals + i));
 for ( int i = 0; i < NUMTHREADS; ++i )
-__libcxxabi_thread_join (  [ i ] );
+std::__libcpp_thread_join (  [ i ] );
 
 for ( int i = 0; i < NUMTHREADS; ++i )
 if ( 0 == thread_globals [ i ] ) {
Index: test/lit.site.cfg.in
===
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -19,6 +19,7 @@
 config.host_triple  = "@LLVM_HOST_TRIPLE@"
 config.target_triple= "@TARGET_TRIPLE@"
 config.use_target   = len("@LIBCXXABI_TARGET_TRIPLE@") > 0
+config.cxx_ext_threads  = "@LIBCXXABI_HAS_EXTERNAL_THREAD_API@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXXABI_SOURCE_DIR@/test/lit.cfg")
Index: test/libcxxabi/test/config.py
===
--- test/libcxxabi/test/config.py
+++ test/libcxxabi/test/config.py
@@ -42,6 +42,9 @@
 self.config.available_features.add('libcxxabi-no-exceptions')
 if not self.has_cpp_feature('noexcept_function_type', 201510):
 self.config.available_features.add('libcxxabi-no-noexcept-function-type')
+# test_exception_storage_nodynmem.pass.cpp fails under this specific configuration
+if self.get_lit_bool('cxx_ext_threads', False) and self.get_lit_bool('libcxxabi_shared', False):
+self.config.available_features.add('libcxxabi-shared-externally-threaded')
 
 def configure_compile_flags(self):
 self.cxx.compile_flags += ['-DLIBCXXABI_NO_TIMER']
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -17,6 +17,7 @@
 pythonize_bool(LIBCXXABI_ENABLE_THREADS)
 pythonize_bool(LIBCXXABI_ENABLE_EXCEPTIONS)
 pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER)
+pythonize_bool(LIBCXXABI_HAS_EXTERNAL_THREAD_API)
 set(LIBCXXABI_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
 set(LIBCXXABI_EXECUTOR "None" CACHE STRING
@@ -34,6 +35,10 @@
   set(LIBCXXABI_TEST_DEPS cxxabi_static)
 endif()
 
+if (LIBCXXABI_HAS_EXTERNAL_THREAD_API)
+  list(APPEND LIBCXXABI_TEST_DEPS cxx_external_threads)
+endif()
+
 if (NOT LIBCXXABI_STANDALONE_BUILD)
   list(APPEND LIBCXXABI_TEST_DEPS cxx)
   if (LIBCXXABI_USE_LLVM_UNWINDER)
Index: src/threading_support.h
===
--- src/threading_support.h
+++ /dev/null
@@ -1,107 +0,0 @@
-//=== threading_support.h -===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef 

r289068 - [CodeCompletion][ObjC] Use a parameterized NSSet return type for

2016-12-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  8 10:49:05 2016
New Revision: 289068

URL: http://llvm.org/viewvc/llvm-project?rev=289068=rev
Log:
[CodeCompletion][ObjC] Use a parameterized NSSet return type for
keyPathsForValuesAffecting* KVO completion results

rdar://23791701

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-kvc.m

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=289068=289067=289068=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Dec  8 10:49:05 2016
@@ -7199,7 +7199,7 @@ static void AddObjCKeyValueCompletions(O
 .second) {
   if (ReturnType.isNull()) {
 Builder.AddChunk(CodeCompletionString::CK_LeftParen);
-Builder.AddTextChunk("NSSet *");
+Builder.AddTextChunk("NSSet *");
 Builder.AddChunk(CodeCompletionString::CK_RightParen);
   }


Modified: cfe/trunk/test/Index/complete-kvc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-kvc.m?rev=289068=289067=289068=diff
==
--- cfe/trunk/test/Index/complete-kvc.m (original)
+++ cfe/trunk/test/Index/complete-kvc.m Thu Dec  8 10:49:05 2016
@@ -97,7 +97,7 @@ typedef signed char BOOL;
 // RUN: c-index-test -code-completion-at=%s:41:3 %s | FileCheck 
-check-prefix=CHECK-CC2 %s
 // CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen 
)}{TypedText automaticallyNotifiesObserversOfArrayProperty} (40)
 // CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen 
)}{TypedText automaticallyNotifiesObserversOfMutableArrayProperty} (40)
-// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text NSSet *}{RightParen 
)}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40)
+// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text NSSet 
*}{RightParen )}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40)
 
 // RUN: c-index-test -code-completion-at=%s:52:8 %s | FileCheck 
-check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText countOfIntProperty} (55)


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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-08 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Looks like compiler has found a couple of bugs:

  In file included from 
llvm.git/tools/clang/tools/extra/clang-tidy/ClangTidy.cpp:38:
  llvm.git/tools/clang/include/clang/Tooling/DiagnosticsYaml.h:38:53: error: 
field 'Message' is uninitialized when used here [-Werror,-Wuninitialized]
  : DiagnosticName(D.DiagnosticName), Message(Message), Fix(D.Fix),
  ^
  llvm.git/tools/clang/include/clang/Tooling/DiagnosticsYaml.h:70:7: error: 
ignoring return value of function declared with warn_unused_result attribute 
[-Werror,-Wunused-result]
Keys->Fix[Fix.getFilePath()].add(Fix);
^~~~ ~~~
  2 errors generated.

Please fix.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D27165: Add format_dynamic_key_arg attribute to improve "-Wformat" warnings for functions that load the formatting string dynamically based on a key value

2016-12-08 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Ping


Repository:
  rL LLVM

https://reviews.llvm.org/D27165



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


[PATCH] D27053: [CodeCompletion] Provide Objective-C class property completion results

2016-12-08 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
arphaman marked an inline comment as done.
Closed by commit rL289058: [CodeCompletion] Provide Objective-C class property 
completion results (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D27053?vs=79086=80759#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27053

Files:
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/test/Index/complete-block-properties.m
  cfe/trunk/test/Index/complete-properties.m

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -9662,6 +9662,9 @@
   bool AtParameterName,
   ParsedType ReturnType,
   ArrayRef SelIdents);
+  void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo ,
+SourceLocation ClassNameLoc,
+bool IsBaseExprStatement);
   void CodeCompletePreprocessorDirective(bool InConditional);
   void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
   void CodeCompletePreprocessorMacroName(bool IsDefinition);
Index: cfe/trunk/test/Index/complete-properties.m
===
--- cfe/trunk/test/Index/complete-properties.m
+++ cfe/trunk/test/Index/complete-properties.m
@@ -94,3 +94,84 @@
 
 // RUN: c-index-test -code-completion-at=%s:57:13 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC8 %s
 // CHECK-CC8: ObjCPropertyDecl:{ResultType int}{TypedText Prop5} (35)
+
+@interface ClassProperties
+
+@property int instanceProperty;
+@property(class) int explicit;
+@property(class, readonly) int explicitReadonly;
+
++ (int)implicit;
++ (int)setImplicit:(int)x;
+
++ (int)implicitReadonly;
+
++ (void)noProperty;
+
+- (int)implicitInstance;
+
++ (int)shadowedImplicit;
+
+@end
+
+@interface ClassProperties (Category)
+
++ (int)implicitInCategory;
+
+@end
+
+@protocol ProtocolClassProperties
+
+@property(class, readonly) int explicitInProtocol;
+
+@end
+
+@interface SubClassProperties: ClassProperties 
+
+@property(class) ClassProperties *shadowedImplicit;
+
+@end
+
+@implementation SubClassProperties
+
+-(void) foo {
+  super.instanceProperty;
+}
+
+@end
+
+void classProperties() {
+  (void)ClassProperties.implicit;
+  (void)SubClassProperties.explicit;
+}
+
+// RUN: c-index-test -code-completion-at=%s:144:25 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: ObjCPropertyDecl:{ResultType int}{TypedText explicit} (35)
+// CHECK-CC9-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText explicitReadonly} (35)
+// CHECK-CC9-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText implicit} (37)
+// CHECK-CC9-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText implicitInCategory} (37)
+// CHECK-CC9-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText implicitReadonly} (37)
+// CHECK-CC9-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText shadowedImplicit} (37)
+// CHECK-CC9-NOT: implicitInstance
+// CHECK-CC9-NOT: noProperty
+// CHECK-CC9-NOT: instanceProperty
+
+// RUN: c-index-test -code-completion-at=%s:145:28 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC10 %s
+// CHECK-CC10: ObjCPropertyDecl:{ResultType int}{TypedText explicit} (35)
+// CHECK-CC10-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText explicitInProtocol} (35)
+// CHECK-CC10-NEXT: ObjCPropertyDecl:{ResultType int}{TypedText explicitReadonly} (35)
+// CHECK-CC10-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText implicit} (37)
+// CHECK-CC10-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText implicitInCategory} (37)
+// CHECK-CC10-NEXT: ObjCClassMethodDecl:{ResultType int}{TypedText implicitReadonly} (37)
+// CHECK-CC10-NEXT: ObjCPropertyDecl:{ResultType ClassProperties *}{TypedText shadowedImplicit} (35)
+// CHECK-CC10-NOT: implicitInstance
+// CHECK-CC10-NOT: noProperty
+// CHECK-CC10-NOT: instanceProperty
+
+// RUN: c-index-test -code-completion-at=%s:138:9 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC11 %s
+// CHECK-CC11-NOT: explicit
+// CHECK-CC11-NOT: explicitReadonly
+// CHECK-CC11-NOT: implicit
+// CHECK-CC11-NOT: implicitReadonly
+// CHECK-CC11-NOT: shadowedImplicit
+// CHECK-CC11-NOT: implicitInCategory
Index: cfe/trunk/test/Index/complete-block-properties.m
===
--- cfe/trunk/test/Index/complete-block-properties.m
+++ cfe/trunk/test/Index/complete-block-properties.m
@@ -70,3 +70,19 @@
 //CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType BarBlock}{TypedText blockProperty2} (35)
 //CHECK-CC2-NEXT: ObjCInstanceMethodDecl:{ResultType void}{TypedText setBlockProperty2:}{Placeholder BarBlock 

r289058 - [CodeCompletion] Provide Objective-C class property completion results

2016-12-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  8 09:09:40 2016
New Revision: 289058

URL: http://llvm.org/viewvc/llvm-project?rev=289058=rev
Log:
[CodeCompletion] Provide Objective-C class property completion results

This commit provides class property code completion results. It supports
explicit and implicit class properties, but the special block completion is done
only for explicit properties right now.

rdar://25636195

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

Modified:
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-block-properties.m
cfe/trunk/test/Index/complete-properties.m

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=289058=289057=289058=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Dec  8 09:09:40 2016
@@ -9662,6 +9662,9 @@ public:
   bool AtParameterName,
   ParsedType ReturnType,
   ArrayRef 
SelIdents);
+  void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo 
,
+SourceLocation ClassNameLoc,
+bool IsBaseExprStatement);
   void CodeCompletePreprocessorDirective(bool InConditional);
   void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
   void CodeCompletePreprocessorMacroName(bool IsDefinition);

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=289058=289057=289058=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Dec  8 09:09:40 2016
@@ -885,7 +885,13 @@ ExprResult Parser::ParseCastExpression(b
  // Allow the base to be 'super' if in an objc-method.
  ( == Ident_super && getCurScope()->isInObjcMethodScope( {
   ConsumeToken();
-  
+
+  if (Tok.is(tok::code_completion) &&  != Ident_super) {
+Actions.CodeCompleteObjCClassPropertyRefExpr(
+getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
+cutOffParsing();
+return ExprError();
+  }
   // Allow either an identifier or the keyword 'class' (in C++).
   if (Tok.isNot(tok::identifier) && 
   !(getLangOpts().CPlusPlus && Tok.is(tok::kw_class))) {

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=289058=289057=289058=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Thu Dec  8 09:09:40 2016
@@ -3654,22 +3654,20 @@ static void AddObjCBlockCall(ASTContext
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
 }
 
-static void AddObjCProperties(const CodeCompletionContext ,
-  ObjCContainerDecl *Container,
-  bool AllowCategories, bool AllowNullaryMethods,
-  DeclContext *CurContext,
-  AddedPropertiesSet ,
-  ResultBuilder ,
-  bool IsBaseExprStatement = false) {
+static void AddObjCProperties(
+const CodeCompletionContext , ObjCContainerDecl *Container,
+bool AllowCategories, bool AllowNullaryMethods, DeclContext *CurContext,
+AddedPropertiesSet , ResultBuilder ,
+bool IsBaseExprStatement = false, bool IsClassProperty = false) {
   typedef CodeCompletionResult Result;
 
   // Retrieve the definition.
   Container = getContainerDef(Container);
   
   // Add properties in this container.
-  for (const auto *P : Container->instance_properties()) {
+  const auto AddProperty = [&](const ObjCPropertyDecl *P) {
 if (!AddedProperties.insert(P->getIdentifier()).second)
-  continue;
+  return;
 
 // FIXME: Provide block invocation completion for non-statement
 // expressions.
@@ -3677,7 +3675,7 @@ static void AddObjCProperties(const Code
 !IsBaseExprStatement) {
   Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
  CurContext);
-  continue;
+  return;
 }
 
 // Block setter and invocation completion is provided only when we are able
@@ -3689,7 +3687,7 @@ static void AddObjCProperties(const Code
 if (!BlockLoc) {
   Results.MaybeAddResult(Result(P, Results.getBasePriority(P), nullptr),
  CurContext);
-  continue;
+  return;
 }
 
 // The default completion result for block 

[PATCH] D26137: [clang-tidy] Add check name to YAML export

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

The patch spans two repos, so I couldn't apply it using arcanist. Just made it 
"manually" (patch -p0 -i ...); now running tests...


Repository:
  rL LLVM

https://reviews.llvm.org/D26137



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


[PATCH] D27123: Add AVR target and toolchain to Clang

2016-12-08 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added a subscriber: rengolin.
jroelofs added a comment.

In https://reviews.llvm.org/D27123#616887, @saaadhu wrote:

> Make defines for CHAR16_TYPE, {U,}INT_{LEAST,FAST}16_TYPE use int instead of 
> short.
>
> {U,}INT16_TYPE still gets defined as short though - 
> lib/Frontend/InitPreprocessor.cpp::DefineExactWidthIntType does not use 
> TargetInfo::getIntTypeByWidth. Instead, InitializePredefinedMacros calls the 
> function with the specific type (SignedShort/UnsignedShort), as 
> getShortWidth() > getCharWidth(), but getIntWidth() == getShortWidth(). Not 
> sure what the best way to fix that is - should I make DefineExactWidthType 
> use TargetInfo::getIntTypeByWidth?


I'm not sure either. I think it's a good question for @rengolin.


https://reviews.llvm.org/D27123



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


[PATCH] D27299: [Sema] C++11 opaque enums should avoid the "case value not in enumerated type" switch warning

2016-12-08 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289055: [Sema] Avoid "case value not in enumerated type" 
warning for C++11 opaque enums (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D27299?vs=79892=80757#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27299

Files:
  cfe/trunk/lib/Sema/SemaStmt.cpp
  cfe/trunk/test/SemaCXX/switch.cpp


Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -1070,7 +1070,8 @@
 const EnumType *ET = CondTypeBeforePromotion->getAs();
 
 // If switch has default case, then ignore it.
-if (!CaseListIsErroneous  && !HasConstantCond && ET) {
+if (!CaseListIsErroneous && !HasConstantCond && ET &&
+ET->getDecl()->isCompleteDefinition()) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 
Index: cfe/trunk/test/SemaCXX/switch.cpp
===
--- cfe/trunk/test/SemaCXX/switch.cpp
+++ cfe/trunk/test/SemaCXX/switch.cpp
@@ -100,3 +100,33 @@
   }
   template void f(S); // expected-note {{instantiation of}}
 }
+
+// rdar://29230764
+namespace OpaqueEnumWarnings {
+
+enum Opaque : int;
+enum class OpaqueClass : int;
+
+enum class Defined : int;
+enum class Defined : int { a };
+
+void test(Opaque o, OpaqueClass oc, Defined d) {
+  // Don't warn that case value is not present in opaque enums.
+  switch (o) {
+  case (Opaque)1:
+break;
+  }
+  switch (oc) {
+  case (OpaqueClass)1:
+break;
+  }
+
+  switch (d) {
+  case Defined::a:
+break;
+  case (Defined)2: // expected-warning {{case value not in enumerated type 
'OpaqueEnumWarnings::Defined'}}
+break;
+  }
+}
+
+}


Index: cfe/trunk/lib/Sema/SemaStmt.cpp
===
--- cfe/trunk/lib/Sema/SemaStmt.cpp
+++ cfe/trunk/lib/Sema/SemaStmt.cpp
@@ -1070,7 +1070,8 @@
 const EnumType *ET = CondTypeBeforePromotion->getAs();
 
 // If switch has default case, then ignore it.
-if (!CaseListIsErroneous  && !HasConstantCond && ET) {
+if (!CaseListIsErroneous && !HasConstantCond && ET &&
+ET->getDecl()->isCompleteDefinition()) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 
Index: cfe/trunk/test/SemaCXX/switch.cpp
===
--- cfe/trunk/test/SemaCXX/switch.cpp
+++ cfe/trunk/test/SemaCXX/switch.cpp
@@ -100,3 +100,33 @@
   }
   template void f(S); // expected-note {{instantiation of}}
 }
+
+// rdar://29230764
+namespace OpaqueEnumWarnings {
+
+enum Opaque : int;
+enum class OpaqueClass : int;
+
+enum class Defined : int;
+enum class Defined : int { a };
+
+void test(Opaque o, OpaqueClass oc, Defined d) {
+  // Don't warn that case value is not present in opaque enums.
+  switch (o) {
+  case (Opaque)1:
+break;
+  }
+  switch (oc) {
+  case (OpaqueClass)1:
+break;
+  }
+
+  switch (d) {
+  case Defined::a:
+break;
+  case (Defined)2: // expected-warning {{case value not in enumerated type 'OpaqueEnumWarnings::Defined'}}
+break;
+  }
+}
+
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r289055 - [Sema] Avoid "case value not in enumerated type" warning for C++11 opaque enums

2016-12-08 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Dec  8 08:46:05 2016
New Revision: 289055

URL: http://llvm.org/viewvc/llvm-project?rev=289055=rev
Log:
[Sema] Avoid "case value not in enumerated type" warning for C++11 opaque enums

This commit ensures that the switch warning "case value not in enumerated type"
isn't shown for opaque enums. We don't know the actual list of values in opaque
enums, so that warning is incorrect.

rdar://29230764

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

Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/SemaCXX/switch.cpp

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=289055=289054=289055=diff
==
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Dec  8 08:46:05 2016
@@ -1070,7 +1070,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocati
 const EnumType *ET = CondTypeBeforePromotion->getAs();
 
 // If switch has default case, then ignore it.
-if (!CaseListIsErroneous  && !HasConstantCond && ET) {
+if (!CaseListIsErroneous && !HasConstantCond && ET &&
+ET->getDecl()->isCompleteDefinition()) {
   const EnumDecl *ED = ET->getDecl();
   EnumValsTy EnumVals;
 

Modified: cfe/trunk/test/SemaCXX/switch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch.cpp?rev=289055=289054=289055=diff
==
--- cfe/trunk/test/SemaCXX/switch.cpp (original)
+++ cfe/trunk/test/SemaCXX/switch.cpp Thu Dec  8 08:46:05 2016
@@ -100,3 +100,33 @@ namespace Conversion {
   }
   template void f(S); // expected-note {{instantiation of}}
 }
+
+// rdar://29230764
+namespace OpaqueEnumWarnings {
+
+enum Opaque : int;
+enum class OpaqueClass : int;
+
+enum class Defined : int;
+enum class Defined : int { a };
+
+void test(Opaque o, OpaqueClass oc, Defined d) {
+  // Don't warn that case value is not present in opaque enums.
+  switch (o) {
+  case (Opaque)1:
+break;
+  }
+  switch (oc) {
+  case (OpaqueClass)1:
+break;
+  }
+
+  switch (d) {
+  case Defined::a:
+break;
+  case (Defined)2: // expected-warning {{case value not in enumerated type 
'OpaqueEnumWarnings::Defined'}}
+break;
+  }
+}
+
+}


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


Re: r285301 - Attempt to make clang-format.py python 3 - compatible.

2016-12-08 Thread Alexander Kornienko via cfe-commits
If this fixes the problem on python 3 (and it leaves the current behavior
on python 2), then it looks good. Can you submit it?

On Wed, Dec 7, 2016 at 6:59 AM, Vedant Kumar  wrote:

> Hi Alexander,
>
> I think this will cause an error if used with python3 (at least, it fails
> on my
> system). Here's the problem:
>
>   line.decode(encoding)
>
> When vim is compiled against python3, the type of 'line' remains 'str' --
> not
> 'bytes'. There isn't a 'decode' method on strings: it only exists for
> bytes. I
> take this to mean that vim has done the decoding already. If not, there's
> a bug
> in vim.
>
> I've attached a small patch that addresses this issue. Wdyt?
>
>
>
>
> thanks,
> vedant
>
>
> > On Oct 27, 2016, at 8:15 AM, Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Author: alexfh
> > Date: Thu Oct 27 10:15:23 2016
> > New Revision: 285301
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=285301=rev
> > Log:
> > Attempt to make clang-format.py python 3 - compatible.
> >
> > Modified:
> >cfe/trunk/tools/clang-format/clang-format.py
> >
> > Modified: cfe/trunk/tools/clang-format/clang-format.py
> > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-
> format/clang-format.py?rev=285301=285300=285301=diff
> > 
> ==
> > --- cfe/trunk/tools/clang-format/clang-format.py (original)
> > +++ cfe/trunk/tools/clang-format/clang-format.py Thu Oct 27 10:15:23
> 2016
> > @@ -51,7 +51,7 @@ if vim.eval('exists("g:clang_format_fall
> > def main():
> >   # Get the current text.
> >   encoding = vim.eval("")
> > -  buf = [ unicode(line, encoding) for line in vim.current.buffer ]
> > +  buf = [ line.decode(encoding) for line in vim.current.buffer ]
> >   text = '\n'.join(buf)
> >
> >   # Determine range to format.
> >
> >
> > ___
> > 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] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 80756.
NoQ added a comment.

Don't construct a `StringRef` to a temporary `std::string`.


https://reviews.llvm.org/D27535

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
  test/Analysis/ObjCPropertiesSyntaxChecks.m

Index: test/Analysis/ObjCPropertiesSyntaxChecks.m
===
--- /dev/null
+++ test/Analysis/ObjCPropertiesSyntaxChecks.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=osx.ObjCProperty %s -verify
+
+#include "Inputs/system-header-simulator-objc.h"
+
+@interface I : NSObject {
+  NSMutableString *_mutableExplicitStr;
+  NSMutableString *_trulyMutableStr;
+  NSMutableString *_trulyMutableExplicitStr;
+}
+@property(copy) NSString *str; // no-warning
+@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has (copy) attribute; an immutable object will be stored instead}}
+@property(copy) NSMutableString *mutableExplicitStr; // expected-warning{{Property of mutable type 'NSMutableString' has (copy) attribute; an immutable object will be stored instead}}
+@property(copy) NSMutableString *trulyMutableStr; // no-warning
+@property(copy) NSMutableString *trulyMutableExplicitStr; // no-warning
+@property(copy) NSMutableString *trulyMutableStrWithSynthesizedStorage; // no-warning
+@end
+
+@implementation I
+@synthesize mutableExplicitStr = _mutableExplicitStr;
+- (NSMutableString *)trulyMutableStr {
+  return _trulyMutableStr;
+}
+- (void)setTrulyMutableStr: (NSMutableString *) S {
+  _trulyMutableStr = [S mutableCopy];
+}
+@dynamic trulyMutableExplicitStr;
+- (NSMutableString *)trulyMutableExplicitStr {
+  return _trulyMutableExplicitStr;
+}
+- (void)setTrulyMutableExplicitStr: (NSMutableString *) S {
+  _trulyMutableExplicitStr = [S mutableCopy];
+}
+@synthesize trulyMutableStrWithSynthesizedStorage;
+- (NSMutableString *)trulyMutableStrWithSynthesizedStorage {
+  return trulyMutableStrWithSynthesizedStorage;
+}
+- (void)setTrulyMutableStrWithSynthesizedStorage: (NSMutableString *) S {
+  trulyMutableStrWithSynthesizedStorage = [S mutableCopy];
+}
+@end
+
+// If we do not see the implementation then we do not want to warn,
+// because we may miss a user-defined setter that works correctly.
+@interface IWithoutImpl : NSObject {}
+@property(copy) NSMutableString *mutableStr; // no-warning
+@end
Index: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
@@ -0,0 +1,76 @@
+//==- ObjCPropertyChecker.cpp - Check ObjC properties *- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker finds issues with Objective-C properties.
+//  Currently finds only one kind of issue:
+//  - Find synthesized properties with copy attribute of mutable NS collection
+//types. Calling -copy on such collections produces an immutable copy,
+//which contradicts the type of the property.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ObjCPropertyChecker
+: public Checker {
+  void checkCopyMutable(const ObjCPropertyDecl *D, BugReporter ) const;
+
+public:
+  void checkASTDecl(const ObjCPropertyDecl *D, AnalysisManager ,
+BugReporter ) const;
+};
+} // end anonymous namespace.
+
+void ObjCPropertyChecker::checkASTDecl(const ObjCPropertyDecl *D,
+   AnalysisManager ,
+   BugReporter ) const {
+  checkCopyMutable(D, BR);
+}
+
+void ObjCPropertyChecker::checkCopyMutable(const ObjCPropertyDecl *D,
+   BugReporter ) const {
+  if (D->getSetterKind() != ObjCPropertyDecl::Copy)
+return;
+
+  QualType T = D->getType();
+  if (!T->isObjCObjectPointerType())
+return;
+
+  const std::string (T->getPointeeType().getCanonicalType()
+ .getUnqualifiedType()
+ .getAsString());
+  if (!StringRef(PropTypeName).startswith("NSMutable"))
+return;
+
+  const ObjCInterfaceDecl *IntD = cast(D->getDeclContext());
+
+  const ObjCImplDecl *IntImplD = IntD->getImplementation();
+  if (!IntImplD || IntImplD->HasUserDeclaredSetterMethod(D))
+return;
+
+  

[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp:68
+return;
+
+  BR.EmitBasicReport(

dcoughlin wrote:
> You'll also want to make sure to not warn on the following idiom, in which 
> programmers use @synthesize to generate the storage but still provide their 
> own accessors:
> 
> ```
> @interface Foo
> @property(copy) NSMutableString *foo;
> @end
> 
> @implementation Foo
> @synthesize foo;
> -(NSMutableString *)foo {
>   return foo;
> }
> - (void)setFoo:(NSMutableString *)newValue {
>   foo = [newValue mutableCopy];
> }
> @end
> ```
> I *think* a call to `ObjCContainerDecl::HasUserDeclaredSetterMethod()` should 
> be sufficient to detect and early exit in this case.
> ObjCContainerDecl::HasUserDeclaredSetterMethod()

Didn't notice this one, that's much easier!


https://reviews.llvm.org/D27535



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


[PATCH] D27535: [analyzer] Add ObjCPropertyChecker - check for autosynthesized copy-properties of mutable types.

2016-12-08 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 80751.
NoQ marked an inline comment as done.
NoQ added a comment.

- Address comments
- Richer warning message (is it in good shape?)
- Add tests for lack of implementation


https://reviews.llvm.org/D27535

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
  test/Analysis/ObjCPropertiesSyntaxChecks.m

Index: test/Analysis/ObjCPropertiesSyntaxChecks.m
===
--- /dev/null
+++ test/Analysis/ObjCPropertiesSyntaxChecks.m
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=osx.ObjCProperty %s -verify
+
+#include "Inputs/system-header-simulator-objc.h"
+
+@interface I : NSObject {
+  NSMutableString *_mutableExplicitStr;
+  NSMutableString *_trulyMutableStr;
+  NSMutableString *_trulyMutableExplicitStr;
+}
+@property(copy) NSString *str; // no-warning
+@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has (copy) attribute; an immutable object will be stored instead}}
+@property(copy) NSMutableString *mutableExplicitStr; // expected-warning{{Property of mutable type 'NSMutableString' has (copy) attribute; an immutable object will be stored instead}}
+@property(copy) NSMutableString *trulyMutableStr; // no-warning
+@property(copy) NSMutableString *trulyMutableExplicitStr; // no-warning
+@property(copy) NSMutableString *trulyMutableStrWithSynthesizedStorage; // no-warning
+@end
+
+@implementation I
+@synthesize mutableExplicitStr = _mutableExplicitStr;
+- (NSMutableString *)trulyMutableStr {
+  return _trulyMutableStr;
+}
+- (void)setTrulyMutableStr: (NSMutableString *) S {
+  _trulyMutableStr = [S mutableCopy];
+}
+@dynamic trulyMutableExplicitStr;
+- (NSMutableString *)trulyMutableExplicitStr {
+  return _trulyMutableExplicitStr;
+}
+- (void)setTrulyMutableExplicitStr: (NSMutableString *) S {
+  _trulyMutableExplicitStr = [S mutableCopy];
+}
+@synthesize trulyMutableStrWithSynthesizedStorage;
+- (NSMutableString *)trulyMutableStrWithSynthesizedStorage {
+  return trulyMutableStrWithSynthesizedStorage;
+}
+- (void)setTrulyMutableStrWithSynthesizedStorage: (NSMutableString *) S {
+  trulyMutableStrWithSynthesizedStorage = [S mutableCopy];
+}
+@end
+
+// If we do not see the implementation then we do not want to warn,
+// because we may miss a user-defined setter that works correctly.
+@interface IWithoutImpl : NSObject {}
+@property(copy) NSMutableString *mutableStr; // no-warning
+@end
Index: lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
@@ -0,0 +1,75 @@
+//==- ObjCPropertyChecker.cpp - Check ObjC properties *- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  This checker finds issues with Objective-C properties.
+//  Currently finds only one kind of issue:
+//  - Find synthesized properties with copy attribute of mutable NS collection
+//types. Calling -copy on such collections produces an immutable copy,
+//which contradicts the type of the property.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+
+using namespace clang;
+using namespace ento;
+
+namespace {
+class ObjCPropertyChecker
+: public Checker {
+  void checkCopyMutable(const ObjCPropertyDecl *D, BugReporter ) const;
+
+public:
+  void checkASTDecl(const ObjCPropertyDecl *D, AnalysisManager ,
+BugReporter ) const;
+};
+} // end anonymous namespace.
+
+void ObjCPropertyChecker::checkASTDecl(const ObjCPropertyDecl *D,
+   AnalysisManager ,
+   BugReporter ) const {
+  checkCopyMutable(D, BR);
+}
+
+void ObjCPropertyChecker::checkCopyMutable(const ObjCPropertyDecl *D,
+   BugReporter ) const {
+  if (D->getSetterKind() != ObjCPropertyDecl::Copy)
+return;
+
+  QualType T = D->getType();
+  if (!T->isObjCObjectPointerType())
+return;
+
+  StringRef PropTypeName(T->getPointeeType().getCanonicalType()
+.getUnqualifiedType().getAsString());
+  if (!PropTypeName.startswith("NSMutable"))
+return;
+
+  const ObjCInterfaceDecl *IntD = cast(D->getDeclContext());
+
+  const ObjCImplDecl *IntImplD = IntD->getImplementation();
+  if (!IntImplD || IntImplD->HasUserDeclaredSetterMethod(D))
+return;
+
+  

[PATCH] D27409: [analyzer] RetainCountChecker: The callback in dispatch_data_create() doesn't free the return symbol.

2016-12-08 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289047: [analyzer] Add dispatch_data_create as a special 
case in RetainCountChecker. (authored by dergachev).

Changed prior to commit:
  https://reviews.llvm.org/D27409?vs=80606=80750#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27409

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
  cfe/trunk/test/Analysis/retain-release-arc.m

Index: cfe/trunk/test/Analysis/retain-release-arc.m
===
--- cfe/trunk/test/Analysis/retain-release-arc.m
+++ cfe/trunk/test/Analysis/retain-release-arc.m
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fobjc-arc -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text
 
+typedef __typeof(sizeof(int)) size_t;
+
 #define HAS_ARC __has_feature(objc_arc)
 
 typedef unsigned long long CFOptionFlags;
@@ -45,6 +47,41 @@
 @interface NSDictionary : NSObject
 @end
 
+#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
+#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
+
+@protocol OS_dispatch_object
+@end
+@protocol OS_dispatch_data 
+@end
+@protocol OS_dispatch_queue 
+@end
+
+typedef NSObject *dispatch_object_t;
+typedef NSObject *dispatch_data_t;
+typedef NSObject *dispatch_queue_t;
+
+typedef void (^dispatch_block_t)(void);
+
+dispatch_queue_t dispatch_get_main_queue(void);
+
+DISPATCH_RETURNS_RETAINED dispatch_data_t
+dispatch_data_create(const void *buffer, size_t size,
+ dispatch_queue_t _Nullable queue,
+ dispatch_block_t _Nullable destructor);
+
+void _dispatch_object_validate(dispatch_object_t object);
+
+#define dispatch_retain(object) \
+  __extension__({ dispatch_object_t _o = (object); \
+  _dispatch_object_validate(_o); \
+  (void)[_o retain]; })
+#define dispatch_release(object) \
+  __extension__({ dispatch_object_t _o = (object); \
+  _dispatch_object_validate(_o); \
+  [_o release]; })
+
+
 @interface SomeClass
 @end
 
@@ -84,3 +121,46 @@
 }
 @end
 
+int buf[1024];
+
+void libdispatch_leaked_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+}
+#if !HAS_ARC
+  // expected-warning@-2{{Potential leak of an object stored into 'data'}}
+  // expected-note@-5{{Call to function 'dispatch_data_create' returns an Objective-C object with a +1 retain count}}
+  // expected-note@-4{{Object leaked: object allocated and stored into 'data' is not referenced later in this execution path and has a retain count of +1}}
+#endif
+
+void libdispatch_dispatch_released_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if !HAS_ARC
+  dispatch_release(data); // no-warning
+#endif
+}
+
+void libdispatch_objc_released_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if !HAS_ARC
+  [data release]; // no-warning
+#endif
+}
+
+void libdispatch_leaked_retained_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if !HAS_ARC
+  dispatch_retain(data);
+  [data release];
+#endif
+}
+#if !HAS_ARC
+// expected-warning@-2{{Potential leak of an object stored into 'data'}}
+// expected-note@-9{{Call to function 'dispatch_data_create' returns an Objective-C object with a +1 retain count}}
+// expected-note@-7{{Reference count incremented. The object now has a +2 retain count}}
+// expected-note@-7{{Reference count decremented. The object now has a +1 retain count}}
+// expected-note@-6{{Object leaked: object allocated and stored into 'data' is not referenced later in this execution path and has a retain count of +1}}
+#endif
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
@@ -953,7 +953,10 @@
   if (IdentifierInfo *Name = FC->getDecl()->getIdentifier()) {
 // When the CGBitmapContext is deallocated, the callback here will free
 // the associated data buffer.
-if (Name->isStr("CGBitmapContextCreateWithData"))
+// The callback in dispatch_data_create frees the buffer, but not
+// the data 

r289047 - [analyzer] Add dispatch_data_create as a special case in RetainCountChecker.

2016-12-08 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Dec  8 08:05:48 2016
New Revision: 289047

URL: http://llvm.org/viewvc/llvm-project?rev=289047=rev
Log:
[analyzer] Add dispatch_data_create as a special case in RetainCountChecker.

This function receives a callback block. The analyzer suspects that this block
may be used to take care of releasing the libdispatch object returned from
the function. In fact, it doesn't - it only releases the raw data buffer.
Inform the analyzer about that. Fixes the resulting false negatives.

rdar://problem/22280098

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release-arc.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=289047=289046=289047=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Thu Dec  8 
08:05:48 2016
@@ -953,7 +953,10 @@ void RetainSummaryManager::updateSummary
   if (IdentifierInfo *Name = FC->getDecl()->getIdentifier()) {
 // When the CGBitmapContext is deallocated, the callback here will free
 // the associated data buffer.
-if (Name->isStr("CGBitmapContextCreateWithData"))
+// The callback in dispatch_data_create frees the buffer, but not
+// the data object.
+if (Name->isStr("CGBitmapContextCreateWithData") ||
+Name->isStr("dispatch_data_create"))
   RE = S->getRetEffect();
   }
 }

Modified: cfe/trunk/test/Analysis/retain-release-arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-arc.m?rev=289047=289046=289047=diff
==
--- cfe/trunk/test/Analysis/retain-release-arc.m (original)
+++ cfe/trunk/test/Analysis/retain-release-arc.m Thu Dec  8 08:05:48 2016
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze 
-analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount
 -fobjc-arc -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze 
-analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount
 -fblocks -verify -Wno-objc-root-class %s -analyzer-output=text
 
+typedef __typeof(sizeof(int)) size_t;
+
 #define HAS_ARC __has_feature(objc_arc)
 
 typedef unsigned long long CFOptionFlags;
@@ -45,6 +47,41 @@ typedef struct _NSZone NSZone;
 @interface NSDictionary : NSObject
 @end
 
+#define OS_OBJECT_RETURNS_RETAINED __attribute__((__ns_returns_retained__))
+#define DISPATCH_RETURNS_RETAINED OS_OBJECT_RETURNS_RETAINED
+
+@protocol OS_dispatch_object
+@end
+@protocol OS_dispatch_data 
+@end
+@protocol OS_dispatch_queue 
+@end
+
+typedef NSObject *dispatch_object_t;
+typedef NSObject *dispatch_data_t;
+typedef NSObject *dispatch_queue_t;
+
+typedef void (^dispatch_block_t)(void);
+
+dispatch_queue_t dispatch_get_main_queue(void);
+
+DISPATCH_RETURNS_RETAINED dispatch_data_t
+dispatch_data_create(const void *buffer, size_t size,
+ dispatch_queue_t _Nullable queue,
+ dispatch_block_t _Nullable destructor);
+
+void _dispatch_object_validate(dispatch_object_t object);
+
+#define dispatch_retain(object) \
+  __extension__({ dispatch_object_t _o = (object); \
+  _dispatch_object_validate(_o); \
+  (void)[_o retain]; })
+#define dispatch_release(object) \
+  __extension__({ dispatch_object_t _o = (object); \
+  _dispatch_object_validate(_o); \
+  [_o release]; })
+
+
 @interface SomeClass
 @end
 
@@ -84,3 +121,46 @@ typedef struct _NSZone NSZone;
 }
 @end
 
+int buf[1024];
+
+void libdispatch_leaked_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+}
+#if !HAS_ARC
+  // expected-warning@-2{{Potential leak of an object stored into 'data'}}
+  // expected-note@-5{{Call to function 'dispatch_data_create' returns an 
Objective-C object with a +1 retain count}}
+  // expected-note@-4{{Object leaked: object allocated and stored into 'data' 
is not referenced later in this execution path and has a retain count of +1}}
+#endif
+
+void libdispatch_dispatch_released_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  dispatch_get_main_queue(), ^{});
+#if !HAS_ARC
+  dispatch_release(data); // no-warning
+#endif
+}
+
+void libdispatch_objc_released_data() {
+  dispatch_data_t data = dispatch_data_create(buf, 1024,
+  

r289042 - [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

2016-12-08 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Dec  8 05:46:22 2016
New Revision: 289042

URL: http://llvm.org/viewvc/llvm-project?rev=289042=rev
Log:
[ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

Summary: Needed for https://reviews.llvm.org/D27166

Reviewers: sbenza, bkramer, klimek

Subscribers: aemerson, cfe-commits

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=289042=289041=289042=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Dec  8 05:46:22 2016
@@ -5421,6 +5421,20 @@ sizeof.
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html;>SubstTemplateTypeParmTypehasReplacementTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>Type
+Matches template 
type parameter substitutions that have a replacement
+type that matches the provided matcher.
+
+Given
+  template typename T
+  double F(T t);
+  int i;
+  double j = F(i);
+
+substTemplateTypeParmType(hasReplacementType(type())) matches int
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html;>SwitchStmtforEachSwitchCaseMatcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html;>SwitchCase
 InnerMatcher
 Matches each case 
or default statement belonging to the given switch
 statement. This matcher may produce multiple matches.

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=289042=289041=289042=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Dec  8 05:46:22 2016
@@ -5019,6 +5019,22 @@ AST_MATCHER_P(ElaboratedType, namesType,
 /// \c substTemplateTypeParmType() matches the type of 't' but not '1'
 AST_TYPE_MATCHER(SubstTemplateTypeParmType, substTemplateTypeParmType);
 
+/// \brief Matches template type parameter substitutions that have a 
replacement
+/// type that matches the provided matcher.
+///
+/// Given
+/// \code
+///   template 
+///   double F(T t);
+///   int i;
+///   double j = F(i);
+/// \endcode
+///
+/// \c substTemplateTypeParmType(hasReplacementType(type())) matches int
+AST_TYPE_TRAVERSE_MATCHER(
+hasReplacementType, getReplacementType,
+AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType));
+
 /// \brief Matches template type parameter types.
 ///
 /// Example matches T, but not int.

Modified: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp?rev=289042=289041=289042=diff
==
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp Thu Dec  8 05:46:22 2016
@@ -252,6 +252,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReplacementType);
   REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=289042=289041=289042=diff
==
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Thu Dec  8 
05:46:22 2016
@@ -2204,5 +2204,22 @@ TEST(Matcher, HasAnyDeclaration) {
functionDecl(hasName("bar"));
 }
 
+TEST(SubstTemplateTypeParmType, HasReplacementType)
+{
+  std::string Fragment = "template"
+ "double F(T t);"
+ "int i;"
+ "double j = F(i);";
+  EXPECT_TRUE(matches(Fragment, substTemplateTypeParmType(hasReplacementType(
+qualType(asString("int"));
+  EXPECT_TRUE(notMatches(Fragment, 
substTemplateTypeParmType(hasReplacementType(
+   qualType(asString("double"));
+  EXPECT_TRUE(
+  notMatches("template"
+ "double F();"
+ "double j = F<5>();",
+ substTemplateTypeParmType(hasReplacementType(qualType();
+}
+
 

[PATCH] D27447: [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

2016-12-08 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289042: [ASTMatcher] Add hasReplacementType matcher for 
SubstTemplateTypeParmType (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D27447?vs=80465=80741#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27447

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2204,5 +2204,22 @@
functionDecl(hasName("bar"));
 }
 
+TEST(SubstTemplateTypeParmType, HasReplacementType)
+{
+  std::string Fragment = "template"
+ "double F(T t);"
+ "int i;"
+ "double j = F(i);";
+  EXPECT_TRUE(matches(Fragment, substTemplateTypeParmType(hasReplacementType(
+qualType(asString("int"));
+  EXPECT_TRUE(notMatches(Fragment, 
substTemplateTypeParmType(hasReplacementType(
+   qualType(asString("double"));
+  EXPECT_TRUE(
+  notMatches("template"
+ "double F();"
+ "double j = F<5>();",
+ substTemplateTypeParmType(hasReplacementType(qualType();
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -5421,6 +5421,20 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html;>SubstTemplateTypeParmTypehasReplacementTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1Type.html;>Type
+Matches template 
type parameter substitutions that have a replacement
+type that matches the provided matcher.
+
+Given
+  template typename T
+  double F(T t);
+  int i;
+  double j = F(i);
+
+substTemplateTypeParmType(hasReplacementType(type())) matches int
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html;>SwitchStmtforEachSwitchCaseMatcherhttp://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html;>SwitchCase
 InnerMatcher
 Matches each case 
or default statement belonging to the given switch
 statement. This matcher may produce multiple matches.
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -5019,6 +5019,22 @@
 /// \c substTemplateTypeParmType() matches the type of 't' but not '1'
 AST_TYPE_MATCHER(SubstTemplateTypeParmType, substTemplateTypeParmType);
 
+/// \brief Matches template type parameter substitutions that have a 
replacement
+/// type that matches the provided matcher.
+///
+/// Given
+/// \code
+///   template 
+///   double F(T t);
+///   int i;
+///   double j = F(i);
+/// \endcode
+///
+/// \c substTemplateTypeParmType(hasReplacementType(type())) matches int
+AST_TYPE_TRAVERSE_MATCHER(
+hasReplacementType, getReplacementType,
+AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType));
+
 /// \brief Matches template type parameter types.
 ///
 /// Example matches T, but not int.
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -252,6 +252,7 @@
   REGISTER_MATCHER(hasQualifier);
   REGISTER_MATCHER(hasRangeInit);
   REGISTER_MATCHER(hasReceiverType);
+  REGISTER_MATCHER(hasReplacementType);
   REGISTER_MATCHER(hasReturnValue);
   REGISTER_MATCHER(hasRHS);
   REGISTER_MATCHER(hasSelector);


Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -2204,5 +2204,22 @@
functionDecl(hasName("bar"));
 }
 
+TEST(SubstTemplateTypeParmType, HasReplacementType)
+{
+  std::string Fragment = "template"
+ "double F(T t);"
+ "int i;"
+ "double j = F(i);";
+  EXPECT_TRUE(matches(Fragment, substTemplateTypeParmType(hasReplacementType(
+qualType(asString("int"));
+  EXPECT_TRUE(notMatches(Fragment, substTemplateTypeParmType(hasReplacementType(
+   

[PATCH] D27447: [ASTMatcher] Add hasReplacementType matcher for SubstTemplateTypeParmType

2016-12-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks!


https://reviews.llvm.org/D27447



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


[PATCH] D21075: Correct invalid end location in diagnostics for some identifiers.

2016-12-08 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv updated this revision to Diff 80735.

https://reviews.llvm.org/D21075

Files:
  lib/Parse/ParseDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/Index/diagnostic-ranges.cpp


Index: test/Index/diagnostic-ranges.cpp
===
--- /dev/null
+++ test/Index/diagnostic-ranges.cpp
@@ -0,0 +1,23 @@
+// RUN: c-index-test -test-load-source all %s > /dev/null 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-RANGE %s
+
+struct Foo {
+  someIdentifierLeadingToAnInvalidRange;
+};
+
+template 
+struct Bar {
+  Bar(const T&) {}
+};
+  
+void f()
+{
+  for (Bar<__typeof__(v.x)> container(v.x); true; )
+return;
+}
+
+// CHECK-RANGE: diagnostic-ranges.cpp:5:3: error: C++ requires a type 
specifier for all declarations
+// CHECK-RANGE: diagnostic-ranges.cpp:15:39: error: use of undeclared 
identifier 'v'
+// CHECK-RANGE: diagnostic-ranges.cpp:5:3:{5:3-5:40}: error: C++ requires a 
type specifier for all declarations
+// CHECK-RANGE: diagnostic-ranges.cpp:15:23:{15:23-15:24}: error: use of 
undeclared identifier 'v'
+
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2042,7 +2042,9 @@
   }
 
   // Give up, we can't recover.
-  Diag(R.getNameLoc(), diagnostic) << Name;
+  auto Builder = Diag(R.getNameLoc(), diagnostic) << Name;
+  if (Name.isIdentifier())
+Builder << SourceRange(R.getNameLoc());
   return true;
 }
 
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -2697,12 +2697,9 @@
 AccessSpecifier AS,
 DeclSpecContext DSContext,
 LateParsedAttrList *LateAttrs) {
-  if (DS.getSourceRange().isInvalid()) {
-// Start the range at the current token but make the end of the range
-// invalid.  This will make the entire range invalid unless we successfully
-// consume a token.
+  if (DS.getSourceRange().isInvalid() && !Tok.is(tok::eof)) {
 DS.SetRangeStart(Tok.getLocation());
-DS.SetRangeEnd(SourceLocation());
+DS.SetRangeEnd(Tok.getLocation());
   }
 
   bool EnteringContext = (DSContext == DSC_class || DSContext == 
DSC_top_level);


Index: test/Index/diagnostic-ranges.cpp
===
--- /dev/null
+++ test/Index/diagnostic-ranges.cpp
@@ -0,0 +1,23 @@
+// RUN: c-index-test -test-load-source all %s > /dev/null 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-RANGE %s
+
+struct Foo {
+  someIdentifierLeadingToAnInvalidRange;
+};
+
+template 
+struct Bar {
+  Bar(const T&) {}
+};
+  
+void f()
+{
+  for (Bar<__typeof__(v.x)> container(v.x); true; )
+return;
+}
+
+// CHECK-RANGE: diagnostic-ranges.cpp:5:3: error: C++ requires a type specifier for all declarations
+// CHECK-RANGE: diagnostic-ranges.cpp:15:39: error: use of undeclared identifier 'v'
+// CHECK-RANGE: diagnostic-ranges.cpp:5:3:{5:3-5:40}: error: C++ requires a type specifier for all declarations
+// CHECK-RANGE: diagnostic-ranges.cpp:15:23:{15:23-15:24}: error: use of undeclared identifier 'v'
+
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -2042,7 +2042,9 @@
   }
 
   // Give up, we can't recover.
-  Diag(R.getNameLoc(), diagnostic) << Name;
+  auto Builder = Diag(R.getNameLoc(), diagnostic) << Name;
+  if (Name.isIdentifier())
+Builder << SourceRange(R.getNameLoc());
   return true;
 }
 
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -2697,12 +2697,9 @@
 AccessSpecifier AS,
 DeclSpecContext DSContext,
 LateParsedAttrList *LateAttrs) {
-  if (DS.getSourceRange().isInvalid()) {
-// Start the range at the current token but make the end of the range
-// invalid.  This will make the entire range invalid unless we successfully
-// consume a token.
+  if (DS.getSourceRange().isInvalid() && !Tok.is(tok::eof)) {
 DS.SetRangeStart(Tok.getLocation());
-DS.SetRangeEnd(SourceLocation());
+DS.SetRangeEnd(Tok.getLocation());
   }
 
   bool EnteringContext = (DSContext == DSC_class || DSContext == DSC_top_level);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26750: [clang-tidy] Add modernize-use-default-member-init check

2016-12-08 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons updated this revision to Diff 80734.
malcolm.parsons added a comment.
Herald added a subscriber: JDevlieghere.

Handle unary operators.


https://reviews.llvm.org/D26750

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tidy/modernize/UseDefaultMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-default-member-init.rst
  test/clang-tidy/modernize-use-default-member-init-assignment.cpp
  test/clang-tidy/modernize-use-default-member-init.cpp

Index: test/clang-tidy/modernize-use-default-member-init.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-default-member-init.cpp
@@ -0,0 +1,264 @@
+// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- -- -std=c++11
+
+struct S {
+};
+
+struct PositiveValueInt {
+  PositiveValueInt() : i() {}
+  // CHECK-FIXES: PositiveValueInt()  {}
+  const int i;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i' [modernize-use-default-member-init]
+  // CHECK-FIXES: const int i{};
+};
+
+struct PositiveInt {
+  PositiveInt() : j(1) {}
+  // CHECK-FIXES: PositiveInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{1};
+};
+
+struct PositiveUnaryMinusInt {
+  PositiveUnaryMinusInt() : j(-1) {}
+  // CHECK-FIXES: PositiveUnaryMinusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{-1};
+};
+
+struct PositiveUnaryPlusInt {
+  PositiveUnaryPlusInt() : j(+1) {}
+  // CHECK-FIXES: PositiveUnaryPlusInt()  {}
+  int j;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
+  // CHECK-FIXES: int j{+1};
+};
+
+struct PositiveValueDouble {
+  PositiveValueDouble() : d() {}
+  // CHECK-FIXES: PositiveValueDouble()  {}
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd'
+  // CHECK-FIXES: double d{};
+};
+
+struct PositiveDouble {
+  PositiveDouble() : f(2.5463e43) {}
+  // CHECK-FIXES: PositiveDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{2.5463e43};
+};
+
+struct PositiveUnaryMinusDouble {
+  PositiveUnaryMinusDouble() : f(-2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryMinusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{-2.5463e43};
+};
+
+struct PositiveUnaryPlusDouble {
+  PositiveUnaryPlusDouble() : f(+2.5463e43) {}
+  // CHECK-FIXES: PositiveUnaryPlusDouble()  {}
+  double f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
+  // CHECK-FIXES: double f{+2.5463e43};
+};
+
+struct PositiveValueBool {
+  PositiveValueBool() : b() {}
+  // CHECK-FIXES: PositiveValueBool()  {}
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b'
+  // CHECK-FIXES: bool b{};
+};
+
+struct PositiveBool {
+  PositiveBool() : a(true) {}
+  // CHECK-FIXES: PositiveBool()  {}
+  bool a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a'
+  // CHECK-FIXES: bool a{true};
+};
+
+struct PositiveValuePointer {
+  PositiveValuePointer() : p() {}
+  // CHECK-FIXES: PositiveValuePointer()  {}
+  int *p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p'
+  // CHECK-FIXES: int *p{};
+};
+
+struct PositiveNullPointer {
+  PositiveNullPointer() : q(nullptr) {}
+  // CHECK-FIXES: PositiveNullPointer()  {}
+  int *q;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q'
+  // CHECK-FIXES: int *q{nullptr};
+};
+
+enum Enum { Foo, Bar };
+struct PositiveEnum {
+  PositiveEnum() : e(Foo) {}
+  // CHECK-FIXES: PositiveEnum()  {}
+  Enum e;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
+  // CHECK-FIXES: Enum e{Foo};
+};
+
+template 
+struct NegativeTemplate {
+NegativeTemplate() : t() {}
+T t;
+};
+
+NegativeTemplate nti;
+NegativeTemplate ntd;
+
+struct NegativeDefaultMember {
+  NegativeDefaultMember() {}
+  int i = 2;
+};
+
+struct NegativeClass : S {
+  NegativeClass() : s() {}
+  S s;
+};
+
+struct NegativeBase : S {
+  NegativeBase() : S() {}
+};
+
+struct NegativeDefaultOtherMember{
+  NegativeDefaultOtherMember() : i(3) {}
+  int i = 4;
+};
+
+struct NegativeUnion {
+  NegativeUnion() : d(5.0) {}
+  union {
+int i;
+double d;
+  };
+};
+
+struct NegativeBitField
+{
+  NegativeBitField() : i(6) {}
+  int i : 5;
+};
+
+struct NegativeNotDefaultInt
+{
+  NegativeNotDefaultInt(int) : i(7) {}
+  int i;
+};
+
+struct ExistingInt {
+  ExistingInt(short) : e1(), e2(), e3(), e4(), 

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

2016-12-08 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: tools/clang-format-vs/ClangFormat/ClangFormat.vsct:76
+
+  Clang Format Document
+

hans wrote:
> amaiorano wrote:
> > hans wrote:
> > > I think File would be better than Document when referring to source code.
> > > 
> > > But it seems a little annoying to need two menu alternatives. Could we 
> > > make the regular "Clang Format" option just format the whole file if 
> > > there is currently no selection, or would that be confusing?
> > The reason I chose "Document" is that it mimics the existing functionality 
> > in Visual Studio:
> > {F2661117}
> > 
> > As you can see, "Ctrl+K, Ctrl+F" is bound to format selection by default; 
> > which I assumed is the reason "Ctrl+R, Ctrl+F" was used for Clang Format 
> > (Selection). So along the same lines, I bound "Ctrl + R, Ctrl + D" to Clang 
> > Format Document.
> > 
> > I don't really have a problem with having multiple menu options, although 
> > we could have both of them underneath a "Clang Format" top menu, with 
> > "Format Selection" and "Format Document" as sub menu items.
> > 
> > As for annoyance in menus, I think most developers would reach for keyboard 
> > shortcuts in this case anyway. Furthermore, the next feature I want to add, 
> > building on top of this one, is allowing the user to enable "Format on 
> > Save", which would make this even easier to use.
> I see, I didn't realize they call it documents. And if they also have 
> separate commands for formating selection and formating the whole file, maybe 
> that makes sense for us too.
> 
> Right, I also imagine folks would use this from the keyboard, but there too 
> it's annoying to have two shortcuts for the same thing. But again, if that's 
> how it's generally done in VS...
> 
> I'd like to hear from Manuel on this patch too, though.
Clang-format currently formats the current line / statement if there is no 
selection, and that's how most people I know use it.
Formatting the whole file by default is not what clang-format is optimized for, 
and highly disruptive (eclipse does that, and it's annoying).
I'm more wondering why we need a setting for this at all - isn't 
ctrl-a,ctrl-k,ctrl-f equivalent to formatting the whole file?


https://reviews.llvm.org/D27501



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


[PATCH] D27569: [OpenCL] Enabling the usage of CLK_NULL_QUEUE as compare operand.

2016-12-08 Thread Egor Churaev via Phabricator via cfe-commits
echuraev created this revision.
echuraev added a reviewer: Anastasia.
echuraev added subscribers: bader, yaxunl, cfe-commits.

Enabling the compression of CLK_NULL_QUEUE to variable of type queue_t.


https://reviews.llvm.org/D27569

Files:
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/null_queue.cl


Index: test/CodeGenOpenCL/null_queue.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/null_queue.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0  -emit-llvm %s -o - | FileCheck %s
+extern queue_t get_default_queue();
+
+#define CLK_NULL_QUEUE 0
+
+bool f() {
+  return CLK_NULL_QUEUE == get_default_queue() &&
+ get_default_queue() == CLK_NULL_QUEUE;
+  // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}
+}
+
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9621,6 +9621,18 @@
 return ResultTy;
   }
 
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {
+if (LHSIsNull && RHSType->isQueueT()) {
+  LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
+  return ResultTy;
+}
+
+if (LHSType->isQueueT() && RHSIsNull) {
+  RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
+  return ResultTy;
+}
+  }
+
   return InvalidOperands(Loc, LHS, RHS);
 }
 


Index: test/CodeGenOpenCL/null_queue.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/null_queue.cl
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -O0 -cl-std=CL2.0  -emit-llvm %s -o - | FileCheck %s
+extern queue_t get_default_queue();
+
+#define CLK_NULL_QUEUE 0
+
+bool f() {
+  return CLK_NULL_QUEUE == get_default_queue() &&
+ get_default_queue() == CLK_NULL_QUEUE;
+  // CHECK: icmp eq %opencl.queue_t* null, %{{.*}}
+}
+
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9621,6 +9621,18 @@
 return ResultTy;
   }
 
+  if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion >= 200) {
+if (LHSIsNull && RHSType->isQueueT()) {
+  LHS = ImpCastExprToType(LHS.get(), RHSType, CK_NullToPointer);
+  return ResultTy;
+}
+
+if (LHSType->isQueueT() && RHSIsNull) {
+  RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);
+  return ResultTy;
+}
+  }
+
   return InvalidOperands(Loc, LHS, RHS);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r289034 - Add more test cases to packaged_task copyability test

2016-12-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec  8 04:02:04 2016
New Revision: 289034

URL: http://llvm.org/viewvc/llvm-project?rev=289034=rev
Log:
Add more test cases to packaged_task copyability test

Modified:

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp

Modified: 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp?rev=289034=289033=289034=diff
==
--- 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp
 Thu Dec  8 04:02:04 2016
@@ -29,6 +29,8 @@ typedef volatile std::packaged_task

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-12-08 Thread Alpha Abdoulaye via Phabricator via cfe-commits
Alpha updated this revision to Diff 80732.
Alpha added a comment.

Rebase on top of HEAD.
Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/Core/Replacement.h
  include/clang/Tooling/DiagnosticsYaml.h
  include/clang/Tooling/ReplacementsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidy.h
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  tools/extra/clang-tidy/tool/ClangTidyMain.cpp
  unittests/Tooling/ReplacementsYamlTest.cpp

Index: unittests/Tooling/ReplacementsYamlTest.cpp
===
--- unittests/Tooling/ReplacementsYamlTest.cpp
+++ unittests/Tooling/ReplacementsYamlTest.cpp
@@ -22,11 +22,10 @@
   TranslationUnitReplacements Doc;
 
   Doc.MainSourceFile = "/path/to/source.cpp";
-  Doc.Context = "some context";
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
-  Doc.Replacements
-  .push_back(Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file1.h", 232, 56, "replacement #1"));
+  Doc.Replacements.push_back(
+  Replacement("/path/to/file2.h", 301, 2, "replacement #2"));
 
   std::string YamlContent;
   llvm::raw_string_ostream YamlContentStream(YamlContent);
@@ -37,7 +36,6 @@
   // NOTE: If this test starts to fail for no obvious reason, check whitespace.
   ASSERT_STREQ("---\n"
"MainSourceFile:  /path/to/source.cpp\n"
-   "Context: some context\n"
"Replacements:\n" // Extra whitespace here!
"  - FilePath:/path/to/file1.h\n"
"Offset:  232\n"
@@ -54,7 +52,6 @@
 TEST(ReplacementsYamlTest, deserializesReplacements) {
   std::string YamlContent = "---\n"
 "MainSourceFile:  /path/to/source.cpp\n"
-"Context: some context\n"
 "Replacements:\n"
 "  - FilePath:/path/to/file1.h\n"
 "Offset:  232\n"
@@ -71,7 +68,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ(2u, DocActual.Replacements.size());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
-  ASSERT_EQ("some context", DocActual.Context);
   ASSERT_EQ("/path/to/file1.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(232u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(56u, DocActual.Replacements[0].getLength());
@@ -98,7 +94,6 @@
   ASSERT_FALSE(YAML.error());
   ASSERT_EQ("/path/to/source.cpp", DocActual.MainSourceFile);
   ASSERT_EQ(1u, DocActual.Replacements.size());
-  ASSERT_EQ(std::string(), DocActual.Context);
   ASSERT_EQ("target_file.h", DocActual.Replacements[0].getFilePath());
   ASSERT_EQ(1u, DocActual.Replacements[0].getOffset());
   ASSERT_EQ(10u, DocActual.Replacements[0].getLength());
Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,45 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager ,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   Diagnostic::Level DiagLevel, StringRef BuildDirectory)
+: DiagnosticName(DiagnosticName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef DiagnosticName,
+   DiagnosticMessage ,
+   

[PATCH] D27202: [analyzer] Do not conjure a symbol for return value of a conservatively evaluated function

2016-12-08 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Could you please remove the IteratorPastEndChecker file differences from this 
patch and make https://reviews.llvm.org/D25660 dependent on this one?


https://reviews.llvm.org/D27202



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


[libcxx] r289033 - Avoid C++17 guaranteed copy elision when testing for non-copyability

2016-12-08 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Dec  8 03:57:00 2016
New Revision: 289033

URL: http://llvm.org/viewvc/llvm-project?rev=289033=rev
Log:
Avoid C++17 guaranteed copy elision when testing for non-copyability

Modified:

libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp

libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp

Modified: 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp?rev=289033=289032=289033=diff
==
--- 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.fail.cpp
 Thu Dec  8 03:57:00 2016
@@ -17,9 +17,9 @@
 #include 
 #include 
 
-std::streambuf get();
+std::streambuf ();
 
 int main()
 {
-std::streambuf sb = get();
+std::streambuf sb = get(); // expected-error {{calling a protected 
constructor}}
 }

Modified: 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp?rev=289033=289032=289033=diff
==
--- 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/thread/futures/futures.task/futures.task.members/ctor1.fail.cpp
 Thu Dec  8 03:57:00 2016
@@ -28,6 +28,7 @@ typedef volatile std::packaged_task

[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-08 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

https://reviews.llvm.org/D27202 is now a dependency, but cannot add it.




Comment at: lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp:166
+IteratorPastEndChecker::IteratorPastEndChecker() {
+  PastEndBugType.reset(new BugType(this, "Iterator Past End", "C++ STL 
Error"));
+  PastEndBugType->setSuppressOnSink(true);

zaks.anna wrote:
> How about: "C++ STL Error" -> "Misuse of STL APIs"
OK, I copied it from another checker :-)


https://reviews.llvm.org/D25660



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


[PATCH] D25660: [Analyzer] Checker for iterators dereferenced beyond their range.

2016-12-08 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 80728.
baloghadamsoftware marked 4 inline comments as done.
baloghadamsoftware added a comment.

Minor corrections, comments, some new tests, test input headers merged.


https://reviews.llvm.org/D25660

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/IteratorPastEndChecker.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/Inputs/system-header-simulator-cxx.h
  test/Analysis/diagnostics/explicit-suppression.cpp
  test/Analysis/inlining/stl.cpp
  test/Analysis/iterator-past-end.cpp

Index: test/Analysis/iterator-past-end.cpp
===
--- /dev/null
+++ test/Analysis/iterator-past-end.cpp
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify
+// RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorPastEnd -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void simple_good(const std::vector ) {
+  auto i = v.end();
+  if (i != v.end())
+*i; // no-warning
+}
+
+void simple_good_negated(const std::vector ) {
+  auto i = v.end();
+  if (!(i == v.end()))
+*i; // no-warning
+}
+
+void simple_bad(const std::vector ) {
+  auto i = v.end();
+  *i; // expected-warning{{Iterator accessed past its end}}
+}
+
+void copy(const std::vector ) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  *i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void decrease(const std::vector ) {
+  auto i = v.end();
+  --i;
+  *i; // no-warning
+}
+
+void copy_and_decrease1(const std::vector ) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  --i1;
+  *i1; // no-warning
+}
+
+void copy_and_decrease2(const std::vector ) {
+  auto i1 = v.end();
+  auto i2 = i1;
+  --i1;
+  *i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void copy_and_increase1(const std::vector ) {
+  auto i1 = v.begin();
+  auto i2 = i1;
+  ++i1;
+  if (i1 == v.end())
+*i2; // no-warning
+}
+
+void copy_and_increase2(const std::vector ) {
+  auto i1 = v.begin();
+  auto i2 = i1;
+  ++i1;
+  if (i2 == v.end())
+*i2; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find(std::vector , int e) {
+  auto first = std::find(vec.begin(), vec.end(), e);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find(std::vector , int e) {
+  auto first = std::find(vec.begin(), vec.end(), e);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_end(std::vector , std::vector ) {
+  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != last)
+*last; // no-warning
+}
+
+void bad_find_end(std::vector , std::vector ) {
+  auto last = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *last; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_first_of(std::vector , std::vector ) {
+  auto first =
+  std::find_first_of(vec.begin(), vec.end(), seq.begin(), seq.end());
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_first_of(std::vector , std::vector ) {
+  auto first = std::find_end(vec.begin(), vec.end(), seq.begin(), seq.end());
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+bool odd(int i) { return i % 2; }
+
+void good_find_if(std::vector ) {
+  auto first = std::find_if(vec.begin(), vec.end(), odd);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if(std::vector , int e) {
+  auto first = std::find_if(vec.begin(), vec.end(), odd);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_find_if_not(std::vector ) {
+  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_find_if_not(std::vector , int e) {
+  auto first = std::find_if_not(vec.begin(), vec.end(), odd);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_lower_bound(std::vector , int e) {
+  auto first = std::lower_bound(vec.begin(), vec.end(), e);
+  if (vec.end() != first)
+*first; // no-warning
+}
+
+void bad_lower_bound(std::vector , int e) {
+  auto first = std::lower_bound(vec.begin(), vec.end(), e);
+  *first; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_upper_bound(std::vector , int e) {
+  auto last = std::lower_bound(vec.begin(), vec.end(), e);
+  if (vec.end() != last)
+*last; // no-warning
+}
+
+void bad_upper_bound(std::vector , int e) {
+  auto last = std::lower_bound(vec.begin(), vec.end(), e);
+  *last; // expected-warning{{Iterator accessed past its end}}
+}
+
+void good_search(std::vector , std::vector ) {
+  auto 

[PATCH] D27345: [OpenMP] Sema and parsing for 'teams distribute parallel for' pragma

2016-12-08 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/D27345



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


[PATCH] D27488: Fixing test to work when the compiler defaults to a different c++ standard version.

2016-12-08 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/D27488



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